📖 CRM:code review 商机模块

This commit is contained in:
YunaiV 2024-01-23 09:35:45 +08:00
parent 655fc03394
commit a86bce6f8b
11 changed files with 16 additions and 24 deletions

View File

@ -14,12 +14,10 @@ public class CrmBusinessProductSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
private Long id; private Long id;
// TODO @lzxhqs这个字段应该是 Long 类型
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "商机编号不能为空") @NotNull(message = "商机编号不能为空")
private Long businessId; private Long businessId;
// TODO @lzxhqs这个字段应该是 Long 类型
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "产品编号不能为空") @NotNull(message = "产品编号不能为空")
private Long productId; private Long productId;
@ -44,7 +42,6 @@ public class CrmBusinessProductSaveReqVO {
@NotNull(message = "小计(折扣后价格)不能为空") @NotNull(message = "小计(折扣后价格)不能为空")
private BigDecimal subtotal; private BigDecimal subtotal;
// TODO @lzxhqs字符串 @NotEmpty因为要考虑 "" 前端搞了这个玩意
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotEmpty(message = "单位不能为空") @NotEmpty(message = "单位不能为空")
private String unit; private String unit;

View File

@ -95,8 +95,6 @@ public class CrmBusinessDO extends BaseDO {
private LocalDateTime contactLastTime; private LocalDateTime contactLastTime;
/** /**
* 跟进状态 * 跟进状态
*
* TODO @lzxhqs目前就是 Boolean是否跟进
*/ */
private Boolean followUpStatus; private Boolean followUpStatus;

View File

@ -44,7 +44,6 @@ public class CrmBusinessProductDO extends BaseDO {
*/ */
private Long productId; private Long productId;
// TODO @lzxhqs改成 Integer单位目前整体倾向放大 100 倍哈
/** /**
* 产品单价 * 产品单价
*/ */
@ -55,7 +54,6 @@ public class CrmBusinessProductDO extends BaseDO {
*/ */
private BigDecimal salesPrice; private BigDecimal salesPrice;
// TODO @lzxhqs改成 count
/** /**
* 数量 * 数量
*/ */

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
* 商机产品 Mapper // TODO @lzxhqs类注释和作者之间要有一个空行 * 商机产品 Mapper
* *
* @author lzxhqs * @author lzxhqs
*/ */
@ -17,7 +17,8 @@ public interface CrmBusinessProductMapper extends BaseMapperX<CrmBusinessProduct
delete(CrmBusinessProductDO::getBusinessId, id); delete(CrmBusinessProductDO::getBusinessId, id);
} }
default CrmBusinessProductDO selectByBusinessId(Long id) { // TODO @lzxhqsid 最好改成 businessId上面也是这样一看更容易懂 default CrmBusinessProductDO selectByBusinessId(Long id) {
return selectOne(CrmBusinessProductDO::getBusinessId, id); return selectOne(CrmBusinessProductDO::getBusinessId, id);
} }
} }

View File

