火车差标配置添加到数据库维护

This commit is contained in:
lulz1 2024-03-22 14:11:26 +08:00
parent 103d5a44f3
commit 346fa44b27
8 changed files with 104 additions and 41 deletions

View File

@ -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.Location;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.standards.CityTag; 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.aggregates.user.User;
import com.chint.domain.exceptions.LocationException; import com.chint.domain.exceptions.LocationException;
import com.chint.domain.repository.*; import com.chint.domain.repository.*;
@ -34,7 +35,6 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.regex.Pattern; 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.LEG_LOCATION_SAME_ERROR;
import static com.chint.infrastructure.constant.CommonMessageConstant.NO_PRICE_ERROR; import static com.chint.infrastructure.constant.CommonMessageConstant.NO_PRICE_ERROR;
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_COUNTY; import static com.chint.infrastructure.constant.LocationConstant.LOCATION_TYPE_COUNTY;
@ -65,6 +65,9 @@ public class CTripEstimatePrice implements EstimatePrice {
@Autowired @Autowired
private RouteRepository routeRepository; private RouteRepository routeRepository;
@Autowired
private TrainStandardsService trainStandardsService;
@Override @Override
public TrainPriceData queryTrainPrice(PriceQueryData priceQueryData) { public TrainPriceData queryTrainPrice(PriceQueryData priceQueryData) {
checkPriceQueryData(priceQueryData); checkPriceQueryData(priceQueryData);
@ -122,7 +125,7 @@ public class CTripEstimatePrice implements EstimatePrice {
}); });
//根据差标等级获取可报销最大火车金额 //根据差标等级获取可报销最大火车金额
String trainStandards = trainStandardsMap.get(standardLevel);//获取可报销座位 String trainStandards = trainStandardsService.priceTrainStandards(standardLevel);//获取可报销座位
Optional<String> optional = trainPriceData.getSeatInfoList().stream() Optional<String> optional = trainPriceData.getSeatInfoList().stream()
.filter(seatInfo -> { .filter(seatInfo -> {
Pattern pattern = Pattern.compile("\\b" + seatInfo.getSeatName() + "\\b"); Pattern pattern = Pattern.compile("\\b" + seatInfo.getSeatName() + "\\b");
@ -254,7 +257,7 @@ public class CTripEstimatePrice implements EstimatePrice {
HotelValuationResult hotelValuationResult = estimate.getData().getHotelValuationResult(); HotelValuationResult hotelValuationResult = estimate.getData().getHotelValuationResult();
String price = hotelValuationResult.getMaxPrice().toString(); String price = hotelValuationResult.getMaxPrice().toString();
if(Double.parseDouble(price) == 0){ if (Double.parseDouble(price) == 0) {
hotelPriceData.setSuccess(false); hotelPriceData.setSuccess(false);
return hotelPriceData; return hotelPriceData;
} }

View File

@ -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<String, String> 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);
}
}

View File

@ -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<String, String> trainStandardsMap;
@Autowired
private TravelStandardsRepository travelStandardsRepository;
@PostConstruct
private void init() {
List<TravelStandards> 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<TravelStandards> 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);
}
}

View File

