| @@ -261,6 +261,40 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| } | |||
| private void sendMsgForSendCoupon(String tenantId, WxCouponSend send, WxCouponOrder couponOrder, WxCUser user) { | |||
| // 发送微信模板消息(公众号模板消息/小程序统一消息/小程序模板消息) | |||
| sendMpMsgForSendCoupon(send, couponOrder, user); | |||
| // 发送短信 | |||
| if (send.getSendSms().equals(EnumCouponSendSms.YES.getCode())) { | |||
| logger.info("》》》》》》》》》》》"); | |||
| logger.info("场景投放发送短信开始"); | |||
| logger.info("》》》》》》》》》》》"); | |||
| //券名 | |||
| String title = send.getTitle(); | |||
| //找出用户手机号 | |||
| String phone = user.getPhone(); | |||
| //小程序名称 | |||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantId); | |||
| String appName = appInfo.getName(); | |||
| Map<String, String> msgReplaceMap = new HashMap(); | |||
| msgReplaceMap.put("title", title); | |||
| msgReplaceMap.put("app", appName); | |||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||
| wxMsgRecord.setModelType(EnumMsgModel.COUPON_SEND.getCode()); | |||
| wxMsgRecord.setReceiver(phone); | |||
| wxMsgRecord.setTenantId(tenantId); | |||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| logger.info("》》》》》》》》》》》"); | |||
| logger.info("场景投放发送短信结束"); | |||
| logger.info("》》》》》》》》》》》"); | |||
| } | |||
| } | |||
| private boolean sendMpMsgForSendCoupon(WxCouponSend send, WxCouponOrder couponOrder, WxCUser user) { | |||
| // 发送 公众号 模板消息 | |||
| SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |||
| String gotopage = "pages/index/index?type=mc"; | |||
| @@ -275,7 +309,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| msgLimit.setLimitId(user.getMpOpenId()); | |||
| if(wxMsgLimitService.checkIsLimit(msgLimit)) { | |||
| logger.error("用户公众号模板消息超限" + user.getId()); | |||
| return; | |||
| return true; | |||
| } | |||
| // 已关注公众号 | |||
| @@ -324,7 +358,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| msgLimit.setLimitId(user.getOpenId()); | |||
| if(wxMsgLimitService.checkIsLimit(msgLimit)) { | |||
| logger.error("用户小程序统一模板消息超限:" + user.getId()); | |||
| return; | |||
| return true; | |||
| } | |||
| // 获取小程序关联的服务号 | |||
| WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | |||
| @@ -356,34 +390,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| } | |||
| } | |||
| } | |||
| // 发送短信 | |||
| if (send.getSendSms().equals(EnumCouponSendSms.YES.getCode())) { | |||
| logger.info("》》》》》》》》》》》"); | |||
| logger.info("场景投放发送短信开始"); | |||
| logger.info("》》》》》》》》》》》"); | |||
| //券名 | |||
| String title = send.getTitle(); | |||
| //找出用户手机号 | |||
| String phone = user.getPhone(); | |||
| //小程序名称 | |||
| WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantId); | |||
| String appName = appInfo.getName(); | |||
| Map<String, String> msgReplaceMap = new HashMap(); | |||
| msgReplaceMap.put("title", title); | |||
| msgReplaceMap.put("app", appName); | |||
| WxMsgRecord wxMsgRecord = new WxMsgRecord(); | |||
| wxMsgRecord.setMsgType(EnumMsgRecordType.SMS.getCode()); | |||
| wxMsgRecord.setModelType(EnumMsgModel.COUPON_SEND.getCode()); | |||
| wxMsgRecord.setReceiver(phone); | |||
| wxMsgRecord.setTenantId(tenantId); | |||
| wxMsgRecord.setDynamicContentMap(msgReplaceMap); | |||
| mqBaseProducer.sendMessage(wxMsgRecord, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| logger.info("》》》》》》》》》》》"); | |||
| logger.info("场景投放发送短信结束"); | |||
| logger.info("》》》》》》》》》》》"); | |||
| } | |||
| return false; | |||
| } | |||
| @Override | |||