| | |
| | | import com.tourguide.modules.operation.mapper.ScenicPricingMapper; |
| | | import com.tourguide.modules.operation.service.PlatformSettingsService; |
| | | import com.tourguide.modules.order.domain.OrderStatus; |
| | | import com.tourguide.modules.order.domain.PaymentMethod; |
| | | import com.tourguide.modules.order.domain.RefundStatus; |
| | | import com.tourguide.modules.order.dto.MiniOrderCreateRequest; |
| | | import com.tourguide.modules.order.dto.TourOrderResponse; |
| | |
| | | import com.tourguide.modules.user.entity.GuideUser; |
| | | import com.tourguide.modules.user.mapper.GuideUserMapper; |
| | | import com.tourguide.modules.user.service.MiniUserService; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private final PlatformSettingsService platformSettingsService; |
| | | private final GuideNotificationService notificationService; |
| | | private final OrderRefundService orderRefundService; |
| | | private final GuideOrderMatchingService matchingService; |
| | | private final boolean skipPayment; |
| | | |
| | | public MiniTourOrderCommandService(TourOrderMapper orderMapper, |
| | | MiniUserService miniUserService, |
| | |
| | | GuideUserMapper guideUserMapper, |
| | | PlatformSettingsService platformSettingsService, |
| | | GuideNotificationService notificationService, |
| | | OrderRefundService orderRefundService) { |
| | | OrderRefundService orderRefundService, |
| | | GuideOrderMatchingService matchingService, |
| | | @Value("${tourguide.order.skip-payment:false}") boolean skipPayment) { |
| | | this.orderMapper = orderMapper; |
| | | this.miniUserService = miniUserService; |
| | | this.scenicSpotMapper = scenicSpotMapper; |
| | |
| | | this.platformSettingsService = platformSettingsService; |
| | | this.notificationService = notificationService; |
| | | this.orderRefundService = orderRefundService; |
| | | this.matchingService = matchingService; |
| | | this.skipPayment = skipPayment; |
| | | } |
| | | |
| | | @Transactional |
| | |
| | | order.setMeetingPointCount(1); |
| | | Integer settlementDays = platformSettingsService.getSettings().getSettlementDays(); |
| | | order.setSettlementDays(settlementDays == null ? 1 : Math.max(0, settlementDays)); |
| | | order.setStatus(OrderStatus.PENDING_PAYMENT.getCode()); |
| | | if (skipPayment) { |
| | | order.setPaymentMethod(PaymentMethod.TEMPORARY_BYPASS.getCode()); |
| | | order.setPaymentOrderNo("TEMP" + order.getOrderNo()); |
| | | order.setPaymentAmount(subtotalAmount); |
| | | order.setPaymentTime(now); |
| | | order.setStatus(OrderStatus.PENDING_ACCEPT.getCode()); |
| | | } else { |
| | | order.setStatus(OrderStatus.PENDING_PAYMENT.getCode()); |
| | | } |
| | | order.setRefundStatus(RefundStatus.NONE.getCode()); |
| | | orderMapper.insert(order); |
| | | if (skipPayment) { |
| | | matchingService.match(order.getId()); |
| | | } |
| | | return TourOrderResponse.from(order); |
| | | } |
| | | |