Просмотр исходного кода

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

release_toaliyun_real
gongbiao 7 лет назад
Родитель
Сommit
00c01b19cb
4 измененных файлов: 42 добавлений и 16 удалений
  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 Просмотреть файл

@@ -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
{


+ 3
- 0
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);

}

+ 24
- 14
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<String> 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);


+ 6
- 2
mallinkService/src/main/resources/mapper/WxMsgMapper.xml Просмотреть файл

@@ -21,11 +21,11 @@
<result column="label" jdbcType="VARCHAR" property="label" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="way" jdbcType="INTEGER" property="way" />
<result column="coupon_inject_id" jdbcType="BIGINT" property="couponInjectId" />
</resultMap>
<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 id="dynamicWhereConditions">
@@ -112,6 +112,10 @@
<if test=" null != way ">
and `way` = #{way}
</if>
<if test=" null != couponInjectId ">
and `coupon_inject_id` = #{couponInjectId}
</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Загрузка…
Отмена
Сохранить