From 825a575deb96cce822468bb9d9ac3e4eea0f91d1 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期四, 17 九月 2026 08:58:14 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/user/mapper/GuideReceivingSessionMapper.java | 61 +++++++++++++++++++++++++++---
1 files changed, 54 insertions(+), 7 deletions(-)
diff --git a/backend/src/main/java/com/tourguide/modules/user/mapper/GuideReceivingSessionMapper.java b/backend/src/main/java/com/tourguide/modules/user/mapper/GuideReceivingSessionMapper.java
index 023dba4..6fe79f2 100644
--- a/backend/src/main/java/com/tourguide/modules/user/mapper/GuideReceivingSessionMapper.java
+++ b/backend/src/main/java/com/tourguide/modules/user/mapper/GuideReceivingSessionMapper.java
@@ -9,12 +9,18 @@
import java.util.List;
public interface GuideReceivingSessionMapper extends BaseMapper<GuideReceivingSession> {
+ @Select("SELECT * FROM guide_receiving_session WHERE id = #{id} AND guide_id = #{guideId} " +
+ "AND deleted = 0 LIMIT 1 FOR UPDATE")
+ GuideReceivingSession selectForUpdate(@Param("id") Long id, @Param("guideId") Long guideId);
+
@Select("SELECT s.* FROM guide_receiving_session s " +
"INNER JOIN guide_realtime_status r ON r.guide_id = s.guide_id AND r.deleted = 0 " +
"INNER JOIN guide_user g ON g.id = s.guide_id AND g.deleted = 0 AND g.status = 1 " +
- "WHERE s.deleted = 0 AND s.status = 'RECEIVING' AND r.online_status = 1 AND r.available_status = 1 " +
+ "WHERE s.deleted = 0 AND r.online_status = 1 " +
+ "AND ((s.status = 'RECEIVING' AND r.available_status = 1) OR s.status = 'IN_SERVICE') " +
"AND s.scenic_spot_id = #{scenicSpotId} AND s.meeting_point_id = #{meetingPointId} " +
- "AND s.receiving_mode = #{receivingMode} AND FIND_IN_SET(#{serviceType}, s.service_types) > 0 " +
+ "AND (s.receiving_mode = #{receivingMode} OR s.receiving_mode = 'ALL') " +
+ "AND FIND_IN_SET(#{serviceType}, s.service_types) > 0 " +
"AND (s.order_cutoff_at IS NULL OR s.order_cutoff_at > NOW()) " +
"ORDER BY g.rating DESC, g.accepted_order_count DESC, g.created_at ASC LIMIT 50 FOR UPDATE")
List<GuideReceivingSession> selectMatchCandidates(@Param("scenicSpotId") Long scenicSpotId,
@@ -22,21 +28,62 @@
@Param("receivingMode") String receivingMode,
@Param("serviceType") String serviceType);
- @Update("UPDATE guide_receiving_session SET current_people_count = current_people_count + #{peopleCount}, " +
+ @Update("UPDATE guide_receiving_session SET receiving_mode = CASE WHEN receiving_mode = 'ALL' AND current_people_count = 0 THEN 'GROUP' ELSE receiving_mode END, " +
+ "current_people_count = current_people_count + #{peopleCount}, " +
"first_order_at = COALESCE(first_order_at, #{now}), service_start_at = COALESCE(service_start_at, #{serviceStartAt}), " +
"order_cutoff_at = COALESCE(order_cutoff_at, #{orderCutoffAt}), updated_at = NOW() " +
- "WHERE id = #{id} AND deleted = 0 AND status = 'RECEIVING' AND current_people_count + #{peopleCount} <= #{maxPeople}")
+ "WHERE id = #{id} AND deleted = 0 AND status IN ('RECEIVING', 'IN_SERVICE') " +
+ "AND current_people_count + #{peopleCount} <= #{maxPeople}")
int reserveGroupCapacity(@Param("id") Long id, @Param("peopleCount") Integer peopleCount,
@Param("maxPeople") Integer maxPeople, @Param("now") LocalDateTime now,
@Param("serviceStartAt") LocalDateTime serviceStartAt,
@Param("orderCutoffAt") LocalDateTime orderCutoffAt);
- @Update("UPDATE guide_receiving_session SET status = 'ASSIGNED', current_people_count = #{peopleCount}, " +
- "first_order_at = #{now}, service_start_at = #{now}, order_cutoff_at = #{now}, updated_at = NOW() " +
+ @Update("UPDATE guide_receiving_session SET receiving_mode = 'PRIVATE', status = 'ASSIGNED', current_people_count = #{peopleCount}, " +
+ "first_order_at = #{now}, service_start_at = #{serviceStartAt}, order_cutoff_at = #{now}, updated_at = NOW() " +
"WHERE id = #{id} AND deleted = 0 AND status = 'RECEIVING'")
- int assignPrivate(@Param("id") Long id, @Param("peopleCount") Integer peopleCount, @Param("now") LocalDateTime now);
+ int assignPrivate(@Param("id") Long id, @Param("peopleCount") Integer peopleCount,
+ @Param("now") LocalDateTime now, @Param("serviceStartAt") LocalDateTime serviceStartAt);
@Update("UPDATE guide_receiving_session SET status = 'IN_SERVICE', updated_at = NOW() " +
"WHERE id = #{id} AND deleted = 0 AND status = 'RECEIVING' AND service_start_at <= NOW()")
int startDueSession(Long id);
+
+ @Update("UPDATE guide_receiving_session SET status = 'IN_SERVICE', updated_at = NOW() " +
+ "WHERE id = #{id} AND guide_id = #{guideId} AND deleted = 0 AND status IN ('RECEIVING', 'ASSIGNED')")
+ int startSession(@Param("id") Long id, @Param("guideId") Long guideId);
+
+ @Update("UPDATE guide_receiving_session SET status = 'STOPPED', updated_at = NOW() " +
+ "WHERE id = #{id} AND guide_id = #{guideId} AND deleted = 0 AND status = 'IN_SERVICE'")
+ int stopServiceSession(@Param("id") Long id, @Param("guideId") Long guideId);
+
+ @Update("UPDATE guide_receiving_session SET reminder_pushed_at = #{now}, updated_at = NOW() " +
+ "WHERE id = #{id} AND deleted = 0 AND status = 'RECEIVING' AND reminder_pushed_at IS NULL")
+ int claimServiceReminder(@Param("id") Long id, @Param("now") LocalDateTime now);
+
+ @Update("UPDATE guide_receiving_session SET reminder_pushed_at = NULL, updated_at = NOW() " +
+ "WHERE id = #{id} AND deleted = 0 AND reminder_pushed_at = #{claimedAt}")
+ int releaseServiceReminder(@Param("id") Long id, @Param("claimedAt") LocalDateTime claimedAt);
+
+ @Update("UPDATE guide_receiving_session SET status = 'RECEIVING', current_people_count = 0, " +
+ "receiving_mode = CASE WHEN service_types LIKE '%GROUP_%' AND service_types LIKE '%PRIVATE_%' THEN 'ALL' ELSE receiving_mode END, " +
+ "first_order_at = NULL, service_start_at = NULL, order_cutoff_at = NULL, reminder_pushed_at = NULL, " +
+ "updated_at = NOW() WHERE id = #{id} AND guide_id = #{guideId} AND deleted = 0 AND status = 'ASSIGNED'")
+ int reopenPrivateAfterOrderCancellation(@Param("id") Long id, @Param("guideId") Long guideId);
+
+ @Update("UPDATE guide_receiving_session SET current_people_count = CASE " +
+ "WHEN current_people_count >= #{peopleCount} THEN current_people_count - #{peopleCount} ELSE 0 END, " +
+ "updated_at = NOW() WHERE id = #{id} AND guide_id = #{guideId} AND deleted = 0 AND status = 'RECEIVING'")
+ int releaseGroupCapacity(@Param("id") Long id, @Param("guideId") Long guideId,
+ @Param("peopleCount") Integer peopleCount);
+
+ @Update("UPDATE guide_receiving_session SET receiving_mode = CASE WHEN service_types LIKE '%GROUP_%' AND service_types LIKE '%PRIVATE_%' THEN 'ALL' ELSE receiving_mode END, " +
+ "current_people_count = 0, first_order_at = NULL, " +
+ "service_start_at = NULL, order_cutoff_at = NULL, reminder_pushed_at = NULL, updated_at = NOW() " +
+ "WHERE id = #{id} AND guide_id = #{guideId} AND deleted = 0 AND status = 'RECEIVING'")
+ int resetGroupAfterOrderCancellation(@Param("id") Long id, @Param("guideId") Long guideId);
+
+ @Update("UPDATE guide_receiving_session SET status = 'STOPPED', updated_at = NOW() " +
+ "WHERE guide_id = #{guideId} AND deleted = 0 AND status = 'RECEIVING'")
+ int stopReceivingByGuide(Long guideId);
}
--
Gitblit v1.7.1