| | |
| | | import com.tourguide.common.api.PageResponse; |
| | | import com.tourguide.common.exception.BusinessException; |
| | | import com.tourguide.modules.order.dto.TourOrderResponse; |
| | | import com.tourguide.modules.order.dto.TourOrderRefundResponse; |
| | | import com.tourguide.modules.order.domain.OrderStatus; |
| | | import com.tourguide.modules.order.domain.RefundAmountCalculator; |
| | | import com.tourguide.modules.order.domain.RefundStatus; |
| | | import com.tourguide.modules.order.entity.TourOrder; |
| | | import com.tourguide.modules.order.entity.TourOrderRefund; |
| | | import com.tourguide.modules.order.mapper.TourOrderMapper; |
| | | import com.tourguide.modules.order.mapper.TourOrderRefundMapper; |
| | | import com.tourguide.modules.system.service.GuideNotificationService; |
| | | import com.tourguide.modules.review.entity.OrderReview; |
| | | import com.tourguide.modules.review.mapper.OrderReviewMapper; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | |
| | | private final OrderReviewMapper reviewMapper; |
| | | private final GuideNotificationService notificationService; |
| | | private final OrderRefundService orderRefundService; |
| | | private final TourOrderRefundMapper refundMapper; |
| | | private final GuideSessionTransitionService sessionTransitionService; |
| | | |
| | | public TourOrderService(TourOrderMapper orderMapper, OrderReviewMapper reviewMapper, |
| | | GuideNotificationService notificationService, |
| | | OrderRefundService orderRefundService) { |
| | | this(orderMapper, reviewMapper, notificationService, orderRefundService, null, null); |
| | | } |
| | | |
| | | public TourOrderService(TourOrderMapper orderMapper, OrderReviewMapper reviewMapper, |
| | | GuideNotificationService notificationService, |
| | | OrderRefundService orderRefundService, |
| | | TourOrderRefundMapper refundMapper) { |
| | | this(orderMapper, reviewMapper, notificationService, orderRefundService, refundMapper, null); |
| | | } |
| | | |
| | | @Autowired |
| | | public TourOrderService(TourOrderMapper orderMapper, OrderReviewMapper reviewMapper, |
| | | GuideNotificationService notificationService, |
| | | OrderRefundService orderRefundService, |
| | | TourOrderRefundMapper refundMapper, |
| | | GuideSessionTransitionService sessionTransitionService) { |
| | | this.orderMapper = orderMapper; |
| | | this.reviewMapper = reviewMapper; |
| | | this.notificationService = notificationService; |
| | | this.orderRefundService = orderRefundService; |
| | | this.refundMapper = refundMapper; |
| | | this.sessionTransitionService = sessionTransitionService; |
| | | } |
| | | |
| | | public PageResponse<TourOrderResponse> page(long page, long size, String keyword, Long visitorId, Long guideId, |
| | |
| | | .eq(OrderReview::getOrderId, id) |
| | | .eq(OrderReview::getStatus, 1) |
| | | .last("LIMIT 1")); |
| | | return TourOrderResponse.from(order, review); |
| | | TourOrderResponse response = TourOrderResponse.from(order, review); |
| | | if (refundMapper == null) return response; |
| | | List<TourOrderRefund> records = refundMapper.selectByOrderId(id); |
| | | if (records == null) return response; |
| | | List<TourOrderRefundResponse> refundRecords = records.stream() |
| | | .map(TourOrderRefundResponse::new) |
| | | .collect(Collectors.toList()); |
| | | return response.withRefundRecords(refundRecords); |
| | | } |
| | | |
| | | public List<String> scenicOptions() { |
| | |
| | | throw new BusinessException(502, "支付渠道退款失败,请稍后重试"); |
| | | } |
| | | if (notifyGuide) { |
| | | if (sessionTransitionService != null) { |
| | | sessionTransitionService.restoreAfterOrderCancellation(order); |
| | | } |
| | | try { |
| | | notificationService.notifyOrderCancelled(order); |
| | | } catch (RuntimeException exception) { |