From dd1a84fdba698f6c59b0bcac46615bbd0a4dcbb6 Mon Sep 17 00:00:00 2001 From: huangxh3 Date: Tue, 27 Feb 2024 14:33:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6,=E9=85=92=E5=BA=97=E6=95=B0=E6=8D=AE=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aggregates/order/HotelOrderDetail.java | 2 + .../LYOrderExtensionFactoryImpl.java | 99 ++++++++++++++++++- .../service/supplier/LYOrderDataAdapter.java | 4 + .../service/supplier/SupplierServiceImpl.java | 2 +- .../dto/hotelorderdatapushbach/Resident.java | 1 + .../response/hotel/HotelDetailResponse.java | 13 +++ .../rest/ly/in/FlyBackController.java | 2 +- src/main/resources/application-dev.yml | 25 +++++ 8 files changed, 143 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetail.java index 198835f1..501aa06e 100644 --- a/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetail.java @@ -2,6 +2,7 @@ package com.chint.domain.aggregates.order; import lombok.Data; +import lombok.experimental.Accessors; import org.springframework.data.annotation.Id; import org.springframework.data.relational.core.mapping.MappedCollection; import org.springframework.data.relational.core.mapping.Table; @@ -10,6 +11,7 @@ import java.util.List; @Data @Table("hotel_order_detail") +@Accessors(chain = true) public class HotelOrderDetail { @Id private Long id; 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 0bb43406..f78b8b3e 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 @@ -1,11 +1,25 @@ package com.chint.domain.factoriy.order_detail; import com.chint.domain.aggregates.order.*; +import com.chint.domain.aggregates.user.User; +import com.chint.domain.repository.UserRepository; import com.chint.domain.value_object.*; +import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident; +import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + @Component -public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory{ +public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { + + + + @Autowired + private UserRepository userRepository; @Override public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { return null; @@ -23,14 +37,93 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory{ @Override public HotelOrderDetail createHotelOrderDetail(Object hotelOrderDetailData) { + HotelOrderDetail hotelOrderDetail = new HotelOrderDetail(); + HotelDetailResponse hotelDetailResponse = (HotelDetailResponse) hotelOrderDetailData; + HotelOrderDetail convertHotel = convertHotel(hotelDetailResponse); - - return null; + return convertHotel; } @Override public OtherOrderDetail createOtherOrderDetail(Object otherOrderDetailData) { return null; } + + + private FlightOrderDetail convertFlight(HotelDetailResponse hotelDetailResponse) { + + + + + + return null; + } + private HotelOrderDetail convertHotel(HotelDetailResponse hotelDetailResponse) { + HotelOrderDetail hotelOrderDetail = new HotelOrderDetail(); + HotelDetailResponse.Data data = hotelDetailResponse.getData(); + HotelDetailResponse.OrderInfo orderInfo = data.getOrderInfo(); + HotelDetailResponse.HotelInfo hotelInfo = data.getHotelInfo(); + List roomList = data.getRoomList(); + hotelOrderDetail.setOrderNo(orderInfo.getOrderSerialNo()) + .setOverStandard(String.valueOf(orderInfo.getRuleViolate())) + .setOrderStatus(String.valueOf(orderInfo.getOrderStatus())) + .setReceiptsNum(orderInfo.getTravelApplyNo()) + .setBookingUserCode(orderInfo.getOutEmployeeId()) + // .setBookingName(orderInfo.getEmployeeName()) + .setCreateTime("2023-04-26 13:15:17") + .setCheckInCity(orderInfo.getCreateTime()) + .setHotelName(hotelInfo.getHotelName()) + .setContactPhone(hotelInfo.getHotelTel()) + .setHotelAddress(hotelInfo.getHotelAddress()) + .setStarRate("4") + .setCheckInDate(hotelInfo.getCheckInDate()) + .setDepartureDate(hotelInfo.getCheckOutDate()) + .setNightCount(String.valueOf(hotelInfo.getNightNum())) + .setRoomCount(String.valueOf(hotelInfo.getRoomNum())) + //.setRefundRoomNightCount("0") + .setRoomTypeName(hotelInfo.getRoomName()) + .setPaymentType(String.valueOf(orderInfo.getPaymentType())) + .setCompanyAmount(String.valueOf(orderInfo.getCompanyPrice())) + .setPersonalAmount(String.valueOf(orderInfo.getPersonalPrice())) + .setCompanyRefundAmount(String.valueOf(orderInfo.getCompanyRefundPrice())) + .setPersonalRefundAmount(String.valueOf(orderInfo.getPersonalRefundPrice())) + .setOrderAmount(String.valueOf(orderInfo.getBusinessAmount())) + .setPreServiceFee(String.valueOf(orderInfo.getServicePrice())) + .setPostServiceFee(String.valueOf(orderInfo.getAfterSettlementServicePrice())) + .setRefundAmount(String.valueOf(orderInfo.getRefundPrice())) + .setCustomers(getCustomers(data.getResidentList())) + .setStandardItems(data.getItems().getPolicyName()) + // .setNightRates() + .setSupplier("Supplier XYZ") + .setAmountFields("Amount A, Amount B") + .setOverStandardReason(orderInfo.getFoulReason()) + .setAgreementHotel(String.valueOf(orderInfo.getProtocolType())); + // .setBOOK_ORG_STRUCT_1("Org A") + // .setBOOK_ORG_STRUCT_2("Org B") + // .setBOOK_ORG_STRUCT_3("Org C") + // .setProjectOrderNo("PROJ789") + // .setCostCenter("COST123") + + + return hotelOrderDetail; + } + + private List getCustomers(List residentList) { + + List list = residentList.stream() + .map(resident -> { + HotelOrderDetailCustomer customer = new HotelOrderDetailCustomer(); + customer.setId(Long.valueOf(resident.getEmployeeId())); + customer.setUserName(resident.getName()); + User user = userRepository.findById(Long.valueOf(resident.getEmployeeId())); + customer.setGender(user.getGender()); + customer.setUserCode(resident.getEmployeeCode()); + customer.setPhone(resident.getContactPhone()); + return customer; + }) + .collect(Collectors.toList()); + + return list; + } } 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 c0a40f54..d4883a98 100644 --- a/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java @@ -39,6 +39,7 @@ public class LYOrderDataAdapter implements OrderDataAdapter { .outOrderNo(data.getOrderNo()) .price(String.valueOf(data.getTotalAmount())) .actualOrderNo(data.getOutOrderNo()) + .trainOrderDetailData(data) .supplierName(SUPPLIER_L_Y) .build() ); @@ -52,6 +53,7 @@ public class LYOrderDataAdapter implements OrderDataAdapter { .outOrderNo(data.getOrderInfo().getOrderSerialNo()) .price(String.valueOf(data.getOrderInfo().getTotalPrice())) .actualOrderNo(data.getOrderInfo().getOrderSerialNo()) + .hotelOrderDetailData(data) .supplierName(SUPPLIER_L_Y) .build() ); @@ -65,6 +67,7 @@ public class LYOrderDataAdapter implements OrderDataAdapter { .outOrderNo(data.getOrderNo()) .price(String.valueOf(data.getTotalAmount())) .actualOrderNo(data.getOutOrderNo()) + .carOrderDetailData(data) .supplierName(SUPPLIER_L_Y) .build() ); @@ -79,6 +82,7 @@ public class LYOrderDataAdapter implements OrderDataAdapter { // .orderNo(data.get()) // .price(String.valueOf( data.getTotalAmount())) // .actualOrderNo(data.getOutOrderNo()) + .flightOrderDetailData(data) .supplierName(SUPPLIER_L_Y) .build() ); diff --git a/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java b/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java index 8730bcb4..a81bdf7d 100644 --- a/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java +++ b/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java @@ -39,7 +39,7 @@ public class SupplierServiceImpl implements SupplierService { Optional data = orderDataAdapterSelector.of(supplierName).adapt(callbackData); if (data.isPresent()) { //获取使用RouteUpdateOrderCommand命令创建的orderDetail - OrderLegData orderLegData = data.get(); + OrderLegData orderLegData = data.get(); Properties properties = Command.of(RouteUpdateOrderCommand.class).data(orderLegData).sendToQueue(); ResultContainer byPropertyName = properties.findByPropertyName(RESULT_ORDER_DETAIL); OrderDetail orderDetail = (OrderDetail) byPropertyName.getValue(); diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/hotelorderdatapushbach/Resident.java b/src/main/java/com/chint/interfaces/rest/ly/dto/hotelorderdatapushbach/Resident.java index 97493fc1..e479e637 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/dto/hotelorderdatapushbach/Resident.java +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/hotelorderdatapushbach/Resident.java @@ -13,5 +13,6 @@ public class Resident { private String employeeId; private String name; private String contactPhone; + private String employeeCode; private String contactEmail; } diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/hotel/HotelDetailResponse.java b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/hotel/HotelDetailResponse.java index 02ba2657..2d8afe85 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/hotel/HotelDetailResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/hotel/HotelDetailResponse.java @@ -18,6 +18,7 @@ public class HotelDetailResponse { public static class Data { private OrderInfo orderInfo; private HotelInfo hotelInfo; + private Items items; private List dayPrices; private List contactPersons; private List residentList; @@ -31,9 +32,18 @@ public class HotelDetailResponse { // Getters and Setters } @lombok.Data + public static class Items { + private String ruleTag;//违规标签 + private String message;//违规提示消息 + private boolean allowable;//违规是否允许预订 + private String policyName;//差旅政策名称 + } + @lombok.Data public static class OrderInfo { private String orderSerialNo; private String travelOrderNo; + private Boolean ruleViolate; + private String foulReason; private String businessTravelOrderNo; private int protocolType; private double totalStandardPrice; @@ -59,6 +69,9 @@ public class HotelDetailResponse { private double payPrice; private double personalPrice; private double companyPrice; + private double companyRefundPrice; + private double personalRefundPrice; + private double refundPrice; private String supplierOrderCreateTime; private String employeeName; private String enterpriseName; diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java b/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java index dd12cd22..3b6055dc 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/FlyBackController.java @@ -32,7 +32,7 @@ public class FlyBackController { private SupplierService supplierService; - //机票订单数据回推 + //机票订单数据回推d @PostMapping("/back") public LYNoteResponse ticketBack(@RequestBody NotificationFly notificationFly) { String orderSerialNo = notificationFly.getOrderDetails().getOrderSerialNo(); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 4d435a38..3b7f3ee4 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -15,6 +15,31 @@ logging: level: org.springframework.jdbc.core.JdbcTemplate: DEBUG org.springframework.jdbc.core.StatementCreatorUtils: TRACE +lYBase: + ly_app_id: "zhengtai" + ly_account: 4f9cb1080b564dd0a94aa95f7a19c8b5 # 测试appkey + ly_password: 1fD3SutgzfS48qznYQiq # 测试app秘钥 + ly_secret: WOHzCMvHd823iHgH # 测试app秘钥 + ly_base_url: https://api.qa.dttrip.cn/openapi + ly_strokepush: /api/TravelBizOrder/ExternalApproval + ly_token_path: /api/OAuth/v2/GetAccessToken + ly_order_path: /api/TravelApplyOrder/ApplyOrderSync + ly_user_path: /api/Employee/SyncEmployeeInfo + ly_login_path: /api/Employee/SSO + ly_flight_list_path: /api/DomesticFlight/GetFlightOrderList + ly_flight_detail_path: /api/DomesticFlight/GetFlightOrderDetail + ly_train_list_path: /api/Train/GetTrainOrderList + ly_train_detail_path: /api/Train/GetTrainOrderDetail + ly_hotel_list_path: /api/Hotel/GetHotelOrderList + ly_hotel_detail_path: /api/Hotel/GetHotelOrderDetail + ly_car_detail_path: /api/Car/QueryCarOrderDetailDistribution + ly_train_max_price: /api/Train/TrainHighPirceSearchByCityName + ly_fly_price: /api/DomesticFlight/CheckFlightOrderBookableStatus + ly_hotel_list: /api/Hotel/GetHotelCityList + ly_hotel_min_price: /api/Hotel/GetHotelMinPrice + + + cTrip: baseUrl: https://ct.ctrip.com