官方文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html
使用步骤
- 微信公众平台申请模板
-
注意:订阅消息模板不要使用微信最新的订阅消息模板(如下图),否则不会弹出订阅提示。微信官方文档说最新的订阅消息不支持弹出:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-2.html

-
将模板信息添加到JooLun后台
核心代码
- com.joolun.cloud.weixin.admin.service.impl.WxTemplateMsgServiceImpl.sendWxMaTemplateMsg
使用案例
- com.joolun.cloud.mall.api.service.impl.notifyOrder
WxTemplateMsgSendDTO wxTemplateMsgSendDTO = new WxTemplateMsgSendDTO();
wxTemplateMsgSendDTO.setMallUserId(orderInfo.getUserId());
wxTemplateMsgSendDTO.setUseType(ConfigConstant.WX_TMP_USE_TYPE_2);
wxTemplateMsgSendDTO.setPage("pages/order/order-detail/index?id="+orderInfo.getId());
Map<String, Object> data = new HashMap();
Map<String, Object> map = BeanUtil.beanToMap(orderInfo);
for(String mapKey: map.keySet()){
data.put("order." + mapKey, map.get(mapKey));
}
Map<String, Object> map2 = BeanUtil.beanToMap(orderLogistics);
for(String mapKey: map2.keySet()){
data.put("orderLogistics." + mapKey, map2.get(mapKey));
}
wxTemplateMsgSendDTO.setData(data);
feignWxTemplateMsgService.sendTemplateMsgMa(wxTemplateMsgSendDTO, SecurityConstants.FROM_IN);
feignWxTemplateMsgService.sendTemplateMsgMp(wxTemplateMsgSendDTO, SecurityConstants.FROM_IN);


