完成部分业务逻辑
This commit is contained in:
parent
c2a7816da7
commit
ca1c093698
4
pom.xml
4
pom.xml
|
@ -71,6 +71,10 @@
|
||||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||||
<version>3.0.3</version>
|
<version>3.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.chint.application.commands;
|
||||||
|
|
||||||
|
import com.chint.domain.value_object.SyncLegData;
|
||||||
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.Constant.LEG_EVENT_NOT_ORDERED;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LegSyncCommand extends Command {
|
||||||
|
private Integer LegEventType = LEG_EVENT_NOT_ORDERED;
|
||||||
|
private Long LegId;
|
||||||
|
private Long routOrderId;
|
||||||
|
private SyncLegData data;
|
||||||
|
|
||||||
|
public LegSyncCommand legId(Long LegId) {
|
||||||
|
this.setLegId(LegId);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LegSyncCommand data(SyncLegData data) {
|
||||||
|
this.data = data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.chint.application.commands;
|
||||||
|
|
||||||
|
import com.chint.domain.value_object.UserLoginParam;
|
||||||
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderCreateCommand extends Command {
|
||||||
|
private UserLoginParam loginParam;
|
||||||
|
|
||||||
|
public OrderCreateCommand of(UserLoginParam loginParam) {
|
||||||
|
this.loginParam = loginParam;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,19 @@
|
||||||
package com.chint.application.out;
|
package com.chint.application.out;
|
||||||
|
|
||||||
|
|
||||||
|
import com.chint.application.commands.OrderCreateCommand;
|
||||||
import com.chint.domain.service.auth.AuthenticateService;
|
import com.chint.domain.service.auth.AuthenticateService;
|
||||||
import com.chint.domain.value_object.UserLoginParam;
|
import com.chint.domain.value_object.UserLoginParam;
|
||||||
import com.chint.domain.value_object.UserLoginResult;
|
import com.chint.domain.value_object.UserLoginResult;
|
||||||
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
import com.chint.infrastructure.util.Digest;
|
import com.chint.infrastructure.util.Digest;
|
||||||
import com.chint.infrastructure.util.Result;
|
import com.chint.infrastructure.util.Result;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.Constant.*;
|
import static com.chint.infrastructure.constant.Constant.*;
|
||||||
|
|
||||||
|
@ -18,6 +24,7 @@ public class LoginController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AuthenticateService authenticateService;
|
private AuthenticateService authenticateService;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@GetMapping("/login")
|
@GetMapping("/login")
|
||||||
public Result<UserLoginResult> login(@RequestParam("sfno") String sfno,
|
public Result<UserLoginResult> login(@RequestParam("sfno") String sfno,
|
||||||
@RequestParam("syscode") String syscode,
|
@RequestParam("syscode") String syscode,
|
||||||
|
@ -32,6 +39,8 @@ public class LoginController {
|
||||||
UserLoginParam userLoginParam = new UserLoginParam(sfno, syscode, billcode, timespan);
|
UserLoginParam userLoginParam = new UserLoginParam(sfno, syscode, billcode, timespan);
|
||||||
UserLoginResult userLoginResult = authenticateService
|
UserLoginResult userLoginResult = authenticateService
|
||||||
.authenticateEmployeeNo(userLoginParam);
|
.authenticateEmployeeNo(userLoginParam);
|
||||||
|
//发送创建行程订单命令
|
||||||
|
Command.of(OrderCreateCommand.class).of(userLoginParam).sendToQueue();
|
||||||
return Result.Success(SUCCESS, userLoginResult);
|
return Result.Success(SUCCESS, userLoginResult);
|
||||||
} else {
|
} else {
|
||||||
return Result.error(SIGN_ERROR);
|
return Result.error(SIGN_ERROR);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.application.services;
|
||||||
|
|
||||||
import com.chint.application.commands.LegPrepareCommand;
|
import com.chint.application.commands.LegPrepareCommand;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
|
import com.chint.domain.exceptions.NotFoundException;
|
||||||
import com.chint.domain.factoriy.leg.LegFactory;
|
import com.chint.domain.factoriy.leg.LegFactory;
|
||||||
import com.chint.domain.factoriy.order.OrderFactory;
|
import com.chint.domain.factoriy.order.OrderFactory;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
|
@ -13,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.Constant.NOT_FOUND;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OrderApplicationService {
|
public class OrderApplicationService {
|
||||||
|
|
||||||
|
@ -35,10 +38,11 @@ public class OrderApplicationService {
|
||||||
order = routeRepository.queryById(orderSaveData.getRouteId());
|
order = routeRepository.queryById(orderSaveData.getRouteId());
|
||||||
order.reloadStatus(orderSaveData, legFactory);
|
order.reloadStatus(orderSaveData, legFactory);
|
||||||
} else {
|
} else {
|
||||||
order = orderFactory.createOrder(orderSaveData);
|
// order = orderFactory.createOrder(orderSaveData);
|
||||||
|
throw new NotFoundException(NOT_FOUND);
|
||||||
}
|
}
|
||||||
RouteOrder routeOrder = orderDomainService.saveOrder(order);
|
RouteOrder routeOrder = orderDomainService.saveOrder(order);
|
||||||
//这里保存订单之后,需要为每个leg执行规划中事件
|
//这里保存订单之后,需要为每个新添加的leg执行规划中事件
|
||||||
routeOrder.getLegItems().forEach(leg ->
|
routeOrder.getLegItems().forEach(leg ->
|
||||||
Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue()
|
Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue()
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,4 +6,5 @@ import lombok.Data;
|
||||||
public class ApproveOrderNo {
|
public class ApproveOrderNo {
|
||||||
private String fakeOrderNo;
|
private String fakeOrderNo;
|
||||||
private String actualOrderNo;
|
private String actualOrderNo;
|
||||||
|
private String accountCompany;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ public class Leg {
|
||||||
case LEG_STATUS_ORDERED -> LEG_STATUS_ORDERED_NAME;
|
case LEG_STATUS_ORDERED -> LEG_STATUS_ORDERED_NAME;
|
||||||
case LEG_STATUS_PAYED -> LEG_STATUS_PAYED_NAME;
|
case LEG_STATUS_PAYED -> LEG_STATUS_PAYED_NAME;
|
||||||
case LEG_STATUS_FINISH -> LEG_STATUS_FINISH_NAME;
|
case LEG_STATUS_FINISH -> LEG_STATUS_FINISH_NAME;
|
||||||
|
case LEG_STATUS_NOT_ORDERED -> LEG_STATUS_NOT_ORDERED_NAME;
|
||||||
default -> "未知状态";
|
default -> "未知状态";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class LegEvent {
|
||||||
case LEG_EVENT_ORDERED -> LEG_EVENT_ORDERED_NAME;
|
case LEG_EVENT_ORDERED -> LEG_EVENT_ORDERED_NAME;
|
||||||
case LEG_EVENT_PAYED -> LEG_EVENT_PAYED_NAME;
|
case LEG_EVENT_PAYED -> LEG_EVENT_PAYED_NAME;
|
||||||
case LEG_EVENT_FINISH -> LEG_EVENT_FINISH_NAME;
|
case LEG_EVENT_FINISH -> LEG_EVENT_FINISH_NAME;
|
||||||
|
case LEG_EVENT_NOT_ORDERED -> LEG_EVENT_NOT_ORDERED_NAME;
|
||||||
default -> "未知事件";
|
default -> "未知事件";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,7 @@ public class RouteOrder extends BaseEntity {
|
||||||
case ORDER_STATUS_ORDERED -> ORDER_STATUS_ORDERED_NAME;
|
case ORDER_STATUS_ORDERED -> ORDER_STATUS_ORDERED_NAME;
|
||||||
case ORDER_STATUS_PAYED -> ORDER_STATUS_PAYED_NAME;
|
case ORDER_STATUS_PAYED -> ORDER_STATUS_PAYED_NAME;
|
||||||
case ORDER_STATUS_FINISH -> ORDER_STATUS_FINISH_NAME;
|
case ORDER_STATUS_FINISH -> ORDER_STATUS_FINISH_NAME;
|
||||||
|
case ORDER_STATUS_NOT_ORDERED -> ORDER_STATUS_NOT_ORDERED_NAME;
|
||||||
default -> "未知状态";
|
default -> "未知状态";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.chint.domain.factoriy.order;
|
package com.chint.domain.factoriy.order;
|
||||||
|
|
||||||
|
import com.chint.application.commands.OrderCreateCommand;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.value_object.OrderSaveData;
|
import com.chint.domain.value_object.OrderSaveData;
|
||||||
|
|
||||||
public interface OrderFactory {
|
public interface OrderFactory {
|
||||||
RouteOrder createOrder(OrderSaveData orderData);
|
RouteOrder createOrder(OrderSaveData orderData);
|
||||||
|
RouteOrder createOrder(OrderCreateCommand command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.chint.domain.factoriy.order;
|
package com.chint.domain.factoriy.order;
|
||||||
|
|
||||||
|
import com.chint.application.commands.OrderCreateCommand;
|
||||||
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
import com.chint.domain.aggregates.order.ApproveOrderNo;
|
||||||
import com.chint.domain.aggregates.order.Leg;
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
|
@ -7,6 +8,7 @@ import com.chint.domain.aggregates.user.User;
|
||||||
import com.chint.domain.factoriy.leg.RouteLegFactory;
|
import com.chint.domain.factoriy.leg.RouteLegFactory;
|
||||||
import com.chint.domain.value_object.LegData;
|
import com.chint.domain.value_object.LegData;
|
||||||
import com.chint.domain.value_object.OrderSaveData;
|
import com.chint.domain.value_object.OrderSaveData;
|
||||||
|
import com.chint.domain.value_object.UserLoginParam;
|
||||||
import com.chint.infrastructure.util.BaseContext;
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
import com.chint.infrastructure.util.OrderNo;
|
import com.chint.infrastructure.util.OrderNo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -38,4 +40,18 @@ public class RouteOrderFactory implements OrderFactory {
|
||||||
routeOrder.setLegItems(leglist);
|
routeOrder.setLegItems(leglist);
|
||||||
return routeOrder;
|
return routeOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RouteOrder createOrder(OrderCreateCommand command) {
|
||||||
|
UserLoginParam loginParam = command.getLoginParam();
|
||||||
|
RouteOrder routeOrder = new RouteOrder();
|
||||||
|
routeOrder.setRouteOrderNo(OrderNo.generate());
|
||||||
|
//根据项目需求,需要保存假审批订单号,真审批订单号 ,创建的时候保存假审批订单号
|
||||||
|
routeOrder.setUserId(Long.valueOf(loginParam.getSfno()));
|
||||||
|
ApproveOrderNo approveOrderNo = new ApproveOrderNo();
|
||||||
|
approveOrderNo.setFakeOrderNo(loginParam.getBillcode());
|
||||||
|
routeOrder.setApproveOrderNo(approveOrderNo);
|
||||||
|
routeOrder.setBookingTime(LocalDateTime.now());
|
||||||
|
return routeOrder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,36 @@
|
||||||
package com.chint.domain.service;
|
package com.chint.domain.service;
|
||||||
|
|
||||||
|
import com.chint.application.commands.OrderCreateCommand;
|
||||||
import com.chint.domain.aggregates.order.Leg;
|
import com.chint.domain.aggregates.order.Leg;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
|
import com.chint.domain.aggregates.user.User;
|
||||||
|
import com.chint.domain.factoriy.order.RouteOrderFactory;
|
||||||
import com.chint.domain.repository.LocationRepository;
|
import com.chint.domain.repository.LocationRepository;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
|
import com.chint.domain.repository.UserRepository;
|
||||||
|
import com.chint.domain.value_object.UserLoginParam;
|
||||||
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
|
import com.chint.infrastructure.util.BaseContext;
|
||||||
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 java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OrderDomainService {
|
public class OrderDomainService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RouteRepository routeRepository;
|
private RouteRepository routeRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LocationRepository locationRepository;
|
private LocationRepository locationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RouteOrderFactory routeOrderFactory;
|
||||||
|
|
||||||
public RouteOrder saveOrder(RouteOrder routeOrder) {
|
public RouteOrder saveOrder(RouteOrder routeOrder) {
|
||||||
return routeRepository.save(routeOrder);
|
return routeRepository.save(routeOrder);
|
||||||
}
|
}
|
||||||
|
@ -28,4 +42,16 @@ public class OrderDomainService {
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ListenTo(command = "OrderCreateCommand", order = 0)
|
||||||
|
public RouteOrder createOrder(OrderCreateCommand command) {
|
||||||
|
UserLoginParam loginParam = command.getLoginParam();
|
||||||
|
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(Long.valueOf(loginParam.getSfno()));
|
||||||
|
return Optional.ofNullable(routeRepository.findByFakeOrderNo(loginParam.getBillcode())).orElseGet(() -> {
|
||||||
|
BaseContext.setCurrentUser(byUserEmployeeNo);
|
||||||
|
RouteOrder order = routeOrderFactory.createOrder(command);
|
||||||
|
this.saveOrder(order);
|
||||||
|
return order;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ public interface LegEventService {
|
||||||
void prepareLeg(LegPrepareCommand command);
|
void prepareLeg(LegPrepareCommand command);
|
||||||
//审批事件要从bpm或其他平台接收到一个真实订单
|
//审批事件要从bpm或其他平台接收到一个真实订单
|
||||||
void approveLeg(LegApprovalCommand command);
|
void approveLeg(LegApprovalCommand command);
|
||||||
|
void syncLeg(LegSyncCommand command);
|
||||||
//下单事件
|
//下单事件
|
||||||
void orderLeg(LegOrderedCommand command);
|
void orderLeg(LegOrderedCommand command);
|
||||||
//付款
|
//付款
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package com.chint.domain.service.leg_event;
|
package com.chint.domain.service.leg_event;
|
||||||
|
|
||||||
import com.chint.application.commands.*;
|
import com.chint.application.commands.*;
|
||||||
import com.chint.domain.aggregates.order.Leg;
|
import com.chint.domain.aggregates.order.*;
|
||||||
import com.chint.domain.aggregates.order.LegEvent;
|
|
||||||
import com.chint.domain.aggregates.order.OrderDetail;
|
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
|
||||||
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
||||||
import com.chint.domain.repository.LegRepository;
|
import com.chint.domain.repository.LegRepository;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
|
@ -12,7 +9,10 @@ import com.chint.domain.service.order_sync.SyncAdapter;
|
||||||
import com.chint.domain.value_object.ApproveLegData;
|
import com.chint.domain.value_object.ApproveLegData;
|
||||||
import com.chint.domain.value_object.OrderLegData;
|
import com.chint.domain.value_object.OrderLegData;
|
||||||
import com.chint.domain.value_object.PayLegData;
|
import com.chint.domain.value_object.PayLegData;
|
||||||
|
import com.chint.domain.value_object.SyncLegData;
|
||||||
|
|
||||||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
|
import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
|
||||||
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 org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -32,28 +32,29 @@ public class LegEventServiceImpl implements LegEventService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private LegEventFactory legEventFactory;
|
private LegEventFactory legEventFactory;
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LegPrepareCommand", order = 0)
|
@TransitionTo(command = "LegPrepareCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public void prepareLeg(LegPrepareCommand command) {
|
public void prepareLeg(LegPrepareCommand command) {
|
||||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
if (leg.getEventList().isEmpty()) {
|
||||||
leg.addEvent(legEvent);
|
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||||
legRepository.save(leg);
|
leg.addEvent(legEvent);
|
||||||
|
legRepository.save(leg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//因为审批是针对整个订单的,因此所有订单下属的行程节点触发审批事件
|
//因为审批是针对整个订单的,因此所有订单下属的行程节点触发审批事件
|
||||||
//出发审批提交事件 , 需要生成 差旅单 , 将差旅但提交到供应商 ,
|
//出发审批提交事件 , 需要生成 差旅单 , 将差旅但提交到供应商 ,
|
||||||
//根据command里面选择的数据来讲差旅但提交到不同的实现类当中
|
//根据command里面选择的数据来讲差旅但提交到不同的实现类当中
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LegApprovalCommand", order = 0)
|
@ListenTo(command = "LegApprovalCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public void approveLeg(LegApprovalCommand command) {
|
public void approveLeg(LegApprovalCommand command) {
|
||||||
ApproveLegData data = command.getData();
|
ApproveLegData data = command.getData();
|
||||||
RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo());
|
RouteOrder routeOrder = routeRepository.findByFakeOrderNo(data.getFakeOrderNo());
|
||||||
routeOrder.getApproveOrderNo().setActualOrderNo(data.getActualOrderNo());
|
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
|
||||||
String supplierName = data.getSupplierName();
|
approveOrderNo.setActualOrderNo(data.getActualOrderNo());
|
||||||
syncAdapter.of(supplierName).syncSupplierOrder(routeOrder);
|
approveOrderNo.setAccountCompany(data.getAccountCompany());
|
||||||
|
|
||||||
//这里order所有的leg触发approve事件
|
//这里order所有的leg触发approve事件
|
||||||
routeOrder.getLegItems().forEach(leg -> leg.getEventList().add(
|
routeOrder.getLegItems().forEach(leg -> leg.getEventList().add(
|
||||||
|
@ -64,7 +65,25 @@ public class LegEventServiceImpl implements LegEventService {
|
||||||
routeRepository.save(routeOrder);
|
routeRepository.save(routeOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
//这里需要获取同步类,价格routeOrder同步到供应商
|
||||||
|
@ListenTo(command = "LegSyncCommand", order = 0)
|
||||||
|
@Override
|
||||||
|
public void syncLeg(LegSyncCommand command) {
|
||||||
|
SyncLegData data = command.getData();
|
||||||
|
RouteOrder routeOrder = routeRepository.queryById(command.getRoutOrderId());
|
||||||
|
String supplierName = data.getSupplierName();
|
||||||
|
|
||||||
|
//这里order所有的leg触发approve事件
|
||||||
|
routeOrder.getLegItems().forEach(leg -> leg.getEventList().add(
|
||||||
|
legEventFactory.creatLegEvent(command.getLegEventType())
|
||||||
|
));
|
||||||
|
syncAdapter.of(supplierName).syncSupplierOrder(routeOrder);
|
||||||
|
|
||||||
|
//保存routeOrder的状态
|
||||||
|
routeRepository.save(routeOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ListenTo(command = "LegOrderedCommand", order = 0)
|
@ListenTo(command = "LegOrderedCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public void orderLeg(LegOrderedCommand command) {
|
public void orderLeg(LegOrderedCommand command) {
|
||||||
|
@ -79,9 +98,9 @@ public class LegEventServiceImpl implements LegEventService {
|
||||||
legRepository.save(leg);
|
legRepository.save(leg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LegPayedCommand", order = 0)
|
|
||||||
@Override
|
@Override
|
||||||
|
@ListenTo(command = "LegPayedCommand", order = 0)
|
||||||
public void payForLeg(LegPayedCommand command) {
|
public void payForLeg(LegPayedCommand command) {
|
||||||
PayLegData data = command.getData();
|
PayLegData data = command.getData();
|
||||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||||
|
@ -94,9 +113,9 @@ public class LegEventServiceImpl implements LegEventService {
|
||||||
legRepository.save(leg);
|
legRepository.save(leg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
@ListenTo(command = "LegFinishedCommand", order = 0)
|
|
||||||
@Override
|
@Override
|
||||||
|
@ListenTo(command = "LegFinishedCommand", order = 0)
|
||||||
public void finishLeg(LegFinishedCommand command) {
|
public void finishLeg(LegFinishedCommand command) {
|
||||||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package com.chint.domain.service.order_sync;
|
package com.chint.domain.service.order_sync;
|
||||||
|
|
||||||
|
import com.chint.domain.aggregates.order.Location;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LYOrderSyncAdapter implements SupplierOrderSync {
|
public class LYOrderSyncAdapter implements SupplierOrderSync {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void syncSupplierOrder(RouteOrder order) {
|
public void syncSupplierOrder(RouteOrder order) {
|
||||||
System.out.println("开始同步同程订单");
|
System.out.println("开始同步同程订单");
|
||||||
|
|
|
@ -4,7 +4,7 @@ import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ApproveLegData {
|
public class ApproveLegData {
|
||||||
private String supplierName;
|
|
||||||
private String actualOrderNo;
|
private String actualOrderNo;
|
||||||
private String fakeOrderNo;
|
private String fakeOrderNo;
|
||||||
|
private String accountCompany;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.chint.domain.value_object;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SyncLegData {
|
||||||
|
private String supplierName;
|
||||||
|
}
|
|
@ -43,24 +43,28 @@ public class Constant {
|
||||||
public static final int ORDER_STATUS_PREPARE = 0;
|
public static final int ORDER_STATUS_PREPARE = 0;
|
||||||
public static final String ORDER_STATUS_PREPARE_NAME = "规划中";
|
public static final String ORDER_STATUS_PREPARE_NAME = "规划中";
|
||||||
public static final int ORDER_STATUS_APPROVAL = 1;
|
public static final int ORDER_STATUS_APPROVAL = 1;
|
||||||
public static final String ORDER_STATUS_APPROVAL_NAME = "审批中";
|
public static final String ORDER_STATUS_APPROVAL_NAME = "提交审批";
|
||||||
public static final int ORDER_STATUS_ORDERED = 2;
|
public static final int ORDER_STATUS_NOT_ORDERED = 2;
|
||||||
|
public static final String ORDER_STATUS_NOT_ORDERED_NAME = "未下单";
|
||||||
|
public static final int ORDER_STATUS_ORDERED = 3;
|
||||||
public static final String ORDER_STATUS_ORDERED_NAME = "已下单";
|
public static final String ORDER_STATUS_ORDERED_NAME = "已下单";
|
||||||
public static final int ORDER_STATUS_PAYED = 3;
|
public static final int ORDER_STATUS_PAYED = 4;
|
||||||
public static final String ORDER_STATUS_PAYED_NAME = "已付款";
|
public static final String ORDER_STATUS_PAYED_NAME = "已付款";
|
||||||
public static final int ORDER_STATUS_FINISH = 4;
|
public static final int ORDER_STATUS_FINISH = 5;
|
||||||
public static final String ORDER_STATUS_FINISH_NAME = "已结束";
|
public static final String ORDER_STATUS_FINISH_NAME = "已结束";
|
||||||
|
|
||||||
// 规划节点状态
|
// 规划节点状态
|
||||||
public static final int LEG_STATUS_PREPARE = 0;
|
public static final int LEG_STATUS_PREPARE = 0;
|
||||||
public static final String LEG_STATUS_PREPARE_NAME = "规划中";
|
public static final String LEG_STATUS_PREPARE_NAME = "规划中";
|
||||||
public static final int LEG_STATUS_APPROVAL = 1;
|
public static final int LEG_STATUS_APPROVAL = 1;
|
||||||
public static final String LEG_STATUS_APPROVAL_NAME = "审批中";
|
public static final String LEG_STATUS_APPROVAL_NAME = "提交审批";
|
||||||
public static final int LEG_STATUS_ORDERED = 2;
|
public static final int LEG_STATUS_NOT_ORDERED = 2;
|
||||||
|
public static final String LEG_STATUS_NOT_ORDERED_NAME = "未下单";
|
||||||
|
public static final int LEG_STATUS_ORDERED = 3;
|
||||||
public static final String LEG_STATUS_ORDERED_NAME = "已下单";
|
public static final String LEG_STATUS_ORDERED_NAME = "已下单";
|
||||||
public static final int LEG_STATUS_PAYED = 3;
|
public static final int LEG_STATUS_PAYED = 4;
|
||||||
public static final String LEG_STATUS_PAYED_NAME = "已付款";
|
public static final String LEG_STATUS_PAYED_NAME = "已付款";
|
||||||
public static final int LEG_STATUS_FINISH = 4;
|
public static final int LEG_STATUS_FINISH = 5;
|
||||||
public static final String LEG_STATUS_FINISH_NAME = "已结束";
|
public static final String LEG_STATUS_FINISH_NAME = "已结束";
|
||||||
|
|
||||||
// 规划节点运输方式
|
// 规划节点运输方式
|
||||||
|
@ -80,11 +84,13 @@ public class Constant {
|
||||||
public static final String LEG_EVENT_PREPARE_NAME = "初始事件";
|
public static final String LEG_EVENT_PREPARE_NAME = "初始事件";
|
||||||
public static final int LEG_EVENT_APPROVAL = 1;
|
public static final int LEG_EVENT_APPROVAL = 1;
|
||||||
public static final String LEG_EVENT_APPROVAL_NAME = "审批事件";
|
public static final String LEG_EVENT_APPROVAL_NAME = "审批事件";
|
||||||
public static final int LEG_EVENT_ORDERED = 2;
|
public static final int LEG_EVENT_NOT_ORDERED = 2;
|
||||||
|
public static final String LEG_EVENT_NOT_ORDERED_NAME = "审批事件";
|
||||||
|
public static final int LEG_EVENT_ORDERED = 3;
|
||||||
public static final String LEG_EVENT_ORDERED_NAME = "下单事件";
|
public static final String LEG_EVENT_ORDERED_NAME = "下单事件";
|
||||||
public static final int LEG_EVENT_PAYED = 3;
|
public static final int LEG_EVENT_PAYED = 4;
|
||||||
public static final String LEG_EVENT_PAYED_NAME = "付款事件";
|
public static final String LEG_EVENT_PAYED_NAME = "付款事件";
|
||||||
public static final int LEG_EVENT_FINISH = 4;
|
public static final int LEG_EVENT_FINISH = 5;
|
||||||
public static final String LEG_EVENT_FINISH_NAME = "结束事件";
|
public static final String LEG_EVENT_FINISH_NAME = "结束事件";
|
||||||
|
|
||||||
// 金额
|
// 金额
|
||||||
|
|
|
@ -3,13 +3,11 @@ package com.chint.infrastructure.echo_framework.annotation;
|
||||||
|
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.*;
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@Target(ElementType.TYPE)
|
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
public @interface BindingCommand {
|
public @interface BindingCommand {
|
||||||
Class<? extends Command> commandClass();
|
Class<? extends Command> commandClass();
|
||||||
}
|
}
|
|
@ -1,13 +1,11 @@
|
||||||
package com.chint.infrastructure.echo_framework.annotation;
|
package com.chint.infrastructure.echo_framework.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.*;
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
// ListenTo Annotation
|
// ListenTo Annotation
|
||||||
|
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.METHOD, ElementType.FIELD})
|
@Documented
|
||||||
public @interface ListenTo {
|
public @interface ListenTo {
|
||||||
String command();
|
String command();
|
||||||
long order();
|
long order();
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package com.chint.infrastructure.echo_framework.annotation;
|
package com.chint.infrastructure.echo_framework.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.*;
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
// TransitionTo Annotation
|
// TransitionTo Annotation
|
||||||
|
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ElementType.METHOD, ElementType.FIELD})
|
@Documented
|
||||||
public @interface TransitionTo {
|
public @interface TransitionTo {
|
||||||
String command();
|
String command();
|
||||||
long order();
|
long order();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.chint.infrastructure.echo_framework.manager;
|
package com.chint.infrastructure.echo_framework.manager;
|
||||||
|
|
||||||
|
|
||||||
|
import com.chint.domain.service.leg_event.LegEventService;
|
||||||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
|
import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
|
@ -17,7 +18,9 @@ import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
import com.chint.domain.service.leg_event.LegEventServiceImpl;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -85,7 +88,7 @@ public class EventManager implements ApplicationContextAware, BeanNameAware, Ini
|
||||||
List<ResultContainer> resultContainers = new ArrayList<>();
|
List<ResultContainer> resultContainers = new ArrayList<>();
|
||||||
containers.forEach(container -> {
|
containers.forEach(container -> {
|
||||||
try {
|
try {
|
||||||
Object result = container.getMethod().invoke(container.getBean(), command, args);
|
Object result = container.getMethod().invoke(container.getBean(), command);
|
||||||
if (result instanceof ResultContainer) {
|
if (result instanceof ResultContainer) {
|
||||||
resultContainers.add((ResultContainer) result);
|
resultContainers.add((ResultContainer) result);
|
||||||
}
|
}
|
||||||
|
@ -97,6 +100,7 @@ public class EventManager implements ApplicationContextAware, BeanNameAware, Ini
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ResultContainer> processTransitionCommand(Command command) {
|
private static List<ResultContainer> processTransitionCommand(Command command) {
|
||||||
|
System.out.println(transitionMethods);
|
||||||
List<MethodContainer> containers = transitionMethods.getOrDefault(command.getCommandName(), Collections.emptyList());
|
List<MethodContainer> containers = transitionMethods.getOrDefault(command.getCommandName(), Collections.emptyList());
|
||||||
List<ResultContainer> resultContainers = new ArrayList<>();
|
List<ResultContainer> resultContainers = new ArrayList<>();
|
||||||
transactionTemplate.execute(transactionStatus -> {
|
transactionTemplate.execute(transactionStatus -> {
|
||||||
|
|
|
@ -13,4 +13,5 @@ public interface JdbcRouteRepository extends CrudRepository<RouteOrder, Long> {
|
||||||
RouteOrder findByRouteId(Long routeId);
|
RouteOrder findByRouteId(Long routeId);
|
||||||
|
|
||||||
RouteOrder findByApproveOrderNo_FakeOrderNo(String approveOrderNo_fakeOrderNo);
|
RouteOrder findByApproveOrderNo_FakeOrderNo(String approveOrderNo_fakeOrderNo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/pubilc/CTrip")
|
@RequestMapping("/public/CTrip")
|
||||||
public class CTripNoteController {
|
public class CTripNoteController {
|
||||||
|
|
||||||
@PostMapping("/event")
|
@PostMapping("/event")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.chint.interfaces.rest.user;
|
package com.chint.interfaces.rest.user;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.chint.dc.api.DataCenterResult;
|
import com.chint.dc.api.DataCenterResult;
|
||||||
import com.chint.dc.api.dto.DataCenterOption;
|
import com.chint.dc.api.dto.DataCenterOption;
|
||||||
import com.chint.dc.api.service.DataCenterService;
|
import com.chint.dc.api.service.DataCenterService;
|
||||||
|
|
Loading…
Reference in New Issue