liujie
2026-07-30 280ef5100bece9b40ac51736aef037704a52a4ca
backend/src/main/java/com/tourguide/modules/order/service/MiniTourOrderCommandService.java
@@ -15,6 +15,7 @@
import com.tourguide.modules.order.dto.TourOrderResponse;
import com.tourguide.modules.order.entity.TourOrder;
import com.tourguide.modules.order.mapper.TourOrderMapper;
import com.tourguide.modules.system.service.GuideNotificationService;
import com.tourguide.modules.user.entity.MiniUser;
import com.tourguide.modules.user.entity.GuideUser;
import com.tourguide.modules.user.mapper.GuideUserMapper;
@@ -37,6 +38,8 @@
    private final ScenicPricingMapper pricingMapper;
    private final GuideUserMapper guideUserMapper;
    private final PlatformSettingsService platformSettingsService;
    private final GuideOrderMatchingService matchingService;
    private final GuideNotificationService notificationService;
    public MiniTourOrderCommandService(TourOrderMapper orderMapper,
                                       MiniUserService miniUserService,
@@ -44,7 +47,9 @@
                                       ScenicMeetingPointMapper meetingPointMapper,
                                       ScenicPricingMapper pricingMapper,
                                       GuideUserMapper guideUserMapper,
                                       PlatformSettingsService platformSettingsService) {
                                       PlatformSettingsService platformSettingsService,
                                       GuideOrderMatchingService matchingService,
                                       GuideNotificationService notificationService) {
        this.orderMapper = orderMapper;
        this.miniUserService = miniUserService;
        this.scenicSpotMapper = scenicSpotMapper;
@@ -52,6 +57,8 @@
        this.pricingMapper = pricingMapper;
        this.guideUserMapper = guideUserMapper;
        this.platformSettingsService = platformSettingsService;
        this.matchingService = matchingService;
        this.notificationService = notificationService;
    }
    @Transactional
@@ -77,9 +84,12 @@
        order.setVisitorId(visitor.getId());
        order.setVisitorNickname(visitor.getNickname());
        order.setVisitorMobile(visitor.getMobile());
        order.setScenicSpotId(scenicSpot.getId());
        order.setScenicName(scenicSpot.getScenicName());
        order.setMeetingPointId(meetingPoint.getId());
        order.setMeetingPointName(meetingPoint.getPointName());
        order.setPackageName(packageName(pricing.getServiceType()));
        order.setServicePackageId(pricing.getId());
        order.setOrderType(pricing.getServiceType());
        order.setPeopleCount(request.getPeopleCount());
        order.setUnitPrice(discountUnitPrice);
@@ -115,7 +125,8 @@
        order.setPaymentTime(now);
        order.setStatus(OrderStatus.PENDING_ACCEPT.getCode());
        orderMapper.updateById(order);
        return TourOrderResponse.from(order);
        matchingService.match(order.getId());
        return TourOrderResponse.from(orderMapper.selectById(order.getId()));
    }
    public TourOrderResponse active(Long visitorId) {
@@ -158,6 +169,7 @@
    @Transactional
    public TourOrderResponse cancel(Long visitorId, Long orderId) {
        TourOrder order = requireVisitorOrder(visitorId, orderId);
        boolean notifyGuide = OrderStatus.PENDING_MEETING.matches(order.getStatus()) && order.getGuideId() != null;
        if (!OrderStatus.PENDING_PAYMENT.matches(order.getStatus())
                && !OrderStatus.PENDING_ACCEPT.matches(order.getStatus())
                && !OrderStatus.PENDING_MEETING.matches(order.getStatus())) {
@@ -172,6 +184,7 @@
            order.setRefundMethod(order.getPaymentMethod());
        }
        orderMapper.updateById(order);
        if (notifyGuide) notificationService.notifyOrderCancelled(order);
        return TourOrderResponse.from(order);
    }