diff --git a/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java b/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java new file mode 100644 index 00000000..b0013e98 --- /dev/null +++ b/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java @@ -0,0 +1,15 @@ +package com.chint.application.commands; + +import com.chint.infrastructure.echo_framework.command.Command; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; + +@Data +public class OrderRecordGenerateCommand extends Command { + //将昨天的结算数据生成为财务共享需要的数据 + private LocalDateTime startTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT); + private LocalDateTime endTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MAX); +} diff --git a/src/main/java/com/chint/application/in/AutoWorkController.java b/src/main/java/com/chint/application/in/AutoWorkController.java index 252ccee0..daebb5ac 100644 --- a/src/main/java/com/chint/application/in/AutoWorkController.java +++ b/src/main/java/com/chint/application/in/AutoWorkController.java @@ -1,6 +1,8 @@ package com.chint.application.in; +import com.chint.application.commands.OrderRecordGenerateCommand; +import com.chint.infrastructure.echo_framework.command.Command; import com.chint.infrastructure.util.Result; import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave; import io.swagger.annotations.ApiOperation; @@ -22,10 +24,12 @@ public class AutoWorkController { @Transactional - @ApiOperation("自动拉取携程昨天的流水号,每天晚上8点执行") + @ApiOperation("自动拉取昨天的流水号,每天晚上8点执行") @PostMapping("/cTrip/record/save") public Result autoSaveCTripRecord(){ cTripOrderRecordAutoSave.saveAll(); + //将昨天的结算数据生成为财务共享需要的数据 + Command.of(OrderRecordGenerateCommand.class).sendToQueue(); return Result.Success(SUCCESS); } diff --git a/src/main/java/com/chint/application/out/OrderDetailController.java b/src/main/java/com/chint/application/out/OrderDetailController.java index 5f2e8fd7..efd43a88 100644 --- a/src/main/java/com/chint/application/out/OrderDetailController.java +++ b/src/main/java/com/chint/application/out/OrderDetailController.java @@ -93,7 +93,7 @@ public class OrderDetailController { @PostMapping("/record/query") public Result> queryRecord(@RequestBody AuthenticationSignDto authenticationDto) { if (signCheck(authenticationDto)) { - return orderDetailPageQuery.orderDetailInfoPageQuery(authenticationDto); + return orderDetailPageQuery.orderRecordInfoPageQuery(authenticationDto); } else { return Result.error("签名错误"); } @@ -153,7 +153,6 @@ public class OrderDetailController { return Result.Success(SUCCESS, flightOrderDetail); } - @TransitionTo(command = "RefundOrderGenerateCommand", order = 0) public void generateCTripRefund(RefundOrderGenerateCommand command) { orderDetailRepository.findByOrderNo(command.getOrderNo()).ifPresent(orderDetail -> { diff --git a/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripCarRecord.java b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripCarRecord.java new file mode 100644 index 00000000..44c9cc6b --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripCarRecord.java @@ -0,0 +1,17 @@ +package com.chint.domain.aggregates.order.ctrip; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +@Table("c_trip_car_record") +public class CTripCarRecord { + + @Id + private Long id; + @MappedCollection(idColumn = "id") + private CTripCarRecordBase cTripCarRecordBase; + + +} diff --git a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripCarOrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripCarRecordBase.java similarity index 95% rename from src/main/java/com/chint/domain/aggregates/order/ctrip/CtripCarOrderDetail.java rename to src/main/java/com/chint/domain/aggregates/order/ctrip/CTripCarRecordBase.java index b87d93f4..ed4ac023 100644 --- a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripCarOrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripCarRecordBase.java @@ -16,7 +16,7 @@ import java.io.Serializable; **/ @Data @Table("c_trip_order_car_settlement_base_info") -public class CtripCarOrderDetail implements Serializable { +public class CTripCarRecordBase implements Serializable { @Serial private static final long serialVersionUID = 4583214623558870145L; @@ -67,9 +67,9 @@ public class CtripCarOrderDetail implements Serializable { private String payMixFlag; private Double personAmount; - public static CtripCarOrderDetail changeInfo(OrderCarResponse.CarOrderSettlementBaseInfo carOrderSettlementBaseInfo) { + public static CTripCarRecordBase changeInfo(OrderCarResponse.CarOrderSettlementBaseInfo carOrderSettlementBaseInfo) { - CtripCarOrderDetail ctripCarOrderDetail = new CtripCarOrderDetail(); + CTripCarRecordBase ctripCarOrderDetail = new CTripCarRecordBase(); if (carOrderSettlementBaseInfo != null) { diff --git a/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightInfo.java b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightInfo.java new file mode 100644 index 00000000..26d55fe0 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightInfo.java @@ -0,0 +1,64 @@ +package com.chint.domain.aggregates.order.ctrip; + +import cn.hutool.core.bean.BeanUtil; +import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse; +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +@Data +@Table("c_trip_flight_info") +public class CTripFlightInfo { + @Id + private Long id; + private Long cTripFlightRecordId; + private int Sequence; + private String Reason; + private String ReasonDesc; + private String LowFlight; + private String LowClass; + private String LowDTime; + private double LowRate; + private double LowPrice; + private String PreBookReason; + private String PreBookReasonDesc; + private String StraightType; + private String TakeOffTime; + private String ArrivalTime; + private String DCityName; + private String ACityName; + private String DPortName; + private String APortName; + private String Flight; + private String ClassNameNew; + private String ClassName; + private String SubClass; + private String BfReturn; + private String CustomerID; + private double StandardPrice; + private double EClassStandardPrice; + private double PriceRate; + private int FlightTime; + private String ClassReason; + private String ClassReasonDesc; + private String AgreementReason; + private String AgreementReasonDesc; + private String CraftType; + private String DCityCode; + private String ACityCode; + private double AgreementRate; + private String AirLineName; + private int DCityID; + private String DepartureDistrictCode; + private int ACityID; + private String ArrivalDistrictCode; + private String DiscountReasonCode; + private String CustomDiscountReason; + private String DiscountReasonDesc; + private String RoundTripType; + private String TimeReasonDesc; + + public static CTripFlightInfo of(OrderFlightResponse.OrderFlightInfo OrderFlightInfo){ + return BeanUtil.copyProperties(OrderFlightInfo,CTripFlightInfo.class); + } +} diff --git a/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightRecord.java b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightRecord.java new file mode 100644 index 00000000..99aa0238 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightRecord.java @@ -0,0 +1,24 @@ +package com.chint.domain.aggregates.order.ctrip; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; +import org.springframework.data.relational.core.mapping.Table; + +@Data +@Table("c_trip_flight_record") +public class CTripFlightRecord { + @Id + private Long id; + @MappedCollection(idColumn = "c_trip_flight_record_id") + private CTripFlightRecordBase cTripFlightRecordBase; + @MappedCollection(idColumn = "c_trip_flight_record_id") + private CTripFlightInfo cTripFlightInfo; + + public static CTripFlightRecord of(CTripFlightRecordBase cTripFlightRecordBase, CTripFlightInfo cTripFlightInfo) { + CTripFlightRecord cTripFlightRecord = new CTripFlightRecord(); + cTripFlightRecord.setCTripFlightRecordBase(cTripFlightRecordBase); + cTripFlightRecord.setCTripFlightInfo(cTripFlightInfo); + return cTripFlightRecord; + } +} diff --git a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripFlightOrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightRecordBase.java similarity index 95% rename from src/main/java/com/chint/domain/aggregates/order/ctrip/CtripFlightOrderDetail.java rename to src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightRecordBase.java index b26f8078..ab80dba8 100644 --- a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripFlightOrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripFlightRecordBase.java @@ -1,8 +1,5 @@ package com.chint.domain.aggregates.order.ctrip; -import cn.hutool.core.bean.BeanUtil; -import com.chint.domain.aggregates.order.HotelOrderDetail; -import com.chint.domain.aggregates.order.HotelOrderDetailCustomer; import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse; import lombok.Data; import org.springframework.data.annotation.Id; @@ -10,7 +7,6 @@ import org.springframework.data.relational.core.mapping.Table; import java.io.Serial; import java.io.Serializable; -import java.util.ArrayList; /** * @author wanglf3 @@ -19,12 +15,12 @@ import java.util.ArrayList; **/ @Data @Table("c_trip_order_flight_settlement_base_info") -public class CtripFlightOrderDetail implements Serializable { - +public class CTripFlightRecordBase implements Serializable { @Serial private static final long serialVersionUID = -2563945926793686074L; @Id private Long id; + private Long cTripFlightRecordId; private Long recordId; private Long orderId; private Integer sequence; @@ -89,11 +85,9 @@ public class CtripFlightOrderDetail implements Serializable { private Double obFee; - public static CtripFlightOrderDetail changeInfo(OrderFlightResponse.FlightOrderSettlementBaseInfo flightOrderSettlementBaseInfo) { - CtripFlightOrderDetail ctripFlightOrderDetail = new CtripFlightOrderDetail(); - + public static CTripFlightRecordBase changeInfo(OrderFlightResponse.FlightOrderSettlementBaseInfo flightOrderSettlementBaseInfo) { + CTripFlightRecordBase ctripFlightOrderDetail = new CTripFlightRecordBase(); if (flightOrderSettlementBaseInfo != null){ - ctripFlightOrderDetail.setRecordId(flightOrderSettlementBaseInfo.getRecordID()); ctripFlightOrderDetail.setOrderId(flightOrderSettlementBaseInfo.getOrderID()); ctripFlightOrderDetail.setSequence(flightOrderSettlementBaseInfo.getSequence()); diff --git a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripHotelOrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripHotelRecordBase.java similarity index 94% rename from src/main/java/com/chint/domain/aggregates/order/ctrip/CtripHotelOrderDetail.java rename to src/main/java/com/chint/domain/aggregates/order/ctrip/CTripHotelRecordBase.java index fe9879c0..5e61c9b9 100644 --- a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripHotelOrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripHotelRecordBase.java @@ -1,6 +1,5 @@ package com.chint.domain.aggregates.order.ctrip; -import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse; import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse; import lombok.Data; import org.springframework.data.annotation.Id; @@ -9,8 +8,6 @@ import org.springframework.data.relational.core.mapping.Table; import java.io.Serial; import java.io.Serializable; import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Date; /** * @author wanglf3 @@ -19,7 +16,7 @@ import java.util.Date; **/ @Data @Table("c_trip_order_hotel_settlement_base_info") -public class CtripHotelOrderDetail implements Serializable { +public class CTripHotelRecordBase implements Serializable { @Serial private static final long serialVersionUID = 3087333171110684513L; @Id @@ -73,8 +70,8 @@ public class CtripHotelOrderDetail implements Serializable { - public static CtripHotelOrderDetail changeInfo(OrderHotelResponse.SettlementDetail SettlementDetail) { - CtripHotelOrderDetail ctripHotelOrderDetail = new CtripHotelOrderDetail(); + public static CTripHotelRecordBase changeInfo(OrderHotelResponse.SettlementDetail SettlementDetail) { + CTripHotelRecordBase ctripHotelOrderDetail = new CTripHotelRecordBase(); if (SettlementDetail != null){ ctripHotelOrderDetail.setRecordId(SettlementDetail.getRecordId()); ctripHotelOrderDetail.setOrderId(SettlementDetail.getOrderID()); diff --git a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripTrainOrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripTrainRecordBase.java similarity index 95% rename from src/main/java/com/chint/domain/aggregates/order/ctrip/CtripTrainOrderDetail.java rename to src/main/java/com/chint/domain/aggregates/order/ctrip/CTripTrainRecordBase.java index 6ed984c0..2db48874 100644 --- a/src/main/java/com/chint/domain/aggregates/order/ctrip/CtripTrainOrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/ctrip/CTripTrainRecordBase.java @@ -1,6 +1,5 @@ package com.chint.domain.aggregates.order.ctrip; -import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse; import com.chint.interfaces.rest.ctrip.dto.order.OrderTrainResponse; import lombok.Data; import org.springframework.data.annotation.Id; @@ -17,7 +16,7 @@ import java.io.Serializable; **/ @Data @Table("c_trip_order_train_settlement_base_info") -public class CtripTrainOrderDetail implements Serializable { +public class CTripTrainRecordBase implements Serializable { @Serial private static final long serialVersionUID = 1642492804808714974L; @Id @@ -76,9 +75,9 @@ public class CtripTrainOrderDetail implements Serializable { private Double ticketPrice; private Double refundTicketServiceFee; - public static CtripTrainOrderDetail changeInfo(OrderTrainResponse.CorpTrainSettlementDetail trainSettlementDetail) { + public static CTripTrainRecordBase changeInfo(OrderTrainResponse.CorpTrainSettlementDetail trainSettlementDetail) { - CtripTrainOrderDetail ctripTrainOrderDetail = new CtripTrainOrderDetail(); + CTripTrainRecordBase ctripTrainOrderDetail = new CTripTrainRecordBase(); if (trainSettlementDetail != null){ ctripTrainOrderDetail.setRecordId(trainSettlementDetail.getRecordID()); ctripTrainOrderDetail.setOrderId(trainSettlementDetail.getOrderID()); diff --git a/src/main/java/com/chint/domain/factoriy/order/OrderFactory.java b/src/main/java/com/chint/domain/factoriy/order/OrderFactory.java index 45a1c6a6..19f7fb74 100644 --- a/src/main/java/com/chint/domain/factoriy/order/OrderFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order/OrderFactory.java @@ -8,7 +8,6 @@ import com.chint.domain.value_object.OrderSaveData; public interface OrderFactory { RouteOrder createRoute(OrderSaveData orderData); RouteOrder createRoute(OrderCreateCommand command); - ApprovalEvent createApprovalEvent(Integer eventType); } 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 eaf753a7..17b88d17 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 @@ -9,6 +9,7 @@ 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.service.OrderDetailDomainService; +import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -17,6 +18,8 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFa @Autowired private OrderDetailDomainService orderDetailDomainService; + @Autowired + private JdbcCtripHotelOrderDetailRepository jdbcCtripHotelOrderDetailRepository; @Override public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) { @@ -27,16 +30,19 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFa @Override public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData) { + return null; } @Override public OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData) { + return null; } @Override public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData) { + return null; } } diff --git a/src/main/java/com/chint/domain/factoriy/order_record/LyStatementOrder.java b/src/main/java/com/chint/domain/factoriy/order_record/LyStatementOrder.java index 076f9c0e..c446b757 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/LyStatementOrder.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/LyStatementOrder.java @@ -23,6 +23,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.ArrayList; import java.util.List; @@ -45,13 +48,14 @@ public class LyStatementOrder { @Autowired private JdbcLyOrderCarRecord jdbcLyOrderCarRecord; + + /** * 同程账单数据拉取 * * @param beginDate 2024-03-01 00:00:00 * @param endDate 2024-03-26 00:00:00 */ - @Transactional public void statementOrder(String beginDate, String endDate) { StatementPageList param = new StatementPageList(); diff --git a/src/main/java/com/chint/domain/repository/CTripOrderDetailRepository.java b/src/main/java/com/chint/domain/repository/CTripOrderDetailRepository.java index 09d88869..c91d8d60 100644 --- a/src/main/java/com/chint/domain/repository/CTripOrderDetailRepository.java +++ b/src/main/java/com/chint/domain/repository/CTripOrderDetailRepository.java @@ -1,9 +1,6 @@ package com.chint.domain.repository; -import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail; +import com.chint.domain.aggregates.order.ctrip.*; import java.util.List; @@ -14,27 +11,31 @@ import java.util.List; **/ public interface CTripOrderDetailRepository { - CtripFlightOrderDetail save(CtripFlightOrderDetail ctripFlightOrderDetail); + CTripFlightRecordBase save(CTripFlightRecordBase ctripFlightOrderDetail); - void saveAllFlightRecord(List cTripFlightOrderDetailList); + void saveAllFlightRecord(List cTripFlightOrderDetailList); - CtripFlightOrderDetail findFlightByRecordId(Long id); + CTripFlightRecord save(CTripFlightRecord cTripFlightRecord); - CtripHotelOrderDetail save(CtripHotelOrderDetail cTripHotelOrderDetailList); + void saveAll(List cTripFlightRecordList); - void saveAllHotelRecord(List ctripHotelOrderDetailList); + CTripFlightRecordBase findFlightByRecordId(Long id); - CtripHotelOrderDetail findHotelByRecordId(Long id); + CTripHotelRecordBase save(CTripHotelRecordBase cTripHotelOrderDetailList); - CtripTrainOrderDetail save(CtripTrainOrderDetail ctripTrainOrderDetail); + void saveAllHotelRecord(List ctripHotelOrderDetailList); - void saveAllTrainRecord(List ctripTrainOrderDetailList); + CTripHotelRecordBase findHotelByRecordId(Long id); - CtripTrainOrderDetail findTrainByRecordId(Long id); + CTripTrainRecordBase save(CTripTrainRecordBase ctripTrainOrderDetail); - CtripCarOrderDetail save(CtripCarOrderDetail ctripCarOrderDetail); + void saveAllTrainRecord(List ctripTrainOrderDetailList); - void saveAllCarRecord(List ctripCarOrderDetailList); + CTripTrainRecordBase findTrainByRecordId(Long id); - CtripCarOrderDetail findCarByRecordId(Long id); + CTripCarRecordBase save(CTripCarRecordBase ctripCarOrderDetail); + + void saveAllCarRecord(List ctripCarOrderDetailList); + + CTripCarRecordBase findCarByRecordId(Long id); } 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 new file mode 100644 index 00000000..c323e9a4 --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordDomainService.java @@ -0,0 +1,46 @@ +package com.chint.domain.service.order_record; + +import com.chint.application.commands.OrderRecordGenerateCommand; +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.factoriy.order_record.CTripOrderRecordExtensionFactory; +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; + +@Component +public class CTripOrderRecordDomainService implements OrderRecordDomainService{ + + @Autowired + private JdbcCtripHotelOrderDetailRepository jdbcCtripHotelOrderDetailRepository; + @Autowired + private CTripOrderRecordExtensionFactory cTripOrderRecordExtensionFactory; + @Autowired + private OrderDetailDomainService orderDetailDomainService; + + @Override + public List generateHotelRecord(OrderRecordGenerateCommand command) { + return null; + } + + @Override + public List generateTrainRecord(OrderRecordGenerateCommand command) { + return null; + } + + @Override + public List generateFlightRecord(OrderRecordGenerateCommand command) { + return null; + } + + @Override + public List generateCarRecord(OrderRecordGenerateCommand command) { + return null; + } +} 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 new file mode 100644 index 00000000..730ca53f --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_record/LYOrderRecordDomainService.java @@ -0,0 +1,36 @@ +package com.chint.domain.service.order_record; + +import com.chint.application.commands.OrderRecordGenerateCommand; +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 java.time.LocalDateTime; +import java.util.List; + +public class LYOrderRecordDomainService implements OrderRecordDomainService{ + + + @Override + public List generateHotelRecord(OrderRecordGenerateCommand command) { + LocalDateTime startTime = command.getStartTime(); + + return null; + } + + @Override + public List generateTrainRecord(OrderRecordGenerateCommand command) { + return null; + } + + @Override + public List generateFlightRecord(OrderRecordGenerateCommand command) { + return null; + } + + @Override + public List generateCarRecord(OrderRecordGenerateCommand command) { + return null; + } +} diff --git a/src/main/java/com/chint/domain/service/order_record/OrderRecordDomainService.java b/src/main/java/com/chint/domain/service/order_record/OrderRecordDomainService.java new file mode 100644 index 00000000..9901939c --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_record/OrderRecordDomainService.java @@ -0,0 +1,16 @@ +package com.chint.domain.service.order_record; + +import com.chint.application.commands.OrderRecordGenerateCommand; +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 java.util.List; + +public interface OrderRecordDomainService { + List generateHotelRecord(OrderRecordGenerateCommand command); + List generateTrainRecord(OrderRecordGenerateCommand command); + List generateFlightRecord(OrderRecordGenerateCommand command); + List generateCarRecord(OrderRecordGenerateCommand command); +} diff --git a/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java b/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java index 41ca1112..ad5cf044 100644 --- a/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/CTripOrderDetailImpl.java @@ -1,14 +1,8 @@ package com.chint.infrastructure.repository; -import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail; +import com.chint.domain.aggregates.order.ctrip.*; import com.chint.domain.repository.CTripOrderDetailRepository; -import com.chint.infrastructure.repository.jdbc.JdbcCtripCarOrderDetailRepository; -import com.chint.infrastructure.repository.jdbc.JdbcCtripFlightOrderDetailRepository; -import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository; -import com.chint.infrastructure.repository.jdbc.JdbcCtripTrainOrderDetailRepository; +import com.chint.infrastructure.repository.jdbc.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; @@ -38,66 +32,79 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository { @Autowired private JdbcCtripCarOrderDetailRepository jdbcCtripCarOrderDetailRepository; + @Autowired + private JdbcCTripFlightRecordRepository jdbcCTripFlightRecordRepository; + @Override - public CtripFlightOrderDetail save(CtripFlightOrderDetail ctripFlightOrderDetail) { + public CTripFlightRecordBase save(CTripFlightRecordBase ctripFlightOrderDetail) { return jdbcCtripFlightOrderDetailRepository.save(ctripFlightOrderDetail); } @Override - public void saveAllFlightRecord(List cTripFlightOrderDetailList) { + public void saveAllFlightRecord(List cTripFlightOrderDetailList) { jdbcCtripFlightOrderDetailRepository.saveAll(cTripFlightOrderDetailList); } @Override - public CtripFlightOrderDetail findFlightByRecordId(Long recordId) { + public CTripFlightRecord save(CTripFlightRecord cTripFlightRecord) { + return jdbcCTripFlightRecordRepository.save(cTripFlightRecord); + } + + @Override + public void saveAll(List cTripFlightRecordList) { + jdbcCTripFlightRecordRepository.saveAll(cTripFlightRecordList); + } + + @Override + public CTripFlightRecordBase findFlightByRecordId(Long recordId) { return jdbcCtripFlightOrderDetailRepository.findByRecordId(recordId); } @Override - public CtripHotelOrderDetail save(CtripHotelOrderDetail ctripHotelOrderDetail) { + public CTripHotelRecordBase save(CTripHotelRecordBase ctripHotelOrderDetail) { return jdbcCtripHotelOrderDetailRepository.save(ctripHotelOrderDetail); } @Override - public void saveAllHotelRecord(List ctripHotelOrderDetailList) { + public void saveAllHotelRecord(List ctripHotelOrderDetailList) { jdbcCtripHotelOrderDetailRepository.saveAll(ctripHotelOrderDetailList); } @Override - public CtripHotelOrderDetail findHotelByRecordId(Long recordId) { + public CTripHotelRecordBase findHotelByRecordId(Long recordId) { return jdbcCtripHotelOrderDetailRepository.findByRecordId(recordId); } @Override - public CtripTrainOrderDetail save(CtripTrainOrderDetail ctripTrainOrderDetail) { + public CTripTrainRecordBase save(CTripTrainRecordBase ctripTrainOrderDetail) { return jdbcCtripTrainOrderDetailRepository.save(ctripTrainOrderDetail); } @Override - public void saveAllTrainRecord(List ctripTrainOrderDetailList) { + public void saveAllTrainRecord(List ctripTrainOrderDetailList) { jdbcCtripTrainOrderDetailRepository.saveAll(ctripTrainOrderDetailList); } @Override - public CtripTrainOrderDetail findTrainByRecordId(Long recordId) { + public CTripTrainRecordBase findTrainByRecordId(Long recordId) { return jdbcCtripTrainOrderDetailRepository.findByRecordId(recordId); } @Override - public CtripCarOrderDetail save(CtripCarOrderDetail ctripCarOrderDetail) { + public CTripCarRecordBase save(CTripCarRecordBase ctripCarOrderDetail) { return jdbcCtripCarOrderDetailRepository.save(ctripCarOrderDetail); } @Override - public void saveAllCarRecord(List ctripCarOrderDetailList) { + public void saveAllCarRecord(List ctripCarOrderDetailList) { jdbcCtripCarOrderDetailRepository.saveAll(ctripCarOrderDetailList); } @Override - public CtripCarOrderDetail findCarByRecordId(Long recordId) { + public CTripCarRecordBase findCarByRecordId(Long recordId) { return jdbcCtripCarOrderDetailRepository.findByRecordId(recordId); } // diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripFlightRecordRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripFlightRecordRepository.java new file mode 100644 index 00000000..c75b7a7f --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCTripFlightRecordRepository.java @@ -0,0 +1,10 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.order.ctrip.CTripFlightRecord; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface JdbcCTripFlightRecordRepository extends CrudRepository { +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripCarOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripCarOrderDetailRepository.java index 4922fbe9..55741b4e 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripCarOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripCarOrderDetailRepository.java @@ -1,12 +1,12 @@ package com.chint.infrastructure.repository.jdbc; -import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail; +import com.chint.domain.aggregates.order.ctrip.CTripCarRecordBase; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository -public interface JdbcCtripCarOrderDetailRepository extends CrudRepository { +public interface JdbcCtripCarOrderDetailRepository extends CrudRepository { // CityEntity findByCityName(String cityName); - CtripCarOrderDetail findByRecordId(Long recordId); + CTripCarRecordBase findByRecordId(Long recordId); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripFlightOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripFlightOrderDetailRepository.java index 93979d89..e1535530 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripFlightOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripFlightOrderDetailRepository.java @@ -1,13 +1,12 @@ package com.chint.infrastructure.repository.jdbc; -import com.chint.domain.aggregates.location.CityEntity; -import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail; +import com.chint.domain.aggregates.order.ctrip.CTripFlightRecordBase; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository -public interface JdbcCtripFlightOrderDetailRepository extends CrudRepository { +public interface JdbcCtripFlightOrderDetailRepository extends CrudRepository { // CityEntity findByCityName(String cityName); - CtripFlightOrderDetail findByRecordId(Long recordId); + CTripFlightRecordBase findByRecordId(Long recordId); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripHotelOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripHotelOrderDetailRepository.java index d9f3dc57..860eb50d 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripHotelOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripHotelOrderDetailRepository.java @@ -1,14 +1,13 @@ package com.chint.infrastructure.repository.jdbc; -import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail; +import com.chint.domain.aggregates.order.ctrip.CTripHotelRecordBase; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository -public interface JdbcCtripHotelOrderDetailRepository extends CrudRepository { +public interface JdbcCtripHotelOrderDetailRepository extends CrudRepository { // CityEntity findByCityName(String cityName); - CtripHotelOrderDetail findByRecordId(Long recordId); + CTripHotelRecordBase findByRecordId(Long recordId); } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripTrainOrderDetailRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripTrainOrderDetailRepository.java index e19ec269..28c4c74a 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripTrainOrderDetailRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcCtripTrainOrderDetailRepository.java @@ -1,12 +1,12 @@ package com.chint.infrastructure.repository.jdbc; -import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail; +import com.chint.domain.aggregates.order.ctrip.CTripTrainRecordBase; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository -public interface JdbcCtripTrainOrderDetailRepository extends CrudRepository { +public interface JdbcCtripTrainOrderDetailRepository extends CrudRepository { // CityEntity findByCityName(String cityName); - CtripTrainOrderDetail findByRecordId(Long recordId); + CTripTrainRecordBase findByRecordId(Long recordId); } diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java index 85e524b1..57b81fc8 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/order/OrderFlightResponse.java @@ -26,8 +26,6 @@ public class OrderFlightResponse { private FlightOrderPrintDetailInfo OrderPrintDetailInfo; //订单打印单信息 private FlightOrderChangeInfo FlightChangeInfo; //航变信息 private FlightTripRecordInfo FlightTripRecordInfo; //最终航程信息 - - } @Data 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 8a5abe8f..c4fe2568 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 @@ -1,9 +1,6 @@ package com.chint.interfaces.rest.ctrip.order; -import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail; -import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail; +import com.chint.domain.aggregates.order.ctrip.*; import com.chint.domain.repository.CTripOrderDetailRepository; import com.chint.interfaces.rest.ctrip.dto.order.OrderCarResponse; import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse; @@ -38,25 +35,16 @@ public class CTripOrderRecordAutoSave { List flightOrderAccountSettlementList = flightOrder .getFlightOrderAccountSettlementList(); if (flightOrderAccountSettlementList != null && !flightOrderAccountSettlementList.isEmpty()) { - List flightRecords = flightOrderAccountSettlementList + List cTripFlightRecords = flightOrderAccountSettlementList .stream() .flatMap(it -> it.getOrderSettlementList().stream()) - .map(OrderFlightResponse.FlightOrderSettlementInfo::getOrderSettlementBaseInfo) - .map(CtripFlightOrderDetail::changeInfo) + .map(it -> CTripFlightRecord.of( + CTripFlightRecordBase.changeInfo( + it.getOrderSettlementBaseInfo() + ), CTripFlightInfo.of(it.getOrderFlightInfo()) + )) .toList(); - - //业务需求这里加入是否退款判断 - flightRecords.forEach(record -> { - //根据id进行更新 - CtripFlightOrderDetail flightByRecordId = cTripOrderDetailRepository.findFlightByRecordId(record.getRecordId()); - if (flightByRecordId != null) { - record.setId(flightByRecordId.getId()); - } - if (record.getAmount() < 0) { - checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getAmount()), record.getCreateTime()); - } - }); - cTripOrderDetailRepository.saveAllFlightRecord(flightRecords); + cTripOrderDetailRepository.saveAll(cTripFlightRecords); } } @@ -65,23 +53,11 @@ public class CTripOrderRecordAutoSave { OrderHotelResponse hotelOrder = cTripOrderDetailRequest.getHotelOrder(); List lstHtlSettlement = hotelOrder.getLstHtlSettlement(); if (lstHtlSettlement != null && !lstHtlSettlement.isEmpty()) { - List list = lstHtlSettlement.stream() + List list = lstHtlSettlement.stream() .flatMap(it -> it.getLstHotelSettlementDetail().stream()) .map(OrderHotelResponse.LstHotelSettlementDetail::getSettlementDetail) - .map(CtripHotelOrderDetail::changeInfo) + .map(CTripHotelRecordBase::changeInfo) .toList(); - - //业务需求这里加入是否退款判断 - list.forEach(record -> { - CtripHotelOrderDetail hotelByRecordId = cTripOrderDetailRepository.findHotelByRecordId(record.getRecordId()); - if (hotelByRecordId != null) { - record.setId(hotelByRecordId.getId()); - } - - if (record.getAmount() < 0) { - checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getAmount()), record.getCreateTime()); - } - }); cTripOrderDetailRepository.saveAllHotelRecord(list); } } @@ -91,27 +67,11 @@ public class CTripOrderRecordAutoSave { OrderTrainResponse trainOrder = cTripOrderDetailRequest.getTrainOrder(); List lstTrainSettlement = trainOrder.getLstTrainSettlement(); if (lstTrainSettlement != null && !lstTrainSettlement.isEmpty()) { - List list = lstTrainSettlement.stream() + List list = lstTrainSettlement.stream() .flatMap(it -> it.getLstTrainSettlementDetail().stream()) .map(OrderTrainResponse.CorpTrainSettlementInfo::getTrainSettlementDetail) - .map(CtripTrainOrderDetail::changeInfo) + .map(CTripTrainRecordBase::changeInfo) .toList(); - - - //业务需求这里加入是否退款判断 - list.forEach(record -> { - - CtripTrainOrderDetail trainByRecordId = cTripOrderDetailRepository.findTrainByRecordId(record.getRecordId()); - if (trainByRecordId != null) { - record.setRecordId(trainByRecordId.getId()); - } - - if (record.getRealAmount() < 0) { - checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getRealAmount()), record.getCreateTime()); - } - }); - - cTripOrderDetailRepository.saveAllTrainRecord(list); } } @@ -121,30 +81,13 @@ public class CTripOrderRecordAutoSave { OrderCarResponse carOrder = cTripOrderDetailRequest.getCarOrder(); List settlementList = carOrder.getCarOrderAccountSettlementList(); if (settlementList != null && !settlementList.isEmpty()) { - List list = settlementList.stream() + List list = settlementList.stream() .flatMap(it -> it.getCarSettlementDetailList().stream()) .map(OrderCarResponse.CarOrderSettlementDetail::getSettlementBaseInfo) - .map(CtripCarOrderDetail::changeInfo) + .map(CTripCarRecordBase::changeInfo) .toList(); - - //业务需求这里加入是否退款判断 - list.forEach(record -> { - CtripCarOrderDetail carByRecordId = cTripOrderDetailRepository.findCarByRecordId(record.getRecordId()); - if (carByRecordId != null) { - record.setId(carByRecordId.getId()); - } - - if (record.getRealAmount() < 0) { - checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getRealAmount()), record.getCreateTime()); - } - }); - cTripOrderDetailRepository.saveAllCarRecord(list); } } - public void checkIfRefund(String orderNo, String amount, String createTime) { - System.out.println("开始触发创建携程退款订单"); -// Command.of(CTripOrderRefundCommand.class).Info(orderNo, amount, createTime).sendToQueue(); - } }