📖 CRM:线索的 code review

This commit is contained in:
YunaiV 2024-01-15 12:29:57 +08:00
parent 4ca1f72d4f
commit 9b7f6cfbac
2 changed files with 7 additions and 6 deletions

View File

@ -14,8 +14,8 @@ public interface ErrorCodeConstants {
// ========== 线索管理 1-020-001-000 ========== // ========== 线索管理 1-020-001-000 ==========
ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在");
ErrorCode ANY_CLUE_NOT_EXISTS = new ErrorCode(1_020_001_001, "线索【{}】不存在"); ErrorCode CLUE_ANY_CLUE_NOT_EXISTS = new ErrorCode(1_020_001_001, "线索【{}】不存在");
ErrorCode ANY_CLUE_ALREADY_TRANSLATED = new ErrorCode(1_020_001_002, "线索【{}】已经转化过了,请勿重复转化"); ErrorCode CLUE_ANY_CLUE_ALREADY_TRANSLATED = new ErrorCode(1_020_001_002, "线索【{}】已经转化过了,请勿重复转化");
// ========== 商机管理 1-020-002-000 ========== // ========== 商机管理 1-020-002-000 ==========
ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在");

View File

@ -138,19 +138,20 @@ public class CrmClueServiceImpl implements CrmClueService {
Set<Long> clueIds = reqVO.getIds(); Set<Long> clueIds = reqVO.getIds();
List<CrmClueDO> clues = getClueList(clueIds, userId); List<CrmClueDO> clues = getClueList(clueIds, userId);
if (CollUtil.isEmpty(clues) || ObjectUtil.notEqual(clues.size(), clueIds.size())) { if (CollUtil.isEmpty(clues) || ObjectUtil.notEqual(clues.size(), clueIds.size())) {
// 提示不存在的线索编号
clueIds.removeAll(convertSet(clues, CrmClueDO::getId)); clueIds.removeAll(convertSet(clues, CrmClueDO::getId));
throw exception(ANY_CLUE_NOT_EXISTS, clueIds.stream().map(String::valueOf).collect(Collectors.joining(","))); // TODO @min可以使用 StrUtil.join(",", clueIds) 简化这种常见操作
throw exception(CLUE_ANY_CLUE_NOT_EXISTS, clueIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
} }
// 过滤出未转化的客户 // 过滤出未转化的客户
// TODO @min1存在已经转化的直接提示哈避免操作的用户以为都转化成功了2常见的过滤逻辑可以使用 CollectionUtils.filterList()
List<CrmClueDO> unTransformClues = clues.stream() List<CrmClueDO> unTransformClues = clues.stream()
.filter(clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus())).toList(); .filter(clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus())).toList();
// 传入的线索中包含已经转化的情况抛出业务异常 // 传入的线索中包含已经转化的情况抛出业务异常
if (ObjectUtil.notEqual(clues.size(), unTransformClues.size())) { if (ObjectUtil.notEqual(clues.size(), unTransformClues.size())) {
// 提示已经转化的线索编号 // TODO @min可以使用 StrUtil.join(",", clueIds) 简化这种常见操作
clueIds.removeAll(convertSet(unTransformClues, CrmClueDO::getId)); clueIds.removeAll(convertSet(unTransformClues, CrmClueDO::getId));
throw exception(ANY_CLUE_ALREADY_TRANSLATED, clueIds.stream().map(String::valueOf).collect(Collectors.joining(","))); throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, clueIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
} }
// 遍历线索(未转化的线索)创建对应的客户 // 遍历线索(未转化的线索)创建对应的客户