liujie
2026-08-21 77649c76ec1c3afcb93e9963243d637665b3a307
backend/src/main/java/com/tourguide/modules/order/service/MiniTourOrderCommandService.java
@@ -10,6 +10,7 @@
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;
@@ -20,6 +21,7 @@
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;
@@ -40,6 +42,8 @@
    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,
@@ -49,7 +53,9 @@
                                       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;
@@ -59,6 +65,8 @@
        this.platformSettingsService = platformSettingsService;
        this.notificationService = notificationService;
        this.orderRefundService = orderRefundService;
        this.matchingService = matchingService;
        this.skipPayment = skipPayment;
    }
    @Transactional
@@ -103,9 +111,20 @@
        order.setMeetingPointCount(1);
        Integer settlementDays = platformSettingsService.getSettings().getSettlementDays();
        order.setSettlementDays(settlementDays == null ? 1 : Math.max(0, settlementDays));
        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);
    }