Commit 948e7ff4 by 吕明尚

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

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