From 2adcf92af0f07d50f771df55d755eb55fdc610a2 Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 28 Mar 2024 20:19:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=8C=E7=A8=8B=E8=A7=84=E5=88=92=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/leg_event/LegEventHandler.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java index 87148a89..53539e4d 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventHandler.java @@ -42,10 +42,9 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE import static com.chint.infrastructure.constant.DataMessageConstant.DATA_NOT_FOUND; import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.OrderConstant.*; -import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_FINISH_NAME; import static com.chint.infrastructure.constant.RankConstant.ZTZW_COMPANY_CODE; import static com.chint.infrastructure.constant.RankConstant.ZTZW_COMPANY_NAME; -import static com.chint.infrastructure.constant.RouteConstant.*; +import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; import static com.chint.infrastructure.constant.UtilConstant.RESULT_ORDER_DETAIL; @Service @@ -161,15 +160,26 @@ public class LegEventHandler implements LegEventService { if (routeOrder.getOrderStatus() >= RouteConstant.ORDER_STATUS_APPROVAL) { String supplierName = data.getSupplierName(); routeOrder.setSupplierName(supplierName); + List legItems = routeOrder.getLegItems(); + + //这里增加一个判断 ,如果这个订单的行程为空,那么就返回给用户提示 + if (legItems == null || legItems.isEmpty()) { + throw new CommandException("订单的行程不能为空"); + } + List needSyncLegs = legItems.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList(); + if (needSyncLegs.isEmpty()) { + throw new CommandException("有所选的行程规划单不存在需要同步的行程"); + } + //这里order所有的leg触发sync事件 - routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( + legItems.forEach(leg -> leg.getEventList().add( legEventFactory.creatLegEvent(command.getLegEventType()) )); + //保存routeOrder的状态 routeRepository.save(routeOrder).reloadStatus(); routeOrder.setLegItems( - routeOrder - .getLegItems() + legItems .stream() .filter(leg -> !leg.getLegType().equals(LegConstant.LEG_TYPE_OTHER)) .toList() @@ -245,8 +255,8 @@ public class LegEventHandler implements LegEventService { LegEvent legEvent = legEventFactory .creatLegEvent(command.getLegEventType()); leg.addEvent(legEvent); - } else if(orderStatus.equals(ORDER_EVENT_REFUND_NAME) || - orderStatus.equals(ORDER_EVENT_CANCEL_NAME)){ + } else if (orderStatus.equals(ORDER_EVENT_REFUND_NAME) || + orderStatus.equals(ORDER_EVENT_CANCEL_NAME)) { //如果是退款状态,那么就创建加入未下单事件 LegEvent legEvent = legEventFactory .creatLegEvent(LEG_EVENT_NOT_ORDERED);