From 7500ba485450e5ab4d6f697c26cc543ed784817d Mon Sep 17 00:00:00 2001 From: lulz1 Date: Fri, 1 Mar 2024 08:21:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/out/LoginController.java | 6 +++- .../queryies/estimate/CTripEstimatePrice.java | 36 ++++++++++++------- .../domain/aggregates/order/Location.java | 1 + .../domain/service/LocationDomainService.java | 7 ++-- .../infrastructure/constant/LegConstant.java | 2 +- .../constant/LocationConstant.java | 7 ++-- .../repository/LocationRepositoryImpl.java | 4 +-- .../jdbc/JdbcLocationRepository.java | 2 +- src/main/resources/application-dev.yml | 2 +- src/main/resources/application-prod.yml | 2 +- src/main/resources/application-test.yml | 2 +- src/test/java/com/chint/CTripTest.java | 9 ++--- 12 files changed, 52 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/chint/application/out/LoginController.java b/src/main/java/com/chint/application/out/LoginController.java index 3b8c00a7..6b4f3f9b 100644 --- a/src/main/java/com/chint/application/out/LoginController.java +++ b/src/main/java/com/chint/application/out/LoginController.java @@ -3,6 +3,7 @@ package com.chint.application.out; import com.chint.application.commands.OrderCreateCommand; import com.chint.application.services.login.strategy.PailaLoginStrategy; +import com.chint.application.services.login.strategy.PailaMobileLoginStrategy; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.OrderException; import com.chint.domain.service.SystemDomainService; @@ -48,6 +49,9 @@ public class LoginController { @Autowired private PailaLoginStrategy pailaLoginStrategy; + @Autowired + private PailaMobileLoginStrategy pailaMobileLoginStrategy; + @ApiOperation("财务共享登录") @Transactional @GetMapping("/login") @@ -136,7 +140,7 @@ public class LoginController { @PostMapping("/login/sso/mobile") public Result loginSSOMobile(@RequestBody UserLoginParam userLoginParam){ - String employeeNo = pailaLoginStrategy.login(userLoginParam.getCode()); + String employeeNo = pailaMobileLoginStrategy.login(userLoginParam.getCode()); userLoginParam.setSfno(employeeNo); UserLoginResult userLoginResult = authenticateService 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 b1b9e060..126f3966 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -1,7 +1,6 @@ package com.chint.application.queryies.estimate; import com.chint.domain.aggregates.standards.CityTag; -import com.chint.domain.aggregates.standards.TrainStandards; import com.chint.domain.aggregates.standards.TravelStandards; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.CityRepository; @@ -30,11 +29,11 @@ import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Optional; -import java.util.regex.Matcher; import java.util.regex.Pattern; import static com.chint.domain.aggregates.standards.TrainStandards.trainStandardsMap; import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL; +import static com.chint.infrastructure.constant.RankConstant.STANDARD_LEVEL_ONE; @Component public class CTripEstimatePrice implements EstimatePrice { @@ -98,7 +97,16 @@ public class CTripEstimatePrice implements EstimatePrice { @Override public FlightPriceData queryFlightPrice(PriceQueryData priceQueryData) { FlightProductInfo flightProductInfo = new FlightProductInfo(); - flightProductInfo.setClassType("YCF"); + User currentUser = BaseContext.getCurrentUser(); + String standardLevel = currentUser.getStandardLevel(); + + //差标价值管控 , 差标等级不是一等,只能选择经济舱 + if (standardLevel.equals(STANDARD_LEVEL_ONE)) { + flightProductInfo.setClassType("YCF"); + } else { + flightProductInfo.setClassType("Y"); + } + RouteInfo routeInfo = new RouteInfo(); routeInfo.setArriveCityID( cityRepository.findByCityName(priceQueryData.getArriveCity()).getCity()); @@ -111,15 +119,19 @@ public class CTripEstimatePrice implements EstimatePrice { BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest); FlightPriceData flightPriceData = new FlightPriceData(); - Optional.ofNullable( - estimate.getData().getFlightValuationResult().getTotalPrice() - ).ifPresentOrElse(price -> { - flightPriceData.setSuccess(true); - flightPriceData.setMaxPrice(String.valueOf(price)); - }, () -> { - flightPriceData.setSuccess(false); - flightPriceData.setMaxPrice("无估算价格"); - }); + if (estimate.getStatus().getSuccess()) { + Optional.ofNullable( + estimate.getData().getFlightValuationResult().getTotalPrice() + ).ifPresentOrElse(price -> { + flightPriceData.setSuccess(true); + flightPriceData.setMaxPrice(String.valueOf(price)); + }, () -> { + flightPriceData.setSuccess(false); + flightPriceData.setMaxPrice("无估算价格"); + }); + } + + return flightPriceData; } diff --git a/src/main/java/com/chint/domain/aggregates/order/Location.java b/src/main/java/com/chint/domain/aggregates/order/Location.java index 9b21aa7c..66feff49 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Location.java +++ b/src/main/java/com/chint/domain/aggregates/order/Location.java @@ -22,6 +22,7 @@ public class Location { private String locationShortName; private String firstPinYin; private Long parentLocationId; + private Integer isInternal; @Column("level") private Integer level; diff --git a/src/main/java/com/chint/domain/service/LocationDomainService.java b/src/main/java/com/chint/domain/service/LocationDomainService.java index 61f37a7b..738c11d5 100644 --- a/src/main/java/com/chint/domain/service/LocationDomainService.java +++ b/src/main/java/com/chint/domain/service/LocationDomainService.java @@ -11,6 +11,9 @@ import org.springframework.stereotype.Service; import java.util.List; +import static com.chint.infrastructure.constant.LocationConstant.LOCATION_IS_INTERNAL; +import static com.chint.infrastructure.constant.LocationConstant.LOCATION_IS_NOT_INTERNAL; + @Service public class LocationDomainService { @@ -33,12 +36,12 @@ public class LocationDomainService { return switch (cityType) { case LocationConstant.CITY_TYPE_DOMESTIC -> queryByCityName .stream() - .filter(location -> location.getLocationPath().startsWith(LocationConstant.CITY_TYPE_DOMESTIC_PATH) + .filter(location -> location.getIsInternal().equals(LOCATION_IS_INTERNAL) && location.getLevel().equals(3)).toList(); case LocationConstant.CITY_TYPE_FOREIGN -> queryByCityName .stream() - .filter(location -> !location.getLocationPath().startsWith(LocationConstant.CITY_TYPE_DOMESTIC_PATH) + .filter(location -> location.getIsInternal().equals(LOCATION_IS_NOT_INTERNAL) && location.getLevel().equals(3)).toList(); default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND); }; diff --git a/src/main/java/com/chint/infrastructure/constant/LegConstant.java b/src/main/java/com/chint/infrastructure/constant/LegConstant.java index ca566a0a..d9159a59 100644 --- a/src/main/java/com/chint/infrastructure/constant/LegConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LegConstant.java @@ -27,7 +27,7 @@ public class LegConstant { public static final String LEG_TYPE_HOTEL_NAME = "酒店"; public static final String LEG_TYPE_HOTEL_EN_NAME = "Hotel"; public static final int LEG_TYPE_TAXI = 3; - public static final String LEG_TYPE_TAXI_NAME = "出租车"; + public static final String LEG_TYPE_TAXI_NAME = "打车"; public static final String LEG_TYPE_TAXI_EN_NAME = "Traffic"; public static final int LEG_TYPE_OTHER = 4; public static final String LEG_TYPE_OTHER_NAME = "其他"; diff --git a/src/main/java/com/chint/infrastructure/constant/LocationConstant.java b/src/main/java/com/chint/infrastructure/constant/LocationConstant.java index fa3e1286..494a4f56 100644 --- a/src/main/java/com/chint/infrastructure/constant/LocationConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LocationConstant.java @@ -2,7 +2,10 @@ package com.chint.infrastructure.constant; public class LocationConstant { // 城市类型 - public static final int CITY_TYPE_DOMESTIC = 0;//国内 + public static final int CITY_TYPE_DOMESTIC = 1;//国内 public static final String CITY_TYPE_DOMESTIC_PATH = "3106_1_";//国内 - public static final int CITY_TYPE_FOREIGN = 1;//国外 + public static final int CITY_TYPE_FOREIGN = 0;//国外 + + public static final int LOCATION_IS_INTERNAL = 1;//是国内 + public static final int LOCATION_IS_NOT_INTERNAL = 0;//是国外 } diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 9bb51a57..b468c7b0 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -63,12 +63,12 @@ public class LocationRepositoryImpl implements LocationRepository { @Override public List findByName(LocationParam locationParam) { - return jdbcLocationRepository.findByLocationNameContaining(locationParam.getQueryWord()); + return jdbcLocationRepository.findByLocationPathNameContaining(locationParam.getQueryWord()); } @Override public List findByName(String localName) { - return jdbcLocationRepository.findByLocationNameContaining(localName); + return jdbcLocationRepository.findByLocationPathNameContaining(localName); } @Override diff --git a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java index f289cd07..058477e3 100644 --- a/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java +++ b/src/main/java/com/chint/infrastructure/repository/jdbc/JdbcLocationRepository.java @@ -21,7 +21,7 @@ public interface JdbcLocationRepository extends CrudRepository { List findByFirstPinYin(String firstPinYin); - List findByLocationNameContaining(String locationName); + List findByLocationPathNameContaining(String locationName); Location findByLocationName(String locationName); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 622493fd..04196998 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -59,7 +59,7 @@ paila: redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ client-mobile-id: 9b24c91ead42ee4b6918 client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef - redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/ + redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/*.* base-url: https://signin-test.chint.com token-name: token diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index b44eb244..dc8b4074 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -29,6 +29,6 @@ paila: redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ client-mobile-id: 9b24c91ead42ee4b6918 client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef - redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/ + redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/*.* base-url: https://signin-test.chint.com token-name: token diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 36b48380..a69edc2a 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -48,7 +48,7 @@ paila: redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ client-mobile-id: 9b24c91ead42ee4b6918 client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef - redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/ + redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/*.* base-url: https://signin-test.chint.com token-name: token diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index 4d0f5145..e3214818 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -118,15 +118,16 @@ public class CTripTest { System.out.println(loginRequest.h5Login(null)); } -// @Test + @Test void estimateFlight() { BaseContext.setCurrentUser(user); + user.setCompanyCode("A30000001"); FlightProductInfo flightProductInfo = new FlightProductInfo(); flightProductInfo.setClassType("YCF"); RouteInfo routeInfo = new RouteInfo(); - routeInfo.setArriveCityID("1"); - routeInfo.setDepartCityID("491"); - routeInfo.setDepartDate("2024-04-01"); + routeInfo.setArriveCityID("347"); + routeInfo.setDepartCityID("633"); + routeInfo.setDepartDate("2024-03-02"); flightProductInfo.setRoutes(List.of(routeInfo)); BookingRelatedApiRequest bookingRelatedApiRequest = estimateRequest .generateBaseRequest(flightProductInfo, null);