From 292d99125e515dfa20868f35ec841be18e58f321 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 20 Mar 2024 17:51:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=81=AB=E8=BD=A6=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=98=8E=E7=BB=86=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../out/OrderDetailController.java | 3 + .../queryies/OrderDetailQuery.java | 23 +- .../CTripOrderExtensionFactoryImpl.java | 19 +- .../LYOrderExtensionFactoryImpl.java | 219 ++++++++++++------ .../order_detail/OrderDetailFactory.java | 9 +- .../order_detail/OrderDetailFactoryImpl.java | 35 ++- .../order_detail/OrderExtensionFactory.java | 3 +- .../domain/service/OrderDomainService.java | 2 +- 8 files changed, 224 insertions(+), 89 deletions(-) diff --git a/src/main/java/com/chint/application/out/OrderDetailController.java b/src/main/java/com/chint/application/out/OrderDetailController.java index 25236e63..0d4a6585 100644 --- a/src/main/java/com/chint/application/out/OrderDetailController.java +++ b/src/main/java/com/chint/application/out/OrderDetailController.java @@ -178,6 +178,9 @@ public class OrderDetailController { trainOrderDetail.setDetailId(newOrderNo); trainOrderDetail.setCreateTime(command.getCreateTime()); trainOrderDetail.setId(null); + if(trainOrderDetail.getSupplier().equals(SUPPLIER_L_Y_CN_NAME)){ + orderExtensionCreator.of(SUPPLIER_L_Y).updateTrainOrderDetailData(trainOrderDetail,command.getOrderInfo()); + } } if (productType == 1) { FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail(); diff --git a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java index 4fd5c229..632bc85f 100644 --- a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java @@ -141,10 +141,16 @@ public class OrderDetailQuery { private Object processHotelOrderDetail(OrderDetail orderDetail, String systemType) { HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail(); + if (hotelOrderDetail != null && hotelOrderDetail.getOrderStatus() != null && !hotelOrderDetail.getOrderStatus().equals(FSSC_ORDER_STATUS_CANCEL) && systemType.equals(hotelOrderDetail.getBelongSysType())) { + + if (hotelOrderDetail.getCreateTime().contains("1900") || hotelOrderDetail.getCreateTime().contains("2999")) { + return null; + } + String receiptsNum = hotelOrderDetail.getReceiptsNum(); if (receiptsNum != null) { hotelOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); @@ -164,10 +170,16 @@ public class OrderDetailQuery { private Object processTrainOrderDetail(OrderDetail orderDetail, String systemType) { TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail(); + if (trainOrderDetail != null && trainOrderDetail.getOrderStatus() != null && !trainOrderDetail.getOrderStatus().equals(FSSC_ORDER_STATUS_CANCEL) && systemType.equals(trainOrderDetail.getBelongSysType())) { + + if (trainOrderDetail.getCreateTime().contains("1900") || trainOrderDetail.getCreateTime().contains("2999")) { + return null; + } + String receiptsNum = trainOrderDetail.getReceiptsNum(); if (receiptsNum != null) { trainOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); @@ -186,6 +198,11 @@ public class OrderDetailQuery { carOrderDetail.getOrderStatus() != null && !carOrderDetail.getOrderStatus().equals(FSSC_ORDER_STATUS_CANCEL) && systemType.equals(carOrderDetail.getBelongSysType())) { + + if (carOrderDetail.getCreateTime().contains("1900") || carOrderDetail.getCreateTime().contains("2999")) { + return null; + } + String receiptsNum = carOrderDetail.getReceiptsNum(); if (receiptsNum != null) { carOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); @@ -201,11 +218,15 @@ public class OrderDetailQuery { private Object processFlightOrderDetail(OrderDetail orderDetail, String systemType) { FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail(); - if (flightOrderDetail != null && flightOrderDetail.getOrderStatus() != null && !flightOrderDetail.getOrderStatus().equals(FSSC_ORDER_STATUS_CANCEL) && systemType.equals(flightOrderDetail.getBelongSysType())) { + + if (flightOrderDetail.getCreateTime().contains("1900") || flightOrderDetail.getCreateTime().contains("2999")) { + return null; + } + String receiptsNum = flightOrderDetail.getReceiptsNum(); if (receiptsNum != null) { flightOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java index b9176fdf..39fbde7c 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java @@ -13,6 +13,8 @@ import com.chint.interfaces.rest.ctrip.dto.search.flight.*; import com.chint.interfaces.rest.ctrip.dto.search.hotel.ClientInfo; import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity; import com.chint.interfaces.rest.ctrip.dto.search.hotel.PaymentReceived; +import com.chint.interfaces.rest.ctrip.tools.CTripUtils; +import com.chint.interfaces.rest.ly.tools.LYOrderUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -185,7 +187,13 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { @Override public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) { + // 携程暂无火车 + return null; + } + @Override + public TrainOrderDetail updateTrainOrderDetailData(TrainOrderDetail flightOrderDetail, Object trainOrderInfo) { + // 携程暂无火车 return null; } @@ -203,14 +211,19 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { .filter(orderDetail -> orderDetail.getOrderNo().equals(orderNo)) .findFirst(); - FlightOrderDetail flightOrderDetail = orderDetailFactory.buildWithRouteOrderAndOrderDetail(routeOrder, first); + FlightOrderDetail flightOrderDetail = orderDetailFactory.buildFlightWithRouteOrderAndOrderDetail(routeOrder, first); //处理订单的状态信息 first.ifPresent(orderDetail -> { OrderEvent lastEvent = orderDetail.getLastEvent(); - flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_SUCCESS); if (lastEvent != null && lastEvent.getEventType().equals(ORDER_EVENT_CANCEL)) { flightOrderDetail.setOrderStatus(FSSC_ORDER_STATUS_CANCEL); + } else { + flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_SUCCESS); + } + //携程创建的飞机订单只有取消和预定成功两个状态 + if(!flightOrderDetail.getOrderStatus().equals(FSSC_ORDER_STATUS_CANCEL)){ + flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_SUCCESS); } }); @@ -372,7 +385,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { if (byOrderNo.get().getHotelOrderDetail() == null) { hotelOrderDetail = new HotelOrderDetail(); } else { - return byOrderNo.get().getHotelOrderDetail(); + hotelOrderDetail = byOrderNo.get().getHotelOrderDetail(); } } else { hotelOrderDetail = new HotelOrderDetail(); diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java index c1aa3ac5..9da42ca4 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java @@ -1,6 +1,5 @@ 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; @@ -8,7 +7,6 @@ import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.UserRepository; -import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity; import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident; import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderResponse; @@ -19,6 +17,8 @@ import com.chint.interfaces.rest.user.UserHttpRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -26,7 +26,10 @@ import java.util.stream.Collectors; import static com.chint.infrastructure.constant.BelongSystemConstant.*; import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.FSSCConstant.*; +import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y_CN_NAME; +import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; @Component public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { @@ -49,6 +52,8 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { @Autowired private OrderDetailFactory orderDetailFactory; + private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); + @Override public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { CarDetailResponse.DataWrapper data = (CarDetailResponse.DataWrapper) carOrderDetailData; @@ -56,13 +61,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { return carOrderDetail; } - @Override - public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) { - // 获取对象的Class对象 - TrainDetailResponse.TrainDetailData trainDetailData = (TrainDetailResponse.TrainDetailData) trainOrderDetailData; - TrainOrderDetail convertTrain = convertTrainOrderDetail(trainDetailData); - return convertTrain; - } @Override public FlightOrderDetail createFlightOrderDetail(Object flightOrderDetailData) { @@ -80,15 +78,10 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { .filter(it -> it.getOrderNo().equals(orderDetails.getOrderSerialNo())) .findFirst(); - FlightOrderDetail flightOrderDetail = orderDetailFactory.buildWithRouteOrderAndOrderDetail(routeOrder, first); - + FlightOrderDetail flightOrderDetail = orderDetailFactory.buildFlightWithRouteOrderAndOrderDetail(routeOrder, first); //飞机票状态属性保存 OrderEvent lastEvent = orderDetail.getLastEvent(); - if (orderDetails.getIsChangeOrder()) { - //如果发现同程的订单号里面还有C就能够判断出 ,它是改签订单 - flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_CHANGE); - } if (lastEvent != null) { flightOrderDetail.setOrderStatus(lastEvent.mapToFlightOrderDetailStatus()); } else { @@ -100,67 +93,15 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { ) ); } - - //配置订单明细的父订单信息和订单号 - 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 + if (orderDetails.getIsChangeOrder()) { + //如果发现同程的订单号里面还有C就能够判断出 ,它是改签订单 + flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_CHANGE); } - 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 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.setFlightCompName(flightSegment.getAirline()); - - flightOrderDetail.setFlightNum(flightSegment.getFlightNo()); - 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()); + if (orderDetails.getIsRefundOrder()) { + //这里根据同程自带的字段进行状态映射 + flightOrderDetail.setOrderStatus(FSSC_FLIGHT_STATUS_REFUND); } - - List 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()); - } - return flightOrderDetail; + return updateFlightOrderDetailData(flightOrderDetail, flightOrderDetailData); } @Override @@ -194,9 +135,7 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { flightOrderDetail.setEndAirportCode(flightSegment.getArriveAirportCode()); flightOrderDetail.setEndTerminal(flightSegment.getArriveTerminal()); flightOrderDetail.setDistance(flightSegment.getMileAge().toString()); -// flightOrderDetail.setFlightCompName(flightSegment.getShareAirlineName()); flightOrderDetail.setFlightCompName(flightSegment.getAirline()); - flightOrderDetail.setFlightNum(flightSegment.getFlightNo()); flightOrderDetail.setSeatPoint(flightSegment.getSeatCode()); flightOrderDetail.setSeatPointName(flightSegment.getSeatName()); @@ -431,7 +370,9 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { // HotelPriceData hotelPriceData = estimatePrice.queryHotelPrice(priceQueryData); String sysCode = routeOrder.getApproveOrderNo().getSysCode(); + HotelOrderDetail hotelOrderDetail = new HotelOrderDetail(); + hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); if (sysCode != null) { if (sysCode.equals(BELONG_SYS_CODE_FSSC)) { @@ -557,6 +498,119 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { return hotelOrderDetail; } + @Override + public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) { + // 获取对象的Class对象 + TrainDetailResponse.TrainDetailData trainDetailData = (TrainDetailResponse.TrainDetailData) trainOrderDetailData; + String orderNo = trainDetailData.getOrderNo(); + OrderDetail byOrderNo = orderDetailRepository.findByOrderNo(orderNo) + .orElseThrow(() -> new NotFoundException(NOT_FOUND)); + RouteOrder routeOrder = routeRepository.queryById(byOrderNo.getRouteId()); + + Optional first = routeOrder + .getOrderDetails() + .stream() + .filter(it -> it.getOrderNo().equals(trainDetailData.getOrderNo())) + .findFirst(); + + TrainOrderDetail trainOrderDetail = orderDetailFactory.buildTrainWithRouteOrderAndOrderDetail(routeOrder, first); + //供应商为同程 + trainOrderDetail.setSupplier(SUPPLIER_L_Y_CN_NAME); + //这里的内容是对火车状态的设置 + first.ifPresent(it -> { + //因为同程的火车改签订单是单独的一条订单,这里可以根据这个状态来判断它是否是改签订单 + if (trainDetailData.getIsChangedOrder().equals(1)) { + trainOrderDetail.setOrderStatus(FSSC_TRAIN_STATUS_CHANGE); + } else { + trainOrderDetail.setOrderStatus(FSSC_TRAIN_STATUS_SUCCESS); + } + String orderStatus = trainDetailData.getOrderStatus(); + if (LYOrderUtil.mapTrainStatus(orderStatus).equals(ORDER_EVENT_CANCEL)) { + trainOrderDetail.setOrderStatus(FSSC_ORDER_STATUS_CANCEL); + } + } + ); + + return updateTrainOrderDetailData(trainOrderDetail, trainDetailData); + } + + @Override + public TrainOrderDetail updateTrainOrderDetailData(TrainOrderDetail trainOrderDetail, Object trainOrderInfo) { + TrainDetailResponse.TrainDetailData trainDetailData = (TrainDetailResponse.TrainDetailData) trainOrderInfo; + + TrainDetailResponse.TravelData travelData = trainDetailData.getTravelData(); + String travelApplyNo = travelData.getTravelApplyNo(); + + + //这里对火车的进行信息进行录入 + trainOrderDetail.setReceiptsNum(travelApplyNo); + trainOrderDetail.setCreateTime(formatter.format(LocalDateTime.now())); + trainOrderDetail.setStartTime(trainDetailData.getPlanBeginDate()); + trainOrderDetail.setArriveTime(trainDetailData.getPlanEndDate()); + trainOrderDetail.setFromStationName(trainDetailData.getFromStation()); + trainOrderDetail.setToStationName(trainDetailData.getToStation()); + trainOrderDetail.setTrainNo(trainDetailData.getTrainNo()); + trainOrderDetail.setFromCity(trainDetailData.getDepartCity()); + trainOrderDetail.setToCity(trainDetailData.getArriveCity()); + + //这里要判断如果火车票不是退票状态,在设置 + if (!trainOrderDetail.getOrderStatus().equals(FSSC_TRAIN_STATUS_REFUND)) { + trainOrderDetail.setOrderAmount(String.valueOf(trainDetailData.getTotalAmount())); + } + + trainOrderDetail.setPersonalAmount(trainDetailData.getPersonalPrice().toString()); + + trainOrderDetail.setUserCode(trainDetailData.getEmployeeCode()); + + //配置付款类型 + if (String.valueOf(trainDetailData.getPaymentType()).equals("1")) { + trainOrderDetail.setPaymentType("0"); + trainOrderDetail.setCompanyAmount(trainDetailData.getCompanyPrice().toString()); + trainOrderDetail.setPersonalAmount(KEEP_TWO_DECIMAL_ZERO); + } else { + trainOrderDetail.setPaymentType("1"); + trainOrderDetail.setCompanyAmount(KEEP_TWO_DECIMAL_ZERO); + trainOrderDetail.setPersonalAmount(trainDetailData.getPersonalPrice().toString()); + } + + List detailDataItems = trainDetailData.getItems(); + if (detailDataItems != null && !detailDataItems.isEmpty()) { + TrainDetailResponse.Item item = detailDataItems.get(0); + trainOrderDetail.setSeatName(item.getSeatNo()); + trainOrderDetail.setTicketPrice(String.valueOf(item.getTicketPrice())); + trainOrderDetail.setRefundCost(String.valueOf(item.getRefundFee())); + trainOrderDetail.setRefundPrice(String.valueOf(item.getRefundAmountCor())); + trainOrderDetail.setChangeCost(String.valueOf(item.getServiceCharge())); + + //座位信息和乘坐人信息 + trainOrderDetail.setPhone(item.getPassengerPhone()); + trainOrderDetail.setUserName(item.getPassengerName()); + trainOrderDetail.setSeatType(translateEnSeatToCnSeat(item.getSeatClass())); + + //前后手续费 + trainOrderDetail.setPreServiceFee(String.valueOf(item.getServiceCharge())); + trainOrderDetail.setPostServiceFee(String.valueOf(item.getAfterServiceCharge())); + trainOrderDetail.setRefundAmount(String.valueOf(item.getRefundAmountCor())); + + TrainDetailResponse.ChangeInfo changeInfo = item.getChangeInfo(); + if (changeInfo != null) { + TrainDetailResponse.ChangeItem changeItem = changeInfo.getChangeItem(); + if (changeItem != null) { + trainOrderDetail.setChangeDifference(String.valueOf(changeItem.getChangePrice())); + //如果 是退票的加入退票费 + if (trainOrderDetail.getOrderStatus().equals(FSSC_TRAIN_STATUS_REFUND)) { + trainOrderDetail.setRefundCost(String.valueOf(changeItem.getRefundFee())); + } else if (trainOrderDetail.getOrderStatus().equals(FSSC_TRAIN_STATUS_CHANGE)) { + //如果是改签的状态 ,就加入改签费 + trainOrderDetail.setRefundCost(String.valueOf(changeItem.getChangeFee())); + } + } + } + } + return trainOrderDetail; + } + + private TrainOrderDetail convertTrainOrderDetail(TrainDetailResponse.TrainDetailData trainDetailData) { // TrainDetailResponse.TrainDetailData trainDetailData = trainDetailResponse.getData(); @@ -611,7 +665,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { if (trainDetailData != null) { trainOrderDetail.setOrderNo(trainDetailData.getOrderNo()); trainOrderDetail.setDetailId(trainDetailData.getOrderNo()); - trainOrderDetail.setParentOrderNo(trainDetailData.getParentOrderSerialNo()); Optional first1 = routeOrder @@ -749,6 +802,18 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { return trainOrderDetail; } + private String translateEnSeatToCnSeat(String seatEnName) { + return switch (seatEnName) { + case "secondseat" -> "二等座"; + case "businessseat" -> "商务座"; + case "hardseat" -> "二等座"; + case "softsleeperup" -> "软卧"; + case "hardsleeperup" -> "硬卧"; + case "firstseat" -> "一等座"; + default -> "未知类型座位"; + }; + } + private CarOrderDetail convertCarOrderDetail(CarDetailResponse.DataWrapper data) { CarDetailResponse.CarOrderDetailInfo carOrderDetailInfo = data.getCarOrderDetailInfo(); diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactory.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactory.java index e2908888..1c94e3b6 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactory.java @@ -1,9 +1,6 @@ package com.chint.domain.factoriy.order_detail; -import com.chint.domain.aggregates.order.FlightOrderDetail; -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.order.*; import com.chint.domain.value_object.OrderLegData; import java.util.Optional; @@ -15,5 +12,7 @@ public interface OrderDetailFactory { BaseOrderExtension buildWithRouteOrder(RouteOrder routeOrder); - FlightOrderDetail buildWithRouteOrderAndOrderDetail(RouteOrder routeOrder, Optional orderDetail); + FlightOrderDetail buildFlightWithRouteOrderAndOrderDetail(RouteOrder routeOrder, Optional orderDetail); + + TrainOrderDetail buildTrainWithRouteOrderAndOrderDetail(RouteOrder routeOrder, Optional orderDetail); } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java index 30ce08a6..3490b503 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java @@ -99,7 +99,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { } @Override - public FlightOrderDetail buildWithRouteOrderAndOrderDetail(RouteOrder routeOrder, Optional first) { + public FlightOrderDetail buildFlightWithRouteOrderAndOrderDetail(RouteOrder routeOrder, Optional first) { //获取飞机订单明细 FlightOrderDetail flightOrderDetail; if (first.isPresent()) { @@ -125,4 +125,37 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { } return flightOrderDetail; } + + @Override + public TrainOrderDetail buildTrainWithRouteOrderAndOrderDetail(RouteOrder routeOrder, Optional orderDetail) { + //获取飞机订单明细 + TrainOrderDetail trainOrderDetail; + if (orderDetail.isPresent()) { + OrderDetail order = orderDetail.get(); + if (order.getFlightOrderDetail() == null) { + trainOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), TrainOrderDetail.class); + } else { + return order.getTrainOrderDetail(); + } + //如果订单存在,直接配置该订单的超标信息和原因 + order.getOrderEventList() + .stream() + .filter(it -> it.getEventType().equals(ORDER_EVENT_ETA)) + .findFirst() + .ifPresentOrElse(it -> { + trainOrderDetail.setOverStandard("是"); + trainOrderDetail.setOverStandardReason(it.getExtension()); + }, () -> trainOrderDetail.setOverStandard("否")); + trainOrderDetail.setOrderNo(order.getOrderNo()); + trainOrderDetail.setDetailId(order.getOrderNo()); + + User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId()); + trainOrderDetail.setBookingUserCode(user.getEmployeeNo()); + trainOrderDetail.setBookingName(user.getName()); + trainOrderDetail.setBookingUserPhone(user.getPhoneNumber()); + }else { + trainOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), TrainOrderDetail.class); + } + return trainOrderDetail; + } } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java index 333d3799..c49791fd 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java @@ -1,7 +1,6 @@ package com.chint.domain.factoriy.order_detail; import com.chint.domain.aggregates.order.*; -import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity; public interface OrderExtensionFactory { @@ -9,6 +8,8 @@ public interface OrderExtensionFactory { TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData); + TrainOrderDetail updateTrainOrderDetailData(TrainOrderDetail flightOrderDetail, Object trainOrderInfo); + FlightOrderDetail createFlightOrderDetail(Object flightOrderDetailData); FlightOrderDetail updateFlightOrderDetailData(FlightOrderDetail flightOrderDetail, Object flightOrderInfo); diff --git a/src/main/java/com/chint/domain/service/OrderDomainService.java b/src/main/java/com/chint/domain/service/OrderDomainService.java index f6fe2134..ffa7f8af 100644 --- a/src/main/java/com/chint/domain/service/OrderDomainService.java +++ b/src/main/java/com/chint/domain/service/OrderDomainService.java @@ -561,7 +561,7 @@ public class OrderDomainService { "-" + item.getRefundAmount(), "3", data.getRefundTime() - ).sendToQueue(); + ).data(trainOrderDetail.getData()).sendToQueue(); } }