Просмотр исходного кода

refactor(sysCustomerUserCommon): 优化用户选择数据结构及查询逻辑

- BindUserBO中新增provinceIds、cityIds和groupIds以支持多值绑定
- 精简SysCustomerUserCommonService中querySelectDataByType方法参数,去除多余标志位
- 调整handleResultData方法,合并并去重用户的多组、省市ID,提升数据准确性
- 移除部分查询方法中注释的“全部”选项代码,简化代码逻辑
- SysCustomerFollowService中完善跟进审核相关流程,新增赢单审核数据处理及状态设定
- SysCustomerFollowAuditEntity添加customerFollowId字段,支持审核关联跟进数据
- 完善SysCustomerDataService中归属人变更日志内容,明确变更前后用户信息
- 优化SysCustomerDataFollowService中查询逻辑,调整部分方法参数及注释废弃代码
- 增加跟进列表中的审核状态和赢单状态字段,丰富数据展示内容
- Query和更新操作中采用LambdaQueryWrapper提高数据库查询效率及代码可读性
- 修复部分UserId判空逻辑,避免空指针异常风险
- DateSelectUtil中移除“全部”选项,统一筛选日期范围逻辑
zhangxf 1 месяц назад
Родитель
Сommit
21a7fcc83b

+ 8 - 3
src/main/java/com/jtzx/crm/module/sys/entity/SysCustomerFollowAuditEntity.java

@@ -3,12 +3,14 @@ package com.jtzx.crm.module.sys.entity;
 import cc.uncarbon.framework.crud.entity.HelioBaseEntity;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
 import lombok.experimental.SuperBuilder;
-import io.swagger.v3.oas.annotations.media.Schema;
 
-import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 
@@ -100,4 +102,7 @@ public class SysCustomerFollowAuditEntity extends HelioBaseEntity<Long> {
     @TableField("del_flag")
     private Integer delFlag;
 
+    @Schema(description = "客户跟进表主id")
+    @TableField(value = "customer_follow_id")
+    private Long customerFollowId;
 }

+ 10 - 0
src/main/java/com/jtzx/crm/module/sys/model/response/BindUserBO.java

@@ -8,6 +8,7 @@ import lombok.experimental.Accessors;
 import lombok.experimental.SuperBuilder;
 
 import java.io.Serializable;
