Commit 1a7be60503bd60cd9a86ed98ed27815ac53eed29
Committed by
Gitee
!853 CRM: 完善跟进日志 TODO
Merge pull request !853 from puhui999/develop
Showing
15 changed files
with
278 additions
and
87 deletions
yudao-module-crm/yudao-module-crm-biz/pom.xml
| ... | ... | @@ -70,5 +70,9 @@ |
| 70 | 70 | <groupId>cn.iocoder.boot</groupId> |
| 71 | 71 | <artifactId>yudao-spring-boot-starter-test</artifactId> |
| 72 | 72 | </dependency> |
| 73 | + <dependency> | |
| 74 | + <groupId>cn.iocoder.boot</groupId> | |
| 75 | + <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId> | |
| 76 | + </dependency> | |
| 73 | 77 | </dependencies> |
| 74 | 78 | </project> | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/CrmOperateLogController.java
| ... | ... | @@ -2,14 +2,14 @@ package cn.iocoder.yudao.module.crm.controller.admin.operatelog; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogPageReqVO; |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo.CrmOperateLogV2RespVO; | |
| 6 | 8 | import cn.iocoder.yudao.module.crm.enums.LogRecordConstants; |
| 7 | 9 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 8 | 10 | import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; |
| 9 | 11 | import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO; |
| 10 | -import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO; | |
| 11 | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | -import io.swagger.v3.oas.annotations.Parameter; | |
| 13 | 13 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 14 | 14 | import jakarta.annotation.Resource; |
| 15 | 15 | import jakarta.validation.Valid; |
| ... | ... | @@ -51,16 +51,14 @@ public class CrmOperateLogController { |
| 51 | 51 | BIZ_TYPE_MAP.put(CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), CRM_RECEIVABLE_PLAN_TYPE); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - // TODO @puhui999:还是搞个 VO 出来哈 | |
| 55 | 54 | @GetMapping("/page") |
| 56 | 55 | @Operation(summary = "获得操作日志") |
| 57 | - @Parameter(name = "id", description = "客户编号", required = true) | |
| 58 | - @PreAuthorize("@ss.hasPermission('crm:customer:query')") | |
| 59 | - public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@Valid CrmOperateLogPageReqVO pageReqVO) { | |
| 56 | + @PreAuthorize("@ss.hasPermission('crm:operate-log:query')") | |
| 57 | + public CommonResult<PageResult<CrmOperateLogV2RespVO>> getCustomerOperateLog(@Valid CrmOperateLogPageReqVO pageReqVO) { | |
| 60 | 58 | OperateLogV2PageReqDTO reqDTO = new OperateLogV2PageReqDTO(); |
| 61 | 59 | reqDTO.setPageSize(PAGE_SIZE_NONE); // 默认不分页,需要分页需注释 |
| 62 | 60 | reqDTO.setBizType(BIZ_TYPE_MAP.get(pageReqVO.getBizType())).setBizId(pageReqVO.getBizId()); |
| 63 | - return success(operateLogApi.getOperateLogPage(reqDTO)); | |
| 61 | + return success(BeanUtils.toBean(operateLogApi.getOperateLogPage(reqDTO), CrmOperateLogV2RespVO.class)); | |
| 64 | 62 | } |
| 65 | 63 | |
| 66 | 64 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogV2RespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.operatelog.vo; | |
| 2 | + | |
| 3 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - CRM 跟进 Response VO") | |
| 10 | +@Data | |
| 11 | +@ExcelIgnoreUnannotated | |
| 12 | +public class CrmOperateLogV2RespVO { | |
| 13 | + | |
| 14 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 15 | + private Long id; | |
| 16 | + /** | |
| 17 | + * 链路追踪编号 | |
| 18 | + */ | |
| 19 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 20 | + private String traceId; | |
| 21 | + /** | |
| 22 | + * 用户编号 | |
| 23 | + */ | |
| 24 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 25 | + private Long userId; | |
| 26 | + /** | |
| 27 | + * 用户名称 | |
| 28 | + */ | |
| 29 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 30 | + private String userName; | |
| 31 | + /** | |
| 32 | + * 用户类型 | |
| 33 | + */ | |
| 34 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 35 | + private Integer userType; | |
| 36 | + /** | |
| 37 | + * 操作模块类型 | |
| 38 | + */ | |
| 39 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 40 | + private String type; | |
| 41 | + /** | |
| 42 | + * 操作名 | |
| 43 | + */ | |
| 44 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "修改客户") | |
| 45 | + private String subType; | |
| 46 | + /** | |
| 47 | + * 操作模块业务编号 | |
| 48 | + */ | |
| 49 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 50 | + private Long bizId; | |
| 51 | + /** | |
| 52 | + * 操作内容 | |
| 53 | + */ | |
| 54 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "将什么从什么改为了什么") | |
| 55 | + private String action; | |
| 56 | + /** | |
| 57 | + * 拓展字段 | |
| 58 | + */ | |
| 59 | + @Schema(description = "编号", example = "{orderId: 1}") | |
| 60 | + private String extra; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * 请求方法名 | |
| 64 | + */ | |
| 65 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 66 | + private String requestMethod; | |
| 67 | + /** | |
| 68 | + * 请求地址 | |
| 69 | + */ | |
| 70 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 71 | + private String requestUrl; | |
| 72 | + /** | |
| 73 | + * 用户 IP | |
| 74 | + */ | |
| 75 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 76 | + private String userIp; | |
| 77 | + /** | |
| 78 | + * 浏览器 UA | |
| 79 | + */ | |
| 80 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") | |
| 81 | + private String userAgent; | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 创建时间 | |
| 85 | + */ | |
| 86 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-01-01") | |
| 87 | + private LocalDateTime createTime; | |
| 88 | + | |
| 89 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.crm.convert.permission; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 6 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 6 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO; |
| 7 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; |
| 8 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| ... | ... | @@ -29,13 +30,10 @@ public interface CrmPermissionConvert { |
| 29 | 30 | |
| 30 | 31 | CrmPermissionConvert INSTANCE = Mappers.getMapper(CrmPermissionConvert.class); |
| 31 | 32 | |
| 32 | - // TODO @puhui999:这个要不也搞到 copy 里 | |
| 33 | - List<CrmPermissionRespVO> convert(List<CrmPermissionDO> permission); | |
| 34 | - | |
| 35 | - default List<CrmPermissionRespVO> convert(List<CrmPermissionDO> permission, List<AdminUserRespDTO> userList, | |
| 33 | + default List<CrmPermissionRespVO> convert(List<CrmPermissionDO> permissions, List<AdminUserRespDTO> userList, | |
| 36 | 34 | Map<Long, DeptRespDTO> deptMap, Map<Long, PostRespDTO> postMap) { |
| 37 | 35 | Map<Long, AdminUserRespDTO> userMap = CollectionUtils.convertMap(userList, AdminUserRespDTO::getId); |
| 38 | - return CollectionUtils.convertList(convert(permission), item -> { | |
| 36 | + return CollectionUtils.convertList(BeanUtils.toBean(permissions, CrmPermissionRespVO.class), item -> { | |
| 39 | 37 | findAndThen(userMap, item.getUserId(), user -> { |
| 40 | 38 | item.setNickname(user.getNickname()); |
| 41 | 39 | findAndThen(deptMap, user.getDeptId(), deptRespDTO -> item.setDeptName(deptRespDTO.getName())); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java
| ... | ... | @@ -115,9 +115,14 @@ public class CrmCustomerDO extends BaseDO { |
| 115 | 115 | private String detailAddress; |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | + * 最后接收时间 | |
| 119 | + */ | |
| 120 | + private LocalDateTime receiveTime; | |
| 121 | + /** | |
| 118 | 122 | * 最后跟进时间 |
| 119 | 123 | */ |
| 120 | 124 | private LocalDateTime contactLastTime; |
| 125 | + | |
| 121 | 126 | /** |
| 122 | 127 | * 最后跟进内容 |
| 123 | 128 | */ | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java
| ... | ... | @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageR |
| 10 | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 11 | 11 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 12 | 12 | import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils; |
| 13 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 13 | 14 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 14 | 15 | import org.apache.ibatis.annotations.Mapper; |
| 15 | 16 | import org.springframework.lang.Nullable; |
| ... | ... | @@ -99,4 +100,10 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { |
| 99 | 100 | return selectJoinPage(pageReqVO, CrmCustomerDO.class, query); |
| 100 | 101 | } |
| 101 | 102 | |
| 103 | + default List<CrmCustomerDO> selectListByLockStatusAndOwnerUserIdNotNull(Boolean lockStatus) { | |
| 104 | + return selectList(new LambdaQueryWrapper<CrmCustomerDO>() | |
| 105 | + .eq(CrmCustomerDO::getLockStatus, lockStatus) | |
| 106 | + .isNotNull(CrmCustomerDO::getOwnerUserId)); | |
| 107 | + } | |
| 108 | + | |
| 102 | 109 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/util/CrmPermissionUtils.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.framework.permission.core.util; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.ObjUtil; | |
| 3 | 4 | import cn.hutool.extra.spring.SpringUtil; |
| 5 | +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | |
| 6 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | |
| 7 | +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | |
| 4 | 8 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionRoleCodeEnum; |
| 9 | +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | |
| 5 | 10 | import cn.iocoder.yudao.module.system.api.permission.PermissionApi; |
| 6 | 11 | |
| 12 | +import java.util.List; | |
| 13 | + | |
| 14 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; | |
| 7 | 15 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 8 | 16 | |
| 9 | 17 | /** |
| ... | ... | @@ -23,6 +31,21 @@ public class CrmPermissionUtils { |
| 23 | 31 | } |
| 24 | 32 | |
| 25 | 33 | /** |
| 34 | + * 校验权限 | |
| 35 | + * | |
| 36 | + * @param bizType 数据类型,关联 {@link CrmBizTypeEnum} | |
| 37 | + * @param bizId 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId() | |
| 38 | + * @param userId 用户编号 | |
| 39 | + * @param levelEnum 权限级别 | |
| 40 | + * @return boolean | |
| 41 | + */ | |
| 42 | + public static boolean hasPermission(Integer bizType, Long bizId, Long userId, CrmPermissionLevelEnum levelEnum) { | |
| 43 | + List<CrmPermissionDO> permissionList = SingletonManager.getCrmPermissionService().getPermissionListByBiz(bizType, bizId); | |
| 44 | + return anyMatch(permissionList, permission -> | |
| 45 | + ObjUtil.equal(permission.getUserId(), userId) && ObjUtil.equal(permission.getLevel(), levelEnum.getLevel())); | |
| 46 | + } | |
| 47 | + | |
| 48 | + /** | |
| 26 | 49 | * 静态内部类实现单例获取 |
| 27 | 50 | * |
| 28 | 51 | * @author HUIHUI |
| ... | ... | @@ -30,11 +53,16 @@ public class CrmPermissionUtils { |
| 30 | 53 | private static class SingletonManager { |
| 31 | 54 | |
| 32 | 55 | private static final PermissionApi PERMISSION_API = SpringUtil.getBean(PermissionApi.class); |
| 56 | + private static final CrmPermissionService CRM_PERMISSION_SERVICE = SpringUtil.getBean(CrmPermissionService.class); | |
| 33 | 57 | |
| 34 | 58 | public static PermissionApi getPermissionApi() { |
| 35 | 59 | return PERMISSION_API; |
| 36 | 60 | } |
| 37 | 61 | |
| 62 | + public static CrmPermissionService getCrmPermissionService() { | |
| 63 | + return CRM_PERMISSION_SERVICE; | |
| 64 | + } | |
| 65 | + | |
| 38 | 66 | } |
| 39 | 67 | |
| 40 | 68 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/customer/CrmCustomerAutoPutPoolJob.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.job.customer; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; | |
| 4 | +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; | |
| 5 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | |
| 6 | +import jakarta.annotation.Resource; | |
| 7 | +import org.springframework.stereotype.Component; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 客户自动掉入公海 Job | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Component | |
| 15 | +public class CrmCustomerAutoPutPoolJob implements JobHandler { | |
| 16 | + | |
| 17 | + @Resource | |
| 18 | + private CrmCustomerService customerService; | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + @TenantJob | |
| 22 | + public String execute(String param) { | |
| 23 | + int count = customerService.customerAutoPutPoolBySystem(); | |
| 24 | + return String.format("掉入公海客户 %s 个", count); | |
| 25 | + } | |
| 26 | + | |
| 27 | +} | |
| 0 | 28 | \ No newline at end of file | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java
0 → 100644
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.service.clue; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | 5 | import cn.hutool.core.lang.Assert; |
| 6 | -import cn.hutool.core.util.ObjUtil; | |
| 7 | 6 | import cn.hutool.core.util.ObjectUtil; |
| 8 | 7 | import cn.hutool.extra.spring.SpringUtil; |
| 9 | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| ... | ... | @@ -15,7 +14,6 @@ import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqV |
| 15 | 14 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO; |
| 16 | 15 | import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; |
| 17 | 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; |
| 18 | -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | |
| 19 | 17 | import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; |
| 20 | 18 | import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; |
| 21 | 19 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| ... | ... | @@ -193,46 +191,39 @@ public class CrmClueServiceImpl implements CrmClueService { |
| 193 | 191 | } |
| 194 | 192 | |
| 195 | 193 | // 2. 遍历线索(未转化的线索),创建对应的客户 |
| 196 | - // TODO @puhui999:这里不用过滤了; | |
| 197 | - List<CrmClueDO> translateClues = filterList(clues, clue -> ObjUtil.equal(Boolean.FALSE, clue.getTransformStatus())); | |
| 198 | - List<CrmCustomerDO> customers = customerService.createCustomerBatch(convertList(translateClues, clue -> | |
| 199 | - BeanUtils.toBean(clue, CrmCustomerCreateReqBO.class)), userId); | |
| 200 | - | |
| 201 | - // TODO @puhui999:这里不用搞一个 clueCustomerIdMap 出来;可以考虑逐个创建,然后把 customerId 设置回 CrmClueDO;避免 name 匹配,极端会有问题哈; | |
| 202 | - // TODO 是不是就直接 foreach 处理好了;因为本身量不大,for 处理性能 ok,可阅读性好 | |
| 203 | - Map<Long, Long> clueCustomerIdMap = new HashMap<>(translateClues.size()); | |
| 194 | + clues.forEach(clue -> { | |
| 195 | + Long customerId = customerService.createCustomer(BeanUtils.toBean(clue, CrmCustomerCreateReqBO.class), userId); | |
| 196 | + clue.setCustomerId(customerId); | |
| 197 | + }); | |
| 198 | + | |
| 204 | 199 | // 2.1 更新线索 |
| 205 | - clueMapper.updateBatch(convertList(customers, customer -> { | |
| 206 | - CrmClueDO firstClue = findFirst(translateClues, clue -> ObjUtil.equal(clue.getName(), customer.getName())); | |
| 207 | - clueCustomerIdMap.put(firstClue.getId(), customer.getId()); | |
| 208 | - return new CrmClueDO().setId(firstClue.getId()).setTransformStatus(Boolean.TRUE).setCustomerId(customer.getId()); | |
| 209 | - })); | |
| 200 | + clueMapper.updateBatch(convertList(clues, clue -> new CrmClueDO().setId(clue.getId()).setTransformStatus(Boolean.TRUE) | |
| 201 | + .setCustomerId(clue.getCustomerId()))); | |
| 210 | 202 | // 2.3 复制跟进 |
| 211 | - updateFollowUpRecords(clueCustomerIdMap); | |
| 212 | - | |
| 203 | + updateFollowUpRecords(clues); | |
| 213 | 204 | // 3. 记录操作日志 |
| 214 | - for (CrmClueDO clue : translateClues) { | |
| 215 | - // TODO @puhui999:这里优化下,translate 操作日志 | |
| 216 | - getSelf().receiveClueLog(clue); | |
| 205 | + for (CrmClueDO clue : clues) { | |
| 206 | + getSelf().translateCustomerLog(clue); | |
| 217 | 207 | } |
| 218 | 208 | } |
| 219 | 209 | |
| 220 | - private void updateFollowUpRecords(Map<Long, Long> clueCustomerIdMap) { | |
| 210 | + private void updateFollowUpRecords(List<CrmClueDO> clues) { | |
| 221 | 211 | List<CrmFollowUpRecordDO> followUpRecords = followUpRecordService.getFollowUpRecordByBiz( |
| 222 | - CrmBizTypeEnum.CRM_LEADS.getType(), clueCustomerIdMap.keySet()); | |
| 212 | + CrmBizTypeEnum.CRM_LEADS.getType(), convertSet(clues, CrmClueDO::getId)); | |
| 223 | 213 | if (CollUtil.isEmpty(followUpRecords)) { |
| 224 | 214 | return; |
| 225 | 215 | } |
| 226 | 216 | |
| 217 | + Map<Long, CrmClueDO> clueMap = convertMap(clues, CrmClueDO::getId); | |
| 227 | 218 | // 创建跟进 |
| 228 | 219 | followUpRecordService.createFollowUpRecordBatch(convertList(followUpRecords, followUpRecord -> |
| 229 | 220 | BeanUtils.toBean(followUpRecord, CrmFollowUpCreateReqBO.class).setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) |
| 230 | - .setBizId(clueCustomerIdMap.get(followUpRecord.getBizId())))); | |
| 221 | + .setBizId(clueMap.get(followUpRecord.getBizId()).getCustomerId()))); | |
| 231 | 222 | } |
| 232 | 223 | |
| 233 | 224 | @LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_TRANSLATE_SUB_TYPE, bizNo = "{{#clue.id}}", |
| 234 | 225 | success = CRM_LEADS_TRANSLATE_SUCCESS) |
| 235 | - public void receiveClueLog(CrmClueDO clue) { | |
| 226 | + public void translateCustomerLog(CrmClueDO clue) { | |
| 236 | 227 | // 记录操作日志上下文 |
| 237 | 228 | LogRecordContext.putVariable("clue", clue); |
| 238 | 229 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessServiceImpl.java
| ... | ... | @@ -6,6 +6,9 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 6 | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessMapper; |
| 9 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | |
| 10 | +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | |
| 11 | +import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; | |
| 9 | 12 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 10 | 13 | import jakarta.annotation.Resource; |
| 11 | 14 | import org.springframework.context.annotation.Lazy; |
| ... | ... | @@ -19,7 +22,6 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU |
| 19 | 22 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; |
| 20 | 23 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; |
| 21 | 24 | |
| 22 | -// TODO @puhui999:数据权限的校验;每个操作; | |
| 23 | 25 | /** |
| 24 | 26 | * 联系人与商机的关联 Service 实现类 |
| 25 | 27 | * |
| ... | ... | @@ -40,6 +42,7 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService |
| 40 | 42 | private CrmContactService contactService; |
| 41 | 43 | |
| 42 | 44 | @Override |
| 45 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#createReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) | |
| 43 | 46 | public void createContactBusinessList(CrmContactBusinessReqVO createReqVO) { |
| 44 | 47 | CrmContactDO contact = contactService.getContact(createReqVO.getContactId()); |
| 45 | 48 | if (contact == null) { |
| ... | ... | @@ -65,6 +68,7 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | @Override |
| 71 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#deleteReqVO.contactId", level = CrmPermissionLevelEnum.WRITE) | |
| 68 | 72 | public void deleteContactBusinessList(CrmContactBusinessReqVO deleteReqVO) { |
| 69 | 73 | CrmContactDO contact = contactService.getContact(deleteReqVO.getContactId()); |
| 70 | 74 | if (contact == null) { |
| ... | ... | @@ -76,11 +80,13 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService |
| 76 | 80 | } |
| 77 | 81 | |
| 78 | 82 | @Override |
| 83 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#contactId", level = CrmPermissionLevelEnum.WRITE) | |
| 79 | 84 | public void deleteContactBusinessByContactId(Long contactId) { |
| 80 | - contactBusinessMapper.delete(CrmContactBusinessDO::getContactId,contactId); | |
| 85 | + contactBusinessMapper.delete(CrmContactBusinessDO::getContactId, contactId); | |
| 81 | 86 | } |
| 82 | 87 | |
| 83 | 88 | @Override |
| 89 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#contactId", level = CrmPermissionLevelEnum.READ) | |
| 84 | 90 | public List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId) { |
| 85 | 91 | return contactBusinessMapper.selectListByContactId(contactId); |
| 86 | 92 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java
| ... | ... | @@ -100,13 +100,13 @@ public interface CrmCustomerService { |
| 100 | 100 | void updateCustomerFollowUp(CrmUpdateFollowUpReqBO customerUpdateFollowUpReqBO); |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | - * 批量创建客户 | |
| 103 | + * 创建客户 | |
| 104 | 104 | * |
| 105 | - * @param customerCreateReqBOs 请求 | |
| 106 | - * @param userId 用户编号 | |
| 105 | + * @param customerCreateReq 请求信息 | |
| 106 | + * @param userId 用户编号 | |
| 107 | 107 | * @return 客户列表 |
| 108 | 108 | */ |
| 109 | - List<CrmCustomerDO> createCustomerBatch(List<CrmCustomerCreateReqBO> customerCreateReqBOs, Long userId); | |
| 109 | + Long createCustomer(CrmCustomerCreateReqBO customerCreateReq, Long userId); | |
| 110 | 110 | |
| 111 | 111 | // ==================== 公海相关操作 ==================== |
| 112 | 112 | |
| ... | ... | @@ -126,4 +126,11 @@ public interface CrmCustomerService { |
| 126 | 126 | */ |
| 127 | 127 | void receiveCustomer(List<Long> ids, Long ownerUserId, Boolean isReceive); |
| 128 | 128 | |
| 129 | + /** | |
| 130 | + * 【系统】客户自动掉入公海 | |
| 131 | + * | |
| 132 | + * @return 掉入公海数量 | |
| 133 | + */ | |
| 134 | + int customerAutoPutPoolBySystem(); | |
| 135 | + | |
| 129 | 136 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -2,9 +2,11 @@ package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.lang.Assert; |
| 5 | +import cn.hutool.core.util.ObjUtil; | |
| 5 | 6 | import cn.hutool.extra.spring.SpringUtil; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 9 | +import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | |
| 8 | 10 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | 11 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLockReqVO; |
| 10 | 12 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; |
| ... | ... | @@ -13,6 +15,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTrans |
| 13 | 15 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; |
| 14 | 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 15 | 17 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 18 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | |
| 16 | 19 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; |
| 17 | 20 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 18 | 21 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| ... | ... | @@ -31,6 +34,7 @@ import com.mzt.logapi.context.LogRecordContext; |
| 31 | 34 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 32 | 35 | import com.mzt.logapi.starter.annotation.LogRecord; |
| 33 | 36 | import jakarta.annotation.Resource; |
| 37 | +import lombok.extern.slf4j.Slf4j; | |
| 34 | 38 | import org.springframework.context.annotation.Lazy; |
| 35 | 39 | import org.springframework.stereotype.Service; |
| 36 | 40 | import org.springframework.transaction.annotation.Transactional; |
| ... | ... | @@ -43,12 +47,10 @@ import java.util.Collections; |
| 43 | 47 | import java.util.List; |
| 44 | 48 | |
| 45 | 49 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 46 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 47 | 50 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 48 | 51 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; |
| 49 | 52 | import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_LOCK_LIMIT; |
| 50 | 53 | import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_OWNER_LIMIT; |
| 51 | -import static java.util.Collections.emptyList; | |
| 52 | 54 | import static java.util.Collections.singletonList; |
| 53 | 55 | |
| 54 | 56 | /** |
| ... | ... | @@ -57,6 +59,7 @@ import static java.util.Collections.singletonList; |
| 57 | 59 | * @author Wanwan |
| 58 | 60 | */ |
| 59 | 61 | @Service |
| 62 | +@Slf4j | |
| 60 | 63 | @Validated |
| 61 | 64 | public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 62 | 65 | |
| ... | ... | @@ -69,6 +72,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 69 | 72 | private CrmCustomerLimitConfigService customerLimitConfigService; |
| 70 | 73 | @Resource |
| 71 | 74 | @Lazy |
| 75 | + private CrmCustomerPoolConfigService customerPoolConfigService; | |
| 76 | + @Resource | |
| 77 | + @Lazy | |
| 72 | 78 | private CrmContactService contactService; |
| 73 | 79 | @Resource |
| 74 | 80 | @Lazy |
| ... | ... | @@ -91,9 +97,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 91 | 97 | |
| 92 | 98 | // 2. 插入客户 |
| 93 | 99 | CrmCustomerDO customer = BeanUtils.toBean(createReqVO, CrmCustomerDO.class) |
| 94 | - .setLockStatus(false).setDealStatus(false) | |
| 95 | - .setContactLastTime(LocalDateTime.now()); | |
| 96 | - // TODO @puhui999:可能要加个 receiveTime 字段,记录最后接收时间 | |
| 100 | + .setLockStatus(false).setDealStatus(false).setContactLastTime(LocalDateTime.now()); | |
| 97 | 101 | customerMapper.insert(customer); |
| 98 | 102 | |
| 99 | 103 | // 3. 创建数据权限 |
| ... | ... | @@ -214,24 +218,24 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 214 | 218 | |
| 215 | 219 | @Override |
| 216 | 220 | @Transactional(rollbackFor = Exception.class) |
| 217 | - public List<CrmCustomerDO> createCustomerBatch(List<CrmCustomerCreateReqBO> customerCreateReqBOs, Long userId) { | |
| 218 | - if (CollUtil.isEmpty(customerCreateReqBOs)) { | |
| 219 | - return emptyList(); | |
| 220 | - } | |
| 221 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", | |
| 222 | + success = CRM_CUSTOMER_CREATE_SUCCESS) | |
| 223 | + public Long createCustomer(CrmCustomerCreateReqBO customerCreateReq, Long userId) { | |
| 224 | + // 1. 插入客户 | |
| 225 | + CrmCustomerDO customer = BeanUtils.toBean(customerCreateReq, CrmCustomerDO.class).setOwnerUserId(userId) | |
| 226 | + .setLockStatus(false).setDealStatus(false).setReceiveTime(LocalDateTime.now()); | |
| 227 | + customerMapper.insert(customer); | |
| 221 | 228 | |
| 222 | - // 创建客户 | |
| 223 | - List<CrmCustomerDO> customers = convertList(customerCreateReqBOs, customerBO -> | |
| 224 | - BeanUtils.toBean(customerBO, CrmCustomerDO.class).setOwnerUserId(userId)); | |
| 225 | - customerMapper.insertBatch(customers); | |
| 229 | + // 2. 创建数据权限 | |
| 230 | + permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) | |
| 231 | + .setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 | |
| 226 | 232 | |
| 227 | - // 创建负责人数据权限 | |
| 228 | - permissionService.createPermissionBatch(convertList(customers, customer -> new CrmPermissionCreateReqBO() | |
| 229 | - .setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()).setBizId(customer.getId()).setUserId(userId) | |
| 230 | - .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()))); | |
| 231 | - return customers; | |
| 233 | + // 3. 记录操作日志上下文 | |
| 234 | + LogRecordContext.putVariable("customer", customer); | |
| 235 | + return customer.getId(); | |
| 232 | 236 | } |
| 233 | 237 | |
| 234 | - // ==================== 公海相关操作 ==================== | |
| 238 | +// ==================== 公海相关操作 ==================== | |
| 235 | 239 | |
| 236 | 240 | @Override |
| 237 | 241 | @Transactional(rollbackFor = Exception.class) |
| ... | ... | @@ -249,17 +253,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 249 | 253 | // 1.3. 校验客户是否锁定 |
| 250 | 254 | validateCustomerIsLocked(customer, true); |
| 251 | 255 | |
| 252 | - // 2.1 设置负责人为 NULL | |
| 253 | - int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null); | |
| 254 | - if (updateOwnerUserIncr == 0) { | |
| 255 | - throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL); | |
| 256 | - } | |
| 257 | - // 2.2 删除负责人数据权限 | |
| 258 | - permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), | |
| 259 | - CrmPermissionLevelEnum.OWNER.getLevel()); | |
| 260 | - | |
| 261 | - // 3. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的 | |
| 262 | - contactService.updateOwnerUserIdByCustomerId(customer.getId(), null); | |
| 256 | + // 2. 客户放入公海 | |
| 257 | + putCustomerPool(customer); | |
| 263 | 258 | |
| 264 | 259 | // 记录操作日志上下文 |
| 265 | 260 | LogRecordContext.putVariable("customerName", customer.getName()); |
| ... | ... | @@ -317,6 +312,49 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 317 | 312 | } |
| 318 | 313 | } |
| 319 | 314 | |
| 315 | + @Override | |
| 316 | + public int customerAutoPutPoolBySystem() { | |
| 317 | + CrmCustomerPoolConfigDO poolConfig = customerPoolConfigService.getCustomerPoolConfig(); | |
| 318 | + if (poolConfig == null || !poolConfig.getEnabled()) { | |
| 319 | + return 0; | |
| 320 | + } | |
| 321 | + // 获取没有锁定的不在公海的客户 | |
| 322 | + List<CrmCustomerDO> customerList = customerMapper.selectListByLockStatusAndOwnerUserIdNotNull(Boolean.FALSE); | |
| 323 | + List<CrmCustomerDO> poolCustomerList = CollectionUtils.filterList(customerList, customer -> { | |
| 324 | + // 1.1 未成交放入公海 | |
| 325 | + if (!customer.getDealStatus()) { | |
| 326 | + return (poolConfig.getDealExpireDays() - LocalDateTimeUtils.between(customer.getCreateTime())) <= 0; | |
| 327 | + } | |
| 328 | + // 1.2 未跟进放入公海 | |
| 329 | + LocalDateTime lastTime = ObjUtil.defaultIfNull(customer.getContactLastTime(), customer.getCreateTime()); | |
| 330 | + return (poolConfig.getContactExpireDays() - LocalDateTimeUtils.between(lastTime)) <= 0; | |
| 331 | + }); | |
| 332 | + int count = 0; | |
| 333 | + for (CrmCustomerDO customer : poolCustomerList) { | |
| 334 | + try { | |
| 335 | + getSelf().putCustomerPool(customer); | |
| 336 | + count++; | |
| 337 | + } catch (Throwable e) { | |
| 338 | + log.error("[customerAutoPutPoolBySystem][Customer 客户({}) 放入公海异常]", customer.getId(), e); | |
| 339 | + } | |
| 340 | + } | |
| 341 | + return count; | |
| 342 | + } | |
| 343 | + | |
| 344 | + private void putCustomerPool(CrmCustomerDO customer) { | |
| 345 | + // 1. 设置负责人为 NULL | |
| 346 | + int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null); | |
| 347 | + if (updateOwnerUserIncr == 0) { | |
| 348 | + throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL); | |
| 349 | + } | |
| 350 | + // 2. 删除负责人数据权限 | |
| 351 | + permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), | |
| 352 | + CrmPermissionLevelEnum.OWNER.getLevel()); | |
| 353 | + | |
| 354 | + // 3. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的 | |
| 355 | + contactService.updateOwnerUserIdByCustomerId(customer.getId(), null); | |
| 356 | + } | |
| 357 | + | |
| 320 | 358 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", |
| 321 | 359 | success = CRM_CUSTOMER_RECEIVE_SUCCESS) |
| 322 | 360 | public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java
| ... | ... | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO; |
| 10 | -import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; | |
| 11 | 10 | import cn.iocoder.yudao.module.crm.dal.mysql.followup.CrmFollowUpRecordMapper; |
| 12 | 11 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 13 | 12 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| ... | ... | @@ -31,10 +30,10 @@ import java.util.Collections; |
| 31 | 30 | import java.util.List; |
| 32 | 31 | |
| 33 | 32 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 34 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch; | |
| 35 | 33 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| 36 | 34 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_DELETE_DENIED; |
| 37 | 35 | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_NOT_EXISTS; |
| 36 | +import static cn.iocoder.yudao.module.crm.framework.permission.core.util.CrmPermissionUtils.hasPermission; | |
| 38 | 37 | |
| 39 | 38 | /** |
| 40 | 39 | * 跟进记录 Service 实现类 |
| ... | ... | @@ -94,14 +93,15 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { |
| 94 | 93 | customerService.updateCustomerFollowUp(updateFollowUpReqBO); |
| 95 | 94 | } |
| 96 | 95 | |
| 97 | - // TODO @puhui999:这两个,不更新 contactLastTime、contactLastContent,只更新 nextTime | |
| 98 | 96 | // 3.1 更新 contactIds 对应的记录 |
| 99 | 97 | if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { |
| 100 | - contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId)); | |
| 98 | + contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), | |
| 99 | + contactId -> updateFollowUpReqBO.setBizId(contactId).setContactLastTime(null).setContactLastContent(null))); | |
| 101 | 100 | } |
| 102 | 101 | // 3.2 需要更新 businessIds、contactIds 对应的记录 |
| 103 | 102 | if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { |
| 104 | - businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), updateFollowUpReqBO::setBizId)); | |
| 103 | + businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), | |
| 104 | + businessId -> updateFollowUpReqBO.setBizId(businessId).setContactLastTime(null).setContactLastContent(null))); | |
| 105 | 105 | } |
| 106 | 106 | return followUpRecord.getId(); |
| 107 | 107 | } |
| ... | ... | @@ -112,8 +112,7 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { |
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - List<CrmFollowUpRecordDO> followUpRecords = BeanUtils.toBean(followUpCreateReqBOs, CrmFollowUpRecordDO.class); | |
| 116 | - crmFollowUpRecordMapper.insertBatch(followUpRecords); | |
| 115 | + crmFollowUpRecordMapper.insertBatch(BeanUtils.toBean(followUpCreateReqBOs, CrmFollowUpRecordDO.class)); | |
| 117 | 116 | } |
| 118 | 117 | |
| 119 | 118 | @Override |
| ... | ... | @@ -121,12 +120,7 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { |
| 121 | 120 | // 校验存在 |
| 122 | 121 | CrmFollowUpRecordDO followUpRecord = validateFollowUpRecordExists(id); |
| 123 | 122 | // 校验权限 |
| 124 | - // TODO @puhui999:是不是封装一个 hasPermission,更简介一点; | |
| 125 | - List<CrmPermissionDO> permissionList = permissionService.getPermissionListByBiz( | |
| 126 | - followUpRecord.getBizType(), followUpRecord.getBizId()); | |
| 127 | - boolean hasPermission = anyMatch(permissionList, permission -> | |
| 128 | - ObjUtil.equal(permission.getUserId(), userId) && ObjUtil.equal(permission.getLevel(), CrmPermissionLevelEnum.OWNER.getLevel())); | |
| 129 | - if (!hasPermission) { | |
| 123 | + if (!hasPermission(followUpRecord.getBizType(), followUpRecord.getBizId(), userId, CrmPermissionLevelEnum.OWNER)) { | |
| 130 | 124 | throw exception(FOLLOW_UP_RECORD_DELETE_DENIED); |
| 131 | 125 | } |
| 132 | 126 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/bo/CrmUpdateFollowUpReqBO.java
| ... | ... | @@ -21,7 +21,6 @@ public class CrmUpdateFollowUpReqBO { |
| 21 | 21 | |
| 22 | 22 | @Schema(description = "最后跟进时间") |
| 23 | 23 | @DiffLogField(name = "最后跟进时间") |
| 24 | - @NotNull(message = "最后跟进时间不能为空") | |
| 25 | 24 | private LocalDateTime contactLastTime; |
| 26 | 25 | |
| 27 | 26 | @Schema(description = "下次联系时间") |
| ... | ... | @@ -30,7 +29,6 @@ public class CrmUpdateFollowUpReqBO { |
| 30 | 29 | |
| 31 | 30 | @Schema(description = "最后更进内容") |
| 32 | 31 | @DiffLogField(name = "最后更进内容") |
| 33 | - @NotNull(message = "最后更进内容不能为空") | |
| 34 | 32 | private String contactLastContent; |
| 35 | 33 | |
| 36 | 34 | } | ... | ... |