From 0654ee094af60f31f1c65653826c1b19bca1793e Mon Sep 17 00:00:00 2001 From: huangxh3 Date: Wed, 28 Feb 2024 09:35:24 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=94=A8=E8=BD=A6=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LYOrderExtensionFactoryImpl.java | 132 +++++++++++++++++- .../service/supplier/LYOrderDataAdapter.java | 12 +- .../response/car/CarDetailResponse.java | 61 +++++++- .../response/filght/FlightListResponse.java | 76 +++++++--- .../rest/ly/in/CarBackController.java | 2 +- 5 files changed, 256 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java index bc9c4c05..8719898c 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/LYOrderExtensionFactoryImpl.java @@ -5,6 +5,8 @@ import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.UserRepository; import com.chint.domain.value_object.*; import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident; +import com.chint.interfaces.rest.ly.dto.search.response.car.CarDetailResponse; +import com.chint.interfaces.rest.ly.dto.search.response.filght.FlightListResponse; import com.chint.interfaces.rest.ly.dto.search.response.hotel.HotelDetailResponse; import com.chint.interfaces.rest.ly.dto.search.response.train.TrainDetailResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +25,9 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { @Override public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { - return null; + CarDetailResponse carDetailResponse = (CarDetailResponse) carOrderDetailData; + CarOrderDetail carOrderDetail = convertCart(carDetailResponse); + return carOrderDetail; } @Override @@ -66,6 +70,132 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { return null; } + private CarOrderDetail convertCart(CarDetailResponse carDetailResponse) { + CarOrderDetail carOrderDetail = new CarOrderDetail(); + CarDetailResponse.Data data = carDetailResponse.getData(); + + // 设置对象的全部属性 + carOrderDetail.setOrderNo(data.getOrderSerialNo()); + // carOrderDetail.setOverStandard(); //无 + // carOrderDetail.setParentOrderNo(parentOrderNo); //无 + // carOrderDetail.setOriginalOrderNo(originalOrderNo); //无 + carOrderDetail.setOrderStatus(data.getOrderStatus()); + // carOrderDetail.setAccountCompanyId(accountCompanyId); //无 + // carOrderDetail.setAccountCompanyName(accountCompanyName); //无 + carOrderDetail.setReceiptsNum(data.getTravelData().getTravelApplyNo()); + // carOrderDetail.setScheduleNum(scheduleNum); //无 + carOrderDetail.setBookingUserCode(data.getOutEmployeeId()); + // carOrderDetail.setBookingName(bookingName); //无 + // carOrderDetail.setBookingUserPhone(bookingUserPhone);//无 + carOrderDetail.setCreateTime(data.getOrder().getCreateTime()); + carOrderDetail.setStartTime(data.getOrderExtend().getChargeTime()); + carOrderDetail.setArriveTime(data.getOrderExtend().getFinishTime()); + carOrderDetail.setFromStationName(data.getOrderExtend().getStartAddress()); + carOrderDetail.setToStationName(data.getOrderExtend().getEndAddress()); + carOrderDetail.setCarModel(data.getOrderExtend().getCarType()); + carOrderDetail.setFromCity(data.getOrderExtend().getStartCityName()); + carOrderDetail.setToCity(data.getOrderExtend().getEndCityName()); + carOrderDetail.setRunTime(data.getOrderExtend().getDuration()); + carOrderDetail.setMileage(data.getOrderExtend().getMileage()); + carOrderDetail.setOrderAmount(String.valueOf(data.getTotalAmount())); + // carOrderDetail.setCancellationFee(cancellationFee); //无 + // carOrderDetail.setStandardItems(standardItems); //无 + carOrderDetail.setUserName(data.getOrder().getContactName()); + carOrderDetail.setUserCode(data.getOrder().getOutEmployeeId()); + carOrderDetail.setPhone(data.getOrder().getContactPhone()); + // carOrderDetail.setSupplier(supplier); //无 + carOrderDetail.setPersonalPaymentAmount(String.valueOf(data.getPersonalPrice())); + carOrderDetail.setCompanyPaymentAmount(String.valueOf(data.getCompanyPrice())); + // carOrderDetail.setOverStandardReason(overStandardReason); contactName + // carOrderDetail.setBOOK_ORG_STRUCT_1(BOOK_ORG_STRUCT_1); //无 + // carOrderDetail.setBOOK_ORG_STRUCT_2(BOOK_ORG_STRUCT_2); //无 + // carOrderDetail.setBOOK_ORG_STRUCT_3(BOOK_ORG_STRUCT_3); //无 + // carOrderDetail.setPaymentType(String.valueOf(data.getPaymentType())); //无 + // carOrderDetail.setProjectOrderNo(projectOrderNo); //无 + // carOrderDetail.setCostCenter(costCenter); //无 + // carOrderDetail.setTollFee(tollFee); //无 + + return carOrderDetail; + } + + private FlightOrderDetail convertFlight(FlightListResponse flightListResponse) { + FlightOrderDetail flightOrderDetail = new FlightOrderDetail(); + FlightListResponse.FlightOrder data = flightListResponse.getData(); + + + // flightOrderDetail.setId(id); + flightOrderDetail.setOrderNo(data.getOriginalOrderNo()); + flightOrderDetail.setOverStandard(String.valueOf(data.getRuleViolate())); + flightOrderDetail.setParentOrderNo(data.getParentRefOrderNo()); + flightOrderDetail.setOriginalOrderNo(data.getOriginalOrderNo()); + flightOrderDetail.setOrderStatus(String.valueOf(data.getOrderStatus())); + + // flightOrderDetail.setAccountCompanyId(accountCompanyId);//核算企业id + // flightOrderDetail.setAccountCompanyName(accountCompanyName);//核算企业名称 + + flightOrderDetail.setReceiptsNum(data.getTravelData().getTravelApplyNo()); + flightOrderDetail.setScheduleNum(data.getTravelOrderNo()); + flightOrderDetail.setChangedScheduleNum(data.getOriginalOrderNo()); + flightOrderDetail.setBookingUserCode(data.getOutEmployeeId()); + flightOrderDetail.setBookingName(data.getEmployeeName()); + + // flightOrderDetail.setBookingUserPhone(data.get); //预订人电话 + + flightOrderDetail.setCreateTime(data.getBookDate()); + + // flightOrderDetail.setStartTime(data.getDepar); + + /* flightOrderDetail.setArriveTime(arriveTime); + flightOrderDetail.setStartCityName(startCityName); + flightOrderDetail.setStartCityCode(startCityCode); + flightOrderDetail.setStartAirportName(startAirportName); + flightOrderDetail.setStartAirportCode(startAirportCode); + flightOrderDetail.setStartTerminal(startTerminal); + flightOrderDetail.setEndCityName(endCityName); + flightOrderDetail.setEndCityCode(endCityCode); + flightOrderDetail.setEndAirportName(endAirportName); + flightOrderDetail.setEndAirportCode(endAirportCode); + flightOrderDetail.setEndTerminal(endTerminal); + flightOrderDetail.setDistance(distance); + flightOrderDetail.setFlightCompName(flightCompName); + flightOrderDetail.setFlightNum(flightNum); + flightOrderDetail.setSeatPoint(seatPoint); + flightOrderDetail.setSeatPointName(seatPointName);*/ + flightOrderDetail.setOrderAmount(String.valueOf(data.getTotalPrice())); + flightOrderDetail.setPreServiceFee(String.valueOf(data.getServicePrice())); + // flightOrderDetail.setPostServiceFee(data.getA); + // flightOrderDetail.setRefundAmount(data.getFlightOrderRefundInfo()); + // flightOrderDetail.setTickets(tickets); + /* flightOrderDetail.setFuelTax(data.getFuel); + flightOrderDetail.setAirportTax(airportTax); + flightOrderDetail.setFacePrice(facePrice); + flightOrderDetail.setChangeFee(changeFee); + flightOrderDetail.setRefundFee(refundFee); + flightOrderDetail.setUpFee(upFee); + flightOrderDetail.setStandard(standard); + flightOrderDetail.setTicketNo(ticketNo); + flightOrderDetail.setChangedTicketNo(changedTicketNo); + flightOrderDetail.setUserName(data.getParr); + flightOrderDetail.setUserCode(data.getOutEmployeeId()); + flightOrderDetail.setIsOverStandard(isOverStandard); + flightOrderDetail.setPhone(phone); + flightOrderDetail.setPaymentType(paymentType); + flightOrderDetail.setNotBookedLowestPriceReason(notBookedLowestPriceReason); + flightOrderDetail.setSupplier(supplier); + flightOrderDetail.setPersonalPaymentAmount(personalPaymentAmount); + flightOrderDetail.setCompanyPaymentAmount(companyPaymentAmount); + flightOrderDetail.setOverStandardReason(overStandardReason); + flightOrderDetail.setBOOK_ORG_STRUCT_1(BOOK_ORG_STRUCT_1); + flightOrderDetail.setBOOK_ORG_STRUCT_2(BOOK_ORG_STRUCT_2); + flightOrderDetail.setBOOK_ORG_STRUCT_3(BOOK_ORG_STRUCT_3); + flightOrderDetail.setInsuranceFee(insuranceFee); + flightOrderDetail.setProjectOrderNo(projectOrderNo); + flightOrderDetail.setCostCenter(costCenter); +*/ + + + return null; + } private HotelOrderDetail convertHotel(HotelDetailResponse hotelDetailResponse) { HotelOrderDetail hotelOrderDetail = new HotelOrderDetail(); HotelDetailResponse.Data data = hotelDetailResponse.getData(); diff --git a/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java b/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java index e31806fe..54998253 100644 --- a/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java +++ b/src/main/java/com/chint/domain/service/supplier/LYOrderDataAdapter.java @@ -36,10 +36,10 @@ public class LYOrderDataAdapter implements OrderDataAdapter { return Optional.of( OrderLegData.builder() .productType(LEG_TYPE_TRAIN) - .outOrderNo(data.getOrderNo()) + .outOrderNo(data.getOutOrderNo()) .price(String.valueOf(data.getTotalAmount())) .actualOrderNo(data.getOutOrderNo()) - .trainOrderDetailData(data) + .trainOrderDetailData(trainDetailResponse) .supplierName(SUPPLIER_L_Y) .build() ); @@ -53,7 +53,7 @@ public class LYOrderDataAdapter implements OrderDataAdapter { .outOrderNo(data.getOrderInfo().getOrderSerialNo()) .price(String.valueOf(data.getOrderInfo().getTotalPrice())) .actualOrderNo(data.getOrderInfo().getOrderSerialNo()) - .hotelOrderDetailData(data) + .hotelOrderDetailData(hotelDetailResponse) .supplierName(SUPPLIER_L_Y) .build() ); @@ -64,10 +64,10 @@ public class LYOrderDataAdapter implements OrderDataAdapter { return Optional.of( OrderLegData.builder() .productType(LEG_TYPE_TAXI) - .outOrderNo(data.getOrderNo()) + .outOrderNo(data.getOrderSerialNo()) .price(String.valueOf(data.getTotalAmount())) .actualOrderNo(data.getOutOrderNo()) - .carOrderDetailData(data) + .carOrderDetailData(carDetailResponse) .supplierName(SUPPLIER_L_Y) .build() ); @@ -82,7 +82,7 @@ public class LYOrderDataAdapter implements OrderDataAdapter { // .orderNo(data.get()) // .price(String.valueOf( data.getTotalAmount())) // .actualOrderNo(data.getOutOrderNo()) - .flightOrderDetailData(data) + .flightOrderDetailData(flightOrderDetail) .supplierName(SUPPLIER_L_Y) .build() ); diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java index b5306ff0..4ed8c6db 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/car/CarDetailResponse.java @@ -1,8 +1,10 @@ package com.chint.interfaces.rest.ly.dto.search.response.car; import com.chint.interfaces.rest.ly.dto.LYBaseResponse; +import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail; import lombok.Data; +import java.math.BigDecimal; import java.util.List; @Data @@ -14,7 +16,7 @@ public class CarDetailResponse extends LYBaseResponse { public static class Data { private String outEmployeeId; private String employeeCode; - private String orderNo; + private String orderSerialNo; private String parentOrderSerialNo; private int isChangedOrder; private String outOrderNo; @@ -46,6 +48,8 @@ public class CarDetailResponse extends LYBaseResponse { private GarbInfo garbInfo; private double totalAmount; private TravelData travelData; + private Order order; + private OrderExtend orderExtend; private int bookingMethod; private int paymentType; private double personalPrice; @@ -57,6 +61,39 @@ public class CarDetailResponse extends LYBaseResponse { private String relationOrderNo; } + + @lombok.Data + public static class OrderExtend { + private Integer serviceType; + private String serviceTypeDesc; + private String departureTime; + private String startCityName; + private String endCityName; + private String carType; + private String carTypeName; + private String startAddress; + private double startLatitude; + private double startLongitude; + private String endAddress; + private double endLatitude; + private double endLongitude; + private Integer passengerCount; + private String chargeTime; + private String finishTime; + private String duration; + private String mileage; + private String flightNo; + private String departAirportCode; + private String arriveAirportCode; + private String departAirportName; + private String arriveAirportName; + private String flightDate; + private String flightArriveTime; + private String departTerminal; + private String arriveTerminal; + private String serviceName; + } + @lombok.Data public static class Item { private int itemId; @@ -139,6 +176,28 @@ public class CarDetailResponse extends LYBaseResponse { private double companyPrice; } + @lombok.Data + public static class Order { + private String orderSerialNo; + private String productName; + private String policyRuleName; + private Integer orderStatus; + private String orderStatusDesc; + private BigDecimal totalPrice; + private String createTime; + private BigDecimal servicePrice; + private String contactName; + private String contactPhone; + private boolean isEstimate; + private List priceDetailList; + private String outEmployeeId; + private String outEnterpriseId; + private BigDecimal diffPrice; + private Integer carPurposeId; + private String subjectMatter; + private String subjectRemark; + } + @lombok.Data public static class ContactInfo { private String personName; diff --git a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/filght/FlightListResponse.java b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/filght/FlightListResponse.java index e0cb94ce..f13be737 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/filght/FlightListResponse.java +++ b/src/main/java/com/chint/interfaces/rest/ly/dto/search/response/filght/FlightListResponse.java @@ -1,29 +1,69 @@ package com.chint.interfaces.rest.ly.dto.search.response.filght; import com.chint.interfaces.rest.ly.dto.LYBaseResponse; +import com.chint.interfaces.rest.ly.dto.flydatapushback.*; import lombok.Data; +import java.math.BigDecimal; import java.util.List; @Data public class FlightListResponse extends LYBaseResponse { - private List data; - @Data - private static class FlightOrder { - private String orderSerialNo; // 机票订单号 - private String originalOrderNo; // 原订单号(祖先单) - private String parentOrderSerialNo; // 父订单号 - private Integer orderType; // 订单类型 0.国际 1.国内 - private String travelApplyNo; // 外部出差申请单号 - private Integer travelType; // 差旅类型 1.因公 2.因私 - private Integer payType; // 支付方式 1.公司授信 2.个人支付 3.组合支付 - private String outEmployeeId; // 外部员工ID - private Double totalPrice; // 订单总价 - private Integer orderStatus; // 订单状态 - private String orderStatusText; // 订单状态文案 - private Boolean isChangeOrder; // 是否改签单 - private Boolean isRefundOrder; // 是否退票单 - private String bookDate; // 预订时间 - } + private FlightOrder data; + @lombok.Data + public static class FlightOrder { + private String orderSerialNo; + private String refOrderNo; + private String parentRefOrderNo; + private String originalOrderNo; + private String parentOrderSerialNo; + private String outEmployeeId; + private String outEnterpriseId; + private String relationId; + private Integer orderStatus; + private String orderStatusText; + private String ticketOutLimitTime; + private Integer payStatus; + private List contact; + private double totalPrice; + private double servicePrice; + private String pnr; + private String fullPnrNo; + private String memberId; + private String reason; + private Integer travelType; + private String travelOrderNo; + private Integer orderType; + private Integer voyageType; + private String ticketTime; + private Integer payType; + private String bookDate; + private String payTime; + private Boolean isChangeOrder; + private Boolean isRefundOrder; + private Object flightOrderRefundInfo; + private Object protrotolId; + private Object changeInfo; + private String apiNotifyUrl; + private Integer platId; + private Integer refId; + private Boolean ruleViolate; + private RuleViolateDetail ruleViolateDetail; + private TravelData travelData; + private List passengerList; + private List flightSegmentList; + private String foulReason; + private String foulReasonCode; + private String foulReasonNote; + private BigDecimal flightMinimumPrice; + private String remarks1; + private String employeeName; + private String updateDate; + private Integer isNeedTransfer; + private boolean gpAgreement; + private boolean priceChanged; + private Integer priceChangeType; + private boolean issueType; + } } diff --git a/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java b/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java index ef5157b8..81ce3781 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java +++ b/src/main/java/com/chint/interfaces/rest/ly/in/CarBackController.java @@ -39,7 +39,7 @@ public class CarBackController { if (orderSerialNo != null) { CarDetailResponse carDetailResponse = lySearchRequest.getCarDetailResponse(orderSerialNo); String outEmployeeId = carDetailResponse.getData().getOutEmployeeId(); //外部员工id - String serialNo = carDetailResponse.getData().getOrderNo();//订单号 + String serialNo = carDetailResponse.getData().getOrderSerialNo();//订单号 SupplierCallbackData supplierCallbackData = SupplierCallbackData.of(SupplierNameConstant.SUPPLIER_L_Y, outEmployeeId); supplierCallbackData.data(carDetailResponse); From d1acab14e59e61bd547cc4a9441fa7556c56b7b6 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 28 Feb 2024 09:42:59 +0800 Subject: [PATCH 2/5] =?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 | 13 ++++++++++--- .../services/login/LocalLoginStrategy.java | 2 +- .../services/login/LoginStrategy.java | 4 ++-- .../login/strategy/PailaLoginStrategy.java | 19 +++++-------------- .../service/auth/AuthenticateServiceImpl.java | 2 +- .../java/com/chint/RouteApplicationTests.java | 2 +- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/chint/application/out/LoginController.java b/src/main/java/com/chint/application/out/LoginController.java index 2d5d665e..f2adef3e 100644 --- a/src/main/java/com/chint/application/out/LoginController.java +++ b/src/main/java/com/chint/application/out/LoginController.java @@ -2,6 +2,7 @@ package com.chint.application.out; import com.chint.application.commands.OrderCreateCommand; +import com.chint.application.services.login.strategy.PailaLoginStrategy; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.OrderException; import com.chint.domain.service.SystemDomainService; @@ -16,6 +17,7 @@ import com.chint.infrastructure.util.Digest; import com.chint.infrastructure.util.Result; import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest; import com.chint.interfaces.rest.ly.LYUserRequest; +import com.chint.interfaces.rest.ly.dto.login.LoginParam; import com.chint.interfaces.rest.user.UserHttpRequest; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -43,6 +45,9 @@ public class LoginController { @Autowired private SystemDomainService systemDomainService; + @Autowired + private PailaLoginStrategy pailaLoginStrategy; + @ApiOperation("财务共享登录") @Transactional @GetMapping("/login") @@ -98,9 +103,11 @@ public class LoginController { @ApiOperation("商旅平台单点") @Transactional @PostMapping("/login/sso") - public Result loginSSO(){ - UserLoginParam userLoginParam = new UserLoginParam(); - userLoginParam.setSfno("170717012"); + public Result loginSSO(@RequestBody UserLoginParam userLoginParam){ + + String employeeNo = pailaLoginStrategy.login(userLoginParam.getCode()); + + userLoginParam.setSfno(employeeNo); UserLoginResult userLoginResult = authenticateService .authenticateEmployeeNo(userLoginParam); diff --git a/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java b/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java index a77d5507..2ec2ea02 100644 --- a/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/LocalLoginStrategy.java @@ -15,7 +15,7 @@ public class LocalLoginStrategy implements LoginStrategy { } @Override - public User getUserInfo(String accessToken) { + public String getUserInfo(String accessToken) { return null; } } diff --git a/src/main/java/com/chint/application/services/login/LoginStrategy.java b/src/main/java/com/chint/application/services/login/LoginStrategy.java index 1f47fdd5..c7855ea4 100644 --- a/src/main/java/com/chint/application/services/login/LoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/LoginStrategy.java @@ -20,14 +20,14 @@ import java.util.regex.Pattern; public interface LoginStrategy { Logger log = LoggerFactory.getLogger("UserService"); - default User login(String code) { + default String login(String code) { Optional accessToken = getAccessToken(code); return getUserInfo(accessToken.orElseThrow(()-> new AuthException("Failed to obtain access token"))); } Optional getAccessToken(String code); - User getUserInfo(String accessToken); + String getUserInfo(String accessToken); static Optional getAccessTokenMethod(HttpRequestBase request, String tokenName) { String responseBody = null; diff --git a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java index 40e39eee..0b883e87 100644 --- a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java @@ -3,8 +3,7 @@ package com.chint.application.services.login.strategy; import com.alibaba.fastjson.JSON; import com.chint.application.dtos.UserDTO; import com.chint.application.services.login.LoginStrategy; -import com.chint.domain.aggregates.user.User; -import com.chint.domain.exceptions.AuthException; +import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.factoriy.user.UserFactory; import com.chint.domain.repository.UserRepository; import com.chint.interfaces.rest.user.UserHttpRequest; @@ -71,7 +70,7 @@ public class PailaLoginStrategy implements LoginStrategy { } @Override - public User getUserInfo(String accessToken) { + public String getUserInfo(String accessToken) { List userInfoParams = Collections.singletonList( @@ -89,18 +88,10 @@ public class PailaLoginStrategy implements LoginStrategy { log.error(e.getMessage()); } UserDTO userDTO = JSON.parseObject(userInfoResBody, UserDTO.class); - User user; - if (userDTO != null) { - user = userRepository.findByUserEmployeeNo(userDTO.getUid()); - if (user == null) { - user = userFactory.create(userDTO.getUid()); - userHttpRequest.loadUserInfo(user); - userRepository.save(user); - } - } else { - throw new AuthException(NOT_FOUND); + if (userDTO == null) { + throw new NotFoundException(NOT_FOUND); } - return user; + return userDTO.getUid(); } private HttpGet getRequest(String path, List parameters) { diff --git a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java index 283f19d2..89da197c 100644 --- a/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java +++ b/src/main/java/com/chint/domain/service/auth/AuthenticateServiceImpl.java @@ -41,7 +41,7 @@ public class AuthenticateServiceImpl implements AuthenticateService { @Override public UserLoginResult authenticateEmployeeNo(UserLoginParam userLoginParam) { User user = userRepository.findByUserEmployeeNo(userLoginParam.getSfno()); - if (user != null) { + if (user != null) { // 部分数据需要通过查询外部的http来获取 BaseContext.setCurrentUser(user); user.setCompanyCode(userLoginParam.getCompanyCode()); diff --git a/src/test/java/com/chint/RouteApplicationTests.java b/src/test/java/com/chint/RouteApplicationTests.java index f880cb16..05d230ab 100644 --- a/src/test/java/com/chint/RouteApplicationTests.java +++ b/src/test/java/com/chint/RouteApplicationTests.java @@ -121,7 +121,7 @@ class RouteApplicationTests { // @Test void ssoLogin(){ - User login = pailaLoginStrategy.login("OC-5909-zRqrWjZGNThNXJiAV1kA7dPXTojGzVxK3nE"); + String login = pailaLoginStrategy.login("OC-5909-zRqrWjZGNThNXJiAV1kA7dPXTojGzVxK3nE"); System.out.println(login); } } From 92fe2073748248ce327ed149186cf58fa01d2a2c Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 28 Feb 2024 11:49:10 +0800 Subject: [PATCH 3/5] =?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 --- .../com/chint/application/dtos/UserDTO.java | 17 ++++++++---- .../login/strategy/PailaLoginStrategy.java | 26 +++++++++++++++---- src/main/resources/application-dev.yml | 6 ++--- src/main/resources/application-prod.yml | 6 ++--- src/main/resources/application-test.yml | 6 ++--- 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/chint/application/dtos/UserDTO.java b/src/main/java/com/chint/application/dtos/UserDTO.java index 715ca635..eeb5e1dd 100644 --- a/src/main/java/com/chint/application/dtos/UserDTO.java +++ b/src/main/java/com/chint/application/dtos/UserDTO.java @@ -5,14 +5,21 @@ import lombok.Data; @Data public class UserDTO { - private String accountId; - private String mobile; - private String userName; - private String uid; - private String email; + private UserData attributes; + private String id; // 构造函数和其他方法(getter 和 setter)可以根据需要添加 // Getter 和 Setter 方法 + @Data + public static class UserData{ + private String user_name; + private String mobile; + private String account_no; + private long token_gtime; + private String token_expired; + private String email; + private String user_uid; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java index 0b883e87..99b764be 100644 --- a/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java +++ b/src/main/java/com/chint/application/services/login/strategy/PailaLoginStrategy.java @@ -12,6 +12,7 @@ import org.apache.http.HttpResponse; import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; import org.apache.http.client.utils.URIBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; @@ -59,13 +60,15 @@ public class PailaLoginStrategy implements LoginStrategy { log.info("开始执行登录"); List parameters = Arrays.asList( + new BasicNameValuePair("grant_type", "authorization_code"), new BasicNameValuePair("client_id", clientId), new BasicNameValuePair("client_secret", clientSecret), - new BasicNameValuePair("redirect_uri", redirectUri), - new BasicNameValuePair("code", code) + new BasicNameValuePair("code", code), + new BasicNameValuePair("redirect_uri", redirectUri) + ); - HttpGet getMethod = getRequest("/profile/oauth2/accessToken", parameters); + HttpPost getMethod = postRequest("/esc-sso/oauth2.0/accessToken", parameters); return LoginStrategy.getAccessTokenMethod(getMethod, "access_token"); } @@ -77,7 +80,7 @@ public class PailaLoginStrategy implements LoginStrategy { new BasicNameValuePair("access_token", accessToken) ); - HttpGet getMethodUserInfo = getRequest("/profile/oauth2/profile", userInfoParams); + HttpGet getMethodUserInfo = getRequest("/esc-sso/oauth2.0/profile", userInfoParams); String userInfoResBody = null; HttpClient client = HttpClients.createDefault(); @@ -91,7 +94,7 @@ public class PailaLoginStrategy implements LoginStrategy { if (userDTO == null) { throw new NotFoundException(NOT_FOUND); } - return userDTO.getUid(); + return userDTO.getAttributes().getAccount_no(); } private HttpGet getRequest(String path, List parameters) { @@ -106,4 +109,17 @@ public class PailaLoginStrategy implements LoginStrategy { request.setHeader("Content-Type", "application/json"); return request; } + + private HttpPost postRequest(String path, List parameters) { + String userInfoUrl = null; + try { + userInfoUrl = new URIBuilder(baseUrl).setPath(path) + .setParameters(parameters).build().toString(); + } catch (URISyntaxException e) { + log.error(e.getMessage()); + } + HttpPost request = new HttpPost(userInfoUrl); + request.setHeader("Content-Type", "application/json"); + return request; + } } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 9cf97bb1..123b1bb0 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -10,7 +10,7 @@ chint: database: itinerary_booking username: tripbook password: W@Xgf25d&lRk*L0X# - url: https://gxdev03.chint.com/businesstravel/ + url: https://gxdev03.chint.com/businesstravelhome/ logging: level: org.springframework.jdbc.core.JdbcTemplate: DEBUG @@ -56,8 +56,8 @@ FSSC: paila: client-id: 0053df85723db94491e8 client-secret: 7368bcec4c0f004c40585f6ed1087d887897 - redirect-url: https://gxdev03.chint.com/businesstravel/ - base-url: http://signin-test.chint.com + redirect-url: https://gxdev03.chint.com/businesstravelhome/*.* + 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 7921bb8d..4fc270e2 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -9,7 +9,7 @@ chint: database: itinerary_booking username: root password: 123456 - url: https://gxdev03.chint.com/businesstravel/ + url: https://gxdev03.chint.com/businesstravelhome/ cTrip: baseUrl: https://ct.ctrip.com @@ -26,6 +26,6 @@ FSSC: paila: client-id: 0053df85723db94491e8 client-secret: 7368bcec4c0f004c40585f6ed1087d887897 - redirect-url: https://gxdev03.chint.com/businesstravel/ - base-url: http://signin-test.chint.com + redirect-url: https://gxdev03.chint.com/businesstravelhome/*.* + 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 676ed1bd..cc10ab02 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -21,7 +21,7 @@ chint: database: itinerary_booking username: tripbook password: W@Xgf25d&lRk*L0X# - url: https://gxdev03.chint.com/businesstravel/ + url: https://gxdev03.chint.com/businesstravelhome/ logging: level: @@ -45,8 +45,8 @@ FSSC: paila: client-id: 0053df85723db94491e8 client-secret: 7368bcec4c0f004c40585f6ed1087d887897 - redirect-url: https://gxdev03.chint.com/businesstravel/ - base-url: http://signin-test.chint.com + redirect-url: https://gxdev03.chint.com/businesstravelhome/*.* + base-url: https://signin-test.chint.com token-name: token bpm: From 1b9fff32d8a68452ae66d12b43e3e719b8b887a2 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 28 Feb 2024 12:39:57 +0800 Subject: [PATCH 4/5] =?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 --- .../chint/application/queryies/estimate/CTripEstimatePrice.java | 2 +- .../com/chint/domain/service/amount_estimate/CTripEstimate.java | 2 +- src/main/java/com/chint/domain/value_object/PriceQueryData.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 393564f8..62270cce 100644 --- a/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java +++ b/src/main/java/com/chint/application/queryies/estimate/CTripEstimatePrice.java @@ -118,7 +118,7 @@ public class CTripEstimatePrice implements EstimatePrice { HotelPriceData hotelPriceData = new HotelPriceData(); if (!travelStandards.isEmpty()) { String price = travelStandards.get(0).getPrice(); - String arriveData = priceQueryData.getArriveData(); + String arriveData = priceQueryData.getArriveDate(); String departDate = priceQueryData.getDepartDate(); if (arriveData != null) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); diff --git a/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java b/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java index 1c36a5d1..ae760c75 100644 --- a/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java +++ b/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java @@ -74,7 +74,7 @@ public class CTripEstimate implements AmountEstimate { priceQueryData.setArriveCity(leg.getDestinationLocation().getLocationName()); priceQueryData.setDepartCity(leg.getOriginLocation().getLocationName()); priceQueryData.setDepartDate(dateTimeFormatter.format(leg.getStartTime())); - priceQueryData.setArriveData(dateTimeFormatter.format(leg.getEndTime())); + priceQueryData.setArriveDate(dateTimeFormatter.format(leg.getEndTime())); return priceQueryData; } } diff --git a/src/main/java/com/chint/domain/value_object/PriceQueryData.java b/src/main/java/com/chint/domain/value_object/PriceQueryData.java index a98f4ee1..0fea9dd0 100644 --- a/src/main/java/com/chint/domain/value_object/PriceQueryData.java +++ b/src/main/java/com/chint/domain/value_object/PriceQueryData.java @@ -7,5 +7,5 @@ public class PriceQueryData { private String departCity; private String arriveCity; private String departDate; - private String arriveData; + private String arriveDate; } From 838f340ebf55c9757774b01043a0a7e451afb265 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Wed, 28 Feb 2024 14:03:30 +0800 Subject: [PATCH 5/5] =?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 --- src/main/resources/application-dev.yml | 2 +- src/main/resources/application-prod.yml | 2 +- src/main/resources/application-test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 123b1bb0..58d1ae82 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -56,7 +56,7 @@ FSSC: paila: client-id: 0053df85723db94491e8 client-secret: 7368bcec4c0f004c40585f6ed1087d887897 - redirect-url: https://gxdev03.chint.com/businesstravelhome/*.* + redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ 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 4fc270e2..acbeb3a9 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -26,6 +26,6 @@ FSSC: paila: client-id: 0053df85723db94491e8 client-secret: 7368bcec4c0f004c40585f6ed1087d887897 - redirect-url: https://gxdev03.chint.com/businesstravelhome/*.* + redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ 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 cc10ab02..bdad94d4 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -45,7 +45,7 @@ FSSC: paila: client-id: 0053df85723db94491e8 client-secret: 7368bcec4c0f004c40585f6ed1087d887897 - redirect-url: https://gxdev03.chint.com/businesstravelhome/*.* + redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ base-url: https://signin-test.chint.com token-name: token