fix:修复部门问题导致高德消费明细推送失败的bug,完善查询未提价订单的功能

This commit is contained in:
lulz1 2024-05-29 16:14:43 +08:00
parent c62440c4e6
commit 196f5b07f7
3 changed files with 32 additions and 11 deletions

View File

@ -2,14 +2,16 @@ package com.chint.application.queryies;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.RoutOrderFieldParam; import com.chint.application.dtos.RoutOrderFieldParam;
import com.chint.application.dtos.mapper.RouteOrderMapper;
import com.chint.application.dtos.response.*; import com.chint.application.dtos.response.*;
import com.chint.application.dtos.trip.*; import com.chint.application.dtos.trip.*;
import com.chint.application.dtos.mapper.RouteOrderMapper;
import com.chint.application.queryies.estimate.EstimatePrice; import com.chint.application.queryies.estimate.EstimatePrice;
import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity; import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity; import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity; import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.*; 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.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.*; import com.chint.domain.repository.*;
@ -89,6 +91,9 @@ public class OrderQuery {
@Autowired @Autowired
private LocationRepository locationRepository; private LocationRepository locationRepository;
@Autowired
private SupplierRepository supplierRepository;
public RouteOrder queryByOrderId(OrderQueryData queryData) { public RouteOrder queryByOrderId(OrderQueryData queryData) {
return routeRepository.queryById(queryData.getRouteId()).reloadStatus(); return routeRepository.queryById(queryData.getRouteId()).reloadStatus();
} }
@ -511,6 +516,7 @@ public class OrderQuery {
} }
public List<RouteOrderPageRes> queryNotSubmit(OrderQueryData queryData) { public List<RouteOrderPageRes> queryNotSubmit(OrderQueryData queryData) {
String supplierName = queryData.getSupplierName();
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
List<RouteOrder> routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo()); List<RouteOrder> routeOrders = routeRepository.findAllByEmployeeNo(currentUser.getEmployeeNo());
routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList(); routeOrders = routeOrders.stream().filter(it -> it.getUserId().equals(currentUser.getEmployeeNo())).toList();
@ -519,13 +525,23 @@ public class OrderQuery {
orderDomainService.checkRouteOrderStatus(route); orderDomainService.checkRouteOrderStatus(route);
}); });
Stream<RouteOrder> stream = routeOrders.stream(); Stream<RouteOrder> stream = routeOrders.stream();
if (queryData.getSupplierName() != null) { if (supplierName != null) {
stream = stream stream = stream
.filter(it -> it.getRouteRequestList() == null || it.getRouteRequestList().isEmpty() || .filter(it -> it.getRouteRequestList() == null || it.getRouteRequestList().isEmpty() ||
it.getRouteRequestList() it.getRouteRequestList()
.stream() .stream()
.noneMatch(routeRequest -> routeRequest.getSupplier().equals(queryData.getSupplierName()))); .noneMatch(routeRequest -> routeRequest.getSupplier().equals(supplierName)));
} }
Optional<Supplier> supplierOptional = supplierRepository.findBySupplierName(supplierName);
if (supplierOptional.isEmpty()) {
throw new NotFoundException("错误的供应商,请联系管理员");
}
Supplier supplier = supplierOptional.get();
List<Integer> allowSupplierProductList = supplier.getSupplierProductList()
.stream()
.filter(SupplierProduct::ifCanOrder)
.map(SupplierProduct::getProductType)
.toList();
return stream return stream
.filter(order -> order.getApprovalStatus() != null) .filter(order -> order.getApprovalStatus() != null)
.filter(order -> !order.getOrderStatus().equals(ORDER_STATUS_FINISH) && .filter(order -> !order.getOrderStatus().equals(ORDER_STATUS_FINISH) &&
@ -535,6 +551,7 @@ public class OrderQuery {
!order.getLegItems().isEmpty() && !order.getLegItems().isEmpty() &&
order.getLegItems().stream().anyMatch(leg -> !leg.getLegType().equals(LEG_TYPE_OTHER))) order.getLegItems().stream().anyMatch(leg -> !leg.getLegType().equals(LEG_TYPE_OTHER)))
.filter(order -> order.getSupplierName() == null) .filter(order -> order.getSupplierName() == null)
.filter(order -> order.getLegItems().stream().map(Leg::getLegType).anyMatch(allowSupplierProductList::contains)) //判断有无允许预订的商品
.sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed()) .sorted(Comparator.comparing(RouteOrder::getUpdateTime).reversed())
.map(order -> { .map(order -> {
User user = userRepository.findByUserEmployeeNo(order.getUserId()); User user = userRepository.findByUserEmployeeNo(order.getUserId());

View File

@ -24,4 +24,8 @@ public class SupplierProduct implements Serializable {
private String ifCanCancelRule; private String ifCanCancelRule;
@MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key") @MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key")
private List<SupplierProductStandardLevel> supplierProductStandardLevelList; private List<SupplierProductStandardLevel> supplierProductStandardLevelList;
public boolean ifCanOrder() {
return ifCanOrder == 1;
}
} }

View File

@ -255,13 +255,13 @@ public class UserDepartmentInfo implements Serializable {
} }
public boolean checkIfIn(String orgShortCode) { public boolean checkIfIn(String orgShortCode) {
return this.companyCode.contains(orgShortCode) || return (this.companyCode != null && this.companyCode.contains(orgShortCode)) ||
this.departmentCodeOne.contains(orgShortCode) || (this.departmentCodeOne != null && this.departmentCodeOne.contains(orgShortCode)) ||
this.departmentCodeTwo.contains(orgShortCode) || (this.departmentCodeTwo != null && this.departmentCodeTwo.contains(orgShortCode)) ||
this.departmentCodeThree.contains(orgShortCode) || (this.departmentCodeThree != null && this.departmentCodeThree.contains(orgShortCode)) ||
this.departmentCodeFour.contains(orgShortCode) || (this.departmentCodeFour != null && this.departmentCodeFour.contains(orgShortCode)) ||
this.departmentCodeFive.contains(orgShortCode) || (this.departmentCodeFive != null && this.departmentCodeFive.contains(orgShortCode)) ||
this.departmentCodeSix.contains(orgShortCode) || (this.departmentCodeSix != null && this.departmentCodeSix.contains(orgShortCode)) ||
this.departmentCodeSeven.contains(orgShortCode); (this.departmentCodeSeven != null && this.departmentCodeSeven.contains(orgShortCode));
} }
} }