|
|
@@ -552,13 +552,16 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
|
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.getEnterpriseTypeId() != null) enterpriseTypeIds.add(vo.getEnterpriseTypeId());
|
|
|
if (vo.getCustomerLevelId() != null) customerLevelIds.add(vo.getCustomerLevelId());
|
|
|
- if (vo.getBelongingDepartmentId() != null) deptIds.add(vo.getBelongingDepartmentId());
|
|
|
});
|
|
|
|
|
|
// 1. 批量查询业务员和客服名称 (远程调用)
|
|
|
@@ -596,13 +599,19 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
// 8. 填充数据
|
|
|
records.forEach(vo -> {
|
|
|
- vo.setSalesPersonName(staffMap.get(vo.getSalesPersonId()));
|
|
|
- vo.setServiceStaffName(staffMap.get(vo.getServiceStaffId()));
|
|
|
+ if (StringUtils.isBlank(vo.getSalesPersonName())) {
|
|
|
+ vo.setSalesPersonName(staffMap.get(vo.getSalesPersonId()));
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(vo.getServiceStaffName())) {
|
|
|
+ vo.setServiceStaffName(staffMap.get(vo.getServiceStaffId()));
|
|
|
+ }
|
|
|
vo.setCreditLevelName(creditLevelMap.get(vo.getCreditLevelId()));
|
|
|
vo.setCompanyName(companyMap.get(vo.getBelongCompanyId()));
|
|
|
vo.setEnterpriseTypeName(enterpriseTypeMap.get(vo.getEnterpriseTypeId()));
|
|
|
vo.setCustomerLevelName(customerLevelMap.get(vo.getCustomerLevelId()));
|
|
|
- vo.setDeptName(deptMap.get(vo.getBelongingDepartmentId()));
|
|
|
+ if (StringUtils.isBlank(vo.getDeptName())) {
|
|
|
+ vo.setDeptName(deptMap.get(vo.getBelongingDepartmentId()));
|
|
|
+ }
|
|
|
vo.setCooperationName(cooperationMap.get(vo.getStatus()));
|
|
|
});
|
|
|
}
|
|
|
@@ -1338,8 +1347,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
@@ -1438,6 +1446,12 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
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)
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1504,27 +1518,33 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean claimPool(CustomerClaimBo claimBo) {
|
|
|
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");
|
|
|
- return customerSalesInfoMapper.insert(salesInfo) > 0;
|
|
|
- }
|
|
|
-
|
|
|
- // 更新销售负责人和客服
|
|
|
+ // 认领操作仅更新客户主表,不再涉及到销售信息表
|
|
|
CustomerInfo customer = new CustomerInfo();
|
|
|
customer.setId(customerId);
|
|
|
customer.setSalesPersonId(claimBo.getSalesPersonId());
|
|
|
customer.setServiceStaffId(claimBo.getServiceStaffId());
|
|
|
+ customer.setBelongingDepartmentId(claimBo.getDeptId());
|
|
|
customer.setStatus("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
|
|
|
public CustomerInfoVo selectCustomerByName(String customerName) {
|
|
|
return baseMapper.selectVoOne(new LambdaQueryWrapper<CustomerInfo>().eq(CustomerInfo::getCustomerName, customerName));
|