| | |
| | | /** 小程序讲解订单创建及状态流转服务。 */ |
| | | @Service |
| | | public class MiniTourOrderCommandService { |
| | | private static final int DEFAULT_UNPAID_CANCEL_MINUTES = 15; |
| | | private final TourOrderMapper orderMapper; |
| | | private final MiniUserService miniUserService; |
| | | private final OperationScenicSpotMapper scenicSpotMapper; |
| | |
| | | .orderByDesc(ScenicPricing::getId) |
| | | .last("LIMIT 1")); |
| | | GuideUser guide = order.getGuideId() == null ? null : guideUserMapper.selectById(order.getGuideId()); |
| | | int unpaidCancelMinutes = scenicSpot == null || scenicSpot.getUnpaidCancelMinutes() == null |
| | | || scenicSpot.getUnpaidCancelMinutes() < 1 |
| | | ? DEFAULT_UNPAID_CANCEL_MINUTES : scenicSpot.getUnpaidCancelMinutes(); |
| | | return TourOrderResponse.from(order) |
| | | .enrich(scenicSpot, meetingPoint, pricing, guide) |
| | | .withUnpaidCancelMinutes(unpaidCancelMinutes) |
| | | .withUnacceptedAutoRefundMinutes( |
| | | platformSettingsService.getSettings().getUnacceptedAutoRefundMinutes()); |
| | | } |
| | |
| | | throw new BusinessException(409, "当前订单状态不支持取消"); |
| | | } |
| | | order.setStatus(OrderStatus.CANCELLED.getCode()); |
| | | order.setCancelledAt(LocalDateTime.now()); |
| | | if (order.getPaymentTime() == null) { |
| | | orderMapper.updateById(order); |
| | | } else { |