Commit 90ac1a09 by 吕明尚

在自动任务中增加订阅消息推送

parent da387aba
...@@ -53,11 +53,7 @@ ...@@ -53,11 +53,7 @@
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>5.8.16</version> <version>5.8.16</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>4.5.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -6,13 +6,16 @@ import cn.hutool.core.date.LocalDateTimeUtil; ...@@ -6,13 +6,16 @@ import cn.hutool.core.date.LocalDateTimeUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import share.system.config.WxMaProperties;
import share.system.domain.vo.SendTemplateMessageItemVo;
import share.system.domain.vo.TemplateMessageVo;
import share.system.service.WechatNewService;
import share.system.util.WXMsgPushUtils; import share.system.util.WXMsgPushUtils;
import share.web.core.config.WxMaProperties;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -63,6 +66,22 @@ public class WxMsgPushController { ...@@ -63,6 +66,22 @@ public class WxMsgPushController {
@GetMapping("/getOpenId") @GetMapping("/getOpenId")
public void getOpenId(String openId) throws Exception { public void getOpenId(String openId) throws Exception {
// HashMap<String, SendTemplateMessageItemVo> data = new HashMap<>();
// TemplateMessageVo templateMessageVo = new TemplateMessageVo();
// templateMessageVo.setTouser(openId);
// templateMessageVo.setTemplate_id("oTc000e4NHkoc7v9OLBZiwM6Q6SFzguemrx6d0iuVS8");
// templateMessageVo.setUrl("http://www.baidu.com");
// data.put("thing4", new SendTemplateMessageItemVo("预约门店"));
// data.put("thing7", new SendTemplateMessageItemVo("服务名称"));
// data.put("date3", new SendTemplateMessageItemVo(LocalDateTimeUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss")));
// data.put("thing5", new SendTemplateMessageItemVo("地址"));
// templateMessageVo.setData(data);
// log.info("开始发送消息!!!!");
// Boolean b = wechatNewService.sendMiniSubscribeMessage(templateMessageVo);
// if(b){
// log.info("消息发送成功!!!!");
// }
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("thing4", "预约门店"); map.put("thing4", "预约门店");
map.put("thing7", "服务名称"); map.put("thing7", "服务名称");
......
...@@ -16,10 +16,8 @@ import share.common.constant.Constants; ...@@ -16,10 +16,8 @@ import share.common.constant.Constants;
import share.common.core.redis.RedisUtil; import share.common.core.redis.RedisUtil;
import share.common.enums.*; import share.common.enums.*;
import share.common.exception.base.BaseException; import share.common.exception.base.BaseException;
import share.system.domain.SConsumer; import share.system.domain.*;
import share.system.domain.SConsumerCoupon; import share.system.domain.vo.TemplateMessageVo;
import share.system.domain.SOrder;
import share.system.domain.SRoom;
import share.system.service.*; import share.system.service.*;
import java.util.*; import java.util.*;
...@@ -63,6 +61,10 @@ public class OrderTask { ...@@ -63,6 +61,10 @@ public class OrderTask {
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Autowired
private WechatNewService wechatNewService;
final int ZERO = 0; final int ZERO = 0;
//10分钟的常量 //10分钟的常量
final long TEN_MINUTES = 60 * 10; final long TEN_MINUTES = 60 * 10;
...@@ -227,7 +229,8 @@ public class OrderTask { ...@@ -227,7 +229,8 @@ public class OrderTask {
//时间到期前10分钟到9分 //时间到期前10分钟到9分
long expire = (expirationTime.getTime() - new Date().getTime()) / 1000; long expire = (expirationTime.getTime() - new Date().getTime()) / 1000;
if (expire < TEN_MINUTES && expire > NINE_MINUTES) { if (expire < TEN_MINUTES && expire > NINE_MINUTES) {
SOrder byOrderNo = orderService.getByOrderNo(String.valueOf(o));
wechatNewService.sendMiniSubscribeMessage(byOrderNo, MessageReminderEnum.RESERVER)
} }
if (expirationTime.getTime() < new Date().getTime()) { if (expirationTime.getTime() < new Date().getTime()) {
sOrders.add(orderService.getByOrderNo(String.valueOf(o))); sOrders.add(orderService.getByOrderNo(String.valueOf(o)));
...@@ -255,6 +258,8 @@ public class OrderTask { ...@@ -255,6 +258,8 @@ public class OrderTask {
room.setUpdateTime(new Date()); room.setUpdateTime(new Date());
} }
}); });
//推送订单开始预定消息
wechatNewService.sendMiniSubscribeMessage(item, MessageReminderEnum.START);
//到达预定时间进行通电 //到达预定时间进行通电
deviceOpService.openOrCloseDevice(item.getRoomId(), item.getConsumerPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), false, ZERO); deviceOpService.openOrCloseDevice(item.getRoomId(), item.getConsumerPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), false, ZERO);
} }
......
...@@ -47,6 +47,9 @@ public class RedisTask { ...@@ -47,6 +47,9 @@ public class RedisTask {
@Autowired @Autowired
private DeviceOpService deviceOpService; private DeviceOpService deviceOpService;
@Autowired
private WechatNewService wechatNewService;
//15分钟的常量 //15分钟的常量
final long FIFTEEN_MINUTES = 60 * 15; final long FIFTEEN_MINUTES = 60 * 15;
//14分钟的常量 //14分钟的常量
...@@ -158,6 +161,8 @@ public class RedisTask { ...@@ -158,6 +161,8 @@ public class RedisTask {
if (b) { if (b) {
//删除redis中的值 //删除redis中的值
redisUtil.delete(o); redisUtil.delete(o);
//推送订单结束消息
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.END);
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getCode(), deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.SEND_CUSTOMER.getCode(),
DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN), DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1"); DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
......
package share.web.core.config; package share.system.config;
import cn.binarywang.wx.miniapp.api.WxMaService; import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
......
package share.web.core.config; package share.system.config;
import lombok.Data; import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
......
package share.system.service; package share.system.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import share.common.enums.MessageReminderEnum;
import share.system.domain.SOrder;
import share.system.domain.vo.*; import share.system.domain.vo.*;
import share.system.response.WeChatJsSdkConfigResponse; import share.system.response.WeChatJsSdkConfigResponse;
...@@ -94,6 +96,8 @@ public interface WechatNewService { ...@@ -94,6 +96,8 @@ public interface WechatNewService {
*/ */
Boolean sendMiniSubscribeMessage(TemplateMessageVo templateMessage); Boolean sendMiniSubscribeMessage(TemplateMessageVo templateMessage);
Boolean sendMiniSubscribeMessage(SOrder byOrderNo, MessageReminderEnum messageReminderEnum);
/** /**
* 获取微信公众号自定义菜单配置 * 获取微信公众号自定义菜单配置
* (使用本自定义菜单查询接口可以获取默认菜单和全部个性化菜单信息) * (使用本自定义菜单查询接口可以获取默认菜单和全部个性化菜单信息)
......
...@@ -347,6 +347,11 @@ public class QPServiceImpl implements QPService { ...@@ -347,6 +347,11 @@ public class QPServiceImpl implements QPService {
} }
/**
* 适用店铺查询接口
*
* @return
*/
@Override @Override
public List<CustomerKeyShopScopeResponseEntity> scope() { public List<CustomerKeyShopScopeResponseEntity> scope() {
Boolean b = redisUtil.exists(ReceiptRdeisEnum.MT_SESSION_KEY.getValue()); Boolean b = redisUtil.exists(ReceiptRdeisEnum.MT_SESSION_KEY.getValue());
......
...@@ -93,7 +93,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -93,7 +93,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private ISConsumptionRecordsService sConsumptionRecordsService; private ISConsumptionRecordsService sConsumptionRecordsService;
@Autowired @Autowired
private MqttxService mqttxService; private WechatNewService wechatNewService;
/** /**
* 查询订单 * 查询订单
...@@ -335,6 +335,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -335,6 +335,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sConsumptionRecords.setPayType(PayTypeEnum.WECHAT.getName()); sConsumptionRecords.setPayType(PayTypeEnum.WECHAT.getName());
sConsumptionRecords.setSign(SignEnum.BURDEN.getValue()); sConsumptionRecords.setSign(SignEnum.BURDEN.getValue());
sConsumptionRecordsService.insertSConsumptionRecords(sConsumptionRecords); sConsumptionRecordsService.insertSConsumptionRecords(sConsumptionRecords);
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtils.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} }
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) { if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
sOrder.setStartDate(sOrder.getPreStartDate()); sOrder.setStartDate(sOrder.getPreStartDate());
...@@ -651,7 +656,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -651,7 +656,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map.put("expirationTime", sOrder.getEndDate().toString()); map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map); JSONObject jsonObject = new JSONObject(map);
redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString()); redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} else { } else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo()); map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString()); map.put("expirationTime", sOrder.getPreStartDate().toString());
......
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