From bcf8a379052570c1631e6515a00651f879e2a517 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 5 Jun 2024 14:59:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8B=89=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=9A=E7=94=A8=E9=80=82=E9=85=8D=E5=99=A8?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/OrderRecordGenerateCommand.java | 2 + .../application/dtos/RecordMonthSaveDTO.java | 1 + .../dtos/system/SupplierRedirectDTO.java | 5 +- .../application/in/AutoWorkController.java | 40 ++- .../out/OrderDetailController.java | 12 +- .../aggregates/supplier/SupplierProduct.java | 12 + .../supplier/SupplierProductCompany.java | 25 ++ .../supplier/SupplierProductSysCode.java | 25 ++ .../AmapOrderExtensionFactoryImpl.java | 15 +- .../CTripOrderExtensionFactoryImpl.java | 16 +- .../LYOrderExtensionFactoryImpl.java | 19 +- .../order_detail/OrderExtensionFactory.java | 3 +- .../AmapOrderRecordExtensionFactory.java | 5 + .../CTripOrderRecordExtensionFactory.java | 6 + .../LyOrderRecordExtensionFactory.java | 6 + .../order_record/LyStatementOrder.java | 1 - .../OrderRecordExtensionFactory.java | 3 +- .../service/RouteRequestDomainService.java | 13 +- .../AmapOrderRecordDomainService.java | 5 + .../order_record/AmapOrderRecordPuller.java | 56 +++++ .../CTripOrderRecordDomainService.java | 5 + .../order_record/CTripOrderRecordPuller.java | 66 +++++ .../order_record/LYOrderRecordPuller.java | 233 ++++++++++++++++++ .../OrderRecordDomainService.java | 3 +- .../order_record/OrderRecordPuller.java | 16 ++ .../order_search/OrderSearchSelector.java | 3 - .../order_sync/AmapOrderSyncAdapter.java | 20 +- .../order_sync/CTripOrderSyncAdapter.java | 6 + .../order_sync/LYOrderSyncAdapter.java | 6 + .../service/order_sync/SupplierOrderSync.java | 52 +++- .../supplier/AmapOrderDataAdapter.java | 6 + .../supplier/CTripOrderDataAdapter.java | 8 +- .../service/supplier/LYOrderDataAdapter.java | 7 +- .../service/supplier/OrderDataAdapter.java | 3 +- .../service/supplier/SupplierAdapter.java | 5 + .../supplier/SupplierAdapterSelector.java | 49 ++++ .../interfaces/rest/amap/AmapUserRequest.java | 3 +- .../interfaces/rest/base/PostRequest.java | 7 + .../interfaces/rest/bpm/BPMParamFactory.java | 5 +- .../rest/ly/dto/user/EmployeeEntity.java | 1 + .../dto/statementList/ResStatementList.java | 2 - src/main/resources/application-test.yml | 20 +- src/test/java/com/chint/CTripTest.java | 11 +- src/test/java/com/chint/LYTest.java | 2 +- .../java/com/chint/RouteApplicationTests.java | 59 ++++- 45 files changed, 777 insertions(+), 91 deletions(-) create mode 100644 src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java create mode 100644 src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java create mode 100644 src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java create mode 100644 src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java create mode 100644 src/main/java/com/chint/domain/service/order_record/LYOrderRecordPuller.java create mode 100644 src/main/java/com/chint/domain/service/order_record/OrderRecordPuller.java create mode 100644 src/main/java/com/chint/domain/service/supplier/SupplierAdapter.java create mode 100644 src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java diff --git a/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java b/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java index 6ec12dc9..94aa3419 100644 --- a/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java +++ b/src/main/java/com/chint/application/commands/OrderRecordGenerateCommand.java @@ -13,7 +13,9 @@ 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); private String date; + private String oneDate; private String supplierName; + private Integer productType; public OrderRecordGenerateCommand startTime(LocalDateTime startTime) { this.setStartTime(startTime); diff --git a/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java b/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java index b3cfd972..d3c50b0e 100644 --- a/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java +++ b/src/main/java/com/chint/application/dtos/RecordMonthSaveDTO.java @@ -6,4 +6,5 @@ import lombok.Data; public class RecordMonthSaveDTO { private String date; private String supplierName; + private Integer productType; } diff --git a/src/main/java/com/chint/application/dtos/system/SupplierRedirectDTO.java b/src/main/java/com/chint/application/dtos/system/SupplierRedirectDTO.java index c469df87..96960407 100644 --- a/src/main/java/com/chint/application/dtos/system/SupplierRedirectDTO.java +++ b/src/main/java/com/chint/application/dtos/system/SupplierRedirectDTO.java @@ -1,6 +1,9 @@ package com.chint.application.dtos.system; -public class SupplierRedirectDTO { +import lombok.Data; + +@Data +public class SupplierRedirectDTO { private String redirectUrl; public static SupplierRedirectDTO of(String redirectUrl) { diff --git a/src/main/java/com/chint/application/in/AutoWorkController.java b/src/main/java/com/chint/application/in/AutoWorkController.java index 7fb55fec..4c783344 100644 --- a/src/main/java/com/chint/application/in/AutoWorkController.java +++ b/src/main/java/com/chint/application/in/AutoWorkController.java @@ -6,6 +6,8 @@ import com.chint.application.dtos.RecordMonthSaveDTO; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.factoriy.order_record.LyStatementOrder; import com.chint.domain.service.OrderRecordDomainService; +import com.chint.domain.service.order_record.OrderRecordPuller; +import com.chint.domain.service.supplier.SupplierAdapterSelector; import com.chint.infrastructure.echo_framework.command.Command; import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository; import com.chint.infrastructure.util.DateTimeUtil; @@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; +import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; @@ -49,6 +52,9 @@ public class AutoWorkController { @Autowired private OrderRecordDomainService orderRecordDomainService; + @Autowired + private SupplierAdapterSelector supplierAdapterSelector; + @ApiOperation("用户状态检查,离职用户将关闭开卡") @PostMapping("/user/status/check") @@ -76,7 +82,7 @@ public class AutoWorkController { String date = recordMonthSaveDTO.getDate(); if (recordMonthSaveDTO.getSupplierName().equals(SUPPLIER_C_TRIP)) { cTripOrderRecordAutoSave.saveAllByDate(date); - } else if (recordMonthSaveDTO.getSupplierName().equals(SUPPLIER_AMAP)) { + } else if (recordMonthSaveDTO.getSupplierName().equals(SUPPLIER_AMAP)) { orderRecordDomainService.saveAllAmapCarOrderRecord(date); } //将昨天的结算数据生成为财务共享需要的数据 @@ -89,12 +95,42 @@ public class AutoWorkController { return Result.Success(SUCCESS); } + @ApiOperation("拉取按月份的流水") + @PostMapping("/record/pull/month/") + public Result pullDataFromSupplier(@RequestBody RecordMonthSaveDTO param) { + String date = param.getDate(); + OrderRecordPuller orderRecordPuller = supplierAdapterSelector + .of(param.getSupplierName(), OrderRecordPuller.class); + //将昨天的结算数据生成为财务共享需要的数据 + OrderRecordGenerateCommand command = Command.of(OrderRecordGenerateCommand.class) + .startTime(DateTimeUtil.firstDayOfMonth(date)) + .endTime(DateTimeUtil.endDayOfMonth(date)) + .date(date) + .supplierName(param.getSupplierName()); + if (param.getProductType().equals(LEG_TYPE_TRAIN)) { + orderRecordPuller.pullTrainOrderRecord(command); + } + if (param.getProductType().equals(LEG_TYPE_AIRPLANE)) { + orderRecordPuller.pullFlightOrderRecord(command); + } + if (param.getProductType().equals(LEG_TYPE_HOTEL)) { + orderRecordPuller.pullHotelOrderRecord(command); + } + if (param.getProductType().equals(LEG_TYPE_TAXI)) { + orderRecordPuller.pullCarOrderRecord(command); + } + return Result.Success(SUCCESS); + } + @Transactional @ApiOperation("根据月份生成结算记录") @PostMapping("/record/save/month") public Result autoSaveRecordByMonth(@RequestBody RecordMonthSaveDTO recordMonthSaveDTO) { String date = recordMonthSaveDTO.getDate(); + if (date == null) { + date = DateTimeUtil.lastMonthStr(); + } //将昨天的结算数据生成为财务共享需要的数据 Command.of(OrderRecordGenerateCommand.class) .startTime(DateTimeUtil.firstDayOfMonth(date)) @@ -106,11 +142,11 @@ public class AutoWorkController { } - @ApiOperation("自动拉取同程上个月的流水号") @PostMapping("/ly/record/save") public Result autoSaveLYRecord() { //同步拉取上月数据 + lyStatementOrder.saveAll(); //将未转换的结算数据生成为财务共享需要的数据 try { Command.of(LYOrderRecordGenerateCommand.class).sendToQueue(); diff --git a/src/main/java/com/chint/application/out/OrderDetailController.java b/src/main/java/com/chint/application/out/OrderDetailController.java index 31ee1505..01930e59 100644 --- a/src/main/java/com/chint/application/out/OrderDetailController.java +++ b/src/main/java/com/chint/application/out/OrderDetailController.java @@ -1,11 +1,10 @@ package com.chint.application.out; -import com.chint.application.commands.RefundOrderGenerateCommand; import com.chint.application.dtos.*; import com.chint.application.dtos.mapper.RouteOrderMapper; import com.chint.application.dtos.response.OrderDetailRes; import com.chint.application.queryies.OrderDetailQuery; -import com.chint.domain.aggregates.order.*; +import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.user.User; import com.chint.domain.factoriy.order_detail.OrderExtensionCreator; import com.chint.domain.repository.ClientRepository; @@ -14,7 +13,6 @@ import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.UserRepository; import com.chint.domain.service.auth.AuthenticateService; import com.chint.domain.value_object.RouteOrderDetail; -import com.chint.infrastructure.echo_framework.annotation.TransitionTo; import com.chint.infrastructure.export.OrderDetailExportFactory; import com.chint.infrastructure.util.Digest; import com.chint.infrastructure.util.PageResult; @@ -41,15 +39,10 @@ import org.springframework.web.bind.annotation.RestController; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; import java.util.Optional; import static com.chint.infrastructure.constant.BPMConstant.H3_BPM; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; -import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; -import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y; @RestController @RequestMapping("/OrderDetail") @@ -172,7 +165,7 @@ public class OrderDetailController { Integer pageNum = authenticationDto.getPageNum(); String orgsign = authenticationDto.getSign(); String input; - if (systemType.equals("AN_FK") || systemType.equals("XN_FK")) { + if (systemType.equals("AN_FK")) { input = productType + systemType + startTime + endTime + pageSize + pageNum; } else { input = orderNo + productType + systemType + startTime + endTime + pageSize + pageNum; @@ -245,5 +238,4 @@ public class OrderDetailController { } - } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java index 0babe7ad..8db59f6a 100644 --- a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java @@ -24,8 +24,20 @@ public class SupplierProduct implements Serializable { private String ifCanCancelRule; @MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key") private List supplierProductStandardLevelList; + @MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key") + private List supplierProductSysCodeList; + @MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key") + private List supplierProductCompanyList; public boolean ifCanOrder() { return ifCanOrder == 1; } + + public boolean checkStandardLevelIfInUse(String standardLevel) { + return this.getSupplierProductStandardLevelList() + .stream() + .filter(SupplierProductStandardLevel::inUse) + .map(SupplierProductStandardLevel::getStandardLevelName) + .anyMatch(it -> it.equals(standardLevel)); + } } diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java new file mode 100644 index 00000000..6bc4123a --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductCompany.java @@ -0,0 +1,25 @@ +package com.chint.domain.aggregates.supplier; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +@Data +@Table("supplier_product_company") +public class SupplierProductCompany implements Serializable { + @Serial + private static final long serialVersionUID = 7176388412356123574L; + @Id + private Long id; + private Long supplierProductId; + private String companyCode; + private String companyName; + private Integer status; + private String extension; + public boolean inUse() { + return status == 1; + } +} diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java new file mode 100644 index 00000000..78e1a687 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProductSysCode.java @@ -0,0 +1,25 @@ +package com.chint.domain.aggregates.supplier; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +import java.io.Serial; +import java.io.Serializable; + +@Data +@Table("supplier_product_sys_code") +public class SupplierProductSysCode implements Serializable { + @Serial + private static final long serialVersionUID = 1987625985511322474L; + @Id + private Long id; + private Long supplierProductId; + private Long SystemCodeId; + private String systemCode; + private Integer status; + private String extension; + public boolean inUse() { + return status == 1; + } +} diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java index 4b93bce0..6bd0dba5 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java @@ -22,6 +22,7 @@ import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_ import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_REFUND; import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_SUCCESS; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP_CN_NAME; import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.mapFSSCOrderStatus; @@ -29,18 +30,9 @@ import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.mapFSSCOrderSta @Component public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory { - @Autowired - private AmapOrderDetailRequest orderDetailRequest; - @Autowired private RouteRequestDomainService routeRequestDomainService; - @Autowired - private OrderDetailRepository orderDetailRepository; - - @Autowired - private RouteRepository routeRepository; - @Autowired private UserRepository userRepository; @@ -246,4 +238,9 @@ public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory { public OtherOrderDetail createOtherOrderDetail(Object otherOrderDetailData) { return null; } + + @Override + public String getSupplierName() { + return SUPPLIER_AMAP; + } } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java index 1c629ac2..8d2e4641 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java @@ -25,29 +25,20 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.FSSCConstant.*; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; @Component public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { - @Autowired - private OrderDetailRepository orderDetailRepository; - - @Autowired - private RouteRepository routeRepository; - @Autowired private UserRepository userRepository; - @Autowired - private LocationRepository locationRepository; @Autowired private OrderDetailFactory orderDetailFactory; - @Autowired - private RouteRequestRepository routeRequestRepository; @Autowired private RouteRequestDomainService routeRequestDomainService; @@ -581,4 +572,9 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { public OtherOrderDetail createOtherOrderDetail(Object otherOrderDetailData) { return null; } + + @Override + public String getSupplierName() { + return SUPPLIER_C_TRIP; + } } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java index dfb14229..44ced9db 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java @@ -28,23 +28,13 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.FSSCConstant.*; import static com.chint.infrastructure.constant.LYConstant.L_Y_CAR_FEE_TYPE_CANCEL; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL; -import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y_CN_NAME; -import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y_EXTENSION_NAME; +import static com.chint.infrastructure.constant.SupplierNameConstant.*; import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; import static com.chint.infrastructure.util.DateTimeUtil.formatter; @Component public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { - - @Autowired - private UserRepository userRepository; - @Autowired - private EstimatePrice estimatePrice; - - @Autowired - private UserHttpRequest userHttpRequest; - @Autowired private RouteRepository routeRepository; @@ -54,9 +44,6 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { @Autowired private OrderDetailFactory orderDetailFactory; - @Autowired - private RouteRequestRepository routeRequestRepository; - //用车消费明细 @Override @@ -575,4 +562,8 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { } + @Override + public String getSupplierName() { + return SUPPLIER_L_Y; + } } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java index ba88d700..ba07bd27 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderExtensionFactory.java @@ -1,8 +1,9 @@ package com.chint.domain.factoriy.order_detail; import com.chint.domain.aggregates.order.*; +import com.chint.domain.service.supplier.SupplierAdapter; -public interface OrderExtensionFactory { +public interface OrderExtensionFactory extends SupplierAdapter { CarOrderDetail createCarOrderDetail(Object carOrderDetailData); diff --git a/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java index 87b2a1e9..6c6b4769 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java @@ -13,6 +13,7 @@ import org.springframework.stereotype.Component; import java.util.Optional; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; @@ -168,4 +169,8 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact return null; } + @Override + public String getSupplierName() { + return SUPPLIER_AMAP; + } } 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 e4871581..5ecb4869 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 @@ -26,6 +26,7 @@ import java.util.Objects; import java.util.Optional; import static com.chint.infrastructure.constant.BelongSystemConstant.*; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; @Component @@ -1342,4 +1343,9 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac userName, userCode); } + + @Override + public String getSupplierName() { + return SUPPLIER_C_TRIP; + } } 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 00467d6a..89da9745 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 @@ -32,6 +32,7 @@ import java.util.function.Consumer; import static com.chint.infrastructure.constant.BelongSystemConstant.*; import static com.chint.infrastructure.constant.OrderRecordConstant.*; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y; /** * 同程数据转换 @@ -870,4 +871,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor default -> "1"; }; } + + @Override + public String getSupplierName() { + return SUPPLIER_L_Y; + } } 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 accda221..bbd352da 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 @@ -266,6 +266,5 @@ public class LyStatementOrder { lyOrderCarRecords.forEach(lyOrderCarRecord -> { lySearchRequest.getCarDetailResponse(lyOrderCarRecord.getOrderSerialNo()); }); - } } diff --git a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java index cb04a94f..36f16036 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/OrderRecordExtensionFactory.java @@ -5,10 +5,11 @@ 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.service.supplier.SupplierAdapter; import java.util.Optional; -public interface OrderRecordExtensionFactory { +public interface OrderRecordExtensionFactory extends SupplierAdapter { OrderCarRecord createCarOrderRecord(Object orderCarRecordData); diff --git a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java index 7a83c8fb..5f1e88fd 100644 --- a/src/main/java/com/chint/domain/service/RouteRequestDomainService.java +++ b/src/main/java/com/chint/domain/service/RouteRequestDomainService.java @@ -9,7 +9,9 @@ import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.RouteRequestRepository; import com.chint.domain.repository.SupplierRepository; +import com.chint.domain.service.order_sync.SupplierOrderSync; import com.chint.domain.service.order_sync.SyncAdapter; +import com.chint.domain.service.supplier.SupplierAdapterSelector; import com.chint.domain.value_object.SyncLegData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -52,6 +54,9 @@ public class RouteRequestDomainService { @Autowired private SupplierDomainService supplierDomainService; + @Autowired + private SupplierAdapterSelector supplierAdapterSelector; + // //这里增加一个判断 ,如果这个订单的行程为空,那么就返回给用户提示 // if (legItems == null || legItems.isEmpty()) { @@ -98,7 +103,7 @@ public class RouteRequestDomainService { legs.forEach(it -> it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_NOT_ORDERED))); //这里执行同步 - if (syncAdapter.of(syncLegData.getSupplierName()).syncRouteRequest(routeRequest)) { + if (supplierAdapterSelector.of(syncLegData.getSupplierName(), SupplierOrderSync.class).syncRouteRequest(routeRequest)) { routeRequest.addEvent(RouteRequestEvent.sync(syncLegData.getSupplierName())); //通过保存聚合根来保存差旅申请单 routeRepository.save(routeOrder); @@ -144,21 +149,21 @@ public class RouteRequestDomainService { List orderedLegs = collect.get(false); if (!orderedLegs.isEmpty()) { it.reloadGenerateRequestLegs(orderedLegs); - syncAdapter.of(it.getSupplier()).syncRouteRequest(it); + supplierAdapterSelector.of(it.getSupplier(), SupplierOrderSync.class).syncRouteRequest(it); it.addEvent(RouteRequestEvent.sync(it.getSupplier())); List notOrderLegs = collect.get(true); notOrderLegs.forEach(leg -> leg.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); } else { it.addEvent(RouteRequestEvent.cancel(it.getSupplier())); getLegInfoFromRouteOrder(it, routeOrder); - syncAdapter.of(it.getSupplier()).cancelRouteRequest(it); + supplierAdapterSelector.of(it.getSupplier(), SupplierOrderSync.class).syncRouteRequest(it); it.getRouteRequestLegList() .forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); } } else { it.addEvent(RouteRequestEvent.cancel(it.getSupplier())); getLegInfoFromRouteOrder(it, routeOrder); - syncAdapter.of(it.getSupplier()).cancelRouteRequest(it); + supplierAdapterSelector.of(it.getSupplier(), SupplierOrderSync.class).syncRouteRequest(it); it.getRouteRequestLegList() .forEach(requestLeg -> requestLeg.getLeg().addEvent(legEventFactory.creatLegEvent(LEG_EVENT_APPROVAL))); } diff --git a/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordDomainService.java b/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordDomainService.java index 9efc7ac8..a451982f 100644 --- a/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordDomainService.java +++ b/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordDomainService.java @@ -75,4 +75,9 @@ public class AmapOrderRecordDomainService implements OrderRecordDomainService{ .toList(); return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList); } + + @Override + public String getSupplierName() { + return SUPPLIER_AMAP; + } } diff --git a/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java b/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java new file mode 100644 index 00000000..54d15a98 --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_record/AmapOrderRecordPuller.java @@ -0,0 +1,56 @@ +package com.chint.domain.service.order_record; + +import com.chint.application.commands.OrderRecordGenerateCommand; +import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord; +import com.chint.domain.repository.AmapCarOrderRecordRepository; +import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse; +import com.chint.interfaces.rest.amap.request.AmapSettleBillRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; + +@Component +public class AmapOrderRecordPuller implements OrderRecordPuller{ + + @Autowired + private AmapSettleBillRequest amapSettleBillRequest; + + @Autowired + private AmapCarOrderRecordRepository amapCarOrderRecordRepository; + + @Override + public boolean pullTrainOrderRecord(OrderRecordGenerateCommand command) { + return false; + } + + @Override + public boolean pullFlightOrderRecord(OrderRecordGenerateCommand command) { + return false; + } + + @Override + public boolean pullHotelOrderRecord(OrderRecordGenerateCommand command) { + return false; + } + + @Override + public boolean pullCarOrderRecord(OrderRecordGenerateCommand command) { + try { + List listElements = amapSettleBillRequest.amapRecordByMonth(command.getDate()); + List list = listElements.stream().map(AmapCarOrderRecord::of).toList(); + amapCarOrderRecordRepository.saveAll(list); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + @Override + public String getSupplierName() { + return SUPPLIER_AMAP; + } +} 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 9d0b1780..76261150 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 @@ -111,4 +111,9 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService { .toList(); return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList); } + + @Override + public String getSupplierName() { + return SUPPLIER_C_TRIP; + } } diff --git a/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java b/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java new file mode 100644 index 00000000..910e27f9 --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_record/CTripOrderRecordPuller.java @@ -0,0 +1,66 @@ +package com.chint.domain.service.order_record; + +import com.chint.application.commands.OrderRecordGenerateCommand; +import com.chint.interfaces.rest.ctrip.order.CTripOrderRecordAutoSave; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Optional; + +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; + +@Component +public class CTripOrderRecordPuller implements OrderRecordPuller { + + @Autowired + private CTripOrderRecordAutoSave cTripOrderRecordAutoSave; + + @Override + public boolean pullTrainOrderRecord(OrderRecordGenerateCommand command) { + try { + cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable(command.getDate())); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + @Override + public boolean pullFlightOrderRecord(OrderRecordGenerateCommand command) { + try { + cTripOrderRecordAutoSave.cTripFlightRecordAutoSave(Optional.ofNullable(command.getDate())); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + @Override + public boolean pullHotelOrderRecord(OrderRecordGenerateCommand command) { + try { + cTripOrderRecordAutoSave.cTripHotelRecordAutoSave(Optional.ofNullable(command.getDate())); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + @Override + public boolean pullCarOrderRecord(OrderRecordGenerateCommand command) { + try { + cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable(command.getDate())); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + @Override + public String getSupplierName() { + return SUPPLIER_C_TRIP; + } +} diff --git a/src/main/java/com/chint/domain/service/order_record/LYOrderRecordPuller.java b/src/main/java/com/chint/domain/service/order_record/LYOrderRecordPuller.java new file mode 100644 index 00000000..818b5e24 --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_record/LYOrderRecordPuller.java @@ -0,0 +1,233 @@ +package com.chint.domain.service.order_record; + +import com.chint.application.commands.OrderRecordGenerateCommand; +import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderCarRecord; +import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderFlightRecord; +import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderHotelRecord; +import com.chint.domain.aggregates.order.order_record.ly_order_record.LyOrderTrainRecord; +import com.chint.infrastructure.repository.jdbc.JdbcLyOrderCarRecord; +import com.chint.infrastructure.repository.jdbc.JdbcLyOrderFlightRecord; +import com.chint.infrastructure.repository.jdbc.JdbcLyOrderHotelRecord; +import com.chint.infrastructure.repository.jdbc.JdbcLyOrderTrainRecord; +import com.chint.infrastructure.util.BeanCopyUtils; +import com.chint.infrastructure.util.DateTimeUtil; +import com.chint.interfaces.rest.ly.LYSearchRequest; +import com.chint.interfaces.rest.ly.reconciliation.dto.BaseDetailParam; +import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.CarStatement; +import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.FlightStatement; +import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.HotelStatement; +import com.chint.interfaces.rest.ly.reconciliation.dto.DetailResponse.TrainStatement; +import com.chint.interfaces.rest.ly.reconciliation.dto.statementList.ResStatementList; +import com.chint.interfaces.rest.ly.reconciliation.dto.statementList.StatementList; +import com.chint.interfaces.rest.ly.reconciliation.dto.statementList.StatementPageList; +import com.chint.interfaces.rest.ly.reconciliation.request.ReqStatement; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; + +import static com.chint.application.services.login.LoginStrategy.log; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y; + +@Component +public class LYOrderRecordPuller implements OrderRecordPuller { + + + @Autowired + private ReqStatement reqStatement; + + @Autowired + private JdbcLyOrderFlightRecord jdbcLyOrderFlightRecord; + + @Autowired + private JdbcLyOrderHotelRecord jdbcLyOrderHotelRecord; + + @Autowired + private JdbcLyOrderTrainRecord jdbcLyOrderTrainRecord; + + @Autowired + private JdbcLyOrderCarRecord jdbcLyOrderCarRecord; + + @Autowired + private LYSearchRequest lySearchRequest; + + + @Override + public boolean pullTrainOrderRecord(OrderRecordGenerateCommand command) { + String date = command.getDate(); + String startOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.startOfDay(date)); + String endOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.endOfDay(date)); + List onlineStatementLists = statementOrder(startOfDay, endOfDay); + List res = new ArrayList<>(); + List orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo(startOfDay, endOfDay); + for (ResStatementList.OnlineStatementList onlineStatementList : onlineStatementLists) { + String statementCode = onlineStatementList.getStatementCode(); + res.addAll(trainStatement(statementCode, orderSerialNoList)); + } + jdbcLyOrderTrainRecord.saveAll(res); + return true; + } + + @Override + public boolean pullFlightOrderRecord(OrderRecordGenerateCommand command) { + String date = command.getDate(); + String startOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.startOfDay(date)); + String endOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.endOfDay(date)); + List onlineStatementLists = statementOrder(startOfDay, endOfDay); + List orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo(startOfDay, endOfDay); + List res = new ArrayList<>(); + for (ResStatementList.OnlineStatementList onlineStatementList : onlineStatementLists) { + String statementCode = onlineStatementList.getStatementCode(); + res.addAll(flightStatement(statementCode, orderSerialNoList)); + } + jdbcLyOrderFlightRecord.saveAll(res); + return true; + } + + @Override + public boolean pullHotelOrderRecord(OrderRecordGenerateCommand command) { + String date = command.getDate(); + String startOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.startOfDay(date)); + String endOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.endOfDay(date)); + List onlineStatementLists = statementOrder(startOfDay, endOfDay); + List orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo(startOfDay, endOfDay); + List res = new ArrayList<>(); + for (ResStatementList.OnlineStatementList onlineStatementList : onlineStatementLists) { + String statementCode = onlineStatementList.getStatementCode(); + res.addAll(hotelStatement(statementCode, orderSerialNoList)); + } + jdbcLyOrderHotelRecord.saveAll(res); + return true; + } + + @Override + public boolean pullCarOrderRecord(OrderRecordGenerateCommand command) { + String date = command.getDate(); + String startOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.startOfDay(date)); + String endOfDay = DateTimeUtil.timeToStrCommon(DateTimeUtil.endOfDay(date)); + List onlineStatementLists = statementOrder(startOfDay, endOfDay); + List orderSerialNoList = jdbcLyOrderCarRecord.queryBillOrderNo(startOfDay, endOfDay); + List res = new ArrayList<>(); + for (ResStatementList.OnlineStatementList onlineStatementList : onlineStatementLists) { + String statementCode = onlineStatementList.getStatementCode(); + res.addAll(carStatement(statementCode, orderSerialNoList)); + } + jdbcLyOrderCarRecord.saveAll(res); + return true; + } + + + public List statementOrder(String beginDate, String endDate) { + StatementPageList param = new StatementPageList(); + param.setPageIndex(1) + .setPageSize(10) + .setBeginDate(beginDate)//2024-03-01 00:00:00 + .setEndDate(endDate); + StatementList statementList = new StatementList(param); + ResStatementList resStatementList = reqStatement.queryStatementList(statementList); + log.info("resStatementList: {}", resStatementList); + return resStatementList.getData().getOnlineStatementList(); + } + + /** + * 飞机账单同步 + */ + public List flightStatement(String statementCode, List orderSerialNoList) { + List res = new ArrayList<>(); + int flightCount = 0;//初始化变量 + int flightPageCount;//飞机总分页数 + do { + //至少查询一次 + BaseDetailParam baseDetailParam = BaseDetailParam.of(1 + flightCount, 100, statementCode); + FlightStatement flightStatement = reqStatement.queryFlightStatement(baseDetailParam); + flightPageCount = flightStatement.getData().getPageInfo().getPageCount();//总页数 + //保存数据 + List statementOrderList = flightStatement.getData().getStatementOrderList(); + //过滤出已经保存的数据 + List statementOrderListNew = statementOrderList.stream().filter(o -> + !orderSerialNoList.contains(o.getBillOrderNo()) + ).toList(); + res.addAll(BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderFlightRecord.class)); + flightCount++; + } while (flightCount < flightPageCount); + return res; + } + + /** + * 酒店账单同步 + */ + public List hotelStatement(String statementCode, List orderSerialNoList) { + List res = new ArrayList<>(); + int hotelCount = 0;//初始化变量 + int hotelPageCount;//酒店总分页数 + do { + BaseDetailParam baseDetailParam = BaseDetailParam.of(1 + hotelCount, 100, statementCode); + HotelStatement hotelStatement = reqStatement.queryHotelStatement(baseDetailParam); + hotelPageCount = hotelStatement.getData().getPageInfo().getPageCount();//总页数 + //保存数据 + List statementOrderList = hotelStatement.getData().getStatementOrderList(); + //过滤出已经保存的数据 + List statementOrderListNew = statementOrderList.stream().filter(o -> + !orderSerialNoList.contains(o.getBillOrderNo()) + ).toList(); + res.addAll(BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderHotelRecord.class)); + hotelCount++; + } while (hotelCount < hotelPageCount); + return res; + } + + + /** + * 火车账单同步 + */ + public List trainStatement(String statementCode, List orderSerialNoList) { + List res = new ArrayList<>(); + int trainCount = 0;//初始化变量 + int trainPageCount;//酒店总分页数 + do { + BaseDetailParam baseDetailParam = BaseDetailParam.of(1 + trainCount, 100, statementCode); + TrainStatement trainStatement = reqStatement.queryTrainStatement(baseDetailParam); + trainPageCount = trainStatement.getData().getPageInfo().getPageCount();//总页数 + //保存数据 + List statementOrderList = trainStatement.getData().getStatementOrderList(); + //过滤出已经保存的数据 + List statementOrderListNew = statementOrderList.stream().filter(o -> + !orderSerialNoList.contains(o.getBillOrderNo()) + ).toList(); + res.addAll(BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderTrainRecord.class)); + //保存结算明细数据 + trainCount++; + } while (trainCount < trainPageCount); + return res; + } + + + /** + * 用车账单同步 + */ + public List carStatement(String statementCode, List orderSerialNoList) { + List res = new ArrayList<>(); + int carCount = 0;//初始化变量 + int carPageCount;//酒店总分页数 + do { + BaseDetailParam baseDetailParam = BaseDetailParam.of(1 + carCount, 100, statementCode); + CarStatement carStatement = reqStatement.queryCarStatement(baseDetailParam); + carPageCount = carStatement.getData().getPageInfo().getPageCount();//总页数 + //保存数据 + List statementOrderList = carStatement.getData().getStatementOrderList(); + //过滤出已经保存的数据 + List statementOrderListNew = statementOrderList.stream().filter(o -> + !orderSerialNoList.contains(o.getBillOrderNo()) + ).toList(); + res.addAll(BeanCopyUtils.copyBeanList(statementOrderListNew, LyOrderCarRecord.class)); + carCount++; + } while (carCount < carPageCount); + return res; + } + + @Override + public String getSupplierName() { + return SUPPLIER_L_Y; + } +} 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 index 9901939c..e7f1dbaa 100644 --- a/src/main/java/com/chint/domain/service/order_record/OrderRecordDomainService.java +++ b/src/main/java/com/chint/domain/service/order_record/OrderRecordDomainService.java @@ -5,10 +5,11 @@ 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.service.supplier.SupplierAdapter; import java.util.List; -public interface OrderRecordDomainService { +public interface OrderRecordDomainService extends SupplierAdapter { List generateHotelRecord(OrderRecordGenerateCommand command); List generateTrainRecord(OrderRecordGenerateCommand command); List generateFlightRecord(OrderRecordGenerateCommand command); diff --git a/src/main/java/com/chint/domain/service/order_record/OrderRecordPuller.java b/src/main/java/com/chint/domain/service/order_record/OrderRecordPuller.java new file mode 100644 index 00000000..b26deb1b --- /dev/null +++ b/src/main/java/com/chint/domain/service/order_record/OrderRecordPuller.java @@ -0,0 +1,16 @@ +package com.chint.domain.service.order_record; + +import com.chint.application.commands.OrderRecordGenerateCommand; +import com.chint.domain.service.supplier.SupplierAdapter; + +public interface OrderRecordPuller extends SupplierAdapter { + + boolean pullTrainOrderRecord(OrderRecordGenerateCommand command); + + boolean pullFlightOrderRecord(OrderRecordGenerateCommand command); + + boolean pullHotelOrderRecord(OrderRecordGenerateCommand command); + + boolean pullCarOrderRecord(OrderRecordGenerateCommand command); + +} diff --git a/src/main/java/com/chint/domain/service/order_search/OrderSearchSelector.java b/src/main/java/com/chint/domain/service/order_search/OrderSearchSelector.java index 63529dc3..d7ffc9d4 100644 --- a/src/main/java/com/chint/domain/service/order_search/OrderSearchSelector.java +++ b/src/main/java/com/chint/domain/service/order_search/OrderSearchSelector.java @@ -1,9 +1,6 @@ package com.chint.domain.service.order_search; import com.chint.domain.exceptions.NotFoundException; -import com.chint.domain.service.supplier.CTripOrderDataAdapter; -import com.chint.domain.service.supplier.LYOrderDataAdapter; -import com.chint.domain.service.supplier.OrderDataAdapter; import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.constant.SupplierNameConstant; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java index 7604363d..4c59ca97 100644 --- a/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/AmapOrderSyncAdapter.java @@ -7,7 +7,10 @@ import com.chint.domain.aggregates.supplier.SupplierProductStandardLevel; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.AuthException; import com.chint.domain.exceptions.CommandException; -import com.chint.domain.repository.*; +import com.chint.domain.repository.AmapPolicyRepository; +import com.chint.domain.repository.AmapRouteRelationshipRepository; +import com.chint.domain.repository.SupplierRepository; +import com.chint.domain.repository.UserRepository; import com.chint.domain.service.LegDomainService; import com.chint.infrastructure.util.DateTimeUtil; import com.chint.interfaces.rest.amap.AmapLocationRequest; @@ -141,7 +144,7 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { } List areaCodes = new ArrayList<>(); for (Location location : locationList) { - if(location.getLocationType() != LOCATION_TYPE_CITY){ + if (location.getLocationType() != LOCATION_TYPE_CITY) { //如果类型不是地级市,那么就从地区路径获取地级市信息 String[] split = location.getLocationPathName().split("_"); areaCodes.add(amapLocationRequest.getACodeByLocationName(split[3])); @@ -155,7 +158,6 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { dto.setStatus("1"); - Optional supplier = supplierRepository.findBySupplierName(SUPPLIER_AMAP); supplier.flatMap(Supplier::carSupplierProduct).ifPresent(carSupplierProduct -> { if (carSupplierProduct.getSupplierProductStandardLevelList() @@ -166,9 +168,14 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { amapPolicyRepository.findByStandardLevel(routeRequestFields.getStandardLevel()) .ifPresent(policy -> dto.setRegulationId(policy.getAmapPolicyCode())); } else { - throw new AuthException("你目前的差标不支持使用高德打车"); + throw new AuthException("你目前的公司暂不支持使用高德打车"); } }); + + if (routeRequestFields.getAccountCompanyName().equals("浙江正泰物联技术有限公司") || + routeRequestFields.getAccountCompanyName().equals("浙江正泰仪器仪表有限责任公司")) { + throw new AuthException("你目前的公司暂不支持使用高德打车"); + } return dto; } @@ -195,4 +202,9 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync { } return code.equals(1); } + + @Override + public String getSupplierName() { + return SUPPLIER_AMAP; + } } diff --git a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java index 05f8df3e..631baadc 100644 --- a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java @@ -30,6 +30,7 @@ import java.util.stream.Collectors; import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_DISTRICT; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; @Slf4j @Component @@ -250,4 +251,9 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync { } return location; } + + @Override + public String getSupplierName() { + return SUPPLIER_C_TRIP; + } } diff --git a/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java index 39d6daf0..a5cb1d86 100644 --- a/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/LYOrderSyncAdapter.java @@ -24,6 +24,7 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.LYConstant.L_Y_ORDER_PATH; import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LocationConstant.*; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y; @Slf4j @Component @@ -373,4 +374,9 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { Set set = new LinkedHashSet<>(Arrays.asList(array)); return String.join(",", set); } + + @Override + public String getSupplierName() { + return SUPPLIER_L_Y; + } } diff --git a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java index 815f989d..8449fc15 100644 --- a/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java +++ b/src/main/java/com/chint/domain/service/order_sync/SupplierOrderSync.java @@ -1,10 +1,15 @@ package com.chint.domain.service.order_sync; -import com.chint.domain.aggregates.order.RouteOrder; -import com.chint.domain.aggregates.order.RouteRequest; +import com.chint.domain.aggregates.order.*; +import com.chint.domain.aggregates.supplier.Supplier; +import com.chint.domain.aggregates.supplier.SupplierProductStandardLevel; +import com.chint.domain.exceptions.AuthException; +import com.chint.domain.service.supplier.SupplierAdapter; -public interface SupplierOrderSync { +import java.util.List; + +public interface SupplierOrderSync extends SupplierAdapter { boolean syncSupplierOrder(RouteOrder order); boolean syncRouteRequest(RouteRequest routeRequest); @@ -12,4 +17,45 @@ public interface SupplierOrderSync { boolean cancelSyncSupplierOrder(RouteOrder order); boolean cancelRouteRequest(RouteRequest routeRequest); + + default boolean syncRouteRequest(RouteRequest routeRequest, Supplier supplier) { + RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields(); + + List legType = routeRequest.getRouteRequestLegList() + .stream() + .map(RouteRequestLeg::getLeg) + .map(Leg::getLegType) + .toList(); + + supplier.carSupplierProduct() + .ifPresent(carSupplierProduct -> { + if (!carSupplierProduct.checkStandardLevelIfInUse(routeRequestFields.getStandardLevel())) { + throw new AuthException("你目前的公司暂不支持使用高德打车"); + } + }); + + + supplier.flightSupplierProduct().ifPresent(flightSupplierProduct -> { + if (flightSupplierProduct.getSupplierProductStandardLevelList() + .stream() + .filter(SupplierProductStandardLevel::inUse) + .map(SupplierProductStandardLevel::getStandardLevelName) + .noneMatch(standardLevel -> standardLevel.equals(routeRequestFields.getStandardLevel()))) { + throw new AuthException("你目前的公司暂不支持使用高德打车"); + } + }); + + supplier.flightSupplierProduct().ifPresent(flightSupplierProduct -> { + if (flightSupplierProduct.getSupplierProductStandardLevelList() + .stream() + .filter(SupplierProductStandardLevel::inUse) + .map(SupplierProductStandardLevel::getStandardLevelName) + .noneMatch(standardLevel -> standardLevel.equals(routeRequestFields.getStandardLevel()))) { + throw new AuthException("你目前的公司暂不支持使用高德打车"); + } + }); + + return syncRouteRequest(routeRequest); + } + } diff --git a/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java index 20c44e83..7b79c25f 100644 --- a/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java @@ -23,6 +23,7 @@ import java.util.Optional; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP_CN_NAME; import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.mapCarStatus; /** @@ -117,6 +118,11 @@ public class AmapOrderDataAdapter implements OrderDataAdapter { return List.of(); } + @Override + public String getSupplierName() { + return SUPPLIER_AMAP; + } + private String handlerLocationName(String locationName) { if (locationName == null) { diff --git a/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java index bf79f2f9..cbdfc358 100644 --- a/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java @@ -33,6 +33,7 @@ import java.util.Optional; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_COUNTY; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; @Component @@ -49,7 +50,7 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { if (!itineraryList.isEmpty()) { ItineraryEntity itineraryEntity = itineraryList.get(0); OrderLegData.Builder builder = OrderLegData.builder() - .supplierName(SupplierNameConstant.SUPPLIER_C_TRIP); + .supplierName(SUPPLIER_C_TRIP); OrderLegData.Builder elementList = findSingleElementList(itineraryEntity, builder); if (elementList == null) { return Optional.empty(); @@ -89,6 +90,11 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { return List.of(); } + @Override + public String getSupplierName() { + return SUPPLIER_C_TRIP; + } + private OrderLegData.Builder findSingleElementList(ItineraryEntity itineraryEntity, OrderLegData.Builder builder) { List hotelOrderInfoList = itineraryEntity.getHotelOrderInfoList(); diff --git a/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java index 51a6524b..06d46e2c 100644 --- a/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java @@ -281,7 +281,7 @@ public class LYOrderDataAdapter implements OrderDataAdapter { } private List commonHotel(RouteOrder routeOrder, SupplierCallbackData callbackData) { - HotelDetailResponse.Data data = (HotelDetailResponse.Data ) callbackData.getData(); + HotelDetailResponse.Data data = (HotelDetailResponse.Data) callbackData.getData(); HotelDetailResponse.OrderInfo orderInfo = data.getOrderInfo(); String outStatus = orderInfo.getOrderStatusDesc(); String orderNo = orderInfo.getOrderSerialNo(); @@ -339,4 +339,9 @@ public class LYOrderDataAdapter implements OrderDataAdapter { return List.of(); } } + + @Override + public String getSupplierName() { + return SUPPLIER_L_Y; + } } diff --git a/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java index 473c092f..363ad744 100644 --- a/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/OrderDataAdapter.java @@ -8,8 +8,7 @@ import com.chint.domain.value_object.SupplierCallbackData; import java.util.List; import java.util.Optional; -public interface OrderDataAdapter { +public interface OrderDataAdapter extends SupplierAdapter{ Optional adapt(SupplierCallbackData supplierData); - List orderStatusToCommand(RouteOrder routeOrder, SupplierCallbackData callbackData); } diff --git a/src/main/java/com/chint/domain/service/supplier/SupplierAdapter.java b/src/main/java/com/chint/domain/service/supplier/SupplierAdapter.java new file mode 100644 index 00000000..3f2c6637 --- /dev/null +++ b/src/main/java/com/chint/domain/service/supplier/SupplierAdapter.java @@ -0,0 +1,5 @@ +package com.chint.domain.service.supplier; + +public interface SupplierAdapter { + String getSupplierName(); +} diff --git a/src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java b/src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java new file mode 100644 index 00000000..34f47ba6 --- /dev/null +++ b/src/main/java/com/chint/domain/service/supplier/SupplierAdapterSelector.java @@ -0,0 +1,49 @@ +package com.chint.domain.service.supplier; + +import com.chint.domain.exceptions.NotFoundException; +import jakarta.annotation.PostConstruct; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; + +import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; + +@Slf4j +@Component +public class SupplierAdapterSelector { + + private final Map, SupplierAdapter>> adapterMap = new HashMap<>(); + + @Autowired + private ApplicationContext applicationContext; + + @PostConstruct + public void init() { + log.info("开始注入供应商适配器到选择器。。。。。"); + Map beansOfType = applicationContext.getBeansOfType(SupplierAdapter.class); + for (SupplierAdapter adapter : beansOfType.values()) { + String supplierName = adapter.getSupplierName(); + log.info(supplierName); + adapterMap + .computeIfAbsent(supplierName, k -> new HashMap<>()) + .put(adapter.getClass().getInterfaces()[0], adapter); + } + } + + @SuppressWarnings("unchecked") + public T of(String supplierName, Class type) { + Map, SupplierAdapter> supplierAdapters = adapterMap.get(supplierName); + if (supplierAdapters == null) { + throw new NotFoundException(NOT_FOUND); + } + SupplierAdapter adapter = supplierAdapters.get(type); + if (adapter == null) { + throw new NotFoundException(NOT_FOUND); + } + return (T) adapter; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java index e1a197fd..5613c852 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/AmapUserRequest.java @@ -41,7 +41,8 @@ public class AmapUserRequest implements UserSync { UserQueryResponse userQueryResponse = queryUser(user); List data = userQueryResponse.getData(); if (data == null || data.isEmpty()) { - return createUser(user); + BaseResponse baseResponse = createUser(user); + return baseResponse; } else { return updateUser(user); } diff --git a/src/main/java/com/chint/interfaces/rest/base/PostRequest.java b/src/main/java/com/chint/interfaces/rest/base/PostRequest.java index dd321581..088f1c44 100644 --- a/src/main/java/com/chint/interfaces/rest/base/PostRequest.java +++ b/src/main/java/com/chint/interfaces/rest/base/PostRequest.java @@ -58,6 +58,13 @@ public class PostRequest { return post(post, responseType); } + public T post(String url, String json, Class responseType) { + HttpPost post = new HttpPost(url); + log.info(json); + post.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON)); + return post(post, responseType); + } + public T post(String url, UrlEncodedFormEntity entity, Class responseType) { HttpPost post = new HttpPost(url); post.setEntity(entity); diff --git a/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java b/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java index 927945fd..ccae104c 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java @@ -98,9 +98,10 @@ public class BPMParamFactory { } }).orElse(new BigDecimal(KEEP_TWO_DECIMAL_ZERO)); }; - + BigDecimal standardPriceFromQuery = handleNullLegId.get(); if (orderDetail.getPrice() != null && orderDetail.getProductType().equals(LEG_TYPE_HOTEL)) { - standardPrice = legId != null ? calculateStandardPrice.apply(legRepository.findByLegId(legId)) : handleNullLegId.get(); + standardPrice = !standardPriceFromQuery.equals(new BigDecimal(KEEP_TWO_DECIMAL_ZERO)) ? standardPriceFromQuery : + calculateStandardPrice.apply(legRepository.findByLegId(legId)); } // 金额计算 diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeEntity.java b/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeEntity.java index 705b224d..44353777 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeEntity.java +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/user/EmployeeEntity.java @@ -24,6 +24,7 @@ public class EmployeeEntity { private int workingState; private String birthday; private String credentialExpireDate; + private Integer modifyType; // private int credentialType; // private int addTravellerAllowed; private String employeeCode; diff --git a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/statementList/ResStatementList.java b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/statementList/ResStatementList.java index 0c1cc3d7..b6822b41 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/statementList/ResStatementList.java +++ b/src/main/java/com/chint/interfaces/rest/ly/reconciliation/dto/statementList/ResStatementList.java @@ -36,6 +36,4 @@ public class ResStatementList extends BaseResponse { private String overDueRemark;//是否过期说明 离付款日还剩xxx天/已过期xxx天 private Double payAmount;//待付款 } - - } diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 75135ba2..7cb8c90e 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -50,19 +50,19 @@ ly: password: glHRJJ9JMUwNfQ8OwAQi secret: MnghmYJpM1U2RaLx baseUrl: https://api.dttrip.cn/openapi - ifForwardRequest: false - forwardRequestBaseUrl: https://secureqrdev-t.chint.com/llz + ifForwardRequest: true + forwardRequestBaseUrl: https://gxdev03.chint.com/routeapi #高德 amap: - eId: 612660 - appId: car_zhengtecm3noxh - key: a1vxgdwobkphirln5fgup0oj6e2rsniw - keyt: car_zhengtecm3noxh - signKey: ngwdzlembqju9lairthw264bzkhw2vto - aesKey: 7eEdUzuVflM8n9Wo - baseUrl: https://sns.testing.amap.com - baseLoginUrl: https://pre-hailing.amap.com + eId: 201107 + appId: car_zhengtveefkay6 + key: vibcxd6ltlxxuct0j9sc079u0rdaur0s + keyt: car_zhengtveefkay6 + signKey: fb0jcukg6hjbn2k2cxedvweux4uozzxo + aesKey: UTatMtHBBVzc05PY + baseUrl: https://gws.amap.com + baseLoginUrl: https://dache.amap.com sf: openApiBaseUrl: https://openapi.chintcloud.net akBaseUrl: https://transitbridge.chint.com diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index bf932a74..a98cbb4a 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; @@ -127,6 +128,9 @@ public class CTripTest { @Autowired private OrderRecordFactorySelector orderRecordFactorySelector; + @Autowired + private CTripOrderRecordAutoSave cTripOrderRecordAutoSave; + @Value("${cTrip.requestSecret}") private String C_TRIP_REQUEST_SECRET; @@ -246,7 +250,7 @@ public class CTripTest { @Test void search() { BaseContext.setCurrentUser(user); - SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32206424651"); + SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32559146895"); System.out.println(response); } @@ -602,4 +606,9 @@ public class CTripTest { OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP); orderRecordExtensionFactory.createHotelOrderRecord(hotelRecordByRecordId); } + + @Test + void pullCarRecord() { + cTripOrderRecordAutoSave.cTripCarRecordAutoSave(Optional.ofNullable("202405")); + } } diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 3b686eaf..886fbe4f 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -828,7 +828,7 @@ public class LYTest { @Test void searchHotel() { - HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240510114900487148"); + HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240417095100616718"); Gson gson = new Gson(); String json = gson.toJson(hotelOrderDetail); System.out.println(json); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index c2914043..b301bed8 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -18,7 +18,6 @@ import com.chint.domain.service.JTCompanyDomainService; import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.SystemDomainService; import com.chint.domain.service.order_sync.LYOrderSyncAdapter; -import com.chint.domain.value_object.RanksData; import com.chint.infrastructure.repository.CTripOrderDetailImpl; import com.chint.infrastructure.util.DateTimeUtil; import com.chint.infrastructure.util.Digest; @@ -35,6 +34,7 @@ import com.chint.interfaces.rest.data_center.user.BatchUserWorker; import com.chint.interfaces.rest.data_center.user.UserHttpRequest; import com.chint.interfaces.rest.data_center.user.UserHttpRequestImpl; import com.chint.interfaces.rest.data_center.user.UserSFRequest; +import com.chint.interfaces.rest.ly.LYNoteResponse; import com.chint.interfaces.rest.ly.LYPostRequest; import com.chint.interfaces.rest.ly.LYSearchRequest; import com.chint.interfaces.rest.ly.LYUserRequest; @@ -59,6 +59,8 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import static com.chint.infrastructure.constant.LocationConstant.*; @@ -302,7 +304,7 @@ class RouteApplicationTests { @Test void loginSign() { - String sfno = "230207110"; + String sfno = "230410022"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; @@ -313,10 +315,10 @@ class RouteApplicationTests { @Test void loginSignProd() { - String sfno = "220531010"; + String sfno = "230214151"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; - String companycode = "A70000021"; + String companycode = "正泰集团股份有限公司"; String timespan = "1708908662738"; String key = "ZhengTaiRoute"; String s = Digest.md5(sfno + syscode + billcode + companycode + key + timespan); @@ -383,7 +385,7 @@ class RouteApplicationTests { @Test - void postUserToAmap(){ + void postUserToAmap() { // 读取文件内容 String filePath = "D:\\data\\routeData\\itinerary_booking_user_employee_no.sql"; // 修改为实际文件路径 String s = readFileAsString(filePath); @@ -393,6 +395,51 @@ class RouteApplicationTests { } } + @Test + void postOrderToProd() { + String filePath = "D:\\data\\routeData\\itinerary_booking_supplier_call_back_log.sql"; + String log = readFileAsString(filePath); + List strings = extractRequestBodies(log); + + int requestCount = 0; + for (String requestBody : strings) { + System.out.println(requestBody); + requestBody = requestBody.replace("\\\\", "\\"); + if (requestBody.startsWith("{\"notifyData\":")) { + postRequest.post("https://trip.chint.com/api/public/common/back", + requestBody, LYNoteResponse.class); + + } + if (requestBody.startsWith("{\"productType\":")) { + postRequest.post("https://trip.chint.com/api/public/CTrip/status", + requestBody, CTripNoteResponse.class); + } + System.out.println("这是第" + requestCount + "次请求"); + // 每发起10次请求后休息1秒 + requestCount++; + if (requestCount % 10 == 0) { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + + public static List extractRequestBodies(String log) { + List requestBodies = new ArrayList<>(); + String patternString = "RequestBody:\\s*(\\{.*?\\})\\s*Stack Trace:"; + Pattern pattern = Pattern.compile(patternString, Pattern.DOTALL); + Matcher matcher = pattern.matcher(log); + + while (matcher.find()) { + requestBodies.add(matcher.group(1).trim()); + } + + return requestBodies; + } + @Test void post() { @@ -446,7 +493,7 @@ class RouteApplicationTests { int requestCount = 0; List alreadyPost = new ArrayList<>(); for (CTripStatusNotification cTripStatusNotification : cTripStatusNotifications) { - if(!CTripUtils.checkHotelStatus(cTripStatusNotification.getOrderStatus())) { + if (!CTripUtils.checkHotelStatus(cTripStatusNotification.getOrderStatus())) { continue; } if (!list1.contains(cTripStatusNotification.getOrderId()) || alreadyPost.contains(cTripStatusNotification.getOrderId())) {