From 32ba08c300c2886d03f5c603c06a65c0ebef5c99 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Mon, 19 Feb 2024 11:01:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dtos/trip/TripCallback.java | 11 ++++++++ .../dtos/trip/TripCallbackCity.java | 13 +++++++++ .../dtos/trip/TripCallbackData.java | 27 +++++++++++++++++++ .../dtos/trip/TripCallbackDocument.java | 16 +++++++++++ .../dtos/trip/TripCallbackScheduleDetail.java | 17 ++++++++++++ .../dtos/trip/TripCallbackUserInfo.java | 15 +++++++++++ .../value_object/SupplierCallbackData.java | 3 ++- .../rest/ctrip/CTripOrderSearchRequest.java | 2 +- .../rest/ctrip/in/CTripNoteController.java | 27 ++++++++++++++----- src/main/resources/application-dev.yml | 8 +++--- src/main/resources/application-test.yml | 16 +++++++++++ src/main/resources/application.yml | 2 +- 12 files changed, 143 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/chint/application/dtos/trip/TripCallback.java create mode 100644 src/main/java/com/chint/application/dtos/trip/TripCallbackCity.java create mode 100644 src/main/java/com/chint/application/dtos/trip/TripCallbackData.java create mode 100644 src/main/java/com/chint/application/dtos/trip/TripCallbackDocument.java create mode 100644 src/main/java/com/chint/application/dtos/trip/TripCallbackScheduleDetail.java create mode 100644 src/main/java/com/chint/application/dtos/trip/TripCallbackUserInfo.java create mode 100644 src/main/resources/application-test.yml diff --git a/src/main/java/com/chint/application/dtos/trip/TripCallback.java b/src/main/java/com/chint/application/dtos/trip/TripCallback.java new file mode 100644 index 00000000..0a962799 --- /dev/null +++ b/src/main/java/com/chint/application/dtos/trip/TripCallback.java @@ -0,0 +1,11 @@ +package com.chint.application.dtos.trip; + +import lombok.Data; + +@Data +public class TripCallback { + private String method; // Method of the callback, e.g., "trip.callback" + private TripCallbackData data; // Main data containing trip details + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/application/dtos/trip/TripCallbackCity.java b/src/main/java/com/chint/application/dtos/trip/TripCallbackCity.java new file mode 100644 index 00000000..886ed7ff --- /dev/null +++ b/src/main/java/com/chint/application/dtos/trip/TripCallbackCity.java @@ -0,0 +1,13 @@ +package com.chint.application.dtos.trip; + + +import lombok.Data; + +@Data +public class TripCallbackCity { + private String geoId; // Geographical ID of the city + private String cityEnName; // English name of the city + private String cityName; // Local name of the city + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/application/dtos/trip/TripCallbackData.java b/src/main/java/com/chint/application/dtos/trip/TripCallbackData.java new file mode 100644 index 00000000..ff4e2d9d --- /dev/null +++ b/src/main/java/com/chint/application/dtos/trip/TripCallbackData.java @@ -0,0 +1,27 @@ +package com.chint.application.dtos.trip; + + +import lombok.Data; + +import java.util.List; + +@Data +public class TripCallbackData { + private String changeCar; // Indicates if a car change is requested + private String startDate; // Start date of the trip + private String endDate; // End date of the trip + private String receiptsNum; // Receipts number + private String businessTripReason; // Reason for the business trip + private String receiptsStatus; // Status of the receipts + private String createUserId; // User ID of the creator + private String createUserName; // Name of the creator + private String createUserMobile; // Mobile number of the creator + private String compName; // Company name + private String compId; // Company ID + private String createTime; // Creation time of the trip + private String type; // Type of document, e.g., "0" for application + // Additional fields... + private List cityList; // List of cities involved in the trip + private List userInfoList; // List of user information + private List scheduleDetailList; // List of schedule details +} diff --git a/src/main/java/com/chint/application/dtos/trip/TripCallbackDocument.java b/src/main/java/com/chint/application/dtos/trip/TripCallbackDocument.java new file mode 100644 index 00000000..6e1aee6d --- /dev/null +++ b/src/main/java/com/chint/application/dtos/trip/TripCallbackDocument.java @@ -0,0 +1,16 @@ +package com.chint.application.dtos.trip; + + +import lombok.Data; + +@Data +public class TripCallbackDocument { + private String docType; // Type of the document, e.g., visa, ticket + private String docId; // Unique identifier for the document + private String docName; // Name of the document + private String issueDate; // Issue date of the document + private String expiryDate; // Expiry date of the document + private String issuingAuthority; // Authority that issued the document + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/application/dtos/trip/TripCallbackScheduleDetail.java b/src/main/java/com/chint/application/dtos/trip/TripCallbackScheduleDetail.java new file mode 100644 index 00000000..e2a5575d --- /dev/null +++ b/src/main/java/com/chint/application/dtos/trip/TripCallbackScheduleDetail.java @@ -0,0 +1,17 @@ +package com.chint.application.dtos.trip; + + +import lombok.Data; + +@Data +public class TripCallbackScheduleDetail { + private String scheduleType; // Type of schedule, e.g., flight, hotel + private String scheduleStartDate; // Start date of the schedule + private String scheduleEndDate; // End date of the schedule + private String city; // City associated with this schedule + private String country; // Country associated with this schedule + private String detail; // Detailed information about the schedule + private TripCallbackDocument document; // Document associated with the schedule + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/application/dtos/trip/TripCallbackUserInfo.java b/src/main/java/com/chint/application/dtos/trip/TripCallbackUserInfo.java new file mode 100644 index 00000000..0d867cff --- /dev/null +++ b/src/main/java/com/chint/application/dtos/trip/TripCallbackUserInfo.java @@ -0,0 +1,15 @@ +package com.chint.application.dtos.trip; + +import lombok.Data; + +import java.util.List; + +@Data +public class TripCallbackUserInfo { + private String userId; // Unique identifier for the user + private String userName; // Name of the user + private String userMobile; // Mobile number of the user + private List documents; // List of documents associated with the user + + // Getters and setters... +} \ No newline at end of file diff --git a/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java b/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java index 73186919..072cfaf2 100644 --- a/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java +++ b/src/main/java/com/chint/domain/value_object/SupplierCallbackData.java @@ -9,9 +9,10 @@ public class SupplierCallbackData { private Integer productType; //用于区分同程搜索数据 private Object data; - public static SupplierCallbackData of(String supplierName) { + public static SupplierCallbackData of(String supplierName, String employeeNo) { SupplierCallbackData supplierCallbackData = new SupplierCallbackData(); supplierCallbackData.setSupplierName(supplierName); + supplierCallbackData.setEmployeeNo(employeeNo); return supplierCallbackData; } diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripOrderSearchRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripOrderSearchRequest.java index ed0443ae..667d4894 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripOrderSearchRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripOrderSearchRequest.java @@ -31,7 +31,7 @@ public class CTripOrderSearchRequest { return postRequest.post(searchUrl, request, SearchOrderResponse.class); } - public SearchOrderResponse SearchOrderResponseByOrderId(String orderId){ + public SearchOrderResponse searchOrderResponseByOrderId(String orderId){ String ticket = ticketRequest.loadTicket(); SearchOrderRequest request = SearchOrderRequest .builder() diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/in/CTripNoteController.java b/src/main/java/com/chint/interfaces/rest/ctrip/in/CTripNoteController.java index 886901ec..e3ca260e 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/in/CTripNoteController.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/in/CTripNoteController.java @@ -1,27 +1,40 @@ package com.chint.interfaces.rest.ctrip.in; +import com.chint.domain.service.supplier.SupplierService; +import com.chint.domain.value_object.SupplierCallbackData; +import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest; import com.chint.interfaces.rest.ctrip.dto.put.CTripNoteResponse; import com.chint.interfaces.rest.ctrip.dto.put.CTripNotification; +import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import static com.chint.infrastructure.constant.Constant.SUPPLIER_C_TRIP; + @RestController @RequestMapping("/public/CTrip") public class CTripNoteController { + @Autowired + private SupplierService supplierService; + + @Autowired + private CTripOrderSearchRequest cTripOrderSearchRequest; @PostMapping("/event") public CTripNoteResponse noteEvent(@RequestBody CTripNotification cTripNotification) { - if (cTripNotification.getContent() != null) { - //成功触发消息,需要查询对于的订单信息, - - //如果订单不存在需要保存到数据库以及对应的行程规划单下 - - //如果订单以及存在,那么只需要给对应的订单加入对应的事件 - + if (cTripNotification.getContent() != null && cTripNotification.getPreEmployeeID() != null) { + //成功触发消息,需要查询对于的订单信息,調用订单查询的服务来查询该订单详情 + SupplierCallbackData supplierCallbackData = + SupplierCallbackData.of(SUPPLIER_C_TRIP, cTripNotification.getPreEmployeeID()); + SearchOrderResponse response = cTripOrderSearchRequest + .searchOrderResponseByOrderId(cTripNotification.getBusinessId()); + supplierCallbackData.data(response); + supplierService.handleSupplierCallback(supplierCallbackData); return new CTripNoteResponse("0", "成功收到消息"); } return new CTripNoteResponse("1", "未收到消息"); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 9d1e0bcc..90224842 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -4,12 +4,12 @@ server: chint: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - host: rm-cn-jeo3lfy9q0006gso.rwlb.rds.aliyuncs.com + host: 10.10.24.44 # host: 10.9.56.48 - port: 3306 + port: 6603 database: itinerary_booking - username: echo - password: R3nd0mP@ssw0rd! + username: tripbook + password: W@Xgf25d&lRk*L0X# logging: level: org.springframework.jdbc.core.JdbcTemplate: DEBUG diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml new file mode 100644 index 00000000..5237f5c5 --- /dev/null +++ b/src/main/resources/application-test.yml @@ -0,0 +1,16 @@ +server: + port: 8081 + +chint: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + host: rm-cn-jeo3lfy9q0006gso.rwlb.rds.aliyuncs.com + # host: 10.9.56.48 + port: 3306 + database: itinerary_booking + username: echo + password: R3nd0mP@ssw0rd! +logging: + level: + org.springframework.jdbc.core.JdbcTemplate: DEBUG + org.springframework.jdbc.core.StatementCreatorUtils: TRACE diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 25bc92fb..04736697 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: dev + active: test datasource: driver-class-name: ${chint.datasource.driver-class-name} url: jdbc:mysql://${chint.datasource.host}:${chint.datasource.port}/${chint.datasource.database}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true