Commit 793ec24d by 吕明尚

优化会员等级滚动降级定时任务

parent 1f1cc81f
......@@ -344,6 +344,46 @@ public class RedisTask {
redisUtil.delete(o);
throw new BaseException("订单不存在!");
}
extracted(sOrder);
if (extracted(o, sOrders, sOrder)) return;
//更改订单状态
sOrder.setStatus(OrderStatusEnum.USED.getCode());
isOrderService.updateById(sOrder);
// 修改房间状态
SRoom room = roomService.getById(sOrder.getRoomId());
if (ObjectUtil.isNotEmpty(room)) {
room.setStatus(RoomStatusEnum.FREE.getValue());
room.setUpdateTime(new Date());
roomService.updateById(room);
}
//判断订单是否已经添加保洁记录
SCleanRecords cleanRecords = isCleanRecordsService.lastCleanByRoomId(sOrder.getRoomId());
if (ObjectUtils.isEmpty(cleanRecords) || cleanRecords.getStatus().compareTo(CleaningStatusEnum.UNCLEAN.getCode()) != 0) {
boolean b = isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId());
}
//删除redis中的值
redisUtil.delete(o);
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",
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
//延时3分钟断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), false, 0L,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
//当前时间加15分钟
Date date = DateUtil.offsetMinute(sOrder.getEndDate(), 15);
map.put("expirationTime", date.toString());
JSONObject json = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ROOM_EXPIRE_TIME.getValue() + sOrder.getOrderNo(), json.toString());
logger.debug("订单号为:" + sOrder.getOrderNo() + "的订单已结束,更改订单状态为已使用");
}
});
logger.debug("AutoAddSCleanRecords:自动添加保洁记录结束");
}
private void extracted(SOrder sOrder) {
//查询是否有上级
LambdaQueryWrapper<SharingActivities> sharingActivitiesLambdaQueryWrapper = new LambdaQueryWrapper<>();
sharingActivitiesLambdaQueryWrapper.eq(SharingActivities::getNewUid, sOrder.getConsumerId());
......@@ -447,45 +487,7 @@ public class RedisTask {
}
}
}
if (extracted(o, sOrders, sOrder)) return;
//更改订单状态
sOrder.setStatus(OrderStatusEnum.USED.getCode());
isOrderService.updateById(sOrder);
// 修改房间状态
SRoom room = roomService.getById(sOrder.getRoomId());
if (ObjectUtil.isNotEmpty(room)) {
room.setStatus(RoomStatusEnum.FREE.getValue());
room.setUpdateTime(new Date());
roomService.updateById(room);
}
//判断订单是否已经添加保洁记录
SCleanRecords cleanRecords = isCleanRecordsService.lastCleanByRoomId(sOrder.getRoomId());
if (ObjectUtils.isEmpty(cleanRecords) || cleanRecords.getStatus().compareTo(CleaningStatusEnum.UNCLEAN.getCode()) != 0) {
boolean b = isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId());
}
//删除redis中的值
redisUtil.delete(o);
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",
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
//延时3分钟断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), false, 0L,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
//当前时间加15分钟
Date date = DateUtil.offsetMinute(sOrder.getEndDate(), 15);
map.put("expirationTime", date.toString());
JSONObject json = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ROOM_EXPIRE_TIME.getValue() + sOrder.getOrderNo(), json.toString());
logger.debug("订单号为:" + sOrder.getOrderNo() + "的订单已结束,更改订单状态为已使用");
}
});
logger.debug("AutoAddSCleanRecords:自动添加保洁记录结束");
}
@XxlJob("autoRoomExpireTime")
public void autoRoomExpireTime() {
logger.debug("autoRoomExpireTime:房间15分钟续单开始");
......
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