Commit e2ec426a9f8c71074f346af7c0e4046385eb9c2f
Committed by
Gitee
!900 CRM:完善数据权限,实现数据权限同时添加、同时转移
Merge pull request !900 from puhui999/develop
Showing
33 changed files
with
340 additions
and
256 deletions
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/core/DictFrameworkUtils.java
| ... | ... | @@ -11,6 +11,9 @@ import lombok.SneakyThrows; |
| 11 | 11 | import lombok.extern.slf4j.Slf4j; |
| 12 | 12 | |
| 13 | 13 | import java.time.Duration; |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 14 | 17 | |
| 15 | 18 | /** |
| 16 | 19 | * 字典工具类 |
| ... | ... | @@ -39,6 +42,20 @@ public class DictFrameworkUtils { |
| 39 | 42 | }); |
| 40 | 43 | |
| 41 | 44 | /** |
| 45 | + * 针对 {@link #getDictDataLabelList(String)} 的缓存 | |
| 46 | + */ | |
| 47 | + private static final LoadingCache<String, List<String>> GET_DICT_DATA_LIST_CACHE = CacheUtils.buildAsyncReloadingCache( | |
| 48 | + Duration.ofMinutes(1L), // 过期时间 1 分钟 | |
| 49 | + new CacheLoader<String, List<String>>() { | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public List<String> load(String dictType) { | |
| 53 | + return dictDataApi.getDictDataLabelList(dictType); | |
| 54 | + } | |
| 55 | + | |
| 56 | + }); | |
| 57 | + | |
| 58 | + /** | |
| 42 | 59 | * 针对 {@link #parseDictDataValue(String, String)} 的缓存 |
| 43 | 60 | */ |
| 44 | 61 | private static final LoadingCache<KeyValue<String, String>, DictDataRespDTO> PARSE_DICT_DATA_CACHE = CacheUtils.buildAsyncReloadingCache( |
| ... | ... | @@ -68,6 +85,11 @@ public class DictFrameworkUtils { |
| 68 | 85 | } |
| 69 | 86 | |
| 70 | 87 | @SneakyThrows |
| 88 | + public static List<String> getDictDataLabelList(String dictType) { | |
| 89 | + return GET_DICT_DATA_LIST_CACHE.get(dictType); | |
| 90 | + } | |
| 91 | + | |
| 92 | + @SneakyThrows | |
| 71 | 93 | public static String parseDictDataValue(String dictType, String label) { |
| 72 | 94 | return PARSE_DICT_DATA_CACHE.get(new KeyValue<>(dictType, label)).getValue(); |
| 73 | 95 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/annotations/ExcelColumnSelect.java
| ... | ... | @@ -13,8 +13,13 @@ import java.lang.annotation.*; |
| 13 | 13 | public @interface ExcelColumnSelect { |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | + * @return 字典类型 | |
| 17 | + */ | |
| 18 | + String dictType() default ""; | |
| 19 | + | |
| 20 | + /** | |
| 16 | 21 | * @return 获取下拉数据源的方法名称 |
| 17 | 22 | */ |
| 18 | - String value(); | |
| 23 | + String functionName() default ""; | |
| 19 | 24 | |
| 20 | 25 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/service/ExcelColumnSelectDataService.java renamed to yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/function/ExcelColumnSelectFunction.java
| 1 | -package cn.iocoder.yudao.framework.excel.core.service; | |
| 1 | +package cn.iocoder.yudao.framework.excel.core.function; | |
| 2 | 2 | |
| 3 | -import cn.hutool.core.util.StrUtil; | |
| 4 | - | |
| 5 | -import java.util.Collections; | |
| 6 | 3 | import java.util.List; |
| 7 | 4 | |
| 8 | 5 | /** |
| 9 | 6 | * Excel 列下拉数据源获取接口 |
| 10 | 7 | * |
| 11 | 8 | * 为什么不直接解析字典还搞个接口?考虑到有的下拉数据不是从字典中获取的所有需要做一个兼容 |
| 12 | - * TODO @puhui999:是不是 @ExcelColumnSelect 可以搞两个属性,一个 dictType,一个 functionName;如果 dictType,则默认走字典,否则走 functionName | |
| 13 | - * 这样的话,ExcelColumnSelectDataService 改成 ExcelColumnSelectFunction 用于获取数据。 | |
| 14 | - * | |
| 9 | + | |
| 15 | 10 | * @author HUIHUI |
| 16 | 11 | */ |
| 17 | -public interface ExcelColumnSelectDataService { | |
| 12 | +public interface ExcelColumnSelectFunction { | |
| 18 | 13 | |
| 19 | - // TODO @puhui999:可以考虑改成 getName | |
| 20 | 14 | /** |
| 21 | 15 | * 获得方法名称 |
| 22 | 16 | * |
| 23 | 17 | * @return 方法名称 |
| 24 | 18 | */ |
| 25 | - String getFunctionName(); | |
| 19 | + String getName(); | |
| 26 | 20 | |
| 27 | - // TODO @puhui999:可以考虑改成 getOptions;因为 select 下面是 option 哈,和前端 html 类似的标签; | |
| 28 | 21 | /** |
| 29 | 22 | * 获得列下拉数据源 |
| 30 | 23 | * |
| 31 | 24 | * @return 下拉数据源 |
| 32 | 25 | */ |
| 33 | - List<String> getSelectDataList(); | |
| 34 | - | |
| 35 | - // TODO @puhui999:这个建议放到 SelectSheetWriteHandler 里 | |
| 36 | - default List<String> handle(String funcName) { | |
| 37 | - if (StrUtil.isEmptyIfStr(funcName) || !StrUtil.equals(getFunctionName(), funcName)) { | |
| 38 | - return Collections.emptyList(); | |
| 39 | - } | |
| 40 | - return getSelectDataList(); | |
| 41 | - } | |
| 26 | + List<String> getOptions(); | |
| 42 | 27 | |
| 43 | 28 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/handler/SelectSheetWriteHandler.java
| ... | ... | @@ -2,15 +2,19 @@ package cn.iocoder.yudao.framework.excel.core.handler; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.map.MapUtil; |
| 5 | +import cn.hutool.core.util.ObjUtil; | |
| 6 | +import cn.hutool.core.util.StrUtil; | |
| 5 | 7 | import cn.hutool.extra.spring.SpringUtil; |
| 6 | 8 | import cn.hutool.poi.excel.ExcelUtil; |
| 7 | 9 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 10 | +import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils; | |
| 8 | 11 | import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; |
| 9 | -import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | |
| 12 | +import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction; | |
| 10 | 13 | import com.alibaba.excel.annotation.ExcelProperty; |
| 11 | 14 | import com.alibaba.excel.write.handler.SheetWriteHandler; |
| 12 | 15 | import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
| 13 | 16 | import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; |
| 17 | +import lombok.extern.slf4j.Slf4j; | |
| 14 | 18 | import org.apache.poi.hssf.usermodel.HSSFDataValidation; |
| 15 | 19 | import org.apache.poi.ss.usermodel.*; |
| 16 | 20 | import org.apache.poi.ss.util.CellRangeAddressList; |
| ... | ... | @@ -26,13 +30,9 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. |
| 26 | 30 | * |
| 27 | 31 | * @author HUIHUI |
| 28 | 32 | */ |
| 33 | +@Slf4j | |
| 29 | 34 | public class SelectSheetWriteHandler implements SheetWriteHandler { |
| 30 | 35 | |
| 31 | - // TODO @puhui999:注释哈; | |
| 32 | - private static final List<String> ALPHABET = getExcelColumnNameList(); | |
| 33 | - | |
| 34 | - private static final List<ExcelColumnSelectDataService> EXCEL_COLUMN_SELECT_DATA_SERVICES = new ArrayList<>(); | |
| 35 | - | |
| 36 | 36 | /** |
| 37 | 37 | * 数据起始行从 0 开始 |
| 38 | 38 | * |
| ... | ... | @@ -46,34 +46,35 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { |
| 46 | 46 | |
| 47 | 47 | private static final String DICT_SHEET_NAME = "字典sheet"; |
| 48 | 48 | |
| 49 | - // TODO @puhui999:这个 selectMap 可以改成 Map<Integer, List<String>>,然后在 afterSheetCreate 里面进行排序。这样整体的理解成本会更简单 | |
| 50 | - private final List<KeyValue<Integer, List<String>>> selectMap = new ArrayList<>(); // 使用 List + KeyValue 组合方便排序 | |
| 49 | + /** | |
| 50 | + * key: 列 value: 下拉数据源 | |
| 51 | + */ | |
| 52 | + private final Map<Integer, List<String>> selectMap = new HashMap<>(); | |
| 51 | 53 | |
| 52 | 54 | public SelectSheetWriteHandler(Class<?> head) { |
| 53 | 55 | // 加载下拉数据获取接口 |
| 54 | - Map<String, ExcelColumnSelectDataService> beansMap = SpringUtil.getBeanFactory().getBeansOfType(ExcelColumnSelectDataService.class); | |
| 56 | + Map<String, ExcelColumnSelectFunction> beansMap = SpringUtil.getBeanFactory().getBeansOfType(ExcelColumnSelectFunction.class); | |
| 55 | 57 | if (MapUtil.isEmpty(beansMap)) { |
| 56 | 58 | return; |
| 57 | 59 | } |
| 58 | - // TODO @puhui999:static 是共享。如果并发情况下,会不会存在问题? 其实 EXCEL_COLUMN_SELECT_DATA_SERVICES 不用全局声明,直接 按照 ExcelColumnSelect 去拿下就好了; | |
| 59 | - if (CollUtil.isEmpty(EXCEL_COLUMN_SELECT_DATA_SERVICES) || EXCEL_COLUMN_SELECT_DATA_SERVICES.size() != beansMap.values().size()) { | |
| 60 | - EXCEL_COLUMN_SELECT_DATA_SERVICES.clear(); | |
| 61 | - EXCEL_COLUMN_SELECT_DATA_SERVICES.addAll(convertList(beansMap.values(), b -> b)); | |
| 62 | - } | |
| 63 | 60 | |
| 64 | 61 | // 解析下拉数据 |
| 65 | - // TODO @puhui999:感觉可以 head 循环 field,如果有 ExcelColumnSelect 则进行处理;而 ExcelProperty 可能是非必须的 | |
| 62 | + // TODO @puhui999:感觉可以 head 循环 field,如果有 ExcelColumnSelect 则进行处理;而 ExcelProperty 可能是非必须的。回答:主要是用于定位到列索引 | |
| 66 | 63 | Map<String, Field> excelPropertyFields = getFieldsWithAnnotation(head, ExcelProperty.class); |
| 67 | 64 | Map<String, Field> excelColumnSelectFields = getFieldsWithAnnotation(head, ExcelColumnSelect.class); |
| 68 | 65 | int colIndex = 0; |
| 69 | 66 | for (String fieldName : excelPropertyFields.keySet()) { |
| 70 | 67 | Field field = excelColumnSelectFields.get(fieldName); |
| 71 | 68 | if (field != null) { |
| 69 | + // ExcelProperty 有一个自定义列索引的属性 index 兼容这个字段 | |
| 70 | + int index = field.getAnnotation(ExcelProperty.class).index(); | |
| 71 | + if (index != -1) { | |
| 72 | + colIndex = index; | |
| 73 | + } | |
| 72 | 74 | getSelectDataList(colIndex, field); |
| 73 | 75 | } |
| 74 | 76 | colIndex++; |
| 75 | 77 | } |
| 76 | - selectMap.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错 | |
| 77 | 78 | } |
| 78 | 79 | |
| 79 | 80 | /** |
| ... | ... | @@ -83,12 +84,25 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { |
| 83 | 84 | * @param field 字段 |
| 84 | 85 | */ |
| 85 | 86 | private void getSelectDataList(int colIndex, Field field) { |
| 86 | - EXCEL_COLUMN_SELECT_DATA_SERVICES.forEach(selectDataService -> { | |
| 87 | - List<String> stringList = selectDataService.handle(field.getAnnotation(ExcelColumnSelect.class).value()); | |
| 88 | - if (CollUtil.isEmpty(stringList)) { | |
| 87 | + // 获得下拉注解信息 | |
| 88 | + ExcelColumnSelect columnSelect = field.getAnnotation(ExcelColumnSelect.class); | |
| 89 | + String dictType = columnSelect.dictType(); | |
| 90 | + if (StrUtil.isNotEmpty(dictType)) { // 情况一: 字典数据 (默认) | |
| 91 | + selectMap.put(colIndex, DictFrameworkUtils.getDictDataLabelList(dictType)); | |
| 92 | + return; | |
| 93 | + } | |
| 94 | + String functionName = columnSelect.functionName(); | |
| 95 | + if (StrUtil.isEmpty(functionName)) { // 情况二: 获取自定义数据 | |
| 96 | + log.warn("[getSelectDataList]解析下拉数据失败,参数信息 dictType[{}] functionName[{}]", dictType, functionName); | |
| 97 | + return; | |
| 98 | + } | |
| 99 | + // 获得所有的下拉数据源获取方法 | |
| 100 | + Map<String, ExcelColumnSelectFunction> functionMap = SpringUtil.getApplicationContext().getBeansOfType(ExcelColumnSelectFunction.class); | |
| 101 | + functionMap.values().forEach(func -> { | |
| 102 | + if (ObjUtil.notEqual(func.getName(), functionName)) { | |
| 89 | 103 | return; |
| 90 | 104 | } |
| 91 | - selectMap.add(new KeyValue<>(colIndex, stringList)); | |
| 105 | + selectMap.put(colIndex, func.getOptions()); | |
| 92 | 106 | }); |
| 93 | 107 | } |
| 94 | 108 | |
| ... | ... | @@ -101,10 +115,11 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { |
| 101 | 115 | // 1. 获取相应操作对象 |
| 102 | 116 | DataValidationHelper helper = writeSheetHolder.getSheet().getDataValidationHelper(); // 需要设置下拉框的 sheet 页的数据验证助手 |
| 103 | 117 | Workbook workbook = writeWorkbookHolder.getWorkbook(); // 获得工作簿 |
| 104 | - | |
| 118 | + List<KeyValue<Integer, List<String>>> keyValues = convertList(selectMap.entrySet(), entry -> new KeyValue<>(entry.getKey(), entry.getValue())); | |
| 119 | + keyValues.sort(Comparator.comparing(item -> item.getValue().size())); // 升序不然创建下拉会报错 | |
| 105 | 120 | // 2. 创建数据字典的 sheet 页 |
| 106 | 121 | Sheet dictSheet = workbook.createSheet(DICT_SHEET_NAME); |
| 107 | - for (KeyValue<Integer, List<String>> keyValue : selectMap) { | |
| 122 | + for (KeyValue<Integer, List<String>> keyValue : keyValues) { | |
| 108 | 123 | int rowLength = keyValue.getValue().size(); |
| 109 | 124 | // 2.1 设置字典 sheet 页的值 每一列一个字典项 |
| 110 | 125 | for (int i = 0; i < rowLength; i++) { |
| ... | ... | @@ -126,7 +141,7 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { |
| 126 | 141 | KeyValue<Integer, List<String>> keyValue) { |
| 127 | 142 | // 1.1 创建可被其他单元格引用的名称 |
| 128 | 143 | Name name = workbook.createName(); |
| 129 | - String excelColumn = ALPHABET.get(keyValue.getKey()); | |
| 144 | + String excelColumn = ExcelUtil.indexToColName(keyValue.getKey()); | |
| 130 | 145 | // 1.2 下拉框数据来源 eg:字典sheet!$B1:$B2 |
| 131 | 146 | String refers = DICT_SHEET_NAME + "!$" + excelColumn + "$1:$" + excelColumn + "$" + keyValue.getValue().size(); |
| 132 | 147 | name.setNameName("dict" + keyValue.getKey()); // 设置名称的名字 |
| ... | ... | @@ -162,18 +177,4 @@ public class SelectSheetWriteHandler implements SheetWriteHandler { |
| 162 | 177 | return annotatedFields; |
| 163 | 178 | } |
| 164 | 179 | |
| 165 | - | |
| 166 | - private static List<String> getExcelColumnNameList() { | |
| 167 | - // TODO @puhui999:是不是可以使用 ExcelUtil.indexToColName() 替代 | |
| 168 | - ArrayList<String> strings = new ArrayList<>(); | |
| 169 | - for (int i = 1; i <= 52; i++) { // 生成 52 列名称,需要更多请重写此方法 | |
| 170 | - if (i <= 26) { | |
| 171 | - strings.add(String.valueOf((char) ('A' + i - 1))); // 使用 ASCII 码值转字母 | |
| 172 | - } else { | |
| 173 | - strings.add(String.valueOf((char) ('A' + (i - 1) / 26 - 1)) + (char) ('A' + (i - 1) % 26)); | |
| 174 | - } | |
| 175 | - } | |
| 176 | - return strings; | |
| 177 | - } | |
| 178 | - | |
| 179 | 180 | } |
| 180 | 181 | \ No newline at end of file | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessTransferReqVO.java
| ... | ... | @@ -3,15 +3,19 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; |
| 3 | 3 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | import jakarta.validation.constraints.NotNull; |
| 6 | +import lombok.AllArgsConstructor; | |
| 6 | 7 | import lombok.Data; |
| 8 | +import lombok.NoArgsConstructor; | |
| 7 | 9 | |
| 8 | 10 | @Schema(description = "管理后台 - 商机转移 Request VO") |
| 9 | 11 | @Data |
| 12 | +@NoArgsConstructor | |
| 13 | +@AllArgsConstructor | |
| 10 | 14 | public class CrmBusinessTransferReqVO { |
| 11 | 15 | |
| 12 | 16 | @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 13 | 17 | @NotNull(message = "商机编号不能为空") |
| 14 | - private Long id; | |
| 18 | + private Long bizId; | |
| 15 | 19 | |
| 16 | 20 | /** |
| 17 | 21 | * 新负责人的用户编号 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueTransferReqVO.java
| ... | ... | @@ -12,7 +12,7 @@ public class CrmClueTransferReqVO { |
| 12 | 12 | |
| 13 | 13 | @Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 14 | 14 | @NotNull(message = "线索编号不能为空") |
| 15 | - private Long id; | |
| 15 | + private Long bizId; | |
| 16 | 16 | |
| 17 | 17 | @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 18 | 18 | @NotNull(message = "新负责人的用户编号不能为空") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java
| ... | ... | @@ -2,17 +2,21 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 4 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | +import lombok.AllArgsConstructor; | |
| 5 | 6 | import lombok.Data; |
| 6 | 7 | |
| 7 | 8 | import jakarta.validation.constraints.NotNull; |
| 9 | +import lombok.NoArgsConstructor; | |
| 8 | 10 | |
| 9 | 11 | @Schema(description = "管理后台 - CRM 联系人转移 Request VO") |
| 10 | 12 | @Data |
| 13 | +@NoArgsConstructor | |
| 14 | +@AllArgsConstructor | |
| 11 | 15 | public class CrmContactTransferReqVO { |
| 12 | 16 | |
| 13 | 17 | @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 14 | 18 | @NotNull(message = "联系人编号不能为空") |
| 15 | - private Long id; | |
| 19 | + private Long bizId; | |
| 16 | 20 | |
| 17 | 21 | /** |
| 18 | 22 | * 新负责人的用户编号 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/contract/CrmContractTransferReqVO.java
| ... | ... | @@ -3,17 +3,21 @@ package cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 5 | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | +import lombok.AllArgsConstructor; | |
| 6 | 7 | import lombok.Data; |
| 7 | 8 | |
| 8 | 9 | import jakarta.validation.constraints.NotNull; |
| 10 | +import lombok.NoArgsConstructor; | |
| 9 | 11 | |
| 10 | 12 | @Schema(description = "管理后台 - CRM 合同转移 Request VO") |
| 11 | 13 | @Data |
| 14 | +@NoArgsConstructor | |
| 15 | +@AllArgsConstructor | |
| 12 | 16 | public class CrmContractTransferReqVO { |
| 13 | 17 | |
| 14 | 18 | @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 15 | 19 | @NotNull(message = "联系人编号不能为空") |
| 16 | - private Long id; | |
| 20 | + private Long bizId; | |
| 17 | 21 | |
| 18 | 22 | @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 19 | 23 | @NotNull(message = "新负责人的用户编号不能为空") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerImportExcelVO.java
| ... | ... | @@ -4,10 +4,7 @@ import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; |
| 4 | 4 | import cn.iocoder.yudao.framework.excel.core.annotations.ExcelColumnSelect; |
| 5 | 5 | import cn.iocoder.yudao.framework.excel.core.convert.AreaConvert; |
| 6 | 6 | import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; |
| 7 | -import cn.iocoder.yudao.module.crm.framework.excel.service.AreaExcelColumnSelectDataServiceImpl; | |
| 8 | -import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerIndustryExcelColumnSelectDataServiceImpl; | |
| 9 | -import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerLevelExcelColumnSelectDataServiceImpl; | |
| 10 | -import cn.iocoder.yudao.module.crm.framework.excel.service.CrmCustomerSourceExcelColumnSelectDataServiceImpl; | |
| 7 | +import cn.iocoder.yudao.module.crm.framework.excel.core.AreaExcelColumnSelectFunctionImpl; | |
| 11 | 8 | import com.alibaba.excel.annotation.ExcelProperty; |
| 12 | 9 | import lombok.AllArgsConstructor; |
| 13 | 10 | import lombok.Builder; |
| ... | ... | @@ -46,7 +43,7 @@ public class CrmCustomerImportExcelVO { |
| 46 | 43 | private String email; |
| 47 | 44 | |
| 48 | 45 | @ExcelProperty(value = "地区", converter = AreaConvert.class) |
| 49 | - @ExcelColumnSelect(AreaExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | |
| 46 | + @ExcelColumnSelect(functionName = AreaExcelColumnSelectFunctionImpl.NAME) | |
| 50 | 47 | private Integer areaId; |
| 51 | 48 | |
| 52 | 49 | @ExcelProperty("详细地址") |
| ... | ... | @@ -54,17 +51,17 @@ public class CrmCustomerImportExcelVO { |
| 54 | 51 | |
| 55 | 52 | @ExcelProperty(value = "所属行业", converter = DictConvert.class) |
| 56 | 53 | @DictFormat(CRM_CUSTOMER_INDUSTRY) |
| 57 | - @ExcelColumnSelect(CrmCustomerIndustryExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | |
| 54 | + @ExcelColumnSelect(dictType = CRM_CUSTOMER_INDUSTRY) | |
| 58 | 55 | private Integer industryId; |
| 59 | 56 | |
| 60 | 57 | @ExcelProperty(value = "客户等级", converter = DictConvert.class) |
| 61 | 58 | @DictFormat(CRM_CUSTOMER_LEVEL) |
| 62 | - @ExcelColumnSelect(CrmCustomerLevelExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | |
| 59 | + @ExcelColumnSelect(dictType = CRM_CUSTOMER_LEVEL) | |
| 63 | 60 | private Integer level; |
| 64 | 61 | |
| 65 | 62 | @ExcelProperty(value = "客户来源", converter = DictConvert.class) |
| 66 | 63 | @DictFormat(CRM_CUSTOMER_SOURCE) |
| 67 | - @ExcelColumnSelect(CrmCustomerSourceExcelColumnSelectDataServiceImpl.FUNCTION_NAME) | |
| 64 | + @ExcelColumnSelect(dictType = CRM_CUSTOMER_SOURCE) | |
| 68 | 65 | private Integer source; |
| 69 | 66 | |
| 70 | 67 | @ExcelProperty("备注") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/customer/CrmCustomerTransferReqVO.java
| ... | ... | @@ -5,13 +5,15 @@ import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | 5 | import jakarta.validation.constraints.NotNull; |
| 6 | 6 | import lombok.Data; |
| 7 | 7 | |
| 8 | +import java.util.List; | |
| 9 | + | |
| 8 | 10 | @Schema(description = "管理后台 - CRM 客户转移 Request VO") |
| 9 | 11 | @Data |
| 10 | 12 | public class CrmCustomerTransferReqVO { |
| 11 | 13 | |
| 12 | 14 | @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") |
| 13 | 15 | @NotNull(message = "客户编号不能为空") |
| 14 | - private Long id; | |
| 16 | + private Long bizId; | |
| 15 | 17 | |
| 16 | 18 | /** |
| 17 | 19 | * 新负责人的用户编号 |
| ... | ... | @@ -28,4 +30,10 @@ public class CrmCustomerTransferReqVO { |
| 28 | 30 | @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 29 | 31 | private Integer oldOwnerPermissionLevel; |
| 30 | 32 | |
| 33 | + /** | |
| 34 | + * 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择 | |
| 35 | + */ | |
| 36 | + @Schema(description = "同时转移", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 37 | + private List<Integer> toBizTypes; | |
| 38 | + | |
| 31 | 39 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java
| ... | ... | @@ -5,12 +5,19 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | -import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO; | |
| 9 | 8 | import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionRespVO; |
| 9 | +import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionSaveReqVO; | |
| 10 | 10 | import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionUpdateReqVO; |
| 11 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | |
| 12 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | |
| 13 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | |
| 11 | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; |
| 15 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | |
| 12 | 16 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 13 | 17 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| 18 | +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; | |
| 19 | +import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; | |
| 20 | +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; | |
| 14 | 21 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 15 | 22 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 16 | 23 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| ... | ... | @@ -27,13 +34,11 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
| 27 | 34 | import jakarta.annotation.Resource; |
| 28 | 35 | import jakarta.validation.Valid; |
| 29 | 36 | import org.springframework.security.access.prepost.PreAuthorize; |
| 37 | +import org.springframework.transaction.annotation.Transactional; | |
| 30 | 38 | import org.springframework.validation.annotation.Validated; |
| 31 | 39 | import org.springframework.web.bind.annotation.*; |
| 32 | 40 | |
| 33 | -import java.util.Collection; | |
| 34 | -import java.util.Collections; | |
| 35 | -import java.util.List; | |
| 36 | -import java.util.Map; | |
| 41 | +import java.util.*; | |
| 37 | 42 | import java.util.stream.Stream; |
| 38 | 43 | |
| 39 | 44 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -50,7 +55,12 @@ public class CrmPermissionController { |
| 50 | 55 | |
| 51 | 56 | @Resource |
| 52 | 57 | private CrmPermissionService permissionService; |
| 53 | - | |
| 58 | + @Resource | |
| 59 | + private CrmContactService contactService; | |
| 60 | + @Resource | |
| 61 | + private CrmBusinessService businessService; | |
| 62 | + @Resource | |
| 63 | + private CrmContractService contractService; | |
| 54 | 64 | @Resource |
| 55 | 65 | private AdminUserApi adminUserApi; |
| 56 | 66 | @Resource |
| ... | ... | @@ -60,13 +70,47 @@ public class CrmPermissionController { |
| 60 | 70 | |
| 61 | 71 | @PostMapping("/create") |
| 62 | 72 | @Operation(summary = "创建数据权限") |
| 73 | + @Transactional(rollbackFor = Exception.class) | |
| 63 | 74 | @PreAuthorize("@ss.hasPermission('crm:permission:create')") |
| 64 | 75 | @CrmPermission(bizTypeValue = "#reqVO.bizType", bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) |
| 65 | - public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionCreateReqVO reqVO) { | |
| 76 | + public CommonResult<Boolean> addPermission(@Valid @RequestBody CrmPermissionSaveReqVO reqVO) { | |
| 66 | 77 | permissionService.createPermission(BeanUtils.toBean(reqVO, CrmPermissionCreateReqBO.class)); |
| 78 | + if (CollUtil.isNotEmpty(reqVO.getToBizTypes())) { | |
| 79 | + createBizTypePermissions(reqVO); | |
| 80 | + } | |
| 67 | 81 | return success(true); |
| 68 | 82 | } |
| 69 | 83 | |
| 84 | + | |
| 85 | + private void createBizTypePermissions(CrmPermissionSaveReqVO reqVO) { | |
| 86 | + List<CrmPermissionCreateReqBO> createPermissions = new ArrayList<>(); | |
| 87 | + if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) { | |
| 88 | + List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getBizId(), getLoginUserId()); | |
| 89 | + contactList.forEach(item -> { | |
| 90 | + createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()) | |
| 91 | + .setBizId(item.getId()).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel())); | |
| 92 | + }); | |
| 93 | + } | |
| 94 | + if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) { | |
| 95 | + List<CrmBusinessDO> businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getBizId(), getLoginUserId()); | |
| 96 | + businessList.forEach(item -> { | |
| 97 | + createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) | |
| 98 | + .setBizId(item.getId()).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel())); | |
| 99 | + }); | |
| 100 | + } | |
| 101 | + if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) { | |
| 102 | + List<CrmContractDO> contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getBizId(), getLoginUserId()); | |
| 103 | + contractList.forEach(item -> { | |
| 104 | + createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()) | |
| 105 | + .setBizId(item.getId()).setUserId(reqVO.getUserId()).setLevel(reqVO.getLevel())); | |
| 106 | + }); | |
| 107 | + } | |
| 108 | + if (CollUtil.isEmpty(createPermissions)) { | |
| 109 | + return; | |
| 110 | + } | |
| 111 | + permissionService.createPermissionBatch(createPermissions); | |
| 112 | + } | |
| 113 | + | |
| 70 | 114 | @PutMapping("/update") |
| 71 | 115 | @Operation(summary = "编辑数据权限") |
| 72 | 116 | @PreAuthorize("@ss.hasPermission('crm:permission:update')") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 7 | - | |
| 8 | -@Schema(description = "管理后台 - CRM 数据权限创建 Request VO") | |
| 9 | -@Data | |
| 10 | -@EqualsAndHashCode(callSuper = true) | |
| 11 | -@ToString(callSuper = true) | |
| 12 | -public class CrmPermissionCreateReqVO extends CrmPermissionBaseVO { | |
| 13 | - | |
| 14 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.controller.admin.permission.vo; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | |
| 5 | +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; | |
| 3 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 7 | +import jakarta.validation.constraints.NotNull; | |
| 4 | 8 | import lombok.Data; |
| 5 | 9 | |
| 6 | 10 | import java.time.LocalDateTime; |
| ... | ... | @@ -8,11 +12,29 @@ import java.util.Set; |
| 8 | 12 | |
| 9 | 13 | @Schema(description = "管理后台 - CRM 数据权限 Response VO") |
| 10 | 14 | @Data |
| 11 | -public class CrmPermissionRespVO extends CrmPermissionBaseVO { | |
| 15 | +public class CrmPermissionRespVO { | |
| 12 | 16 | |
| 13 | 17 | @Schema(description = "数据权限编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") |
| 14 | 18 | private Long id; |
| 15 | 19 | |
| 20 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") | |
| 21 | + @NotNull(message = "用户编号不能为空") | |
| 22 | + private Long userId; | |
| 23 | + | |
| 24 | + @Schema(description = "CRM 类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 25 | + @InEnum(CrmBizTypeEnum.class) | |
| 26 | + @NotNull(message = "CRM 类型不能为空") | |
| 27 | + private Integer bizType; | |
| 28 | + | |
| 29 | + @Schema(description = "CRM 类型数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 30 | + @NotNull(message = "CRM 类型数据编号不能为空") | |
| 31 | + private Long bizId; | |
| 32 | + | |
| 33 | + @Schema(description = "权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 34 | + @InEnum(CrmPermissionLevelEnum.class) | |
| 35 | + @NotNull(message = "权限级别不能为空") | |
| 36 | + private Integer level; | |
| 37 | + | |
| 16 | 38 | @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") |
| 17 | 39 | private String nickname; |
| 18 | 40 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/vo/CrmPermissionSaveReqVO.java
| ... | ... | @@ -8,14 +8,11 @@ import lombok.Data; |
| 8 | 8 | |
| 9 | 9 | import jakarta.validation.constraints.NotNull; |
| 10 | 10 | |
| 11 | -/** | |
| 12 | - * 数据权限 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 13 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 14 | - * | |
| 15 | - * @author HUIHUI | |
| 16 | - */ | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +@Schema(description = "管理后台 - CRM 数据权限创建/更新 Request VO") | |
| 17 | 14 | @Data |
| 18 | -public class CrmPermissionBaseVO { | |
| 15 | +public class CrmPermissionSaveReqVO { | |
| 19 | 16 | |
| 20 | 17 | @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456") |
| 21 | 18 | @NotNull(message = "用户编号不能为空") |
| ... | ... | @@ -35,4 +32,10 @@ public class CrmPermissionBaseVO { |
| 35 | 32 | @NotNull(message = "权限级别不能为空") |
| 36 | 33 | private Integer level; |
| 37 | 34 | |
| 35 | + /** | |
| 36 | + * 添加客户团队成员时,需要额外有【联系人】【商机】【合同】的 checkbox 选择 | |
| 37 | + */ | |
| 38 | + @Schema(description = "同时添加", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") | |
| 39 | + private List<Integer> toBizTypes; | |
| 40 | + | |
| 38 | 41 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java
| ... | ... | @@ -6,12 +6,14 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | |
| 9 | 10 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 10 | 11 | import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; |
| 11 | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 12 | 13 | import org.apache.ibatis.annotations.Mapper; |
| 13 | 14 | |
| 14 | 15 | import java.util.Collection; |
| 16 | +import java.util.List; | |
| 15 | 17 | |
| 16 | 18 | /** |
| 17 | 19 | * 商机 Mapper |
| ... | ... | @@ -57,4 +59,10 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> { |
| 57 | 59 | return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId); |
| 58 | 60 | } |
| 59 | 61 | |
| 62 | + default List<CrmBusinessDO> selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId){ | |
| 63 | + return selectList(new LambdaQueryWrapperX<CrmBusinessDO>() | |
| 64 | + .eq(CrmBusinessDO::getCustomerId, customerId) | |
| 65 | + .eq(CrmBusinessDO::getOwnerUserId, ownerUserId)); | |
| 66 | + } | |
| 67 | + | |
| 60 | 68 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java
| ... | ... | @@ -73,4 +73,10 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> { |
| 73 | 73 | return selectList(CrmContactDO::getCustomerId, customerId); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | + default List<CrmContactDO> selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { | |
| 77 | + return selectList(new LambdaQueryWrapperX<CrmContactDO>() | |
| 78 | + .eq(CrmContactDO::getCustomerId, customerId) | |
| 79 | + .eq(CrmContactDO::getOwnerUserId, ownerUserId)); | |
| 80 | + } | |
| 81 | + | |
| 76 | 82 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java
| ... | ... | @@ -117,4 +117,10 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> { |
| 117 | 117 | return selectCount(query); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | + default List<CrmContractDO> selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { | |
| 121 | + return selectList(new LambdaQueryWrapperX<CrmContractDO>() | |
| 122 | + .eq(CrmContractDO::getCustomerId, customerId) | |
| 123 | + .eq(CrmContractDO::getOwnerUserId, ownerUserId)); | |
| 124 | + } | |
| 125 | + | |
| 120 | 126 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/AreaExcelColumnSelectDataServiceImpl.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/core/AreaExcelColumnSelectFunctionImpl.java
| 1 | -package cn.iocoder.yudao.module.crm.framework.excel.service; | |
| 1 | +package cn.iocoder.yudao.module.crm.framework.excel.core; | |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.function.ExcelColumnSelectFunction; | |
| 4 | 4 | import cn.iocoder.yudao.framework.ip.core.Area; |
| 5 | 5 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 6 | 6 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -13,17 +13,17 @@ import java.util.List; |
| 13 | 13 | * @author HUIHUI |
| 14 | 14 | */ |
| 15 | 15 | @Service |
| 16 | -public class AreaExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | |
| 16 | +public class AreaExcelColumnSelectFunctionImpl implements ExcelColumnSelectFunction { | |
| 17 | 17 | |
| 18 | - public static final String FUNCTION_NAME = "getCrmAreaNameList"; // 防止和别的模块重名 | |
| 18 | + public static final String NAME = "getCrmAreaNameList"; // 防止和别的模块重名 | |
| 19 | 19 | |
| 20 | 20 | @Override |
| 21 | - public String getFunctionName() { | |
| 22 | - return FUNCTION_NAME; | |
| 21 | + public String getName() { | |
| 22 | + return NAME; | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | @Override |
| 26 | - public List<String> getSelectDataList() { | |
| 26 | + public List<String> getOptions() { | |
| 27 | 27 | // 获取地区下拉数据 |
| 28 | 28 | // TODO @puhui999:嘿嘿,这里改成省份、城市、区域,三个选项,难度大么? |
| 29 | 29 | Area area = AreaUtils.getArea(Area.ID_CHINA); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/package-info.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerIndustryExcelColumnSelectDataServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.framework.excel.service; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | |
| 4 | -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | |
| 5 | -import jakarta.annotation.Resource; | |
| 6 | -import org.springframework.stereotype.Service; | |
| 7 | - | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Excel 客户所属行业列下拉数据源获取接口实现类 | |
| 14 | - * | |
| 15 | - * @author HUIHUI | |
| 16 | - */ | |
| 17 | -@Service | |
| 18 | -public class CrmCustomerIndustryExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | |
| 19 | - | |
| 20 | - public static final String FUNCTION_NAME = "getCrmCustomerIndustryList"; | |
| 21 | - | |
| 22 | - @Resource | |
| 23 | - private DictDataApi dictDataApi; | |
| 24 | - | |
| 25 | - @Override | |
| 26 | - public String getFunctionName() { | |
| 27 | - return FUNCTION_NAME; | |
| 28 | - } | |
| 29 | - | |
| 30 | - @Override | |
| 31 | - public List<String> getSelectDataList() { | |
| 32 | - return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_INDUSTRY); | |
| 33 | - } | |
| 34 | - | |
| 35 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerLevelExcelColumnSelectDataServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.framework.excel.service; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | |
| 4 | -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | |
| 5 | -import jakarta.annotation.Resource; | |
| 6 | -import org.springframework.stereotype.Service; | |
| 7 | - | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Excel 客户等级列下拉数据源获取接口实现类 | |
| 14 | - * | |
| 15 | - * @author HUIHUI | |
| 16 | - */ | |
| 17 | -@Service | |
| 18 | -public class CrmCustomerLevelExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | |
| 19 | - | |
| 20 | - public static final String FUNCTION_NAME = "getCrmCustomerLevelList"; | |
| 21 | - | |
| 22 | - @Resource | |
| 23 | - private DictDataApi dictDataApi; | |
| 24 | - | |
| 25 | - @Override | |
| 26 | - public String getFunctionName() { | |
| 27 | - return FUNCTION_NAME; | |
| 28 | - } | |
| 29 | - | |
| 30 | - @Override | |
| 31 | - public List<String> getSelectDataList() { | |
| 32 | - return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_LEVEL); | |
| 33 | - } | |
| 34 | - | |
| 35 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/excel/service/CrmCustomerSourceExcelColumnSelectDataServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.framework.excel.service; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.excel.core.service.ExcelColumnSelectDataService; | |
| 4 | -import cn.iocoder.yudao.module.system.api.dict.DictDataApi; | |
| 5 | -import jakarta.annotation.Resource; | |
| 6 | -import org.springframework.stereotype.Service; | |
| 7 | - | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | -import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Excel 客户来源列下拉数据源获取接口实现类 | |
| 14 | - * | |
| 15 | - * @author HUIHUI | |
| 16 | - */ | |
| 17 | -@Service | |
| 18 | -public class CrmCustomerSourceExcelColumnSelectDataServiceImpl implements ExcelColumnSelectDataService { | |
| 19 | - | |
| 20 | - public static final String FUNCTION_NAME = "getCrmCustomerSourceList"; | |
| 21 | - | |
| 22 | - @Resource | |
| 23 | - private DictDataApi dictDataApi; | |
| 24 | - | |
| 25 | - @Override | |
| 26 | - public String getFunctionName() { | |
| 27 | - return FUNCTION_NAME; | |
| 28 | - } | |
| 29 | - | |
| 30 | - @Override | |
| 31 | - public List<String> getSelectDataList() { | |
| 32 | - return dictDataApi.getDictDataLabelList(CRM_CUSTOMER_SOURCE); | |
| 33 | - } | |
| 34 | - | |
| 35 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java
| ... | ... | @@ -46,8 +46,8 @@ public interface CrmBusinessService { |
| 46 | 46 | /** |
| 47 | 47 | * 更新商机相关跟进信息 |
| 48 | 48 | * |
| 49 | - * @param id 编号 | |
| 50 | - * @param contactNextTime 下次联系时间 | |
| 49 | + * @param id 编号 | |
| 50 | + * @param contactNextTime 下次联系时间 | |
| 51 | 51 | * @param contactLastContent 最后联系内容 |
| 52 | 52 | */ |
| 53 | 53 | void updateBusinessFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); |
| ... | ... | @@ -55,7 +55,7 @@ public interface CrmBusinessService { |
| 55 | 55 | /** |
| 56 | 56 | * 更新商机的下次联系时间 |
| 57 | 57 | * |
| 58 | - * @param ids 编号数组 | |
| 58 | + * @param ids 编号数组 | |
| 59 | 59 | * @param contactNextTime 下次联系时间 |
| 60 | 60 | */ |
| 61 | 61 | void updateBusinessContactNextTime(Collection<Long> ids, LocalDateTime contactNextTime); |
| ... | ... | @@ -185,4 +185,13 @@ public interface CrmBusinessService { |
| 185 | 185 | return status.getName(); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | + /** | |
| 189 | + * 获得商机列表 | |
| 190 | + * | |
| 191 | + * @param customerId 客户编号 | |
| 192 | + * @param ownerUserId 负责人编号 | |
| 193 | + * @return 商机列表 | |
| 194 | + */ | |
| 195 | + List<CrmBusinessDO> getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); | |
| 196 | + | |
| 188 | 197 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.business; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | +import cn.hutool.extra.spring.SpringUtil; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| ... | ... | @@ -23,6 +24,7 @@ import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService; |
| 23 | 24 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| 24 | 25 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| 25 | 26 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 27 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerServiceImpl; | |
| 26 | 28 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 27 | 29 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 28 | 30 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| ... | ... | @@ -204,7 +206,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 204 | 206 | |
| 205 | 207 | private List<CrmBusinessProductDO> validateBusinessProducts(List<CrmBusinessSaveReqVO.Product> list) { |
| 206 | 208 | // 1. 校验产品存在 |
| 207 | - productService.validProductList(convertSet(list, CrmBusinessSaveReqVO.Product::getProductId)); | |
| 209 | + productService.validProductList(convertSet(list, CrmBusinessSaveReqVO.Product::getProductId)); | |
| 208 | 210 | // 2. 转化为 CrmBusinessProductDO 列表 |
| 209 | 211 | return convertList(list, o -> BeanUtils.toBean(o, CrmBusinessProductDO.class, |
| 210 | 212 | item -> item.setTotalPrice(MoneyUtils.priceMultiply(item.getBusinessPrice(), item.getCount())))); |
| ... | ... | @@ -234,7 +236,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 234 | 236 | } |
| 235 | 237 | // 1.4 校验是不是状态没变更 |
| 236 | 238 | if ((reqVO.getStatusId() != null && reqVO.getStatusId().equals(business.getStatusId())) |
| 237 | - || (reqVO.getEndStatus() != null && reqVO.getEndStatus().equals(business.getEndStatus()))) { | |
| 239 | + || (reqVO.getEndStatus() != null && reqVO.getEndStatus().equals(business.getEndStatus()))) { | |
| 238 | 240 | throw exception(BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS); |
| 239 | 241 | } |
| 240 | 242 | |
| ... | ... | @@ -292,18 +294,18 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 292 | 294 | |
| 293 | 295 | @Override |
| 294 | 296 | @Transactional(rollbackFor = Exception.class) |
| 295 | - @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", | |
| 297 | + @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}", | |
| 296 | 298 | success = CRM_BUSINESS_TRANSFER_SUCCESS) |
| 297 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) | |
| 299 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_BUSINESS, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) | |
| 298 | 300 | public void transferBusiness(CrmBusinessTransferReqVO reqVO, Long userId) { |
| 299 | 301 | // 1 校验商机是否存在 |
| 300 | - CrmBusinessDO business = validateBusinessExists(reqVO.getId()); | |
| 302 | + CrmBusinessDO business = validateBusinessExists(reqVO.getBizId()); | |
| 301 | 303 | |
| 302 | 304 | // 2.1 数据权限转移 |
| 303 | 305 | permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_BUSINESS.getType(), |
| 304 | - reqVO.getNewOwnerUserId(), reqVO.getId(), CrmPermissionLevelEnum.OWNER.getLevel())); | |
| 306 | + reqVO.getBizId(), reqVO.getNewOwnerUserId(), CrmPermissionLevelEnum.OWNER.getLevel())); | |
| 305 | 307 | // 2.2 设置新的负责人 |
| 306 | - businessMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId()); | |
| 308 | + businessMapper.updateOwnerUserIdById(reqVO.getBizId(), reqVO.getNewOwnerUserId()); | |
| 307 | 309 | |
| 308 | 310 | // 记录操作日志上下文 |
| 309 | 311 | LogRecordContext.putVariable("business", business); |
| ... | ... | @@ -370,4 +372,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 370 | 372 | return businessMapper.selectCountByStatusTypeId(statusTypeId); |
| 371 | 373 | } |
| 372 | 374 | |
| 375 | + @Override | |
| 376 | + public List<CrmBusinessDO> getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { | |
| 377 | + return businessMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); | |
| 378 | + } | |
| 379 | + | |
| 373 | 380 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java
| ... | ... | @@ -159,18 +159,18 @@ public class CrmClueServiceImpl implements CrmClueService { |
| 159 | 159 | |
| 160 | 160 | @Override |
| 161 | 161 | @Transactional(rollbackFor = Exception.class) |
| 162 | - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", | |
| 162 | + @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}", | |
| 163 | 163 | success = CRM_CLUE_TRANSFER_SUCCESS) |
| 164 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) | |
| 164 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) | |
| 165 | 165 | public void transferClue(CrmClueTransferReqVO reqVO, Long userId) { |
| 166 | 166 | // 1 校验线索是否存在 |
| 167 | - CrmClueDO clue = validateClueExists(reqVO.getId()); | |
| 167 | + CrmClueDO clue = validateClueExists(reqVO.getBizId()); | |
| 168 | 168 | |
| 169 | 169 | // 2.1 数据权限转移 |
| 170 | 170 | crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CLUE.getType(), |
| 171 | - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 171 | + reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 172 | 172 | // 2.2 设置新的负责人 |
| 173 | - clueMapper.updateById(new CrmClueDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | |
| 173 | + clueMapper.updateById(new CrmClueDO().setId(reqVO.getBizId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | |
| 174 | 174 | |
| 175 | 175 | // 3. 记录转移日志 |
| 176 | 176 | LogRecordContext.putVariable("clue", clue); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactService.java
| ... | ... | @@ -75,8 +75,8 @@ public interface CrmContactService { |
| 75 | 75 | /** |
| 76 | 76 | * 更新联系人的下次联系时间 |
| 77 | 77 | * |
| 78 | - * @param ids 编号数组 | |
| 79 | - * @param contactNextTime 下次联系时间 | |
| 78 | + * @param ids 编号数组 | |
| 79 | + * @param contactNextTime 下次联系时间 | |
| 80 | 80 | */ |
| 81 | 81 | void updateContactContactNextTime(Collection<Long> ids, LocalDateTime contactNextTime); |
| 82 | 82 | |
| ... | ... | @@ -160,4 +160,13 @@ public interface CrmContactService { |
| 160 | 160 | */ |
| 161 | 161 | Long getContactCountByCustomerId(Long customerId); |
| 162 | 162 | |
| 163 | + /** | |
| 164 | + * 获得联系人列表 | |
| 165 | + * | |
| 166 | + * @param customerId 客户编号 | |
| 167 | + * @param ownerUserId 负责人编号 | |
| 168 | + * @return 联系人列表 | |
| 169 | + */ | |
| 170 | + List<CrmContactDO> getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); | |
| 171 | + | |
| 163 | 172 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.contact; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | +import cn.hutool.extra.spring.SpringUtil; | |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | 8 | 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 |
| 17 | 18 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 18 | 19 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| 19 | 20 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 21 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerServiceImpl; | |
| 20 | 22 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 21 | 23 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 22 | 24 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| ... | ... | @@ -177,18 +179,18 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 177 | 179 | |
| 178 | 180 | @Override |
| 179 | 181 | @Transactional(rollbackFor = Exception.class) |
| 180 | - @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", | |
| 182 | + @LogRecord(type = CRM_CONTACT_TYPE, subType = CRM_CONTACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}", | |
| 181 | 183 | success = CRM_CONTACT_TRANSFER_SUCCESS) |
| 182 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) | |
| 184 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) | |
| 183 | 185 | public void transferContact(CrmContactTransferReqVO reqVO, Long userId) { |
| 184 | 186 | // 1 校验联系人是否存在 |
| 185 | - CrmContactDO contact = validateContactExists(reqVO.getId()); | |
| 187 | + CrmContactDO contact = validateContactExists(reqVO.getBizId()); | |
| 186 | 188 | |
| 187 | 189 | // 2.1 数据权限转移 |
| 188 | 190 | permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTACT.getType(), |
| 189 | - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 191 | + reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 190 | 192 | // 2.2 设置新的负责人 |
| 191 | - contactMapper.updateById(new CrmContactDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | |
| 193 | + contactMapper.updateById(new CrmContactDO().setId(reqVO.getBizId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | |
| 192 | 194 | |
| 193 | 195 | // 3. 记录转移日志 |
| 194 | 196 | LogRecordContext.putVariable("contact", contact); |
| ... | ... | @@ -298,4 +300,9 @@ public class CrmContactServiceImpl implements CrmContactService { |
| 298 | 300 | return contactMapper.selectCount(CrmContactDO::getCustomerId, customerId); |
| 299 | 301 | } |
| 300 | 302 | |
| 303 | + @Override | |
| 304 | + public List<CrmContactDO> getContactListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { | |
| 305 | + return contactMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); | |
| 306 | + } | |
| 307 | + | |
| 301 | 308 | } |
| 302 | 309 | \ No newline at end of file | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java
| ... | ... | @@ -58,8 +58,8 @@ public interface CrmContractService { |
| 58 | 58 | /** |
| 59 | 59 | * 更新合同相关的更进信息 |
| 60 | 60 | * |
| 61 | - * @param id 合同编号 | |
| 62 | - * @param contactNextTime 下次联系时间 | |
| 61 | + * @param id 合同编号 | |
| 62 | + * @param contactNextTime 下次联系时间 | |
| 63 | 63 | * @param contactLastContent 最后联系内容 |
| 64 | 64 | */ |
| 65 | 65 | void updateContractFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); |
| ... | ... | @@ -75,7 +75,7 @@ public interface CrmContractService { |
| 75 | 75 | /** |
| 76 | 76 | * 更新合同流程审批结果 |
| 77 | 77 | * |
| 78 | - * @param id 合同编号 | |
| 78 | + * @param id 合同编号 | |
| 79 | 79 | * @param bpmResult BPM 审批结果 |
| 80 | 80 | */ |
| 81 | 81 | void updateContractAuditStatus(Long id, Integer bpmResult); |
| ... | ... | @@ -193,4 +193,13 @@ public interface CrmContractService { |
| 193 | 193 | */ |
| 194 | 194 | Long getRemindContractCount(Long userId); |
| 195 | 195 | |
| 196 | + /** | |
| 197 | + * 获得合同列表 | |
| 198 | + * | |
| 199 | + * @param customerId 客户编号 | |
| 200 | + * @param ownerUserId 负责人编号 | |
| 201 | + * @return 合同列表 | |
| 202 | + */ | |
| 203 | + List<CrmContractDO> getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); | |
| 204 | + | |
| 196 | 205 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| ... | ... | @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | 5 | import cn.hutool.core.lang.Assert; |
| 6 | 6 | import cn.hutool.core.util.ObjUtil; |
| 7 | +import cn.hutool.extra.spring.SpringUtil; | |
| 7 | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | 9 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 9 | 10 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| ... | ... | @@ -26,6 +27,7 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm |
| 26 | 27 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 27 | 28 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| 28 | 29 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 30 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerServiceImpl; | |
| 29 | 31 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 30 | 32 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 31 | 33 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| ... | ... | @@ -229,7 +231,7 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 229 | 231 | // 1.1 校验存在 |
| 230 | 232 | CrmContractDO contract = validateContractExists(id); |
| 231 | 233 | // 1.2 如果被 CrmReceivableDO 所使用,则不允许删除 |
| 232 | - if (CollUtil.isNotEmpty(receivableService.getReceivableByContractId(contract.getId()))) { | |
| 234 | + if (receivableService.getReceivableByContractId(contract.getId()) != 0) { | |
| 233 | 235 | throw exception(CONTRACT_DELETE_FAIL); |
| 234 | 236 | } |
| 235 | 237 | |
| ... | ... | @@ -252,18 +254,18 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 252 | 254 | |
| 253 | 255 | @Override |
| 254 | 256 | @Transactional(rollbackFor = Exception.class) |
| 255 | - @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", | |
| 257 | + @LogRecord(type = CRM_CONTRACT_TYPE, subType = CRM_CONTRACT_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}", | |
| 256 | 258 | success = CRM_CONTRACT_TRANSFER_SUCCESS) |
| 257 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) | |
| 259 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) | |
| 258 | 260 | public void transferContract(CrmContractTransferReqVO reqVO, Long userId) { |
| 259 | 261 | // 1. 校验合同是否存在 |
| 260 | - CrmContractDO contract = validateContractExists(reqVO.getId()); | |
| 262 | + CrmContractDO contract = validateContractExists(reqVO.getBizId()); | |
| 261 | 263 | |
| 262 | 264 | // 2.1 数据权限转移 |
| 263 | 265 | crmPermissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CONTRACT.getType(), |
| 264 | - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 266 | + reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 265 | 267 | // 2.2 设置负责人 |
| 266 | - contractMapper.updateById(new CrmContractDO().setId(reqVO.getId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | |
| 268 | + contractMapper.updateById(new CrmContractDO().setId(reqVO.getBizId()).setOwnerUserId(reqVO.getNewOwnerUserId())); | |
| 267 | 269 | |
| 268 | 270 | // 3. 记录转移日志 |
| 269 | 271 | LogRecordContext.putVariable("contract", contract); |
| ... | ... | @@ -407,4 +409,9 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 407 | 409 | return contractMapper.selectCountByRemind(userId, config); |
| 408 | 410 | } |
| 409 | 411 | |
| 412 | + @Override | |
| 413 | + public List<CrmContractDO> getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { | |
| 414 | + return contractMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); | |
| 415 | + } | |
| 416 | + | |
| 410 | 417 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -9,7 +9,13 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 10 | 10 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 11 | 11 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 12 | +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; | |
| 13 | +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO; | |
| 14 | +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.contract.CrmContractTransferReqVO; | |
| 12 | 15 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*; |
| 16 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; | |
| 17 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; | |
| 18 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | |
| 13 | 19 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 14 | 20 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 15 | 21 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; |
| ... | ... | @@ -193,26 +199,60 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 193 | 199 | |
| 194 | 200 | @Override |
| 195 | 201 | @Transactional(rollbackFor = Exception.class) |
| 196 | - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", | |
| 202 | + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.bizId}}", | |
| 197 | 203 | success = CRM_CUSTOMER_TRANSFER_SUCCESS) |
| 198 | - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) | |
| 204 | + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.bizId", level = CrmPermissionLevelEnum.OWNER) | |
| 199 | 205 | public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { |
| 200 | 206 | // 1.1 校验客户是否存在 |
| 201 | - CrmCustomerDO customer = validateCustomerExists(reqVO.getId()); | |
| 207 | + CrmCustomerDO customer = validateCustomerExists(reqVO.getBizId()); | |
| 202 | 208 | // 1.2 校验拥有客户是否到达上限 |
| 203 | 209 | validateCustomerExceedOwnerLimit(reqVO.getNewOwnerUserId(), 1); |
| 204 | - | |
| 205 | 210 | // 2.1 数据权限转移 |
| 206 | 211 | permissionService.transferPermission(new CrmPermissionTransferReqBO(userId, CrmBizTypeEnum.CRM_CUSTOMER.getType(), |
| 207 | - reqVO.getId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 212 | + reqVO.getBizId(), reqVO.getNewOwnerUserId(), reqVO.getOldOwnerPermissionLevel())); | |
| 208 | 213 | // 2.2 转移后重新设置负责人 |
| 209 | - customerMapper.updateById(new CrmCustomerDO().setId(reqVO.getId()) | |
| 214 | + customerMapper.updateById(new CrmCustomerDO().setId(reqVO.getBizId()) | |
| 210 | 215 | .setOwnerUserId(reqVO.getNewOwnerUserId()).setOwnerTime(LocalDateTime.now())); |
| 211 | 216 | |
| 217 | + // 2.3 同时转移 | |
| 218 | + if (CollUtil.isNotEmpty(reqVO.getToBizTypes())) { | |
| 219 | + transfer(reqVO, userId); | |
| 220 | + } | |
| 221 | + | |
| 212 | 222 | // 3. 记录转移日志 |
| 213 | 223 | LogRecordContext.putVariable("customer", customer); |
| 214 | 224 | } |
| 215 | 225 | |
| 226 | + /** | |
| 227 | + * 转移客户时,需要额外有【联系人】【商机】【合同】 | |
| 228 | + * | |
| 229 | + * @param reqVO 请求 | |
| 230 | + * @param userId 用户编号 | |
| 231 | + */ | |
| 232 | + private void transfer(CrmCustomerTransferReqVO reqVO, Long userId) { | |
| 233 | + if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTACT.getType())) { | |
| 234 | + List<CrmContactDO> contactList = contactService.getContactListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); | |
| 235 | + contactList.forEach(item -> { | |
| 236 | + contactService.transferContact(new CrmContactTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), | |
| 237 | + reqVO.getOldOwnerPermissionLevel()), userId); | |
| 238 | + }); | |
| 239 | + } | |
| 240 | + if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_BUSINESS.getType())) { | |
| 241 | + List<CrmBusinessDO> businessList = businessService.getBusinessListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); | |
| 242 | + businessList.forEach(item -> { | |
| 243 | + businessService.transferBusiness(new CrmBusinessTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), | |
| 244 | + reqVO.getOldOwnerPermissionLevel()), userId); | |
| 245 | + }); | |
| 246 | + } | |
| 247 | + if (reqVO.getToBizTypes().contains(CrmBizTypeEnum.CRM_CONTRACT.getType())) { | |
| 248 | + List<CrmContractDO> contractList = contractService.getContractListByCustomerIdOwnerUserId(reqVO.getBizId(), userId); | |
| 249 | + contractList.forEach(item -> { | |
| 250 | + contractService.transferContract(new CrmContractTransferReqVO(item.getId(), reqVO.getNewOwnerUserId(), | |
| 251 | + reqVO.getOldOwnerPermissionLevel()), userId); | |
| 252 | + }); | |
| 253 | + } | |
| 254 | + } | |
| 255 | + | |
| 216 | 256 | @Override |
| 217 | 257 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}", |
| 218 | 258 | success = CRM_CUSTOMER_LOCK_SUCCESS) | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java
| ... | ... | @@ -122,13 +122,12 @@ public interface CrmReceivableService { |
| 122 | 122 | */ |
| 123 | 123 | Map<Long, BigDecimal> getReceivablePriceMapByContractId(Collection<Long> contractIds); |
| 124 | 124 | |
| 125 | - // TODO @puhui999:这个搞成根据数量判断,会更好一点哈; | |
| 126 | 125 | /** |
| 127 | 126 | * 更具合同编号查询回款列表 |
| 128 | 127 | * |
| 129 | 128 | * @param contractId 合同编号 |
| 130 | 129 | * @return 回款 |
| 131 | 130 | */ |
| 132 | - List<CrmReceivableDO> getReceivableByContractId(Long contractId); | |
| 131 | + Long getReceivableByContractId(Long contractId); | |
| 133 | 132 | |
| 134 | 133 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
| ... | ... | @@ -302,8 +302,8 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | @Override |
| 305 | - public List<CrmReceivableDO> getReceivableByContractId(Long contractId) { | |
| 306 | - return receivableMapper.selectList(CrmReceivableDO::getContractId, contractId); | |
| 305 | + public Long getReceivableByContractId(Long contractId) { | |
| 306 | + return receivableMapper.selectCount(CrmReceivableDO::getContractId, contractId); | |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | } | ... | ... |