diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index 09b154d0..0b97aa55 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -202,10 +202,25 @@ public class OrderApplicationService { public RouteOrder deleteLegToOrder(DeleteLegData deleteLegData) { - RouteOrder order = Optional.ofNullable(routeRepository.queryById(deleteLegData.getRouteId())) - .orElseThrow(() -> new NotFoundException(NOT_FOUND)).reloadStatus(); - order.deleteLeg(deleteLegData.getLegNo()); - return orderDomainService.saveOrder(order); + String legNo = deleteLegData.getLegNo(); + RouteOrder routeOrder = null; + if (legNo.contains("&")) { + String[] split = legNo.split("&"); + routeOrder = routeRepository.findTempRouteOrderBySysCodeAndBillCode(split[1], split[2]); + } + if (routeOrder == null) { + routeOrder = Optional.ofNullable(routeRepository.queryById(deleteLegData.getRouteId())) + .orElseThrow(() -> new NotFoundException(NOT_FOUND)).reloadStatus(); + } + if (routeOrder != null) { + routeOrder.reloadStatus(); + if (!routeOrder.getApprovalStatusCode().equals(APPROVAL_EVENT_PREPARE)) { + return routeRepository.saveTempRouteOrder(routeOrder, 24L); + } else { + return routeRepository.save(routeOrder); + } + } + return null; } @Transactional