|
@@ -372,10 +372,12 @@ 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);
|
|
|
|
|
|
-
|
|
|
UserUtil.assignmentNickName(customerList, Customer::getUserId, Customer::setUserName);
|
|
|
|
|
|
Integer countAmount = customerList.stream().map(Customer::getCount).reduce(Integer::sum).orElse(0);
|
|
@@ -384,6 +386,50 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> followStatistics(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", ""));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 客户最后一次跟进时间范围计数
|
|
|
+ QueryWrapper<Customer> clone = query.clone();
|
|
|
+ clone.select("count(1) as count");
|
|
|
+ clone.gt("DATEDIFF( NOW(), last_follow_time )", 7);
|
|
|
+ clone.le("DATEDIFF( NOW(), last_follow_time )", 30);
|
|
|
+ Customer customer = baseMapper.selectOne(clone);
|
|
|
+
|
|
|
+ QueryWrapper<Customer> clone1 = query.clone();
|
|
|
+ clone1.select("count(1) as count");
|
|
|
+ clone1.gt("DATEDIFF( NOW(), last_follow_time )", 30);
|
|
|
+ clone1.le("DATEDIFF( NOW(), last_follow_time )", 180);
|
|
|
+ Customer customer1 = baseMapper.selectOne(clone1);
|
|
|
+
|
|
|
+ QueryWrapper<Customer> clone2 = query.clone();
|
|
|
+ clone2.select("count(1) as count");
|
|
|
+ clone2.gt("DATEDIFF( NOW(), last_follow_time )", 180);
|
|
|
+ clone2.or().isNull("last_follow_time");
|
|
|
+ Customer customer2 = baseMapper.selectOne(clone2);
|
|
|
+
|
|
|
+ //返回最终结果
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("7", customer.getCount());
|
|
|
+ map.put("30", customer1.getCount());
|
|
|
+ map.put("180", customer2.getCount());
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 客户分配
|
|
|
*/
|
|
@@ -398,14 +444,6 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
|
return listObject(Customer::getId, q -> q.in(Customer::getUserId, authUserIdList));
|
|
|
}
|
|
|
|
|
|
- // 根据字典编码获取字典的数据
|
|
|
- private List<DictTenantDataVo> getDict(String code) {
|
|
|
- DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
|
|
|
- dto.setDictCode(code);
|
|
|
- List<DictTenantDataVo> dictTenantDataServiceList = dictTenantDataService.getList(dto);
|
|
|
- return dictTenantDataServiceList;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public CustomerCodeAndCountryId getCustomerCodeAndCountryId(Long customerId) {
|
|
|
if (customerId == null) {
|