Commit 948e7ff4 by 吕明尚

增加公众号订单模板通知,保洁模板通知

parent d9e410fe
...@@ -16,7 +16,6 @@ import share.system.request.WxBindingPhoneRequest; ...@@ -16,7 +16,6 @@ import share.system.request.WxBindingPhoneRequest;
import share.system.request.WxRegisterPhoneRequest; import share.system.request.WxRegisterPhoneRequest;
import share.system.response.LoginResponse; import share.system.response.LoginResponse;
import share.system.service.SConsumerCenterService; import share.system.service.SConsumerCenterService;
import share.system.service.SystemNotificationService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
......
...@@ -84,6 +84,9 @@ public class RedisTask { ...@@ -84,6 +84,9 @@ public class RedisTask {
@Autowired @Autowired
private RoomLabelService roomLabelService; private RoomLabelService roomLabelService;
@Autowired
private WechatNewService wechatNewService1;
//15分钟的常量 //15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15; final long FIFTEEN_MINUTES = 60 * 15;
...@@ -209,6 +212,8 @@ public class RedisTask { ...@@ -209,6 +212,8 @@ public class RedisTask {
if (!tiktok) { if (!tiktok) {
tiktokService.clientToken(); tiktokService.clientToken();
} }
wechatNewService.getPublicAccessToken();
} }
//自动添加保洁记录 //自动添加保洁记录
...@@ -264,6 +269,8 @@ public class RedisTask { ...@@ -264,6 +269,8 @@ public class RedisTask {
sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> { sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> {
// 循环发送短信提示门店保洁打扫卫生 // 循环发送短信提示门店保洁打扫卫生
smsService.sendSmsCleanRecordsRemind15(item.getPhone(), sStore, sRoom); smsService.sendSmsCleanRecordsRemind15(item.getPhone(), sStore, sRoom);
//公众号发送保洁工单派单通知
// wechatNewService.sendPublicTemplateMessage(finalSOrder,MessageReminderEnum.CLEANING,item.getId());
}); });
return; return;
} }
......
...@@ -89,7 +89,7 @@ public interface WechatNewService { ...@@ -89,7 +89,7 @@ public interface WechatNewService {
*/ */
Boolean sendPublicTemplateMessage(OfficialAccountTemplate templateMessage); Boolean sendPublicTemplateMessage(OfficialAccountTemplate templateMessage);
Boolean sendPublicTemplateMessage(SOrder byOrderNo, MessageReminderEnum messageReminderEnum); Boolean sendPublicTemplateMessage(SOrder byOrderNo, MessageReminderEnum messageReminderEnum, Long consumerId);
UserOpenIdVo getWechatUSERList(); UserOpenIdVo getWechatUSERList();
/** /**
......
...@@ -951,6 +951,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -951,6 +951,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (consumers.size() > 0) { if (consumers.size() > 0) {
consumers.forEach(o -> { consumers.forEach(o -> {
phones.add(o.getPhone()); phones.add(o.getPhone());
//公众号发送订单预订成功通知
// wechatNewService.sendPublicTemplateMessage(sOrder,MessageReminderEnum.ORDER_RESERVE,o.getId());
}); });
smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, room); smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, room);
} }
...@@ -1459,6 +1461,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1459,6 +1461,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (consumers.size() > 0) { if (consumers.size() > 0) {
consumers.forEach(o->{ consumers.forEach(o->{
phones.add(o.getPhone()); phones.add(o.getPhone());
//公众号发送订单预订成功通知
// wechatNewService.sendPublicTemplateMessage(sOrder,MessageReminderEnum.ORDER_RESERVE,o.getId());
}); });
smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, sRoom); smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, sRoom);
} }
......
...@@ -93,11 +93,11 @@ public class WechatNewServiceImpl implements WechatNewService { ...@@ -93,11 +93,11 @@ public class WechatNewServiceImpl implements WechatNewService {
} }
String appId = officialAccountConfig.getAppId(); String appId = officialAccountConfig.getAppId();
if (StrUtil.isBlank(appId)) { if (StrUtil.isBlank(appId)) {
throw new BaseException("微信小程序appId未设置"); throw new BaseException("微信公众号appId未设置");
} }
String secret = officialAccountConfig.getAppSecret(); String secret = officialAccountConfig.getAppSecret();
if (StrUtil.isBlank(secret)) { if (StrUtil.isBlank(secret)) {
throw new BaseException("微信小程序secret未设置"); throw new BaseException("微信公众号secret未设置");
} }
WeChatAccessTokenVo accessTokenVo = getAccessToken(appId, secret, "public"); WeChatAccessTokenVo accessTokenVo = getAccessToken(appId, secret, "public");
// 缓存accessToken // 缓存accessToken
...@@ -518,11 +518,13 @@ public class WechatNewServiceImpl implements WechatNewService { ...@@ -518,11 +518,13 @@ public class WechatNewServiceImpl implements WechatNewService {
if (ObjectUtil.isNull(data)) { if (ObjectUtil.isNull(data)) {
throw new BaseException("微信平台接口异常,没任何数据返回!"); throw new BaseException("微信平台接口异常,没任何数据返回!");
} }
if (data.containsKey("errcode") && !data.getString("errcode").equals("0")) { if (data.containsKey("errcode") && !data.getString("errcode").equals("0") && !data.getString("errcode").equals("40014")) {
if (data.containsKey("errmsg")) { if (data.containsKey("errmsg")) {
wxExceptionDispose(data, "微信公众号发送模板消息异常"); wxExceptionDispose(data, "微信公众号发送模板消息异常");
throw new BaseException("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg")); throw new BaseException("微信接口调用失败:" + data.getString("errcode") + data.getString("errmsg"));
} }
} else if (data.getString("errcode").equals("40014")) {
return sendPublicTemplateMessage(templateMessage);
} }
return Boolean.TRUE; return Boolean.TRUE;
} }
...@@ -575,7 +577,7 @@ public class WechatNewServiceImpl implements WechatNewService { ...@@ -575,7 +577,7 @@ public class WechatNewServiceImpl implements WechatNewService {
* 微信公众号发送模板消息 * 微信公众号发送模板消息
*/ */
@Override @Override
public Boolean sendPublicTemplateMessage(SOrder byOrderNo, MessageReminderEnum messageReminderEnum) { public Boolean sendPublicTemplateMessage(SOrder byOrderNo, MessageReminderEnum messageReminderEnum, Long consumerId) {
OfficialAccountTemplate officialAccountTemplate = new OfficialAccountTemplate(); OfficialAccountTemplate officialAccountTemplate = new OfficialAccountTemplate();
officialAccountTemplate.setAppid(weChatConfig.getAppId()); officialAccountTemplate.setAppid(weChatConfig.getAppId());
String pagepath = "/pages/orderResult/orderResult?orderNo=" + byOrderNo.getOrderNo(); String pagepath = "/pages/orderResult/orderResult?orderNo=" + byOrderNo.getOrderNo();
...@@ -583,6 +585,11 @@ public class WechatNewServiceImpl implements WechatNewService { ...@@ -583,6 +585,11 @@ public class WechatNewServiceImpl implements WechatNewService {
HashMap<String, SendTemplateMessageItemVo> data = new HashMap<>(); HashMap<String, SendTemplateMessageItemVo> data = new HashMap<>();
SStore sStore = storeService.getById(byOrderNo.getStoreId()); SStore sStore = storeService.getById(byOrderNo.getStoreId());
SRoomVo sRoomVo = roomService.selectSRoomById(byOrderNo.getRoomId()); SRoomVo sRoomVo = roomService.selectSRoomById(byOrderNo.getRoomId());
SConsumerToken tokenByUserId = sConsumerTokenService.getTokenByUserId(consumerId);
if (StringUtils.isEmpty(tokenByUserId.getOpenId())) {
return false;
}
officialAccountTemplate.setTouser(tokenByUserId.getOpenId());
//拼接开始和结束时间 //拼接开始和结束时间
Date preStartDate = byOrderNo.getPreStartDate(); Date preStartDate = byOrderNo.getPreStartDate();
Date preEndDate = byOrderNo.getPreEndDate(); Date preEndDate = byOrderNo.getPreEndDate();
......
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