📖 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")
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;

View File

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

View File

@ -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
/**
* 数量
*/

View File

@ -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<CrmBusinessProduct
delete(CrmBusinessProductDO::getBusinessId, id);
}
default CrmBusinessProductDO selectByBusinessId(Long id) { // TODO @lzxhqsid 最好改成 businessId上面也是这样一看更容易懂
default CrmBusinessProductDO selectByBusinessId(Long id) {
return selectOne(CrmBusinessProductDO::getBusinessId, id);
}
}

View File

@ -66,7 +66,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
return selectCount(CrmContractDO::getContactId, contactId);
}
default Long selectCountByBusinessId(Long businessId) { // TODO @lzxhqs1方法和方法之间要有空行2selectCountByBusinessId一个是应该求数量一个是不要缩写 BizId 可读性
default Long selectCountByBusinessId(Long 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;
// TODO @lzxhqs方法名上带下 BusinessProduct主要考虑不精简的原因是因为一个逻辑可能会出现一些超越它自身方法省略不容易懂
/**
* 商机产品关联表 Service 接口
*

View File

@ -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<CrmBusinessProductDO> list) {
businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list,CrmBusinessProductDO::getId));
businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list, CrmBusinessProductDO::getId));
}
@Override
public void deleteByBusinessId(Long businessId) {
businessProductMapper.deleteByBusinessId(businessId);
}
}

View File

@ -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<CrmBusinessProductSaveReqVO> products, Long businessId, Boolean updateFlag) {
// TODO @lzxhqs可以用 CollectionUtils.convertList
List<CrmBusinessProductDO> 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 @lzxhqscreateBusinessProducts 可以抽成两个方法一个新增一个修改修改需要把 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);

View File

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

View File

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

View File

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