Ver Fonte

feat(customer): 优化客户跟进及预约相关功能

- AdminSysCustomerOperLogListDTO新增查询字符串queryStr字段
- AdminSysCustomerTodoInsertOrUpdateDTO新增id字段,修改待办时间格式为日期时间格式
- 取消预约接口方法添加BusinessException异常声明
- SysCustomerDataFollowOrderService查询逻辑调整,修正日期字符串判断及使用,添加更多查询字段和排序条件
- 优化SysCustomerDataFollowService查询客户数据及跟进数据,补充客户地址、上次跟进时间及客户类型名称
- SysCustomerFollowListBO新增上次跟进时间、客户类型名称、预约取消原因和地址字段
- SysCustomerFollowService取消预约方法添加异常抛出声明
- SysCustomerOperLogService查询逻辑增加对queryStr的模糊匹配,修正查询条件判断
- SysCustomerTodoService新增待办初始化订单状态,编辑待办时增加异常处理和数据存在校验
- 各模块优化列表查询条件判断,避免空值异常,并统一空集合处理逻辑
- 修正若干过滤条件逻辑错误,确保数据筛选准确
- 引入工具类StrUtil进行字符串非空判断,提高代码健壮性
zhangxf há 1 mês atrás
pai
commit
01b57a29fc

+ 2 - 1
src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataOrderController.java

@@ -1,6 +1,7 @@
 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 com.jtzx.crm.module.api.constant.ApiConstant;
