|
@@ -239,13 +239,54 @@ public class UserTicketOrderServiceImpl extends
|
|
return sb.toString();
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public boolean batchCancelOrder(String boxId, List<String> orderIds) {
|
|
|
|
+ int sumTicket = 0;
|
|
|
|
+ for (String orderId : orderIds) {
|
|
|
|
+ UserTicketOrder userTicketOrder = getById(orderId);
|
|
|
|
+ Assert.isTrue(userTicketOrder.getResource() == TicketTypeEnum.ONLINE);
|
|
|
|
+ if (!rollbackOrder(userTicketOrder)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ sumTicket += userTicketOrder.getTicketNum();
|
|
|
|
+ }
|
|
|
|
+ rollbackBoxQty(boxId, sumTicket);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void rollbackBoxQty(String boxId, int qty) {
|
|
|
|
+ TicketBox ticketBox = ticketBoxService.getById(boxId);
|
|
|
|
+ boolean updateBox = ticketBoxService.update(new LambdaUpdateWrapper<TicketBox>().set(TicketBox::getSaleQty,
|
|
|
|
+ ticketBox.getSaleQty() - qty)
|
|
|
|
+ .set(
|
|
|
|
+ ticketBox.getStatus() == TicketBoxStatusEnum.PUT_OFF && ticketBox.getManualOff() != 1,
|
|
|
|
+ TicketBox::getStatus, TicketBoxStatusEnum.PUT_ON)
|
|
|
|
+ .eq(TicketBox::getBoxId, ticketBox.getBoxId())
|
|
|
|
+ .eq(TicketBox::getSaleQty, ticketBox.getSaleQty()));
|
|
|
|
+ Assert.isTrue(updateBox, "取消过期未支付盲票购买订单,恢复票组销量失败。boxId:{0}" + boxId);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public boolean cancelOrder(String orderId) {
|
|
public boolean cancelOrder(String orderId) {
|
|
UserTicketOrder userTicketOrder = getById(orderId);
|
|
UserTicketOrder userTicketOrder = getById(orderId);
|
|
|
|
+
|
|
|
|
+ if (!rollbackOrder(userTicketOrder)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (userTicketOrder.getResource() == TicketTypeEnum.ONLINE) {
|
|
|
|
+ rollbackBoxQty(userTicketOrder.getBoxId(), userTicketOrder.getTicketNum());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean rollbackOrder(UserTicketOrder userTicketOrder) {
|
|
if (userTicketOrder.getStatus() != UserTicketOrderStatusEnum.NOT_PAY) {
|
|
if (userTicketOrder.getStatus() != UserTicketOrderStatusEnum.NOT_PAY) {
|
|
LogUtil.warn(logger, "取消购票订单时,订单状态不是待支付,忽略。orderId:{0}, status:{1}",
|
|
LogUtil.warn(logger, "取消购票订单时,订单状态不是待支付,忽略。orderId:{0}, status:{1}",
|
|
- orderId, userTicketOrder.getStatus());
|
|
|
|
|
|
+ userTicketOrder.getOrderId(), userTicketOrder.getStatus());
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -256,28 +297,15 @@ public class UserTicketOrderServiceImpl extends
|
|
.set(UserCoupon::getStatus, UserCouponStatusEnum.UNUSED)
|
|
.set(UserCoupon::getStatus, UserCouponStatusEnum.UNUSED)
|
|
.set(UserCoupon::getVerifyTime, null)
|
|
.set(UserCoupon::getVerifyTime, null)
|
|
.in(UserCoupon::getId, userCouponIds));
|
|
.in(UserCoupon::getId, userCouponIds));
|
|
- Assert.isTrue(rst, "盲票购买订单取消时,反核销优惠券失败。orderId:" + orderId + "userCouponIds:"
|
|
|
|
|
|
+ Assert.isTrue(rst, "盲票购买订单取消时,反核销优惠券失败。orderId:" + userTicketOrder.getOrderId() + "userCouponIds:"
|
|
+ userTicketOrder.getCouponInfo());
|
|
+ userTicketOrder.getCouponInfo());
|
|
}
|
|
}
|
|
- if (userTicketOrder.getResource() == TicketTypeEnum.ONLINE) {
|
|
|
|
- // TODO 线上票库存回滚,此处需要按票组累计起来回滚
|
|
|
|
- TicketBox ticketBox = ticketBoxService.getById(userTicketOrder.getBoxId());
|
|
|
|
- ticketBoxService.update(new LambdaUpdateWrapper<TicketBox>().set(TicketBox::getSaleQty,
|
|
|
|
- ticketBox.getSaleQty() - userTicketOrder.getTicketNum())
|
|
|
|
- .set(
|
|
|
|
- ticketBox.getStatus() == TicketBoxStatusEnum.PUT_OFF && ticketBox.getManualOff() != 1,
|
|
|
|
- TicketBox::getStatus, TicketBoxStatusEnum.PUT_ON)
|
|
|
|
- .eq(TicketBox::getBoxId, ticketBox.getBoxId())
|
|
|
|
- .eq(TicketBox::getSaleQty, ticketBox.getSaleQty()));
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
boolean rst = update(new LambdaUpdateWrapper<UserTicketOrder>().set(UserTicketOrder::getStatus,
|
|
boolean rst = update(new LambdaUpdateWrapper<UserTicketOrder>().set(UserTicketOrder::getStatus,
|
|
UserTicketOrderStatusEnum.CANCELED)
|
|
UserTicketOrderStatusEnum.CANCELED)
|
|
- .eq(UserTicketOrder::getOrderId, orderId)
|
|
|
|
|
|
+ .eq(UserTicketOrder::getOrderId, userTicketOrder.getOrderId())
|
|
.eq(UserTicketOrder::getStatus, UserTicketOrderStatusEnum.NOT_PAY));
|
|
.eq(UserTicketOrder::getStatus, UserTicketOrderStatusEnum.NOT_PAY));
|
|
- Assert.isTrue(rst, "盲票购买订单取消时,更新订单状态失败。orderId:" + orderId);
|
|
|
|
-
|
|
|
|
|
|
+ Assert.isTrue(rst, "盲票购买订单取消时,更新订单状态失败。orderId:" + userTicketOrder.getOrderId());
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|