+import java.util.List;
 
 
 /**
@@ -26,12 +27,21 @@ public class BindUserBO implements Serializable {
     @Schema(description = "省份id")
     private Long provinceId;
 
+    @Schema(description = "provinceIds")
+    private List<Long> provinceIds;
+
     @Schema(description = "城市id")
     private Long cityId;
 
+    @Schema(description = "cityIds")
+    private List<Long> cityIds;
+
     @Schema(description = "groupID")
     private Long groupId;
 
+    @Schema(description = "groupIDs")
+    private List<Long> groupIds;
+
     @Schema(description = "姓名")
     private String username;
 

+ 6 - 2
src/main/java/com/jtzx/crm/module/sys/model/response/SysCustomerFollowListBO.java

@@ -1,7 +1,5 @@
 package com.jtzx.crm.module.sys.model.response;
 
-import cc.uncarbon.framework.core.constant.HelioConstant;
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
@@ -70,6 +68,9 @@ public class SysCustomerFollowListBO implements Serializable {
     @Schema(description = "预约,待办状态,0-待开始,1-已结束,2-已取消(预约的取消需要填写取消原因)")
     private Integer orderStatus;
 
+    @Schema(description = "是否赢单,0-否,1-是")
+    private Integer successStatus;
+
     @Schema(description = "跟进时间")
     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
@@ -82,4 +83,7 @@ public class SysCustomerFollowListBO implements Serializable {
 
     @Schema(description = "类型,0-跟进的待办不可删除,1-自定义的待办可删除")
     private Integer type;
+
+    @Schema(description = "审核状态:0-待审核,1-已通过,2-已驳回")
+    private Integer auditStatus;
 }

+ 59 - 36
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowService.java

@@ -47,6 +47,7 @@ public class SysCustomerDataFollowService {
     private final SysGroupMapper sysGroupMapper;
 
     private final SysParamBaseDataMapper sysParamBaseDataMapper;
+
     private final SysCustomerFollowAuditMapper sysCustomerFollowAuditMapper;
 
     private final SysCustomerUserCommonService sysCustomerUserCommonService;
@@ -71,7 +72,7 @@ public class SysCustomerDataFollowService {
         //产品信息
         resultData.setProductData(sysCustomerUserCommonService.handleProductData());
         //省市信息
-        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType2(true, true);
+        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType2( true);
         if (sysCustomerSelectBO != null && CollUtil.isNotEmpty(sysCustomerSelectBO.getRegionData())) {
             //省市信息
             resultData.setRegionData(sysCustomerSelectBO.getRegionData());
@@ -175,7 +176,7 @@ public class SysCustomerDataFollowService {
         if (dto.getGroupId() != null) {
             groupIds.add(dto.getGroupId());
         }
-        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType2(false, true);
+        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType2( true);
         if (selectBO != null && CollUtil.isNotEmpty(selectBO.getRegionData())) {
             List<Long> cityIds = Lists.newArrayList();
             selectBO.getRegionData()
@@ -252,17 +253,17 @@ public class SysCustomerDataFollowService {
                         }
                     }
             );
-            BindUserBO memberBO = BindUserBO.builder()
-                    .username("全部")
-                    .build();
-            memberData.addFirst(memberBO);
+//            BindUserBO memberBO = BindUserBO.builder()
+//                    .username("全部")
+//                    .build();
+//            memberData.addFirst(memberBO);
         }
         resultData.setMemberData(memberData);
         if (orderStatus) {
-            OrderBO orderStatusBO = OrderBO.builder()
-                    .name("全部")
-                    .build();
-            orderStatusData.addFirst(orderStatusBO);
+//            OrderBO orderStatusBO = OrderBO.builder()
+//                    .name("全部")
+//                    .build();
+//            orderStatusData.addFirst(orderStatusBO);
             resultData.setOrderStatusData(orderStatusData);
         }
 
@@ -291,7 +292,9 @@ public class SysCustomerDataFollowService {
                                         SysCustomerFollowEntity::getFollowId,
                                         SysCustomerFollowEntity::getFollowName,
                                         SysCustomerFollowEntity::getClaimUserId,
-                                        SysCustomerFollowEntity::getClaimUserName
+                                        SysCustomerFollowEntity::getClaimUserName,
+                                        SysCustomerFollowEntity::getPositionId,
+                                        SysCustomerFollowEntity::getPositionName
                                 )
                                 .eq(customerId != null, SysCustomerFollowEntity::getCustomerId, customerId)
                                 .ne(userId != null, SysCustomerFollowEntity::getClaimUserId, userId)
@@ -321,38 +324,32 @@ public class SysCustomerDataFollowService {
                                     .build();
                             memberData.add(memberBO);
                         }
-                        if (userId != null) {
-                            if (CollUtil.isEmpty(positionData) || positionData.stream().map(SelectBO::getId).noneMatch(entity.getPositionId()::equals)) {
-                                SelectBO positionBO = SelectBO.builder()
-                                        .id(entity.getPositionId())
-                                        .name(entity.getPositionName())
-                                        .build();
-                                positionData.add(positionBO);
-                            }
+                        if (CollUtil.isEmpty(positionData) || positionData.stream().map(SelectBO::getId).noneMatch(entity.getPositionId()::equals)) {
+                            SelectBO positionBO = SelectBO.builder()
+                                    .id(entity.getPositionId())
+                                    .name(entity.getPositionName())
+                                    .build();
+                            positionData.add(positionBO);
                         }
                     }
             );
-            SelectBO bo = SelectBO.builder()
-                    .name("全部")
-                    .build();
-            productData.addFirst(bo);
-            followData.addFirst(bo);
-            positionData.addFirst(bo);
-            BindUserBO memberBO = BindUserBO.builder()
-                    .username("全部")
-                    .build();
-            memberData.addFirst(memberBO);
+//            SelectBO bo = SelectBO.builder()
+//                    .name("全部")
+//                    .build();
+//            productData.addFirst(bo);
+//            followData.addFirst(bo);
+//            positionData.addFirst(bo);
+//            BindUserBO memberBO = BindUserBO.builder()
+//                    .username("全部")
+//                    .build();
+//            memberData.addFirst(memberBO);
         }
         resultData.setProductData(productData);
         resultData.setFollowData(followData);
         resultData.setMemberData(memberData);
-        resultData.setDateData(Lists.newArrayList());
-        resultData.setPositionData(Lists.newArrayList());
         resultData.setOrderStatusData(Lists.newArrayList());
-        if (userId != null) {
-            resultData.setPositionData(positionData);
-            resultData.setDateData(DateSelectUtil.getDateData());
-        }
+        resultData.setPositionData(positionData);
+        resultData.setDateData(DateSelectUtil.getDateData());
         return resultData;
     }
 
@@ -464,12 +461,31 @@ public class SysCustomerDataFollowService {
             return Collections.emptyList();
         }
 
+        //查询审核数据
+        List<Long> customerFollowIds =
+                entityList.stream()
+                        .map(SysCustomerFollowEntity::getId)
+                        .filter(Objects::nonNull).distinct().toList();
+
+        List<SysCustomerFollowAuditEntity> auditData =
+        sysCustomerFollowAuditMapper.selectList(
+                new LambdaQueryWrapper<SysCustomerFollowAuditEntity>()
+                        .select(
+                                SysCustomerFollowAuditEntity::getCustomerFollowId,
+                                SysCustomerFollowAuditEntity::getCustomerId,
+                                SysCustomerFollowAuditEntity::getAuditStatus
+                        )
+                        .in(SysCustomerFollowAuditEntity::getCustomerFollowId, customerFollowIds)
+        );
         //查询小组数据
         List<Long> groupIds =
                 entityList.stream()
                         .map(SysCustomerFollowEntity::getClaimUserGroupId)
                         .filter(Objects::nonNull).distinct().toList();
-        List<SysGroupEntity> groupEntityList = sysGroupMapper.selectByIds(groupIds);
+        List<SysGroupEntity> groupEntityList = Lists.newArrayList();
+        if(CollUtil.isNotEmpty(groupIds)){
+            groupEntityList.addAll(sysGroupMapper.selectByIds(groupIds));
+        }
         //查询学段
         List<Long> stageIds =
                 entityList.stream()
@@ -517,6 +533,13 @@ public class SysCustomerDataFollowService {
                                 .findFirst()
                                 .ifPresent(e -> bo.setFollowName(e.getTitle()));
                     }
+
+                    if(CollUtil.isNotEmpty(auditData)){
+                        auditData.stream()
+                                .filter(x -> x.getCustomerFollowId().equals(entity.getId()))
+                                .findFirst()
+                                .ifPresent(e -> bo.setAuditStatus(e.getAuditStatus()));
+                    }
                     bo.setType(0);
                     ret.add(bo);
                 }

+ 5 - 2
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataPrivateService.java

@@ -67,7 +67,7 @@ public class SysCustomerDataPrivateService {
         //学段信息
         resultData.setStageData(sysCustomerUserCommonService.handleStageData());
         //省市信息
-        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType1(true, true);
+        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType1( true);
         if (sysCustomerSelectBO != null) {
             resultData.setRegionData(sysCustomerSelectBO.getRegionData());
             resultData.setGroupData(sysCustomerSelectBO.getGroupData());
@@ -244,6 +244,9 @@ public class SysCustomerDataPrivateService {
         permissionService.publicPrivateCustomerPermission();
         SysCustomerDetailBO detailBO = SysCustomerDetailBO.builder().build();
         dto.setUserId(UserContextHolder.getUserId());
+        if(UserContextHolder.getUserContext().getRoles().contains("Admin")){
+            dto.setUserId(null);
+        }
         //顶部筛选条件数据
         SysCustomerFollowHistorySelectBO publicCustomerSelectData = sysCustomerDataFollowService.queryCustomerFollowSelectCommonData(dto.getCustomerId(), dto.getUserId());
         detailBO.setSelectData(publicCustomerSelectData);
@@ -284,7 +287,7 @@ public class SysCustomerDataPrivateService {
         if (dto.getGroupId() != null) {
             groupIds.add(dto.getGroupId());
         }
-        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType1(false, true);
+        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType1( true);
         if (selectBO != null && CollUtil.isNotEmpty(selectBO.getRegionData())) {
             List<Long> cityIds = Lists.newArrayList();
             selectBO.getRegionData()

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

@@ -64,7 +64,7 @@ public class SysCustomerDataPublicService {
         //学段信息
         resultData.setStageData(sysCustomerUserCommonService.handleStageData());
         //省市信息
-        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType1(true, false);
+        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType1( false);
         if (sysCustomerSelectBO != null) {
             resultData.setRegionData(sysCustomerSelectBO.getRegionData());
         }

+ 5 - 2
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataService.java

@@ -282,11 +282,13 @@ public class SysCustomerDataService {
         if (sysCustomerDataEntity == null) {
             throw new BusinessException(400, "客户信息不存在");
         }
+        //查询新归属人用户信息
         SysUserEntity sysUserEntity = sysUserMapper.selectById(dto.getUserId());
         if (sysUserEntity == null) {
             throw new BusinessException(400, "用户不存在");
         }
-
+        //原来的归属人用户名
+        String oldUserName = sysCustomerDataEntity.getClaimUserName();
         SysUserGroupRelationEntity groupRelationEntity =
                 sysUserGroupRelationMapper.selectOne(
                         new LambdaQueryWrapper<>(SysUserGroupRelationEntity.class)
@@ -316,6 +318,7 @@ public class SysCustomerDataService {
         }
         sysCustomerDataMapper.updateById(sysCustomerDataEntity);
 
+        String content = "将【" + sysCustomerDataEntity.getName() + "】归属人【" + oldUserName + "】,【" +sysUserEntity.getUserName()+ "】";
         //添加认领日志
         SysCustomerOperLogEntity logEntity = SysCustomerOperLogEntity.builder()
                 .customerId(sysCustomerDataEntity.getId())
@@ -328,7 +331,7 @@ public class SysCustomerDataService {
                 .provinceName(sysCustomerDataEntity.getProvinceName())
                 .cityId(sysCustomerDataEntity.getCityId())
                 .cityName(sysCustomerDataEntity.getCityName())
-                .content(sysCustomerDataEntity.returnCustomString())
+                .content(content)
                 .operUserGroupId(sysCustomerDataEntity.getClaimUserGroupId())
                 .operDataType(0)
                 .build();

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

@@ -93,6 +93,7 @@ public class SysCustomerFollowAuditService {
         if (entity == null) {
             throw new BusinessException(400, "赢单跟进审核信息不存在");
         }
+        entity.setAuditStatus(auditStatus);
         SysCustomerDataEntity sysCustomerDataEntity = sysCustomerDataMapper.selectById(entity.getCustomerId());
         if (sysCustomerDataEntity == null) {
             throw new BusinessException(400, "客户数据不存在");

+ 93 - 57
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerFollowService.java

@@ -74,6 +74,12 @@ public class SysCustomerFollowService {
         entity.setOrderStatus(0);
         entity.setOrderDatetime(dto.getOrderDatetime());
         sysCustomerFollowMapper.insert(entity);
+        dto.setId(entity.getId());
+        if (dto.getFollowId() == 37) {
+//            //发送赢单审核
+            this.addFollowAuditData(dto);
+        }
+
         if (dto.getOrderType() != null && dto.getOrderType() == 0 && dto.getOrderDatetime() != null) {
 
 //            if (!dto.getOrderDatetime().isAfter(LocalDateTime.now())) {
@@ -231,7 +237,7 @@ public class SysCustomerFollowService {
                 sysCustomerFollowMapper.selectList(
                         new LambdaQueryWrapper<>(SysCustomerFollowEntity.class)
                                 .eq(SysCustomerFollowEntity::getCustomerId, customerId)
-                                .eq(SysCustomerFollowEntity::getClaimUserId, userId)
+                                .eq(userId!=null,SysCustomerFollowEntity::getClaimUserId, userId)
                 );
         if (CollUtil.isNotEmpty(followEntityList)) {
             List<Long> productIdList = followEntityList.stream()
@@ -290,7 +296,7 @@ public class SysCustomerFollowService {
                 sysCustomerFollowMapper.selectList(
                         new LambdaQueryWrapper<>(SysCustomerFollowEntity.class)
                                 .eq(SysCustomerFollowEntity::getCustomerId, customerId)
-                                .eq(SysCustomerFollowEntity::getClaimUserId, userId)
+                                .eq(userId!=null,SysCustomerFollowEntity::getClaimUserId, userId)
                                 .eq(SysCustomerFollowEntity::getOrderStatus, 0)//待开始的
                                 .isNotNull(SysCustomerFollowEntity::getOrderType)//预约待办不能为空的
                                 .orderByDesc(SysCustomerFollowEntity::getCreatedAt)
@@ -315,35 +321,84 @@ public class SysCustomerFollowService {
     @Transactional(rollbackFor = Exception.class)
     public void handleParams(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
         //处理联系人
-        SysCustomerPersonEntity sysCustomerPersonEntity = sysCustomerPersonMapper.selectById(dto.getCustomerPersonId());
+        SysCustomerPersonEntity sysCustomerPersonEntity = sysCustomerPersonMapper.selectOne(
+                new LambdaQueryWrapper<SysCustomerPersonEntity>()
+                        .select(
+                                SysCustomerPersonEntity::getName
+                        )
+                        .eq(SysCustomerPersonEntity::getId, dto.getCustomerPersonId())
+                        .last("limit 1")
+        );
         if (sysCustomerPersonEntity == null) {
             throw new RuntimeException("参数错误,联系人不存在");
         }
         dto.setCustomerPersonName(sysCustomerPersonEntity.getName());
         //处理产品
-        SysParamBaseDataEntity productDataEntity = sysParamBaseDataMapper.selectById(dto.getProductId());
+        SysParamBaseDataEntity productDataEntity = sysParamBaseDataMapper.selectOne(
+                new LambdaQueryWrapper<SysParamBaseDataEntity>()
+                        .select(
+                                SysParamBaseDataEntity::getTitle
+                        )
+                        .eq(SysParamBaseDataEntity::getId, dto.getProductId())
+                        .last("limit 1")
+        );
         if (productDataEntity == null) {
             throw new RuntimeException("参数错误,产品不存在");
         }
         dto.setProductName(productDataEntity.getTitle());
         //处理跟进状态
-        SysParamBaseDataEntity followDataEntity = sysParamBaseDataMapper.selectById(dto.getFollowId());
+        SysParamBaseDataEntity followDataEntity = sysParamBaseDataMapper.selectOne(
+                new LambdaQueryWrapper<SysParamBaseDataEntity>()
+                        .select(
+                                SysParamBaseDataEntity::getTitle
+                        )
+                        .eq(SysParamBaseDataEntity::getId, dto.getFollowId())
+                        .last("limit 1")
+        );
         if (followDataEntity == null) {
             throw new RuntimeException("参数错误,跟进状态不存在");
         }
         dto.setFollowName(followDataEntity.getTitle());
         //处理职务
-        SysParamBaseDataEntity positionDataEntity = sysParamBaseDataMapper.selectById(dto.getPositionId());
+        SysParamBaseDataEntity positionDataEntity = sysParamBaseDataMapper.selectOne(
+                new LambdaQueryWrapper<SysParamBaseDataEntity>()
+                        .select(
+                                SysParamBaseDataEntity::getTitle
+                        )
+                        .eq(SysParamBaseDataEntity::getId, dto.getPositionId())
+                        .last("limit 1")
+        );
         if (positionDataEntity == null) {
             throw new RuntimeException("参数错误,职务不存在");
         }
         dto.setPositionName(positionDataEntity.getTitle());
         //处理客户
-        SysCustomerDataEntity sysCustomerDataEntity = sysCustomerDataMapper.selectById(dto.getCustomerId());
+        SysCustomerDataEntity sysCustomerDataEntity = sysCustomerDataMapper.selectOne(
+                new LambdaQueryWrapper<SysCustomerDataEntity>()
+                        .select(
+                                SysCustomerDataEntity::getClaimUserId,
+                                SysCustomerDataEntity::getClaimUserName,
+                                SysCustomerDataEntity::getClaimUserGroupId,
+                                SysCustomerDataEntity::getName,
+                                SysCustomerDataEntity::getStageId,
+                                SysCustomerDataEntity::getStageName,
+                                SysCustomerDataEntity::getProvinceId,
+                                SysCustomerDataEntity::getProvinceName,
+                                SysCustomerDataEntity::getCityId,
+                                SysCustomerDataEntity::getCityName
+                        )
+                        .eq(SysCustomerDataEntity::getId, dto.getCustomerId())
+                        .last("limit 1")
+        );
         if (sysCustomerDataEntity == null) {
             throw new RuntimeException("参数错误,客户不存在");
         }
+//        dto.setClaimUserId(sysCustomerDataEntity.getClaimUserId());
+//        dto.setClaimUserName(sysCustomerDataEntity.getClaimUserName());
+        dto.setClaimUserId(UserContextHolder.getUserId());
+        dto.setClaimUserName(UserContextHolder.getUserName());
         dto.setClaimUserGroupId(sysCustomerDataEntity.getClaimUserGroupId());
+        dto.setClaimDatetime(LocalDateTime.now());
         //省市数据
         dto.setCustomerName(sysCustomerDataEntity.getName());
         dto.setStageId(sysCustomerDataEntity.getStageId());
@@ -352,19 +407,14 @@ public class SysCustomerFollowService {
         dto.setProvinceName(sysCustomerDataEntity.getProvinceName());
         dto.setCityId(sysCustomerDataEntity.getCityId());
         dto.setCityName(sysCustomerDataEntity.getCityName());
-        dto.setFollowId(UserContextHolder.getUserId()); // 处理认领人(跟进)id
-        dto.setFollowName(UserContextHolder.getUserName()); // 处理认领人(跟进)name
+        dto.setFollowId(dto.getFollowId());
+        dto.setFollowName(dto.getFollowName());
+        dto.setSuccessStatus(0);
         //处理赢单
         if (dto.getFollowId() == 37) {
             dto.setSuccessStatus(1);
-            // 处理客户表的赢单字段
-//            sysCustomerDataEntity.setSuccessStatus(1); //这个状态不在这里使用,赢单需要审核,只有审核通过后才能改这个状态,这里只把赢单人先设置
-//            sysCustomerDataEntity.setSuccessUserId(UserContextHolder.getUserId());
-//            sysCustomerDataEntity.setSuccessUserName(UserContextHolder.getUserName());
-//            sysCustomerDataMapper.updateById(sysCustomerDataEntity);
-            //发送赢单审核
-            this.addFollowAuditData(sysCustomerDataEntity, followDataEntity,
-                    sysCustomerPersonEntity, productDataEntity, positionDataEntity, dto.getFollowContent());
+//            //发送赢单审核
+//            this.addFollowAuditData(dto);
         }
 
     }
@@ -372,15 +422,9 @@ public class SysCustomerFollowService {
     /**
      * 添加赢单跟进审核数据
      *
-     * @param sysCustomerDataEntity
      */
     @Transactional(rollbackFor = Exception.class)
