From 346fa44b270290bce3b4224fd4957aae7e14276a Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 22 Mar 2024 14:11:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=81=AB=E8=BD=A6=E5=B7=AE=E6=A0=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=B7=BB=E5=8A=A0=E5=88=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../queryies/estimate/CTripEstimatePrice.java | 9 ++- .../aggregates/standards/TrainStandards.java | 34 --------- .../standards/TrainStandardsService.java | 74 +++++++++++++++++++ .../repository/TravelStandardsRepository.java | 3 + .../infrastructure/constant/LYConstant.java | 5 ++ .../TravelStandardsRepositoryImpl.java | 14 +++- .../jdbc/JdbcTravelStandardsRepository.java | 3 +- .../response/car/CarDetailResponse.java | 3 +- 8 files changed, 104 insertions(+), 41 deletions(-) delete mode 100644 src/main/java/com/chint/domain/aggregates/standards/TrainStandards.java create mode 100644 src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java 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..03a72b9b --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java @@ -0,0 +1,74 @@ +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.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 { + public static final HashMap trainStandardsMap; + + @Autowired + private TravelStandardsRepository travelStandardsRepository; + + @PostConstruct + private void init() { + List allTrain = travelStandardsRepository.findAllTrain(); + allTrain.forEach(it -> trainStandardsMap.put(it.getStandardLevel(), it.getPrice())); + } + + public String priceTrainStandards(String standardLevel) { + 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(); + } + } + + 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); + //物联 + String oneStandardsWL = "商务座,一等座,高级软卧,一等双软,动卧,软卧,硬卧,硬座"; + String twoStandardsWL = "一等座,高级软卧,一等双软,动卧,软卧,硬卧,硬座"; + String threeStandardsWL = "一等座,二等座,二等双软,动卧,软卧,硬卧,硬座"; + String fourStandardsWL = "二等座,二等双软,软卧,无座,硬卧,硬座"; + trainStandardsMap.put(STANDARD_LEVEL_ONE_WL, oneStandardsWL); + trainStandardsMap.put(STANDARD_LEVEL_TWO_WL, twoStandardsWL); + trainStandardsMap.put(STANDARD_LEVEL_THREE_WL, threeStandardsWL); + trainStandardsMap.put(STANDARD_LEVEL_FOUR_WL, fourStandardsWL); + } +} 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/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; From d4b3faae801bb370d9b86d3d3647844be3199d81 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 22 Mar 2024 14:15:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=81=AB=E8=BD=A6=E5=B7=AE=E6=A0=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=B7=BB=E5=8A=A0=E5=88=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chint/domain/factoriy/ranks/RanksFactoryImpl.java | 1 + .../com/chint/infrastructure/constant/RankConstant.java | 9 +++++++++ 2 files changed, 10 insertions(+) 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/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 } From ae189b0ee3463a2d7ce196263ac221edbc27d2de Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 22 Mar 2024 14:25:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=81=AB=E8=BD=A6=E5=B7=AE=E6=A0=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=B7=BB=E5=8A=A0=E5=88=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../standards/TrainStandardsService.java | 76 +++++++------------ 1 file changed, 28 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java b/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java index 03a72b9b..ec1c51b7 100644 --- a/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java +++ b/src/main/java/com/chint/domain/aggregates/standards/TrainStandardsService.java @@ -5,6 +5,7 @@ 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; @@ -15,60 +16,39 @@ import static com.chint.infrastructure.constant.RankConstant.*; @Component public class TrainStandardsService { - public static final HashMap trainStandardsMap; + @Autowired private TravelStandardsRepository travelStandardsRepository; - @PostConstruct - private void init() { - List allTrain = travelStandardsRepository.findAllTrain(); - allTrain.forEach(it -> trainStandardsMap.put(it.getStandardLevel(), it.getPrice())); - } +// @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) { - 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(); - } - } - 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); - //物联 - String oneStandardsWL = "商务座,一等座,高级软卧,一等双软,动卧,软卧,硬卧,硬座"; - String twoStandardsWL = "一等座,高级软卧,一等双软,动卧,软卧,硬卧,硬座"; - String threeStandardsWL = "一等座,二等座,二等双软,动卧,软卧,硬卧,硬座"; - String fourStandardsWL = "二等座,二等双软,软卧,无座,硬卧,硬座"; - trainStandardsMap.put(STANDARD_LEVEL_ONE_WL, oneStandardsWL); - trainStandardsMap.put(STANDARD_LEVEL_TWO_WL, twoStandardsWL); - trainStandardsMap.put(STANDARD_LEVEL_THREE_WL, threeStandardsWL); - trainStandardsMap.put(STANDARD_LEVEL_FOUR_WL, fourStandardsWL); + 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(); +// } } }