Commit e387b1f9 by 吕明尚

在自动任务中增加续费声音提醒

parent 20128729
......@@ -40,6 +40,10 @@ public enum VoiceEnum {
return name + value;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
......
package share.quartz.task;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
......@@ -17,10 +20,9 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import share.common.core.redis.RedisUtil;
import share.common.enums.OrderStatusEnum;
import share.common.enums.OrderTypeEnum;
import share.common.enums.ReceiptRdeisEnum;
import share.common.enums.RoomStatusEnum;
import share.common.enums.*;
import share.common.exception.base.BaseException;
import share.system.domain.Device;
import share.system.domain.SOrder;
import share.system.domain.SRoom;
import share.system.service.*;
......@@ -54,6 +56,12 @@ public class RedisTask {
@Autowired
private ISRoomService roomService;
@Autowired
private MqttxService mqttxService;
@Autowired
private DeviceService deviceService;
public void AuToReceiptCode() {
//获取redis中所有以tuangou.receipt.prepare开头的key
......@@ -101,6 +109,50 @@ public class RedisTask {
//获取key对应的value
String value = redisUtil.get(String.valueOf(o));
JSONObject jsonObject = new JSONObject(value);
long expire = redisUtil.getExpire(o);
//判断时间是否在15分钟到14分钟
if (expire < 60 * 15 && expire > 60 * 14) {
//语音
String orderNo = jsonObject.getStr("orderNo");
SOrder sOrder = isOrderService.selectSOrderByOrderNo(orderNo);
//判断订单单是否存在
if (ObjectUtils.isEmpty(sOrder)) {
redisUtil.delete(o);
throw new BaseException("订单不存在!");
}
LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(Device::getRoomId, sOrder.getRoomId());
deviceLambdaQueryWrapper.eq(Device::getDevType, DeviceType.DEVICE_0001.getCode());
Device device = deviceService.getOne(deviceLambdaQueryWrapper);
if (ObjectUtils.isEmpty(device)) {
throw new BaseException("设备不存在!");
}
mqttxService.actionExecute(device.getDevId(), sOrder.getConsumerPhone(), VoiceEnum.RENEWAL_REMINDER1.getValue(),
DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
return;
}
//判断时间是否在5分钟到4分钟
if (expire < 60 * 5 && expire > 60 * 4) {
String orderNo = jsonObject.getStr("orderNo");
SOrder sOrder = isOrderService.selectSOrderByOrderNo(orderNo);
//判断订单单是否存在
if (ObjectUtils.isEmpty(sOrder)) {
redisUtil.delete(o);
throw new BaseException("订单不存在!");
}
LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(Device::getRoomId, sOrder.getRoomId());
deviceLambdaQueryWrapper.eq(Device::getDevType, DeviceType.DEVICE_0001.getCode());
Device device = deviceService.getOne(deviceLambdaQueryWrapper);
if (ObjectUtils.isEmpty(device)) {
throw new BaseException("设备不存在!");
}
mqttxService.actionExecute(device.getDevId(), sOrder.getConsumerPhone(), VoiceEnum.RENEWAL_REMINDER2.getValue(),
DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
DateUtil.format(DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1");
return;
}
Date expirationTime = jsonObject.getDate("expirationTime");
//判断是否过期
if (expirationTime.getTime() < new Date().getTime()) {
......@@ -109,7 +161,8 @@ public class RedisTask {
SOrder sOrder = isOrderService.selectSOrderByOrderNo(orderNo);
//判断订单单是否存在
if (ObjectUtils.isEmpty(sOrder)) {
return;
redisUtil.delete(o);
throw new BaseException("订单不存在!");
}
//查询当前门店房间下是否有续单
SOrder order = new SOrder();
......
......@@ -82,5 +82,5 @@ public interface DeviceMapper extends BaseMapper<Device>
int clearDeviceRoomId(Device device);
Device selectDeviceByRoomId(Long roomId);
List<Device> selectDeviceByRoomId(Long roomId);
}
......@@ -71,5 +71,5 @@ public interface DeviceService extends IService<Device>
List<Device> notRoomIdList(Device device);
List<Device> selectDeviceListByIds(List<Long> collect);
Device selectDeviceByRoomId(Long roomId);
List<Device> selectDeviceByRoomId(Long roomId);
}
......@@ -123,7 +123,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
}
@Override
public Device selectDeviceByRoomId(Long roomId) {
public List<Device> selectDeviceByRoomId(Long roomId) {
return deviceMapper.selectDeviceByRoomId(roomId);
}
......
......@@ -307,7 +307,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// 加入自动未支付自动取消队列
redisUtil.lPush(Constants.ORDER_AUTO_CANCEL_KEY, sOrder.getOrderNo());
}
save(sOrder);
if (response.getStatus().equals(YesNoEnum.yes.getFlag())) {
if (Objects.nonNull(request.getCouponId()) && request.getCouponId() != 0) {
SConsumerCoupon byId = consumerCouponService.getById(request.getCouponId());
......@@ -327,6 +326,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
sConsumptionRecords.setSign(SignEnum.BURDEN.getValue());
sConsumptionRecordsService.insertSConsumptionRecords(sConsumptionRecords);
}
save(sOrder);
return response;
}
......@@ -762,7 +762,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (Objects.isNull(sRoomVo)) {
throw new BaseException("房间不存在!");
}
Device one = deviceService.selectDeviceByRoomId(sOrder.getRoomId());
LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(Device::getRoomId, sOrder.getRoomId());
deviceLambdaQueryWrapper.eq(Device::getDevType, DeviceType.DEVICE_CCEE.getCode());
Device one = deviceService.getOne(deviceLambdaQueryWrapper);
if (Objects.isNull(one)) {
throw new BaseException("设备不存在!");
}
......
......@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import share.common.enums.DeviceType;
import share.common.enums.RoleTypeEnum;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils;
......@@ -231,7 +232,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
if (Objects.isNull(room)) {
throw new RuntimeException("房间不存在");
}
Device one = deviceService.selectDeviceByRoomId(id);
LambdaQueryWrapper<Device> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(Device::getRoomId, id);
deviceLambdaQueryWrapper.eq(Device::getDevType, DeviceType.DEVICE_CCEE.getCode());
Device one = deviceService.getOne(deviceLambdaQueryWrapper);
if (Objects.isNull(one)) {
throw new BaseException("设备不存在!");
}
......
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