@@ -47,7 +48,7 @@ public class CustomerDataOrderController {
 
     @Operation(summary = "取消预约接口")
     @PostMapping(value = "/order/cancelOrder")
-    public ApiResult<Void> cancelOrder(@RequestBody @Valid CannelOrderDTO dto) {
+    public ApiResult<Void> cancelOrder(@RequestBody @Valid CannelOrderDTO dto) throws BusinessException {
         sysCustomerFollowService.cancelOrder(dto, false);
         return ApiResult.success();
     }

+ 2 - 1
src/main/java/com/jtzx/crm/module/api/web/sys/CustomerDataPrivateController.java

@@ -1,6 +1,7 @@
 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;
@@ -139,7 +140,7 @@ public class CustomerDataPrivateController {
 
     @Operation(summary = "去消预约跟进接口")
     @PostMapping(value = "/customer/data/cancelOrder", produces = "application/json;charset=UTF-8")
-    public ApiResult<Void> cancelOrder(@RequestBody CannelOrderDTO dto) {
+    public ApiResult<Void> cancelOrder(@RequestBody CannelOrderDTO dto) throws BusinessException {
         sysCustomerFollowService.cancelOrder(dto, true);
         return ApiResult.success();
     }

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

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

+ 5 - 6
src/main/java/com/jtzx/crm/module/sys/model/request/AdminSysCustomerTodoInsertOrUpdateDTO.java

@@ -3,18 +3,15 @@ package com.jtzx.crm.module.sys.model.request;
 import cc.uncarbon.framework.core.constant.HelioConstant;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.Size;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
 import lombok.experimental.SuperBuilder;
-import jakarta.validation.constraints.NotBlank;
-import jakarta.validation.constraints.NotNull;
-import jakarta.validation.constraints.Size;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
-import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 
@@ -28,13 +25,15 @@ import java.time.LocalDateTime;
 @Data
 public class AdminSysCustomerTodoInsertOrUpdateDTO implements Serializable {
 
+    private Long id;
+
     @Schema(description = "跟进(待办)内容")
     @Size(max = 5000, message = "【跟进(待办)内容】最长5000位")
     private String followContent;
 
     @Schema(description = "待办时间")
-    @DateTimeFormat(pattern = HelioConstant.Jackson.DATE_FORMAT)
-    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = HelioConstant.Jackson.DATE_FORMAT)
+    @DateTimeFormat(pattern = HelioConstant.Jackson.DATE_TIME_FORMAT)
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = HelioConstant.Jackson.DATE_TIME_FORMAT)
     private LocalDateTime orderDatetime;
 
 }

+ 14 - 0
src/main/java/com/jtzx/crm/module/sys/model/response/SysCustomerFollowListBO.java

@@ -86,4 +86,18 @@ public class SysCustomerFollowListBO implements Serializable {
 
     @Schema(description = "审核状态:0-待审核,1-已通过,2-已驳回")
     private Integer auditStatus;
+
+    @Schema(description = "上次跟进时间")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
+    private LocalDateTime lastClaimDatetime;
+
+    @Schema(description = "客户类型名称")
+    private String typeName;
+
+    @Schema(description = "预约取消原因")
+    private String cancelRemark;
+
+    @Schema(description = "地址")
+    private String address;
 }

+ 14 - 11
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowOrderService.java

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.collect.Lists;
 import com.jtzx.crm.module.sys.entity.SysCustomerFollowEntity;
@@ -44,9 +45,9 @@ public class SysCustomerDataFollowOrderService {
         resultData.setDateList(Lists.newArrayList());
         // 筛选条件数据
         resultData.setSelectData(sysCustomerDataFollowService.queryCustomerOrderSelectData(0, true));
-        String monthStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM");
-        String dateStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
-        if (dto.getDatetime() != null) {
+        String monthStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
+        String dateStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss");
+        if (StrUtil.isNotEmpty(dto.getDatetime())) {
             dateStr = dto.getDatetime().trim();
             monthStr = dto.getDatetime();
         }
@@ -60,9 +61,9 @@ public class SysCustomerDataFollowOrderService {
         //如果是 yyyy-MM-dd 格式,则需要重新设置为当天开始时间和结束时间
         if (dateStr.length() == 10) {
             //当天开始时间
-            startDateTime = DateUtil.beginOfDay(DateUtil.parseTime(dateStr));
+            startDateTime = DateUtil.beginOfDay(DateUtil.parseDate(dateStr));
             //当天结束时间
-            endDateTime = DateUtil.endOfDay(DateUtil.parseTime(dateStr));
+            endDateTime = DateUtil.endOfDay(DateUtil.parseDate(dateStr));
         }
         //数据列表
         resultData.setDataList(
@@ -79,7 +80,9 @@ public class SysCustomerDataFollowOrderService {
                                 .select(
                                         SysCustomerFollowEntity::getId,
                                         SysCustomerFollowEntity::getOrderDatetime,
-                                        SysCustomerFollowEntity::getOrderStatus
+                                        SysCustomerFollowEntity::getOrderStatus,
+                                        SysCustomerFollowEntity::getSuccessStatus,
+                                        SysCustomerFollowEntity::getClaimDatetime
                                 )
                                 .ge(SysCustomerFollowEntity::getOrderDatetime, startMonthDay)
                                 .le(SysCustomerFollowEntity::getOrderDatetime, endMonthDay)
@@ -89,17 +92,17 @@ public class SysCustomerDataFollowOrderService {
             //月待开始时间
             resultData.setStatus0Count(
                     listData.stream()
-                            .filter(x -> x.getSuccessStatus() == 0)
+                            .filter(x -> x.getOrderStatus() == 0)
                             .toList().size());
             //月已结束时间
             resultData.setStatus1Count(
                     listData.stream()
-                            .filter(x -> x.getSuccessStatus() == 1)
+                            .filter(x -> x.getOrderStatus() == 1)
                             .toList().size());
             //月已取消时间
             resultData.setStatus2Count(
                     listData.stream()
-                            .filter(x -> x.getSuccessStatus() == 2)
+                            .filter(x -> x.getOrderStatus() == 2)
                             .toList().size());
             //总条数
             resultData.setTotalCount(listData.size());
@@ -119,8 +122,8 @@ public class SysCustomerDataFollowOrderService {
                 DateTime endDateTime1 = DateUtil.endOfDay(e);
                 int size =
                         listData.stream()
-                                .filter(x -> !x.getClaimDatetime().isBefore(DateUtil.toLocalDateTime(startDateTime1))
-                                        && !x.getClaimDatetime().isAfter(DateUtil.toLocalDateTime(endDateTime1)))
+                                .filter(x -> !x.getOrderDatetime().isBefore(DateUtil.toLocalDateTime(startDateTime1))
+                                        && !x.getOrderDatetime().isAfter(DateUtil.toLocalDateTime(endDateTime1)))
                                 .toList().size();
                 if (size > 0) {
                     detailBO.setStatus(1);

+ 73 - 42
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowService.java

@@ -11,14 +11,8 @@ 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.SysCustomerFollowAuditEntity;
-import com.jtzx.crm.module.sys.entity.SysCustomerFollowEntity;
-import com.jtzx.crm.module.sys.entity.SysGroupEntity;
-import com.jtzx.crm.module.sys.entity.SysParamBaseDataEntity;
-import com.jtzx.crm.module.sys.mapper.SysCustomerFollowAuditMapper;
-import com.jtzx.crm.module.sys.mapper.SysCustomerFollowMapper;
-import com.jtzx.crm.module.sys.mapper.SysGroupMapper;
-import com.jtzx.crm.module.sys.mapper.SysParamBaseDataMapper;
+import com.jtzx.crm.module.sys.entity.*;
+import com.jtzx.crm.module.sys.mapper.*;
 import com.jtzx.crm.module.sys.model.request.AdminSysCustomerDataFollowListDTO;
 import com.jtzx.crm.module.sys.model.request.AdminSysCustomerFollowReqDTO;
 import com.jtzx.crm.module.sys.model.request.AdminSysCustomerOperLogListDTO;
@@ -29,10 +23,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * 客户跟进业务
@@ -50,6 +41,8 @@ public class SysCustomerDataFollowService {
 
     private final SysCustomerFollowAuditMapper sysCustomerFollowAuditMapper;
 
+    private final SysCustomerDataMapper sysCustomerDataMapper;
+
     private final SysCustomerUserCommonService sysCustomerUserCommonService;
 
     private final SysCustomerOperLogService sysCustomerOperLogService;
@@ -72,7 +65,7 @@ public class SysCustomerDataFollowService {
         //产品信息
         resultData.setProductData(sysCustomerUserCommonService.handleProductData());
         //省市信息
-        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType2( true);
+        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType2(true);
         if (sysCustomerSelectBO != null && CollUtil.isNotEmpty(sysCustomerSelectBO.getRegionData())) {
             //省市信息
             resultData.setRegionData(sysCustomerSelectBO.getRegionData());
@@ -116,24 +109,19 @@ public class SysCustomerDataFollowService {
         List<Long> cityIds = sysCustomerUserCommonService.queryUserCityIds1(dto.getProvinceId());
         List<BindUserBO> bindUserBOS = sysCustomerUserCommonService.queryBindUserListByCityId(cityIds);
         if (CollUtil.isNotEmpty(bindUserBOS)) {
-            if (CollUtil.isEmpty(userIds)) {
+            if (CollUtil.isEmpty(userIds) && !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
                 userIds.addAll(
                         bindUserBOS.stream()
                                 .map(BindUserBO::getId).toList());
             }
-            if (CollUtil.isEmpty(groupIds)) {
+            if (CollUtil.isEmpty(groupIds) && !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
                 groupIds.addAll(
                         bindUserBOS.stream()
                                 .map(BindUserBO::getGroupId).distinct().toList());
             }
         }
-        if (CollUtil.isEmpty(userIds) || CollUtil.isEmpty(groupIds)) {
-            return new PageResult<SysCustomerFollowListBO>()
-                    .setCurrent(1)
-                    .setSize(dto.getPageSize())
-                    .setTotal(0)
-                    .setRecords(Lists.newArrayList());
-        }
+
+
         Page<SysCustomerFollowEntity> entityPage = sysCustomerFollowMapper.selectPage(
                 new Page<>(dto.getPageNum(), dto.getPageSize()),
                 new QueryWrapper<SysCustomerFollowEntity>()
@@ -141,7 +129,7 @@ public class SysCustomerDataFollowService {
                         // 名称
                         .like(CharSequenceUtil.isNotBlank(dto.getQueryStr()), SysCustomerFollowEntity::getCustomerName, CharSequenceUtil.cleanBlank(dto.getQueryStr()))
                         //用户判断
-                        .in(SysCustomerFollowEntity::getClaimUserId, userIds)
+                        .in(CollUtil.isNotEmpty(userIds), SysCustomerFollowEntity::getClaimUserId, userIds)
                         // 学段id(param_base_data表主id)
                         .eq(Objects.nonNull(dto.getStageId()), SysCustomerFollowEntity::getStageId, dto.getStageId())
                         // 省份id(省份表主id)
@@ -149,9 +137,9 @@ public class SysCustomerDataFollowService {
                         // 城市id(不为空时)
                         .eq(Objects.nonNull(dto.getCityId()), SysCustomerFollowEntity::getCityId, dto.getCityId())
                         // 城市id(为空时)
-                        .in(Objects.isNull(dto.getCityId()), SysCustomerFollowEntity::getCityId, cityIds)
+                        .in(Objects.isNull(dto.getCityId()) && CollUtil.isNotEmpty(cityIds), SysCustomerFollowEntity::getCityId, cityIds)
                         //小组
-                        .in(SysCustomerFollowEntity::getClaimUserGroupId, groupIds)
+                        .in(CollUtil.isNotEmpty(groupIds), SysCustomerFollowEntity::getClaimUserGroupId, groupIds)
                         //开始时间
                         .ge(dto.getStartDatetime() != null, SysCustomerFollowEntity::getClaimDatetime, dto.getStartDatetime())
                         //结束时间
@@ -176,7 +164,7 @@ public class SysCustomerDataFollowService {
         if (dto.getGroupId() != null) {
             groupIds.add(dto.getGroupId());
         }
-        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType2( true);
+        SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType2(true);
         if (selectBO != null && CollUtil.isNotEmpty(selectBO.getRegionData())) {
             List<Long> cityIds = Lists.newArrayList();
             selectBO.getRegionData()
@@ -422,15 +410,15 @@ public class SysCustomerDataFollowService {
                                 .ge(startDateTime != null, SysCustomerFollowEntity::getOrderDatetime, startDateTime)
                                 .le(endDateTime != null, SysCustomerFollowEntity::getOrderDatetime, endDateTime)
                                 .eq(SysCustomerFollowEntity::getOrderType, orderType)
-                                .ne(orderType==1,SysCustomerFollowEntity::getOrderStatus, 2)
+                                .ne(orderType == 1, SysCustomerFollowEntity::getOrderStatus, 2)
                                 .and(StrUtil.isNotEmpty(queryStr), z ->
-                                        z.like(SysCustomerFollowEntity::getCustomerName, queryStr)
-                                        .or().like(SysCustomerFollowEntity::getClaimUserName, queryStr)
+                                                z.like(SysCustomerFollowEntity::getCustomerName, queryStr)
+                                                        .or().like(SysCustomerFollowEntity::getClaimUserName, queryStr)
 //                                        .or().like(SysCustomerFollowEntity::getCustomerPersonName, queryStr)
 //                                        .or().like(SysCustomerFollowEntity::getPositionName, queryStr)
                                 )
-                                .orderByDesc(orderType==0,SysCustomerFollowEntity::getOrderDatetime, SysCustomerFollowEntity::getCreatedAt)
-                                .orderByDesc(orderType==1,SysCustomerFollowEntity::getCreatedAt)
+                                .orderByDesc(orderType == 0, SysCustomerFollowEntity::getOrderDatetime, SysCustomerFollowEntity::getCreatedAt)
+                                .orderByDesc(orderType == 1, SysCustomerFollowEntity::getCreatedAt)
                 );
         return this.entityList2BOs(listData);
     }
@@ -460,6 +448,31 @@ public class SysCustomerDataFollowService {
         if (CollUtil.isEmpty(entityList)) {
             return Collections.emptyList();
         }
+        //查询客户学校数据
+        List<SysCustomerDataEntity> customerDataEntityList =
+                sysCustomerDataMapper.selectList(
+                        new LambdaQueryWrapper<SysCustomerDataEntity>()
+                                .select(SysCustomerDataEntity::getId, SysCustomerDataEntity::getName, SysCustomerDataEntity::getAddress)
+                                .in(SysCustomerDataEntity::getId, entityList.stream().map(SysCustomerFollowEntity::getCustomerId).distinct().toList())
+                );
+        if(CollUtil.isEmpty(customerDataEntityList)){
+            return Collections.emptyList();
+        }
+
+        //查询当前登录用户对 customer 的上次跟进时间
+        List<SysCustomerFollowEntity> customerFollowList =
+                sysCustomerFollowMapper.selectList(
+                        new QueryWrapper<SysCustomerFollowEntity>()
+                                .lambda()
+                                .select(
+                                        SysCustomerFollowEntity::getCustomerId,
+                                        SysCustomerFollowEntity::getClaimUserGroupId,
+                                        SysCustomerFollowEntity::getClaimUserId,
+                                        SysCustomerFollowEntity::getClaimDatetime
+                                )
+                                .eq(SysCustomerFollowEntity::getClaimUserId, UserContextHolder.getUserId())
+                );
+
 
         //查询审核数据
         List<Long> customerFollowIds =
@@ -468,22 +481,22 @@ public class SysCustomerDataFollowService {
                         .filter(Objects::nonNull).distinct().toList();
 
         List<SysCustomerFollowAuditEntity> auditData =
-        sysCustomerFollowAuditMapper.selectList(
-                new LambdaQueryWrapper<SysCustomerFollowAuditEntity>()
-                        .select(
-                                SysCustomerFollowAuditEntity::getCustomerFollowId,
-                                SysCustomerFollowAuditEntity::getCustomerId,
-                                SysCustomerFollowAuditEntity::getAuditStatus
-                        )
-                        .in(SysCustomerFollowAuditEntity::getCustomerFollowId, customerFollowIds)
-        );
+                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 = Lists.newArrayList();
-        if(CollUtil.isNotEmpty(groupIds)){
+        if (CollUtil.isNotEmpty(groupIds)) {
             groupEntityList.addAll(sysGroupMapper.selectByIds(groupIds));
         }
         //查询学段
@@ -509,6 +522,20 @@ public class SysCustomerDataFollowService {
         entityList.forEach(
                 entity -> {
                     SysCustomerFollowListBO bo = this.entity2BO(entity);
+                    if(CollUtil.isNotEmpty(customerDataEntityList)){
+                        customerDataEntityList.stream()
+                                .filter(x -> x.getId().equals(entity.getCustomerId()))
+                                .findFirst()
+                                .ifPresent(e -> bo.setAddress(e.getAddress()));
+                    }
+                    //上次跟进
+                    if (CollUtil.isNotEmpty(customerFollowList)) {
+                        customerFollowList.stream()
+                                .filter(x -> x.getCustomerId().equals(entity.getCustomerId()))
+                                .filter(x -> x.getClaimUserId().equals(entity.getClaimUserId()))
+                                .max(Comparator.comparing(SysCustomerFollowEntity::getClaimDatetime))
+                                .ifPresent(e -> bo.setLastClaimDatetime(e.getClaimDatetime()));
+                    }
                     if (CollUtil.isNotEmpty(groupEntityList)) {
                         groupEntityList.stream()
                                 .filter(x -> x.getId().equals(entity.getClaimUserGroupId()))
@@ -534,7 +561,7 @@ public class SysCustomerDataFollowService {
                                 .ifPresent(e -> bo.setFollowName(e.getTitle()));
                     }
 
-                    if(CollUtil.isNotEmpty(auditData)){
+                    if (CollUtil.isNotEmpty(auditData)) {
                         auditData.stream()
                                 .filter(x -> x.getCustomerFollowId().equals(entity.getId()))
                                 .findFirst()
@@ -562,6 +589,10 @@ public class SysCustomerDataFollowService {
         // 可以在此处为BO填充字段
         bo.setClaimUserName(entity.getClaimUserName());
         bo.setClaimDatetime(entity.getClaimDatetime());
+        bo.setTypeName("首单客户");
+        if (entity.getSuccessStatus() != null && entity.getSuccessStatus() == 1) {
+            bo.setTypeName("存量客户");
+        }
         return bo;
     }
 

+ 5 - 4
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowTodoService.java

@@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateField;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.StrUtil;
 import com.google.common.collect.Lists;
 import com.jtzx.crm.module.sys.model.request.AdminSysCustomerFollowTodoDTO;
 import com.jtzx.crm.module.sys.model.response.SysCustomerFollowListBO;
@@ -45,7 +46,7 @@ public class SysCustomerDataFollowTodoService {
             dto.setUserId(UserContextHolder.getUserContext().getUserId());
         }
         String dateStr;
-        if (dto.getDatetime() == null) {
+        if (StrUtil.isEmpty(dto.getDatetime())) {
             dateStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
         } else {
             dateStr = dto.getDatetime().trim() + "-01";//当月第一天时间
@@ -77,9 +78,9 @@ public class SysCustomerDataFollowTodoService {
                 //当天结束时间
                 DateTime endDateTime = DateUtil.endOfDay(e);
                 listData.stream()
-                        .filter(x -> !x.getClaimDatetime().isBefore(DateUtil.toLocalDateTime(startDateTime))
-                                && !x.getClaimDatetime().isAfter(DateUtil.toLocalDateTime(endDateTime)))
-                        .sorted(Comparator.comparing(SysCustomerFollowListBO::getClaimDatetime))
+                        .filter(x -> !x.getOrderDatetime().isBefore(DateUtil.toLocalDateTime(startDateTime))
+                                && !x.getOrderDatetime().isAfter(DateUtil.toLocalDateTime(endDateTime)))
+                        .sorted(Comparator.comparing(SysCustomerFollowListBO::getOrderDatetime))
                         .forEach(detailBO.getDataList()::add);
                 detailBO.setCount(detailBO.getDataList().size());
             }

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

@@ -360,12 +360,12 @@ public class SysCustomerDataPrivateService {
                                 .select(
                                         SysCustomerFollowEntity::getCustomerId,
                                         SysCustomerFollowEntity::getClaimUserGroupId,
-                                        SysCustomerFollowEntity::getClaimUserGroupId,
+                                        SysCustomerFollowEntity::getClaimUserId,
                                         SysCustomerFollowEntity::getClaimDatetime
                                 )
                                 .in(SysCustomerFollowEntity::getCustomerId, entityList.stream().map(SysCustomerDataEntity::getId).toList())
                                 .in(CollUtil.isNotEmpty(groupIds),SysCustomerFollowEntity::getClaimUserGroupId, groupIds)
-                                .in(SysCustomerFollowEntity::getClaimUserId, entityList.stream().map(SysCustomerDataEntity::getClaimUserGroupId).distinct().toList())
+                                .eq(SysCustomerFollowEntity::getClaimUserId, UserContextHolder.getUserId())
                 );
 
 
@@ -390,7 +390,7 @@ public class SysCustomerDataPrivateService {
                         List<SysCustomerFollowEntity> userFollowEntityList =
                                 followEntityList.stream()
                                         .filter(x -> x.getCustomerId().equals(entity.getId()))
-                                        .filter(x -> x.getClaimUserGroupId().equals(entity.getClaimUserGroupId()))
+                                        .filter(x -> x.getClaimUserGroupId()!=null && x.getClaimUserGroupId().equals(entity.getClaimUserGroupId()))
                                         .filter(x -> x.getClaimUserId().equals(entity.getClaimUserId()))
                                         .sorted(Comparator.comparing(SysCustomerFollowEntity::getClaimDatetime).reversed())
                                         .toList();

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

@@ -101,7 +101,7 @@ public class SysCustomerFollowService {
     /**
      * 我的客户页面,预约待办列表去消预约操作
      */
-    public void cancelOrder(CannelOrderDTO dto, Boolean privateStatus) {
+    public void cancelOrder(CannelOrderDTO dto, Boolean privateStatus) throws BusinessException {
         if (privateStatus) {
             permissionService.publicPrivateCustomerPermission();
         }

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

@@ -2,8 +2,10 @@ package com.jtzx.crm.module.sys.service;
 
 import cc.uncarbon.framework.core.exception.BusinessException;
 import cc.uncarbon.framework.core.page.PageResult;
+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;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -56,6 +58,11 @@ public class SysCustomerOperLogService {
                         .in(CollUtil.isNotEmpty(groupIds), SysCustomerOperLogEntity::getOperUserGroupId, groupIds)
                         .ge(dto.getStartDate() != null, SysCustomerOperLogEntity::getCreatedAt, dto.getStartDate())
                         .le(dto.getEndDate() != null, SysCustomerOperLogEntity::getCreatedAt, dto.getEndDate())
+                        .and(StrUtil.isNotBlank(dto.getQueryStr()), z ->
+                                z.like(SysCustomerOperLogEntity::getCustomerName, dto.getQueryStr())
+                                        .or()
+                                        .like(HelioBaseEntity::getCreatedBy, dto.getQueryStr())
+                        )
                         // 排序
                         .orderByDesc(SysCustomerOperLogEntity::getCreatedAt)
         );
@@ -83,7 +90,7 @@ public class SysCustomerOperLogService {
                                         SysCustomerOperLogEntity::getOperName,
                                         SysCustomerOperLogEntity::getOperUserGroupId
                                 )
-                                .eq(SysCustomerOperLogEntity::getCustomerId, dto.getCustomerId())
+                                .eq(dto.getCustomerId() != null, SysCustomerOperLogEntity::getCustomerId, dto.getCustomerId())
                                 .orderByDesc(SysCustomerOperLogEntity::getCreatedAt)
                 );
         if (CollUtil.isNotEmpty(logEntityList)) {

+ 21 - 6
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerTodoService.java

@@ -1,6 +1,7 @@
 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.crud.entity.HelioBaseEntity;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
@@ -96,6 +97,10 @@ public class SysCustomerTodoService {
                 );
 
         List<SysCustomerFollowListBO> sysCustomerFollowListBOS = sysCustomerDataFollowService.queryCustomerFollowOrderData(startDateTime, endDateTime, userId, null, null, 1);
+        List<SysCustomerFollowListBO> sysCustomerFollowLists = Lists.newArrayList();
+        if(CollUtil.isNotEmpty(sysCustomerFollowListBOS)){
+            sysCustomerFollowLists.addAll(sysCustomerFollowListBOS);
+        }
         if (CollUtil.isNotEmpty(todoEntityList)) {
             todoEntityList.forEach(
                     entity -> {
@@ -108,12 +113,13 @@ public class SysCustomerTodoService {
                         bo.setOrderStatus(entity.getOrderStatus());
                         bo.setOrderType(1);
                         bo.setType(1);
-                        sysCustomerFollowListBOS.add(bo);
+                        sysCustomerFollowLists.add(bo);
                     }
             );
         }
-        return sysCustomerFollowListBOS;
+        return sysCustomerFollowLists;
     }
+
     /**
      * 后台管理-新增
      */
@@ -124,6 +130,7 @@ public class SysCustomerTodoService {
         BeanUtil.copyProperties(dto, entity);
         entity.setClaimUserId(UserContextHolder.getUserId());
         entity.setClaimUserName(UserContextHolder.getUserName());
+        entity.setOrderStatus(0);
         sysCustomerTodoMapper.insert(entity);
         return entity.getId();
     }
@@ -132,11 +139,18 @@ public class SysCustomerTodoService {
      * 后台管理-编辑
      */
     @Transactional(rollbackFor = Exception.class)
-    public void adminUpdate(AdminSysCustomerTodoInsertOrUpdateDTO dto) {
+    public void adminUpdate(AdminSysCustomerTodoInsertOrUpdateDTO dto) throws BusinessException {
         log.info("[后台管理-自定义待办信息数据-编辑] >> DTO={}", dto);
-        SysCustomerTodoEntity entity = new SysCustomerTodoEntity();
-        BeanUtil.copyProperties(dto, entity);
-        sysCustomerTodoMapper.updateById(entity);
+        SysCustomerTodoEntity entity = sysCustomerTodoMapper.selectById(dto.getId());
+        if (entity != null) {
+            BeanUtil.copyProperties(dto, entity);
+            if (entity.getOrderStatus() == null) {
+                entity.setOrderStatus(0);
+            }
+            sysCustomerTodoMapper.updateById(entity);
+        } else {
+            throw new BusinessException("待办信息数据不存在");
+        }
     }
 
     /**
@@ -150,6 +164,7 @@ public class SysCustomerTodoService {
 
     /**
      * 关闭待办信息数据
+     *
      * @param id
      */
     public void cancelTodoStatus(Long id) {