Commit 901111fd by 吕明尚

添加微信小程序订阅消息

parent c651553d
package share.common.enums;
public enum MessageReminderEnum {
//预约到期通知:oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8,订单开始通知:K8fbcKVq46w9o7Ekpesn74WPjwxnbso947YZiYBQw9c,订单结单通知:HB2_moQRQrXC2cKw6zE08NU3AQO9Ggj3aAOg0lIgecg
RESERVER("预约到期通知", "oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8"),
START("订单开始通知", "K8fbcKVq46w9o7Ekpesn74RThj_Yw6hFNwA-A5L3XA0"),
END("订单结单通知", "HB2_moQRQrXC2cKw6zE08NU3AQO9Ggj3aAOg0lIgecg");
RESERVER("预约成功通知", "UkvsRnZkZB_w3MqXPbRhi4jEk8ML4N9PWT3rnd3Bhxg", "若因事迟到,迟到部分时间不延期不退还"),
START("订单开始通知", "K8fbcKVq46w9o7Ekpesn70wK3mYjXqdSfFUth4AufqU", "您的凑角房间使用订单即将开始"),
END("订单结单通知", "HB2_moQRQrXC2cKw6zE08FF8UZJ5ue1h_qXZhvOkacc", "您的房间使用时间还剩15分钟");
private String name;
private String value;
private String tips;
MessageReminderEnum() {
}
MessageReminderEnum(String name, String value) {
MessageReminderEnum(String name, String value, String tips) {
this.name = name;
this.value = value;
this.tips = tips;
}
public String getname() {
public String getName() {
return name;
}
public void setname(String name) {
public void setName(String name) {
this.name = name;
}
......@@ -31,4 +33,12 @@ public enum MessageReminderEnum {
public void setValue(String value) {
this.value = value;
}
public String getTips() {
return tips;
}
public void setTips(String tips) {
this.tips = tips;
}
}
......@@ -76,9 +76,9 @@ public class OrderTask {
final int ZERO = 0;
//10分钟的常量
final long TEN_MINUTES = 60 * 10;
final long TEN_MINUTES = 60 * 30;
//9分钟的常量
final long NINE_MINUTES = 60 * 9;
final long NINE_MINUTES = 60 * 29;
//15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15;
//14分钟的常量
......@@ -248,12 +248,11 @@ public class OrderTask {
logger.info("订单号为:" + jsonObject.getStr("orderNo") + "的订单不存在");
return;
}
//时间到期前10分钟到9分
//时间到期前30分钟到29分
long expire = (expirationTime.getTime() - new Date().getTime()) / 1000;
// if (expire < TEN_MINUTES && expire > NINE_MINUTES) {
// SOrder byOrderNo = orderService.getByOrderNo(String.valueOf(orderNo));
// wechatNewService.sendMiniSubscribeMessage(byOrderNo, MessageReminderEnum.RESERVER);
// }
if (expire < TEN_MINUTES && expire > NINE_MINUTES) {
wechatNewService.sendMiniSubscribeMessage(byOrderNo, MessageReminderEnum.START);
}
//判断时间是否在15分钟到14分钟
if (expire < FIFTEEN_MINUTES && expire > FOURTEEN_MINUTES) {
SStore sStore = storeService.getById(byOrderNo.getStoreId());
......@@ -291,10 +290,6 @@ public class OrderTask {
room.setUpdateTime(new Date());
}
});
// logger.info("开始发送消息!!!!");
// //推送订单开始预定消息
// wechatNewService.sendMiniSubscribeMessage(item, MessageReminderEnum.START);
// logger.info("发送消息结束!!!!");
logger.info("开始通电!!!!");
//到达预定时间进行通电
deviceOpService.openOrCloseDevice(item.getRoomId(), item.getConsumerPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), false, ZERO);
......
......@@ -226,6 +226,8 @@ public class RedisTask {
SRoom sRoom = sRoomList.stream().filter(item -> item.getId().equals(sOrder.getRoomId())).findFirst().orElse(null);
// 通知用户
smsService.sendSmsOrderEndRemind(sOrder.getConsumerPhone(), sStore, sRoom);
//推送订单结束消息
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.END);
//通知保洁人员
sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> {
// 循环发送短信提示门店保洁打扫卫生
......@@ -263,8 +265,6 @@ public class RedisTask {
boolean b = isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId());
//删除redis中的值
redisUtil.delete(o);
//推送订单结束消息
// wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.END);
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getCode(),
DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
......
......@@ -990,7 +990,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
device1.setRoomId(sOrder.getRoomId());
device1.setDevType(DeviceType.DEVICE_0001.getCode());
redisUtils.delete(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo());
// wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.START);
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
//开门、取电
deviceOpService.openDoor(sRoomVo.getId(), sOrder.getConsumerPhone());
//语音
......
......@@ -529,7 +529,9 @@ public class WechatNewServiceImpl implements WechatNewService {
public Boolean sendMiniSubscribeMessage(SOrder byOrderNo, MessageReminderEnum messageReminderEnum) {
//发送模板消息 预约提醒到期
TemplateMessageVo templateMessageVo = new TemplateMessageVo();
String url = "https://www.coujio.com/front-api/order/" + byOrderNo.getOrderNo();
// String url = "https://www.coujio.com/front-api/order/" + byOrderNo.getOrderNo();
//测试页面
String url = "/pages/orderResult/orderResult?orderNo=" + byOrderNo.getOrderNo();
templateMessageVo.setPage(url);
templateMessageVo.setMiniprogram_state("trial");
HashMap<String, SendTemplateMessageItemVo> data = new HashMap<>();
......@@ -543,21 +545,17 @@ public class WechatNewServiceImpl implements WechatNewService {
String preEndDateStr = DateUtil.format(preEndDate, DatePattern.NORM_DATETIME_MINUTE_FORMATTER);
SConsumerToken tokenByUserId = sConsumerTokenService.getTokenByUserId(byOrderNo.getConsumerId());
String date = preStartDateStr + "~" + preEndDateStr;
String address = sStore.getAddress();
if (address.length() > 20) {
address = address.substring(0, 20);
}
templateMessageVo.setTouser(tokenByUserId.getToken());
if (messageReminderEnum.equals(MessageReminderEnum.RESERVER)) {
templateMessageVo.setTemplate_id(MessageReminderEnum.RESERVER.getValue());
//添加门店名称
data.put("thing4", new SendTemplateMessageItemVo("武汉" + sStore.getName()));
//订单门店
data.put("thing5", new SendTemplateMessageItemVo("武汉" + sStore.getName()));
//服务名称
data.put("thing7", new SendTemplateMessageItemVo(sRoomVo.getName()));
//预约时间
data.put("date3", new SendTemplateMessageItemVo(date));
//地址
data.put("thing5", new SendTemplateMessageItemVo(address));
data.put("thin6", new SendTemplateMessageItemVo(sRoomVo.getName()));
//订单时间
data.put("time7", new SendTemplateMessageItemVo(date));
//温馨提示
data.put("thing4", new SendTemplateMessageItemVo(MessageReminderEnum.RESERVER.getTips()));
} else if (messageReminderEnum.equals(MessageReminderEnum.START)) {
templateMessageVo.setTemplate_id(MessageReminderEnum.START.getValue());
//预约门店
......@@ -566,10 +564,8 @@ public class WechatNewServiceImpl implements WechatNewService {
data.put("thing7", new SendTemplateMessageItemVo(sRoomVo.getName()));
//预约时间
data.put("time8", new SendTemplateMessageItemVo(date));
//地址
data.put("thing9", new SendTemplateMessageItemVo(address));
//订单金额
data.put("amount4", new SendTemplateMessageItemVo(String.valueOf(byOrderNo.getPackPrice())));
//温馨提示
data.put("thing5", new SendTemplateMessageItemVo(MessageReminderEnum.START.getTips()));
} else if (messageReminderEnum.equals(MessageReminderEnum.END)) {
templateMessageVo.setTemplate_id(MessageReminderEnum.END.getValue());
//订单门店
......@@ -578,8 +574,8 @@ public class WechatNewServiceImpl implements WechatNewService {
data.put("thing6", new SendTemplateMessageItemVo(sRoomVo.getName()));
//订单时间
data.put("time7", new SendTemplateMessageItemVo(date));
//地址
data.put("thing8", new SendTemplateMessageItemVo(address));
//温馨提示
data.put("thing4", new SendTemplateMessageItemVo(MessageReminderEnum.END.getTips()));
}
templateMessageVo.setData(data);
return sendMiniSubscribeMessage(templateMessageVo);
......
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