修复分页查询显示错误用户名问题, 修复价格估算使用错误差标估算问题

This commit is contained in:
lulz1 2024-03-15 14:36:58 +08:00
parent 26460d8568
commit d3751b0208
5 changed files with 110 additions and 18 deletions

View File

@ -126,6 +126,7 @@ public class OrderQuery {
//根据系统标识进行筛选
routeOrders = sysCodeFilter(routeOrders, queryData.getSysCode());
int total = routeOrders.size();
List<RouteOrderPageRes> orders = routeOrders
.stream()
@ -134,7 +135,8 @@ public class OrderQuery {
.limit(pageSize)
.map(routeOrder -> {
orderDomainService.queryLocation(routeOrder.getLegItems());
return getRouteOrderPageRes(routeOrder);
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
return getRouteOrderPageRes(routeOrder, user);
})
.toList();
return new PageResult<>(total, orders);
@ -256,9 +258,8 @@ public class OrderQuery {
}
private static RouteOrderPageRes getRouteOrderPageRes(RouteOrder routeOrder) {
private static RouteOrderPageRes getRouteOrderPageRes(RouteOrder routeOrder, User user) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
User currentUser = BaseContext.getCurrentUser();
RouteOrderPageRes res = BeanUtil.copyProperties(routeOrder.reloadStatus(), RouteOrderPageRes.class);
List<Leg> legItems = routeOrder.getLegItems();
@ -279,7 +280,7 @@ public class OrderQuery {
.filter(Objects::nonNull)
.toList();
res.setLocationResList(locationRes);
res.setUserName(currentUser.getName());
res.setUserName(user.getName());
if (LocalDateTime.now().isAfter(routeOrder.getEndTime())) {
res.setIfCanBeFinished(CAN_BE_FINISHED);
@ -514,7 +515,10 @@ public class OrderQuery {
}
return stream
.filter(order -> order.reloadStatus().getOrderStatus().equals(ORDER_STATUS_APPROVAL))
.map(OrderQuery::getRouteOrderPageRes)
.map(order -> {
User user = userRepository.findByUserEmployeeNo(order.getUserId());
return getRouteOrderPageRes(order, user);
})
.toList();
}
}

View File

@ -3,6 +3,7 @@ package com.chint.application.queryies.estimate;
import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
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.user.User;
import com.chint.domain.exceptions.LocationException;
@ -61,6 +62,9 @@ public class CTripEstimatePrice implements EstimatePrice {
@Autowired
private CountryLevelInfoRepository countryLevelInfoRepository;
@Autowired
private RouteRepository routeRepository;
@Override
public TrainPriceData queryTrainPrice(PriceQueryData priceQueryData) {
checkPriceQueryData(priceQueryData);
@ -80,8 +84,21 @@ public class CTripEstimatePrice implements EstimatePrice {
trainProductInfo.setDepartDate(priceQueryData.getDepartDate());
trainProductInfo.setReturnNoTicket(true);
String employeeNo;
String standardLevel;
if (priceQueryData.getRouteId() != null) {
RouteOrder routeOrder = routeRepository.queryById(priceQueryData.getRouteId());
employeeNo = getEmployeeNo(routeOrder);
standardLevel = getStandardLevel(routeOrder);
} else {
User currentUser = BaseContext.getCurrentUser();
employeeNo = currentUser.getEmployeeNo();
standardLevel = currentUser.getStandardLevel();
}
BookingRelatedApiRequest bookingRelatedApiRequest = cTripEstimateRequest
.generateBaseRequest(null, trainProductInfo, null);
.generateBaseRequest(null, trainProductInfo, null, employeeNo, standardLevel);
BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest);
TrainPriceData trainPriceData = new TrainPriceData();
@ -105,9 +122,6 @@ public class CTripEstimatePrice implements EstimatePrice {
});
//根据差标等级获取可报销最大火车金额
//1.获取该用户的差标等级
User user = BaseContext.getCurrentUser();//用户
String standardLevel = user.getStandardLevel();//差旅等级
String trainStandards = trainStandardsMap.get(standardLevel);//获取可报销座位
Optional<String> optional = trainPriceData.getSeatInfoList().stream()
.filter(seatInfo -> {
@ -133,8 +147,18 @@ public class CTripEstimatePrice implements EstimatePrice {
public FlightPriceData queryFlightPrice(PriceQueryData priceQueryData) {
checkPriceQueryData(priceQueryData);
FlightProductInfo flightProductInfo = new FlightProductInfo();
User currentUser = BaseContext.getCurrentUser();
String standardLevel = currentUser.getStandardLevel();
String employeeNo;
String standardLevel;
if (priceQueryData.getRouteId() != null) {
RouteOrder routeOrder = routeRepository.queryById(priceQueryData.getRouteId());
employeeNo = getEmployeeNo(routeOrder);
standardLevel = getStandardLevel(routeOrder);
} else {
User currentUser = BaseContext.getCurrentUser();
employeeNo = currentUser.getEmployeeNo();
standardLevel = currentUser.getStandardLevel();
}
//差标价值管控 差标等级不是一等只能选择经济舱
if (standardLevel.equals(STANDARD_LEVEL_ONE)) {
@ -155,8 +179,10 @@ public class CTripEstimatePrice implements EstimatePrice {
arriveLocation.getCityId().toString());
routeInfo.setDepartDate(priceQueryData.getDepartDate());
flightProductInfo.setRoutes(List.of(routeInfo));
BookingRelatedApiRequest bookingRelatedApiRequest = cTripEstimateRequest
.generateBaseRequest(flightProductInfo, null, null);
.generateBaseRequest(flightProductInfo, null, null, employeeNo, standardLevel);
BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest);
FlightPriceData flightPriceData = new FlightPriceData();
@ -188,10 +214,20 @@ public class CTripEstimatePrice implements EstimatePrice {
@Override
public HotelPriceData queryHotelPrice(PriceQueryData priceQueryData) {
//1.获取该用户的差标
User user = BaseContext.getCurrentUser();//用户
String standardLevel = user.getStandardLevel();//差旅等级
//查询差旅标准
String employeeNo;
String standardLevel;
if (priceQueryData.getRouteId() != null) {
RouteOrder routeOrder = routeRepository.queryById(priceQueryData.getRouteId());
employeeNo = getEmployeeNo(routeOrder);
standardLevel = getStandardLevel(routeOrder);
} else {
User currentUser = BaseContext.getCurrentUser();
employeeNo = currentUser.getEmployeeNo();
standardLevel = currentUser.getStandardLevel();
}
HotelPriceData hotelPriceData = new HotelPriceData();
Long departCity = priceQueryData.getDepartCity();
@ -205,12 +241,12 @@ public class CTripEstimatePrice implements EstimatePrice {
getCityId(location);
HotelProductInfo hotelProductInfo = new HotelProductInfo();
if(location.getCityId() == null){
if (location.getCityId() == null) {
//如果到这里返回无城市id那么就直接报错 然后发送错误的日志 用于记录无法查找到城市id的location的name
}
hotelProductInfo.setCityID(location.getCityId().toString());
BookingRelatedApiRequest bookingRelatedApiRequest = cTripEstimateRequest
.generateBaseRequest(null, null, hotelProductInfo);
.generateBaseRequest(null, null, hotelProductInfo, employeeNo, standardLevel);
BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest);
Boolean success = estimate.getStatus().getSuccess();
@ -296,7 +332,7 @@ public class CTripEstimatePrice implements EstimatePrice {
} else {
List<PrefectureLevelCityInfoEntity> prefectureLevelCityInfoEntity = prefectureLevelRepository
.findByCityName(location.getLocationName());
if(prefectureLevelCityInfoEntity != null && !prefectureLevelCityInfoEntity.isEmpty()){
if (prefectureLevelCityInfoEntity != null && !prefectureLevelCityInfoEntity.isEmpty()) {
location.setCityId(prefectureLevelCityInfoEntity.get(0).getCityId());
}
}
@ -304,4 +340,19 @@ public class CTripEstimatePrice implements EstimatePrice {
}
return location;
}
private String getStandardLevel(RouteOrder routeOrder) {
if (routeOrder != null && routeOrder.getStandardLevel() != null) {
return routeOrder.getStandardLevel();
}
return BaseContext.getCurrentUser().getStandardLevel();
}
private String getEmployeeNo(RouteOrder routeOrder) {
if (routeOrder != null && routeOrder.getUserId() != null) {
return routeOrder.getUserId();
}
return BaseContext.getCurrentUser().getEmployeeNo();
}
}

View File

@ -11,4 +11,5 @@ public class PriceQueryData implements Serializable{
private String departDate;
private String arriveDate;
private Integer ifRound;
private Long routeId;
}

View File

@ -4,6 +4,7 @@ import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserRepository;
import com.chint.infrastructure.repository.jdbc.JdbcUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;
@Repository
@ -17,6 +18,7 @@ public class UserRepositoryImpl implements UserRepository {
return null;
}
@Cacheable(value = "UserByEmployeeNo", key = "#employeeNo")
@Override
public User findByUserEmployeeNo(String employeeNo) {
return jdbcUserRepository.findByEmployeeNo(employeeNo);

View File

@ -66,7 +66,9 @@ public class CTripEstimateRequest {
return postRequest.post("sign", sign, estimateUrl, bookingRelatedApiRequest, BookingRelatedApiResponse.class);
}
public BookingRelatedApiRequest generateBaseRequest(FlightProductInfo flightProductInfo, TrainProductInfo trainProductInfo, HotelProductInfo hotelProductInfo) {
public BookingRelatedApiRequest generateBaseRequest(FlightProductInfo flightProductInfo,
TrainProductInfo trainProductInfo,
HotelProductInfo hotelProductInfo) {
BookingRelatedApiRequest bookingRelatedApiRequest = new BookingRelatedApiRequest();
String token = tokenRequest.getToken();
bookingRelatedApiRequest.setApiName(apiName);
@ -94,4 +96,36 @@ public class CTripEstimateRequest {
.done()
.build();
}
public BookingRelatedApiRequest generateBaseRequest(FlightProductInfo flightProductInfo,
TrainProductInfo trainProductInfo,
HotelProductInfo hotelProductInfo,
String employeeNo,
String standardLevel){
BookingRelatedApiRequest bookingRelatedApiRequest = new BookingRelatedApiRequest();
String token = tokenRequest.getToken();
bookingRelatedApiRequest.setApiName(apiName);
bookingRelatedApiRequest.setLanguage(CTripConstant.LANGUAGE_CN);
bookingRelatedApiRequest.setAuthInfo(AuthInfo.of(C_TRIP_APP_KEY, token));
return BookingRelatedApiRequest.builder()
.language(CTripConstant.LANGUAGE_CN)
.apiName(apiName)
.authInfo()
.details(C_TRIP_APP_KEY, token)
.done()
.requestContent()
.valuationBaseInfo()
.eID(employeeNo)
.corpID(C_TRIP_CORP_ID)
.rankName(standardLevel)
.done()
.valuationProductInfo()
.addFlightProductInfo(flightProductInfo)
.addTrainProductInfo(trainProductInfo)
.addHotelProductInfo(hotelProductInfo)
.done()
.done()
.build();
}
}