📖 CRM:【联系人】code review 商机的代码,补全对应的 todo list

This commit is contained in:
YunaiV 2024-01-04 07:53:00 +08:00
parent 02324f9e60
commit b9f1e8ffaf
4 changed files with 23 additions and 22 deletions

View File

@ -50,6 +50,7 @@ public class CrmBusinessController {
@Resource @Resource
private CrmBusinessStatusService businessStatusService; private CrmBusinessStatusService businessStatusService;
// TODO @商机待定CrmBusinessCreateReqVOCrmBusinessUpdateReqVOCrmBusinessRespVO 按照新的 VO 规范
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建商机") @Operation(summary = "创建商机")
@PreAuthorize("@ss.hasPermission('crm:business:create')") @PreAuthorize("@ss.hasPermission('crm:business:create')")

View File

@ -1,4 +0,0 @@
/**
* 商机销售机会
*/
package cn.iocoder.yudao.module.crm.dal.dataobject.business;

View File

@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -45,22 +44,22 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
@Resource @Resource
private CrmPermissionService permissionService; private CrmPermissionService permissionService;
@Resource @Resource
private CrmContactService contactService;
@Resource
private CrmContactBusinessService contactBusinessService; private CrmContactBusinessService contactBusinessService;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
// TODO @商机待定操作日志
public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) { public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) {
// 插入 // 1. 插入商机
CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO); CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO);
businessMapper.insert(business); businessMapper.insert(business);
// TODO 商机待定插入商机与产品的关联表校验商品存在
// 创建数据权限 // TODO 商机待定在联系人的详情页如果直接新建商机则需要关联下这里要搞个 CrmContactBusinessDO
// 2. 创建数据权限
permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())
.setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人
// 返回
return business.getId(); return business.getId();
} }
@ -68,12 +67,17 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id",
level = CrmPermissionLevelEnum.WRITE) level = CrmPermissionLevelEnum.WRITE)
// TODO @商机待定操作日志
public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) { public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) {
// 校验存在 // 1. 校验存在
validateBusinessExists(updateReqVO.getId()); validateBusinessExists(updateReqVO.getId());
// 更新
// 2. 更新商机
CrmBusinessDO updateObj = CrmBusinessConvert.INSTANCE.convert(updateReqVO); CrmBusinessDO updateObj = CrmBusinessConvert.INSTANCE.convert(updateReqVO);
businessMapper.updateById(updateObj); businessMapper.updateById(updateObj);
// TODO 商机待定插入商机与产品的关联表校验商品存在
// TODO @商机待定如果状态发生变化插入商机状态变更记录表
} }
@Override @Override
@ -82,6 +86,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
public void deleteBusiness(Long id) { public void deleteBusiness(Long id) {
// 校验存在 // 校验存在
validateBusinessExists(id); validateBusinessExists(id);
// TODO @商机待定需要校验有没关联合同CrmContractDO businessId 字段
// 删除 // 删除
businessMapper.deleteById(id); businessMapper.deleteById(id);
// 删除数据权限 // 删除数据权限
@ -137,6 +143,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
// TODO @puhui999操作日志
public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) {
// 1 校验商机是否存在 // 1 校验商机是否存在
validateBusinessExists(reqVO.getId()); validateBusinessExists(reqVO.getId());
@ -146,8 +153,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()));
// 2.2 设置新的负责人 // 2.2 设置新的负责人
businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
// 3. TODO 记录转移日志
} }
} }

View File

@ -40,7 +40,7 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
validateParentProductCategory(createReqVO.getParentId()); validateParentProductCategory(createReqVO.getParentId());
// 1.2 分类名称是否存在 // 1.2 分类名称是否存在
validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName()); validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName());
// 2. 插入 // 2. 插入分类
CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class);
productCategoryMapper.insert(category); productCategoryMapper.insert(category);
return category.getId(); return category.getId();
@ -54,7 +54,7 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
validateParentProductCategory(updateReqVO.getParentId()); validateParentProductCategory(updateReqVO.getParentId());
// 1.3 分类名称是否存在 // 1.3 分类名称是否存在
validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
// 2. 更新 // 2. 更新分类
CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class); CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class);
productCategoryMapper.updateById(updateObj); productCategoryMapper.updateById(updateObj);
} }
@ -92,18 +92,17 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
@Override @Override
public void deleteProductCategory(Long id) { public void deleteProductCategory(Long id) {
// TODO zange参考 mall ProductCategoryServiceImpl 补充下必要的参数校验 // 1.1 校验存在
// 校验存在
validateProductCategoryExists(id); validateProductCategoryExists(id);
// 校验是否还有子分类 // 1.2 校验是否还有子分类
if (productCategoryMapper.selectCountByParentId(id) > 0) { if (productCategoryMapper.selectCountByParentId(id) > 0) {
throw exception(product_CATEGORY_EXISTS_CHILDREN); throw exception(product_CATEGORY_EXISTS_CHILDREN);
} }
// 校验是否被产品使用 // 1.3 校验是否被产品使用
if (crmProductService.getProductByCategoryId(id) !=null) { if (crmProductService.getProductByCategoryId(id) !=null) {
throw exception(PRODUCT_CATEGORY_USED); throw exception(PRODUCT_CATEGORY_USED);
} }
// 删除 // 2. 删除
productCategoryMapper.deleteById(id); productCategoryMapper.deleteById(id);
} }