|
|
|
@@ -130,20 +130,18 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { |
|
|
|
|
|
|
|
record.setCouponName(wxCoupon.getTitle()); |
|
|
|
record.setSendAmount(cUsers.size()); |
|
|
|
|
|
|
|
couponInjectMapper.insertSelective(record); |
|
|
|
if(record.getSendType().equals(EnumCouponInjectSendType.IMMEDIATE.getCode())) { |
|
|
|
|
|
|
|
List<WxCUser> sentUsers = sendCoupon(wxCoupon, cUsers, record); |
|
|
|
if (sentUsers.size() > 0) { |
|
|
|
record.setStatus(EnumCouponInjectStatus.HAS_SENT.getCode()); |
|
|
|
ResultData msgSendRes = sendMsg(record, sentUsers); |
|
|
|
if (msgSendRes.code == Result.SUCCESS) |
|
|
|
record.setMsgId((Long)msgSendRes.data); |
|
|
|
//发送短信 |
|
|
|
sendMsg(record, sentUsers); |
|
|
|
} else { |
|
|
|
record.setStatus(EnumCouponInjectStatus.SEND_FAILED.getCode()); |
|
|
|
} |
|
|
|
record.setSendAmount(sentUsers.size()); |
|
|
|
|
|
|
|
couponInjectMapper.updateByPrimaryKeySelective(record); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -171,7 +169,8 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { |
|
|
|
return new ResultData(ErrorCode.MSG_SUM_ZERO); |
|
|
|
} |
|
|
|
|
|
|
|
wxmsg.setExpectSendNumber(cUsers.size());//预计发送数量 |
|
|
|
//预计发送数量 |
|
|
|
wxmsg.setExpectSendNumber(cUsers.size()); |
|
|
|
if(wxMsgConfig.getRemains()<cUsers.size()){ |
|
|
|
return new ResultData(ErrorCode.MSG_SUM_INSUFFICENT); |
|
|
|
} |
|
|
|
@@ -183,8 +182,9 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { |
|
|
|
StringBuffer sb=new StringBuffer(); |
|
|
|
for(WxCUser user:cUsers){ |
|
|
|
String phone = user.getPhone(); |
|
|
|
if(null!=phone && !phone.equals("")) |
|
|
|
if(null!=phone && !phone.equals("")){ |
|
|
|
sb.append(phone).append(","); |
|
|
|
} |
|
|
|
} |
|
|
|
wxmsg.setPhones(sb.deleteCharAt(sb.length()-1).toString()); |
|
|
|
wxmsg.setLabel(""); |
|
|
|
@@ -192,7 +192,8 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { |
|
|
|
return new ResultData(ErrorCode.MSG_NO_VALID_PHONE); |
|
|
|
} |
|
|
|
|
|
|
|
wxmsg.setIsright(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode());//立即发送 |
|
|
|
//立即发送 |
|
|
|
wxmsg.setIsright(EnumMsgSend.MSG_SEND_IMMEDIATELY.getCode()); |
|
|
|
wxmsg.setStatus(EnumMsgStatus.MSG_STATUS_SENDED.getCode()); |
|
|
|
wxmsg.setSendtime(com.iformall.utils.DateUtils.getSystemTime("yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
|
|
|
@@ -202,8 +203,10 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { |
|
|
|
wxmsg.setSignature(model.getSignature()); |
|
|
|
wxmsg.setSuccessNumber(0); |
|
|
|
wxmsg.setErrorNumber(0); |
|
|
|
wxmsg.setWay(EnumSendWay.COUPON.getCode());//1、标签短信2、精准发券 |
|
|
|
return wxMsgService.saveOrUpdate(wxmsg,wxMsgConfig); |
|
|
|
//1、标签短信2、精准发券 |
|
|
|
wxmsg.setWay(EnumSendWay.COUPON.getCode()); |
|
|
|
wxMsgService.sendMsgFromCouponInject(wxmsg,wxMsgConfig,record); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
private List<WxCUser> sendCoupon(WxCoupon wxCoupon,List<WxCUser> cUsers,WxCouponInject record){ |
|
|
|
|