完成部分 同程新推送超标审批接口代码

This commit is contained in:
Superdandan 2024-03-23 13:00:17 +08:00
parent cbe17bf5db
commit 31293a65ff
12 changed files with 325 additions and 30 deletions

View File

@ -20,6 +20,7 @@ public class SystemCode implements Serializable {
private String systemCode; private String systemCode;
private String bpmCode; private String bpmCode;
private String redirectPath; private String redirectPath;
private Integer ifImmediateResponse; //是否立马回复审批结果0不是1是
@MappedCollection(idColumn = "system_id", keyColumn = "system_key") @MappedCollection(idColumn = "system_id", keyColumn = "system_key")
private List<CompanyInfo> companyInfos; private List<CompanyInfo> companyInfos;
} }

View File

@ -1,5 +1,6 @@
package com.chint.domain.service; package com.chint.domain.service;
import com.chint.domain.aggregates.system.SystemCode;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.SystemCodeRepository; import com.chint.domain.repository.SystemCodeRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -20,4 +21,13 @@ public class SystemDomainService {
} }
return b; return b;
} }
//是否返回结果
public boolean ifImmediateResponse(String sysCode) {
SystemCode bySysCode = systemCodeRepository.findBySysCode(sysCode);
if (bySysCode == null) {
throw new NotFoundException(SYS_CODE_ERROR);
}
return bySysCode.getIfImmediateResponse() == 1;
}
} }

View File

