mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
CRM:【线索】转化为客户接口修改
This commit is contained in:
parent
722b33513c
commit
1280f49a04
@ -99,9 +99,8 @@ public class CrmClueController {
|
||||
@PostMapping("/transform")
|
||||
@Operation(summary = "线索转化为客户")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||
// TODO @min:方法改成 translateCustomer
|
||||
public CommonResult<Boolean> translate(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
|
||||
clueService.translate(reqVO, getLoginUserId());
|
||||
public CommonResult<Boolean> translateCustomer(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
|
||||
clueService.translateCustomer(reqVO, getLoginUserId());
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import java.util.Set;
|
||||
public class CrmClueTransformReqVO {
|
||||
|
||||
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]")
|
||||
@NotEmpty(message = "线索编号不能为空") Set<Long> ids; // TODO @min:应该空行噢
|
||||
@NotEmpty(message = "线索编号不能为空")
|
||||
private Set<Long> ids;
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ 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;
|
||||
@ -78,8 +77,4 @@ public interface CrmCustomerConvert {
|
||||
|
||||
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
|
||||
|
||||
// TODO @min:使用 BeanUtils 拷贝哈。我们慢慢简单的对象,不再直接基于 convert 做啦。
|
||||
@Mapping(ignore = true, target = "id")
|
||||
CrmCustomerSaveReqVO convert(CrmClueDO bean);
|
||||
|
||||
}
|
||||
|
@ -79,6 +79,6 @@ public interface CrmClueService {
|
||||
* @param reqVO 线索编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void translate(CrmClueTransformReqVO reqVO, Long userId);
|
||||
void translateCustomer(CrmClueTransformReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,15 @@ package cn.iocoder.yudao.module.crm.service.clue;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||
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;
|
||||
@ -129,23 +131,27 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void translate(CrmClueTransformReqVO reqVO, Long userId) {
|
||||
public void translateCustomer(CrmClueTransformReqVO reqVO, Long userId) {
|
||||
// 校验线索都存在
|
||||
List<CrmClueDO> clues = getClueList(reqVO.getIds(), userId);
|
||||
if (CollUtil.isEmpty(clues)) {
|
||||
throw exception(CLUE_NOT_EXISTS);
|
||||
}
|
||||
// TODO @min:如果已经转化,则不能重复转化
|
||||
|
||||
// 遍历线索,创建对应的客户
|
||||
clues.forEach(clue -> {
|
||||
// 创建客户
|
||||
customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clue), userId);
|
||||
// 更新线索状态
|
||||
// TODO @min:新建一个 CrmClueDO 去更新。尽量规避直接用原本的对象去更新。因为这样万一并发更新,会存在覆盖的问题。
|
||||
// 遍历线索(过滤掉已转化的线索),创建对应的客户
|
||||
clues.stream().filter(clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus()))
|
||||
.forEach(clue -> {
|
||||
// 1.创建客户
|
||||
CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(clue, CrmCustomerSaveReqVO.class)
|
||||
.setId(null);
|
||||
Long customerId = customerService.createCustomer(customerSaveReqVO, userId);
|
||||
// TODO @puhui999:如果有跟进记录,需要一起转过去;
|
||||
clue.setTransformStatus(Boolean.TRUE);
|
||||
clueMapper.updateById(clue);
|
||||
// 2.更新线索,新建一个 CrmClueDO 去更新。尽量规避直接用原本的对象去更新。因为这样万一并发更新,会存在覆盖的问题。
|
||||
clueMapper.updateById(BeanUtils.toBean(clue, CrmClueDO.class)
|
||||
// 线索状态设置为已转化
|
||||
.setTransformStatus(Boolean.TRUE)
|
||||
// 设置关联的客户编号
|
||||
.setCustomerId(customerId));
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user