diff --git a/src/main/java/com/chint/application/out/OrderDetailController.java b/src/main/java/com/chint/application/out/OrderDetailController.java index 11a52722..3de92011 100644 --- a/src/main/java/com/chint/application/out/OrderDetailController.java +++ b/src/main/java/com/chint/application/out/OrderDetailController.java @@ -178,8 +178,8 @@ public class OrderDetailController { trainOrderDetail.setDetailId(newOrderNo); trainOrderDetail.setCreateTime(command.getCreateTime()); trainOrderDetail.setId(null); - if(trainOrderDetail.getSupplier().equals(SUPPLIER_L_Y_EXTENSION_NAME)){ - orderExtensionCreator.of(SUPPLIER_L_Y).updateTrainOrderDetailData(trainOrderDetail,command.getOrderInfo()); + if (trainOrderDetail.getSupplier().equals(SUPPLIER_L_Y_EXTENSION_NAME)) { + orderExtensionCreator.of(SUPPLIER_L_Y).updateTrainOrderDetailData(trainOrderDetail, command.getOrderInfo()); } } if (productType == 1) { @@ -211,7 +211,7 @@ public class OrderDetailController { newCustomers.add(customer); } hotelOrderDetail.setCustomers(newCustomers); - if(hotelOrderDetail.getSupplier().equals(SUPPLIER_L_Y_EXTENSION_NAME)){ + if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y_CN_NAME) && hotelOrderDetail.getSupplier().equals(SUPPLIER_L_Y_EXTENSION_NAME)) { orderExtensionCreator.of(SUPPLIER_L_Y).updateHotelOrderDetailData(hotelOrderDetail, command.getOrderInfo()); } } diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index b696e541..ab734322 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -16,7 +16,10 @@ public interface LocationRepository { List findAll(); - Location findByCityId(Long cityId); + Location findByCityIdAndLevelThree(Long cityId); + + Location findByCityIdAndLevelFour(Long cityId); + List findAllLevelThreeAndFour(); 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 c60b941f..fe1850c0 100644 --- a/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/CTripOrderDataAdapter.java @@ -56,7 +56,13 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { if (hotelOrderInfoList != null && hotelOrderInfoList.size() == 1) { HotelOrderInfoEntity hotelOrderInfoEntity = hotelOrderInfoList.get(0); - Location byName = locationRepository.findByCityId(Long.valueOf(hotelOrderInfoEntity.getCityID())); + + Location location = getLocationId(hotelOrderInfoEntity.getCityName(), + Long.valueOf(hotelOrderInfoEntity.getCityID())); + Long originId = null; + if (location != null) { + originId = location.getLocationId(); + } String currency = hotelOrderInfoEntity.getCurrency(); if (currency == null) { @@ -68,8 +74,8 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { .orderTime(hotelOrderInfoEntity.getOrderDate()) .startTime(hotelOrderInfoEntity.getStartTime()) .endTime(hotelOrderInfoEntity.getEndTime()) - .originId(byName.getLocationId()) - .destinationId(byName.getLocationId()) + .originId(originId) + .destinationId(originId) .selfOrderNo(hotelOrderInfoEntity.getJourneyNo()) .outOrderNo(hotelOrderInfoEntity.getOrderID()) .orderStatus(translateHotelOrderStatus(hotelOrderInfoEntity.getOrderDetailStatus())) @@ -93,7 +99,6 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { originId = listByCityName.get(0).getLocationId(); } - Long destinationId; List arriveLocation = locationRepository.findListByCityName(flightInfo.getACityName()); if (arriveLocation == null || arriveLocation.isEmpty()) { @@ -138,8 +143,19 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { CarQuickOrderInfoEntity carOrderInfo = carOrderInfoList.get(0); OrderProduct orderProduct = carOrderInfo.getOrderProduct(); CarBasicInfo carBasicInfo = carOrderInfo.getBasicInfo(); - Location departCityName = locationRepository.findByCityId(Long.valueOf(orderProduct.getDepartAddress().getCityId())); - Location arriveCityName = locationRepository.findByCityId(Long.valueOf(orderProduct.getArriveAddress().getCityId())); + + + Long departCityId = Long.valueOf(orderProduct.getDepartAddress().getCityId()); + Location departCityName = locationRepository.findByCityIdAndLevelThree(departCityId); + if(departCityName == null){ + departCityName = locationRepository.findByCityIdAndLevelFour(departCityId); + } + + Long arriveCityId = Long.valueOf(orderProduct.getArriveAddress().getCityId()); + Location arriveCityName = locationRepository.findByCityIdAndLevelThree(arriveCityId); + if(arriveCityName == null){ + arriveCityName = locationRepository.findByCityIdAndLevelFour(arriveCityId); + } return builder.productType(LegConstant.LEG_TYPE_TAXI) .carOrderDetailData(carOrderInfo) .currencyCode(CurrencyType.RENMINBI.getCode()) @@ -160,6 +176,17 @@ public class CTripOrderDataAdapter implements OrderDataAdapter { return null; } + private Location getLocationId(String cityName, Long cityId) { + Location byName = locationRepository.findByCityIdAndLevelThree(cityId); + if (byName == null) { + List listByCityName = locationRepository.findListByCityName(cityName); + if (listByCityName != null && !listByCityName.isEmpty()) { + byName = listByCityName.get(0); + } + } + return byName; + } + private Integer translateTrainOrderStatus(String trainOrderStatus) { return switch (trainOrderStatus) { case "N" -> OrderConstant.ORDER_EVENT_PREPARE; //未提交 diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 674b9f21..e83290f1 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -18,6 +18,7 @@ import java.util.List; import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_AIRPLANE; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_CITY; +import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_COUNTY; @Repository public class LocationRepositoryImpl implements LocationRepository { @@ -65,10 +66,15 @@ public class LocationRepositoryImpl implements LocationRepository { } @Override - public Location findByCityId(Long cityId) { + public Location findByCityIdAndLevelThree(Long cityId) { return jdbcLocationRepository.findByCityIdAndLevel(cityId, LOCATION_TYPE_CITY); } + @Override + public Location findByCityIdAndLevelFour(Long cityId) { + return jdbcLocationRepository.findByCityIdAndLevel(cityId, LOCATION_TYPE_COUNTY); + } + @Override public List findAllLevelThreeAndFour() { return jdbcLocationRepository.findByLevelOrLevel(3, 4);