Explorar el Código

refactor(service): 优化客户跟进服务异常处理

- 统一抛出 BusinessException 异常,提升异常管理一致性
- 调整 SysCustomerFollowService 中相关方法的异常声明
- 修正部分 Lambda 表达式格式,增加代码可读性
- 优化 SysCustomerFollowMapper 接口方法声明,简化代码风格
- 删除 SysCustomerTodoService 中未使用的导入,清理冗余代码
zhangxf hace 1 mes
padre
commit
5e8f7e67a7

+ 1 - 1
src/main/java/com/jtzx/crm/module/sys/mapper/SysCustomerFollowMapper.java

@@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Param;
 @Mapper
 public interface SysCustomerFollowMapper extends BaseMapper<SysCustomerFollowEntity> {
 
-    public void cancelTodoStatus(@Param("id") Long id);
+    void cancelTodoStatus(@Param("id") Long id);
 }

+ 9 - 8
src/main/java/com/jtzx/crm/module/sys/service/SysCustomerFollowService.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 cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
@@ -61,7 +62,7 @@ public class SysCustomerFollowService {
      * 后台管理-新增
      */
     @Transactional(rollbackFor = Exception.class)
-    public void adminInsert(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
+    public void adminInsert(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException {
         log.info("[后台管理-客户跟进数据信息-新增] >> DTO={}", dto);
         permissionService.publicPrivateCustomerPermission();
         dto.setId(null);
@@ -100,7 +101,7 @@ public class SysCustomerFollowService {
     /**
      * 我的客户页面,预约待办列表去消预约操作
      */
-    public void cancelOrder(CannelOrderDTO dto,Boolean privateStatus) {
+    public void cancelOrder(CannelOrderDTO dto, Boolean privateStatus) {
         if (privateStatus) {
             permissionService.publicPrivateCustomerPermission();
         }
@@ -237,7 +238,7 @@ public class SysCustomerFollowService {
                 sysCustomerFollowMapper.selectList(
                         new LambdaQueryWrapper<>(SysCustomerFollowEntity.class)
                                 .eq(SysCustomerFollowEntity::getCustomerId, customerId)
-                                .eq(userId!=null,SysCustomerFollowEntity::getClaimUserId, userId)
+                                .eq(userId != null, SysCustomerFollowEntity::getClaimUserId, userId)
                 );
         if (CollUtil.isNotEmpty(followEntityList)) {
             List<Long> productIdList = followEntityList.stream()
@@ -296,7 +297,7 @@ public class SysCustomerFollowService {
                 sysCustomerFollowMapper.selectList(
                         new LambdaQueryWrapper<>(SysCustomerFollowEntity.class)
                                 .eq(SysCustomerFollowEntity::getCustomerId, customerId)
-                                .eq(userId!=null,SysCustomerFollowEntity::getClaimUserId, userId)
+                                .eq(userId != null, SysCustomerFollowEntity::getClaimUserId, userId)
                                 .eq(SysCustomerFollowEntity::getOrderStatus, 0)//待开始的
                                 .isNotNull(SysCustomerFollowEntity::getOrderType)//预约待办不能为空的
                                 .orderByDesc(SysCustomerFollowEntity::getCreatedAt)
@@ -319,7 +320,7 @@ public class SysCustomerFollowService {
      * @param dto
      */
     @Transactional(rollbackFor = Exception.class)
-    public void handleParams(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
+    public void handleParams(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException{
         //处理联系人
         SysCustomerPersonEntity sysCustomerPersonEntity = sysCustomerPersonMapper.selectOne(
                 new LambdaQueryWrapper<SysCustomerPersonEntity>()
@@ -424,7 +425,7 @@ public class SysCustomerFollowService {
      *
      */
     @Transactional(rollbackFor = Exception.class)
-    public void addFollowAuditData(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
+    public void addFollowAuditData(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException{
         //先查询管理员数据
         List<SysUserRoleRelationEntity> adminUserList =
                 sysUserRoleRelationMapper.selectList(
@@ -448,7 +449,7 @@ public class SysCustomerFollowService {
             throw new RuntimeException("参数错误,管理员不存在");
         }
         adminUserList.forEach(adminUser -> {
-            SysCustomerFollowAuditEntity entity =this.getFollowAuditEntity(dto);
+            SysCustomerFollowAuditEntity entity = this.getFollowAuditEntity(dto);
             entity.setAuditUserId(adminUser.getUserId()); // 设置审核人id
             sysUserEntities.stream()
                     .filter(x -> x.getId().equals(adminUser.getUserId()))
@@ -491,7 +492,7 @@ public class SysCustomerFollowService {
      */
 
     @Transactional(rollbackFor = Exception.class)
-    public void checkParam(AdminSysCustomerFollowInsertOrUpdateDTO dto) {
+    public void checkParam(AdminSysCustomerFollowInsertOrUpdateDTO dto) throws BusinessException {
 
         if (dto.getCustomerId() == null) {
             throw new RuntimeException("参数错误,客户不能为空");

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

@@ -1,7 +1,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.crud.entity.HelioBaseEntity;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;