修复部分参数字段

This commit is contained in:
lulz1 2024-02-06 15:06:54 +08:00
parent 84f4d9d342
commit b4d8f012ca
27 changed files with 366 additions and 144 deletions

View File

@ -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;
}

View File

@ -9,14 +9,12 @@ import static com.chint.infrastructure.constant.Constant.LEG_EVENT_NOT_ORDERED;
@Data @Data
public class LegSyncCommand extends Command { public class LegSyncCommand extends Command {
private Integer LegEventType = LEG_EVENT_NOT_ORDERED; private Integer LegEventType = LEG_EVENT_NOT_ORDERED;
private Long LegId;
private Long routOrderId;
private SyncLegData data; private SyncLegData data;
public LegSyncCommand legId(Long LegId) { // public LegSyncCommand legId(Long LegId) {
this.setLegId(LegId); // this.setLegId(LegId);
return this; // return this;
} // }
public LegSyncCommand data(SyncLegData data) { public LegSyncCommand data(SyncLegData data) {
this.data = data; this.data = data;

View File

@ -2,12 +2,16 @@ package com.chint.application.out;
import com.chint.application.commands.OrderCreateCommand; import com.chint.application.commands.OrderCreateCommand;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.service.auth.AuthenticateService; import com.chint.domain.service.auth.AuthenticateService;
import com.chint.domain.value_object.UserLoginParam; import com.chint.domain.value_object.UserLoginParam;
import com.chint.domain.value_object.UserLoginResult; import com.chint.domain.value_object.UserLoginResult;
import com.chint.infrastructure.echo_framework.command.Command; 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.Digest;
import com.chint.infrastructure.util.Result; 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.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.CompletableFuture;
import static com.chint.infrastructure.constant.Constant.*; import static com.chint.infrastructure.constant.Constant.*;
@RestController @RestController
@ -24,6 +30,12 @@ public class LoginController {
@Autowired @Autowired
private AuthenticateService authenticateService; private AuthenticateService authenticateService;
@Autowired
private LYUserRequest lyUserRequest;
@Autowired
private CTripUserSaveRequest cTripUserSaveRequest;
@Transactional @Transactional
@GetMapping("/login") @GetMapping("/login")
public Result<UserLoginResult> login(@RequestParam("sfno") String sfno, public Result<UserLoginResult> login(@RequestParam("sfno") String sfno,
@ -41,6 +53,21 @@ public class LoginController {
.authenticateEmployeeNo(userLoginParam); .authenticateEmployeeNo(userLoginParam);
//发送创建行程订单命令 //发送创建行程订单命令
Command.of(OrderCreateCommand.class).of(userLoginParam).sendToQueue(); 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); return Result.Success(SUCCESS, userLoginResult);
} else { } else {
return Result.error(SIGN_ERROR); return Result.error(SIGN_ERROR);

View File

@ -3,7 +3,9 @@ package com.chint.application.out;
import com.chint.application.services.SupplierLoginService; import com.chint.application.services.SupplierLoginService;
import com.chint.infrastructure.util.Result; 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 com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -18,16 +20,18 @@ public class SupplierLoginController {
@Autowired @Autowired
private SupplierLoginService supplierLoginService; private SupplierLoginService supplierLoginService;
@ApiOperation("单点登录同程")
@PostMapping("/ly/login") @PostMapping("/ly/login")
public Result<LYRedirectUrlResponse> lyLogin() { public Result<LYRedirectUrlResponse> lyLogin() {
//登录 //登录
LYRedirectUrlResponse data = supplierLoginService.lyLogin(); LYRedirectUrlResponse data = supplierLoginService.lyLogin();
return Result.Success(SUCCESS,data); return Result.Success(SUCCESS, data);
} }
@ApiOperation("单点登录携程")
@PostMapping("/CTrip/login") @PostMapping("/CTrip/login")
public Result<String> cTripLogin() { public Result<H5Response> cTripLogin() {
return Result.Success(SUCCESS); return Result.Success(SUCCESS, supplierLoginService.cTripLogin());
} }
} }

View File

@ -1,5 +1,7 @@
package com.chint.application.services; 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.LYLoginRequest;
import com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse; import com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -13,10 +15,18 @@ public class SupplierLoginService {
@Autowired @Autowired
private LYLoginRequest lyLoginRequest; private LYLoginRequest lyLoginRequest;
@Autowired
private CTripLoginRequest cTripLoginRequest;
/** /**
* 登录接口 * 登录接口
*/ */
public LYRedirectUrlResponse lyLogin() { public LYRedirectUrlResponse lyLogin() {
return lyLoginRequest.login(L_Y_ENTRANCE_HOME); return lyLoginRequest.login(L_Y_ENTRANCE_HOME);
} }
public H5Response cTripLogin() {
return cTripLoginRequest.hSingleLogin();
}
} }

View File

@ -13,10 +13,7 @@ import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table; import org.springframework.data.relational.core.mapping.Table;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static com.chint.infrastructure.constant.Constant.*; import static com.chint.infrastructure.constant.Constant.*;
@ -75,22 +72,23 @@ public class Leg {
} }
public Leg reloadStatus() { public Leg reloadStatus() {
if (eventList == null) { if (eventList == null || eventList.isEmpty()) {
this.legStatus = LEG_STATUS_PREPARE; this.legStatus = LEG_STATUS_PREPARE;
} else { } else {
int eventLength = eventList.size() - 1; // Find the latest event based on the maximum id
this.legStatus = eventLength < 0 ? LEG_STATUS_PREPARE : eventLength; LegEvent latestEvent = this.eventList.stream()
if (legStatus > 1) { .max(Comparator.comparingLong(LegEvent::getLegEventId))
Optional<LegEvent> legEvent = this.eventList .orElse(null);
.stream()
.filter(event -> event.getEventType().equals(LEG_EVENT_ORDERED)) // Set the legStatus based on the type of the latest event
.findFirst(); this.legStatus = latestEvent.getEventType();
if (legEvent.isPresent()) {
LegEvent event = legEvent.get(); // If the latest event is an order event, update the amount
this.amount = event.getOrderDetail().getAmount(); if (latestEvent.getEventType().equals(LEG_EVENT_ORDERED)) {
} this.amount = latestEvent.getOrderDetail().getAmount();
} }
} }
this.legStatusName = translateLegStatus(this.legStatus); this.legStatusName = translateLegStatus(this.legStatus);
if (legType != null) { if (legType != null) {
this.legTypeName = translateLegType(this.legType); this.legTypeName = translateLegType(this.legType);
@ -98,6 +96,7 @@ public class Leg {
return this; return this;
} }
public Leg reloadStatus(LegData legData) { public Leg reloadStatus(LegData legData) {
this.reloadStatus(); this.reloadStatus();
if (Objects.equals(legData.getLegId(), this.getLegId()) && this.legStatus.equals(LEG_STATUS_PREPARE)) { 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_PAYED -> LEG_STATUS_PAYED_NAME;
case LEG_STATUS_FINISH -> LEG_STATUS_FINISH_NAME; case LEG_STATUS_FINISH -> LEG_STATUS_FINISH_NAME;
case LEG_STATUS_NOT_ORDERED -> LEG_STATUS_NOT_ORDERED_NAME; case LEG_STATUS_NOT_ORDERED -> LEG_STATUS_NOT_ORDERED_NAME;
case LEG_STATUS_REJECT -> LEG_STATUS_REJECT_NAME;
default -> "未知状态"; default -> "未知状态";
}; };
} }
@ -151,11 +151,16 @@ public class Leg {
throw new LegEventException("The first event must be a prepare event."); throw new LegEventException("The first event must be a prepare event.");
} }
// 事件类型为负数代表是可以任何时机都可进行的事件
if(event.getEventType() < 0) {
eventList.add(event);
return this;
}
// 如果列表不为空确保新事件的类型是按顺序的 // 如果列表不为空确保新事件的类型是按顺序的
if (!eventList.isEmpty()) { if (!eventList.isEmpty()) {
LegEvent lastEvent = eventList.get(eventList.size() - 1); LegEvent lastEvent = eventList.get(eventList.size() - 1);
int lastEventType = lastEvent.getEventType(); int lastEventType = lastEvent.getEventType();
if (newEventType != lastEventType + 1) { if (newEventType != lastEventType + 1) {
throw new LegEventException("Events must be added in sequence."); throw new LegEventException("Events must be added in sequence.");
} }

View File

@ -35,6 +35,8 @@ public class LegEvent {
case LEG_EVENT_PAYED -> LEG_EVENT_PAYED_NAME; case LEG_EVENT_PAYED -> LEG_EVENT_PAYED_NAME;
case LEG_EVENT_FINISH -> LEG_EVENT_FINISH_NAME; case LEG_EVENT_FINISH -> LEG_EVENT_FINISH_NAME;
case LEG_EVENT_NOT_ORDERED -> LEG_EVENT_NOT_ORDERED_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 -> "未知事件"; default -> "未知事件";
}; };
} }

View File

@ -190,6 +190,7 @@ public class RouteOrder extends BaseEntity {
case ORDER_STATUS_PAYED -> ORDER_STATUS_PAYED_NAME; case ORDER_STATUS_PAYED -> ORDER_STATUS_PAYED_NAME;
case ORDER_STATUS_FINISH -> ORDER_STATUS_FINISH_NAME; case ORDER_STATUS_FINISH -> ORDER_STATUS_FINISH_NAME;
case ORDER_STATUS_NOT_ORDERED -> ORDER_STATUS_NOT_ORDERED_NAME; case ORDER_STATUS_NOT_ORDERED -> ORDER_STATUS_NOT_ORDERED_NAME;
case ORDER_STATUS_REJECT -> ORDER_STATUS_REJECT_NAME;
default -> "未知状态"; default -> "未知状态";
}; };
} }

View File

@ -65,7 +65,7 @@ public class LYEstimate implements AmountEstimate {
TrainMaxPrice trainMaxPrice = new TrainMaxPrice(); TrainMaxPrice trainMaxPrice = new TrainMaxPrice();
trainMaxPrice.setTicketType(0); trainMaxPrice.setTicketType(0);
trainMaxPrice.setDepartDate(leg.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));//开始时间 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());//到达城市 trainMaxPrice.setArriveCityName(leg.getDestinationLocation().getLocationName());//到达城市
Description<TrainMaxPrice> description = new Description<>(); Description<TrainMaxPrice> description = new Description<>();
description.setParam(trainMaxPrice); description.setParam(trainMaxPrice);

View File

@ -16,4 +16,5 @@ public interface LegEventService {
void payForLeg(LegPayedCommand command); void payForLeg(LegPayedCommand command);
//结束 //结束
void finishLeg(LegFinishedCommand command); void finishLeg(LegFinishedCommand command);
void rejectLeg(LegRejectCommand command);
} }

View File

@ -2,6 +2,7 @@ package com.chint.domain.service.leg_event;
import com.chint.application.commands.*; import com.chint.application.commands.*;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.exceptions.CommandException;
import com.chint.domain.factoriy.leg_event.LegEventFactory; import com.chint.domain.factoriy.leg_event.LegEventFactory;
import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.LegRepository;
import com.chint.domain.repository.RouteRepository; 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.OrderLegData;
import com.chint.domain.value_object.PayLegData; import com.chint.domain.value_object.PayLegData;
import com.chint.domain.value_object.SyncLegData; import com.chint.domain.value_object.SyncLegData;
import com.chint.infrastructure.echo_framework.annotation.ListenTo; import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.echo_framework.annotation.TransitionTo; import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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 @Service
public class LegEventServiceImpl implements LegEventService { public class LegEventServiceImpl implements LegEventService {
@ -52,6 +54,8 @@ public class LegEventServiceImpl implements LegEventService {
public void approveLeg(LegApprovalCommand command) { public void approveLeg(LegApprovalCommand command) {
ApproveLegData data = command.getData(); ApproveLegData data = command.getData();
RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo()); RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo());
if (routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE)){
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
approveOrderNo.setActualOrderNo(data.getActualOrderNo()); approveOrderNo.setActualOrderNo(data.getActualOrderNo());
approveOrderNo.setAccountCompany(data.getAccountCompany()); approveOrderNo.setAccountCompany(data.getAccountCompany());
@ -63,6 +67,9 @@ public class LegEventServiceImpl implements LegEventService {
//保存routeOrder的状态 //保存routeOrder的状态
routeRepository.save(routeOrder); routeRepository.save(routeOrder);
} else {
throw new CommandException("订单未初始化");
}
} }
//这里需要获取同步类价格routeOrder同步到供应商 //这里需要获取同步类价格routeOrder同步到供应商
@ -70,7 +77,8 @@ public class LegEventServiceImpl implements LegEventService {
@Override @Override
public void syncLeg(LegSyncCommand command) { public void syncLeg(LegSyncCommand command) {
SyncLegData data = command.getData(); SyncLegData data = command.getData();
RouteOrder routeOrder = routeRepository.queryById(command.getRoutOrderId()); RouteOrder routeOrder = routeRepository.queryById(data.getRouteId());
if (routeOrder.getOrderStatus().equals(ORDER_STATUS_APPROVAL)) {
String supplierName = data.getSupplierName(); String supplierName = data.getSupplierName();
routeOrder.setSupplierName(supplierName); routeOrder.setSupplierName(supplierName);
//这里order所有的leg触发approve事件 //这里order所有的leg触发approve事件
@ -80,6 +88,9 @@ public class LegEventServiceImpl implements LegEventService {
syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus()); syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus());
//保存routeOrder的状态 //保存routeOrder的状态
routeRepository.save(routeOrder); routeRepository.save(routeOrder);
} else {
throw new CommandException("订单未提交审批");
}
} }
@ -121,4 +132,13 @@ public class LegEventServiceImpl implements LegEventService {
leg.addEvent(legEvent); leg.addEvent(legEvent);
legRepository.save(leg); 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);
}
} }

