Commit c9c1bc98 by 吕明尚

修改模版分享页面跳转逻辑

parent 5b922a0e
......@@ -508,7 +508,13 @@ public class WechatNewServiceImpl implements WechatNewService {
*/
@Override
public Boolean sendPublicTemplateMessage(OfficialAccountTemplate templateMessage) {
String accessToken = getPublicAccessToken();
boolean exists = redisUtil.exists(WeChatConstants.REDIS_WECAHT_PUBLIC_ACCESS_TOKEN_KEY);
String accessToken = null;
if (exists) {
accessToken = redisUtil.get(WeChatConstants.REDIS_WECAHT_PUBLIC_ACCESS_TOKEN_KEY).toString();
} else {
accessToken = getPublicAccessToken();
}
String url = StrUtil.format(WeChatConstants.WECHAT_PUBLIC_SEND_TEMPLATE_URL, accessToken);
JSONObject jsonData = JSONObject.parseObject(JSONObject.toJSONString(templateMessage));
String result = restTemplateUtil.postJsonData(url, jsonData);
......@@ -516,14 +522,15 @@ public class WechatNewServiceImpl implements WechatNewService {
if (ObjectUtil.isNull(data)) {
throw new BaseException("微信平台接口异常,没任何数据返回!");
}
if (data.containsKey("errcode") && !data.getString("errcode").equals("0") && !data.getString("errcode").equals("40014")) {
if (data.containsKey("errcode") && !data.getString("errcode").equals("0") && !data.getString("errcode").equals("40014") && !data.getString("errcode").equals("40001")) {
if (data.containsKey("errmsg")) {
wxExceptionDispose(data, "微信公众号发送模板消息异常");
// throw new BaseException("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg"));
logger.error("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg"));
}
} else if (data.getString("errcode").equals("40014")) {
} else if (data.getString("errcode").equals("40014") || data.getString("errcode").equals("40001")) {
getPublicAccessToken();
return sendPublicTemplateMessage(templateMessage);
}
return Boolean.TRUE;
......@@ -579,10 +586,6 @@ public class WechatNewServiceImpl implements WechatNewService {
@Override
public Boolean sendPublicTemplateMessage(SOrder byOrderNo, MessageReminderEnum messageReminderEnum, Long consumerId) {
OfficialAccountTemplate officialAccountTemplate = new OfficialAccountTemplate();
Miniprogram miniprogram = new Miniprogram();
miniprogram.setAppid(weChatConfig.getAppId());
miniprogram.setPagepath("/pages/orderResult/orderResult?orderNo=" + byOrderNo.getOrderNo() + "&share=share");
officialAccountTemplate.setMiniprogram(miniprogram);
HashMap<String, SendTemplateMessageItemVo> data = new HashMap<>();
SStore sStore = storeService.getById(byOrderNo.getStoreId());
SRoomVo sRoomVo = roomService.selectSRoomById(byOrderNo.getRoomId());
......@@ -612,6 +615,9 @@ public class WechatNewServiceImpl implements WechatNewService {
//预约时间
data.put("time1", new SendTemplateMessageItemVo(preEndDateStr));
} else if (messageReminderEnum.equals(MessageReminderEnum.ORDER_RESERVE)) {
Miniprogram miniprogram = new Miniprogram();
miniprogram.setAppid(weChatConfig.getAppId());
miniprogram.setPagepath("/pages/orderResult/orderResult?orderNo=" + byOrderNo.getOrderNo() + "&share=share");
officialAccountTemplate.setTemplate_id(MessageReminderEnum.ORDER_RESERVE.getValue());
//门店名称
data.put("thing2", new SendTemplateMessageItemVo("武汉" + sStore.getName() + "(" + sRoomVo.getName() + ")"));
......@@ -623,6 +629,7 @@ public class WechatNewServiceImpl implements WechatNewService {
data.put("phrase11", new SendTemplateMessageItemVo(OrderTypeEnum.getNameByCode(byOrderNo.getOrderType())));
//商品名称
data.put("thing21", new SendTemplateMessageItemVo(msg));
officialAccountTemplate.setMiniprogram(miniprogram);
}
officialAccountTemplate.setData(data);
return sendPublicTemplateMessage(officialAccountTemplate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment