Commit 39ae547b9d9730e9dcd9960a7a426bf87fc44b15
1 parent
180a6269
📖 CRM:code review 线索逻辑
Showing
1 changed file
with
7 additions
and
11 deletions
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 { | @@ -69,7 +69,6 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 69 | @Transactional(rollbackFor = Exception.class) | 69 | @Transactional(rollbackFor = Exception.class) |
| 70 | @LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}", | 70 | @LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}", |
| 71 | success = CRM_LEADS_CREATE_SUCCESS) | 71 | success = CRM_LEADS_CREATE_SUCCESS) |
| 72 | - // TODO @min:补充相关几个方法的操作日志; | ||
| 73 | public Long createClue(CrmClueSaveReqVO createReqVO) { | 72 | public Long createClue(CrmClueSaveReqVO createReqVO) { |
| 74 | // 1. 校验关联数据 | 73 | // 1. 校验关联数据 |
| 75 | validateRelationDataExists(createReqVO); | 74 | validateRelationDataExists(createReqVO); |
| @@ -111,7 +110,6 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -111,7 +110,6 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 111 | // 3. 记录操作日志上下文 | 110 | // 3. 记录操作日志上下文 |
| 112 | LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldClue, CrmCustomerSaveReqVO.class)); | 111 | LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldClue, CrmCustomerSaveReqVO.class)); |
| 113 | LogRecordContext.putVariable("clueName", oldClue.getName()); | 112 | LogRecordContext.putVariable("clueName", oldClue.getName()); |
| 114 | - | ||
| 115 | } | 113 | } |
| 116 | 114 | ||
| 117 | @Override | 115 | @Override |
| @@ -189,23 +187,21 @@ public class CrmClueServiceImpl implements CrmClueService { | @@ -189,23 +187,21 @@ public class CrmClueServiceImpl implements CrmClueService { | ||
| 189 | throw exception(CLUE_ANY_CLUE_NOT_EXISTS, StrUtil.join(",", clueIds)); | 187 | throw exception(CLUE_ANY_CLUE_NOT_EXISTS, StrUtil.join(",", clueIds)); |
| 190 | } | 188 | } |
| 191 | 189 | ||
| 192 | - // 过滤出未转化的客户 | ||
| 193 | - List<CrmClueDO> unTransformClues = CollectionUtils.filterList(clues, | ||
| 194 | - clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus())); | ||
| 195 | // 存在已经转化的,直接提示哈。避免操作的用户,以为都转化成功了 | 190 | // 存在已经转化的,直接提示哈。避免操作的用户,以为都转化成功了 |
| 196 | - if (ObjectUtil.notEqual(clues.size(), unTransformClues.size())) { | ||
| 197 | - clueIds.removeAll(convertSet(unTransformClues, CrmClueDO::getId)); | ||
| 198 | - throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, StrUtil.join(",", clueIds)); | 191 | + List<CrmClueDO> translatedClues = CollectionUtils.filterList(clues, |
| 192 | + clue -> ObjectUtil.equal(Boolean.TRUE, clue.getTransformStatus())); | ||
| 193 | + if (CollUtil.isNotEmpty(translatedClues)) { | ||
| 194 | + throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, StrUtil.join(",", convertSet(translatedClues, CrmClueDO::getId))); | ||
| 199 | } | 195 | } |
| 200 | 196 | ||
| 201 | // 遍历线索(未转化的线索),创建对应的客户 | 197 | // 遍历线索(未转化的线索),创建对应的客户 |
| 202 | - unTransformClues.forEach(clue -> { | 198 | + reqVO.getIds().forEach(id -> { |
| 203 | // 1. 创建客户 | 199 | // 1. 创建客户 |
| 204 | - CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(clue, CrmCustomerSaveReqVO.class).setId(null); | 200 | + CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(id, CrmCustomerSaveReqVO.class).setId(null); |
| 205 | Long customerId = customerService.createCustomer(customerSaveReqVO, userId); | 201 | Long customerId = customerService.createCustomer(customerSaveReqVO, userId); |
| 206 | // TODO @puhui999:如果有跟进记录,需要一起转过去;提问:艿艿这里是复制线索所有的跟进吗?还是直接把线索相关的跟进 bizType、bizId 全改为关联客户? | 202 | // TODO @puhui999:如果有跟进记录,需要一起转过去;提问:艿艿这里是复制线索所有的跟进吗?还是直接把线索相关的跟进 bizType、bizId 全改为关联客户? |
| 207 | // 2. 更新线索 | 203 | // 2. 更新线索 |
| 208 | - clueMapper.updateById(new CrmClueDO().setId(clue.getId()) | 204 | + clueMapper.updateById(new CrmClueDO().setId(id) |
| 209 | .setTransformStatus(Boolean.TRUE).setCustomerId(customerId)); | 205 | .setTransformStatus(Boolean.TRUE).setCustomerId(customerId)); |
| 210 | }); | 206 | }); |
| 211 | } | 207 | } |