@ -3,6 +3,7 @@ package com.chint.infrastructure.constant;
public class LYConstant { public class LYConstant {
//同程 //同程
public static final String L_Y_STROKE_PUSH = "/api/TravelBizOrder/ExternalApproval";//行程推送外部审批 public static final String L_Y_STROKE_PUSH = "/api/TravelBizOrder/ExternalApproval";//行程推送外部审批
public static final String L_Y_STROKE_PUSH_NEW = "/api/TravelBizOrder/ExternalApprovalNew";//行程推送外部审批 -
public static final String L_Y_TOKEN_PATH = "/api/OAuth/v2/GetAccessToken"; public static final String L_Y_TOKEN_PATH = "/api/OAuth/v2/GetAccessToken";
public static final String L_Y_ORDER_PATH = "/api/TravelApplyOrder/ApplyOrderSync"; public static final String L_Y_ORDER_PATH = "/api/TravelApplyOrder/ApplyOrderSync";
public static final String L_Y_USER_PATH = "/api/Employee/SyncEmployeeInfo"; public static final String L_Y_USER_PATH = "/api/Employee/SyncEmployeeInfo";

View File

@ -5,8 +5,11 @@ import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.SystemCodeRepository; import com.chint.domain.repository.SystemCodeRepository;
import com.chint.infrastructure.repository.jdbc.JdbcSystemCodeRepository; import com.chint.infrastructure.repository.jdbc.JdbcSystemCodeRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND; import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
@Repository @Repository
@ -20,6 +23,7 @@ public class SystemCodeRepositoryImpl implements SystemCodeRepository {
return jdbcSystemCodeRepository.save(systemCode); return jdbcSystemCodeRepository.save(systemCode);
} }
@Cacheable(value = "SystemCode", key = "#sysCode")
@Override @Override
public SystemCode findBySysCode(String sysCode) { public SystemCode findBySysCode(String sysCode) {
return jdbcSystemCodeRepository.findBySystemCode(sysCode); return jdbcSystemCodeRepository.findBySystemCode(sysCode);

View File

@ -2,6 +2,9 @@ package com.chint.interfaces.rest.ctrip.tools;
import com.chint.infrastructure.constant.OrderConstant; import com.chint.infrastructure.constant.OrderConstant;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_UNKNOWN;
public class CTripUtils { public class CTripUtils {
public static Integer mapFlightStatus(String status) { public static Integer mapFlightStatus(String status) {
return switch (status) { return switch (status) {
@ -35,13 +38,13 @@ public class CTripUtils {
// "改签取消"可能需要新的状态常量因为它没有直接映射 // "改签取消"可能需要新的状态常量因为它没有直接映射
OrderConstant.ORDER_EVENT_PAYED; OrderConstant.ORDER_EVENT_PAYED;
case "Paid" -> OrderConstant.ORDER_EVENT_PAYED; // "已支付"映射到已预定 case "Paid" -> OrderConstant.ORDER_EVENT_PAYED; // "已支付"映射到已预定
case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving2" -> OrderConstant.ORDER_EVENT_ETA; // 未知状态 case "Approving2" -> ORDER_EVENT_ETA; // 未知状态
case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态
default -> default ->
// 处理未知或未映射的状态 // 处理未知或未映射的状态
-99; -99;
@ -73,13 +76,13 @@ public class CTripUtils {
case "submitFailed" -> case "submitFailed" ->
// "提交失败"可能需要新的状态常量因为它没有直接映射 // "提交失败"可能需要新的状态常量因为它没有直接映射
OrderConstant.ORDER_EVENT_PREPARE; OrderConstant.ORDER_EVENT_PREPARE;
case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving2" -> OrderConstant.ORDER_EVENT_ETA; // 未知状态 case "Approving2" -> ORDER_EVENT_ETA; // 未知状态
case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态
default -> default ->
// 处理未知或未映射的状态 // 处理未知或未映射的状态
-99; -99;
@ -105,13 +108,13 @@ public class CTripUtils {
// "退票成功"可能最接近"已经退票"但具体映射取决于业务逻辑 // "退票成功"可能最接近"已经退票"但具体映射取决于业务逻辑
OrderConstant.ORDER_EVENT_REFUND; // 使用退票状态作为近似映射 OrderConstant.ORDER_EVENT_REFUND; // 使用退票状态作为近似映射
case "Paid" -> OrderConstant.ORDER_EVENT_PAYED; // "已支付"映射到已预定状态 case "Paid" -> OrderConstant.ORDER_EVENT_PAYED; // "已支付"映射到已预定状态
case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving2" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approving2" -> ORDER_EVENT_ETA; // 未知状态
case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态
default -> default ->
// 处理未知或未映射的状态 // 处理未知或未映射的状态
-99; -99;
@ -148,13 +151,13 @@ public class CTripUtils {
case "Canceling" -> case "Canceling" ->
// "取消中"可能表示订单正在取消过程中但没有直接映射可能需要新的状态常量 // "取消中"可能表示订单正在取消过程中但没有直接映射可能需要新的状态常量
OrderConstant.ORDER_EVENT_REFUND; OrderConstant.ORDER_EVENT_REFUND;
case "Approve_G" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_G" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approving" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approving2" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approving2" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_T" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_T" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_F" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_F" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_A" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_A" -> ORDER_EVENT_UNKNOWN; // 未知状态
case "Approve_C" -> OrderConstant.ORDER_EVENT_UNKNOWN; // 未知状态 case "Approve_C" -> ORDER_EVENT_UNKNOWN; // 未知状态
default -> default ->
// 处理未知或未映射的状态 // 处理未知或未映射的状态
-99; -99;

View File

@ -14,4 +14,8 @@ public class LYNoteResponse {
public static LYNoteResponse success() { public static LYNoteResponse success() {
return new LYNoteResponse("100", "OK"); return new LYNoteResponse("100", "OK");
} }
public static LYNoteResponse error(String resMsg) {
return new LYNoteResponse("100", resMsg);
}
} }

View File

@ -0,0 +1,35 @@
package com.chint.interfaces.rest.ly;
import com.chint.interfaces.rest.ly.dto.approval.ApprovalRequest;
import com.chint.interfaces.rest.ly.dto.approval.ApprovalResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import static com.chint.infrastructure.constant.LYConstant.L_Y_STROKE_PUSH_NEW;
@Component
public class LyApprovalRequest {
@Value("${ly.baseUrl}")
private String baseUrl;
@Autowired
private LYPostRequest lyPostRequest;
public ApprovalResponse pushApprovalSuccess(String approvalId) {
return pushApprovalRes(approvalId, 2);
}
public ApprovalResponse pushApprovalError(String approvalId) {
return pushApprovalRes(approvalId, 1);
}
private ApprovalResponse pushApprovalRes(String approvalId, Integer approvalStatus) {
ApprovalRequest approvalRequest = ApprovalRequest.approvalOrder(approvalId, approvalStatus);
return lyPostRequest.post(baseUrl + L_Y_STROKE_PUSH_NEW,
approvalRequest,
ApprovalResponse.class);
}
}

View File

@ -0,0 +1,26 @@
package com.chint.interfaces.rest.ly.dto.approval;
import com.chint.interfaces.rest.ly.dto.LYBaseRequest;
import lombok.Data;
@Data
public class ApprovalRequest extends LYBaseRequest {
private ApprovalParam param;
public static ApprovalRequest approvalOrder(String approvalId, Integer approvalStatus) {
ApprovalRequest approvalRequest = new ApprovalRequest();
ApprovalParam param = new ApprovalParam();
param.setApprovalId(approvalId);
param.setApprovalStatus(approvalStatus);
approvalRequest.setParam(param);
return approvalRequest;
}
@Data
public static class ApprovalParam {
private String approvalId;
private Integer remarks;
private Integer approvalStatus;
private Integer outApprovalId;
}
}

View File

@ -0,0 +1,10 @@
package com.chint.interfaces.rest.ly.dto.approval;
import com.chint.interfaces.rest.ly.dto.LYBaseResponse;
import lombok.Data;
@Data
public class ApprovalResponse extends LYBaseResponse {
private String data;
private Integer errorType;
}

View File

@ -0,0 +1,157 @@
package com.chint.interfaces.rest.ly.dto.eta;
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightInfo;
import lombok.Data;
import java.util.List;
@Data
public class LyETAPush {
private NotifyData notifyData;
private int notifyType;
private int subNotifyType;
private long notifyTime;
private String sign;
private String soleKey;
private boolean isEncrypt;
@Data
public static class NotifyData {
private String ApprovalOrderId;
private String TravelApplyNo;
private String TravelOrderNo;
private List<Employee> Employees;
private String BookEmpId;
private String BookEmpEmail;
private String CompanyCode;
private List<String> OrderNos;
private OrderInfo OrderInfos;
}
@Data
public static class Employee {
private String empId;
private String empEmail;
private String empName;
}
@Data
public static class OrderInfo {
private List<FlightOrderInfo> flightOrderInfos;
private List<HotelOrderInfo> hotelOrderInfos;
private List<TrainOrderInfo> trainOrderInfos;
}
@Data
public static class FlightOrderInfo {
private String orderNo;
private List<BusinessTravelPolicy> businessTravelPolicies;
private double totalAmount;
private double originalAmount;
private double refundAmount;
private double changeAmount;
private List<FlightInfo> flightInfo;
}
@Data
public static class BusinessTravelPolicy {
private int isViolation;
private String passengerEmpId;
private String violationReasonCode;
private String violationReasonChinese;
private String violationReasonRemark;
private List<PolicyDetail> policyDetails;
}
@Data
public static class PolicyDetail {
private String violationContent;
private String violationContentCode;
}
@Data
public static class FlightInfo {
private String arrivalAirport;
private String arrivalCity;
private String arrivalDate;
private String cabin;
private String departureAirport;
private String departureCity;
private String departureDate;
private String flightCompany;
private String flight;
private String meal;
private String planeModel;
private double price;
private double tax;
private double oil;
private double amount;
private int flightNo;
}
//酒店订单信息
@Data
public static class HotelOrderInfo {
private List<BusinessTravelPolicy> businessTravelPolicies;
private String orderNo;
private AmountInfo amountInfo;
private List<HotelInfo> hotelInfos;
// Getters and Setters
}
@Data
public static class AmountInfo {
private double totalAmount;
private String currency;
private String payType;
private double companyAmt;
private double personAmt;
// Getters and Setters
}
@Data
public static class HotelInfo {
private String clientName;
private String city;
private String startTime;
private String endTime;
private String quantity;
private String roomDays;
private String roomName;
private String roomNo;
private String meal;
private String stars;
private String hotelType;
}
//火车订单信息
@Data
class TrainOrderInfo {
private String orderNo;
private double totalAmount;
private double originalAmount;
private double changeAmount;
private double refundAmount;
private List<TrainInfo> trainInfos;
private List<BusinessTravelPolicy> businessTravelPolicies;
}
@Data
class TrainInfo {
private String passengerName;
private String trainNum;
private String seatType;
private String departureTime;
private String arriveTime;
private String dCityName;
private String aCityName;
private String dStationName;
private String aStationName;
private double price;
}
}

View File

@ -0,0 +1,44 @@
package com.chint.interfaces.rest.ly.in;
import com.chint.domain.service.SystemDomainService;
import com.chint.interfaces.rest.ly.LYNoteResponse;
import com.chint.interfaces.rest.ly.dto.eta.LyETAPush;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/public/common")
public class LYETAController {
@Autowired
private SystemDomainService systemDomainService;
@PostMapping("/eta")
public LYNoteResponse noteByETA(@RequestBody LyETAPush lyETAPush) {
if (lyETAPush.getNotifyType() != 51) {
return LYNoteResponse.error("推送类型错误");
}
String travelApplyNo = lyETAPush.getNotifyData().getTravelApplyNo();
String[] split = travelApplyNo.split("-");
if (split.length == 0) {
return LYNoteResponse.error("外部申请单格式错误");
}
//获取系统标识
String sysCode = split[0];
// systemDomainService.ifImmediateResponse(sysCode)
return null;
}
}