Commit b9f1e8ffaf831e03867a063d21e4a61bd31c7623

Authored by YunaiV
1 parent 02324f9e

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

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