Sfoglia il codice sorgente

feat(customer): 新增客户业务人员和客服人员转移功能

- 在CustomerInfoController中新增transferSalesPerson接口用于转移业务人员
- 在CustomerInfoController中新增transferServiceStaff接口用于转移客服人员
- 在CustomerInfoService接口中定义transferSalesPerson和transferServiceStaff方法
- 在CustomerInfoServiceImpl中实现业务人员转移逻辑,包括参数校验和批量更新
- 在CustomerInfoServiceImpl中实现客服人员转移逻辑,包括参数校验和批量更新
- 扩展SetCustomerInfoTagDto数据传输对象,添加deptId、salesPersonId和serviceStaffId字段
- 优化订单评价服务层代码结构,调整import顺序和类组织方式
hurx 1 mese fa
parent
commit
d87f49bf45

+ 39 - 21
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/controller/CustomerInfoController.java

@@ -1,33 +1,33 @@
 package org.dromara.customer.controller;
 package org.dromara.customer.controller;
 
 
-import java.util.Collection;
-import java.util.List;
-
-import lombok.RequiredArgsConstructor;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.servlet.http.HttpServletResponse;
-import jakarta.validation.constraints.*;
-import cn.dev33.satoken.annotation.SaCheckPermission;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.domain.R;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.core.utils.StringUtils;
-import org.dromara.customer.domain.CustomerSalesInfo;
-import org.dromara.customer.domain.bo.CustomerSalesInfoBo;
-import org.dromara.customer.domain.bo.CustomerListBo;
-import org.dromara.customer.domain.bo.MessagePublishCustomerBo;
-import org.dromara.customer.domain.dto.SetCustomerInfoTagDto;
-import org.dromara.customer.domain.vo.*;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.validation.annotation.Validated;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.excel.utils.ExcelUtil;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
 import org.dromara.common.log.annotation.Log;
 import org.dromara.common.log.annotation.Log;
-import org.dromara.common.web.core.BaseController;
-import org.dromara.common.mybatis.core.page.PageQuery;
-import org.dromara.common.core.domain.R;
-import org.dromara.common.core.validate.AddGroup;
-import org.dromara.common.core.validate.EditGroup;
 import org.dromara.common.log.enums.BusinessType;
 import org.dromara.common.log.enums.BusinessType;
-import org.dromara.common.excel.utils.ExcelUtil;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.web.core.BaseController;
 import org.dromara.customer.domain.bo.CustomerInfoBo;
 import org.dromara.customer.domain.bo.CustomerInfoBo;
+import org.dromara.customer.domain.bo.CustomerListBo;
+import org.dromara.customer.domain.bo.CustomerSalesInfoBo;
+import org.dromara.customer.domain.bo.MessagePublishCustomerBo;
+import org.dromara.customer.domain.dto.SetCustomerInfoTagDto;
+import org.dromara.customer.domain.vo.ContractVo;
+import org.dromara.customer.domain.vo.CustomerInfoVo;
+import org.dromara.customer.domain.vo.CustomerListVo;
+import org.dromara.customer.domain.vo.MessagePublishCustomerVo;
 import org.dromara.customer.service.ICustomerInfoService;
 import org.dromara.customer.service.ICustomerInfoService;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 
 /**
 /**
  * 客户信息
  * 客户信息
@@ -184,4 +184,22 @@ public class CustomerInfoController extends BaseController {
     public R<Void> setCustomerInfoTag(@RequestBody SetCustomerInfoTagDto bo) {
     public R<Void> setCustomerInfoTag(@RequestBody SetCustomerInfoTagDto bo) {
         return toAjax(customerInfoService.setCustomerInfoTag(bo.getCustomerIds(), bo.getTagIds()));
         return toAjax(customerInfoService.setCustomerInfoTag(bo.getCustomerIds(), bo.getTagIds()));
     }
     }
+
+    /**
+     * 转移业务人员
+     */
+    @Log(title = "客户信息", businessType = BusinessType.UPDATE)
+    @PutMapping("/transferSalesPerson")
+    public R<Integer> transferSalesPerson(@RequestBody SetCustomerInfoTagDto bo) {
+        return R.ok(customerInfoService.transferSalesPerson(bo.getCustomerIds(), bo.getSalesPersonId(), bo.getDeptId()));
+    }
+
+    /**
+     * 转移客服人员
+     */
+    @Log(title = "客户信息", businessType = BusinessType.UPDATE)
+    @PutMapping("/transferServiceStaff")
+    public R<Integer> transferServiceStaff(@RequestBody SetCustomerInfoTagDto bo) {
+        return R.ok(customerInfoService.transferServiceStaff(bo.getCustomerIds(), bo.getServiceStaffId()));
+    }
 }
 }

