diff --git a/src/main/java/com/chint/application/dtos/LocationParam.java b/src/main/java/com/chint/application/dtos/LocationParam.java index 646f28de..fcf99ad9 100644 --- a/src/main/java/com/chint/application/dtos/LocationParam.java +++ b/src/main/java/com/chint/application/dtos/LocationParam.java @@ -7,4 +7,5 @@ import lombok.Data; public class LocationParam extends BaseQuery { private Long level; private Long parentLocationId; + private String cityName; } diff --git a/src/main/java/com/chint/application/out/SupplierLoginController.java b/src/main/java/com/chint/application/out/SupplierLoginController.java index 1653738b..750fbec2 100644 --- a/src/main/java/com/chint/application/out/SupplierLoginController.java +++ b/src/main/java/com/chint/application/out/SupplierLoginController.java @@ -17,4 +17,10 @@ public class SupplierLoginController { public Result lyLogin() { return Result.Success(SUCCESS); } + + @PostMapping("/CTrip/login") + public Result cTripLogin() { + return Result.Success(SUCCESS); + } + } diff --git a/src/main/java/com/chint/domain/aggregates/order/Leg.java b/src/main/java/com/chint/domain/aggregates/order/Leg.java index 555e3997..f066dc81 100644 --- a/src/main/java/com/chint/domain/aggregates/order/Leg.java +++ b/src/main/java/com/chint/domain/aggregates/order/Leg.java @@ -2,6 +2,7 @@ package com.chint.domain.aggregates.order; import com.chint.domain.exceptions.LegEventException; +import com.chint.domain.service.amount_estimate.EstimateAdapter; import com.chint.domain.value_object.LegData; import lombok.Data; import lombok.NoArgsConstructor; @@ -55,7 +56,7 @@ public class Leg { @Transient private String legStatusName; - @MappedCollection(idColumn = "leg_id",keyColumn = "leg_key") + @MappedCollection(idColumn = "leg_id", keyColumn = "leg_key") private List eventList; public Leg(Long legId) { @@ -66,6 +67,13 @@ public class Leg { return new Leg(legId); } + public Leg queryEstimateAmount(EstimateAdapter estimateAdapter, String supplierName) { + if (this.legStatus >= (LEG_STATUS_NOT_ORDERED)) { + this.estimateAmount = estimateAdapter.of(supplierName).amountEstimate(this); + } + return this; + } + public Leg reloadStatus() { if (eventList == null) { this.legStatus = LEG_STATUS_PREPARE; diff --git a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java index df501a39..50ea3bf1 100644 --- a/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java +++ b/src/main/java/com/chint/domain/aggregates/order/RouteOrder.java @@ -3,6 +3,7 @@ package com.chint.domain.aggregates.order; import com.chint.domain.aggregates.base.BaseEntity; import com.chint.domain.factoriy.leg.LegFactory; +import com.chint.domain.service.amount_estimate.EstimateAdapter; import com.chint.domain.value_object.LegData; import com.chint.domain.value_object.OrderSaveData; import com.chint.infrastructure.util.BigDecimalCalculator; @@ -50,6 +51,8 @@ public class RouteOrder extends BaseEntity { @Transient private String orderStatusName; + private String supplierName; + @MappedCollection(idColumn = "route_id", keyColumn = "route_order_key") public List legItems; @@ -77,6 +80,17 @@ public class RouteOrder extends BaseEntity { .collect(Collectors.toList()); } + public RouteOrder queryEstimateAmount(EstimateAdapter estimateAdapter) { + if (this.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) { + this.estimateAmount = estimateAdapter + .of(this.supplierName) + .amountEstimate(this); + this.getLegItems() + .forEach(leg -> leg.queryEstimateAmount(estimateAdapter, this.supplierName)); + } + return this; + } + public RouteOrder reloadStatus() { this.getLegItems().forEach(Leg::reloadStatus); this.estimateAmount = this.getLegItems() diff --git a/src/main/java/com/chint/domain/service/amount_estimate/AmountEstimate.java b/src/main/java/com/chint/domain/service/amount_estimate/AmountEstimate.java new file mode 100644 index 00000000..ee258dd4 --- /dev/null +++ b/src/main/java/com/chint/domain/service/amount_estimate/AmountEstimate.java @@ -0,0 +1,9 @@ +package com.chint.domain.service.amount_estimate; + +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.order.RouteOrder; + +public interface AmountEstimate { + String amountEstimate(Leg leg); + String amountEstimate(RouteOrder routeOrder); +} diff --git a/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java b/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java new file mode 100644 index 00000000..89e20371 --- /dev/null +++ b/src/main/java/com/chint/domain/service/amount_estimate/CTripEstimate.java @@ -0,0 +1,18 @@ +package com.chint.domain.service.amount_estimate; + +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.order.RouteOrder; +import org.springframework.stereotype.Component; + +@Component +public class CTripEstimate implements AmountEstimate { + @Override + public String amountEstimate(Leg leg) { + return null; + } + + @Override + public String amountEstimate(RouteOrder routeOrder) { + return null; + } +} diff --git a/src/main/java/com/chint/domain/service/amount_estimate/EstimateAdapter.java b/src/main/java/com/chint/domain/service/amount_estimate/EstimateAdapter.java new file mode 100644 index 00000000..69b8c2de --- /dev/null +++ b/src/main/java/com/chint/domain/service/amount_estimate/EstimateAdapter.java @@ -0,0 +1,25 @@ +package com.chint.domain.service.amount_estimate; + +import com.chint.domain.exceptions.NotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import static com.chint.infrastructure.constant.Constant.*; + +@Component +public class EstimateAdapter { + + @Autowired + private CTripEstimate cTripEstimate; + + @Autowired + private LYEstimate lyEstimate; + + public AmountEstimate of(String supplierName) { + return switch (supplierName) { + case SUPPLIER_C_TRIP -> cTripEstimate; + case SUPPLIER_L_Y -> lyEstimate; + default -> throw new NotFoundException(NOT_FOUND); + }; + } +} diff --git a/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java b/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java new file mode 100644 index 00000000..64f0a666 --- /dev/null +++ b/src/main/java/com/chint/domain/service/amount_estimate/LYEstimate.java @@ -0,0 +1,20 @@ +package com.chint.domain.service.amount_estimate; + +import com.chint.domain.aggregates.order.Leg; +import com.chint.domain.aggregates.order.RouteOrder; +import org.springframework.stereotype.Component; + +@Component +public class LYEstimate implements AmountEstimate { + @Override + public String amountEstimate(Leg leg) { + return null; + } + + @Override + public String amountEstimate(RouteOrder routeOrder) { + return null; + } + + +} diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java index 1f9c6bf3..d59f0d64 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java @@ -72,13 +72,12 @@ public class LegEventServiceImpl implements LegEventService { SyncLegData data = command.getData(); RouteOrder routeOrder = routeRepository.queryById(command.getRoutOrderId()); String supplierName = data.getSupplierName(); - + routeOrder.setSupplierName(supplierName); //这里order所有的leg触发approve事件 routeOrder.getLegItems().forEach(leg -> leg.getEventList().add( legEventFactory.creatLegEvent(command.getLegEventType()) )); syncAdapter.of(supplierName).syncSupplierOrder(routeOrder.reloadStatus()); - //保存routeOrder的状态 routeRepository.save(routeOrder); } diff --git a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java index 1e122213..00ef1f48 100644 --- a/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java +++ b/src/main/java/com/chint/infrastructure/repository/LocationRepositoryImpl.java @@ -26,6 +26,10 @@ public class LocationRepositoryImpl implements LocationRepository { locationParam.getPageNum() - 1, locationParam.getPageSize() ); + if(locationParam.getCityName() != null){ + Page res = jdbcLocationRepository.findAllByLocationPathContaining(locationParam.getCityName(), pageResult); + return PageResult.totalPageNum(res.getTotalElements(), res.toList()); + } if (locationParam.getLevel() != null) { Page res = jdbcLocationRepository.findAllByLevel(locationParam.getLevel(), pageResult); return PageResult.totalPageNum(res.getTotalElements(), res.toList());