Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
dengwc 2024-03-02 16:04:38 +08:00
commit c818afc501
26 changed files with 163 additions and 37 deletions

View File

@ -6,10 +6,11 @@ import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
@Data
public class BPMLegChangeCommand extends Command {
public class BPMLegChangeCommand extends Command {
private Long routeId;
private Leg oldLeg;
private Leg newleg;
private String reason;
private Integer changeType; //0 is add, 1 is update
public BPMLegChangeCommand oldLeg(Leg leg) {
@ -21,6 +22,11 @@ public class BPMLegChangeCommand extends Command {
this.newleg = leg;
return this;
}
public BPMLegChangeCommand reason(String reason) {
this.reason = reason;
return this;
}
public BPMLegChangeCommand routeId(Long routeId) {
this.routeId = routeId;

View File

@ -0,0 +1,25 @@
package com.chint.application.commands;
import com.chint.domain.value_object.FinishLegData;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_CHANGE;
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_FINISH;
@Data
public class LegChangeCommand extends Command {
private final Integer legEventType = LEG_EVENT_CHANGE;
private Long legId;
private String reason;
public LegChangeCommand legId(Long LegId) {
this.setLegId(LegId);
return this;
}
public LegChangeCommand reason(String reason) {
this.reason = reason;
return this;
}
}

View File

@ -28,6 +28,7 @@ public class LegRes {
private LocationRes originLocation;
private LocationRes destinationLocation;
private String amount;
private String legTypeName;
private String legTypeEnName;
@ -44,7 +45,7 @@ public class LegRes {
@ApiModelProperty("目的地详细")
private String destinationDescription;
private Integer legStatus;
private String changeReason;
private String legStatusName;

View File

@ -3,6 +3,7 @@ package com.chint.application.dtos.response;
import com.chint.domain.aggregates.order.ApproveOrderNo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Column;
@ -41,5 +42,6 @@ public class RouteOrderPageRes {
private String endTime;
private String supplierName;
private String supplierCNName;
@ApiModelProperty("是否为有火车的订单0无1有")
private String ifHaveTrainLeg;
}

View File

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.CommonMessageConstant.SYNC_FAILURE_TRAIN;
@RestController
@RequestMapping("/order")
@ -82,7 +83,7 @@ public class OrderController {
@Transactional
@ApiOperation("修改行程节点")
@PostMapping("/leg/change/")
@PostMapping("/leg/change")
public Result<String> changeLeg(@RequestBody AddLegData addLegData) {
orderApplicationService.changeLeg(addLegData);
return Result.Success(SUCCESS);
@ -101,7 +102,10 @@ public class OrderController {
@ApiOperation("同步行程规划单的订单状态")
@PostMapping("/sync/order")
public Result<String> reloadOrderDetail(@RequestBody SyncLegData syncLegData) {
orderDetailDomainService.syncOrderDetailStatusByRouteId(syncLegData.getRouteId());
return Result.Success(SUCCESS);
if (orderDetailDomainService.syncOrderDetailStatusByRouteId(syncLegData.getRouteId())) {
return Result.Success(SUCCESS);
} else {
return Result.error(SYNC_FAILURE_TRAIN);
}
}
}

View File

@ -25,6 +25,10 @@ public class FSSCController {
public Result<LoginResponse> loginToFSSC() {
User currentUser = BaseContext.getCurrentUser();
String companyCode = currentUser.getCompanyCode();//公司编号
//这里需要根据companyCode进行匹配到正确的申请单网址
return Result.Success(SUCCESS, LoginResponse.success(FSSCUrl + FSSC_LOGIN_PATH_APPROVAL + currentUser.getEmployeeNo()));
}

View File

@ -151,6 +151,13 @@ public class OrderQuery {
User currentUser = BaseContext.getCurrentUser();
RouteOrderPageRes res = BeanUtil.copyProperties(routeOrder.reloadStatus(), RouteOrderPageRes.class);
List<Leg> legItems = routeOrder.getLegItems();
if (routeOrder.checkIfHaveTrainLeg()) {
res.setIfHaveTrainLeg("1");
} else {
res.setIfHaveTrainLeg("0");
}
List<LocationRes> locationRes = legItems
.stream()
.flatMap(leg -> Stream.of(leg.getOriginLocation(), leg.getDestinationLocation()))

View File

@ -75,7 +75,8 @@ public class OrderApplicationService {
.orElseThrow(() -> new NotFoundException(CommonMessageConstant.NOT_FOUND));
order.reloadStatus();
List<Leg> legs = processLegData(addLegData.getLegData(), order);
LegData legData = addLegData.getLegData();
List<Leg> legs = processLegData(legData, order);
orderDomainService.queryLocation(legs);
RouteOrder routeOrder = orderDomainService.saveOrder(order);
legs.forEach(leg -> {
@ -86,6 +87,11 @@ public class OrderApplicationService {
Command.of(LegApprovalCommand.class).legId(leg.getLegId()).sendToQueue();
}
//如果是变更事件推送变更事件
if (legData.getChangeReason() != null) {
Command.of(LegChangeCommand.class).legId(leg.getLegId()).reason(legData.getChangeReason()).sendToQueue();
}
if (!order.getOrderStatus().equals(ORDER_STATUS_PREPARE)) {
Command.of(BPMLegChangeCommand.class).newleg(leg).routeId(routeOrder.getRouteId()).changeType(0).sendToQueue();
}
@ -118,7 +124,20 @@ public class OrderApplicationService {
leg.setDestinationId(legData.getDestinationId());
orderDomainService.queryLocation(List.of(oldLeg,leg));
legRepository.save(leg).reloadStatus();
Command.of(BPMLegChangeCommand.class).routeId(addLegData.getRouteId()).oldLeg(oldLeg).newleg(leg).changeType(1).sendToQueue();
//保存变更事件理由
Command.of(LegChangeCommand.class)
.legId(leg.getLegId())
.reason(legData.getChangeReason())
.sendToQueue();
//发送bpm保存结果
Command.of(BPMLegChangeCommand.class)
.routeId(addLegData.getRouteId())
.reason(addLegData.getLegData().getChangeReason())
.oldLeg(oldLeg)
.newleg(leg)
.changeType(1)
.sendToQueue();
//异步操作-如果是当前的状态已经进行过匹配那么就要订单同步到供应商一次

View File

@ -22,8 +22,7 @@ import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
import static com.chint.infrastructure.constant.LegConstant.*;
@Slf4j
@Data
@ -68,6 +67,8 @@ public class Leg {
@Transient
private String legStatusName;
@Transient
private String changeReason;
@Transient
private CurrencyType currencyType;
@Transient
private List<OrderDetail> orderDetails; //这个属性不做持久化保存 根据下单事件进行获取
@ -117,7 +118,14 @@ public class Leg {
this.getLegExtensionField().reloadStatus();
}
//
//添加变更理由
this.eventList
.stream()
.filter(legEvent -> legEvent.getEventType().equals(LEG_EVENT_CHANGE))
.max(Comparator.comparingLong(LegEvent::getLegEventId))
.ifPresent(legEvent -> this.changeReason = legEvent.getExtension());
return this;
}

View File

@ -22,6 +22,8 @@ public class LegEvent {
@Transient
private String eventName;
private String extension;
private LocalDateTime happenTime;
@Transient
@ -36,6 +38,7 @@ public class LegEvent {
case LegConstant.LEG_EVENT_NOT_ORDERED -> LegConstant.LEG_EVENT_NOT_ORDERED_NAME;
case LegConstant.LEG_EVENT_APPROVAL -> LegConstant.LEG_EVENT_APPROVAL_NAME;
case LegConstant.LEG_EVENT_REJECT -> LegConstant.LEG_EVENT_REJECT_NAME;
case LegConstant.LEG_EVENT_CHANGE -> LegConstant.LEG_EVENT_CHANGE_NAME;
default -> "未知事件";
};
}

View File

@ -30,6 +30,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TRAIN;
import static com.chint.infrastructure.constant.UtilConstant.RESULT_ORDER_DETAIL;
@Data
@ -197,7 +198,6 @@ public class RouteOrder extends BaseEntity {
}
public RouteOrder reloadStatus(OrderSaveData orderSaveData) {
// 重新加载所有Leg的状态
List<Leg> legs = this.getLegItems();
@ -390,4 +390,9 @@ public class RouteOrder extends BaseEntity {
// 返回综合评分
return timeScore;
}
public boolean checkIfHaveTrainLeg() {
return legItems.stream()
.anyMatch(leg -> leg.getLegType().equals(LEG_TYPE_TRAIN));
}
}

View File

@ -10,4 +10,6 @@ public class SystemCode {
private String systemName;
private String systemCode;
private String bpmCode;
private String redirectPath;
// private List<String>
}

View File

@ -47,13 +47,15 @@ public class RouteOrderFactory implements OrderFactory {
User currentUser = BaseContext.getCurrentUser();
User user = command.getUser();
UserLoginParam loginParam = user.getUserLoginParam();
String syscode = loginParam.getSyscode();
String billcode = loginParam.getBillcode();
RouteOrder routeOrder = new RouteOrder();
routeOrder.setRouteOrderNo(OrderNo.generate());
routeOrder.setRouteOrderNo(OrderNo.generate(syscode, billcode));
//根据项目需求需要保存假审批订单号真审批订单号 创建的时候保存假审批订单号
routeOrder.setUserId(loginParam.getSfno());
ApproveOrderNo approveOrderNo = new ApproveOrderNo();
approveOrderNo.setSysCode(loginParam.getSyscode());
approveOrderNo.setFakeOrderNo(loginParam.getBillcode());
approveOrderNo.setSysCode(syscode);
approveOrderNo.setFakeOrderNo(billcode);
approveOrderNo.setAccountCompany(currentUser.getCompanyCode());
approveOrderNo.setAccountCompanyName(currentUser.getCompanyName());
routeOrder.setApproveOrderNo(approveOrderNo);

View File

@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.List;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@Service
public class OrderDetailDomainService {
@ -49,9 +50,12 @@ public class OrderDetailDomainService {
}
}
public void syncOrderDetailStatusByRouteId(Long RouteId) {
public boolean syncOrderDetailStatusByRouteId(Long RouteId) {
RouteOrder routeOrder = routeRepository.queryById(RouteId);
String supplierName = routeOrder.getSupplierName();
if (routeOrder.checkIfHaveTrainLeg() && supplierName.equals(SUPPLIER_C_TRIP)) {
return false;
}
List<OrderLegData> orderLegDataList = new ArrayList<>();
List<String> list = routeOrder.getOrderDetails().stream()
.filter(it -> it.getLastEvent().getEventType() != ORDER_EVENT_CANCEL)
@ -61,5 +65,6 @@ public class OrderDetailDomainService {
orderDataAdapterSelector.of(supplierName).adapt(supplierCallbackData).ifPresent(orderLegDataList::add);
}
syncOrderDetailStatus(orderLegDataList);
return true;
}
}

View File

@ -244,7 +244,7 @@ public class LegEventHandler implements LegEventService {
Integer changeType = command.getChangeType();
Leg leg = command.getNewleg();
Long routeId = leg.getRouteId();
if(routeId == null){
if (routeId == null) {
routeId = command.getRouteId();
}
RouteOrder routeOrder = routeRepository.queryById(routeId);
@ -254,7 +254,10 @@ public class LegEventHandler implements LegEventService {
switch (bpmCode) {
case H3_BPM -> {
JTH3ChangeDto jth3ChangeDto = new JTH3ChangeDto();
if(changeType.equals(0)){
if (leg.getChangeReason() != null) {
jth3ChangeDto.setReason(leg.getChangeReason());
}
if (changeType.equals(0)) {
jth3ChangeDto.addLegNewTrip(leg);
} else {
jth3ChangeDto.addLegOldTrip(command.getOldLeg());
@ -264,7 +267,10 @@ public class LegEventHandler implements LegEventService {
}
case XNYS_BPM -> {
XNChangeDto xnChangeDto = new XNChangeDto();
if(changeType.equals(0)){
if (leg.getChangeReason() != null) {
xnChangeDto.setReason(leg.getChangeReason());
}
if (changeType.equals(0)) {
xnChangeDto.addLegNewTrip(leg);
} else {
xnChangeDto.addLegOldTrip(command.getOldLeg());
@ -279,4 +285,12 @@ public class LegEventHandler implements LegEventService {
default -> throw new NotFoundException(DATA_NOT_FOUND);
}
}
@Override
public void changeLeg(LegChangeCommand command) {
Leg byLegId = legRepository.findByLegId(command.getLegId());
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
byLegId.addEvent(legEvent);
legRepository.save(byLegId);
}
}

View File

@ -28,4 +28,6 @@ public interface LegEventService {
void rejectLeg(LegRejectCommand command);
void pushChangeLegToBpm(BPMLegChangeCommand command);
void changeLeg(LegChangeCommand command);
}

View File

@ -80,4 +80,10 @@ public class LegEventServiceImpl implements LegEventService {
public void pushChangeLegToBpm(BPMLegChangeCommand command) {
legEventHandler.pushChangeLegToBpm(command);
}
@Override
@ListenTo(command = "LegChangeCommand", order = 0)
public void changeLeg(LegChangeCommand command) {
legEventHandler.changeLeg(command);
}
}

View File

@ -66,10 +66,13 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
aosPeople.add(aosPerson);
//4.前置差旅政策
List<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>();
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
aosPreTravelPolicy.setPolicyCode("");//一般指客户经理提供的差旅政策标题
aosPreTravelPolicy.setProductTypeId(0);//产品ID 1国内机票2国际机票3国内酒店4海外酒店5火车票6用车
aosPreTravelPolicies.add(aosPreTravelPolicy);
;
for (int i = 1; i < 7; i++) {
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
aosPreTravelPolicy.setPolicyCode(order.getStandardLevel());//一般指客户经理提供的差旅政策标题
aosPreTravelPolicy.setProductTypeId(i);//产品ID 1国内机票2国际机票3国内酒店4海外酒店5火车票6用车
aosPreTravelPolicies.add(aosPreTravelPolicy);
}
param.setItemList(aosItems); // 同程节点内容
param.setPersonList(aosPeople);// 同程信息实际出行人
@ -122,10 +125,12 @@ public class LYOrderSyncAdapter implements SupplierOrderSync {
aosPeople.add(aosPerson);
//4.前置差旅政策
List<AOSPreTravelPolicy> aosPreTravelPolicies = new ArrayList<>();
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
aosPreTravelPolicy.setPolicyCode("");//一般指客户经理提供的差旅政策标题
aosPreTravelPolicy.setProductTypeId(0);//产品ID 1国内机票2国际机票3国内酒店4海外酒店5火车票6用车
aosPreTravelPolicies.add(aosPreTravelPolicy);
for (int i = 1; i < 7; i++) {
AOSPreTravelPolicy aosPreTravelPolicy = new AOSPreTravelPolicy();
aosPreTravelPolicy.setPolicyCode(order.getStandardLevel());//一般指客户经理提供的差旅政策标题
aosPreTravelPolicy.setProductTypeId(i);//产品ID 1国内机票2国际机票3国内酒店4海外酒店5火车票6用车
aosPreTravelPolicies.add(aosPreTravelPolicy);
}
param.setItemList(aosItems); // 同程节点内容
param.setPersonList(aosPeople);// 同程信息实际出行人

View File

@ -1,18 +1,16 @@
package com.chint.domain.value_object;
import com.chint.domain.aggregates.order.LegExtensionField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class LegData {
public final Long legId;
public final Integer legType;
@ApiModelProperty("变更理由")
private final String changeReason;
public final String startTime;

View File

@ -4,6 +4,7 @@ public class CommonMessageConstant {
// 通用消息
public static final String SUCCESS = "操作成功";
public static final String FAILURE = "操作失败";
public static final String SYNC_FAILURE_TRAIN = "携程暂不支持火车票预订";
public static final String DUPLICATE_ERROR = "数据重复";
public static final String NOT_FOUND = "未找到相关数据";
public static final String INVALID_REQUEST = "无效的请求";

View File

@ -60,6 +60,8 @@ public class LegConstant {
public static final String LEG_EVENT_ORDERED_NAME = "下单事件";
public static final int LEG_EVENT_PAYED = 5;
public static final String LEG_EVENT_PAYED_NAME = "付款事件";
public static final int LEG_EVENT_CHANGE = 6;
public static final String LEG_EVENT_CHANGE_NAME = "变更事件";
public static final int LEG_EVENT_FINISH = 9;
public static final String LEG_EVENT_FINISH_NAME = "结束事件";
public static final int LEG_EVENT_REJECT = -1;

View File

@ -17,6 +17,11 @@ public class OrderNo {
return "R" + datePart + randomPart;
}
public static String generate(String sysCode, String billCode) {
// 拼接最终的订单号
return sysCode + "-" + billCode;
}
public static String generateLegNo() {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();

View File

@ -67,8 +67,8 @@ public class HotelBackController {
.orderNo(serialNo)
.outStatus(String.valueOf(notification.getSubNotifyType()));
//状态映射
command.eventType(ORDER_EVENT_ETA);
command.sendToQueue();
command2.eventType(ORDER_EVENT_ETA);
command2.sendToQueue();
}
return new LYNoteResponse("100", "成功收到消息");
}

View File

@ -51,7 +51,7 @@ cTrip:
requestSecret: zhengtai2024_nEbmKfOo
FSSC:
baseUrl: http://10.10.14.178:8080
baseUrl: https://fssc-t.chint.com
paila:
client-id: 0053df85723db94491e8

View File

@ -21,7 +21,7 @@ cTrip:
requestSecret: zhengtai2024_nEbmKfOo
FSSC:
baseUrl: http://10.10.14.178:8080
baseUrl: https://fssc-t.chint.com
paila:
client-id: 0053df85723db94491e8

View File

@ -40,7 +40,7 @@ cTrip:
requestSecret: zhengtai2024_nEbmKfOo
FSSC:
baseUrl: http://10.10.14.178:8080
baseUrl: https://fssc-t.chint.com
paila:
client-id: 0053df85723db94491e8