+ 6 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/domain/dto/SetCustomerInfoTagDto.java

@@ -10,4 +10,10 @@ public class SetCustomerInfoTagDto implements Serializable {
     private List<Long> customerIds;
     private List<Long> customerIds;
 
 
     private List<Long> tagIds;
     private List<Long> tagIds;
+
+    private Long deptId;
+
+    private Long salesPersonId;
+
+    private Long serviceStaffId;
 }
 }

+ 14 - 4
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/ICustomerInfoService.java

@@ -1,14 +1,17 @@
 package org.dromara.customer.service;
 package org.dromara.customer.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.customer.domain.CustomerInfo;
 import org.dromara.customer.domain.CustomerInfo;
+import org.dromara.customer.domain.bo.CustomerInfoBo;
 import org.dromara.customer.domain.bo.CustomerListBo;
 import org.dromara.customer.domain.bo.CustomerListBo;
 import org.dromara.customer.domain.bo.CustomerRegisterBo;
 import org.dromara.customer.domain.bo.CustomerRegisterBo;
 import org.dromara.customer.domain.bo.MessagePublishCustomerBo;
 import org.dromara.customer.domain.bo.MessagePublishCustomerBo;
-import org.dromara.customer.domain.vo.*;
-import org.dromara.customer.domain.bo.CustomerInfoBo;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
-import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.customer.domain.vo.ContractVo;
+import org.dromara.customer.domain.vo.CustomerInfoVo;
+import org.dromara.customer.domain.vo.CustomerListVo;
+import org.dromara.customer.domain.vo.MessagePublishCustomerVo;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.Collection;
@@ -112,6 +115,13 @@ public interface ICustomerInfoService extends IService<CustomerInfo> {
     /*设置客户标签*/
     /*设置客户标签*/
     int setCustomerInfoTag(List<Long> customerIds, List<Long> tagIds);
     int setCustomerInfoTag(List<Long> customerIds, List<Long> tagIds);
 
 
+    /*客户转移业务人员*/
+    int transferSalesPerson(List<Long> customerIds, Long salesPersonId, Long deptId);
+
+    /*客户转移客服人员*/
+    int transferServiceStaff(List<Long> customerIds, Long serviceStaffId);
+
+
     Map<Long, String> selectCustomerNameByIds(Set<Long> ids);
     Map<Long, String> selectCustomerNameByIds(Set<Long> ids);
 
 
     /**
     /**

+ 105 - 0
ruoyi-modules/ruoyi-customer/src/main/java/org/dromara/customer/service/impl/CustomerInfoServiceImpl.java

@@ -1051,4 +1051,109 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
         log.info("客户注册成功,客户ID:{},客户名称:{}", customerId, bo.getCustomerName());
         log.info("客户注册成功,客户ID:{},客户名称:{}", customerId, bo.getCustomerName());
         return true;
         return true;
     }
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int transferSalesPerson(List<Long> customerIds, Long salesPersonId, Long deptId) {
+        if (CollUtil.isEmpty(customerIds)) {
+            log.warn("转移业务人员失败,客户 ID 列表为空");
+            return 0;
+        }
+
+        if (salesPersonId == null || deptId == null) {
+            log.warn("转移业务人员失败,业务人员 ID 或部门 ID 为空");
+            throw new ServiceException("业务人员和所属部门不能为空");
+        }
+
+        try {
+            List<CustomerSalesInfo> updateList = new ArrayList<>();
+            CustomerSalesInfo salesInfo = null;
+            for (Long customerId : customerIds) {
+                if (customerId == null) {
+                    continue;
+                }
+
+                salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
+                if (salesInfo != null) {
+                    salesInfo.setSalesPersonId(salesPersonId);
+                    salesInfo.setBelongingDepartmentId(deptId);
+                    updateList.add(salesInfo);
+                } else {
+                    log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
+                }
+            }
+
+            if (!updateList.isEmpty()) {
+                boolean success = customerSalesInfoMapper.updateBatchById(updateList);
+                if (success) {
+                    log.info("成功转移 {} 个客户的业务人员,目标业务员 ID: {}, 部门 ID: {}",
+                        updateList.size(), salesPersonId, deptId);
+                    return updateList.size();
+                } else {
+                    log.error("批量更新销售信息失败");
+                    throw new ServiceException("批量更新销售信息失败");
+                }
+            }
+
+            log.info("没有需要更新的客户销售信息");
+            return 0;
+
+        } catch (Exception e) {
+            log.error("转移业务人员失败,客户 IDs: {}, 业务员 ID: {}, 部门 ID: {}, 错误:{}",
+                customerIds, salesPersonId, deptId, e.getMessage(), e);
+            throw new ServiceException("转移业务人员失败:" + e.getMessage());
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int transferServiceStaff(List<Long> customerIds, Long serviceStaffId) {
+        if (CollUtil.isEmpty(customerIds)) {
+            log.warn("转移客服人员失败,客户 ID 列表为空");
+            return 0;
+        }
+
+        if (serviceStaffId == null) {
+            log.warn("转移客服人员失败,客服人员 ID 为空");
+            throw new ServiceException("客服人员和不能为空");
+        }
+
+        try {
+            List<CustomerSalesInfo> updateList = new ArrayList<>();
+            CustomerSalesInfo salesInfo = null;
+            for (Long customerId : customerIds) {
+                if (customerId == null) {
+                    continue;
+                }
+
+                salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
+                if (salesInfo != null) {
+                    salesInfo.setServiceStaffId(serviceStaffId);
+                    updateList.add(salesInfo);
+                } else {
+                    log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
+                }
+            }
+
+            if (!updateList.isEmpty()) {
+                boolean success = customerSalesInfoMapper.updateBatchById(updateList);
+                if (success) {
+                    log.info("成功转移 {} 个客户的客服人员,目标客服人员 ID: {}",
+                        updateList.size(), serviceStaffId);
+                    return updateList.size();
+                } else {
+                    log.error("批量更新销售信息失败");
+                    throw new ServiceException("批量更新销售信息失败");
+                }
+            }
+
+            log.info("没有需要更新的客户销售信息");
+            return 0;
+
+        } catch (Exception e) {
+            log.error("转移客服人员失败,客户 IDs: {}, 客服人员 ID: {},  错误:{}",
+                customerIds, serviceStaffId, e.getMessage(), e);
+            throw new ServiceException("转移客服人员失败:" + e.getMessage());
+        }
+    }
 }
 }

+ 3 - 3
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/IOrderEvaluationHeaderService.java

@@ -1,11 +1,11 @@
 package org.dromara.order.service;
 package org.dromara.order.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.order.domain.OrderEvaluationHeader;
 import org.dromara.order.domain.OrderEvaluationHeader;
-import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
 import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
 import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
-import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
 import org.dromara.order.domain.vo.OrderEvaluationListVo;
 import org.dromara.order.domain.vo.OrderEvaluationListVo;
 
 
 import java.util.Collection;
 import java.util.Collection;

+ 11 - 12
ruoyi-modules/ruoyi-order/src/main/java/org/dromara/order/service/impl/OrderEvaluationHeaderServiceImpl.java

@@ -1,35 +1,34 @@
 package org.dromara.order.service.impl;
 package org.dromara.order.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.core.utils.StringUtils;
-import org.dromara.common.mybatis.core.page.TableDataInfo;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.PageQuery;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.order.domain.OrderEvaluationHeader;
 import org.dromara.order.domain.OrderEvaluationItem;
 import org.dromara.order.domain.OrderEvaluationItem;
 import org.dromara.order.domain.OrderMain;
 import org.dromara.order.domain.OrderMain;
 import org.dromara.order.domain.OrderProduct;
 import org.dromara.order.domain.OrderProduct;
+import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
 import org.dromara.order.domain.bo.OrderEvaluationItemBo;
 import org.dromara.order.domain.bo.OrderEvaluationItemBo;
+import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
 import org.dromara.order.domain.vo.OrderEvaluationItemVo;
 import org.dromara.order.domain.vo.OrderEvaluationItemVo;
 import org.dromara.order.domain.vo.OrderEvaluationListVo;
 import org.dromara.order.domain.vo.OrderEvaluationListVo;
 import org.dromara.order.domain.vo.OrderProductBriefVo;
 import org.dromara.order.domain.vo.OrderProductBriefVo;
+import org.dromara.order.mapper.OrderEvaluationHeaderMapper;
 import org.dromara.order.mapper.OrderEvaluationItemMapper;
 import org.dromara.order.mapper.OrderEvaluationItemMapper;
 import org.dromara.order.mapper.OrderMainMapper;
 import org.dromara.order.mapper.OrderMainMapper;
 import org.dromara.order.mapper.OrderProductMapper;
 import org.dromara.order.mapper.OrderProductMapper;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-import org.dromara.order.domain.bo.OrderEvaluationHeaderBo;
-import org.dromara.order.domain.vo.OrderEvaluationHeaderVo;
-import org.dromara.order.domain.OrderEvaluationHeader;
-import org.dromara.order.mapper.OrderEvaluationHeaderMapper;
 import org.dromara.order.service.IOrderEvaluationHeaderService;
 import org.dromara.order.service.IOrderEvaluationHeaderService;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
 import java.util.*;
 import java.util.*;