修改同程飞机订单明细的生成逻辑
This commit is contained in:
parent
19690efda1
commit
1a5139f0df
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
public class OrderDetailQueryParam extends BaseQuery {
|
||||
private Long orderId;
|
||||
private Long routeId;
|
||||
private String orderNo;
|
||||
private Integer ifNotStart; //0全部,1未出行
|
||||
private List<Integer> productTypes;
|
||||
}
|
||||
|
|
|
@ -109,36 +109,36 @@ public class OrderDetailController {
|
|||
|
||||
@ApiOperation("查询携程订单")
|
||||
@PostMapping("/public/query/cTrip")
|
||||
public Result<Object> queryOrderDetail(@RequestBody String orderNo) {
|
||||
SearchOrderResponse response = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderNo);
|
||||
public Result<Object> queryOrderDetail(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
|
||||
SearchOrderResponse response = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderDetailQueryParam.getOrderNo());
|
||||
return Result.Success(SUCCESS, response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询同程订单火车")
|
||||
@PostMapping("/public/query/ly/train")
|
||||
public Result<Object> queryOrderDetailTrain(@RequestBody String orderNo) {
|
||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail(orderNo);
|
||||
public Result<Object> queryOrderDetailTrain(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
|
||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail(orderDetailQueryParam.getOrderNo());
|
||||
return Result.Success(SUCCESS, trainOrderDetail);
|
||||
}
|
||||
|
||||
@ApiOperation("查询同程订单酒店")
|
||||
@PostMapping("/public/query/ly/hotel")
|
||||
public Result<Object> queryOrderDetailHotel(@RequestBody String orderNo) {
|
||||
HotelDetailResponse response = lySearchRequest.getHotelOrderDetail(orderNo);
|
||||
public Result<Object> queryOrderDetailHotel(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
|
||||
HotelDetailResponse response = lySearchRequest.getHotelOrderDetail(orderDetailQueryParam.getOrderNo());
|
||||
return Result.Success(SUCCESS, response);
|
||||
}
|
||||
|
||||
@ApiOperation("查询同程订单用车")
|
||||
@PostMapping("/public/query/ly/car")
|
||||
public Result<Object> queryOrderDetailCar(@RequestBody String orderNo) {
|
||||
CarDetailResponse carDetailResponse = lySearchRequest.getCarDetailResponse(orderNo);
|
||||
public Result<Object> queryOrderDetailCar(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
|
||||
CarDetailResponse carDetailResponse = lySearchRequest.getCarDetailResponse(orderDetailQueryParam.getOrderNo());
|
||||
return Result.Success(SUCCESS, carDetailResponse);
|
||||
}
|
||||
|
||||
@ApiOperation("查询同程订单飞机")
|
||||
@PostMapping("/public/query/ly/flight")
|
||||
public Result<Object> queryOrderDetailFlight(@RequestBody String orderNo) {
|
||||
FlightOrderResponse flightOrderDetail = lySearchRequest.getFlightOrderDetail(orderNo);
|
||||
public Result<Object> queryOrderDetailFlight(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
|
||||
FlightOrderResponse flightOrderDetail = lySearchRequest.getFlightOrderDetail(orderDetailQueryParam.getOrderNo());
|
||||
return Result.Success(SUCCESS, flightOrderDetail);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.domain.factoriy.order_detail;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.queryies.estimate.EstimatePrice;
|
||||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
@ -44,6 +45,9 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
@Autowired
|
||||
private OrderDetailRepository orderDetailRepository;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailFactory orderDetailFactory;
|
||||
|
||||
@Override
|
||||
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
|
||||
CarDetailResponse.DataWrapper data = (CarDetailResponse.DataWrapper) carOrderDetailData;
|
||||
|
@ -61,10 +65,113 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
|
||||
@Override
|
||||
public FlightOrderDetail createFlightOrderDetail(Object flightOrderDetailData) {
|
||||
// 获取对象的Class对象
|
||||
|
||||
FlightOrderResponse.Data data = (FlightOrderResponse.Data) flightOrderDetailData;
|
||||
FlightOrderDetail convertFlight = convertFlightOrderDetail(data);
|
||||
return convertFlight;
|
||||
|
||||
FlightOrderResponse.OrderDetails orderDetails = data.getOrderDetails();
|
||||
OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderDetails.getOrderSerialNo())
|
||||
.orElseThrow(() -> new NotFoundException(NOT_FOUND));
|
||||
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
|
||||
|
||||
BaseOrderExtension baseOrderExtension = orderDetailFactory.buildWithRouteOrder(routeOrder);
|
||||
|
||||
FlightOrderDetail flightOrderDetail;
|
||||
Optional<FlightOrderDetail> first = routeOrder
|
||||
.getOrderDetails()
|
||||
.stream()
|
||||
.filter(it -> it.getOrderNo().equals(orderDetails.getOrderSerialNo()))
|
||||
.map(OrderDetail::getFlightOrderDetail)
|
||||
.findFirst();
|
||||
|
||||
flightOrderDetail = first.orElseGet(() -> BeanUtil.copyProperties(baseOrderExtension, FlightOrderDetail.class));
|
||||
|
||||
|
||||
//飞机票状态属性保存
|
||||
OrderEvent lastEvent = orderDetail.getLastEvent();
|
||||
if (orderDetails.getIsChangeOrder()) {
|
||||
//如果发现同程的订单号里面还有C就能够判断出 ,它是改签订单
|
||||
flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_CHANGE);
|
||||
}
|
||||
if (lastEvent != null) {
|
||||
flightOrderDetail.setOrderStatus(lastEvent.mapToFlightOrderDetailStatus());
|
||||
} else {
|
||||
//如果订单事件为空,那么就需要重新根据查询到的订单信息重新进行映射
|
||||
Integer orderStatus = orderDetails.getOrderStatus();
|
||||
flightOrderDetail.setOrderStatus(
|
||||
OrderEvent.mapToFlightOrderDetailStatus(
|
||||
LYOrderUtil.mapFlightStatus(orderStatus.toString())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//配置订单明细的父订单信息
|
||||
flightOrderDetail.setParentOrderNo(orderDetails.getParentOrderSerialNo());
|
||||
flightOrderDetail.setOriginalOrderNo(orderDetails.getOriginalOrderNo());
|
||||
flightOrderDetail.setChangedScheduleNum(orderDetails.getOriginalOrderNo());
|
||||
|
||||
//获取订单明细的退票信息, 如果有的话也补上
|
||||
FlightOrderResponse.FlightOrderRefundInfo flightOrderRefundInfo = orderDetails.getFlightOrderRefundInfo();
|
||||
if (flightOrderRefundInfo != null) {
|
||||
flightOrderDetail.setRefundFee(String.valueOf(flightOrderRefundInfo.getRefundFee()));
|
||||
flightOrderDetail.setRefundAmount(String.valueOf(flightOrderRefundInfo.getRefundPrice())); //无refundPrice
|
||||
}
|
||||
flightOrderDetail.setCreateTime(orderDetails.getBookDate());
|
||||
flightOrderDetail.setOrderAmount(String.valueOf(orderDetails.getTotalPrice()));
|
||||
flightOrderDetail.setPreServiceFee(String.valueOf(orderDetails.getServicePrice()));
|
||||
flightOrderDetail.setPostServiceFee(String.valueOf(orderDetails.getAfterSettlementServicePrice()));
|
||||
flightOrderDetail.setCompanyPaymentAmount(String.valueOf(orderDetails.getTotalPrice().toString()));
|
||||
flightOrderDetail.setNotBookedLowestPriceReason(orderDetails.getFoulReason());
|
||||
flightOrderDetail.setPaymentType("0");
|
||||
|
||||
|
||||
List<FlightOrderResponse.FlightSegment> flightSegmentList = data.getFlightSegmentList();
|
||||
if (flightSegmentList != null && !flightSegmentList.isEmpty()) {
|
||||
FlightOrderResponse.FlightSegment flightSegment = flightSegmentList.get(0);
|
||||
flightOrderDetail.setEndAirportName(flightSegment.getArriveAirport());
|
||||
flightOrderDetail.setEndAirportCode(flightSegment.getArriveAirportCode());
|
||||
flightOrderDetail.setEndTerminal(flightSegment.getArriveTerminal());
|
||||
flightOrderDetail.setDistance(flightSegment.getMileAge().toString());
|
||||
flightOrderDetail.setFlightCompName(flightSegment.getShareAirlineName());
|
||||
flightOrderDetail.setFlightNum(flightSegment.getShareNum());
|
||||
flightOrderDetail.setSeatPoint(flightSegment.getSeatCode());
|
||||
flightOrderDetail.setSeatPointName(flightSegment.getSeatName());
|
||||
flightOrderDetail.setStartTime(flightSegment.getDepartTimeFull());
|
||||
flightOrderDetail.setArriveTime(flightSegment.getArriveTimeFull());
|
||||
flightOrderDetail.setStartCityName(flightSegment.getDepartCity());
|
||||
flightOrderDetail.setStartAirportName(flightSegment.getDepartAirport());
|
||||
flightOrderDetail.setStartAirportCode(flightSegment.getDepartAirportCode());
|
||||
flightOrderDetail.setStartTerminal(flightSegment.getDepartTerminal());
|
||||
flightOrderDetail.setEndCityName(flightSegment.getArriveCity());
|
||||
flightOrderDetail.setFlightModel(flightSegment.getFlightNo());
|
||||
flightOrderDetail.setStandard(flightSegment.getSeatName() + flightSegment.getSeatDiscount());
|
||||
}
|
||||
|
||||
List<FlightOrderResponse.Passenger> passengerList = data.getPassengerList();
|
||||
if (passengerList != null && !passengerList.isEmpty()) {
|
||||
FlightOrderResponse.Passenger passenger = data.getPassengerList().get(0);
|
||||
flightOrderDetail.setFuelTax(passenger.getFuelTax().toString());
|
||||
flightOrderDetail.setAirportTax(passenger.getAirportTax().toString());
|
||||
flightOrderDetail.setFacePrice(passenger.getParPrice().toString());
|
||||
flightOrderDetail.setChangeFee(passenger.getChangeFee().toString());
|
||||
flightOrderDetail.setUpFee(passenger.getChangePrice().toString());
|
||||
flightOrderDetail.setTicketNo(passenger.getTicketNo());
|
||||
flightOrderDetail.setChangedTicketNo(passenger.getTicketNo()); //无改签后票号
|
||||
flightOrderDetail.setUserName(passenger.getPassengerName());
|
||||
flightOrderDetail.setUserCode(passenger.getOutEmployeeId());
|
||||
flightOrderDetail.setPhone(passenger.getContractPhone());
|
||||
flightOrderDetail.setInsuranceFee(passenger.getInsurancePrice().toString());
|
||||
}
|
||||
|
||||
orderDetail.getOrderEventList()
|
||||
.stream()
|
||||
.filter(it -> it.getEventType().equals(ORDER_EVENT_ETA))
|
||||
.findFirst()
|
||||
.ifPresentOrElse(it -> {
|
||||
flightOrderDetail.setOverStandard("是");
|
||||
flightOrderDetail.setOverStandardReason(it.getExtension());
|
||||
}, () -> flightOrderDetail.setOverStandard("否"));
|
||||
|
||||
return flightOrderDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,6 +193,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderDetails.getOrderSerialNo())
|
||||
.orElseThrow(() -> new NotFoundException(NOT_FOUND));
|
||||
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
|
||||
|
||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
FlightOrderDetail flightOrderDetail = new FlightOrderDetail();
|
||||
if (approveOrderNo != null) {
|
||||
|
@ -167,7 +275,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
if (flightOrderRefundInfo != null) {
|
||||
flightOrderDetail.setRefundFee(String.valueOf(flightOrderRefundInfo.getRefundFee()));
|
||||
flightOrderDetail.setRefundAmount(String.valueOf(flightOrderRefundInfo.getRefundPrice())); //无refundPrice
|
||||
|
||||
}
|
||||
flightOrderDetail.setCreateTime(orderDetails.getBookDate());
|
||||
flightOrderDetail.setOrderAmount(String.valueOf(orderDetails.getTotalPrice()));
|
||||
|
@ -685,7 +792,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
}
|
||||
|
||||
|
||||
|
||||
List<CarDetailResponse.SubmitItem> submitItemList =
|
||||
data.getTravelDataInfo().getSubmitItemList();
|
||||
|
||||
|
@ -751,5 +857,4 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package com.chint.domain.factoriy.order_detail;
|
||||
|
||||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.aggregates.order.OrderEvent;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.value_object.*;
|
||||
import com.chint.domain.value_object.enums.CurrencyType;
|
||||
import com.chint.domain.value_object.OrderLegData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -19,18 +21,19 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
|
|||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Override
|
||||
public OrderDetail create(OrderLegData orderLegData) {
|
||||
OrderDetail orderDetail = OrderDetail.of(orderLegData.getOutOrderNo(), orderLegData.getSupplierName());
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if(orderLegData.getStartTime() != null){
|
||||
if (orderLegData.getStartTime() != null) {
|
||||
orderDetail.setStartTime(LocalDateTime.parse(orderLegData.getStartTime(), dateTimeFormatter));
|
||||
}
|
||||
if(orderLegData.getEndTime() != null){
|
||||
if (orderLegData.getEndTime() != null) {
|
||||
orderDetail.setEndTime(LocalDateTime.parse(orderLegData.getEndTime(), dateTimeFormatter));
|
||||
}
|
||||
orderDetail.setOrderDate(LocalDateTime.parse(orderLegData.getOrderTime(), dateTimeFormatter));
|
||||
// orderDetail.setCurrencyType(CurrencyType.getByCode(orderLegData.getCurrencyCode()));
|
||||
// orderDetail.setCurrencyType(CurrencyType.getByCode(orderLegData.getCurrencyCode()));
|
||||
orderDetail.setDestinationId(orderLegData.getDestinationId());
|
||||
orderDetail.setOriginId(orderLegData.getOriginId());
|
||||
orderDetail
|
||||
|
@ -48,6 +51,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
|
|||
|
||||
@Override
|
||||
public BaseOrderExtension buildWithRouteOrder(RouteOrder routeOrder) {
|
||||
routeOrder.reloadStatus();
|
||||
BaseOrderExtension baseOrderExtension = new BaseOrderExtension();
|
||||
//完成身份信息
|
||||
String userId = routeOrder.getUserId();
|
||||
|
@ -59,18 +63,20 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
|
|||
|
||||
//配置供应商信息
|
||||
String supplierName = routeOrder.getSupplierName();
|
||||
if(supplierName.equals(SUPPLIER_C_TRIP)){
|
||||
if (supplierName.equals(SUPPLIER_C_TRIP)) {
|
||||
baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
|
||||
} else {
|
||||
baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
|
||||
}
|
||||
|
||||
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||
if(approveOrderNo != null){
|
||||
if (approveOrderNo != null) {
|
||||
baseOrderExtension.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
|
||||
baseOrderExtension.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
|
||||
baseOrderExtension.setCostCenter(approveOrderNo.getCostCenter());
|
||||
baseOrderExtension.setProjectOrderNo(approveOrderNo.getProjectName());
|
||||
baseOrderExtension.setOrderNo(approveOrderNo.getActualOrderNo());
|
||||
baseOrderExtension.setDetailId(approveOrderNo.getActualOrderNo());
|
||||
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
|
||||
if (sysCode != null) {
|
||||
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
|
||||
|
@ -89,6 +95,8 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
|
|||
}
|
||||
|
||||
//配置唯一标识
|
||||
baseOrderExtension.setReceiptsNum(routeOrder.getRouteOrderNo());
|
||||
baseOrderExtension.setSupplier(routeOrder.getSupplierCNName());
|
||||
return baseOrderExtension;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue