diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java index 0894b43df..2290d7307 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.operatelog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogPageReqVO; +import cn.iocoder.yudao.module.crm.enums.LogRecordConstants; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO; @@ -25,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; -@Tag(name = "管理后台 - 操作日志") +@Tag(name = "管理后台 - CRM 操作日志") @RestController @RequestMapping("/crm/operate-log") @Validated @@ -34,6 +35,9 @@ public class CrmOperateLogController { @Resource private OperateLogApi operateLogApi; + /** + * {@link CrmBizTypeEnum} 与 {@link LogRecordConstants} 的映射关系 + */ private static final Map BIZ_TYPE_MAP = new HashMap<>(); static { @@ -47,6 +51,7 @@ public class CrmOperateLogController { BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), CRM_RECEIVABLE_PLAN_TYPE); } + // TODO @puhui999:还是搞个 VO 出来哈 @GetMapping("/page") @Operation(summary = "获得操作日志") @Parameter(name = "id", description = "客户编号", required = true) @@ -54,8 +59,7 @@ public class CrmOperateLogController { public CommonResult> getCustomerOperateLog(@Valid CrmOperateLogPageReqVO pageReqVO) { OperateLogV2PageReqDTO reqDTO = new OperateLogV2PageReqDTO(); reqDTO.setPageSize(PAGE_SIZE_NONE); // 默认不分页,需要分页需注释 - reqDTO.setBizType(BIZ_TYPE_MAP.get(pageReqVO.getBizType())); - reqDTO.setBizId(pageReqVO.getBizId()); + reqDTO.setBizType(BIZ_TYPE_MAP.get(pageReqVO.getBizType())).setBizId(pageReqVO.getBizId()); return success(operateLogApi.getOperateLogPage(reqDTO)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java index 9f54247bf..f49ccb38b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogPageReqVO.java @@ -9,7 +9,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Schema(description = "管理后台 - 跟进记录分页 Request VO") +@Schema(description = "管理后台 - CRM 操作日志 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java index 61145f688..d6c36f176 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java @@ -29,6 +29,7 @@ public interface CrmPermissionConvert { CrmPermissionConvert INSTANCE = Mappers.getMapper(CrmPermissionConvert.class); + // TODO @puhui999:这个要不也搞到 copy 里 List convert(List permission); default List convert(List permission, List userList, diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java index 59d800c22..45e2b412e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/followup/CrmFollowUpRecordMapper.java @@ -26,12 +26,14 @@ public interface CrmFollowUpRecordMapper extends BaseMapperX().eq(CrmFollowUpRecordDO::getBizType, bizType) + delete(new LambdaQueryWrapperX() + .eq(CrmFollowUpRecordDO::getBizType, bizType) .eq(CrmFollowUpRecordDO::getBizId, bizId)); } default List selectListByBiz(Integer bizType, Collection bizIds) { - return selectList(new LambdaQueryWrapperX().eq(CrmFollowUpRecordDO::getBizType, bizType) + return selectList(new LambdaQueryWrapperX() + .eq(CrmFollowUpRecordDO::getBizType, bizType) .in(CrmFollowUpRecordDO::getBizId, bizIds)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java index da721ef5a..304b150fe 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -73,17 +73,17 @@ public class CrmClueServiceImpl implements CrmClueService { @LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}", success = CRM_LEADS_CREATE_SUCCESS) public Long createClue(CrmClueSaveReqVO createReqVO, Long userId) { - // 1. 校验关联数据 + // 1.1 校验关联数据 validateRelationDataExists(createReqVO); + // 1.2 校验负责人是否存在 + if (createReqVO.getOwnerUserId() != null) { + adminUserApi.validateUserList(singletonList(createReqVO.getOwnerUserId())); + } else { + createReqVO.setOwnerUserId(userId); // 如果没有设置负责人那么默认操作人为负责人 + } // 2. 插入 CrmClueDO clue = BeanUtils.toBean(createReqVO, CrmClueDO.class).setId(null); - if (ObjUtil.isNull(createReqVO.getOwnerUserId())) { - clue.setOwnerUserId(userId); // 如果没有设置负责人那么默认操作人为负责人 - } else { - // 校验负责人是否存在 - adminUserApi.validateUserList(singletonList(createReqVO.getOwnerUserId())); - } clueMapper.insert(clue); // 3. 创建数据权限 @@ -193,10 +193,13 @@ public class CrmClueServiceImpl implements CrmClueService { } // 2. 遍历线索(未转化的线索),创建对应的客户 + // TODO @puhui999:这里不用过滤了; List translateClues = filterList(clues, clue -> ObjUtil.equal(Boolean.FALSE, clue.getTransformStatus())); List customers = customerService.createCustomerBatch(convertList(translateClues, clue -> BeanUtils.toBean(clue, CrmCustomerCreateReqBO.class)), userId); + // TODO @puhui999:这里不用搞一个 clueCustomerIdMap 出来;可以考虑逐个创建,然后把 customerId 设置回 CrmClueDO;避免 name 匹配,极端会有问题哈; + // TODO 是不是就直接 foreach 处理好了;因为本身量不大,for 处理性能 ok,可阅读性好 Map clueCustomerIdMap = new HashMap<>(translateClues.size()); // 2.1 更新线索 clueMapper.updateBatch(convertList(customers, customer -> { @@ -209,6 +212,7 @@ public class CrmClueServiceImpl implements CrmClueService { // 3. 记录操作日志 for (CrmClueDO clue : translateClues) { + // TODO @puhui999:这里优化下,translate 操作日志 getSelf().receiveClueLog(clue); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java index fc573643d..e63631e4a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java @@ -120,11 +120,12 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { // 校验存在 CrmFollowUpRecordDO followUpRecord = validateFollowUpRecordExists(id); // 校验权限 + // TODO @puhui999:是不是封装一个 hasPermission,更简介一点; List permissionList = permissionService.getPermissionListByBiz( followUpRecord.getBizType(), followUpRecord.getBizId()); - boolean condition = anyMatch(permissionList, permission -> + boolean hasPermission = anyMatch(permissionList, permission -> ObjUtil.equal(permission.getUserId(), userId) && ObjUtil.equal(permission.getLevel(), CrmPermissionLevelEnum.OWNER.getLevel())); - if (!condition) { + if (!hasPermission) { throw exception(FOLLOW_UP_RECORD_DELETE_DENIED); } @@ -134,7 +135,6 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { @Override public void deleteFollowUpRecordByBiz(Integer bizType, Long bizId) { - // 删除 crmFollowUpRecordMapper.deleteByBiz(bizType, bizId); }