From 0386820a1c80354917afe20e31cc5048a1f5be3d Mon Sep 17 00:00:00 2001 From: dhb52 Date: Tue, 5 Mar 2024 23:16:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0[=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E8=A1=8C=E4=B8=9A=E3=80=81=E5=AE=A2=E6=88=B7=E6=9D=A5=E6=BA=90?= =?UTF-8?q?]=E7=AD=89=E5=AD=97=E6=AE=B5=E6=98=BE=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/customer/CrmCustomerController.java | 2 +- ...CrmStatisticsCustomerByUserBaseRespVO.java | 2 + ...atisticsCustomerContractSummaryRespVO.java | 22 ++- ...StatisticsCustomerSummaryByUserRespVO.java | 4 +- .../CrmStatisticsCustomerServiceImpl.java | 177 +++++++++++------- .../CrmStatisticsCustomerMapper.xml | 4 +- 6 files changed, 138 insertions(+), 73 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index 36b3ee813..a4adeee3e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -142,7 +142,7 @@ public class CrmCustomerController { return java.util.Collections.emptyList(); } // 1.1 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(list, + Map userMap = adminUserApi.getUserMap(convertSetByFlatMap(list, contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); // 1.2 获取距离进入公海的时间 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java index 82f74f230..340e93066 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -10,6 +11,7 @@ import lombok.Data; public class CrmStatisticsCustomerByUserBaseRespVO { @Schema(description = "负责人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @JsonIgnore private Long ownerUserId; @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java index 7cb02e521..019309f8e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java @@ -1,13 +1,18 @@ package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; + @Schema(description = "管理后台 - CRM 客户转化率分析 VO") @Data public class CrmStatisticsCustomerContractSummaryRespVO { @@ -24,20 +29,30 @@ public class CrmStatisticsCustomerContractSummaryRespVO { @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1200.00") private BigDecimal receivablePrice; + @Schema(description = "客户行业ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @JsonIgnore + private String industryId; + @Schema(description = "客户行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "金融") - private String customerType; + private String industryName; + + @Schema(description = "客户来源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @JsonIgnore + private String source; @Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "外呼") - private String customerSource; + private String sourceName; @Schema(description = "负责人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @JsonIgnore private Long ownerUserId; @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码") private String ownerUserName; @Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Long creatorUserId; + @JsonIgnore + private String creatorUserId; @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "源码") private String creatorUserName; @@ -46,6 +61,7 @@ public class CrmStatisticsCustomerContractSummaryRespVO { private LocalDateTime createTime; @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02 00:00:00") + @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT) private LocalDate orderDate; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java index ffa5e21ae..bd719a1b8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java @@ -16,9 +16,9 @@ public class CrmStatisticsCustomerSummaryByUserRespVO extends CrmStatisticsCusto private Integer customerDealCount = 0; @Schema(description = "合同总金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal contractPrice = BigDecimal.valueOf(0); + private BigDecimal contractPrice = BigDecimal.ZERO; @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") - private BigDecimal receivablePrice = BigDecimal.valueOf(0); + private BigDecimal receivablePrice = BigDecimal.ZERO; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java index 77bd0fcf6..6b664dce5 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; @@ -19,9 +20,14 @@ import org.springframework.validation.annotation.Validated; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.*; /** * CRM 客户分析 Service 实现类 @@ -68,16 +74,20 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe final List times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); // 4. 合并统计数据 - List result = new ArrayList<>(times.size()); - final Map customerCreateCountMap = convertMap(customerCreateCount, CrmStatisticsCustomerSummaryByDateRespVO::getTime, CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount); - final Map customerDealCountMap = convertMap(customerDealCount, CrmStatisticsCustomerSummaryByDateRespVO::getTime, CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount); - times.forEach(time -> result.add( + List respVoList = new ArrayList<>(times.size()); + final Map customerCreateCountMap = convertMap(customerCreateCount, + CrmStatisticsCustomerSummaryByDateRespVO::getTime, + CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount); + final Map customerDealCountMap = convertMap(customerDealCount, + CrmStatisticsCustomerSummaryByDateRespVO::getTime, + CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount); + times.forEach(time -> respVoList.add( new CrmStatisticsCustomerSummaryByDateRespVO().setTime(time) .setCustomerCreateCount(customerCreateCountMap.getOrDefault(time, 0)) .setCustomerDealCount(customerDealCountMap.getOrDefault(time, 0)) )); - return result; + return respVoList; } @Override @@ -96,25 +106,33 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe final List receivablePrice = customerMapper.selectReceivablePriceGroupbyUser(reqVO); // 3. 合并统计数据 - final Map customerCreateCountMap = convertMap(customerCreateCount, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount); - final Map customerDealCountMap = convertMap(customerDealCount, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); - final Map contractPriceMap = convertMap(contractPrice, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getContractPrice); - final Map receivablePriceMap = convertMap(receivablePrice, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getReceivablePrice); - List result = new ArrayList<>(userIds.size()); + final Map customerCreateCountMap = convertMap(customerCreateCount, + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, + CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount); + final Map customerDealCountMap = convertMap(customerDealCount, + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, + CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); + final Map contractPriceMap = convertMap(contractPrice, + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, + CrmStatisticsCustomerSummaryByUserRespVO::getContractPrice); + final Map receivablePriceMap = convertMap(receivablePrice, + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, + CrmStatisticsCustomerSummaryByUserRespVO::getReceivablePrice); + List respVoList = new ArrayList<>(userIds.size()); userIds.forEach(userId -> { - final CrmStatisticsCustomerSummaryByUserRespVO respVO = new CrmStatisticsCustomerSummaryByUserRespVO(); - respVO.setOwnerUserId(userId); - respVO.setCustomerCreateCount(customerCreateCountMap.getOrDefault(userId, 0)) + final CrmStatisticsCustomerSummaryByUserRespVO vo = new CrmStatisticsCustomerSummaryByUserRespVO(); + vo.setOwnerUserId(userId); + vo.setCustomerCreateCount(customerCreateCountMap.getOrDefault(userId, 0)) .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0)) - .setContractPrice(contractPriceMap.getOrDefault(userId, BigDecimal.valueOf(0))) - .setReceivablePrice(receivablePriceMap.getOrDefault(userId, BigDecimal.valueOf(0))); - result.add(respVO); + .setContractPrice(contractPriceMap.getOrDefault(userId, BigDecimal.ZERO)) + .setReceivablePrice(receivablePriceMap.getOrDefault(userId, BigDecimal.ZERO)); + respVoList.add(vo); }); // 4. 拼接用户信息 - appendUserInfo(result); + appendUserInfo(respVoList); - return result; + return respVoList; } @Override @@ -136,16 +154,20 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe final List times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); // 4. 合并统计数据 - List result = new ArrayList<>(times.size()); - final Map followupRecordCountMap = convertMap(followupRecordCount, CrmStatisticsFollowupSummaryByDateRespVO::getTime, CrmStatisticsFollowupSummaryByDateRespVO::getFollowupRecordCount); - final Map followupCustomerCountMap = convertMap(followupCustomerCount, CrmStatisticsFollowupSummaryByDateRespVO::getTime, CrmStatisticsFollowupSummaryByDateRespVO::getFollowupCustomerCount); - times.forEach(time -> result.add( + List respVoList = new ArrayList<>(times.size()); + final Map followupRecordCountMap = convertMap(followupRecordCount, + CrmStatisticsFollowupSummaryByDateRespVO::getTime, + CrmStatisticsFollowupSummaryByDateRespVO::getFollowupRecordCount); + final Map followupCustomerCountMap = convertMap(followupCustomerCount, + CrmStatisticsFollowupSummaryByDateRespVO::getTime, + CrmStatisticsFollowupSummaryByDateRespVO::getFollowupCustomerCount); + times.forEach(time -> respVoList.add( new CrmStatisticsFollowupSummaryByDateRespVO().setTime(time) .setFollowupRecordCount(followupRecordCountMap.getOrDefault(time, 0)) .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(time, 0)) )); - return result; + return respVoList; } @Override @@ -163,21 +185,25 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe final List followupCustomerCount = customerMapper.selectFollowupCustomerCountGroupbyUser(reqVO); // 3. 合并统计数据 - final Map followupRecordCountMap = convertMap(followupRecordCount, CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, CrmStatisticsFollowupSummaryByUserRespVO::getFollowupRecordCount); - final Map followupCustomerCountMap = convertMap(followupCustomerCount, CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, CrmStatisticsFollowupSummaryByUserRespVO::getFollowupCustomerCount); - List result = new ArrayList<>(userIds.size()); + final Map followupRecordCountMap = convertMap(followupRecordCount, + CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, + CrmStatisticsFollowupSummaryByUserRespVO::getFollowupRecordCount); + final Map followupCustomerCountMap = convertMap(followupCustomerCount, + CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, + CrmStatisticsFollowupSummaryByUserRespVO::getFollowupCustomerCount); + List respVoList = new ArrayList<>(userIds.size()); userIds.forEach(userId -> { - final CrmStatisticsFollowupSummaryByUserRespVO stat = new CrmStatisticsFollowupSummaryByUserRespVO() + final CrmStatisticsFollowupSummaryByUserRespVO vo = new CrmStatisticsFollowupSummaryByUserRespVO() .setFollowupRecordCount(followupRecordCountMap.getOrDefault(userId, 0)) .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(userId, 0)); - stat.setOwnerUserId(userId); - result.add(stat); + vo.setOwnerUserId(userId); + respVoList.add(vo); }); // 4. 拼接用户信息 - appendUserInfo(result); + appendUserInfo(respVoList); - return result; + return respVoList; } @Override @@ -191,16 +217,17 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe // 2. 获得排行数据 reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); - List stats = customerMapper.selectFollowupRecordCountGroupbyType(reqVO); + List respVoList = customerMapper.selectFollowupRecordCountGroupbyType(reqVO); // 3. 获取字典数据 - List followUpTypes = dictDataApi.getDictDataList("crm_follow_up_type"); - final Map followUpTypeMap = convertMap(followUpTypes, DictDataRespDTO::getValue, DictDataRespDTO::getLabel); - stats.forEach(stat -> { - stat.setFollowupType(followUpTypeMap.get(stat.getFollowupType())); + List followUpTypes = dictDataApi.getDictDataList(CRM_FOLLOW_UP_TYPE); + final Map followUpTypeMap = convertMap(followUpTypes, + DictDataRespDTO::getValue, DictDataRespDTO::getLabel); + respVoList.forEach(vo -> { + vo.setFollowupType(followUpTypeMap.get(vo.getFollowupType())); }); - return stats; + return respVoList; } @Override @@ -212,17 +239,29 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe } reqVO.setUserIds(userIds); - List contractSummary = customerMapper.selectContractSummary(reqVO); + // 2. 获取统计数据 + List respVoList = customerMapper.selectContractSummary(reqVO); - // 2. 拼接用户信息 - final Set userIdSet = new HashSet<>(); - userIdSet.addAll(userIds); - userIdSet.addAll(convertSet(contractSummary, CrmStatisticsCustomerContractSummaryRespVO::getCreatorUserId)); - final Map userMap = adminUserApi.getUserMap(userIdSet); - contractSummary.forEach(contract -> contract.setCreatorUserName(userMap.get(contract.getCreatorUserId()).getNickname()) - .setOwnerUserName(userMap.get(contract.getOwnerUserId()).getNickname())); + // 3. 设置 创建人、负责人、行业、来源 + // 获取客户所属行业 + Map industryMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_INDUSTRY), + DictDataRespDTO::getValue, DictDataRespDTO::getLabel); + // 获取客户来源 + Map sourceMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_SOURCE), + DictDataRespDTO::getValue, DictDataRespDTO::getLabel); + // 获取创建人、负责人列表 + Map userMap = adminUserApi.getUserMap(convertSetByFlatMap(respVoList, + vo -> Stream.of(NumberUtils.parseLong(vo.getCreatorUserId()), vo.getOwnerUserId()))); - return contractSummary; + respVoList.forEach(vo -> { + MapUtils.findAndThen(industryMap, vo.getIndustryId(), vo::setIndustryName); + MapUtils.findAndThen(sourceMap, vo.getSource(), vo::setSourceName); + MapUtils.findAndThen(userMap, NumberUtils.parseLong(vo.getCreatorUserId()), + user -> vo.setCreatorUserName(user.getNickname())); + MapUtils.findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname())); + }); + + return respVoList; } @Override @@ -243,14 +282,16 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe final List times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]); // 4. 合并统计数据 - List result = new ArrayList<>(times.size()); - final Map customerDealCycleMap = convertMap(customerDealCycle, CrmStatisticsCustomerDealCycleByDateRespVO::getTime, CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle); - times.forEach(time -> result.add( + List respVoList = new ArrayList<>(times.size()); + final Map customerDealCycleMap = convertMap(customerDealCycle, + CrmStatisticsCustomerDealCycleByDateRespVO::getTime, + CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle); + times.forEach(time -> respVoList.add( new CrmStatisticsCustomerDealCycleByDateRespVO().setTime(time) - .setCustomerDealCycle(customerDealCycleMap.getOrDefault(time, Double.valueOf(0))) + .setCustomerDealCycle(customerDealCycleMap.getOrDefault(time, 0D)) )); - return result; + return respVoList; } @Override @@ -268,33 +309,37 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe final List customerDealCount = customerMapper.selectCustomerDealCountGroupbyUser(reqVO); // 3. 合并统计数据 - final Map customerDealCycleMap = convertMap(customerDealCycle, CrmStatisticsCustomerDealCycleByUserRespVO::getOwnerUserId, CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle); - final Map customerDealCountMap = convertMap(customerDealCount, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); - List result = new ArrayList<>(userIds.size()); + final Map customerDealCycleMap = convertMap(customerDealCycle, + CrmStatisticsCustomerDealCycleByUserRespVO::getOwnerUserId, + CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle); + final Map customerDealCountMap = convertMap(customerDealCount, + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, + CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount); + List respVoList = new ArrayList<>(userIds.size()); userIds.forEach(userId -> { - final CrmStatisticsCustomerDealCycleByUserRespVO stat = new CrmStatisticsCustomerDealCycleByUserRespVO() + final CrmStatisticsCustomerDealCycleByUserRespVO vo = new CrmStatisticsCustomerDealCycleByUserRespVO() .setCustomerDealCycle(customerDealCycleMap.getOrDefault(userId, 0.0)) .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0)); - stat.setOwnerUserId(userId); - result.add(stat); + vo.setOwnerUserId(userId); + respVoList.add(vo); }); // 4. 拼接用户信息 - appendUserInfo(result); + appendUserInfo(respVoList); - return result; + return respVoList; } /** * 拼接用户信息(昵称) * - * @param stats 统计数据 + * @param respVoList 统计数据 */ - private void appendUserInfo(List stats) { - Map userMap = adminUserApi.getUserMap(convertSet(stats, CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId)); - stats.forEach(stat -> MapUtils.findAndThen(userMap, stat.getOwnerUserId(), user -> { - stat.setOwnerUserName(user.getNickname()); - })); + private void appendUserInfo(List respVoList) { + Map userMap = adminUserApi.getUserMap(convertSet(respVoList, + CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId)); + respVoList.forEach(vo -> MapUtils.findAndThen(userMap, + vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname()))); } /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml index c612d4a24..3fd52f3e7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml @@ -180,8 +180,10 @@ SELECT a.`name` AS customer_name, b.`name` AS contract_name, - b.total_price AS contract_price, + b.total_price, IFNULL( c.price, 0 ) AS receivable_price, + a.industry_id, + a.source, a.owner_user_id, a.creator AS creator_user_id, a.create_time,