From 9eb9fc58e193a43b46d265e37b34bb15315f784f Mon Sep 17 00:00:00 2001 From: dengwc Date: Mon, 1 Apr 2024 17:14:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=98=8E=E7=BB=86=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=98=A0=E5=B0=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LyOrderRecordExtensionFactory.java | 118 +++++++++++------- 1 file changed, 72 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java index 61e9debb..9f2f5ff7 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/LyOrderRecordExtensionFactory.java @@ -1,7 +1,6 @@ package com.chint.domain.factoriy.order_record; -import com.chint.domain.aggregates.order.OrderDetail; -import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; @@ -19,7 +18,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.math.BigDecimal; +import java.util.List; import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; /** * 同程数据转换 @@ -37,6 +39,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor @Autowired private OrderRecordFactory orderRecordFactory; + @Autowired + private JdbcOrderTravelRepository orderTravelRepository; + @Override public OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData) { OrderFlightRecord orderFlightRecord = new OrderFlightRecord(); @@ -77,35 +82,44 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor private void createFlightOrder(OrderFlightRecord orderFlightRecord, LyOrderFlightRecord lyOrderFlightRecord) { String orderSerialNo = lyOrderFlightRecord.getOrderSerialNo();//订单号 - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo); + AtomicReference orderDetailRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); BeanUtils.copyProperties(orderRecordBasic, orderFlightRecord); + OrderDetail orderDetail = orderDetailRef.get();//获取订单明细 + FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail() == null ? new FlightOrderDetail() : orderDetail.getFlightOrderDetail();//机票订单明细 + //公共字段校验 + + orderFlightRecord.setDetailId(lyOrderFlightRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderFlightRecord.getReserveManName())//票务员 .setAccountPeriod(lyOrderFlightRecord.getStatementCode())//账期号 .setBillNo(lyOrderFlightRecord.getBillOrderNo())//账单号 .setOrderNo(lyOrderFlightRecord.getOrderSerialNo())//订单号 - .setParentOrderNo("")//父级订单号 + .setParentOrderNo(flightOrderDetail.getParentOrderNo())//父级订单号 .setOriginalOrderNo(lyOrderFlightRecord.getOriginOrderSerialNo())//原始订单号 - .setTicketNo(lyOrderFlightRecord.getTicketNo())//票号 - .setScheduleNum("")//行程单号 + .setTicketNo(lyOrderFlightRecord.getTicketNo());//票号 + //行程单号 + List byOrderNo = orderTravelRepository.findByOrderNo(orderSerialNo); + String travelNo = byOrderNo.isEmpty() ? "" : byOrderNo.get(0).getTravelNo(); + orderFlightRecord.setScheduleNum(travelNo)//行程单号 .setReceiptsNum(lyOrderFlightRecord.getOutApplayOrderNo())//关联申请单号 .setUserName(lyOrderFlightRecord.getPassengerName())//出行人姓名 .setUserCode(lyOrderFlightRecord.getPassengerExternalId())//出行人编码 .setOverStandard("是".equals(lyOrderFlightRecord.getOverStandardStatus()) ? "1" : "0")//"是否违规(超标):0否 ,1是" .setOverStandardReason(lyOrderFlightRecord.getViolationReason())//违规原因(超标原因) - .setStartAirportName("")//起飞机场名称 - .setStartCityCode("")//起飞城市编码 - .setStartCityName("")//起飞城市名称 + .setStartAirportName(flightOrderDetail.getStartAirportName())//起飞机场名称 + .setStartCityCode(flightOrderDetail.getStartCityCode())//起飞城市编码 + .setStartCityName(flightOrderDetail.getStartCityName())//起飞城市名称 .setStartTime(lyOrderFlightRecord.getPlanBeginDate())//起飞时间 yyyy-MM-dd HH:mm:ss - .setEndAirportCode("")//到达机场三字码 - .setEndAirportName("")//到达机场名称 - .setEndCityCode("")//到达城市编码 - .setEndCityName("")//到达城市名称 - .setEndTerminal("")//到达航站楼 + .setEndAirportCode(flightOrderDetail.getEndAirportCode())//到达机场三字码 + .setEndAirportName(flightOrderDetail.getEndAirportName())//到达机场名称 + .setEndCityCode(flightOrderDetail.getEndCityCode())//到达城市编码 + .setEndCityName(flightOrderDetail.getEndCityName())//到达城市名称 + .setEndTerminal(flightOrderDetail.getEndTerminal())//到达航站楼 .setEndTime(lyOrderFlightRecord.getPlanEndDate())//到达时间 yyyy-MM-dd HH:mm:ss .setFlightCompName(lyOrderFlightRecord.getAirlineCompanyName())//航空公司名称 .setFlightLowestPrice(String.valueOf(lyOrderFlightRecord.getFligthMinPrice()))//航班最低价 - .setFlightNum(lyOrderFlightRecord.getFligthNo())// + .setFlightNum(lyOrderFlightRecord.getFligthNo())//航班号 .setOrderAmount(String.valueOf(lyOrderFlightRecord.getToBePayAmount())) //结算总额 .setFacePrice(String.valueOf(lyOrderFlightRecord.getTicketOutAmount())) //票面价 .setNoTaxAmt(String.valueOf(BigDecimal.valueOf(lyOrderFlightRecord.getTicketTotalAmount() == null ? 0 : lyOrderFlightRecord.getTicketTotalAmount()) @@ -125,24 +139,26 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setSeatPoint(lyOrderFlightRecord.getSeatClass())//舱位 .setSeatPointName(lyOrderFlightRecord.getSeatClass())//舱位名称 .setUseStatus(lyOrderFlightRecord.getTicketStatus()) //机票使用情况 - .setOrderSource("") //预订来源:线上/线下 + .setOrderSource(lyOrderFlightRecord.getBookingPlat()) //预订来源:线上/线下 .setNotLowReason("正泰机票无超标") //未预订最低价原因 .setBookOrgCode1(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息1 .setBookOrgCode2(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息2 .setBookOrgCode3(lyOrderFlightRecord.getPassengerDepartment()) //出行人组织架构信息3 .setOfflineCcomyCode(lyOrderFlightRecord.getPassengerCostCenter()) //成本中心 - /* .setOrderStatus() //结算状态 - .setExpenseOrderAmount() //订单金额 + .setOrderStatus("") //结算状态 +/* .setExpenseOrderAmount("") //订单金额 .setSettleOrderFlag() //订单对账状态 - .setPayAmount() //支付金额 -*/ + .setPayAmount() //支付金额*/ ; } private void createHotelOrder(OrderHotelRecord orderHotelRecord, LyOrderHotelRecord lyOrderHotelRecord) { String orderSerialNo = lyOrderHotelRecord.getOrderSerialNo();//订单号 - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo); + AtomicReference orderDetailRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); BeanUtils.copyProperties(orderRecordBasic, orderHotelRecord); + OrderDetail orderDetail = orderDetailRef.get();//订单明细 + HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail() == null ? new HotelOrderDetail() : orderDetail.getHotelOrderDetail();//酒店订单明细 orderHotelRecord.setDetailId(lyOrderHotelRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderHotelRecord.getReserveManName()) //票务员 .setAccountPeriod(lyOrderHotelRecord.getStatementCode()) //账期号 @@ -162,10 +178,10 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setCountry(lyOrderHotelRecord.getCountryName()) //国家 .setCustomerServiceName("") //客服处理人 .setDepartureDate(lyOrderHotelRecord.getLeaveTime()) //离店日期yyyy - MM - dd - .setHotelAddress("") //酒店地址 + .setHotelAddress(hotelOrderDetail.getHotelAddress()) //酒店地址 .setHotelName(lyOrderHotelRecord.getHotelName()) //酒店名称 .setIncludeAmount("") //含早情况:XX份 - .setIsAgreement(0) //是否协议酒店:0否1是 + .setIsAgreement("是".equals(hotelOrderDetail.getAgreementHotel()) ? 1 : 0) //是否协议酒店:0否1是 .setPaymentType(getPaymentType(lyOrderHotelRecord.getPayType()))//"付款方式:0-公司统付 1-个人付 2-混付" .setOrderAmount(String.valueOf(lyOrderHotelRecord.getToBePayAmount())) //结算总额 .setCompanyAmount(String.valueOf(lyOrderHotelRecord.getToBePayAmount())) //企业统付总额 @@ -173,9 +189,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setUnifiedPayAmt(String.valueOf(lyOrderHotelRecord.getServiceAmount())) //统付服务费 .setPersonalPayAmt("") //个人服务费 .setProvince("") //省份 - .setRoomCount(1) //房间数 + .setRoomCount(Integer.parseInt(hotelOrderDetail.getRoomCount())) //房间数 .setRoomNightCount(lyOrderHotelRecord.getHotelNights()) //夜间数 - .setNightCount(1) //间夜数 + .setNightCount(lyOrderHotelRecord.getHotelNights()) //间夜数 .setRoomPrice("") //房价(房间单价不包含服务费) .setRoomRate(String.valueOf(lyOrderHotelRecord.getTotalRoomPrice())) //房费(订单总额减总服务费) .setNoTaxAmt("") //不含税价 @@ -186,11 +202,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setNoTaxCusFee("") //托管费不含税 .setTaxCusFee("") //托管费税费 .setRoomTypeName(lyOrderHotelRecord.getBedType()) //房型 - .setStarRate("") //星级 + .setStarRate(hotelOrderDetail.getStarRate()) //星级 .setOrderSource(lyOrderHotelRecord.getBookingPlat()) //预订来源:线上/线下 .setBookOrgCode1(lyOrderHotelRecord.getPassengerDepartment()) //入住人组织架构信息1 - .setBookOrgCode2("") //入住人组织架构信息2 - .setBookOrgCode3("") //入住人组织架构信息3 + .setBookOrgCode2(hotelOrderDetail.getBOOK_ORG_STRUCT_2()) //入住人组织架构信息2 + .setBookOrgCode3(hotelOrderDetail.getBOOK_ORG_STRUCT_3()) //入住人组织架构信息3 .setOfflineCcomyCode(lyOrderHotelRecord.getPassengerCostCenter()) //成本中心 /* .setOrderStatus() //结算状态 .setExpenseOrderAmount() //订单金额 @@ -202,14 +218,17 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor private void createTrainOrder(OrderTrainRecord orderTrainRecord, LyOrderTrainRecord lyOrderTrainRecord) { String orderSerialNo = lyOrderTrainRecord.getOrderSerialNo();//订单号 - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo); + AtomicReference orderDetailRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); BeanUtils.copyProperties(orderRecordBasic, orderTrainRecord); + OrderDetail orderDetail = orderDetailRef.get();//订单明细 + TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail() == null ? new TrainOrderDetail() : orderDetail.getTrainOrderDetail();//火车订单明细 orderTrainRecord.setDetailId(lyOrderTrainRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderTrainRecord.getReserveManName()) //票务员 .setAccountPeriod(lyOrderTrainRecord.getStatementCode()) //账期号 .setBillNo(lyOrderTrainRecord.getBillOrderNo()) //账单号 .setOrderNo(lyOrderTrainRecord.getOrderSerialNo()) //订单号 - .setParentOrderNo("") //父级订单号 + .setParentOrderNo(trainOrderDetail.getParentOrderNo()) //父级订单号 .setOriginalOrderNo(lyOrderTrainRecord.getOriginOrderSerialNo()) //原始订单号 .setReceiptsNum(lyOrderTrainRecord.getOutApplayOrderNo()) //关联申请单号 .setStartDate(lyOrderTrainRecord.getPlanBeginDate()) //出发日期 @@ -234,15 +253,15 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setToCity(lyOrderTrainRecord.getTripName()) //到达城市 .setToStationName(lyOrderTrainRecord.getTripName()) //到达站 .setIssueTicketTime(lyOrderTrainRecord.getEnterAccount()) //出票时间 yyyy-MM-dd HH:mm:ss - .setRunTime("") //时长 - .setSeatType("")// 座位等级 + .setRunTime(trainOrderDetail.getRunTime()) //时长 + .setSeatType(trainOrderDetail.getSeatType())// 座位等级 .setTrainNo(lyOrderTrainRecord.getTrainNo()) //车次 .setUserCode(lyOrderTrainRecord.getPassengerNo())//出行人编码 .setUserName(lyOrderTrainRecord.getPassengerName())//出行人姓名 .setOrderSource(lyOrderTrainRecord.getBookingPlat())//预订来源:线上 / 线下 .setBookOrgCode1(lyOrderTrainRecord.getPassengerDepartment())//出行人组织架构信息1 - .setBookOrgCode2("")//出行人组织架构信息2 - .setBookOrgCode3("")//出行人组织架构信息3 + .setBookOrgCode2(trainOrderDetail.getBOOK_ORG_STRUCT_2())//出行人组织架构信息2 + .setBookOrgCode3(trainOrderDetail.getBOOK_ORG_STRUCT_3())//出行人组织架构信息3 .setOfflineCcomyCode(lyOrderTrainRecord.getPassengerCostCenter())//成本中心 /* .setOrderStatus() //结算状态 .setExpenseOrderAmount() //订单金额 @@ -263,8 +282,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor private void createCarOrder(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) { String orderSerialNo = lyOrderCarRecord.getOrderSerialNo();//订单号 - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo); + AtomicReference orderDetailRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); BeanUtils.copyProperties(orderRecordBasic, orderCarRecord); + OrderDetail orderDetail = orderDetailRef.get();//订单明细 + CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail() == null ? new CarOrderDetail() : orderDetail.getCarOrderDetail();//用车订单明细 orderCarRecord.setDetailId(lyOrderCarRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderCarRecord.getReserveManName()) //票务员 .setAccountPeriod(lyOrderCarRecord.getStatementCode()) //账期号 @@ -273,19 +295,19 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setOverStandard("0") //"是否违规(超标):0否 1是" .setOverStandardReason("无")//违规原因(超标原因) .setOrderNo(lyOrderCarRecord.getOrderSerialNo()) //订单号 - .setParentOrderNo("")//父级订单号 + .setParentOrderNo(carOrderDetail.getParentOrderNo())//父级订单号 .setOriginalOrderNo(lyOrderCarRecord.getOriginOrderSerialNo())//原始订单号 .setOrderStatus("") //"结算状态" .setCreateTime(lyOrderCarRecord.getBookingDate()) //"订单创建时间格式:2023-04-26 13:15:17" .setStartTime(lyOrderCarRecord.getPlanBeginDate()) //"出发时间格式:2023-04-26 13:15:17" - .setArriveTime("") //"到达时间格式:2023-04-26 13:15:17" + .setArriveTime(carOrderDetail.getArriveTime()) //"到达时间格式:2023-04-26 13:15:17" .setFromStationName(lyOrderCarRecord.getCarStartPlaceActual()) //出发地 .setToStationName(lyOrderCarRecord.getCarEndPlaceActual()) //到达地 - .setCarType("") //车型 + .setCarType(carOrderDetail.getCarModel()) //车型 .setFromCity(lyOrderCarRecord.getStartCityName()) //出发城市 - .setToCity("") //到达城市 - .setRunTime("") //运行时长 - .setMiles("") //里程数 + .setToCity(carOrderDetail.getToCity()) //到达城市 + .setRunTime(carOrderDetail.getRunTime()) //运行时长 + .setMiles(carOrderDetail.getMileage()) //里程数 .setNoTaxAmt("") //未税金额 .setTaxAmt("") //税费 .setOrderAmount(String.valueOf(lyOrderCarRecord.getToBePayAmount())) //结算总额(含前收服务费) @@ -296,11 +318,11 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setCancelCost(String.valueOf(lyOrderCarRecord.getToBePayAmount())) //取消费 .setUserName(String.valueOf(lyOrderCarRecord.getPassengerName())) //用车人姓名 .setUserCode(lyOrderCarRecord.getPassengerNo()) //用车人code -// .setOwnPayAmt() //个人支付金额 + .setOwnPayAmt(carOrderDetail.getPersonalPaymentAmount()) //个人支付金额 .setComyPayAmt(String.valueOf(lyOrderCarRecord.getToBePayAmount())) //公司统付金额 .setBookOrgCode1(lyOrderCarRecord.getPassengerDepartment()) //用车人组织架构信息1 - .setBookOrgCode2("") //用车人组织架构信息2 - .setBookOrgCode3("") //用车人组织架构信息3 + .setBookOrgCode2(carOrderDetail.getBOOK_ORG_STRUCT_2()) //用车人组织架构信息2 + .setBookOrgCode3(carOrderDetail.getBOOK_ORG_STRUCT_3()) //用车人组织架构信息3 .setPaymentType(String.valueOf(getPaymentType(lyOrderCarRecord.getPayType()))) //"付款方式0:公司统付 1:个人付 2:混付" .setOfflineCcomyCode(lyOrderCarRecord.getPassengerDepartment()) //成本中心 .setOrderSource(lyOrderCarRecord.getBookingPlat()) //预订来源:线上/线下 @@ -312,9 +334,13 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor } //获取公共对象 - public OrderRecordBasic getOrderRecordBasic(String orderSerialNo) { + public OrderRecordBasic getOrderRecordBasic(String orderSerialNo, Consumer consumer) { OrderDetail orderDetail = jdbcOrderDetailRepository.findByOrderNo(orderSerialNo); - Long routeId = orderDetail == null ? 0L : orderDetail.getRouteId(); + consumer.accept(orderDetail == null ? new OrderDetail() : orderDetail);//设置订单明细数据 + if (Objects.isNull(orderDetail)) { + return new OrderRecordBasic(); + } + Long routeId = orderDetail.getRouteId(); RouteOrder routeOrder = jdbcRouteRepository.findByRouteId(routeId); if (Objects.isNull(routeOrder)) { return new OrderRecordBasic();