-    public void addFollowAuditData(SysCustomerDataEntity sysCustomerDataEntity,
-                                   SysParamBaseDataEntity followDataEntity,
-                                   SysCustomerPersonEntity sysCustomerPersonEntity,
-                                   SysParamBaseDataEntity productDataEntity,
-                                   SysParamBaseDataEntity positionDataEntity,
-                                   String followContent) {
+    public void addFollowAuditData(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
         //先查询管理员数据
         List<SysUserRoleRelationEntity> adminUserList =
                 sysUserRoleRelationMapper.selectList(
@@ -391,21 +435,24 @@ public class SysCustomerFollowService {
         if (CollUtil.isEmpty(adminUserList)) {
             throw new RuntimeException("参数错误,管理员不存在");
         }
-
         List<Long> userIds =
                 adminUserList.stream()
                         .map(SysUserRoleRelationEntity::getUserId)
                         .distinct().toList();
-        List<SysUserEntity> sysUserEntities = sysUserMapper.selectByIds(userIds);
+        List<SysUserEntity> sysUserEntities = sysUserMapper.selectList(
+                new LambdaQueryWrapper<SysUserEntity>()
+                        .select(SysUserEntity::getId, SysUserEntity::getUserName)
+                        .in(SysUserEntity::getId, userIds)
+        );
         if (CollUtil.isEmpty(sysUserEntities)) {
             throw new RuntimeException("参数错误,管理员不存在");
         }
         adminUserList.forEach(adminUser -> {
-            SysCustomerFollowAuditEntity entity =
-                    this.getFollowAuditEntity(sysCustomerDataEntity, followDataEntity, sysCustomerPersonEntity,
-                            productDataEntity, positionDataEntity, followContent);
+            SysCustomerFollowAuditEntity entity =this.getFollowAuditEntity(dto);
             entity.setAuditUserId(adminUser.getUserId()); // 设置审核人id
-            sysUserEntities.stream().findFirst().ifPresent(sysUserEntity -> entity.setAuditUserName(sysUserEntity.getUserName()));
+            sysUserEntities.stream()
+                    .filter(x -> x.getId().equals(adminUser.getUserId()))
+                    .findFirst().ifPresent(sysUserEntity -> entity.setAuditUserName(sysUserEntity.getUserName()));
             sysCustomerFollowAuditMapper.insert(entity);
         });
     }
@@ -413,38 +460,27 @@ public class SysCustomerFollowService {
     /**
      * 获取跟进审核数据
      *
-     * @param sysCustomerDataEntity
-     * @param sysCustomerPersonEntity
-     * @param productDataEntity
-     * @param positionDataEntity
-     * @param followContent
      * @return
      */
-    public SysCustomerFollowAuditEntity getFollowAuditEntity(SysCustomerDataEntity sysCustomerDataEntity,
-                                                             SysParamBaseDataEntity followDataEntity,
-                                                             SysCustomerPersonEntity sysCustomerPersonEntity,
-                                                             SysParamBaseDataEntity productDataEntity,
-                                                             SysParamBaseDataEntity positionDataEntity,
-                                                             String followContent) {
+    public SysCustomerFollowAuditEntity getFollowAuditEntity(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
         SysCustomerFollowAuditEntity entity = SysCustomerFollowAuditEntity.builder().build();
-        entity.setClaimUserId(sysCustomerDataEntity.getClaimUserId());
-        entity.setClaimUserName(sysCustomerDataEntity.getClaimUserName());
-        entity.setClaimUserGroupId(sysCustomerDataEntity.getClaimUserGroupId());
+        entity.setClaimUserId(dto.getClaimUserId());
+        entity.setClaimUserName(dto.getClaimUserName());
+        entity.setClaimUserGroupId(dto.getClaimUserGroupId());
         entity.setClaimDatetime(LocalDateTime.now());
-        entity.setCustomerId(sysCustomerDataEntity.getId());
-        entity.setCustomerName(sysCustomerDataEntity.getName());
-        entity.setFollowId(followDataEntity.getId());
-        entity.setFollowName(followDataEntity.getTitle());
-        entity.setCustomerPersonId(sysCustomerPersonEntity.getId());
-        entity.setCustomerPersonName(sysCustomerPersonEntity.getName());
-        entity.setPositionId(positionDataEntity.getId());
-        entity.setPositionName(positionDataEntity.getTitle());
-        entity.setFollowContent(followContent);
-        entity.setProductId(productDataEntity.getId());
-        entity.setProductName(productDataEntity.getTitle());
+        entity.setCustomerId(dto.getCustomerId());
+        entity.setCustomerName(dto.getCustomerName());
+        entity.setFollowId(dto.getFollowId());
+        entity.setFollowName(dto.getFollowName());
+        entity.setCustomerPersonId(dto.getCustomerPersonId());
+        entity.setCustomerPersonName(dto.getCustomerPersonName());
+        entity.setPositionId(dto.getPositionId());
+        entity.setPositionName(dto.getPositionName());
+        entity.setFollowContent(dto.getFollowContent());
+        entity.setProductId(dto.getProductId());
+        entity.setProductName(dto.getProductName());
         entity.setAuditStatus(0);
-//        entity.setAuditUserId(0L);
-//        entity.setAuditUserName("");
+        entity.setCustomerFollowId(dto.getId());
         return entity;
     }
 

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

@@ -54,7 +54,7 @@ public class SysCustomerPersonService {
                         // 客户表主id
                         .eq(SysCustomerPersonEntity::getCustomerId, dto.getCustomerId())
                         //创建人过滤
-                        .eq(dto.getUserId()!=null,SysCustomerPersonEntity::getCreatedBy,dto.getUserId())
+//                        .eq(dto.getUserId()!=null,SysCustomerPersonEntity::getCreatedBy,dto.getUserId())
                         // 职务id(param_base_data表主id)
                         .eq(dto.getPositionId() != null, SysCustomerPersonEntity::getPositionId, dto.getPositionId())
                         .and(StrUtil.isNotEmpty(dto.getQueryStr()),z->z.like(SysCustomerPersonEntity::getName,dto.getQueryStr())

+ 80 - 87
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerUserCommonService.java

@@ -51,7 +51,7 @@ public class SysCustomerUserCommonService {
      */
     public List<Long> queryUserCityIds(Long provinceId) {
         List<Long> cityIds = Lists.newArrayList();
-        SysCustomerSelectBO selectBO = this.querySelectDataByType1(false, false);
+        SysCustomerSelectBO selectBO = this.querySelectDataByType1(false);
         if (CollUtil.isNotEmpty(selectBO.getRegionData())) {
             selectBO.getRegionData().stream()
                     .filter(x -> provinceId != null && provinceId.equals(x.getId()))
@@ -70,7 +70,7 @@ public class SysCustomerUserCommonService {
      */
     public List<Long> queryUserCityIds1(Long provinceId) {
         List<Long> cityIds = Lists.newArrayList();
-        SysCustomerSelectBO selectBO = this.querySelectDataByType2(false, false);
+        SysCustomerSelectBO selectBO = this.querySelectDataByType2(false);
         if (CollUtil.isNotEmpty(selectBO.getRegionData())) {
             selectBO.getRegionData().stream()
                     .filter(x -> provinceId != null && provinceId.equals(x.getId()))
@@ -204,7 +204,7 @@ public class SysCustomerUserCommonService {
      *
      * @return
      */
-    public SysCustomerSelectBO querySelectDataByType1(Boolean allStatus, Boolean userStatus) {
+    public SysCustomerSelectBO querySelectDataByType1(Boolean userStatus) {
         //获取用户角色
         List<String> roles = UserContextHolder.getUserContext().getRoles();
         if (CollUtil.isEmpty(roles)) {
@@ -215,11 +215,11 @@ public class SysCustomerUserCommonService {
         List<Long> groupIds = Lists.newArrayList();
         //管理员
         if (roles.contains("Admin")) {
-            return this.handleAdminRole(provinceIds, cityIds, groupIds, allStatus, userStatus);
+            return this.handleAdminRole(provinceIds, cityIds, groupIds, userStatus);
         }
         //普通成员或小组组长
         if (roles.contains("Member") || roles.contains("GroupManager")) {
-            return this.handleMemberRole(provinceIds, cityIds, groupIds, allStatus, userStatus);
+            return this.handleMemberRole(provinceIds, cityIds, groupIds, userStatus);
         }
         return SysCustomerSelectBO.builder().build();
     }
@@ -231,7 +231,7 @@ public class SysCustomerUserCommonService {
      *
      * @return
      */
-    public SysCustomerSelectBO querySelectDataByType2(Boolean allStatus, Boolean userStatus) {
+    public SysCustomerSelectBO querySelectDataByType2(Boolean userStatus) {
         //获取用户角色
         List<String> roles = UserContextHolder.getUserContext().getRoles();
         if (CollUtil.isEmpty(roles)) {
@@ -242,15 +242,15 @@ public class SysCustomerUserCommonService {
         List<Long> groupIds = Lists.newArrayList();
         //管理员
         if (roles.contains("Admin")) {
-            return this.handleAdminRole(provinceIds, cityIds, groupIds, allStatus, userStatus);
+            return this.handleAdminRole(provinceIds, cityIds, groupIds, userStatus);
         }
         //小组组长
         if (roles.contains("GroupManager")) {
-            return this.handeGroupManagerRole(provinceIds, cityIds, allStatus, userStatus);
+            return this.handeGroupManagerRole(provinceIds, cityIds, userStatus);
         }
         //普通成员
         if (roles.contains("Member")) {
-            return this.handleMemberRole(provinceIds, cityIds, groupIds, allStatus, userStatus);
+            return this.handleMemberRole(provinceIds, cityIds, groupIds, userStatus);
         }
         return SysCustomerSelectBO.builder().build();
     }
@@ -266,11 +266,11 @@ public class SysCustomerUserCommonService {
         //查询所有学段信息
         List<SysParamBaseDataEntity> stageDataList = this.queryParamBaseData(0);
         if (CollUtil.isNotEmpty(stageDataList)) {
-            SelectBO all = SelectBO.builder().build();
-            all.setName("全部");
-            all.setSortCode(0);
-            all.setSelectStatus(true);
-            stageData.add(all);
+//            SelectBO all = SelectBO.builder().build();
+//            all.setName("全部");
+//            all.setSortCode(0);
+//            all.setSelectStatus(true);
+//            stageData.add(all);
             stageDataList.forEach(e -> {
                 SelectBO bo = SelectBO.builder().build();
                 bo.setId(e.getId());
@@ -293,11 +293,11 @@ public class SysCustomerUserCommonService {
         //查询所有学段信息
         List<SysParamBaseDataEntity> stageDataList = this.queryParamBaseData(1);
         if (CollUtil.isNotEmpty(stageDataList)) {
-            SelectBO all = SelectBO.builder().build();
-            all.setName("全部");
-            all.setSortCode(0);
-            all.setSelectStatus(true);
-            stageData.add(all);
+//            SelectBO all = SelectBO.builder().build();
+//            all.setName("全部");
+//            all.setSortCode(0);
+//            all.setSelectStatus(true);
+//            stageData.add(all);
             stageDataList.forEach(e -> {
                 SelectBO bo = SelectBO.builder().build();
                 bo.setId(e.getId());
@@ -319,11 +319,11 @@ public class SysCustomerUserCommonService {
     public List<SelectBO> handleTypeData() {
         List<SelectBO> typeData = Lists.newArrayList();
         //查询所有类型信息
-        SelectBO all = SelectBO.builder().build();
-        all.setName("全部");
-        all.setSortCode(0);
-        all.setSelectStatus(true);
-        typeData.add(all);
+//        SelectBO all = SelectBO.builder().build();
+//        all.setName("全部");
+//        all.setSortCode(0);
+//        all.setSelectStatus(true);
+//        typeData.add(all);
 
         SelectBO firstBO = SelectBO.builder().build();
         firstBO.setId(1L);
@@ -356,7 +356,6 @@ public class SysCustomerUserCommonService {
     public SysCustomerSelectBO handleAdminRole(List<Long> provinceIds,
                                                List<Long> cityIds,
                                                List<Long> groupIds,
-                                               Boolean allStatus,
                                                Boolean userStatus) {
 
         List<DictProvinceRegionEntity> provinceRegionEntityList =
@@ -370,7 +369,7 @@ public class SysCustomerUserCommonService {
                 );
         if (CollUtil.isNotEmpty(provinceRegionEntityList)) {
             this.handleAdmin(provinceRegionEntityList, provinceIds, cityIds, groupIds);
-            return this.handleResultData(provinceIds, cityIds, groupIds, allStatus, userStatus);
+            return this.handleResultData(provinceIds, cityIds, groupIds, userStatus);
         }
         return SysCustomerSelectBO.builder().build();
     }
@@ -384,7 +383,6 @@ public class SysCustomerUserCommonService {
      */
     public SysCustomerSelectBO handeGroupManagerRole(List<Long> provinceIds,
                                                      List<Long> cityIds,
-                                                     Boolean allStatus,
                                                      Boolean userStatus) {
         List<SysUserRoleRelationEntity> groupManagerRelationEntityList =
                 sysUserRoleRelationMapper.selectList(
@@ -402,7 +400,7 @@ public class SysCustomerUserCommonService {
                             .map(SysUserRoleRelationEntity::getGroupId)
                             .distinct().toList();
             //开通的省市都有相同的小组,所有这里查询开通的省市查询使用管理员的查询
-            return this.handleAdminRole(provinceIds, cityIds, groupIds, allStatus, userStatus);
+            return this.handleAdminRole(provinceIds, cityIds, groupIds, userStatus);
         }
         return SysCustomerSelectBO.builder().build();
     }
@@ -418,7 +416,6 @@ public class SysCustomerUserCommonService {
     public SysCustomerSelectBO handleMemberRole(List<Long> provinceIds,
                                                 List<Long> cityIds,
                                                 List<Long> groupIds,
-                                                Boolean allStatus,
                                                 Boolean userStatus) {
         List<SysUserGroupRelationEntity> userGroupRelationEntityList =
                 sysUserGroupRelationMapper.selectList(
@@ -433,7 +430,7 @@ public class SysCustomerUserCommonService {
                 );
         if (CollUtil.isNotEmpty(userGroupRelationEntityList)) {
             this.handleMemberData(userGroupRelationEntityList, provinceIds, cityIds, groupIds);
-            return this.handleResultData(provinceIds, cityIds, groupIds, allStatus, userStatus);
+            return this.handleResultData(provinceIds, cityIds, groupIds, userStatus);
         }
         return SysCustomerSelectBO.builder().build();
     }
@@ -448,12 +445,11 @@ public class SysCustomerUserCommonService {
      */
     public SysCustomerSelectBO handleResultData(List<Long> provinceIds,
                                                 List<Long> cityIds,
-                                                List<Long> groupIds,
-                                                Boolean allStatus, Boolean userStatus) {
+                                                List<Long> groupIds, Boolean userStatus) {
 
         SysCustomerSelectBO selectBO = SysCustomerSelectBO.builder().build();
         //小组
-        selectBO.setGroupData(this.handeGroupData(groupIds, allStatus));
+        selectBO.setGroupData(this.handeGroupData(groupIds));
 
         List<SysUserEntity> userEntityList =
                 sysUserMapper.selectList(
@@ -461,7 +457,7 @@ public class SysCustomerUserCommonService {
                                 .eq(SysUserEntity::getStatus, 1)
                 );
         //省市
-        List<SelectBO> regionData = this.handleRegionData(provinceIds, cityIds, allStatus);
+        List<SelectBO> regionData = this.handleRegionData(provinceIds, cityIds);
         //省市
         selectBO.setRegionData(regionData);
         //成员
@@ -483,7 +479,7 @@ public class SysCustomerUserCommonService {
                 );
         if (userStatus) {
             regionData.forEach(province -> {
-                if(CollUtil.isNotEmpty(province.getSubData())){
+                if (CollUtil.isNotEmpty(province.getSubData())) {
                     province.getSubData().forEach(city -> {
                                 if (CollUtil.isNotEmpty(groupIds) && CollUtil.isNotEmpty(groupRelationEntityList)) {
 
@@ -493,41 +489,24 @@ public class SysCustomerUserCommonService {
                                             .filter(x -> CollUtil.isNotEmpty(groupIds) && groupIds.contains(x.getGroupId()))
                                             .sorted(Comparator.comparing(SysUserGroupRelationEntity::getCreatedAt))
                                             .collect(Collectors.groupingBy(SysUserGroupRelationEntity::getGroupId, LinkedHashMap::new, Collectors.toList()))
-                                            .forEach((key, value) -> {
-                                                if (allStatus) {
-                                                    if(CollUtil.isEmpty(userData) || userData.stream().map(BindUserBO::getUsername).noneMatch("全部"::equals)){
-                                                        BindUserBO userBO = BindUserBO.builder().build();
-                                                        userBO.setProvinceId(province.getId());
-                                                        userBO.setCityId(city.getId());
-                                                        userBO.setGroupId(key);
-                                                        userBO.setUsername("全部");
-                                                        userBO.setSortCode(0);
-                                                        userBO.setSelectStatus(true);
-                                                        userData.add(userBO);
-                                                    }
-                                                }
-                                                AtomicInteger sortCode = new AtomicInteger(0);
-                                                value.forEach(user -> {
-                                                    if (CollUtil.isNotEmpty(userEntityList)) {
-                                                        userEntityList.stream()
-                                                                .filter(x -> x.getId().equals(user.getUserId()))
-                                                                .findFirst()
-                                                                .ifPresent(e -> {
-                                                                    if(CollUtil.isEmpty(userData)||userData.stream().map(BindUserBO::getId).noneMatch(user.getUserId()::equals)){
+                                            .forEach((key, value) ->
+                                                    value.forEach(user -> {
+                                                        if (CollUtil.isNotEmpty(userEntityList)) {
+                                                            userEntityList.stream()
+                                                                    .filter(x -> x.getId().equals(user.getUserId()))
+                                                                    .findFirst()
+                                                                    .ifPresent(e -> {
                                                                         BindUserBO userBO = BindUserBO.builder().build();
+                                                                        userBO.setGroupId(user.getGroupId());
                                                                         userBO.setId(user.getUserId());
                                                                         userBO.setProvinceId(user.getProvinceId());
                                                                         userBO.setCityId(user.getCityId());
-                                                                        userBO.setGroupId(user.getGroupId());
                                                                         userBO.setUsername(e.getUserName());
                                                                         userBO.setSelectStatus(false);
-                                                                        userBO.setSortCode(sortCode.incrementAndGet());
                                                                         userData.add(userBO);
-                                                                    }
-                                                                });
-                                                    }
-                                                });
-                                            });
+                                                                    });
+                                                        }
+                                                    }));
                                 }
                             }
                     );
@@ -535,7 +514,23 @@ public class SysCustomerUserCommonService {
 
             });
         }
-        selectBO.setMemberData(userData);
+        List<BindUserBO> userData1 = Lists.newArrayList();
+
+        if (CollUtil.isNotEmpty(userData)) {
+            userData.stream()
+                    .collect(Collectors.groupingBy(BindUserBO::getId))
+                    .forEach((key, value) -> {
+                        BindUserBO userBO = value.getFirst();
+                        userBO.setGroupId(null);
+                        userBO.setGroupIds(value.stream().map(BindUserBO::getGroupId).filter(Objects::nonNull).distinct().toList());
+                        userBO.setProvinceId(null);
+                        userBO.setProvinceIds(value.stream().map(BindUserBO::getProvinceId).filter(Objects::nonNull).distinct().toList());
+                        userBO.setCityId(null);
+                        userBO.setCityIds(value.stream().map(BindUserBO::getCityId).filter(Objects::nonNull).distinct().toList());
+                        userData1.add(userBO);
+                    });
+        }
+        selectBO.setMemberData(userData1);
         return selectBO;
     }
 
@@ -631,19 +626,18 @@ public class SysCustomerUserCommonService {
      * @param groupIds
      * @return
      */
-    public List<SelectBO> handeGroupData(List<Long> groupIds,
-                                         Boolean allStatus) {
+    public List<SelectBO> handeGroupData(List<Long> groupIds) {
         List<SelectBO> groupData = Lists.newArrayList();
         //小组
         if (CollUtil.isNotEmpty(groupIds)) {
-            if (allStatus) {
-                SelectBO selectBO = SelectBO.builder()
-                        .name("全部")
-                        .sortCode(0)
-                        .selectStatus(true)
-                        .build();
-                groupData.add(selectBO);
-            }
+//            if (allStatus) {
+//                SelectBO selectBO = SelectBO.builder()
+//                        .name("全部")
+//                        .sortCode(0)
+//                        .selectStatus(true)
+//                        .build();
+//                groupData.add(selectBO);
+//            }
             List<SysGroupEntity> groupEntityList = sysGroupMapper.selectByIds(groupIds);
             if (CollUtil.isNotEmpty(groupEntityList)) {
                 groupEntityList.stream()
@@ -670,17 +664,16 @@ public class SysCustomerUserCommonService {
      * @return
      */
     public List<SelectBO> handleRegionData(List<Long> provinceIds,
-                                           List<Long> cityIds,
-                                           Boolean allStatus) {
+                                           List<Long> cityIds) {
         List<SelectBO> regionData = Lists.newArrayList();
-        SelectBO selectBO = SelectBO.builder()
-                .name("全部")
-                .sortCode(0)
-                .selectStatus(true)
-                .build();
-        if (allStatus) {
-            regionData.add(selectBO);
-        }
+//        SelectBO selectBO = SelectBO.builder()
+//                .name("全部")
+//                .sortCode(0)
+//                .selectStatus(true)
+//                .build();
+//        if (allStatus) {
+//            regionData.add(selectBO);
+//        }
         //省份
         List<DictProvinceRegionEntity> regionEntityList = dictProvinceRegionMapper.selectByIds(provinceIds);
         //城市
@@ -696,9 +689,9 @@ public class SysCustomerUserCommonService {
                     provinceBO.setSortCode(province.getSortCode());
                     provinceBO.setSelectStatus(false);
                     List<SelectBO> subData = Lists.newArrayList();
-                    if (allStatus) {
-                        subData.add(selectBO);
-                    }
+//                    if (allStatus) {
+//                        subData.add(selectBO);
+//                    }
                     AtomicInteger sortCode = new AtomicInteger(0);
                     dictCityRegionEntities.stream()
                             .filter(x -> x.getParentCode().equals(province.getCode()))

+ 1 - 1
src/main/java/com/jtzx/crm/module/sys/util/DateSelectUtil.java

@@ -15,7 +15,7 @@ public class DateSelectUtil {
 
     public static List<DateSelectBO> getDateData() {
         List<DateSelectBO> dateData = Lists.newArrayList();
-        dateData.add(getBO("全部",0,null));
+//        dateData.add(getBO("全部",0,null));
         dateData.add(getBO("今天",0, DateField.DAY_OF_YEAR));
         dateData.add(getBO("昨天",1, DateField.DAY_OF_YEAR));
         dateData.add(getBO("近3天",3, DateField.DAY_OF_YEAR));