wangqifan 3 yıl önce
ebeveyn
işleme
1e20b583cd

+ 13 - 0
src/main/java/com/izouma/zhumj/service/sale/ContractService.java

@@ -232,6 +232,19 @@ public class ContractService {
                                 break;
                         }
                     }
+                    if (SecurityUtils.getAuthenticatedUser().getCompanyId() != null) {
+                        List<Long> storeIds = storeInfoRepo
+                                .findAllByCompanyId(SecurityUtils.getAuthenticatedUser().getCompanyId()).stream()
+                                .map(StoreInfo::getId).collect(Collectors.toList());
+                        Set<Long> ids = contractStoreRepo.findAllByStoreIdIn(storeIds).stream()
+                                .map(ContractStore::getContractId).collect(Collectors.toSet());
+                        if (!ids.isEmpty()) {
+                            predicates.add(root.get("id").in(ids));
+                        } else {
+                            predicates.add(criteriaBuilder.disjunction());
+                        }
+
+                    }
                     if (pageQuery.getQuery().get("storeId") != null) {
                         Set<Long> ids = contractStoreRepo
                                 .queryStoreContractIds(MapUtils.getLong(pageQuery.getQuery(), "storeId"));