From 5b8a9a3ac265d7fc9a0fd087e577f7d7181d841e Mon Sep 17 00:00:00 2001 From: lulz1 Date: Mon, 26 Feb 2024 19:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aggregates/order/ApproveOrderNo.java | 4 +- .../domain/aggregates/order/OrderDetail.java | 1 + .../chint/domain/aggregates/user/User.java | 2 + .../factoriy/order/RouteOrderFactory.java | 1 + .../CTripOrderExtensionFactoryImpl.java | 70 ++++++++++++++++++- .../domain/repository/LocationRepository.java | 2 + .../supplier/CTripOrderDataAdapter.java | 1 + .../service/supplier/SupplierServiceImpl.java | 16 ++--- .../domain/value_object/OrderLegData.java | 31 ++++++++ .../constant/OrderConstant.java | 8 +++ .../repository/LocationRepositoryImpl.java | 6 ++ .../jdbc/JdbcLocationRepository.java | 3 + .../rest/user/UserHttpRequestImpl.java | 2 + 13 files changed, 136 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/chint/domain/aggregates/order/ApproveOrderNo.java b/src/main/java/com/chint/domain/aggregates/order/ApproveOrderNo.java index cf24d0e3..4da201b3 100644 --- a/src/main/java/com/chint/domain/aggregates/order/ApproveOrderNo.java +++ b/src/main/java/com/chint/domain/aggregates/order/ApproveOrderNo.java @@ -11,8 +11,10 @@ public class ApproveOrderNo { private String sysCode; @ApiModelProperty("实际单号") private String actualOrderNo; - @ApiModelProperty("入账公司") + @ApiModelProperty("入账公司编码") private String accountCompany; + @ApiModelProperty("入账公司名称") + private String accountCompanyName; @ApiModelProperty("申请说明") private String instructions; @ApiModelProperty("财务共享订单创建人") diff --git a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java index 93b6acba..943e4206 100644 --- a/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java +++ b/src/main/java/com/chint/domain/aggregates/order/OrderDetail.java @@ -23,6 +23,7 @@ public class OrderDetail { @Id private Long orderId; // 使用 order_id 作为主键 private Long legId; // 使用行程节点关联leg + private Long routeId; private String orderNo; private String supplierName; private Integer productType; // 商品类型 diff --git a/src/main/java/com/chint/domain/aggregates/user/User.java b/src/main/java/com/chint/domain/aggregates/user/User.java index 84b357f0..bdf4f009 100644 --- a/src/main/java/com/chint/domain/aggregates/user/User.java +++ b/src/main/java/com/chint/domain/aggregates/user/User.java @@ -32,6 +32,8 @@ public class User { @Transient private String companyCode; @Transient + private String companyName; + @Transient private String workStatus; @Transient private String manaLevel; diff --git a/src/main/java/com/chint/domain/factoriy/order/RouteOrderFactory.java b/src/main/java/com/chint/domain/factoriy/order/RouteOrderFactory.java index 19c31e62..9e2cf4e6 100644 --- a/src/main/java/com/chint/domain/factoriy/order/RouteOrderFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order/RouteOrderFactory.java @@ -55,6 +55,7 @@ public class RouteOrderFactory implements OrderFactory { approveOrderNo.setSysCode(loginParam.getSyscode()); approveOrderNo.setFakeOrderNo(loginParam.getBillcode()); approveOrderNo.setAccountCompany(currentUser.getCompanyCode()); + approveOrderNo.setAccountCompanyName(currentUser.getCompanyName()); routeOrder.setApproveOrderNo(approveOrderNo); routeOrder.setBookingTime(LocalDateTime.now()); return routeOrder; 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 37f7257f..4a9d10b8 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 @@ -1,17 +1,45 @@ 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.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.hotel.HotelOrderInfoEntity; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Optional; + +import static com.chint.infrastructure.constant.OrderConstant.ORDER_DETAIL_STATUS_SUCCESS; + @Component -public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory{ +public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { + + + @Autowired + private OrderDetailRepository orderDetailRepository; + + @Autowired + private RouteRepository routeRepository; + + @Autowired + private UserRepository userRepository; + + @Autowired + private LocationRepository locationRepository; + @Override public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { + + return null; } @Override public TrainOrderDetail createTrainOrderDetail(Object trainOrderDetailData) { + return null; } @@ -22,7 +50,45 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory{ @Override public HotelOrderDetail createHotelOrderDetail(Object hotelOrderDetailData) { - return null; + + HotelOrderInfoEntity hotelOrderInfoEntity = (HotelOrderInfoEntity) hotelOrderDetailData; + String orderNo = hotelOrderInfoEntity.getOrderID(); + Optional byOrderNo = orderDetailRepository.findByOrderNo(orderNo); + String journeyNo = hotelOrderInfoEntity.getJourneyNo(); + RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo); + + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + HotelOrderDetail hotelOrderDetail = new HotelOrderDetail(); + hotelOrderDetail.setOrderNo(orderNo); //订单号 + hotelOrderDetail.setOverStandard(null); //是否超标 + hotelOrderDetail.setOrderStatus(ORDER_DETAIL_STATUS_SUCCESS); + hotelOrderDetail.setAccountCompanyId(approveOrderNo.getAccountCompany()); + hotelOrderDetail.setAccountCompanyName(approveOrderNo.getAccountCompanyName()); + hotelOrderDetail.setReceiptsNum(journeyNo); + + byOrderNo.flatMap(orderDetail -> routeOrder.getLegItems() + .stream() + .filter(it -> byOrderNo.get().getLegId().equals(it.getLegId())) + .findFirst()).ifPresent(it -> + hotelOrderDetail.setScheduleNum(it.getLegNo())); + + Long EmployeeNo = routeOrder.getUserId(); + User user = userRepository.findByUserEmployeeNo(EmployeeNo); + String cityName = hotelOrderInfoEntity.getCityName(); + hotelOrderDetail.setBookingUserCode(String.valueOf(user.getEmployeeNo())); + hotelOrderDetail.setBookingName(user.getName()); + hotelOrderDetail.setBookingUserPhone(user.getPhoneNumber()); + hotelOrderDetail.setCreateTime(hotelOrderInfoEntity.getOrderDate()); + hotelOrderDetail.setCheckInCity(cityName); + hotelOrderDetail.setHotelName(hotelOrderInfoEntity.getHotelName()); + hotelOrderDetail.setContactPhone(hotelOrderInfoEntity.getTelephone()); + hotelOrderDetail.setHotelAddress(locationRepository.locationPathByName(cityName) + + hotelOrderInfoEntity.getDistrictName() + hotelOrderInfoEntity.getAddress()); + hotelOrderDetail.setStarRate(hotelOrderInfoEntity.getStar()); + hotelOrderDetail.setCheckInDate(hotelOrderInfoEntity.getStartTime()); + hotelOrderDetail.setDepartureDate(hotelOrderInfoEntity.getEndTime()); +// hotelOrderDetail.setNightCount(hotelOrderInfoEntity.); + return hotelOrderDetail; } @Override diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index 5a85c7f9..c8034d09 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -20,4 +20,6 @@ public interface LocationRepository { List findByName(LocationParam locationParam); List findByName(String localName); + + String locationPathByName(String localName); } \ No newline at end of file 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 ae1c5401..3ba27992 100644 --- a/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java @@ -55,6 +55,7 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { Location byName = locationRepository.findByName(hotelOrderInfoEntity.getCityName()).get(0); return builder.productType(LegConstant.LEG_TYPE_HOTEL) + .hotelOrderDetailData(hotelOrderInfoEntity) .currencyCode(hotelOrderInfoEntity.getCurrency()) .orderTime(hotelOrderInfoEntity.getOrderDate()) .startTime(hotelOrderInfoEntity.getStartTime()) 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 05ec2cb4..8730bcb4 100644 --- a/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java +++ b/src/main/java/com/chint/domain/service/supplier/SupplierServiceImpl.java @@ -39,31 +39,31 @@ public class SupplierServiceImpl implements SupplierService { Optional data = orderDataAdapterSelector.of(supplierName).adapt(callbackData); if (data.isPresent()) { //获取使用RouteUpdateOrderCommand命令创建的orderDetail - Properties properties = Command.of(RouteUpdateOrderCommand.class).data(data.get()).sendToQueue(); + 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(); - Integer productType = data.get().getProductType(); + Integer productType = orderLegData.getProductType(); OrderExtensionFactory orderExtensionFactory = orderExtensionCreator .of(supplierName); - Object callbackDataData = callbackData.getData(); //根据产品的不同类型添加不同的扩展字段 switch (productType) { case LegConstant.LEG_TYPE_TRAIN -> orderDetail.addTrainOrderData( - orderExtensionFactory.createTrainOrderDetail(callbackDataData) + orderExtensionFactory.createTrainOrderDetail(orderLegData.getTrainOrderDetailData()) ); case LegConstant.LEG_TYPE_AIRPLANE -> orderDetail.addFlightOrderData( - orderExtensionFactory.createFlightOrderDetail(callbackDataData) + orderExtensionFactory.createFlightOrderDetail(orderLegData.getFlightOrderDetailData()) ); case LegConstant.LEG_TYPE_HOTEL -> orderDetail.addHotelOrderData( - orderExtensionFactory.createHotelOrderDetail(callbackDataData) + orderExtensionFactory.createHotelOrderDetail(orderLegData.getHotelOrderDetailData()) ); case LegConstant.LEG_TYPE_TAXI -> orderDetail.addCarOrderData( - orderExtensionFactory.createCarOrderDetail(callbackDataData) + orderExtensionFactory.createCarOrderDetail(orderLegData.getCarOrderDetailData()) ); case LegConstant.LEG_TYPE_OTHER -> orderDetail.addOtherOrderData( - orderExtensionFactory.createOtherOrderDetail(callbackDataData) + orderExtensionFactory.createOtherOrderDetail(orderLegData.getOtherOrderDetailData()) ); } //对orderDetail进行保存 diff --git a/src/main/java/com/chint/domain/value_object/OrderLegData.java b/src/main/java/com/chint/domain/value_object/OrderLegData.java index c1d088d6..95c66dca 100644 --- a/src/main/java/com/chint/domain/value_object/OrderLegData.java +++ b/src/main/java/com/chint/domain/value_object/OrderLegData.java @@ -47,6 +47,11 @@ public class OrderLegData { this.destinationId = builder.destinationId; this.originOrderStatus = builder.originOrderStatus; this.currencyCode = builder.currencyCode; + this.carOrderDetailData = builder.carOrderDetailData; + this.trainOrderDetailData = builder.trainOrderDetailData; + this.hotelOrderDetailData = builder.hotelOrderDetailData; + this.flightOrderDetailData = builder.flightOrderDetailData; + this.otherOrderDetailData = builder.otherOrderDetailData; } public static Builder builder() { @@ -71,10 +76,36 @@ public class OrderLegData { private Long destinationId; private String currencyCode; + private Object carOrderDetailData; + private Object trainOrderDetailData; + private Object hotelOrderDetailData; + private Object flightOrderDetailData; + private Object otherOrderDetailData; public Builder() { } + public Builder carOrderDetailData(Object carOrderDetailData) { + this.carOrderDetailData = carOrderDetailData; + return this; + } + public Builder trainOrderDetailData(Object trainOrderDetailData) { + this.trainOrderDetailData = trainOrderDetailData; + return this; + } + public Builder hotelOrderDetailData(Object hotelOrderDetailData) { + this.hotelOrderDetailData = hotelOrderDetailData; + return this; + } + public Builder flightOrderDetailData(Object flightOrderDetailData) { + this.flightOrderDetailData = flightOrderDetailData; + return this; + } + public Builder otherOrderDetailData(Object otherOrderDetailData) { + this.otherOrderDetailData = otherOrderDetailData; + return this; + } + public Builder currencyCode(String currencyCode) { this.currencyCode = currencyCode; return this; diff --git a/src/main/java/com/chint/infrastructure/constant/OrderConstant.java b/src/main/java/com/chint/infrastructure/constant/OrderConstant.java index c925f3c4..3b11952c 100644 --- a/src/main/java/com/chint/infrastructure/constant/OrderConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/OrderConstant.java @@ -20,4 +20,12 @@ public class OrderConstant { public static final String ORDER_EVENT_ETA_NAME = "超标"; public static final int ORDER_EVENT_UNKNOWN = -99; public static final String ORDER_EVENT_UNKNOWN_NAME = "未知事件"; + + + //这批字段用于 + public static final String ORDER_DETAIL_STATUS_SUCCESS = "1"; + public static final String ORDER_DETAIL_STATUS_HALF = "4"; + public static final String ORDER_EVENT_UNKNOWN_FAIL = "3"; + + } diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 3f07f92a..3e6ab08c 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -70,4 +70,10 @@ public class LocationRepositoryImpl implements LocationRepository { public List findByName(String localName) { return jdbcLocationRepository.findByLocationNameContaining(localName); } + + @Override + public String locationPathByName(String localName) { + Location byLocationName = jdbcLocationRepository.findByLocationName(localName); + return byLocationName.getLocationPathName().replace("_", "、"); + } } diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java index 3ffa3e3f..849bb9ab 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -19,5 +19,8 @@ public interface JdbcLocationRepository extends CrudRepository { Page findAllByLevel(Integer level, Pageable pageable); List findByFirstPinYin(String firstPinYin); + List findByLocationNameContaining(String locationName); + + Location findByLocationName(String locationName); } diff --git a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java index baaba1bf..55c70c0d 100644 --- a/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java +++ b/src/main/java/com/chint/interfaces/rest/user/UserHttpRequestImpl.java @@ -108,6 +108,7 @@ public class UserHttpRequestImpl implements UserHttpRequest { if (fromJson.size() == 1) { UserDataDTO userData = fromJson.get(0); user.setCompanyCode(userData.getCompany()); + user.setCompanyName(userData.getCompany_cn()); user.setWorkStatus(userData.getStatus()); user.setGender(userData.getGender()); user.setName(userData.getUname()); @@ -134,6 +135,7 @@ public class UserHttpRequestImpl implements UserHttpRequest { user.setGender(userData.getGender()); user.setName(userData.getUname()); user.setPhoneNumber(userData.getMobilePhone()); + user.setCompanyName(userData.getCompany_cn()); } ); fromJson.stream()