From b4d8f012ca9656444350b2d32cbdf2776a9ef932 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Tue, 6 Feb 2024 15:06:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/LegRejectCommand.java | 9 + .../application/commands/LegSyncCommand.java | 10 +- .../application/out/LoginController.java | 27 +++ .../out/SupplierLoginController.java | 10 +- .../services/SupplierLoginService.java | 10 ++ .../chint/domain/aggregates/order/Leg.java | 39 +++-- .../domain/aggregates/order/LegEvent.java | 2 + .../domain/aggregates/order/RouteOrder.java | 1 + .../service/amount_estimate/LYEstimate.java | 2 +- .../service/leg_event/LegEventService.java | 1 + .../leg_event/LegEventServiceImpl.java | 62 ++++--- .../order_sync/CTripOrderSyncAdapter.java | 19 +- .../domain/value_object/SyncLegData.java | 1 + .../infrastructure/constant/Constant.java | 34 ++-- .../webconfig/JwtTokenAdminInterceptor.java | 6 +- .../interfaces/rest/base/PostRequest.java | 14 ++ .../rest/ctrip/CTripEstimateRequest.java | 2 +- .../rest/ctrip/CTripLoginRequest.java | 162 ++++++++++++------ .../rest/ctrip/CTripSyncRequest.java | 4 + .../rest/ctrip/CTripUserSaveRequest.java | 11 +- .../ctrip/dto/approval/quick/RankInfo.java | 5 + .../rest/ctrip/dto/login/H5LoginToken.java | 9 + .../rest/ctrip/dto/login/H5Response.java | 9 + .../rest/ctrip/dto/login/H5TicketModel.java | 19 ++ .../rest/ctrip/dto/login/PageViewData.java | 11 ++ .../interfaces/rest/ly/LYUserRequest.java | 1 + src/test/java/com/chint/CTripTest.java | 30 ++-- 27 files changed, 366 insertions(+), 144 deletions(-) create mode 100644 src/main/java/com/chint/application/commands/LegRejectCommand.java create mode 100644 src/main/java/com/chint/interfaces/rest/ctrip/CTripSyncRequest.java create mode 100644 src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5LoginToken.java create mode 100644 src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5Response.java create mode 100644 src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5TicketModel.java create mode 100644 src/main/java/com/chint/interfaces/rest/ctrip/dto/login/PageViewData.java diff --git a/src/main/java/com/chint/application/commands/LegRejectCommand.java b/src/main/java/com/chint/application/commands/LegRejectCommand.java new file mode 100644 index 00000000..e9185762 --- /dev/null +++ b/src/main/java/com/chint/application/commands/LegRejectCommand.java @@ -0,0 +1,9 @@ +package com.chint.application.commands; + +import com.chint.infrastructure.echo_framework.command.Command; + +import static com.chint.infrastructure.constant.Constant.LEG_EVENT_NOT_ORDERED; + +public class LegRejectCommand extends Command { + private Integer LegEventType = LEG_EVENT_NOT_ORDERED; +} diff --git a/src/main/java/com/chint/application/commands/LegSyncCommand.java b/src/main/java/com/chint/application/commands/LegSyncCommand.java index e50a7e3a..c7f257b6 100644 --- a/src/main/java/com/chint/application/commands/LegSyncCommand.java +++ b/src/main/java/com/chint/application/commands/LegSyncCommand.java @@ -9,14 +9,12 @@ import static com.chint.infrastructure.constant.Constant.LEG_EVENT_NOT_ORDERED; @Data public class LegSyncCommand extends Command { private Integer LegEventType = LEG_EVENT_NOT_ORDERED; - private Long LegId; - private Long routOrderId; private SyncLegData data; - public LegSyncCommand legId(Long LegId) { - this.setLegId(LegId); - return this; - } +// public LegSyncCommand legId(Long LegId) { +// this.setLegId(LegId); +// return this; +// } public LegSyncCommand data(SyncLegData data) { this.data = data; diff --git a/src/main/java/com/chint/application/out/LoginController.java b/src/main/java/com/chint/application/out/LoginController.java index bd8ea167..1bc5ab1a 100644 --- a/src/main/java/com/chint/application/out/LoginController.java +++ b/src/main/java/com/chint/application/out/LoginController.java @@ -2,12 +2,16 @@ package com.chint.application.out; import com.chint.application.commands.OrderCreateCommand; +import com.chint.domain.aggregates.user.User; import com.chint.domain.service.auth.AuthenticateService; import com.chint.domain.value_object.UserLoginParam; import com.chint.domain.value_object.UserLoginResult; import com.chint.infrastructure.echo_framework.command.Command; +import com.chint.infrastructure.util.BaseContext; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; @@ -15,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.concurrent.CompletableFuture; + import static com.chint.infrastructure.constant.Constant.*; @RestController @@ -24,6 +30,12 @@ public class LoginController { @Autowired private AuthenticateService authenticateService; + @Autowired + private LYUserRequest lyUserRequest; + + @Autowired + private CTripUserSaveRequest cTripUserSaveRequest; + @Transactional @GetMapping("/login") public Result login(@RequestParam("sfno") String sfno, @@ -41,6 +53,21 @@ public class LoginController { .authenticateEmployeeNo(userLoginParam); //发送创建行程订单命令 Command.of(OrderCreateCommand.class).of(userLoginParam).sendToQueue(); + + //异步执行更新用户信息到同程 + User currentUser = userLoginResult.getUser(); + CompletableFuture.runAsync(() -> { + BaseContext.setCurrentUser(currentUser); + lyUserRequest.saveCurrentUser(); + BaseContext.removeCurrentUser(); + }); + //异步执行更新用户信息到携程 + CompletableFuture.runAsync(() -> { + BaseContext.setCurrentUser(currentUser); + cTripUserSaveRequest.saveUserToCTrip(); + BaseContext.removeCurrentUser(); + }); + return Result.Success(SUCCESS, userLoginResult); } else { return Result.error(SIGN_ERROR); diff --git a/src/main/java/com/chint/application/out/SupplierLoginController.java b/src/main/java/com/chint/application/out/SupplierLoginController.java index b332a9a8..e83d1359 100644 --- a/src/main/java/com/chint/application/out/SupplierLoginController.java +++ b/src/main/java/com/chint/application/out/SupplierLoginController.java @@ -3,7 +3,9 @@ package com.chint.application.out; import com.chint.application.services.SupplierLoginService; import com.chint.infrastructure.util.Result; +import com.chint.interfaces.rest.ctrip.dto.login.H5Response; import com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,16 +20,18 @@ public class SupplierLoginController { @Autowired private SupplierLoginService supplierLoginService; + @ApiOperation("单点登录同程") @PostMapping("/ly/login") public Result lyLogin() { //登录 LYRedirectUrlResponse data = supplierLoginService.lyLogin(); - return Result.Success(SUCCESS,data); + return Result.Success(SUCCESS, data); } + @ApiOperation("单点登录携程") @PostMapping("/CTrip/login") - public Result cTripLogin() { - return Result.Success(SUCCESS); + public Result cTripLogin() { + return Result.Success(SUCCESS, supplierLoginService.cTripLogin()); } } diff --git a/src/main/java/com/chint/application/services/SupplierLoginService.java b/src/main/java/com/chint/application/services/SupplierLoginService.java index bcdddcb8..56420150 100644 --- a/src/main/java/com/chint/application/services/SupplierLoginService.java +++ b/src/main/java/com/chint/application/services/SupplierLoginService.java @@ -1,5 +1,7 @@ package com.chint.application.services; +import com.chint.interfaces.rest.ctrip.CTripLoginRequest; +import com.chint.interfaces.rest.ctrip.dto.login.H5Response; import com.chint.interfaces.rest.ly.LYLoginRequest; import com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse; import org.springframework.beans.factory.annotation.Autowired; @@ -13,10 +15,18 @@ public class SupplierLoginService { @Autowired private LYLoginRequest lyLoginRequest; + + @Autowired + private CTripLoginRequest cTripLoginRequest; + /** * 登录接口 */ public LYRedirectUrlResponse lyLogin() { return lyLoginRequest.login(L_Y_ENTRANCE_HOME); } + + public H5Response cTripLogin() { + return cTripLoginRequest.hSingleLogin(); + } } diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index d1104ca9..f6008f5e 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -13,10 +13,7 @@ import org.springframework.data.relational.core.mapping.MappedCollection; import org.springframework.data.relational.core.mapping.Table; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; +import java.util.*; import static com.chint.infrastructure.constant.Constant.*; @@ -75,22 +72,23 @@ public class Leg { } public Leg reloadStatus() { - if (eventList == null) { + if (eventList == null || eventList.isEmpty()) { this.legStatus = LEG_STATUS_PREPARE; } else { - int eventLength = eventList.size() - 1; - this.legStatus = eventLength < 0 ? LEG_STATUS_PREPARE : eventLength; - if (legStatus > 1) { - Optional legEvent = this.eventList - .stream() - .filter(event -> event.getEventType().equals(LEG_EVENT_ORDERED)) - .findFirst(); - if (legEvent.isPresent()) { - LegEvent event = legEvent.get(); - this.amount = event.getOrderDetail().getAmount(); - } + // Find the latest event based on the maximum id + LegEvent latestEvent = this.eventList.stream() + .max(Comparator.comparingLong(LegEvent::getLegEventId)) + .orElse(null); + + // Set the legStatus based on the type of the latest event + this.legStatus = latestEvent.getEventType(); + + // If the latest event is an order event, update the amount + if (latestEvent.getEventType().equals(LEG_EVENT_ORDERED)) { + this.amount = latestEvent.getOrderDetail().getAmount(); } } + this.legStatusName = translateLegStatus(this.legStatus); if (legType != null) { this.legTypeName = translateLegType(this.legType); @@ -98,6 +96,7 @@ public class Leg { return this; } + public Leg reloadStatus(LegData legData) { this.reloadStatus(); if (Objects.equals(legData.getLegId(), this.getLegId()) && this.legStatus.equals(LEG_STATUS_PREPARE)) { @@ -118,6 +117,7 @@ public class Leg { case LEG_STATUS_PAYED -> LEG_STATUS_PAYED_NAME; case LEG_STATUS_FINISH -> LEG_STATUS_FINISH_NAME; case LEG_STATUS_NOT_ORDERED -> LEG_STATUS_NOT_ORDERED_NAME; + case LEG_STATUS_REJECT -> LEG_STATUS_REJECT_NAME; default -> "未知状态"; }; } @@ -151,11 +151,16 @@ public class Leg { throw new LegEventException("The first event must be a prepare event."); } + // 事件类型为负数,代表是可以任何时机都可进行的事件 + if(event.getEventType() < 0) { + eventList.add(event); + return this; + } + // 如果列表不为空,确保新事件的类型是按顺序的 if (!eventList.isEmpty()) { LegEvent lastEvent = eventList.get(eventList.size() - 1); int lastEventType = lastEvent.getEventType(); - if (newEventType != lastEventType + 1) { throw new LegEventException("Events must be added in sequence."); } diff --git a/src/main/java/com/chint/domain/aggregates/order/LegEvent.java b/src/main/java/com/chint/domain/aggregates/order/LegEvent.java index 5262949d..00178b06 100644 --- a/src/main/java/com/chint/domain/aggregates/order/LegEvent.java +++ b/src/main/java/com/chint/domain/aggregates/order/LegEvent.java @@ -35,6 +35,8 @@ public class LegEvent { case LEG_EVENT_PAYED -> LEG_EVENT_PAYED_NAME; case LEG_EVENT_FINISH -> LEG_EVENT_FINISH_NAME; case LEG_EVENT_NOT_ORDERED -> LEG_EVENT_NOT_ORDERED_NAME; + case LEG_EVENT_APPROVAL -> LEG_EVENT_APPROVAL_NAME; + case LEG_EVENT_REJECT -> LEG_EVENT_REJECT_NAME; default -> "未知事件"; }; } 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 50ea3bf1..5d9e164e 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -190,6 +190,7 @@ public class RouteOrder extends BaseEntity { case ORDER_STATUS_PAYED -> ORDER_STATUS_PAYED_NAME; case ORDER_STATUS_FINISH -> ORDER_STATUS_FINISH_NAME; case ORDER_STATUS_NOT_ORDERED -> ORDER_STATUS_NOT_ORDERED_NAME; + case ORDER_STATUS_REJECT -> ORDER_STATUS_REJECT_NAME; default -> "未知状态"; }; } diff --git a/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java b/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java index 1ec94f03..26acfe87 100644 --- a/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java +++ b/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java @@ -65,7 +65,7 @@ public class LYEstimate implements AmountEstimate { TrainMaxPrice trainMaxPrice = new TrainMaxPrice(); trainMaxPrice.setTicketType(0); trainMaxPrice.setDepartDate(leg.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));//开始时间 - trainMaxPrice.setDepartCityName(leg.getOriginLocationId().getLocationName());//出发城市 + trainMaxPrice.setDepartCityName(leg.getOriginLocation().getLocationName());//出发城市 trainMaxPrice.setArriveCityName(leg.getDestinationLocation().getLocationName());//到达城市 Description description = new Description<>(); description.setParam(trainMaxPrice); diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventService.java b/src/main/java/com/chint/domain/service/leg_event/LegEventService.java index 3fef58f2..c917091e 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventService.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventService.java @@ -16,4 +16,5 @@ public interface LegEventService { void payForLeg(LegPayedCommand command); //结束 void finishLeg(LegFinishedCommand command); + void rejectLeg(LegRejectCommand command); } \ No newline at end of file diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java index 9a852733..bf7b29de 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java @@ -2,6 +2,7 @@ package com.chint.domain.service.leg_event; import com.chint.application.commands.*; import com.chint.domain.aggregates.order.*; +import com.chint.domain.exceptions.CommandException; import com.chint.domain.factoriy.leg_event.LegEventFactory; import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.RouteRepository; @@ -10,12 +11,13 @@ import com.chint.domain.value_object.ApproveLegData; import com.chint.domain.value_object.OrderLegData; import com.chint.domain.value_object.PayLegData; import com.chint.domain.value_object.SyncLegData; - import com.chint.infrastructure.echo_framework.annotation.ListenTo; import com.chint.infrastructure.echo_framework.annotation.TransitionTo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; + +import static com.chint.infrastructure.constant.Constant.ORDER_STATUS_APPROVAL; +import static com.chint.infrastructure.constant.Constant.ORDER_STATUS_PREPARE; @Service public class LegEventServiceImpl implements LegEventService { @@ -52,17 +54,22 @@ public class LegEventServiceImpl implements LegEventService { public void approveLeg(LegApprovalCommand command) { ApproveLegData data = command.getData(); RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo()); - ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); - approveOrderNo.setActualOrderNo(data.getActualOrderNo()); - approveOrderNo.setAccountCompany(data.getAccountCompany()); - //这里order所有的leg触发approve事件 - routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( - legEventFactory.creatLegEvent(command.getLegEventType()) - )); + if (routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE)){ + ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); + approveOrderNo.setActualOrderNo(data.getActualOrderNo()); + approveOrderNo.setAccountCompany(data.getAccountCompany()); - //保存routeOrder的状态 - routeRepository.save(routeOrder); + //这里order所有的leg触发approve事件 + routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( + legEventFactory.creatLegEvent(command.getLegEventType()) + )); + + //保存routeOrder的状态 + routeRepository.save(routeOrder); + } else { + throw new CommandException("订单未初始化"); + } } //这里需要获取同步类,价格routeOrder同步到供应商 @@ -70,16 +77,20 @@ public class LegEventServiceImpl implements LegEventService { @Override public void syncLeg(LegSyncCommand command) { SyncLegData data = command.getData(); - RouteOrder routeOrder = routeRepository.queryById(command.getRoutOrderId()); - String supplierName = data.getSupplierName(); - routeOrder.setSupplierName(supplierName); - //这里order所有的leg触发approve事件 - routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( - legEventFactory.creatLegEvent(command.getLegEventType()) - )); - syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus()); - //保存routeOrder的状态 - routeRepository.save(routeOrder); + RouteOrder routeOrder = routeRepository.queryById(data.getRouteId()); + if (routeOrder.getOrderStatus().equals(ORDER_STATUS_APPROVAL)) { + String supplierName = data.getSupplierName(); + routeOrder.setSupplierName(supplierName); + //这里order所有的leg触发approve事件 + routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( + legEventFactory.creatLegEvent(command.getLegEventType()) + )); + syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus()); + //保存routeOrder的状态 + routeRepository.save(routeOrder); + } else { + throw new CommandException("订单未提交审批"); + } } @@ -121,4 +132,13 @@ public class LegEventServiceImpl implements LegEventService { leg.addEvent(legEvent); legRepository.save(leg); } + + @Override + @ListenTo(command = "LegRejectCommand", order = 0) + public void rejectLeg(LegRejectCommand command) { +// Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); +// LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); +// leg.addEvent(legEvent); +// legRepository.save(leg); + } } diff --git a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java index d2b503a4..9d9f86ea 100644 --- a/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java +++ b/src/main/java/com/chint/domain/service/order_sync/CTripOrderSyncAdapter.java @@ -1,8 +1,14 @@ package com.chint.domain.service.order_sync; +import com.chint.domain.aggregates.order.ApproveOrderNo; import com.chint.domain.aggregates.order.RouteOrder; +import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.CityRepository; import com.chint.domain.repository.LocationRepository; +import com.chint.infrastructure.util.BaseContext; +import com.chint.interfaces.rest.ctrip.CTripApprovalRequest; +import com.chint.interfaces.rest.ctrip.dto.approval.ApprovalRequest; +import com.chint.interfaces.rest.ctrip.dto.approval.quick.RankInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -12,10 +18,21 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync { @Autowired private CityRepository cityRepository; + @Autowired + private CTripApprovalRequest approvalRequest; + @Autowired private LocationRepository locationRepository; + @Override public void syncSupplierOrder(RouteOrder order) { - System.out.println("开始同步协程订单"); +// User currentUser = BaseContext.getCurrentUser(); +// ApproveOrderNo approveOrderNo = order.getApproveOrderNo(); +// new RankInfo() +// ApprovalRequest.buildApproval(currentUser.getEmployeeNo(), approveOrderNo.getActualOrderNo(), ) +// +// approvalRequest.approval() +// +// System.out.println("开始同步协程订单"); } } diff --git a/src/main/java/com/chint/domain/value_object/SyncLegData.java b/src/main/java/com/chint/domain/value_object/SyncLegData.java index d24aee3f..56ae6543 100644 --- a/src/main/java/com/chint/domain/value_object/SyncLegData.java +++ b/src/main/java/com/chint/domain/value_object/SyncLegData.java @@ -4,5 +4,6 @@ import lombok.Data; @Data public class SyncLegData { + private Long routeId; private String supplierName; } diff --git a/src/main/java/com/chint/infrastructure/constant/Constant.java b/src/main/java/com/chint/infrastructure/constant/Constant.java index 05809b5a..e202d6df 100644 --- a/src/main/java/com/chint/infrastructure/constant/Constant.java +++ b/src/main/java/com/chint/infrastructure/constant/Constant.java @@ -52,6 +52,8 @@ public class Constant { public static final String ORDER_STATUS_PAYED_NAME = "已付款"; public static final int ORDER_STATUS_FINISH = 5; public static final String ORDER_STATUS_FINISH_NAME = "已结束"; + public static final int ORDER_STATUS_REJECT = -1; + public static final String ORDER_STATUS_REJECT_NAME = "审批拒绝"; // 规划节点状态 public static final int LEG_STATUS_PREPARE = 0; @@ -66,6 +68,8 @@ public class Constant { public static final String LEG_STATUS_PAYED_NAME = "已付款"; public static final int LEG_STATUS_FINISH = 5; public static final String LEG_STATUS_FINISH_NAME = "已结束"; + public static final int LEG_STATUS_REJECT = -1; + public static final String LEG_STATUS_REJECT_NAME = "审批未通过"; // 规划节点运输方式 public static final int LEG_TYPE_TRAIN = 0; @@ -85,13 +89,15 @@ public class Constant { public static final int LEG_EVENT_APPROVAL = 1; public static final String LEG_EVENT_APPROVAL_NAME = "审批事件"; public static final int LEG_EVENT_NOT_ORDERED = 2; - public static final String LEG_EVENT_NOT_ORDERED_NAME = "审批事件"; + public static final String LEG_EVENT_NOT_ORDERED_NAME = "同步事件"; public static final int LEG_EVENT_ORDERED = 3; public static final String LEG_EVENT_ORDERED_NAME = "下单事件"; public static final int LEG_EVENT_PAYED = 4; public static final String LEG_EVENT_PAYED_NAME = "付款事件"; public static final int LEG_EVENT_FINISH = 5; public static final String LEG_EVENT_FINISH_NAME = "结束事件"; + public static final int LEG_EVENT_REJECT = -1; + public static final String LEG_EVENT_REJECT_NAME = "拒绝事件"; // 金额 public static final String KEEP_TWO_DECIMAL_ZERO = "0.00"; @@ -131,9 +137,11 @@ public class Constant { public static final String TICKET_PATH = "/SwitchAPI/Order/Ticket"; public static final String C_TRIP_LOGIN_PATH = "/singlesignon/openapi/saml/login"; public static final String C_TRIP_ENTITY_ID = "/zhengtai"; - public static final String C_TRIP_CORP_ID = "zhengtai"; - public static final String C_TRIP_APP_KEY = "obk_zhengtai"; // 测试appkey - public static final String C_TRIP_APP_SECURITY = "gV417qxpou5bFlh2C93c452T"; // 测试app秘钥 + public static final String C_TRIP_APP_ID = "zhengtai2024"; + public static final String C_TRIP_CORP_ID = "zhengtai2024"; + public static final String C_TRIP_APP_KEY = "obk_zhengtai2024"; // 测试appkey + public static final String C_TRIP_APP_SECURITY = "fI3}FZX+zUdxPa2W!R6I2gYO"; // 测试app秘钥 + public static final String C_TRIP_H5_LOGIN = "/corpservice/authorize/getticket"; // 测试app秘钥 public static final String USER_SAVE_PATH = "/corpservice/CorpCustService/SaveCorpCustInfoList"; public static final String HOTEL_CITY_PATH = "/corpopenapi/HotelCity/GetCountryCityExtend"; public static final String HOTEL_COUNTRY_PATH = "/corpopenapi/HotelCity/GetCountry"; @@ -163,15 +171,15 @@ public class Constant { public static final String L_Y_ACCOUNT = "4f9cb1080b564dd0a94aa95f7a19c8b5"; // 测试appkey public static final String L_Y_PASSWORD = "1fD3SutgzfS48qznYQiq"; // 测试app秘钥 public static final String L_Y_SECRET = "WOHzCMvHd823iHgH"; // 测试app秘钥 - public static final Integer L_Y_PLAT_PC = 0; // 测试app秘钥 - public static final Integer L_Y_PLAT_H5 = 1; // 测试app秘钥 - public static final Integer L_Y_ENTRANCE_HOME = 0; // 测试app秘钥 - public static final Integer L_Y_ENTRANCE_AIR_ORDER = 11; // 测试app秘钥page - public static final Integer L_Y_ENTRANCE_AIR_DETAIL = 1; // 测试app秘钥 - public static final Integer L_Y_ENTRANCE_AIR_ORDER_OVERSEA = 22; // 测试app秘钥 - public static final Integer L_Y_ENTRANCE_AIR_DETAIL_OVERSEA = 2; // 测试app秘钥 - public static final Integer L_Y_ENTRANCE_HOTEL_ORDER = 33; // 测试app秘钥 - public static final Integer L_Y_ENTRANCE_HOTEL_DETAIL = 3; // 测试app秘钥 + public static final Integer L_Y_PLAT_PC = 0; // + public static final Integer L_Y_PLAT_H5 = 1; // + public static final Integer L_Y_ENTRANCE_HOME = 0; // + public static final Integer L_Y_ENTRANCE_AIR_ORDER = 11; // + public static final Integer L_Y_ENTRANCE_AIR_DETAIL = 1; // + public static final Integer L_Y_ENTRANCE_AIR_ORDER_OVERSEA = 22; // + public static final Integer L_Y_ENTRANCE_AIR_DETAIL_OVERSEA = 2; // + public static final Integer L_Y_ENTRANCE_HOTEL_ORDER = 33; // + public static final Integer L_Y_ENTRANCE_HOTEL_DETAIL = 3; // public static final Integer L_Y_TRAVEL_TYPE_ALL = 0; // 全部(因公因私) public static final Integer L_Y_TRAVEL_TYPE_PERSON = 1; // (因公) public static final Integer L_Y_TRAVEL_TYPE_NO_PERSON = 2; // (因私) diff --git a/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java b/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java index 2828c38e..da87d686 100644 --- a/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java +++ b/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java @@ -16,9 +16,9 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String token = request.getHeader(HEADER_TOKEN); - if (request.getRequestURI().endsWith("/login")) { - return true; - } +// if (request.getRequestURI().endsWith("/login")) { +// return true; +// } if (request.getRequestURI().contains("/pubilc")) { return true; } diff --git a/src/main/java/com/chint/interfaces/rest/base/PostRequest.java b/src/main/java/com/chint/interfaces/rest/base/PostRequest.java index 73d4a511..51216c99 100644 --- a/src/main/java/com/chint/interfaces/rest/base/PostRequest.java +++ b/src/main/java/com/chint/interfaces/rest/base/PostRequest.java @@ -55,6 +55,20 @@ public class PostRequest { return gson.fromJson(responseBody, responseType); } + public T post(HttpPost post, Class responseType) { + String responseBody = null; + HttpEntity responseEntity = null; + HttpResponse response = null; + try { + response = client.execute(post); + responseEntity = response.getEntity(); + responseBody = EntityUtils.toString(responseEntity, "UTF-8"); + } catch (IOException e) { + throw new RuntimeException(e); + } + return gson.fromJson(responseBody, responseType); + } + public Gson gson() { return gson; } 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 988504e2..cc62f048 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripEstimateRequest.java @@ -62,7 +62,7 @@ public class CTripEstimateRequest { .done() .valuationProductInfo() .addFlightProductInfo(flightProductInfo) -// .addTrainProductInfo(trainProductInfo) + .addTrainProductInfo(trainProductInfo) .done() .done() .build(); diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripLoginRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripLoginRequest.java index 1ed86bf9..761be83e 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripLoginRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripLoginRequest.java @@ -1,22 +1,19 @@ package com.chint.interfaces.rest.ctrip; +import com.chint.domain.aggregates.user.User; +import com.chint.domain.exceptions.NotFoundException; +import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.Digest; -import com.chint.infrastructure.util.Result; import com.chint.interfaces.rest.base.PostRequest; -import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList; -import com.chint.interfaces.rest.ctrip.dto.login.CTripAuthLoginParam; -import com.chint.interfaces.rest.ctrip.dto.login.CTripHSingleLoginParam; -import com.chint.interfaces.rest.ctrip.dto.login.CTripLoginParam; -import com.chint.interfaces.rest.ly.dto.LYBaseRequest; +import com.chint.interfaces.rest.ctrip.dto.login.*; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -24,6 +21,8 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -50,6 +49,7 @@ public class CTripLoginRequest { //H5单点登录 private String singleLoginUrl = C_TRIP_BASE_URL + C_TRIP_SINGLE_LOGIN; + private String singleTokenUrl = C_TRIP_BASE_URL + C_TRIP_H5_LOGIN; private String IDPEntityID = C_TRIP_ENTITY_ID; private String corpId = C_TRIP_CORP_ID; @@ -66,26 +66,26 @@ public class CTripLoginRequest { authLoginParam.setTicket(ticket); String appKey = C_TRIP_APP_KEY; - String uid = StringUtils.isNotBlank(authLoginParam.getUID())?authLoginParam.getUID():""; + String uid = StringUtils.isNotBlank(authLoginParam.getUID()) ? authLoginParam.getUID() : ""; - String employeeId = StringUtils.isNotBlank(authLoginParam.getEmployeeID())?authLoginParam.getEmployeeID():""; - String email = StringUtils.isNotBlank(authLoginParam.getEmail())?authLoginParam.getEmail():""; - String ta = StringUtils.isNotBlank(authLoginParam.getTA())?authLoginParam.getTA():""; - Integer forCorp = authLoginParam.getForCorp() == null? authLoginParam.getForCorp():0; + String employeeId = StringUtils.isNotBlank(authLoginParam.getEmployeeID()) ? authLoginParam.getEmployeeID() : ""; + String email = StringUtils.isNotBlank(authLoginParam.getEmail()) ? authLoginParam.getEmail() : ""; + String ta = StringUtils.isNotBlank(authLoginParam.getTA()) ? authLoginParam.getTA() : ""; + Integer forCorp = authLoginParam.getForCorp() == null ? authLoginParam.getForCorp() : 0; String forCopStr = forCorp.toString(); - String cost1 = StringUtils.isNotBlank(authLoginParam.getCost1())?authLoginParam.getCost1():""; - if (isContainsChinese(cost1)){ + String cost1 = StringUtils.isNotBlank(authLoginParam.getCost1()) ? authLoginParam.getCost1() : ""; + if (isContainsChinese(cost1)) { ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost1); cost1 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); } - String cost2 = StringUtils.isNotBlank(authLoginParam.getCost2())?authLoginParam.getCost2():""; - if (isContainsChinese(cost2)){ + String cost2 = StringUtils.isNotBlank(authLoginParam.getCost2()) ? authLoginParam.getCost2() : ""; + if (isContainsChinese(cost2)) { ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost2); cost2 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); } - String cost3 = StringUtils.isNotBlank(authLoginParam.getCost3())?authLoginParam.getCost3():""; - if (isContainsChinese(cost3)){ + String cost3 = StringUtils.isNotBlank(authLoginParam.getCost3()) ? authLoginParam.getCost3() : ""; + if (isContainsChinese(cost3)) { ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost3); cost3 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); } @@ -93,7 +93,7 @@ public class CTripLoginRequest { String finallySign = - Digest.md5(appKey+uid+employeeId+email+ta+forCopStr+cost1+cost2+cost3+mdAppSecurity); + Digest.md5(appKey + uid + employeeId + email + ta + forCopStr + cost1 + cost2 + cost3 + mdAppSecurity); authLoginParam.setSignature(finallySign); // Result post = postRequest.post(authLoginUrl, authLoginParam, Result.class); @@ -101,13 +101,12 @@ public class CTripLoginRequest { // HttpClient client = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(authLoginUrl); List entitys = new ArrayList<>(); - entitys.add(new BasicNameValuePair("AppKey",appKey)); - entitys.add(new BasicNameValuePair("Token",token)); - - entitys.add(new BasicNameValuePair("Ticket",ticket)); - entitys.add(new BasicNameValuePair("EmployeeID",authLoginParam.getEmployeeID())); - entitys.add(new BasicNameValuePair("Signature",finallySign)); - entitys.add(new BasicNameValuePair("ForCorp","0")); + entitys.add(new BasicNameValuePair("AppKey", appKey)); + entitys.add(new BasicNameValuePair("Token", token)); + entitys.add(new BasicNameValuePair("Ticket", ticket)); + entitys.add(new BasicNameValuePair("EmployeeID", employeeId)); + entitys.add(new BasicNameValuePair("Signature", finallySign)); + entitys.add(new BasicNameValuePair("ForCorp", "0")); try { httpPost.setEntity(new UrlEncodedFormEntity(entitys)); @@ -123,55 +122,64 @@ public class CTripLoginRequest { } - public HttpResponse hSingleLogin(CTripHSingleLoginParam hSingleLoginParam) { - String ticket = ticketRequest.loadTicket(); - String token = tokenRequest.getToken(); + public H5Response hSingleLogin() { + CTripHSingleLoginParam hSingleLoginParam = new CTripHSingleLoginParam(); + User currentUser = BaseContext.getCurrentUser(); + H5LoginToken h5TokenResponse = postRequest.post(singleTokenUrl, H5TicketModel.build(), H5LoginToken.class); + String token = h5TokenResponse.getToken(); String accessUserId = C_TRIP_APP_KEY; - String employeeId = StringUtils.isNotBlank(hSingleLoginParam.getEmployeeId())?hSingleLoginParam.getEmployeeId():""; - String corpPayType = StringUtils.isNotBlank(hSingleLoginParam.getCorpPayType())? - hSingleLoginParam.getCorpPayType():"public"; + String employeeId = String.valueOf(currentUser.getEmployeeNo()); + String corpPayType = StringUtils.isNotBlank(hSingleLoginParam.getCorpPayType()) ? + hSingleLoginParam.getCorpPayType() : "public"; - String costCenter1 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter1())? - hSingleLoginParam.getCostCenter1():""; - if (isContainsChinese(costCenter1)){ + String costCenter1 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter1()) ? + hSingleLoginParam.getCostCenter1() : ""; + if (isContainsChinese(costCenter1)) { ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter1); costCenter1 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); } - String costCenter2 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter2())? - hSingleLoginParam.getCostCenter2():""; - if (isContainsChinese(costCenter2)){ + String costCenter2 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter2()) ? + hSingleLoginParam.getCostCenter2() : ""; + if (isContainsChinese(costCenter2)) { ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter2); costCenter2 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); } - String costCenter3 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter3())? - hSingleLoginParam.getCostCenter3():""; - if (isContainsChinese(costCenter3)){ + String costCenter3 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter3()) ? + hSingleLoginParam.getCostCenter3() : ""; + if (isContainsChinese(costCenter3)) { ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter3); costCenter3 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); } - String mdAppSecurity = Digest.md5(C_TRIP_APP_SECURITY); + String mdAppSecurity = getMD5Hash(C_TRIP_APP_SECURITY); + String signOrigin = accessUserId + employeeId + corpPayType + costCenter1 + costCenter2 + costCenter3 + mdAppSecurity; + System.out.println(signOrigin); String finallySign = - Digest.md5(accessUserId+employeeId+corpPayType+costCenter1+costCenter2+costCenter3+mdAppSecurity); + getMD5Hash(signOrigin); hSingleLoginParam.setSignature(finallySign); HttpPost httpPost = new HttpPost(hSinngleLoginUrl); List entitys = new ArrayList<>(); - entitys.add(new BasicNameValuePair("accessUserId",accessUserId)); - entitys.add(new BasicNameValuePair("employeeId",employeeId)); - entitys.add(new BasicNameValuePair("token",token)); - entitys.add(new BasicNameValuePair("appId","zhengtai")); - entitys.add(new BasicNameValuePair("signature",finallySign)); - entitys.add(new BasicNameValuePair("corpPayType","public")); + entitys.add(new BasicNameValuePair("accessUserId", accessUserId)); + entitys.add(new BasicNameValuePair("employeeId", employeeId)); + entitys.add(new BasicNameValuePair("token", token)); + entitys.add(new BasicNameValuePair("appId", C_TRIP_APP_ID)); + entitys.add(new BasicNameValuePair("signature", finallySign)); + entitys.add(new BasicNameValuePair("corpPayType", corpPayType)); try { - UrlEncodedFormEntity entity = new UrlEncodedFormEntity(entitys,"UTF-8"); - + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(entitys, "UTF-8"); httpPost.setEntity(entity); HttpClient client = new DefaultHttpClient(); try { - return client.execute(httpPost); + HttpResponse execute = client.execute(httpPost); + String body = EntityUtils.toString(execute.getEntity(), "UTF-8"); + String url = getUrlFromHtml(body); + H5Response h5Response = new H5Response(); + h5Response.setSuccess(true); + h5Response.setRedirectUrl(url); + return h5Response; } catch (IOException e) { throw new RuntimeException(e); } @@ -186,4 +194,52 @@ public class CTripLoginRequest { return matcher.find(); } + + public H5Response h5Login() { + User currentUser = BaseContext.getCurrentUser(); + + + CTripHSingleLoginParam cTripHSingleLoginParam = new CTripHSingleLoginParam(); + cTripHSingleLoginParam.setAppId(C_TRIP_APP_KEY); + cTripHSingleLoginParam.setEmployeeId(String.valueOf(currentUser.getEmployeeNo())); + cTripHSingleLoginParam.setToken(tokenRequest.getToken()); + cTripHSingleLoginParam.setAppId("zhengtai"); + cTripHSingleLoginParam.setCorpPayType("public"); + + + String finallySign = + Digest.md5(C_TRIP_APP_KEY + currentUser.getEmployeeNo() + "public" + Digest.md5(C_TRIP_APP_SECURITY)); + cTripHSingleLoginParam.setSignature(finallySign); + + return postRequest.post(hSinngleLoginUrl, cTripHSingleLoginParam, H5Response.class); + } + + + public String getMD5Hash(String source) { + StringBuilder sb = new StringBuilder(); + MessageDigest md5; + try { + md5 = MessageDigest.getInstance("MD5"); + md5.update(source.getBytes()); + for (byte b : md5.digest()) { + sb.append(String.format("%02x", b)); + } + return sb.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return null; + } + + private static String getUrlFromHtml(String htmlContent) { + String regexPattern = "var config = \\{\"url\":\"(.*?)\",\"appid\":"; + Pattern pattern = Pattern.compile(regexPattern); + Matcher matcher = pattern.matcher(htmlContent); + + if (matcher.find()) { + return matcher.group(1); + } else { + throw new NotFoundException(NOT_FOUND); + } + } } diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripSyncRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripSyncRequest.java new file mode 100644 index 00000000..188adb1e --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripSyncRequest.java @@ -0,0 +1,4 @@ +package com.chint.interfaces.rest.ctrip; + +public class CTripSyncRequest { +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java b/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java index ea46ecd2..c243433b 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/CTripUserSaveRequest.java @@ -3,13 +3,14 @@ package com.chint.interfaces.rest.ctrip; import com.chint.domain.aggregates.user.User; import com.chint.infrastructure.util.BaseContext; import com.chint.interfaces.rest.base.PostRequest; +import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList; import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationEntity; import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationInfo; import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationListRequest; import com.chint.interfaces.rest.user.UserHttpRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList; + import java.util.List; import static com.chint.infrastructure.constant.Constant.*; @@ -27,6 +28,7 @@ public class CTripUserSaveRequest { private final String userUrl = C_TRIP_BASE_URL + C_TRIP_USER_SAVE_PATH; + public void saveUserToCTrip() { User currentUser = BaseContext.getCurrentUser(); User user = userHttpRequest.loadUserInfo(currentUser); @@ -35,13 +37,12 @@ public class CTripUserSaveRequest { AuthenticationListRequest authenticationListRequest = new AuthenticationListRequest(); authenticationListRequest.setAppkey(C_TRIP_APP_KEY); authenticationListRequest.setTicket(ticket); - authenticationListRequest.setCorporationID("zhengtai"); + authenticationListRequest.setCorporationID(C_TRIP_CORP_ID); AuthenticationInfo authenticationInfo = new AuthenticationInfo(); authenticationInfo.setSequence("0"); authenticationInfo.setAuthentication(authenticationEntity); authenticationListRequest.setAuthenticationInfoList(List.of(authenticationInfo)); - AuthenticationResponseList post = postRequest.post(userUrl, authenticationInfo, AuthenticationResponseList.class); - System.out.println(post); + postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class); } @@ -49,7 +50,7 @@ public class CTripUserSaveRequest { AuthenticationEntity authenticationEntity = new AuthenticationEntity(); authenticationEntity.setName(user.getName()); authenticationEntity.setEmployeeID(user.getEmployeeNo().toString()); - authenticationEntity.setRankName(user.getRankCode()); +// authenticationEntity.setRankName(user.getRankCode()); authenticationEntity.setValid(user.getWorkStatus()); authenticationEntity.setSubAccountName("zhengtai_提前审批测试"); return authenticationEntity; diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankInfo.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankInfo.java index 9500d6ec..bb3715b3 100644 --- a/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankInfo.java +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/approval/quick/RankInfo.java @@ -9,4 +9,9 @@ public class RankInfo { private String rankName; // Getters and setters... + public static RankInfo of(String rankName) { + RankInfo rankInfo = new RankInfo(); + rankInfo.setRankName(rankName); + return rankInfo; + } } \ No newline at end of file diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5LoginToken.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5LoginToken.java new file mode 100644 index 00000000..cc47b475 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5LoginToken.java @@ -0,0 +1,9 @@ +package com.chint.interfaces.rest.ctrip.dto.login; + +import lombok.Data; + +@Data +public class H5LoginToken { + private String Token; + private boolean Success; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5Response.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5Response.java new file mode 100644 index 00000000..cbd4b1a5 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5Response.java @@ -0,0 +1,9 @@ +package com.chint.interfaces.rest.ctrip.dto.login; + +import lombok.Data; + +@Data +public class H5Response { + private String redirectUrl; + private boolean success; +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5TicketModel.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5TicketModel.java new file mode 100644 index 00000000..967b1966 --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/H5TicketModel.java @@ -0,0 +1,19 @@ +package com.chint.interfaces.rest.ctrip.dto.login; + +import lombok.Data; + +import static com.chint.infrastructure.constant.Constant.C_TRIP_APP_KEY; +import static com.chint.infrastructure.constant.Constant.C_TRIP_APP_SECURITY; + +@Data +public class H5TicketModel { + private String AppKey; + private String AppSecurity; + + public static H5TicketModel build(){ + H5TicketModel h5TicketModel = new H5TicketModel(); + h5TicketModel.setAppKey(C_TRIP_APP_KEY); + h5TicketModel.setAppSecurity(C_TRIP_APP_SECURITY); + return h5TicketModel; + } +} diff --git a/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/PageViewData.java b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/PageViewData.java new file mode 100644 index 00000000..82820d2c --- /dev/null +++ b/src/main/java/com/chint/interfaces/rest/ctrip/dto/login/PageViewData.java @@ -0,0 +1,11 @@ +package com.chint.interfaces.rest.ctrip.dto.login; + +import lombok.Data; + +@Data +public class PageViewData { + private String serviceStatus; + private boolean success; + private String url; + private String ssoType; +} diff --git a/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java b/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java index 469b9691..f8a2d9d9 100644 --- a/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java +++ b/src/main/java/com/chint/interfaces/rest/ly/LYUserRequest.java @@ -29,6 +29,7 @@ public class LYUserRequest { private String userUrl = L_Y_BASE_URL + L_Y_USER_PATH; public boolean saveCurrentUser() { + System.out.println("saveCurrentUser"); User currentUser = BaseContext.getCurrentUser(); userHttpRequest.loadUserInfo(currentUser); EmployeeEntity employeeEntity = user2LYEmployee(currentUser); diff --git a/src/test/java/com/chint/CTripTest.java b/src/test/java/com/chint/CTripTest.java index 8a987861..fdca100a 100644 --- a/src/test/java/com/chint/CTripTest.java +++ b/src/test/java/com/chint/CTripTest.java @@ -3,7 +3,6 @@ package com.chint; import com.chint.domain.aggregates.user.User; import com.chint.domain.repository.CityRepository; import com.chint.infrastructure.util.BaseContext; -import com.chint.infrastructure.util.Result; import com.chint.interfaces.rest.ctrip.CTripEstimateRequest; import com.chint.interfaces.rest.ctrip.CTripLocationHttpRequest; import com.chint.interfaces.rest.ctrip.CTripLoginRequest; @@ -15,7 +14,6 @@ import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiRe import com.chint.interfaces.rest.ctrip.dto.location.CTripCity; import com.chint.interfaces.rest.ctrip.dto.location.CTripCountry; import com.chint.interfaces.rest.ctrip.dto.login.CTripAuthLoginParam; -import com.chint.interfaces.rest.ctrip.dto.login.CTripHSingleLoginParam; import com.chint.interfaces.rest.ctrip.dto.login.CTripLoginParam; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -100,7 +98,7 @@ public class CTripTest { HttpEntity entity = response.getEntity(); String result = null; try { - result = EntityUtils.toString(entity,"UTF-8"); + result = EntityUtils.toString(entity, "UTF-8"); } catch (IOException e) { throw new RuntimeException(e); } @@ -112,24 +110,16 @@ public class CTripTest { @Test void hSingleLogin() { -// BaseContext.setCurrentUser(user); -// CTripLoginParam cTripLoginParam = new CTripLoginParam(); -// cTripLoginParam.setEmployeeID(String.valueOf(user.getEmployeeNo())); - - CTripHSingleLoginParam param = new CTripHSingleLoginParam(); - param.setEmployeeId("230615020"); - param.setCorpPayType("public"); - HttpResponse response = loginRequest.hSingleLogin(param); - HttpEntity entity = response.getEntity(); - String result = null; - try { - result = EntityUtils.toString(entity,"UTF-8"); - } catch (IOException e) { - throw new RuntimeException(e); - } - - System.out.println(result); + BaseContext.setCurrentUser(user); + System.out.println(loginRequest.hSingleLogin().getRedirectUrl()); } + + @Test + void h5LoginTest() { + BaseContext.setCurrentUser(user); + System.out.println(loginRequest.h5Login()); + } + @Test void estimate() { BaseContext.setCurrentUser(user);