diff --git a/src/main/java/com/chint/application/queryies/OrderQuery.java b/src/main/java/com/chint/application/queryies/OrderQuery.java index d1d27528..99e9ef14 100644 --- a/src/main/java/com/chint/application/queryies/OrderQuery.java +++ b/src/main/java/com/chint/application/queryies/OrderQuery.java @@ -2,14 +2,16 @@ package com.chint.application.queryies; import cn.hutool.core.bean.BeanUtil; import com.chint.application.dtos.RoutOrderFieldParam; +import com.chint.application.dtos.mapper.RouteOrderMapper; import com.chint.application.dtos.response.*; import com.chint.application.dtos.trip.*; -import com.chint.application.dtos.mapper.RouteOrderMapper; import com.chint.application.queryies.estimate.EstimatePrice; import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity; import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity; import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity; import com.chint.domain.aggregates.order.*; +import com.chint.domain.aggregates.supplier.Supplier; +import com.chint.domain.aggregates.supplier.SupplierProduct; import com.chint.domain.aggregates.user.User; import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.repository.*; @@ -89,6 +91,9 @@ public class OrderQuery { @Autowired private LocationRepository locationRepository; + @Autowired + private SupplierRepository supplierRepository; + public RouteOrder queryByOrderId(OrderQueryData queryData) { return routeRepository.queryById(queryData.getRouteId()).reloadStatus(); } @@ -511,6 +516,7 @@ public class OrderQuery { } public List queryNotSubmit(OrderQueryData queryData) { + String supplierName = queryData.getSupplierName(); User currentUser = BaseContext.getCurrentUser(); List routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo()); routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList(); @@ -519,13 +525,23 @@ public class OrderQuery { orderDomainService.checkRouteOrderStatus(route); }); Stream stream = routeOrders.stream(); - if (queryData.getSupplierName() != null) { + if (supplierName != null) { stream = stream .filter(it -> it.getRouteRequestList() == null || it.getRouteRequestList().isEmpty() || it.getRouteRequestList() .stream() - .noneMatch(routeRequest -> routeRequest.getSupplier().equals(queryData.getSupplierName()))); + .noneMatch(routeRequest -> routeRequest.getSupplier().equals(supplierName))); } + Optional supplierOptional = supplierRepository.findBySupplierName(supplierName); + if (supplierOptional.isEmpty()) { + throw new NotFoundException("错误的供应商,请联系管理员"); + } + Supplier supplier = supplierOptional.get(); + List allowSupplierProductList = supplier.getSupplierProductList() + .stream() + .filter(SupplierProduct::ifCanOrder) + .map(SupplierProduct::getProductType) + .toList(); return stream .filter(order -> order.getApprovalStatus() != null) .filter(order -> !order.getOrderStatus().equals(ORDER_STATUS_FINISH) && @@ -535,6 +551,7 @@ public class OrderQuery { !order.getLegItems().isEmpty() && order.getLegItems().stream().anyMatch(leg -> !leg.getLegType().equals(LEG_TYPE_OTHER))) .filter(order -> order.getSupplierName() == null) + .filter(order -> order.getLegItems().stream().map(Leg::getLegType).anyMatch(allowSupplierProductList::contains)) //判断有无允许预订的商品 .sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed()) .map(order -> { User user = userRepository.findByUserEmployeeNo(order.getUserId()); diff --git a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java index 65d13b63..0babe7ad 100644 --- a/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java +++ b/src/main/java/com/chint/domain/aggregates/supplier/SupplierProduct.java @@ -24,4 +24,8 @@ public class SupplierProduct implements Serializable { private String ifCanCancelRule; @MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key") private List supplierProductStandardLevelList; + + public boolean ifCanOrder() { + return ifCanOrder == 1; + } } diff --git a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java index 9621142f..326be616 100644 --- a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java +++ b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java @@ -255,13 +255,13 @@ public class UserDepartmentInfo implements Serializable { } public boolean checkIfIn(String orgShortCode) { - return this.companyCode.contains(orgShortCode) || - this.departmentCodeOne.contains(orgShortCode) || - this.departmentCodeTwo.contains(orgShortCode) || - this.departmentCodeThree.contains(orgShortCode) || - this.departmentCodeFour.contains(orgShortCode) || - this.departmentCodeFive.contains(orgShortCode) || - this.departmentCodeSix.contains(orgShortCode) || - this.departmentCodeSeven.contains(orgShortCode); + return (this.companyCode != null && this.companyCode.contains(orgShortCode)) || + (this.departmentCodeOne != null && this.departmentCodeOne.contains(orgShortCode)) || + (this.departmentCodeTwo != null && this.departmentCodeTwo.contains(orgShortCode)) || + (this.departmentCodeThree != null && this.departmentCodeThree.contains(orgShortCode)) || + (this.departmentCodeFour != null && this.departmentCodeFour.contains(orgShortCode)) || + (this.departmentCodeFive != null && this.departmentCodeFive.contains(orgShortCode)) || + (this.departmentCodeSix != null && this.departmentCodeSix.contains(orgShortCode)) || + (this.departmentCodeSeven != null && this.departmentCodeSeven.contains(orgShortCode)); } }