mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
📖 CRM:code review 商机模块
This commit is contained in:
parent
655fc03394
commit
a86bce6f8b
@ -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;
|
||||
|
@ -95,8 +95,6 @@ public class CrmBusinessDO extends BaseDO {
|
||||
private LocalDateTime contactLastTime;
|
||||
/**
|
||||
* 跟进状态
|
||||
*
|
||||
* TODO @lzxhqs:目前就是 Boolean;是否跟进
|
||||
*/
|
||||
private Boolean followUpStatus;
|
||||
|
||||
|
@ -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
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
|
@ -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 @lzxhqs:id 最好改成 businessId,上面也是;这样一看更容易懂
|
||||
default CrmBusinessProductDO selectByBusinessId(Long id) {
|
||||
return selectOne(CrmBusinessProductDO::getBusinessId, id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// TODO @lzxhqs:方法名上,带下 BusinessProduct;主要考虑不精简的原因,是因为一个逻辑,可能会出现一些超越它自身方法,省略不容易懂;
|
||||
/**
|
||||
* 商机产品关联表 Service 接口
|
||||
*
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 @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);
|
||||
|
@ -43,8 +43,10 @@ public interface CrmContactBusinessService {
|
||||
List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId);
|
||||
|
||||
/**
|
||||
* 新增联系人与商机的
|
||||
* 新增联系人与商机的关联
|
||||
*
|
||||
* @param contactBusiness 新增联系人与商机的对象
|
||||
*/
|
||||
void insert(CrmContactBusinessDO contactBusiness);
|
||||
|
||||
}
|
@ -111,7 +111,7 @@ public interface CrmContractService {
|
||||
Long getContractCountByCustomerId(Long customerId);
|
||||
|
||||
/**
|
||||
* 根据商机ID获取关联客户的合同数量
|
||||
* 根据商机ID获取关联客户的合同数量 TODO @lzxhqs:1)方法注释,和参数注释之间要有空行;2)中英文之间有空格,更清晰,例如说 商机 ID
|
||||
* @param businessId 商机ID
|
||||
* @return 数量
|
||||
*/
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user