diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java index e9721857..0499e5d0 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/CTripOrderExtensionFactoryImpl.java @@ -91,6 +91,10 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { } carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); + if(carOrderDetail.getOrderNo() == null || carOrderDetail.getDetailId() == null){ + carOrderDetail.setOrderNo(orderNo); + carOrderDetail.setDetailId(orderNo); + } return updateCarOrderDetailData(carOrderDetail, carOrderDetailData); } @@ -192,6 +196,10 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { flightOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); updateFlightOrderDetailData(flightOrderDetail, flightOrderInfoEntity); + if(flightOrderDetail.getOrderNo() == null || flightOrderDetail.getDetailId() == null){ + flightOrderDetail.setOrderNo(orderNo); + flightOrderDetail.setDetailId(orderNo); + } return flightOrderDetail; } @@ -528,6 +536,11 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory { first1.ifPresent(orderEvent -> hotelOrderDetail.setOverStandardReason(orderEvent.getExtension())); hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); + + if(hotelOrderDetail.getOrderNo() == null || hotelOrderDetail.getDetailId() == null){ + hotelOrderDetail.setOrderNo(orderNo); + hotelOrderDetail.setDetailId(orderNo); + } return hotelOrderDetail; } 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 fef73e58..b6be26a7 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 @@ -102,6 +102,11 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { } carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); + + if(carOrderDetail.getOrderNo() == null || carOrderDetail.getDetailId() == null){ + carOrderDetail.setOrderNo(orderSerialNo); + carOrderDetail.setDetailId(orderSerialNo); + } return updateCarOrderDetailData(carOrderDetail, data); } @@ -281,14 +286,15 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { FlightOrderResponse.Data data = (FlightOrderResponse.Data) flightOrderDetailData; FlightOrderResponse.OrderDetails orderDetails = data.getOrderDetails(); - OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderDetails.getOrderSerialNo()) + String orderSerialNo = orderDetails.getOrderSerialNo(); + OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderSerialNo) .orElseThrow(() -> new NotFoundException(NOT_FOUND)); RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId()); Optional first = routeOrder .getOrderDetails() .stream() - .filter(it -> it.getOrderNo().equals(orderDetails.getOrderSerialNo())) + .filter(it -> it.getOrderNo().equals(orderSerialNo)) .findFirst(); FlightOrderDetail flightOrderDetail = orderDetailFactory.buildFlightWithRouteOrderAndOrderDetail(routeOrder, first); @@ -312,6 +318,11 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { } flightOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); + + if(flightOrderDetail.getOrderNo() == null || flightOrderDetail.getDetailId() == null){ + flightOrderDetail.setOrderNo(orderSerialNo); + flightOrderDetail.setDetailId(orderSerialNo); + } return updateFlightOrderDetailData(flightOrderDetail, flightOrderDetailData); } @@ -410,6 +421,11 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { hotelOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); + + if(hotelOrderDetail.getOrderNo() == null || hotelOrderDetail.getDetailId() == null){ + hotelOrderDetail.setOrderNo(orderInfo.getOrderSerialNo()); + hotelOrderDetail.setDetailId(orderInfo.getOrderSerialNo()); + } return updateHotelOrderDetailData(hotelOrderDetail, data); } @@ -554,6 +570,11 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory { ); trainOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); + + if(trainOrderDetail.getOrderNo() == null || trainOrderDetail.getDetailId() == null){ + trainOrderDetail.setOrderNo(orderNo); + trainOrderDetail.setDetailId(orderNo); + } return updateTrainOrderDetailData(trainOrderDetail, trainDetailData); } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java index 2499df86..d8aff103 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java @@ -222,7 +222,6 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { }, () -> carOrderDetail.setOverStandard("否")); carOrderDetail.setOrderNo(orderDetail.getOrderNo()); carOrderDetail.setDetailId(orderDetail.getOrderNo()); - User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId()); carOrderDetail.setBookingUserCode(user.getEmployeeNo()); carOrderDetail.setBookingName(user.getName()); diff --git a/src/main/java/com/chint/infrastructure/constant/AmapConstant.java b/src/main/java/com/chint/infrastructure/constant/AmapConstant.java index 185e2d00..2b61e89f 100644 --- a/src/main/java/com/chint/infrastructure/constant/AmapConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/AmapConstant.java @@ -15,5 +15,5 @@ public class AmapConstant { public static final String CANCEL_AN_ORDER_URL = "/ws/car/open/enterprise/cancelOrder";//取消订单 //登录路径 - public static final String AMAP_LOGIN_PATH = "/ws/car/open/enterprise/order/detail"; + public static final String AMAP_LOGIN_PATH = "/node"; } diff --git a/src/main/java/com/chint/interfaces/rest/amap/AmapLoginRequest.java b/src/main/java/com/chint/interfaces/rest/amap/AmapLoginRequest.java index 7cd53963..81a3dc46 100644 --- a/src/main/java/com/chint/interfaces/rest/amap/AmapLoginRequest.java +++ b/src/main/java/com/chint/interfaces/rest/amap/AmapLoginRequest.java @@ -9,6 +9,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; + +import static com.chint.infrastructure.constant.AmapConstant.AMAP_LOGIN_PATH; + @Component public class AmapLoginRequest { @@ -22,8 +28,11 @@ public class AmapLoginRequest { private String baseLoginUrl; - private H5LoginResponse h5Login(User user) { + public H5LoginResponse h5Login(User user) { TokenResponse token = tokenRequest.getToken(user); - return null; + String tokenValue = token.getData().getToken(); + String loginUrl = baseLoginUrl + AMAP_LOGIN_PATH; + return H5LoginResponse.Success(loginUrl).token(tokenValue); } + } diff --git a/src/main/java/com/chint/interfaces/rest/base/dto/H5LoginResponse.java b/src/main/java/com/chint/interfaces/rest/base/dto/H5LoginResponse.java index 5f7efd49..4de323f7 100644 --- a/src/main/java/com/chint/interfaces/rest/base/dto/H5LoginResponse.java +++ b/src/main/java/com/chint/interfaces/rest/base/dto/H5LoginResponse.java @@ -7,4 +7,17 @@ public class H5LoginResponse { private String redirectUrl; private String htmlContent; private boolean success; + private String token; + + public static H5LoginResponse Success(String redirectUrl) { + H5LoginResponse h5LoginResponse = new H5LoginResponse(); + h5LoginResponse.setRedirectUrl(redirectUrl); + h5LoginResponse.setSuccess(true); + return h5LoginResponse; + } + + public H5LoginResponse token(String token) { + this.setToken(token); + return this; + } } diff --git a/src/test/java/com/chint/AmapTest.java b/src/test/java/com/chint/AmapTest.java index d2dc82a5..a3d811c7 100644 --- a/src/test/java/com/chint/AmapTest.java +++ b/src/test/java/com/chint/AmapTest.java @@ -1,6 +1,7 @@ package com.chint; import com.chint.domain.aggregates.user.User; +import com.chint.interfaces.rest.amap.AmapLoginRequest; import com.chint.interfaces.rest.amap.AmapUserRequest; import com.chint.interfaces.rest.amap.BaseResponse; import com.chint.interfaces.rest.amap.dto.UserQueryResponse; @@ -11,6 +12,7 @@ import com.chint.interfaces.rest.amap.request.OrderDetailRequest; import com.chint.interfaces.rest.amap.request.SettleBillRequest; import com.chint.interfaces.rest.amap.request.TakeCarRequest; import com.chint.interfaces.rest.amap.request.TokenRequest; +import com.chint.interfaces.rest.base.dto.H5LoginResponse; import com.google.gson.Gson; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +24,9 @@ public class AmapTest { @Autowired private AmapUserRequest amapUserRequest; + @Autowired + private AmapLoginRequest amapLoginRequest; + private Gson gson = new Gson(); private User user = new User(1L, "230615020", 1, "卢麟哲", "lulz1@chint.com", "15857193365", "A30000001"); @@ -45,6 +50,12 @@ public class AmapTest { System.out.println(gson.toJson(baseResponse)); } + @Test + public void login(){ + H5LoginResponse h5LoginResponse = amapLoginRequest.h5Login(user); + System.out.println(gson.toJson(h5LoginResponse.getRedirectUrl())); + } + @Autowired private TokenRequest tokenRequest;