JooLun Plus 百科 ⬇ 源码下载

05.09 小程序订阅消息

JooLun 于 2026-10-21 14:40:14 +08:00 修改了此页面

官方文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html

使用步骤

  • 微信公众平台申请模板

核心代码

  • 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);