Compare commits
10 Commits
84f4d9d342
...
aea8ca7f0c
Author | SHA1 | Date |
---|---|---|
dengwc | aea8ca7f0c | |
lulz1 | d1408e39d9 | |
lulz1 | 4fe1eb411b | |
lulz1 | f82a5d6800 | |
lulz1 | 72e57f3bff | |
lulz1 | 3656d28727 | |
dengwc | 722b82f2b8 | |
dengwc | 6d829e2b5c | |
dengwc | 2e0e666e99 | |
lulz1 | b4d8f012ca |
|
@ -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;
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.chint.domain.value_object.*;
|
||||||
import com.chint.infrastructure.util.Result;
|
import com.chint.infrastructure.util.Result;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
@ -24,6 +25,8 @@ public class OrderController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderQuery orderQuery;
|
private OrderQuery orderQuery;
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@ApiOperation("保存行程规划单")
|
@ApiOperation("保存行程规划单")
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
public Result<RouteOrder> creatOrder(@RequestBody OrderSaveData orderCreateData) {
|
public Result<RouteOrder> creatOrder(@RequestBody OrderSaveData orderCreateData) {
|
||||||
|
@ -31,6 +34,8 @@ public class OrderController {
|
||||||
return Result.Success(SUCCESS);
|
return Result.Success(SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@ApiOperation("提交审批行程规划单")
|
@ApiOperation("提交审批行程规划单")
|
||||||
@PostMapping("/approve")
|
@PostMapping("/approve")
|
||||||
public Result<String> approveOrder(@RequestBody ApproveLegData approveLegData) {
|
public Result<String> approveOrder(@RequestBody ApproveLegData approveLegData) {
|
||||||
|
@ -38,6 +43,7 @@ public class OrderController {
|
||||||
return Result.Success(SUCCESS);
|
return Result.Success(SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@ApiOperation("同步行程规划单到供应商")
|
@ApiOperation("同步行程规划单到供应商")
|
||||||
@PostMapping("/sync")
|
@PostMapping("/sync")
|
||||||
public Result<String> syncOrder(@RequestBody SyncLegData syncLegData) {
|
public Result<String> syncOrder(@RequestBody SyncLegData syncLegData) {
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -21,11 +21,16 @@ import static com.chint.infrastructure.constant.Constant.SUCCESS;
|
||||||
public class OrderOutController {
|
public class OrderOutController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderQuery orderQuery;
|
private OrderQuery orderQuery;
|
||||||
|
|
||||||
|
@ApiOperation("根据临时单号查询订单")
|
||||||
|
@PostMapping("/query/billcode")
|
||||||
|
public Result<RouteOrder> queryOrderByBillCode(@RequestBody OrderQueryData queryData) {
|
||||||
|
return Result.Success(SUCCESS, orderQuery.queryByBillCode(queryData.getBillcode()).reloadStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("查询行程规划订单详情")
|
@ApiOperation("查询行程规划订单详情")
|
||||||
@PostMapping("/query")
|
@PostMapping("/query")
|
||||||
public Result<RouteOrder> queryOrder(@RequestBody OrderQueryData queryData) {
|
public Result<RouteOrder> queryOrder(@RequestBody OrderQueryData queryData) {
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package com.chint.application.queryies;
|
package com.chint.application.queryies;
|
||||||
|
|
||||||
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.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
import com.chint.domain.service.OrderDomainService;
|
import com.chint.domain.service.OrderDomainService;
|
||||||
import com.chint.domain.value_object.OrderQueryData;
|
import com.chint.domain.value_object.OrderQueryData;
|
||||||
import com.chint.infrastructure.util.BaseContext;
|
|
||||||
import com.chint.infrastructure.util.PageResult;
|
import com.chint.infrastructure.util.PageResult;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -36,4 +34,8 @@ public class OrderQuery {
|
||||||
orderDomainService.queryLocation(routeOrder.getLegItems());
|
orderDomainService.queryLocation(routeOrder.getLegItems());
|
||||||
return routeOrder;
|
return routeOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RouteOrder queryByBillCode(String billCode) {
|
||||||
|
return routeRepository.findByFakeOrderNo(billCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 -> "未知事件";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class RouteOrder extends BaseEntity {
|
||||||
this.getLegItems().forEach(Leg::reloadStatus);
|
this.getLegItems().forEach(Leg::reloadStatus);
|
||||||
this.estimateAmount = this.getLegItems()
|
this.estimateAmount = this.getLegItems()
|
||||||
.stream()
|
.stream()
|
||||||
|
.filter(leg -> leg.getEstimateAmount() != null)
|
||||||
.map(Leg::getEstimateAmount)
|
.map(Leg::getEstimateAmount)
|
||||||
.reduce(BigDecimalCalculator::add)
|
.reduce(BigDecimalCalculator::add)
|
||||||
.orElse(KEEP_TWO_DECIMAL_ZERO);
|
.orElse(KEEP_TWO_DECIMAL_ZERO);
|
||||||
|
@ -190,6 +191,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 -> "未知状态";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.domain.service.amount_estimate;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.Leg;
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
|
import com.chint.domain.service.OrderDomainService;
|
||||||
import com.chint.infrastructure.constant.Constant;
|
import com.chint.infrastructure.constant.Constant;
|
||||||
import com.chint.infrastructure.util.BigDecimalCalculator;
|
import com.chint.infrastructure.util.BigDecimalCalculator;
|
||||||
import com.chint.interfaces.rest.ly.LYPostRequest;
|
import com.chint.interfaces.rest.ly.LYPostRequest;
|
||||||
|
@ -65,7 +66,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);
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
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;
|
||||||
|
import com.chint.domain.service.order_sync.SyncAdapter;
|
||||||
|
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 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 LegEventHandler implements LegEventService{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SyncAdapter syncAdapter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RouteRepository routeRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LegRepository legRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LegEventFactory legEventFactory;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void prepareLeg(LegPrepareCommand command) {
|
||||||
|
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||||
|
if (leg.getEventList().isEmpty()) {
|
||||||
|
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||||
|
leg.addEvent(legEvent);
|
||||||
|
legRepository.save(leg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void approveLeg(LegApprovalCommand command) {
|
||||||
|
ApproveLegData data = command.getData();
|
||||||
|
RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo()).reloadStatus();
|
||||||
|
|
||||||
|
if (routeOrder.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
|
||||||
|
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())
|
||||||
|
));
|
||||||
|
|
||||||
|
//保存routeOrder的状态
|
||||||
|
routeRepository.save(routeOrder);
|
||||||
|
} else {
|
||||||
|
throw new CommandException("订单未初始化");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void syncLeg(LegSyncCommand command) {
|
||||||
|
SyncLegData data = command.getData();
|
||||||
|
RouteOrder routeOrder = routeRepository.queryById(data.getRouteId()).reloadStatus();
|
||||||
|
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())
|
||||||
|
));
|
||||||
|
//保存routeOrder的状态
|
||||||
|
routeRepository.save(routeOrder);
|
||||||
|
if (!syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus())) {
|
||||||
|
throw new CommandException("订单提交失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new CommandException("订单未提交审批");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void orderLeg(LegOrderedCommand command) {
|
||||||
|
OrderLegData data = command.getData();
|
||||||
|
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||||
|
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||||
|
OrderDetail orderDetail = new OrderDetail();
|
||||||
|
orderDetail.setAmount(data.getOrderNo());
|
||||||
|
orderDetail.setAmount(data.getAmount());
|
||||||
|
legEvent.setOrderDetail(orderDetail);
|
||||||
|
leg.addEvent(legEvent);
|
||||||
|
legRepository.save(leg);
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void payForLeg(LegPayedCommand command) {
|
||||||
|
PayLegData data = command.getData();
|
||||||
|
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||||
|
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||||
|
OrderDetail orderDetail = new OrderDetail();
|
||||||
|
orderDetail.setAmount(data.getOrderNo());
|
||||||
|
orderDetail.setAmount(data.getAmount());
|
||||||
|
legEvent.setOrderDetail(orderDetail);
|
||||||
|
leg.addEvent(legEvent);
|
||||||
|
legRepository.save(leg);
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void finishLeg(LegFinishedCommand command) {
|
||||||
|
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||||
|
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||||
|
leg.addEvent(legEvent);
|
||||||
|
legRepository.save(leg);
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void rejectLeg(LegRejectCommand command) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
}
|
}
|
|
@ -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,38 +11,27 @@ 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 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 {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SyncAdapter syncAdapter;
|
private LegEventHandler legEventHandler;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RouteRepository routeRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LegRepository legRepository;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LegEventFactory legEventFactory;
|
|
||||||
|
|
||||||
|
|
||||||
@TransitionTo(command = "LegPrepareCommand", order = 0)
|
@TransitionTo(command = "LegPrepareCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public void prepareLeg(LegPrepareCommand command) {
|
public void prepareLeg(LegPrepareCommand command) {
|
||||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
legEventHandler.prepareLeg(command);
|
||||||
if (leg.getEventList().isEmpty()) {
|
|
||||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
|
||||||
leg.addEvent(legEvent);
|
|
||||||
legRepository.save(leg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//因为审批是针对整个订单的,因此所有订单下属的行程节点触发审批事件
|
//因为审批是针对整个订单的,因此所有订单下属的行程节点触发审批事件
|
||||||
|
@ -50,75 +40,42 @@ public class LegEventServiceImpl implements LegEventService {
|
||||||
@ListenTo(command = "LegApprovalCommand", order = 0)
|
@ListenTo(command = "LegApprovalCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public void approveLeg(LegApprovalCommand command) {
|
public void approveLeg(LegApprovalCommand command) {
|
||||||
ApproveLegData data = command.getData();
|
legEventHandler.approveLeg(command);
|
||||||
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())
|
|
||||||
));
|
|
||||||
|
|
||||||
//保存routeOrder的状态
|
|
||||||
routeRepository.save(routeOrder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//这里需要获取同步类,价格routeOrder同步到供应商
|
//这里需要获取同步类,价格routeOrder同步到供应商
|
||||||
@ListenTo(command = "LegSyncCommand", order = 0)
|
@ListenTo(command = "LegSyncCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public void syncLeg(LegSyncCommand command) {
|
public void syncLeg(LegSyncCommand command) {
|
||||||
SyncLegData data = command.getData();
|
legEventHandler.syncLeg(command);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//下单时间要求回传,需要付款的金额,以及生成对于的行程订单号,如果没有行程订单号根据地点和时间进行匹配
|
//下单时间要求回传,需要付款的金额,以及生成对于的行程订单号,如果没有行程订单号根据地点和时间进行匹配
|
||||||
@ListenTo(command = "LegOrderedCommand", order = 0)
|
@ListenTo(command = "LegOrderedCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public void orderLeg(LegOrderedCommand command) {
|
public void orderLeg(LegOrderedCommand command) {
|
||||||
OrderLegData data = command.getData();
|
legEventHandler.orderLeg(command);
|
||||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
|
||||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
|
||||||
OrderDetail orderDetail = new OrderDetail();
|
|
||||||
orderDetail.setAmount(data.getOrderNo());
|
|
||||||
orderDetail.setAmount(data.getAmount());
|
|
||||||
legEvent.setOrderDetail(orderDetail);
|
|
||||||
leg.addEvent(legEvent);
|
|
||||||
legRepository.save(leg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ListenTo(command = "LegPayedCommand", order = 0)
|
@ListenTo(command = "LegPayedCommand", order = 0)
|
||||||
public void payForLeg(LegPayedCommand command) {
|
public void payForLeg(LegPayedCommand command) {
|
||||||
PayLegData data = command.getData();
|
legEventHandler.payForLeg(command);
|
||||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
|
||||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
|
||||||
OrderDetail orderDetail = new OrderDetail();
|
|
||||||
orderDetail.setAmount(data.getOrderNo());
|
|
||||||
orderDetail.setAmount(data.getAmount());
|
|
||||||
legEvent.setOrderDetail(orderDetail);
|
|
||||||
leg.addEvent(legEvent);
|
|
||||||
legRepository.save(leg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ListenTo(command = "LegFinishedCommand", order = 0)
|
@ListenTo(command = "LegFinishedCommand", order = 0)
|
||||||
public void finishLeg(LegFinishedCommand command) {
|
public void finishLeg(LegFinishedCommand command) {
|
||||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
|
||||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,68 @@
|
||||||
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.domain.service.OrderDomainService;
|
||||||
|
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.PassengerDetail;
|
||||||
|
import com.chint.interfaces.rest.ctrip.dto.approval.hotel.HotelEndorsementDetail;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.Constant.LEG_TYPE_HOTEL;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CTripOrderSyncAdapter implements SupplierOrderSync {
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderDomainService orderDomainService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void syncSupplierOrder(RouteOrder order) {
|
public boolean syncSupplierOrder(RouteOrder order) {
|
||||||
System.out.println("开始同步协程订单");
|
System.out.println("开始同步协程订单");
|
||||||
|
User currentUser = BaseContext.getCurrentUser();
|
||||||
|
ApproveOrderNo approveOrderNo = order.getApproveOrderNo();
|
||||||
|
RankInfo rankInfo = RankInfo.of(currentUser.getRankCode());
|
||||||
|
List<String> cityCode = new ArrayList<>();
|
||||||
|
List<HotelEndorsementDetail> hotelList = new ArrayList<>();
|
||||||
|
orderDomainService.queryLocation(order.getLegItems())
|
||||||
|
.forEach(
|
||||||
|
leg -> {
|
||||||
|
cityCode.add(
|
||||||
|
cityRepository.findByCityName(leg.getOriginLocation().getLocationName()).getCity()
|
||||||
|
);
|
||||||
|
if (leg.getLegType().equals(LEG_TYPE_HOTEL)) {
|
||||||
|
hotelList.add(
|
||||||
|
HotelEndorsementDetail.of(cityCode.stream().distinct().toList())
|
||||||
|
.passenger(PassengerDetail.of(String.valueOf(currentUser.getEmployeeNo())))
|
||||||
|
.starTime(leg.getStartTime())
|
||||||
|
.endTime(leg.getEndTime())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
ApprovalRequest approvalRequestParam = ApprovalRequest.buildApproval(String.valueOf(currentUser.getEmployeeNo()), approveOrderNo.getActualOrderNo(), rankInfo)
|
||||||
|
.withHotel(hotelList);
|
||||||
|
approvalRequest.approval(approvalRequestParam);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,127 @@
|
||||||
package com.chint.domain.service.order_sync;
|
package com.chint.domain.service.order_sync;
|
||||||
|
|
||||||
import com.chint.domain.aggregates.order.Location;
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
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.LocationRepository;
|
import com.chint.domain.repository.LocationRepository;
|
||||||
|
import com.chint.domain.service.OrderDomainService;
|
||||||
|
import com.chint.infrastructure.constant.Constant;
|
||||||
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
|
import com.chint.interfaces.rest.ly.LYPostRequest;
|
||||||
|
import com.chint.interfaces.rest.ly.dto.applyordersync.*;
|
||||||
|
import com.chint.interfaces.rest.ly.dto.commonresult.Result;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LYOrderSyncAdapter implements SupplierOrderSync {
|
public class LYOrderSyncAdapter implements SupplierOrderSync {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LYPostRequest postRequest;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LocationRepository locationRepository;
|
private LocationRepository locationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderDomainService orderDomainService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void syncSupplierOrder(RouteOrder order) {
|
public boolean syncSupplierOrder(RouteOrder order) {
|
||||||
|
String supplierOrderSyncUrl = Constant.L_Y_BASE_URL + Constant.L_Y_ORDER_PATH;//请求地址
|
||||||
|
//1.设置订单参数
|
||||||
|
SupplierOrderParam param = new SupplierOrderParam();//参数
|
||||||
|
param.setOutEmployeeIdType(0);//外部员工ID类型,默认为0
|
||||||
|
param.setOutTravelApplyNo(order.getApproveOrderNo().getActualOrderNo());//审批订单号
|
||||||
|
param.setTravelApplyType(1); //差旅类型:1 普通差旅,2 福利差旅
|
||||||
|
param.setStatus(1);//状态:1通过,2作废
|
||||||
|
//日期格式化
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||||
|
String applyTime = order.getCreateTime().format(formatter);
|
||||||
|
String updateTime = order.getUpdateTime().format(formatter);
|
||||||
|
param.setTravelApplyTime(applyTime);//开始(创建)时间
|
||||||
|
param.setTravelUpdateTime(updateTime);//最后更新时间
|
||||||
|
param.setOperationType(1);//1新增,2更新
|
||||||
|
//获取用户信息
|
||||||
|
User user = BaseContext.getCurrentUser();
|
||||||
|
param.setOutEmployeeId(String.valueOf(user.getEmployeeNo()));//用户id
|
||||||
|
param.setTravelDescription("同程订单");//描述信息
|
||||||
|
param.setBookableProducts("1,3,5");//1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
|
||||||
|
//2.同程的行程节点集合
|
||||||
|
ArrayList<AOSItem> aosItems = getAosItems(order);
|
||||||
|
//3.差旅人信息
|
||||||
|
ArrayList<AOSPerson> aosPeople = new ArrayList<>();
|
||||||
|
AOSPerson aosPerson = new AOSPerson();
|
||||||
|
aosPerson.setName(user.getName());//用户名
|
||||||
|
aosPerson.setRelation(0);//0:内部员工,1:配偶,2:子女,3:父母,4:面试候选人,5:实习生,6:外部宾客
|
||||||
|
aosPerson.setPassengerType(0);//0:成人, 1:儿童, 2:婴儿
|
||||||
|
aosPerson.setOutEmployeeId(String.valueOf(user.getEmployeeNo()));//SF号(长工号)
|
||||||
|
aosPeople.add(aosPerson);
|
||||||
|
//4.前置差旅政策
|
||||||
|
ArrayList<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>();
|
||||||
|
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
|
||||||
|
aosPreTravelPolicy.setPolicyCode("");//一般指客户经理提供的差旅政策标题
|
||||||
|
aosPreTravelPolicy.setProductTypeId(0);//产品ID 1:国内机票,2:国际机票,3:国内酒店,4:海外酒店,5:火车票,6:用车
|
||||||
|
aosPreTravelPolicies.add(aosPreTravelPolicy);
|
||||||
|
|
||||||
|
param.setItemList(aosItems); // 同程节点内容
|
||||||
|
param.setPersonList(aosPeople);// 同程信息(实际出行人)
|
||||||
|
param.setPreTravelPolicyList(aosPreTravelPolicies);// 同程政策
|
||||||
|
param.setApproveRuleType(0);//审批规则
|
||||||
|
SupplierOrderSyncDto supplierOrderSyncDto = new SupplierOrderSyncDto();
|
||||||
|
supplierOrderSyncDto.setParam(param);
|
||||||
|
Result result = postRequest.post(supplierOrderSyncUrl, supplierOrderSyncDto, Result.class);
|
||||||
|
System.out.println("result = " + result);
|
||||||
System.out.println("开始同步同程订单");
|
System.out.println("开始同步同程订单");
|
||||||
|
String success = result.getSuccess();
|
||||||
|
return Boolean.parseBoolean(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
//同程Leg集合解析
|
||||||
|
private ArrayList<AOSItem> getAosItems(RouteOrder order) {
|
||||||
|
ArrayList<AOSItem> aosItems = new ArrayList<>();
|
||||||
|
AOSItem aosItem = new AOSItem();
|
||||||
|
LocalDateTime startDate = LocalDateTime.MAX;
|
||||||
|
LocalDateTime endDate = LocalDateTime.MIN;
|
||||||
|
StringBuilder departCityStr = new StringBuilder();
|
||||||
|
StringBuilder arriveCityStr = new StringBuilder();
|
||||||
|
//提取所有行程节点信息
|
||||||
|
List<Leg> legItems = order.getLegItems();
|
||||||
|
orderDomainService.queryLocation(legItems);
|
||||||
|
for (Leg leg : legItems) {
|
||||||
|
//开始时间
|
||||||
|
LocalDateTime startTime = leg.getStartTime();
|
||||||
|
if (startTime.isBefore(startDate)) {
|
||||||
|
startDate = startTime;
|
||||||
|
}
|
||||||
|
//结束时间
|
||||||
|
LocalDateTime endTime = leg.getEndTime();
|
||||||
|
if (endTime.isAfter(endDate)) {
|
||||||
|
endDate = endTime;
|
||||||
|
}
|
||||||
|
String departCity = leg.getOriginLocation().getLocationName();//出发城市名
|
||||||
|
String arriveCity = leg.getDestinationLocation().getLocationName();//到达城市名
|
||||||
|
departCityStr.append(departCity).append(",");
|
||||||
|
arriveCityStr.append(arriveCity).append(",");
|
||||||
|
|
||||||
|
}
|
||||||
|
// 移除最后一个逗号
|
||||||
|
if (!departCityStr.isEmpty()) {
|
||||||
|
departCityStr.setLength(departCityStr.length() - 1);
|
||||||
|
}
|
||||||
|
if (!arriveCityStr.isEmpty()) {
|
||||||
|
arriveCityStr.setLength(arriveCityStr.length() - 1);
|
||||||
|
}
|
||||||
|
aosItem.setStartDate(startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));//行程最早时间
|
||||||
|
aosItem.setEndDate(endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));//行程最晚时间
|
||||||
|
aosItem.setDepartCity(String.valueOf(departCityStr));//各行程节点出发城市
|
||||||
|
aosItem.setArriveCity(String.valueOf(arriveCityStr));//各行程节点到达城市
|
||||||
|
aosItem.setOtherCity("");//其它城市
|
||||||
|
aosItems.add(aosItem);
|
||||||
|
return aosItems;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,5 @@ import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
||||||
|
|
||||||
public interface SupplierOrderSync {
|
public interface SupplierOrderSync {
|
||||||
void syncSupplierOrder(RouteOrder order);
|
boolean syncSupplierOrder(RouteOrder order);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,6 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class OrderQueryData extends BaseQuery {
|
public class OrderQueryData extends BaseQuery {
|
||||||
private Long routeId;
|
private Long routeId;
|
||||||
|
|
||||||
|
private String billcode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,5 +4,6 @@ import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class SyncLegData {
|
public class SyncLegData {
|
||||||
|
private Long routeId;
|
||||||
private String supplierName;
|
private String supplierName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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";
|
||||||
|
@ -157,21 +165,21 @@ public class Constant {
|
||||||
//同程
|
//同程
|
||||||
public static final String L_Y_BASE_URL = "https://api.qa.dttrip.cn";
|
public static final String L_Y_BASE_URL = "https://api.qa.dttrip.cn";
|
||||||
public static final String L_Y_TOKEN_PATH = "/openapi/api/OAuth/v2/GetAccessToken";
|
public static final String L_Y_TOKEN_PATH = "/openapi/api/OAuth/v2/GetAccessToken";
|
||||||
public static final String L_Y_ORDER_PATH = "openapi/api/TravelApplyOrder/ApplyOrderSync";
|
public static final String L_Y_ORDER_PATH = "/openapi/api/TravelApplyOrder/ApplyOrderSync";
|
||||||
public static final String L_Y_USER_PATH = "/openapi/api/Employee/SyncEmployeeInfo";
|
public static final String L_Y_USER_PATH = "/openapi/api/Employee/SyncEmployeeInfo";
|
||||||
public static final String L_Y_LOGIN_PATH = "/openapi/api/Employee/SSO";
|
public static final String L_Y_LOGIN_PATH = "/openapi/api/Employee/SSO";
|
||||||
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; // (因私)
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.chint.infrastructure.repository;
|
||||||
import com.chint.domain.aggregates.location.CityEntity;
|
import com.chint.domain.aggregates.location.CityEntity;
|
||||||
import com.chint.domain.repository.CityRepository;
|
import com.chint.domain.repository.CityRepository;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcCityRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcCityRepository;
|
||||||
import com.chint.interfaces.rest.ctrip.dto.location.CTripCity;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@ -23,7 +22,7 @@ public class CityRepositoryImpl implements CityRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CityEntity findByCityName(String name) {
|
public CityEntity findByCityName(String name) {
|
||||||
return null;
|
return jdbcCityRepository.findByCityName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class RouteRepositoryImpl implements RouteRepository {
|
||||||
return jdbcRouteRepository.findByRouteId(orderId);
|
return jdbcRouteRepository.findByRouteId(orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RouteOrder findByFakeOrderNo(String fakeOrderNo) {
|
public RouteOrder findByFakeOrderNo(String fakeOrderNo) {
|
||||||
return jdbcRouteRepository.findByApproveOrderNo_FakeOrderNo(fakeOrderNo);
|
return jdbcRouteRepository.findByApproveOrderNo_FakeOrderNo(fakeOrderNo);
|
||||||
|
|
|
@ -6,4 +6,5 @@ import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface JdbcCityRepository extends CrudRepository<CityEntity,Long> {
|
public interface JdbcCityRepository extends CrudRepository<CityEntity,Long> {
|
||||||
|
CityEntity findByCityName(String cityName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.chint.infrastructure.util;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
public class DateTimeUtil {
|
||||||
|
|
||||||
|
public static String timeToStr(LocalDateTime input) {
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
return input.format(formatter);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package com.chint.interfaces.rest.ctrip;
|
||||||
|
|
||||||
|
public class CTripSyncRequest {
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.chint.interfaces.rest.ctrip.dto.approval;
|
package com.chint.interfaces.rest.ctrip.dto.approval;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class PassengerDetail {
|
public class PassengerDetail {
|
||||||
|
|
||||||
// 姓名 - 必填
|
// 姓名 - 必填
|
||||||
|
@ -62,4 +65,10 @@ public class PassengerDetail {
|
||||||
|
|
||||||
// Getters and setters for each field would be included below...
|
// Getters and setters for each field would be included below...
|
||||||
|
|
||||||
|
public static PassengerDetail of(String employeeNo) {
|
||||||
|
PassengerDetail passengerDetail = new PassengerDetail();
|
||||||
|
passengerDetail.setEID(employeeNo);
|
||||||
|
return passengerDetail;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,16 @@
|
||||||
package com.chint.interfaces.rest.ctrip.dto.approval.hotel;
|
package com.chint.interfaces.rest.ctrip.dto.approval.hotel;
|
||||||
|
|
||||||
|
import com.chint.infrastructure.util.DateTimeUtil;
|
||||||
import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType;
|
import com.chint.interfaces.rest.ctrip.dto.approval.CurrencyType;
|
||||||
import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail;
|
import com.chint.interfaces.rest.ctrip.dto.approval.PassengerDetail;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
public class HotelEndorsementDetail {
|
public class HotelEndorsementDetail {
|
||||||
|
|
||||||
// 产品类型
|
// 产品类型
|
||||||
|
@ -68,4 +74,30 @@ public class HotelEndorsementDetail {
|
||||||
private long preVerifyFields;
|
private long preVerifyFields;
|
||||||
|
|
||||||
// Getters and setters...
|
// Getters and setters...
|
||||||
|
|
||||||
|
public static HotelEndorsementDetail of(List<String> cityCodes) {
|
||||||
|
HotelEndorsementDetail hotelEndorsementDetail = new HotelEndorsementDetail();
|
||||||
|
hotelEndorsementDetail.setCheckInCityCodes(cityCodes);
|
||||||
|
return hotelEndorsementDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HotelEndorsementDetail passenger(PassengerDetail passengerDetail) {
|
||||||
|
if (this.passengerList == null) {
|
||||||
|
this.passengerList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
this.passengerList.add(passengerDetail);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HotelEndorsementDetail starTime(LocalDateTime startTime) {
|
||||||
|
this.checkInDateBegin = DateTimeUtil.timeToStr(startTime);
|
||||||
|
this.checkOutDateBegin = DateTimeUtil.timeToStr(startTime);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HotelEndorsementDetail endTime(LocalDateTime endTime) {
|
||||||
|
this.checkInDateEnd = DateTimeUtil.timeToStr(endTime);
|
||||||
|
this.checkOutDateEnd = DateTimeUtil.timeToStr(endTime);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -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);
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.chint.interfaces.rest.ly.dto.applyordersync;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SupplierOrderParam {
|
||||||
|
private Integer outEmployeeIdType; //外部人员Id类型
|
||||||
|
private String outTravelApplyNo;//外部同程单单号
|
||||||
|
private Integer travelApplyType;//同程类型
|
||||||
|
private Integer status;//同程单状态
|
||||||
|
private String travelApplyTime;//同程单申请时间
|
||||||
|
private String travelUpdateTime;//同程单更新时间
|
||||||
|
private Integer operationType;//操作类型
|
||||||
|
private String outEmployeeId;//外部员工ID(申请人)
|
||||||
|
private String travelDescription;//同程内容
|
||||||
|
private String bookableProducts;//可预订产品
|
||||||
|
|
||||||
|
private List<AOSItem> itemList;//同程内容
|
||||||
|
private List<AOSPerson> personList;//同程人信息(实际出行人)
|
||||||
|
private List<AOSPreTravelPolicy> preTravelPolicyList;//前置同程政策
|
||||||
|
|
||||||
|
private Integer approveRuleType;//审批规则类型
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.chint.interfaces.rest.ly.dto.applyordersync;
|
||||||
|
|
||||||
|
import com.chint.interfaces.rest.ly.dto.LYBaseRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SupplierOrderSyncDto extends LYBaseRequest {
|
||||||
|
private SupplierOrderParam param;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.chint.interfaces.rest.ly.vo.estimateprice;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class HotelInfo {
|
||||||
|
private String hotelId;
|
||||||
|
private List<PriceInfo> priceList;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.chint.interfaces.rest.ly.vo.estimateprice;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class HotelListVo {
|
||||||
|
|
||||||
|
private List<HotelInfo> hotelList;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.chint.interfaces.rest.ly.vo.estimateprice;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PriceInfo {
|
||||||
|
private LocalDateTime saleDate;
|
||||||
|
private int paymentType;
|
||||||
|
private double price;
|
||||||
|
|
||||||
|
}
|
|
@ -47,8 +47,8 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
||||||
level = level.substring(0, level.length() - 3) + "M0";
|
level = level.substring(0, level.length() - 3) + "M0";
|
||||||
}
|
}
|
||||||
TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level));
|
TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level));
|
||||||
user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
// user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
||||||
// user.setRankCode("M0");
|
user.setRankCode("测试职级");
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.chint;
|
package com.chint;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.chint.domain.aggregates.base.BaseEntity;
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.infrastructure.constant.Constant;
|
import com.chint.infrastructure.constant.Constant;
|
||||||
import com.chint.infrastructure.util.BaseContext;
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
|
@ -11,21 +11,18 @@ import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||||
import com.chint.interfaces.rest.ly.dto.applyordersync.*;
|
import com.chint.interfaces.rest.ly.dto.applyordersync.*;
|
||||||
import com.chint.interfaces.rest.ly.dto.commonresult.Result;
|
import com.chint.interfaces.rest.ly.dto.commonresult.Result;
|
||||||
import com.chint.interfaces.rest.ly.dto.estimateprice.*;
|
import com.chint.interfaces.rest.ly.dto.estimateprice.*;
|
||||||
|
import com.chint.interfaces.rest.ly.vo.estimateprice.HotelListVo;
|
||||||
import com.chint.interfaces.rest.ly.vo.estimateprice.TrainPriceVo;
|
import com.chint.interfaces.rest.ly.vo.estimateprice.TrainPriceVo;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.internal.LinkedTreeMap;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.Constant.*;
|
import static com.chint.infrastructure.constant.Constant.*;
|
||||||
|
@ -74,8 +71,8 @@ public class LYTest {
|
||||||
void ticketNewPrice() {
|
void ticketNewPrice() {
|
||||||
String flyPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_FLY_PRICE;
|
String flyPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_FLY_PRICE;
|
||||||
TicketNewPrice ticketNewPrice = new TicketNewPrice();
|
TicketNewPrice ticketNewPrice = new TicketNewPrice();
|
||||||
ticketNewPrice.setOrderSerialNo("");
|
ticketNewPrice.setOrderSerialNo("");//订单号
|
||||||
Description<TicketNewPrice> description = new Description<TicketNewPrice>();
|
Description<TicketNewPrice> description = new Description<>();
|
||||||
description.setParam(ticketNewPrice);
|
description.setParam(ticketNewPrice);
|
||||||
Result post = postRequest.post(flyPriceUrl, description, Result.class);
|
Result post = postRequest.post(flyPriceUrl, description, Result.class);
|
||||||
System.out.println(post);
|
System.out.println(post);
|
||||||
|
@ -103,7 +100,7 @@ public class LYTest {
|
||||||
Description<HotleMinPrice> description = new Description<>();
|
Description<HotleMinPrice> description = new Description<>();
|
||||||
description.setParam(hotleMinPrice);
|
description.setParam(hotleMinPrice);
|
||||||
Result post = postRequest.post(minPriceUrl, description, Result.class);
|
Result post = postRequest.post(minPriceUrl, description, Result.class);
|
||||||
System.out.println(post);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//火车票最高价查询
|
//火车票最高价查询
|
||||||
|
@ -209,6 +206,62 @@ public class LYTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//同步同程订单
|
||||||
|
@Test
|
||||||
|
void syncSupplierOrder() {
|
||||||
|
String supplierOrderSyncUrl = Constant.L_Y_BASE_URL + Constant.L_Y_ORDER_PATH;
|
||||||
|
SupplierOrderParam param = new SupplierOrderParam();
|
||||||
|
param.setOutEmployeeIdType(0);
|
||||||
|
param.setOutTravelApplyNo("string");
|
||||||
|
param.setTravelApplyType(1); //同程类型
|
||||||
|
param.setStatus(1);
|
||||||
|
/*
|
||||||
|
时间转换
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.of(2024, 2, 6, 12, 57, 33, 6000000);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||||
|
String formattedDateTime = localDateTime.format(formatter);
|
||||||
|
DateTimeFormatter formatter1 = DateTimeFormatter.ISO_DATE_TIME;
|
||||||
|
LocalDateTime dateTime = LocalDateTime.parse(formattedDateTime, formatter1);*/
|
||||||
|
param.setTravelApplyTime("2024-02-05T02:24:49.601Z");
|
||||||
|
param.setTravelUpdateTime("2024-02-06T02:24:49.601Z");
|
||||||
|
param.setOperationType(1);
|
||||||
|
param.setOutEmployeeId("string");
|
||||||
|
param.setTravelDescription("string");
|
||||||
|
param.setBookableProducts("string");
|
||||||
|
//行程节点
|
||||||
|
ArrayList<AOSItem> aosItems = new ArrayList<>();
|
||||||
|
AOSItem aosItem = new AOSItem();
|
||||||
|
aosItem.setStartDate("2024-02-05");//行程最早时间
|
||||||
|
aosItem.setEndDate("2024-02-06");//行程最晚时间
|
||||||
|
aosItem.setDepartCity("string");
|
||||||
|
aosItem.setArriveCity("HGH");
|
||||||
|
aosItem.setOtherCity("string");
|
||||||
|
aosItems.add(aosItem);
|
||||||
|
//差旅人信息
|
||||||
|
ArrayList<AOSPerson> aosPeople = new ArrayList<>();
|
||||||
|
AOSPerson aosPerson = new AOSPerson();
|
||||||
|
aosPerson.setName("测试");
|
||||||
|
aosPerson.setRelation(0);
|
||||||
|
aosPerson.setPassengerType(0);
|
||||||
|
aosPerson.setOutEmployeeId("string");
|
||||||
|
aosPeople.add(aosPerson);
|
||||||
|
//同程政策
|
||||||
|
ArrayList<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>();
|
||||||
|
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
|
||||||
|
aosPreTravelPolicy.setPolicyCode("string");
|
||||||
|
aosPreTravelPolicy.setProductTypeId(0);
|
||||||
|
aosPreTravelPolicies.add(aosPreTravelPolicy);
|
||||||
|
|
||||||
|
param.setItemList(aosItems); // 同程节点内容
|
||||||
|
param.setPersonList(aosPeople);// 同程信息(实际出行人)
|
||||||
|
param.setPreTravelPolicyList(aosPreTravelPolicies);// 同程政策
|
||||||
|
param.setApproveRuleType(0);
|
||||||
|
SupplierOrderSyncDto supplierOrderSyncDto = new SupplierOrderSyncDto();
|
||||||
|
supplierOrderSyncDto.setParam(param);
|
||||||
|
Result post = postRequest.post(supplierOrderSyncUrl, supplierOrderSyncDto, Result.class);
|
||||||
|
System.out.println(post);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loadToken() {
|
void loadToken() {
|
||||||
System.out.println(lyTokenRequest.loadToken());
|
System.out.println(lyTokenRequest.loadToken());
|
||||||
|
|
Loading…
Reference in New Issue