Răsfoiți Sursa

feat(sys): 优化客户数据权限控制及操作日志查询

- 新增SysCustomerDataPermissionService用于统一管理客户权限,只允许管理员和普通成员访问
- 修改多处客户数据相关服务,加权限校验,替换原来的权限判断逻辑
- 优化操作日志查询,支持根据操作人及所属组筛选,且统一管理用户和组权限范围
- 客户跟进、私域、公海等数据查询及操作接口增加权限校验
- 新增客户跟进、用户组及参数数据排序接口,添加参数校验和异常处理
- 新增查询日志记录接口,支持客户公海、私域、跟进等模块
- 优化赢单审核逻辑,增强参数校验及错误提示
- 调整部分接口及方法注释,统一接口风格和返回结构
zhangxf 1 lună în urmă
părinte
comite
8bf5b0e0ff
16 a modificat fișierele cu 299 adăugiri și 139 ștergeri
  1. 16 3
      src/main/java/com/jtzx/crm/module/api/web/sys/AdminParamController.java
  2. 11 0
      src/main/java/com/jtzx/crm/module/api/web/sys/AdminUserGroupController.java
  3. 69 0
      src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataFollowController.java
  4. 7 5
      src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataPrivateController.java
  5. 8 4
      src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataPublicController.java
  6. 3 0
      src/main/java/com/jtzx/crm/module/sys/model/request/AdminSysCustomerOperLogListDTO.java
  7. 4 0
      src/main/java/com/jtzx/crm/module/sys/model/request/AdminSysParamBaseDataInsertOrUpdateDTO.java
  8. 32 7
      src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowService.java
  9. 32 0
      src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataPermissionService.java
  10. 43 45
      src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataPrivateService.java
  11. 44 33
      src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataPublicService.java
  12. 7 10
      src/main/java/com/jtzx/crm/module/sys/service/SysCustomerFollowAuditService.java
  13. 2 1
      src/main/java/com/jtzx/crm/module/sys/service/SysCustomerFollowService.java
  14. 5 30
      src/main/java/com/jtzx/crm/module/sys/service/SysCustomerOperLogService.java
  15. 15 0
      src/main/java/com/jtzx/crm/module/sys/service/SysParamBaseDataService.java
  16. 1 1
      src/main/java/com/jtzx/crm/module/sys/service/SysUserGroupRelationService.java

+ 16 - 3
src/main/java/com/jtzx/crm/module/api/web/sys/AdminParamController.java

@@ -1,8 +1,10 @@
 package com.jtzx.crm.module.api.web.sys;
 
 
+import cc.uncarbon.framework.core.exception.BusinessException;
 import cc.uncarbon.framework.web.model.response.ApiResult;
 import cn.dev33.satoken.annotation.SaCheckLogin;
+import cn.hutool.core.collection.CollUtil;
 import com.jtzx.crm.module.api.constant.ApiConstant;
 import com.jtzx.crm.module.api.util.CrmAdminStpUtil;
 import com.jtzx.crm.module.sys.model.request.AdminSysParamBaseDataInsertOrUpdateDTO;
@@ -39,15 +41,15 @@ public class AdminParamController {
         return ApiResult.data(sysParamBO);
     }
 
-    @Operation(summary = "修改参数配置",description = "公海设置的三个框")
+    @Operation(summary = "修改参数配置", description = "公海设置的三个框")
     @PostMapping(value = "/updateParams")
