查询酒店估算金额

This commit is contained in:
dengwc 2024-02-22 17:15:33 +08:00
parent f946d61329
commit 42946a89c6
11 changed files with 216 additions and 16 deletions

View File

@ -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<FlightPriceData> estimateFlightPrice(@RequestBody PriceQueryData priceQueryData) {
return Result.Success(SUCCESS, orderQuery.queryFlightPrice(priceQueryData));
}
@ApiOperation("查询酒店估算价格")
@PostMapping("/estimate/hotel")
public Result<HotelPriceData> estimateHotelPrice(@RequestBody PriceQueryData priceQueryData) {
return Result.Success(SUCCESS, orderQuery.queryHotelPrice(priceQueryData));
}
@ApiOperation("根据Id查询行程规划单-元年数据")
@PostMapping("/query/tripCallback")

View File

@ -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");

View File

@ -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<TravelStandards> travelStandardsList = travelStandardsRepository.findByStandardLevel(standardLevel);
//2.过滤出酒店的差标
List<TravelStandards> 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<String, String> cityMap = CityTag.cityMap;
return cityMap.get(city) == null ? "2" : cityMap.get(city);//"2"代表其它城市
}
}

View File

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

View File

@ -0,0 +1,49 @@
package com.chint.domain.aggregates.standards;
import java.util.HashMap;
public class CityTag {
public static final HashMap<String, String> 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");
}
}

View File

@ -20,4 +20,5 @@ public class DifferenceStandards {
private int rankId; // 与职级表关联的职级ID
// private String details;
// private String tags;
private String cityTag;//1:直辖市省会特别行政区2其它城市
}

View File

@ -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其它城市
}

View File

@ -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<TravelStandards> travelStandardsList);
List<TravelStandards> findByStandardLevel(String standardLevel);
}

View File

@ -0,0 +1,9 @@
package com.chint.domain.value_object;
import lombok.Data;
@Data
public class HotelPriceData {
private boolean success;
private String maxPrice;
}

View File

@ -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<TravelStandards> travelStandardsList) {
jdbcTravelStandardsRepository.saveAll(travelStandardsList);
}
@Override
public List<TravelStandards> findByStandardLevel(String standardLevel) {
return jdbcTravelStandardsRepository.findByStandardLevel(standardLevel);
}
}

View File

@ -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<TravelStandards, Integer> {
List<TravelStandards> findByStandardLevel(String standardLevel);
}