Browse Source

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

release_toaliyun_real
gongbiao 6 years ago
parent
commit
145c569f25
8 changed files with 36 additions and 17 deletions
  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 View File

@@ -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 View File

@@ -49,4 +49,7 @@ public class WxMsgCallback extends BaseEntity {
@io.swagger.annotations.ApiModelProperty(value="msgId",name="msgId") @io.swagger.annotations.ApiModelProperty(value="msgId",name="msgId")
private Long 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 View File

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


import java.util.Map;

public interface WxMsgValidationcodeService { public interface WxMsgValidationcodeService {
/** /**
* 根据实体查询分页列表 * 根据实体查询分页列表
@@ -44,6 +42,6 @@ public interface WxMsgValidationcodeService {
ResultData hasvalidationcode(WxMsgValidationcode record); 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 View File

@@ -115,7 +115,7 @@ public class WxCouponPresentServiceImpl implements WxCouponPresentService {
for (String phone : phoneSet) { for (String phone : phoneSet) {
WxCouponPassword couponPassword = list.get(i); 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); couponPassword.setSendedPhone(phone);
tempList.add(couponPassword); tempList.add(couponPassword);
@@ -126,11 +126,12 @@ public class WxCouponPresentServiceImpl implements WxCouponPresentService {
return new ResultData(); 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("系统发卡发送短信开始"); logger.info("系统发卡发送短信开始");
logger.info("》》》》》》》》》》》"); logger.info("》》》》》》》》》》》");
Map<String, String> msgReplaceMap = new HashMap(); Map<String, String> msgReplaceMap = new HashMap();
msgReplaceMap.put("id", id);
msgReplaceMap.put("app", appName); msgReplaceMap.put("app", appName);
msgReplaceMap.put("money", money); msgReplaceMap.put("money", money);
msgReplaceMap.put("password", password); msgReplaceMap.put("password", password);


+ 15
- 6
mallinkService/src/main/java/com/iformall/service/impl/WxMsgCallbackServiceImpl.java View File

@@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker; 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.enums.EnumMsgSendStatus;
import com.iformall.mapper.*; import com.iformall.mapper.*;
import com.iformall.service.WxMsgCallbackService; import com.iformall.service.WxMsgCallbackService;
@@ -38,6 +36,9 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService {
@Autowired @Autowired
WxMsgMapper wxMsgMapper; WxMsgMapper wxMsgMapper;


@Autowired
WxCouponPasswordMapper wxCouponPasswordMapper;

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


+ 5
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java View File

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


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


+ 4
- 3
mallinkService/src/main/java/com/iformall/service/msg/impl/SendSmsServiceImpl.java View File

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


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


+ 3
- 2
mallinkService/src/main/resources/mapper/WxMsgCallbackMapper.xml View File

@@ -15,11 +15,12 @@
<result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" /> <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime" />
<result column="callback_id" jdbcType="BIGINT" property="callbackId" /> <result column="callback_id" jdbcType="BIGINT" property="callbackId" />
<result column="msg_id" jdbcType="BIGINT" property="msgId" /> <result column="msg_id" jdbcType="BIGINT" property="msgId" />
<result column="business_id" jdbcType="BIGINT" property="businessId"/>
</resultMap> </resultMap>
<sql id="allColumns"> <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>


<sql id="dynamicWhereConditions"> <sql id="dynamicWhereConditions">


Loading…
Cancel
Save