同步代码
This commit is contained in:
parent
786abad905
commit
b7425c7b80
|
@ -1,6 +1,5 @@
|
|||
package com.chint.application.commands;
|
||||
|
||||
import com.chint.domain.value_object.ApproveLegData;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -8,17 +7,11 @@ import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_APPROVAL;
|
|||
|
||||
@Data
|
||||
public class LegApprovalCommand extends Command {
|
||||
private Integer LegEventType = LEG_EVENT_APPROVAL;
|
||||
private Long LegId;
|
||||
private ApproveLegData data;
|
||||
private Integer legEventType = LEG_EVENT_APPROVAL;
|
||||
private Long legId;
|
||||
|
||||
public LegApprovalCommand legId(Long LegId) {
|
||||
this.setLegId(LegId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LegApprovalCommand data(ApproveLegData data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.chint.application.commands;
|
||||
|
||||
import com.chint.domain.value_object.ApproveLegData;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import lombok.Data;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_APPROVAL;
|
||||
|
||||
@Data
|
||||
public class RouteApprovalCommand extends Command {
|
||||
private Integer LegEventType = LEG_EVENT_APPROVAL;
|
||||
private Long LegId;
|
||||
private ApproveLegData data;
|
||||
|
||||
public RouteApprovalCommand legId(Long LegId) {
|
||||
this.setLegId(LegId);
|
||||
return this;
|
||||
}
|
||||
|
||||
public RouteApprovalCommand data(ApproveLegData data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -28,8 +28,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_NOT_ORDERED;
|
||||
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
|
||||
import static com.chint.infrastructure.constant.RouteConstant.*;
|
||||
|
||||
@Service
|
||||
public class OrderApplicationService {
|
||||
|
@ -77,7 +76,14 @@ public class OrderApplicationService {
|
|||
|
||||
List<Leg> legs = processLegData(addLegData.getLegData(), order);
|
||||
RouteOrder routeOrder = orderDomainService.saveOrder(order);
|
||||
legs.forEach(leg -> Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue());
|
||||
legs.forEach(leg -> {
|
||||
Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue();
|
||||
//如果订单状态已经处于审批中, 那么为这个新增的leg也提交审批状态
|
||||
if (order.getOrderStatus() >= ORDER_STATUS_APPROVAL) {
|
||||
Command.of(LegApprovalCommand.class).legId(leg.getLegId()).sendToQueue();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//异步操作-如果是当前的状态已经进行过匹配,那么就要订单同步到供应商一次
|
||||
if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) {
|
||||
|
@ -142,7 +148,7 @@ public class OrderApplicationService {
|
|||
|
||||
@Transactional
|
||||
public void approve(ApproveLegData approveLegData) {
|
||||
Command.of(LegApprovalCommand.class).data(approveLegData).sendToQueue();
|
||||
Command.of(RouteApprovalCommand.class).data(approveLegData).sendToQueue();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
@ -72,7 +72,7 @@ public class LegEventHandler implements LegEventService {
|
|||
|
||||
@Transactional
|
||||
@Override
|
||||
public void approveLeg(LegApprovalCommand command) {
|
||||
public void approveRoute(RouteApprovalCommand command) {
|
||||
ApproveLegData data = command.getData();
|
||||
RouteOrder routeOrder = routeRepository.findByFakeOrderNoAndSysCode(data.getFakeOrderNo(), data.getSysCode()).reloadStatus();
|
||||
if (routeOrder.getLegItems().isEmpty()) {
|
||||
|
@ -135,6 +135,13 @@ public class LegEventHandler implements LegEventService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void approveLeg(LegApprovalCommand command) {
|
||||
Leg leg = legRepository.findByLegId(command.getLegId());
|
||||
leg.addEvent(legEventFactory.creatLegEvent(command.getLegEventType()));
|
||||
legRepository.save(leg);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) {
|
||||
|
|
|
@ -8,10 +8,12 @@ public interface LegEventService {
|
|||
void prepareLeg(LegPrepareCommand command);
|
||||
|
||||
//审批事件要从bpm或其他平台接收到一个真实订单
|
||||
void approveLeg(LegApprovalCommand command);
|
||||
void approveRoute(RouteApprovalCommand command);
|
||||
|
||||
void syncLeg(LegSyncCommand command);
|
||||
|
||||
void approveLeg(LegApprovalCommand command);
|
||||
|
||||
//下单事件
|
||||
ResultContainer orderLeg(LegOrderedCommand command);
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ public class LegEventServiceImpl implements LegEventService {
|
|||
//因为审批是针对整个订单的,因此所有订单下属的行程节点触发审批事件
|
||||
//出发审批提交事件 , 需要生成 差旅单 , 将差旅但提交到供应商 ,
|
||||
//根据command里面选择的数据来讲差旅但提交到不同的实现类当中
|
||||
@ListenTo(command = "LegApprovalCommand", order = 0)
|
||||
@ListenTo(command = "RouteApprovalCommand", order = 0)
|
||||
@Override
|
||||
public void approveLeg(LegApprovalCommand command) {
|
||||
legEventHandler.approveLeg(command);
|
||||
public void approveRoute(RouteApprovalCommand command) {
|
||||
legEventHandler.approveRoute(command);
|
||||
}
|
||||
|
||||
//这里需要获取同步类,价格routeOrder同步到供应商
|
||||
|
@ -36,6 +36,13 @@ public class LegEventServiceImpl implements LegEventService {
|
|||
legEventHandler.syncLeg(command);
|
||||
}
|
||||
|
||||
|
||||
@ListenTo(command = "LegApprovalCommand", order = 0)
|
||||
@Override
|
||||
public void approveLeg(LegApprovalCommand command) {
|
||||
legEventHandler.approveLeg(command);
|
||||
}
|
||||
|
||||
//下单时间要求回传,需要付款的金额,以及生成对于的行程订单号,如果没有行程订单号根据地点和时间进行匹配
|
||||
@ListenTo(command = "LegOrderedCommand", order = 0)
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue