From a86bce6f8baf21950c5fbd9b14e2554a2d2974f3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 23 Jan 2024 09:35:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9Acode=20review=20?= =?UTF-8?q?=E5=95=86=E6=9C=BA=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/product/CrmBusinessProductSaveReqVO.java | 3 --- .../crm/dal/dataobject/business/CrmBusinessDO.java | 2 -- .../dataobject/business/CrmBusinessProductDO.java | 2 -- .../dal/mysql/business/CrmBusinessProductMapper.java | 5 +++-- .../crm/dal/mysql/contract/CrmContractMapper.java | 2 +- .../service/business/CrmBusinessProductService.java | 1 + .../business/CrmBusinessProductServiceImpl.java | 6 ++++-- .../crm/service/business/CrmBusinessServiceImpl.java | 12 ++---------- .../service/contact/CrmContactBusinessService.java | 4 +++- .../crm/service/contract/CrmContractService.java | 2 +- .../followup/CrmFollowUpRecordServiceImpl.java | 1 + 11 files changed, 16 insertions(+), 24 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/product/CrmBusinessProductSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/product/CrmBusinessProductSaveReqVO.java index 86598bad5..f28f0f350 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/product/CrmBusinessProductSaveReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/product/CrmBusinessProductSaveReqVO.java @@ -14,12 +14,10 @@ public class CrmBusinessProductSaveReqVO { @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") private Long id; - // TODO @lzxhqs:这个字段,应该是 Long 类型 @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") @NotNull(message = "商机编号不能为空") private Long businessId; - // TODO @lzxhqs:这个字段,应该是 Long 类型 @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") @NotNull(message = "产品编号不能为空") private Long productId; @@ -44,7 +42,6 @@ public class CrmBusinessProductSaveReqVO { @NotNull(message = "小计(折扣后价格)不能为空") private BigDecimal subtotal; - // TODO @lzxhqs:字符串,用 @NotEmpty,因为要考虑 "" 前端搞了这个玩意 @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") @NotEmpty(message = "单位不能为空") private String unit; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java index e8df68d2d..3a543712b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -95,8 +95,6 @@ public class CrmBusinessDO extends BaseDO { private LocalDateTime contactLastTime; /** * 跟进状态 - * - * TODO @lzxhqs:目前就是 Boolean;是否跟进 */ private Boolean followUpStatus; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java index 776d537ef..b1275f4c5 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java @@ -44,7 +44,6 @@ public class CrmBusinessProductDO extends BaseDO { */ private Long productId; - // TODO @lzxhqs:改成 Integer,单位:分。目前整体倾向放大 100 倍哈 /** * 产品单价 */ @@ -55,7 +54,6 @@ public class CrmBusinessProductDO extends BaseDO { */ private BigDecimal salesPrice; - // TODO @lzxhqs:改成 count /** * 数量 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java index ab84b2958..1730067fe 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; import org.apache.ibatis.annotations.Mapper; /** - * 商机产品 Mapper // TODO @lzxhqs:类注释,和作者之间要有一个空行 + * 商机产品 Mapper * * @author lzxhqs */ @@ -17,7 +17,8 @@ public interface CrmBusinessProductMapper extends BaseMapperX { return selectCount(CrmContractDO::getContactId, contactId); } - default Long selectCountByBusinessId(Long businessId) { // TODO @lzxhqs:1)方法和方法之间要有空行;2)selectCountByBusinessId,一个是应该求数量,一个是不要缩写 BizId 可读性; + default Long selectCountByBusinessId(Long businessId) { return selectCount(CrmContractDO::getBusinessId, businessId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductService.java index 16dfce371..010be4a92 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductService.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; import java.util.List; +// TODO @lzxhqs:方法名上,带下 BusinessProduct;主要考虑不精简的原因,是因为一个逻辑,可能会出现一些超越它自身方法,省略不容易懂; /** * 商机产品关联表 Service 接口 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductServiceImpl.java index ec52a9d9f..afad6ae31 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductServiceImpl.java @@ -17,6 +17,7 @@ import java.util.List; @Service @Validated public class CrmBusinessProductServiceImpl implements CrmBusinessProductService { + @Resource private CrmBusinessProductMapper businessProductMapper; @@ -35,14 +36,15 @@ public class CrmBusinessProductServiceImpl implements CrmBusinessProductService businessProductMapper.updateBatch(list); } + // TODO @lzxhqs:这个方法,可以直接调用 deleteList 方法,然后传递 ids 就好了; @Override public void deleteBatch(List list) { - businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list,CrmBusinessProductDO::getId)); - + businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list, CrmBusinessProductDO::getId)); } @Override public void deleteByBusinessId(Long businessId) { businessProductMapper.deleteByBusinessId(businessId); } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index abe55bc5f..716485007 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -55,12 +55,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @Resource private CrmBusinessProductService businessProductService; - // TODO @lzxhqs:不直接调用这个 mapper,要调用对方的 service;每个业务独立收敛 @Resource private CrmContractService contractService; - - // TODO @lzxhqs:不直接调用这个 mapper,要调用对方的 service;每个业务独立收敛 - @Resource private CrmPermissionService permissionService; @Resource @@ -77,8 +73,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { .setOwnerUserId(userId); businessMapper.insert(business); // TODO 商机待定:插入商机与产品的关联表;校验商品存在 - // TODO lzxhqs:新增时,是不是不用调用这个方法哈; - // TODO @lzxhqs:用 CollUtils.isNotEmpty; if (CollUtil.isNotEmpty(createReqVO.getProducts())) { createBusinessProducts(createReqVO.getProducts(), business.getId(), false); } @@ -108,7 +102,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { contactBusiness.setBusinessId(businessId); contactBusiness.setContactId(contactId); contactBusinessService.insert(contactBusiness); - } // TODO @lzxhqs:这个方法注释格式不对;删除@description,然后把 插入商机产品关联表 作为方法注释; @@ -121,7 +114,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { * @author lzxhqs */ private void createBusinessProducts(List products, Long businessId, Boolean updateFlag) { - // TODO @lzxhqs:可以用 CollectionUtils.convertList; List list = CollectionUtils.convertList(products, product -> CrmBusinessProductConvert.INSTANCE.convert(product).setBusinessId(businessId)); if (Boolean.TRUE.equals(updateFlag)) { @@ -141,7 +133,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { } else { businessProductService.insertBatch(list); } - } @Override @@ -157,7 +148,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); businessMapper.updateById(updateObj); // TODO 商机待定:插入商机与产品的关联表;校验商品存在 - // TODO @lzxhqs:更新时,可以调用 CollectionUtils 的 diffList,尽量避免这种先删除再插入;而是新增的插入、变更的更新,没的删除;不然这个表每次更新,会多好多数据; + // TODO @lzxhqs:createBusinessProducts 可以抽成两个方法,一个新增;一个修改,修改需要把 businessProductService.deleteByBusinessId(updateReqVO.getId()); 一起处理进去; if (CollUtil.isNotEmpty(updateReqVO.getProducts())) { createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId(), true); } else { @@ -202,6 +193,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { * @author lzxhqs */ private void validateContractExists(Long businessId) { + // TODO @lzxhqs:保持风格的统一,selectCountByBusinessId 改成 getContractCountByBusinessId;另外,可以不用声明 count,因为就一次性使用,直接把 197 和 198 合并成一行; Long count = contractService.selectCountByBusinessId(businessId); if (count > 0) { throw exception(BUSINESS_CONTRACT_EXISTS); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java index 7816040fb..8a9c4192f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactBusinessService.java @@ -43,8 +43,10 @@ public interface CrmContactBusinessService { List getContactBusinessListByContactId(Long contactId); /** - * 新增联系人与商机的 + * 新增联系人与商机的关联 + * * @param contactBusiness 新增联系人与商机的对象 */ void insert(CrmContactBusinessDO contactBusiness); + } \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java index ae1347853..6695e4f5d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java @@ -111,7 +111,7 @@ public interface CrmContractService { Long getContractCountByCustomerId(Long customerId); /** - * 根据商机ID获取关联客户的合同数量 + * 根据商机ID获取关联客户的合同数量 TODO @lzxhqs:1)方法注释,和参数注释之间要有空行;2)中英文之间有空格,更清晰,例如说 商机 ID * @param businessId 商机ID * @return 数量 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java index e63631e4a..dc2001565 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/followup/CrmFollowUpRecordServiceImpl.java @@ -94,6 +94,7 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService { customerService.updateCustomerFollowUp(updateFollowUpReqBO); } + // TODO @puhui999:这两个,不更新 contactLastTime、contactLastContent,只更新 nextTime // 3.1 更新 contactIds 对应的记录 if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId));