瀏覽代碼

fix(service): 增加异常抛出并修复客户数据查询与预约状态逻辑

- 在多个Controller和Service方法中添加了BusinessException异常声明和抛出,增强异常管理
- 优化客户数据新增和编辑时的名称唯一性校验,防止重复添加和编辑
- 调整查询日期处理逻辑,规范日期范围查询行为
- 修改客户跟进数据查询添加固定筛选条件,仅查询方案演示数据
- 更新预约和待办时间校验逻辑,增加时间合法性判定和状态设置
- 修正历史跟进总览开关逻辑,增加管理员权限判定支持
- 为客户详情和跟进列表新增历史跟进状态和取消预约标识字段
- 优化代码格式,调整部分排序逻辑为升序
- 增加用户存在性检查,避免空指针异常
- 调整部分日志内容字符串格式,提升可读性
zhangxf 4 周之前
父節點
當前提交
a670a10da1

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

@@ -119,7 +119,7 @@ public class CustomerDataPrivateController {
 
     @Operation(summary = "查询详情信息接口")
     @PostMapping(value = "/customer/data/detail", produces = "application/json;charset=UTF-8")
-    public ApiResult<SysCustomerDetailBO> queryCustomerDetail(@RequestBody AdminSysCustomerFollowReqDTO dto) {
+    public ApiResult<SysCustomerDetailBO> queryCustomerDetail(@RequestBody AdminSysCustomerFollowReqDTO dto) throws BusinessException{
         SysCustomerDetailBO detailBO = sysCustomerDataPrivateService.queryCustomerDetail(dto);
         return ApiResult.data(detailBO);
     }

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

@@ -61,7 +61,7 @@ public class CustomerDataPublicController {
 
     @Operation(summary = "新增公海客户数据接口")
     @PostMapping(value = "/customer/add")
-    public ApiResult<Void> add(@RequestBody @Valid AdminSysCustomerDataInsertOrUpdateDTO dto) {
+    public ApiResult<Void> add(@RequestBody @Valid AdminSysCustomerDataInsertOrUpdateDTO dto) throws BusinessException{
         sysCustomerDataPublicService.adminInsertCustomerData(dto);
         return ApiResult.success();
     }
@@ -69,7 +69,7 @@ public class CustomerDataPublicController {
 
     @Operation(summary = "修改公海客户数据接口")
     @PostMapping(value = "/customer/update")
-    public ApiResult<Void> update(@RequestBody @Valid AdminSysCustomerDataInsertOrUpdateDTO dto) {
+    public ApiResult<Void> update(@RequestBody @Valid AdminSysCustomerDataInsertOrUpdateDTO dto) throws BusinessException{
         sysCustomerDataPublicService.adminUpdateCustomerData(dto);
         return ApiResult.success();
     }
@@ -120,7 +120,7 @@ public class CustomerDataPublicController {
 
     @Operation(summary = "查询详情信息接口")
     @PostMapping(value = "/customer/data/detail", produces = "application/json;charset=UTF-8")
-    public ApiResult<SysCustomerDetailBO> queryCustomerDetail(@RequestBody AdminSysCustomerFollowReqDTO dto) {
+    public ApiResult<SysCustomerDetailBO> queryCustomerDetail(@RequestBody AdminSysCustomerFollowReqDTO dto) throws BusinessException{
         SysCustomerDetailBO detailBO = sysCustomerDataPublicService.queryCustomerDetail(dto);
         return ApiResult.data(detailBO);
     }

+ 2 - 1
src/main/java/com/jtzx/crm/module/sys/model/response/SysCustomerDetailBO.java

@@ -48,6 +48,7 @@ public class SysCustomerDetailBO implements Serializable {
     @Schema(description = "预约待办数据")
     private List<SysCustomerFollowDataBO> orderData;
 
-
+    @Schema(description = "历史跟进状态开关,0-关,1-开")
+    private Integer historyFollowStatus;
 
 }

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

@@ -26,15 +26,24 @@ public class SysCustomerFollowListBO implements Serializable {
     @Schema(description = "主键ID")
     private Long id;
 
+    @Schema(description = "客户ID")
+    private Long customerId;
+
 //    @Schema(description = "客户类型名称")
 //    private String typeName;
 
     @Schema(description = "客户名称")
     private String customerName;
 
+    @Schema(description = "联系人id(customer_person表主id)")
+    private Long customerPersonId;
+
     @Schema(description = "联系人名称")
     private String customerPersonName;
 
+    @Schema(description = "职务id(param_base_data表主id)")
+    private Long positionId;
+
     @Schema(description = "职务名称")
     private String positionName;
 
@@ -53,9 +62,15 @@ public class SysCustomerFollowListBO implements Serializable {
     @Schema(description = "认领人(跟进)名称")
     private String claimUserName;
 
+    @Schema(description = "产品id(param_base_data表主id)")
+    private Long productId;
+
     @Schema(description = "产品名称")
     private String productName;
 
+    @Schema(description = "跟进状态id,赢单状态id固定-37,方案演示id固定-33")
+    private Long followId;
+
     @Schema(description = "跟进状态的名称")
     private String followName;
 
@@ -100,4 +115,7 @@ public class SysCustomerFollowListBO implements Serializable {
 
     @Schema(description = "地址")
     private String address;
+
+    @Schema(description = "可否取消预约状态,true-可取消,false-不可取消")
+    private Boolean cancelStatus;
 }

+ 23 - 16
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowOrderService.java

@@ -45,34 +45,38 @@ public class SysCustomerDataFollowOrderService {
         resultData.setDateList(Lists.newArrayList());
         // 筛选条件数据
         resultData.setSelectData(sysCustomerDataFollowService.queryCustomerOrderSelectData(0, true));
-        String monthStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
-        String dateStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd HH:mm:ss");
+//        String monthStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
+        String dateStr = DateUtil.format(LocalDateTime.now(), "yyyy-MM-dd");
         if (StrUtil.isNotEmpty(dto.getDatetime())) {
             dateStr = dto.getDatetime().trim();
-            monthStr = dto.getDatetime();
+//            monthStr = dto.getDatetime().trim();
         }
+        //处理月份
+//        if(monthStr.length() == 7){
+//            monthStr = monthStr +"-01";
+//        }
         //当月开始时间
-        DateTime startMonthDay = DateUtil.beginOfMonth(DateUtil.parse(monthStr));
-        //当月结束时间
-        DateTime endMonthDay = DateUtil.endOfMonth(DateUtil.parse(monthStr));
+        DateTime startMonthDay = DateUtil.beginOfMonth(DateUtil.parse(dateStr));
+//        //当月结束时间
+        DateTime endMonthDay = DateUtil.endOfMonth(DateUtil.parse(dateStr));
+
         //如果是 yyyy-MM 格式,则需要重新设置为当月开始时间和结束时间
-        DateTime startDateTime = startMonthDay;
-        DateTime endDateTime = endMonthDay;
+        DateTime startDateTime = DateUtil.beginOfDay(DateUtil.parseDate(dateStr));
+        DateTime endDateTime = DateUtil.endOfDay(DateUtil.parseDate(dateStr));
         //如果是 yyyy-MM-dd 格式,则需要重新设置为当天开始时间和结束时间
-        if (dateStr.length() == 10) {
-            //当天开始时间
-            startDateTime = DateUtil.beginOfDay(DateUtil.parseDate(dateStr));
-            //当天结束时间
-            endDateTime = DateUtil.endOfDay(DateUtil.parseDate(dateStr));
-        }
+//        if (dateStr.length() == 10) {
+//            //当天开始时间
+//            startDateTime = DateUtil.beginOfDay(DateUtil.parseDate(dateStr));
+//            //当天结束时间
+//            endDateTime = DateUtil.endOfDay(DateUtil.parseDate(dateStr));
+//        }
         //数据列表
         resultData.setDataList(
                 sysCustomerDataFollowService.queryCustomerFollowOrderData(DateUtil.toLocalDateTime(startDateTime),
                         DateUtil.toLocalDateTime(endDateTime), dto.getUserId(), dto.getOrderStatus(),
                         dto.getQueryStr(), 0));
 
-        //日期列表
-        List<SysCustomerFollowOrderDetailBO> dateList = Lists.newArrayList();
+
         //查询数据
         List<SysCustomerFollowEntity> listData =
                 sysCustomerFollowMapper.selectList(
@@ -86,6 +90,7 @@ public class SysCustomerDataFollowOrderService {
                                 )
                                 .ge(SysCustomerFollowEntity::getOrderDatetime, startMonthDay)
                                 .le(SysCustomerFollowEntity::getOrderDatetime, endMonthDay)
+                                .eq(SysCustomerFollowEntity::getFollowId,33) //只查询方案演示
                                 .eq(SysCustomerFollowEntity::getOrderType, 0)
                 );
         if (CollUtil.isNotEmpty(listData)) {
@@ -108,6 +113,8 @@ public class SysCustomerDataFollowOrderService {
             resultData.setTotalCount(listData.size());
         }
 
+        //日期列表
+        List<SysCustomerFollowOrderDetailBO> dateList = Lists.newArrayList();
         List<DateTime> dateTimes = DateUtil.rangeToList(startMonthDay, endMonthDay, DateField.DAY_OF_MONTH);
         dateTimes.forEach(e -> {
             SysCustomerFollowOrderDetailBO detailBO = SysCustomerFollowOrderDetailBO.builder()

+ 10 - 5
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerDataFollowService.java

@@ -120,8 +120,6 @@ public class SysCustomerDataFollowService {
                                 .map(BindUserBO::getGroupId).distinct().toList());
             }
         }
-
-
         Page<SysCustomerFollowEntity> entityPage = sysCustomerFollowMapper.selectPage(
                 new Page<>(dto.getPageNum(), dto.getPageSize()),
                 new QueryWrapper<SysCustomerFollowEntity>()
@@ -208,6 +206,7 @@ public class SysCustomerDataFollowService {
                                         SysCustomerFollowEntity::getOrderStatus
                                 )
                                 .eq(SysCustomerFollowEntity::getOrderType, orderType)
+                                .eq(SysCustomerFollowEntity::getFollowId,33) //只查询方案演示
                                 .orderByDesc(SysCustomerFollowEntity::getCreatedAt)
                 );
         if (CollUtil.isNotEmpty(followEntityList)) {
@@ -410,6 +409,7 @@ public class SysCustomerDataFollowService {
                                 .ge(startDateTime != null, SysCustomerFollowEntity::getOrderDatetime, startDateTime)
                                 .le(endDateTime != null, SysCustomerFollowEntity::getOrderDatetime, endDateTime)
                                 .eq(SysCustomerFollowEntity::getOrderType, orderType)
+                                .eq(orderType == 0,SysCustomerFollowEntity::getFollowId,33) //只查询方案演示
                                 .ne(orderType == 1, SysCustomerFollowEntity::getOrderStatus, 2)
                                 .and(StrUtil.isNotEmpty(queryStr), z ->
                                                 z.like(SysCustomerFollowEntity::getCustomerName, queryStr)
@@ -417,7 +417,7 @@ public class SysCustomerDataFollowService {
 //                                        .or().like(SysCustomerFollowEntity::getCustomerPersonName, queryStr)
 //                                        .or().like(SysCustomerFollowEntity::getPositionName, queryStr)
                                 )
-                                .orderByDesc(orderType == 0, SysCustomerFollowEntity::getOrderDatetime, SysCustomerFollowEntity::getCreatedAt)
+                                .orderByAsc(orderType == 0, SysCustomerFollowEntity::getOrderDatetime, SysCustomerFollowEntity::getCreatedAt)
                                 .orderByDesc(orderType == 1, SysCustomerFollowEntity::getCreatedAt)
                 );
         return this.entityList2BOs(listData);
@@ -455,7 +455,7 @@ public class SysCustomerDataFollowService {
                                 .select(SysCustomerDataEntity::getId, SysCustomerDataEntity::getName, SysCustomerDataEntity::getAddress)
                                 .in(SysCustomerDataEntity::getId, entityList.stream().map(SysCustomerFollowEntity::getCustomerId).distinct().toList())
                 );
-        if(CollUtil.isEmpty(customerDataEntityList)){
+        if (CollUtil.isEmpty(customerDataEntityList)) {
             return Collections.emptyList();
         }
 
@@ -522,7 +522,7 @@ public class SysCustomerDataFollowService {
         entityList.forEach(
                 entity -> {
                     SysCustomerFollowListBO bo = this.entity2BO(entity);
-                    if(CollUtil.isNotEmpty(customerDataEntityList)){
+                    if (CollUtil.isNotEmpty(customerDataEntityList)) {
                         customerDataEntityList.stream()
                                 .filter(x -> x.getId().equals(entity.getCustomerId()))
                                 .findFirst()
@@ -593,6 +593,11 @@ public class SysCustomerDataFollowService {
         if (entity.getSuccessStatus() != null && entity.getSuccessStatus() == 1) {
             bo.setTypeName("存量客户");
         }
+        bo.setCancelStatus(false);
+        if (UserContextHolder.getUserId().equals(entity.getClaimUserId())) {
+            bo.setCancelStatus(true);
+        }
+        bo.setCustomerId(entity.getCustomerId());
         return bo;
     }
 

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

@@ -4,7 +4,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 cc.uncarbon.framework.crud.entity.HelioBaseEntity;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.text.CharSequenceUtil;
@@ -241,7 +240,7 @@ public class SysCustomerDataPrivateService {
      *
      * @param dto
      */
-    public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) {
+    public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) throws BusinessException{
         permissionService.publicPrivateCustomerPermission();
 
         SysCustomerDetailBO detailBO = SysCustomerDetailBO.builder().build();
@@ -254,8 +253,11 @@ public class SysCustomerDataPrivateService {
                                             SysCustomerDataEntity::getId,
                                             SysCustomerDataEntity::getClaimUserId
                                     )
-                                    .eq(HelioBaseEntity::getId,dto.getCustomerId())
+                                    .eq(SysCustomerDataEntity::getId,dto.getCustomerId())
                     );
+            if(entity == null){
+                throw new BusinessException(400, "参数错误,客户不存在");
+            }
             dto.setUserId(entity.getClaimUserId());
         }
         //顶部筛选条件数据
@@ -282,7 +284,7 @@ public class SysCustomerDataPrivateService {
         detailBO.setOrderData(sysCustomerFollowService.handleOrderData(dto.getCustomerId(), dto.getUserId()));
         SysUserEntity sysUserEntity = sysUserMapper.selectById(UserContextHolder.getUserId());
         //历史跟进总览开关
-        if (sysUserEntity.getHistoryFollowStatus() != null && sysUserEntity.getHistoryFollowStatus() == 1) {
+        if (UserContextHolder.getUserContext().getRoles().contains("Admin") || (sysUserEntity.getHistoryFollowStatus() != null && sysUserEntity.getHistoryFollowStatus() == 1)) {
             //历史跟进总览
             detailBO.setFollowOverViewData(sysCustomerFollowService.handleCustomerFollowOverViewData(dto.getCustomerId(), dto.getUserId()));
         }

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

@@ -1,6 +1,8 @@
 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;
@@ -11,8 +13,10 @@ 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.SysParamBaseDataEntity;
+import com.jtzx.crm.module.sys.entity.SysUserEntity;
 import com.jtzx.crm.module.sys.mapper.SysCustomerDataMapper;
 import com.jtzx.crm.module.sys.mapper.SysParamBaseDataMapper;
+import com.jtzx.crm.module.sys.mapper.SysUserMapper;
 import com.jtzx.crm.module.sys.model.request.*;
 import com.jtzx.crm.module.sys.model.response.*;
 import lombok.RequiredArgsConstructor;
@@ -52,6 +56,8 @@ public class SysCustomerDataPublicService {
 
     private final SysCustomerDataPermissionService permissionService;
 
+    private final SysUserMapper sysUserMapper;
+
     /**
      * 查询公海客户页面顶部筛选条件数据
      *
@@ -64,7 +70,7 @@ public class SysCustomerDataPublicService {
         //学段信息
         resultData.setStageData(sysCustomerUserCommonService.handleStageData());
         //省市信息
-        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType1( false);
+        SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType1(false);
         if (sysCustomerSelectBO != null) {
             resultData.setRegionData(sysCustomerSelectBO.getRegionData());
         }
@@ -90,7 +96,7 @@ public class SysCustomerDataPublicService {
                         // 城市id(不为空时)
                         .eq(Objects.nonNull(dto.getCityId()), SysCustomerDataEntity::getCityId, dto.getCityId())
                         // 城市id(为空时)
-                        .in(Objects.isNull(dto.getCityId())&&dto.getProvinceId()!=null, SysCustomerDataEntity::getCityId, sysCustomerUserCommonService.queryUserCityIds(dto.getProvinceId()))
+                        .in(Objects.isNull(dto.getCityId()) && dto.getProvinceId() != null, SysCustomerDataEntity::getCityId, sysCustomerUserCommonService.queryUserCityIds(dto.getProvinceId()))
                         //认领状态
                         .eq(SysCustomerDataEntity::getClaimStatus, 0)
                         // 排序
@@ -194,19 +200,33 @@ public class SysCustomerDataPublicService {
      *
      * @param dto
      */
-    public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) {
+    public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) throws BusinessException {
         permissionService.publicPrivateCustomerPermission();
         SysCustomerDetailBO detailBO = SysCustomerDetailBO.builder().build();
-        //顶部筛选条件数据
-        SysCustomerFollowHistorySelectBO publicCustomerSelectData = sysCustomerDataFollowService.queryCustomerFollowSelectCommonData(dto.getCustomerId(), null);
-        detailBO.setSelectData(publicCustomerSelectData);
-        //客户详情信息
-        PageResult<SysCustomerFollowListBO> dataPageList = sysCustomerDataFollowService.queryCustomerFollowDataCommonByPage(dto);
-        detailBO.setDataPageList(dataPageList);
-        //信息总览
-        detailBO.setProductOverviewData(sysCustomerFollowService.queryProductOverViewData(dto.getCustomerId(),null));
-        //跟进记录总览
-        detailBO.setFollowOverViewData(sysCustomerFollowService.handleCustomerFollowOverViewData(dto.getCustomerId(), null));
+        SysUserEntity sysUserEntity = sysUserMapper.selectById(UserContextHolder.getUserId());
+        if (sysUserEntity == null) {
+            throw new BusinessException("用户不存在");
+        }
+        dto.setUserId(null);
+
+        detailBO.setHistoryFollowStatus(sysUserEntity.getHistoryFollowStatus() == null ? 0 : sysUserEntity.getHistoryFollowStatus());
+        if(UserContextHolder.getUserContext().getRoles().contains("Admin")){
+            detailBO.setHistoryFollowStatus(1);
+        }
+        //历史跟进总览开关
+        if (UserContextHolder.getUserContext().getRoles().contains("Admin") ||
+                sysUserEntity.getHistoryFollowStatus() != null && sysUserEntity.getHistoryFollowStatus() == 1) {
+            //顶部筛选条件数据
+            SysCustomerFollowHistorySelectBO publicCustomerSelectData = sysCustomerDataFollowService.queryCustomerFollowSelectCommonData(dto.getCustomerId(), null);
+            detailBO.setSelectData(publicCustomerSelectData);
+            //客户详情信息
+            PageResult<SysCustomerFollowListBO> dataPageList = sysCustomerDataFollowService.queryCustomerFollowDataCommonByPage(dto);
+            detailBO.setDataPageList(dataPageList);
+            //信息总览
+            detailBO.setProductOverviewData(sysCustomerFollowService.queryProductOverViewData(dto.getCustomerId(), null));
+            //跟进记录总览
+            detailBO.setFollowOverViewData(sysCustomerFollowService.handleCustomerFollowOverViewData(dto.getCustomerId(), null));
+        }
         return detailBO;
     }
 
@@ -223,7 +243,7 @@ public class SysCustomerDataPublicService {
         if (dto.getGroupId() != null) {
             groupIds.add(dto.getGroupId());
         }
-        return sysCustomerOperLogService.adminList(dto,userIds, groupIds,false, false);
+        return sysCustomerOperLogService.adminList(dto, userIds, groupIds, false, false);
     }
 
 

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

@@ -62,9 +62,19 @@ public class SysCustomerDataService {
      * 后台管理-新增
      */
     @Transactional(rollbackFor = Exception.class)
-    public Long adminInsert(AdminSysCustomerDataInsertOrUpdateDTO dto) {
+    public Long adminInsert(AdminSysCustomerDataInsertOrUpdateDTO dto) throws BusinessException {
         log.info("[后台管理-客户(学校)数据-新增] >> DTO={}", dto);
-
+        long count =
+                sysCustomerDataMapper.selectCount(
+                        new LambdaQueryWrapper<SysCustomerDataEntity>()
+                                .select(
+                                        SysCustomerDataEntity::getId
+                                )
+                                .eq(SysCustomerDataEntity::getName, dto.getName())
+                );
+        if (count > 0) {
+            throw new BusinessException(400, "添加失败,已存在相同名称学校");
+        }
         dto.setId(null);
         SysCustomerDataEntity entity = new SysCustomerDataEntity();
         BeanUtil.copyProperties(dto, entity);
@@ -95,8 +105,20 @@ public class SysCustomerDataService {
      * 后台管理-编辑
      */
     @Transactional(rollbackFor = Exception.class)
-    public void adminUpdate(AdminSysCustomerDataInsertOrUpdateDTO dto) {
+    public void adminUpdate(AdminSysCustomerDataInsertOrUpdateDTO dto) throws BusinessException {
         log.info("[后台管理-客户(学校)数据-编辑] >> DTO={}", dto);
+        long count =
+                sysCustomerDataMapper.selectCount(
+                        new LambdaQueryWrapper<SysCustomerDataEntity>()
+                                .select(
+                                        SysCustomerDataEntity::getId
+                                )
+                                .eq(SysCustomerDataEntity::getName, dto.getName())
+                                .ne(SysCustomerDataEntity::getId, dto.getId())
+                );
+        if (count > 0) {
+            throw new BusinessException(400, "编辑失败,已存在相同名称学校");
+        }
         SysCustomerDataEntity entity = sysCustomerDataMapper.selectById(dto.getId());
         if (entity == null) {
             throw new BusinessException(400, "无效客户(学校)数据ID");
@@ -305,7 +327,7 @@ public class SysCustomerDataService {
         sysCustomerDataEntity.setClaimUserGroupId(groupRelationEntity.getGroupId());
         sysCustomerDataEntity.setClaimUserName(sysUserEntity.getUserName());
         sysCustomerDataEntity.setClaimUserId(sysUserEntity.getId());
-        if(sysCustomerDataEntity.getSuccessStatus()==null){
+        if (sysCustomerDataEntity.getSuccessStatus() == null) {
             sysCustomerDataEntity.setSuccessStatus(0);
         }
         if (sysCustomerDataEntity.getSuccessStatus() == 0) {
@@ -318,7 +340,7 @@ public class SysCustomerDataService {
         }
         sysCustomerDataMapper.updateById(sysCustomerDataEntity);
 
-        String content = "将【" + sysCustomerDataEntity.getName() + "】归属人【" + oldUserName + "】,【" +sysUserEntity.getUserName()+ "】";
+        String content = "将【" + sysCustomerDataEntity.getName() + "】归属人【" + oldUserName + "】,【" + sysUserEntity.getUserName() + "】";
         //添加认领日志
         SysCustomerOperLogEntity logEntity = SysCustomerOperLogEntity.builder()
                 .customerId(sysCustomerDataEntity.getId())

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

@@ -69,8 +69,22 @@ public class SysCustomerFollowService {
         this.handleParams(dto);
         SysCustomerFollowEntity entity = new SysCustomerFollowEntity();
         BeanUtil.copyProperties(dto, entity);
-        entity.setOrderStatus(0);
-        entity.setOrderDatetime(dto.getOrderDatetime());
+        entity.setOrderDatetime(null);
+        if (dto.getOrderType() != null) {
+            if (dto.getOrderDatetime() == null) {
+                if (dto.getOrderType() == 0) {
+                    throw new BusinessException("请选择预约时间");
+                }
+                if (dto.getOrderType() == 1) {
+                    throw new BusinessException("请选择待办时间");
+                }
+            }
+            entity.setOrderStatus(0);
+            if (!dto.getOrderDatetime().isAfter(LocalDateTime.now())) {
+                entity.setOrderStatus(1);
+            }
+            entity.setOrderDatetime(dto.getOrderDatetime());
+        }
         sysCustomerFollowMapper.insert(entity);
         dto.setId(entity.getId());
         if (dto.getFollowId() == 37) {
@@ -79,11 +93,6 @@ public class SysCustomerFollowService {
         }
 
         if (dto.getOrderType() != null && dto.getOrderType() == 0 && dto.getOrderDatetime() != null) {
-
-//            if (!dto.getOrderDatetime().isAfter(LocalDateTime.now())) {
-//                entity.setOrderStatus(1);
-//            }
-//            sysCustomerFollowMapper.updateById(entity);
             LocalDateTime now = LocalDateTime.now();
             if (dto.getOrderDatetime().isAfter(now)) {
                 //发送定时任务,时间到之后改为已结束
@@ -224,14 +233,13 @@ public class SysCustomerFollowService {
     }
 
 
-
     /**
      * 查询我的客户状态信息总览
      *
      * @param customerId
      * @return
      */
-    public List<CustomerStatusOverViewBO> queryStatusOverViewData(Long customerId,Long userId) {
+    public List<CustomerStatusOverViewBO> queryStatusOverViewData(Long customerId, Long userId) {
 
         List<CustomerStatusOverViewBO> productOverViewBOList = new ArrayList<>();
         List<SysCustomerFollowEntity> followEntityList =
@@ -369,7 +377,7 @@ public class SysCustomerFollowService {
      * @param dto
      */
     @Transactional(rollbackFor = Exception.class)
-    public void handleParams(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException{
+    public void handleParams(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException {
         //处理联系人
         SysCustomerPersonEntity sysCustomerPersonEntity = sysCustomerPersonMapper.selectOne(
                 new LambdaQueryWrapper<SysCustomerPersonEntity>()
@@ -474,7 +482,7 @@ public class SysCustomerFollowService {
      *
      */
     @Transactional(rollbackFor = Exception.class)
-    public void addFollowAuditData(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException{
+    public void addFollowAuditData(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException {
         //先查询管理员数据
         List<SysUserRoleRelationEntity> adminUserList =
                 sysUserRoleRelationMapper.selectList(