liujie
2026-08-04 e9e42b621afdf6ac94f5327ee843b32b10a401b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package com.tourguide.modules.order.dto;
 
import com.tourguide.modules.order.entity.TourOrder;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
 
/** 导游端订单列表与详情返回对象,仅暴露导游工作台需要的订单信息。 */
public class GuideOrderResponse {
    private final Long id;
    private final String orderNo;
    private final String scenicName;
    private final String scenicShortName;
    private final String meetingPointName;
    private final String serviceName;
    private final Integer durationMinutes;
    private final Integer quantity;
    private final String status;
    private final LocalDateTime receiveTime;
    private final LocalDateTime receiveStartTime;
    private final LocalDateTime lectureStartTime;
    private final LocalDateTime lectureEndTime;
    private final LocalDateTime completedAt;
    private final String customerPhone;
    private final List<Customer> customers;
 
    private GuideOrderResponse(TourOrder order) {
        this.id = order.getId();
        this.orderNo = order.getOrderNo();
        this.scenicName = order.getScenicName();
        this.scenicShortName = shortScenicName(order.getScenicName());
        this.meetingPointName = order.getMeetingPointName();
        this.serviceName = serviceName(order);
        this.durationMinutes = durationMinutes(order.getOrderType());
        this.quantity = order.getPeopleCount() == null ? 0 : order.getPeopleCount();
        this.status = guideStatus(order.getStatus());
        this.receiveTime = firstPresent(order.getAcceptedAt(), order.getPlacedAt(), order.getCreatedAt());
        this.receiveStartTime = this.receiveTime;
        this.lectureStartTime = firstPresent(order.getServiceStartedAt(), order.getArrivedAt());
        this.lectureEndTime = order.getCompletedAt();
        this.completedAt = order.getCompletedAt();
        this.customerPhone = order.getVisitorMobile();
        this.customers = Collections.singletonList(new Customer(
                1,
                order.getVisitorMobile(),
                this.quantity,
                firstPresent(order.getAcceptedAt(), order.getPlacedAt(), order.getCreatedAt())));
    }
 
    public static GuideOrderResponse from(TourOrder order) {
        return new GuideOrderResponse(order);
    }
 
    private static String guideStatus(String orderStatus) {
        if ("IN_SERVICE".equals(orderStatus)) { return "serving"; }
        if ("COMPLETED".equals(orderStatus)) { return "completed"; }
        if ("CANCELLED".equals(orderStatus) || "REFUNDED".equals(orderStatus)) { return "canceled"; }
        return "accepted";
    }
 
    private static String serviceName(TourOrder order) {
        if (order.getPackageName() != null && !order.getPackageName().trim().isEmpty()) {
            return order.getPackageName();
        }
        if ("GROUP_PREMIUM".equals(order.getOrderType())) { return "拼团 · 精讲"; }
        if ("PRIVATE_QUICK".equals(order.getOrderType())) { return "包团 · 快讲"; }
        if ("PRIVATE_PREMIUM".equals(order.getOrderType())) { return "包团 · 精讲"; }
        return "拼团 · 快讲";
    }
 
    private static Integer durationMinutes(String orderType) {
        if ("GROUP_PREMIUM".equals(orderType) || "PRIVATE_PREMIUM".equals(orderType)) {
            return 60;
        }
        return 30;
    }
 
    private static String shortScenicName(String scenicName) {
        if (scenicName == null || scenicName.trim().isEmpty()) {
            return "";
        }
        return scenicName.replace("景区", "");
    }
 
    private static LocalDateTime firstPresent(LocalDateTime first, LocalDateTime second) {
        return first == null ? second : first;
    }
 
    private static LocalDateTime firstPresent(LocalDateTime first, LocalDateTime second, LocalDateTime third) {
        return firstPresent(firstPresent(first, second), third);
    }
 
    public Long getId() { return id; }
    public String getOrderNo() { return orderNo; }
    public String getScenicName() { return scenicName; }
    public String getScenicShortName() { return scenicShortName; }
    public String getMeetingPointName() { return meetingPointName; }
    public String getServiceName() { return serviceName; }
    public Integer getDurationMinutes() { return durationMinutes; }
    public Integer getQuantity() { return quantity; }
    public String getStatus() { return status; }
    public LocalDateTime getReceiveTime() { return receiveTime; }
    public LocalDateTime getReceiveStartTime() { return receiveStartTime; }
    public LocalDateTime getLectureStartTime() { return lectureStartTime; }
    public LocalDateTime getLectureEndTime() { return lectureEndTime; }
    public LocalDateTime getCompletedAt() { return completedAt; }
    public String getCustomerPhone() { return customerPhone; }
    public List<Customer> getCustomers() { return customers; }
 
    public static class Customer {
        private final int no;
        private final String phone;
        private final int people;
        private final LocalDateTime time;
 
        public Customer(int no, String phone, int people, LocalDateTime time) {
            this.no = no;
            this.phone = phone;
            this.people = people;
            this.time = time;
        }
 
        public int getNo() { return no; }
        public String getPhone() { return phone; }
        public int getPeople() { return people; }
        public LocalDateTime getTime() { return time; }
    }
}