Commit b9f1e8ffaf831e03867a063d21e4a61bd31c7623
1 parent
02324f9e
📖 CRM:【联系人】code review 商机的代码,补全对应的 todo list
Showing
4 changed files
with
23 additions
and
22 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| @@ -50,6 +50,7 @@ public class CrmBusinessController { | @@ -50,6 +50,7 @@ public class CrmBusinessController { | ||
| 50 | @Resource | 50 | @Resource |
| 51 | private CrmBusinessStatusService businessStatusService; | 51 | private CrmBusinessStatusService businessStatusService; |
| 52 | 52 | ||
| 53 | + // TODO @商机待定:CrmBusinessCreateReqVO、CrmBusinessUpdateReqVO、CrmBusinessRespVO 按照新的 VO 规范 | ||
| 53 | @PostMapping("/create") | 54 | @PostMapping("/create") |
| 54 | @Operation(summary = "创建商机") | 55 | @Operation(summary = "创建商机") |
| 55 | @PreAuthorize("@ss.hasPermission('crm:business:create')") | 56 | @PreAuthorize("@ss.hasPermission('crm:business:create')") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java deleted
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | @@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 15 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | 15 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 16 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; | 16 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| 17 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; | 17 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; |
| 18 | -import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; | ||
| 19 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; | 18 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 20 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; | 19 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 21 | import jakarta.annotation.Resource; | 20 | import jakarta.annotation.Resource; |
| @@ -45,22 +44,22 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -45,22 +44,22 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 45 | @Resource | 44 | @Resource |
| 46 | private CrmPermissionService permissionService; | 45 | private CrmPermissionService permissionService; |
| 47 | @Resource | 46 | @Resource |
| 48 | - private CrmContactService contactService; | ||
| 49 | - @Resource | ||
| 50 | private CrmContactBusinessService contactBusinessService; | 47 | private CrmContactBusinessService contactBusinessService; |
| 51 | 48 | ||
| 52 | @Override | 49 | @Override |
| 53 | @Transactional(rollbackFor = Exception.class) | 50 | @Transactional(rollbackFor = Exception.class) |
| 51 | + // TODO @商机待定:操作日志; | ||
| 54 | public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) { | 52 | public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) { |
| 55 | - // 插入 | 53 | + // 1. 插入商机 |
| 56 | CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO); | 54 | CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO); |
| 57 | businessMapper.insert(business); | 55 | businessMapper.insert(business); |
| 56 | + // TODO 商机待定:插入商机与产品的关联表;校验商品存在 | ||
| 57 | + | ||
| 58 | + // TODO 商机待定:在联系人的详情页,如果直接【新建商机】,则需要关联下。这里要搞个 CrmContactBusinessDO 表 | ||
| 58 | 59 | ||
| 59 | - // 创建数据权限 | 60 | + // 2. 创建数据权限 |
| 60 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) | 61 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) |
| 61 | .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 | 62 | .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 |
| 62 | - | ||
| 63 | - // 返回 | ||
| 64 | return business.getId(); | 63 | return business.getId(); |
| 65 | } | 64 | } |
| 66 | 65 | ||
| @@ -68,12 +67,17 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -68,12 +67,17 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 68 | @Transactional(rollbackFor = Exception.class) | 67 | @Transactional(rollbackFor = Exception.class) |
| 69 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", | 68 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#updateReqVO.id", |
| 70 | level = CrmPermissionLevelEnum.WRITE) | 69 | level = CrmPermissionLevelEnum.WRITE) |
| 70 | + // TODO @商机待定:操作日志; | ||
| 71 | public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) { | 71 | public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) { |
| 72 | - // 校验存在 | 72 | + // 1. 校验存在 |
| 73 | validateBusinessExists(updateReqVO.getId()); | 73 | validateBusinessExists(updateReqVO.getId()); |
| 74 | - // 更新 | 74 | + |
| 75 | + // 2. 更新商机 | ||
| 75 | CrmBusinessDO updateObj = CrmBusinessConvert.INSTANCE.convert(updateReqVO); | 76 | CrmBusinessDO updateObj = CrmBusinessConvert.INSTANCE.convert(updateReqVO); |
| 76 | businessMapper.updateById(updateObj); | 77 | businessMapper.updateById(updateObj); |
| 78 | + // TODO 商机待定:插入商机与产品的关联表;校验商品存在 | ||
| 79 | + | ||
| 80 | + // TODO @商机待定:如果状态发生变化,插入商机状态变更记录表 | ||
| 77 | } | 81 | } |
| 78 | 82 | ||
| 79 | @Override | 83 | @Override |
| @@ -82,6 +86,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -82,6 +86,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 82 | public void deleteBusiness(Long id) { | 86 | public void deleteBusiness(Long id) { |
| 83 | // 校验存在 | 87 | // 校验存在 |
| 84 | validateBusinessExists(id); | 88 | validateBusinessExists(id); |
| 89 | + // TODO @商机待定:需要校验有没关联合同。CrmContractDO 的 businessId 字段 | ||
| 90 | + | ||
| 85 | // 删除 | 91 | // 删除 |
| 86 | businessMapper.deleteById(id); | 92 | businessMapper.deleteById(id); |
| 87 | // 删除数据权限 | 93 | // 删除数据权限 |
| @@ -137,6 +143,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -137,6 +143,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 137 | 143 | ||
| 138 | @Override | 144 | @Override |
| 139 | @Transactional(rollbackFor = Exception.class) | 145 | @Transactional(rollbackFor = Exception.class) |
| 146 | + // TODO @puhui999:操作日志 | ||
| 140 | public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { | 147 | public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { |
| 141 | // 1 校验商机是否存在 | 148 | // 1 校验商机是否存在 |
| 142 | validateBusinessExists(reqVO.getId()); | 149 | validateBusinessExists(reqVO.getId()); |
| @@ -146,8 +153,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -146,8 +153,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 146 | CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); | 153 | CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())); |
| 147 | // 2.2 设置新的负责人 | 154 | // 2.2 设置新的负责人 |
| 148 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | 155 | businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); |
| 149 | - | ||
| 150 | - // 3. TODO 记录转移日志 | ||
| 151 | } | 156 | } |
| 152 | 157 | ||
| 153 | } | 158 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java
| @@ -40,7 +40,7 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService | @@ -40,7 +40,7 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService | ||
| 40 | validateParentProductCategory(createReqVO.getParentId()); | 40 | validateParentProductCategory(createReqVO.getParentId()); |
| 41 | // 1.2 分类名称是否存在 | 41 | // 1.2 分类名称是否存在 |
| 42 | validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName()); | 42 | validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName()); |
| 43 | - // 2. 插入 | 43 | + // 2. 插入分类 |
| 44 | CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); | 44 | CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); |
| 45 | productCategoryMapper.insert(category); | 45 | productCategoryMapper.insert(category); |
| 46 | return category.getId(); | 46 | return category.getId(); |
| @@ -54,7 +54,7 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService | @@ -54,7 +54,7 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService | ||
| 54 | validateParentProductCategory(updateReqVO.getParentId()); | 54 | validateParentProductCategory(updateReqVO.getParentId()); |
| 55 | // 1.3 分类名称是否存在 | 55 | // 1.3 分类名称是否存在 |
| 56 | validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); | 56 | validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName()); |
| 57 | - // 2. 更新 | 57 | + // 2. 更新分类 |
| 58 | CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class); | 58 | CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class); |
| 59 | productCategoryMapper.updateById(updateObj); | 59 | productCategoryMapper.updateById(updateObj); |
| 60 | } | 60 | } |
| @@ -92,18 +92,17 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService | @@ -92,18 +92,17 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService | ||
| 92 | 92 | ||
| 93 | @Override | 93 | @Override |
| 94 | public void deleteProductCategory(Long id) { | 94 | public void deleteProductCategory(Long id) { |
| 95 | - // TODO zange:参考 mall: ProductCategoryServiceImpl 补充下必要的参数校验; | ||
| 96 | - // 校验存在 | 95 | + // 1.1 校验存在 |
| 97 | validateProductCategoryExists(id); | 96 | validateProductCategoryExists(id); |
| 98 | - // 校验是否还有子分类 | 97 | + // 1.2 校验是否还有子分类 |
| 99 | if (productCategoryMapper.selectCountByParentId(id) > 0) { | 98 | if (productCategoryMapper.selectCountByParentId(id) > 0) { |
| 100 | throw exception(product_CATEGORY_EXISTS_CHILDREN); | 99 | throw exception(product_CATEGORY_EXISTS_CHILDREN); |
| 101 | } | 100 | } |
| 102 | - // 校验是否被产品使用 | 101 | + // 1.3 校验是否被产品使用 |
| 103 | if (crmProductService.getProductByCategoryId(id) !=null) { | 102 | if (crmProductService.getProductByCategoryId(id) !=null) { |
| 104 | throw exception(PRODUCT_CATEGORY_USED); | 103 | throw exception(PRODUCT_CATEGORY_USED); |
| 105 | } | 104 | } |
| 106 | - // 删除 | 105 | + // 2. 删除 |
| 107 | productCategoryMapper.deleteById(id); | 106 | productCategoryMapper.deleteById(id); |
| 108 | } | 107 | } |
| 109 | 108 |