Commit ee2be799875f0e4e415b5c551a2c171876d492c0
1 parent
d556b292
fix: [CRM-客户统计]根据Code-Review 修改代码
Showing
4 changed files
with
263 additions
and
305 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import jakarta.validation.constraints.NotEmpty; | 4 | import jakarta.validation.constraints.NotEmpty; |
| 6 | import jakarta.validation.constraints.NotNull; | 5 | import jakarta.validation.constraints.NotNull; |
| @@ -48,11 +47,4 @@ public class CrmStatisticsCustomerReqVO { | @@ -48,11 +47,4 @@ public class CrmStatisticsCustomerReqVO { | ||
| 48 | @Schema(description = "Group By 日期格式", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "%Y%m") | 47 | @Schema(description = "Group By 日期格式", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "%Y%m") |
| 49 | private String sqlDateFormat; | 48 | private String sqlDateFormat; |
| 50 | 49 | ||
| 51 | - // TODO @dhb52:这个字段,目前是不是没啥用呀? | ||
| 52 | - /** | ||
| 53 | - * 数据类型 {@link CrmBizTypeEnum} | ||
| 54 | - */ | ||
| 55 | - @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") | ||
| 56 | - private Integer bizType; | ||
| 57 | - | ||
| 58 | } | 50 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java
| @@ -13,33 +13,32 @@ import java.util.List; | @@ -13,33 +13,32 @@ import java.util.List; | ||
| 13 | @Mapper | 13 | @Mapper |
| 14 | public interface CrmStatisticsCustomerMapper { | 14 | public interface CrmStatisticsCustomerMapper { |
| 15 | 15 | ||
| 16 | - // TODO @dhb52:拼写,GroupBy。一般 idea 如果出现绿色的警告,可能是单词拼写错误,建议是要修改的哈; | ||
| 17 | - List<CrmStatisticsCustomerSummaryByDateRespVO> selectCustomerCreateCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); // 已经 review | 16 | + List<CrmStatisticsCustomerSummaryByDateRespVO> selectCustomerCreateCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); // 已经 review |
| 18 | 17 | ||
| 19 | - List<CrmStatisticsCustomerSummaryByDateRespVO> selectCustomerDealCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); // 已经 review | 18 | + List<CrmStatisticsCustomerSummaryByDateRespVO> selectCustomerDealCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); // 已经 review |
| 20 | 19 | ||
| 21 | - List<CrmStatisticsCustomerSummaryByUserRespVO> selectCustomerCreateCountGroupbyUser(CrmStatisticsCustomerReqVO reqVO); // 已经 review | 20 | + List<CrmStatisticsCustomerSummaryByUserRespVO> selectCustomerCreateCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); // 已经 review |
| 22 | 21 | ||
| 23 | - List<CrmStatisticsCustomerSummaryByUserRespVO> selectCustomerDealCountGroupbyUser(CrmStatisticsCustomerReqVO crmStatisticsCustomerReqVO); // 已经 review | 22 | + List<CrmStatisticsCustomerSummaryByUserRespVO> selectCustomerDealCountGroupByUser(CrmStatisticsCustomerReqVO crmStatisticsCustomerReqVO); // 已经 review |
| 24 | 23 | ||
| 25 | - List<CrmStatisticsCustomerSummaryByUserRespVO> selectContractPriceGroupbyUser(CrmStatisticsCustomerReqVO crmStatisticsCustomerReqVO); // 已经 review | 24 | + List<CrmStatisticsCustomerSummaryByUserRespVO> selectContractPriceGroupByUser(CrmStatisticsCustomerReqVO crmStatisticsCustomerReqVO); // 已经 review |
| 26 | 25 | ||
| 27 | - List<CrmStatisticsCustomerSummaryByUserRespVO> selectReceivablePriceGroupbyUser(CrmStatisticsCustomerReqVO crmStatisticsCustomerReqVO); // 已经 review | 26 | + List<CrmStatisticsCustomerSummaryByUserRespVO> selectReceivablePriceGroupByUser(CrmStatisticsCustomerReqVO crmStatisticsCustomerReqVO); // 已经 review |
| 28 | 27 | ||
| 29 | - List<CrmStatisticsFollowupSummaryByDateRespVO> selectFollowupRecordCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | 28 | + List<CrmStatisticsFollowupSummaryByDateRespVO> selectFollowupRecordCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 30 | 29 | ||
| 31 | - List<CrmStatisticsFollowupSummaryByDateRespVO> selectFollowupCustomerCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | 30 | + List<CrmStatisticsFollowupSummaryByDateRespVO> selectFollowupCustomerCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 32 | 31 | ||
| 33 | - List<CrmStatisticsFollowupSummaryByUserRespVO> selectFollowupRecordCountGroupbyUser(CrmStatisticsCustomerReqVO reqVO); | 32 | + List<CrmStatisticsFollowupSummaryByUserRespVO> selectFollowupRecordCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 34 | 33 | ||
| 35 | - List<CrmStatisticsFollowupSummaryByUserRespVO> selectFollowupCustomerCountGroupbyUser(CrmStatisticsCustomerReqVO reqVO); | 34 | + List<CrmStatisticsFollowupSummaryByUserRespVO> selectFollowupCustomerCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 36 | 35 | ||
| 37 | List<CrmStatisticsCustomerContractSummaryRespVO> selectContractSummary(CrmStatisticsCustomerReqVO reqVO); | 36 | List<CrmStatisticsCustomerContractSummaryRespVO> selectContractSummary(CrmStatisticsCustomerReqVO reqVO); |
| 38 | 37 | ||
| 39 | - List<CrmStatisticsFollowupSummaryByTypeRespVO> selectFollowupRecordCountGroupbyType(CrmStatisticsCustomerReqVO reqVO); | 38 | + List<CrmStatisticsFollowupSummaryByTypeRespVO> selectFollowupRecordCountGroupByType(CrmStatisticsCustomerReqVO reqVO); |
| 40 | 39 | ||
| 41 | - List<CrmStatisticsCustomerDealCycleByDateRespVO> selectCustomerDealCycleGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | 40 | + List<CrmStatisticsCustomerDealCycleByDateRespVO> selectCustomerDealCycleGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 42 | 41 | ||
| 43 | - List<CrmStatisticsCustomerDealCycleByUserRespVO> selectCustomerDealCycleGroupbyUser(CrmStatisticsCustomerReqVO reqVO); | 42 | + List<CrmStatisticsCustomerDealCycleByUserRespVO> selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 44 | 43 | ||
| 45 | } | 44 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java
| @@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | ||
| 7 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | 7 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; |
| 9 | import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; |
| 10 | -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 11 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; | 10 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| 12 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | 11 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| 13 | import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | 12 | import cn.iocoder.yudao.module.system.api.dict.DictDataApi; |
| @@ -20,7 +19,6 @@ import org.springframework.validation.annotation.Validated; | @@ -20,7 +19,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 20 | 19 | ||
| 21 | import java.math.BigDecimal; | 20 | import java.math.BigDecimal; |
| 22 | import java.time.LocalDateTime; | 21 | import java.time.LocalDateTime; |
| 23 | -import java.util.ArrayList; | ||
| 24 | import java.util.Collections; | 22 | import java.util.Collections; |
| 25 | import java.util.List; | 23 | import java.util.List; |
| 26 | import java.util.Map; | 24 | import java.util.Map; |
| @@ -58,87 +56,83 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -58,87 +56,83 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 58 | @Override | 56 | @Override |
| 59 | public List<CrmStatisticsCustomerSummaryByDateRespVO> getCustomerSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { | 57 | public List<CrmStatisticsCustomerSummaryByDateRespVO> getCustomerSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { |
| 60 | // 1. 获得用户编号数组 | 58 | // 1. 获得用户编号数组 |
| 61 | - final List<Long> userIds = getUserIds(reqVO); | 59 | + List<Long> userIds = getUserIds(reqVO); |
| 62 | if (CollUtil.isEmpty(userIds)) { | 60 | if (CollUtil.isEmpty(userIds)) { |
| 63 | return Collections.emptyList(); | 61 | return Collections.emptyList(); |
| 64 | } | 62 | } |
| 65 | reqVO.setUserIds(userIds); | 63 | reqVO.setUserIds(userIds); |
| 66 | 64 | ||
| 67 | // 2. 获取分项统计数据 | 65 | // 2. 获取分项统计数据 |
| 68 | - // TODO @dhb52:如果是 list 变量,要么 List 要么 s 后缀 | ||
| 69 | reqVO.setSqlDateFormat(getSqlDateFormat(reqVO.getTimes()[0], reqVO.getTimes()[1])); | 66 | reqVO.setSqlDateFormat(getSqlDateFormat(reqVO.getTimes()[0], reqVO.getTimes()[1])); |
| 70 | - final List<CrmStatisticsCustomerSummaryByDateRespVO> customerCreateCount = customerMapper.selectCustomerCreateCountGroupbyDate(reqVO); | ||
| 71 | - final List<CrmStatisticsCustomerSummaryByDateRespVO> customerDealCount = customerMapper.selectCustomerDealCountGroupbyDate(reqVO); | 67 | + List<CrmStatisticsCustomerSummaryByDateRespVO> customerCreateCountVoList = customerMapper.selectCustomerCreateCountGroupByDate(reqVO); |
| 68 | + List<CrmStatisticsCustomerSummaryByDateRespVO> customerDealCountVoList = customerMapper.selectCustomerDealCountGroupByDate(reqVO); | ||
| 72 | 69 | ||
| 73 | - // 3. 获取时间序列 | ||
| 74 | - // TODO @dhb52:3 和 4 其实做的是一类事情,所以可以考虑 3.1 获取时间序列、3.2 合并统计数据 这样注释;然后中间就不空行了;就是说,一般空行的目的,是让逻辑分片,看着整体性更好,但是不能让逻辑感觉碎碎的; | ||
| 75 | - final List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); | ||
| 76 | - | ||
| 77 | - // 4. 合并统计数据 | ||
| 78 | - // TODO @dhb52:这个是不是要 add 到 respVoList 里?或者还可以 convertList(times, time -> new CrmStatisticsCustomerDealCycleByDateRespVO()...) | ||
| 79 | - List<CrmStatisticsCustomerSummaryByDateRespVO> respVoList = new ArrayList<>(times.size()); | ||
| 80 | - final Map<String, Integer> customerCreateCountMap = convertMap(customerCreateCount, | 70 | + // 3. 合并数据 |
| 71 | + List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); | ||
| 72 | + Map<String, Integer> customerCreateCountMap = convertMap(customerCreateCountVoList, | ||
| 81 | CrmStatisticsCustomerSummaryByDateRespVO::getTime, | 73 | CrmStatisticsCustomerSummaryByDateRespVO::getTime, |
| 82 | CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount); | 74 | CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount); |
| 83 | - final Map<String, Integer> customerDealCountMap = convertMap(customerDealCount, | 75 | + Map<String, Integer> customerDealCountMap = convertMap(customerDealCountVoList, |
| 84 | CrmStatisticsCustomerSummaryByDateRespVO::getTime, | 76 | CrmStatisticsCustomerSummaryByDateRespVO::getTime, |
| 85 | CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount); | 77 | CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount); |
| 86 | - times.forEach(time -> respVoList.add( | ||
| 87 | - new CrmStatisticsCustomerSummaryByDateRespVO().setTime(time) | 78 | + List<CrmStatisticsCustomerSummaryByDateRespVO> respVoList = convertList(times, |
| 79 | + time -> new CrmStatisticsCustomerSummaryByDateRespVO() | ||
| 80 | + .setTime(time) | ||
| 88 | .setCustomerCreateCount(customerCreateCountMap.getOrDefault(time, 0)) | 81 | .setCustomerCreateCount(customerCreateCountMap.getOrDefault(time, 0)) |
| 89 | - .setCustomerDealCount(customerDealCountMap.getOrDefault(time, 0)) | ||
| 90 | - )); | 82 | + .setCustomerDealCount(customerDealCountMap.getOrDefault(time, 0))); |
| 83 | + | ||
| 91 | return respVoList; | 84 | return respVoList; |
| 92 | } | 85 | } |
| 93 | 86 | ||
| 94 | @Override | 87 | @Override |
| 95 | public List<CrmStatisticsCustomerSummaryByUserRespVO> getCustomerSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { | 88 | public List<CrmStatisticsCustomerSummaryByUserRespVO> getCustomerSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { |
| 96 | // 1. 获得用户编号数组 | 89 | // 1. 获得用户编号数组 |
| 97 | - final List<Long> userIds = getUserIds(reqVO); | 90 | + List<Long> userIds = getUserIds(reqVO); |
| 98 | if (CollUtil.isEmpty(userIds)) { | 91 | if (CollUtil.isEmpty(userIds)) { |
| 99 | return Collections.emptyList(); | 92 | return Collections.emptyList(); |
| 100 | } | 93 | } |
| 101 | reqVO.setUserIds(userIds); | 94 | reqVO.setUserIds(userIds); |
| 102 | 95 | ||
| 103 | // 2. 获取分项统计数据 | 96 | // 2. 获取分项统计数据 |
| 104 | - final List<CrmStatisticsCustomerSummaryByUserRespVO> customerCreateCount = customerMapper.selectCustomerCreateCountGroupbyUser(reqVO); | ||
| 105 | - final List<CrmStatisticsCustomerSummaryByUserRespVO> customerDealCount = customerMapper.selectCustomerDealCountGroupbyUser(reqVO); | ||
| 106 | - final List<CrmStatisticsCustomerSummaryByUserRespVO> contractPrice = customerMapper.selectContractPriceGroupbyUser(reqVO); | ||
| 107 | - final List<CrmStatisticsCustomerSummaryByUserRespVO> receivablePrice = customerMapper.selectReceivablePriceGroupbyUser(reqVO); | 97 | + List<CrmStatisticsCustomerSummaryByUserRespVO> customerCreateCount = customerMapper.selectCustomerCreateCountGroupByUser(reqVO); |
| 98 | + List<CrmStatisticsCustomerSummaryByUserRespVO> customerDealCount = customerMapper.selectCustomerDealCountGroupByUser(reqVO); | ||
| 99 | + List<CrmStatisticsCustomerSummaryByUserRespVO> contractPrice = customerMapper.selectContractPriceGroupByUser(reqVO); | ||
| 100 | + List<CrmStatisticsCustomerSummaryByUserRespVO> receivablePrice = customerMapper.selectReceivablePriceGroupByUser(reqVO); | ||
| 108 | 101 | ||
| 109 | // 3. 合并统计数据 | 102 | // 3. 合并统计数据 |
| 110 | - final Map<Long, Integer> customerCreateCountMap = convertMap(customerCreateCount, | 103 | + Map<Long, Integer> customerCreateCountMap = convertMap(customerCreateCount, |
| 111 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, | 104 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, |
| 112 | CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount); | 105 | CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount); |
| 113 | - final Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount, | 106 | + Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount, |
| 114 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, | 107 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, |
| 115 | CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); | 108 | CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); |
| 116 | - final Map<Long, BigDecimal> contractPriceMap = convertMap(contractPrice, | 109 | + Map<Long, BigDecimal> contractPriceMap = convertMap(contractPrice, |
| 117 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, | 110 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, |
| 118 | CrmStatisticsCustomerSummaryByUserRespVO::getContractPrice); | 111 | CrmStatisticsCustomerSummaryByUserRespVO::getContractPrice); |
| 119 | - final Map<Long, BigDecimal> receivablePriceMap = convertMap(receivablePrice, | 112 | + Map<Long, BigDecimal> receivablePriceMap = convertMap(receivablePrice, |
| 120 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, | 113 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, |
| 121 | CrmStatisticsCustomerSummaryByUserRespVO::getReceivablePrice); | 114 | CrmStatisticsCustomerSummaryByUserRespVO::getReceivablePrice); |
| 122 | - List<CrmStatisticsCustomerSummaryByUserRespVO> respVoList = new ArrayList<>(userIds.size()); | ||
| 123 | - userIds.forEach(userId -> { | ||
| 124 | - final CrmStatisticsCustomerSummaryByUserRespVO vo = new CrmStatisticsCustomerSummaryByUserRespVO(); | 115 | + List<CrmStatisticsCustomerSummaryByUserRespVO> respVoList = convertList(userIds, userId -> { |
| 116 | + CrmStatisticsCustomerSummaryByUserRespVO vo = new CrmStatisticsCustomerSummaryByUserRespVO(); | ||
| 117 | + // ownerUserId 为基类属性 | ||
| 125 | vo.setOwnerUserId(userId); | 118 | vo.setOwnerUserId(userId); |
| 126 | vo.setCustomerCreateCount(customerCreateCountMap.getOrDefault(userId, 0)) | 119 | vo.setCustomerCreateCount(customerCreateCountMap.getOrDefault(userId, 0)) |
| 127 | .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0)) | 120 | .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0)) |
| 128 | .setContractPrice(contractPriceMap.getOrDefault(userId, BigDecimal.ZERO)) | 121 | .setContractPrice(contractPriceMap.getOrDefault(userId, BigDecimal.ZERO)) |
| 129 | .setReceivablePrice(receivablePriceMap.getOrDefault(userId, BigDecimal.ZERO)); | 122 | .setReceivablePrice(receivablePriceMap.getOrDefault(userId, BigDecimal.ZERO)); |
| 130 | - respVoList.add(vo); | 123 | + return vo; |
| 131 | }); | 124 | }); |
| 132 | 125 | ||
| 133 | // 4. 拼接用户信息 | 126 | // 4. 拼接用户信息 |
| 134 | appendUserInfo(respVoList); | 127 | appendUserInfo(respVoList); |
| 128 | + | ||
| 135 | return respVoList; | 129 | return respVoList; |
| 136 | } | 130 | } |
| 137 | 131 | ||
| 138 | @Override | 132 | @Override |
| 139 | public List<CrmStatisticsFollowupSummaryByDateRespVO> getFollowupSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { | 133 | public List<CrmStatisticsFollowupSummaryByDateRespVO> getFollowupSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { |
| 140 | // 1. 获得用户编号数组 | 134 | // 1. 获得用户编号数组 |
| 141 | - final List<Long> userIds = getUserIds(reqVO); | 135 | + List<Long> userIds = getUserIds(reqVO); |
| 142 | if (CollUtil.isEmpty(userIds)) { | 136 | if (CollUtil.isEmpty(userIds)) { |
| 143 | return Collections.emptyList(); | 137 | return Collections.emptyList(); |
| 144 | } | 138 | } |
| @@ -146,26 +140,22 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -146,26 +140,22 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 146 | 140 | ||
| 147 | // 2. 获取分项统计数据 | 141 | // 2. 获取分项统计数据 |
| 148 | reqVO.setSqlDateFormat(getSqlDateFormat(reqVO.getTimes()[0], reqVO.getTimes()[1])); | 142 | reqVO.setSqlDateFormat(getSqlDateFormat(reqVO.getTimes()[0], reqVO.getTimes()[1])); |
| 149 | - reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||
| 150 | - final List<CrmStatisticsFollowupSummaryByDateRespVO> followupRecordCount = customerMapper.selectFollowupRecordCountGroupbyDate(reqVO); | ||
| 151 | - final List<CrmStatisticsFollowupSummaryByDateRespVO> followupCustomerCount = customerMapper.selectFollowupCustomerCountGroupbyDate(reqVO); | 143 | + List<CrmStatisticsFollowupSummaryByDateRespVO> followupRecordCount = customerMapper.selectFollowupRecordCountGroupByDate(reqVO); |
| 144 | + List<CrmStatisticsFollowupSummaryByDateRespVO> followupCustomerCount = customerMapper.selectFollowupCustomerCountGroupByDate(reqVO); | ||
| 152 | 145 | ||
| 153 | - // 3. 获取时间序列 | ||
| 154 | - final List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); | ||
| 155 | - | ||
| 156 | - // 4. 合并统计数据 | ||
| 157 | - List<CrmStatisticsFollowupSummaryByDateRespVO> respVoList = new ArrayList<>(times.size()); | ||
| 158 | - final Map<String, Integer> followupRecordCountMap = convertMap(followupRecordCount, | 146 | + // 3. 合并统计数据 |
| 147 | + List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); | ||
| 148 | + Map<String, Integer> followupRecordCountMap = convertMap(followupRecordCount, | ||
| 159 | CrmStatisticsFollowupSummaryByDateRespVO::getTime, | 149 | CrmStatisticsFollowupSummaryByDateRespVO::getTime, |
| 160 | CrmStatisticsFollowupSummaryByDateRespVO::getFollowupRecordCount); | 150 | CrmStatisticsFollowupSummaryByDateRespVO::getFollowupRecordCount); |
| 161 | - final Map<String, Integer> followupCustomerCountMap = convertMap(followupCustomerCount, | 151 | + Map<String, Integer> followupCustomerCountMap = convertMap(followupCustomerCount, |
| 162 | CrmStatisticsFollowupSummaryByDateRespVO::getTime, | 152 | CrmStatisticsFollowupSummaryByDateRespVO::getTime, |
| 163 | CrmStatisticsFollowupSummaryByDateRespVO::getFollowupCustomerCount); | 153 | CrmStatisticsFollowupSummaryByDateRespVO::getFollowupCustomerCount); |
| 164 | - times.forEach(time -> respVoList.add( | 154 | + List<CrmStatisticsFollowupSummaryByDateRespVO> respVoList = convertList(times, time -> |
| 165 | new CrmStatisticsFollowupSummaryByDateRespVO().setTime(time) | 155 | new CrmStatisticsFollowupSummaryByDateRespVO().setTime(time) |
| 166 | .setFollowupRecordCount(followupRecordCountMap.getOrDefault(time, 0)) | 156 | .setFollowupRecordCount(followupRecordCountMap.getOrDefault(time, 0)) |
| 167 | .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(time, 0)) | 157 | .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(time, 0)) |
| 168 | - )); | 158 | + ); |
| 169 | 159 | ||
| 170 | return respVoList; | 160 | return respVoList; |
| 171 | } | 161 | } |
| @@ -173,31 +163,30 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -173,31 +163,30 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 173 | @Override | 163 | @Override |
| 174 | public List<CrmStatisticsFollowupSummaryByUserRespVO> getFollowupSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { | 164 | public List<CrmStatisticsFollowupSummaryByUserRespVO> getFollowupSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { |
| 175 | // 1. 获得用户编号数组 | 165 | // 1. 获得用户编号数组 |
| 176 | - final List<Long> userIds = getUserIds(reqVO); | 166 | + List<Long> userIds = getUserIds(reqVO); |
| 177 | if (CollUtil.isEmpty(userIds)) { | 167 | if (CollUtil.isEmpty(userIds)) { |
| 178 | return Collections.emptyList(); | 168 | return Collections.emptyList(); |
| 179 | } | 169 | } |
| 180 | reqVO.setUserIds(userIds); | 170 | reqVO.setUserIds(userIds); |
| 181 | 171 | ||
| 182 | // 2. 获取分项统计数据 | 172 | // 2. 获取分项统计数据 |
| 183 | - reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||
| 184 | - final List<CrmStatisticsFollowupSummaryByUserRespVO> followupRecordCount = customerMapper.selectFollowupRecordCountGroupbyUser(reqVO); | ||
| 185 | - final List<CrmStatisticsFollowupSummaryByUserRespVO> followupCustomerCount = customerMapper.selectFollowupCustomerCountGroupbyUser(reqVO); | 173 | + List<CrmStatisticsFollowupSummaryByUserRespVO> followupRecordCount = customerMapper.selectFollowupRecordCountGroupByUser(reqVO); |
| 174 | + List<CrmStatisticsFollowupSummaryByUserRespVO> followupCustomerCount = customerMapper.selectFollowupCustomerCountGroupByUser(reqVO); | ||
| 186 | 175 | ||
| 187 | // 3. 合并统计数据 | 176 | // 3. 合并统计数据 |
| 188 | - final Map<Long, Integer> followupRecordCountMap = convertMap(followupRecordCount, | 177 | + Map<Long, Integer> followupRecordCountMap = convertMap(followupRecordCount, |
| 189 | CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, | 178 | CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, |
| 190 | CrmStatisticsFollowupSummaryByUserRespVO::getFollowupRecordCount); | 179 | CrmStatisticsFollowupSummaryByUserRespVO::getFollowupRecordCount); |
| 191 | - final Map<Long, Integer> followupCustomerCountMap = convertMap(followupCustomerCount, | 180 | + Map<Long, Integer> followupCustomerCountMap = convertMap(followupCustomerCount, |
| 192 | CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, | 181 | CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, |
| 193 | CrmStatisticsFollowupSummaryByUserRespVO::getFollowupCustomerCount); | 182 | CrmStatisticsFollowupSummaryByUserRespVO::getFollowupCustomerCount); |
| 194 | - List<CrmStatisticsFollowupSummaryByUserRespVO> respVoList = new ArrayList<>(userIds.size()); | ||
| 195 | - userIds.forEach(userId -> { | ||
| 196 | - final CrmStatisticsFollowupSummaryByUserRespVO vo = new CrmStatisticsFollowupSummaryByUserRespVO() | 183 | + List<CrmStatisticsFollowupSummaryByUserRespVO> respVoList = convertList(userIds, userId -> { |
| 184 | + CrmStatisticsFollowupSummaryByUserRespVO vo = new CrmStatisticsFollowupSummaryByUserRespVO() | ||
| 197 | .setFollowupRecordCount(followupRecordCountMap.getOrDefault(userId, 0)) | 185 | .setFollowupRecordCount(followupRecordCountMap.getOrDefault(userId, 0)) |
| 198 | .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(userId, 0)); | 186 | .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(userId, 0)); |
| 187 | + // ownerUserId 为基类属性 | ||
| 199 | vo.setOwnerUserId(userId); | 188 | vo.setOwnerUserId(userId); |
| 200 | - respVoList.add(vo); | 189 | + return vo; |
| 201 | }); | 190 | }); |
| 202 | 191 | ||
| 203 | // 4. 拼接用户信息 | 192 | // 4. 拼接用户信息 |
| @@ -208,19 +197,18 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -208,19 +197,18 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 208 | @Override | 197 | @Override |
| 209 | public List<CrmStatisticsFollowupSummaryByTypeRespVO> getFollowupSummaryByType(CrmStatisticsCustomerReqVO reqVO) { | 198 | public List<CrmStatisticsFollowupSummaryByTypeRespVO> getFollowupSummaryByType(CrmStatisticsCustomerReqVO reqVO) { |
| 210 | // 1. 获得用户编号数组 | 199 | // 1. 获得用户编号数组 |
| 211 | - final List<Long> userIds = getUserIds(reqVO); | 200 | + List<Long> userIds = getUserIds(reqVO); |
| 212 | if (CollUtil.isEmpty(userIds)) { | 201 | if (CollUtil.isEmpty(userIds)) { |
| 213 | return Collections.emptyList(); | 202 | return Collections.emptyList(); |
| 214 | } | 203 | } |
| 215 | reqVO.setUserIds(userIds); | 204 | reqVO.setUserIds(userIds); |
| 216 | 205 | ||
| 217 | // 2. 获得排行数据 | 206 | // 2. 获得排行数据 |
| 218 | - reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||
| 219 | - List<CrmStatisticsFollowupSummaryByTypeRespVO> respVoList = customerMapper.selectFollowupRecordCountGroupbyType(reqVO); | 207 | + List<CrmStatisticsFollowupSummaryByTypeRespVO> respVoList = customerMapper.selectFollowupRecordCountGroupByType(reqVO); |
| 220 | 208 | ||
| 221 | // 3. 获取字典数据 | 209 | // 3. 获取字典数据 |
| 222 | List<DictDataRespDTO> followUpTypes = dictDataApi.getDictDataList(CRM_FOLLOW_UP_TYPE); | 210 | List<DictDataRespDTO> followUpTypes = dictDataApi.getDictDataList(CRM_FOLLOW_UP_TYPE); |
| 223 | - final Map<String, String> followUpTypeMap = convertMap(followUpTypes, | 211 | + Map<String, String> followUpTypeMap = convertMap(followUpTypes, |
| 224 | DictDataRespDTO::getValue, DictDataRespDTO::getLabel); | 212 | DictDataRespDTO::getValue, DictDataRespDTO::getLabel); |
| 225 | respVoList.forEach(vo -> { | 213 | respVoList.forEach(vo -> { |
| 226 | vo.setFollowupType(followUpTypeMap.get(vo.getFollowupType())); | 214 | vo.setFollowupType(followUpTypeMap.get(vo.getFollowupType())); |
| @@ -232,7 +220,7 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -232,7 +220,7 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 232 | @Override | 220 | @Override |
| 233 | public List<CrmStatisticsCustomerContractSummaryRespVO> getContractSummary(CrmStatisticsCustomerReqVO reqVO) { | 221 | public List<CrmStatisticsCustomerContractSummaryRespVO> getContractSummary(CrmStatisticsCustomerReqVO reqVO) { |
| 234 | // 1. 获得用户编号数组 | 222 | // 1. 获得用户编号数组 |
| 235 | - final List<Long> userIds = getUserIds(reqVO); | 223 | + List<Long> userIds = getUserIds(reqVO); |
| 236 | if (CollUtil.isEmpty(userIds)) { | 224 | if (CollUtil.isEmpty(userIds)) { |
| 237 | return Collections.emptyList(); | 225 | return Collections.emptyList(); |
| 238 | } | 226 | } |
| @@ -242,16 +230,16 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -242,16 +230,16 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 242 | List<CrmStatisticsCustomerContractSummaryRespVO> respVoList = customerMapper.selectContractSummary(reqVO); | 230 | List<CrmStatisticsCustomerContractSummaryRespVO> respVoList = customerMapper.selectContractSummary(reqVO); |
| 243 | 231 | ||
| 244 | // 3. 设置 创建人、负责人、行业、来源 | 232 | // 3. 设置 创建人、负责人、行业、来源 |
| 245 | - // 获取客户所属行业 | 233 | + // 3.1 获取客户所属行业 |
| 246 | Map<String, String> industryMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_INDUSTRY), | 234 | Map<String, String> industryMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_INDUSTRY), |
| 247 | DictDataRespDTO::getValue, DictDataRespDTO::getLabel); | 235 | DictDataRespDTO::getValue, DictDataRespDTO::getLabel); |
| 248 | - // 获取客户来源 | 236 | + // 3.2 获取客户来源 |
| 249 | Map<String, String> sourceMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_SOURCE), | 237 | Map<String, String> sourceMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_SOURCE), |
| 250 | DictDataRespDTO::getValue, DictDataRespDTO::getLabel); | 238 | DictDataRespDTO::getValue, DictDataRespDTO::getLabel); |
| 251 | - // 获取创建人、负责人列表 | 239 | + // 3.3 获取创建人、负责人列表 |
| 252 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSetByFlatMap(respVoList, | 240 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSetByFlatMap(respVoList, |
| 253 | vo -> Stream.of(NumberUtils.parseLong(vo.getCreatorUserId()), vo.getOwnerUserId()))); | 241 | vo -> Stream.of(NumberUtils.parseLong(vo.getCreatorUserId()), vo.getOwnerUserId()))); |
| 254 | - | 242 | + // 3.4 设置 创建人、负责人、行业、来源 |
| 255 | respVoList.forEach(vo -> { | 243 | respVoList.forEach(vo -> { |
| 256 | MapUtils.findAndThen(industryMap, vo.getIndustryId(), vo::setIndustryName); | 244 | MapUtils.findAndThen(industryMap, vo.getIndustryId(), vo::setIndustryName); |
| 257 | MapUtils.findAndThen(sourceMap, vo.getSource(), vo::setSourceName); | 245 | MapUtils.findAndThen(sourceMap, vo.getSource(), vo::setSourceName); |
| @@ -266,7 +254,7 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -266,7 +254,7 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 266 | @Override | 254 | @Override |
| 267 | public List<CrmStatisticsCustomerDealCycleByDateRespVO> getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO) { | 255 | public List<CrmStatisticsCustomerDealCycleByDateRespVO> getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO) { |
| 268 | // 1. 获得用户编号数组 | 256 | // 1. 获得用户编号数组 |
| 269 | - final List<Long> userIds = getUserIds(reqVO); | 257 | + List<Long> userIds = getUserIds(reqVO); |
| 270 | if (CollUtil.isEmpty(userIds)) { | 258 | if (CollUtil.isEmpty(userIds)) { |
| 271 | return Collections.emptyList(); | 259 | return Collections.emptyList(); |
| 272 | } | 260 | } |
| @@ -274,52 +262,48 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -274,52 +262,48 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 274 | 262 | ||
| 275 | // 2. 获取分项统计数据 | 263 | // 2. 获取分项统计数据 |
| 276 | reqVO.setSqlDateFormat(getSqlDateFormat(reqVO.getTimes()[0], reqVO.getTimes()[1])); | 264 | reqVO.setSqlDateFormat(getSqlDateFormat(reqVO.getTimes()[0], reqVO.getTimes()[1])); |
| 277 | - reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||
| 278 | - final List<CrmStatisticsCustomerDealCycleByDateRespVO> customerDealCycle = customerMapper.selectCustomerDealCycleGroupbyDate(reqVO); | ||
| 279 | - | ||
| 280 | - // 3. 获取时间序列 | ||
| 281 | - final List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); | 265 | + List<CrmStatisticsCustomerDealCycleByDateRespVO> customerDealCycle = customerMapper.selectCustomerDealCycleGroupByDate(reqVO); |
| 282 | 266 | ||
| 283 | - // 4. 合并统计数据 | ||
| 284 | - List<CrmStatisticsCustomerDealCycleByDateRespVO> respVoList = new ArrayList<>(times.size()); | ||
| 285 | - final Map<String, Double> customerDealCycleMap = convertMap(customerDealCycle, | 267 | + // 3. 合并统计数据 |
| 268 | + List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); | ||
| 269 | + Map<String, Double> customerDealCycleMap = convertMap(customerDealCycle, | ||
| 286 | CrmStatisticsCustomerDealCycleByDateRespVO::getTime, | 270 | CrmStatisticsCustomerDealCycleByDateRespVO::getTime, |
| 287 | CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle); | 271 | CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle); |
| 288 | - times.forEach(time -> respVoList.add( | 272 | + List<CrmStatisticsCustomerDealCycleByDateRespVO> respVoList = convertList(times, time -> |
| 289 | new CrmStatisticsCustomerDealCycleByDateRespVO().setTime(time) | 273 | new CrmStatisticsCustomerDealCycleByDateRespVO().setTime(time) |
| 290 | .setCustomerDealCycle(customerDealCycleMap.getOrDefault(time, 0D)) | 274 | .setCustomerDealCycle(customerDealCycleMap.getOrDefault(time, 0D)) |
| 291 | - )); | 275 | + ); |
| 276 | + | ||
| 292 | return respVoList; | 277 | return respVoList; |
| 293 | } | 278 | } |
| 294 | 279 | ||
| 295 | @Override | 280 | @Override |
| 296 | public List<CrmStatisticsCustomerDealCycleByUserRespVO> getCustomerDealCycleByUser(CrmStatisticsCustomerReqVO reqVO) { | 281 | public List<CrmStatisticsCustomerDealCycleByUserRespVO> getCustomerDealCycleByUser(CrmStatisticsCustomerReqVO reqVO) { |
| 297 | // 1. 获得用户编号数组 | 282 | // 1. 获得用户编号数组 |
| 298 | - final List<Long> userIds = getUserIds(reqVO); | 283 | + List<Long> userIds = getUserIds(reqVO); |
| 299 | if (CollUtil.isEmpty(userIds)) { | 284 | if (CollUtil.isEmpty(userIds)) { |
| 300 | return Collections.emptyList(); | 285 | return Collections.emptyList(); |
| 301 | } | 286 | } |
| 302 | reqVO.setUserIds(userIds); | 287 | reqVO.setUserIds(userIds); |
| 303 | 288 | ||
| 304 | // 2. 获取分项统计数据 | 289 | // 2. 获取分项统计数据 |
| 305 | - reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||
| 306 | - final List<CrmStatisticsCustomerDealCycleByUserRespVO> customerDealCycle = customerMapper.selectCustomerDealCycleGroupbyUser(reqVO); | ||
| 307 | - final List<CrmStatisticsCustomerSummaryByUserRespVO> customerDealCount = customerMapper.selectCustomerDealCountGroupbyUser(reqVO); | 290 | + List<CrmStatisticsCustomerDealCycleByUserRespVO> customerDealCycle = customerMapper.selectCustomerDealCycleGroupByUser(reqVO); |
| 291 | + List<CrmStatisticsCustomerSummaryByUserRespVO> customerDealCount = customerMapper.selectCustomerDealCountGroupByUser(reqVO); | ||
| 308 | 292 | ||
| 309 | // 3. 合并统计数据 | 293 | // 3. 合并统计数据 |
| 310 | - final Map<Long, Double> customerDealCycleMap = convertMap(customerDealCycle, | 294 | + Map<Long, Double> customerDealCycleMap = convertMap(customerDealCycle, |
| 311 | CrmStatisticsCustomerDealCycleByUserRespVO::getOwnerUserId, | 295 | CrmStatisticsCustomerDealCycleByUserRespVO::getOwnerUserId, |
| 312 | CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle); | 296 | CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle); |
| 313 | - final Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount, | 297 | + Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount, |
| 314 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, | 298 | CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, |
| 315 | CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); | 299 | CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); |
| 316 | - List<CrmStatisticsCustomerDealCycleByUserRespVO> respVoList = new ArrayList<>(userIds.size()); | ||
| 317 | - userIds.forEach(userId -> { | ||
| 318 | - final CrmStatisticsCustomerDealCycleByUserRespVO vo = new CrmStatisticsCustomerDealCycleByUserRespVO() | 300 | + List<CrmStatisticsCustomerDealCycleByUserRespVO> respVoList = convertList(userIds, userId -> { |
| 301 | + CrmStatisticsCustomerDealCycleByUserRespVO vo = new CrmStatisticsCustomerDealCycleByUserRespVO() | ||
| 319 | .setCustomerDealCycle(customerDealCycleMap.getOrDefault(userId, 0.0)) | 302 | .setCustomerDealCycle(customerDealCycleMap.getOrDefault(userId, 0.0)) |
| 320 | .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0)); | 303 | .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0)); |
| 304 | + // ownerUserId 为基类属性 | ||
| 321 | vo.setOwnerUserId(userId); | 305 | vo.setOwnerUserId(userId); |
| 322 | - respVoList.add(vo); | 306 | + return vo; |
| 323 | }); | 307 | }); |
| 324 | 308 | ||
| 325 | // 4. 拼接用户信息 | 309 | // 4. 拼接用户信息 |
| @@ -335,8 +319,9 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -335,8 +319,9 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 335 | */ | 319 | */ |
| 336 | private <T extends CrmStatisticsCustomerByUserBaseRespVO> void appendUserInfo(List<T> respVoList) { | 320 | private <T extends CrmStatisticsCustomerByUserBaseRespVO> void appendUserInfo(List<T> respVoList) { |
| 337 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(respVoList, | 321 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(respVoList, |
| 338 | - CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId)); | ||
| 339 | - respVoList.forEach(vo -> MapUtils.findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname()))); | 322 | + CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId)); |
| 323 | + respVoList.forEach(vo -> MapUtils.findAndThen(userMap, | ||
| 324 | + vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname()))); | ||
| 340 | } | 325 | } |
| 341 | 326 | ||
| 342 | /** | 327 | /** |
| @@ -352,7 +337,7 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | @@ -352,7 +337,7 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||
| 352 | } | 337 | } |
| 353 | // 情况二:选中某个部门 | 338 | // 情况二:选中某个部门 |
| 354 | // 2.1 获得部门列表 | 339 | // 2.1 获得部门列表 |
| 355 | - final Long deptId = reqVO.getDeptId(); | 340 | + Long deptId = reqVO.getDeptId(); |
| 356 | List<Long> deptIds = convertList(deptApi.getChildDeptList(deptId), DeptRespDTO::getId); | 341 | List<Long> deptIds = convertList(deptApi.getChildDeptList(deptId), DeptRespDTO::getId); |
| 357 | deptIds.add(deptId); | 342 | deptIds.add(deptId); |
| 358 | // 2.2 获得用户编号 | 343 | // 2.2 获得用户编号 |
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml
| @@ -2,251 +2,233 @@ | @@ -2,251 +2,233 @@ | ||
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | <mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper"> | 3 | <mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper"> |
| 4 | 4 | ||
| 5 | - <!-- TODO @dhb52:数据库的关键字,进行大写。例如说,COUNT --> | ||
| 6 | - | ||
| 7 | - <select id="selectCustomerCreateCountGroupbyDate" | 5 | + <select id="selectCustomerCreateCountGroupByDate" |
| 8 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByDateRespVO"> | 6 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByDateRespVO"> |
| 9 | SELECT | 7 | SELECT |
| 10 | - <!-- TODO @dhb52:下面这个,缩进一个 tab;这样可读性更好哈 --> | ||
| 11 | - DATE_FORMAT( create_time, #{sqlDateFormat} ) AS time, | ||
| 12 | - COUNT(*) AS customerCreateCount | ||
| 13 | - FROM crm_customer | ||
| 14 | - WHERE deleted = 0 | ||
| 15 | - AND owner_user_id IN | ||
| 16 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 17 | - #{userId} | ||
| 18 | - </foreach> | ||
| 19 | - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 20 | - <!-- TODO @dhb52:这可以考虑不换行,直接跟在后面的 AND,更连贯哈; --> | ||
| 21 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 22 | - GROUP BY time | 8 | + DATE_FORMAT( create_time, #{sqlDateFormat} ) AS time, |
| 9 | + COUNT(*) AS customerCreateCount | ||
| 10 | + FROM crm_customer | ||
| 11 | + WHERE deleted = 0 | ||
| 12 | + AND owner_user_id IN | ||
| 13 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 14 | + #{userId} | ||
| 15 | + </foreach> | ||
| 16 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 17 | + GROUP BY time | ||
| 23 | </select> | 18 | </select> |
| 24 | 19 | ||
| 25 | - <select id="selectCustomerDealCountGroupbyDate" | 20 | + <select id="selectCustomerDealCountGroupByDate" |
| 26 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByDateRespVO"> | 21 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByDateRespVO"> |
| 27 | SELECT | 22 | SELECT |
| 28 | - <!-- TODO @dhb52:下面这个,缩进一个 tab;这样可读性更好哈 --> | ||
| 29 | - <!-- TODO @dhb52:表变量最好不要用 a、b;可以用 customer 和 constract;虽然长一点,但是一眼看的清楚哈 --> | ||
| 30 | - DATE_FORMAT( b.order_date, #{sqlDateFormat} ) AS time, | ||
| 31 | - count( DISTINCT a.id ) AS customerDealCount | ||
| 32 | - FROM crm_customer AS a | ||
| 33 | - LEFT JOIN crm_contract AS b ON b.customer_id = a.id | ||
| 34 | - WHERE a.deleted = 0 AND b.deleted = 0 | ||
| 35 | - AND b.audit_status = 20 | ||
| 36 | - AND a.owner_user_id IN | ||
| 37 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 38 | - #{userId} | ||
| 39 | - </foreach> | ||
| 40 | - <!-- TODO @dhb52:这个应该是 order_date 的范围哈;貌似如果改成这样,不需要查询 customer 表,只要 contract 表就 ok 拉 --> | ||
| 41 | - AND b.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 42 | - #{times[1],javaType=java.time.LocalDateTime} | 23 | + DATE_FORMAT( order_date, #{sqlDateFormat} ) AS time, |
| 24 | + COUNT( DISTINCT customer_id ) AS customerDealCount | ||
| 25 | + FROM crm_contract | ||
| 26 | + WHERE deleted = 0 | ||
| 27 | + AND audit_status = 20 | ||
| 28 | + AND owner_user_id IN | ||
| 29 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 30 | + #{userId} | ||
| 31 | + </foreach> | ||
| 32 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 43 | GROUP BY time | 33 | GROUP BY time |
| 44 | </select> | 34 | </select> |
| 45 | 35 | ||
| 46 | - <!-- TODO @dhb52:根据上面建议,进行优化 --> | ||
| 47 | - <select id="selectCustomerCreateCountGroupbyUser" | 36 | + <select id="selectCustomerCreateCountGroupByUser" |
| 48 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> | 37 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> |
| 49 | - SELECT owner_user_id, COUNT(1) AS customer_create_count | ||
| 50 | - FROM crm_customer | ||
| 51 | - WHERE deleted = 0 | ||
| 52 | - AND owner_user_id in | ||
| 53 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 54 | - #{userId} | ||
| 55 | - </foreach> | ||
| 56 | - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 57 | - #{times[1],javaType=java.time.LocalDateTime} | 38 | + SELECT |
| 39 | + owner_user_id, | ||
| 40 | + COUNT(1) AS customer_create_count | ||
| 41 | + FROM crm_customer | ||
| 42 | + WHERE deleted = 0 | ||
| 43 | + AND owner_user_id in | ||
| 44 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 45 | + #{userId} | ||
| 46 | + </foreach> | ||
| 47 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 58 | GROUP BY owner_user_id | 48 | GROUP BY owner_user_id |
| 59 | </select> | 49 | </select> |
| 60 | 50 | ||
| 61 | - <!-- TODO @dhb52:根据上面建议,进行优化 --> | ||
| 62 | - <select id="selectCustomerDealCountGroupbyUser" | 51 | + <select id="selectCustomerDealCountGroupByUser" |
| 63 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> | 52 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> |
| 64 | - SELECT a.owner_user_id, count( DISTINCT a.id ) AS customer_deal_count | ||
| 65 | - FROM crm_customer AS a | ||
| 66 | - LEFT JOIN crm_contract AS b ON b.customer_id = a.id | ||
| 67 | - WHERE a.deleted = 0 AND b.deleted = 0 | ||
| 68 | - AND b.audit_status = 20 | ||
| 69 | - AND a.owner_user_id IN | ||
| 70 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 71 | - #{userId} | ||
| 72 | - </foreach> | ||
| 73 | - AND b.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 74 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 75 | - GROUP BY a.owner_user_id | 53 | + SELECT |
| 54 | + customer.owner_user_id, | ||
| 55 | + COUNT( DISTINCT customer.id ) AS customer_deal_count | ||
| 56 | + FROM crm_customer AS customer | ||
| 57 | + LEFT JOIN crm_contract AS contract ON contract.customer_id = customer.id | ||
| 58 | + WHERE customer.deleted = 0 AND contract.deleted = 0 | ||
| 59 | + AND contract.audit_status = 20 | ||
| 60 | + AND customer.owner_user_id IN | ||
| 61 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 62 | + #{userId} | ||
| 63 | + </foreach> | ||
| 64 | + AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 65 | + GROUP BY customer.owner_user_id | ||
| 76 | </select> | 66 | </select> |
| 77 | 67 | ||
| 78 | - <!-- TODO @dhb52:根据上面建议,进行优化 --> | ||
| 79 | - <select id="selectContractPriceGroupbyUser" | 68 | + <select id="selectContractPriceGroupByUser" |
| 80 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> | 69 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> |
| 81 | - SELECT owner_user_id, IFNULL(SUM(total_price), 0) AS contract_price | ||
| 82 | - FROM crm_contract | ||
| 83 | - WHERE deleted = 0 | ||
| 84 | - AND audit_status = 20 | ||
| 85 | - AND owner_user_id in | ||
| 86 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 87 | - #{userId} | ||
| 88 | - </foreach> | ||
| 89 | - AND order_date BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 90 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 91 | - GROUP BY owner_user_id | 70 | + SELECT |
| 71 | + owner_user_id, | ||
| 72 | + IFNULL(SUM(total_price), 0) AS contract_price | ||
| 73 | + FROM crm_contract | ||
| 74 | + WHERE deleted = 0 | ||
| 75 | + AND audit_status = 20 | ||
| 76 | + AND owner_user_id in | ||
| 77 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 78 | + #{userId} | ||
| 79 | + </foreach> | ||
| 80 | + AND order_date BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 81 | + GROUP BY owner_user_id | ||
| 92 | </select> | 82 | </select> |
| 93 | 83 | ||
| 94 | - | ||
| 95 | - <!-- TODO @dhb52:根据上面建议,进行优化 --> | ||
| 96 | - <select id="selectReceivablePriceGroupbyUser" | 84 | + <select id="selectReceivablePriceGroupByUser" |
| 97 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> | 85 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByUserRespVO"> |
| 98 | - SELECT owner_user_id, | ||
| 99 | - IFNULL(SUM(price), 0) AS receivable_price | ||
| 100 | - FROM crm_receivable | ||
| 101 | - WHERE deleted = 0 | ||
| 102 | - AND audit_status = 20 | ||
| 103 | - AND owner_user_id IN | ||
| 104 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 105 | - #{userId} | ||
| 106 | - </foreach> | ||
| 107 | - AND return_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 108 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 109 | - GROUP BY owner_user_id | 86 | + SELECT |
| 87 | + owner_user_id, | ||
| 88 | + IFNULL(SUM(price), 0) AS receivable_price | ||
| 89 | + FROM crm_receivable | ||
| 90 | + WHERE deleted = 0 | ||
| 91 | + AND audit_status = 20 | ||
| 92 | + AND owner_user_id IN | ||
| 93 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 94 | + #{userId} | ||
| 95 | + </foreach> | ||
| 96 | + AND return_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 97 | + GROUP BY owner_user_id | ||
| 110 | </select> | 98 | </select> |
| 111 | 99 | ||
| 112 | - <select id="selectFollowupRecordCountGroupbyDate" | 100 | + <select id="selectFollowupRecordCountGroupByDate" |
| 113 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByDateRespVO"> | 101 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByDateRespVO"> |
| 114 | - SELECT DATE_FORMAT( create_time, #{sqlDateFormat} ) AS time, | ||
| 115 | - count(*) AS followup_record_count | ||
| 116 | - FROM crm_follow_up_record | ||
| 117 | - WHERE creator IN | ||
| 118 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 119 | - #{userId} | ||
| 120 | - </foreach> | ||
| 121 | - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 122 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 123 | - AND biz_type = #{bizType} | ||
| 124 | - GROUP BY time | 102 | + SELECT |
| 103 | + DATE_FORMAT( create_time, #{sqlDateFormat} ) AS time, | ||
| 104 | + COUNT(*) AS followup_record_count | ||
| 105 | + FROM crm_follow_up_record | ||
| 106 | + WHERE creator IN | ||
| 107 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 108 | + #{userId} | ||
| 109 | + </foreach> | ||
| 110 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 111 | + AND biz_type = ${@cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum@CRM_CUSTOMER.type} | ||
| 112 | + GROUP BY time | ||
| 125 | </select> | 113 | </select> |
| 126 | 114 | ||
| 127 | - <select id="selectFollowupCustomerCountGroupbyDate" | 115 | + <select id="selectFollowupCustomerCountGroupByDate" |
| 128 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByDateRespVO"> | 116 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByDateRespVO"> |
| 129 | SELECT | 117 | SELECT |
| 130 | - DATE_FORMAT( create_time, #{sqlDateFormat} ) AS time, | ||
| 131 | - count(DISTINCT biz_id) AS followup_customer_count | ||
| 132 | - FROM crm_follow_up_record | ||
| 133 | - WHERE creator IN | ||
| 134 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 135 | - #{userId} | ||
| 136 | - </foreach> | ||
| 137 | - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 138 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 139 | - AND biz_type = #{bizType} | ||
| 140 | - GROUP BY time | 118 | + DATE_FORMAT( create_time, #{sqlDateFormat} ) AS time, |
| 119 | + COUNT(DISTINCT biz_id) AS followup_customer_count | ||
| 120 | + FROM crm_follow_up_record | ||
| 121 | + WHERE creator IN | ||
| 122 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 123 | + #{userId} | ||
| 124 | + </foreach> | ||
| 125 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 126 | + AND biz_type = ${@cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum@CRM_CUSTOMER.type} | ||
| 127 | + GROUP BY time | ||
| 141 | </select> | 128 | </select> |
| 142 | 129 | ||
| 143 | - <select id="selectFollowupRecordCountGroupbyUser" | 130 | + <select id="selectFollowupRecordCountGroupByUser" |
| 144 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByUserRespVO"> | 131 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByUserRespVO"> |
| 145 | - SELECT creator as owner_user_id, | ||
| 146 | - count(*) AS followup_record_count | ||
| 147 | - FROM crm_follow_up_record | ||
| 148 | - WHERE creator IN | ||
| 149 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 150 | - #{userId} | ||
| 151 | - </foreach> | ||
| 152 | - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 153 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 154 | - AND biz_type = #{bizType} | ||
| 155 | - GROUP BY creator | 132 | + SELECT |
| 133 | + creator as owner_user_id, | ||
| 134 | + COUNT(*) AS followup_record_count | ||
| 135 | + FROM crm_follow_up_record | ||
| 136 | + WHERE creator IN | ||
| 137 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 138 | + #{userId} | ||
| 139 | + </foreach> | ||
| 140 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 141 | + AND biz_type = ${@cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum@CRM_CUSTOMER.type} | ||
| 142 | + GROUP BY creator | ||
| 156 | </select> | 143 | </select> |
| 157 | 144 | ||
| 158 | - <select id="selectFollowupCustomerCountGroupbyUser" | 145 | + <select id="selectFollowupCustomerCountGroupByUser" |
| 159 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByUserRespVO"> | 146 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByUserRespVO"> |
| 160 | - SELECT creator as owner_user_id, | ||
| 161 | - count(DISTINCT biz_id) AS followup_customer_count | ||
| 162 | - FROM crm_follow_up_record | ||
| 163 | - WHERE creator IN | ||
| 164 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 165 | - #{userId} | ||
| 166 | - </foreach> | ||
| 167 | - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 168 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 169 | - AND biz_type = #{bizType} | ||
| 170 | - GROUP BY creator | 147 | + SELECT |
| 148 | + creator as owner_user_id, | ||
| 149 | + COUNT(DISTINCT biz_id) AS followup_customer_count | ||
| 150 | + FROM crm_follow_up_record | ||
| 151 | + WHERE creator IN | ||
| 152 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 153 | + #{userId} | ||
| 154 | + </foreach> | ||
| 155 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 156 | + AND biz_type = ${@cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum@CRM_CUSTOMER.type} | ||
| 157 | + GROUP BY creator | ||
| 171 | </select> | 158 | </select> |
| 172 | 159 | ||
| 173 | - <select id="selectFollowupRecordCountGroupbyType" | 160 | + <select id="selectFollowupRecordCountGroupByType" |
| 174 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByTypeRespVO"> | 161 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsFollowupSummaryByTypeRespVO"> |
| 175 | SELECT | 162 | SELECT |
| 176 | - type AS followupType, | ||
| 177 | - count(*) AS followup_record_count | ||
| 178 | - FROM crm_follow_up_record | ||
| 179 | - WHERE creator IN | ||
| 180 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 181 | - #{userId} | ||
| 182 | - </foreach> | ||
| 183 | - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 184 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 185 | - AND biz_type = #{bizType} | ||
| 186 | - GROUP BY followupType | 163 | + type AS followupType, |
| 164 | + COUNT(*) AS followup_record_count | ||
| 165 | + FROM crm_follow_up_record | ||
| 166 | + WHERE creator IN | ||
| 167 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 168 | + #{userId} | ||
| 169 | + </foreach> | ||
| 170 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 171 | + AND biz_type = ${@cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum@CRM_CUSTOMER.type} | ||
| 172 | + GROUP BY followupType | ||
| 187 | </select> | 173 | </select> |
| 188 | 174 | ||
| 189 | <select id="selectContractSummary" | 175 | <select id="selectContractSummary" |
| 190 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerContractSummaryRespVO"> | 176 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerContractSummaryRespVO"> |
| 191 | SELECT | 177 | SELECT |
| 192 | - a.`name` AS customer_name, | ||
| 193 | - b.`name` AS contract_name, | ||
| 194 | - b.total_price, | ||
| 195 | - IFNULL( c.price, 0 ) AS receivable_price, | ||
| 196 | - a.industry_id, | ||
| 197 | - a.source, | ||
| 198 | - a.owner_user_id, | ||
| 199 | - a.creator AS creator_user_id, | ||
| 200 | - a.create_time, | ||
| 201 | - b.order_date | ||
| 202 | - FROM | ||
| 203 | - crm_customer AS a | ||
| 204 | - INNER JOIN crm_contract AS b ON a.id = b.customer_id | ||
| 205 | - LEFT JOIN crm_receivable AS c ON b.id = c.contract_id | ||
| 206 | - WHERE a.deleted = 0 AND b.deleted = 0 AND c.deleted = 0 | ||
| 207 | - AND b.audit_status = 20 | ||
| 208 | - AND a.owner_user_id IN | ||
| 209 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 210 | - #{userId} | ||
| 211 | - </foreach> | ||
| 212 | - AND b.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 213 | - #{times[1],javaType=java.time.LocalDateTime} | 178 | + customer.`name` AS customer_name, |
| 179 | + contract.`name` AS contract_name, | ||
| 180 | + contract.total_price, | ||
| 181 | + IFNULL( receivable.price, 0 ) AS receivable_price, | ||
| 182 | + customer.industry_id, | ||
| 183 | + customer.source, | ||
| 184 | + customer.owner_user_id, | ||
| 185 | + customer.creator AS creator_user_id, | ||
| 186 | + customer.create_time, | ||
| 187 | + contract.order_date | ||
| 188 | + FROM crm_customer AS customer | ||
| 189 | + INNER JOIN crm_contract AS contract ON customer.id = contract.customer_id | ||
| 190 | + LEFT JOIN crm_receivable AS receivable ON contract.id = receivable.contract_id | ||
| 191 | + WHERE customer.deleted = 0 AND contract.deleted = 0 AND receivable.deleted = 0 | ||
| 192 | + AND contract.audit_status = 20 | ||
| 193 | + AND customer.owner_user_id IN | ||
| 194 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 195 | + #{userId} | ||
| 196 | + </foreach> | ||
| 197 | + AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 214 | </select> | 198 | </select> |
| 215 | 199 | ||
| 216 | - <select id="selectCustomerDealCycleGroupbyDate" | 200 | + <select id="selectCustomerDealCycleGroupByDate" |
| 217 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerDealCycleByDateRespVO"> | 201 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerDealCycleByDateRespVO"> |
| 218 | SELECT | 202 | SELECT |
| 219 | - DATE_FORMAT( b.order_date, #{sqlDateFormat} ) AS time, | ||
| 220 | - IFNULL( TRUNCATE ( AVG( TIMESTAMPDIFF( DAY, a.create_time, b.order_date )), 1 ), 0 ) AS customer_deal_cycle | ||
| 221 | - FROM crm_customer AS a | ||
| 222 | - LEFT JOIN crm_contract AS b ON b.customer_id = a.id | ||
| 223 | - WHERE a.deleted = 0 AND b.deleted = 0 | ||
| 224 | - AND b.audit_status = 20 | ||
| 225 | - AND a.owner_user_id IN | ||
| 226 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 227 | - #{userId} | ||
| 228 | - </foreach> | ||
| 229 | - AND b.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 230 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 231 | - GROUP BY time | 203 | + DATE_FORMAT( contract.order_date, #{sqlDateFormat} ) AS time, |
| 204 | + IFNULL( TRUNCATE ( AVG( TIMESTAMPDIFF( DAY, customer.create_time, contract.order_date )), 1 ), 0 ) AS customer_deal_cycle | ||
| 205 | + FROM crm_customer AS customer | ||
| 206 | + LEFT JOIN crm_contract AS contract ON contract.customer_id = customer.id | ||
| 207 | + WHERE customer.deleted = 0 AND contract.deleted = 0 | ||
| 208 | + AND contract.audit_status = 20 | ||
| 209 | + AND customer.owner_user_id IN | ||
| 210 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 211 | + #{userId} | ||
| 212 | + </foreach> | ||
| 213 | + AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 214 | + GROUP BY time | ||
| 232 | </select> | 215 | </select> |
| 233 | 216 | ||
| 234 | - <select id="selectCustomerDealCycleGroupbyUser" | 217 | + <select id="selectCustomerDealCycleGroupByUser" |
| 235 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerDealCycleByUserRespVO"> | 218 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerDealCycleByUserRespVO"> |
| 236 | SELECT | 219 | SELECT |
| 237 | - a.owner_user_id, | ||
| 238 | - IFNULL( TRUNCATE ( AVG( TIMESTAMPDIFF( DAY, a.create_time, b.order_date )), 1 ), 0 ) AS customer_deal_cycle | ||
| 239 | - FROM crm_customer AS a | ||
| 240 | - LEFT JOIN crm_contract AS b ON b.customer_id = a.id | ||
| 241 | - WHERE a.deleted = 0 AND b.deleted = 0 | ||
| 242 | - AND b.audit_status = 20 | ||
| 243 | - AND a.owner_user_id IN | ||
| 244 | - <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 245 | - #{userId} | ||
| 246 | - </foreach> | ||
| 247 | - AND b.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||
| 248 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 249 | - GROUP BY a.owner_user_id | 220 | + customer.owner_user_id, |
| 221 | + IFNULL( TRUNCATE ( AVG( TIMESTAMPDIFF( DAY, customer.create_time, contract.order_date )), 1 ), 0 ) AS customer_deal_cycle | ||
| 222 | + FROM crm_customer AS customer | ||
| 223 | + LEFT JOIN crm_contract AS contract ON contract.customer_id = customer.id | ||
| 224 | + WHERE customer.deleted = 0 AND contract.deleted = 0 | ||
| 225 | + AND contract.audit_status = 20 | ||
| 226 | + AND customer.owner_user_id IN | ||
| 227 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||
| 228 | + #{userId} | ||
| 229 | + </foreach> | ||
| 230 | + AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} | ||
| 231 | + GROUP BY customer.owner_user_id | ||
| 250 | </select> | 232 | </select> |
| 251 | 233 | ||
| 252 | </mapper> | 234 | </mapper> |