From e9e42b621afdf6ac94f5327ee843b32b10a401b4 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 04 八月 2026 17:45:14 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/order/service/MiniTourOrderCommandService.java | 51 ++++++++++++++++-----------------------------------
1 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/backend/src/main/java/com/tourguide/modules/order/service/MiniTourOrderCommandService.java b/backend/src/main/java/com/tourguide/modules/order/service/MiniTourOrderCommandService.java
index 62b53fb..17f17ae 100644
--- a/backend/src/main/java/com/tourguide/modules/order/service/MiniTourOrderCommandService.java
+++ b/backend/src/main/java/com/tourguide/modules/order/service/MiniTourOrderCommandService.java
@@ -38,8 +38,8 @@
private final ScenicPricingMapper pricingMapper;
private final GuideUserMapper guideUserMapper;
private final PlatformSettingsService platformSettingsService;
- private final GuideOrderMatchingService matchingService;
private final GuideNotificationService notificationService;
+ private final OrderRefundService orderRefundService;
public MiniTourOrderCommandService(TourOrderMapper orderMapper,
MiniUserService miniUserService,
@@ -48,8 +48,8 @@
ScenicPricingMapper pricingMapper,
GuideUserMapper guideUserMapper,
PlatformSettingsService platformSettingsService,
- GuideOrderMatchingService matchingService,
- GuideNotificationService notificationService) {
+ GuideNotificationService notificationService,
+ OrderRefundService orderRefundService) {
this.orderMapper = orderMapper;
this.miniUserService = miniUserService;
this.scenicSpotMapper = scenicSpotMapper;
@@ -57,8 +57,8 @@
this.pricingMapper = pricingMapper;
this.guideUserMapper = guideUserMapper;
this.platformSettingsService = platformSettingsService;
- this.matchingService = matchingService;
this.notificationService = notificationService;
+ this.orderRefundService = orderRefundService;
}
@Transactional
@@ -107,28 +107,6 @@
return TourOrderResponse.from(order);
}
- /**
- * 确认游客订单支付成功,并将订单流转到等待导游接单状态。
- * 当前小程序尚未接入微信支付回调,因此由待支付页面在支付动作成功后调用;
- * 正式接入微信支付后应由服务端支付回调触发本方法对应的领域逻辑。
- */
- @Transactional
- public TourOrderResponse confirmPayment(Long visitorId, Long orderId) {
- TourOrder order = requireVisitorOrder(visitorId, orderId);
- if (!OrderStatus.PENDING_PAYMENT.matches(order.getStatus())) {
- throw new BusinessException(409, "当前订单状态不支持支付");
- }
- LocalDateTime now = LocalDateTime.now();
- order.setPaymentMethod("WECHAT");
- order.setPaymentOrderNo("LOCAL" + order.getOrderNo());
- order.setPaymentAmount(order.getAmount());
- order.setPaymentTime(now);
- order.setStatus(OrderStatus.PENDING_ACCEPT.getCode());
- orderMapper.updateById(order);
- matchingService.match(order.getId());
- return TourOrderResponse.from(orderMapper.selectById(order.getId()));
- }
-
public TourOrderResponse active(Long visitorId) {
miniUserService.findEnabledById(visitorId);
TourOrder order = orderMapper.selectOne(
@@ -168,7 +146,13 @@
@Transactional
public TourOrderResponse cancel(Long visitorId, Long orderId) {
- TourOrder order = requireVisitorOrder(visitorId, orderId);
+ TourOrder order = orderMapper.selectForUpdate(orderId);
+ if (order == null || visitorId == null || !visitorId.equals(order.getVisitorId())) {
+ throw new BusinessException(404, "订单不存在");
+ }
+ if (OrderStatus.CANCELLED.matches(order.getStatus())) {
+ return TourOrderResponse.from(order);
+ }
boolean notifyGuide = OrderStatus.PENDING_MEETING.matches(order.getStatus()) && order.getGuideId() != null;
if (!OrderStatus.PENDING_PAYMENT.matches(order.getStatus())
&& !OrderStatus.PENDING_ACCEPT.matches(order.getStatus())
@@ -176,15 +160,12 @@
throw new BusinessException(409, "当前订单状态不支持取消");
}
order.setStatus(OrderStatus.CANCELLED.getCode());
- if (order.getPaymentTime() != null) {
- order.setRefundStatus(RefundStatus.REFUNDED.getCode());
- order.setRefundAmount(order.getPaymentAmount());
- order.setRefundTime(LocalDateTime.now());
- order.setRefundOrderNo("RF" + generateOrderNo());
- order.setRefundMethod(order.getPaymentMethod());
+ if (order.getPaymentTime() == null) {
+ orderMapper.updateById(order);
+ } else {
+ orderRefundService.requestRefund(order);
}
- orderMapper.updateById(order);
- if (notifyGuide) notificationService.notifyOrderCancelled(order);
+ if (notifyGuide) notificationService.notifyVisitorCancelledOrder(order);
return TourOrderResponse.from(order);
}
--
Gitblit v1.7.1