Explorar el Código

[精准发券][修改][短信发送]

release_toaliyun_real
gongbiao hace 7 años
padre
commit
00c01b19cb
Se han modificado 4 ficheros con 42 adiciones y 16 borrados
  1. +9
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java
  2. +3
    -0
      mallinkService/src/main/java/com/iformall/service/WxMsgService.java
  3. +24
    -14
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java
  4. +6
    -2
      mallinkService/src/main/resources/mapper/WxMsgMapper.xml

+ 9
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxMsg.java Ver fichero

@@ -95,6 +95,9 @@ public class WxMsg implements Serializable {
@io.swagger.annotations.ApiModelProperty(value="1标签短信2精准投放",name="way") @io.swagger.annotations.ApiModelProperty(value="1标签短信2精准投放",name="way")
private Integer way; private Integer way;


@io.swagger.annotations.ApiModelProperty(value="couponInjectId",name="couponInjectId")
private Long couponInjectId;

public String getTenantId() { public String getTenantId() {
return tenantId; return tenantId;
} }
@@ -222,7 +225,13 @@ public class WxMsg implements Serializable {
this.tagsList = tagsList; this.tagsList = tagsList;
} }


public Long getCouponInjectId() {
return couponInjectId;
}


public void setCouponInjectId(Long couponInjectId) {
this.couponInjectId = couponInjectId;
}


