diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java index 05fa38857..7ab0941fa 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java @@ -95,6 +95,9 @@ public class WxMsg implements Serializable { @io.swagger.annotations.ApiModelProperty(value="1标签短信2精准投放",name="way") private Integer way; + @io.swagger.annotations.ApiModelProperty(value="couponInjectId",name="couponInjectId") + private Long couponInjectId; + public String getTenantId() { return tenantId; } @@ -222,7 +225,13 @@ public class WxMsg implements Serializable { this.tagsList = tagsList; } + public Long getCouponInjectId() { + return couponInjectId; + } + public void setCouponInjectId(Long couponInjectId) { + this.couponInjectId = couponInjectId; + } public static enum Field { diff --git a/mallinkService/src/main/java/com/iformall/service/WxMsgService.java b/mallinkService/src/main/java/com/iformall/service/WxMsgService.java index 3dc47188e..f7d1e3a8f 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxMsgService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxMsgService.java @@ -2,6 +2,7 @@ package com.iformall.service; import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCouponInject; import com.iformall.domain.po.WxMsg; import com.iformall.domain.po.WxMsgConfig; @@ -40,4 +41,6 @@ public interface WxMsgService { */ void deleteById(Long id); + void sendMsgFromCouponInject(WxMsg wxmsg, WxMsgConfig wxMsgConfig, WxCouponInject record); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java index a3e5bc052..29f44a8b5 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java @@ -7,6 +7,7 @@ import com.iformall.common.ErrorCode; import com.iformall.common.IdWorker; import com.iformall.common.Result; import com.iformall.common.ResultData; +import com.iformall.domain.po.WxCouponInject; import com.iformall.domain.po.WxMsg; import com.iformall.domain.po.WxMsgCallback; import com.iformall.domain.po.WxMsgConfig; @@ -15,10 +16,7 @@ import com.iformall.enums.EnumMsgSendStatus; import com.iformall.enums.EnumMsgStatus; import com.iformall.enums.EnumVerifyCode; import com.iformall.exception.MallinkException; -import com.iformall.mapper.WxCUserBasicInfoMapper; -import com.iformall.mapper.WxMsgCallbackMapper; -import com.iformall.mapper.WxMsgConfigMapper; -import com.iformall.mapper.WxMsgMapper; +import com.iformall.mapper.*; import com.iformall.service.PushLimitService; import com.iformall.service.WxCUserTagsService; import com.iformall.service.WxMsgService; @@ -34,6 +32,9 @@ import org.springframework.stereotype.Service; import java.util.*; +/** + * @author gongbiao + */ @Service public class WxMsgServiceImpl implements WxMsgService { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -118,9 +119,9 @@ public class WxMsgServiceImpl implements WxMsgService { return new ResultData(e.getErrorCode(),e.getMessage()); } if(wxMsg.getExpectSendNumber().intValue()>1000){ - batchSendMsg(wxMsg,wxMsgConfig); + batchSendMsg(wxMsg,wxMsgConfig,null); }else{ - sendmsg(wxMsg,wxMsgConfig); + sendmsg(wxMsg,wxMsgConfig,null); } return new ResultData(Result.SUCCESS, "短信已发送"); } else { @@ -150,9 +151,9 @@ public class WxMsgServiceImpl implements WxMsgService { return new ResultData(e.getErrorCode(),e.getMessage()); } if(wxMsg.getExpectSendNumber().intValue()>1000){ - batchSendMsg(wxMsg,wxMsgConfig); + batchSendMsg(wxMsg,wxMsgConfig,null); }else{ - sendmsg(wxMsg,wxMsgConfig); + sendmsg(wxMsg,wxMsgConfig,null); } return new ResultData(Result.SUCCESS, "短信已发送"); } else { @@ -172,8 +173,14 @@ public class WxMsgServiceImpl implements WxMsgService { wxMsgMapper.deleteByPrimaryKey(id); } + @Async + @Override + public void sendMsgFromCouponInject(WxMsg wxmsg, WxMsgConfig wxMsgConfig, WxCouponInject couponInject) { + batchSendMsg(wxmsg,wxMsgConfig,couponInject); + } + - public void batchSendMsg(WxMsg wxMsg,WxMsgConfig wxMsgConfig){ + public void batchSendMsg(WxMsg wxMsg,WxMsgConfig wxMsgConfig,WxCouponInject couponInject){ String[] split = wxMsg.getPhones().split(","); int length=split.length; @@ -186,20 +193,20 @@ public class WxMsgServiceImpl implements WxMsgService { String phones = StringUtils.join(phoneList, ","); wxMsg.setPhones(phones); wxMsg.setExpectSendNumber(extra); - sendmsg(wxMsg,wxMsgConfig); + sendmsg(wxMsg,wxMsgConfig,couponInject); }else{ List phoneList = Arrays.asList(split).subList(i * 1000, (i+1) * 1000); String phones = StringUtils.join(phoneList, ","); wxMsg.setExpectSendNumber(1000); wxMsg.setPhones(phones); - sendmsg(wxMsg,wxMsgConfig); + sendmsg(wxMsg,wxMsgConfig,couponInject); } } } - public ResultData sendmsg(WxMsg record,WxMsgConfig wxMsgConfig) { + public ResultData sendmsg(WxMsg record,WxMsgConfig wxMsgConfig,WxCouponInject couponInject) { logger.info("发送短信开始..."); - + logger.info("couponInject:"+couponInject); String secret = wxMsgConfig.getSecret(); String bid = wxMsgConfig.getBid(); String publickey = wxMsgConfig.getPublickey(); @@ -241,9 +248,12 @@ public class WxMsgServiceImpl implements WxMsgService { String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); wxMsg.setSendtime(systemTime); wxMsg.setCreatetime(DateUtils.stringToDate(systemTime,"yyyy-MM-dd HH:mm:ss")); + //精准投放 + if(couponInject!=null){ + wxMsg.setCouponInjectId(couponInject.getId()); + } wxMsgMapper.insertSelective(wxMsg); - logger.info("发送短信结束..."); if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { addMsgCallback(wxMsg,batchNo); diff --git a/mallinkService/src/main/resources/mapper/WxMsgMapper.xml b/mallinkService/src/main/resources/mapper/WxMsgMapper.xml index fcf1ec800..3d8ce43ae 100644 --- a/mallinkService/src/main/resources/mapper/WxMsgMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxMsgMapper.xml @@ -21,11 +21,11 @@ - + - `id`,`tenant_id`,`model_id`,`msg`,`sendtime`,`createtime`,`expect_send_number`,`success_number`,`error_number`,`return_result`,`phones`,`signature`,`isright`,`name`,`sendstatus`,`excelpath`,`label`,`status`,`way` + `id`,`tenant_id`,`model_id`,`msg`,`sendtime`,`createtime`,`expect_send_number`,`success_number`,`error_number`,`return_result`,`phones`,`signature`,`isright`,`name`,`sendstatus`,`excelpath`,`label`,`status`,`way`,`coupon_inject_id` @@ -112,6 +112,10 @@ and `way` = #{way} + + and `coupon_inject_id` = #{couponInjectId} + + and id in