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