public static enum Field public static enum Field
{ {


+ 3
- 0
mallinkService/src/main/java/com/iformall/service/WxMsgService.java Ver fichero

@@ -2,6 +2,7 @@ package com.iformall.service;


import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCouponInject;
import com.iformall.domain.po.WxMsg; import com.iformall.domain.po.WxMsg;
import com.iformall.domain.po.WxMsgConfig; import com.iformall.domain.po.WxMsgConfig;


@@ -40,4 +41,6 @@ public interface WxMsgService {
*/ */
void deleteById(Long id); void deleteById(Long id);


void sendMsgFromCouponInject(WxMsg wxmsg, WxMsgConfig wxMsgConfig, WxCouponInject record);

} }

+ 24
- 14
mallinkService/src/main/java/com/iformall/service/impl/WxMsgServiceImpl.java Ver fichero

@@ -7,6 +7,7 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker; import com.iformall.common.IdWorker;
import com.iformall.common.Result; import com.iformall.common.Result;
import com.iformall.common.ResultData; import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCouponInject;
import com.iformall.domain.po.WxMsg; import com.iformall.domain.po.WxMsg;
import com.iformall.domain.po.WxMsgCallback; import com.iformall.domain.po.WxMsgCallback;
import com.iformall.domain.po.WxMsgConfig; import com.iformall.domain.po.WxMsgConfig;
@@ -15,10 +16,7 @@ import com.iformall.enums.EnumMsgSendStatus;
import com.iformall.enums.EnumMsgStatus; import com.iformall.enums.EnumMsgStatus;
import com.iformall.enums.EnumVerifyCode; import com.iformall.enums.EnumVerifyCode;
import com.iformall.exception.MallinkException; 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.PushLimitService;
import com.iformall.service.WxCUserTagsService; import com.iformall.service.WxCUserTagsService;
import com.iformall.service.WxMsgService; import com.iformall.service.WxMsgService;
@@ -34,6 +32,9 @@ import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;




/**
* @author gongbiao
*/
@Service @Service
public class WxMsgServiceImpl implements WxMsgService { public class WxMsgServiceImpl implements WxMsgService {
private final Logger logger = LoggerFactory.getLogger(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -118,9 +119,9 @@ public class WxMsgServiceImpl implements WxMsgService {
return new ResultData(e.getErrorCode(),e.getMessage()); return new ResultData(e.getErrorCode(),e.getMessage());
} }
if(wxMsg.getExpectSendNumber().intValue()>1000){ if(wxMsg.getExpectSendNumber().intValue()>1000){
batchSendMsg(wxMsg,wxMsgConfig);
batchSendMsg(wxMsg,wxMsgConfig,null);
}else{ }else{
sendmsg(wxMsg,wxMsgConfig);
sendmsg(wxMsg,wxMsgConfig,null);
} }
return new ResultData(Result.SUCCESS, "短信已发送"); return new ResultData(Result.SUCCESS, "短信已发送");
} else { } else {
@@ -150,9 +151,9 @@ public class WxMsgServiceImpl implements WxMsgService {
return new ResultData(e.getErrorCode(),e.getMessage()); return new ResultData(e.getErrorCode(),e.getMessage());
} }
if(wxMsg.getExpectSendNumber().intValue()>1000){ if(wxMsg.getExpectSendNumber().intValue()>1000){
batchSendMsg(wxMsg,wxMsgConfig);
batchSendMsg(wxMsg,wxMsgConfig,null);
}else{ }else{
sendmsg(wxMsg,wxMsgConfig);
sendmsg(wxMsg,wxMsgConfig,null);
} }
return new ResultData(Result.SUCCESS, "短信已发送"); return new ResultData(Result.SUCCESS, "短信已发送");
} else { } else {
@@ -172,8 +173,14 @@ public class WxMsgServiceImpl implements WxMsgService {
wxMsgMapper.deleteByPrimaryKey(id); 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(","); String[] split = wxMsg.getPhones().split(",");
int length=split.length; int length=split.length;
@@ -186,20 +193,20 @@ public class WxMsgServiceImpl implements WxMsgService {
String phones = StringUtils.join(phoneList, ","); String phones = StringUtils.join(phoneList, ",");
wxMsg.setPhones(phones); wxMsg.setPhones(phones);
wxMsg.setExpectSendNumber(extra); wxMsg.setExpectSendNumber(extra);
sendmsg(wxMsg,wxMsgConfig);
sendmsg(wxMsg,wxMsgConfig,couponInject);
}else{ }else{
List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i+1) * 1000); List<String> phoneList = Arrays.asList(split).subList(i * 1000, (i+1) * 1000);
String phones = StringUtils.join(phoneList, ","); String phones = StringUtils.join(phoneList, ",");
wxMsg.setExpectSendNumber(1000); wxMsg.setExpectSendNumber(1000);
wxMsg.setPhones(phones); 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("发送短信开始...");
logger.info("couponInject:"+couponInject);
String secret = wxMsgConfig.getSecret(); String secret = wxMsgConfig.getSecret();
String bid = wxMsgConfig.getBid(); String bid = wxMsgConfig.getBid();
String publickey = wxMsgConfig.getPublickey(); String publickey = wxMsgConfig.getPublickey();
@@ -241,9 +248,12 @@ public class WxMsgServiceImpl implements WxMsgService {
String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss"); String systemTime = DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss");
wxMsg.setSendtime(systemTime); wxMsg.setSendtime(systemTime);
wxMsg.setCreatetime(DateUtils.stringToDate(systemTime,"yyyy-MM-dd HH:mm:ss")); wxMsg.setCreatetime(DateUtils.stringToDate(systemTime,"yyyy-MM-dd HH:mm:ss"));
//精准投放
if(couponInject!=null){
wxMsg.setCouponInjectId(couponInject.getId());
}
wxMsgMapper.insertSelective(wxMsg); wxMsgMapper.insertSelective(wxMsg);



logger.info("发送短信结束..."); logger.info("发送短信结束...");
if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) { if (ret.equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode().toString())) {
addMsgCallback(wxMsg,batchNo); addMsgCallback(wxMsg,batchNo);


+ 6
- 2
mallinkService/src/main/resources/mapper/WxMsgMapper.xml Ver fichero

@@ -21,11 +21,11 @@
<result column="label" jdbcType="VARCHAR" property="label" /> <result column="label" jdbcType="VARCHAR" property="label" />
<result column="status" jdbcType="INTEGER" property="status" /> <result column="status" jdbcType="INTEGER" property="status" />
<result column="way" jdbcType="INTEGER" property="way" /> <result column="way" jdbcType="INTEGER" property="way" />
<result column="coupon_inject_id" jdbcType="BIGINT" property="couponInjectId" />
</resultMap> </resultMap>
<sql id="allColumns"> <sql id="allColumns">
`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`
</sql> </sql>


<sql id="dynamicWhereConditions"> <sql id="dynamicWhereConditions">
@@ -112,6 +112,10 @@
<if test=" null != way "> <if test=" null != way ">
and `way` = #{way} and `way` = #{way}
</if> </if>
<if test=" null != couponInjectId ">
and `coupon_inject_id` = #{couponInjectId}
</if>
<if test=" null != ids "> <if test=" null != ids ">
and id in and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Cargando…
Cancelar
Guardar