View File

@ -1,8 +1,14 @@
package com.chint.domain.service.order_sync; 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.order.RouteOrder;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.CityRepository; import com.chint.domain.repository.CityRepository;
import com.chint.domain.repository.LocationRepository; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -12,10 +18,21 @@ public class CTripOrderSyncAdapter implements SupplierOrderSync {
@Autowired @Autowired
private CityRepository cityRepository; private CityRepository cityRepository;
@Autowired
private CTripApprovalRequest approvalRequest;
@Autowired @Autowired
private LocationRepository locationRepository; private LocationRepository locationRepository;
@Override @Override
public void syncSupplierOrder(RouteOrder order) { 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("开始同步协程订单");
} }
} }

View File

@ -4,5 +4,6 @@ import lombok.Data;
@Data @Data
public class SyncLegData { public class SyncLegData {
private Long routeId;
private String supplierName; private String supplierName;
} }

View File

@ -52,6 +52,8 @@ public class Constant {
public static final String ORDER_STATUS_PAYED_NAME = "已付款"; public static final String ORDER_STATUS_PAYED_NAME = "已付款";
public static final int ORDER_STATUS_FINISH = 5; public static final int ORDER_STATUS_FINISH = 5;
public static final String ORDER_STATUS_FINISH_NAME = "已结束"; 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; 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 String LEG_STATUS_PAYED_NAME = "已付款";
public static final int LEG_STATUS_FINISH = 5; public static final int LEG_STATUS_FINISH = 5;
public static final String LEG_STATUS_FINISH_NAME = "已结束"; 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; 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 int LEG_EVENT_APPROVAL = 1;
public static final String LEG_EVENT_APPROVAL_NAME = "审批事件"; public static final String LEG_EVENT_APPROVAL_NAME = "审批事件";
public static final int LEG_EVENT_NOT_ORDERED = 2; 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 int LEG_EVENT_ORDERED = 3;
public static final String LEG_EVENT_ORDERED_NAME = "下单事件"; public static final String LEG_EVENT_ORDERED_NAME = "下单事件";
public static final int LEG_EVENT_PAYED = 4; public static final int LEG_EVENT_PAYED = 4;
public static final String LEG_EVENT_PAYED_NAME = "付款事件"; public static final String LEG_EVENT_PAYED_NAME = "付款事件";
public static final int LEG_EVENT_FINISH = 5; public static final int LEG_EVENT_FINISH = 5;
public static final String LEG_EVENT_FINISH_NAME = "结束事件"; 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"; 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 TICKET_PATH = "/SwitchAPI/Order/Ticket";
public static final String C_TRIP_LOGIN_PATH = "/singlesignon/openapi/saml/login"; 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_ENTITY_ID = "/zhengtai";
public static final String C_TRIP_CORP_ID = "zhengtai"; public static final String C_TRIP_APP_ID = "zhengtai2024";
public static final String C_TRIP_APP_KEY = "obk_zhengtai"; // 测试appkey public static final String C_TRIP_CORP_ID = "zhengtai2024";
public static final String C_TRIP_APP_SECURITY = "gV417qxpou5bFlh2C93c452T"; // 测试app秘钥 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 USER_SAVE_PATH = "/corpservice/CorpCustService/SaveCorpCustInfoList";
public static final String HOTEL_CITY_PATH = "/corpopenapi/HotelCity/GetCountryCityExtend"; public static final String HOTEL_CITY_PATH = "/corpopenapi/HotelCity/GetCountryCityExtend";
public static final String HOTEL_COUNTRY_PATH = "/corpopenapi/HotelCity/GetCountry"; 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_ACCOUNT = "4f9cb1080b564dd0a94aa95f7a19c8b5"; // 测试appkey
public static final String L_Y_PASSWORD = "1fD3SutgzfS48qznYQiq"; // 测试app秘钥 public static final String L_Y_PASSWORD = "1fD3SutgzfS48qznYQiq"; // 测试app秘钥
public static final String L_Y_SECRET = "WOHzCMvHd823iHgH"; // 测试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_PC = 0; //
public static final Integer L_Y_PLAT_H5 = 1; // 测试app秘钥 public static final Integer L_Y_PLAT_H5 = 1; //
public static final Integer L_Y_ENTRANCE_HOME = 0; // 测试app秘钥 public static final Integer L_Y_ENTRANCE_HOME = 0; //
public static final Integer L_Y_ENTRANCE_AIR_ORDER = 11; // 测试app秘钥page public static final Integer L_Y_ENTRANCE_AIR_ORDER = 11; //
public static final Integer L_Y_ENTRANCE_AIR_DETAIL = 1; // 测试app秘钥 public static final Integer L_Y_ENTRANCE_AIR_DETAIL = 1; //
public static final Integer L_Y_ENTRANCE_AIR_ORDER_OVERSEA = 22; // 测试app秘钥 public static final Integer L_Y_ENTRANCE_AIR_ORDER_OVERSEA = 22; //
public static final Integer L_Y_ENTRANCE_AIR_DETAIL_OVERSEA = 2; // 测试app秘钥 public static final Integer L_Y_ENTRANCE_AIR_DETAIL_OVERSEA = 2; //
public static final Integer L_Y_ENTRANCE_HOTEL_ORDER = 33; // 测试app秘钥 public static final Integer L_Y_ENTRANCE_HOTEL_ORDER = 33; //
public static final Integer L_Y_ENTRANCE_HOTEL_DETAIL = 3; // 测试app秘钥 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_ALL = 0; // 全部(因公因私)
public static final Integer L_Y_TRAVEL_TYPE_PERSON = 1; // (因公) public static final Integer L_Y_TRAVEL_TYPE_PERSON = 1; // (因公)
public static final Integer L_Y_TRAVEL_TYPE_NO_PERSON = 2; // (因私) public static final Integer L_Y_TRAVEL_TYPE_NO_PERSON = 2; // (因私)

View File

@ -16,9 +16,9 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String token = request.getHeader(HEADER_TOKEN); String token = request.getHeader(HEADER_TOKEN);
if (request.getRequestURI().endsWith("/login")) { // if (request.getRequestURI().endsWith("/login")) {
return true; // return true;
} // }
if (request.getRequestURI().contains("/pubilc")) { if (request.getRequestURI().contains("/pubilc")) {
return true; return true;
} }

View File

@ -55,6 +55,20 @@ public class PostRequest {
return gson.fromJson(responseBody, responseType); return gson.fromJson(responseBody, responseType);
} }
public <T> T post(HttpPost post, Class<T> 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() { public Gson gson() {
return gson; return gson;
} }

View File

@ -62,7 +62,7 @@ public class CTripEstimateRequest {
.done() .done()
.valuationProductInfo() .valuationProductInfo()
.addFlightProductInfo(flightProductInfo) .addFlightProductInfo(flightProductInfo)
// .addTrainProductInfo(trainProductInfo) .addTrainProductInfo(trainProductInfo)
.done() .done()
.done() .done()
.build(); .build();

View File

@ -1,22 +1,19 @@
package com.chint.interfaces.rest.ctrip; 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.Digest;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.base.PostRequest; import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList; import com.chint.interfaces.rest.ctrip.dto.login.*;
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 org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -24,6 +21,8 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -50,6 +49,7 @@ public class CTripLoginRequest {
//H5单点登录 //H5单点登录
private String singleLoginUrl = C_TRIP_BASE_URL + C_TRIP_SINGLE_LOGIN; 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 IDPEntityID = C_TRIP_ENTITY_ID;
private String corpId = C_TRIP_CORP_ID; private String corpId = C_TRIP_CORP_ID;
@ -66,26 +66,26 @@ public class CTripLoginRequest {
authLoginParam.setTicket(ticket); authLoginParam.setTicket(ticket);
String appKey = C_TRIP_APP_KEY; 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 employeeId = StringUtils.isNotBlank(authLoginParam.getEmployeeID()) ? authLoginParam.getEmployeeID() : "";
String email = StringUtils.isNotBlank(authLoginParam.getEmail())?authLoginParam.getEmail():""; String email = StringUtils.isNotBlank(authLoginParam.getEmail()) ? authLoginParam.getEmail() : "";
String ta = StringUtils.isNotBlank(authLoginParam.getTA())?authLoginParam.getTA():""; String ta = StringUtils.isNotBlank(authLoginParam.getTA()) ? authLoginParam.getTA() : "";
Integer forCorp = authLoginParam.getForCorp() == null? authLoginParam.getForCorp():0; Integer forCorp = authLoginParam.getForCorp() == null ? authLoginParam.getForCorp() : 0;
String forCopStr = forCorp.toString(); String forCopStr = forCorp.toString();
String cost1 = StringUtils.isNotBlank(authLoginParam.getCost1())?authLoginParam.getCost1():""; String cost1 = StringUtils.isNotBlank(authLoginParam.getCost1()) ? authLoginParam.getCost1() : "";
if (isContainsChinese(cost1)){ if (isContainsChinese(cost1)) {
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost1); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost1);
cost1 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); cost1 = StandardCharsets.UTF_8.decode(byteBuffer).toString();
} }
String cost2 = StringUtils.isNotBlank(authLoginParam.getCost2())?authLoginParam.getCost2():""; String cost2 = StringUtils.isNotBlank(authLoginParam.getCost2()) ? authLoginParam.getCost2() : "";
if (isContainsChinese(cost2)){ if (isContainsChinese(cost2)) {
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost2); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost2);
cost2 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); cost2 = StandardCharsets.UTF_8.decode(byteBuffer).toString();
} }
String cost3 = StringUtils.isNotBlank(authLoginParam.getCost3())?authLoginParam.getCost3():""; String cost3 = StringUtils.isNotBlank(authLoginParam.getCost3()) ? authLoginParam.getCost3() : "";
if (isContainsChinese(cost3)){ if (isContainsChinese(cost3)) {
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost3); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(cost3);
cost3 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); cost3 = StandardCharsets.UTF_8.decode(byteBuffer).toString();
} }
@ -93,7 +93,7 @@ public class CTripLoginRequest {
String finallySign = 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); authLoginParam.setSignature(finallySign);
// Result post = postRequest.post(authLoginUrl, authLoginParam, Result.class); // Result post = postRequest.post(authLoginUrl, authLoginParam, Result.class);
@ -101,13 +101,12 @@ public class CTripLoginRequest {
// HttpClient client = HttpClients.createDefault(); // HttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(authLoginUrl); HttpPost httpPost = new HttpPost(authLoginUrl);
List entitys = new ArrayList<>(); List entitys = new ArrayList<>();
entitys.add(new BasicNameValuePair("AppKey",appKey)); entitys.add(new BasicNameValuePair("AppKey", appKey));
entitys.add(new BasicNameValuePair("Token",token)); entitys.add(new BasicNameValuePair("Token", token));
entitys.add(new BasicNameValuePair("Ticket", ticket));
entitys.add(new BasicNameValuePair("Ticket",ticket)); entitys.add(new BasicNameValuePair("EmployeeID", employeeId));
entitys.add(new BasicNameValuePair("EmployeeID",authLoginParam.getEmployeeID())); entitys.add(new BasicNameValuePair("Signature", finallySign));
entitys.add(new BasicNameValuePair("Signature",finallySign)); entitys.add(new BasicNameValuePair("ForCorp", "0"));
entitys.add(new BasicNameValuePair("ForCorp","0"));
try { try {
httpPost.setEntity(new UrlEncodedFormEntity(entitys)); httpPost.setEntity(new UrlEncodedFormEntity(entitys));
@ -123,55 +122,64 @@ public class CTripLoginRequest {
} }
public HttpResponse hSingleLogin(CTripHSingleLoginParam hSingleLoginParam) { public H5Response hSingleLogin() {
String ticket = ticketRequest.loadTicket(); CTripHSingleLoginParam hSingleLoginParam = new CTripHSingleLoginParam();
String token = tokenRequest.getToken(); User currentUser = BaseContext.getCurrentUser();
H5LoginToken h5TokenResponse = postRequest.post(singleTokenUrl, H5TicketModel.build(), H5LoginToken.class);
String token = h5TokenResponse.getToken();
String accessUserId = C_TRIP_APP_KEY; String accessUserId = C_TRIP_APP_KEY;
String employeeId = StringUtils.isNotBlank(hSingleLoginParam.getEmployeeId())?hSingleLoginParam.getEmployeeId():""; String employeeId = String.valueOf(currentUser.getEmployeeNo());
String corpPayType = StringUtils.isNotBlank(hSingleLoginParam.getCorpPayType())? String corpPayType = StringUtils.isNotBlank(hSingleLoginParam.getCorpPayType()) ?
hSingleLoginParam.getCorpPayType():"public"; hSingleLoginParam.getCorpPayType() : "public";
String costCenter1 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter1())? String costCenter1 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter1()) ?
hSingleLoginParam.getCostCenter1():""; hSingleLoginParam.getCostCenter1() : "";
if (isContainsChinese(costCenter1)){ if (isContainsChinese(costCenter1)) {
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter1); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter1);
costCenter1 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); costCenter1 = StandardCharsets.UTF_8.decode(byteBuffer).toString();
} }
String costCenter2 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter2())? String costCenter2 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter2()) ?
hSingleLoginParam.getCostCenter2():""; hSingleLoginParam.getCostCenter2() : "";
if (isContainsChinese(costCenter2)){ if (isContainsChinese(costCenter2)) {
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter2); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter2);
costCenter2 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); costCenter2 = StandardCharsets.UTF_8.decode(byteBuffer).toString();
} }
String costCenter3 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter3())? String costCenter3 = StringUtils.isNotBlank(hSingleLoginParam.getCostCenter3()) ?
hSingleLoginParam.getCostCenter3():""; hSingleLoginParam.getCostCenter3() : "";
if (isContainsChinese(costCenter3)){ if (isContainsChinese(costCenter3)) {
ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter3); ByteBuffer byteBuffer = StandardCharsets.UTF_8.encode(costCenter3);
costCenter3 = StandardCharsets.UTF_8.decode(byteBuffer).toString(); 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 = String finallySign =
Digest.md5(accessUserId+employeeId+corpPayType+costCenter1+costCenter2+costCenter3+mdAppSecurity); getMD5Hash(signOrigin);
hSingleLoginParam.setSignature(finallySign); hSingleLoginParam.setSignature(finallySign);
HttpPost httpPost = new HttpPost(hSinngleLoginUrl); HttpPost httpPost = new HttpPost(hSinngleLoginUrl);
List entitys = new ArrayList<>(); List entitys = new ArrayList<>();
entitys.add(new BasicNameValuePair("accessUserId",accessUserId)); entitys.add(new BasicNameValuePair("accessUserId", accessUserId));
entitys.add(new BasicNameValuePair("employeeId",employeeId)); entitys.add(new BasicNameValuePair("employeeId", employeeId));
entitys.add(new BasicNameValuePair("token",token)); entitys.add(new BasicNameValuePair("token", token));
entitys.add(new BasicNameValuePair("appId","zhengtai")); entitys.add(new BasicNameValuePair("appId", C_TRIP_APP_ID));
entitys.add(new BasicNameValuePair("signature",finallySign)); entitys.add(new BasicNameValuePair("signature", finallySign));
entitys.add(new BasicNameValuePair("corpPayType","public")); entitys.add(new BasicNameValuePair("corpPayType", corpPayType));
try { try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(entitys,"UTF-8"); UrlEncodedFormEntity entity = new UrlEncodedFormEntity(entitys, "UTF-8");
httpPost.setEntity(entity); httpPost.setEntity(entity);
HttpClient client = new DefaultHttpClient(); HttpClient client = new DefaultHttpClient();
try { 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) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -186,4 +194,52 @@ public class CTripLoginRequest {
return matcher.find(); 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);
}
}
} }

