|
@@ -390,9 +390,6 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
} else if (customerDto.getStatisticsType() == 3) {// 业务员统计
|
|
|
query.groupBy("user_id");
|
|
|
query.select("count(*) count,user_id");
|
|
|
- } else if (customerDto.getStatisticsType() == 4) {// 客户标签统计
|
|
|
- query.groupBy("SUBSTRING_INDEX( IFNULL(tag,''), ',', - 1 )");
|
|
|
- query.select("count(*) count,SUBSTRING_INDEX( IFNULL(tag,''), ',', - 1 ) as tag");
|
|
|
}
|
|
|
List<Customer> customerList = baseMapper.selectList(query);
|
|
|
|
|
@@ -451,6 +448,54 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> tagStatistics(CustomerSelectDto customerDto) {
|
|
|
+ if (ObjectUtil.isEmpty(customerDto) && ObjectUtil.isEmpty(customerDto.getStatisticsType())) {
|
|
|
+ throw new ServiceException("参数异常:统计类型不能为null");
|
|
|
+ }
|
|
|
+ QueryWrapper<Customer> query = Wrappers.query();
|
|
|
+ if (ObjectUtil.isNotEmpty(customerDto.getType())) {
|
|
|
+ // 私海客户查询
|
|
|
+ if (customerDto.getType().equals("1")) {
|
|
|
+ query.isNotNull("user_id");
|
|
|
+ // 私海客户需要添加权限(自己查自己)
|
|
|
+ query.eq("user_id", SecurityUtils.getUserId());
|
|
|
+ } else if (customerDto.getType().equals("0")) {// 公海客户
|
|
|
+ query.and(wrapper1 -> wrapper1.isNull("user_id").or().eq("user_id", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //将标签合在一起
|
|
|
+ query.select("GROUP_CONCAT(IFNULL(tag,'')) as tag");
|
|
|
+ Customer customer = baseMapper.selectOne(query);
|
|
|
+
|
|
|
+ Integer sumCount = 0;
|
|
|
+ Map<String, Integer> map = new HashMap<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(customer)) {
|
|
|
+ String tags = customer.getTag();
|
|
|
+ String[] split = tags.split(",");
|
|
|
+ for (String tag : split) {
|
|
|
+ Integer count = map.getOrDefault(tag, 0);
|
|
|
+ map.put(tag, ++count);
|
|
|
+ sumCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Customer> arr = new ArrayList<>();
|
|
|
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
|
|
+ Customer customer1 = new Customer();
|
|
|
+ customer1.setTag(entry.getKey());
|
|
|
+ customer1.setCount(entry.getValue());
|
|
|
+ arr.add(customer1);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> reData = new HashMap<>();
|
|
|
+ reData.put("countAmount", sumCount);
|
|
|
+ reData.put("customerList", arr);
|
|
|
+
|
|
|
+ return reData;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 客户分配
|
|
|
*/
|