同步代码
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.UserRepository;
|
||||
import com.chint.domain.service.OrderDomainService;
|
||||
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
||||
import com.chint.domain.value_object.*;
|
||||
import com.chint.infrastructure.constant.FSSCConstant;
|
||||
import com.chint.infrastructure.constant.LegConstant;
|
||||
|
@ -30,6 +31,9 @@ import java.util.Objects;
|
|||
import java.util.stream.Collectors;
|
||||
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
|
||||
public class OrderQuery {
|
||||
|
||||
|
@ -48,6 +52,8 @@ public class OrderQuery {
|
|||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private EstimateAdapter estimateAdapter;
|
||||
|
||||
public RouteOrder queryByOrderId(OrderQueryData queryData) {
|
||||
return routeRepository.queryById(queryData.getRouteId()).reloadStatus();
|
||||
|
@ -246,7 +252,7 @@ public class OrderQuery {
|
|||
.endDate(simpleFormatter.format(leg.getEndTime()))
|
||||
.systemStatus(FSSCConstant.TRIP_CALLBACK_RECEIPT_STATUS)
|
||||
.parentScheduleNum(leg.getLegNo())
|
||||
.amount(leg.getAmount())
|
||||
.amount(leg.queryEstimateAmount(estimateAdapter,SUPPLIER_C_TRIP).getEstimateAmount())
|
||||
.reserveCount("1")
|
||||
.quoteGroupNum("0")
|
||||
.extStatus(0)
|
||||
|
|
|
@ -82,12 +82,11 @@ public class Leg {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public Leg reloadStatus() {
|
||||
if (eventList == null || eventList.isEmpty()) {
|
||||
this.legStatus = LegConstant.LEG_STATUS_PREPARE;
|
||||
|
|
|
@ -1,26 +1,79 @@
|
|||
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.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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
|
||||
@Component
|
||||
public class CTripEstimate implements AmountEstimate {
|
||||
|
||||
@Autowired
|
||||
private CTripEstimateRequest cTripEstimateRequest;
|
||||
|
||||
@Autowired
|
||||
private EstimatePrice estimatePrice;
|
||||
|
||||
@Autowired
|
||||
private OrderDomainService orderDomainService;
|
||||
|
||||
|
||||
@Override
|
||||
public String amountEstimate(Leg leg) {
|
||||
|
||||
// cTripEstimateRequest.generateBaseRequest(null,)
|
||||
|
||||
return null;
|
||||
Integer legType = leg.getLegType();
|
||||
return switch (legType) {
|
||||
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
|
||||
public String amountEstimate(RouteOrder routeOrder) {
|
||||
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