CRM-客户:精简 VO
This commit is contained in:
parent
e6f4c1f0d5
commit
ea4b4b8956
|
@ -1,6 +1,6 @@
|
||||||
package cn.iocoder.yudao.framework.operatelog.config;
|
package cn.iocoder.yudao.framework.operatelog.config;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.service.ILogRecordServiceImpl;
|
import cn.iocoder.yudao.framework.operatelog.core.service.LogRecordServiceImpl;
|
||||||
import com.mzt.logapi.service.ILogRecordService;
|
import com.mzt.logapi.service.ILogRecordService;
|
||||||
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -21,7 +21,7 @@ public class YudaoOperateLogV2Configuration {
|
||||||
@Bean
|
@Bean
|
||||||
@Primary
|
@Primary
|
||||||
public ILogRecordService iLogRecordServiceImpl() {
|
public ILogRecordService iLogRecordServiceImpl() {
|
||||||
return new ILogRecordServiceImpl();
|
return new LogRecordServiceImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ package cn.iocoder.yudao.framework.operatelog.core.service;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2CreateReqDTO;
|
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2CreateReqDTO;
|
||||||
import com.mzt.logapi.beans.LogRecord;
|
import com.mzt.logapi.beans.LogRecord;
|
||||||
|
@ -13,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
// TODO @puhui999:LogRecordServiceImpl 改成这个名字哈
|
|
||||||
/**
|
/**
|
||||||
* 操作日志 ILogRecordService 实现类
|
* 操作日志 ILogRecordService 实现类
|
||||||
*
|
*
|
||||||
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ILogRecordServiceImpl implements ILogRecordService {
|
public class LogRecordServiceImpl implements ILogRecordService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OperateLogApi operateLogApi;
|
private OperateLogApi operateLogApi;
|
||||||
|
@ -46,9 +46,13 @@ public class ILogRecordServiceImpl implements ILogRecordService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fillUserFields(OperateLogV2CreateReqDTO reqDTO) {
|
private static void fillUserFields(OperateLogV2CreateReqDTO reqDTO) {
|
||||||
// TODO @puhui999:使用 SecurityFrameworkUtils。因为要考虑,rpc、mq、job,它其实不是 web;
|
// 使用 SecurityFrameworkUtils。因为要考虑,rpc、mq、job,它其实不是 web;
|
||||||
reqDTO.setUserId(WebFrameworkUtils.getLoginUserId());
|
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
reqDTO.setUserType(WebFrameworkUtils.getLoginUserType());
|
if (loginUser == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reqDTO.setUserId(loginUser.getId());
|
||||||
|
reqDTO.setUserType(loginUser.getUserType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void fillModuleFields(OperateLogV2CreateReqDTO reqDTO, LogRecord logRecord) {
|
public static void fillModuleFields(OperateLogV2CreateReqDTO reqDTO, LogRecord logRecord) {
|
|
@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
||||||
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.customer.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
||||||
|
@ -19,7 +18,6 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
@ -58,28 +56,24 @@ public class CrmCustomerController {
|
||||||
@Resource
|
@Resource
|
||||||
private OperateLogApi operateLogApi;
|
private OperateLogApi operateLogApi;
|
||||||
|
|
||||||
// TODO @puhui999:把 CrmCustomerCreateReqVO、CrmCustomerUpdateReqVO、CrmCustomerRespVO 按照新的规范,搞一下哈;
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建客户")
|
@Operation(summary = "创建客户")
|
||||||
@OperateLog(enable = false) // TODO 关闭原有日志记录;@puhui999:注解都先删除。先记录,没关系。我们下个迭代,就都删除掉操作日志了;
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:create')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:create')")
|
||||||
public CommonResult<Long> createCustomer(@Valid @RequestBody CrmCustomerCreateReqVO createReqVO) {
|
public CommonResult<Long> createCustomer(@Valid @RequestBody CrmCustomerSaveReqVO createReqVO) {
|
||||||
return success(customerService.createCustomer(createReqVO, getLoginUserId()));
|
return success(customerService.createCustomer(createReqVO, getLoginUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新客户")
|
@Operation(summary = "更新客户")
|
||||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||||
public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) {
|
public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerSaveReqVO updateReqVO) {
|
||||||
customerService.updateCustomer(updateReqVO);
|
customerService.updateCustomer(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/delete")
|
@DeleteMapping("/delete")
|
||||||
@Operation(summary = "删除客户")
|
@Operation(summary = "删除客户")
|
||||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
@Parameter(name = "id", description = "客户编号", required = true)
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:delete')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:delete')")
|
||||||
public CommonResult<Boolean> deleteCustomer(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> deleteCustomer(@RequestParam("id") Long id) {
|
||||||
customerService.deleteCustomer(id);
|
customerService.deleteCustomer(id);
|
||||||
|
@ -103,7 +97,6 @@ public class CrmCustomerController {
|
||||||
return success(CrmCustomerConvert.INSTANCE.convert(customer, userMap, deptMap));
|
return success(CrmCustomerConvert.INSTANCE.convert(customer, userMap, deptMap));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999:这个查询会查出多个;微信发你图了
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得客户分页")
|
@Operation(summary = "获得客户分页")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
||||||
|
@ -131,32 +124,32 @@ public class CrmCustomerController {
|
||||||
pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||||
List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList();
|
List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
List<CrmCustomerExcelVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list);
|
List<CrmCustomerRespVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list);
|
||||||
ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas);
|
ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class, datas);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/transfer")
|
@PutMapping("/transfer")
|
||||||
@Operation(summary = "转移客户")
|
@Operation(summary = "转移客户")
|
||||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) {
|
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) {
|
||||||
customerService.transferCustomer(reqVO, getLoginUserId());
|
customerService.transferCustomer(reqVO, getLoginUserId());
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999:是不是接口只要传递 bizId,由 Controller 自己组装出 OperateLogV2PageReqDTO
|
|
||||||
@GetMapping("/operate-log-page")
|
@GetMapping("/operate-log-page")
|
||||||
@Operation(summary = "获得客户操作日志")
|
@Operation(summary = "获得客户操作日志")
|
||||||
|
@Parameter(name = "id", description = "客户编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
||||||
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(CrmCustomerOperateLogPageReqVO reqVO) {
|
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("id") Long id) {
|
||||||
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
OperateLogV2PageReqDTO reqDTO = new OperateLogV2PageReqDTO();
|
||||||
reqVO.setBizType(CRM_CUSTOMER);
|
reqDTO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||||
return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class)));
|
reqDTO.setBizType(CRM_CUSTOMER);
|
||||||
|
reqDTO.setBizId(id);
|
||||||
|
return success(operateLogApi.getOperateLogPage(reqDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/lock")
|
@PutMapping("/lock")
|
||||||
@Operation(summary = "锁定/解锁客户")
|
@Operation(summary = "锁定/解锁客户")
|
||||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||||
public CommonResult<Boolean> lockCustomer(@Valid @RequestBody CrmCustomerLockReqVO lockReqVO) {
|
public CommonResult<Boolean> lockCustomer(@Valid @RequestBody CrmCustomerLockReqVO lockReqVO) {
|
||||||
customerService.lockCustomer(lockReqVO, getLoginUserId());
|
customerService.lockCustomer(lockReqVO, getLoginUserId());
|
||||||
|
@ -167,7 +160,6 @@ public class CrmCustomerController {
|
||||||
|
|
||||||
@PutMapping("/put-pool")
|
@PutMapping("/put-pool")
|
||||||
@Operation(summary = "数据放入公海")
|
@Operation(summary = "数据放入公海")
|
||||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
|
||||||
@Parameter(name = "id", description = "客户编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "客户编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||||
public CommonResult<Boolean> putCustomerPool(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> putCustomerPool(@RequestParam("id") Long id) {
|
||||||
|
@ -184,28 +176,22 @@ public class CrmCustomerController {
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO @puhui999:需要搞个 VO 类
|
|
||||||
@PutMapping("/distribute")
|
@PutMapping("/distribute")
|
||||||
@Operation(summary = "分配公海给对应负责人")
|
@Operation(summary = "分配公海给对应负责人")
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = "ids", description = "客户编号数组", required = true, example = "1,2,3"),
|
|
||||||
@Parameter(name = "ownerUserId", description = "分配的负责人编号", required = true, example = "12345")
|
|
||||||
})
|
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:distribute')")
|
@PreAuthorize("@ss.hasPermission('crm:customer:distribute')")
|
||||||
public CommonResult<Boolean> distributeCustomer(@RequestParam(value = "ids") List<Long> ids,
|
public CommonResult<Boolean> distributeCustomer(@Valid @RequestBody CrmCustomerDistributeReqVO distributeReqVO) {
|
||||||
@RequestParam(value = "ownerUserId") Long ownerUserId) {
|
customerService.receiveCustomer(distributeReqVO.getIds(), distributeReqVO.getOwnerUserId());
|
||||||
customerService.receiveCustomer(ids, ownerUserId);
|
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 芋艿:这个接口要调整下
|
// TODO 芋艿:这个接口要调整下
|
||||||
@GetMapping("/query-all-list")
|
//@GetMapping("/query-all-list")
|
||||||
@Operation(summary = "查询客户列表")
|
//@Operation(summary = "查询客户列表")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer:all')")
|
//@PreAuthorize("@ss.hasPermission('crm:customer:all')")
|
||||||
public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll() {
|
//public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll() {
|
||||||
List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList();
|
// List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList();
|
||||||
List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList);
|
// List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList);
|
||||||
return success(data);
|
// return success(data);
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 客户创建 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
|
||||||
@NotNull(message = "负责人不能为空")
|
|
||||||
private Long ownerUserId;
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - CRM 客户分配公海给对应负责人 Request VO")
|
||||||
|
@Data
|
||||||
|
public class CrmCustomerDistributeReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]")
|
||||||
|
@NotNull(message = "客户编号不能为空")
|
||||||
|
private List<Long> ids;
|
||||||
|
|
||||||
|
@Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
@NotNull(message = "负责人不能为空")
|
||||||
|
private Long ownerUserId;
|
||||||
|
|
||||||
|
}
|
|
@ -1,93 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
|
||||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
// TODO 芋艿:导出最后做,等基本确认的差不多之后;
|
|
||||||
/**
|
|
||||||
* CRM 客户 Excel VO
|
|
||||||
*
|
|
||||||
* @author Wanwan
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CrmCustomerExcelVO {
|
|
||||||
|
|
||||||
@ExcelProperty("编号")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@ExcelProperty("客户名称")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
|
|
||||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
|
||||||
private Boolean followUpStatus;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "锁定状态", converter = DictConvert.class)
|
|
||||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
|
||||||
private Boolean lockStatus;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "成交状态", converter = DictConvert.class)
|
|
||||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
|
||||||
private Boolean dealStatus;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
|
|
||||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY)
|
|
||||||
private Integer industryId;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
|
|
||||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL)
|
|
||||||
private Integer level;
|
|
||||||
|
|
||||||
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
|
|
||||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE)
|
|
||||||
private Integer source;
|
|
||||||
|
|
||||||
@ExcelProperty("手机")
|
|
||||||
private String mobile;
|
|
||||||
|
|
||||||
@ExcelProperty("电话")
|
|
||||||
private String telephone;
|
|
||||||
|
|
||||||
@ExcelProperty("网址")
|
|
||||||
private String website;
|
|
||||||
|
|
||||||
@ExcelProperty("QQ")
|
|
||||||
private String qq;
|
|
||||||
|
|
||||||
@ExcelProperty("wechat")
|
|
||||||
private String wechat;
|
|
||||||
|
|
||||||
@ExcelProperty("email")
|
|
||||||
private String email;
|
|
||||||
|
|
||||||
@ExcelProperty("客户描述")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@ExcelProperty("备注")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
@ExcelProperty("负责人的用户编号")
|
|
||||||
private Long ownerUserId;
|
|
||||||
|
|
||||||
@ExcelProperty("地区编号")
|
|
||||||
private Integer areaId;
|
|
||||||
|
|
||||||
@ExcelProperty("详细地址")
|
|
||||||
private String detailAddress;
|
|
||||||
|
|
||||||
@ExcelProperty("最后跟进时间")
|
|
||||||
private LocalDateTime contactLastTime;
|
|
||||||
|
|
||||||
@ExcelProperty("下次联系时间")
|
|
||||||
private LocalDateTime contactNextTime;
|
|
||||||
|
|
||||||
@ExcelProperty("创建时间")
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - crm 客户操作日志分页 Request VO")
|
|
||||||
@Data
|
|
||||||
public class CrmCustomerOperateLogPageReqVO extends PageParam {
|
|
||||||
|
|
||||||
@Schema(description = "模块数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Long bizId;
|
|
||||||
|
|
||||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
@Schema(description = "模块类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
|
||||||
private String bizType;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
// TODO 芋艿:这块要统一下;
|
|
||||||
@Schema(description = "管理后台 - CRM 全部客户 Response VO")
|
|
||||||
@Data
|
|
||||||
public class CrmCustomerQueryAllRespVO{
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,9 +1,12 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
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;
|
||||||
|
@ -12,45 +15,121 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 客户 Response VO")
|
@Schema(description = "管理后台 - CRM 客户 Response VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@ExcelIgnoreUnannotated
|
||||||
@ToString(callSuper = true)
|
public class CrmCustomerRespVO {
|
||||||
public class CrmCustomerRespVO extends CrmCustomerBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty("编号")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty("客户名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
|
||||||
|
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||||
private Boolean followUpStatus;
|
private Boolean followUpStatus;
|
||||||
|
|
||||||
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty(value = "锁定状态", converter = DictConvert.class)
|
||||||
|
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||||
private Boolean lockStatus;
|
private Boolean lockStatus;
|
||||||
|
|
||||||
@Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
@Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty(value = "成交状态", converter = DictConvert.class)
|
||||||
|
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||||
private Boolean dealStatus;
|
private Boolean dealStatus;
|
||||||
|
|
||||||
|
@Schema(description = "所属行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
|
||||||
|
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY)
|
||||||
|
private Integer industryId;
|
||||||
|
|
||||||
|
@Schema(description = "客户等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
|
||||||
|
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL)
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
@Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
|
||||||
|
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE)
|
||||||
|
private Integer source;
|
||||||
|
|
||||||
@Schema(description = "负责人的用户编号", example = "25682")
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("手机")
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("电话")
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("网址")
|
||||||
|
private String website;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("QQ")
|
||||||
|
private String qq;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("wechat")
|
||||||
|
private String wechat;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("email")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("客户描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", example = "25682")
|
||||||
|
@ExcelProperty("负责人的用户编号")
|
||||||
private Long ownerUserId;
|
private Long ownerUserId;
|
||||||
@Schema(description = "负责人名字", example = "25682")
|
@Schema(description = "负责人名字", example = "25682")
|
||||||
|
@ExcelProperty("负责人名字")
|
||||||
private String ownerUserName;
|
private String ownerUserName;
|
||||||
@Schema(description = "负责人部门")
|
@Schema(description = "负责人部门")
|
||||||
|
@ExcelProperty("负责人部门")
|
||||||
private String ownerUserDeptName;
|
private String ownerUserDeptName;
|
||||||
|
|
||||||
|
@Schema(description = "地区编号", example = "1024")
|
||||||
|
@ExcelProperty("地区编号")
|
||||||
|
private Integer areaId;
|
||||||
@Schema(description = "地区名称", example = "北京市")
|
@Schema(description = "地区名称", example = "北京市")
|
||||||
|
@ExcelProperty("地区名称")
|
||||||
private String areaName;
|
private String areaName;
|
||||||
|
@Schema(description = "详细地址", example = "北京市成华大道")
|
||||||
|
@ExcelProperty("详细地址")
|
||||||
|
private String detailAddress;
|
||||||
|
|
||||||
@Schema(description = "最后跟进时间")
|
@Schema(description = "最后跟进时间")
|
||||||
|
@ExcelProperty("最后跟进时间")
|
||||||
@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 = "下次联系时间")
|
||||||
|
@ExcelProperty("下次联系时间")
|
||||||
|
private LocalDateTime contactNextTime;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("更新时间")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
@Schema(description = "创建人")
|
@Schema(description = "创建人", example = "1024")
|
||||||
|
@ExcelProperty("创建人")
|
||||||
private String creator;
|
private String creator;
|
||||||
@Schema(description = "创建人名字")
|
@Schema(description = "创建人名字", example = "芋道源码")
|
||||||
|
@ExcelProperty("创建人名字")
|
||||||
private String creatorName;
|
private String creatorName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@ 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;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
|
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
|
||||||
|
|
||||||
/**
|
@Schema(description = "管理后台 - CRM 客户新增/修改 Request VO")
|
||||||
* 客户 Base VO,提供给添加、修改、详细的子 VO 使用
|
|
||||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
public class CrmCustomerBaseVO {
|
public class CrmCustomerSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||||
@DiffLogField(name = "客户名称")
|
@DiffLogField(name = "客户名称")
|
||||||
|
@ -96,4 +96,7 @@ public class CrmCustomerBaseVO {
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime contactNextTime;
|
private LocalDateTime contactNextTime;
|
||||||
|
|
||||||
|
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
|
private Long ownerUserId;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 客户更新 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO {
|
|
||||||
|
|
||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
|
||||||
@NotNull(message = "编号不能为空")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,7 +2,9 @@ package cn.iocoder.yudao.module.crm.convert.customer;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||||
|
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.CrmCustomerPoolConfigRespVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
|
@ -29,9 +31,7 @@ public interface CrmCustomerConvert {
|
||||||
|
|
||||||
CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class);
|
CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class);
|
||||||
|
|
||||||
CrmCustomerDO convert(CrmCustomerCreateReqVO bean);
|
CrmCustomerDO convert(CrmCustomerSaveReqVO bean);
|
||||||
|
|
||||||
CrmCustomerDO convert(CrmCustomerUpdateReqVO bean);
|
|
||||||
|
|
||||||
CrmCustomerRespVO convert(CrmCustomerDO bean);
|
CrmCustomerRespVO convert(CrmCustomerDO bean);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public interface CrmCustomerConvert {
|
||||||
findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname()));
|
findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname()));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list);
|
List<CrmCustomerRespVO> convertList02(List<CrmCustomerDO> list);
|
||||||
|
|
||||||
@Mapping(target = "bizId", source = "reqVO.id")
|
@Mapping(target = "bizId", source = "reqVO.id")
|
||||||
CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId);
|
CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId);
|
||||||
|
@ -76,6 +76,4 @@ public interface CrmCustomerConvert {
|
||||||
|
|
||||||
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
|
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
|
||||||
|
|
||||||
List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package cn.iocoder.yudao.module.crm.service.customer;
|
package cn.iocoder.yudao.module.crm.service.customer;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLockReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
@ -22,14 +25,14 @@ public interface CrmCustomerService {
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO, Long userId);
|
Long createCustomer(@Valid CrmCustomerSaveReqVO createReqVO, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新客户
|
* 更新客户
|
||||||
*
|
*
|
||||||
* @param updateReqVO 更新信息
|
* @param updateReqVO 更新信息
|
||||||
*/
|
*/
|
||||||
void updateCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO);
|
void updateCustomer(@Valid CrmCustomerSaveReqVO updateReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除客户
|
* 删除客户
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package cn.iocoder.yudao.module.crm.service.customer;
|
package cn.iocoder.yudao.module.crm.service.customer;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLockReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||||
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.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
||||||
|
@ -24,7 +28,10 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||||
|
@ -56,8 +63,10 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CUSTOMER, subType = "创建客户", bizNo = "{{#customerId}}", success = "创建了客户") // TODO @puhui999:创建了客户【客户名】,要记录进去;不然在展示操作日志的全列表,看不清楚是哪个客户哈;
|
@LogRecord(type = CRM_CUSTOMER, subType = "创建客户", bizNo = "{{#customerId}}", success = "创建了客户")
|
||||||
public Long createCustomer(CrmCustomerCreateReqVO createReqVO, Long userId) {
|
// TODO @puhui999:创建了客户【客户名】,要记录进去;不然在展示操作日志的全列表,看不清楚是哪个客户哈;
|
||||||
|
public Long createCustomer(CrmCustomerSaveReqVO createReqVO, Long userId) {
|
||||||
|
createReqVO.setId(null);
|
||||||
// 1. 校验拥有客户是否到达上限
|
// 1. 校验拥有客户是否到达上限
|
||||||
validateCustomerExceedOwnerLimit(createReqVO.getOwnerUserId(), 1);
|
validateCustomerExceedOwnerLimit(createReqVO.getOwnerUserId(), 1);
|
||||||
|
|
||||||
|
@ -81,8 +90,10 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CUSTOMER, subType = "更新客户", bizNo = "{{#updateReqVO.id}}", success = "更新了客户{_DIFF{#updateReqVO}}", extra = "{{#extra}}")
|
@LogRecord(type = CRM_CUSTOMER, subType = "更新客户", bizNo = "{{#updateReqVO.id}}", success = "更新了客户{_DIFF{#updateReqVO}}", extra = "{{#extra}}")
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||||
public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) {
|
public void updateCustomer(CrmCustomerSaveReqVO updateReqVO) {
|
||||||
// TODO @puhui999:更新的时候,要把 updateReqVO 负责人设置为空,避免修改。
|
Assert.notNull(updateReqVO.getId(), "客户编号不能为空");
|
||||||
|
// 更新的时候,要把 updateReqVO 负责人设置为空,避免修改。
|
||||||
|
updateReqVO.setOwnerUserId(null);
|
||||||
// 1. 校验存在
|
// 1. 校验存在
|
||||||
CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId());
|
CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId());
|
||||||
|
|
||||||
|
@ -91,11 +102,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||||
customerMapper.updateById(updateObj);
|
customerMapper.updateById(updateObj);
|
||||||
|
|
||||||
// 3. 记录操作日志
|
// 3. 记录操作日志
|
||||||
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomer, CrmCustomerUpdateReqVO.class));
|
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomer, CrmCustomerSaveReqVO.class));
|
||||||
// TODO 扩展信息测试 @puhui999:看着没啥问题,可以删除啦;
|
|
||||||
HashMap<String, Object> extra = new HashMap<>();
|
|
||||||
extra.put("tips", "随便记录一点啦");
|
|
||||||
LogRecordContext.putVariable("extra", extra);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -197,7 +204,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||||
/**
|
/**
|
||||||
* 校验用户拥有的客户数量,是否到达上限
|
* 校验用户拥有的客户数量,是否到达上限
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param newCount 附加数量
|
* @param newCount 附加数量
|
||||||
*/
|
*/
|
||||||
private void validateCustomerExceedOwnerLimit(Long userId, int newCount) {
|
private void validateCustomerExceedOwnerLimit(Long userId, int newCount) {
|
||||||
|
@ -237,7 +244,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CUSTOMER, subType = "客户放入公海", bizNo = "{{#id}}", success = "将客户放入了公海") // TODO @puhui999:将客户【】放入了公海
|
@LogRecord(type = CRM_CUSTOMER, subType = "客户放入公海", bizNo = "{{#id}}", success = "将客户放入了公海")
|
||||||
|
// TODO @puhui999:将客户【】放入了公海
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public void putCustomerPool(Long id) {
|
public void putCustomerPool(Long id) {
|
||||||
// 1. 校验存在
|
// 1. 校验存在
|
||||||
|
|
|
@ -2,19 +2,17 @@ package cn.iocoder.yudao.module.crm.service.customer;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
@ -47,7 +45,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCreateCustomer_success() {
|
public void testCreateCustomer_success() {
|
||||||
// 准备参数
|
// 准备参数
|
||||||
CrmCustomerCreateReqVO reqVO = randomPojo(CrmCustomerCreateReqVO.class);
|
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class);
|
||||||
|
|
||||||
// 调用
|
// 调用
|
||||||
Long customerId = customerService.createCustomer(reqVO, getLoginUserId());
|
Long customerId = customerService.createCustomer(reqVO, getLoginUserId());
|
||||||
|
@ -64,7 +62,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
|
||||||
CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class);
|
CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class);
|
||||||
customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据
|
customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据
|
||||||
// 准备参数
|
// 准备参数
|
||||||
CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class, o -> {
|
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class, o -> {
|
||||||
o.setId(dbCustomer.getId()); // 设置更新的 ID
|
o.setId(dbCustomer.getId()); // 设置更新的 ID
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -78,7 +76,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateCustomer_notExists() {
|
public void testUpdateCustomer_notExists() {
|
||||||
// 准备参数
|
// 准备参数
|
||||||
CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class);
|
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class);
|
||||||
|
|
||||||
// 调用, 并断言异常
|
// 调用, 并断言异常
|
||||||
assertServiceException(() -> customerService.updateCustomer(reqVO), CUSTOMER_NOT_EXISTS);
|
assertServiceException(() -> customerService.updateCustomer(reqVO), CUSTOMER_NOT_EXISTS);
|
||||||
|
|
Loading…
Reference in New Issue