diff --git a/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java b/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java index e4790be..e63ec0d 100644 --- a/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java +++ b/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java @@ -612,30 +612,38 @@ public class StorePromotionDataService { public void distinctCustomer(HttpServletResponse response) throws IOException { List> customerIds = storePromotionDataDOMapper.selectDistinctCustomer(); List customerDistinctDTOS = new ArrayList<>(); + Map storeCompanyMap = new HashMap<>(); customerIds.forEach(customerId ->{ QueryWrapper relationQw = new QueryWrapper<>(); relationQw.eq("customer_id",customerId.get("customerId")).ne("type",3); List opSellerCustomerRelations = opSellerCustomerRelationDOMapper.selectList(relationQw); - OpCustomer customer = opCustomerDOMapper.selectById((Serializable) customerId.get("customerId")); opSellerCustomerRelations.forEach(opSellerCustomerRelation -> { CustomerDistinctDTO customerDistinctDTO = new CustomerDistinctDTO(); customerDistinctDTO.setCount((Long) customerId.get("count")); PoiStore poiStore = poiStoreDOMapper.selectById(opSellerCustomerRelation.getStoreId()); customerDistinctDTO.setStoreName(poiStore.getName()); customerDistinctDTO.setStoreCode(poiStore.getCode()); - Long orgCustomerId = privilageDomainEntityDOMapper.selectDomainIdByShopEntity(poiStore.getId()); - - if (orgCustomerId != null) { - PrivilageOrganizational orgCustomer = retailCompanyMapper.selectById(orgCustomerId); - PrivilageOrganizational company = retailCompanyMapper.selectById(orgCustomer.getParentId()); - + if (storeCompanyMap.get(poiStore.getId())!=null){ + PrivilageOrganizational company = storeCompanyMap.get(poiStore.getId()); customerDistinctDTO.setCompanyName(company.getName()); customerDistinctDTO.setCompanyCode(company.getCode()); + }else{ + Long orgCustomerId = privilageDomainEntityDOMapper.selectDomainIdByShopEntity(poiStore.getId()); + + if (orgCustomerId != null) { + PrivilageOrganizational orgCustomer = retailCompanyMapper.selectById(orgCustomerId); + PrivilageOrganizational company = retailCompanyMapper.selectById(orgCustomer.getParentId()); + + customerDistinctDTO.setCompanyName(company.getName()); + customerDistinctDTO.setCompanyCode(company.getCode()); + storeCompanyMap.put(poiStore.getId(),company); + } } + customerDistinctDTO.setStoreId(opSellerCustomerRelation.getStoreId()); customerDistinctDTO.setCustomerId(opSellerCustomerRelation.getCustomerId()); - customerDistinctDTO.setCustomerName(customer.getName()); - customerDistinctDTO.setCustomerUserId(customer.getExternalUserid()); + customerDistinctDTO.setCustomerName((String)customerId.get("customerName")); + customerDistinctDTO.setCustomerUserId((String)customerId.get("customerUserId")); customerDistinctDTOS.add(customerDistinctDTO); }); }); diff --git a/src/main/resources/mapper/StorePromotionDataDOMapper.xml b/src/main/resources/mapper/StorePromotionDataDOMapper.xml index 4b66b4c..3f594b1 100644 --- a/src/main/resources/mapper/StorePromotionDataDOMapper.xml +++ b/src/main/resources/mapper/StorePromotionDataDOMapper.xml @@ -411,13 +411,13 @@