mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
CRM:【线索】线索转化为客户
This commit is contained in:
parent
63db275af1
commit
4237cfb4a9
@ -96,4 +96,12 @@ public class CrmClueController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/transform")
|
||||
@Operation(summary = "线索转化为客户")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||
public CommonResult<Boolean> translate(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
|
||||
clueService.translate(reqVO, getLoginUserId());
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author min
|
||||
*/
|
||||
@Schema(description = "管理后台 - 线索转化为客户 Request VO")
|
||||
@Data
|
||||
public class CrmClueTransformReqVO {
|
||||
|
||||
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]")
|
||||
@NotEmpty(message = "线索编号不能为空") Set<Long> ids;
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveR
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||
@ -77,4 +78,6 @@ public interface CrmCustomerConvert {
|
||||
|
||||
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
|
||||
|
||||
@Mapping(ignore = true, target = "id")
|
||||
CrmCustomerSaveReqVO convert(CrmClueDO bean);
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.service.clue;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@ -73,4 +70,11 @@ public interface CrmClueService {
|
||||
*/
|
||||
void transferClue(CrmClueTransferReqVO reqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 线索转化为客户
|
||||
*
|
||||
* @param reqVO 线索编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void translate(CrmClueTransformReqVO reqVO, Long userId);
|
||||
}
|
||||
|
@ -3,11 +3,9 @@ package cn.iocoder.yudao.module.crm.service.clue;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
@ -17,6 +15,7 @@ import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -108,12 +107,28 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
validateClueExists(reqVO.getId());
|
||||
|
||||
// 2.1 数据权限转移
|
||||
crmPermissionService.transferPermission(
|
||||
CrmClueConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_LEADS.getType()));
|
||||
crmPermissionService.transferPermission(CrmClueConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_LEADS.getType()));
|
||||
// 2.2 设置新的负责人
|
||||
clueMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
||||
// 3. TODO 记录转移日志
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void translate(CrmClueTransformReqVO reqVO, Long userId) {
|
||||
List<CrmClueDO> clues = getClueList(reqVO.getIds(), userId);
|
||||
// 不存在抛出异常
|
||||
if (CollUtil.isEmpty(clues)) {
|
||||
throw exception(CLUE_NOT_EXISTS);
|
||||
}
|
||||
// 遍历线索,创建对应的客户
|
||||
clues.forEach(clueDO -> {
|
||||
// 创建客户
|
||||
customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clueDO), userId);
|
||||
// 更新线索状态
|
||||
clueDO.setTransformStatus(Boolean.TRUE);
|
||||
clueMapper.updateById(clueDO);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user