mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	✨ CRM:增加回款的待办事项逻辑
This commit is contained in:
		| @ -164,13 +164,6 @@ public class CrmReceivableController { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @GetMapping("/check-receivables-count") |  | ||||||
|     @Operation(summary = "获得待审核回款数量") |  | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:query')") |  | ||||||
|     public CommonResult<Long> getCheckReceivablesCount() { |  | ||||||
|         return success(receivableService.getCheckReceivablesCount(getLoginUserId())); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @PutMapping("/submit") |     @PutMapping("/submit") | ||||||
|     @Operation(summary = "提交回款审批") |     @Operation(summary = "提交回款审批") | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable:update')") |     @PreAuthorize("@ss.hasPermission('crm:receivable:update')") | ||||||
| @ -179,4 +172,11 @@ public class CrmReceivableController { | |||||||
|         return success(true); |         return success(true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/audit-count") | ||||||
|  |     @Operation(summary = "获得待审核回款数量") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('crm:receivable:query')") | ||||||
|  |     public CommonResult<Long> getAuditReceivableCount() { | ||||||
|  |         return success(receivableService.getAuditReceivableCount(getLoginUserId())); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -163,13 +163,6 @@ public class CrmReceivablePlanController { | |||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @GetMapping("/remind-receivable-plan-count") |  | ||||||
|     @Operation(summary = "获得待回款提醒数量") |  | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") |  | ||||||
|     public CommonResult<Long> getRemindReceivablesCount() { |  | ||||||
|         return success(receivablePlanService.getRemindReceivablePlanCount(getLoginUserId())); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @GetMapping("/simple-list") |     @GetMapping("/simple-list") | ||||||
|     @Operation(summary = "获得回款计划精简列表", description = "获得回款计划精简列表,主要用于前端的下拉选项") |     @Operation(summary = "获得回款计划精简列表", description = "获得回款计划精简列表,主要用于前端的下拉选项") | ||||||
|     @Parameters({ |     @Parameters({ | ||||||
| @ -187,4 +180,11 @@ public class CrmReceivablePlanController { | |||||||
|                 .setPrice(receivablePlan.getPrice()).setReturnType(receivablePlan.getReturnType()))); |                 .setPrice(receivablePlan.getPrice()).setReturnType(receivablePlan.getReturnType()))); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("/remind-count") | ||||||
|  |     @Operation(summary = "获得待回款提醒数量") | ||||||
|  |     @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") | ||||||
|  |     public CommonResult<Long> getReceivablePlanRemindCount() { | ||||||
|  |         return success(receivablePlanService.getReceivablePlanRemindCount(getLoginUserId())); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -68,13 +68,13 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> { | |||||||
|         return selectJoinList(CrmReceivableDO.class, query); |         return selectJoinList(CrmReceivableDO.class, query); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     default Long selectCheckReceivablesCount(Long userId) { |     default Long selectCountByAudit(Long userId) { | ||||||
|         MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>(); |         MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>(); | ||||||
|         // 我负责的 + 非公海 |         // 我负责的 + 非公海 | ||||||
|         CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), |         CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), | ||||||
|                 CrmReceivableDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); |                 CrmReceivableDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); | ||||||
|         // 未提交 or 审核不通过 |         // 未审核 | ||||||
|         query.in(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.DRAFT.getStatus(), CrmAuditStatusEnum.REJECT.getStatus()); |         query.eq(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.PROCESS.getStatus()); | ||||||
|         return selectCount(query); |         return selectCount(query); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -60,19 +60,16 @@ public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Backlog: 回款提醒类型 |         // Backlog: 回款提醒类型 | ||||||
|         // TODO: @dhb52 需要配置 提前提醒天数 |  | ||||||
|         int REMIND_DAYS = 20; |  | ||||||
|         LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); |         LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); | ||||||
|         LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); |  | ||||||
|         if (CrmReceivablePlanPageReqVO.REMIND_TYPE_NEEDED.equals(pageReqVO.getRemindType())) { // 待回款 |         if (CrmReceivablePlanPageReqVO.REMIND_TYPE_NEEDED.equals(pageReqVO.getRemindType())) { // 待回款 | ||||||
|             query.isNull(CrmReceivablePlanDO::getReceivableId) |             query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 | ||||||
|                     .between(CrmReceivablePlanDO::getReturnTime, beginOfToday, endOfToday.plusDays(REMIND_DAYS)); |                     .lt(CrmReceivablePlanDO::getReturnTime, beginOfToday) // 已逾期 | ||||||
|  |                     .lt(CrmReceivablePlanDO::getRemindTime, beginOfToday); // 今天开始提醒 | ||||||
|         } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_EXPIRED.equals(pageReqVO.getRemindType())) {  // 已逾期 |         } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_EXPIRED.equals(pageReqVO.getRemindType())) {  // 已逾期 | ||||||
|             query.isNull(CrmReceivablePlanDO::getReceivableId) |             query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 | ||||||
|                     .lt(CrmReceivablePlanDO::getReturnTime, endOfToday); |                     .ge(CrmReceivablePlanDO::getReturnTime, beginOfToday); // 已逾期 | ||||||
|         } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_RECEIVED.equals(pageReqVO.getRemindType())) { // 已回款 |         } else if (CrmReceivablePlanPageReqVO.REMIND_TYPE_RECEIVED.equals(pageReqVO.getRemindType())) { // 已回款 | ||||||
|             query.isNotNull(CrmReceivablePlanDO::getReceivableId) |             query.isNotNull(CrmReceivablePlanDO::getReceivableId); | ||||||
|                     .between(CrmReceivablePlanDO::getReturnTime, beginOfToday, endOfToday.plusDays(REMIND_DAYS)); |  | ||||||
|         } |         } | ||||||
|         return selectJoinPage(pageReqVO, CrmReceivablePlanDO.class, query); |         return selectJoinPage(pageReqVO, CrmReceivablePlanDO.class, query); | ||||||
|     } |     } | ||||||
| @ -86,20 +83,16 @@ public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO | |||||||
|         return selectJoinList(CrmReceivablePlanDO.class, query); |         return selectJoinList(CrmReceivablePlanDO.class, query); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     default Long selectRemindReceivablePlanCount(Long userId) { |     default Long selectReceivablePlanCountByRemind(Long userId) { | ||||||
|         MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>(); |         MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>(); | ||||||
|         // 我负责的 + 非公海 |         // 我负责的 + 非公海 | ||||||
|         CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), |         CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), | ||||||
|                 CrmReceivablePlanDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); |                 CrmReceivablePlanDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE); | ||||||
|         // TODO: @dhb52 需要配置 提前提醒天数 |         // 未回款 + 已逾期 + 今天开始提醒 | ||||||
|         int REMIND_DAYS = 20; |  | ||||||
|         LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); |         LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now()); | ||||||
|         LocalDateTime endOfToday = LocalDateTimeUtil.endOfDay(LocalDateTime.now()); |         query.isNull(CrmReceivablePlanDO::getReceivableId) // 未回款 | ||||||
|         query.isNull(CrmReceivablePlanDO::getReceivableId) |                 .lt(CrmReceivablePlanDO::getReturnTime, beginOfToday) // 已逾期 | ||||||
|                 .between(CrmReceivablePlanDO::getReturnTime, beginOfToday, endOfToday.plusDays(REMIND_DAYS)); |                 .lt(CrmReceivablePlanDO::getRemindTime, beginOfToday); // 今天开始提醒 | ||||||
|         // TODO return_time 小于现在; |  | ||||||
|         // TODO 未回款 |  | ||||||
|         // TODO remind_time 大于现在; |  | ||||||
|         return selectCount(query); |         return selectCount(query); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| /** | /** | ||||||
|  * TODO 芋艿:临时占位,后续可删除 |  * 定时任务 | ||||||
|  */ |  */ | ||||||
| package cn.iocoder.yudao.module.crm.job; | package cn.iocoder.yudao.module.crm.job; | ||||||
| @ -222,7 +222,7 @@ public class CrmContractServiceImpl implements CrmContractService { | |||||||
|             success = CRM_CONTRACT_DELETE_SUCCESS) |             success = CRM_CONTRACT_DELETE_SUCCESS) | ||||||
|     @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) |     @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) | ||||||
|     public void deleteContract(Long id) { |     public void deleteContract(Long id) { | ||||||
|         // TODO @合同待定:如果被 CrmReceivableDO 所使用,则不允许删除 |         // TODO @puhui999:如果被 CrmReceivableDO 所使用,则不允许删除 | ||||||
|         // 校验存在 |         // 校验存在 | ||||||
|         CrmContractDO contract = validateContractExists(id); |         CrmContractDO contract = validateContractExists(id); | ||||||
|         // 删除 |         // 删除 | ||||||
|  | |||||||
| @ -90,6 +90,6 @@ public interface CrmReceivablePlanService { | |||||||
|      * @param userId 用户编号 |      * @param userId 用户编号 | ||||||
|      * @return 提醒数量 |      * @return 提醒数量 | ||||||
|      */ |      */ | ||||||
|     Long getRemindReceivablePlanCount(Long userId); |     Long getReceivablePlanRemindCount(Long userId); | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -184,8 +184,8 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Long getRemindReceivablePlanCount(Long userId) { |     public Long getReceivablePlanRemindCount(Long userId) { | ||||||
|         return receivablePlanMapper.selectRemindReceivablePlanCount(userId); |         return receivablePlanMapper.selectReceivablePlanCountByRemind(userId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -110,9 +110,9 @@ public interface CrmReceivableService { | |||||||
|      * 获得待审核回款数量 |      * 获得待审核回款数量 | ||||||
|      * |      * | ||||||
|      * @param userId 用户编号 |      * @param userId 用户编号 | ||||||
|      * @return 提醒数量 |      * @return 待审批数量 | ||||||
|      */ |      */ | ||||||
|     Long getCheckReceivablesCount(Long userId); |     Long getAuditReceivableCount(Long userId); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 获得合同已回款金额 Map |      * 获得合同已回款金额 Map | ||||||
|  | |||||||
| @ -212,7 +212,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | |||||||
|         if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) { |         if (receivable.getPlanId() != null && receivablePlanService.getReceivablePlan(receivable.getPlanId()) != null) { | ||||||
|             throw exception(RECEIVABLE_DELETE_FAIL); |             throw exception(RECEIVABLE_DELETE_FAIL); | ||||||
|         } |         } | ||||||
|         // TODO @芋艿:审批通过时,不允许删除; |         // TODO @puhui999:审批通过时,不允许删除; | ||||||
|  |  | ||||||
|         // 2. 删除 |         // 2. 删除 | ||||||
|         receivableMapper.deleteById(id); |         receivableMapper.deleteById(id); | ||||||
| @ -280,8 +280,8 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Long getCheckReceivablesCount(Long userId) { |     public Long getAuditReceivableCount(Long userId) { | ||||||
|         return receivableMapper.selectCheckReceivablesCount(userId); |         return receivableMapper.selectCountByAudit(userId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV