瀏覽代碼

[系统发卡][修改][发送短信业务]

release_toaliyun_real
gongbiao 6 年之前
父節點
當前提交
145c569f25
共有 8 個文件被更改,包括 36 次插入17 次删除
  1. +2
    -0
      mallinkAdmin/src/main/resources/db/migration/V201909170451__G_MSG_CALLBACK.sql
  2. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxMsgCallback.java
  3. +1
    -3
      mallinkService/src/main/java/com/iformall/service/WxMsgValidationcodeService.java
  4. +3
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponPresentServiceImpl.java
  5. +15
    -6
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgCallbackServiceImpl.java
  6. +5
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java
  7. +4
    -3
      mallinkService/src/main/java/com/iformall/service/msg/impl/SendSmsServiceImpl.java
  8. +3
    -2
      mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml

+ 2
- 0
mallinkAdmin/src/main/resources/db/migration/V201909170451__G_MSG_CALLBACK.sql 查看文件

@@ -0,0 +1,2 @@
alter table wx_msg_callback
add column business_id bigint(20) default 0 not null comment '业务ID';

+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxMsgCallback.java 查看文件

@@ -49,4 +49,7 @@ public class WxMsgCallback extends BaseEntity {
@io.swagger.annotations.ApiModelProperty(value="msgId",name="msgId")
private Long msgId;

@io.swagger.annotations.ApiModelProperty(value = "业务ID", name = "businessId")
private Long businessId;

}

+ 1
- 3
mallinkService/src/main/java/com/iformall/service/WxMsgValidationcodeService.java 查看文件

@@ -4,8 +4,6 @@ import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxMsgValidationcode;

import java.util.Map;

