Commit b2380b31 by 吕明尚

Merge branch 'refs/heads/dev' into test

parents 89cf7903 97abafa3
...@@ -1636,119 +1636,146 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1636,119 +1636,146 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
SOrder order = getOne(queryWrapper); SOrder order = getOne(queryWrapper);
if (ObjectUtil.isNotEmpty(order)) { if (ObjectUtil.isNotEmpty(order)) {
baseMapper.updateSOrder(sOrder); baseMapper.updateSOrder(sOrder);
//延迟5秒
try {
// 延迟 5 秒
Thread.sleep(5000);
} catch (InterruptedException e) {
// 如果线程被中断,这里可以处理异常
e.printStackTrace();
}
logger.debug("订单:" + sOrder.getOrderNo() + "和订单:" + order.getOrderNo() + "预约时间有干涉"); logger.debug("订单:" + sOrder.getOrderNo() + "和订单:" + order.getOrderNo() + "预约时间有干涉");
//退款 //退款
AdminRefundRequest refundRequest = new AdminRefundRequest(); // AdminRefundRequest refundRequest = new AdminRefundRequest();
refundRequest.setOrderNo(sOrder.getOrderNo()); // refundRequest.setOrderNo(sOrder.getOrderNo());
refundRequest.setAmount(sOrder.getPayPrice()); // refundRequest.setAmount(sOrder.getPayPrice());
refundRequest.setIsClean(YesNoEnum.no.getIndex()); // refundRequest.setIsClean(YesNoEnum.no.getIndex());
refundRequest.setRefundCoupon(YesNoEnum.yes.getIndex()); // refundRequest.setRefundCoupon(YesNoEnum.yes.getIndex());
refundRequest.setRefundReason("当前订单:" + sOrder.getOrderNo() + "和订单:" + order.getOrderNo() + "预约时间有干涉"); // refundRequest.setRefundReason("当前订单:" + sOrder.getOrderNo() + "和订单:" + order.getOrderNo() + "预约时间有干涉");
int i = sOrderService.refundOp(refundRequest); // int i = sOrderService.refundOp(refundRequest);
if (i == 1) { OrderRefundRequest request = new OrderRefundRequest();
sOrderService.removeById(sOrder); request.setOrderNo(sOrder.getOrderNo());
} request.setAmount(sOrder.getPayPrice());
return; request.setApprovalStatus(YesNoEnum.yes.getIndex());
} request.setRefundReason("当前订单:" + sOrder.getOrderNo() + "和订单:" + order.getOrderNo() + "预约时间有干涉");
boolean isRefund = orderRefundService.refund(request, sOrder);
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) { if (isRefund) {
SRoom room = roomService.getById(sOrder.getRoomId()); // 删除redis 缓存信息,防止退款订单自动开始及给用户发送提示短信
if (room.getStatus().equals(RoomStatusEnum.FREE.getValue())) { redisUtil.delete(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo());
room.setStatus(RoomStatusEnum.HOLD.getValue()); redisUtil.delete(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo());
roomService.updateById(room); //查询是否有使用中的订单
} LambdaQueryWrapper<SOrder> wrapper = new LambdaQueryWrapper<>();
SCleanRecords sCleanRecords = isCleanRecordsService.getOne(new LambdaQueryWrapper<SCleanRecords>() wrapper.eq(SOrder::getRoomId, sOrder.getRoomId());
.eq(SCleanRecords::getRoomId, sOrder.getRoomId()) wrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
.ne(SCleanRecords::getStatus, CleaningStatusEnum.CLEANED.getCode()) List<SOrder> list = baseMapper.selectList(wrapper);
); if (CollectionUtils.isEmpty(list)) {
if (ObjectUtil.isNotEmpty(sCleanRecords)) { //房间断电
sCleanRecords.setStartDate(new Date()); deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.CUT_ELECTRIC.getCode(), true, 5,
sCleanRecords.setEndDate(new Date()); DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
sCleanRecords.setStatus(CleaningStatusEnum.CLEANED.getCode());
isCleanRecordsService.updateById(sCleanRecords);
}
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
sOrder.setStartDate(sOrder.getPreStartDate());
sOrder.setEndDate(sOrder.getPreEndDate());
sOrder.setArrivalTime(new Date());
sOrder.setStatus(OrderStatusEnum.INUSE.getCode());
} else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
}
if (sOrder.getIsDelete().equals(YesNoEnum.yes.getIndex()) && sOrder.getPayStatus().equals(YesNoEnum.yes.getIndex())) {
sOrder.setIsDelete(YesNoEnum.no.getIndex());
}
creatExtracted(consumerWallet, sOrder, consumerMember);
baseMapper.updateSOrder(sOrder);
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getEndDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
} else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
}
Long couponId = sOrder.getCouponId();
SStore sStore = storeService.getById(sOrder.getStoreId());
SRoom sRoom = roomService.getById(sOrder.getRoomId());
if (couponId != null && couponId > 0) {
SConsumerCoupon consumerCoupon = consumerCouponService.getById(couponId);
if (ObjectUtil.isNotEmpty(consumerCoupon)) {
if (consumerCoupon.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
consumerCoupon.setUseDate(new Date());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
} }
refundExtracted(consumerWallet, sOrder, consumerMember);
} }
} } else {
//续费成功语音播报
if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) { if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.RENEWAL_SUCCESS.getCode(), SRoom room = roomService.getById(sOrder.getRoomId());
cn.hutool.core.date.DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN), if (room.getStatus().equals(RoomStatusEnum.FREE.getValue())) {
cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1", room.setStatus(RoomStatusEnum.HOLD.getValue());
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode()); roomService.updateById(room);
//通知保洁人员 }
sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> { SCleanRecords sCleanRecords = isCleanRecordsService.getOne(new LambdaQueryWrapper<SCleanRecords>()
// 循环发送短信提示门店保洁打扫卫生 .eq(SCleanRecords::getRoomId, sOrder.getRoomId())
smsService.sendSmsCleanRecordsStopRemind(item.getPhone(), sStore, sRoom); .ne(SCleanRecords::getStatus, CleaningStatusEnum.CLEANED.getCode())
}); );
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), true, 5L, if (ObjectUtil.isNotEmpty(sCleanRecords)) {
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode()); sCleanRecords.setStartDate(new Date());
} sCleanRecords.setEndDate(new Date());
sConsumptionRecordsService.insertSConsumptionRecords(sOrder); sCleanRecords.setStatus(CleaningStatusEnum.CLEANED.getCode());
// 订单预定成功, 发送短信通知运维客服 isCleanRecordsService.updateById(sCleanRecords);
List<String> phones = new ArrayList<>(); }
SConsumerVo sConsumer = new SConsumerVo(); wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
sConsumer.setStoreId(sStore.getId()); sOrder.setStartDate(sOrder.getPreStartDate());
sConsumer.setPosition(3); sOrder.setEndDate(sOrder.getPreEndDate());
List<SConsumer> consumers = sConsumerService.selectAllocatedList(sConsumer); sOrder.setArrivalTime(new Date());
if (consumers.size() > 0) { sOrder.setStatus(OrderStatusEnum.INUSE.getCode());
List<Long> sconsumerIds = consumers.stream().map(SConsumer::getId).collect(Collectors.toList()); } else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
Map<Long, SStoreConsumer> consumerMap = storeConsumerMapper.selectList(new LambdaQueryWrapper<SStoreConsumer>() wechatNewService.sendMiniSubscribeMessage(sOrder, MessageReminderEnum.RESERVER);
.in(SStoreConsumer::getConsumerId, sconsumerIds) }
.eq(SStoreConsumer::getPosition, PositionEnum.CUSTOMER_SERVICE.getCode()) if (sOrder.getIsDelete().equals(YesNoEnum.yes.getIndex()) && sOrder.getPayStatus().equals(YesNoEnum.yes.getIndex())) {
.eq(SStoreConsumer::getStoreId, sOrder.getStoreId()) sOrder.setIsDelete(YesNoEnum.no.getIndex());
).stream().collect(Collectors.toMap(SStoreConsumer::getConsumerId, Function.identity())); }
logger.debug("订单预订成功通知发送开始"); creatExtracted(consumerWallet, sOrder, consumerMember);
consumers.forEach(o->{ baseMapper.updateSOrder(sOrder);
SStoreConsumer sStoreConsumer = consumerMap.get(o.getId()); if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
if (ObjectUtil.isNotEmpty(sStoreConsumer)) { Map<String, String> map = new HashMap<>();
if (sStoreConsumer.getGating().equals(YesNoEnum.yes.getIndex())) { map.put("orderNo", sOrder.getOrderNo());
phones.add(o.getPhone()); map.put("expirationTime", sOrder.getEndDate().toString());
} JSONObject jsonObject = new JSONObject(map);
if (sStoreConsumer.getController().equals(YesNoEnum.yes.getIndex())) { redisUtil.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo(), jsonObject.toString());
//公众号发送订单预订成功通知 } else if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
wechatNewService.sendPublicTemplateMessage(sOrder, MessageReminderEnum.ORDER_RESERVE, o.getId()); Map<String, String> map = new HashMap<>();
map.put("orderNo", sOrder.getOrderNo());
map.put("expirationTime", sOrder.getPreStartDate().toString());
JSONObject jsonObject = new JSONObject(map);
redisUtil.set(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo(), jsonObject.toString());
}
Long couponId = sOrder.getCouponId();
SStore sStore = storeService.getById(sOrder.getStoreId());
SRoom sRoom = roomService.getById(sOrder.getRoomId());
if (couponId != null && couponId > 0) {
SConsumerCoupon consumerCoupon = consumerCouponService.getById(couponId);
if (ObjectUtil.isNotEmpty(consumerCoupon)) {
if (consumerCoupon.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
consumerCoupon.setUseDate(new Date());
consumerCoupon.setUseStatus(UserStatusEnum.USED.getCode());
consumerCouponService.updateById(consumerCoupon);
} }
} }
}); }
smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, sRoom); //续费成功语音播报
logger.debug("订单预订成功通知发送结束"); if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
deviceOpService.actionExecute(sOrder.getRoomId(), sOrder.getConsumerPhone(), VoiceEnum.RENEWAL_SUCCESS.getCode(),
cn.hutool.core.date.DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN),
cn.hutool.core.date.DateUtil.format(cn.hutool.core.date.DateUtil.offsetMinute(new Date(), 1), DatePattern.NORM_DATETIME_PATTERN), "1",
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
//通知保洁人员
sConsumerService.selectListByStoreId(sOrder.getStoreId()).stream().forEach(item -> {
// 循环发送短信提示门店保洁打扫卫生
smsService.sendSmsCleanRecordsStopRemind(item.getPhone(), sStore, sRoom);
});
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(), OpTypeEnum.GET_ELECTRIC.getCode(), true, 5L,
DeviceOpSourceEnum.DEVICE_SOURCE_20.getCode());
}
sConsumptionRecordsService.insertSConsumptionRecords(sOrder);
// 订单预定成功, 发送短信通知运维客服
List<String> phones = new ArrayList<>();
SConsumerVo sConsumer = new SConsumerVo();
sConsumer.setStoreId(sStore.getId());
sConsumer.setPosition(3);
List<SConsumer> consumers = sConsumerService.selectAllocatedList(sConsumer);
if (consumers.size() > 0) {
List<Long> sconsumerIds = consumers.stream().map(SConsumer::getId).collect(Collectors.toList());
Map<Long, SStoreConsumer> consumerMap = storeConsumerMapper.selectList(new LambdaQueryWrapper<SStoreConsumer>()
.in(SStoreConsumer::getConsumerId, sconsumerIds)
.eq(SStoreConsumer::getPosition, PositionEnum.CUSTOMER_SERVICE.getCode())
.eq(SStoreConsumer::getStoreId, sOrder.getStoreId())
).stream().collect(Collectors.toMap(SStoreConsumer::getConsumerId, Function.identity()));
logger.debug("订单预订成功通知发送开始");
consumers.forEach(o -> {
SStoreConsumer sStoreConsumer = consumerMap.get(o.getId());
if (ObjectUtil.isNotEmpty(sStoreConsumer)) {
if (sStoreConsumer.getGating().equals(YesNoEnum.yes.getIndex())) {
phones.add(o.getPhone());
}
if (sStoreConsumer.getController().equals(YesNoEnum.yes.getIndex())) {
//公众号发送订单预订成功通知
wechatNewService.sendPublicTemplateMessage(sOrder, MessageReminderEnum.ORDER_RESERVE, o.getId());
}
}
});
smsService.sendSmsOrderPredetermine(phones, sOrder, sStore, sRoom);
logger.debug("订单预订成功通知发送结束");
}
} }
} }
......
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