From df29f0682f4a52a79ea0eb919096350750d996f0 Mon Sep 17 00:00:00 2001
From: YunaiV <zhijiantianya@gmail.com>
Date: Sat, 13 Jan 2024 11:07:28 +0800
Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9A=E7=BA=BF=E7=B4=A2?=
 =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84=20review?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../crm/service/clue/CrmClueServiceImpl.java       | 14 +++++---------
 1 file changed, 5 insertions(+), 9 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 b87fd547e..e40731616 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
@@ -141,17 +141,13 @@ public class CrmClueServiceImpl implements CrmClueService {
         // 遍历线索(过滤掉已转化的线索),创建对应的客户
         clues.stream().filter(clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus()))
                 .forEach(clue -> {
-                    // 1.创建客户
-                    CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(clue, CrmCustomerSaveReqVO.class)
-                            .setId(null);
+                    // 1. 创建客户
+                    CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(clue, CrmCustomerSaveReqVO.class).setId(null);
                     Long customerId = customerService.createCustomer(customerSaveReqVO, userId);
                     // TODO @puhui999:如果有跟进记录,需要一起转过去;
-                    // 2.更新线索,新建一个 CrmClueDO 去更新。尽量规避直接用原本的对象去更新。因为这样万一并发更新,会存在覆盖的问题。
-                    clueMapper.updateById(BeanUtils.toBean(clue, CrmClueDO.class)
-                            // 线索状态设置为已转化
-                            .setTransformStatus(Boolean.TRUE)
-                            // 设置关联的客户编号
-                            .setCustomerId(customerId));
+                    // 2. 更新线索
+                    clueMapper.updateById(new CrmClueDO().setId(clue.getId())
+                            .setTransformStatus(Boolean.TRUE).setCustomerId(customerId));
                 });
     }