From 39ae547b9d9730e9dcd9960a7a426bf87fc44b15 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 20 Jan 2024 18:55:28 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9Acode=20review=20?= =?UTF-8?q?=E7=BA=BF=E7=B4=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crm/service/clue/CrmClueServiceImpl.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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 0d2be4ba9..0185c3206 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 @@ -69,7 +69,6 @@ public class CrmClueServiceImpl implements CrmClueService { @Transactional(rollbackFor = Exception.class) @LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}", success = CRM_LEADS_CREATE_SUCCESS) - // TODO @min:补充相关几个方法的操作日志; public Long createClue(CrmClueSaveReqVO createReqVO) { // 1. 校验关联数据 validateRelationDataExists(createReqVO); @@ -111,7 +110,6 @@ public class CrmClueServiceImpl implements CrmClueService { // 3. 记录操作日志上下文 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldClue, CrmCustomerSaveReqVO.class)); LogRecordContext.putVariable("clueName", oldClue.getName()); - } @Override @@ -189,23 +187,21 @@ public class CrmClueServiceImpl implements CrmClueService { throw exception(CLUE_ANY_CLUE_NOT_EXISTS, StrUtil.join(",", clueIds)); } - // 过滤出未转化的客户 - List unTransformClues = CollectionUtils.filterList(clues, - clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus())); // 存在已经转化的,直接提示哈。避免操作的用户,以为都转化成功了 - if (ObjectUtil.notEqual(clues.size(), unTransformClues.size())) { - clueIds.removeAll(convertSet(unTransformClues, CrmClueDO::getId)); - throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, StrUtil.join(",", clueIds)); + List translatedClues = CollectionUtils.filterList(clues, + clue -> ObjectUtil.equal(Boolean.TRUE, clue.getTransformStatus())); + if (CollUtil.isNotEmpty(translatedClues)) { + throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, StrUtil.join(",", convertSet(translatedClues, CrmClueDO::getId))); } // 遍历线索(未转化的线索),创建对应的客户 - unTransformClues.forEach(clue -> { + reqVO.getIds().forEach(id -> { // 1. 创建客户 - CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(clue, CrmCustomerSaveReqVO.class).setId(null); + CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(id, CrmCustomerSaveReqVO.class).setId(null); Long customerId = customerService.createCustomer(customerSaveReqVO, userId); // TODO @puhui999:如果有跟进记录,需要一起转过去;提问:艿艿这里是复制线索所有的跟进吗?还是直接把线索相关的跟进 bizType、bizId 全改为关联客户? // 2. 更新线索 - clueMapper.updateById(new CrmClueDO().setId(clue.getId()) + clueMapper.updateById(new CrmClueDO().setId(id) .setTransformStatus(Boolean.TRUE).setCustomerId(customerId)); }); }