From dc46aee7fb9d90e561dcd00d7b69e5e26cc59cb5 Mon Sep 17 00:00:00 2001 From: LegnaYet <1023868505@qq.com> Date: Tue, 19 May 2020 15:39:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E5=8F=B7=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EmployeeController.java | 65 ---- .../ic/employee/service/EmployeeService.java | 317 ------------------ 2 files changed, 382 deletions(-) diff --git a/src/main/java/com/kiisoo/ic/employee/controller/EmployeeController.java b/src/main/java/com/kiisoo/ic/employee/controller/EmployeeController.java index 3830283..2076fbe 100644 --- a/src/main/java/com/kiisoo/ic/employee/controller/EmployeeController.java +++ b/src/main/java/com/kiisoo/ic/employee/controller/EmployeeController.java @@ -51,23 +51,6 @@ public class EmployeeController extends BaseController { } } - - /** - * 同步客户数据 - * @return - * @throws Exception - */ - @RequestMapping(value = "sync/custommer",method = RequestMethod.GET) - @ResponseBody - public Map syncCustoemr(){ - try { - employeeService.syncCustoemr(); - return success(); - }catch (Exception e){ - log.error("同步客户数据失败",e); - return fail(); - } - } /** * 同步客户数据 * @return @@ -100,54 +83,6 @@ public class EmployeeController extends BaseController { return fail(); } } - /** - * 清理客户数据 - * @return - * @throws Exception - */ - @RequestMapping(value = "clean/custommer",method = RequestMethod.GET) - @ResponseBody - public Map cleanCustomerRelation(){ - try { - employeeService.cleanCustomerRelation(); - return success(); - }catch (Exception e){ - log.error("清理客户数据失败",e); - return fail(); - } - } - /** - * 清理店铺客户数据 - * @return - * @throws Exception - */ - @RequestMapping(value = "clean/store/custommer",method = RequestMethod.GET) - @ResponseBody - public Map cleanCustomerRelation(@RequestParam("storeCode") String storeCode){ - try { - employeeService.cleanCustomerRelationByStoreCode(storeCode); - return success(); - }catch (Exception e){ - log.error("清理店铺客户数据失败",e); - return fail(); - } - } - /** - * 清理店铺客户数据 - * @return - * @throws Exception - */ - @RequestMapping(value = "clean/company/custommer",method = RequestMethod.GET) - @ResponseBody - public Map cleanCustomerRelation(@RequestParam("companyId") Long companyId){ - try { - employeeService.cleanCustomerRelationBycompanyId(companyId); - return success(); - }catch (Exception e){ - log.error("清理店铺客户数据失败",e); - return fail(); - } - } /** * 下载图片 * @return diff --git a/src/main/java/com/kiisoo/ic/employee/service/EmployeeService.java b/src/main/java/com/kiisoo/ic/employee/service/EmployeeService.java index 5ffdb36..31eaabf 100644 --- a/src/main/java/com/kiisoo/ic/employee/service/EmployeeService.java +++ b/src/main/java/com/kiisoo/ic/employee/service/EmployeeService.java @@ -468,114 +468,6 @@ public class EmployeeService { return inputStream; } - public void syncCustoemr() throws Exception { - //初始化线程 - ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(8); - - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - //查询所有店长 - List privilageCpUserStoreDOS = privilageCpUserStoreDOMapper.selectList(null); - if (CollectionUtils.isNotEmpty(privilageCpUserStoreDOS)){ - //分组 - final List> afterPageList = com.kiisoo.ic.utils.CollectionUtils.portListByQuantity(privilageCpUserStoreDOS, 100); - //定义线程池长度 - int threadPoolSize = afterPageList.size(); - //定义countDownLatch - final CountDownLatch countDownLatch = new CountDownLatch(threadPoolSize); - for (int i = 0; i < afterPageList.size(); i++) { - List cpUserStoreDOS = afterPageList.get(i); - newFixedThreadPool.execute(new Runnable() { - @Override - public void run() { - try { - for (PrivilageCpUserStoreDO cpUserStoreDO : cpUserStoreDOS) { - String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(cpUserStoreDO.getStoreId()); - if (StringUtils.isBlank(cpUserId)){ - continue; - } - List customers = null; - try { - customers = qwMailListManageService.getCustomer(cpUserId); - }catch (Exception e) { - log.error("查询联系人失败:"+cpUserId,e); - } - - if (CollectionUtils.isNotEmpty(customers)){ - for (WxCpUserExternalContactInfo customer:customers){ - TurnBackDTO turnBackDTO = new TurnBackDTO(); - - WxCpUserExternalContactInfo.ExternalContact externalContact = customer.getExternalContact(); - List followedUsers = customer.getFollowedUsers(); - - turnBackDTO.setEaCode(""); - if (CollectionUtils.isNotEmpty(followedUsers)){ - turnBackDTO.setJoinTime(sdf.format(new Date())); - for (WxCpUserExternalContactInfo.FollowedUser followedUser:followedUsers){ - if (cpUserId.equals(followedUser.getUserId())){ - String state = followedUser.getState(); - WxCpUserExternalContactInfo.Tag[] tags = followedUser.getTags(); - if (StringUtils.isNotBlank(state)){ - //判断是否有导购码 - turnBackDTO.setEaCode(state); - }else if(tags != null && tags.length > 0){ - //判断是否有打tag - //todo 根据tag获取导购码 - for (int j = 0;j poiStores = poiStoreDOMapper.selectShopByCompany(110L); @@ -676,213 +568,4 @@ public class EmployeeService { } } - - public void cleanCustomerRelation(){ - List privilageCpUserStoreDOS = privilageCpUserStoreDOMapper.selectList(null); - if (CollectionUtils.isNotEmpty(privilageCpUserStoreDOS)) { - for (PrivilageCpUserStoreDO privilageCpUserStoreDO : privilageCpUserStoreDOS) { - Long storeId = privilageCpUserStoreDO.getStoreId(); - QueryWrapper qw = new QueryWrapper<>(); - qw.eq("store_id",storeId); - List poiStoreStaffs = opSellerCustomerRelationDOMapper.selectList(qw); - //同一家店根据客户分组 - Map> customerMap = new HashMap<>(); - for (OpSellerCustomerRelation opSellerCustomerRelation : poiStoreStaffs) { - Long customerId = opSellerCustomerRelation.getCustomerId(); - if (customerMap.get(customerId) != null){ - List relations = customerMap.get(customerId); - relations.add(opSellerCustomerRelation); - }else { - List relations = new ArrayList<>(); - relations.add(opSellerCustomerRelation); - customerMap.put(customerId,relations); - } - } - Set customerIds = customerMap.keySet(); - for (Long customerId:customerIds){ - List relations = customerMap.get(customerId); - //根据导购分组 - Map> sellerMap = new HashMap<>(); - for (OpSellerCustomerRelation opSellerCustomerRelation : relations) { - Long sellerId = opSellerCustomerRelation.getUserId(); - if (sellerMap.get(sellerId) != null){ - List sellerRelations = sellerMap.get(sellerId); - sellerRelations.add(opSellerCustomerRelation); - }else { - List sellerRelations = new ArrayList<>(); - sellerRelations.add(opSellerCustomerRelation); - sellerMap.put(sellerId,sellerRelations); - } - } - //获取sellerId为0的分组 - List storeRelation = sellerMap.get(0L); - if (CollectionUtils.isEmpty(storeRelation)){ - continue; - } - Set sellerIds = sellerMap.keySet(); - for (Long sellerId : sellerIds){ - if (sellerId.equals(0L)){ - continue; - } - //获取导购与客户的关系 - List sellRelations = sellerMap.get(sellerId); - //遍历关系,看是否存在店铺关系,如果存在则删除店铺关系 - for (OpSellerCustomerRelation sellRelation : sellRelations) { - Long sellCustomer = sellRelation.getCustomerId(); - for (OpSellerCustomerRelation opSellerCustomerRelation : storeRelation) { - if (opSellerCustomerRelation.getCustomerId().equals(sellCustomer)){ - //店铺中存在则删除这条店铺记录(该记录为回调产生,保留的是同步过来的数据) - if (opSellerCustomerRelation.getType().equals(TYPE_CUSTOMER_EFFECTIVE)){ - //判断是否有效,有效则说明导购数据是有效的 - sellRelation.setType(TYPE_CUSTOMER_EFFECTIVE); - opSellerCustomerRelationDOMapper.updateById(sellRelation); - } - //删除店铺数据 - opSellerCustomerRelationDOMapper.deleteById(opSellerCustomerRelation.getId()); - } - } - } - } - } - } - } - } - public void cleanCustomerRelationByStoreCode(String storeCode){ - QueryWrapper storeQw = new QueryWrapper<>(); - storeQw.eq("code",storeCode).last("limit 1"); - PoiStore poiStore = poiStoreDOMapper.selectOne(storeQw); - QueryWrapper qw = new QueryWrapper<>(); - qw.eq("store_id",poiStore.getId()); - List poiStoreStaffs = opSellerCustomerRelationDOMapper.selectList(qw); - //同一家店根据客户分组 - Map> customerMap = new HashMap<>(); - for (OpSellerCustomerRelation opSellerCustomerRelation : poiStoreStaffs) { - Long customerId = opSellerCustomerRelation.getCustomerId(); - if (customerMap.get(customerId) != null){ - List relations = customerMap.get(customerId); - relations.add(opSellerCustomerRelation); - }else { - List relations = new ArrayList<>(); - relations.add(opSellerCustomerRelation); - customerMap.put(customerId,relations); - } - } - Set customerIds = customerMap.keySet(); - for (Long customerId:customerIds) { - List relations = customerMap.get(customerId); - //根据导购分组 - Map> sellerMap = new HashMap<>(); - for (OpSellerCustomerRelation opSellerCustomerRelation : relations) { - Long sellerId = opSellerCustomerRelation.getUserId(); - if (sellerMap.get(sellerId) != null) { - List sellerRelations = sellerMap.get(sellerId); - sellerRelations.add(opSellerCustomerRelation); - } else { - List sellerRelations = new ArrayList<>(); - sellerRelations.add(opSellerCustomerRelation); - sellerMap.put(sellerId, sellerRelations); - } - } - //获取sellerId为0的分组 - List storeRelation = sellerMap.get(0L); - if (CollectionUtils.isEmpty(storeRelation)) { - continue; - } - Set sellerIds = sellerMap.keySet(); - for (Long sellerId : sellerIds) { - if (sellerId.equals(0L)) { - continue; - } - //获取导购与客户的关系 - List sellRelations = sellerMap.get(sellerId); - //遍历关系,看是否存在店铺关系,如果存在则删除店铺关系 - for (OpSellerCustomerRelation sellRelation : sellRelations) { - Long sellCustomer = sellRelation.getCustomerId(); - for (OpSellerCustomerRelation opSellerCustomerRelation : storeRelation) { - if (opSellerCustomerRelation.getCustomerId().equals(sellCustomer)) { - //店铺中存在则删除这条店铺记录(该记录为回调产生,保留的是同步过来的数据) - if (opSellerCustomerRelation.getType().equals(TYPE_CUSTOMER_EFFECTIVE)) { - //判断是否有效,有效则说明导购数据是有效的 - sellRelation.setType(TYPE_CUSTOMER_EFFECTIVE); - opSellerCustomerRelationDOMapper.updateById(sellRelation); - } - //删除店铺数据 - opSellerCustomerRelationDOMapper.deleteById(opSellerCustomerRelation.getId()); - } - } - } - } - } - } - - public void cleanCustomerRelationBycompanyId(Long companyId){ - List poiStores = poiStoreDOMapper.selectShopByCompany(companyId); - if (CollectionUtils.isNotEmpty(poiStores)) { - for (PoiStore poiStore : poiStores) { - Long storeId = poiStore.getId(); - QueryWrapper qw = new QueryWrapper<>(); - qw.eq("store_id",storeId); - List poiStoreStaffs = opSellerCustomerRelationDOMapper.selectList(qw); - //同一家店根据客户分组 - Map> customerMap = new HashMap<>(); - for (OpSellerCustomerRelation opSellerCustomerRelation : poiStoreStaffs) { - Long customerId = opSellerCustomerRelation.getCustomerId(); - if (customerMap.get(customerId) != null){ - List relations = customerMap.get(customerId); - relations.add(opSellerCustomerRelation); - }else { - List relations = new ArrayList<>(); - relations.add(opSellerCustomerRelation); - customerMap.put(customerId,relations); - } - } - Set customerIds = customerMap.keySet(); - for (Long customerId:customerIds){ - List relations = customerMap.get(customerId); - //根据导购分组 - Map> sellerMap = new HashMap<>(); - for (OpSellerCustomerRelation opSellerCustomerRelation : relations) { - Long sellerId = opSellerCustomerRelation.getUserId(); - if (sellerMap.get(sellerId) != null){ - List sellerRelations = sellerMap.get(sellerId); - sellerRelations.add(opSellerCustomerRelation); - }else { - List sellerRelations = new ArrayList<>(); - sellerRelations.add(opSellerCustomerRelation); - sellerMap.put(sellerId,sellerRelations); - } - } - //获取sellerId为0的分组 - List storeRelation = sellerMap.get(0L); - if (CollectionUtils.isEmpty(storeRelation)){ - continue; - } - Set sellerIds = sellerMap.keySet(); - for (Long sellerId : sellerIds){ - if (sellerId.equals(0L)){ - continue; - } - //获取导购与客户的关系 - List sellRelations = sellerMap.get(sellerId); - //遍历关系,看是否存在店铺关系,如果存在则删除店铺关系 - for (OpSellerCustomerRelation sellRelation : sellRelations) { - Long sellCustomer = sellRelation.getCustomerId(); - for (OpSellerCustomerRelation opSellerCustomerRelation : storeRelation) { - if (opSellerCustomerRelation.getCustomerId().equals(sellCustomer)){ - //店铺中存在则删除这条店铺记录(该记录为回调产生,保留的是同步过来的数据) - if (opSellerCustomerRelation.getType().equals(TYPE_CUSTOMER_EFFECTIVE)){ - //判断是否有效,有效则说明导购数据是有效的 - sellRelation.setType(TYPE_CUSTOMER_EFFECTIVE); - opSellerCustomerRelationDOMapper.updateById(sellRelation); - } - //删除店铺数据 - opSellerCustomerRelationDOMapper.deleteById(opSellerCustomerRelation.getId()); - } - } - } - } - } - } - } - } }