View File

@ -0,0 +1,4 @@
package com.chint.interfaces.rest.ctrip;
public class CTripSyncRequest {
}

View File

@ -3,13 +3,14 @@ package com.chint.interfaces.rest.ctrip;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.base.PostRequest; 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.AuthenticationEntity;
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationInfo; import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationInfo;
import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationListRequest; import com.chint.interfaces.rest.ctrip.dto.user.AuthenticationListRequest;
import com.chint.interfaces.rest.user.UserHttpRequest; import com.chint.interfaces.rest.user.UserHttpRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.chint.interfaces.rest.ctrip.dto.AuthenticationResponseList;
import java.util.List; import java.util.List;
import static com.chint.infrastructure.constant.Constant.*; 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; private final String userUrl = C_TRIP_BASE_URL + C_TRIP_USER_SAVE_PATH;
public void saveUserToCTrip() { public void saveUserToCTrip() {
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
User user = userHttpRequest.loadUserInfo(currentUser); User user = userHttpRequest.loadUserInfo(currentUser);
@ -35,13 +37,12 @@ public class CTripUserSaveRequest {
AuthenticationListRequest authenticationListRequest = new AuthenticationListRequest(); AuthenticationListRequest authenticationListRequest = new AuthenticationListRequest();
authenticationListRequest.setAppkey(C_TRIP_APP_KEY); authenticationListRequest.setAppkey(C_TRIP_APP_KEY);
authenticationListRequest.setTicket(ticket); authenticationListRequest.setTicket(ticket);
authenticationListRequest.setCorporationID("zhengtai"); authenticationListRequest.setCorporationID(C_TRIP_CORP_ID);
AuthenticationInfo authenticationInfo = new AuthenticationInfo(); AuthenticationInfo authenticationInfo = new AuthenticationInfo();
authenticationInfo.setSequence("0"); authenticationInfo.setSequence("0");
authenticationInfo.setAuthentication(authenticationEntity); authenticationInfo.setAuthentication(authenticationEntity);
authenticationListRequest.setAuthenticationInfoList(List.of(authenticationInfo)); authenticationListRequest.setAuthenticationInfoList(List.of(authenticationInfo));
AuthenticationResponseList post = postRequest.post(userUrl, authenticationInfo, AuthenticationResponseList.class); postRequest.post(userUrl, authenticationListRequest, AuthenticationResponseList.class);
System.out.println(post);
} }
@ -49,7 +50,7 @@ public class CTripUserSaveRequest {
AuthenticationEntity authenticationEntity = new AuthenticationEntity(); AuthenticationEntity authenticationEntity = new AuthenticationEntity();
authenticationEntity.setName(user.getName()); authenticationEntity.setName(user.getName());
authenticationEntity.setEmployeeID(user.getEmployeeNo().toString()); authenticationEntity.setEmployeeID(user.getEmployeeNo().toString());
authenticationEntity.setRankName(user.getRankCode()); // authenticationEntity.setRankName(user.getRankCode());
authenticationEntity.setValid(user.getWorkStatus()); authenticationEntity.setValid(user.getWorkStatus());
authenticationEntity.setSubAccountName("zhengtai_提前审批测试"); authenticationEntity.setSubAccountName("zhengtai_提前审批测试");
return authenticationEntity; return authenticationEntity;

View File

@ -9,4 +9,9 @@ public class RankInfo {
private String rankName; private String rankName;
// Getters and setters... // Getters and setters...
public static RankInfo of(String rankName) {
RankInfo rankInfo = new RankInfo();
rankInfo.setRankName(rankName);
return rankInfo;
}
} }

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -29,6 +29,7 @@ public class LYUserRequest {
private String userUrl = L_Y_BASE_URL + L_Y_USER_PATH; private String userUrl = L_Y_BASE_URL + L_Y_USER_PATH;
public boolean saveCurrentUser() { public boolean saveCurrentUser() {
System.out.println("saveCurrentUser");
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
userHttpRequest.loadUserInfo(currentUser); userHttpRequest.loadUserInfo(currentUser);
EmployeeEntity employeeEntity = user2LYEmployee(currentUser); EmployeeEntity employeeEntity = user2LYEmployee(currentUser);

View File

@ -3,7 +3,6 @@ package com.chint;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.CityRepository; import com.chint.domain.repository.CityRepository;
import com.chint.infrastructure.util.BaseContext; 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.CTripEstimateRequest;
import com.chint.interfaces.rest.ctrip.CTripLocationHttpRequest; import com.chint.interfaces.rest.ctrip.CTripLocationHttpRequest;
import com.chint.interfaces.rest.ctrip.CTripLoginRequest; 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.CTripCity;
import com.chint.interfaces.rest.ctrip.dto.location.CTripCountry; 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.CTripAuthLoginParam;
import com.chint.interfaces.rest.ctrip.dto.login.CTripHSingleLoginParam;
import com.chint.interfaces.rest.ctrip.dto.login.CTripLoginParam; import com.chint.interfaces.rest.ctrip.dto.login.CTripLoginParam;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
@ -100,7 +98,7 @@ public class CTripTest {
HttpEntity entity = response.getEntity(); HttpEntity entity = response.getEntity();
String result = null; String result = null;
try { try {
result = EntityUtils.toString(entity,"UTF-8"); result = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -112,24 +110,16 @@ public class CTripTest {
@Test @Test
void hSingleLogin() { void hSingleLogin() {
// BaseContext.setCurrentUser(user); BaseContext.setCurrentUser(user);
// CTripLoginParam cTripLoginParam = new CTripLoginParam(); System.out.println(loginRequest.hSingleLogin().getRedirectUrl());
// 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); @Test
void h5LoginTest() {
BaseContext.setCurrentUser(user);
System.out.println(loginRequest.h5Login());
} }
@Test @Test
void estimate() { void estimate() {
BaseContext.setCurrentUser(user); BaseContext.setCurrentUser(user);