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 6f87b6c7..b4e7eec3 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -7,6 +7,7 @@ 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; +import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.*; import com.chint.domain.service.TrainStandardsService; import com.chint.domain.value_object.FlightPriceData; @@ -254,6 +255,7 @@ public class CTripEstimatePrice implements EstimatePrice { HotelProductInfo hotelProductInfo = new HotelProductInfo(); if (location.getCityId() == null) { //如果到这里返回无城市id,那么就直接报错 , 然后发送错误的日志 , 用于记录无法查找到城市id的location的name + throw new NotFoundException("地点:" + location.getLocationName() + "缺失相关信息(CityId),联系管理员进行添加"); } hotelProductInfo.setCityID(location.getCityId().toString()); BookingRelatedApiRequest bookingRelatedApiRequest = cTripEstimateRequest @@ -264,10 +266,11 @@ public class CTripEstimatePrice implements EstimatePrice { if (success) { HotelValuationResult hotelValuationResult = estimate.getData().getHotelValuationResult(); BigDecimal maxPrice = hotelValuationResult.getMaxPrice(); - String price = maxPrice == null ? KEEP_TWO_DECIMAL_ZERO : maxPrice.toString(); ; + String price = maxPrice == null ? KEEP_TWO_DECIMAL_ZERO : maxPrice.toString(); if (Double.parseDouble(price) == 0) { hotelPriceData.setSuccess(false); + hotelPriceData.setMaxPrice(NO_PRICE_ERROR); return hotelPriceData; } @@ -288,35 +291,7 @@ public class CTripEstimatePrice implements EstimatePrice { hotelPriceData.setSuccess(success); hotelPriceData.setMaxPrice(NO_PRICE_ERROR); } - return hotelPriceData; - - -// 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.isEmpty()) { -// String price = travelStandards.get(0).getPrice(); -// String arriveData = priceQueryData.getArriveDate(); -// String departDate = priceQueryData.getDepartDate(); -// if (arriveData != null) { -// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); -// int count = calculateNightsBetweenDates(LocalDate.parse(departDate, formatter), -// LocalDate.parse(arriveData, formatter)); -// int res = Integer.parseInt(price) * count; -// price = String.valueOf(res); -// } -// hotelPriceData.setSuccess(true); -// hotelPriceData.setMaxPrice(price); -// } else { -// hotelPriceData.setSuccess(false); -// hotelPriceData.setMaxPrice("无估算价格"); -// } -// return hotelPriceData; } /** diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index f974681a..50514519 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -269,14 +269,14 @@ public class RouteOrder implements Serializable { this.getLegItems().forEach(Leg::reloadStatus); this.estimateAmount = this.getLegItems() .stream() - .filter(leg -> leg.getEstimateAmount() != null) .map(Leg::getEstimateAmount) + .filter(Objects::nonNull) .reduce(BigDecimalCalculator::add) .orElse(KEEP_TWO_DECIMAL_ZERO); this.amount = this.legItems .stream() - .filter(leg -> leg.getAmount() != null) .map(Leg::getAmount) + .filter(Objects::nonNull) .reduce(BigDecimalCalculator::add) .orElse(KEEP_TWO_DECIMAL_ZERO); this.updateStatus(); @@ -577,12 +577,10 @@ public class RouteOrder implements Serializable { // 计算时间匹配得分,这里只是一个示例,可以根据实际需要调整计算方式 long startTimeDiff = Math.abs(Duration.between(leg.getStartTime(), orderDetail.getStartTime()).toMillis()); long endTimeDiff = Math.abs(Duration.between(leg.getEndTime(), orderDetail.getEndTime()).toMillis()); - double timeScore = 1.0 / (1 + startTimeDiff / tolerance) + 1.0 / (1 + endTimeDiff / tolerance); - // 可以添加更多的评分项,比如地点匹配得分、产品类型得分等 // 返回综合评分 - return timeScore; + return 1.0 / (1 + (double) startTimeDiff / tolerance) + 1.0 / (1 + (double) endTimeDiff / tolerance); } public boolean checkIfHaveTrainLeg() { diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java index d23d0dc4..4b93bce0 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java @@ -19,6 +19,7 @@ import java.math.RoundingMode; import java.util.List; import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_TYPE_AMAP; +import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_REFUND; import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_SUCCESS; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP_CN_NAME; @@ -118,6 +119,16 @@ public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory { } carOrderDetail.setOrderStatus(mapFSSCOrderStatus(data.getShowStatus())); + List originalFeeDetails = data.parseOriginalFeeDetail(); + + if (originalFeeDetails.stream().anyMatch(it -> it.getFeeCode().equals("cancelFee") && it.getValue() > 0)) { + carOrderDetail.setOrderStatus(FSSC_CAR_STATUS_REFUND); + originalFeeDetails.stream().filter(it -> it.getFeeCode().equals("cancelFee")).findFirst() + .ifPresent(it -> { + String cancelFee = it.getValue().toString(); + carOrderDetail.setCancellationFee(BigDecimalCalculator.divide(cancelFee, "100")); + }); + } carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_AMAP); updateCarOrderDetailData(carOrderDetail, response); diff --git a/src/main/java/com/chint/domain/repository/LocationRepository.java b/src/main/java/com/chint/domain/repository/LocationRepository.java index 387c817a..67c7dcd4 100644 --- a/src/main/java/com/chint/domain/repository/LocationRepository.java +++ b/src/main/java/com/chint/domain/repository/LocationRepository.java @@ -5,11 +5,14 @@ import com.chint.domain.aggregates.order.Location; import com.chint.infrastructure.util.PageResult; import java.util.List; +import java.util.Optional; public interface LocationRepository { // List findByHot(List locationHots); Location findByLocationId(Long locationId); + Optional findOptById(Long id); + Location save(Location location); PageResult pageQuery(LocationParam locationParam); diff --git a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java index 9b7544d2..aecf4e4a 100644 --- a/src/main/java/com/chint/domain/service/BPMOrderDomainService.java +++ b/src/main/java/com/chint/domain/service/BPMOrderDomainService.java @@ -8,7 +8,8 @@ import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.system.ProcessInitiationControl; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.NotFoundException; -import com.chint.domain.repository.*; +import com.chint.domain.repository.RouteRepository; +import com.chint.domain.repository.UserRepository; import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.repository.jdbc.JdbcLegRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; @@ -41,14 +42,11 @@ import java.util.List; import java.util.Objects; import static com.chint.infrastructure.constant.BPMConstant.*; -import static com.chint.infrastructure.constant.BPMConstant.REFUND_TYPE_FLIGHT; import static com.chint.infrastructure.constant.BelongSystemConstant.BELONG_SYS_CODE_ANFSSC; import static com.chint.infrastructure.constant.LegConstant.*; -import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CHANGE; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_REFUND; import static com.chint.infrastructure.constant.SupplierNameConstant.*; -import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y_BPM_NAME; @Service public class BPMOrderDomainService { @@ -102,7 +100,7 @@ public class BPMOrderDomainService { String employeeNo = orderDetail.getEmployeeNo();//用户id String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany();//用户编号 //查询用户公司部门信息 - User user=userRepository.findByUserEmployeeNo(employeeNo); + User user = userRepository.findByUserEmployeeNo(employeeNo); //获取公司编号 //安能超标 if (BELONG_SYS_CODE_ANFSSC.equals(sysCode)) { @@ -118,7 +116,7 @@ public class BPMOrderDomainService { Leg leg = jdbcLegRepository.findByLegId(legId); anExceedStandardDto.setApplyNo(routeOrder.getApproveOrderNo().getFakeOrderNo())//申请单号 .setLegNo(leg == null ? "" : leg.getLegNo());//行程编号 - boolean success=bpmRequest.ANExceedStandard(anExceedStandardDto).getSuccess(); + boolean success = bpmRequest.ANExceedStandard(anExceedStandardDto).getSuccess(); DelayDispatch.attemptToSend(() -> success, 0); //保存超标报表 @@ -141,7 +139,7 @@ public class BPMOrderDomainService { ExceedStandardDto exceedStandardDto = switch (command.getProductType()) { case LEG_TYPE_TRAIN -> bpmParamFactory.creatAuditParamByTrain(orderDetail); case LEG_TYPE_AIRPLANE -> bpmParamFactory.creatAuditParamByFlight(orderDetail); - case LEG_TYPE_HOTEL -> bpmParamFactory.creatAuditParamByHotel(orderDetail); + case LEG_TYPE_HOTEL -> bpmParamFactory.creatAuditParamByHotel(orderDetail, routeOrder); case LEG_TYPE_TAXI -> bpmParamFactory.creatAuditParamByCar(orderDetail); case LEG_TYPE_OTHER -> bpmParamFactory.creatAuditParamByOther(orderDetail); default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); @@ -150,14 +148,14 @@ public class BPMOrderDomainService { exceedStandardDto.setReason(command.getReason()); } //加入高压系统标识 - String filterFieldName="S_sysCode"; - String filterFileValue="GYBPM"; + String filterFieldName = "S_sysCode"; + String filterFileValue = "GYBPM"; List list = jdbcRouteCustomExtensionFieldRepository.findByRouteId(routeOrder.getRouteId()) .stream().filter(s -> s.getFieldName().equals(filterFieldName) && s.getFieldValue().equals(filterFileValue)).toList(); if (!list.isEmpty()) { exceedStandardDto.setSysCode(filterFileValue); } - boolean success=bpmRequest.exceedStandard(exceedStandardDto, sysCode, employeeNo, accountCompany).getSuccess(); + boolean success = bpmRequest.exceedStandard(exceedStandardDto, sysCode, employeeNo, accountCompany).getSuccess(); DelayDispatch.attemptToSend(() -> success, 0); //保存超标报表 @@ -183,15 +181,15 @@ public class BPMOrderDomainService { jdbcProcessInitiationControlRepository.save(processInitiationControl); } - private String getProductTypeName(Integer type){ + private String getProductTypeName(Integer type) { String typeName = null; - switch (type){ - case LEG_TYPE_TRAIN -> typeName=LEG_TYPE_TRAIN_NAME; - case LEG_TYPE_AIRPLANE -> typeName=LEG_TYPE_AIRPLANE_NAME; - case LEG_TYPE_HOTEL -> typeName=LEG_TYPE_HOTEL_NAME; - case LEG_TYPE_TAXI -> typeName=LEG_TYPE_TAXI_NAME; - case LEG_TYPE_OTHER -> typeName=LEG_TYPE_OTHER_NAME; - default -> typeName=LEG_TYPE_OTHER_NAME+type; + switch (type) { + case LEG_TYPE_TRAIN -> typeName = LEG_TYPE_TRAIN_NAME; + case LEG_TYPE_AIRPLANE -> typeName = LEG_TYPE_AIRPLANE_NAME; + case LEG_TYPE_HOTEL -> typeName = LEG_TYPE_HOTEL_NAME; + case LEG_TYPE_TAXI -> typeName = LEG_TYPE_TAXI_NAME; + case LEG_TYPE_OTHER -> typeName = LEG_TYPE_OTHER_NAME; + default -> typeName = LEG_TYPE_OTHER_NAME + type; } return typeName; } diff --git a/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java index 9c271790..20c44e83 100644 --- a/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/AmapOrderDataAdapter.java @@ -11,6 +11,7 @@ import com.chint.domain.value_object.enums.CurrencyType; import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.constant.OrderConstant; import com.chint.infrastructure.echo_framework.command.Command; +import com.chint.infrastructure.util.BigDecimalCalculator; import com.chint.interfaces.rest.amap.dto.detail.AmapOrderDetailResponse; import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest; import com.google.gson.Gson; @@ -57,7 +58,8 @@ public class AmapOrderDataAdapter implements OrderDataAdapter { } else { Integer enterpriseAmount = data.getEnterpriseAmount(); Integer personAmount = data.getPersonAmount(); - price = String.valueOf((enterpriseAmount == null ? 0 : enterpriseAmount) + (personAmount == null ? 0 : personAmount)); + price = BigDecimalCalculator.divide(String.valueOf((enterpriseAmount == null ? 0 : enterpriseAmount) + (personAmount == null ? 0 : personAmount)), + "100"); } Optional startLocationId = locationRepository diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index cd073189..5db7fd96 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Repository; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_AIRPLANE; @@ -31,6 +32,11 @@ public class LocationRepositoryImpl implements LocationRepository { return jdbcLocationRepository.findByLocationId(locationId); } + @Override + public Optional findOptById(Long id) { + return jdbcLocationRepository.findById(id); + } + @Override public Location save(Location location) { return jdbcLocationRepository.save(location); @@ -216,7 +222,7 @@ public class LocationRepositoryImpl implements LocationRepository { @Override public List findByLocationNameContainingAndIfInternalAndLocationType(String locationName, Integer ifInternal, Integer locationType) { - return jdbcLocationRepository.findByLocationNameContainingAndIsInternalAndLocationType(locationName, ifInternal, locationType); + return jdbcLocationRepository.findByLocationNameContainingAndIsInternalAndLocationType(locationName, ifInternal, locationType); } diff --git a/src/main/java/com/chint/interfaces/rest/amap/dto/detail/AmapOrderDetailResponse.java b/src/main/java/com/chint/interfaces/rest/amap/dto/detail/AmapOrderDetailResponse.java index bc07ebd7..32b95d9a 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/dto/detail/AmapOrderDetailResponse.java +++ b/src/main/java/com/chint/interfaces/rest/amap/dto/detail/AmapOrderDetailResponse.java @@ -1,9 +1,13 @@ package com.chint.interfaces.rest.amap.dto.detail; import com.chint.interfaces.rest.amap.BaseResponse; +import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import lombok.Data; +import java.lang.reflect.Type; +import java.util.List; + @Data public class AmapOrderDetailResponse extends BaseResponse { @@ -99,6 +103,13 @@ public class AmapOrderDetailResponse extends BaseResponse { ApplyRecord applyRecord1 = gson.fromJson(record, ApplyRecord.class); return applyRecord1.getOutApplyRecordId(); } + + public List parseOriginalFeeDetail() { + Gson gson = new Gson(); + String originalFeeDetail1 = this.getOriginalFeeDetail(); + Type listType = new TypeToken>() {}.getType(); + return gson.fromJson(originalFeeDetail1, listType); + } } @lombok.Data @@ -134,5 +145,11 @@ public class AmapOrderDetailResponse extends BaseResponse { private String value;//费用 } - + @lombok.Data + public static class OriginalFeeDetail { + private String feeCode;//名称 + private String pFeeCode;//名称 + private String title;//费用 + private Double value;//费用 + } } diff --git a/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java b/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java index 6a5ae496..927945fd 100644 --- a/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java +++ b/src/main/java/com/chint/interfaces/rest/bpm/BPMParamFactory.java @@ -4,28 +4,30 @@ import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.LegRepository; +import com.chint.domain.repository.LocationRepository; import com.chint.infrastructure.constant.BPMConstant; import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.repository.jdbc.JdbcUserRepository; import com.chint.infrastructure.util.DaysUtil; import com.chint.interfaces.rest.bpm.dto.ANExceedStandardDto; import com.chint.interfaces.rest.bpm.dto.ExceedStandardDto; +import com.chint.interfaces.rest.ctrip.CTripEstimateRequest; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.math.RoundingMode; -import java.time.Duration; import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.UUID; +import java.util.Optional; +import java.util.function.Function; +import java.util.function.Supplier; import static com.chint.infrastructure.constant.BPMConstant.CHINT_CB_TAG; import static com.chint.infrastructure.constant.BPMConstant.CHINT_TRIP_TAG; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL; import static com.chint.infrastructure.constant.SupplierNameConstant.*; +import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; @Component public class BPMParamFactory { @@ -36,6 +38,13 @@ public class BPMParamFactory { @Autowired private JdbcUserRepository userRepository; + @Autowired + private CTripEstimateRequest cTripEstimateRequest; + + @Autowired + private LocationRepository locationRepository; + + public ExceedStandardDto creatAuditParamByCar(OrderDetail orderDetail) { CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail(); ExceedStandardDto exceedStandardDto = new ExceedStandardDto(); @@ -61,6 +70,69 @@ public class BPMParamFactory { return exceedStandardDto; } + public ExceedStandardDto creatAuditParamByHotel(OrderDetail orderDetail, RouteOrder routeOrder) { + HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail(); + ExceedStandardDto exceedStandardDto = new ExceedStandardDto(); + Long legId = orderDetail.getLegId(); + // 差旅标准金额 + BigDecimal standardPrice = new BigDecimal("0"); + + // 定义用于计算标准价格的函数 + Function calculateStandardPrice = leg -> { + String standardTotalPrice = leg.getEstimateAmount() == null ? "0" : leg.getEstimateAmount(); + BigDecimal bigStandardPrice = new BigDecimal(standardTotalPrice); + int days = DaysUtil.calculateNightsBetweenDates(LocalDate.from(leg.getStartTime()), LocalDate.from(leg.getEndTime())); + return days > 0 ? bigStandardPrice.divide(new BigDecimal(days), 3, RoundingMode.HALF_UP) : bigStandardPrice; + }; + + // 当 legId 为 null 时的处理逻辑 + Supplier handleNullLegId = () -> { + Optional optById = locationRepository.findOptById(orderDetail.getOriginId()); + return optById.map(location -> { + Long cityId = location.getCityId(); + if (cityId != null) { + String maxPrice = cTripEstimateRequest.hotelMaxPrice(cityId, routeOrder.getUserId(), routeOrder.getStandardLevel()); + return maxPrice != null ? new BigDecimal(maxPrice) : new BigDecimal(KEEP_TWO_DECIMAL_ZERO); + } else { + return new BigDecimal(KEEP_TWO_DECIMAL_ZERO); + } + }).orElse(new BigDecimal(KEEP_TWO_DECIMAL_ZERO)); + }; + + if (orderDetail.getPrice() != null && orderDetail.getProductType().equals(LEG_TYPE_HOTEL)) { + standardPrice = legId != null ? calculateStandardPrice.apply(legRepository.findByLegId(legId)) : handleNullLegId.get(); + } + + // 金额计算 + BigDecimal bigTotalPrice = new BigDecimal(orderDetail.getPrice() == null ? "0" : orderDetail.getPrice()); // 获取酒店需要支付的总价格 + int actualDays = DaysUtil.calculateNightsBetweenDates(LocalDate.from(orderDetail.getStartTime()), LocalDate.from(orderDetail.getEndTime())); + BigDecimal result = bigTotalPrice.subtract(standardPrice.multiply(BigDecimal.valueOf(actualDays))); + BigDecimal divide = actualDays > 0 ? result.divide(new BigDecimal(actualDays), 3, RoundingMode.HALF_UP) : result; + + // 超标总金额 + String supplierName = getSupplierName(orderDetail.getSupplierName()); + exceedStandardDto.setOrderType(BPMConstant.EXCEED_STANDARD_TYPE_HOTEL) + .setHotelStandard(String.valueOf(standardPrice)) // 差旅标准 + .setHouseLayout(hotelOrderDetail.getRoomTypeName()) + .setHotelName(hotelOrderDetail.getHotelName()) + .setOrderSource(supplierName) + .setOrderNo(hotelOrderDetail.getOrderNo()) + .setExcessAmount(result) // 超标金额 + .setReason(hotelOrderDetail.getOverStandardReason()) + .setOccupant(hotelOrderDetail.getBookingName()) // 入住人 + .setDays(Integer.valueOf(hotelOrderDetail.getNightCount())) // 入住天数 + .setExcessAmountDay(divide); // 超标金额(元/天) + + if (StringUtils.isBlank(exceedStandardDto.getOccupant())) { + String employeeNo = orderDetail.getEmployeeNo(); // 用户id + User user = userRepository.findByEmployeeNo(employeeNo); + if (user != null) { + exceedStandardDto.setOccupant(user.getName()); // 入住人 + } + } + return exceedStandardDto; + } + public ExceedStandardDto creatAuditParamByHotel(OrderDetail orderDetail) { HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail(); ExceedStandardDto exceedStandardDto = new ExceedStandardDto(); diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java index 1bc2d84d..ed31afc3 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java @@ -15,6 +15,8 @@ import org.springframework.stereotype.Component; import java.nio.charset.StandardCharsets; +import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO; + @Component public class CTripEstimateRequest { @@ -66,6 +68,19 @@ public class CTripEstimateRequest { return postRequest.post("sign", sign, estimateUrl, bookingRelatedApiRequest, BookingRelatedApiResponse.class); } + public String hotelMaxPrice(Long cityId, String employeeNo, String standardLevel) { + HotelProductInfo hotelProductInfo = new HotelProductInfo(); + hotelProductInfo.setCityID(cityId.toString()); + BookingRelatedApiRequest bookingRelatedApiRequest = generateBaseRequest(null, null, + hotelProductInfo, employeeNo, standardLevel); + BookingRelatedApiResponse estimate = estimate(bookingRelatedApiRequest); + if (estimate.getStatus().getSuccess()) { + return estimate.getData().getHotelValuationResult().getMaxPrice().toString(); + } else { + return KEEP_TWO_DECIMAL_ZERO; + } + } + public BookingRelatedApiRequest generateBaseRequest(FlightProductInfo flightProductInfo, TrainProductInfo trainProductInfo, HotelProductInfo hotelProductInfo) { @@ -98,10 +113,10 @@ public class CTripEstimateRequest { } public BookingRelatedApiRequest generateBaseRequest(FlightProductInfo flightProductInfo, - TrainProductInfo trainProductInfo, - HotelProductInfo hotelProductInfo, + TrainProductInfo trainProductInfo, + HotelProductInfo hotelProductInfo, String employeeNo, - String standardLevel){ + String standardLevel) { BookingRelatedApiRequest bookingRelatedApiRequest = new BookingRelatedApiRequest(); String token = tokenRequest.getToken(); bookingRelatedApiRequest.setApiName(apiName); diff --git a/src/test/java/com/chint/AmapTest.java b/src/test/java/com/chint/AmapTest.java index 607b4aeb..482a711f 100644 --- a/src/test/java/com/chint/AmapTest.java +++ b/src/test/java/com/chint/AmapTest.java @@ -59,7 +59,7 @@ public class AmapTest { @Test public void search() { Gson gson = new Gson(); - AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40168289001340014634615053"); + AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019637848323"); System.out.println(gson.toJson(orderDetailResponse)); } diff --git a/src/test/java/com/chint/LYTest.java b/src/test/java/com/chint/LYTest.java index 3a9cb16d..3b686eaf 100644 --- a/src/test/java/com/chint/LYTest.java +++ b/src/test/java/com/chint/LYTest.java @@ -828,7 +828,7 @@ public class LYTest { @Test void searchHotel() { - HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240414144500947464"); + HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240510114900487148"); Gson gson = new Gson(); String json = gson.toJson(hotelOrderDetail); System.out.println(json); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index be39a89a..31ba67e8 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -299,7 +299,7 @@ class RouteApplicationTests { @Test void loginSign() { - String sfno = "220208013"; + String sfno = "220727017"; String syscode = "FSSC"; String billcode = "CLSQ240225000099"; String companycode = "正泰集团股份有限公司"; @@ -356,7 +356,7 @@ class RouteApplicationTests { @Test void deleteOrderDetail() { - orderDetailRepository.deleteById(3076L); + orderDetailRepository.deleteById(3128L); } // @Test