-    public ApiResult<Void> updateParams(@RequestBody AdminSysParamInsertOrUpdateDTO dto){
+    public ApiResult<Void> updateParams(@RequestBody AdminSysParamInsertOrUpdateDTO dto) {
         sysParamService.adminUpdate(dto);
         return ApiResult.success();
     }
 
 
-    @Operation(summary = "学段,产品,职务,跟进状态列表",description = "type类型:0-学段,1-产品,2-职务,3-跟进")
+    @Operation(summary = "学段,产品,职务,跟进状态列表", description = "type类型:0-学段,1-产品,2-职务,3-跟进")
     @GetMapping("/listParams/{type}")
     public ApiResult<List<SysParamBaseDataBO>> queryStage(@PathVariable Integer type) {
         return ApiResult.data(sysParamBaseDataService.queryList(type));
@@ -69,6 +71,17 @@ public class AdminParamController {
     }
 
 
+    @Operation(summary = "学段,产品,职务,跟进状态排序")
+    @PostMapping(value = "/paramSort")
+    public ApiResult<Void> paramSort(@RequestBody @Valid List<AdminSysParamBaseDataInsertOrUpdateDTO> dtoList) {
+        if (CollUtil.isEmpty(dtoList)) {
+            throw new BusinessException(400, "参数不能为空");
+        }
+        dtoList.forEach(sysParamBaseDataService::update);
+        return ApiResult.success();
+    }
+
+
     @Operation(summary = "删除学段,产品,职务,跟进状态")
     @GetMapping("/deleteParams/{id}")
     public ApiResult<Void> deleteParams(@PathVariable Long id) {

+ 11 - 0
src/main/java/com/jtzx/crm/module/api/web/sys/AdminUserGroupController.java

@@ -1,9 +1,11 @@
 package com.jtzx.crm.module.api.web.sys;
 
 
+import cc.uncarbon.framework.core.exception.BusinessException;
 import cc.uncarbon.framework.core.page.PageResult;
 import cc.uncarbon.framework.web.model.response.ApiResult;
 import cn.dev33.satoken.annotation.SaCheckLogin;
+import cn.hutool.core.collection.CollUtil;
 import com.jtzx.crm.module.api.constant.ApiConstant;
 import com.jtzx.crm.module.api.util.CrmAdminStpUtil;
 import com.jtzx.crm.module.sys.model.request.AdminSysGroupInsertOrUpdateDTO;
@@ -105,4 +107,13 @@ public class AdminUserGroupController {
         return ApiResult.success();
     }
 
+    @Operation(summary = "分组排序数据接口")
+    @PostMapping(value = "/group/manager/groupSort")
+    public ApiResult<Void> groupSort(@RequestBody List<AdminSysGroupInsertOrUpdateDTO> dtoList) {
+        if(CollUtil.isEmpty(dtoList)){
+            throw new BusinessException(400, "参数不能为空");
+        }
+        dtoList.forEach(sysGroupService::adminUpdate);
+        return ApiResult.success();
+    }
 }

+ 69 - 0
src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataFollowController.java

@@ -0,0 +1,69 @@
+package com.jtzx.crm.module.api.web.sys;
+
+import cc.uncarbon.framework.core.page.PageResult;
+import cc.uncarbon.framework.web.model.response.ApiResult;
+import cn.dev33.satoken.annotation.SaCheckLogin;
+import com.jtzx.crm.module.api.constant.ApiConstant;
+import com.jtzx.crm.module.api.util.CrmAdminStpUtil;
+import com.jtzx.crm.module.sys.model.request.AdminSysCustomerDataFollowListDTO;
+import com.jtzx.crm.module.sys.model.request.AdminSysCustomerOperLogListDTO;
+import com.jtzx.crm.module.sys.model.response.SysCustomerFollowAuditDataBO;
+import com.jtzx.crm.module.sys.model.response.SysCustomerFollowListBO;
+import com.jtzx.crm.module.sys.model.response.SysCustomerFollowSelectBO;
+import com.jtzx.crm.module.sys.model.response.SysCustomerOperLogDataBO;
+import com.jtzx.crm.module.sys.service.SysCustomerDataFollowService;
+import com.jtzx.crm.module.sys.service.SysCustomerFollowAuditService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+@SaCheckLogin(type = CrmAdminStpUtil.TYPE)
+@Tag(name = "客户跟进接口")
+@RequestMapping(value = ApiConstant.HTTP_API_URL_PREFIX + "/api/v1/follow")
+@RequiredArgsConstructor
+@RestController
+@Slf4j
+public class CustomerDataFollowController {
+
+    private final SysCustomerDataFollowService sysCustomerDataFollowService;
+
+    private final SysCustomerFollowAuditService sysCustomerFollowAuditService;
+
+    @Operation(summary = "查询顶部筛选条件信息接口")
+    @GetMapping(value = "/headSelect/data")
+    public ApiResult<SysCustomerFollowSelectBO> queryHeadSelectData() {
+        return ApiResult.data(sysCustomerDataFollowService.queryHeadSelectPrivateData());
+    }
+
+
+    @Operation(summary = "分页查询客户跟进信息列表数据接口")
+    @PostMapping(value = "/customer/listPage")
+    public ApiResult<PageResult<SysCustomerFollowListBO>> list(@RequestBody @Valid AdminSysCustomerDataFollowListDTO dto) {
+        PageResult<SysCustomerFollowListBO> pageResult = sysCustomerDataFollowService.adminList(dto);
+        return ApiResult.data(pageResult);
+    }
+
+    @Operation(summary = "赢单申请列表信息接口")
+    @GetMapping(value = "/auditFollow/data/{auditStatus}")
+    public ApiResult<SysCustomerFollowAuditDataBO> queryAuditListData(@PathVariable Integer auditStatus) {
+        return ApiResult.data(sysCustomerFollowAuditService.adminList(auditStatus));
+    }
+
+    @Operation(summary = "赢单审核操作信息接口")
+    @PostMapping(value = "/auditFollow/oper/{id}/{auditStatus}")
+    public ApiResult<SysCustomerFollowAuditDataBO> queryHeadSelectData(@PathVariable Long id,
+                                                                       @PathVariable Integer auditStatus) {
+        sysCustomerFollowAuditService.auditFollow(id, auditStatus);
+        return ApiResult.success();
+    }
+
+    @Operation(summary = "查询日志记录信息接口")
+    @PostMapping(value = "/customer/oper/log/", produces = "application/json;charset=UTF-8")
+    public ApiResult<SysCustomerOperLogDataBO> queryOperLogData(@RequestBody AdminSysCustomerOperLogListDTO dto) {
+        SysCustomerOperLogDataBO result = sysCustomerDataFollowService.queryOperLogData(dto);
+        return ApiResult.data(result);
+    }
+}

+ 7 - 5
src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataPrivateController.java

@@ -1,7 +1,6 @@
 package com.jtzx.crm.module.api.web.sys;
 
 import cc.uncarbon.framework.core.context.UserContextHolder;
-import cc.uncarbon.framework.core.exception.BusinessException;
 import cc.uncarbon.framework.core.page.PageResult;
 import cc.uncarbon.framework.web.model.response.ApiResult;
 import cn.dev33.satoken.annotation.SaCheckLogin;
@@ -38,10 +37,6 @@ public class CustomerDataPrivateController {
     @Operation(summary = "添加跟进信息接口")
     @PostMapping(value = "/customer/data/follow/add")
     public ApiResult<Void> addFollow(@RequestBody AdminSysCustomerFollowInsertOrUpdateDTO dto) {
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            throw new BusinessException(400, "无权操作");
-        }
         sysCustomerFollowService.adminInsert(dto);
         return ApiResult.success();
     }
@@ -135,4 +130,11 @@ public class CustomerDataPrivateController {
         return ApiResult.data(sysCustomerDataFollowService.queryCustomerFollowHistoryDataByPage(dto));
     }
 
+    @Operation(summary = "查询日志记录信息接口")
+    @PostMapping(value = "/customer/oper/log/", produces = "application/json;charset=UTF-8")
+    public ApiResult<SysCustomerOperLogDataBO> queryOperLogData(@RequestBody AdminSysCustomerOperLogListDTO dto) {
+        SysCustomerOperLogDataBO result = sysCustomerDataPrivateService.queryOperLogData(dto);
+        return ApiResult.data(result);
+    }
+
 }

+ 8 - 4
src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataPublicController.java

@@ -7,10 +7,7 @@ import cn.dev33.satoken.annotation.SaCheckLogin;
 import com.jtzx.crm.module.api.constant.ApiConstant;
 import com.jtzx.crm.module.api.util.CrmAdminStpUtil;
 import com.jtzx.crm.module.sys.model.request.*;
-import com.jtzx.crm.module.sys.model.response.SysCustomerDataPublicBO;
-import com.jtzx.crm.module.sys.model.response.SysCustomerDetailBO;
-import com.jtzx.crm.module.sys.model.response.SysCustomerPersonBO;
-import com.jtzx.crm.module.sys.model.response.SysCustomerPublicSelectBO;
+import com.jtzx.crm.module.sys.model.response.*;
 import com.jtzx.crm.module.sys.service.SysCustomerDataPublicService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -110,4 +107,11 @@ public class CustomerDataPublicController {
         SysCustomerDetailBO detailBO = sysCustomerDataPublicService.queryCustomerDetail(dto);
         return ApiResult.data(detailBO);
     }
+
+    @Operation(summary = "查询日志记录信息接口")
+    @PostMapping(value = "/customer/oper/log/", produces = "application/json;charset=UTF-8")
+    public ApiResult<SysCustomerOperLogDataBO> queryOperLogData(@RequestBody AdminSysCustomerOperLogListDTO dto) {
+        SysCustomerOperLogDataBO result = sysCustomerDataPublicService.queryOperLogData(dto);
+        return ApiResult.data(result);
+    }
 }

