From 814b6f688d8751f61f16ddc124c41de91bc5270c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 26 Jan 2024 23:46:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9Acode=20review=20?= =?UTF-8?q?=E8=B7=9F=E8=BF=9B=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/shell/deploy.sh | 2 +- yudao-module-crm/yudao-module-crm-biz/pom.xml | 2 + .../operatelog/vo/CrmOperateLogV2RespVO.java | 61 +++---------------- .../dal/mysql/customer/CrmCustomerMapper.java | 1 + .../core/util/CrmPermissionUtils.java | 1 + .../yudao/module/crm/job/package-info.java | 3 + .../crm/service/clue/CrmClueServiceImpl.java | 22 ++++--- .../service/customer/CrmCustomerService.java | 1 + .../followup/CrmFollowUpRecordService.java | 4 +- .../CrmFollowUpRecordServiceImpl.java | 11 ++-- .../system/enums/ErrorCodeConstants.java | 2 +- 11 files changed, 38 insertions(+), 72 deletions(-) diff --git a/script/shell/deploy.sh b/script/shell/deploy.sh index f0fdf1fe6..b635a70b8 100644 --- a/script/shell/deploy.sh +++ b/script/shell/deploy.sh @@ -74,7 +74,7 @@ function stop() { if [ -n "$PID" ]; then echo -e ".\c" else - echo '[stop] 停止 $BASE_PATH/$SERVER_NAME 成功' + echo "[stop] 停止 $BASE_PATH/$SERVER_NAME 成功" break fi done diff --git a/yudao-module-crm/yudao-module-crm-biz/pom.xml b/yudao-module-crm/yudao-module-crm-biz/pom.xml index d786a90fa..234cf268e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/pom.xml +++ b/yudao-module-crm/yudao-module-crm-biz/pom.xml @@ -70,6 +70,8 @@ cn.iocoder.boot yudao-spring-boot-starter-test + + cn.iocoder.boot yudao-spring-boot-starter-biz-tenant diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogV2RespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogV2RespVO.java index 298b5a51d..b3405428f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogV2RespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/operatelog/vo/CrmOperateLogV2RespVO.java @@ -13,76 +13,31 @@ public class CrmOperateLogV2RespVO { @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") private Long id; - /** - * 链路追踪编号 - */ - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private String traceId; - /** - * 用户编号 - */ + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Long userId; - /** - * 用户名称 - */ + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") private String userName; - /** - * 用户类型 - */ + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Integer userType; - /** - * 操作模块类型 - */ + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") private String type; - /** - * 操作名 - */ + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "修改客户") private String subType; - /** - * 操作模块业务编号 - */ + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") private Long bizId; - /** - * 操作内容 - */ + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "将什么从什么改为了什么") private String action; - /** - * 拓展字段 - */ + @Schema(description = "编号", example = "{orderId: 1}") private String extra; - /** - * 请求方法名 - */ - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private String requestMethod; - /** - * 请求地址 - */ - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private String requestUrl; - /** - * 用户 IP - */ - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private String userIp; - /** - * 浏览器 UA - */ - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") - private String userAgent; - - /** - * 创建时间 - */ @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-01-01") private LocalDateTime createTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java index c38d114c2..79ba99d22 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -103,6 +103,7 @@ public interface CrmCustomerMapper extends BaseMapperX { default List selectListByLockStatusAndOwnerUserIdNotNull(Boolean lockStatus) { return selectList(new LambdaQueryWrapper() .eq(CrmCustomerDO::getLockStatus, lockStatus) + // TODO @puhui999:not null 可以转化成大于 0 .isNotNull(CrmCustomerDO::getOwnerUserId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/util/CrmPermissionUtils.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/util/CrmPermissionUtils.java index 8f9c19410..4e5898455 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/util/CrmPermissionUtils.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/util/CrmPermissionUtils.java @@ -30,6 +30,7 @@ public class CrmPermissionUtils { return SingletonManager.getPermissionApi().hasAnyRoles(getLoginUserId(), CrmPermissionRoleCodeEnum.CRM_ADMIN.getCode()); } + // TODO @puhui999:这个貌似直接放到 CrmPermissionService 会更好? /** * 校验权限 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java index 85cccce72..144f64d02 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/job/package-info.java @@ -1 +1,4 @@ +/** + * TODO 芋艿:临时占位,后续可删除 + */ package cn.iocoder.yudao.module.crm.job; \ No newline at end of file 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 2329c4dce..387d9732f 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 @@ -190,32 +190,36 @@ public class CrmClueServiceImpl implements CrmClueService { throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, convertSet(translatedClues, CrmClueDO::getId)); } - // 2. 遍历线索(未转化的线索),创建对应的客户 + // 2.1 遍历线索(未转化的线索),创建对应的客户 clues.forEach(clue -> { Long customerId = customerService.createCustomer(BeanUtils.toBean(clue, CrmCustomerCreateReqBO.class), userId); clue.setCustomerId(customerId); }); + // 2.2 更新线索 + clueMapper.updateBatch(convertList(clues, clue -> new CrmClueDO().setId(clue.getId()) + .setTransformStatus(Boolean.TRUE).setCustomerId(clue.getCustomerId()))); + // 2.3 复制跟进记录 + copyFollowUpRecords(clues); - // 2.1 更新线索 - clueMapper.updateBatch(convertList(clues, clue -> new CrmClueDO().setId(clue.getId()).setTransformStatus(Boolean.TRUE) - .setCustomerId(clue.getCustomerId()))); - // 2.3 复制跟进 - updateFollowUpRecords(clues); // 3. 记录操作日志 for (CrmClueDO clue : clues) { getSelf().translateCustomerLog(clue); } } - private void updateFollowUpRecords(List clues) { + /** + * 线索被转换客户后,需要将线索的跟进记录,复制到客户上 + * + * @param clues 被转化的线索 + */ + private void copyFollowUpRecords(List clues) { List followUpRecords = followUpRecordService.getFollowUpRecordByBiz( CrmBizTypeEnum.CRM_LEADS.getType(), convertSet(clues, CrmClueDO::getId)); if (CollUtil.isEmpty(followUpRecords)) { return; } - - Map clueMap = convertMap(clues, CrmClueDO::getId); // 创建跟进 + Map clueMap = convertMap(clues, CrmClueDO::getId); followUpRecordService.createFollowUpRecordBatch(convertList(followUpRecords, followUpRecord -> BeanUtils.toBean(followUpRecord, CrmFollowUpCreateReqBO.class).setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) .setBizId(clueMap.get(followUpRecord.getBizId()).getCustomerId()))); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java index e4d06d2fc..bff150c14 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -126,6 +126,7 @@ public interface CrmCustomerService { */ void receiveCustomer(List ids, Long ownerUserId, Boolean isReceive); + // TODO @puhui999:autoPutCustomerPool,注释说明是系统就好哈; /** * 【系统】客户自动掉入公海 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java index f881e5259..d2a7cb8f9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordService.java @@ -28,9 +28,9 @@ public interface CrmFollowUpRecordService { /** * 创建更进 * - * @param followUpCreateReqBOs 请求 + * @param list 请求 */ - void createFollowUpRecordBatch(List followUpCreateReqBOs); + void createFollowUpRecordBatch(List list); /** * 删除跟进记录 (数据权限基于 bizType、 bizId) 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 9a04e2d94..9d6f87faa 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 @@ -93,12 +93,12 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { customerService.updateCustomerFollowUp(updateFollowUpReqBO); } - // 3.1 更新 contactIds 对应的记录 + // 3.1 更新 contactIds 对应的记录,不更新 lastTime 和 lastContent if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), contactId -> updateFollowUpReqBO.setBizId(contactId).setContactLastTime(null).setContactLastContent(null))); } - // 3.2 需要更新 businessIds、contactIds 对应的记录 + // 3.2 需要更新 businessIds 对应的记录,不更新 lastTime 和 lastContent if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) { businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), businessId -> updateFollowUpReqBO.setBizId(businessId).setContactLastTime(null).setContactLastContent(null))); @@ -107,12 +107,11 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { } @Override - public void createFollowUpRecordBatch(List followUpCreateReqBOs) { - if (CollUtil.isEmpty(followUpCreateReqBOs)) { + public void createFollowUpRecordBatch(List list) { + if (CollUtil.isEmpty(list)) { return; } - - crmFollowUpRecordMapper.insertBatch(BeanUtils.toBean(followUpCreateReqBOs, CrmFollowUpRecordDO.class)); + crmFollowUpRecordMapper.insertBatch(BeanUtils.toBean(list, CrmFollowUpRecordDO.class)); } @Override diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index ef5c3a624..2f41f67e9 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -98,7 +98,7 @@ public interface ErrorCodeConstants { ErrorCode SMS_CODE_USED = new ErrorCode(1_002_014_002, "验证码已使用"); ErrorCode SMS_CODE_NOT_CORRECT = new ErrorCode(1_002_014_003, "验证码不正确"); ErrorCode SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY = new ErrorCode(1_002_014_004, "超过每日短信发送数量"); - ErrorCode SMS_CODE_SEND_TOO_FAST = new ErrorCode(1_002_014_005, "短信发送过于频率"); + ErrorCode SMS_CODE_SEND_TOO_FAST = new ErrorCode(1_002_014_005, "短信发送过于频繁"); ErrorCode SMS_CODE_IS_EXISTS = new ErrorCode(1_002_014_006, "手机号已被使用"); ErrorCode SMS_CODE_IS_UNUSED = new ErrorCode(1_002_014_007, "验证码未被使用");