Commit 6f95f37117a65fc65b25289130734fd154a70f00
1 parent
cd28128e
📖 CRM:code review 待进入公海的客户
Showing
2 changed files
with
15 additions
and
32 deletions
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 { | @@ -59,7 +59,6 @@ public class CrmCustomerController { | ||
| 59 | @Resource | 59 | @Resource |
| 60 | private AdminUserApi adminUserApi; | 60 | private AdminUserApi adminUserApi; |
| 61 | 61 | ||
| 62 | - | ||
| 63 | @PostMapping("/create") | 62 | @PostMapping("/create") |
| 64 | @Operation(summary = "创建客户") | 63 | @Operation(summary = "创建客户") |
| 65 | @PreAuthorize("@ss.hasPermission('crm:customer:create')") | 64 | @PreAuthorize("@ss.hasPermission('crm:customer:create')") |
| @@ -120,17 +119,16 @@ public class CrmCustomerController { | @@ -120,17 +119,16 @@ public class CrmCustomerController { | ||
| 120 | return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); | 119 | return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); |
| 121 | } | 120 | } |
| 122 | 121 | ||
| 123 | - | ||
| 124 | @GetMapping("/put-in-pool-remind-page") | 122 | @GetMapping("/put-in-pool-remind-page") |
| 125 | @Operation(summary = "获得待进入公海客户分页") | 123 | @Operation(summary = "获得待进入公海客户分页") |
| 126 | @PreAuthorize("@ss.hasPermission('crm:customer:query')") | 124 | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| 127 | public CommonResult<PageResult<CrmCustomerRespVO>> getPutInPoolRemindCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { | 125 | public CommonResult<PageResult<CrmCustomerRespVO>> getPutInPoolRemindCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |
| 128 | - // 获取公海配置 | 126 | + // 获取公海配置 TODO @dbh52:合并到 getPutInPoolRemindCustomerPage 会更合适哈; |
| 129 | CrmCustomerPoolConfigDO poolConfigDO = customerPoolConfigService.getCustomerPoolConfig(); | 127 | CrmCustomerPoolConfigDO poolConfigDO = customerPoolConfigService.getCustomerPoolConfig(); |
| 130 | if (ObjUtil.isNull(poolConfigDO) | 128 | if (ObjUtil.isNull(poolConfigDO) |
| 131 | || Boolean.FALSE.equals(poolConfigDO.getEnabled()) | 129 | || Boolean.FALSE.equals(poolConfigDO.getEnabled()) |
| 132 | || Boolean.FALSE.equals(poolConfigDO.getNotifyEnabled()) | 130 | || Boolean.FALSE.equals(poolConfigDO.getNotifyEnabled()) |
| 133 | - ) { | 131 | + ) { // TODO @dbh52:这个括号,一般不换行,在 java 这里; |
| 134 | throw exception(CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED); | 132 | throw exception(CUSTOMER_POOL_CONFIG_NOT_EXISTS_OR_DISABLED); |
| 135 | } | 133 | } |
| 136 | 134 | ||
| @@ -141,11 +139,11 @@ public class CrmCustomerController { | @@ -141,11 +139,11 @@ public class CrmCustomerController { | ||
| 141 | } | 139 | } |
| 142 | 140 | ||
| 143 | // 2. 拼接数据 | 141 | // 2. 拼接数据 |
| 142 | + // TODO @芋艿:合并 getCustomerPage 和 getPutInPoolRemindCustomerPage 的后置处理; | ||
| 144 | Map<Long, Long> poolDayMap = getPoolDayMap(pageResult.getList()); // 客户界面,需要查看距离进入公海的时间 | 143 | Map<Long, Long> poolDayMap = getPoolDayMap(pageResult.getList()); // 客户界面,需要查看距离进入公海的时间 |
| 145 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | 144 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 146 | convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); | 145 | convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); |
| 147 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); | 146 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); |
| 148 | - | ||
| 149 | return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); | 147 | return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); |
| 150 | } | 148 | } |
| 151 | 149 |
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<CrmCustomerDO> { | @@ -115,47 +115,32 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||
| 115 | // 拼接数据权限的查询条件 | 115 | // 拼接数据权限的查询条件 |
| 116 | CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), | 116 | CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), |
| 117 | CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); | 117 | CrmCustomerDO::getId, userId, pageReqVO.getSceneType(), null); |
| 118 | + // TODO @dhb52:lock 的情况,不需要提醒哈; | ||
| 118 | 119 | ||
| 119 | // 拼接自身的查询条件 | 120 | // 拼接自身的查询条件 |
| 120 | query.selectAll(CrmCustomerDO.class); | 121 | query.selectAll(CrmCustomerDO.class); |
| 121 | - | ||
| 122 | - // 未跟进放入公海天数 | ||
| 123 | - final Integer contactExpireDays = poolConfigDO.getContactExpireDays(); | ||
| 124 | - // 未成交放入公海天数 | ||
| 125 | - final Integer dealExpireDays = poolConfigDO.getDealExpireDays(); | ||
| 126 | - // 提前提醒天数 | ||
| 127 | - final Integer notifyDays = poolConfigDO.getNotifyDays(); | ||
| 128 | - | ||
| 129 | - // 未成交提醒日期区间 | ||
| 130 | - // dealExpireDays 开始提醒 | 122 | + // 情况一:未成交提醒日期区间 |
| 123 | + Integer dealExpireDays = poolConfigDO.getDealExpireDays(); | ||
| 131 | LocalDateTime startDealRemindDate = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()) | 124 | LocalDateTime startDealRemindDate = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()) |
| 132 | .minusDays(dealExpireDays); | 125 | .minusDays(dealExpireDays); |
| 133 | - // dealExpireDays - notifyDays 结束提醒 | ||
| 134 | LocalDateTime endDealRemindDate = LocalDateTimeUtil.endOfDay(LocalDateTime.now()) | 126 | LocalDateTime endDealRemindDate = LocalDateTimeUtil.endOfDay(LocalDateTime.now()) |
| 135 | - .minusDays(Math.max(dealExpireDays - notifyDays, 0)); | ||
| 136 | - | ||
| 137 | - // 未跟进提醒日期区间 | ||
| 138 | - // contactExpireDays 开始提醒 | 127 | + .minusDays(Math.max(dealExpireDays - poolConfigDO.getNotifyDays(), 0)); |
| 128 | + // 情况二:未跟进提醒日期区间 | ||
| 129 | + Integer contactExpireDays = poolConfigDO.getContactExpireDays(); | ||
| 139 | LocalDateTime startContactRemindDate = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()) | 130 | LocalDateTime startContactRemindDate = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()) |
| 140 | .minusDays(contactExpireDays); | 131 | .minusDays(contactExpireDays); |
| 141 | - // contactExpireDays - notifyDays 结束提醒 | ||
| 142 | LocalDateTime endContactRemindDate = LocalDateTimeUtil.endOfDay(LocalDateTime.now()) | 132 | LocalDateTime endContactRemindDate = LocalDateTimeUtil.endOfDay(LocalDateTime.now()) |
| 143 | - .minusDays(Math.max(contactExpireDays - notifyDays, 0)); | ||
| 144 | - | 133 | + .minusDays(Math.max(contactExpireDays - poolConfigDO.getNotifyDays(), 0)); |
| 145 | query | 134 | query |
| 146 | - // 1.1 未成交放入公海提醒 | 135 | + // 情况一:1. 未成交放入公海提醒 |
| 147 | .eq(CrmCustomerDO::getDealStatus, false) | 136 | .eq(CrmCustomerDO::getDealStatus, false) |
| 148 | .between(CrmCustomerDO::getCreateTime, startDealRemindDate, endDealRemindDate) | 137 | .between(CrmCustomerDO::getCreateTime, startDealRemindDate, endDealRemindDate) |
| 149 | - .or() | ||
| 150 | - // 1.2 未跟进放入公海提醒 | ||
| 151 | - // 1.2.1 ContactLastTime 为空 | 138 | + // 情况二:未跟进放入公海提醒 |
| 139 | + .or() // 2.1 contactLastTime 为空 TODO 芋艿:这个要不要搞个默认值; | ||
| 152 | .isNull(CrmCustomerDO::getContactLastTime) | 140 | .isNull(CrmCustomerDO::getContactLastTime) |
| 153 | .between(CrmCustomerDO::getCreateTime, startContactRemindDate, endContactRemindDate) | 141 | .between(CrmCustomerDO::getCreateTime, startContactRemindDate, endContactRemindDate) |
| 154 | - .or() | ||
| 155 | - // 1.2.2 ContactLastTime 不为空 | ||
| 156 | - .between(CrmCustomerDO::getContactLastTime, startContactRemindDate, endContactRemindDate) | ||
| 157 | - ; | ||
| 158 | - | 142 | + .or() // 2.2 ContactLastTime 不为空 |
| 143 | + .between(CrmCustomerDO::getContactLastTime, startContactRemindDate, endContactRemindDate); | ||
| 159 | return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); | 144 | return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); |
| 160 | } | 145 | } |
| 161 | 146 |