diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripCarRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripCarRecord.java index dad4db00..590ba38b 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripCarRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripCarRecord.java @@ -21,6 +21,11 @@ public class CTripCarRecord implements Serializable { private LocalDateTime createTime; private String routeOrderNo; private String orderDate; + private String bookingUserName; + private String bookingUserCode; + private String bookingUserPhone; + private String userName; + private String userCode; @MappedCollection(idColumn = "c_trip_car_record_id") private CTripCarRecordBase cTripCarRecordBase; @MappedCollection(idColumn = "c_trip_car_record_id") diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripFlightRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripFlightRecord.java index 8fe8346c..9256c182 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripFlightRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripFlightRecord.java @@ -21,6 +21,11 @@ public class CTripFlightRecord implements Serializable { public LocalDateTime createTime; private String routeOrderNo; private String ticketNo; + private String bookingUserName; + private String bookingUserCode; + private String bookingUserPhone; + private String userName; + private String userCode; @MappedCollection(idColumn = "c_trip_flight_record_id") private CTripFlightRecordBase cTripFlightRecordBase; @MappedCollection(idColumn = "c_trip_flight_record_id") diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripHotelRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripHotelRecord.java index 3d48c646..1c9fd0df 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripHotelRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripHotelRecord.java @@ -20,6 +20,11 @@ public class CTripHotelRecord implements Serializable { private String recordId; private LocalDateTime createTime; private String routeOrderNo; + private String bookingUserName; + private String bookingUserCode; + private String bookingUserPhone; + private String userName; + private String userCode; @MappedCollection(idColumn = "c_trip_hotel_record_id") private CTripHotelRecordBase cTripHotelRecordBase; @MappedCollection(idColumn = "c_trip_hotel_record_id") diff --git a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripTrainRecord.java b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripTrainRecord.java index 2db57c72..71a9b239 100644 --- a/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripTrainRecord.java +++ b/src/main/java/com/chint/domain/aggregates/order/order_record/ctrip_order_record/CTripTrainRecord.java @@ -20,6 +20,11 @@ public class CTripTrainRecord implements Serializable { private String recordId; private LocalDateTime createTime; private String routeOrderNo; + private String bookingUserName; + private String bookingUserCode; + private String bookingUserPhone; + private String userName; + private String userCode; @MappedCollection(idColumn = "c_trip_train_record_id") private CTripTrainRecordBase cTripTrainRecordBase; @MappedCollection(idColumn = "c_trip_train_record_id") diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java index d8aff103..a9d5fe55 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java @@ -108,7 +108,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { flightOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), FlightOrderDetail.class); } else { //如果已经存在的话 ,那么这些基础字段就不用重新构建了 - return orderDetail.getFlightOrderDetail(); + flightOrderDetail = orderDetail.getFlightOrderDetail(); } if(orderDetail.getOrderEventList() != null){ //如果订单存在,直接配置该订单的超标信息和原因 @@ -139,7 +139,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { trainOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), TrainOrderDetail.class); } else { //如果已经存在的话 ,那么这些基础字段就不用重新构建了 - return order.getTrainOrderDetail(); + trainOrderDetail = order.getTrainOrderDetail(); } if(order.getOrderEventList() != null){ //如果订单存在,直接配置该订单的超标信息和原因 @@ -174,7 +174,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { hotelOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), HotelOrderDetail.class); } else { //如果已经存在的话 ,那么这些基础字段就不用重新构建了 - return orderDetail.getHotelOrderDetail(); + hotelOrderDetail = orderDetail.getHotelOrderDetail(); } //如果订单存在,直接配置该订单的超标信息和原因 @@ -207,7 +207,7 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { carOrderDetail = BeanUtil.copyProperties(buildWithRouteOrder(routeOrder), CarOrderDetail.class); } else { //如果已经存在的话 ,那么这些基础字段就不用重新构建了 - return orderDetail.getCarOrderDetail(); + carOrderDetail = orderDetail.getCarOrderDetail(); } //如果订单存在,直接配置该订单的超标信息和原因 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 5dacbe32..279ee090 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 @@ -13,6 +13,7 @@ import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.UserCustomCodeRepository; import com.chint.domain.repository.UserRepository; import com.chint.domain.service.OrderDetailDomainService; +import com.chint.domain.service.RouteRequestDomainService; import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository; import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.OrderNo; @@ -46,6 +47,9 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac @Autowired private UserHttpRequest userHttpRequest; + @Autowired + private RouteRequestDomainService routeRequestDomainService;; + @Autowired private UserCustomCodeRepository userCustomCodeRepository; @@ -70,20 +74,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac return res; } - private OrderRecordBasic buildWithRecord(CTripCarRecord cTripCarRecord) { - OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); - CTripCarPassengerInfo cTripCarPassengerInfo = cTripCarRecord.getCTripCarPassengerInfo(); - String employeeID = cTripCarPassengerInfo.getEmployeeID(); + private OrderRecordBasic buildWithRecord(CTripCarRecord record) { + CTripCarPassengerInfo cTripCarPassengerInfo = record.getCTripCarPassengerInfo(); - //如果employeeID为空随机生成一个id给该用户名 - if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) { - employeeID = getCustomCode(cTripCarPassengerInfo.getPassengerName()); - } - orderRecordBasic.loadBookingInfo(employeeID, - cTripCarPassengerInfo.getPassengerName(), - "", - cTripCarPassengerInfo.getPassengerName(), - employeeID); + OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(), + record.getBookingUserName(), + record.getBookingUserPhone(), + record.getUserCode(), + record.getUserName()); orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setAccountCompanyId(cTripCarPassengerInfo.getCostCenter1()); @@ -98,7 +96,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) { CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData; String routeOrderNo = cTripCarRecord.getRouteOrderNo(); - Optional byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); + Optional byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo)); OrderCarRecord orderCarRecord = buildWithRecord(cTripCarRecord) .carRecord(); CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase(); @@ -275,20 +273,14 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac return null; } - private OrderRecordBasic buildWithRecord(CTripFlightRecord cTripFlightRecord) { - OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); - CTripFlightBaseInfo cTripFlightBaseInfo = cTripFlightRecord.getCTripFlightBaseInfo(); - String employeeID = cTripFlightBaseInfo.getEmployeeID(); - //如果employeeID为空随机生成一个id给该用户名 - if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) { - employeeID = getCustomCode(cTripFlightBaseInfo.getName()); - } + private OrderRecordBasic buildWithRecord(CTripFlightRecord record) { - orderRecordBasic.loadBookingInfo(employeeID, - cTripFlightBaseInfo.getName(), - "", - cTripFlightBaseInfo.getName(), - employeeID); + CTripFlightBaseInfo cTripFlightBaseInfo = record.getCTripFlightBaseInfo(); + OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(), + record.getBookingUserName(), + record.getBookingUserPhone(), + record.getUserCode(), + record.getUserName()); orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setAccountCompanyId(cTripFlightBaseInfo.getCostCenter()); @@ -305,7 +297,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac CTripFlightBaseInfo cTripFlightBaseInfo = cTripFlightRecord.getCTripFlightBaseInfo(); CTripFlightTripInfo cTripFlightTripInfo = cTripFlightRecord.getCTripFlightTripInfo(); String routeOrderNo = cTripFlightRecord.getRouteOrderNo(); - Optional byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); + Optional byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo)); OrderFlightRecord orderFlightRecord = buildWithRecord(cTripFlightRecord) .flightRecord(); @@ -498,21 +490,13 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac } - private OrderRecordBasic buildWithRecord(CTripHotelRecord cTripHotelRecord) { - OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); - CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail(); - - String employeeID = cTripHotelOrderDetail.getEmployeeID(); - //如果employeeID为空随机生成一个id给该用户名 - if (employeeID == null || employeeID.isBlank() || employeeID.isEmpty()) { - employeeID = getCustomCode(cTripHotelOrderDetail.getEmployeeName()); - } - - orderRecordBasic.loadBookingInfo(employeeID, - cTripHotelOrderDetail.getEmployeeName(), - "", - cTripHotelOrderDetail.getEmployeeName(), - employeeID); + private OrderRecordBasic buildWithRecord(CTripHotelRecord record) { + CTripHotelOrderDetail cTripHotelOrderDetail = record.getCTripHotelOrderDetail(); + OrderRecordBasic orderRecordBasic = loadBookingInfoAndUserInfo(record.getBookingUserCode(), + record.getBookingUserName(), + record.getBookingUserPhone(), + record.getUserCode(), + record.getUserName()); orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); orderRecordBasic.setAccountCompanyId(cTripHotelOrderDetail.getCostCenter()); orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2()); @@ -527,7 +511,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac CTripHotelRecord cTripHotelRecord = (CTripHotelRecord) orderHotelRecordData; CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail(); String routeOrderNo = cTripHotelRecord.getRouteOrderNo(); - Optional byOrderNo = Optional.ofNullable(routeRepository.findByOrderNo(routeOrderNo)); + Optional byOrderNo = Optional.ofNullable(routeRequestDomainService.getRouteOrder(routeOrderNo)); OrderHotelRecord orderHotelRecord = buildWithRecord(cTripHotelRecord) .hotelRecord(); @@ -771,4 +755,27 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac default -> "0"; }; } + + private String checkAndGenerateEmployeeId(String employeeId, String employeeName) { + //如果employeeID为空随机生成一个id给该用户名 + if (employeeId == null || employeeId.isBlank() || employeeId.isEmpty()) { + employeeId = getCustomCode(employeeName); + } + return employeeId; + } + + private OrderRecordBasic loadBookingInfoAndUserInfo(String bookingUserCode, + String bookingUserName, + String bookingUserPhone, + String userCode, + String userName) { + bookingUserCode = checkAndGenerateEmployeeId(bookingUserCode, bookingUserName); + userCode = checkAndGenerateEmployeeId(userCode, userName); + OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); + return orderRecordBasic.loadBookingInfo(bookingUserCode, + bookingUserName, + bookingUserPhone, + userName, + userCode); + } } 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 32584d12..e223d823 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 @@ -8,6 +8,7 @@ import com.chint.domain.aggregates.order.order_record.OrderTrainRecord; import com.chint.domain.aggregates.order.order_record.ly_order_record.*; import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.UserDepartmentInfo; +import com.chint.domain.repository.RouteRepository; import com.chint.infrastructure.repository.jdbc.*; import com.chint.infrastructure.util.BeanCopyUtils; import com.chint.interfaces.rest.bpm.dto.BPMResponse; @@ -43,6 +44,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor @Autowired private JdbcRouteRepository jdbcRouteRepository; + @Autowired + private RouteRepository routeRepository; + @Autowired private OrderRecordFactory orderRecordFactory; @@ -554,7 +558,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor return new OrderRecordBasic(); } Long routeId = orderDetail.getRouteId(); - RouteOrder routeOrder = jdbcRouteRepository.findByRouteId(routeId); + RouteOrder routeOrder = routeRepository.queryById(routeId); consumerRouteOrder.accept(routeOrder == null ? new RouteOrder() : routeOrder); if (Objects.isNull(routeOrder)) { return new OrderRecordBasic(); diff --git a/src/main/java/com/chint/infrastructure/cache/RouteCacheManage.java b/src/main/java/com/chint/infrastructure/cache/RouteCacheManage.java index 749e7c47..11ecac2f 100644 --- a/src/main/java/com/chint/infrastructure/cache/RouteCacheManage.java +++ b/src/main/java/com/chint/infrastructure/cache/RouteCacheManage.java @@ -29,4 +29,7 @@ public interface RouteCacheManage { Long cacheFakeOrderNoAndSysCodeMapRouteId(String approveOrderNo_fakeOrderNo, String approveOrderNo_sysCode, RouteOrder routeOrder); Long cacheActualOrderNoAndSysCodeMapRouteId(String approveOrderNo_actualOrderNo, String approveOrderNo_sysCode, RouteOrder routeOrder); + + Long cacheRouteOrderNoMapRouteId(String routeOrderNo, RouteOrder routeOrder); + void invalidateRouteOrderNoMapRouteId(String routeOrderNo); } diff --git a/src/main/java/com/chint/infrastructure/cache/RouteCacheManageImpl.java b/src/main/java/com/chint/infrastructure/cache/RouteCacheManageImpl.java index 0228eaad..e66256f8 100644 --- a/src/main/java/com/chint/infrastructure/cache/RouteCacheManageImpl.java +++ b/src/main/java/com/chint/infrastructure/cache/RouteCacheManageImpl.java @@ -9,7 +9,6 @@ import org.springframework.cache.annotation.Cacheable; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; -import java.util.ArrayList; import java.util.List; @Slf4j @@ -20,7 +19,7 @@ public class RouteCacheManageImpl implements RouteCacheManage { private JdbcRouteRepository jdbcRouteRepository; @Autowired - private RedisTemplate redisTemplate; + private RedisTemplate redisTemplate; @Override @Cacheable(value = "userRouteLists", key = "#employeeNo") @@ -90,6 +89,20 @@ public class RouteCacheManageImpl implements RouteCacheManage { return routeOrder.getRouteId(); } + @Cacheable(value = "RouteOrderNo", key = "#routeOrderNo") + public Long cacheRouteOrderNoMapRouteId(String routeOrderNo, RouteOrder routeOrder) { + if (routeOrder == null) { + return null; + } + return routeOrder.getRouteId(); + } + + @CacheEvict(value = "RouteOrderNo", key = "#routeOrderNo") + @Override + public void invalidateRouteOrderNoMapRouteId(String routeOrderNo) { + + } + @CacheEvict(value = "FakeOrderNoAndSysCodeMapRouteId", key = "#approveOrderNo_fakeOrderNo+'-'+ #approveOrderNo_sysCode") public void invalidateFakeOrderNoAndSysCodeMapRouteId(String approveOrderNo_fakeOrderNo, String approveOrderNo_sysCode) { diff --git a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java index 6206ad6e..4d0f4494 100644 --- a/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java +++ b/src/main/java/com/chint/infrastructure/cache/RouteCacheService.java @@ -117,7 +117,6 @@ public class RouteCacheService { Long routeId = routeCacheManage.cacheActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode, null); if (routeId == null) { routeCacheManage.invalidateActualOrderNoAndSysCodeMapRouteId(actualOrderNo, sysCode); - return null; } RouteOrder routeOrder = jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(actualOrderNo, sysCode); if (routeOrder == null) { @@ -130,6 +129,20 @@ public class RouteCacheService { } } + public RouteOrder getRouteByRouteOrderNo(String routeOrderNo){ + Long routeId = routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, null); + if (routeId == null) { + routeCacheManage.invalidateRouteOrderNoMapRouteId(routeOrderNo); + } else { + return getFromCacheOrSaveToCache(routeId); + } + RouteOrder routeOrder = jdbcRouteRepository.findByRouteOrderNo(routeOrderNo); + if(routeOrder != null) { + routeCacheManage.cacheRouteOrderNoMapRouteId(routeOrderNo, routeOrder.reloadStatus()); + } + return routeOrder; + } + public void invalidateRouteCache(Long routeId) { routeCacheManage.invalidateRouteCache(routeId); diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java index 3c76625d..24472b95 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRepositoryImpl.java @@ -8,6 +8,7 @@ import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; @@ -63,9 +64,10 @@ public class RouteRepositoryImpl implements RouteRepository { } + @Override public RouteOrder findByOrderNo(String orderNo) { - return jdbcRouteRepository.findByRouteOrderNo(orderNo); + return routeCacheService.getRouteByRouteOrderNo(orderNo); } @Override diff --git a/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java index 8b7f130f..407fd734 100644 --- a/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/RouteRequestRepositoryImpl.java @@ -4,6 +4,7 @@ import com.chint.domain.aggregates.order.RouteRequest; import com.chint.domain.repository.RouteRequestRepository; import com.chint.infrastructure.repository.jdbc.JdbcRouteRequestRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Repository; @Repository @@ -12,6 +13,7 @@ public class RouteRequestRepositoryImpl implements RouteRequestRepository { @Autowired private JdbcRouteRequestRepository jdbcRouteRequestRepository; + @Cacheable(value = "RouteRequestNo" , key = "#routeRequestNo") @Override public RouteRequest findByRouteRequestNo(String routeRequestNo) { return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo); 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 f4573720..5a57d7ca 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 @@ -82,9 +82,18 @@ public class CTripOrderRecordAutoSave { OrderFlightResponse.FlightOrderBaseInfo orderBaseInfo = it.getOrderBaseInfo(); record.setRouteOrderNo(orderBaseInfo.getJourneyID()); OrderFlightResponse.FlightOrderPassenger orderPassengerInfo = it.getOrderPassengerInfo(); + if (orderPassengerInfo != null) { record.setTicketNo(orderPassengerInfo.getTicketNo()); + record.setUserCode(orderPassengerInfo.getEmployeeID()); + record.setUserName(orderPassengerInfo.getPassengerName()); + } else { + record.setUserCode(orderBaseInfo.getEmployeeID()); + record.setUserName(orderBaseInfo.getName()); } + record.setBookingUserCode(orderBaseInfo.getPreEmployeeID()); + record.setBookingUserName(orderBaseInfo.getName()); + record.setBookingUserPhone(""); return record; }).toList(); cTripOrderDetailRepository.saveAllCTripFlightRecord(cTripFlightRecords); @@ -106,20 +115,30 @@ public class CTripOrderRecordAutoSave { OrderHotelResponse.SettlementDetail settlementDetail = it.getSettlementDetail(); CTripHotelRecord record = cTripOrderDetailRepository.findHotelRecordByRecordId( String.valueOf(settlementDetail.getRecordId())); + OrderHotelResponse.SettlementOrderDetail settlementOrderDetail = it.getOrderDetail(); if (record == null) { record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), CTripHotelInfo.of(it.getHotelDetail()), - CTripHotelOrderDetail.of(it.getOrderDetail())); + CTripHotelOrderDetail.of(settlementOrderDetail)); } else { Long originId = record.getId(); record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail), CTripHotelInfo.of(it.getHotelDetail()), - CTripHotelOrderDetail.of(it.getOrderDetail())); + CTripHotelOrderDetail.of(settlementOrderDetail)); record.setId(originId); } //补充额外的字段 - OrderHotelResponse.SettlementOrderDetail orderDetail = it.getOrderDetail(); - record.setRouteOrderNo(orderDetail.getHotelRelatedJourneyNo()); + + record.setRouteOrderNo(settlementOrderDetail.getHotelRelatedJourneyNo()); + List clientDetailList = settlementOrderDetail.getClientDetailList(); + if (clientDetailList != null && !clientDetailList.isEmpty()) { + OrderHotelResponse.SettlementClientDetail settlementClientDetail = clientDetailList.get(0); + record.setUserCode(settlementClientDetail.getEmployeeID()); + record.setUserName(settlementOrderDetail.getClientName()); + } + record.setBookingUserCode(settlementOrderDetail.getEmployeeID()); + record.setBookingUserName(settlementOrderDetail.getEmployeeName()); + record.setBookingUserPhone(""); return record; }).toList(); Map> collect = list.stream() @@ -170,29 +189,43 @@ public class CTripOrderRecordAutoSave { List list = settlementList.stream() .flatMap(it -> it.getCarSettlementDetailList().stream()) .map(it -> { + OrderCarResponse.CarOrderDetail orderDetail = it.getOrderDetail(); OrderCarResponse.CarOrderSettlementBaseInfo settlementBaseInfo = it.getSettlementBaseInfo(); CTripCarRecord record = cTripOrderDetailRepository.findCarRecordByRecordId( String.valueOf(settlementBaseInfo.getRecordId())); + + List passengerInfoList = orderDetail.getPassengerInfoList(); + OrderCarResponse.CarOrderPassengerInfo carOrderPassengerInfo = passengerInfoList.get(0); + if (record == null) { record = CTripCarRecord.of( CTripCarRecordBase.changeInfo(settlementBaseInfo), - CTripCarQuickInfo.of(it.getOrderDetail().getQuickProductInfo()), - CTripCarPassengerInfo.of(it.getOrderDetail().getPassengerInfoList().get(0)) + CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()), + CTripCarPassengerInfo.of(carOrderPassengerInfo) ); } else { Long originId = record.getId(); record = CTripCarRecord.of( CTripCarRecordBase.changeInfo(settlementBaseInfo), - CTripCarQuickInfo.of(it.getOrderDetail().getQuickProductInfo()), - CTripCarPassengerInfo.of(it.getOrderDetail().getPassengerInfoList().get(0)) + CTripCarQuickInfo.of(orderDetail.getQuickProductInfo()), + CTripCarPassengerInfo.of(carOrderPassengerInfo) ); record.setId(originId); } //补充额外的字段 - OrderCarResponse.CarOrderCorpInfo corpInfo = it.getOrderDetail().getCorpInfo(); + OrderCarResponse.CarOrderCorpInfo corpInfo = orderDetail.getCorpInfo(); record.setRouteOrderNo(corpInfo.getJouneryId()); - String orderDate = it.getOrderDetail().getOrderBaseInfo().getOrderDate(); + OrderCarResponse.CarOrderBaseInfo orderBaseInfo = orderDetail.getOrderBaseInfo(); + + String orderDate = orderBaseInfo.getOrderDate(); record.setOrderDate(DateTimeUtil.timeToStrCommon(DateTimeUtil.strToTime(orderDate))); + + + record.setUserCode(carOrderPassengerInfo.getEmployeeID()); + record.setUserName(carOrderPassengerInfo.getPassengerName()); + record.setBookingUserCode(orderBaseInfo.getPreEmployeeID()); + record.setBookingUserName(orderBaseInfo.getUserName()); + record.setBookingUserPhone(orderBaseInfo.getContactMobile()); return record; }).toList(); cTripOrderDetailRepository.saveAllCTripCarRecord(list);