| | |
| | | package com.tourguide.modules.order.dto; |
| | | |
| | | import com.tourguide.modules.order.entity.TourOrder; |
| | | import com.tourguide.modules.operation.entity.ScenicMeetingPoint; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Collections; |
| | |
| | | public class GuideOrderResponse { |
| | | private final Long id; |
| | | private final String orderNo; |
| | | private final Long scenicSpotId; |
| | | private final String scenicName; |
| | | private final String scenicShortName; |
| | | private final Long meetingPointId; |
| | | private final String meetingPointName; |
| | | private final String meetingPointAddress; |
| | | private final BigDecimal meetingPointLongitude; |
| | | private final BigDecimal meetingPointLatitude; |
| | | private final String serviceName; |
| | | private final Integer durationMinutes; |
| | | private final Integer quantity; |
| | |
| | | private final String customerPhone; |
| | | private final List<Customer> customers; |
| | | |
| | | private GuideOrderResponse(TourOrder order, Integer configuredDurationMinutes) { |
| | | private GuideOrderResponse(TourOrder order, Integer configuredDurationMinutes, ScenicMeetingPoint meetingPoint) { |
| | | this.id = order.getId(); |
| | | this.orderNo = order.getOrderNo(); |
| | | this.scenicSpotId = order.getScenicSpotId(); |
| | | this.scenicName = order.getScenicName(); |
| | | this.scenicShortName = shortScenicName(order.getScenicName()); |
| | | this.meetingPointName = order.getMeetingPointName(); |
| | | this.meetingPointId = order.getMeetingPointId() != null |
| | | ? order.getMeetingPointId() : meetingPoint == null ? null : meetingPoint.getId(); |
| | | this.meetingPointName = valueOrFallback(order.getMeetingPointName(), |
| | | meetingPoint == null ? null : meetingPoint.getPointName()); |
| | | this.meetingPointAddress = meetingPoint == null ? null : meetingPoint.getAddress(); |
| | | this.meetingPointLongitude = meetingPoint == null ? null : meetingPoint.getLongitude(); |
| | | this.meetingPointLatitude = meetingPoint == null ? null : meetingPoint.getLatitude(); |
| | | this.serviceName = serviceName(order); |
| | | this.durationMinutes = durationMinutes(configuredDurationMinutes, order.getOrderType()); |
| | | this.quantity = order.getPeopleCount() == null ? 0 : order.getPeopleCount(); |
| | |
| | | } |
| | | |
| | | public static GuideOrderResponse from(TourOrder order) { |
| | | return from(order, null); |
| | | return from(order, null, null); |
| | | } |
| | | |
| | | public static GuideOrderResponse from(TourOrder order, Integer configuredDurationMinutes) { |
| | | return new GuideOrderResponse(order, configuredDurationMinutes); |
| | | return from(order, configuredDurationMinutes, null); |
| | | } |
| | | |
| | | public static GuideOrderResponse from(TourOrder order, Integer configuredDurationMinutes, |
| | | ScenicMeetingPoint meetingPoint) { |
| | | return new GuideOrderResponse(order, configuredDurationMinutes, meetingPoint); |
| | | } |
| | | |
| | | private static String guideStatus(String orderStatus) { |
| | |
| | | return scenicName.replace("景区", ""); |
| | | } |
| | | |
| | | private static String valueOrFallback(String value, String fallback) { |
| | | return value == null || value.trim().isEmpty() ? fallback : value; |
| | | } |
| | | |
| | | private static LocalDateTime firstPresent(LocalDateTime first, LocalDateTime second) { |
| | | return first == null ? second : first; |
| | | } |
| | |
| | | |
| | | public Long getId() { return id; } |
| | | public String getOrderNo() { return orderNo; } |
| | | public Long getScenicSpotId() { return scenicSpotId; } |
| | | public String getScenicName() { return scenicName; } |
| | | public String getScenicShortName() { return scenicShortName; } |
| | | public Long getMeetingPointId() { return meetingPointId; } |
| | | public String getMeetingPointName() { return meetingPointName; } |
| | | public String getMeetingPointAddress() { return meetingPointAddress; } |
| | | public BigDecimal getMeetingPointLongitude() { return meetingPointLongitude; } |
| | | public BigDecimal getMeetingPointLatitude() { return meetingPointLatitude; } |
| | | public String getServiceName() { return serviceName; } |
| | | public Integer getDurationMinutes() { return durationMinutes; } |
| | | public Integer getQuantity() { return quantity; } |