完成超标状态回推bpm代码

This commit is contained in:
Superdandan 2024-02-25 18:40:11 +08:00
parent d815148587
commit 9ab000791e
31 changed files with 366 additions and 122 deletions

View File

@ -0,0 +1,26 @@
package com.chint.application.commands;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
@Data
public class BPMAuditCommand extends Command {
private String orderNo;
private Integer productType;
private Object extensionData;
public BPMAuditCommand orderNo(String orderNo) {
this.orderNo = orderNo;
return this;
}
public BPMAuditCommand productType(Integer productType) {
this.productType = productType;
return this;
}
public BPMAuditCommand extensionData(Object extensionData) {
this.extensionData = extensionData;
return this;
}
}

View File

@ -0,0 +1,8 @@
package com.chint.application.dtos;
import lombok.Data;
@Data
public class SupplierLoginParam {
private Long routeId;
}

View File

@ -50,15 +50,15 @@ public class RankController {
return Result.Success(SUCCESS, save);
}
@Transactional
@ApiOperation("添加差标")
@PostMapping("/add/standards")
public Result<Ranks> addStandardsToRanks(@RequestBody StandardsData standardsData) {
Ranks ranks = ranksRepository.queryById(standardsData.getRanksId());
DifferenceStandards differenceStandards = ranksFactory.createDifferenceStandards(standardsData);
ranks.addStandards(differenceStandards);
return Result.Success(SUCCESS, ranks);
}
// @Transactional
// @ApiOperation("添加差标")
// @PostMapping("/add/standards")
// public Result<Ranks> addStandardsToRanks(@RequestBody StandardsData standardsData) {
// Ranks ranks = ranksRepository.queryById(standardsData.getRanksId());
// DifferenceStandards differenceStandards = ranksFactory.createDifferenceStandards(standardsData);
// ranks.addStandards(differenceStandards);
// return Result.Success(SUCCESS, ranks);
// }
@Transactional
@ApiOperation("修改差标")
@ -76,7 +76,7 @@ public class RankController {
ranks.setIndustry(ranksdata.getIndustry());
if (ranksdata.getStandardsData() != null) {
DifferenceStandards differenceStandards = ranksFactory.createDifferenceStandards(ranksdata.getStandardsData());
ranks.addStandards(differenceStandards);
// ranks.addStandards(differenceStandards);
}
ranksRepository.save(ranks);
return Result.Success(SUCCESS, ranks);

View File

@ -1,6 +1,7 @@
package com.chint.application.out;
import com.chint.application.dtos.SupplierLoginParam;
import com.chint.application.services.SupplierLoginService;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.dto.login.H5Response;
@ -23,30 +24,30 @@ public class SupplierLoginController {
@ApiOperation("单点登录同程-移动")
@PostMapping("/ly/login")
public Result<LYRedirectUrlResponse> lyLogin() {
public Result<LYRedirectUrlResponse> lyLogin(SupplierLoginParam supplierLoginParam) {
//登录
LYRedirectUrlResponse data = supplierLoginService.lyLogin();
LYRedirectUrlResponse data = supplierLoginService.lyLogin(supplierLoginParam);
return Result.Success(SUCCESS, data);
}
@ApiOperation("单点登录同程-PC")
@PostMapping("/ly/login/pc")
public Result<LYRedirectUrlResponse> lyLoginPC() {
public Result<LYRedirectUrlResponse> lyLoginPC(SupplierLoginParam supplierLoginParam) {
//登录
LYRedirectUrlResponse data = supplierLoginService.lyLoginPC();
LYRedirectUrlResponse data = supplierLoginService.lyLoginPC(supplierLoginParam);
return Result.Success(SUCCESS, data);
}
@ApiOperation("单点登录携程-移动")
@PostMapping("/CTrip/login")
public Result<H5Response> cTripLogin() {
return Result.Success(SUCCESS, supplierLoginService.cTripLogin());
public Result<H5Response> cTripLogin(SupplierLoginParam supplierLoginParam) {
return Result.Success(SUCCESS, supplierLoginService.cTripLogin(supplierLoginParam));
}
@ApiOperation("单点登录携程-PC")
@PostMapping("/CTrip/login/pc")
public Result<PCResponse> cTripLoginPC() {
return Result.Success(SUCCESS, supplierLoginService.cTripLoginPC());
public Result<PCResponse> cTripLoginPC(SupplierLoginParam supplierLoginParam) {
return Result.Success(SUCCESS, supplierLoginService.cTripLoginPC(supplierLoginParam));
}
}

View File

@ -1,5 +1,8 @@
package com.chint.application.services;
import com.chint.application.dtos.SupplierLoginParam;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.repository.RouteRepository;
import com.chint.interfaces.rest.ctrip.CTripLoginRequest;
import com.chint.interfaces.rest.ctrip.dto.login.H5Response;
import com.chint.interfaces.rest.ctrip.dto.login.PCResponse;
@ -7,7 +10,6 @@ import com.chint.interfaces.rest.ly.LYLoginRequest;
import com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yaml.snakeyaml.extensions.compactnotation.PackageCompactConstructor;
import static com.chint.infrastructure.constant.Constant.L_Y_ENTRANCE_HOME;
@ -20,21 +22,30 @@ public class SupplierLoginService {
@Autowired
private CTripLoginRequest cTripLoginRequest;
@Autowired
private RouteRepository routeRepository;
/**
* 登录接口
*/
public LYRedirectUrlResponse lyLogin() {
return lyLoginRequest.login(L_Y_ENTRANCE_HOME);
public LYRedirectUrlResponse lyLogin(SupplierLoginParam supplierLoginParam) {
return lyLoginRequest.login(L_Y_ENTRANCE_HOME, getEmployeeNo(supplierLoginParam.getRouteId()));
}
public LYRedirectUrlResponse lyLoginPC() {
return lyLoginRequest.loginPC(L_Y_ENTRANCE_HOME);
public LYRedirectUrlResponse lyLoginPC(SupplierLoginParam supplierLoginParam) {
return lyLoginRequest.loginPC(L_Y_ENTRANCE_HOME, getEmployeeNo(supplierLoginParam.getRouteId()));
}
public H5Response cTripLogin() {
return cTripLoginRequest.hSingleLogin();
public H5Response cTripLogin(SupplierLoginParam supplierLoginParam) {
return cTripLoginRequest.hSingleLogin(getEmployeeNo(supplierLoginParam.getRouteId()));
}
public PCResponse cTripLoginPC() {
return cTripLoginRequest.authLogin();
public PCResponse cTripLoginPC(SupplierLoginParam supplierLoginParam) {
return cTripLoginRequest.authLogin(getEmployeeNo(supplierLoginParam.getRouteId()));
}
private String getEmployeeNo(Long routeId) {
RouteOrder routeOrder = routeRepository.queryById(routeId);
return routeOrder.getUserId().toString();
}
}

View File

@ -15,4 +15,6 @@ public class ApproveOrderNo {
private String accountCompany;
@ApiModelProperty("申请说明")
private String instructions;
@ApiModelProperty("财务共享订单创建人")
private String creator;
}

View File

@ -1,5 +1,6 @@
package com.chint.domain.aggregates.order;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.value_object.enums.CurrencyType;
import lombok.Data;
import org.springframework.data.annotation.Id;
@ -12,8 +13,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import static com.chint.infrastructure.constant.Constant.ORDER_EVENT_PREPARE_NAME;
import static com.chint.infrastructure.constant.Constant.ORDER_EVENT_UNKNOWN;
import static com.chint.infrastructure.constant.Constant.*;
@Data
@Table("order_detail")
@ -97,6 +97,17 @@ public class OrderDetail {
return this;
}
public Object getExtensionDataByProductType() {
return switch (this.productType) {
case LEG_TYPE_TRAIN -> this.trainOrderDetail;
case LEG_TYPE_AIRPLANE -> this.flightOrderDetail;
case LEG_TYPE_HOTEL -> this.hotelOrderDetail;
case LEG_TYPE_TAXI -> this.carOrderDetail;
case LEG_TYPE_OTHER -> this.otherOrderDetail;
default -> throw new NotFoundException(NOT_FOUND);
};
}
public OrderDetail addCarOrderData(CarOrderDetail carOrderDetail) {
this.carOrderDetail = carOrderDetail;
return this;

View File

@ -36,6 +36,7 @@ public class OrderEvent {
case ORDER_EVENT_REFUND -> ORDER_EVENT_REFUND_NAME;
case ORDER_EVENT_UNKNOWN -> ORDER_EVENT_UNKNOWN_NAME;
case ORDER_EVENT_FINISH -> ORDER_EVENT_FINISH_NAME;
case ORDER_EVENT_ETA -> ORDER_EVENT_ETA_NAME;
default -> "未知事件";
};
}

View File

@ -13,4 +13,5 @@ public interface OrderDetailRepository {
Optional<OrderDetail> findByOrderNo(String orderNo);
OrderDetail save(OrderDetail orderDetail);
}

View File

@ -16,8 +16,6 @@ public interface RouteRepository {
RouteOrder findByActualOrderNoAndSysCode(String actualOrderNo,String sysCode);
RouteOrder findByOrderNo(String orderNo);
Page<RouteOrder> findByOrderNoFuzzy(OrderQueryData orderQueryData);

View File

@ -1,13 +1,12 @@
package com.chint.domain.service;
import com.chint.application.commands.BPMAuditCommand;
import com.chint.application.commands.OrderApprovalCommand;
import com.chint.application.commands.OrderCreateCommand;
import com.chint.application.commands.OrderStatusChangeCommand;
import com.chint.domain.aggregates.order.ApprovalEvent;
import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.OrderEvent;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
import com.chint.domain.repository.LocationRepository;
@ -17,7 +16,11 @@ import com.chint.domain.repository.UserRepository;
import com.chint.domain.value_object.ApprovalLegData;
import com.chint.domain.value_object.UserLoginParam;
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.util.DelayDispatch;
import com.chint.interfaces.rest.bpm.BPMParamFactory;
import com.chint.interfaces.rest.bpm.BPMRequest;
import com.chint.interfaces.rest.bpm.dot.ExceedStandardDto;
import com.chint.interfaces.rest.user.UserHttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -25,7 +28,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.Constant.APPROVAL_EVENT_PREPARE;
import static com.chint.infrastructure.constant.Constant.*;
@Service
public class OrderDomainService {
@ -50,6 +53,13 @@ public class OrderDomainService {
@Autowired
private UserHttpRequest userHttpRequest;
@Autowired
private BPMParamFactory bpmParamFactory;
@Autowired
private BPMRequest bpmRequest;
public RouteOrder saveOrder(RouteOrder routeOrder) {
return routeRepository.save(routeOrder);
}
@ -93,15 +103,39 @@ public class OrderDomainService {
@ListenTo(command = "OrderStatusChangeCommand", order = 0)
public void orderDetailStatusChange(OrderStatusChangeCommand command) {
orderDetailRepository.findByOrderNo(command.getOrderNo()).ifPresent(orderDetail -> {
OrderEvent event = orderDetailFactory.createEvent(command.getOrderEventType(), command.getOutStatus());
String outStatus = command.getOutStatus();
Integer orderEventType = command.getOrderEventType();
OrderEvent event = orderDetailFactory.createEvent(orderEventType,
outStatus);
orderDetail.addOrderEvent(event);
orderDetailRepository.save(orderDetail);
});
//这里如果发现事件的状态为Approving2 需要根据发送审批给bpm需要先查询订单数据
if (orderEventType.equals(ORDER_EVENT_ETA)) {
//这里如果发现事件的状态为ORDER_EVENT_ETA
//需要根据发送审批给bpm
//根据订单类型获取不同的订单扩展明细
orderDetail.getExtensionDataByProductType();
Command.of(BPMAuditCommand.class)
.orderNo(orderDetail.getOrderNo())
.productType(orderDetail.getProductType())
.extensionData(orderDetail.getExtensionDataByProductType())
.sendToQueue();
}
});
}
public void legAutoAddOrder(){
@ListenTo(command = "BPMAuditCommand", order = 0)
public void toBpmAudit(BPMAuditCommand command) {
Object data = command.getExtensionData();
ExceedStandardDto exceedStandardDto = switch (command.getProductType()) {
case LEG_TYPE_TRAIN -> bpmParamFactory.creatAuditParamByTrain((TrainOrderDetail) data);
case LEG_TYPE_AIRPLANE -> bpmParamFactory.creatAuditParamByFlight((FlightOrderDetail) data);
case LEG_TYPE_HOTEL -> bpmParamFactory.creatAuditParamByHotel((HotelOrderDetail) data);
case LEG_TYPE_TAXI -> bpmParamFactory.creatAuditParamByCar((CarOrderDetail) data);
case LEG_TYPE_OTHER -> bpmParamFactory.creatAuditParamByOther((OtherOrderDetail) data);
default -> throw new NotFoundException(NOT_FOUND);
};
DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto).getSuccess(),
0);
}
}

View File

@ -80,6 +80,7 @@ public class LegEventHandler implements LegEventService {
approveOrderNo.setActualOrderNo(data.getActualOrderNo());
approveOrderNo.setAccountCompany(data.getAccountCompany());
approveOrderNo.setInstructions(data.getInstructions());
approveOrderNo.setCreator(data.getCreator());
//这里order所有的leg触发approve事件
routeOrder.getLegItems().forEach(leg -> leg.getEventList().add(
legEventFactory.creatLegEvent(command.getLegEventType())

View File

@ -8,4 +8,5 @@ public class ApprovalLegData {
// private String fakeOrderNo;
private String actualOrderNo;
private String sysCode;
private String creator;
}

View File

@ -9,4 +9,5 @@ public class ApproveLegData {
private String accountCompany;
private String sysCode;
private String instructions;
private String creator;
}

View File

@ -149,6 +149,8 @@ public class Constant {
public static final String ORDER_EVENT_FINISH_NAME = "已完成";
public static final int ORDER_EVENT_CANCEL = -1;
public static final String ORDER_EVENT_CANCEL_NAME = "取消";
public static final int ORDER_EVENT_ETA = -2;
public static final String ORDER_EVENT_ETA_NAME = "超标";
public static final int ORDER_EVENT_UNKNOWN = -99;
public static final String ORDER_EVENT_UNKNOWN_NAME = "未知事件";
@ -196,8 +198,13 @@ public class Constant {
public static final String TRAVEL_RANK_PATH = "/fssc/queryBill/queryTravelLevelByRank";
public static final String SUPPLIER_C_TRIP = "CTrip";
public static final String SUPPLIER_C_TRIP_CN_NAME = "携程";
public static final String SUPPLIER_C_TRIP_EXTENSION_NAME = "携程预定";
public static final String SUPPLIER_C_TRIP_BPM_NAME = "携程商旅";
public static final String SUPPLIER_L_Y = "LY";
public static final String SUPPLIER_L_Y_CN_NAME = "同程";
public static final String SUPPLIER_L_Y_EXTENSION_NAME = "同程预定";
public static final String SUPPLIER_L_Y_BPM_NAME = "同程商旅";
// 携程
public static final String TICKET_PATH = "/SwitchAPI/Order/Ticket";
@ -296,4 +303,10 @@ public class Constant {
//BPM
public static final String EXCEED_STANDARD_URL = "http://10.207.0.245:8012/Portal/Webservices/ExternalStartService.asmx?op=StartWorkflowByEntityTransJson";
public static final String EXCEED_STANDARD_TYPE_TRAIN = "火车票超标";//方法名称
public static final String EXCEED_STANDARD_TYPE_HOTEL = "酒店超标";//方法名称
public static final String EXCEED_STANDARD_TYPE_FLIGHT = "机票超标";//方法名称
public static final String EXCEED_STANDARD_TYPE_CAR = "用车超标";//方法名称
public static final String EXCEED_STANDARD_TYPE_OTHER = "其他超标";//方法名称
}

View File

@ -1,7 +1,6 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.value_object.OrderQueryData;
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
@ -51,19 +50,27 @@ public class RouteRepositoryImpl implements RouteRepository {
public Page<RouteOrder> findByOrderNoFuzzy(OrderQueryData orderQueryData) {
PageRequest sort = PageRequest
.of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort"));
User currentUser = BaseContext.getCurrentUser();
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
return jdbcRouteRepository
.findByCreateUserAndRouteOrderNoContaining(currentUser.getUserId().toString()
, orderQueryData.getOrderNo(), sort);
.findByUserIdAndRouteOrderNoContainingOrApproveOrderNo_CreatorAndRouteOrderNoContaining(
Long.valueOf(employeeNo),
orderQueryData.getOrderNo(),
employeeNo,
orderQueryData.getOrderNo(),
sort);
}
@Override
public Page<RouteOrder> findByInstructions(OrderQueryData orderQueryData) {
PageRequest sort = PageRequest
.of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort"));
User currentUser = BaseContext.getCurrentUser();
return jdbcRouteRepository.findByCreateUserAndApproveOrderNo_InstructionsContaining(currentUser.getUserId().toString(),
orderQueryData.getInstructions(),sort);
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
return jdbcRouteRepository.findByUserIdAndApproveOrderNo_InstructionsContainingOrApproveOrderNo_CreatorAndApproveOrderNo_InstructionsContaining(
Long.valueOf(employeeNo),
orderQueryData.getInstructions(),
employeeNo,
orderQueryData.getInstructions(),
sort);
}
@Override
@ -75,9 +82,9 @@ public class RouteRepositoryImpl implements RouteRepository {
public PageResult<RouteOrder> pageQuery(OrderQueryData orderQueryData) {
PageRequest sort = PageRequest
.of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort"));
User currentUser = BaseContext.getCurrentUser();
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
Page<RouteOrder> byUserId = jdbcRouteRepository
.findByCreateUserAndApproveOrderNo_ActualOrderNoNotNull(currentUser.getUserId().toString(), sort);
.findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long.valueOf(employeeNo), employeeNo, sort);
List<RouteOrder> orders = byUserId.toList();
orders.forEach(RouteOrder::reloadStatus);
return new PageResult<>(byUserId.getTotalElements(), orders);
@ -85,7 +92,7 @@ public class RouteRepositoryImpl implements RouteRepository {
@Override
public List<RouteOrder> findByActualOrderNoNotNull(OrderQueryData orderQueryData) {
User currentUser = BaseContext.getCurrentUser();
return jdbcRouteRepository.findByCreateUserAndApproveOrderNo_ActualOrderNoNotNull(currentUser.getUserId().toString());
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
return jdbcRouteRepository.findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long.valueOf(employeeNo), employeeNo);
}
}

View File

@ -3,7 +3,9 @@ package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.RouteOrder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -12,19 +14,26 @@ import java.util.List;
public interface JdbcRouteRepository extends CrudRepository<RouteOrder, Long> {
Page<RouteOrder> findByCreateUser(String userId, Pageable pageable);
Page<RouteOrder> findByCreateUserAndApproveOrderNo_ActualOrderNoNotNull(String userId, Pageable pageable);
RouteOrder findByRouteId(Long routeId);
RouteOrder findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(String approveOrderNo_fakeOrderNo, String sysCode);
Page<RouteOrder> findByCreateUserAndApproveOrderNo_InstructionsContaining(String createUser, String approveOrderNo_instructions, Pageable pageable);
RouteOrder findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(String approveOrderNo_actualOrderNo, String approveOrderNo_sysCode);
RouteOrder findByRouteOrderNo(String routeOrderNo);
List<RouteOrder> findByCreateUserAndApproveOrderNo_ActualOrderNoNotNull(String createUser);
Page<RouteOrder> findByCreateUserAndRouteOrderNoContaining(String createUser, String routeOrderNo, Pageable pageable);
Page<RouteOrder> findByUserIdAndRouteOrderNoContainingOrApproveOrderNo_CreatorAndRouteOrderNoContaining(Long userId, String routeOrderNo, String approveOrderNo_creator, String routeOrderNo2, Pageable pageable);
Page<RouteOrder> findByUserIdAndApproveOrderNo_InstructionsContainingOrApproveOrderNo_CreatorAndApproveOrderNo_InstructionsContaining(Long userId, String approveOrderNo_instructions, String approveOrderNo_creator, String approveOrderNo_instructions2, Pageable pageable);
Page<RouteOrder> findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long userId, String approveOrderNo_creator, Pageable pageable);
List<RouteOrder> findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long userId, String approveOrderNo_creator);
}

View File

@ -0,0 +1,26 @@
package com.chint.infrastructure.util;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
public class DelayDispatch {
public static void attemptToSend(Supplier<Boolean> requestSupplier, int attempt) {
if (attempt >= 5) {
return;
}
boolean success = requestSupplier.get(); // 使用Supplier<Boolean>获取请求成功与否的状态
if (!success) {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.schedule(() -> {
try {
attemptToSend(requestSupplier, attempt + 1);
} finally {
scheduler.shutdown(); // 确保在任务执行完毕后关闭scheduler
}
}, 30, TimeUnit.SECONDS);
}
}
}

View File

@ -0,0 +1,78 @@
package com.chint.interfaces.rest.bpm;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.interfaces.rest.bpm.dot.ExceedStandardDto;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import static com.chint.infrastructure.constant.Constant.*;
@Component
public class BPMParamFactory {
public ExceedStandardDto creatAuditParamByCar(CarOrderDetail carOrderDetail) {
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
exceedStandardDto.setOrderType(EXCEED_STANDARD_TYPE_CAR)
.setOrderSource(getSupplierName(carOrderDetail.getSupplier()))
.setOrderNo(carOrderDetail.getOrderNo())
.setExcessAmount(BigDecimal.valueOf(Double.parseDouble(carOrderDetail.getOrderAmount())))
.setReason(carOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
public ExceedStandardDto creatAuditParamByTrain(TrainOrderDetail trainOrderDetail) {
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
exceedStandardDto.setOrderType(EXCEED_STANDARD_TYPE_TRAIN)
.setSeatingStandard(trainOrderDetail.getSeatName())
.setOrderSource(getSupplierName(trainOrderDetail.getSupplier()))
.setOrderNo(trainOrderDetail.getOrderNo())
.setExcessAmount(BigDecimal.valueOf(Double.parseDouble(trainOrderDetail.getOrderAmount())))
.setReason(trainOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
public ExceedStandardDto creatAuditParamByHotel(HotelOrderDetail hotelOrderDetail) {
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
exceedStandardDto.setOrderType(EXCEED_STANDARD_TYPE_HOTEL)
.setHotelStandard(hotelOrderDetail.getStarRate())
.setHouseLayout(hotelOrderDetail.getRoomTypeName())
.setHotelName(hotelOrderDetail.getHotelName())
.setOrderSource(getSupplierName(hotelOrderDetail.getSupplier()))
.setOrderNo(hotelOrderDetail.getOrderNo())
.setExcessAmount(BigDecimal.valueOf(Double.parseDouble(hotelOrderDetail.getOrderAmount())))
.setReason(hotelOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
public ExceedStandardDto creatAuditParamByFlight(FlightOrderDetail flightOrderDetail) {
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
exceedStandardDto.setOrderType(EXCEED_STANDARD_TYPE_CAR)
.setCabinClass(flightOrderDetail.getSeatPointName())
.setOrderSource(getSupplierName(flightOrderDetail.getSupplier()))
.setOrderNo(flightOrderDetail.getOrderNo())
.setExcessAmount(BigDecimal.valueOf(Double.parseDouble(flightOrderDetail.getOrderAmount())))
.setReason(flightOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
public ExceedStandardDto creatAuditParamByOther(OtherOrderDetail otherOrderDetail) {
ExceedStandardDto exceedStandardDto = new ExceedStandardDto();
// exceedStandardDto.setOrderType(EXCEED_STANDARD_TYPE_CAR)
// .setOrderSource(getSupplierName(carOrderDetail.getSupplier()))
// .setOrderNo(carOrderDetail.getOrderNo())
// .setExcessAmount(BigDecimal.valueOf(Double.parseDouble(carOrderDetail.getOrderAmount())))
// .setReason(carOrderDetail.getOverStandardReason());
return exceedStandardDto;
}
private String getSupplierName(String supplier) {
return switch (supplier) {
case SUPPLIER_C_TRIP_EXTENSION_NAME -> SUPPLIER_C_TRIP_BPM_NAME;
case SUPPLIER_L_Y_EXTENSION_NAME -> SUPPLIER_L_Y_BPM_NAME;
default -> throw new NotFoundException(NOT_FOUND);
};
}
}

View File

@ -1,12 +1,12 @@
package com.chint.interfaces.rest.ly;
package com.chint.interfaces.rest.bpm;
import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.ly.dto.bpm.BPMBaseRequest;
import com.chint.interfaces.rest.ly.dto.bpm.BPMResponse;
import com.chint.interfaces.rest.ly.dto.bpm.ExceedStandardDto;
import com.chint.interfaces.rest.ly.dto.bpm.RescheduleDto;
import com.chint.interfaces.rest.bpm.dot.BPMBaseRequest;
import com.chint.interfaces.rest.bpm.dot.BPMResponse;
import com.chint.interfaces.rest.bpm.dot.ExceedStandardDto;
import com.chint.interfaces.rest.bpm.dot.RescheduleDto;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

View File

@ -1,4 +1,4 @@
package com.chint.interfaces.rest.ly.dto.bpm;
package com.chint.interfaces.rest.bpm.dot;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@ -1,4 +1,4 @@
package com.chint.interfaces.rest.ly.dto.bpm;
package com.chint.interfaces.rest.bpm.dot;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.chint.interfaces.rest.ly.dto.bpm;
package com.chint.interfaces.rest.bpm.dot;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package com.chint.interfaces.rest.ly.dto.bpm;
package com.chint.interfaces.rest.bpm.dot;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@ -71,14 +71,16 @@ public class CTripLoginRequest {
}
public PCResponse authLogin() {
public PCResponse authLogin(String employeeNo) {
String employeeId;
if (employeeNo == null) {
User currentUser = BaseContext.getCurrentUser();
String employeeId = String.valueOf(
currentUser.getEmployeeNo()
);
CTripAuthLoginParam authLoginParam = CTripAuthLoginParam.of(String.valueOf(
employeeId
));
employeeId = currentUser.getEmployeeNo().toString();
} else {
employeeId = employeeNo;
}
CTripAuthLoginParam authLoginParam = CTripAuthLoginParam.of(employeeId);
authLoginParam.setForCorp(0);
String ticket = loadLoginToken();
@ -144,12 +146,17 @@ public class CTripLoginRequest {
}
public H5Response hSingleLogin() {
public H5Response hSingleLogin(String employeeNo) {
CTripHSingleLoginParam hSingleLoginParam = new CTripHSingleLoginParam();
String employeeId;
if (employeeNo == null) {
User currentUser = BaseContext.getCurrentUser();
employeeId = String.valueOf(currentUser.getEmployeeNo());
} else {
employeeId = employeeNo;
}
String token = loadLoginToken();
String accessUserId = C_TRIP_APP_KEY;
String employeeId = String.valueOf(currentUser.getEmployeeNo());
String corpPayType = StringUtils.isNotBlank(hSingleLoginParam.getCorpPayType()) ?
hSingleLoginParam.getCorpPayType() : "public";
@ -216,20 +223,22 @@ public class CTripLoginRequest {
}
public H5Response h5Login() {
public H5Response h5Login(String employeeNo) {
String employeeId;
if (employeeNo == null) {
User currentUser = BaseContext.getCurrentUser();
employeeId = String.valueOf(currentUser.getEmployeeNo());
} else {
employeeId = employeeNo;
}
CTripHSingleLoginParam cTripHSingleLoginParam = new CTripHSingleLoginParam();
cTripHSingleLoginParam.setAppId(C_TRIP_APP_KEY);
cTripHSingleLoginParam.setEmployeeId(String.valueOf(currentUser.getEmployeeNo()));
cTripHSingleLoginParam.setEmployeeId(String.valueOf(employeeId));
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));
Digest.md5(C_TRIP_APP_KEY + employeeId + "public" + Digest.md5(C_TRIP_APP_SECURITY));
cTripHSingleLoginParam.setSignature(finallySign);
return postRequest.post(hSinngleLoginUrl, cTripHSingleLoginParam, H5Response.class);

View File

@ -19,27 +19,27 @@ public class LYLoginRequest {
private final String loginUrl = L_Y_BASE_URL + L_Y_LOGIN_PATH;
public LYRedirectUrlResponse login(Integer entrance) {
User currentUser = BaseContext.getCurrentUser();
public LYRedirectUrlResponse login(Integer entrance, String employeeNo) {
return getLyRedirectUrlResponse(entrance, employeeNo, L_Y_PLAT_H5);
}
private LYRedirectUrlResponse getLyRedirectUrlResponse(Integer entrance, String employeeNo, Integer lYPlatH5) {
LoginTokenData loginTokenData = new LoginTokenData();
LoginParam loginParam = new LoginParam();
if(employeeNo == null){
User currentUser = BaseContext.getCurrentUser();
loginParam.setOutEmployeeId(String.valueOf(currentUser.getEmployeeNo()));
loginParam.setPlat(L_Y_PLAT_H5);
} else {
loginParam.setOutEmployeeId(employeeNo);
}
loginParam.setPlat(lYPlatH5);
loginParam.setEntrance(entrance);
loginParam.setTravelType(L_Y_TRAVEL_TYPE_ALL);
loginTokenData.setParam(loginParam);
return postRequest.post(loginUrl, loginTokenData, LYRedirectUrlResponse.class);
}
public LYRedirectUrlResponse loginPC(Integer entrance) {
User currentUser = BaseContext.getCurrentUser();
LoginTokenData loginTokenData = new LoginTokenData();
LoginParam loginParam = new LoginParam();
loginParam.setOutEmployeeId(String.valueOf(currentUser.getEmployeeNo()));
loginParam.setPlat(L_Y_PLAT_PC);
loginParam.setEntrance(entrance);
loginParam.setTravelType(L_Y_TRAVEL_TYPE_ALL);
loginTokenData.setParam(loginParam);
return postRequest.post(loginUrl, loginTokenData, LYRedirectUrlResponse.class);
public LYRedirectUrlResponse loginPC(Integer entrance, String employeeNo) {
return getLyRedirectUrlResponse(entrance, employeeNo, L_Y_PLAT_PC);
}
}

View File

@ -13,3 +13,10 @@ chint:
cTrip:
baseUrl: https://ct.ctrip.com
auditBaseUrl: https://gateway-fat.ctripqa.com/switchapi
appId: zhengtai2024
corpId: zhengtai2024
appKey: obk_zhengtai2024
appSecurity: fI3}FZX+zUdxPa2W!R6I2gYO
requestSecret: zhengtai2024_nEbmKfOo

View File

@ -31,3 +31,9 @@ logging:
cTrip:
baseUrl: https://ct.ctrip.com
auditBaseUrl: https://gateway-fat.ctripqa.com/switchapi
appId: zhengtai2024
corpId: zhengtai2024
appKey: obk_zhengtai2024
appSecurity: fI3}FZX+zUdxPa2W!R6I2gYO
requestSecret: zhengtai2024_nEbmKfOo

View File

@ -93,7 +93,7 @@ public class CTripTest {
//@Test
void authLogin() {
BaseContext.setCurrentUser(user);
PCResponse response = loginRequest.authLogin();
PCResponse response = loginRequest.authLogin(null);
System.out.println(response.getRedirectUrl());
}
@ -101,13 +101,13 @@ public class CTripTest {
//@Test
void hSingleLogin() {
BaseContext.setCurrentUser(user);
System.out.println(loginRequest.hSingleLogin().getRedirectUrl());
System.out.println(loginRequest.hSingleLogin(null).getRedirectUrl());
}
//@Test
void h5LoginTest() {
BaseContext.setCurrentUser(user);
System.out.println(loginRequest.h5Login());
System.out.println(loginRequest.h5Login(null));
}
// @Test

View File

@ -1,6 +1,5 @@
package com.chint;
import com.chint.domain.aggregates.base.BaseEntity;
import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.constant.Constant;
import com.chint.infrastructure.util.BaseContext;
@ -10,19 +9,14 @@ import com.chint.interfaces.rest.ly.LYPostRequest;
import com.chint.interfaces.rest.ly.LYTokenRequest;
import com.chint.interfaces.rest.ly.LYUserRequest;
import com.chint.interfaces.rest.ly.dto.applyordersync.*;
import com.chint.interfaces.rest.ly.dto.bpm.BPMBaseRequest;
import com.chint.interfaces.rest.ly.dto.bpm.BPMResponse;
import com.chint.interfaces.rest.ly.dto.bpm.ExceedStandardDto;
import com.chint.interfaces.rest.ly.dto.bpm.RescheduleDto;
import com.chint.interfaces.rest.bpm.dot.BPMBaseRequest;
import com.chint.interfaces.rest.bpm.dot.BPMResponse;
import com.chint.interfaces.rest.bpm.dot.ExceedStandardDto;
import com.chint.interfaces.rest.bpm.dot.RescheduleDto;
import com.chint.interfaces.rest.ly.dto.commonresult.Result;
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.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@ -31,7 +25,6 @@ import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.chint.infrastructure.constant.Constant.*;
@ -292,13 +285,13 @@ public class LYTest {
// @Test
void loginLY() {
BaseContext.setCurrentUser(user);
System.out.println(loginRequest.login(L_Y_ENTRANCE_HOME));
System.out.println(loginRequest.login(L_Y_ENTRANCE_HOME,null));
}
// @Test
void loginLYPC() {
BaseContext.setCurrentUser(user);
System.out.println(loginRequest.loginPC(L_Y_ENTRANCE_HOME));
System.out.println(loginRequest.loginPC(L_Y_ENTRANCE_HOME,null));
}
//超标

View File

@ -45,9 +45,9 @@ class RouteApplicationTests {
}
@Test
void loginSign() {
String sfno = "230615020";
String sfno = "230615021";
String syscode = "abc";
String billcode = "KKK12321412323";
String billcode = "NNN12321412323";
String companycode = "浙江正泰电器股份有限公司";
String sec = "Superdandan";
String timespan = "12312321412312";