diff --git a/src/main/java/com/chint/application/out/OrderOutController.java b/src/main/java/com/chint/application/out/OrderOutController.java index 50025e9f..746e199d 100644 --- a/src/main/java/com/chint/application/out/OrderOutController.java +++ b/src/main/java/com/chint/application/out/OrderOutController.java @@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; @Slf4j @@ -86,4 +88,10 @@ public class OrderOutController { return Result.Success(SUCCESS, tripCallback); } + + @ApiOperation("分页查询行程规划订单") + @PostMapping("/query/not/submit") + public Result> queryNotSubmit(@RequestBody OrderQueryData queryData) { + return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData)); + } } diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index 2cf6b502..1a128e95 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -34,6 +34,7 @@ import java.util.stream.Stream; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME; +import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_APPROVAL; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; @Service @@ -60,6 +61,7 @@ public class OrderQuery { @Autowired private EstimateAdapter estimateAdapter; + public RouteOrder queryByOrderId(OrderQueryData queryData) { return routeRepository.queryById(queryData.getRouteId()).reloadStatus(); } @@ -299,7 +301,7 @@ public class OrderQuery { }; } - public RouteOrderRes queryRouteRes(RouteOrder routeOrder){ + public RouteOrderRes queryRouteRes(RouteOrder routeOrder) { RouteOrderRes routeOrderRes = RouteOrderRes.copyFrom(routeOrder); List legItems = routeOrder.getLegItems(); orderDomainService.queryLocation(legItems); @@ -320,4 +322,11 @@ public class OrderQuery { .toList()); return routeOrderRes; } + + public List queryNotSubmit(OrderQueryData queryData) { + List byActualOrderNoNotNull = routeRepository.findByActualOrderNoNotNull(queryData); + return byActualOrderNoNotNull.stream().filter(order -> order.reloadStatus().getOrderStatus().equals(ORDER_STATUS_APPROVAL)) + .map(OrderQuery::getRouteOrderPageRes) + .toList(); + } } diff --git a/src/main/java/com/chint/application/services/OrderApplicationService.java b/src/main/java/com/chint/application/services/OrderApplicationService.java index f2fae889..6a923445 100644 --- a/src/main/java/com/chint/application/services/OrderApplicationService.java +++ b/src/main/java/com/chint/application/services/OrderApplicationService.java @@ -9,25 +9,25 @@ import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.OrderException; import com.chint.domain.factoriy.leg.LegFactory; import com.chint.domain.factoriy.order.OrderFactory; +import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.RouteRepository; import com.chint.domain.service.OrderDomainService; import com.chint.domain.value_object.*; import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.constant.DataMessageConstant; import com.chint.infrastructure.constant.LegConstant; -import com.chint.infrastructure.constant.RouteConstant; import com.chint.infrastructure.echo_framework.command.Command; -import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; import java.util.Optional; import static com.chint.infrastructure.constant.CommonMessageConstant.ORDER_STATUS_ERROR; -import static com.chint.infrastructure.constant.LegConstant.LEG_STATUS_PREPARE; import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; @Service @@ -45,6 +45,8 @@ public class OrderApplicationService { @Autowired private LegFactory legFactory; + @Autowired + private LegRepository legRepository; @Transactional @@ -156,5 +158,13 @@ public class OrderApplicationService { @Transactional public void changeLeg(AddLegData addLegData) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); + LegData legData = addLegData.getLegData(); + Leg byLegId = legRepository.findByLegId(legData.getLegId()); + byLegId.setStartTime(LocalDateTime.parse(legData.getStartTime(), formatter)); + byLegId.setEndTime(LocalDateTime.parse(legData.getEndTime(), formatter)); + byLegId.setOriginId(legData.getOriginId()); + byLegId.setDestinationId(legData.getDestinationId()); + legRepository.save(byLegId); } } diff --git a/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java b/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java index ebe3810c..f62a8413 100644 --- a/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java +++ b/src/main/java/com/chint/domain/aggregates/order/LegExtensionField.java @@ -6,6 +6,8 @@ import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Transient; import org.springframework.data.relational.core.mapping.Table; +import java.util.List; + @Data @Table("leg_extension_field") public class LegExtensionField { @@ -13,6 +15,9 @@ public class LegExtensionField { private Long id; private Long legId; private Integer amountType; + private String locationIds; + @Transient + private List locationList; @Transient private String amountTypeName; @Transient diff --git a/src/main/java/com/chint/domain/event/LegEventListener.java b/src/main/java/com/chint/domain/event/LegEventListener.java index 9d27f696..5e527c3e 100644 --- a/src/main/java/com/chint/domain/event/LegEventListener.java +++ b/src/main/java/com/chint/domain/event/LegEventListener.java @@ -21,7 +21,7 @@ public class LegEventListener { // @TransitionTo(command = "LegPrepareCommand", order = 0) public void onLegStatusChange(LegPrepareCommand command) { - Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); + Leg leg = legRepository.findByLegId(command.getLegId()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); leg.addEvent(legEvent); legRepository.save(leg); diff --git a/src/main/java/com/chint/domain/repository/LegRepository.java b/src/main/java/com/chint/domain/repository/LegRepository.java index 9ddd9cfe..7e31c8db 100644 --- a/src/main/java/com/chint/domain/repository/LegRepository.java +++ b/src/main/java/com/chint/domain/repository/LegRepository.java @@ -14,5 +14,7 @@ public interface LegRepository { void saveAll(List legs); - Leg findByLegId(Leg leg); + Leg findByLegId(Long legId); + + } \ No newline at end of file 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 4990c620..dd6cf0a5 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 @@ -62,7 +62,7 @@ public class LegEventHandler implements LegEventService { @Transactional @Override public void prepareLeg(LegPrepareCommand command) { - Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); + Leg leg = legRepository.findByLegId(command.getLegId()); if (leg.getEventList().isEmpty()) { LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); leg.addEvent(legEvent); @@ -174,7 +174,7 @@ public class LegEventHandler implements LegEventService { @Override public ResultContainer orderLeg(LegOrderedCommand command) { //如果筛选事件可能会是错误,需要用户手动添加并修改事件 , 因此会进行额外出发修改下单事件。 - Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); + Leg leg = legRepository.findByLegId(command.getLegId()); //因为orderDetail已经进行持久化保存 ,只需要从数据库进行查询 OrderDetail orderDetail = orderDetailRepository.findById(command.getOrderDetailId()); LegEvent legEvent = legEventFactory @@ -190,7 +190,7 @@ public class LegEventHandler implements LegEventService { @Override public void payForLeg(LegPayedCommand command) { // PayLegData data = command.getData(); - Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); + Leg leg = legRepository.findByLegId(command.getLegId()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); leg.addEvent(legEvent); legRepository.save(leg); @@ -199,7 +199,7 @@ public class LegEventHandler implements LegEventService { @Transactional @Override public void finishLeg(LegFinishedCommand command) { - Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); + Leg leg = legRepository.findByLegId(command.getLegId()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); leg.addEvent(legEvent); legRepository.save(leg); diff --git a/src/main/java/com/chint/infrastructure/repository/LegRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LegRepositoryImpl.java index ef99b946..2abbeda2 100644 --- a/src/main/java/com/chint/infrastructure/repository/LegRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LegRepositoryImpl.java @@ -39,7 +39,7 @@ public class LegRepositoryImpl implements LegRepository { } @Override - public Leg findByLegId(Leg leg) { - return legRepository.findById(leg.getLegId()).orElseThrow(()->new NotFoundException(NOT_FOUND)); + public Leg findByLegId(Long legId) { + return legRepository.findById(legId).orElseThrow(()->new NotFoundException(NOT_FOUND)); } }