diff --git a/src/main/java/com/chint/application/out/OrderOutController.java b/src/main/java/com/chint/application/out/OrderOutController.java index 169e6946..b3a4f215 100644 --- a/src/main/java/com/chint/application/out/OrderOutController.java +++ b/src/main/java/com/chint/application/out/OrderOutController.java @@ -9,10 +9,7 @@ import com.chint.application.dtos.trip.TripCallback; import com.chint.application.queryies.OrderQuery; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.user.User; -import com.chint.domain.value_object.FlightPriceData; -import com.chint.domain.value_object.OrderQueryData; -import com.chint.domain.value_object.PriceQueryData; -import com.chint.domain.value_object.TrainPriceData; +import com.chint.domain.value_object.*; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.Result; @@ -80,6 +77,12 @@ public class OrderOutController { public Result estimateFlightPrice(@RequestBody PriceQueryData priceQueryData) { return Result.Success(SUCCESS, orderQuery.queryFlightPrice(priceQueryData)); } + @ApiOperation("查询酒店估算价格") + @PostMapping("/estimate/hotel") + public Result estimateHotelPrice(@RequestBody PriceQueryData priceQueryData) { + return Result.Success(SUCCESS, orderQuery.queryHotelPrice(priceQueryData)); + } + @ApiOperation("根据Id查询行程规划单-元年数据") @PostMapping("/query/tripCallback") diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 61160e3d..6b171f38 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -14,10 +14,7 @@ import com.chint.domain.repository.CityRepository; import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.UserRepository; import com.chint.domain.service.OrderDomainService; -import com.chint.domain.value_object.FlightPriceData; -import com.chint.domain.value_object.OrderQueryData; -import com.chint.domain.value_object.PriceQueryData; -import com.chint.domain.value_object.TrainPriceData; +import com.chint.domain.value_object.*; import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.PageResult; import org.springframework.beans.factory.annotation.Autowired; @@ -98,6 +95,10 @@ public class OrderQuery { return estimatePrice.queryFlightPrice(priceQueryData); } + public HotelPriceData queryHotelPrice(PriceQueryData priceQueryData) { + return estimatePrice.queryHotelPrice(priceQueryData); + } + public TripCallback queryTripCallbackData(OrderQueryData queryData) { User currentUser = BaseContext.getCurrentUser(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 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 5d04aa05..3925ff6f 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -1,22 +1,28 @@ package com.chint.application.queryies.estimate; +import com.chint.domain.aggregates.standards.CityTag; +import com.chint.domain.aggregates.standards.Ranks; +import com.chint.domain.aggregates.standards.TravelStandards; +import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.CityRepository; -import com.chint.domain.value_object.FlightPriceData; -import com.chint.domain.value_object.PriceQueryData; -import com.chint.domain.value_object.TrainPriceData; +import com.chint.domain.repository.RanksRepository; +import com.chint.domain.repository.TravelStandardsRepository; +import com.chint.domain.value_object.*; +import com.chint.infrastructure.util.BaseContext; import com.chint.interfaces.rest.ctrip.CTripEstimateRequest; -import com.chint.interfaces.rest.ctrip.dto.estimate.request.BookingRelatedApiRequest; -import com.chint.interfaces.rest.ctrip.dto.estimate.request.FlightProductInfo; -import com.chint.interfaces.rest.ctrip.dto.estimate.request.RouteInfo; -import com.chint.interfaces.rest.ctrip.dto.estimate.request.TrainProductInfo; +import com.chint.interfaces.rest.ctrip.dto.estimate.request.*; import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiResponse; import com.chint.interfaces.rest.ctrip.dto.estimate.response.CTripSeatType; import com.chint.interfaces.rest.ctrip.dto.estimate.response.TrainValuationResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.HashMap; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; + +import static com.chint.infrastructure.constant.Constant.LEG_TYPE_HOTEL; @Component public class CTripEstimatePrice implements EstimatePrice { @@ -26,6 +32,9 @@ public class CTripEstimatePrice implements EstimatePrice { @Autowired private CityRepository cityRepository; + @Autowired + private TravelStandardsRepository travelStandardsRepository; + @Override public TrainPriceData queryTrainPrice(PriceQueryData priceQueryData) { TrainProductInfo trainProductInfo = new TrainProductInfo(); @@ -84,4 +93,39 @@ public class CTripEstimatePrice implements EstimatePrice { }); return flightPriceData; } + + /** + * 查询酒店价格 + */ + @Override + public HotelPriceData queryHotelPrice(PriceQueryData priceQueryData) { + //1.获取该用户的差标 + User user = BaseContext.getCurrentUser();//用户 + String standardLevel = user.getStandardLevel();//差旅等级 + //查询差旅标准 + List travelStandardsList = travelStandardsRepository.findByStandardLevel(standardLevel); + //2.过滤出酒店的差标 + List travelStandards = travelStandardsList.stream() + .filter(o -> String.valueOf(LEG_TYPE_HOTEL).equals(o.getProductType()) //酒店 + && cityCategory(priceQueryData.getDepartCity()).equals(o.getCityTag()))//3.根据城市确认具体金额 + .toList(); + HotelPriceData hotelPriceData = new HotelPriceData(); + if (travelStandards.size() == 1) { + String price = travelStandards.get(0).getPrice(); + hotelPriceData.setSuccess(true); + hotelPriceData.setMaxPrice(price); + } else { + hotelPriceData.setSuccess(false); + hotelPriceData.setMaxPrice("无估算价格"); + } + return hotelPriceData; + } + + /** + * 判断类型 + */ + public String cityCategory(String city) { + HashMap cityMap = CityTag.cityMap; + return cityMap.get(city) == null ? "2" : cityMap.get(city);//"2":代表其它城市 + } } diff --git a/src/main/java/com/chint/application/queryies/estimate/EstimatePrice.java b/src/main/java/com/chint/application/queryies/estimate/EstimatePrice.java index 7cc9c2a9..a3233583 100644 --- a/src/main/java/com/chint/application/queryies/estimate/EstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/EstimatePrice.java @@ -1,6 +1,7 @@ package com.chint.application.queryies.estimate; import com.chint.domain.value_object.FlightPriceData; +import com.chint.domain.value_object.HotelPriceData; import com.chint.domain.value_object.PriceQueryData; import com.chint.domain.value_object.TrainPriceData; @@ -9,4 +10,5 @@ public interface EstimatePrice { TrainPriceData queryTrainPrice(PriceQueryData priceQueryData); FlightPriceData queryFlightPrice(PriceQueryData priceQueryData); + HotelPriceData queryHotelPrice(PriceQueryData priceQueryData); } diff --git a/src/main/java/com/chint/domain/aggregates/standards/CityTag.java b/src/main/java/com/chint/domain/aggregates/standards/CityTag.java new file mode 100644 index 00000000..771368d8 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/standards/CityTag.java @@ -0,0 +1,49 @@ +package com.chint.domain.aggregates.standards; + +import java.util.HashMap; + +public class CityTag { + + public static final HashMap cityMap; + + static { + cityMap = new HashMap<>(); + //直辖市 + cityMap.put("北京市", "1"); + cityMap.put("上海市", "1"); + cityMap.put("天津市", "1"); + cityMap.put("重庆市", "1"); + //省会城市 + cityMap.put("石家庄市", "1"); + cityMap.put("太原市", "1"); + cityMap.put("呼和浩特市", "1"); + cityMap.put("沈阳市", "1"); + cityMap.put("长春市", "1"); + cityMap.put("哈尔滨市", "1"); + cityMap.put("南京市", "1"); + cityMap.put("杭州市", "1"); + cityMap.put("合肥市", "1"); + cityMap.put("福州市", "1"); + cityMap.put("南昌市", "1"); + cityMap.put("济南市", "1"); + cityMap.put("郑州市", "1"); + cityMap.put("武汉市", "1"); + cityMap.put("长沙市", "1"); + cityMap.put("广州市", "1"); + cityMap.put("南宁市", "1"); + cityMap.put("海口市", "1"); + cityMap.put("成都市", "1"); + cityMap.put("贵阳市", "1"); + cityMap.put("昆明市", "1"); + cityMap.put("拉萨市", "1"); + cityMap.put("西安市", "1"); + cityMap.put("兰州市", "1"); + cityMap.put("西宁市", "1"); + cityMap.put("银川市", "1"); + cityMap.put("乌鲁木齐市", "1"); + //特别行政区 + cityMap.put("香港特别行政区", "1"); + cityMap.put("澳门特别行政区", "1"); + } + +} diff --git a/src/main/java/com/chint/domain/aggregates/standards/DifferenceStandards.java b/src/main/java/com/chint/domain/aggregates/standards/DifferenceStandards.java index 4400b0b8..56a18d10 100644 --- a/src/main/java/com/chint/domain/aggregates/standards/DifferenceStandards.java +++ b/src/main/java/com/chint/domain/aggregates/standards/DifferenceStandards.java @@ -18,6 +18,7 @@ public class DifferenceStandards { private String productTypeName; // private String region; private int rankId; // 与职级表关联的职级ID -// private String details; + // private String details; // private String tags; + private String cityTag;//1:直辖市,省会,特别行政区;2其它城市 } diff --git a/src/main/java/com/chint/domain/aggregates/standards/TravelStandards.java b/src/main/java/com/chint/domain/aggregates/standards/TravelStandards.java new file mode 100644 index 00000000..2834f2f6 --- /dev/null +++ b/src/main/java/com/chint/domain/aggregates/standards/TravelStandards.java @@ -0,0 +1,29 @@ +package com.chint.domain.aggregates.standards; + +import lombok.Data; +import org.springframework.data.annotation.Id; +import org.springframework.data.relational.core.mapping.Table; + +/** + * (TravelStandards)表实体类 + * + * @author dengweichao + * @since 2024-02-22 15:53:29 + */ +@Data +@Table("travel_standards") +public class TravelStandards { + @Id + private Integer id; + //商品类型 + private String productType; + //价格 + private String price; + //差标等级 + private String standardLevel; + //城市类别 + private String cityTag;//1:直辖市,省会,特别行政区,2:其它城市 + + +} + diff --git a/src/main/java/com/chint/domain/repository/TravelStandardsRepository.java b/src/main/java/com/chint/domain/repository/TravelStandardsRepository.java new file mode 100644 index 00000000..e8c5be77 --- /dev/null +++ b/src/main/java/com/chint/domain/repository/TravelStandardsRepository.java @@ -0,0 +1,15 @@ +package com.chint.domain.repository; + +import com.chint.domain.aggregates.location.CountryEntity; +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.standards.Ranks; +import com.chint.domain.aggregates.standards.TravelStandards; + +import java.util.List; + +public interface TravelStandardsRepository { + TravelStandards save(TravelStandards travelStandards); + void saveAll(List travelStandardsList); + List findByStandardLevel(String standardLevel); + +} diff --git a/src/main/java/com/chint/domain/value_object/HotelPriceData.java b/src/main/java/com/chint/domain/value_object/HotelPriceData.java new file mode 100644 index 00000000..54073993 --- /dev/null +++ b/src/main/java/com/chint/domain/value_object/HotelPriceData.java @@ -0,0 +1,9 @@ +package com.chint.domain.value_object; + +import lombok.Data; + +@Data +public class HotelPriceData { + private boolean success; + private String maxPrice; +} diff --git a/src/main/java/com/chint/infrastructure/repository/TravelStandardsRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/TravelStandardsRepositoryImpl.java new file mode 100644 index 00000000..ac14c920 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/TravelStandardsRepositoryImpl.java @@ -0,0 +1,33 @@ +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; + +@Repository +public class TravelStandardsRepositoryImpl implements TravelStandardsRepository { + + @Autowired + private JdbcTravelStandardsRepository jdbcTravelStandardsRepository; + + @Override + public TravelStandards save(TravelStandards travelStandards) { + return jdbcTravelStandardsRepository.save(travelStandards); + } + + @Override + public void saveAll(List travelStandardsList) { + jdbcTravelStandardsRepository.saveAll(travelStandardsList); + } + + @Override + public List findByStandardLevel(String standardLevel) { + return jdbcTravelStandardsRepository.findByStandardLevel(standardLevel); + } +} diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcTravelStandardsRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcTravelStandardsRepository.java new file mode 100644 index 00000000..729da6b9 --- /dev/null +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcTravelStandardsRepository.java @@ -0,0 +1,14 @@ +package com.chint.infrastructure.repository.jdbc; + +import com.chint.domain.aggregates.standards.Ranks; +import com.chint.domain.aggregates.standards.TravelStandards; +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface JdbcTravelStandardsRepository extends CrudRepository { + + List findByStandardLevel(String standardLevel); +}