Commit 86eb4104 by YG8999

退款修改房间状态,不存在其他使用中订单修改空闲

parent 5ffc7766
......@@ -356,7 +356,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override
public int refundOp(AdminRefundRequest request) {
SOrder sOrder = getInfoException(request.getOrderNo());
SOrder oldSOrder = sOrder;
SOrder oldSOrder = new SOrder();
BeanUtils.copyProperties(sOrder, oldSOrder);
if (sOrder == null) {
throw new BaseException("订单不存在");
}
......@@ -373,8 +374,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// if (request.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
// throw new BaseException("退款金额不能为0,请修改退款金额");
// }
// 当前订单状态
Integer status = sOrder.getStatus();
// 退款记录
OrderRefundArtificial artificial = new OrderRefundArtificial();
artificial.setIsRefundCoupon(request.getRefundCoupon());
......@@ -404,13 +403,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
boolean b = isCleanRecordsService.addSCleanRecords(sOrder.getStoreId(), sOrder.getRoomId());
}
}
if (sOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
// 如果订单使用中,房间修改状态为空闲
SRoom sRoom = new SRoom();
sRoom.setId(sOrder.getRoomId());
sRoom.setStatus(RoomStatusEnum.FREE.getValue());
roomService.updateById(sRoom);
}
if (request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
// 退款金额大于0, 微信退款
//退款
......@@ -477,6 +469,20 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
redisUtils.set(ReceiptRdeisEnum.ORDER_NO_KEY.getValue() + one.getOrderNo(), jsonObject.toString());
}
}
// 如果订单使用中,房间修改状态
if (oldSOrder.getStatus().equals(OrderStatusEnum.INUSE.getCode())) {
LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SOrder::getRoomId, oldSOrder.getRoomId());
queryWrapper.eq(SOrder::getStatus, OrderStatusEnum.INUSE.getCode());
List<SOrder> list = list(queryWrapper);
if (CollectionUtils.isEmpty(list)) {
// 不存在其他使用中订单,修改状态为空闲
SRoom sRoom = new SRoom();
sRoom.setId(sOrder.getRoomId());
sRoom.setStatus(RoomStatusEnum.FREE.getValue());
roomService.updateById(sRoom);
}
}
// 生成退款人工退款记录
return orderRefundArtificialService.insertOrderRefundArtificial(artificial);
......
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