| @@ -0,0 +1,2 @@ | |||||
| alter table wx_msg_callback | |||||
| add column business_id bigint(20) default 0 not null comment '业务ID'; | |||||
| @@ -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; | |||||
| } | } | ||||
| @@ -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); | |||||
| } | } | ||||
| @@ -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); | ||||
| @@ -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()); | ||||
| @@ -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("验证码发送时主动添加回调记录结束..."); | ||||
| } | } | ||||
| @@ -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); | ||||
| @@ -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"> | ||||