|
@@ -499,13 +499,16 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
|
|
|
records.forEach(vo -> {
|
|
records.forEach(vo -> {
|
|
|
- if (vo.getSalesPersonId() != null) staffIds.add(vo.getSalesPersonId());
|
|
|
|
|
- if (vo.getServiceStaffId() != null) staffIds.add(vo.getServiceStaffId());
|
|
|
|
|
- if (vo.getCreditLevelId() != null) creditLevelIds.add(vo.getCreditLevelId());
|
|
|
|
|
|
|
+ // 如果是公海客户,不处理销售ERP相关内容(负责人、客服、部门、信用等级)
|
|
|
|
|
+ if (!"true".equals(bo.getIsHighSeas())) {
|
|
|
|
|
+ if (vo.getSalesPersonId() != null) staffIds.add(vo.getSalesPersonId());
|
|
|
|
|
+ if (vo.getServiceStaffId() != null) staffIds.add(vo.getServiceStaffId());
|
|
|
|
|
+ if (vo.getBelongingDepartmentId() != null) deptIds.add(vo.getBelongingDepartmentId());
|
|
|
|
|
+ if (vo.getCreditLevelId() != null) creditLevelIds.add(vo.getCreditLevelId());
|
|
|
|
|
+ }
|
|
|
if (vo.getBelongCompanyId() != null) companyIds.add(vo.getBelongCompanyId());
|
|
if (vo.getBelongCompanyId() != null) companyIds.add(vo.getBelongCompanyId());
|
|
|
if (vo.getEnterpriseTypeId() != null) enterpriseTypeIds.add(vo.getEnterpriseTypeId());
|
|
if (vo.getEnterpriseTypeId() != null) enterpriseTypeIds.add(vo.getEnterpriseTypeId());
|
|
|
if (vo.getCustomerLevelId() != null) customerLevelIds.add(vo.getCustomerLevelId());
|
|
if (vo.getCustomerLevelId() != null) customerLevelIds.add(vo.getCustomerLevelId());
|
|
|
- if (vo.getBelongingDepartmentId() != null) deptIds.add(vo.getBelongingDepartmentId());
|
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 1. 批量查询业务员和客服名称 (远程调用)
|
|
// 1. 批量查询业务员和客服名称 (远程调用)
|
|
@@ -1232,102 +1235,31 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int transferSalesPerson(List<Long> customerIds, Long salesPersonId, Long deptId) {
|
|
public int transferSalesPerson(List<Long> customerIds, Long salesPersonId, Long deptId) {
|
|
|
- if (CollUtil.isEmpty(customerIds)) {
|
|
|
|
|
- log.warn("转移业务人员失败,客户 ID 列表为空");
|
|
|
|
|
|
|
+ if (CollUtil.isEmpty(customerIds) || salesPersonId == null) {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (salesPersonId == null || deptId == null) {
|
|
|
|
|
- log.warn("转移业务人员失败,业务人员 ID 或部门 ID 为空");
|
|
|
|
|
- throw new ServiceException("业务人员和所属部门不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- List<CustomerInfo> updateList = new ArrayList<>();
|
|
|
|
|
- for (Long customerId : customerIds) {
|
|
|
|
|
- if (customerId == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- CustomerInfo customerInfo = baseMapper.selectById(customerId);
|
|
|
|
|
- if (customerInfo != null) {
|
|
|
|
|
- customerInfo.setSalesPersonId(salesPersonId);
|
|
|
|
|
- customerInfo.setBelongingDepartmentId(deptId);
|
|
|
|
|
- updateList.add(customerInfo);
|
|
|
|
|
- } else {
|
|
|
|
|
- log.warn("客户 ID: {} 不存在,跳过更新", customerId);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!updateList.isEmpty()) {
|
|
|
|
|
- boolean success = baseMapper.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());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 直接进行批量更新,不再循环查询
|
|
|
|
|
+ return baseMapper.update(null, new LambdaUpdateWrapper<CustomerInfo>()
|
|
|
|
|
+ .set(CustomerInfo::getSalesPersonId, salesPersonId)
|
|
|
|
|
+ // 如果传了部门ID则更新,没传则不更新
|
|
|
|
|
+ .set(deptId != null, CustomerInfo::getBelongingDepartmentId, deptId)
|
|
|
|
|
+ .in(CustomerInfo::getId, customerIds)
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int transferServiceStaff(List<Long> customerIds, Long serviceStaffId) {
|
|
public int transferServiceStaff(List<Long> customerIds, Long serviceStaffId) {
|
|
|
- if (CollUtil.isEmpty(customerIds)) {
|
|
|
|
|
- log.warn("转移客服人员失败,客户 ID 列表为空");
|
|
|
|
|
|
|
+ if (CollUtil.isEmpty(customerIds) || serviceStaffId == null) {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (serviceStaffId == null) {
|
|
|
|
|
- log.warn("转移客服人员失败,客服人员 ID 为空");
|
|
|
|
|
- throw new ServiceException("客服人员和不能为空");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- List<CustomerInfo> updateList = new ArrayList<>();
|
|
|
|
|
- for (Long customerId : customerIds) {
|
|
|
|
|
- if (customerId == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- CustomerInfo customerInfo = baseMapper.selectById(customerId);
|
|
|
|
|
- if (customerInfo != null) {
|
|
|
|
|
- customerInfo.setServiceStaffId(serviceStaffId);
|
|
|
|
|
- updateList.add(customerInfo);
|
|
|
|
|
- } else {
|
|
|
|
|
- log.warn("客户 ID: {} 不存在,跳过更新", customerId);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!updateList.isEmpty()) {
|
|
|
|
|
- boolean success = baseMapper.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());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 直接进行批量更新
|
|
|
|
|
+ return baseMapper.update(null, new LambdaUpdateWrapper<CustomerInfo>()
|
|
|
|
|
+ .set(CustomerInfo::getServiceStaffId, serviceStaffId)
|
|
|
|
|
+ .in(CustomerInfo::getId, customerIds)
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1392,34 +1324,33 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean claimPool(CustomerClaimBo claimBo) {
|
|
public Boolean claimPool(CustomerClaimBo claimBo) {
|
|
|
Long customerId = claimBo.getId();
|
|
Long customerId = claimBo.getId();
|
|
|
- CustomerSalesInfo salesInfo = customerSalesInfoMapper.selectOne(new LambdaQueryWrapper<CustomerSalesInfo>()
|
|
|
|
|
- .eq(CustomerSalesInfo::getCustomerId, customerId));
|
|
|
|
|
-
|
|
|
|
|
- if (salesInfo == null) {
|
|
|
|
|
- salesInfo = new CustomerSalesInfo();
|
|
|
|
|
- salesInfo.setCustomerId(customerId);
|
|
|
|
|
- salesInfo.setSalesPersonId(claimBo.getSalesPersonId());
|
|
|
|
|
- salesInfo.setServiceStaffId(claimBo.getServiceStaffId());
|
|
|
|
|
- salesInfo.setStatus("0");
|
|
|
|
|
- boolean insertResult = customerSalesInfoMapper.insert(salesInfo) > 0;
|
|
|
|
|
- CustomerInfo customer = new CustomerInfo();
|
|
|
|
|
- customer.setId(customerId);
|
|
|
|
|
- customer.setSalesPersonId(claimBo.getSalesPersonId());
|
|
|
|
|
- customer.setServiceStaffId(claimBo.getServiceStaffId());
|
|
|
|
|
- customer.setStatus("0");
|
|
|
|
|
- baseMapper.updateById(customer);
|
|
|
|
|
- return insertResult;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 更新销售负责人和客服
|
|
|
|
|
|
|
+ // 认领操作仅更新客户主表,不再涉及到销售信息表
|
|
|
CustomerInfo customer = new CustomerInfo();
|
|
CustomerInfo customer = new CustomerInfo();
|
|
|
customer.setId(customerId);
|
|
customer.setId(customerId);
|
|
|
customer.setSalesPersonId(claimBo.getSalesPersonId());
|
|
customer.setSalesPersonId(claimBo.getSalesPersonId());
|
|
|
customer.setServiceStaffId(claimBo.getServiceStaffId());
|
|
customer.setServiceStaffId(claimBo.getServiceStaffId());
|
|
|
|
|
+ customer.setBelongingDepartmentId(claimBo.getDeptId());
|
|
|
customer.setStatus("0"); // 认领成功后,将客户主表状态改为有效
|
|
customer.setStatus("0"); // 认领成功后,将客户主表状态改为有效
|
|
|
return baseMapper.updateById(customer) > 0;
|
|
return baseMapper.updateById(customer) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public int releaseToPool(List<Long> customerIds, String reason) {
|
|
|
|
|
+ if (customerIds == null || customerIds.isEmpty()) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 使用 LambdaUpdateWrapper 显式更新字段为 null,因为 updateById 默认忽略 null 值
|
|
|
|
|
+ return baseMapper.update(null, new LambdaUpdateWrapper<CustomerInfo>()
|
|
|
|
|
+ .set(CustomerInfo::getSalesPersonId, null)
|
|
|
|
|
+ .set(CustomerInfo::getServiceStaffId, null)
|
|
|
|
|
+ .set(CustomerInfo::getBelongingDepartmentId, null)
|
|
|
|
|
+ .set(CustomerInfo::getStatus, "1") // 标记为公海状态
|
|
|
|
|
+ .in(CustomerInfo::getId, customerIds)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public CustomerInfoVo selectCustomerByName(String customerName) {
|
|
public CustomerInfoVo selectCustomerByName(String customerName) {
|
|
|
return baseMapper.selectVoOne(new LambdaQueryWrapper<CustomerInfo>().eq(CustomerInfo::getCustomerName, customerName));
|
|
return baseMapper.selectVoOne(new LambdaQueryWrapper<CustomerInfo>().eq(CustomerInfo::getCustomerName, customerName));
|