From a862d4cde356f8a233b432073b3224d3e3ff4afb Mon Sep 17 00:00:00 2001 From: lulz1 Date: Mon, 25 Mar 2024 12:46:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=8E=AF=E5=A2=83=E8=AE=A2?= =?UTF-8?q?=E7=A5=A8=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=90=8C=E7=A8=8B=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/aggregates/order/OrderTravel.java | 7 +++- .../repository/OrderTravelRepository.java | 9 +++++ .../order_sync/LYOrderSyncAdapter.java | 4 +-- .../repository/OrderTravelRepositoryImpl.java | 34 +++++++++++++++++++ .../rest/ly/in/LYETAController.java | 12 +++++-- src/main/resources/application-dev.yml | 8 ++--- src/main/resources/application-prod.yml | 4 +-- src/main/resources/application-test.yml | 8 ++--- .../java/com/chint/RouteApplicationTests.java | 13 +++++-- 9 files changed, 82 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/chint/domain/repository/OrderTravelRepository.java create mode 100644 src/main/java/com/chint/infrastructure/repository/OrderTravelRepositoryImpl.java diff --git a/src/main/java/com/chint/domain/aggregates/order/OrderTravel.java b/src/main/java/com/chint/domain/aggregates/order/OrderTravel.java index ae5c5d0d..d1000e0d 100644 --- a/src/main/java/com/chint/domain/aggregates/order/OrderTravel.java +++ b/src/main/java/com/chint/domain/aggregates/order/OrderTravel.java @@ -5,7 +5,6 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import org.springframework.data.annotation.Id; -import org.springframework.data.relational.core.mapping.Column; import org.springframework.data.relational.core.mapping.Table; import java.io.Serial; @@ -23,4 +22,10 @@ public class OrderTravel implements Serializable { private String orderNo; private String travelNo; + public static OrderTravel of(String orderNo, String travelNo) { + OrderTravel orderTravel = new OrderTravel(); + orderTravel.setTravelNo(travelNo); + orderTravel.setOrderNo(orderNo); + return orderTravel; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/repository/OrderTravelRepository.java b/src/main/java/com/chint/domain/repository/OrderTravelRepository.java new file mode 100644 index 00000000..fbb041d4 --- /dev/null +++ b/src/main/java/com/chint/domain/repository/OrderTravelRepository.java @@ -0,0 +1,9 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.order.OrderTravel; + +public interface OrderTravelRepository { + OrderTravel save(OrderTravel orderTravel); + + OrderTravel findByOrderNo(String orderNo); +} 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 4093bcdb..b2f5ed05 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 @@ -216,10 +216,10 @@ public class LYOrderSyncAdapter implements SupplierOrderSync { } - private Location getCityLocation(Location location) { + public Location getCityLocation(Location location) { if (location.getLocationType().equals(LOCATION_TYPE_CITY)) { return location; - } else if (location.getLocationType().equals(LOCATION_LEVEL_COUNTY) || location.getLocationType().equals(LOCATION_TYPE_DISTRICT)) { + } else if (location.getLocationType().equals(LOCATION_TYPE_COUNTY) || location.getLocationType().equals(LOCATION_TYPE_DISTRICT)) { return locationRepository.findById(location.getParentLocationId()); } else if (location.getLocationType().equals(LOCATION_TYPE_AIRPORT)) { //如果是机场的话,要查询出对应的地级市 diff --git a/src/main/java/com/chint/infrastructure/repository/OrderTravelRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/OrderTravelRepositoryImpl.java new file mode 100644 index 00000000..262f3382 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/OrderTravelRepositoryImpl.java @@ -0,0 +1,34 @@ +package com.chint.infrastructure.repository; + +import com.chint.domain.aggregates.order.OrderTravel; +import com.chint.domain.repository.OrderTravelRepository; +import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public class OrderTravelRepositoryImpl implements OrderTravelRepository { + + @Autowired + private JdbcOrderTravelRepository jdbcOrderTravelRepository; + + @Override + public OrderTravel save(OrderTravel orderTravel) { + List byOrderNo = jdbcOrderTravelRepository.findByOrderNo(orderTravel.getOrderNo()); + if (byOrderNo != null && byOrderNo.isEmpty()) { + jdbcOrderTravelRepository.save(orderTravel); + } + return orderTravel; + } + + @Override + public OrderTravel findByOrderNo(String orderNo) { + List byOrderNo = jdbcOrderTravelRepository.findByOrderNo(orderNo); + if (byOrderNo != null && !byOrderNo.isEmpty()) { + return byOrderNo.get(0); + } + return null; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java b/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java index d012b764..d934686a 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/LYETAController.java @@ -2,7 +2,9 @@ package com.chint.interfaces.rest.ly.in; import com.chint.application.commands.OrderStatusChangeCommand; import com.chint.domain.aggregates.order.OrderDetail; +import com.chint.domain.aggregates.order.OrderTravel; import com.chint.domain.exceptions.NotFoundException; +import com.chint.domain.repository.OrderTravelRepository; import com.chint.domain.service.SystemDomainService; import com.chint.domain.service.supplier.SupplierService; import com.chint.domain.value_object.SupplierCallbackData; @@ -49,6 +51,9 @@ public class LYETAController { @Autowired private SupplierService supplierService; + @Autowired + private OrderTravelRepository orderTravelRepository; + @PostMapping("/eta") public LYNoteResponse noteByETA(@RequestBody LyETAPush lyETAPush) { if (lyETAPush.getNotifyType() != 51) { @@ -56,6 +61,7 @@ public class LYETAController { } LyETAPush.NotifyData notifyData = lyETAPush.getNotifyData(); + String approvalOrderId = notifyData.getApprovalOrderId(); String travelApplyNo = notifyData.getTravelApplyNo(); String[] split = travelApplyNo.split("-"); if (split.length == 0) { @@ -67,7 +73,7 @@ public class LYETAController { if (systemDomainService.ifImmediateResponse(sysCode)) { //如果是可以立刻返回结果的,直接返回审批通过信息 CompletableFuture.runAsync(() -> DelayDispatch.attemptToSend( - () -> lyApprovalRequest.pushApprovalSuccess(notifyData.getApprovalOrderId()).isSuccess(), 0 + () -> lyApprovalRequest.pushApprovalSuccess(approvalOrderId).isSuccess(), 0 )); } @@ -75,6 +81,8 @@ public class LYETAController { SupplierCallbackData supplierCallbackData = handlerETACallBackData(lyETAPush); OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData); + orderTravelRepository.save(OrderTravel.of(orderDetail.getOrderNo(), approvalOrderId)); + //发送超标事件 Command.of(OrderStatusChangeCommand.class) .orderDetail(orderDetail) @@ -85,7 +93,7 @@ public class LYETAController { .sendToQueue(); int subNotifyType = lyETAPush.getSubNotifyType(); - if(subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6 ){ + if (subNotifyType == 2 || subNotifyType == 4 || subNotifyType == 6) { //如果推送类是2,4,6还要触发改签事件 Command.of(OrderStatusChangeCommand.class) .orderDetail(orderDetail) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 48c22cb9..14b8d551 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -38,10 +38,10 @@ logging: #正式 ly: appId: zhengtai - account: ab9fe0c19dd64a99b936fded72c3bb94 - password: glHRJJ9JMUwNfQ8OwAQi - secret: MnghmYJpM1U2RaLx - baseUrl: https://api.dttrip.cn/openapi + account: 4f9cb1080b564dd0a94aa95f7a19c8b5 + password: 1fD3SutgzfS48qznYQiq + secret: WOHzCMvHd823iHgH + baseUrl: https://api.qa.dttrip.cn/openapi ifForwardRequest: false forwardRequestBaseUrl: https://secureqrdev-t.chint.com/llz diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index a05d54f3..30addde9 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -14,8 +14,8 @@ chint: # host: gf-jump.chint.com # port: 30108 # database: itinerary_booking -# username: e2b8171f-9920-4972-8f84-383ff27eee44 -# password: zbPYf9CUI1ef1nhW +# username: 5d34865d-187b-45a1-937b-13687ba4d4a4 +# password: XqU0PhUa8LQla6Gl url: https://trip.chint.com/ redis: diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 0e552aab..f4381294 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -48,10 +48,10 @@ logging: #正式 ly: appId: zhengtai - account: ab9fe0c19dd64a99b936fded72c3bb94 - password: glHRJJ9JMUwNfQ8OwAQi - secret: MnghmYJpM1U2RaLx - baseUrl: https://api.dttrip.cn/openapi + account: 4f9cb1080b564dd0a94aa95f7a19c8b5 + password: 1fD3SutgzfS48qznYQiq + secret: WOHzCMvHd823iHgH + baseUrl: https://api.qa.dttrip.cn/openapi ifForwardRequest: false forwardRequestBaseUrl: https://secureqrdev-t.chint.com/llz diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index e13ed798..fbd04e0c 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -14,6 +14,7 @@ import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.*; import com.chint.domain.service.JTCompanyDomainService; +import com.chint.domain.service.order_sync.LYOrderSyncAdapter; import com.chint.domain.value_object.RanksData; import com.chint.infrastructure.util.Digest; import com.chint.infrastructure.util.PinyinUtil; @@ -116,6 +117,8 @@ class RouteApplicationTests { @Autowired private UserHttpRequestImpl userHttpRequestImpl; + @Autowired + private LYOrderSyncAdapter lyOrderSyncAdapter; @Autowired private UserSFRequest userSFRequest; @@ -264,9 +267,9 @@ class RouteApplicationTests { // log.trace("trace"); } - // @Test + @Test void loginSignProd() { - String sfno = "081001001"; + String sfno = "230601010"; String syscode = "FSSC"; String billcode = "CLSQ240315000308"; String companycode = "浙江正泰电器股份有限公司"; @@ -1206,4 +1209,10 @@ class RouteApplicationTests { } + @Test + void testQueryCity() { + Location location = locationRepository.findById(373L); + Location cityLocation = lyOrderSyncAdapter.getCityLocation(location); + System.out.println(cityLocation); + } }