@ -66,7 +66,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
return selectCount(CrmContractDO::getContactId, contactId); return selectCount(CrmContractDO::getContactId, contactId);
} }
default Long selectCountByBusinessId(Long businessId) { // TODO @lzxhqs1方法和方法之间要有空行2selectCountByBusinessId一个是应该求数量一个是不要缩写 BizId 可读性 default Long selectCountByBusinessId(Long businessId) {
return selectCount(CrmContractDO::getBusinessId, businessId); return selectCount(CrmContractDO::getBusinessId, businessId);
} }

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
import java.util.List; import java.util.List;
// TODO @lzxhqs方法名上带下 BusinessProduct主要考虑不精简的原因是因为一个逻辑可能会出现一些超越它自身方法省略不容易懂
/** /**
* 商机产品关联表 Service 接口 * 商机产品关联表 Service 接口
* *

View File

@ -17,6 +17,7 @@ import java.util.List;
@Service @Service
@Validated @Validated
public class CrmBusinessProductServiceImpl implements CrmBusinessProductService { public class CrmBusinessProductServiceImpl implements CrmBusinessProductService {
@Resource @Resource
private CrmBusinessProductMapper businessProductMapper; private CrmBusinessProductMapper businessProductMapper;
@ -35,14 +36,15 @@ public class CrmBusinessProductServiceImpl implements CrmBusinessProductService
businessProductMapper.updateBatch(list); businessProductMapper.updateBatch(list);
} }
// TODO @lzxhqs这个方法可以直接调用 deleteList 方法然后传递 ids 就好了
@Override @Override
public void deleteBatch(List<CrmBusinessProductDO> list) { public void deleteBatch(List<CrmBusinessProductDO> list) {
businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list,CrmBusinessProductDO::getId)); businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list, CrmBusinessProductDO::getId));
} }
@Override @Override
public void deleteByBusinessId(Long businessId) { public void deleteByBusinessId(Long businessId) {
businessProductMapper.deleteByBusinessId(businessId); businessProductMapper.deleteByBusinessId(businessId);
} }
} }

View File

@ -55,12 +55,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
@Resource @Resource
private CrmBusinessProductService businessProductService; private CrmBusinessProductService businessProductService;
// TODO @lzxhqs不直接调用这个 mapper要调用对方的 service每个业务独立收敛
@Resource @Resource
private CrmContractService contractService; private CrmContractService contractService;
// TODO @lzxhqs不直接调用这个 mapper要调用对方的 service每个业务独立收敛
@Resource @Resource
private CrmPermissionService permissionService; private CrmPermissionService permissionService;
@Resource @Resource
@ -77,8 +73,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
.setOwnerUserId(userId); .setOwnerUserId(userId);
businessMapper.insert(business); businessMapper.insert(business);
// TODO 商机待定插入商机与产品的关联表校验商品存在 // TODO 商机待定插入商机与产品的关联表校验商品存在
// TODO lzxhqs新增时是不是不用调用这个方法哈
// TODO @lzxhqs CollUtils.isNotEmpty
if (CollUtil.isNotEmpty(createReqVO.getProducts())) { if (CollUtil.isNotEmpty(createReqVO.getProducts())) {
createBusinessProducts(createReqVO.getProducts(), business.getId(), false); createBusinessProducts(createReqVO.getProducts(), business.getId(), false);
} }
@ -108,7 +102,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
contactBusiness.setBusinessId(businessId); contactBusiness.setBusinessId(businessId);
contactBusiness.setContactId(contactId); contactBusiness.setContactId(contactId);
contactBusinessService.insert(contactBusiness); contactBusinessService.insert(contactBusiness);
} }
// TODO @lzxhqs这个方法注释格式不对删除@description然后把 插入商机产品关联表 作为方法注释 // TODO @lzxhqs这个方法注释格式不对删除@description然后把 插入商机产品关联表 作为方法注释
@ -121,7 +114,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
* @author lzxhqs * @author lzxhqs
*/ */
private void createBusinessProducts(List<CrmBusinessProductSaveReqVO> products, Long businessId, Boolean updateFlag) { private void createBusinessProducts(List<CrmBusinessProductSaveReqVO> products, Long businessId, Boolean updateFlag) {
// TODO @lzxhqs可以用 CollectionUtils.convertList
List<CrmBusinessProductDO> list = CollectionUtils.convertList(products, product -> List<CrmBusinessProductDO> list = CollectionUtils.convertList(products, product ->
CrmBusinessProductConvert.INSTANCE.convert(product).setBusinessId(businessId)); CrmBusinessProductConvert.INSTANCE.convert(product).setBusinessId(businessId));
if (Boolean.TRUE.equals(updateFlag)) { if (Boolean.TRUE.equals(updateFlag)) {
@ -141,7 +133,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
} else { } else {
businessProductService.insertBatch(list); businessProductService.insertBatch(list);
} }
} }
@Override @Override
@ -157,7 +148,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class);
businessMapper.updateById(updateObj); businessMapper.updateById(updateObj);
// TODO 商机待定插入商机与产品的关联表校验商品存在 // TODO 商机待定插入商机与产品的关联表校验商品存在
// TODO @lzxhqs更新时可以调用 CollectionUtils diffList尽量避免这种先删除再插入而是新增的插入变更的更新没的删除不然这个表每次更新会多好多数据 // TODO @lzxhqscreateBusinessProducts 可以抽成两个方法一个新增一个修改修改需要把 businessProductService.deleteByBusinessId(updateReqVO.getId()); 一起处理进去
if (CollUtil.isNotEmpty(updateReqVO.getProducts())) { if (CollUtil.isNotEmpty(updateReqVO.getProducts())) {
createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId(), true); createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId(), true);
} else { } else {
@ -202,6 +193,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
* @author lzxhqs * @author lzxhqs
*/ */
private void validateContractExists(Long businessId) { private void validateContractExists(Long businessId) {
// TODO @lzxhqs保持风格的统一selectCountByBusinessId 改成 getContractCountByBusinessId另外可以不用声明 count因为就一次性使用直接把 197 198 合并成一行
Long count = contractService.selectCountByBusinessId(businessId); Long count = contractService.selectCountByBusinessId(businessId);
if (count > 0) { if (count > 0) {
throw exception(BUSINESS_CONTRACT_EXISTS); throw exception(BUSINESS_CONTRACT_EXISTS);

View File

@ -43,8 +43,10 @@ public interface CrmContactBusinessService {
List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId); List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId);
/** /**
* 新增联系人与商机的 * 新增联系人与商机的关联
*
* @param contactBusiness 新增联系人与商机的对象 * @param contactBusiness 新增联系人与商机的对象
*/ */
void insert(CrmContactBusinessDO contactBusiness); void insert(CrmContactBusinessDO contactBusiness);
} }

View File

@ -111,7 +111,7 @@ public interface CrmContractService {
Long getContractCountByCustomerId(Long customerId); Long getContractCountByCustomerId(Long customerId);
/** /**
* 根据商机ID获取关联客户的合同数量 * 根据商机ID获取关联客户的合同数量 TODO @lzxhqs1方法注释和参数注释之间要有空行2中英文之间有空格更清晰例如说 商机 ID
* @param businessId 商机ID * @param businessId 商机ID
* @return 数量 * @return 数量
*/ */

View File

@ -94,6 +94,7 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
customerService.updateCustomerFollowUp(updateFollowUpReqBO); customerService.updateCustomerFollowUp(updateFollowUpReqBO);
} }
// TODO @puhui999这两个不更新 contactLastTimecontactLastContent只更新 nextTime
// 3.1 更新 contactIds 对应的记录 // 3.1 更新 contactIds 对应的记录
if (CollUtil.isNotEmpty(createReqVO.getContactIds())) { if (CollUtil.isNotEmpty(createReqVO.getContactIds())) {
contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId)); contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), updateFollowUpReqBO::setBizId));