From 12011f37698da13f6ca676ff5114fcf3e0d38772 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Mon, 1 Apr 2024 16:19:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=BA=E7=A8=8B=E7=BB=93=E7=AE=97=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dtos/AuthenticationSignDto.java | 1 - .../out/OrderDetailController.java | 5 +- .../queryies/OrderDetailQuery.java | 108 ++++++------------ .../order/order_record/OrderCarRecord.java | 1 + .../CTripOrderRecordExtensionFactory.java | 80 ++++++++----- .../order_record/OrderRecordFactory.java | 13 --- .../OrderRecordFactorySelector.java | 24 ++++ .../repository/OrderCarRecordRepository.java | 6 +- .../OrderFlightRecordRepository.java | 8 ++ .../OrderHotelRecordRepository.java | 5 + .../OrderTrainRecordRepository.java | 5 + .../CTripOrderRecordDomainService.java | 13 ++- .../constant/OrderConstant.java | 1 + .../OrderCarRecordRepositoryImpl.java | 18 +++ .../OrderFlightRecordRepositoryImpl.java | 13 +++ .../OrderHotelRecordRepositoryImpl.java | 14 +++ .../OrderTrainRecordRepositoryImpl.java | 13 +++ .../config/OrderRecordCallbackImpl.java | 22 ++++ .../jdbc/JdbcOrderCarRecordRepository.java | 7 +- .../jdbc/JdbcOrderFlightRecordRepository.java | 7 +- .../jdbc/JdbcOrderHotelRecordRepository.java | 7 +- .../jdbc/JdbcOrderTrainRecordRepository.java | 7 +- .../ctrip/order/CTripOrderRecordAutoSave.java | 34 +++++- src/main/resources/application-prod.yml | 8 +- src/test/java/com/chint/CTripTest.java | 9 ++ .../java/com/chint/RouteApplicationTests.java | 2 +- 26 files changed, 293 insertions(+), 138 deletions(-) create mode 100644 src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactorySelector.java create mode 100644 src/main/java/com/chint/infrastructure/repository/config/OrderRecordCallbackImpl.java diff --git a/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java b/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java index 9e9d01a3..05678cc0 100644 --- a/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java +++ b/src/main/java/com/chint/application/dtos/AuthenticationSignDto.java @@ -11,6 +11,5 @@ public class AuthenticationSignDto extends BaseQuery { private String systemType; private String startTime; private String endTime; - private String sign; } diff --git a/src/main/java/com/chint/application/out/OrderDetailController.java b/src/main/java/com/chint/application/out/OrderDetailController.java index efd43a88..bf4d9851 100644 --- a/src/main/java/com/chint/application/out/OrderDetailController.java +++ b/src/main/java/com/chint/application/out/OrderDetailController.java @@ -25,7 +25,6 @@ import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightOrderRespon import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse; import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -91,9 +90,9 @@ public class OrderDetailController { @ApiOperation("订单结算查询接口") @PostMapping("/record/query") - public Result> queryRecord(@RequestBody AuthenticationSignDto authenticationDto) { + public Result queryRecord(@RequestBody AuthenticationSignDto authenticationDto) { if (signCheck(authenticationDto)) { - return orderDetailPageQuery.orderRecordInfoPageQuery(authenticationDto); + return Result.Success(SUCCESS, orderDetailPageQuery.orderRecordInfoPageQuery(authenticationDto)); } else { return Result.error("签名错误"); } diff --git a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java index ec23d125..f701e7b1 100644 --- a/src/main/java/com/chint/application/queryies/OrderDetailQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderDetailQuery.java @@ -7,8 +7,8 @@ import com.chint.application.dtos.mapper.OrderDetailMapper; import com.chint.application.dtos.response.OrderDetailRes; import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.user.User; -import com.chint.domain.repository.OrderDetailRepository; -import com.chint.domain.repository.RouteRepository; +import com.chint.domain.exceptions.NotFoundException; +import com.chint.domain.repository.*; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.Result; @@ -39,76 +39,37 @@ public class OrderDetailQuery { @Autowired private RouteRepository routeRepository; + @Autowired + private OrderCarRecordRepository orderCarRecordRepository; + @Autowired + private OrderHotelRecordRepository orderHotelRecordRepository; + @Autowired + private OrderFlightRecordRepository orderFlightRecordRepository; + @Autowired + private OrderTrainRecordRepository orderTrainRecordRepository; + + + public PageResult orderRecordInfoPageQuery(AuthenticationSignDto authenticationDto) { + Integer productType = authenticationDto.getProductType(); + String systemType = authenticationDto.getSystemType(); + Integer pageSize = authenticationDto.getPageSize(); + Integer pageNum = authenticationDto.getPageNum(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter); + LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter); + return switch (productType) { + case 1 -> orderFlightRecordRepository.findByUpdateDataTime(targetTimeBegin, + targetTimeEnd, pageSize, pageNum, systemType); + case 2 -> orderHotelRecordRepository.findByUpdateDataTime(targetTimeBegin, + targetTimeEnd, pageSize, pageNum, systemType); + case 3 -> orderTrainRecordRepository.findByUpdateDataTime(targetTimeBegin, + targetTimeEnd, pageSize, pageNum, systemType); + case 4 -> orderCarRecordRepository.findByUpdateDataTime(targetTimeBegin, + targetTimeEnd, pageSize, pageNum, systemType); + default -> throw new NotFoundException("错误产品类型"); + }; + } -// public Result> orderDetailInfoPageQuery(AuthenticationSignDto authenticationDto) { -// Integer productType = authenticationDto.getProductType(); -// String systemType = authenticationDto.getSystemType(); -// Integer pageSize = authenticationDto.getPageSize(); -// Integer pageNum = authenticationDto.getPageNum(); -// -// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); -// LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter); -// LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter); -// List orderDetailList = orderDetailRepository.findByUpdateTimeBetween(targetTimeBegin, targetTimeEnd); -// List orderDetailResList = new ArrayList<>(); -// for (OrderDetail orderDetail : orderDetailList) { -// if (productType == 1) { -// FlightOrderDetail flightOrderDetail = orderDetail.getFlightOrderDetail(); -// -// if (flightOrderDetail != null) { -// String receiptsNum = flightOrderDetail.getReceiptsNum(); -// if (receiptsNum != null) { -// flightOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); -// } -// if (flightOrderDetail.getOrderStatus() != null && flightOrderDetail.getBelongSysType() != null && flightOrderDetail.getBelongSysType().equals(systemType)) { -// orderDetailResList.add(flightOrderDetail); -// } -// } -// } -// if (productType == 2) { -// HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail(); -// if (hotelOrderDetail != null) { -// String receiptsNum = hotelOrderDetail.getReceiptsNum(); -// if (receiptsNum != null) { -// hotelOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); -// } -// if (hotelOrderDetail.getBelongSysType() != null && hotelOrderDetail.getBelongSysType().equals(systemType)) { -// //这里添加过滤逻辑 ,如果该订单为同程酒店订单 , 并且金额为0 判断为 临时订单数据 -// if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y) && Double.parseDouble(hotelOrderDetail.getOrderAmount()) == 0) -// continue; -// orderDetailResList.add(hotelOrderDetail); -// } -// } -// } -// if (productType == 3) { -// TrainOrderDetail trainOrderDetail = orderDetail.getTrainOrderDetail(); -// if (trainOrderDetail != null) { -// String receiptsNum = trainOrderDetail.getReceiptsNum(); -// if (receiptsNum != null) { -// trainOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); -// } -// if (trainOrderDetail.getOrderStatus() != null && trainOrderDetail.getBelongSysType() != null && trainOrderDetail.getBelongSysType().equals(systemType)) { -// orderDetailResList.add(trainOrderDetail); -// } -// } -// } -// if (productType == 4) { -// CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail(); -// if (carOrderDetail != null) { -// String receiptsNum = carOrderDetail.getReceiptsNum(); -// if (receiptsNum != null) { -// carOrderDetail.setReceiptsNum(regetReceiptsNum(receiptsNum)); -// } -// if (carOrderDetail.getOrderStatus() != null && carOrderDetail.getBelongSysType() != null && carOrderDetail.getBelongSysType().equals(systemType)) { -// orderDetailResList.add(carOrderDetail); -// } -// } -// } -// } -// List newres2 = orderDetailResList.stream().skip((long) (pageNum - 1) * pageSize).limit(pageSize).toList(); -// -// return Result.Success(SUCCESS, PageResult.totalPageNum(Long.parseLong(String.valueOf(orderDetailResList.size())), newres2)); -// } public Result> orderDetailInfoPageQuery(AuthenticationSignDto authenticationDto) { Integer productType = authenticationDto.getProductType(); @@ -118,7 +79,6 @@ public class OrderDetailQuery { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime targetTimeBegin = LocalDateTime.parse(authenticationDto.getStartTime(), formatter); LocalDateTime targetTimeEnd = LocalDateTime.parse(authenticationDto.getEndTime(), formatter); - List orderDetailList = orderDetailRepository.findByUpdateTimeBetween(targetTimeBegin, targetTimeEnd); Stream orderDetailStream = orderDetailList.stream().map(orderDetail -> switch (productType) { @@ -139,10 +99,6 @@ public class OrderDetailQuery { return Result.Success(SUCCESS, PageResult.totalPageNum(res.size(), paginatedResults)); } - public Result> orderRecordInfoPageQuery(AuthenticationSignDto authenticationDto) { - return null; - } - private Object processHotelOrderDetail(OrderDetail orderDetail, String systemType) { HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail(); diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java index 4c8bac06..19513612 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/OrderCarRecord.java @@ -72,6 +72,7 @@ public class OrderCarRecord extends OrderBaseRecord { private String payAmount;//支付总金额 + //添加行程信息 public OrderCarRecord loadTravelInfo(String startTime, String arriveTime, diff --git a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java index 783ef50f..d0582cd9 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/CTripOrderRecordExtensionFactory.java @@ -72,17 +72,16 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) { CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData; String routeOrderNo = cTripCarRecord.getRouteOrderNo(); - RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo); + Optional byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); OrderCarRecord orderCarRecord = buildWithRecord(cTripCarRecord) .carRecord(); CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase(); //携程的打车订单可以直接通过订单号获取对应的订单 - Optional orderDetail = byOrderNo - .getOrderDetails() + Optional orderDetail = byOrderNo.flatMap(routeOrder -> routeOrder.getOrderDetails() .stream() .filter(it -> it.getOrderNo().equals(String.valueOf( cTripCarRecordBase.getOrderId() - ))).findFirst(); + ))).findFirst()); CTripCarQuickInfo cTripCarQuickInfo = cTripCarRecord.getCTripCarQuickInfo(); @@ -147,7 +146,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac } // 加载超标信息, 加载订单关联信息 , 加载订单状态 ,单号,创建时间等信息 - orderDetail.ifPresent(it -> { + orderDetail.ifPresentOrElse(it -> { CarOrderDetail carOrderDetail = it.getCarOrderDetail(); orderCarRecord.loadComplianceInfo(it) .loadRelatedOrderInfo(it.getOrderId(), @@ -158,7 +157,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac .loadBasicOrderInfo(carOrderDetail.getOrderNo(), carOrderDetail.getOrderStatus(), carOrderDetail.getCreateTime()); - }); + }, () -> orderCarRecord.loadRelatedOrderInfo(cTripCarRecordBase.getOrderId(), + cTripCarRecord.getRecordId(), + cTripCarRecord.getRouteOrderNo(), + String.valueOf(cTripCarRecordBase.getOrderId()), + String.valueOf(cTripCarRecordBase.getOrderId())) + .loadBasicOrderInfo( String.valueOf(cTripCarRecordBase.getOrderId()), + "", + cTripCarRecordBase.getCreateTime())); return orderCarRecord; } @@ -208,18 +214,18 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac CTripFlightRecord cTripFlightRecord = (CTripFlightRecord) orderFlightRecordData; CTripFlightBaseInfo cTripFlightBaseInfo = cTripFlightRecord.getCTripFlightBaseInfo(); String routeOrderNo = cTripFlightRecord.getRouteOrderNo(); - RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo); + Optional byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); OrderFlightRecord orderFlightRecord = buildWithRecord(cTripFlightRecord) .flightRecord(); CTripFlightInfo cTripFlightInfo = cTripFlightRecord.getCTripFlightInfo(); CTripFlightRecordBase cTripFlightRecordBase = cTripFlightRecord.getCTripFlightRecordBase(); //携程的打车订单可以直接通过订单号获取对应的订单 - Optional orderDetail = byOrderNo. + Optional orderDetail = byOrderNo.flatMap(routeOrder -> routeOrder. getOrderDetails() .stream() .filter(it -> it.getOrderNo().equals(String.valueOf(cTripFlightRecordBase.getOrderId() - ))).findFirst(); + ))).findFirst()); // 加载航班信息 , 航线 orderFlightRecord.loadFlightInfo(cTripFlightInfo.getFlight(), @@ -273,19 +279,6 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac orderFlightRecord.loadSourceInfo("Y"); } - // 加载关联票价原因 - orderDetail.ifPresent(it -> { - FlightOrderDetail flightOrderDetail = it.getFlightOrderDetail(); - orderFlightRecord.loadComplianceInfo(it) - .loadBasicOrderInfo(String.valueOf(cTripFlightRecordBase.getOrderId()), - flightOrderDetail.getOrderStatus(), - cTripFlightRecordBase.getCreateTime()) - .loadRelatedOrderInfo(it.getOrderId(), - String.valueOf(cTripFlightRecordBase.getRecordId()), - flightOrderDetail.getReceiptsNum(), - flightOrderDetail.getParentOrderNo(), - it.getOrderNo()); - }); // 加载未预订最低价原因 orderFlightRecord.loadNotLowReason(cTripFlightInfo.getReasonDesc()); @@ -294,6 +287,26 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac cTripFlightBaseInfo.getDept2(), cTripFlightBaseInfo.getDept3()); + // 加载关联票价原因 + orderDetail.ifPresentOrElse(it -> { + FlightOrderDetail flightOrderDetail = it.getFlightOrderDetail(); + orderFlightRecord.loadComplianceInfo(it) + .loadBasicOrderInfo(String.valueOf(cTripFlightRecordBase.getOrderId()), + flightOrderDetail.getOrderStatus(), + cTripFlightRecordBase.getCreateTime()) + .loadRelatedOrderInfo(cTripFlightRecordBase.getOrderId(), + String.valueOf(cTripFlightRecordBase.getRecordId()), + flightOrderDetail.getReceiptsNum(), + flightOrderDetail.getParentOrderNo(), + it.getOrderNo()); + }, () -> orderFlightRecord.loadRelatedOrderInfo(cTripFlightRecordBase.getOrderId(), //兼容测试环境没有申请单的情况 + String.valueOf(cTripFlightRecordBase.getRecordId()), + cTripFlightBaseInfo.getJourneyID(), + String.valueOf(cTripFlightRecordBase.getOrderId()), + String.valueOf(cTripFlightRecordBase.getOrderId())) + .loadBasicOrderInfo(String.valueOf(cTripFlightRecordBase.getOrderId()), + "", + cTripFlightRecordBase.getCreateTime())); return orderFlightRecord; } @@ -336,12 +349,18 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac CTripHotelRecord cTripHotelRecord = (CTripHotelRecord) orderHotelRecordData; CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail(); String routeOrderNo = cTripHotelRecord.getRouteOrderNo(); - RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo); + Optional byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); OrderHotelRecord orderHotelRecord = buildWithRecord(cTripHotelRecord) .hotelRecord(); CTripHotelInfo cTripHotelInfo = cTripHotelRecord.getCTripHotelInfo(); CTripHotelRecordBase cTripHotelRecordBase = cTripHotelRecord.getCTripHotelRecordBase(); + + Optional orderDetailOptional = byOrderNo.flatMap(it -> it.getOrderDetails() + .stream() + .filter(orderDetail -> orderDetail.getOrderNo().equals(String.valueOf(cTripHotelRecordBase.getOrderId()))) + .findFirst()); + // 加载酒店和入住信息 orderHotelRecord.loadHotelInfo(cTripHotelInfo.getHotelName(), cTripHotelInfo.getHotelName(), @@ -391,12 +410,8 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac } orderHotelRecord.loadSourceInfo(sourceInfo); - Optional orderDetailOptional = byOrderNo.getOrderDetails() - .stream() - .filter(it -> it.getOrderNo().equals(String.valueOf(cTripHotelRecordBase.getOrderId()))) - .findFirst(); - orderDetailOptional.ifPresent(it -> { + orderDetailOptional.ifPresentOrElse(it -> { orderHotelRecord.loadComplianceInfo(it); // 加载违规信息 HotelOrderDetail hotelOrderDetail = it.getHotelOrderDetail(); orderHotelRecord.loadOrderNoInfo(it.getOrderId(), // 加载订单关联号信息 @@ -407,7 +422,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac orderHotelRecord.loadBasicOrderInfo(hotelOrderDetail.getOrderNo(), // 加载基础订单信息 hotelOrderDetail.getOrderStatus(), cTripHotelRecordBase.getCreateTime()); - }); + }, () -> orderHotelRecord.loadOrderNoInfo(cTripHotelRecordBase.getOrderId(), //兼容测试环境不存在行程规划单的情况 // 加载订单关联号信息 + cTripHotelRecord.getRecordId(), + cTripHotelRecord.getRouteOrderNo(), + String.valueOf(cTripHotelRecordBase.getOrderId()), + String.valueOf(cTripHotelRecordBase.getOrderId())) + .loadBasicOrderInfo(String.valueOf(cTripHotelRecordBase.getOrderId()), // 加载基础订单信息 + "", + cTripHotelRecordBase.getCreateTime())); // 加载财务信息 orderHotelRecord.loadFinancialInfo(cTripHotelRecordBase.getSubAccCheckBatchNo(), diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java index 2064d583..83f99b58 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactory.java @@ -17,12 +17,6 @@ public class OrderRecordFactory { @Autowired private UserRepository userRepository; - @Autowired - private CTripOrderRecordExtensionFactory cTripOrderRecordExtensionFactory; - - @Autowired - private LyOrderRecordExtensionFactory lyOrderRecordExtensionFactory; - public OrderRecordBasic buildWithRouteOrder(RouteOrder routeOrder) { routeOrder.reloadStatus(); OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); @@ -71,11 +65,4 @@ public class OrderRecordFactory { return orderRecordBasic; } - public OrderRecordExtensionFactory extensionFactoryOfSupplierName(String supplierName) { - return switch (supplierName) { - case SUPPLIER_C_TRIP -> cTripOrderRecordExtensionFactory; - case SUPPLIER_L_Y -> lyOrderRecordExtensionFactory; - default -> null; - }; - } } diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactorySelector.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactorySelector.java new file mode 100644 index 00000000..88aa0973 --- /dev/null +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordFactorySelector.java @@ -0,0 +1,24 @@ +package com.chint.domain.factoriy.order_record; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y; + +@Component +public class OrderRecordFactorySelector { + @Autowired + private CTripOrderRecordExtensionFactory cTripOrderRecordExtensionFactory; + + @Autowired + private LyOrderRecordExtensionFactory lyOrderRecordExtensionFactory; + + public OrderRecordExtensionFactory extensionFactoryOfSupplierName(String supplierName) { + return switch (supplierName) { + case SUPPLIER_C_TRIP -> cTripOrderRecordExtensionFactory; + case SUPPLIER_L_Y -> lyOrderRecordExtensionFactory; + default -> null; + }; + } +} diff --git a/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java index 1bd7acab..435ed60c 100644 --- a/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderCarRecordRepository.java @@ -1,12 +1,16 @@ package com.chint.domain.repository; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; +import com.chint.infrastructure.util.PageResult; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; public interface OrderCarRecordRepository { List saveAll(List orderCarRecordList); - Optional findByDetailId(String detailId); + Optional findByDetailId(String detailId); + + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); } diff --git a/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java index 5a11f804..26776622 100644 --- a/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderFlightRecordRepository.java @@ -1,7 +1,9 @@ package com.chint.domain.repository; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; +import com.chint.infrastructure.util.PageResult; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -9,4 +11,10 @@ public interface OrderFlightRecordRepository { List saveAll(List orderFlightRecordList); Optional findByDetailId(String detailId); + + PageResult findByUpdateDataTime(LocalDateTime startTime, + LocalDateTime endTime, + Integer pageSize, + Integer pageNum, + String systemType); } diff --git a/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java index b7b51daa..be2cc0fd 100644 --- a/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderHotelRecordRepository.java @@ -1,7 +1,10 @@ package com.chint.domain.repository; +import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; +import com.chint.infrastructure.util.PageResult; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -9,4 +12,6 @@ public interface OrderHotelRecordRepository { List saveAll(List orderHotelRecordList); Optional findByDetailId(String detailId); + + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); } diff --git a/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java index 110ab308..3a50a491 100644 --- a/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java +++ b/src/main/java/com/chint/domain/repository/OrderTrainRecordRepository.java @@ -1,8 +1,11 @@ package com.chint.domain.repository; +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.infrastructure.util.PageResult; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -10,4 +13,6 @@ public interface OrderTrainRecordRepository { List saveAll(List orderTrainRecordList); Optional findByDetailId(String detailId); + + PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType); } diff --git a/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordDomainService.java b/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordDomainService.java index 522ceedc..06a0d451 100644 --- a/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordDomainService.java +++ b/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordDomainService.java @@ -11,8 +11,10 @@ import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHo import com.chint.domain.factoriy.order_record.CTripOrderRecordExtensionFactory; import com.chint.domain.factoriy.order_record.OrderRecordExtensionFactory; import com.chint.domain.factoriy.order_record.OrderRecordFactory; +import com.chint.domain.factoriy.order_record.OrderRecordFactorySelector; import com.chint.domain.repository.CTripOrderDetailRepository; import com.chint.domain.service.OrderDetailDomainService; +import com.chint.infrastructure.echo_framework.annotation.ListenTo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -31,13 +33,14 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService { @Autowired private CTripOrderDetailRepository cTripOrderDetailRepository; @Autowired - private OrderRecordFactory orderRecordFactory; + private OrderRecordFactorySelector orderRecordFactorySelector; + @ListenTo(command = "OrderRecordGenerateCommand", order = 0) @Override public List generateHotelRecord(OrderRecordGenerateCommand command) { List records = cTripOrderDetailRepository.findHotelRecordByCreateTime(command.getStartTime(), command.getEndTime()); - OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); + OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); List list = records.stream().map(orderRecordExtensionFactory::createHotelOrderRecord).toList(); return orderDetailDomainService.saveHotelOrderRecordBatch(list); } @@ -48,18 +51,20 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService { return null; } + @ListenTo(command = "OrderRecordGenerateCommand", order = 1) @Override public List generateFlightRecord(OrderRecordGenerateCommand command) { List records = cTripOrderDetailRepository.findFlightRecordByCreateTime(command.getStartTime(), command.getEndTime()); - OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); + OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); List list = records.stream().map(orderRecordExtensionFactory::createFlightOrderRecord).toList(); return orderDetailDomainService.saveFlightOrderRecordBatch(list); } + @ListenTo(command = "OrderRecordGenerateCommand", order = 2) @Override public List generateCarRecord(OrderRecordGenerateCommand command) { List records = cTripOrderDetailRepository.findCarRecordByCreateTime(command.getStartTime(), command.getEndTime()); - OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); + OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); List list = records.stream().map(orderRecordExtensionFactory::createCarOrderRecord).toList(); return orderDetailDomainService.saveCarOrderRecordBatch(list); } diff --git a/src/main/java/com/chint/infrastructure/constant/OrderConstant.java b/src/main/java/com/chint/infrastructure/constant/OrderConstant.java index 3b11952c..f5494b1c 100644 --- a/src/main/java/com/chint/infrastructure/constant/OrderConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/OrderConstant.java @@ -14,6 +14,7 @@ public class OrderConstant { public static final String ORDER_EVENT_REFUND_NAME = "退票"; public static final int ORDER_EVENT_FINISH = 5; public static final String ORDER_EVENT_FINISH_NAME = "已完成"; + public static final int ORDER_EVENT_CANCEL = -1; public static final String ORDER_EVENT_CANCEL_NAME = "取消"; public static final int ORDER_EVENT_ETA = -2; diff --git a/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java index 3d9018b9..bd675e95 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderCarRecordRepositoryImpl.java @@ -3,9 +3,14 @@ package com.chint.infrastructure.repository; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.repository.OrderCarRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderCarRecordRepository; +import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -14,6 +19,7 @@ import java.util.Optional; public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository { @Autowired private JdbcOrderCarRecordRepository orderCarRecordRepository; + @Override public List saveAll(List orderCarRecordList) { List res = new ArrayList<>(); @@ -25,4 +31,16 @@ public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository { public Optional findByDetailId(String detailId) { return orderCarRecordRepository.findByDetailId(detailId); } + + @Override + public PageResult findByUpdateDataTime(LocalDateTime startTime, + LocalDateTime endTime, + Integer pageSize, + Integer pageNum, + String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + Page byUpdateDataTimeBetween = orderCarRecordRepository + .findByBelongSysTypeAndUpdateDataTimeBetween(systemType, startTime, endTime, pageRequest); + return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java index 0d28efee..87e8436d 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderFlightRecordRepositoryImpl.java @@ -3,9 +3,14 @@ package com.chint.infrastructure.repository; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; import com.chint.domain.repository.OrderFlightRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderFlightRecordRepository; +import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -28,4 +33,12 @@ public class OrderFlightRecordRepositoryImpl implements OrderFlightRecordReposit return jdbcOrderFlightRecordRepository.findByDetailId(detailId); } + @Override + public PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum, String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + Page byUpdateDataTimeBetween = jdbcOrderFlightRecordRepository + .findByBelongSysTypeAndUpdateDataTimeBetween(systemType, startTime, endTime, pageRequest); + return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); + } + } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java index fced6b8c..50b7e88c 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderHotelRecordRepositoryImpl.java @@ -1,13 +1,19 @@ package com.chint.infrastructure.repository; +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.repository.OrderHotelRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderFlightRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository; +import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -28,4 +34,12 @@ public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepositor public Optional findByDetailId(String detailId) { return jdbcOrderHotelRecordRepository.findByDetailId(detailId); } + + @Override + public PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + Page byUpdateDataTimeBetween = jdbcOrderHotelRecordRepository + .findByBelongSysTypeAndUpdateDataTimeBetween(systemType, startTime, endTime, pageRequest); + return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java index 9581a020..e9a8df6d 100644 --- a/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/OrderTrainRecordRepositoryImpl.java @@ -5,9 +5,14 @@ import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; import com.chint.domain.repository.OrderTrainRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderTrainRecordRepository; +import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -27,4 +32,12 @@ public class OrderTrainRecordRepositoryImpl implements OrderTrainRecordRepositor public Optional findByDetailId(String detailId) { return jdbcOrderTrainRecordRepository.findByDetailId(detailId); } + + @Override + public PageResult findByUpdateDataTime(LocalDateTime startTime, LocalDateTime endTime, Integer pageSize, Integer pageNum ,String systemType) { + PageRequest pageRequest = PageRequest.of(pageNum - 1, pageSize, Sort.by("update_data_time").descending()); + Page byUpdateDataTimeBetween = jdbcOrderTrainRecordRepository + .findByBelongSysTypeAndUpdateDataTimeBetween(systemType, startTime, endTime, pageRequest); + return PageResult.totalPageNum(byUpdateDataTimeBetween.getTotalElements(), byUpdateDataTimeBetween.getContent()); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/config/OrderRecordCallbackImpl.java b/src/main/java/com/chint/infrastructure/repository/config/OrderRecordCallbackImpl.java new file mode 100644 index 00000000..68ad7379 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/config/OrderRecordCallbackImpl.java @@ -0,0 +1,22 @@ +package com.chint.infrastructure.repository.config; + +import com.chint.domain.aggregates.base.BaseEntity; +import com.chint.domain.aggregates.order.order_record.OrderBaseRecord; +import com.chint.infrastructure.util.BaseContext; +import org.springframework.data.relational.core.conversion.MutableAggregateChange; +import org.springframework.data.relational.core.mapping.event.BeforeSaveCallback; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; + +@Component +public class OrderRecordCallbackImpl implements BeforeSaveCallback { + @Override + public OrderBaseRecord onBeforeSave(OrderBaseRecord entity, MutableAggregateChange aggregateChange) { + if (entity.getCreateDataTime() == null) { + entity.setCreateDataTime(LocalDateTime.now()); + } + entity.setUpdateDataTime(LocalDateTime.now()); + return entity; + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java index 70b21aa6..bf1fac92 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderCarRecordRepository.java @@ -1,13 +1,18 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.order.order_record.OrderCarRecord; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.Optional; @Repository -public interface JdbcOrderCarRecordRepository extends CrudRepository { +public interface JdbcOrderCarRecordRepository extends CrudRepository { Optional findByDetailId(String detailId); + + Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java index 88a5ce4a..a6d053d7 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderFlightRecordRepository.java @@ -1,12 +1,17 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.Optional; @Repository -public interface JdbcOrderFlightRecordRepository extends CrudRepository { +public interface JdbcOrderFlightRecordRepository extends CrudRepository { Optional findByDetailId(String detailId); + + Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java index 919524e5..4bf5cd9a 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderHotelRecordRepository.java @@ -1,13 +1,18 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.order.order_record.OrderHotelRecord; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.Optional; @Repository -public interface JdbcOrderHotelRecordRepository extends CrudRepository { +public interface JdbcOrderHotelRecordRepository extends CrudRepository { Optional findByDetailId(String detailId); + + Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java index 36457a1d..ee634c0a 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcOrderTrainRecordRepository.java @@ -1,12 +1,17 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.Optional; @Repository -public interface JdbcOrderTrainRecordRepository extends CrudRepository { +public interface JdbcOrderTrainRecordRepository extends CrudRepository { Optional findByDetailId(String detailId); + + Page findByBelongSysTypeAndUpdateDataTimeBetween(String belongSysType, LocalDateTime updateDataTime, LocalDateTime updateDataTime2, Pageable pageable); } diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java index 764e569c..6793cf08 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/order/CTripOrderRecordAutoSave.java @@ -11,6 +11,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Component @Slf4j @@ -49,6 +51,13 @@ public class CTripOrderRecordAutoSave { CTripFlightInfo.of(it.getOrderFlightInfo()), CTripFlightBaseInfo.of(it.getOrderBaseInfo()) ); + } else { + Long originId = record.getId(); + record = CTripFlightRecord.of( + CTripFlightRecordBase.changeInfo(orderSettlementBaseInfo), + CTripFlightInfo.of(it.getOrderFlightInfo()), + CTripFlightBaseInfo.of(it.getOrderBaseInfo())); + record.setId(originId); } //补充额外的字段 OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo(); @@ -74,13 +83,21 @@ public class CTripOrderRecordAutoSave { record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), CTripHotelInfo.of(it.getHotelDetail()), CTripHotelOrderDetail.of(it.getOrderDetail())); + } else { + Long originId = record.getId(); + record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), + CTripHotelInfo.of(it.getHotelDetail()), + CTripHotelOrderDetail.of(it.getOrderDetail())); + record.setId(originId); } //补充额外的字段 OrderHotelResponse.SettlementOrderDetail orderDetail = it.getOrderDetail(); - record.setRecordId(orderDetail.getHotelRelatedJourneyNo()); + record.setRouteOrderNo(orderDetail.getHotelRelatedJourneyNo()); return record; }).toList(); - cTripOrderDetailRepository.saveAllCTripHotelRecord(list); + Map> collect = list.stream() + .collect(Collectors.groupingBy(record -> record.getId() != null)); + collect.values().forEach(it -> cTripOrderDetailRepository.saveAllCTripHotelRecord(it)); } } @@ -98,6 +115,11 @@ public class CTripOrderRecordAutoSave { if (record == null) { record = CTripTrainRecord.of(CTripTrainRecordBase.changeInfo(trainSettlementDetail), CTripTrainInfo.of(it.getTrainSettlementTicket())); + } else { + Long originId = record.getId(); + record = CTripTrainRecord.of(CTripTrainRecordBase.changeInfo(trainSettlementDetail), + CTripTrainInfo.of(it.getTrainSettlementTicket())); + record.setId(originId); } //补充额外的字段 record.setRouteOrderNo(it.getTrainSettlementOrder().getJouneryID()); @@ -123,6 +145,14 @@ public class CTripOrderRecordAutoSave { CTripCarQuickInfo.of(it.getOrderDetail().getQuickProductInfo()), CTripCarPassengerInfo.of(it.getOrderDetail().getPassengerInfoList().get(0)) ); + } else { + Long originId = record.getId(); + record = CTripCarRecord.of( + CTripCarRecordBase.changeInfo(settlementBaseInfo), + CTripCarQuickInfo.of(it.getOrderDetail().getQuickProductInfo()), + CTripCarPassengerInfo.of(it.getOrderDetail().getPassengerInfoList().get(0)) + ); + record.setId(originId); } //补充额外的字段 OrderCarResponse.CarOrderCorpInfo corpInfo = it.getOrderDetail().getCorpInfo(); diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index e3af2944..70ba7b84 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -14,8 +14,8 @@ chint: # host: gf-jump.chint.com # port: 30108 # database: itinerary_booking -# username: 42b24d69-49d0-4085-b8a8-a281d0b66bb2 -# password: bHFb2HZtUHKIoZ2O +# username: fe1ff9fb-6d54-46ab-84ae-e76f00d2d473 +# password: EpqDr9g6xc3CrQlg url: https://trip.chint.com/ redis: @@ -27,8 +27,8 @@ chint: logging: level: - org.springframework.jdbc.core.JdbcTemplate: info - org.springframework.jdbc.core.StatementCreatorUtils: info + org.springframework.jdbc.core.JdbcTemplate: debug + org.springframework.jdbc.core.StatementCreatorUtils: debug root: info org.springframework.cache: info diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index de2b5abe..2ee1855b 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -40,6 +40,7 @@ import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification; import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; import com.chint.interfaces.rest.ctrip.in.CTripNoteController; import com.chint.interfaces.rest.ctrip.order.CTripOrderDetailRequest; +import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave; import com.google.gson.Gson; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -130,6 +131,9 @@ public class CTripTest { @Autowired private CTripOrderDetailImpl cTripOrderDetail; + @Autowired + private CTripOrderRecordAutoSave cTripOrderRecordAutoSave; + private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365", "A30000001"); @@ -613,4 +617,9 @@ public class CTripTest { System.out.println(gson.toJson(byId)); } + +// @Test + void saveFlightRecord(){ + cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(); + } } diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index 3e948ad8..0a70fb33 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -279,7 +279,7 @@ class RouteApplicationTests { // @Test void loginSignProd() { - String sfno = "231201060"; + String sfno = "190801115"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司";