public interface WxMsgValidationcodeService {
/**
* 根据实体查询分页列表
@@ -44,6 +42,6 @@ public interface WxMsgValidationcodeService {
ResultData hasvalidationcode(WxMsgValidationcode record);


void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo);
void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo, String id);
}

+ 3
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCouponPresentServiceImpl.java 查看文件

@@ -115,7 +115,7 @@ public class WxCouponPresentServiceImpl implements WxCouponPresentService {
for (String phone : phoneSet) {
WxCouponPassword couponPassword = list.get(i);
//发送
sendMsg(tenantId, phone, priceStr, name, couponPassword.getPassword());
sendMsg(tenantId, phone, priceStr, name, couponPassword.getPassword(), couponPassword.getId().toString());
//记录发送数据便于更新状态
couponPassword.setSendedPhone(phone);
tempList.add(couponPassword);
@@ -126,11 +126,12 @@ public class WxCouponPresentServiceImpl implements WxCouponPresentService {
return new ResultData();
}

private void sendMsg(String tenantId, String phone, String money, String appName, String password) {
private void sendMsg(String tenantId, String phone, String money, String appName, String password, String id) {
logger.info("》》》》》》》》》》》");
logger.info("系统发卡发送短信开始");
logger.info("》》》》》》》》》》》");
Map<String, String> msgReplaceMap = new HashMap();
msgReplaceMap.put("id", id);
msgReplaceMap.put("app", appName);
msgReplaceMap.put("money", money);
msgReplaceMap.put("password", password);


+ 15
- 6
mallinkService/src/main/java/com/iformall/service/impl/WxMsgCallbackServiceImpl.java 查看文件

@@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxMsgCallback;
import com.iformall.domain.po.WxMsgConfig;
import com.iformall.domain.po.WxMsgModel;
import com.iformall.domain.po.WxMsgValidationcodeModel;
import com.iformall.domain.po.*;
import com.iformall.enums.EnumCouponPasswordStatus;
import com.iformall.enums.EnumMsgSendStatus;
import com.iformall.mapper.*;
import com.iformall.service.WxMsgCallbackService;
@@ -38,6 +36,9 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService {
@Autowired
WxMsgMapper wxMsgMapper;

@Autowired
WxCouponPasswordMapper wxCouponPasswordMapper;

@Override
public PageInfo<WxMsgCallback> listAsPage(WxMsgCallback record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMsgCallbackMapper.findList(record));
@@ -75,11 +76,11 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService {
List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(param.get("item"), WxMsgCallback.class);
wxMsgConfig = list.get(0);
wxMsgConfig.setRemains(wxMsgConfig.getRemains() - wxMsgCallbacks.size());
//wxMsgConfigMapper.updateByPrimaryKeySelective(wxMsgConfig);
final IdWorker idWorker = IdWorker.get();
for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) {
WxMsgCallback callback=wxMsgCallbackMapper.queryCallbackByBatchNoAndPhone(wxMsgCallback);
if(callback!=null){//有更新,无插入
if (callback != null) {
//有更新,无插入
callback.setSign(param.get("sign"));
callback.setTenantId(tenantId);
if (!wxMsgCallback.getStatus().equals(EnumMsgSendStatus.MSG_SEND_SUCCESS.getCode())) {
@@ -93,6 +94,14 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService {
callback.setCallbackId(wxMsgCallback.getId());
callback.setUpdatetime(new Date());
wxMsgCallbackMapper.updateByPrimaryKeySelective(callback);
//更新业务
if (!callback.getBusinessId().equals(0L)) {
WxCouponPassword couponPassword = new WxCouponPassword();
couponPassword.setId(callback.getBusinessId());
couponPassword.setStatus(EnumCouponPasswordStatus.MSG_SENDED.getCode());
couponPassword.setUpdateDate(new Date());
wxCouponPasswordMapper.updateByPrimaryKeySelective(couponPassword);
}
}else{
Long callbackId = wxMsgCallback.getId();
wxMsgCallback.setId(idWorker.nextId());


+ 5
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java 查看文件

@@ -14,6 +14,7 @@ import com.iformall.mq.MqBaseProducer;
import com.iformall.service.WxMsgValidationcodeService;
import com.iformall.utils.DateUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -113,7 +114,7 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic
}

@Override
public void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo){
public void addMsgCallback(WxMsgValidationcode wxmsg, String batchNo, String id) {
logger.info("验证码发送时主动添加回调记录开始...");
String phone = wxmsg.getPhone();
final IdWorker idWorker = IdWorker.get();
@@ -125,6 +126,9 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic
wxMsgCallback.setMsgId(wxmsg.getId());
wxMsgCallback.setStatus(EnumMsgSendStatus.MSG_SEND_FAIL.getCode());
wxMsgCallback.setCreatetime(new Date());
if (StringUtils.isNotEmpty(id)) {
wxMsgCallback.setBusinessId(Long.parseLong(id));
}
wxMsgCallbackMapper.insertSelective(wxMsgCallback);
logger.info("验证码发送时主动添加回调记录结束...");
}


+ 4
- 3
mallinkService/src/main/java/com/iformall/service/msg/impl/SendSmsServiceImpl.java 查看文件

@@ -56,7 +56,7 @@ public class SendSmsServiceImpl implements MsgSendService {
throw new MallinkException(ErrorCode.MSG_CONFIG_NOT_FOUND);
}
wxMsgConfig = wxMsgConfigs.get(0);
if(wxMsgConfig.getRemains() <=0l){
if (wxMsgConfig.getRemains() <= 0L) {
throw new MallinkException(ErrorCode.MSG_CONFIG_ACCOUNT);
}

@@ -96,7 +96,7 @@ public class SendSmsServiceImpl implements MsgSendService {
if (ret.equals("1")) {
final IdWorker idWorker = IdWorker.get();
wxMsgValidationcode.setId(idWorker.nextId());
long currentTime = System.currentTimeMillis() ;
long currentTime = System.currentTimeMillis();
Date createtime=new Date(currentTime);
wxMsgValidationcode.setCreatetime(createtime);
Integer minutes = wxMsgValidationcodeModel.getMinutes();
@@ -106,7 +106,8 @@ public class SendSmsServiceImpl implements MsgSendService {
wxMsgValidationcode.setExpiretime(expiredate);
}
wxMsgValidationcodeMapper.insertSelective(wxMsgValidationcode);
wxMsgValidationcodeService.addMsgCallback(wxMsgValidationcode,batchNo);
String id = record.getDynamicContentMap().get("id");
wxMsgValidationcodeService.addMsgCallback(wxMsgValidationcode, batchNo, id);
//扣减剩余条数
wxMsgConfig.setRemains(1L);
wxMsgConfigMapper.updateRemains(wxMsgConfig);


+ 3
- 2
mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml 查看文件

@@ -15,11 +15,12 @@
<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
<result column="callback_id" jdbcType="BIGINT" property="callbackId" />
<result column="msg_id" jdbcType="BIGINT" property="msgId" />
<result column="business_id" jdbcType="BIGINT" property="businessId"/>
</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`batch_no`,`phone`,`begintime`,`endtime`,`status`,`status_msg`,`sign`,`createtime`,`updatetime`,`msg_id`,`callback_id`
`id`,`tenant_id`,`batch_no`,`phone`,`begintime`,`endtime`,`status`,`status_msg`,`sign`,`createtime`,`updatetime`,`msg_id`,`callback_id`,`business_id`
</sql>

<sql id="dynamicWhereConditions">


Loading…
取消
儲存