Commit 5ffc7766 by 吕明尚

小程序退款增加判断是否有使用中的订单才断电,删除

parent c0f750d3
......@@ -356,6 +356,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override
public int refundOp(AdminRefundRequest request) {
SOrder sOrder = getInfoException(request.getOrderNo());
SOrder oldSOrder = sOrder;
if (sOrder == null) {
throw new BaseException("订单不存在");
}
......@@ -432,28 +433,28 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
redisUtil.delete(ReceiptRdeisEnum.ORDER_NO.getValue() + sOrder.getOrderNo());
redisUtil.delete(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + sOrder.getOrderNo());
//判断订单类型
if (sOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
if (sOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
if (oldSOrder.getOrderType().equals(OrderTypeEnum.RESERVER.getCode())) {
if (oldSOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
// 使用中订单断电, 延时3分钟断电
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(),
deviceOpService.openOrCloseDevice(oldSOrder.getRoomId(), oldSOrder.getConsumerPhone(),
OpTypeEnum.CUT_ELECTRIC.getCode(), true, 180);
} else if (sOrder.getStatus().equals(OrderStatusEnum.UNUSED.getCode())) {
} else if (oldSOrder.getStatus().equals(OrderStatusEnum.UNUSED.getCode())) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getRoomId, sOrder.getRoomId());
queryWrapper.eq(SOrder::getRoomId, oldSOrder.getRoomId());
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
List<SOrder> list = list(queryWrapper);
if (CollectionUtils.isEmpty(list)) {
deviceOpService.openOrCloseDevice(sOrder.getRoomId(), sOrder.getConsumerPhone(),
deviceOpService.openOrCloseDevice(oldSOrder.getRoomId(), oldSOrder.getConsumerPhone(),
OpTypeEnum.CUT_ELECTRIC.getCode(), true, 180);
}
}
} else if (sOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
} else if (oldSOrder.getOrderType().equals(OrderTypeEnum.RENEW.getCode())) {
//查询续单的前预定单
Date preStartDate = sOrder.getPreStartDate();
Date preStartDate = oldSOrder.getPreStartDate();
//查询预定的结束时间是否在续单的开始时间之后和开始时间加一分钟前
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getRoomId, sOrder.getRoomId());
queryWrapper.eq(SOrder::getRoomId, oldSOrder.getRoomId());
queryWrapper.between(SOrder::getEndDate, preStartDate, DateUtil.addMin(preStartDate, 1));
SOrder one = getOne(queryWrapper);
if (one.getStatus().equals(OrderStatusEnum.USED.getCode())) {
......
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