From 82a8bc62d5b9d5d607f6952329952b17eda2f0a0 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 14 九月 2026 15:44:34 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/order/mapper/TourOrderMapper.java | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/backend/src/main/java/com/tourguide/modules/order/mapper/TourOrderMapper.java b/backend/src/main/java/com/tourguide/modules/order/mapper/TourOrderMapper.java
index 3ee201b..2fba7db 100644
--- a/backend/src/main/java/com/tourguide/modules/order/mapper/TourOrderMapper.java
+++ b/backend/src/main/java/com/tourguide/modules/order/mapper/TourOrderMapper.java
@@ -40,10 +40,10 @@
})
List<VisitorOrderStatRow> selectVisitorOrderStats(@Param("visitorIds") Collection<Long> visitorIds);
- @Select("SELECT COALESCE(SUM(COALESCE(payment_amount, amount)), 0) FROM tour_order " +
+ @Select("SELECT COALESCE(SUM(guide_earning_amount), 0) FROM tour_order " +
"WHERE deleted = 0 AND guide_id = #{guideId} AND status = 'COMPLETED' " +
"AND guide_earning_amount IS NOT NULL " +
- "AND (refund_status IS NULL OR refund_status <> 'REFUNDED') " +
+ "AND (refund_status IS NULL OR refund_status IN ('NONE', 'REFUND_FAILED')) " +
"AND completed_at >= #{startTime} AND completed_at < #{endTime}")
BigDecimal selectGuideEarningSum(@Param("guideId") Long guideId,
@Param("startTime") LocalDateTime startTime,
@@ -52,7 +52,7 @@
@Select("SELECT DISTINCT scenic_name FROM tour_order " +
"WHERE deleted = 0 AND guide_id = #{guideId} AND status = 'COMPLETED' " +
"AND guide_earning_amount IS NOT NULL " +
- "AND (refund_status IS NULL OR refund_status <> 'REFUNDED') " +
+ "AND (refund_status IS NULL OR refund_status IN ('NONE', 'REFUND_FAILED')) " +
"AND scenic_name IS NOT NULL AND scenic_name <> '' ORDER BY scenic_name")
List<String> selectGuideEarningScenics(Long guideId);
@@ -60,7 +60,7 @@
"AND settled_at IS NULL AND settlement_due_at IS NOT NULL " +
"AND settlement_due_at <= #{now} AND guide_id IS NOT NULL " +
"AND guide_earning_amount IS NOT NULL " +
- "AND (refund_status IS NULL OR refund_status <> 'REFUNDED') " +
+ "AND (refund_status IS NULL OR refund_status IN ('NONE', 'PARTIAL', 'REFUND_FAILED')) " +
"ORDER BY settlement_due_at, id LIMIT #{limit}")
List<Long> selectDueSettlementIds(@Param("now") LocalDateTime now, @Param("limit") int limit);
@@ -72,6 +72,19 @@
@Param("sessionId") Long sessionId,
@Param("completedAt") LocalDateTime completedAt);
+ @Select("SELECT o.receiving_session_id FROM tour_order o " +
+ "INNER JOIN guide_receiving_session s ON s.id = o.receiving_session_id " +
+ "AND s.deleted = 0 AND s.status = 'IN_SERVICE' " +
+ "INNER JOIN operation_scenic_pricing p ON p.id = o.service_package_id " +
+ "AND p.deleted = 0 " +
+ "WHERE o.deleted = 0 AND o.status = 'IN_SERVICE' " +
+ "AND o.receiving_session_id IS NOT NULL AND o.service_started_at IS NOT NULL " +
+ "AND p.duration_minutes > 0 " +
+ "AND TIMESTAMPADD(MINUTE, p.duration_minutes, o.service_started_at) <= #{now} " +
+ "GROUP BY o.receiving_session_id ORDER BY MIN(o.service_started_at), o.receiving_session_id " +
+ "LIMIT #{limit}")
+ List<Long> selectDueServiceSessionIds(@Param("now") LocalDateTime now, @Param("limit") int limit);
+
@Update("UPDATE tour_order SET status = 'CANCELLED', cancelled_at = COALESCE(cancelled_at, NOW()), refund_status = 'REFUNDING', updated_at = NOW() " +
"WHERE id = #{id} AND deleted = 0 AND status = 'PENDING_ACCEPT' " +
"AND payment_time IS NOT NULL AND (refund_status IS NULL OR refund_status = 'NONE')")
--
Gitblit v1.7.1