Commit a86bce6f8baf21950c5fbd9b14e2554a2d2974f3
1 parent
655fc033
📖 CRM:code review 商机模块
Showing
11 changed files
with
16 additions
and
24 deletions
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 { |
| 14 | 14 | @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") |
| 15 | 15 | private Long id; |
| 16 | 16 | |
| 17 | - // TODO @lzxhqs:这个字段,应该是 Long 类型 | |
| 18 | 17 | @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") |
| 19 | 18 | @NotNull(message = "商机编号不能为空") |
| 20 | 19 | private Long businessId; |
| 21 | 20 | |
| 22 | - // TODO @lzxhqs:这个字段,应该是 Long 类型 | |
| 23 | 21 | @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") |
| 24 | 22 | @NotNull(message = "产品编号不能为空") |
| 25 | 23 | private Long productId; |
| ... | ... | @@ -44,7 +42,6 @@ public class CrmBusinessProductSaveReqVO { |
| 44 | 42 | @NotNull(message = "小计(折扣后价格)不能为空") |
| 45 | 43 | private BigDecimal subtotal; |
| 46 | 44 | |
| 47 | - // TODO @lzxhqs:字符串,用 @NotEmpty,因为要考虑 "" 前端搞了这个玩意 | |
| 48 | 45 | @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") |
| 49 | 46 | @NotEmpty(message = "单位不能为空") |
| 50 | 47 | private String unit; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java
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 { |
| 44 | 44 | */ |
| 45 | 45 | private Long productId; |
| 46 | 46 | |
| 47 | - // TODO @lzxhqs:改成 Integer,单位:分。目前整体倾向放大 100 倍哈 | |
| 48 | 47 | /** |
| 49 | 48 | * 产品单价 |
| 50 | 49 | */ |
| ... | ... | @@ -55,7 +54,6 @@ public class CrmBusinessProductDO extends BaseDO { |
| 55 | 54 | */ |
| 56 | 55 | private BigDecimal salesPrice; |
| 57 | 56 | |
| 58 | - // TODO @lzxhqs:改成 count | |
| 59 | 57 | /** |
| 60 | 58 | * 数量 |
| 61 | 59 | */ | ... | ... |
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; |
| 6 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * 商机产品 Mapper // TODO @lzxhqs:类注释,和作者之间要有一个空行 | |
| 9 | + * 商机产品 Mapper | |
| 10 | 10 | * |
| 11 | 11 | * @author lzxhqs |
| 12 | 12 | */ |
| ... | ... | @@ -17,7 +17,8 @@ public interface CrmBusinessProductMapper extends BaseMapperX<CrmBusinessProduct |
| 17 | 17 | delete(CrmBusinessProductDO::getBusinessId, id); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - default CrmBusinessProductDO selectByBusinessId(Long id) { // TODO @lzxhqs:id 最好改成 businessId,上面也是;这样一看更容易懂 | |
| 20 | + default CrmBusinessProductDO selectByBusinessId(Long id) { | |
| 21 | 21 | return selectOne(CrmBusinessProductDO::getBusinessId, id); |
| 22 | 22 | } |
| 23 | + | |
| 23 | 24 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java
| ... | ... | @@ -66,7 +66,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> { |
| 66 | 66 | return selectCount(CrmContractDO::getContactId, contactId); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - default Long selectCountByBusinessId(Long businessId) { // TODO @lzxhqs:1)方法和方法之间要有空行;2)selectCountByBusinessId,一个是应该求数量,一个是不要缩写 BizId 可读性; | |
| 69 | + default Long selectCountByBusinessId(Long businessId) { | |
| 70 | 70 | return selectCount(CrmContractDO::getBusinessId, businessId); |
| 71 | 71 | } |
| 72 | 72 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductService.java
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; |
| 17 | 17 | @Service |
| 18 | 18 | @Validated |
| 19 | 19 | public class CrmBusinessProductServiceImpl implements CrmBusinessProductService { |
| 20 | + | |
| 20 | 21 | @Resource |
| 21 | 22 | private CrmBusinessProductMapper businessProductMapper; |
| 22 | 23 | |
| ... | ... | @@ -35,14 +36,15 @@ public class CrmBusinessProductServiceImpl implements CrmBusinessProductService |
| 35 | 36 | businessProductMapper.updateBatch(list); |
| 36 | 37 | } |
| 37 | 38 | |
| 39 | + // TODO @lzxhqs:这个方法,可以直接调用 deleteList 方法,然后传递 ids 就好了; | |
| 38 | 40 | @Override |
| 39 | 41 | public void deleteBatch(List<CrmBusinessProductDO> list) { |
| 40 | - businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list,CrmBusinessProductDO::getId)); | |
| 41 | - | |
| 42 | + businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list, CrmBusinessProductDO::getId)); | |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | @Override |
| 45 | 46 | public void deleteByBusinessId(Long businessId) { |
| 46 | 47 | businessProductMapper.deleteByBusinessId(businessId); |
| 47 | 48 | } |
| 49 | + | |
| 48 | 50 | } | ... | ... |
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 { |
| 55 | 55 | |
| 56 | 56 | @Resource |
| 57 | 57 | private CrmBusinessProductService businessProductService; |
| 58 | - // TODO @lzxhqs:不直接调用这个 mapper,要调用对方的 service;每个业务独立收敛 | |
| 59 | 58 | @Resource |
| 60 | 59 | private CrmContractService contractService; |
| 61 | - | |
| 62 | - // TODO @lzxhqs:不直接调用这个 mapper,要调用对方的 service;每个业务独立收敛 | |
| 63 | - | |
| 64 | 60 | @Resource |
| 65 | 61 | private CrmPermissionService permissionService; |
| 66 | 62 | @Resource |
| ... | ... | @@ -77,8 +73,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 77 | 73 | .setOwnerUserId(userId); |
| 78 | 74 | businessMapper.insert(business); |
| 79 | 75 | // TODO 商机待定:插入商机与产品的关联表;校验商品存在 |
| 80 | - // TODO lzxhqs:新增时,是不是不用调用这个方法哈; | |
| 81 | - // TODO @lzxhqs:用 CollUtils.isNotEmpty; | |
| 82 | 76 | if (CollUtil.isNotEmpty(createReqVO.getProducts())) { |
| 83 | 77 | createBusinessProducts(createReqVO.getProducts(), business.getId(), false); |
| 84 | 78 | } |
| ... | ... | @@ -108,7 +102,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 108 | 102 | contactBusiness.setBusinessId(businessId); |
| 109 | 103 | contactBusiness.setContactId(contactId); |
| 110 | 104 | contactBusinessService.insert(contactBusiness); |
| 111 | - | |
| 112 | 105 | } |
| 113 | 106 | |
| 114 | 107 | // TODO @lzxhqs:这个方法注释格式不对;删除@description,然后把 插入商机产品关联表 作为方法注释; |
| ... | ... | @@ -121,7 +114,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 121 | 114 | * @author lzxhqs |
| 122 | 115 | */ |
| 123 | 116 | private void createBusinessProducts(List<CrmBusinessProductSaveReqVO> products, Long businessId, Boolean updateFlag) { |
| 124 | - // TODO @lzxhqs:可以用 CollectionUtils.convertList; | |
| 125 | 117 | List<CrmBusinessProductDO> list = CollectionUtils.convertList(products, product -> |
| 126 | 118 | CrmBusinessProductConvert.INSTANCE.convert(product).setBusinessId(businessId)); |
| 127 | 119 | if (Boolean.TRUE.equals(updateFlag)) { |
| ... | ... | @@ -141,7 +133,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 141 | 133 | } else { |
| 142 | 134 | businessProductService.insertBatch(list); |
| 143 | 135 | } |
| 144 | - | |
| 145 | 136 | } |
| 146 | 137 | |
| 147 | 138 | @Override |
| ... | ... | @@ -157,7 +148,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 157 | 148 | CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); |
| 158 | 149 | businessMapper.updateById(updateObj); |
| 159 | 150 | // TODO 商机待定:插入商机与产品的关联表;校验商品存在 |
| 160 | - // TODO @lzxhqs:更新时,可以调用 CollectionUtils 的 diffList,尽量避免这种先删除再插入;而是新增的插入、变更的更新,没的删除;不然这个表每次更新,会多好多数据; | |
| 151 | + // TODO @lzxhqs:createBusinessProducts 可以抽成两个方法,一个新增;一个修改,修改需要把 businessProductService.deleteByBusinessId(updateReqVO.getId()); 一起处理进去; | |
| 161 | 152 | if (CollUtil.isNotEmpty(updateReqVO.getProducts())) { |
| 162 | 153 | createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId(), true); |
| 163 | 154 | } else { |
| ... | ... | @@ -202,6 +193,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 202 | 193 | * @author lzxhqs |
| 203 | 194 | */ |
| 204 | 195 | private void validateContractExists(Long businessId) { |
| 196 | + // TODO @lzxhqs:保持风格的统一,selectCountByBusinessId 改成 getContractCountByBusinessId;另外,可以不用声明 count,因为就一次性使用,直接把 197 和 198 合并成一行; | |
| 205 | 197 | Long count = contractService.selectCountByBusinessId(businessId); |
| 206 | 198 | if (count > 0) { |
| 207 | 199 | throw exception(BUSINESS_CONTRACT_EXISTS); | ... | ... |
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 { |
| 43 | 43 | List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId); |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | - * 新增联系人与商机的 | |
| 46 | + * 新增联系人与商机的关联 | |
| 47 | + * | |
| 47 | 48 | * @param contactBusiness 新增联系人与商机的对象 |
| 48 | 49 | */ |
| 49 | 50 | void insert(CrmContactBusinessDO contactBusiness); |
| 51 | + | |
| 50 | 52 | } |
| 51 | 53 | \ No newline at end of file | ... | ... |
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 { |
| 111 | 111 | Long getContractCountByCustomerId(Long customerId); |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | - * 根据商机ID获取关联客户的合同数量 | |
| 114 | + * 根据商机ID获取关联客户的合同数量 TODO @lzxhqs:1)方法注释,和参数注释之间要有空行;2)中英文之间有空格,更清晰,例如说 商机 ID | |
| 115 | 115 | * @param businessId 商机ID |
| 116 | 116 | * @return 数量 |
| 117 | 117 | */ | ... | ... |
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 { |
| 94 | 94 | customerService.updateCustomerFollowUp(updateFollowUpReqBO); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | + // TODO @puhui999:这两个,不更新 contactLastTime、contactLastContent,只更新 nextTime | |
| 97 | 98 | // 3.1 更新 contactIds 对应的记录 |
| 98 | 99 | if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { |
| 99 | 100 | contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId)); | ... | ... |