From 9af471035aff47441d83a92569291d2a1ed67aab Mon Sep 17 00:00:00 2001 From: yechenhao Date: Fri, 22 May 2020 16:54:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/StorePromotionDataService.java | 26 ++++++++++++------- .../mapper/StorePromotionDataDOMapper.xml | 8 +++--- 2 files changed, 21 insertions(+), 13 deletions(-) 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 @@