同步代码
This commit is contained in:
parent
1aa9fb2c63
commit
803efc7790
|
@ -14,6 +14,7 @@ import com.chint.domain.repository.CityRepository;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
import com.chint.domain.repository.UserRepository;
|
import com.chint.domain.repository.UserRepository;
|
||||||
import com.chint.domain.service.OrderDomainService;
|
import com.chint.domain.service.OrderDomainService;
|
||||||
|
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
||||||
import com.chint.domain.value_object.*;
|
import com.chint.domain.value_object.*;
|
||||||
import com.chint.infrastructure.constant.FSSCConstant;
|
import com.chint.infrastructure.constant.FSSCConstant;
|
||||||
import com.chint.infrastructure.constant.LegConstant;
|
import com.chint.infrastructure.constant.LegConstant;
|
||||||
|
@ -30,6 +31,9 @@ import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||||
|
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OrderQuery {
|
public class OrderQuery {
|
||||||
|
|
||||||
|
@ -48,6 +52,8 @@ public class OrderQuery {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EstimateAdapter estimateAdapter;
|
||||||
|
|
||||||
public RouteOrder queryByOrderId(OrderQueryData queryData) {
|
public RouteOrder queryByOrderId(OrderQueryData queryData) {
|
||||||
return routeRepository.queryById(queryData.getRouteId()).reloadStatus();
|
return routeRepository.queryById(queryData.getRouteId()).reloadStatus();
|
||||||
|
@ -246,7 +252,7 @@ public class OrderQuery {
|
||||||
.endDate(simpleFormatter.format(leg.getEndTime()))
|
.endDate(simpleFormatter.format(leg.getEndTime()))
|
||||||
.systemStatus(FSSCConstant.TRIP_CALLBACK_RECEIPT_STATUS)
|
.systemStatus(FSSCConstant.TRIP_CALLBACK_RECEIPT_STATUS)
|
||||||
.parentScheduleNum(leg.getLegNo())
|
.parentScheduleNum(leg.getLegNo())
|
||||||
.amount(leg.getAmount())
|
.amount(leg.queryEstimateAmount(estimateAdapter,SUPPLIER_C_TRIP).getEstimateAmount())
|
||||||
.reserveCount("1")
|
.reserveCount("1")
|
||||||
.quoteGroupNum("0")
|
.quoteGroupNum("0")
|
||||||
.extStatus(0)
|
.extStatus(0)
|
||||||
|
|
|
@ -82,12 +82,11 @@ public class Leg {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Leg queryEstimateAmount(EstimateAdapter estimateAdapter, String supplierName) {
|
public Leg queryEstimateAmount(EstimateAdapter estimateAdapter, String supplierName) {
|
||||||
if (this.legStatus >= (LegConstant.LEG_STATUS_NOT_ORDERED)) {
|
|
||||||
this.estimateAmount = estimateAdapter.of(supplierName).amountEstimate(this);
|
this.estimateAmount = estimateAdapter.of(supplierName).amountEstimate(this);
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Leg reloadStatus() {
|
public Leg reloadStatus() {
|
||||||
if (eventList == null || eventList.isEmpty()) {
|
if (eventList == null || eventList.isEmpty()) {
|
||||||
this.legStatus = LegConstant.LEG_STATUS_PREPARE;
|
this.legStatus = LegConstant.LEG_STATUS_PREPARE;
|
||||||
|
|
|
@ -1,26 +1,79 @@
|
||||||
package com.chint.domain.service.amount_estimate;
|
package com.chint.domain.service.amount_estimate;
|
||||||
|
|
||||||
|
import com.chint.application.queryies.estimate.EstimatePrice;
|
||||||
import com.chint.domain.aggregates.order.Leg;
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
|
import com.chint.domain.service.OrderDomainService;
|
||||||
|
import com.chint.domain.value_object.FlightPriceData;
|
||||||
|
import com.chint.domain.value_object.HotelPriceData;
|
||||||
|
import com.chint.domain.value_object.PriceQueryData;
|
||||||
|
import com.chint.domain.value_object.TrainPriceData;
|
||||||
import com.chint.interfaces.rest.ctrip.CTripEstimateRequest;
|
import com.chint.interfaces.rest.ctrip.CTripEstimateRequest;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CTripEstimate implements AmountEstimate {
|
public class CTripEstimate implements AmountEstimate {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CTripEstimateRequest cTripEstimateRequest;
|
private CTripEstimateRequest cTripEstimateRequest;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EstimatePrice estimatePrice;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderDomainService orderDomainService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String amountEstimate(Leg leg) {
|
public String amountEstimate(Leg leg) {
|
||||||
|
|
||||||
// cTripEstimateRequest.generateBaseRequest(null,)
|
Integer legType = leg.getLegType();
|
||||||
|
return switch (legType) {
|
||||||
return null;
|
case LEG_TYPE_TRAIN -> queryTrainPrice(leg);
|
||||||
|
case LEG_TYPE_AIRPLANE -> queryTrainPrice(leg);
|
||||||
|
case LEG_TYPE_HOTEL -> queryTrainPrice(leg);
|
||||||
|
default -> throw new IllegalStateException("Unexpected value: " + legType);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String amountEstimate(RouteOrder routeOrder) {
|
public String amountEstimate(RouteOrder routeOrder) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String queryFlightPrice(Leg leg) {
|
||||||
|
PriceQueryData queryData = getQueryData(leg);
|
||||||
|
FlightPriceData flightPriceData = estimatePrice.queryFlightPrice(queryData);
|
||||||
|
return flightPriceData.getMaxPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String queryHotelPrice(Leg leg) {
|
||||||
|
PriceQueryData queryData = getQueryData(leg);
|
||||||
|
HotelPriceData hotelPriceData = estimatePrice.queryHotelPrice(queryData);
|
||||||
|
return hotelPriceData.getMaxPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String queryTrainPrice(Leg leg) {
|
||||||
|
PriceQueryData queryData = getQueryData(leg);
|
||||||
|
TrainPriceData trainPriceData = estimatePrice.queryTrainPrice(queryData);
|
||||||
|
return trainPriceData.getMaxPrice();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private PriceQueryData getQueryData(Leg leg) {
|
||||||
|
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
PriceQueryData priceQueryData = new PriceQueryData();
|
||||||
|
leg = orderDomainService.queryLocation(List.of(leg)).get(0);
|
||||||
|
priceQueryData.setArriveCity(leg.getDestinationLocation().getLocationName());
|
||||||
|
priceQueryData.setDepartCity(leg.getOriginLocation().getLocationName());
|
||||||
|
priceQueryData.setDepartDate(dateTimeFormatter.format(leg.getStartTime()));
|
||||||
|
return priceQueryData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue