Commit 05af77b786b0eb370bd721382647646dcc629f58

Authored by YunaiV
1 parent 9ea43ce5

crm:code review 客户画像

yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java
... ... @@ -40,21 +40,22 @@ public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitSe
40 40  
41 41 @Override
42 42 public List<CrmStatisticCustomerAreaRespVO> getCustomerSummaryByArea(CrmStatisticsPortraitReqVO reqVO) {
43   - // 1.1 获得用户编号数组
  43 + // 1. 获得用户编号数组
44 44 List<Long> userIds = getUserIds(reqVO);
45 45 if (CollUtil.isEmpty(userIds)) {
46 46 return Collections.emptyList();
47 47 }
48 48 reqVO.setUserIds(userIds);
49   - // 1.2 获取客户地区统计数据
  49 +
  50 + // 2. 获取客户地区统计数据
50 51 List<CrmStatisticCustomerAreaRespVO> list = portraitMapper.selectSummaryListGroupByAreaId(reqVO);
51 52 if (CollUtil.isEmpty(list)) {
52 53 return Collections.emptyList();
53 54 }
54 55  
55   - // 2. 拼接数据
  56 + // 3. 拼接数据
56 57 List<Area> areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area);
57   - areaList.add(new Area().setId(null).setName("未知"));
  58 + areaList.add(new Area().setId(null).setName("未知")); // TODO @puhui999:是不是 65 find 的逻辑改下;不用 findAndThen,直接从 areaMap 拿;拿到就设置,不拿到就设置 null 和 未知;这样,58 本行可以删除掉完事了;这样代码更简单和一致
58 59 Map<Integer, Area> areaMap = convertMap(areaList, Area::getId);
59 60 return convertList(list, item -> {
60 61 Integer parentId = AreaUtils.getParentIdByType(item.getAreaId(), AreaTypeEnum.PROVINCE);
... ... @@ -76,11 +77,7 @@ public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitSe
76 77 reqVO.setUserIds(userIds);
77 78  
78 79 // 2. 获取客户行业统计数据
79   - List<CrmStatisticCustomerIndustryRespVO> industryRespVOList = portraitMapper.selectCustomerIndustryListGroupByIndustryId(reqVO);
80   - if (CollUtil.isEmpty(industryRespVOList)) {
81   - return Collections.emptyList();
82   - }
83   - return industryRespVOList;
  80 + return portraitMapper.selectCustomerIndustryListGroupByIndustryId(reqVO);
84 81 }
85 82  
86 83 @Override
... ... @@ -93,11 +90,7 @@ public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitSe
93 90 reqVO.setUserIds(userIds);
94 91  
95 92 // 2. 获取客户行业统计数据
96   - List<CrmStatisticCustomerSourceRespVO> sourceRespVOList = portraitMapper.selectCustomerSourceListGroupBySource(reqVO);
97   - if (CollUtil.isEmpty(sourceRespVOList)) {
98   - return Collections.emptyList();
99   - }
100   - return sourceRespVOList;
  93 + return portraitMapper.selectCustomerSourceListGroupBySource(reqVO);
101 94 }
102 95  
103 96 @Override
... ... @@ -110,11 +103,7 @@ public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitSe
110 103 reqVO.setUserIds(userIds);
111 104  
112 105 // 2. 获取客户级别统计数据
113   - List<CrmStatisticCustomerLevelRespVO> levelRespVOList = portraitMapper.selectCustomerLevelListGroupByLevel(reqVO);
114   - if (CollUtil.isEmpty(levelRespVOList)) {
115   - return Collections.emptyList();
116   - }
117   - return levelRespVOList;
  106 + return portraitMapper.selectCustomerLevelListGroupByLevel(reqVO);
118 107 }
119 108  
120 109 /**
... ...