From c6e1cff665e4b06f41009984508afadf735492fe Mon Sep 17 00:00:00 2001 From: Superdandan <1033719135@qq.com> Date: Mon, 26 Feb 2024 22:28:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=83=A8=E5=88=86=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=98=8E=E7=BB=86=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aggregates/order/HotelOrderDetail.java | 6 +- .../order/HotelOrderDetailCustomer.java | 14 +++ .../domain/aggregates/order/OrderEvent.java | 15 ++++ .../CTripOrderExtensionFactoryImpl.java | 86 ++++++++++++++++++- .../search/hotel/HotelOrderInfoEntity.java | 2 + 5 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/chint/domain/aggregates/order/HotelOrderDetailCustomer.java 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 bff8204a..a8e396a1 100644 --- a/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetail.java @@ -3,8 +3,11 @@ package com.chint.domain.aggregates.order; import lombok.Data; import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.MappedCollection; import org.springframework.data.relational.core.mapping.Table; +import java.util.List; + @Data @Table("hotel_order_detail") public class HotelOrderDetail { @@ -105,7 +108,8 @@ public class HotelOrderDetail { private String refundAmount; // 入住人信息 - private String customers; + @MappedCollection(idColumn = "hotel_order_detail_id", keyColumn = "hotel_order_detail_key") + private List customers; // 入住人性别 private String gender; diff --git a/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetailCustomer.java b/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetailCustomer.java new file mode 100644 index 00000000..06fe7c9e --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/order/HotelOrderDetailCustomer.java @@ -0,0 +1,14 @@ +package com.chint.domain.aggregates.order; + + +import lombok.Data; +import org.springframework.data.relational.core.mapping.Table; + +@Data +@Table("hotel_order_detail") +public class HotelOrderDetailCustomer { + private Long id; + private String userName; + private String userCode; + private String phone; +} diff --git a/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java b/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java index 5409a87b..9fff299c 100644 --- a/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/OrderEvent.java @@ -40,6 +40,21 @@ public class OrderEvent { }; } + public String mapToFlightOrderDetailStatus(){ + return switch (this.eventType) { + case OrderConstant.ORDER_EVENT_PREPARE -> "0"; + case OrderConstant.ORDER_EVENT_PAYED -> "1"; + case OrderConstant.ORDER_EVENT_CHANGE -> "2"; + case OrderConstant.ORDER_EVENT_CANCEL -> "3"; + case OrderConstant.ORDER_EVENT_ORDERED -> "0"; + case OrderConstant.ORDER_EVENT_REFUND -> "3"; + case OrderConstant.ORDER_EVENT_UNKNOWN -> "0"; + case OrderConstant.ORDER_EVENT_FINISH -> "1"; + case OrderConstant.ORDER_EVENT_ETA -> "0"; + default -> "未知事件"; + }; + } + public OrderEvent reloadStatus() { this.setEventName(translateOrderEvent(this.eventType)); return this; 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 4a9d10b8..180391e2 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 @@ -6,13 +6,17 @@ import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.UserRepository; +import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity; import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.ArrayList; +import java.util.List; import java.util.Optional; import static com.chint.infrastructure.constant.OrderConstant.ORDER_DETAIL_STATUS_SUCCESS; +import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; @Component public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { @@ -45,6 +49,41 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { @Override public FlightOrderDetail createFlightOrderDetail(Object flightOrderDetailData) { + + FlightOrderInfoEntity flightOrderInfoEntity = (FlightOrderInfoEntity) flightOrderDetailData; + String orderNo = flightOrderInfoEntity.getBasicInfo().getOrderID(); + String journeyNo = flightOrderInfoEntity.getBasicInfo().getJourneyID(); + RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo); + + Optional first = routeOrder + .getOrderDetails() + .stream() + .filter(orderDetail -> orderDetail.getOrderNo().equals(orderNo)) + .findFirst(); + + FlightOrderDetail flightOrderDetail = new FlightOrderDetail(); + flightOrderDetail.setOrderNo(orderNo); + + first.ifPresent(orderDetail -> + flightOrderDetail.setOrderStatus(orderDetail.getLastEvent().mapToFlightOrderDetailStatus()) + ); + + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + flightOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany()); + flightOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName()); + flightOrderDetail.setReceiptsNum(journeyNo); + first.flatMap(orderDetail -> routeOrder.getLegItems() + .stream() + .filter(it -> first.get().getLegId().equals(it.getLegId())) + .findFirst()).ifPresent(it -> + flightOrderDetail.setScheduleNum(it.getLegNo())); + Long EmployeeNo = routeOrder.getUserId(); + User user = userRepository.findByUserEmployeeNo(EmployeeNo); + flightOrderDetail.setBookingUserCode(String.valueOf(user.getEmployeeNo())); + flightOrderDetail.setBookingName(user.getName()); + flightOrderDetail.setBookingUserPhone(user.getPhoneNumber()); + + return null; } @@ -85,9 +124,50 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { hotelOrderDetail.setHotelAddress(locationRepository.locationPathByName(cityName) + hotelOrderInfoEntity.getDistrictName() + hotelOrderInfoEntity.getAddress()); hotelOrderDetail.setStarRate(hotelOrderInfoEntity.getStar()); - hotelOrderDetail.setCheckInDate(hotelOrderInfoEntity.getStartTime()); - hotelOrderDetail.setDepartureDate(hotelOrderInfoEntity.getEndTime()); -// hotelOrderDetail.setNightCount(hotelOrderInfoEntity.); + hotelOrderDetail.setCheckInDate(hotelOrderInfoEntity.getStartTime()); //入住日期 + hotelOrderDetail.setDepartureDate(hotelOrderInfoEntity.getEndTime()); //离店日期 "2022-09-10" + hotelOrderDetail.setNightCount(hotelOrderInfoEntity.getQuantity()); //退订夜间数 + hotelOrderDetail.setRoomCount(hotelOrderInfoEntity.getQuantity()); //退订夜间数 + hotelOrderDetail.setRoomTypeName(hotelOrderInfoEntity.getRoomName()); //房型 + hotelOrderDetail.setPaymentType("1"); //付款方式 0:公司统付1:个人付 2:混付 + + if (Double.parseDouble(hotelOrderInfoEntity.getSettlementACCNTAmt()) > 0) { + hotelOrderDetail.setCompanyAmount(hotelOrderInfoEntity.getSettlementACCNTAmt()); + hotelOrderDetail.setCompanyRefundAmount(KEEP_TWO_DECIMAL_ZERO); + } else { + //如果公司统付为负数, 那么表示退款 + hotelOrderDetail.setCompanyAmount(KEEP_TWO_DECIMAL_ZERO); + hotelOrderDetail.setCompanyRefundAmount(hotelOrderInfoEntity.getSettlementACCNTAmt()); + } + + if (Double.parseDouble(hotelOrderInfoEntity.getSettlementPersonAmt()) > 0) { + hotelOrderDetail.setPersonalAmount(hotelOrderInfoEntity.getSettlementPersonAmt()); + hotelOrderDetail.setPersonalRefundAmount(KEEP_TWO_DECIMAL_ZERO); + } else { + hotelOrderDetail.setPersonalAmount(KEEP_TWO_DECIMAL_ZERO); + hotelOrderDetail.setPersonalRefundAmount(hotelOrderInfoEntity.getSettlementPersonAmt()); + } + + if (Double.parseDouble(hotelOrderInfoEntity.getAmount()) > 0) { + hotelOrderDetail.setOrderAmount(hotelOrderInfoEntity.getAmount()); + hotelOrderDetail.setRefundAmount(KEEP_TWO_DECIMAL_ZERO); + } else { + hotelOrderDetail.setOrderAmount(KEEP_TWO_DECIMAL_ZERO); + hotelOrderDetail.setRefundAmount(hotelOrderInfoEntity.getAmount()); + } + + hotelOrderDetail.setPreServiceFee(hotelOrderInfoEntity.getFrontendServiceFee()); + hotelOrderDetail.setPostServiceFee(hotelOrderInfoEntity.getServicefee()); + + List customers = new ArrayList<>(); + HotelOrderDetailCustomer hotelOrderDetailCustomer = new HotelOrderDetailCustomer(); + hotelOrderDetailCustomer.setUserCode(user.getEmployeeNo().toString()); + hotelOrderDetailCustomer.setUserName(user.getName()); + hotelOrderDetailCustomer.setPhone(user.getPhoneNumber()); + customers.add(hotelOrderDetailCustomer); + hotelOrderDetail.setCustomers(customers); + + hotelOrderDetail.setSupplier(routeOrder.getSupplierCNName() + "预定"); return hotelOrderDetail; } diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/hotel/HotelOrderInfoEntity.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/hotel/HotelOrderInfoEntity.java index 66ce04e1..82b99d30 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/hotel/HotelOrderInfoEntity.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/search/hotel/HotelOrderInfoEntity.java @@ -66,6 +66,8 @@ public class HotelOrderInfoEntity { private String HotelConfirmNo; // 酒店确认号 private String JourneyNo; // 旅程编号 private String CostCenter; // 成本中心 + private String Quantity; //夜间数量 + private String Servicefee; // 后续字段含义类似,可根据实际情况添加注释 private List ClientInfo; // 客户信息列表 }