mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-30 03:01:53 +08:00
!900 CRM:完善数据权限,实现数据权限同时添加、同时转移
Merge pull request !900 from puhui999/develop
This commit is contained in:
commit
e2ec426a9f
@ -11,6 +11,9 @@ import lombok.SneakyThrows;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典工具类
|
* 字典工具类
|
||||||
@ -38,6 +41,20 @@ public class DictFrameworkUtils {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 针对 {@link #getDictDataLabelList(String)} 的缓存
|
||||||
|
*/
|
||||||
|
private static final LoadingCache<String, List<String>> GET_DICT_DATA_LIST_CACHE = CacheUtils.buildAsyncReloadingCache(
|
||||||
|
Duration.ofMinutes(1L), // 过期时间 1 分钟
|
||||||
|
new CacheLoader<String, List<String>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> load(String dictType) {
|
||||||
|
return dictDataApi.getDictDataLabelList(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 针对 {@link #parseDictDataValue(String, String)} 的缓存
|
* 针对 {@link #parseDictDataValue(String, String)} 的缓存
|
||||||
*/
|
*/
|
||||||
@ -67,6 +84,11 @@ public class DictFrameworkUtils {
|
|||||||
return GET_DICT_DATA_CACHE.get(new KeyValue<>(dictType, value)).getLabel();
|
return GET_DICT_DATA_CACHE.get(new KeyValue<>(dictType, value)).getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public static List<String> getDictDataLabelList(String dictType) {
|
||||||
|
return GET_DICT_DATA_LIST_CACHE.get(dictType);
|
||||||
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static String parseDictDataValue(String dictType, String label) {
|
public static String parseDictDataValue(String dictType, String label) {
|
||||||
return PARSE_DICT_DATA_CACHE.get(new KeyValue<>(dictType, label)).getValue();
|
return PARSE_DICT_DATA_CACHE.get(new KeyValue<>(dictType, label)).getValue();
|
||||||
|
@ -12,9 +12,14 @@ import java.lang.annotation.*;
|
|||||||
@Inherited
|
@Inherited
|
||||||
public @interface ExcelColumnSelect {
|
public @interface ExcelColumnSelect {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return 字典类型
|
||||||
|
*/
|
||||||
|
String dictType() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 获取下拉数据源的方法名称
|
* @return 获取下拉数据源的方法名称
|
||||||
*/
|
*/
|
||||||
String value();
|
String functionName() default "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.framework.excel.core.function;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel 列下拉数据源获取接口
|
||||||
|
*
|
||||||
|
* 为什么不直接解析字典还搞个接口?考虑到有的下拉数据不是从字典中获取的所有需要做一个兼容
|
||||||
|
|
||||||
|
* @author HUIHUI
|
||||||
|
*/
|
||||||
|
public interface ExcelColumnSelectFunction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得方法名称
|
||||||
|
*
|
||||||
|
* @return 方法名称
|
||||||
|
*/
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得列下拉数据源
|
||||||
|
*
|
||||||
|
* @return 下拉数据源
|
||||||
|
*/
|
||||||
|
List<String> getOptions();
|
||||||
|
|
||||||
|
}
|
@ -2,15 +2,19 @@ package cn.iocoder.yudao.framework.excel.core.handler;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||||
|
import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
|
||||||
import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect;
|
import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect;
|
||||||
import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService;
|
import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction;
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
import com.alibaba.excel.write.handler.SheetWriteHandler;
|
||||||
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
|
||||||
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
|
import org.apache.poi.hssf.usermodel.HSSFDataValidation;
|
||||||
import org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||||
@ -26,13 +30,9 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
|||||||
*
|
*
|
||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class SelectSheetWriteHandler implements SheetWriteHandler {
|
public class SelectSheetWriteHandler implements SheetWriteHandler {
|
||||||
|
|
||||||
// TODO @puhui999:注释哈;
|
|
||||||
private static final List<String> ALPHABET = getExcelColumnNameList();
|
|
||||||
|
|
||||||
private static final List<ExcelColumnSelectDataService> EXCEL_COLUMN_SELECT_DATA_SERVICES = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据起始行从 0 开始
|
* 数据起始行从 0 开始
|
||||||
*
|
*
|
||||||
@ -46,34 +46,35 @@ public class SelectSheetWriteHandler implements SheetWriteHandler {
|
|||||||
|
|
||||||
private static final String DICT_SHEET_NAME = "字典sheet";
|
private static final String DICT_SHEET_NAME = "字典sheet";
|
||||||
|
|
||||||
// TODO @puhui999:这个 selectMap 可以改成 Map<Integer, List<String>>,然后在 afterSheetCreate 里面进行排序。这样整体的理解成本会更简单
|
/**
|
||||||
private final List<KeyValue<Integer, List<String>>> selectMap = new ArrayList<>(); // 使用 List + KeyValue 组合方便排序
|
* key: 列 value: 下拉数据源
|
||||||
|
*/
|
||||||
|
private final Map<Integer, List<String>> selectMap = new HashMap<>();
|
||||||
|
|
||||||
public SelectSheetWriteHandler(Class<?> head) {
|
public SelectSheetWriteHandler(Class<?> head) {
|
||||||
// 加载下拉数据获取接口
|
// 加载下拉数据获取接口
|
||||||
Map<String, ExcelColumnSelectDataService> beansMap = SpringUtil.getBeanFactory().getBeansOfType(ExcelColumnSelectDataService.class);
|
Map<String, ExcelColumnSelectFunction> beansMap = SpringUtil.getBeanFactory().getBeansOfType(ExcelColumnSelectFunction.class);
|
||||||
if (MapUtil.isEmpty(beansMap)) {
|
if (MapUtil.isEmpty(beansMap)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO @puhui999:static 是共享。如果并发情况下,会不会存在问题? 其实 EXCEL_COLUMN_SELECT_DATA_SERVICES 不用全局声明,直接 按照 ExcelColumnSelect 去拿下就好了;
|
|
||||||
if (CollUtil.isEmpty(EXCEL_COLUMN_SELECT_DATA_SERVICES) || EXCEL_COLUMN_SELECT_DATA_SERVICES.size() != beansMap.values().size()) {
|
|
||||||
EXCEL_COLUMN_SELECT_DATA_SERVICES.clear();
|
|
||||||
EXCEL_COLUMN_SELECT_DATA_SERVICES.addAll(convertList(beansMap.values(), b -> b));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析下拉数据
|
// 解析下拉数据
|
||||||
// TODO @puhui999:感觉可以 head 循环 field,如果有 ExcelColumnSelect 则进行处理;而 ExcelProperty 可能是非必须的
|
// TODO @puhui999:感觉可以 head 循环 field,如果有 ExcelColumnSelect 则进行处理;而 ExcelProperty 可能是非必须的。回答:主要是用于定位到列索引
|
||||||
Map<String, Field> excelPropertyFields = getFieldsWithAnnotation(head, ExcelProperty.class);
|
Map<String, Field> excelPropertyFields = getFieldsWithAnnotation(head, ExcelProperty.class);
|
||||||
Map<String, Field> excelColumnSelectFields = getFieldsWithAnnotation(head, ExcelColumnSelect.class);
|
Map<String, Field> excelColumnSelectFields = getFieldsWithAnnotation(head, ExcelColumnSelect.class);
|
||||||
int colIndex = 0;
|
int colIndex = 0;
|
||||||
for (String fieldName : excelPropertyFields.keySet()) {
|
for (String fieldName : excelPropertyFields.keySet()) {
|
||||||
Field field = excelColumnSelectFields.get(fieldName);
|
Field field = excelColumnSelectFields.get(fieldName);
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
|
// ExcelProperty 有一个自定义列索引的属性 index 兼容这个字段
|
||||||
|
int index = field.getAnnotation(ExcelProperty.class).index();
|
||||||
|
if (index != -1) {
|
||||||
|
colIndex = index;
|
||||||
|
}
|
||||||
getSelectDataList(colIndex, field);
|
getSelectDataList(colIndex, field);
|
||||||
}
|
}
|
||||||
colIndex++;
|
colIndex++;
|
||||||
}
|
}
|
||||||
selectMap.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,12 +84,25 @@ public class SelectSheetWriteHandler implements SheetWriteHandler {
|
|||||||
* @param field 字段
|
* @param field 字段
|
||||||
*/
|
*/
|
||||||
private void getSelectDataList(int colIndex, Field field) {
|
private void getSelectDataList(int colIndex, Field field) {
|
||||||
EXCEL_COLUMN_SELECT_DATA_SERVICES.forEach(selectDataService -> {
|
// 获得下拉注解信息
|
||||||
List<String> stringList = selectDataService.handle(field.getAnnotation(ExcelColumnSelect.class).value());
|
ExcelColumnSelect columnSelect = field.getAnnotation(ExcelColumnSelect.class);
|
||||||
if (CollUtil.isEmpty(stringList)) {
|
String dictType = columnSelect.dictType();
|
||||||
|
if (StrUtil.isNotEmpty(dictType)) { // 情况一: 字典数据 (默认)
|
||||||
|
selectMap.put(colIndex, DictFrameworkUtils.getDictDataLabelList(dictType));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectMap.add(new KeyValue<>(colIndex, stringList));
|
String functionName = columnSelect.functionName();
|
||||||
|
if (StrUtil.isEmpty(functionName)) { // 情况二: 获取自定义数据
|
||||||
|
log.warn("[getSelectDataList]解析下拉数据失败,参数信息 dictType[{}] functionName[{}]", dictType, functionName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获得所有的下拉数据源获取方法
|
||||||
|
Map<String, ExcelColumnSelectFunction> functionMap = SpringUtil.getApplicationContext().getBeansOfType(ExcelColumnSelectFunction.class);
|
||||||
|
functionMap.values().forEach(func -> {
|
||||||
|
if (ObjUtil.notEqual(func.getName(), functionName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
selectMap.put(colIndex, func.getOptions());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,10 +115,11 @@ public class SelectSheetWriteHandler implements SheetWriteHandler {
|
|||||||
// 1. 获取相应操作对象
|
// 1. 获取相应操作对象
|
||||||
DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper(); // 需要设置下拉框的 sheet 页的数据验证助手
|
DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper(); // 需要设置下拉框的 sheet 页的数据验证助手
|
||||||
Workbook workbook = writeWorkbookHolder.getWorkbook(); // 获得工作簿
|
Workbook workbook = writeWorkbookHolder.getWorkbook(); // 获得工作簿
|
||||||
|
List<KeyValue<Integer, List<String>>> keyValues = convertList(selectMap.entrySet(), entry -> new KeyValue<>(entry.getKey(), entry.getValue()));
|
||||||
|
keyValues.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错
|
||||||
// 2. 创建数据字典的 sheet 页
|
// 2. 创建数据字典的 sheet 页
|
||||||
Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME);
|
Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME);
|
||||||
for (KeyValue<Integer, List<String>> keyValue : selectMap) {
|
for (KeyValue<Integer, List<String>> keyValue : keyValues) {
|
||||||
int rowLength = keyValue.getValue().size();
|
int rowLength = keyValue.getValue().size();
|
||||||
// 2.1 设置字典 sheet 页的值 每一列一个字典项
|
// 2.1 设置字典 sheet 页的值 每一列一个字典项
|
||||||
for (int i = 0; i < rowLength; i++) {
|
for (int i = 0; i < rowLength; i++) {
|
||||||
@ -126,7 +141,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler {
|
|||||||
KeyValue<Integer, List<String>> keyValue) {
|
KeyValue<Integer, List<String>> keyValue) {
|
||||||
// 1.1 创建可被其他单元格引用的名称
|
// 1.1 创建可被其他单元格引用的名称
|
||||||
Name name = workbook.createName();
|
Name name = workbook.createName();
|
||||||
String excelColumn = ALPHABET.get(keyValue.getKey());
|
String excelColumn = ExcelUtil.indexToColName(keyValue.getKey());
|
||||||
// 1.2 下拉框数据来源 eg:字典sheet!$B1:$B2
|
// 1.2 下拉框数据来源 eg:字典sheet!$B1:$B2
|
||||||
String refers = DICT_SHEET_NAME + "!$" + excelColumn + "$1:$" + excelColumn + "$" + keyValue.getValue().size();
|
String refers = DICT_SHEET_NAME + "!$" + excelColumn + "$1:$" + excelColumn + "$" + keyValue.getValue().size();
|
||||||
name.setNameName("dict" + keyValue.getKey()); // 设置名称的名字
|
name.setNameName("dict" + keyValue.getKey()); // 设置名称的名字
|
||||||
@ -162,18 +177,4 @@ public class SelectSheetWriteHandler implements SheetWriteHandler {
|
|||||||
return annotatedFields;
|
return annotatedFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static List<String> getExcelColumnNameList() {
|
|
||||||
// TODO @puhui999:是不是可以使用 ExcelUtil.indexToColName() 替代
|
|
||||||
ArrayList<String> strings = new ArrayList<>();
|
|
||||||
for (int i = 1; i <= 52; i++) { // 生成 52 列名称,需要更多请重写此方法
|
|
||||||
if (i <= 26) {
|
|
||||||
strings.add(String.valueOf((char) ('A' + i - 1))); // 使用 ASCII 码值转字母
|
|
||||||
} else {
|
|
||||||
strings.add(String.valueOf((char) ('A' + (i - 1) / 26 - 1)) + (char) ('A' + (i - 1) % 26));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,43 +0,0 @@
|
|||||||
package cn.iocoder.yudao.framework.excel.core.service;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel 列下拉数据源获取接口
|
|
||||||
*
|
|
||||||
* 为什么不直接解析字典还搞个接口?考虑到有的下拉数据不是从字典中获取的所有需要做一个兼容
|
|
||||||
* TODO @puhui999:是不是 @ExcelColumnSelect 可以搞两个属性,一个 dictType,一个 functionName;如果 dictType,则默认走字典,否则走 functionName
|
|
||||||
* 这样的话,ExcelColumnSelectDataService 改成 ExcelColumnSelectFunction 用于获取数据。
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
public interface ExcelColumnSelectDataService {
|
|
||||||
|
|
||||||
// TODO @puhui999:可以考虑改成 getName
|
|
||||||
/**
|
|
||||||
* 获得方法名称
|
|
||||||
*
|
|
||||||
* @return 方法名称
|
|
||||||
*/
|
|
||||||
String getFunctionName();
|
|
||||||
|
|
||||||
// TODO @puhui999:可以考虑改成 getOptions;因为 select 下面是 option 哈,和前端 html 类似的标签;
|
|
||||||
/**
|
|
||||||
* 获得列下拉数据源
|
|
||||||
*
|
|
||||||
* @return 下拉数据源
|
|
||||||
*/
|
|
||||||
List<String> getSelectDataList();
|
|
||||||
|
|
||||||
// TODO @puhui999:这个建议放到 SelectSheetWriteHandler 里
|
|
||||||
default List<String> handle(String funcName) {
|
|
||||||
if (StrUtil.isEmptyIfStr(funcName) || !StrUtil.equals(getFunctionName(), funcName)) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
return getSelectDataList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -3,15 +3,19 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
|||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 商机转移 Request VO")
|
@Schema(description = "管理后台 - 商机转移 Request VO")
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class CrmBusinessTransferReqVO {
|
public class CrmBusinessTransferReqVO {
|
||||||
|
|
||||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
@NotNull(message = "商机编号不能为空")
|
@NotNull(message = "商机编号不能为空")
|
||||||
private Long id;
|
private Long bizId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新负责人的用户编号
|
* 新负责人的用户编号
|
||||||
|
@ -12,7 +12,7 @@ public class CrmClueTransferReqVO {
|
|||||||
|
|
||||||
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
@NotNull(message = "线索编号不能为空")
|
@NotNull(message = "线索编号不能为空")
|
||||||
private Long id;
|
private Long bizId;
|
||||||
|
|
||||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
@NotNull(message = "新负责人的用户编号不能为空")
|
@NotNull(message = "新负责人的用户编号不能为空")
|
||||||
|
@ -2,17 +2,21 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 联系人转移 Request VO")
|
@Schema(description = "管理后台 - CRM 联系人转移 Request VO")
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class CrmContactTransferReqVO {
|
public class CrmContactTransferReqVO {
|
||||||
|
|
||||||
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
@NotNull(message = "联系人编号不能为空")
|
@NotNull(message = "联系人编号不能为空")
|
||||||
private Long id;
|
private Long bizId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新负责人的用户编号
|
* 新负责人的用户编号
|
||||||
|
@ -3,17 +3,21 @@ package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract;
|
|||||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 合同转移 Request VO")
|
@Schema(description = "管理后台 - CRM 合同转移 Request VO")
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class CrmContractTransferReqVO {
|
public class CrmContractTransferReqVO {
|
||||||
|
|
||||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
@NotNull(message = "联系人编号不能为空")
|
@NotNull(message = "联系人编号不能为空")
|
||||||
private Long id;
|
private Long bizId;
|
||||||
|
|
||||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
@NotNull(message = "新负责人的用户编号不能为空")
|
@NotNull(message = "新负责人的用户编号不能为空")
|
||||||
|
@ -62,8 +62,6 @@ public class CrmCustomerController {
|
|||||||
private DeptApi deptApi;
|
private DeptApi deptApi;
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
@Resource
|
|
||||||
private DictDataApi dictDataApi;
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建客户")
|
@Operation(summary = "创建客户")
|
||||||
|
@ -4,10 +4,7 @@ import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
|||||||
import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect;
|
import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect;
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert;
|
import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert;
|
||||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
import cn.iocoder.yudao.module.crm.framework.excel.service.AreaExcelColumnSelectDataServiceImpl;
|
import cn.iocoder.yudao.module.crm.framework.excel.core.AreaExcelColumnSelectFunctionImpl;
|
||||||
import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerIndustryExcelColumnSelectDataServiceImpl;
|
|
||||||
import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerLevelExcelColumnSelectDataServiceImpl;
|
|
||||||
import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerSourceExcelColumnSelectDataServiceImpl;
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
@ -46,7 +43,7 @@ public class CrmCustomerImportExcelVO {
|
|||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@ExcelProperty(value = "地区", converter = AreaConvert.class)
|
@ExcelProperty(value = "地区", converter = AreaConvert.class)
|
||||||
@ExcelColumnSelect(AreaExcelColumnSelectDataServiceImpl.FUNCTION_NAME)
|
@ExcelColumnSelect(functionName = AreaExcelColumnSelectFunctionImpl.NAME)
|
||||||
private Integer areaId;
|
private Integer areaId;
|
||||||
|
|
||||||
@ExcelProperty("详细地址")
|
@ExcelProperty("详细地址")
|
||||||
@ -54,17 +51,17 @@ public class CrmCustomerImportExcelVO {
|
|||||||
|
|
||||||
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
|
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
|
||||||
@DictFormat(CRM_CUSTOMER_INDUSTRY)
|
@DictFormat(CRM_CUSTOMER_INDUSTRY)
|
||||||
@ExcelColumnSelect(CrmCustomerIndustryExcelColumnSelectDataServiceImpl.FUNCTION_NAME)
|
@ExcelColumnSelect(dictType = CRM_CUSTOMER_INDUSTRY)
|
||||||
private Integer industryId;
|
private Integer industryId;
|
||||||
|
|
||||||
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
|
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
|
||||||
@DictFormat(CRM_CUSTOMER_LEVEL)
|
@DictFormat(CRM_CUSTOMER_LEVEL)
|
||||||
@ExcelColumnSelect(CrmCustomerLevelExcelColumnSelectDataServiceImpl.FUNCTION_NAME)
|
@ExcelColumnSelect(dictType = CRM_CUSTOMER_LEVEL)
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
|
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
|
||||||
@DictFormat(CRM_CUSTOMER_SOURCE)
|
@DictFormat(CRM_CUSTOMER_SOURCE)
|
||||||
@ExcelColumnSelect(CrmCustomerSourceExcelColumnSelectDataServiceImpl.FUNCTION_NAME)
|
@ExcelColumnSelect(dictType = CRM_CUSTOMER_SOURCE)
|
||||||
private Integer source;
|
private Integer source;
|
||||||
|
|
||||||
@ExcelProperty("备注")
|
@ExcelProperty("备注")
|
||||||
|
@ -5,13 +5,15 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 客户转移 Request VO")
|
@Schema(description = "管理后台 - CRM 客户转移 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class CrmCustomerTransferReqVO {
|
public class CrmCustomerTransferReqVO {
|
||||||
|
|
||||||
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
@NotNull(message = "客户编号不能为空")
|
@NotNull(message = "客户编号不能为空")
|
||||||
private Long id;
|
private Long bizId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新负责人的用户编号
|
* 新负责人的用户编号
|
||||||
@ -28,4 +30,10 @@ public class CrmCustomerTransferReqVO {
|
|||||||
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
private Integer oldOwnerPermissionLevel;
|
private Integer oldOwnerPermissionLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择
|
||||||
|
*/
|
||||||
|
@Schema(description = "同时转移", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
|
private List<Integer> toBizTypes;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,19 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|||||||
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.collection.MapUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
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.permission.vo.CrmPermissionCreateReqVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
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.framework.permission.core.annotations.CrmPermission;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
@ -27,13 +34,11 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -50,7 +55,12 @@ public class CrmPermissionController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CrmPermissionService permissionService;
|
private CrmPermissionService permissionService;
|
||||||
|
@Resource
|
||||||
|
private CrmContactService contactService;
|
||||||
|
@Resource
|
||||||
|
private CrmBusinessService businessService;
|
||||||
|
@Resource
|
||||||
|
private CrmContractService contractService;
|
||||||
@Resource
|
@Resource
|
||||||
private AdminUserApi adminUserApi;
|
private AdminUserApi adminUserApi;
|
||||||
@Resource
|
@Resource
|
||||||
@ -60,13 +70,47 @@ public class CrmPermissionController {
|
|||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建数据权限")
|
@Operation(summary = "创建数据权限")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@PreAuthorize("@ss.hasPermission('crm:permission:create')")
|
@PreAuthorize("@ss.hasPermission('crm:permission:create')")
|
||||||
@CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
@CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionCreateReqVO reqVO) {
|
public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionSaveReqVO reqVO) {
|
||||||
permissionService.createPermission(BeanUtils.toBean(reqVO, CrmPermissionCreateReqBO.class));
|
permissionService.createPermission(BeanUtils.toBean(reqVO, CrmPermissionCreateReqBO.class));
|
||||||
|
if (CollUtil.isNotEmpty(reqVO.getToBizTypes())) {
|
||||||
|
createBizTypePermissions(reqVO);
|
||||||
|
}
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void createBizTypePermissions(CrmPermissionSaveReqVO reqVO) {
|
||||||
|
List<CrmPermissionCreateReqBO> createPermissions = new ArrayList<>();
|
||||||
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) {
|
||||||
|
List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getBizId(), getLoginUserId());
|
||||||
|
contactList.forEach(item -> {
|
||||||
|
createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTACT.getType())
|
||||||
|
.setBizId(item.getId()).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) {
|
||||||
|
List<CrmBusinessDO> businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getBizId(), getLoginUserId());
|
||||||
|
businessList.forEach(item -> {
|
||||||
|
createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())
|
||||||
|
.setBizId(item.getId()).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) {
|
||||||
|
List<CrmContractDO> contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getBizId(), getLoginUserId());
|
||||||
|
contractList.forEach(item -> {
|
||||||
|
createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType())
|
||||||
|
.setBizId(item.getId()).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel()));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(createPermissions)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
permissionService.createPermissionBatch(createPermissions);
|
||||||
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "编辑数据权限")
|
@Operation(summary = "编辑数据权限")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:permission:update')")
|
@PreAuthorize("@ss.hasPermission('crm:permission:update')")
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.permission.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 数据权限创建 Request VO")
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@ToString(callSuper = true)
|
|
||||||
public class CrmPermissionCreateReqVO extends CrmPermissionBaseVO {
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,10 @@
|
|||||||
package cn.iocoder.yudao.module.crm.controller.admin.permission.vo;
|
package cn.iocoder.yudao.module.crm.controller.admin.permission.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -8,11 +12,29 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Schema(description = "管理后台 - CRM 数据权限 Response VO")
|
@Schema(description = "管理后台 - CRM 数据权限 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class CrmPermissionRespVO extends CrmPermissionBaseVO {
|
public class CrmPermissionRespVO {
|
||||||
|
|
||||||
@Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
@Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||||
|
@NotNull(message = "用户编号不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@InEnum(CrmBizTypeEnum.class)
|
||||||
|
@NotNull(message = "CRM 类型不能为空")
|
||||||
|
private Integer bizType;
|
||||||
|
|
||||||
|
@Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
@NotNull(message = "CRM 类型数据编号不能为空")
|
||||||
|
private Long bizId;
|
||||||
|
|
||||||
|
@Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@InEnum(CrmPermissionLevelEnum.class)
|
||||||
|
@NotNull(message = "权限级别不能为空")
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
|
||||||
|
@ -8,14 +8,11 @@ import lombok.Data;
|
|||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
import java.util.List;
|
||||||
* 数据权限 Base VO,提供给添加、修改、详细的子 VO 使用
|
|
||||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
@Schema(description = "管理后台 - CRM 数据权限创建/更新 Request VO")
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
public class CrmPermissionBaseVO {
|
public class CrmPermissionSaveReqVO {
|
||||||
|
|
||||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||||
@NotNull(message = "用户编号不能为空")
|
@NotNull(message = "用户编号不能为空")
|
||||||
@ -35,4 +32,10 @@ public class CrmPermissionBaseVO {
|
|||||||
@NotNull(message = "权限级别不能为空")
|
@NotNull(message = "权限级别不能为空")
|
||||||
private Integer level;
|
private Integer level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加客户团队成员时,需要额外有【联系人】【商机】【合同】的 checkbox 选择
|
||||||
|
*/
|
||||||
|
@Schema(description = "同时添加", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||||
|
private List<Integer> toBizTypes;
|
||||||
|
|
||||||
}
|
}
|
@ -6,12 +6,14 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||||||
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商机 Mapper
|
* 商机 Mapper
|
||||||
@ -57,4 +59,10 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
|
|||||||
return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId);
|
return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<CrmBusinessDO> selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId){
|
||||||
|
return selectList(new LambdaQueryWrapperX<CrmBusinessDO>()
|
||||||
|
.eq(CrmBusinessDO::getCustomerId, customerId)
|
||||||
|
.eq(CrmBusinessDO::getOwnerUserId, ownerUserId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,4 +73,10 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
|
|||||||
return selectList(CrmContactDO::getCustomerId, customerId);
|
return selectList(CrmContactDO::getCustomerId, customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<CrmContactDO> selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<CrmContactDO>()
|
||||||
|
.eq(CrmContactDO::getCustomerId, customerId)
|
||||||
|
.eq(CrmContactDO::getOwnerUserId, ownerUserId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,10 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
|||||||
return selectCount(query);
|
return selectCount(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<CrmContractDO> selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<CrmContractDO>()
|
||||||
|
.eq(CrmContractDO::getCustomerId, customerId)
|
||||||
|
.eq(CrmContractDO::getOwnerUserId, ownerUserId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.crm.framework.excel.service;
|
package cn.iocoder.yudao.module.crm.framework.excel.core;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService;
|
import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction;
|
||||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -13,17 +13,17 @@ import java.util.List;
|
|||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class AreaExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService {
|
public class AreaExcelColumnSelectFunctionImpl implements ExcelColumnSelectFunction {
|
||||||
|
|
||||||
public static final String FUNCTION_NAME = "getCrmAreaNameList"; // 防止和别的模块重名
|
public static final String NAME = "getCrmAreaNameList"; // 防止和别的模块重名
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFunctionName() {
|
public String getName() {
|
||||||
return FUNCTION_NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSelectDataList() {
|
public List<String> getOptions() {
|
||||||
// 获取地区下拉数据
|
// 获取地区下拉数据
|
||||||
// TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么?
|
// TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么?
|
||||||
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
Area area = AreaUtils.getArea(Area.ID_CHINA);
|
@ -1,2 +1 @@
|
|||||||
// TODO @puhui999:在 framework 目录,保持 config 和 core 目录的风格哈;
|
|
||||||
package cn.iocoder.yudao.module.crm.framework.excel;
|
package cn.iocoder.yudao.module.crm.framework.excel;
|
@ -1,35 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.framework.excel.service;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService;
|
|
||||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel 客户所属行业列下拉数据源获取接口实现类
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class CrmCustomerIndustryExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService {
|
|
||||||
|
|
||||||
public static final String FUNCTION_NAME = "getCrmCustomerIndustryList";
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DictDataApi dictDataApi;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFunctionName() {
|
|
||||||
return FUNCTION_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getSelectDataList() {
|
|
||||||
return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.framework.excel.service;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService;
|
|
||||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel 客户等级列下拉数据源获取接口实现类
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class CrmCustomerLevelExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService {
|
|
||||||
|
|
||||||
public static final String FUNCTION_NAME = "getCrmCustomerLevelList";
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DictDataApi dictDataApi;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFunctionName() {
|
|
||||||
return FUNCTION_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getSelectDataList() {
|
|
||||||
return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.framework.excel.service;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService;
|
|
||||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Excel 客户来源列下拉数据源获取接口实现类
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class CrmCustomerSourceExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService {
|
|
||||||
|
|
||||||
public static final String FUNCTION_NAME = "getCrmCustomerSourceList";
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private DictDataApi dictDataApi;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFunctionName() {
|
|
||||||
return FUNCTION_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getSelectDataList() {
|
|
||||||
return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -185,4 +185,13 @@ public interface CrmBusinessService {
|
|||||||
return status.getName();
|
return status.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得商机列表
|
||||||
|
*
|
||||||
|
* @param customerId 客户编号
|
||||||
|
* @param ownerUserId 负责人编号
|
||||||
|
* @return 商机列表
|
||||||
|
*/
|
||||||
|
List<CrmBusinessDO> getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.business;
|
|||||||
|
|
||||||
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.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
@ -23,6 +24,7 @@ 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.contact.CrmContactService;
|
||||||
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
||||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerServiceImpl;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||||
@ -292,18 +294,18 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}",
|
@LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}",
|
||||||
success = CRM_BUSINESS_TRANSFER_SUCCESS)
|
success = CRM_BUSINESS_TRANSFER_SUCCESS)
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) {
|
public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) {
|
||||||
// 1 校验商机是否存在
|
// 1 校验商机是否存在
|
||||||
CrmBusinessDO business = validateBusinessExists(reqVO.getId());
|
CrmBusinessDO business = validateBusinessExists(reqVO.getBizId());
|
||||||
|
|
||||||
// 2.1 数据权限转移
|
// 2.1 数据权限转移
|
||||||
permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_BUSINESS.getType(),
|
permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_BUSINESS.getType(),
|
||||||
reqVO.getNewOwnerUserId(), reqVO.getId(), CrmPermissionLevelEnum.OWNER.getLevel()));
|
reqVO.getBizId(), reqVO.getNewOwnerUserId(), CrmPermissionLevelEnum.OWNER.getLevel()));
|
||||||
// 2.2 设置新的负责人
|
// 2.2 设置新的负责人
|
||||||
businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
businessMapper.updateOwnerUserIdById(reqVO.getBizId(), reqVO.getNewOwnerUserId());
|
||||||
|
|
||||||
// 记录操作日志上下文
|
// 记录操作日志上下文
|
||||||
LogRecordContext.putVariable("business", business);
|
LogRecordContext.putVariable("business", business);
|
||||||
@ -370,4 +372,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
|
|||||||
return businessMapper.selectCountByStatusTypeId(statusTypeId);
|
return businessMapper.selectCountByStatusTypeId(statusTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CrmBusinessDO> getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) {
|
||||||
|
return businessMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -159,18 +159,18 @@ public class CrmClueServiceImpl implements CrmClueService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}",
|
@LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}",
|
||||||
success = CRM_CLUE_TRANSFER_SUCCESS)
|
success = CRM_CLUE_TRANSFER_SUCCESS)
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public void transferClue(CrmClueTransferReqVO reqVO, Long userId) {
|
public void transferClue(CrmClueTransferReqVO reqVO, Long userId) {
|
||||||
// 1 校验线索是否存在
|
// 1 校验线索是否存在
|
||||||
CrmClueDO clue = validateClueExists(reqVO.getId());
|
CrmClueDO clue = validateClueExists(reqVO.getBizId());
|
||||||
|
|
||||||
// 2.1 数据权限转移
|
// 2.1 数据权限转移
|
||||||
crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CLUE.getType(),
|
crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CLUE.getType(),
|
||||||
reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
||||||
// 2.2 设置新的负责人
|
// 2.2 设置新的负责人
|
||||||
clueMapper.updateById(new CrmClueDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId()));
|
clueMapper.updateById(new CrmClueDO().setId(reqVO.getBizId()).setOwnerUserId(reqVO.getNewOwnerUserId()));
|
||||||
|
|
||||||
// 3. 记录转移日志
|
// 3. 记录转移日志
|
||||||
LogRecordContext.putVariable("clue", clue);
|
LogRecordContext.putVariable("clue", clue);
|
||||||
|
@ -160,4 +160,13 @@ public interface CrmContactService {
|
|||||||
*/
|
*/
|
||||||
Long getContactCountByCustomerId(Long customerId);
|
Long getContactCountByCustomerId(Long customerId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得联系人列表
|
||||||
|
*
|
||||||
|
* @param customerId 客户编号
|
||||||
|
* @param ownerUserId 负责人编号
|
||||||
|
* @return 联系人列表
|
||||||
|
*/
|
||||||
|
List<CrmContactDO> getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.contact;
|
|||||||
|
|
||||||
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.hutool.extra.spring.SpringUtil;
|
||||||
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.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO;
|
||||||
@ -17,6 +18,7 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm
|
|||||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||||
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
||||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerServiceImpl;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||||
@ -177,18 +179,18 @@ public class CrmContactServiceImpl implements CrmContactService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}",
|
@LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}",
|
||||||
success = CRM_CONTACT_TRANSFER_SUCCESS)
|
success = CRM_CONTACT_TRANSFER_SUCCESS)
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public void transferContact(CrmContactTransferReqVO reqVO, Long userId) {
|
public void transferContact(CrmContactTransferReqVO reqVO, Long userId) {
|
||||||
// 1 校验联系人是否存在
|
// 1 校验联系人是否存在
|
||||||
CrmContactDO contact = validateContactExists(reqVO.getId());
|
CrmContactDO contact = validateContactExists(reqVO.getBizId());
|
||||||
|
|
||||||
// 2.1 数据权限转移
|
// 2.1 数据权限转移
|
||||||
permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(),
|
permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(),
|
||||||
reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
||||||
// 2.2 设置新的负责人
|
// 2.2 设置新的负责人
|
||||||
contactMapper.updateById(new CrmContactDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId()));
|
contactMapper.updateById(new CrmContactDO().setId(reqVO.getBizId()).setOwnerUserId(reqVO.getNewOwnerUserId()));
|
||||||
|
|
||||||
// 3. 记录转移日志
|
// 3. 记录转移日志
|
||||||
LogRecordContext.putVariable("contact", contact);
|
LogRecordContext.putVariable("contact", contact);
|
||||||
@ -298,4 +300,9 @@ public class CrmContactServiceImpl implements CrmContactService {
|
|||||||
return contactMapper.selectCount(CrmContactDO::getCustomerId, customerId);
|
return contactMapper.selectCount(CrmContactDO::getCustomerId, customerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CrmContactDO> getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) {
|
||||||
|
return contactMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -193,4 +193,13 @@ public interface CrmContractService {
|
|||||||
*/
|
*/
|
||||||
Long getRemindContractCount(Long userId);
|
Long getRemindContractCount(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得合同列表
|
||||||
|
*
|
||||||
|
* @param customerId 客户编号
|
||||||
|
* @param ownerUserId 负责人编号
|
||||||
|
* @return 合同列表
|
||||||
|
*/
|
||||||
|
List<CrmContractDO> getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import cn.hutool.core.lang.Assert;
|
import cn.hutool.core.lang.Assert;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
@ -26,6 +27,7 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm
|
|||||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||||
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerServiceImpl;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||||
@ -229,7 +231,7 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
// 1.1 校验存在
|
// 1.1 校验存在
|
||||||
CrmContractDO contract = validateContractExists(id);
|
CrmContractDO contract = validateContractExists(id);
|
||||||
// 1.2 如果被 CrmReceivableDO 所使用,则不允许删除
|
// 1.2 如果被 CrmReceivableDO 所使用,则不允许删除
|
||||||
if (CollUtil.isNotEmpty(receivableService.getReceivableByContractId(contract.getId()))) {
|
if (receivableService.getReceivableByContractId(contract.getId()) != 0) {
|
||||||
throw exception(CONTRACT_DELETE_FAIL);
|
throw exception(CONTRACT_DELETE_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,18 +254,18 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}",
|
@LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}",
|
||||||
success = CRM_CONTRACT_TRANSFER_SUCCESS)
|
success = CRM_CONTRACT_TRANSFER_SUCCESS)
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public void transferContract(CrmContractTransferReqVO reqVO, Long userId) {
|
public void transferContract(CrmContractTransferReqVO reqVO, Long userId) {
|
||||||
// 1. 校验合同是否存在
|
// 1. 校验合同是否存在
|
||||||
CrmContractDO contract = validateContractExists(reqVO.getId());
|
CrmContractDO contract = validateContractExists(reqVO.getBizId());
|
||||||
|
|
||||||
// 2.1 数据权限转移
|
// 2.1 数据权限转移
|
||||||
crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
||||||
reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
||||||
// 2.2 设置负责人
|
// 2.2 设置负责人
|
||||||
contractMapper.updateById(new CrmContractDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId()));
|
contractMapper.updateById(new CrmContractDO().setId(reqVO.getBizId()).setOwnerUserId(reqVO.getNewOwnerUserId()));
|
||||||
|
|
||||||
// 3. 记录转移日志
|
// 3. 记录转移日志
|
||||||
LogRecordContext.putVariable("contract", contract);
|
LogRecordContext.putVariable("contract", contract);
|
||||||
@ -407,4 +409,9 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
return contractMapper.selectCountByRemind(userId, config);
|
return contractMapper.selectCountByRemind(userId, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CrmContractDO> getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) {
|
||||||
|
return contractMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,13 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|||||||
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.business.vo.business.CrmBusinessTransferReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
|
||||||
|
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||||
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;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
||||||
@ -193,26 +199,60 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}",
|
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}",
|
||||||
success = CRM_CUSTOMER_TRANSFER_SUCCESS)
|
success = CRM_CUSTOMER_TRANSFER_SUCCESS)
|
||||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER)
|
||||||
public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
||||||
// 1.1 校验客户是否存在
|
// 1.1 校验客户是否存在
|
||||||
CrmCustomerDO customer = validateCustomerExists(reqVO.getId());
|
CrmCustomerDO customer = validateCustomerExists(reqVO.getBizId());
|
||||||
// 1.2 校验拥有客户是否到达上限
|
// 1.2 校验拥有客户是否到达上限
|
||||||
validateCustomerExceedOwnerLimit(reqVO.getNewOwnerUserId(), 1);
|
validateCustomerExceedOwnerLimit(reqVO.getNewOwnerUserId(), 1);
|
||||||
|
|
||||||
// 2.1 数据权限转移
|
// 2.1 数据权限转移
|
||||||
permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
||||||
reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel()));
|
||||||
// 2.2 转移后重新设置负责人
|
// 2.2 转移后重新设置负责人
|
||||||
customerMapper.updateById(new CrmCustomerDO().setId(reqVO.getId())
|
customerMapper.updateById(new CrmCustomerDO().setId(reqVO.getBizId())
|
||||||
.setOwnerUserId(reqVO.getNewOwnerUserId()).setOwnerTime(LocalDateTime.now()));
|
.setOwnerUserId(reqVO.getNewOwnerUserId()).setOwnerTime(LocalDateTime.now()));
|
||||||
|
|
||||||
|
// 2.3 同时转移
|
||||||
|
if (CollUtil.isNotEmpty(reqVO.getToBizTypes())) {
|
||||||
|
transfer(reqVO, userId);
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 记录转移日志
|
// 3. 记录转移日志
|
||||||
LogRecordContext.putVariable("customer", customer);
|
LogRecordContext.putVariable("customer", customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转移客户时,需要额外有【联系人】【商机】【合同】
|
||||||
|
*
|
||||||
|
* @param reqVO 请求
|
||||||
|
* @param userId 用户编号
|
||||||
|
*/
|
||||||
|
private void transfer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
||||||
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) {
|
||||||
|
List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getBizId(), userId);
|
||||||
|
contactList.forEach(item -> {
|
||||||
|
contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
||||||
|
reqVO.getOldOwnerPermissionLevel()), userId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) {
|
||||||
|
List<CrmBusinessDO> businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getBizId(), userId);
|
||||||
|
businessList.forEach(item -> {
|
||||||
|
businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
||||||
|
reqVO.getOldOwnerPermissionLevel()), userId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) {
|
||||||
|
List<CrmContractDO> contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getBizId(), userId);
|
||||||
|
contractList.forEach(item -> {
|
||||||
|
contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(),
|
||||||
|
reqVO.getOldOwnerPermissionLevel()), userId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}",
|
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}",
|
||||||
success = CRM_CUSTOMER_LOCK_SUCCESS)
|
success = CRM_CUSTOMER_LOCK_SUCCESS)
|
||||||
|
@ -122,13 +122,12 @@ public interface CrmReceivableService {
|
|||||||
*/
|
*/
|
||||||
Map<Long, BigDecimal> getReceivablePriceMapByContractId(Collection<Long> contractIds);
|
Map<Long, BigDecimal> getReceivablePriceMapByContractId(Collection<Long> contractIds);
|
||||||
|
|
||||||
// TODO @puhui999:这个搞成根据数量判断,会更好一点哈;
|
|
||||||
/**
|
/**
|
||||||
* 更具合同编号查询回款列表
|
* 更具合同编号查询回款列表
|
||||||
*
|
*
|
||||||
* @param contractId 合同编号
|
* @param contractId 合同编号
|
||||||
* @return 回款
|
* @return 回款
|
||||||
*/
|
*/
|
||||||
List<CrmReceivableDO> getReceivableByContractId(Long contractId);
|
Long getReceivableByContractId(Long contractId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -302,8 +302,8 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CrmReceivableDO> getReceivableByContractId(Long contractId) {
|
public Long getReceivableByContractId(Long contractId) {
|
||||||
return receivableMapper.selectList(CrmReceivableDO::getContractId, contractId);
|
return receivableMapper.selectCount(CrmReceivableDO::getContractId, contractId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user