From c6da4013be6f464c59903d7fa0dd3729af2dc46b Mon Sep 17 00:00:00 2001 From: Superdandan <1033719135@qq.com> Date: Mon, 1 Apr 2024 11:11:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=90=BA=E7=A8=8B=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order_record/OrderRecordFactory.java | 15 ++++++++ .../CTripOrderDetailRepository.java | 23 +++++++++++-- .../CTripOrderRecordDomainService.java | 34 ++++++++++++++----- .../repository/CTripOrderDetailImpl.java | 27 +++++++++++---- .../jdbc/JdbcCTripCarRecordRepository.java | 6 ++++ .../jdbc/JdbcCTripFlightRecordRepository.java | 5 +++ .../jdbc/JdbcCTripHotelRecordRepository.java | 5 +++ .../jdbc/JdbcCTripTrainRecordRepository.java | 5 +++ 8 files changed, 103 insertions(+), 17 deletions(-) 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 384192a1..2064d583 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 @@ -9,6 +9,7 @@ import org.springframework.stereotype.Component; import static com.chint.infrastructure.constant.BelongSystemConstant.*; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y; @Component public class OrderRecordFactory { @@ -16,6 +17,12 @@ 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(); @@ -63,4 +70,12 @@ 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/repository/CTripOrderDetailRepository.java b/src/main/java/com/chint/domain/repository/CTripOrderDetailRepository.java index b43d66f5..11503043 100644 --- a/src/main/java/com/chint/domain/repository/CTripOrderDetailRepository.java +++ b/src/main/java/com/chint/domain/repository/CTripOrderDetailRepository.java @@ -2,6 +2,7 @@ package com.chint.domain.repository; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*; +import java.time.LocalDateTime; import java.util.List; /** @@ -37,14 +38,32 @@ public interface CTripOrderDetailRepository { void saveAllCarRecord(List ctripCarOrderDetailList); CTripCarRecordBase findCarByRecordId(Long id); + void saveAllCTripFlightRecord(List cTripFlightRecordList); - CTripFlightRecord findFlightRecordById(Long id); + + CTripFlightRecord findFlightRecordById(Long id); + CTripFlightRecord findFlightRecordByRecordId(String recordId); + void saveAllCTripHotelRecord(List cTripHotelRecordList); - CTripHotelRecord findHotelRecordById(Long id); + + CTripHotelRecord findHotelRecordById(Long id); + CTripHotelRecord findHotelRecordByRecordId(String recordId); + void saveAllCTripTrainRecord(List cTripTrainRecordList); + CTripTrainRecord findTrainRecordByRecordId(String recordId); + void saveAllCTripCarRecord(List cTripCarRecordList); + CTripCarRecord findCarRecordByRecordId(String recordId); + + List findHotelRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime); + + List findFlightRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime); + + List findCarRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime); + + List findTrainRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime); } 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 38906319..522ceedc 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 @@ -5,29 +5,41 @@ 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.ctrip_order_record.CTripCarRecord; +import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripFlightRecord; +import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord; 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.repository.CTripOrderDetailRepository; import com.chint.domain.service.OrderDetailDomainService; -import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.time.LocalDateTime; import java.util.List; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; + @Component -public class CTripOrderRecordDomainService implements OrderRecordDomainService{ +public class CTripOrderRecordDomainService implements OrderRecordDomainService { @Autowired private CTripOrderRecordExtensionFactory cTripOrderRecordExtensionFactory; @Autowired private OrderDetailDomainService orderDetailDomainService; + @Autowired + private CTripOrderDetailRepository cTripOrderDetailRepository; + @Autowired + private OrderRecordFactory orderRecordFactory; @Override public List generateHotelRecord(OrderRecordGenerateCommand command) { - - return null; + List records = cTripOrderDetailRepository.findHotelRecordByCreateTime(command.getStartTime(), command.getEndTime()); + OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); + List list = records.stream().map(orderRecordExtensionFactory::createHotelOrderRecord).toList(); + return orderDetailDomainService.saveHotelOrderRecordBatch(list); } @Override @@ -38,13 +50,17 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService{ @Override public List generateFlightRecord(OrderRecordGenerateCommand command) { - - return null; + List records = cTripOrderDetailRepository.findFlightRecordByCreateTime(command.getStartTime(), command.getEndTime()); + OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); + List list = records.stream().map(orderRecordExtensionFactory::createFlightOrderRecord).toList(); + return orderDetailDomainService.saveFlightOrderRecordBatch(list); } @Override public List generateCarRecord(OrderRecordGenerateCommand command) { - - return null; + List records = cTripOrderDetailRepository.findCarRecordByCreateTime(command.getStartTime(), command.getEndTime()); + OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactory.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/repository/CTripOrderDetailImpl.java b/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java index ab6568e1..14bce675 100644 --- a/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java @@ -6,6 +6,7 @@ import com.chint.infrastructure.repository.jdbc.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.List; /** @@ -120,7 +121,7 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository { } @Override - public CTripFlightRecord findFlightRecordById(Long id) { + public CTripFlightRecord findFlightRecordById(Long id) { return jdbcCTripFlightRecordRepository.findById(id).get(); } @@ -163,11 +164,25 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository { public CTripCarRecord findCarRecordByRecordId(String recordId) { return jdbcCTripCarRecordRepository.findByRecordId(recordId); } -// -// @Override -// public Client findByClientId(String clientId){ -// return jdbcClientRepository.findByClientId(clientId); -// } + @Override + public List findHotelRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) { + return jdbcCTripHotelRecordRepository.findByCreateTimeBetween(startTime, endTime); + } + + @Override + public List findFlightRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) { + return jdbcCTripFlightRecordRepository.findByCreateTimeBetween(startTime, endTime); + } + + @Override + public List findCarRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) { + return jdbcCTripCarRecordRepository.findByCreateTimeBetween(startTime, endTime); + } + + @Override + public List findTrainRecordByCreateTime(LocalDateTime startTime, LocalDateTime endTime) { + return jdbcCTripTrainRecordRepository.findByCreateTimeBetween(startTime, endTime); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripCarRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripCarRecordRepository.java index 6f2da842..29d4f727 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripCarRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripCarRecordRepository.java @@ -3,10 +3,16 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarRecord; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarRecordBase; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripFlightRecordBase; +import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; +import java.util.List; + @Repository public interface JdbcCTripCarRecordRepository extends CrudRepository { CTripCarRecord findByRecordId(String recordId); + + List findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripFlightRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripFlightRecordRepository.java index 8669cf7e..774a7a3e 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripFlightRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripFlightRecordRepository.java @@ -1,11 +1,16 @@ package com.chint.infrastructure.repository.jdbc; import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripFlightRecord; +import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; +import java.util.List; + @Repository public interface JdbcCTripFlightRecordRepository extends CrudRepository { CTripFlightRecord findByRecordId(String recordId); + List findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripHotelRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripHotelRecordRepository.java index c844e383..897c6a8f 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripHotelRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripHotelRecordRepository.java @@ -5,7 +5,12 @@ import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHo import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; +import java.util.List; + @Repository public interface JdbcCTripHotelRecordRepository extends CrudRepository { CTripHotelRecord findByRecordId(String recordId); + + List findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripTrainRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripTrainRecordRepository.java index 2dabe052..7ce1e3fe 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripTrainRecordRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripTrainRecordRepository.java @@ -5,7 +5,12 @@ import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripTr import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; +import java.util.List; + @Repository public interface JdbcCTripTrainRecordRepository extends CrudRepository { CTripTrainRecord findByRecordId(String recordId); + + List findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2); }