mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	📖 CRM:code review 待进入公海的客户
This commit is contained in:
		| @@ -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<PageResult<CrmCustomerRespVO>> 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<Long, Long> poolDayMap = getPoolDayMap(pageResult.getList()); // 客户界面,需要查看距离进入公海的时间 | ||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | ||||
|                 convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); | ||||
|         Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); | ||||
|  | ||||
|         return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -115,47 +115,32 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||||
|         // 拼接数据权限的查询条件 | ||||
|         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); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV