|
@@ -142,14 +142,14 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
Set<Long> staffIds = new HashSet<>();
|
|
Set<Long> staffIds = new HashSet<>();
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
|
|
|
- if (customerSalesInfo.getSalesPersonId() != null) {
|
|
|
|
|
- staffIds.add(customerSalesInfo.getSalesPersonId());
|
|
|
|
|
|
|
+ if (vo.getSalesPersonId() != null) {
|
|
|
|
|
+ staffIds.add(vo.getSalesPersonId());
|
|
|
}
|
|
}
|
|
|
- if (customerSalesInfo.getServiceStaffId() != null) {
|
|
|
|
|
- staffIds.add(customerSalesInfo.getServiceStaffId());
|
|
|
|
|
|
|
+ if (vo.getServiceStaffId() != null) {
|
|
|
|
|
+ staffIds.add(vo.getServiceStaffId());
|
|
|
}
|
|
}
|
|
|
- if (customerSalesInfo.getBelongingDepartmentId() != null) {
|
|
|
|
|
- deptIds.add(customerSalesInfo.getBelongingDepartmentId());
|
|
|
|
|
|
|
+ if (vo.getBelongingDepartmentId() != null) {
|
|
|
|
|
+ deptIds.add(vo.getBelongingDepartmentId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Map<Long, String> staffMap = staffIds.isEmpty()
|
|
Map<Long, String> staffMap = staffIds.isEmpty()
|
|
@@ -165,9 +165,13 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
|
|
// 再补充名称
|
|
// 再补充名称
|
|
|
if (voObj != null) {
|
|
if (voObj != null) {
|
|
|
- voObj.setSalesPerson(staffMap.get(customerSalesInfo.getSalesPersonId()));
|
|
|
|
|
- voObj.setServiceStaff(staffMap.get(customerSalesInfo.getServiceStaffId()));
|
|
|
|
|
- voObj.setBelongingDepartment(deptMap.get(customerSalesInfo.getBelongingDepartmentId()));
|
|
|
|
|
|
|
+ vo.setSalesPersonName(staffMap.get(vo.getSalesPersonId()));
|
|
|
|
|
+ vo.setServiceStaffName(staffMap.get(vo.getServiceStaffId()));
|
|
|
|
|
+ vo.setBelongingDepartmentName(deptMap.get(vo.getBelongingDepartmentId()));
|
|
|
|
|
+
|
|
|
|
|
+ voObj.setSalesPerson(staffMap.get(vo.getSalesPersonId()));
|
|
|
|
|
+ voObj.setServiceStaff(staffMap.get(vo.getServiceStaffId()));
|
|
|
|
|
+ voObj.setBelongingDepartment(deptMap.get(vo.getBelongingDepartmentId()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
vo.setCustomerSalesInfoVo(voObj);
|
|
vo.setCustomerSalesInfoVo(voObj);
|
|
@@ -281,7 +285,8 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
Set<Long> staffIds = new HashSet<>();
|
|
Set<Long> staffIds = new HashSet<>();
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
|
|
|
- for (CustomerSalesInfoVo vo : salesInfoVos) {
|
|
|
|
|
|
|
+ // === 3. 提取人员和部门ID用于查询名称 ===
|
|
|
|
|
+ for (CustomerInfoVo vo : records) {
|
|
|
if (vo.getSalesPersonId() != null) staffIds.add(vo.getSalesPersonId());
|
|
if (vo.getSalesPersonId() != null) staffIds.add(vo.getSalesPersonId());
|
|
|
if (vo.getServiceStaffId() != null) staffIds.add(vo.getServiceStaffId());
|
|
if (vo.getServiceStaffId() != null) staffIds.add(vo.getServiceStaffId());
|
|
|
if (vo.getBelongingDepartmentId() != null) deptIds.add(vo.getBelongingDepartmentId());
|
|
if (vo.getBelongingDepartmentId() != null) deptIds.add(vo.getBelongingDepartmentId());
|
|
@@ -299,11 +304,11 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
? Collections.emptyMap()
|
|
? Collections.emptyMap()
|
|
|
: remoteErpDeptService.selectDeptNameByIds(deptIds);
|
|
: remoteErpDeptService.selectDeptNameByIds(deptIds);
|
|
|
|
|
|
|
|
- // === 6. 回填人员和部门名称到 salesInfoVo ===
|
|
|
|
|
- for (CustomerSalesInfoVo vo : salesInfoVos) {
|
|
|
|
|
- vo.setSalesPerson(staffMap.get(vo.getSalesPersonId()));
|
|
|
|
|
- vo.setServiceStaff(staffMap.get(vo.getServiceStaffId()));
|
|
|
|
|
- vo.setBelongingDepartment(deptMap.get(vo.getBelongingDepartmentId()));
|
|
|
|
|
|
|
+ // === 6. 回填人员和部门名称到 vo ===
|
|
|
|
|
+ for (CustomerInfoVo vo : records) {
|
|
|
|
|
+ vo.setSalesPersonName(staffMap.get(vo.getSalesPersonId()));
|
|
|
|
|
+ vo.setServiceStaffName(staffMap.get(vo.getServiceStaffId()));
|
|
|
|
|
+ vo.setBelongingDepartmentName(deptMap.get(vo.getBelongingDepartmentId()));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// === 7. 将销售信息回填到客户VO ===
|
|
// === 7. 将销售信息回填到客户VO ===
|
|
@@ -471,6 +476,15 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public TableDataInfo<CustomerListVo> queryCustomerListPage(CustomerListBo bo, PageQuery pageQuery) {
|
|
public TableDataInfo<CustomerListVo> queryCustomerListPage(CustomerListBo bo, PageQuery pageQuery) {
|
|
|
|
|
+ // 强制处理 isHighSeas 参数逻辑
|
|
|
|
|
+ Object isHighSeas = StringUtils.isNotBlank(bo.getIsHighSeas()) ? bo.getIsHighSeas() : bo.getParams().get("isHighSeas");
|
|
|
|
|
+ if (isHighSeas == null) {
|
|
|
|
|
+ // 如果没传,默认当做有效客户处理
|
|
|
|
|
+ bo.setIsHighSeas("false");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ bo.setIsHighSeas(String.valueOf(isHighSeas));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
Page<CustomerListVo> page = baseMapper.selectCustomerListPage(pageQuery.build(), bo);
|
|
Page<CustomerListVo> page = baseMapper.selectCustomerListPage(pageQuery.build(), bo);
|
|
|
|
|
|
|
|
// 补充业务员名称和信用等级名称
|
|
// 补充业务员名称和信用等级名称
|
|
@@ -582,8 +596,23 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getRegCityNo()), CustomerInfo::getRegCityNo, bo.getRegCityNo());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getRegCityNo()), CustomerInfo::getRegCityNo, bo.getRegCityNo());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getRegCountyNo()), CustomerInfo::getRegCountyNo, bo.getRegCountyNo());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getRegCountyNo()), CustomerInfo::getRegCountyNo, bo.getRegCountyNo());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getProvincialCityCounty()), CustomerInfo::getProvincialCityCounty, bo.getProvincialCityCounty());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getProvincialCityCounty()), CustomerInfo::getProvincialCityCounty, bo.getProvincialCityCounty());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getStatus()), CustomerInfo::getStatus, bo.getStatus());
|
|
|
|
|
|
|
+
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), CustomerInfo::getPlatformCode, bo.getPlatformCode());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), CustomerInfo::getPlatformCode, bo.getPlatformCode());
|
|
|
|
|
+ lqw.eq(bo.getSalesPersonId() != null, CustomerInfo::getSalesPersonId, bo.getSalesPersonId());
|
|
|
|
|
+ lqw.eq(bo.getServiceStaffId() != null, CustomerInfo::getServiceStaffId, bo.getServiceStaffId());
|
|
|
|
|
+ lqw.eq(bo.getBelongingDepartmentId() != null, CustomerInfo::getBelongingDepartmentId, bo.getBelongingDepartmentId());
|
|
|
|
|
+ Object isHighSeasObj = StringUtils.isNotBlank(bo.getIsHighSeas()) ? bo.getIsHighSeas() : bo.getParams().get("isHighSeas");
|
|
|
|
|
+ String isHighSeasStr = (isHighSeasObj != null) ? StringUtils.lowerCase(String.valueOf(isHighSeasObj)) : "false";
|
|
|
|
|
+
|
|
|
|
|
+ if ("true".equals(isHighSeasStr)) {
|
|
|
|
|
+ // 公海客户:负责人和客服均为空(或为0)
|
|
|
|
|
+ lqw.and(w -> w.and(a -> a.isNull(CustomerInfo::getSalesPersonId).or().eq(CustomerInfo::getSalesPersonId, 0))
|
|
|
|
|
+ .and(b -> b.isNull(CustomerInfo::getServiceStaffId).or().eq(CustomerInfo::getServiceStaffId, 0)));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 有效客户:负责人不为空(且不为0) OR 客服不为空(且不为0)
|
|
|
|
|
+ lqw.and(w -> w.and(a -> a.isNotNull(CustomerInfo::getSalesPersonId).ne(CustomerInfo::getSalesPersonId, 0))
|
|
|
|
|
+ .or(b -> b.isNotNull(CustomerInfo::getServiceStaffId).ne(CustomerInfo::getServiceStaffId, 0)));
|
|
|
|
|
+ }
|
|
|
return lqw;
|
|
return lqw;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1208,32 +1237,30 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- List<CustomerSalesInfo> updateList = new ArrayList<>();
|
|
|
|
|
- CustomerSalesInfo salesInfo = null;
|
|
|
|
|
|
|
+ List<CustomerInfo> updateList = new ArrayList<>();
|
|
|
for (Long customerId : customerIds) {
|
|
for (Long customerId : customerIds) {
|
|
|
if (customerId == null) {
|
|
if (customerId == null) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
|
|
|
|
|
- if (salesInfo != null) {
|
|
|
|
|
- salesInfo.setSalesPersonId(salesPersonId);
|
|
|
|
|
- salesInfo.setBelongingDepartmentId(deptId);
|
|
|
|
|
- updateList.add(salesInfo);
|
|
|
|
|
|
|
+ CustomerInfo customerInfo = baseMapper.selectById(customerId);
|
|
|
|
|
+ if (customerInfo != null) {
|
|
|
|
|
+ customerInfo.setSalesPersonId(salesPersonId);
|
|
|
|
|
+ customerInfo.setBelongingDepartmentId(deptId);
|
|
|
|
|
+ updateList.add(customerInfo);
|
|
|
} else {
|
|
} else {
|
|
|
- log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
|
|
|
|
|
|
|
+ log.warn("客户 ID: {} 不存在,跳过更新", customerId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!updateList.isEmpty()) {
|
|
if (!updateList.isEmpty()) {
|
|
|
- boolean success = customerSalesInfoMapper.updateBatchById(updateList);
|
|
|
|
|
|
|
+ boolean success = baseMapper.updateBatchById(updateList);
|
|
|
if (success) {
|
|
if (success) {
|
|
|
log.info("成功转移 {} 个客户的业务人员,目标业务员 ID: {}, 部门 ID: {}",
|
|
log.info("成功转移 {} 个客户的业务人员,目标业务员 ID: {}, 部门 ID: {}",
|
|
|
updateList.size(), salesPersonId, deptId);
|
|
updateList.size(), salesPersonId, deptId);
|
|
|
return updateList.size();
|
|
return updateList.size();
|
|
|
} else {
|
|
} else {
|
|
|
- log.error("批量更新销售信息失败");
|
|
|
|
|
- throw new ServiceException("批量更新销售信息失败");
|
|
|
|
|
|
|
+ log.error("批量更新客户信息失败");
|
|
|
|
|
+ throw new ServiceException("批量更新客户信息失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1261,31 +1288,29 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- List<CustomerSalesInfo> updateList = new ArrayList<>();
|
|
|
|
|
- CustomerSalesInfo salesInfo = null;
|
|
|
|
|
|
|
+ List<CustomerInfo> updateList = new ArrayList<>();
|
|
|
for (Long customerId : customerIds) {
|
|
for (Long customerId : customerIds) {
|
|
|
if (customerId == null) {
|
|
if (customerId == null) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- salesInfo = customerSalesInfoMapper.selectByCustomerId(customerId);
|
|
|
|
|
- if (salesInfo != null) {
|
|
|
|
|
- salesInfo.setServiceStaffId(serviceStaffId);
|
|
|
|
|
- updateList.add(salesInfo);
|
|
|
|
|
|
|
+ CustomerInfo customerInfo = baseMapper.selectById(customerId);
|
|
|
|
|
+ if (customerInfo != null) {
|
|
|
|
|
+ customerInfo.setServiceStaffId(serviceStaffId);
|
|
|
|
|
+ updateList.add(customerInfo);
|
|
|
} else {
|
|
} else {
|
|
|
- log.warn("客户 ID: {} 的销售信息不存在,跳过更新", customerId);
|
|
|
|
|
|
|
+ log.warn("客户 ID: {} 不存在,跳过更新", customerId);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!updateList.isEmpty()) {
|
|
if (!updateList.isEmpty()) {
|
|
|
- boolean success = customerSalesInfoMapper.updateBatchById(updateList);
|
|
|
|
|
|
|
+ boolean success = baseMapper.updateBatchById(updateList);
|
|
|
if (success) {
|
|
if (success) {
|
|
|
log.info("成功转移 {} 个客户的客服人员,目标客服人员 ID: {}",
|
|
log.info("成功转移 {} 个客户的客服人员,目标客服人员 ID: {}",
|
|
|
updateList.size(), serviceStaffId);
|
|
updateList.size(), serviceStaffId);
|
|
|
return updateList.size();
|
|
return updateList.size();
|
|
|
} else {
|
|
} else {
|
|
|
- log.error("批量更新销售信息失败");
|
|
|
|
|
- throw new ServiceException("批量更新销售信息失败");
|
|
|
|
|
|
|
+ log.error("批量更新客户信息失败");
|
|
|
|
|
+ throw new ServiceException("批量更新客户信息失败");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1344,8 +1369,6 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
CustomerBusinessInfo customerBusinessInfo = customerBusinessInfoMapper.selectOne(new LambdaQueryWrapper<CustomerBusinessInfo>().eq(CustomerBusinessInfo::getCustomerId, update.getId()));
|
|
CustomerBusinessInfo customerBusinessInfo = customerBusinessInfoMapper.selectOne(new LambdaQueryWrapper<CustomerBusinessInfo>().eq(CustomerBusinessInfo::getCustomerId, update.getId()));
|
|
|
|
|
|
|
|
if (customerSalesInfo != null) {
|
|
if (customerSalesInfo != null) {
|
|
|
- customerSalesInfo.setSalesPersonId(customerSalesInfoBo.getSalesPersonId());
|
|
|
|
|
- customerSalesInfo.setServiceStaffId(customerSalesInfoBo.getServiceStaffId());
|
|
|
|
|
customerSalesInfo.setCreditLevelId(customerSalesInfoBo.getCreditLevelId());
|
|
customerSalesInfo.setCreditLevelId(customerSalesInfoBo.getCreditLevelId());
|
|
|
customerSalesInfoMapper.updateById(customerSalesInfo);
|
|
customerSalesInfoMapper.updateById(customerSalesInfo);
|
|
|
}
|
|
}
|
|
@@ -1376,18 +1399,12 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新销售负责人和客服
|
|
// 更新销售负责人和客服
|
|
|
- salesInfo.setSalesPersonId(claimBo.getSalesPersonId());
|
|
|
|
|
- salesInfo.setServiceStaffId(claimBo.getServiceStaffId());
|
|
|
|
|
- boolean flag = customerSalesInfoMapper.updateById(salesInfo) > 0;
|
|
|
|
|
-
|
|
|
|
|
- if (flag) {
|
|
|
|
|
- // 认领成功后,将客户主表状态改为有效 (通常 0 代表有效/正常)
|
|
|
|
|
- CustomerInfo customer = new CustomerInfo();
|
|
|
|
|
- customer.setId(customerId);
|
|
|
|
|
- customer.setStatus("0"); // 设置为有效客户
|
|
|
|
|
- baseMapper.updateById(customer);
|
|
|
|
|
- }
|
|
|
|
|
- return flag;
|
|
|
|
|
|
|
+ CustomerInfo customer = new CustomerInfo();
|
|
|
|
|
+ customer.setId(customerId);
|
|
|
|
|
+ customer.setSalesPersonId(claimBo.getSalesPersonId());
|
|
|
|
|
+ customer.setServiceStaffId(claimBo.getServiceStaffId());
|
|
|
|
|
+ customer.setStatus("0"); // 认领成功后,将客户主表状态改为有效
|
|
|
|
|
+ return baseMapper.updateById(customer) > 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|