diff --git a/src/main/java/com/chint/application/commands/LYOrderRecordGenerateCommand.java b/src/main/java/com/chint/application/commands/LYOrderRecordGenerateCommand.java new file mode 100644 index 00000000..beaf49e7 --- /dev/null +++ b/src/main/java/com/chint/application/commands/LYOrderRecordGenerateCommand.java @@ -0,0 +1,12 @@ +package com.chint.application.commands; + +import com.chint.infrastructure.echo_framework.command.Command; +import lombok.Data; + + + +//将上月的结算数据生成为财务共享需要的数据 +@Data +public class LYOrderRecordGenerateCommand extends Command { + +} diff --git a/src/main/java/com/chint/application/in/AutoWorkController.java b/src/main/java/com/chint/application/in/AutoWorkController.java index 26a9da28..f67aa207 100644 --- a/src/main/java/com/chint/application/in/AutoWorkController.java +++ b/src/main/java/com/chint/application/in/AutoWorkController.java @@ -1,6 +1,7 @@ package com.chint.application.in; +import com.chint.application.commands.LYOrderRecordGenerateCommand; import com.chint.application.dtos.CTripRecordMonthSaveDTO; import com.chint.domain.factoriy.order_record.LyStatementOrder; import com.chint.infrastructure.echo_framework.command.Command; @@ -69,7 +70,7 @@ public class AutoWorkController { //同步拉取上月数据 lyStatementOrder.saveAll(); //将上月的结算数据生成为财务共享需要的数据 - Command.of(OrderRecordGenerateCommand.class).sendToQueue(); + Command.of(LYOrderRecordGenerateCommand.class).sendToQueue(); return Result.Success(SUCCESS); } diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderCarRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderCarRecord.java index 398dc579..5d79ca87 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderCarRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderCarRecord.java @@ -52,7 +52,7 @@ public class LyOrderCarRecord implements Serializable { private String subjectRemark; @MappedCollection(idColumn = "ly_record_id", keyColumn = "ly_record_key") - private List tripSubmitItemList; + private List tripSubmitItemList; //出行人职级 private String passengerPositionLevelName; diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderFlightRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderFlightRecord.java index 026901ce..88d09c13 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderFlightRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderFlightRecord.java @@ -92,7 +92,7 @@ public class LyOrderFlightRecord implements Serializable { private String overStandardStatus; @MappedCollection(idColumn = "ly_record_id", keyColumn = "ly_record_key") - private List tripSubmitItemList; + private List tripSubmitItemList; //出行人职级 private String passengerPositionLevelName; diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderHotelRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderHotelRecord.java index 6897503c..d5635153 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderHotelRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderHotelRecord.java @@ -64,7 +64,7 @@ public class LyOrderHotelRecord implements Serializable { private String overStandardStatus; @MappedCollection(idColumn = "ly_record_id", keyColumn = "ly_record_key") - private List tripSubmitItemList; + private List tripSubmitItemList; //出行人职级 private String passengerPositionLevelName; diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderTrainRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderTrainRecord.java index f266be19..ce4eb780 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderTrainRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/LyOrderTrainRecord.java @@ -58,7 +58,7 @@ public class LyOrderTrainRecord implements Serializable { private String overStandardStatus; @MappedCollection(idColumn = "ly_record_id", keyColumn = "ly_record_key") - private List tripSubmitItemList; + private List tripSubmitItemList; //出行人职级 private String passengerPositionLevelName; diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemCarList.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemCarList.java new file mode 100644 index 00000000..57ebfd94 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemCarList.java @@ -0,0 +1,45 @@ +package com.chint.domain.aggregates.order.order_record.ly_order_record; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 行程提交项目(TripSubmitItem)表实体类 + * + * @author dengweichao + * @since 2024-03-27 10:17:58 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Table("trip_submit_item_car_list") +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TripSubmitItemCarList implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + + @Id + private Integer id; + + //父id + private Integer lyRecordId; + + private Integer lyRecordKey; + //编码 + private String code; + //名称 + private String name; + //内容 + private String content; + +} diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemFlightList.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemFlightList.java new file mode 100644 index 00000000..067a050d --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemFlightList.java @@ -0,0 +1,46 @@ +package com.chint.domain.aggregates.order.order_record.ly_order_record; + + +import java.io.Serial; +import java.io.Serializable; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +/** + * 行程提交项目(TripSubmitItem)表实体类 + * + * @author dengweichao + * @since 2024-03-27 10:17:58 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Table("trip_submit_item_flight_list") +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TripSubmitItemFlightList implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + + @Id + private Integer id; + + //父id + private Integer lyRecordId; + + private Integer lyRecordKey; + //编码 + private String code; + //名称 + private String name; + //内容 + private String content; + +} diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemHotelList.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemHotelList.java new file mode 100644 index 00000000..a7e9d896 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemHotelList.java @@ -0,0 +1,45 @@ +package com.chint.domain.aggregates.order.order_record.ly_order_record; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 行程提交项目(TripSubmitItem)表实体类 + * + * @author dengweichao + * @since 2024-03-27 10:17:58 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Table("trip_submit_item_hotel_list") +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TripSubmitItemHotelList implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + + @Id + private Integer id; + + //父id + private Integer lyRecordId; + + private Integer lyRecordKey; + //编码 + private String code; + //名称 + private String name; + //内容 + private String content; + +} diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemList.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemList.java index 2f4f451f..9c7f87e4 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemList.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemList.java @@ -1,19 +1,18 @@ package com.chint.domain.aggregates.order.order_record.ly_order_record; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + import java.io.Serial; import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import com.fasterxml.jackson.annotation.JsonInclude; -import org.springframework.data.annotation.Id; -import org.springframework.data.relational.core.mapping.Table; - /** - * 行程提交项目(TripSubmitItem)表实体类 + * 行程提交项目 * * @author dengweichao * @since 2024-03-27 10:17:58 @@ -21,15 +20,9 @@ import org.springframework.data.relational.core.mapping.Table; @Data @AllArgsConstructor @NoArgsConstructor -@Table("trip_submit_item_list") @JsonInclude(JsonInclude.Include.NON_NULL) public class TripSubmitItemList implements Serializable { - @Serial - private static final long serialVersionUID = 1L; - - - @Id private Integer id; //父id diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemTrainList.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemTrainList.java new file mode 100644 index 00000000..108617fc --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ly_order_record/TripSubmitItemTrainList.java @@ -0,0 +1,45 @@ +package com.chint.domain.aggregates.order.order_record.ly_order_record; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +/** + * 行程提交项目(TripSubmitItem)表实体类 + * + * @author dengweichao + * @since 2024-03-27 10:17:58 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Table("trip_submit_item_train_list") +@JsonInclude(JsonInclude.Include.NON_NULL) +public class TripSubmitItemTrainList implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + + @Id + private Integer id; + + //父id + private Integer lyRecordId; + + private Integer lyRecordKey; + //编码 + private String code; + //名称 + private String name; + //内容 + private String content; + +} 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 a3d0f1cd..fdda0234 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 @@ -5,14 +5,10 @@ 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; import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; -import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderCarRecord; -import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderFlightRecord; -import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderHotelRecord; -import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderTrainRecord; -import com.chint.domain.repository.UserRepository; -import com.chint.domain.service.OrderDetailDomainService; +import com.chint.domain.aggregates.order.order_record.ly_order_record.*; import com.chint.infrastructure.repository.jdbc.*; import com.chint.infrastructure.util.BeanCopyUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -20,9 +16,13 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_TYPE_LY; +import static com.chint.infrastructure.constant.OrderRecordConstant.*; + /** * 同程数据转换 */ @@ -83,13 +83,15 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor private void createFlightOrder(OrderFlightRecord orderFlightRecord, LyOrderFlightRecord lyOrderFlightRecord) { String orderSerialNo = lyOrderFlightRecord.getOrderSerialNo();//订单号 AtomicReference orderDetailRef = new AtomicReference<>(); - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); + AtomicReference routeOrderRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set); BeanUtils.copyProperties(orderRecordBasic, orderFlightRecord); OrderDetail orderDetail = orderDetailRef.get();//获取订单明细 + RouteOrder routeOrder = routeOrderRef.get();//获取财务共享订单 FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail() == null ? new FlightOrderDetail() : orderDetail.getFlightOrderDetail();//机票订单明细 + orderFlightRecord.setOrderDetailId(orderDetail.getOrderId() == null ? -1L : orderDetail.getOrderId()); //公共字段校验 - - + flightFieldCheck(orderFlightRecord, lyOrderFlightRecord); orderFlightRecord.setDetailId(lyOrderFlightRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderFlightRecord.getReserveManName())//票务员 .setAccountPeriod(lyOrderFlightRecord.getStatementCode())//账期号 @@ -101,8 +103,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor //行程单号 List byOrderNo = orderTravelRepository.findByOrderNo(orderSerialNo); String travelNo = byOrderNo.isEmpty() ? "" : byOrderNo.get(0).getTravelNo(); - orderFlightRecord.setScheduleNum(travelNo)//行程单号 - .setReceiptsNum(lyOrderFlightRecord.getOutApplayOrderNo())//关联申请单号 + orderFlightRecord.setScheduleNum(travelNo);//行程单号 + orderFlightRecord.setReceiptsNum(getReceiptsNum(lyOrderFlightRecord.getOutApplayOrderNo(), routeOrder))//关联申请单号 + .setReceiptsNumOrigin(lyOrderFlightRecord.getOutApplayOrderNo())//原关联申请单号 .setUserName(lyOrderFlightRecord.getPassengerName())//出行人姓名 .setUserCode(lyOrderFlightRecord.getPassengerExternalId())//出行人编码 .setOverStandard("是".equals(lyOrderFlightRecord.getOverStandardStatus()) ? "1" : "0")//"是否违规(超标):0否 ,1是" @@ -152,13 +155,19 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor ; } + private void createHotelOrder(OrderHotelRecord orderHotelRecord, LyOrderHotelRecord lyOrderHotelRecord) { String orderSerialNo = lyOrderHotelRecord.getOrderSerialNo();//订单号 AtomicReference orderDetailRef = new AtomicReference<>(); - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); + AtomicReference routeOrderRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set); BeanUtils.copyProperties(orderRecordBasic, orderHotelRecord); OrderDetail orderDetail = orderDetailRef.get();//订单明细 + RouteOrder routeOrder = routeOrderRef.get();//财务共享订单数据 HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail() == null ? new HotelOrderDetail() : orderDetail.getHotelOrderDetail();//酒店订单明细 + orderHotelRecord.setOrderDetailId(orderDetail.getOrderId() == null ? -1L : orderDetail.getOrderId());//订单明细id + //公共字段校验 + hotelFieldCheck(orderHotelRecord, lyOrderHotelRecord); orderHotelRecord.setDetailId(lyOrderHotelRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderHotelRecord.getReserveManName()) //票务员 .setAccountPeriod(lyOrderHotelRecord.getStatementCode()) //账期号 @@ -169,8 +178,10 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setBrandGroup("") //酒店品牌集团 .setBrandName("") //酒店品牌 .setOverStandard("是".equals(lyOrderHotelRecord.getOverStandardStatus()) ? "1" : "0") //"是否违规(超标) 0否,1是" - .setOverStandardReason(lyOrderHotelRecord.getViolationReason()) //违规原因(超标原因) - .setReceiptsNum(lyOrderHotelRecord.getOutApplayOrderNo()) //关联申请单号 + .setOverStandardReason(lyOrderHotelRecord.getViolationReason());//违规原因(超标原因) + + orderHotelRecord.setReceiptsNum(getReceiptsNum(lyOrderHotelRecord.getOutApplayOrderNo(), routeOrder))//关联申请单号 + .setReceiptsNumOrigin(lyOrderHotelRecord.getOutApplayOrderNo()) //原关联申请单号 .setUserName(lyOrderHotelRecord.getPassengerName()) //入住人姓名 .setUserCode(lyOrderHotelRecord.getPassengerNo()) //入住人编码 .setCheckInCity(lyOrderHotelRecord.getCityName()) //入住城市 @@ -189,7 +200,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor .setUnifiedPayAmt(String.valueOf(lyOrderHotelRecord.getServiceAmount())) //统付服务费 .setPersonalPayAmt("") //个人服务费 .setProvince("") //省份 - .setRoomCount(Integer.parseInt(hotelOrderDetail.getRoomCount())) //房间数 + .setRoomCount(Integer.parseInt(StringUtils.isBlank(hotelOrderDetail.getRoomCount()) ? "1" : hotelOrderDetail.getRoomCount())) //房间数 .setRoomNightCount(lyOrderHotelRecord.getHotelNights()) //夜间数 .setNightCount(lyOrderHotelRecord.getHotelNights()) //间夜数 .setRoomPrice("") //房价(房间单价不包含服务费) @@ -219,18 +230,24 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor private void createTrainOrder(OrderTrainRecord orderTrainRecord, LyOrderTrainRecord lyOrderTrainRecord) { String orderSerialNo = lyOrderTrainRecord.getOrderSerialNo();//订单号 AtomicReference orderDetailRef = new AtomicReference<>(); - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); + AtomicReference routeOrderRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set); BeanUtils.copyProperties(orderRecordBasic, orderTrainRecord); OrderDetail orderDetail = orderDetailRef.get();//订单明细 + RouteOrder routeOrder = routeOrderRef.get();//财务共享订单数据 TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail() == null ? new TrainOrderDetail() : orderDetail.getTrainOrderDetail();//火车订单明细 + orderTrainRecord.setOrderDetailId(orderDetail.getOrderId() == null ? -1L : orderDetail.getOrderId());//订单明细id + //公共字段校验 + trainFieldCheck(orderTrainRecord, lyOrderTrainRecord); orderTrainRecord.setDetailId(lyOrderTrainRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderTrainRecord.getReserveManName()) //票务员 .setAccountPeriod(lyOrderTrainRecord.getStatementCode()) //账期号 .setBillNo(lyOrderTrainRecord.getBillOrderNo()) //账单号 .setOrderNo(lyOrderTrainRecord.getOrderSerialNo()) //订单号 .setParentOrderNo(trainOrderDetail.getParentOrderNo()) //父级订单号 - .setOriginalOrderNo(lyOrderTrainRecord.getOriginOrderSerialNo()) //原始订单号 - .setReceiptsNum(lyOrderTrainRecord.getOutApplayOrderNo()) //关联申请单号 + .setOriginalOrderNo(lyOrderTrainRecord.getOriginOrderSerialNo());//原始订单号 + orderTrainRecord.setReceiptsNum(getReceiptsNum(lyOrderTrainRecord.getOutApplayOrderNo(), routeOrder))//关联申请单号 + .setReceiptsNumOrigin(lyOrderTrainRecord.getOutApplayOrderNo()) //原关联申请单号 .setStartDate(lyOrderTrainRecord.getPlanBeginDate()) //出发日期 .setArriveDate(lyOrderTrainRecord.getPlanEndDate()) //到达日期 .setOverStandard("是".equals(lyOrderTrainRecord.getOverStandardStatus()) ? "1" : "0") //"是否违规(超标):0否 1是" @@ -283,15 +300,21 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor private void createCarOrder(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) { String orderSerialNo = lyOrderCarRecord.getOrderSerialNo();//订单号 AtomicReference orderDetailRef = new AtomicReference<>(); - OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set); + AtomicReference routeOrderRef = new AtomicReference<>(); + OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set); BeanUtils.copyProperties(orderRecordBasic, orderCarRecord); OrderDetail orderDetail = orderDetailRef.get();//订单明细 + RouteOrder routeOrder = routeOrderRef.get();//财务共享订单数据 CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail() == null ? new CarOrderDetail() : orderDetail.getCarOrderDetail();//用车订单明细 + orderCarRecord.setOrderDetailId(orderDetail.getOrderId() == null ? -1L : orderDetail.getOrderId());//订单明细id + //公共字段校验 + carFieldCheck(orderCarRecord, lyOrderCarRecord); orderCarRecord.setDetailId(lyOrderCarRecord.getBillOrderNo())//防重标识 .setTicketClerk(lyOrderCarRecord.getReserveManName()) //票务员 .setAccountPeriod(lyOrderCarRecord.getStatementCode()) //账期号 - .setBillNo(lyOrderCarRecord.getBillOrderNo()) //账单号 - .setReceiptsNum(lyOrderCarRecord.getOrderSerialNo()) //关联申请单号 + .setBillNo(lyOrderCarRecord.getBillOrderNo()); //账单号 + orderCarRecord.setReceiptsNum(getReceiptsNum(lyOrderCarRecord.getOutApplayOrderNo(), routeOrder))//关联申请单号 + .setReceiptsNumOrigin(lyOrderCarRecord.getOutApplayOrderNo()) //原关联申请单号 .setOverStandard("0") //"是否违规(超标):0否 1是" .setOverStandardReason("无")//违规原因(超标原因) .setOrderNo(lyOrderCarRecord.getOrderSerialNo()) //订单号 @@ -334,20 +357,181 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor } //获取公共对象 - public OrderRecordBasic getOrderRecordBasic(String orderSerialNo, Consumer consumer) { + public OrderRecordBasic getOrderRecordBasic(String orderSerialNo, Consumer consumerOrderDetail, Consumer consumerRouteOrder) { OrderDetail orderDetail = jdbcOrderDetailRepository.findByOrderNo(orderSerialNo); - consumer.accept(orderDetail == null ? new OrderDetail() : orderDetail);//设置订单明细数据 + consumerOrderDetail.accept(orderDetail == null ? new OrderDetail() : orderDetail);//设置订单明细数据 if (Objects.isNull(orderDetail)) { + consumerRouteOrder.accept(new RouteOrder()); return new OrderRecordBasic(); } Long routeId = orderDetail.getRouteId(); RouteOrder routeOrder = jdbcRouteRepository.findByRouteId(routeId); + consumerRouteOrder.accept(routeOrder == null ? new RouteOrder() : routeOrder); if (Objects.isNull(routeOrder)) { return new OrderRecordBasic(); } return orderRecordFactory.buildWithRouteOrder(routeOrder); } + public void flightFieldCheck(OrderFlightRecord orderFlightRecord, LyOrderFlightRecord lyOrderFlightRecord) { + orderFlightRecord.setTrvaleSysType(TRAVAL_SYS_TYPE_LY)//数据来源商旅平台 XC:携程 TC:同程 + .setBookingName(lyOrderFlightRecord.getReserveManName()) //预订人姓名 + .setBookingUserCode(lyOrderFlightRecord.getReserveManNo()); //预订人编码 + List tripSubmitItemFlightList = lyOrderFlightRecord.getTripSubmitItemList(); + List tripSubmitItemList = BeanCopyUtils.copyBeanList(tripSubmitItemFlightList, TripSubmitItemList.class); + if (StringUtils.isBlank(orderFlightRecord.getBelongSysType())) { + String belongSysType = findBelongSysType(tripSubmitItemList, lyOrderFlightRecord.getOutApplayOrderNo()); + orderFlightRecord.setBelongSysType(belongSysType);//对应所属系统 + } + if (StringUtils.isBlank(orderFlightRecord.getAccountCompanyId())) { + findAccountCompanyId(tripSubmitItemList).ifPresent(orderFlightRecord::setAccountCompanyId);//核算企业code + } + if (StringUtils.isBlank(orderFlightRecord.getAccountCompanyName())) { + findAccountCompanyName(tripSubmitItemList).ifPresent(orderFlightRecord::setAccountCompanyName);//核算企业名称 + + } + if (StringUtils.isBlank(orderFlightRecord.getProjectOrderNo())) { + findProjectOrderNo(tripSubmitItemList).ifPresent(orderFlightRecord::setProjectOrderNo);//项目订单号 + } + + } + + public void hotelFieldCheck(OrderHotelRecord orderHotelRecord, LyOrderHotelRecord lyOrderHotelRecord) { + orderHotelRecord.setTrvaleSysType(TRAVAL_SYS_TYPE_LY)//数据来源商旅平台 XC:携程 TC:同程 + .setBookingName(lyOrderHotelRecord.getReserveManName()) //预订人姓名 + .setBookingUserCode(lyOrderHotelRecord.getReserveManNo()); //预订人编码 + List tripSubmitItemHotelList = lyOrderHotelRecord.getTripSubmitItemList(); + List tripSubmitItemList = BeanCopyUtils.copyBeanList(tripSubmitItemHotelList, TripSubmitItemList.class); + if (StringUtils.isBlank(orderHotelRecord.getBelongSysType())) { + String belongSysType = findBelongSysType(tripSubmitItemList, lyOrderHotelRecord.getOutApplayOrderNo()); + orderHotelRecord.setBelongSysType(belongSysType);//对应所属系统 + } + if (StringUtils.isBlank(orderHotelRecord.getAccountCompanyId())) { + findAccountCompanyId(tripSubmitItemList).ifPresent(orderHotelRecord::setAccountCompanyId);//核算企业code + } + if (StringUtils.isBlank(orderHotelRecord.getAccountCompanyName())) { + findAccountCompanyName(tripSubmitItemList).ifPresent(orderHotelRecord::setAccountCompanyName);//核算企业名称 + + } + if (StringUtils.isBlank(orderHotelRecord.getProjectOrderNo())) { + findProjectOrderNo(tripSubmitItemList).ifPresent(orderHotelRecord::setProjectOrderNo);//项目订单号 + } + + } + + public void trainFieldCheck(OrderTrainRecord orderTrainRecord, LyOrderTrainRecord lyOrderTrainRecord) { + orderTrainRecord.setTrvaleSysType(TRAVAL_SYS_TYPE_LY)//数据来源商旅平台 XC:携程 TC:同程 + .setBookingName(lyOrderTrainRecord.getReserveManName()) //预订人姓名 + .setBookingUserCode(lyOrderTrainRecord.getReserveManNo()); //预订人编码 + List tripSubmitItemTrainList = lyOrderTrainRecord.getTripSubmitItemList(); + List tripSubmitItemList = BeanCopyUtils.copyBeanList(tripSubmitItemTrainList, TripSubmitItemList.class); + if (StringUtils.isBlank(orderTrainRecord.getBelongSysType())) { + String belongSysType = findBelongSysType(tripSubmitItemList, lyOrderTrainRecord.getOutApplayOrderNo()); + orderTrainRecord.setBelongSysType(belongSysType);//对应所属系统 + } + if (StringUtils.isBlank(orderTrainRecord.getAccountCompanyId())) { + findAccountCompanyId(tripSubmitItemList).ifPresent(orderTrainRecord::setAccountCompanyId);//核算企业code + } + if (StringUtils.isBlank(orderTrainRecord.getAccountCompanyName())) { + findAccountCompanyName(tripSubmitItemList).ifPresent(orderTrainRecord::setAccountCompanyName);//核算企业名称 + + } + if (StringUtils.isBlank(orderTrainRecord.getProjectOrderNo())) { + findProjectOrderNo(tripSubmitItemList).ifPresent(orderTrainRecord::setProjectOrderNo);//项目订单号 + } + + } + + public void carFieldCheck(OrderCarRecord orderCarRecord, LyOrderCarRecord lyOrderCarRecord) { + orderCarRecord.setTrvaleSysType(TRAVAL_SYS_TYPE_LY)//数据来源商旅平台 XC:携程 TC:同程 + .setBookingName(lyOrderCarRecord.getReserveManName()) //预订人姓名 + .setBookingUserCode(lyOrderCarRecord.getReserveManNo()); //预订人编码 + List tripSubmitItemCarList = lyOrderCarRecord.getTripSubmitItemList(); + List tripSubmitItemList = BeanCopyUtils.copyBeanList(tripSubmitItemCarList, TripSubmitItemList.class); + if (StringUtils.isBlank(orderCarRecord.getBelongSysType())) { + String belongSysType = findBelongSysType(tripSubmitItemList, lyOrderCarRecord.getOutApplayOrderNo()); + orderCarRecord.setBelongSysType(belongSysType);//对应所属系统 + } + if (StringUtils.isBlank(orderCarRecord.getAccountCompanyId())) { + findAccountCompanyId(tripSubmitItemList).ifPresent(orderCarRecord::setAccountCompanyId);//核算企业code + } + if (StringUtils.isBlank(orderCarRecord.getAccountCompanyName())) { + findAccountCompanyName(tripSubmitItemList).ifPresent(orderCarRecord::setAccountCompanyName);//核算企业名称 + + } + if (StringUtils.isBlank(orderCarRecord.getProjectOrderNo())) { + findProjectOrderNo(tripSubmitItemList).ifPresent(orderCarRecord::setProjectOrderNo);//项目订单号 + } + + } + + //对应所属系统 + private static String findBelongSysType(List itemList, String outApplayOrderNo) { + return itemList.stream() + .filter(item -> LY_CUSTOM1.equals(item.getCode())) + .findFirst() + .map(TripSubmitItemList::getContent) + .orElseGet(() -> Optional.ofNullable(outApplayOrderNo) + .map(no -> no.split("-")[0]) + .orElse("")); + } + + //核算企业code + private static Optional findAccountCompanyId(List tripSubmitItemList) { + return tripSubmitItemList.stream() + .filter(item -> LY_CUSTOM2.equals(item.getCode())) + .findFirst() + .map(TripSubmitItemList::getContent); + } + + ////核算企业名称 + private static Optional findAccountCompanyName(List tripSubmitItemList) { + return tripSubmitItemList.stream() + .filter(item -> LY_CUSTOM3.equals(item.getCode())) + .findFirst() + .map(TripSubmitItemList::getContent); + } + + //项目订单号 + private static Optional findProjectOrderNo(List tripSubmitItemList) { + return tripSubmitItemList.stream() + .filter(item -> LY_CUSTOM4.equals(item.getCode())) + .findFirst() + .map(TripSubmitItemList::getContent); + } + + + private void flightReceiptsNum(OrderFlightRecord orderFlightRecord, LyOrderFlightRecord lyOrderFlightRecord, RouteOrder routeOrder) { + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + String outApplayOrderNo = lyOrderFlightRecord.getOutApplayOrderNo(); + String receiptsNum = ""; + if (Objects.isNull(approveOrderNo) && StringUtils.isNotBlank(outApplayOrderNo)) { + String[] receiptsNums = outApplayOrderNo.split("-"); + if (receiptsNums.length > 1) { + receiptsNum = receiptsNums[1]; + } + } else { + receiptsNum = approveOrderNo.getActualOrderNo(); + } + orderFlightRecord.setReceiptsNum(receiptsNum); + } + + //获取财务共享单号 + private String getReceiptsNum(String outApplayOrderNo, RouteOrder routeOrder) { + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + if (Objects.isNull(approveOrderNo)) { + if (StringUtils.isNotBlank(outApplayOrderNo)) { + String[] receiptsNums = outApplayOrderNo.split("-"); + if (receiptsNums.length > 1) { + return receiptsNums[1]; + } + } + return ""; + } + return approveOrderNo.getActualOrderNo(); + } + + //映射付款方式 //支付类型(1:企业授信 / 2:个人支付 / 3:组合支付) public int getPaymentType(String payType) { diff --git a/src/main/java/com/chint/domain/service/order_record/LYOrderRecordDomainService.java b/src/main/java/com/chint/domain/service/order_record/LYOrderRecordDomainService.java index 1089a02f..df93f4db 100644 --- a/src/main/java/com/chint/domain/service/order_record/LYOrderRecordDomainService.java +++ b/src/main/java/com/chint/domain/service/order_record/LYOrderRecordDomainService.java @@ -1,5 +1,6 @@ package com.chint.domain.service.order_record; +import com.chint.application.commands.LYOrderRecordGenerateCommand; import com.chint.application.commands.OrderRecordGenerateCommand; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; @@ -12,6 +13,7 @@ import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderTra import com.chint.domain.factoriy.order_record.CTripOrderRecordExtensionFactory; import com.chint.domain.factoriy.order_record.LyOrderRecordExtensionFactory; import com.chint.domain.service.OrderDetailDomainService; +import com.chint.infrastructure.echo_framework.annotation.ListenTo; import com.chint.infrastructure.repository.jdbc.*; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; @@ -25,7 +27,7 @@ import java.util.ArrayList; import java.util.List; @Component -public class LYOrderRecordDomainService implements OrderRecordDomainService { +public class LYOrderRecordDomainService { @Autowired private JdbcLyOrderFlightRecord jdbcLyOrderFlightRecord; @@ -46,9 +48,10 @@ public class LYOrderRecordDomainService implements OrderRecordDomainService { @Autowired private OrderDetailDomainService orderDetailDomainService; - @Override + @Transactional - public List generateFlightRecord(OrderRecordGenerateCommand command) { + @ListenTo(command = "LYOrderRecordGenerateCommand", order = 0) + public List generateFlightRecord(LYOrderRecordGenerateCommand command) { ArrayList orderFlightRecordList = new ArrayList<>(); int count = 0;//初始化变量 int pageSize = 100; // 假设每页大小为10 @@ -75,9 +78,10 @@ public class LYOrderRecordDomainService implements OrderRecordDomainService { return orderFlightRecordList; } - @Override + @Transactional - public List generateHotelRecord(OrderRecordGenerateCommand command) { + @ListenTo(command = "LYOrderRecordGenerateCommand", order = 1) + public List generateHotelRecord(LYOrderRecordGenerateCommand command) { ArrayList orderHotelRecordList = new ArrayList<>(); int count = 0;//初始化变量 int pageSize = 100; // 假设每页大小为10 @@ -104,9 +108,10 @@ public class LYOrderRecordDomainService implements OrderRecordDomainService { return orderHotelRecordList; } - @Override + @Transactional - public List generateTrainRecord(OrderRecordGenerateCommand command) { + @ListenTo(command = "LYOrderRecordGenerateCommand", order = 2) + public List generateTrainRecord(LYOrderRecordGenerateCommand command) { ArrayList orderTrainRecordsList = new ArrayList<>(); int count = 0;//初始化变量 int pageSize = 100; // 假设每页大小为10 @@ -134,9 +139,10 @@ public class LYOrderRecordDomainService implements OrderRecordDomainService { } - @Override + @Transactional - public List generateCarRecord(OrderRecordGenerateCommand command) { + @ListenTo(command = "LYOrderRecordGenerateCommand", order = 3) + public List generateCarRecord(LYOrderRecordGenerateCommand command) { ArrayList orderCarRecordsList = new ArrayList<>(); int count = 0;//初始化变量 int pageSize = 100; // 假设每页大小为10 diff --git a/src/main/java/com/chint/infrastructure/constant/OrderRecordConstant.java b/src/main/java/com/chint/infrastructure/constant/OrderRecordConstant.java new file mode 100644 index 00000000..38c40762 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/constant/OrderRecordConstant.java @@ -0,0 +1,14 @@ +package com.chint.infrastructure.constant; + +public class OrderRecordConstant { + + // 对应所属系统 + public static final String LY_CUSTOM1 = "Custom1"; + //核算企业code + public static final String LY_CUSTOM2 = "Custom2"; + //核算企业名称 + public static final String LY_CUSTOM3 = "Custom3"; + //项目订单号 + public static final String LY_CUSTOM4 = "Custom4"; + +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/CarStatement.java b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/CarStatement.java index 684e48b7..fa775fe6 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/CarStatement.java +++ b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/CarStatement.java @@ -1,6 +1,6 @@ package com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse; -import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemList; +import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemCarList; import com.chint.interfaces.rest.ly.reconciliation.dto.BaseResponse; import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo; import lombok.AllArgsConstructor; @@ -71,7 +71,7 @@ public class CarStatement extends BaseResponse { private Double ticketOutAmount;//票面 private Double serviceAmount;//服务费 private Double insuranceAmount;//保险 - private List tripSubmitItemList;//行程提交项 + private List tripSubmitItemList;//行程提交项 private String orderOperType;//类型 预订/变更/退票 private String payType;//支付类型(1:企业授信 / 2:个人支付 / 3:组合支付) private Double totalShouldPay;//总计应付 diff --git a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/FlightStatement.java b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/FlightStatement.java index 370017da..5cc89d1d 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/FlightStatement.java +++ b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/FlightStatement.java @@ -1,6 +1,6 @@ package com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse; -import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemList; +import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemFlightList; import com.chint.interfaces.rest.ly.reconciliation.dto.BaseResponse; import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo; import lombok.AllArgsConstructor; @@ -93,7 +93,7 @@ public class FlightStatement extends BaseResponse { private Double ticketOutAmount;//票面 private Double serviceAmount;//服务费 private Double insuranceAmount;//保险 - private List tripSubmitItemList;//行程提交项 + private List tripSubmitItemList;//行程提交项 private String orderOperType;//类型 预订/变更/退票 private String payType;//支付类型(1:企业授信 / 2:个人支付 / 3:组合支付) private Double totalShouldPay;//总计应付 diff --git a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/HotelStatement.java b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/HotelStatement.java index 0b839992..c80b1b0d 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/HotelStatement.java +++ b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/HotelStatement.java @@ -1,6 +1,7 @@ package com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse; -import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemList; + +import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemHotelList; import com.chint.interfaces.rest.ly.reconciliation.dto.BaseResponse; import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo; import lombok.AllArgsConstructor; @@ -79,7 +80,7 @@ public class HotelStatement extends BaseResponse { private Double ticketOutAmount;//票面 private Double serviceAmount;//服务费 private Double insuranceAmount;//保险 - private List tripSubmitItemList;//行程提交项 + private List tripSubmitItemList;//行程提交项 private String orderOperType;//类型 预订/变更/退票 private String payType;//支付类型(1:企业授信 / 2:个人支付 / 3:组合支付) private Double totalShouldPay;//总计应付 diff --git a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/TrainStatement.java b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/TrainStatement.java index 5fa91036..219f079e 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/TrainStatement.java +++ b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/DetailResponse/TrainStatement.java @@ -1,6 +1,7 @@ package com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse; -import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemList; + +import com.chint.domain.aggregates.order.order_record.ly_order_record.TripSubmitItemTrainList; import com.chint.interfaces.rest.ly.reconciliation.dto.BaseResponse; import com.chint.interfaces.rest.ly.reconciliation.dto.PageInfo; import lombok.AllArgsConstructor; @@ -77,7 +78,7 @@ public class TrainStatement extends BaseResponse { private Double ticketOutAmount;//票面 private Double serviceAmount;//服务费 private Double insuranceAmount;//保险 - private List tripSubmitItemList;//行程提交项 + private List tripSubmitItemList;//行程提交项 private String orderOperType;//类型 预订/变更/退票 private String payType;//支付类型(1:企业授信 / 2:个人支付 / 3:组合支付) private Double totalShouldPay;//总计应付