@ -10,7 +10,10 @@ import java.util.List;
public interface TravelStandardsRepository { public interface TravelStandardsRepository {
TravelStandards save(TravelStandards travelStandards); TravelStandards save(TravelStandards travelStandards);
void saveAll(List<TravelStandards> travelStandardsList); void saveAll(List<TravelStandards> travelStandardsList);
List<TravelStandards> findAllTrain();
List<TravelStandards> findByStandardLevel(String standardLevel); List<TravelStandards> findByStandardLevel(String standardLevel);
List<TravelStandards> findByStandardLevelAndProductType(String standardLevel, String productType);
List<TravelStandards> findByTravelStandards(TravelStandards travelStandards); List<TravelStandards> findByTravelStandards(TravelStandards travelStandards);

View File

@ -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_CAR = 6; //用车
public static final int L_Y_PRODUCT_TYPE_HOTEL = 3; //酒店 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_NOTIFY_COMMON = 1; //酒店
// public static final int L_Y_PRODUCT_TYPE_HOTEL = 3; //酒店 // public static final int L_Y_PRODUCT_TYPE_HOTEL = 3; //酒店

View File

@ -1,15 +1,15 @@
package com.chint.infrastructure.repository; package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.standards.Ranks;
import com.chint.domain.aggregates.standards.TravelStandards; import com.chint.domain.aggregates.standards.TravelStandards;
import com.chint.domain.repository.TravelStandardsRepository; import com.chint.domain.repository.TravelStandardsRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRanksRepository;
import com.chint.infrastructure.repository.jdbc.JdbcTravelStandardsRepository; import com.chint.infrastructure.repository.jdbc.JdbcTravelStandardsRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TRAIN;
@Repository @Repository
public class TravelStandardsRepositoryImpl implements TravelStandardsRepository { public class TravelStandardsRepositoryImpl implements TravelStandardsRepository {
@ -26,11 +26,21 @@ public class TravelStandardsRepositoryImpl implements TravelStandardsRepository
jdbcTravelStandardsRepository.saveAll(travelStandardsList); jdbcTravelStandardsRepository.saveAll(travelStandardsList);
} }
@Override
public List<TravelStandards> findAllTrain() {
return jdbcTravelStandardsRepository.findByProductType(String.valueOf(LEG_TYPE_TRAIN));
}
@Override @Override
public List<TravelStandards> findByStandardLevel(String standardLevel) { public List<TravelStandards> findByStandardLevel(String standardLevel) {
return jdbcTravelStandardsRepository.findByStandardLevel(standardLevel); return jdbcTravelStandardsRepository.findByStandardLevel(standardLevel);
} }
@Override
public List<TravelStandards> findByStandardLevelAndProductType(String standardLevel, String productType) {
return jdbcTravelStandardsRepository.findByStandardLevelAndProductType(standardLevel, productType);
}
@Override @Override
public List<TravelStandards> findByTravelStandards(TravelStandards travelStandards) { public List<TravelStandards> findByTravelStandards(TravelStandards travelStandards) {
return jdbcTravelStandardsRepository.findByProductTypeAndStandardLevelAndCityTag( return jdbcTravelStandardsRepository.findByProductTypeAndStandardLevelAndCityTag(

View File

@ -9,7 +9,8 @@ import java.util.List;
@Repository @Repository
public interface JdbcTravelStandardsRepository extends CrudRepository<TravelStandards, Integer> { public interface JdbcTravelStandardsRepository extends CrudRepository<TravelStandards, Integer> {
List<TravelStandards> findByProductType(String productType);
List<TravelStandards> findByStandardLevel(String standardLevel); List<TravelStandards> findByStandardLevel(String standardLevel);
List<TravelStandards> findByProductTypeAndStandardLevelAndCityTag(String productType,String standardLevel,String cityTag); List<TravelStandards> findByProductTypeAndStandardLevelAndCityTag(String productType,String standardLevel,String cityTag);
List<TravelStandards> findByStandardLevelAndProductType(String standardLevel, String productType);
} }

View File

@ -1,6 +1,7 @@
package com.chint.interfaces.rest.ly.dto.search.response.car; 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.LYBaseResponse;
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@ -13,7 +14,7 @@ public class CarDetailResponse extends LYBaseResponse {
@Data @Data
public static class DataWrapper { public static class DataWrapper {
private CarOrderDetailInfo carOrderDetailInfo; private CarOrderDetailInfo carOrderDetailInfo;
private List<Object> priceDetailList; private List<PriceDetail> priceDetailList;
private OrderExtendInfo orderExtendInfo; private OrderExtendInfo orderExtendInfo;
private OrderDriverInfo orderDriverInfo; private OrderDriverInfo orderDriverInfo;
private TravelDataInfo travelDataInfo; private TravelDataInfo travelDataInfo;