| @@ -90,7 +90,8 @@ public class WxMsgRecordController extends BaseController { | |||||
| wxMsg.setReceiver(wxMsgRecord.getReceiver()); | wxMsg.setReceiver(wxMsgRecord.getReceiver()); | ||||
| wxMsg.updateTenantInfo(tenantEntity); | wxMsg.updateTenantInfo(tenantEntity); | ||||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | ||||
| }else if(EnumMsgRecordType.SMART_APP.getCode().equals(wxMsgRecord.getMsgType())){ | |||||
| // }else if(EnumMsgRecordType.SMART_APP.getCode().equals(wxMsgRecord.getMsgType())){ | |||||
| }else if(EnumMsgRecordType.SMART_APP_TO.getCode().equals(wxMsgRecord.getMsgType())){ | |||||
| //微信小程序 | //微信小程序 | ||||
| SmartAppMsg wxMsg = (SmartAppMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),SmartAppMsg.class); | SmartAppMsg wxMsg = (SmartAppMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),SmartAppMsg.class); | ||||
| wxMsg.setMsgType(wxMsgRecord.getMsgType()); | wxMsg.setMsgType(wxMsgRecord.getMsgType()); | ||||
| @@ -67,7 +67,8 @@ public class MqBaseConsumer { | |||||
| //邮件 | //邮件 | ||||
| MailMsg msg = (MailMsg)JsonUtil.readValue(message,MailMsg.class); | MailMsg msg = (MailMsg)JsonUtil.readValue(message,MailMsg.class); | ||||
| sendEmailService.send(msg); | sendEmailService.send(msg); | ||||
| } else if(EnumMsgRecordType.SMART_APP.getCode().equals(baseMsg.getMsgType())){ | |||||
| // } else if(EnumMsgRecordType.SMART_APP.getCode().equals(baseMsg.getMsgType())){ | |||||
| } else if(EnumMsgRecordType.SMART_APP_TO.getCode().equals(baseMsg.getMsgType())){ | |||||
| //微信小程序-模板消息 | //微信小程序-模板消息 | ||||
| SmartAppMsg msg = (SmartAppMsg)JsonUtil.readValue(message,SmartAppMsg.class); | SmartAppMsg msg = (SmartAppMsg)JsonUtil.readValue(message,SmartAppMsg.class); | ||||
| sendSmartAppMsgService.send(msg); | sendSmartAppMsgService.send(msg); | ||||
| @@ -7,7 +7,8 @@ public enum EnumMsgRecordType { | |||||
| SMS(1, "短信"), | SMS(1, "短信"), | ||||
| SMS_CALLBACK(2, "业务短信"), | SMS_CALLBACK(2, "业务短信"), | ||||
| EMAIL(3, "邮件"), | EMAIL(3, "邮件"), | ||||
| SMART_APP(4, "小程序"), | |||||
| SMART_APP(4, "小程序"),//模板消息作废 | |||||
| SMART_APP_TO(44, "小程序"),//订阅消息 | |||||
| PUBLIC(5, "公众号"), | PUBLIC(5, "公众号"), | ||||
| SYSTEM(6, "系统通知"), | SYSTEM(6, "系统通知"), | ||||
| SMART_APP_UNIFORM(7, "小程序统一消息"), | SMART_APP_UNIFORM(7, "小程序统一消息"), | ||||
| @@ -954,7 +954,8 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| * 温馨提示 {{keyword7.DATA}} | * 温馨提示 {{keyword7.DATA}} | ||||
| */ | */ | ||||
| smartAppMsg = new SmartAppMsg(); | smartAppMsg = new SmartAppMsg(); | ||||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||||
| // smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||||
| smartAppMsg.setAppId(user.getAppId()); | smartAppMsg.setAppId(user.getAppId()); | ||||
| smartAppMsg.updateTenantInfo(couponOrder); | smartAppMsg.updateTenantInfo(couponOrder); | ||||
| smartAppMsg.setTemplateType(EnumTemplateType.VERIFY_SUCCESS.getCode()); | smartAppMsg.setTemplateType(EnumTemplateType.VERIFY_SUCCESS.getCode()); | ||||
| @@ -989,7 +990,8 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| * 备注 {{keyword4.DATA}} | * 备注 {{keyword4.DATA}} | ||||
| */ | */ | ||||
| smartAppMsg = new SmartAppMsg(); | smartAppMsg = new SmartAppMsg(); | ||||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||||
| // smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||||
| smartAppMsg.setAppId(user.getAppId()); | smartAppMsg.setAppId(user.getAppId()); | ||||
| smartAppMsg.updateTenantInfo(couponOrder); | smartAppMsg.updateTenantInfo(couponOrder); | ||||
| smartAppMsg.setTemplateType(EnumTemplateType.VERIFY_FAIL.getCode()); | smartAppMsg.setTemplateType(EnumTemplateType.VERIFY_FAIL.getCode()); | ||||
| @@ -226,7 +226,8 @@ public class WxOrderPressServiceImpl implements WxOrderPressService { | |||||
| System.out.println(calendar.get(Calendar.DATE));// 加1之后的日期Top | System.out.println(calendar.get(Calendar.DATE));// 加1之后的日期Top | ||||
| System.out.println(); | System.out.println(); | ||||
| smartAppMsg = new SmartAppMsg(); | smartAppMsg = new SmartAppMsg(); | ||||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||||
| // smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP.getCode()); | |||||
| smartAppMsg.setMsgType(EnumMsgRecordType.SMART_APP_TO.getCode()); | |||||
| smartAppMsg.setAppId(user.getAppId()); | smartAppMsg.setAppId(user.getAppId()); | ||||
| smartAppMsg.setTenantId(user.getTenantId()); | smartAppMsg.setTenantId(user.getTenantId()); | ||||
| smartAppMsg.setTemplateType(EnumTemplateType.PRESS_SUCCESS.getCode()); | smartAppMsg.setTemplateType(EnumTemplateType.PRESS_SUCCESS.getCode()); | ||||
| @@ -1,8 +1,10 @@ | |||||
| package com.iformall.service.msg.impl; | package com.iformall.service.msg.impl; | ||||
| import cn.binarywang.wx.miniapp.api.WxMaService; | import cn.binarywang.wx.miniapp.api.WxMaService; | ||||
| import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage; | |||||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | ||||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; | import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; | ||||
| import cn.binarywang.wx.miniapp.constant.WxMaConstants; | |||||
| import com.alibaba.fastjson.JSON; | import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
| @@ -50,7 +52,8 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { | |||||
| TenantEntity tenantEntity = smartAppMsg.getTenantInfo(); | TenantEntity tenantEntity = smartAppMsg.getTenantInfo(); | ||||
| WxTemplateMsg msg = null; | WxTemplateMsg msg = null; | ||||
| WxMaTemplateMessage templateMessage; | |||||
| WxMaSubscribeMessage subscribeMessage; | |||||
| // WxMaTemplateMessage templateMessage; | |||||
| WxMaService wxMaService = null; | WxMaService wxMaService = null; | ||||
| if(isFmOpen) { | if(isFmOpen) { | ||||
| @@ -79,24 +82,45 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { | |||||
| String emphasis = customParam.getString("emphasis"); | String emphasis = customParam.getString("emphasis"); | ||||
| // build template data list | // build template data list | ||||
| List<WxMaTemplateData> dataTempList = new ArrayList<>(); | |||||
| List<String> dataList = smartAppMsg.getDataList(); | List<String> dataList = smartAppMsg.getDataList(); | ||||
| JSONArray indexArr = customParam.getJSONArray("index"); | JSONArray indexArr = customParam.getJSONArray("index"); | ||||
| List<WxMaSubscribeMessage.Data> dataTempList = new ArrayList<>(); | |||||
| for(int i=0;i<indexArr.size();i++) { | for(int i=0;i<indexArr.size();i++) { | ||||
| String key = indexArr.getString(i); | String key = indexArr.getString(i); | ||||
| String value = customParam.getString(key); | |||||
| value = value.replace("{"+key+"}", dataList.get(i)); | |||||
| WxMaTemplateData templateData = new WxMaTemplateData(key, value); | |||||
| String value = dataList.get(i); | |||||
| WxMaSubscribeMessage.Data templateData = new WxMaSubscribeMessage.Data(key, value); | |||||
| dataTempList.add(templateData); | dataTempList.add(templateData); | ||||
| } | } | ||||
| templateMessage = WxMaTemplateMessage.builder() | |||||
| // List<WxMaTemplateData> dataTempList = new ArrayList<>(); | |||||
| // for(int i=0;i<indexArr.size();i++) { | |||||
| // String key = indexArr.getString(i); | |||||
| // String value = customParam.getString(key); | |||||
| // value = value.replace("{"+key+"}", dataList.get(i)); | |||||
| // WxMaTemplateData templateData = new WxMaTemplateData(key, value); | |||||
| // dataTempList.add(templateData); | |||||
| // } | |||||
| // templateMessage = WxMaTemplateMessage.builder() | |||||
| // .toUser(smartAppMsg.getTo()) | |||||
| // .formId(smartAppMsg.getFormId()) // 微信支付的formId是prepayId | |||||
| // .page(smartAppMsg.getGotopage()) | |||||
| // .data(dataTempList) | |||||
| // .templateId(msg.getTemplateId()) | |||||
| // .emphasisKeyword(emphasis) | |||||
| // .build(); | |||||
| // wxMaService.getMsgService().sendTemplateMsg(templateMessage); | |||||
| subscribeMessage = WxMaSubscribeMessage.builder() | |||||
| .templateId(msg.getTemplateId()) | |||||
| .toUser(smartAppMsg.getTo()) | .toUser(smartAppMsg.getTo()) | ||||
| .formId(smartAppMsg.getFormId()) // 微信支付的formId是prepayId | |||||
| .lang(WxMaConstants.MiniprogramLang.ZH_CN) | |||||
| .miniprogramState(WxMaConstants.MiniprogramState.FORMAL) | |||||
| .page(smartAppMsg.getGotopage()) | .page(smartAppMsg.getGotopage()) | ||||
| .data(dataTempList) | .data(dataTempList) | ||||
| .templateId(msg.getTemplateId()) | |||||
| .emphasisKeyword(emphasis) | |||||
| .build(); | .build(); | ||||
| wxMaService.getMsgService().sendTemplateMsg(templateMessage); | |||||
| wxMaService.getMsgService().sendSubscribeMsg(subscribeMessage); | |||||
| } | } | ||||
| } | } | ||||
| @@ -88,7 +88,8 @@ public class WxMsgRecordController extends BaseController { | |||||
| wxMsg.setReceiver(wxMsgRecord.getReceiver()); | wxMsg.setReceiver(wxMsgRecord.getReceiver()); | ||||
| wxMsg.setTenantId(wxMsgRecord.getTenantId()); | wxMsg.setTenantId(wxMsgRecord.getTenantId()); | ||||
| mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | mqBaseProducer.sendMessage(wxMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | ||||
| }else if(EnumMsgRecordType.SMART_APP.getCode().equals(wxMsgRecord.getMsgType())){ | |||||
| // }else if(EnumMsgRecordType.SMART_APP.getCode().equals(wxMsgRecord.getMsgType())){ | |||||
| }else if(EnumMsgRecordType.SMART_APP_TO.getCode().equals(wxMsgRecord.getMsgType())){ | |||||
| //微信小程序 | //微信小程序 | ||||
| SmartAppMsg wxMsg = (SmartAppMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),SmartAppMsg.class); | SmartAppMsg wxMsg = (SmartAppMsg) JsonUtil.readValue(wxMsgRecord.getMsgJson(),SmartAppMsg.class); | ||||
| wxMsg.setMsgType(wxMsgRecord.getMsgType()); | wxMsg.setMsgType(wxMsgRecord.getMsgType()); | ||||