From ad5db85e540947e82c7a4d5612879b3b3ecdf459 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期五, 21 八月 2026 10:38:07 +0800
Subject: [PATCH] update

---
 backend/src/test/java/com/tourguide/modules/order/service/MiniTourOrderCommandServiceTest.java |   43 +++++++++++--------------------------------
 1 files changed, 11 insertions(+), 32 deletions(-)

diff --git a/backend/src/test/java/com/tourguide/modules/order/service/MiniTourOrderCommandServiceTest.java b/backend/src/test/java/com/tourguide/modules/order/service/MiniTourOrderCommandServiceTest.java
index b190118..5cf75d4 100644
--- a/backend/src/test/java/com/tourguide/modules/order/service/MiniTourOrderCommandServiceTest.java
+++ b/backend/src/test/java/com/tourguide/modules/order/service/MiniTourOrderCommandServiceTest.java
@@ -6,6 +6,7 @@
 import com.tourguide.modules.operation.mapper.OperationScenicSpotMapper;
 import com.tourguide.modules.operation.mapper.ScenicMeetingPointMapper;
 import com.tourguide.modules.operation.mapper.ScenicPricingMapper;
+import com.tourguide.modules.operation.dto.PlatformSettingsResponse;
 import com.tourguide.modules.operation.service.PlatformSettingsService;
 import com.tourguide.modules.order.domain.OrderStatus;
 import com.tourguide.modules.order.dto.MiniOrderCreateRequest;
@@ -40,8 +41,8 @@
     private ScenicPricingMapper pricingMapper;
     private GuideUserMapper guideUserMapper;
     private PlatformSettingsService platformSettingsService;
-    private GuideOrderMatchingService matchingService;
     private GuideNotificationService notificationService;
+    private OrderRefundService orderRefundService;
     private MiniTourOrderCommandService commandService;
 
     @BeforeEach
@@ -53,11 +54,11 @@
         pricingMapper = mock(ScenicPricingMapper.class);
         guideUserMapper = mock(GuideUserMapper.class);
         platformSettingsService = mock(PlatformSettingsService.class);
-        matchingService = mock(GuideOrderMatchingService.class);
         notificationService = mock(GuideNotificationService.class);
+        orderRefundService = mock(OrderRefundService.class);
         commandService = new MiniTourOrderCommandService(
                 orderMapper, miniUserService, scenicSpotMapper, meetingPointMapper, pricingMapper,
-                guideUserMapper, platformSettingsService, matchingService, notificationService);
+                guideUserMapper, platformSettingsService, notificationService, orderRefundService);
     }
 
     @Test
@@ -89,6 +90,9 @@
         pricing.setDiscountPrice(new BigDecimal("36.00"));
         pricing.setMaxParticipants(10);
         when(pricingMapper.selectOne(any())).thenReturn(pricing);
+        PlatformSettingsResponse settings = new PlatformSettingsResponse();
+        settings.setSettlementDays(7);
+        when(platformSettingsService.getSettings()).thenReturn(settings);
         doAnswer(invocation -> {
             TourOrder order = invocation.getArgument(0);
             order.setId(99L);
@@ -111,33 +115,8 @@
         assertThat(order.getPaymentOrderNo()).isNull();
         assertThat(order.getPaymentAmount()).isNull();
         assertThat(order.getPaymentTime()).isNull();
+        assertThat(order.getSettlementDays()).isEqualTo(7);
         assertThat(response.getStatus()).isEqualTo(OrderStatus.PENDING_PAYMENT.getCode());
-    }
-
-    @Test
-    void confirmPaymentShouldMovePendingOrderToPendingAccept() {
-        MiniUser visitor = new MiniUser();
-        visitor.setId(7L);
-        when(miniUserService.findEnabledById(7L)).thenReturn(visitor);
-
-        TourOrder order = new TourOrder();
-        order.setId(99L);
-        order.setOrderNo("MJ202607290001");
-        order.setVisitorId(7L);
-        order.setAmount(new BigDecimal("144.00"));
-        order.setStatus(OrderStatus.PENDING_PAYMENT.getCode());
-        when(orderMapper.selectOne(any())).thenReturn(order);
-        when(orderMapper.selectById(99L)).thenReturn(order);
-
-        TourOrderResponse response = commandService.confirmPayment(7L, 99L);
-
-        assertThat(order.getStatus()).isEqualTo(OrderStatus.PENDING_ACCEPT.getCode());
-        assertThat(order.getPaymentMethod()).isEqualTo("WECHAT");
-        assertThat(order.getPaymentOrderNo()).isEqualTo("LOCALMJ202607290001");
-        assertThat(order.getPaymentAmount()).isEqualByComparingTo("144.00");
-        assertThat(order.getPaymentTime()).isNotNull();
-        assertThat(response.getStatus()).isEqualTo(OrderStatus.PENDING_ACCEPT.getCode());
-        verify(orderMapper).updateById(order);
     }
 
     @Test
@@ -168,12 +147,12 @@
         order.setStatus(OrderStatus.PENDING_MEETING.getCode());
         order.setPaymentTime(LocalDateTime.now());
         order.setPaymentAmount(new BigDecimal("36.00"));
-        when(orderMapper.selectOne(any())).thenReturn(order);
+        when(orderMapper.selectForUpdate(99L)).thenReturn(order);
 
         commandService.cancel(7L, 99L);
 
         assertThat(order.getStatus()).isEqualTo(OrderStatus.CANCELLED.getCode());
-        verify(orderMapper).updateById(order);
-        verify(notificationService).notifyOrderCancelled(order);
+        verify(orderRefundService).requestRefund(order);
+        verify(notificationService).notifyVisitorCancelledOrder(order);
     }
 }

--
Gitblit v1.7.1