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:
		| @@ -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; | ||||
|  | ||||
|   | ||||
| @@ -103,6 +103,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> { | ||||
|     default List<CrmCustomerDO> selectListByLockStatusAndOwnerUserIdNotNull(Boolean lockStatus) { | ||||
|         return selectList(new LambdaQueryWrapper<CrmCustomerDO>() | ||||
|                 .eq(CrmCustomerDO::getLockStatus, lockStatus) | ||||
|                 // TODO @puhui999:not null 可以转化成大于 0 | ||||
|                 .isNotNull(CrmCustomerDO::getOwnerUserId)); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -30,6 +30,7 @@ public class CrmPermissionUtils { | ||||
|         return SingletonManager.getPermissionApi().hasAnyRoles(getLoginUserId(), CrmPermissionRoleCodeEnum.CRM_ADMIN.getCode()); | ||||
|     } | ||||
|  | ||||
|     // TODO @puhui999:这个貌似直接放到 CrmPermissionService 会更好? | ||||
|     /** | ||||
|      * 校验权限 | ||||
|      * | ||||
|   | ||||
| @@ -1 +1,4 @@ | ||||
| /** | ||||
|  * TODO 芋艿:临时占位,后续可删除 | ||||
|  */ | ||||
| package cn.iocoder.yudao.module.crm.job; | ||||
| @@ -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<CrmClueDO> clues) { | ||||
|     /** | ||||
|      * 线索被转换客户后,需要将线索的跟进记录,复制到客户上 | ||||
|      * | ||||
|      * @param clues 被转化的线索 | ||||
|      */ | ||||
|     private void copyFollowUpRecords(List<CrmClueDO> clues) { | ||||
|         List<CrmFollowUpRecordDO> followUpRecords = followUpRecordService.getFollowUpRecordByBiz( | ||||
|                 CrmBizTypeEnum.CRM_LEADS.getType(), convertSet(clues, CrmClueDO::getId)); | ||||
|         if (CollUtil.isEmpty(followUpRecords)) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         Map<Long, CrmClueDO> clueMap = convertMap(clues, CrmClueDO::getId); | ||||
|         // 创建跟进 | ||||
|         Map<Long, CrmClueDO> 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()))); | ||||
|   | ||||
| @@ -126,6 +126,7 @@ public interface CrmCustomerService { | ||||
|      */ | ||||
|     void receiveCustomer(List<Long> ids, Long ownerUserId, Boolean isReceive); | ||||
|  | ||||
|     // TODO @puhui999:autoPutCustomerPool,注释说明是系统就好哈; | ||||
|     /** | ||||
|      * 【系统】客户自动掉入公海 | ||||
|      * | ||||
|   | ||||
| @@ -28,9 +28,9 @@ public interface CrmFollowUpRecordService { | ||||
|     /** | ||||
|      * 创建更进 | ||||
|      * | ||||
|      * @param followUpCreateReqBOs 请求 | ||||
|      * @param list 请求 | ||||
|      */ | ||||
|     void createFollowUpRecordBatch(List<CrmFollowUpCreateReqBO> followUpCreateReqBOs); | ||||
|     void createFollowUpRecordBatch(List<CrmFollowUpCreateReqBO> list); | ||||
|  | ||||
|     /** | ||||
|      * 删除跟进记录 (数据权限基于 bizType、 bizId) | ||||
|   | ||||
| @@ -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<CrmFollowUpCreateReqBO> followUpCreateReqBOs) { | ||||
|         if (CollUtil.isEmpty(followUpCreateReqBOs)) { | ||||
|     public void createFollowUpRecordBatch(List<CrmFollowUpCreateReqBO> list) { | ||||
|         if (CollUtil.isEmpty(list)) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         crmFollowUpRecordMapper.insertBatch(BeanUtils.toBean(followUpCreateReqBOs, CrmFollowUpRecordDO.class)); | ||||
|         crmFollowUpRecordMapper.insertBatch(BeanUtils.toBean(list, CrmFollowUpRecordDO.class)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV