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