diff --git a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java index 2846b9ec..c3d04362 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -5,6 +5,7 @@ import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEnti import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.standards.CityTag; +import com.chint.domain.aggregates.standards.TrainStandardsService; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.LocationException; import com.chint.domain.repository.*; @@ -34,7 +35,6 @@ import java.util.List; import java.util.Optional; import java.util.regex.Pattern; -import static com.chint.domain.aggregates.standards.TrainStandards.trainStandardsMap; import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_LOCATION_SAME_ERROR; import static com.chint.infrastructure.constant.CommonMessageConstant.NO_PRICE_ERROR; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_COUNTY; @@ -65,6 +65,9 @@ public class CTripEstimatePrice implements EstimatePrice { @Autowired private RouteRepository routeRepository; + @Autowired + private TrainStandardsService trainStandardsService; + @Override public TrainPriceData queryTrainPrice(PriceQueryData priceQueryData) { checkPriceQueryData(priceQueryData); @@ -122,7 +125,7 @@ public class CTripEstimatePrice implements EstimatePrice { }); //根据差标等级获取可报销最大火车金额 - String trainStandards = trainStandardsMap.get(standardLevel);//获取可报销座位 + String trainStandards = trainStandardsService.priceTrainStandards(standardLevel);//获取可报销座位 Optional optional = trainPriceData.getSeatInfoList().stream() .filter(seatInfo -> { Pattern pattern = Pattern.compile("\\b" + seatInfo.getSeatName() + "\\b"); @@ -254,7 +257,7 @@ public class CTripEstimatePrice implements EstimatePrice { HotelValuationResult hotelValuationResult = estimate.getData().getHotelValuationResult(); String price = hotelValuationResult.getMaxPrice().toString(); - if(Double.parseDouble(price) == 0){ + if (Double.parseDouble(price) == 0) { hotelPriceData.setSuccess(false); return hotelPriceData; } diff --git a/src/main/java/com/chint/domain/aggregates/standards/TrainStandards.java b/src/main/java/com/chint/domain/aggregates/standards/TrainStandards.java deleted file mode 100644 index ac58c559..00000000 --- a/src/main/java/com/chint/domain/aggregates/standards/TrainStandards.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.chint.domain.aggregates.standards; - - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static com.chint.infrastructure.constant.RankConstant.*; - -public class TrainStandards { - public static final HashMap trainStandardsMap; - - static { - trainStandardsMap = new HashMap<>(); - //集团 - String oneStandards = "商务座,一等双软,一等座,二等座,高级软卧,一等双软"; - String twoStandards = "一等座,高级软卧,一等双软,动卧,软卧,硬卧,硬座"; - String threeStandards = "一等座,一等双软,二等座,软卧,硬卧,硬座"; - String fourStandards = "二等座,二等双软,软卧,无座,硬卧,硬座"; - trainStandardsMap.put(STANDARD_LEVEL_ONE, oneStandards); - trainStandardsMap.put(STANDARD_LEVEL_TWO, twoStandards); - trainStandardsMap.put(STANDARD_LEVEL_THREE, threeStandards); - trainStandardsMap.put(STANDARD_LEVEL_FOUR, fourStandards); - //仪表 - String oneStandardsYB = "一等座,高级软卧,一等双软,动卧,软卧,硬卧,硬座"; - String twoStandardsYB = "一等座,高级软卧,一等双软,动卧,软卧,硬卧,硬座"; - String threeStandardsYB = "一等座,一等双软,二等座,软卧,硬卧,硬座"; - String fourStandardsYB = "二等座,二等双软,软卧,无座,硬卧,硬座"; - trainStandardsMap.put(STANDARD_LEVEL_ONE_YB, oneStandardsYB); - trainStandardsMap.put(STANDARD_LEVEL_TWO_YB, twoStandardsYB); - trainStandardsMap.put(STANDARD_LEVEL_THREE_YB, threeStandardsYB); - trainStandardsMap.put(STANDARD_LEVEL_FOUR_YB, fourStandardsYB); - } -} diff --git a/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java b/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java new file mode 100644 index 00000000..ec1c51b7 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java @@ -0,0 +1,54 @@ +package com.chint.domain.aggregates.standards; + + +import com.chint.domain.exceptions.NotFoundException; +import com.chint.domain.repository.TravelStandardsRepository; +import jakarta.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.List; + +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TRAIN; +import static com.chint.infrastructure.constant.RankConstant.*; + +@Component +public class TrainStandardsService { + + + @Autowired + private TravelStandardsRepository travelStandardsRepository; + +// @PostConstruct +// private void init() { +// List allTrain = travelStandardsRepository.findAllTrain(); +// allTrain.forEach(it -> trainStandardsMap.put(it.getStandardLevel(), it.getPrice())); +// } + + @Cacheable(value = "TrainStandards" , key = "#standardLevel") + public String priceTrainStandards(String standardLevel) { + + List byStandardLevelAndProductType = travelStandardsRepository. + findByStandardLevelAndProductType(standardLevel, String.valueOf(LEG_TYPE_TRAIN)); + if (byStandardLevelAndProductType.isEmpty()) { + throw new NotFoundException("火车相关差标未配置,请联系管理员"); + } + TravelStandards travelStandards = byStandardLevelAndProductType.get(0); + return travelStandards.getPrice(); + +// if (trainStandardsMap.containsKey(standardLevel)) { +// return trainStandardsMap.get(standardLevel); +// } else { +// List byStandardLevelAndProductType = travelStandardsRepository. +// findByStandardLevelAndProductType(standardLevel, String.valueOf(LEG_TYPE_TRAIN)); +// if (byStandardLevelAndProductType.isEmpty()) { +// throw new NotFoundException("火车相关差标未配置,请联系管理员"); +// } +// TravelStandards travelStandards = byStandardLevelAndProductType.get(0); +// trainStandardsMap.put(travelStandards.getStandardLevel(), travelStandards.getPrice()); +// return travelStandards.getPrice(); +// } + } +} diff --git a/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java index decaedd2..489133ba 100644 --- a/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/ranks/RanksFactoryImpl.java @@ -25,6 +25,7 @@ public class RanksFactoryImpl implements RanksFactory { String prefix = switch (ranksData.getCompanyCode()) { case JT_COMPANY_CODE -> STANDARD_LEVEL_JT; case STANDARD_LEVEL_YB_CODE -> STANDARD_LEVEL_YB; + case STANDARD_LEVEL_WL_CODE -> STANDARD_LEVEL_WL; // case STANDARD_LEVEL_SZKJ_CODE -> STANDARD_LEVEL_SZKJ; case STANDARD_LEVEL_SDZN_CODE -> STANDARD_LEVEL_SDZN; // case STANDARD_LEVEL_DQXS_CODE -> STANDARD_LEVEL_DQXS; diff --git a/src/main/java/com/chint/domain/repository/TravelStandardsRepository.java b/src/main/java/com/chint/domain/repository/TravelStandardsRepository.java index 702b2b0c..b0844ad6 100644 --- a/src/main/java/com/chint/domain/repository/TravelStandardsRepository.java +++ b/src/main/java/com/chint/domain/repository/TravelStandardsRepository.java @@ -10,7 +10,10 @@ import java.util.List; public interface TravelStandardsRepository { TravelStandards save(TravelStandards travelStandards); void saveAll(List travelStandardsList); + + List findAllTrain(); List findByStandardLevel(String standardLevel); + List findByStandardLevelAndProductType(String standardLevel, String productType); List findByTravelStandards(TravelStandards travelStandards); diff --git a/src/main/java/com/chint/infrastructure/constant/LYConstant.java b/src/main/java/com/chint/infrastructure/constant/LYConstant.java index 76ad4711..dc914e44 100644 --- a/src/main/java/com/chint/infrastructure/constant/LYConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LYConstant.java @@ -46,6 +46,11 @@ public class LYConstant { public static final int L_Y_PRODUCT_TYPE_CAR = 6; //用车 public static final int L_Y_PRODUCT_TYPE_HOTEL = 3; //酒店 + public static final int L_Y_CAR_FEE_TYPE_START = 1; //起步费 + public static final int L_Y_CAR_FEE_TYPE_MILE = 2; //里程费 + public static final int L_Y_CAR_FEE_TYPE_TIME= 3; //时长费 + public static final int L_Y_CAR_FEE_TYPE_CANCEL = 4; //取消费 + //同程订单推送类型 // public static final int L_Y_NOTIFY_COMMON = 1; //酒店 // public static final int L_Y_PRODUCT_TYPE_HOTEL = 3; //酒店 diff --git a/src/main/java/com/chint/infrastructure/constant/RankConstant.java b/src/main/java/com/chint/infrastructure/constant/RankConstant.java index 8718e62c..a44aa63d 100644 --- a/src/main/java/com/chint/infrastructure/constant/RankConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/RankConstant.java @@ -7,7 +7,9 @@ public class RankConstant { public static final String XN_COMPANY_CODE = "A70000056";//新能编号 public static final String STANDARD_LEVEL_JT = "JT_";//正泰集团股份有限公司 public static final String STANDARD_LEVEL_YB_CODE = "A10160001";//仪表编号 + public static final String STANDARD_LEVEL_WL_CODE = "A70000059";//仪表编号 public static final String STANDARD_LEVEL_YB = "YB_";//浙江正泰仪器仪表有限责任公司 + public static final String STANDARD_LEVEL_WL = "WL_";//浙江正泰仪器仪表有限责任公司 public static final String STANDARD_LEVEL_SZKJ_CODE = "";//数智科技编号 public static final String STANDARD_LEVEL_SZKJ = "SZKJ_";//数智科技 public static final String STANDARD_LEVEL_SDZN_CODE = "A70000067";//山东智能编号 @@ -39,4 +41,11 @@ public class RankConstant { public static final String STANDARD_LEVEL_TWO_YB = "YB_STANDARD_LEVEL_TWO";//差标2 public static final String STANDARD_LEVEL_THREE_YB = "YB_STANDARD_LEVEL_THREE";//差标3 public static final String STANDARD_LEVEL_FOUR_YB = "YB_STANDARD_LEVEL_FOUR";//差标4 + + + //物联 + public static final String STANDARD_LEVEL_ONE_WL = "WL_STANDARD_LEVEL_ONE";//差标1 + public static final String STANDARD_LEVEL_TWO_WL = "WL_STANDARD_LEVEL_TWO";//差标2 + public static final String STANDARD_LEVEL_THREE_WL = "WL_STANDARD_LEVEL_THREE";//差标3 + public static final String STANDARD_LEVEL_FOUR_WL = "WL_STANDARD_LEVEL_FOUR";//差标4 } diff --git a/src/main/java/com/chint/infrastructure/repository/TravelStandardsRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/TravelStandardsRepositoryImpl.java index 12ce94fb..c81448d4 100644 --- a/src/main/java/com/chint/infrastructure/repository/TravelStandardsRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/TravelStandardsRepositoryImpl.java @@ -1,15 +1,15 @@ package com.chint.infrastructure.repository; -import com.chint.domain.aggregates.standards.Ranks; import com.chint.domain.aggregates.standards.TravelStandards; import com.chint.domain.repository.TravelStandardsRepository; -import com.chint.infrastructure.repository.jdbc.JdbcRanksRepository; import com.chint.infrastructure.repository.jdbc.JdbcTravelStandardsRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.List; +import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TRAIN; + @Repository public class TravelStandardsRepositoryImpl implements TravelStandardsRepository { @@ -26,11 +26,21 @@ public class TravelStandardsRepositoryImpl implements TravelStandardsRepository jdbcTravelStandardsRepository.saveAll(travelStandardsList); } + @Override + public List findAllTrain() { + return jdbcTravelStandardsRepository.findByProductType(String.valueOf(LEG_TYPE_TRAIN)); + } + @Override public List findByStandardLevel(String standardLevel) { return jdbcTravelStandardsRepository.findByStandardLevel(standardLevel); } + @Override + public List findByStandardLevelAndProductType(String standardLevel, String productType) { + return jdbcTravelStandardsRepository.findByStandardLevelAndProductType(standardLevel, productType); + } + @Override public List findByTravelStandards(TravelStandards travelStandards) { return jdbcTravelStandardsRepository.findByProductTypeAndStandardLevelAndCityTag( diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcTravelStandardsRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcTravelStandardsRepository.java index 889aacd5..e9b927f5 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcTravelStandardsRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcTravelStandardsRepository.java @@ -9,7 +9,8 @@ import java.util.List; @Repository public interface JdbcTravelStandardsRepository extends CrudRepository { - + List findByProductType(String productType); List findByStandardLevel(String standardLevel); List findByProductTypeAndStandardLevelAndCityTag(String productType,String standardLevel,String cityTag); + List findByStandardLevelAndProductType(String standardLevel, String productType); } diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java index fc38cbf8..ca07280a 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java @@ -1,6 +1,7 @@ package com.chint.interfaces.rest.ly.dto.search.response.car; import com.chint.interfaces.rest.ly.dto.LYBaseResponse; +import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail; import lombok.Data; import java.util.List; @@ -13,7 +14,7 @@ public class CarDetailResponse extends LYBaseResponse { @Data public static class DataWrapper { private CarOrderDetailInfo carOrderDetailInfo; - private List priceDetailList; + private List priceDetailList; private OrderExtendInfo orderExtendInfo; private OrderDriverInfo orderDriverInfo; private TravelDataInfo travelDataInfo;