+ 3 - 0
src/main/java/com/jtzx/crm/module/sys/model/request/AdminSysCustomerOperLogListDTO.java

@@ -30,6 +30,9 @@ public class AdminSysCustomerOperLogListDTO implements Serializable {
     @Schema(description = "操作人id")
     private Long operUserId;
 
+    @Schema(description = "操作人所属组id")
+    private Long groupId;
+
     @Schema(description = "开始时间")
     @DateTimeFormat(pattern = HelioConstant.Jackson.DATE_TIME_FORMAT)
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = HelioConstant.Jackson.DATE_TIME_FORMAT)

+ 4 - 0
src/main/java/com/jtzx/crm/module/sys/model/request/AdminSysParamBaseDataInsertOrUpdateDTO.java

@@ -10,6 +10,7 @@ import lombok.experimental.Accessors;
 import lombok.experimental.SuperBuilder;
 
 import java.io.Serializable;
+import java.util.List;
 
 
 /**
@@ -36,4 +37,7 @@ public class AdminSysParamBaseDataInsertOrUpdateDTO implements Serializable {
     @Schema(description = "类型:0-学段,1-产品,2-职务,3-跟进")
     private Integer type;
 
+    @Schema(description = "默认的跟进状态不变的ID列表,只有type是跟进状态类型时才有这个数据")
+    private List<Long> defaultIdList;
+
 }

+ 32 - 7
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowService.java

@@ -2,7 +2,6 @@ package com.jtzx.crm.module.sys.service;
 
 
 import cc.uncarbon.framework.core.context.UserContextHolder;
-import cc.uncarbon.framework.core.exception.BusinessException;
 import cc.uncarbon.framework.core.page.PageResult;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
@@ -65,10 +64,11 @@ public class SysCustomerDataFollowService {
         //学段信息
         resultData.setStageData(sysCustomerUserCommonService.handleStageData());
         //产品信息
-        resultData.setStageData(sysCustomerUserCommonService.handleProductData());
+        resultData.setProductData(sysCustomerUserCommonService.handleProductData());
         //省市信息
         SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType2(true, true);
         if (sysCustomerSelectBO != null && CollUtil.isNotEmpty(sysCustomerSelectBO.getRegionData())) {
+            //省市信息
             resultData.setRegionData(sysCustomerSelectBO.getRegionData());
             //小组
             resultData.setGroupData(sysCustomerSelectBO.getGroupData());
@@ -83,7 +83,6 @@ public class SysCustomerDataFollowService {
      * 后台管理-客户(学校)跟进分页列表
      */
     public PageResult<SysCustomerFollowListBO> adminList(AdminSysCustomerDataFollowListDTO dto) {
-
         List<Long> userIds = Lists.newArrayList();
         if (dto.getUserId() != null) {
             userIds.add(dto.getUserId());
@@ -147,10 +146,36 @@ public class SysCustomerDataFollowService {
      * 操作日志列表查询
      */
     public SysCustomerOperLogDataBO queryOperLogData(AdminSysCustomerOperLogListDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
+        List<Long> userIds = Lists.newArrayList();
+        if (dto.getOperUserId() != null) {
+            userIds.add(dto.getOperUserId());
+        }
+        List<Long> groupIds = Lists.newArrayList();
+        if (dto.getGroupId() != null) {
+            groupIds.add(dto.getGroupId());
+        }
+        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType2(false, true);
+        if (selectBO != null && CollUtil.isNotEmpty(selectBO.getRegionData())) {
+            List<Long> cityIds = Lists.newArrayList();
+            selectBO.getRegionData()
+                    .forEach(provinceRegion ->
+                            provinceRegion.getSubData()
+                                    .forEach(city -> cityIds.add(city.getId())));
+            List<BindUserBO> bindUserBOS = sysCustomerUserCommonService.queryBindUserListByCityId(cityIds);
+            if (CollUtil.isNotEmpty(bindUserBOS)) {
+                if (CollUtil.isEmpty(userIds)) {
+                    userIds.addAll(
+                            bindUserBOS.stream()
+                                    .map(BindUserBO::getId).toList());
+                }
+                if (CollUtil.isEmpty(groupIds)) {
+                    groupIds.addAll(
+                            bindUserBOS.stream()
+                                    .map(BindUserBO::getGroupId).distinct().toList());
+                }
+            }
         }
-        return sysCustomerOperLogService.adminList(dto, true, true);
+        return sysCustomerOperLogService.adminList(dto, userIds,groupIds,true, true);
     }
 
 
@@ -242,7 +267,7 @@ public class SysCustomerDataFollowService {
 
 
     /**
-     * 查询客户跟进历史数据
+     * 查询我的客户跟进历史数据
      *
      * @param dto
      */

+ 32 - 0
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataPermissionService.java

@@ -0,0 +1,32 @@
+package com.jtzx.crm.module.sys.service;
+
+import cc.uncarbon.framework.core.context.UserContextHolder;
+import cc.uncarbon.framework.core.exception.BusinessException;
+import cn.hutool.core.collection.CollUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 客户数据权限业务
+ */
+@RequiredArgsConstructor
+@Service
+@Slf4j
+public class SysCustomerDataPermissionService {
+
+
+    /**
+     * 客户权限,只允许管理员和普通成员查看,没有小组长权限,如果小组长同时是管理员或普通成员,则可以查看
+     */
+    public void publicPrivateCustomerPermission() {
+        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles())) {
+            throw new BusinessException(400, "无权操作");
+        }
+        if (!UserContextHolder.getUserContext().getRoles().contains("Admin") ||
+                !UserContextHolder.getUserContext().getRoles().contains("Member")) {
+            throw new BusinessException(400, "无权操作");
+        }
+    }
+
+}

+ 43 - 45
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataPrivateService.java

@@ -52,13 +52,15 @@ public class SysCustomerDataPrivateService {
 
     private final SysCustomerOperLogService sysCustomerOperLogService;
 
+    private final SysCustomerDataPermissionService permissionService;
+
     /**
      * 查询私域(我的)客户页面顶部筛选条件数据
      *
      * @return
      */
     public SysCustomerPrivateSelectBO queryHeadSelectPrivateData() {
-
+        permissionService.publicPrivateCustomerPermission();
         SysCustomerPrivateSelectBO resultData = SysCustomerPrivateSelectBO.builder().build();
         //类型
         resultData.setTypeData(sysCustomerUserCommonService.handleTypeData());
@@ -79,16 +81,7 @@ public class SysCustomerDataPrivateService {
      * 后台管理-我的客户(学校)分页列表
      */
     public PageResult<SysCustomerDataPrivateBO> adminList(AdminSysCustomerDataPrivateListDTO dto) {
-
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            return new PageResult<SysCustomerDataPrivateBO>()
-                    .setCurrent(1)
-                    .setSize(dto.getPageSize())
-                    .setTotal(0)
-                    .setRecords(Lists.newArrayList());
-        }
-
+        permissionService.publicPrivateCustomerPermission();
         List<Long> userIds = Lists.newArrayList();
         if (dto.getUserId() != null) {
             userIds.add(dto.getUserId());
@@ -158,10 +151,7 @@ public class SysCustomerDataPrivateService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminUpdateCustomerData(AdminSysCustomerDataInsertOrUpdateDTO dto) {
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerDataService.adminUpdate(dto);
     }
 
@@ -189,10 +179,7 @@ public class SysCustomerDataPrivateService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminInsertCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerPersonService.adminInsert(dto);
     }
 
@@ -204,10 +191,7 @@ public class SysCustomerDataPrivateService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminUpdateCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerPersonService.adminUpdate(dto);
     }
 
@@ -218,10 +202,7 @@ public class SysCustomerDataPrivateService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminDeleteCustomerPerson(Long id) {
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerPersonService.adminDelete(id);
     }
 
@@ -230,10 +211,8 @@ public class SysCustomerDataPrivateService {
      * 查询我的客户联系人
      */
     public List<SysCustomerPersonBO> adminListCustomerPerson(CustomerPersonReqDTO dto) {
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            return Lists.newArrayList();
-        }
+        permissionService.publicPrivateCustomerPermission();
+
         return sysCustomerPersonService.adminList(dto);
     }
 
@@ -246,10 +225,7 @@ public class SysCustomerDataPrivateService {
      */
     public List<TransferUserReqBO> queryTransferUser(Long customerId) {
 
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         return sysCustomerDataService.queryTransferUser(customerId);
     }
 
@@ -259,10 +235,7 @@ public class SysCustomerDataPrivateService {
      * @param dto
      */
     public void transferUser(TransferUserReqDTO dto) {
-        List<String> roles = UserContextHolder.getUserContext().getRoles();
-        if (!roles.contains("Admin") && !roles.contains("Member")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerDataService.transferUser(dto);
     }
 
@@ -273,9 +246,7 @@ public class SysCustomerDataPrivateService {
      * @param dto
      */
     public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         SysCustomerDetailBO detailBO = SysCustomerDetailBO.builder().build();
         dto.setUserId(UserContextHolder.getUserId());
         //顶部筛选条件数据
@@ -309,10 +280,37 @@ public class SysCustomerDataPrivateService {
      * 操作日志列表查询
      */
     public SysCustomerOperLogDataBO queryOperLogData(AdminSysCustomerOperLogListDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
+        permissionService.publicPrivateCustomerPermission();
+        List<Long> userIds = Lists.newArrayList();
+        if (dto.getOperUserId() != null) {
+            userIds.add(dto.getOperUserId());
+        }
+        List<Long> groupIds = Lists.newArrayList();
+        if (dto.getGroupId() != null) {
+            groupIds.add(dto.getGroupId());
+        }
+        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType1(false, true);
+        if (selectBO != null && CollUtil.isNotEmpty(selectBO.getRegionData())) {
+            List<Long> cityIds = Lists.newArrayList();
+            selectBO.getRegionData()
+                    .forEach(provinceRegion ->
+                            provinceRegion.getSubData()
+                                    .forEach(city -> cityIds.add(city.getId())));
+            List<BindUserBO> bindUserBOS = sysCustomerUserCommonService.queryBindUserListByCityId(cityIds);
+            if (CollUtil.isNotEmpty(bindUserBOS)) {
+                if (CollUtil.isEmpty(userIds)) {
+                    userIds.addAll(
+                            bindUserBOS.stream()
+                                    .map(BindUserBO::getId).toList());
+                }
+                if (CollUtil.isEmpty(groupIds)) {
+                    groupIds.addAll(
+                            bindUserBOS.stream()
+                                    .map(BindUserBO::getGroupId).distinct().toList());
+                }
+            }
         }
-        return sysCustomerOperLogService.adminList(dto, true, false);
+        return sysCustomerOperLogService.adminList(dto, userIds, groupIds, true, false);
     }
 
 

+ 44 - 33
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataPublicService.java

@@ -1,22 +1,17 @@
 package com.jtzx.crm.module.sys.service;
 
 
-import cc.uncarbon.framework.core.context.UserContextHolder;
-import cc.uncarbon.framework.core.exception.BusinessException;
-import cc.uncarbon.framework.core.page.PageParam;
 import cc.uncarbon.framework.core.page.PageResult;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.text.CharSequenceUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
 import com.jtzx.crm.module.sys.entity.SysCustomerDataEntity;
-import com.jtzx.crm.module.sys.entity.SysCustomerFollowEntity;
 import com.jtzx.crm.module.sys.entity.SysParamBaseDataEntity;
 import com.jtzx.crm.module.sys.mapper.SysCustomerDataMapper;
-import com.jtzx.crm.module.sys.mapper.SysCustomerFollowMapper;
 import com.jtzx.crm.module.sys.mapper.SysParamBaseDataMapper;
 import com.jtzx.crm.module.sys.model.request.*;
 import com.jtzx.crm.module.sys.model.response.*;
@@ -55,12 +50,15 @@ public class SysCustomerDataPublicService {
 
     private final SysCustomerOperLogService sysCustomerOperLogService;
 
+    private final SysCustomerDataPermissionService permissionService;
+
     /**
      * 查询公海客户页面顶部筛选条件数据
      *
      * @return
      */
     public SysCustomerPublicSelectBO queryHeadSelectData() {
+        permissionService.publicPrivateCustomerPermission();
         //返回数据对象
         SysCustomerPublicSelectBO resultData = SysCustomerPublicSelectBO.builder().build();
         //学段信息
@@ -78,6 +76,7 @@ public class SysCustomerDataPublicService {
      * 后台管理-公海客户(学校)分页列表
      */
     public PageResult<SysCustomerDataPublicBO> adminList(AdminSysCustomerDataPublicListDTO dto) {
+        permissionService.publicPrivateCustomerPermission();
         Page<SysCustomerDataEntity> entityPage = sysCustomerDataMapper.selectPage(
                 new Page<>(dto.getPageNum(), dto.getPageSize()),
                 new QueryWrapper<SysCustomerDataEntity>()
@@ -108,9 +107,7 @@ public class SysCustomerDataPublicService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminInsertCustomerData(AdminSysCustomerDataInsertOrUpdateDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerDataService.adminInsert(dto);
     }
 
@@ -121,9 +118,7 @@ public class SysCustomerDataPublicService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminUpdateCustomerData(AdminSysCustomerDataInsertOrUpdateDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerDataService.adminUpdate(dto);
     }
 
@@ -134,9 +129,7 @@ public class SysCustomerDataPublicService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminDeleteCustomerData(Long id) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerDataService.adminDelete(id);
     }
 
@@ -147,6 +140,7 @@ public class SysCustomerDataPublicService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void claimCustomer(Long customerId) {
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerDataService.claimCustomer(customerId);
     }
 
@@ -159,9 +153,7 @@ public class SysCustomerDataPublicService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminInsertCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerPersonService.adminInsert(dto);
     }
 
@@ -173,9 +165,7 @@ public class SysCustomerDataPublicService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminUpdateCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerPersonService.adminUpdate(dto);
     }
 
@@ -186,9 +176,7 @@ public class SysCustomerDataPublicService {
      */
     @Transactional(rollbackFor = Exception.class)
     public void adminDeleteCustomerPerson(Long id) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         sysCustomerPersonService.adminDelete(id);
     }
 
@@ -196,9 +184,7 @@ public class SysCustomerDataPublicService {
      * 查询公海客户联系人
      */
     public List<SysCustomerPersonBO> adminListCustomerPerson(CustomerPersonReqDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         return sysCustomerPersonService.adminList(dto);
     }
 
@@ -209,9 +195,7 @@ public class SysCustomerDataPublicService {
      * @param dto
      */
     public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
-        }
+        permissionService.publicPrivateCustomerPermission();
         SysCustomerDetailBO detailBO = SysCustomerDetailBO.builder().build();
         //顶部筛选条件数据
         SysCustomerFollowHistorySelectBO publicCustomerSelectData = sysCustomerDataFollowService.queryCustomerFollowSelectCommonData(dto.getCustomerId(), null);
@@ -230,10 +214,37 @@ public class SysCustomerDataPublicService {
      * 操作日志列表查询
      */
     public SysCustomerOperLogDataBO queryOperLogData(AdminSysCustomerOperLogListDTO dto) {
-        if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
-            throw new BusinessException(400, "无权操作");
+        permissionService.publicPrivateCustomerPermission();
+        List<Long> userIds = Lists.newArrayList();
+        if (dto.getOperUserId() != null) {
+            userIds.add(dto.getOperUserId());
+        }
+        List<Long> groupIds = Lists.newArrayList();
+        if (dto.getGroupId() != null) {
+            groupIds.add(dto.getGroupId());
+        }
+        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType1(false,true);
+        if(selectBO!=null && CollUtil.isNotEmpty(selectBO.getRegionData())){
+            List<Long> cityIds = Lists.newArrayList();
+            selectBO.getRegionData()
+                    .forEach(provinceRegion ->
+                            provinceRegion.getSubData()
+                                    .forEach(city -> cityIds.add(city.getId())));
+            List<BindUserBO> bindUserBOS = sysCustomerUserCommonService.queryBindUserListByCityId(cityIds);
+            if (CollUtil.isNotEmpty(bindUserBOS)) {
+                if (CollUtil.isEmpty(userIds)) {
+                    userIds.addAll(
+                            bindUserBOS.stream()
+                                    .map(BindUserBO::getId).toList());
+                }
+                if (CollUtil.isEmpty(groupIds)) {
+                    groupIds.addAll(
+                            bindUserBOS.stream()
+                                    .map(BindUserBO::getGroupId).distinct().toList());
+                }
+            }
         }
-        return sysCustomerOperLogService.adminList(dto, false, false);
+        return sysCustomerOperLogService.adminList(dto,userIds, groupIds,false, false);
     }
 
 

+ 7 - 10
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerFollowAuditService.java

@@ -40,7 +40,7 @@ public class SysCustomerFollowAuditService {
         if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
             throw new BusinessException(403, "无权操作");
         }
-        if(!Arrays.asList(0,1,2).contains(auditStatus)){
+        if (!Arrays.asList(0, 1, 2).contains(auditStatus)) {
             throw new BusinessException(400, "审核参数错误");
         }
         SysCustomerFollowAuditDataBO resultData = SysCustomerFollowAuditDataBO.builder().build();
@@ -77,27 +77,26 @@ public class SysCustomerFollowAuditService {
     }
 
     /**
-     * 赢单审核通过
+     * 审核操作
      * auditStatus 1-通过,2-不通过
+     *
      * @param id
      */
-    public void auditSuccess(Long id, Integer auditStatus) {
-        if(!Arrays.asList(1,2).contains(auditStatus)){
-            throw new BusinessException(400, "审核参数错误");
-        }
+    public void auditFollow(Long id, Integer auditStatus) {
         if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
             throw new BusinessException(403, "无权操作");
         }
+        if (!Arrays.asList(1, 2).contains(auditStatus)) {
+            throw new BusinessException(400, "审核参数错误");
+        }
         SysCustomerFollowAuditEntity entity = sysCustomerFollowAuditMapper.selectById(id);
         if (entity == null) {
             throw new BusinessException(400, "赢单跟进审核信息不存在");
         }
-
         SysCustomerDataEntity sysCustomerDataEntity = sysCustomerDataMapper.selectById(entity.getCustomerId());
         if (sysCustomerDataEntity == null) {
             throw new BusinessException(400, "客户数据不存在");
         }
-
         sysCustomerFollowAuditMapper.updateById(entity);
         List<SysCustomerFollowAuditEntity> sysCustomerFollowAuditEntities =
                 sysCustomerFollowAuditMapper.selectList(
@@ -107,7 +106,6 @@ public class SysCustomerFollowAuditService {
                                 )
                                 .eq(SysCustomerFollowAuditEntity::getCustomerId, entity.getCustomerId())
                 );
-
         if (CollUtil.isNotEmpty(sysCustomerFollowAuditEntities)) {
             sysCustomerFollowAuditEntities.forEach(e -> {
                 e.setAuditStatus(auditStatus);
@@ -116,7 +114,6 @@ public class SysCustomerFollowAuditService {
                 sysCustomerFollowAuditMapper.updateById(e);
             });
         }
-
         // 审核通过,设置客户数据表的赢单信息,以及赢单审核信息
         if (auditStatus == 1) {
             sysCustomerDataEntity.setSuccessStatus(1);

+ 2 - 1
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerFollowService.java

@@ -1,7 +1,6 @@
 package com.jtzx.crm.module.sys.service;
 
 import cc.uncarbon.framework.core.context.UserContextHolder;
-import cc.uncarbon.framework.crud.entity.HelioBaseEntity;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
@@ -49,6 +48,7 @@ public class SysCustomerFollowService {
 
     private final SysUserMapper sysUserMapper;
 
+    private final SysCustomerDataPermissionService permissionService;
 
     /**
      * 后台管理-新增
@@ -56,6 +56,7 @@ public class SysCustomerFollowService {
     @Transactional(rollbackFor = Exception.class)
     public void adminInsert(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
         log.info("[后台管理-客户跟进数据信息-新增] >> DTO={}", dto);
+        permissionService.publicPrivateCustomerPermission();
         dto.setId(null);
         // 参数校验
         this.checkParam(dto);

+ 5 - 30
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerOperLogService.java

@@ -1,7 +1,6 @@
 package com.jtzx.crm.module.sys.service;
 
 import cc.uncarbon.framework.core.exception.BusinessException;
-import cc.uncarbon.framework.core.page.PageParam;
 import cc.uncarbon.framework.core.page.PageResult;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
@@ -40,10 +39,12 @@ public class SysCustomerOperLogService {
 
     private final SysGroupMapper sysGroupMapper;
 
+
     /**
      * 操作日志列表查询
      */
-    public SysCustomerOperLogDataBO adminList(AdminSysCustomerOperLogListDTO dto, Boolean dateSelectStatus, Boolean groupSelectStatus) {
+    public SysCustomerOperLogDataBO adminList(AdminSysCustomerOperLogListDTO dto,List<Long> userIds,List<Long> groupIds, Boolean dateSelectStatus, Boolean groupSelectStatus) {
+
         Page<SysCustomerOperLogEntity> entityPage = sysCustomerOperLogMapper.selectPage(
                 new Page<>(dto.getPageNum(), dto.getPageSize()),
                 new QueryWrapper<SysCustomerOperLogEntity>()
@@ -51,7 +52,8 @@ public class SysCustomerOperLogService {
                         // 客户表主id
                         .eq(Objects.nonNull(dto.getCustomerId()), SysCustomerOperLogEntity::getCustomerId, dto.getCustomerId())
                         // 操作人id
-                        .eq(Objects.nonNull(dto.getOperUserId()), SysCustomerOperLogEntity::getOperUserId, dto.getOperUserId())
+                        .in(CollUtil.isNotEmpty(userIds), SysCustomerOperLogEntity::getOperUserId, userIds)
+                        .in(CollUtil.isNotEmpty(groupIds), SysCustomerOperLogEntity::getOperUserGroupId, groupIds)
                         .ge(dto.getStartDate() != null, SysCustomerOperLogEntity::getCreatedAt, dto.getStartDate())
                         .le(dto.getEndDate() != null, SysCustomerOperLogEntity::getCreatedAt, dto.getEndDate())
                         // 排序
@@ -164,8 +166,6 @@ public class SysCustomerOperLogService {
     @Transactional(rollbackFor = Exception.class)
     public Long adminInsert(AdminSysCustomerOperLogInsertOrUpdateDTO dto) {
         log.info("[后台管理-客户操作日志信息数据-新增] >> DTO={}", dto);
-        this.checkExistence(dto);
-
         dto.setId(null);
         SysCustomerOperLogEntity entity = new SysCustomerOperLogEntity();
         BeanUtil.copyProperties(dto, entity);
@@ -181,8 +181,6 @@ public class SysCustomerOperLogService {
     @Transactional(rollbackFor = Exception.class)
     public void adminUpdate(AdminSysCustomerOperLogInsertOrUpdateDTO dto) {
         log.info("[后台管理-客户操作日志信息数据-编辑] >> DTO={}", dto);
-        this.checkExistence(dto);
-
         SysCustomerOperLogEntity entity = new SysCustomerOperLogEntity();
         BeanUtil.copyProperties(dto, entity);
 
@@ -258,27 +256,4 @@ public class SysCustomerOperLogService {
                 .setRecords(this.entityList2BOs(entityPage.getRecords()));
     }
 
-    /**
-     * 检查是否已存在同名数据
-     *
-     * @param dto DTO
-     */
-    private void checkExistence(AdminSysCustomerOperLogInsertOrUpdateDTO dto) {
-        /*
-        可以根据自己业务需要,解禁这段代码,修改判断条件和文案
-
-        SysCustomerOperLogEntity existingEntity = sysCustomerOperLogMapper.selectOne(
-                new QueryWrapper<SysCustomerOperLogEntity>()
-                        .lambda()
-                        .select(SysCustomerOperLogEntity::getId)
-                        .eq(SysCustomerOperLogEntity::getTitle, dto.getTitle())
-                        .last(HelioConstant.CRUD.SQL_LIMIT_1)
-        );
-
-        if (existingEntity != null && !existingEntity.getId().equals(dto.getId())) {
-            throw new BusinessException(400, "已存在相同客户操作日志信息数据,请重新输入");
-        }
-        */
-    }
-
 }

+ 15 - 0
src/main/java/com/jtzx/crm/module/sys/service/SysParamBaseDataService.java

@@ -30,6 +30,7 @@ public class SysParamBaseDataService {
 
     /**
      * 查询学段
+     *
      * @return
      */
     public List<SysParamBaseDataBO> queryStage() {
@@ -39,6 +40,7 @@ public class SysParamBaseDataService {
 
     /**
      * 查询产品
+     *
      * @return
      */
     public List<SysParamBaseDataBO> queryProduct() {
@@ -48,6 +50,7 @@ public class SysParamBaseDataService {
 
     /**
      * 查询职务
+     *
      * @return
      */
     public List<SysParamBaseDataBO> queryPosition() {
@@ -56,6 +59,7 @@ public class SysParamBaseDataService {
 
     /**
      * 查询跟进状态
+     *
      * @return
      */
     public List<SysParamBaseDataBO> queryFollowStatus() {
@@ -65,6 +69,7 @@ public class SysParamBaseDataService {
 
     /**
      * 类型:0-学段,1-产品,2-职务,3-跟进
+     *
      * @param type
      * @return
      */
@@ -107,6 +112,16 @@ public class SysParamBaseDataService {
         BeanUtil.copyProperties(dto, entity);
         entity.setStatus(0);
         sysParamBaseDataMapper.insert(entity);
+        if (dto.getType() == 3 && CollUtil.isNotEmpty(dto.getDefaultIdList())) {
+            //把后面默认的3个编号都加一
+            List<SysParamBaseDataEntity> sysParamBaseDataEntities = sysParamBaseDataMapper.selectByIds(dto.getDefaultIdList());
+            sysParamBaseDataEntities.forEach(sysParamBaseDataEntity -> {
+                sysParamBaseDataEntity.setSortCode(sysParamBaseDataEntity.getSortCode() + 1);
+                sysParamBaseDataMapper.updateById(sysParamBaseDataEntity);
+            });
+        }
+
+
         return entity.getId();
     }
 

+ 1 - 1
src/main/java/com/jtzx/crm/module/sys/service/SysUserGroupRelationService.java

@@ -58,7 +58,7 @@ public class SysUserGroupRelationService {
         List<SysUserEntity> sysUserEntities =
                 sysUserMapper.selectList(
                         new LambdaQueryWrapper<>(SysUserEntity.class)
-                                .eq(StrUtil.isNotEmpty(username), SysUserEntity::getUserName, username)
+                                .like(StrUtil.isNotEmpty(username), SysUserEntity::getUserName, username)
                                 .eq(SysUserEntity::getStatus, 1)
                                 .orderByAsc(HelioBaseEntity::getCreatedAt)
                 );