package com.tourguide.modules.order.dto;
|
|
import com.tourguide.modules.order.entity.TourOrder;
|
import com.tourguide.modules.order.domain.RefundAmountCalculator;
|
import com.tourguide.modules.operation.entity.OperationScenicSpot;
|
import com.tourguide.modules.operation.entity.ScenicMeetingPoint;
|
import com.tourguide.modules.operation.entity.ScenicPricing;
|
import com.tourguide.modules.review.entity.OrderReview;
|
import com.tourguide.modules.user.entity.GuideUser;
|
import java.math.BigDecimal;
|
import java.time.LocalDateTime;
|
import java.util.Collections;
|
import java.util.List;
|
|
public class TourOrderResponse {
|
private Long id;
|
private String orderNo;
|
private Long visitorId;
|
private String visitorNickname;
|
private String visitorMobile;
|
private String scenicName;
|
private String meetingPointName;
|
private String packageName;
|
private String familyNo;
|
private String orderType;
|
private Integer peopleCount;
|
private BigDecimal unitPrice;
|
private BigDecimal originalPrice;
|
private BigDecimal discountPrice;
|
private BigDecimal subtotalAmount;
|
private String discountType;
|
private BigDecimal discountAmount;
|
private BigDecimal amount;
|
private String paymentMethod;
|
private String paymentOrderNo;
|
private BigDecimal paymentAmount;
|
private LocalDateTime paymentTime;
|
private LocalDateTime placedAt;
|
private Integer meetingPointCount;
|
private Long guideId;
|
private String guideName;
|
private String guideMobile;
|
private String commissionSource;
|
private BigDecimal commissionRate;
|
private Long commissionTeamId;
|
private BigDecimal guideEarningAmount;
|
private LocalDateTime acceptedAt;
|
private LocalDateTime arrivedAt;
|
private LocalDateTime serviceStartedAt;
|
private LocalDateTime completedAt;
|
private LocalDateTime cancelledAt;
|
private String status;
|
private String refundStatus;
|
private BigDecimal refundAmount;
|
private BigDecimal refundedAmount;
|
private BigDecimal refundableAmount;
|
private LocalDateTime refundTime;
|
private String refundOrderNo;
|
private String refundMethod;
|
private List<TourOrderRefundResponse> refundRecords = Collections.emptyList();
|
private Long reviewId;
|
private LocalDateTime reviewedAt;
|
private LocalDateTime createdAt;
|
private LocalDateTime updatedAt;
|
private Long scenicSpotId;
|
private Long meetingPointId;
|
private Long servicePackageId;
|
private Integer durationMinutes;
|
private BigDecimal meetingPointLongitude;
|
private BigDecimal meetingPointLatitude;
|
private BigDecimal guideRating;
|
private String guideAvatar;
|
private Integer unacceptedAutoRefundMinutes;
|
private Integer unpaidCancelMinutes;
|
|
public static TourOrderResponse from(TourOrder order) {
|
TourOrderResponse response = new TourOrderResponse();
|
response.id = order.getId();
|
response.orderNo = order.getOrderNo();
|
response.visitorId = order.getVisitorId();
|
response.visitorNickname = order.getVisitorNickname();
|
response.visitorMobile = order.getVisitorMobile();
|
response.scenicSpotId = order.getScenicSpotId();
|
response.scenicName = order.getScenicName();
|
response.meetingPointId = order.getMeetingPointId();
|
response.meetingPointName = order.getMeetingPointName();
|
response.packageName = order.getPackageName();
|
response.servicePackageId = order.getServicePackageId();
|
response.familyNo = order.getFamilyNo();
|
response.orderType = order.getOrderType();
|
response.peopleCount = order.getPeopleCount();
|
response.unitPrice = order.getUnitPrice();
|
response.originalPrice = order.getOriginalPrice();
|
response.discountPrice = order.getDiscountPrice();
|
response.subtotalAmount = order.getSubtotalAmount();
|
response.discountType = order.getDiscountType();
|
response.discountAmount = order.getDiscountAmount();
|
response.amount = order.getAmount();
|
response.paymentMethod = order.getPaymentMethod();
|
response.paymentOrderNo = order.getPaymentOrderNo();
|
response.paymentAmount = order.getPaymentAmount();
|
response.paymentTime = order.getPaymentTime();
|
response.placedAt = order.getPlacedAt();
|
response.meetingPointCount = order.getMeetingPointCount();
|
response.guideId = order.getGuideId();
|
response.guideName = order.getGuideName();
|
response.guideMobile = order.getGuideMobile();
|
response.commissionSource = order.getCommissionSource();
|
response.commissionRate = order.getCommissionRate();
|
response.commissionTeamId = order.getCommissionTeamId();
|
response.guideEarningAmount = order.getGuideEarningAmount();
|
response.acceptedAt = order.getAcceptedAt();
|
response.arrivedAt = order.getArrivedAt();
|
response.serviceStartedAt = order.getServiceStartedAt();
|
response.completedAt = order.getCompletedAt();
|
response.cancelledAt = order.getCancelledAt();
|
response.status = order.getStatus();
|
response.refundStatus = order.getRefundStatus();
|
response.refundAmount = order.getRefundAmount();
|
response.refundedAmount = RefundAmountCalculator.refundedAmount(order);
|
response.refundableAmount = RefundAmountCalculator.refundableAmount(order);
|
response.refundTime = order.getRefundTime();
|
response.refundOrderNo = order.getRefundOrderNo();
|
response.refundMethod = order.getRefundMethod();
|
response.createdAt = order.getCreatedAt();
|
response.updatedAt = order.getUpdatedAt();
|
return response;
|
}
|
|
public static TourOrderResponse from(TourOrder order, OrderReview review) {
|
TourOrderResponse response = from(order);
|
if (review != null) {
|
response.reviewId = review.getId();
|
response.reviewedAt = review.getReviewedAt();
|
}
|
return response;
|
}
|
|
public TourOrderResponse enrich(OperationScenicSpot scenicSpot, ScenicMeetingPoint meetingPoint,
|
ScenicPricing pricing, GuideUser guide) {
|
if (scenicSpot != null) this.scenicSpotId = scenicSpot.getId();
|
if (meetingPoint != null) {
|
this.meetingPointId = meetingPoint.getId();
|
this.meetingPointLongitude = meetingPoint.getLongitude();
|
this.meetingPointLatitude = meetingPoint.getLatitude();
|
}
|
if (pricing != null) {
|
this.servicePackageId = pricing.getId();
|
this.durationMinutes = pricing.getDurationMinutes();
|
}
|
if (guide != null) {
|
this.guideRating = guide.getRating();
|
this.guideAvatar = guide.getAvatar();
|
}
|
return this;
|
}
|
|
public TourOrderResponse withUnacceptedAutoRefundMinutes(Integer minutes) {
|
this.unacceptedAutoRefundMinutes = minutes;
|
return this;
|
}
|
|
public TourOrderResponse withUnpaidCancelMinutes(Integer minutes) {
|
this.unpaidCancelMinutes = minutes;
|
return this;
|
}
|
|
public TourOrderResponse withRefundRecords(List<TourOrderRefundResponse> records) {
|
this.refundRecords = records == null ? Collections.<TourOrderRefundResponse>emptyList() : records;
|
return this;
|
}
|
|
public Long getId() { return id; }
|
public String getOrderNo() { return orderNo; }
|
public Long getVisitorId() { return visitorId; }
|
public String getVisitorNickname() { return visitorNickname; }
|
public String getVisitorMobile() { return visitorMobile; }
|
public String getScenicName() { return scenicName; }
|
public String getMeetingPointName() { return meetingPointName; }
|
public String getPackageName() { return packageName; }
|
public String getFamilyNo() { return familyNo; }
|
public String getOrderType() { return orderType; }
|
public Integer getPeopleCount() { return peopleCount; }
|
public BigDecimal getUnitPrice() { return unitPrice; }
|
public BigDecimal getOriginalPrice() { return originalPrice; }
|
public BigDecimal getDiscountPrice() { return discountPrice; }
|
public BigDecimal getSubtotalAmount() { return subtotalAmount; }
|
public String getDiscountType() { return discountType; }
|
public BigDecimal getDiscountAmount() { return discountAmount; }
|
public BigDecimal getAmount() { return amount; }
|
public String getPaymentMethod() { return paymentMethod; }
|
public String getPaymentOrderNo() { return paymentOrderNo; }
|
public BigDecimal getPaymentAmount() { return paymentAmount; }
|
public LocalDateTime getPaymentTime() { return paymentTime; }
|
public LocalDateTime getPlacedAt() { return placedAt; }
|
public Integer getMeetingPointCount() { return meetingPointCount; }
|
public Long getGuideId() { return guideId; }
|
public String getGuideName() { return guideName; }
|
public String getGuideMobile() { return guideMobile; }
|
public String getCommissionSource() { return commissionSource; }
|
public BigDecimal getCommissionRate() { return commissionRate; }
|
public Long getCommissionTeamId() { return commissionTeamId; }
|
public BigDecimal getGuideEarningAmount() { return guideEarningAmount; }
|
public LocalDateTime getAcceptedAt() { return acceptedAt; }
|
public LocalDateTime getArrivedAt() { return arrivedAt; }
|
public LocalDateTime getServiceStartedAt() { return serviceStartedAt; }
|
public LocalDateTime getCompletedAt() { return completedAt; }
|
public LocalDateTime getCancelledAt() { return cancelledAt; }
|
public String getStatus() { return status; }
|
public String getRefundStatus() { return refundStatus; }
|
public BigDecimal getRefundAmount() { return refundAmount; }
|
public BigDecimal getRefundedAmount() { return refundedAmount; }
|
public BigDecimal getRefundableAmount() { return refundableAmount; }
|
public LocalDateTime getRefundTime() { return refundTime; }
|
public String getRefundOrderNo() { return refundOrderNo; }
|
public String getRefundMethod() { return refundMethod; }
|
public List<TourOrderRefundResponse> getRefundRecords() { return refundRecords; }
|
public Long getReviewId() { return reviewId; }
|
public LocalDateTime getReviewedAt() { return reviewedAt; }
|
public LocalDateTime getCreatedAt() { return createdAt; }
|
public LocalDateTime getUpdatedAt() { return updatedAt; }
|
public Long getScenicSpotId() { return scenicSpotId; }
|
public Long getMeetingPointId() { return meetingPointId; }
|
public Long getServicePackageId() { return servicePackageId; }
|
public Integer getDurationMinutes() { return durationMinutes; }
|
public BigDecimal getMeetingPointLongitude() { return meetingPointLongitude; }
|
public BigDecimal getMeetingPointLatitude() { return meetingPointLatitude; }
|
public BigDecimal getGuideRating() { return guideRating; }
|
public String getGuideAvatar() { return guideAvatar; }
|
public Integer getUnacceptedAutoRefundMinutes() { return unacceptedAutoRefundMinutes; }
|
public Integer getUnpaidCancelMinutes() { return unpaidCancelMinutes; }
|
}
|