| @@ -0,0 +1,15 @@ | |||
| ALTER TABLE wx_template_msg | |||
| ADD COLUMN `custom_param` json DEFAULT null COMMENT '自定义参数' after `type`; | |||
| UPDATE wx_template_msg | |||
| SET custom_param='{"index":["keyword1","keyword2","keyword3","keyword4","keyword5","keyword6","keyword7"],"keyword1":"可抵{keyword1}元","keyword2":"{keyword2}","keyword3":"{keyword3}","keyword4":"{keyword4}","keyword5":"{keyword5}元","keyword6":"{keyword6}","keyword7":"猜也猜不到的优惠,只有幸运的人才能看到,就是你,{keyword7}\n☟☟☟☟☟☟☟\n☞ 快看看 ☜\n☝︎☝︎☝︎☝︎☝︎☝︎☝︎\n","emphasis":"keyword1.DATA"}' | |||
| WHERE type = 1; | |||
| UPDATE wx_template_msg | |||
| SET custom_param='{"index":["keyword1","keyword2","keyword3","keyword4"],"keyword1":"可抵{keyword1}元","keyword2":"{keyword2}","keyword3":"{keyword3}","keyword4":"猜也猜不到的优惠,只有幸运的人才能看到,就是你,{keyword4}\n☟☟☟☟☟☟☟\n☞ 快看看 ☜\n☝︎☝︎☝︎☝︎☝︎☝︎☝︎\n","emphasis":"keyword1.DATA"}' | |||
| WHERE type = 2; | |||
| UPDATE wx_template_msg | |||
| SET custom_param='{"url":"http://iformall.com","index":["first","keyword1","keyword2","keyword3","remark"],"first":"商家{first}的券被核销","keyword1":"{keyword1}","keyword2":"{keyword2}","keyword3":"{keyword3}","remark":"猜也猜不到的优惠,只有幸运的人才能看到,就是你,{remark}\n☟☟☟☟☟☟☟\n☞ 快看看 ☜\n☝︎☝︎☝︎☝︎☝︎☝︎☝︎\n"}' | |||
| WHERE type = 102; | |||
| UPDATE wx_template_msg | |||
| SET custom_param='{"url":"http://iformall.com","index":["first","keyword1","keyword2","keyword3","keyword4","keyword5","remark"],"first":"您有新的惊喜,请点详情查看","keyword1":"{keyword1}","keyword2":"{keyword2}","keyword3":"{keyword3}","keyword4":"{keyword4}","keyword5":"{keyword5}","remark":"猜也猜不到的优惠,只有幸运的人才能看到,就是你,{remark}\n☟☟☟☟☟☟☟\n☞ 快看看 ☜\n☝︎☝︎☝︎☝︎☝︎☝︎☝︎\n"}' | |||
| WHERE type = 103; | |||
| @@ -28,6 +28,8 @@ public class WxTemplateMsg implements Serializable { | |||
| private String templateId; | |||
| @io.swagger.annotations.ApiModelProperty(value="模板类型1:核销成功消息,2:核销失败消息, 101:公众号审核结果消息, 102:公众号卡券核销消息",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value="自定义参数",name="customParam") | |||
| private String customParam; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| @@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * 微信公众号-模板消息 | |||
| @@ -30,8 +31,6 @@ public class AppUniformMsg extends BaseMsg { | |||
| private Integer templateType; | |||
| @io.swagger.annotations.ApiModelProperty(value="公众号AppId",name="mpAppId") | |||
| private String mpAppId; | |||
| @io.swagger.annotations.ApiModelProperty(value="公众号url",name="url") | |||
| private String url; | |||
| @io.swagger.annotations.ApiModelProperty(value="公众号模板主体",name="templateDataList") | |||
| private List<WxMaTemplateData> templateDataList; | |||
| @io.swagger.annotations.ApiModelProperty(value="公众号模板主体",name="dataList") | |||
| private List<String> dataList; | |||
| } | |||
| @@ -28,6 +28,6 @@ public class MpAppMsg extends BaseMsg { | |||
| private String miniAppId; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序路径",name="miniPagePath") | |||
| private String miniPagePath; | |||
| @io.swagger.annotations.ApiModelProperty(value="公众号模板主体",name="templateDataList") | |||
| private List<WxMpTemplateData> templateDataList; | |||
| @io.swagger.annotations.ApiModelProperty(value="公众号模板参数",name="dataList") | |||
| private List<String> dataList; | |||
| } | |||
| @@ -29,8 +29,6 @@ public class SmartAppMsg extends BaseMsg { | |||
| private Integer templateType; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序路径",name="gotopage") | |||
| private String gotopage; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序模板消息标题",name="emphasisKeyword") | |||
| private String emphasisKeyword; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序模板实体",name="templateDataList") | |||
| private List<WxMaTemplateData> templateDataList; | |||
| @io.swagger.annotations.ApiModelProperty(value="小程序模板参数列表",name="dataList") | |||
| private List<String> dataList; | |||
| } | |||
| @@ -577,11 +577,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| boolean bUsed = false; | |||
| String gotopage = "pages/index/index"; | |||
| String notes = ""; | |||
| if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) { | |||
| if (hadSentCoupon) { | |||
| gotopage = "pages/index/index?type=mc"; | |||
| notes = "您有新的券"; | |||
| } | |||
| bUsed = true; | |||
| } | |||
| @@ -604,7 +602,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| SmartAppMsg smartAppMsg; | |||
| if (bUsed) { | |||
| //mq发送小程序消息 - 核销成功消息 | |||
| doVerifySuccessMsg(couponOrder, formId, coupon, merchant, user, dateFormat, couponDetail, gotopage, notes); | |||
| doVerifySuccessMsg(couponOrder, formId, coupon, merchant, user, dateFormat, couponDetail, gotopage); | |||
| } else { | |||
| // mq发送小程序消息 - 核销失败消息 | |||
| doVerifyFailMsg(couponOrder, formId, coupon, user, dateFormat, couponDetail, gotopage); | |||
| @@ -630,12 +628,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| mpAppMsg.setMiniPagePath(gotopage); | |||
| mpAppMsg.setTenantId(couponOrder.getTenantId()); | |||
| mpAppMsg.setTemplateType(EnumTemplateType.VERIFY_RESULT.getCode()); | |||
| mpAppMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMpTemplateData("first", "商家"+merchant.getName()+"的券被核销", "#173177"), | |||
| new WxMpTemplateData("keyword1", EnumCouponType.getEnum(coupon.getType()).getMessage(), "#173177"), | |||
| new WxMpTemplateData("keyword2", couponOrder.getId().toString(), "#173177"), | |||
| new WxMpTemplateData("keyword3", dateFormat.format(new Date()), "#173177"), | |||
| new WxMpTemplateData("remark", "更多优惠等您来!", "#173177") | |||
| mpAppMsg.setDataList(Lists.newArrayList( | |||
| merchant.getName(), | |||
| EnumCouponType.getEnum(coupon.getType()).getMessage(), | |||
| couponOrder.getId().toString(), | |||
| dateFormat.format(new Date()), | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| @@ -658,14 +656,13 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| appUniformMsg.setTo(user.getOpenId()); | |||
| appUniformMsg.setTemplateType(EnumTemplateType.VERIFY_RESULT.getCode()); | |||
| appUniformMsg.setPagePath(gotopage); | |||
| appUniformMsg.setUrl("http://iformall.com"); | |||
| appUniformMsg.setMpAppId(weappInfo.getAuthorizerAppid()); | |||
| appUniformMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMaTemplateData("first", "商家"+merchant.getName()+"的券被核销", "#173177"), | |||
| new WxMaTemplateData("keyword1", EnumCouponType.getEnum(coupon.getType()).getMessage(), "#173177"), | |||
| new WxMaTemplateData("keyword2", couponOrder.getId().toString(), "#173177"), | |||
| new WxMaTemplateData("keyword3", dateFormat.format(new Date()), "#173177"), | |||
| new WxMaTemplateData("remark", "更多优惠等您来!", "#173177") | |||
| appUniformMsg.setDataList(Lists.newArrayList( | |||
| merchant.getName(), | |||
| EnumCouponType.getEnum(coupon.getType()).getMessage(), | |||
| couponOrder.getId().toString(), | |||
| dateFormat.format(new Date()), | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| mqBaseProducer.sendMessage(appUniformMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -676,8 +673,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| } | |||
| private void doVerifySuccessMsg(WxCouponOrder couponOrder, String formId, WxCoupon coupon, WxMerchant merchant, WxCUser user, SimpleDateFormat dateFormat, String couponDetail, String gotopage, String notes) { | |||
| SmartAppMsg smartAppMsg; /** | |||
| private void doVerifySuccessMsg(WxCouponOrder couponOrder, String formId, WxCoupon coupon, WxMerchant merchant, WxCUser user, SimpleDateFormat dateFormat, String couponDetail, String gotopage) { | |||
| SmartAppMsg smartAppMsg; | |||
| /** | |||
| * 核销成功消息 | |||
| * 核销金额 {{keyword1.DATA}} | |||
| * 商家名称 {{keyword2.DATA}} | |||
| @@ -695,15 +693,15 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| smartAppMsg.setGotopage(gotopage); | |||
| smartAppMsg.setTo(user.getOpenId()); | |||
| smartAppMsg.setFormId(formId); | |||
| smartAppMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMaTemplateData("keyword1", coupon.getPriceStr() + "元", "#173177"), | |||
| new WxMaTemplateData("keyword2", merchant.getName(), "#173177"), | |||
| new WxMaTemplateData("keyword3", coupon.getTitle(), "#173177"), | |||
| new WxMaTemplateData("keyword4", couponDetail, "#173177"), | |||
| new WxMaTemplateData("keyword5", coupon.getSalePriceStr() + "元", "#173177"), | |||
| new WxMaTemplateData("keyword6", dateFormat.format(new Date()), "#173177"), | |||
| new WxMaTemplateData("keyword7", notes, "#173177"))); | |||
| smartAppMsg.setEmphasisKeyword("keyword1.DATA"); | |||
| smartAppMsg.setDataList(Lists.newArrayList( | |||
| coupon.getPriceStr(), | |||
| merchant.getName(), | |||
| coupon.getTitle(), | |||
| couponDetail, | |||
| coupon.getSalePriceStr(), | |||
| dateFormat.format(new Date()), | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -730,12 +728,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| smartAppMsg.setTo(user.getOpenId()); | |||
| smartAppMsg.setReceiver(user.getOpenId()); | |||
| smartAppMsg.setFormId(formId); | |||
| smartAppMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMaTemplateData("keyword1", coupon.getTitle(), "#173177"), | |||
| new WxMaTemplateData("keyword2", dateFormat.format(new Date()), "#173177"), | |||
| new WxMaTemplateData("keyword3", "未知"), | |||
| new WxMaTemplateData("keyword4", couponDetail))); | |||
| smartAppMsg.setEmphasisKeyword("keyword1.DATA"); | |||
| smartAppMsg.setDataList(Lists.newArrayList( | |||
| coupon.getTitle(), | |||
| dateFormat.format(new Date()), | |||
| "核销失败", | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| mqBaseProducer.sendMessage(smartAppMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -288,14 +288,15 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| mpAppMsg.setMiniPagePath(gotopage); | |||
| mpAppMsg.setTenantId(couponOrder.getTenantId()); | |||
| mpAppMsg.setTemplateType(EnumTemplateType.GIFT_MESSAGE.getCode()); | |||
| mpAppMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMpTemplateData("first", "您有新的惊喜,请点详情查看", "#173177"), | |||
| new WxMpTemplateData("keyword1", String.valueOf(couponOrder.getOrderId()), "#173177"), | |||
| new WxMpTemplateData("keyword2", couponOrder.getId().toString(), "#173177"), | |||
| new WxMpTemplateData("keyword3", send.getTitle(), "#173177"), | |||
| new WxMpTemplateData("keyword4", dateFormat.format(couponOrder.getExpiredTime()), "#173177"), | |||
| new WxMpTemplateData("keyword5", "1", "#173177"), | |||
| new WxMpTemplateData("remark", "更多惊喜等您来!", "#173177") | |||
| mpAppMsg.setDataList(Lists.newArrayList( | |||
| user.getNickName(), | |||
| String.valueOf(couponOrder.getOrderId()), | |||
| couponOrder.getId().toString(), | |||
| send.getTitle(), | |||
| dateFormat.format(couponOrder.getExpiredTime()), | |||
| "1", | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| @@ -319,16 +320,15 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| appUniformMsg.setTo(user.getOpenId()); | |||
| appUniformMsg.setTemplateType(EnumTemplateType.GIFT_MESSAGE.getCode()); | |||
| appUniformMsg.setPagePath(gotopage); | |||
| appUniformMsg.setUrl("http://iformall.com"); | |||
| appUniformMsg.setMpAppId(weappInfo.getAuthorizerAppid()); | |||
| appUniformMsg.setTemplateDataList(Lists.newArrayList( | |||
| new WxMaTemplateData("first", "您有新的惊喜,请点详情查看", "#173177"), | |||
| new WxMaTemplateData("keyword1", String.valueOf(couponOrder.getOrderId()), "#173177"), | |||
| new WxMaTemplateData("keyword2", couponOrder.getId().toString(), "#173177"), | |||
| new WxMaTemplateData("keyword3", send.getTitle(), "#173177"), | |||
| new WxMaTemplateData("keyword4", dateFormat.format(couponOrder.getExpiredTime()), "#173177"), | |||
| new WxMaTemplateData("keyword5", "1", "#173177"), | |||
| new WxMaTemplateData("remark", "更多惊喜等您来!", "#173177") | |||
| appUniformMsg.setDataList(Lists.newArrayList( | |||
| user.getNickName(), | |||
| String.valueOf(couponOrder.getOrderId()), | |||
| couponOrder.getId().toString(), | |||
| send.getTitle(), | |||
| dateFormat.format(couponOrder.getExpiredTime()), | |||
| "1", | |||
| user.getNickName() | |||
| )); | |||
| try { | |||
| mqBaseProducer.sendMessage(appUniformMsg, EnumMsgMqTopic.DEFAULT.getCode(),EnumMsgMqTag.DEFAULT.getCode(),EnumMsgMqKey.DEFAULT.getCode()); | |||
| @@ -1,5 +1,9 @@ | |||
| package com.iformall.service.msg.impl; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.msg.BaseMsg; | |||
| @@ -9,12 +13,17 @@ import com.iformall.mapper.WxTemplateMsgMapper; | |||
| import com.iformall.service.msg.MsgSendService; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| import me.chanjar.weixin.mp.api.WxMpService; | |||
| import me.chanjar.weixin.mp.bean.template.WxMpTemplate; | |||
| import me.chanjar.weixin.mp.bean.template.WxMpTemplateData; | |||
| import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| * 发送微信公众号模板消息 | |||
| * @author Stormeye | |||
| @@ -50,6 +59,21 @@ public class SendMpMsgServiceImpl implements MsgSendService { | |||
| throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| } | |||
| JSONObject customParam = JSON.parseObject(msg.getCustomParam()); | |||
| String url = customParam.getString("url"); | |||
| // build template data list | |||
| List<WxMpTemplateData> dataTempList = new ArrayList<>(); | |||
| List<String> dataList = mpAppMsg.getDataList(); | |||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||
| 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)); | |||
| WxMpTemplateData templateData = new WxMpTemplateData(key, value); | |||
| dataTempList.add(templateData); | |||
| } | |||
| WxMpTemplateMessage.MiniProgram miniprogram = new WxMpTemplateMessage.MiniProgram(); | |||
| miniprogram.setAppid(mpAppMsg.getMiniAppId()); | |||
| miniprogram.setPagePath(mpAppMsg.getMiniPagePath()); | |||
| @@ -58,7 +82,7 @@ public class SendMpMsgServiceImpl implements MsgSendService { | |||
| .toUser(mpAppMsg.getTo()) | |||
| .templateId(msg.getTemplateId()) | |||
| .miniProgram(miniprogram) | |||
| .data(mpAppMsg.getTemplateDataList()) | |||
| .data(dataTempList) | |||
| .build(); | |||
| String retStr = wxMpService.getTemplateMsgService().sendTemplateMsg(mpTemplateMessage); | |||
| logger.info(retStr); | |||
| @@ -1,7 +1,11 @@ | |||
| package com.iformall.service.msg.impl; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateMessage; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.msg.BaseMsg; | |||
| @@ -16,6 +20,8 @@ import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| @@ -62,20 +68,29 @@ public class SendSmartAppMsgServiceImpl implements MsgSendService { | |||
| logger.error("找不到模板Id"); | |||
| throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| } | |||
| /** | |||
| * 核销失败 | |||
| * 商品名称 {{keyword1.DATA}} | |||
| * 核销时间 {{keyword2.DATA}} | |||
| * 失败原因 {{keyword3.DATA}} | |||
| * 备注 {{keyword4.DATA}} | |||
| */ | |||
| JSONObject customParam = JSON.parseObject(msg.getCustomParam()); | |||
| String url = customParam.getString("url"); | |||
| String emphasis = customParam.getString("emphasis"); | |||
| // build template data list | |||
| List<WxMaTemplateData> dataTempList = new ArrayList<>(); | |||
| List<String> dataList = smartAppMsg.getDataList(); | |||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||
| 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(smartAppMsg.getTemplateDataList()) | |||
| .data(dataTempList) | |||
| .templateId(msg.getTemplateId()) | |||
| .emphasisKeyword(smartAppMsg.getEmphasisKeyword()) | |||
| .emphasisKeyword(emphasis) | |||
| .build(); | |||
| wxMaService.getMsgService().sendTemplateMsg(templateMessage); | |||
| } | |||
| @@ -1,7 +1,11 @@ | |||
| package com.iformall.service.msg.impl; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaTemplateData; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.msg.AppUniformMsg; | |||
| import com.iformall.domain.po.msg.BaseMsg; | |||
| @@ -18,6 +22,9 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| * 发送微信小程序-统一消息 | |||
| * @author Stormeye | |||
| @@ -52,6 +59,20 @@ public class SendWeappUniformMsgServiceImpl implements MsgSendService { | |||
| logger.error("找不到模板Id"); | |||
| throw new MallinkException(ErrorCode.TEMPLATE_NOT_FOUND); | |||
| } | |||
| JSONObject customParam = JSON.parseObject(msg.getCustomParam()); | |||
| String url = customParam.getString("url"); | |||
| // build template data list | |||
| List<WxMaTemplateData> dataTempList = new ArrayList<>(); | |||
| List<String> dataList = appUniformMsg.getDataList(); | |||
| JSONArray indexArr = customParam.getJSONArray("index"); | |||
| 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); | |||
| } | |||
| WxMaUniformMessage.MiniProgram miniprogram = new WxMaUniformMessage.MiniProgram(); | |||
| miniprogram.setAppid(appUniformMsg.getAppId()); | |||
| @@ -62,10 +83,10 @@ public class SendWeappUniformMsgServiceImpl implements MsgSendService { | |||
| .toUser(appUniformMsg.getTo()) | |||
| .appid(appUniformMsg.getMpAppId()) | |||
| .templateId(msg.getTemplateId()) | |||
| .url(appUniformMsg.getUrl()) | |||
| .url(url) | |||
| .miniProgram(miniprogram) | |||
| .formId(appUniformMsg.getFormId()) | |||
| .data(appUniformMsg.getTemplateDataList()) | |||
| .data(dataTempList) | |||
| .build(); | |||
| wxMaService.getMsgService().sendUniformMsg(uniformMessage); | |||
| } | |||