mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
📖 CRM:code review 线索模块
This commit is contained in:
parent
e4936725f5
commit
6a93484260
@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|||||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||||
import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
|
import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
|
||||||
@ -100,6 +99,7 @@ public class CrmClueController {
|
|||||||
@PostMapping("/transform")
|
@PostMapping("/transform")
|
||||||
@Operation(summary = "线索转化为客户")
|
@Operation(summary = "线索转化为客户")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||||
|
// TODO @min:方法改成 translateCustomer
|
||||||
public CommonResult<Boolean> translate(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
|
public CommonResult<Boolean> translate(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
|
||||||
clueService.translate(reqVO, getLoginUserId());
|
clueService.translate(reqVO, getLoginUserId());
|
||||||
return success(Boolean.TRUE);
|
return success(Boolean.TRUE);
|
||||||
|
@ -4,31 +4,26 @@ import cn.iocoder.yudao.framework.common.validation.Mobile;
|
|||||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author minhx
|
|
||||||
*/
|
|
||||||
@Schema(description = "管理后台 - CRM 线索 创建/更新 Request VO")
|
@Schema(description = "管理后台 - CRM 线索 创建/更新 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class CrmClueSaveReqVO {
|
public class CrmClueSaveReqVO {
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969")
|
@Schema(description = "编号", example = "10969")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx")
|
@Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx")
|
||||||
@NotEmpty(message = "线索名称不能为空")
|
@NotEmpty(message = "线索名称不能为空")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520")
|
// TODO @min:是不是不传递 customerId?
|
||||||
|
@Schema(description = "客户 id", example = "520")
|
||||||
private Long customerId;
|
private Long customerId;
|
||||||
|
|
||||||
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
||||||
@ -50,9 +45,10 @@ public class CrmClueSaveReqVO {
|
|||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime contactLastTime;
|
private LocalDateTime contactLastTime;
|
||||||
|
|
||||||
@Schema(description = "负责人编号")
|
@Schema(description = "负责人编号", example = "2048")
|
||||||
private Long ownerUserId;
|
private Long ownerUserId;
|
||||||
|
|
||||||
@Schema(description = "备注", example = "随便")
|
@Schema(description = "备注", example = "随便")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,11 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author min
|
|
||||||
*/
|
|
||||||
@Schema(description = "管理后台 - 线索转化为客户 Request VO")
|
@Schema(description = "管理后台 - 线索转化为客户 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class CrmClueTransformReqVO {
|
public class CrmClueTransformReqVO {
|
||||||
|
|
||||||
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]")
|
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]")
|
||||||
@NotEmpty(message = "线索编号不能为空") Set<Long> ids;
|
@NotEmpty(message = "线索编号不能为空") Set<Long> ids; // TODO @min:应该空行噢
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.crm.convert.clue;
|
package cn.iocoder.yudao.module.crm.convert.clue;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExcelVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueRespVO;
|
||||||
|
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.dal.dataobject.clue.CrmClueDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
@ -21,6 +23,7 @@ public interface CrmClueConvert {
|
|||||||
|
|
||||||
CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class);
|
CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class);
|
||||||
|
|
||||||
|
// TODO @min:这几个 convert,都使用 BeanUtils 替代哈
|
||||||
CrmClueDO convert(CrmClueSaveReqVO bean);
|
CrmClueDO convert(CrmClueSaveReqVO bean);
|
||||||
|
|
||||||
CrmClueRespVO convert(CrmClueDO bean);
|
CrmClueRespVO convert(CrmClueDO bean);
|
||||||
|
@ -78,6 +78,8 @@ public interface CrmCustomerConvert {
|
|||||||
|
|
||||||
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
|
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
// TODO @min:使用 BeanUtils 拷贝哈。我们慢慢简单的对象,不再直接基于 convert 做啦。
|
||||||
@Mapping(ignore = true, target = "id")
|
@Mapping(ignore = true, target = "id")
|
||||||
CrmCustomerSaveReqVO convert(CrmClueDO bean);
|
CrmCustomerSaveReqVO convert(CrmClueDO bean);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.crm.service.clue;
|
package cn.iocoder.yudao.module.crm.service.clue;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO;
|
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.dal.dataobject.clue.CrmClueDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
@ -78,4 +80,5 @@ public interface CrmClueService {
|
|||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
*/
|
*/
|
||||||
void translate(CrmClueTransformReqVO reqVO, Long userId);
|
void translate(CrmClueTransformReqVO reqVO, Long userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@ package cn.iocoder.yudao.module.crm.service.clue;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO;
|
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.convert.clue.CrmClueConvert;
|
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
||||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
|
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.dataobject.clue.CrmClueDO;
|
||||||
@ -51,6 +53,7 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
// TODO @min:补充相关几个方法的操作日志;
|
||||||
public Long createClue(CrmClueSaveReqVO createReqVO) {
|
public Long createClue(CrmClueSaveReqVO createReqVO) {
|
||||||
// 校验关联数据
|
// 校验关联数据
|
||||||
validateRelationDataExists(createReqVO);
|
validateRelationDataExists(createReqVO);
|
||||||
@ -58,7 +61,6 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|||||||
// 插入
|
// 插入
|
||||||
CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO);
|
CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO);
|
||||||
clueMapper.insert(clue);
|
clueMapper.insert(clue);
|
||||||
System.out.println(1);
|
|
||||||
// 返回
|
// 返回
|
||||||
return clue.getId();
|
return clue.getId();
|
||||||
}
|
}
|
||||||
@ -128,18 +130,20 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void translate(CrmClueTransformReqVO reqVO, Long userId) {
|
public void translate(CrmClueTransformReqVO reqVO, Long userId) {
|
||||||
|
// 校验线索都存在
|
||||||
List<CrmClueDO> clues = getClueList(reqVO.getIds(), userId);
|
List<CrmClueDO> clues = getClueList(reqVO.getIds(), userId);
|
||||||
// 不存在抛出异常
|
|
||||||
if (CollUtil.isEmpty(clues)) {
|
if (CollUtil.isEmpty(clues)) {
|
||||||
throw exception(CLUE_NOT_EXISTS);
|
throw exception(CLUE_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 遍历线索,创建对应的客户
|
// 遍历线索,创建对应的客户
|
||||||
clues.forEach(clueDO -> {
|
clues.forEach(clue -> {
|
||||||
// 创建客户
|
// 创建客户
|
||||||
customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clueDO), userId);
|
customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clue), userId);
|
||||||
// 更新线索状态
|
// 更新线索状态
|
||||||
clueDO.setTransformStatus(Boolean.TRUE);
|
// TODO @min:新建一个 CrmClueDO 去更新。尽量规避直接用原本的对象去更新。因为这样万一并发更新,会存在覆盖的问题。
|
||||||
clueMapper.updateById(clueDO);
|
clue.setTransformStatus(Boolean.TRUE);
|
||||||
|
clueMapper.updateById(clue);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,4 +160,5 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|||||||
throw exception(USER_NOT_EXISTS);
|
throw exception(USER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user