From 6f95f37117a65fc65b25289130734fd154a70f00 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 30 Jan 2024 12:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9Acode=20review=20?= =?UTF-8?q?=E5=BE=85=E8=BF=9B=E5=85=A5=E5=85=AC=E6=B5=B7=E7=9A=84=E5=AE=A2?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/customer/CrmCustomerController.java | 8 ++-- .../dal/mysql/customer/CrmCustomerMapper.java | 39 ++++++------------- 2 files changed, 15 insertions(+), 32 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 84c669778..1eab89073 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 @@ -59,7 +59,6 @@ public class CrmCustomerController { @Resource private AdminUserApi adminUserApi; - @PostMapping("/create") @Operation(summary = "创建客户") @PreAuthorize("@ss.hasPermission('crm:customer:create')") @@ -120,17 +119,16 @@ public class CrmCustomerController { return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); } - @GetMapping("/put-in-pool-remind-page") @Operation(summary = "获得待进入公海客户分页") @PreAuthorize("@ss.hasPermission('crm:customer:query')") public CommonResult> getPutInPoolRemindCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { - // 获取公海配置 + // 获取公海配置 TODO @dbh52:合并到 getPutInPoolRemindCustomerPage 会更合适哈; CrmCustomerPoolConfigDO poolConfigDO = customerPoolConfigService.getCustomerPoolConfig(); if (ObjUtil.isNull(poolConfigDO) || Boolean.FALSE.equals(poolConfigDO.getEnabled()) || Boolean.FALSE.equals(poolConfigDO.getNotifyEnabled()) - ) { + ) { // TODO @dbh52:这个括号,一般不换行,在 java 这里; throw exception(CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED); } @@ -141,11 +139,11 @@ public class CrmCustomerController { } // 2. 拼接数据 + // TODO @芋艿:合并 getCustomerPage 和 getPutInPoolRemindCustomerPage 的后置处理; Map poolDayMap = getPoolDayMap(pageResult.getList()); // 客户界面,需要查看距离进入公海的时间 Map userMap = adminUserApi.getUserMap( convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); - return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java index db25dcff8..09ff70a79 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -115,47 +115,32 @@ public interface CrmCustomerMapper extends BaseMapperX { // 拼接数据权限的查询条件 CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); + // TODO @dhb52:lock 的情况,不需要提醒哈; // 拼接自身的查询条件 query.selectAll(CrmCustomerDO.class); - - // 未跟进放入公海天数 - final Integer contactExpireDays = poolConfigDO.getContactExpireDays(); - // 未成交放入公海天数 - final Integer dealExpireDays = poolConfigDO.getDealExpireDays(); - // 提前提醒天数 - final Integer notifyDays = poolConfigDO.getNotifyDays(); - - // 未成交提醒日期区间 - // dealExpireDays 开始提醒 + // 情况一:未成交提醒日期区间 + Integer dealExpireDays = poolConfigDO.getDealExpireDays(); LocalDateTime startDealRemindDate = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()) .minusDays(dealExpireDays); - // dealExpireDays - notifyDays 结束提醒 LocalDateTime endDealRemindDate = LocalDateTimeUtil.endOfDay(LocalDateTime.now()) - .minusDays(Math.max(dealExpireDays - notifyDays, 0)); - - // 未跟进提醒日期区间 - // contactExpireDays 开始提醒 + .minusDays(Math.max(dealExpireDays - poolConfigDO.getNotifyDays(), 0)); + // 情况二:未跟进提醒日期区间 + Integer contactExpireDays = poolConfigDO.getContactExpireDays(); LocalDateTime startContactRemindDate = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()) .minusDays(contactExpireDays); - // contactExpireDays - notifyDays 结束提醒 LocalDateTime endContactRemindDate = LocalDateTimeUtil.endOfDay(LocalDateTime.now()) - .minusDays(Math.max(contactExpireDays - notifyDays, 0)); - + .minusDays(Math.max(contactExpireDays - poolConfigDO.getNotifyDays(), 0)); query - // 1.1 未成交放入公海提醒 + // 情况一:1. 未成交放入公海提醒 .eq(CrmCustomerDO::getDealStatus, false) .between(CrmCustomerDO::getCreateTime, startDealRemindDate, endDealRemindDate) - .or() - // 1.2 未跟进放入公海提醒 - // 1.2.1 ContactLastTime 为空 + // 情况二:未跟进放入公海提醒 + .or() // 2.1 contactLastTime 为空 TODO 芋艿:这个要不要搞个默认值; .isNull(CrmCustomerDO::getContactLastTime) .between(CrmCustomerDO::getCreateTime, startContactRemindDate, endContactRemindDate) - .or() - // 1.2.2 ContactLastTime 不为空 - .between(CrmCustomerDO::getContactLastTime, startContactRemindDate, endContactRemindDate) - ; - + .or() // 2.2 ContactLastTime 不为空 + .between(CrmCustomerDO::getContactLastTime, startContactRemindDate, endContactRemindDate); return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); }