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);