Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
3db25286ba
|
@ -0,0 +1,41 @@
|
||||||
|
package com.chint.domain.aggregates.system;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程发起管控表(ProcessInitiationControl)表实体类
|
||||||
|
*
|
||||||
|
* @author dengweichao
|
||||||
|
* @since 2024-03-29 09:28:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Table("process_initiation_control")
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class ProcessInitiationControl implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 7383041462839869026L;
|
||||||
|
|
||||||
|
//id
|
||||||
|
@Id
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
//订单号
|
||||||
|
private String orderNo;
|
||||||
|
|
||||||
|
//1:超标,2改签,3退票
|
||||||
|
private Integer tag;
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package com.chint.domain.service;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
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.aggregates.system.ProcessInitiationControl;
|
||||||
import com.chint.domain.aggregates.user.User;
|
import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.domain.exceptions.NotFoundException;
|
import com.chint.domain.exceptions.NotFoundException;
|
||||||
import com.chint.domain.exceptions.OrderException;
|
import com.chint.domain.exceptions.OrderException;
|
||||||
|
@ -19,6 +20,7 @@ import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcLegRepository;
|
||||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
|
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
|
||||||
|
import com.chint.infrastructure.repository.jdbc.JdbcProcessInitiationControlRepository;
|
||||||
import com.chint.infrastructure.util.DelayDispatch;
|
import com.chint.infrastructure.util.DelayDispatch;
|
||||||
import com.chint.interfaces.rest.bpm.BPMParamFactory;
|
import com.chint.interfaces.rest.bpm.BPMParamFactory;
|
||||||
import com.chint.interfaces.rest.bpm.BPMRequest;
|
import com.chint.interfaces.rest.bpm.BPMRequest;
|
||||||
|
@ -45,14 +47,12 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
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 java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.BPMConstant.*;
|
import static com.chint.infrastructure.constant.BPMConstant.*;
|
||||||
import static com.chint.infrastructure.constant.BelongSystemConstant.BELONG_SYS_CODE_ANFSSC;
|
import static com.chint.infrastructure.constant.BelongSystemConstant.BELONG_SYS_CODE_ANFSSC;
|
||||||
|
@ -113,6 +113,9 @@ public class OrderDomainService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private JdbcLegRepository jdbcLegRepository;
|
private JdbcLegRepository jdbcLegRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JdbcProcessInitiationControlRepository jdbcProcessInitiationControlRepository;
|
||||||
|
|
||||||
private Set<String> companyBlackList = new HashSet<>();
|
private Set<String> companyBlackList = new HashSet<>();
|
||||||
|
|
||||||
public RouteOrder saveOrder(RouteOrder routeOrder) {
|
public RouteOrder saveOrder(RouteOrder routeOrder) {
|
||||||
|
@ -162,7 +165,6 @@ public class OrderDomainService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ListenTo(command = "OrderCreateCommand", order = 0)
|
@ListenTo(command = "OrderCreateCommand", order = 0)
|
||||||
public RouteOrder createOrder(OrderCreateCommand command) {
|
public RouteOrder createOrder(OrderCreateCommand command) {
|
||||||
User user = command.getUser();
|
User user = command.getUser();
|
||||||
|
@ -270,6 +272,7 @@ public class OrderDomainService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ListenTo(command = "BPMAuditCommand", order = 0)
|
@ListenTo(command = "BPMAuditCommand", order = 0)
|
||||||
|
@Transactional
|
||||||
public void toBpmAudit(BPMAuditCommand command) {
|
public void toBpmAudit(BPMAuditCommand command) {
|
||||||
if (command.getOperationType().equals(ORDER_EVENT_ETA)) {
|
if (command.getOperationType().equals(ORDER_EVENT_ETA)) {
|
||||||
toBpmAuditETA(command);
|
toBpmAuditETA(command);
|
||||||
|
@ -281,8 +284,14 @@ public class OrderDomainService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toBpmAuditETA(BPMAuditCommand command) {
|
@Transactional
|
||||||
|
public void toBpmAuditETA(BPMAuditCommand command) {
|
||||||
OrderDetail orderDetail = command.getExtensionData();
|
OrderDetail orderDetail = command.getExtensionData();
|
||||||
|
List<ProcessInitiationControl> byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 1);
|
||||||
|
//不为空表示已推动过超标,直接返回结果
|
||||||
|
if (!byOrderNoAndTag.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
|
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
|
||||||
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
|
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
|
||||||
String employeeNo = orderDetail.getEmployeeNo();//用户id
|
String employeeNo = orderDetail.getEmployeeNo();//用户id
|
||||||
|
@ -318,9 +327,14 @@ public class OrderDomainService {
|
||||||
DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto, sysCode, employeeNo, accountCompany).getSuccess(),
|
DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto, sysCode, employeeNo, accountCompany).getSuccess(),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
//结束保存推送信息
|
||||||
|
ProcessInitiationControl processInitiationControl = new ProcessInitiationControl();
|
||||||
|
processInitiationControl.setOrderNo(orderDetail.getOrderNo())
|
||||||
|
.setTag(1);
|
||||||
|
jdbcProcessInitiationControlRepository.save(processInitiationControl);
|
||||||
}
|
}
|
||||||
|
@Transactional
|
||||||
private void toBpmReschedule(BPMAuditCommand command) {
|
public void toBpmReschedule(BPMAuditCommand command) {
|
||||||
OrderDetail orderDetail = command.getExtensionData();
|
OrderDetail orderDetail = command.getExtensionData();
|
||||||
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
|
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
|
||||||
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
|
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
|
||||||
|
@ -332,14 +346,29 @@ public class OrderDomainService {
|
||||||
.setReason(reason);//原因
|
.setReason(reason);//原因
|
||||||
//携程
|
//携程
|
||||||
if (orderDetail.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
if (orderDetail.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
||||||
|
//退票
|
||||||
|
if (command.getOperationType().equals(ORDER_EVENT_REFUND)) {
|
||||||
|
List<ProcessInitiationControl> byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 3);
|
||||||
|
//不为空表示已推动过退票,直接返回结果
|
||||||
|
if (!byOrderNoAndTag.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Integer rebookId = null;//默认为空
|
||||||
rescheduleDto.setOrderSource(SUPPLIER_C_TRIP_BPM_NAME);//携程商旅
|
rescheduleDto.setOrderSource(SUPPLIER_C_TRIP_BPM_NAME);//携程商旅
|
||||||
//查询订单明细
|
//查询订单明细
|
||||||
SearchOrderResponse searchOrderResponse = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderDetail.getOrderNo());
|
SearchOrderResponse searchOrderResponse = cTripOrderSearchRequest.searchOrderResponseByOrderId(orderDetail.getOrderNo());
|
||||||
//机票改签
|
//机票改签
|
||||||
if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) {
|
if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) {
|
||||||
//设置改签原时间、改签后时间、改签原因
|
//设置改签原时间、改签后时间、改签原因
|
||||||
setCTripChangeFlight(rescheduleDto, searchOrderResponse);
|
rebookId = setCTripChangeFlight(rescheduleDto, searchOrderResponse);
|
||||||
rescheduleDto.setOrderType(RESCHEDULE_TYPE_FLIGHT);
|
rescheduleDto.setOrderType(RESCHEDULE_TYPE_FLIGHT);
|
||||||
|
//改签
|
||||||
|
List<ProcessInitiationControl> byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo() + "-" + rebookId, 2);
|
||||||
|
//不为空表示已推动过改签,直接返回结果
|
||||||
|
if (!byOrderNoAndTag.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//机票退票
|
//机票退票
|
||||||
if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_REFUND)) {
|
if (orderDetail.getProductType().equals(LEG_TYPE_AIRPLANE) && command.getOperationType().equals(ORDER_EVENT_REFUND)) {
|
||||||
|
@ -354,10 +383,44 @@ public class OrderDomainService {
|
||||||
}
|
}
|
||||||
rescheduleDto.setOrderType(REFUND_TYPE_FLIGHT);
|
rescheduleDto.setOrderType(REFUND_TYPE_FLIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String employeeNo = orderDetail.getEmployeeNo();
|
||||||
|
String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany();
|
||||||
|
//发送
|
||||||
|
DelayDispatch.attemptToSend(() -> bpmRequest.reschedule(rescheduleDto, sysCode, employeeNo, accountCompany).getSuccess(),
|
||||||
|
0);
|
||||||
|
|
||||||
|
//结束保存推送信息
|
||||||
|
ProcessInitiationControl processInitiationControl = new ProcessInitiationControl();
|
||||||
|
if (command.getOperationType().equals(ORDER_EVENT_CHANGE)) {
|
||||||
|
processInitiationControl.setOrderNo(orderDetail.getOrderNo() + "-" + rebookId);
|
||||||
|
processInitiationControl.setTag(2);
|
||||||
|
}
|
||||||
|
if (command.getOperationType().equals(ORDER_EVENT_REFUND)) {
|
||||||
|
processInitiationControl.setOrderNo(orderDetail.getOrderNo());
|
||||||
|
processInitiationControl.setTag(3);
|
||||||
|
}
|
||||||
|
jdbcProcessInitiationControlRepository.save(processInitiationControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
//同程
|
//同程
|
||||||
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
|
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
|
||||||
|
//改签
|
||||||
|
if (command.getOperationType().equals(ORDER_EVENT_CHANGE)) {
|
||||||
|
List<ProcessInitiationControl> byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 2);
|
||||||
|
//不为空表示已推动过改签,直接返回结果
|
||||||
|
if (!byOrderNoAndTag.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//退票
|
||||||
|
if (command.getOperationType().equals(ORDER_EVENT_REFUND)) {
|
||||||
|
List<ProcessInitiationControl> byOrderNoAndTag = jdbcProcessInitiationControlRepository.findByOrderNoAndTag(orderDetail.getOrderNo(), 3);
|
||||||
|
//不为空表示已推动过退票,直接返回结果
|
||||||
|
if (!byOrderNoAndTag.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
rescheduleDto.setOrderSource(SUPPLIER_L_Y_BPM_NAME);//同程商旅
|
rescheduleDto.setOrderSource(SUPPLIER_L_Y_BPM_NAME);//同程商旅
|
||||||
//火车票改签
|
//火车票改签
|
||||||
if (orderDetail.getProductType().equals(LEG_TYPE_TRAIN) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) {
|
if (orderDetail.getProductType().equals(LEG_TYPE_TRAIN) && command.getOperationType().equals(ORDER_EVENT_CHANGE)) {
|
||||||
|
@ -394,16 +457,28 @@ public class OrderDomainService {
|
||||||
rescheduleDto.setReason("计划有变,更改行程");
|
rescheduleDto.setReason("计划有变,更改行程");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String employeeNo = orderDetail.getEmployeeNo();
|
||||||
|
String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany();
|
||||||
|
//发送
|
||||||
|
DelayDispatch.attemptToSend(() -> bpmRequest.reschedule(rescheduleDto, sysCode, employeeNo, accountCompany).getSuccess(),
|
||||||
|
0);
|
||||||
|
|
||||||
|
//结束保存推送信息
|
||||||
|
ProcessInitiationControl processInitiationControl = new ProcessInitiationControl();
|
||||||
|
processInitiationControl.setOrderNo(orderDetail.getOrderNo());
|
||||||
|
if (command.getOperationType().equals(ORDER_EVENT_CHANGE)) {
|
||||||
|
processInitiationControl.setTag(2);
|
||||||
|
}
|
||||||
|
if (command.getOperationType().equals(ORDER_EVENT_REFUND)) {
|
||||||
|
processInitiationControl.setTag(3);
|
||||||
|
}
|
||||||
|
jdbcProcessInitiationControlRepository.save(processInitiationControl);
|
||||||
}
|
}
|
||||||
String employeeNo = orderDetail.getEmployeeNo();
|
|
||||||
String accountCompany = routeOrder.getApproveOrderNo().getAccountCompany();
|
|
||||||
//发送
|
|
||||||
DelayDispatch.attemptToSend(() -> bpmRequest.reschedule(rescheduleDto, sysCode, employeeNo, accountCompany).getSuccess(),
|
|
||||||
0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//携程机票改签
|
//携程机票改签
|
||||||
private void setCTripChangeFlight(RescheduleDto rescheduleDto, SearchOrderResponse searchOrderResponse) {
|
private Integer setCTripChangeFlight(RescheduleDto rescheduleDto, SearchOrderResponse searchOrderResponse) {
|
||||||
List<ItineraryEntity> itineraryList = searchOrderResponse.getItineraryList();
|
List<ItineraryEntity> itineraryList = searchOrderResponse.getItineraryList();
|
||||||
try {
|
try {
|
||||||
ItineraryEntity itineraryEntity = itineraryList.get(0);
|
ItineraryEntity itineraryEntity = itineraryList.get(0);
|
||||||
|
@ -422,6 +497,7 @@ public class OrderDomainService {
|
||||||
rescheduleDto.setStartTime(cTakeOffTimeOld)
|
rescheduleDto.setStartTime(cTakeOffTimeOld)
|
||||||
.setRebookStartTime(cTakeOffTimeNew)
|
.setRebookStartTime(cTakeOffTimeNew)
|
||||||
.setReason(rebookReasonDescNew);
|
.setReason(rebookReasonDescNew);
|
||||||
|
return changeInfoNew.getRebookId();
|
||||||
} else {
|
} else {
|
||||||
ChangeInfo changeInfo = changeInfoList.get(changeInfoList.size() - 1);
|
ChangeInfo changeInfo = changeInfoList.get(changeInfoList.size() - 1);
|
||||||
//改签后时间
|
//改签后时间
|
||||||
|
@ -431,13 +507,16 @@ public class OrderDomainService {
|
||||||
rescheduleDto.setStartTime(createTime)
|
rescheduleDto.setStartTime(createTime)
|
||||||
.setRebookStartTime(cTakeOffTime)
|
.setRebookStartTime(cTakeOffTime)
|
||||||
.setReason(RebookReasonDesc);
|
.setReason(RebookReasonDesc);
|
||||||
|
return changeInfo.getRebookId();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
rescheduleDto.setStartTime("")
|
rescheduleDto.setStartTime("")
|
||||||
.setRebookStartTime("")
|
.setRebookStartTime("")
|
||||||
.setReason("计划有变,更改行程");
|
.setReason("计划有变,更改行程");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//火车票改签
|
//火车票改签
|
||||||
private void setLYChangeTrain(RescheduleDto rescheduleDto, TrainDetailResponse trainDetailResponse) {
|
private void setLYChangeTrain(RescheduleDto rescheduleDto, TrainDetailResponse trainDetailResponse) {
|
||||||
TrainDetailResponse.TrainDetailData data = trainDetailResponse.getData();
|
TrainDetailResponse.TrainDetailData data = trainDetailResponse.getData();
|
||||||
|
@ -449,9 +528,25 @@ public class OrderDomainService {
|
||||||
TrainDetailResponse.Item item = data.getItems().get(0);
|
TrainDetailResponse.Item item = data.getItems().get(0);
|
||||||
String seatClassOld = item.getSeatClass();//原席别
|
String seatClassOld = item.getSeatClass();//原席别
|
||||||
TrainDetailResponse.ChangeInfo changeInfo = item.getChangeInfo();
|
TrainDetailResponse.ChangeInfo changeInfo = item.getChangeInfo();
|
||||||
String planBeginDateNew = changeInfo.getPlanBeginDate();//改签后时间
|
//如果是空表示是改签后订单
|
||||||
String trainNoNew = changeInfo.getTrainNo();//改签后车次
|
if (Objects.isNull(changeInfo)) {
|
||||||
String seatClassNew = changeInfo.getChangeItem().getSeatClass();//改签后席别
|
//获取原订单的changeInfo
|
||||||
|
String parentOrderSerialNo = data.getParentOrderSerialNo();
|
||||||
|
TrainDetailResponse parentTrainDetailResponse = lySearchRequest.getTrainOrderDetail(parentOrderSerialNo);
|
||||||
|
if (parentTrainDetailResponse != null) {
|
||||||
|
changeInfo = parentTrainDetailResponse.getData().getItems().get(0).getChangeInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
String planBeginDateNew = "";
|
||||||
|
String trainNoNew = "";
|
||||||
|
String seatClassNew = "";
|
||||||
|
//不为空
|
||||||
|
if (!Objects.isNull(changeInfo)) {
|
||||||
|
planBeginDateNew = changeInfo.getPlanBeginDate();//改签后时间
|
||||||
|
trainNoNew = changeInfo.getTrainNo();//改签后车次
|
||||||
|
seatClassNew = changeInfo.getChangeItem().getSeatClass();//改签后席别
|
||||||
|
}
|
||||||
//设置值
|
//设置值
|
||||||
rescheduleDto.setRebookStartTime(planBeginDateNew)
|
rescheduleDto.setRebookStartTime(planBeginDateNew)
|
||||||
.setSeatingStandard(seatClassOld)//原席别
|
.setSeatingStandard(seatClassOld)//原席别
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.chint.infrastructure.repository.jdbc;
|
||||||
|
|
||||||
|
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
|
||||||
|
import com.chint.domain.aggregates.system.ProcessInitiationControl;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface JdbcProcessInitiationControlRepository extends CrudRepository<ProcessInitiationControl, Long> {
|
||||||
|
|
||||||
|
List<ProcessInitiationControl> findByOrderNoAndTag(String orderNo,Integer tag);
|
||||||
|
}
|
Loading…
Reference in New Issue