|
@@ -2,7 +2,6 @@ package com.fjhx.customer.service.customer.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -12,15 +11,19 @@ import com.fjhx.customer.entity.customer.dto.CustomerDto;
|
|
import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
|
|
import com.fjhx.customer.entity.customer.dto.CustomerSelectDto;
|
|
import com.fjhx.customer.entity.customer.po.Customer;
|
|
import com.fjhx.customer.entity.customer.po.Customer;
|
|
import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
|
|
import com.fjhx.customer.entity.customer.po.CustomerFollowRecords;
|
|
|
|
+import com.fjhx.customer.entity.customer.po.CustomerTop;
|
|
import com.fjhx.customer.entity.customer.po.CustomerUser;
|
|
import com.fjhx.customer.entity.customer.po.CustomerUser;
|
|
import com.fjhx.customer.entity.customer.vo.CustomerVo;
|
|
import com.fjhx.customer.entity.customer.vo.CustomerVo;
|
|
import com.fjhx.customer.mapper.customer.CustomerMapper;
|
|
import com.fjhx.customer.mapper.customer.CustomerMapper;
|
|
import com.fjhx.customer.service.customer.CustomerFollowRecordsService;
|
|
import com.fjhx.customer.service.customer.CustomerFollowRecordsService;
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
import com.fjhx.customer.service.customer.CustomerService;
|
|
|
|
+import com.fjhx.customer.service.customer.CustomerTopService;
|
|
import com.fjhx.customer.service.customer.CustomerUserService;
|
|
import com.fjhx.customer.service.customer.CustomerUserService;
|
|
import com.fjhx.customer.utils.code.CodeEnum;
|
|
import com.fjhx.customer.utils.code.CodeEnum;
|
|
import com.obs.services.internal.ServiceException;
|
|
import com.obs.services.internal.ServiceException;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -41,6 +44,8 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
private CustomerUserService customerUserService;
|
|
private CustomerUserService customerUserService;
|
|
@Autowired
|
|
@Autowired
|
|
private CustomerFollowRecordsService customerFollowRecordsService;
|
|
private CustomerFollowRecordsService customerFollowRecordsService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CustomerTopService customerTopService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -51,23 +56,34 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Page<CustomerVo> getPage(CustomerSelectDto dto) {
|
|
public Page<CustomerVo> getPage(CustomerSelectDto dto) {
|
|
- LambdaQueryWrapper<Customer> wrapper = Wrappers.<Customer>lambdaQuery();
|
|
|
|
- wrapper.eq(ObjectUtil.isNotEmpty(dto.getSource()), Customer::getSource, dto.getSource());
|
|
|
|
- wrapper.eq(ObjectUtil.isNotEmpty(dto.getStatus()), Customer::getStatus, dto.getStatus());
|
|
|
|
|
|
+// LambdaQueryWrapper<Customer> wrapper = Wrappers.<Customer>lambdaQuery();
|
|
|
|
+ IWrapper<CustomerVo> wrapper = IWrapper.getWrapper();
|
|
|
|
+ wrapper.eq("c", Customer::getSource, dto.getSource());
|
|
|
|
+ wrapper.eq(Customer::getStatus, dto.getStatus());
|
|
//客户状态(0:公海客户 1:私海客户)(业务员ID为null为公海客户,业务员ID不为null为私海客户)
|
|
//客户状态(0:公海客户 1:私海客户)(业务员ID为null为公海客户,业务员ID不为null为私海客户)
|
|
if (ObjectUtil.isNotEmpty(dto.getType())) {
|
|
if (ObjectUtil.isNotEmpty(dto.getType())) {
|
|
//私海客户查询
|
|
//私海客户查询
|
|
if (dto.getType().equals("1")) {
|
|
if (dto.getType().equals("1")) {
|
|
- wrapper.isNotNull(Customer::getUserId);
|
|
|
|
|
|
+ wrapper.isNotNull("c.user_id");
|
|
} else if (dto.getType().equals("0")) {
|
|
} else if (dto.getType().equals("0")) {
|
|
- wrapper.and(wrapper1 -> wrapper1.isNull(Customer::getUserId).or().eq(Customer::getUserId, ""));
|
|
|
|
|
|
+ wrapper.and(wrapper1 -> wrapper1.isNull("c.user_id").or().eq(Customer::getUserId, ""));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
//查询客户名称或者客户编码
|
|
//查询客户名称或者客户编码
|
|
wrapper.and(wrapper1 -> wrapper1.like(Customer::getName, dto.getKeyword()).or().eq(Customer::getCode, dto.getKeyword()));
|
|
wrapper.and(wrapper1 -> wrapper1.like(Customer::getName, dto.getKeyword()).or().eq(Customer::getCode, dto.getKeyword()));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //置顶条件
|
|
|
|
+ List<Long> customerIds = customerTopService.listObject(CustomerTop::getCustomerId, q -> q.eq(CustomerTop::getUserId,
|
|
|
|
+ SecurityUtils.getUserId()));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(customerIds)) {
|
|
|
|
+ String join = StringUtils.join(customerIds, ",");
|
|
|
|
+ wrapper.orderByDesc("id IN ( " + join + " )");
|
|
|
|
+ }
|
|
|
|
+
|
|
wrapper.orderByDesc(Customer::getCreateTime);
|
|
wrapper.orderByDesc(Customer::getCreateTime);
|
|
|
|
+
|
|
Page<CustomerVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
Page<CustomerVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
|
|
//复制城市信息
|
|
//复制城市信息
|
|
@@ -81,6 +97,11 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
record.setCustomerFollowRecordsList(customerFollowRecordsList);
|
|
record.setCustomerFollowRecordsList(customerFollowRecordsList);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //赋值是否置顶
|
|
|
|
+ for (CustomerVo record : records) {
|
|
|
|
+ record.setIsTop(customerIds.contains(record.getId()) ? 1 : 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -155,15 +176,25 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Page<CustomerVo> privateSeaPage(CustomerSelectDto dto) {
|
|
public Page<CustomerVo> privateSeaPage(CustomerSelectDto dto) {
|
|
- LambdaQueryWrapper<Customer> wrapper = Wrappers.<Customer>lambdaQuery();
|
|
|
|
- wrapper.eq(ObjectUtil.isNotEmpty(dto.getSource()), Customer::getSource, dto.getSource());
|
|
|
|
- wrapper.eq(ObjectUtil.isNotEmpty(dto.getStatus()), Customer::getStatus, dto.getStatus());
|
|
|
|
|
|
+// LambdaQueryWrapper<Customer> wrapper = Wrappers.<Customer>lambdaQuery();
|
|
|
|
+ IWrapper<CustomerVo> wrapper = IWrapper.getWrapper();
|
|
|
|
+ wrapper.eq("c", Customer::getSource, dto.getSource());
|
|
|
|
+ wrapper.eq("c", Customer::getStatus, dto.getStatus());
|
|
if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
//查询客户名称或者客户编码
|
|
//查询客户名称或者客户编码
|
|
wrapper.and(wrapper1 -> wrapper1.like(Customer::getName, dto.getKeyword()).or().eq(Customer::getCode, dto.getKeyword()));
|
|
wrapper.and(wrapper1 -> wrapper1.like(Customer::getName, dto.getKeyword()).or().eq(Customer::getCode, dto.getKeyword()));
|
|
}
|
|
}
|
|
//添加权限(自己看自己)
|
|
//添加权限(自己看自己)
|
|
wrapper.eq(Customer::getUserId, SecurityUtils.getUserId());
|
|
wrapper.eq(Customer::getUserId, SecurityUtils.getUserId());
|
|
|
|
+
|
|
|
|
+ //置顶条件
|
|
|
|
+ List<Long> customerIds = customerTopService.listObject(CustomerTop::getCustomerId, q -> q.eq(CustomerTop::getUserId,
|
|
|
|
+ SecurityUtils.getUserId()));
|
|
|
|
+ if (ObjectUtil.isNotEmpty(customerIds)) {
|
|
|
|
+ String join = StringUtils.join(customerIds, ",");
|
|
|
|
+ wrapper.orderByDesc("id IN ( " + join + " )");
|
|
|
|
+ }
|
|
|
|
+
|
|
wrapper.orderByDesc(Customer::getCreateTime);
|
|
wrapper.orderByDesc(Customer::getCreateTime);
|
|
Page<CustomerVo> page = baseMapper.getPage(dto.getPage(), wrapper);
|
|
Page<CustomerVo> page = baseMapper.getPage(dto.getPage(), wrapper);
|
|
//复制城市信息
|
|
//复制城市信息
|
|
@@ -176,6 +207,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
|
.orderByDesc(CustomerFollowRecords::getDate).last("limit 3"));
|
|
.orderByDesc(CustomerFollowRecords::getDate).last("limit 3"));
|
|
record.setCustomerFollowRecordsList(customerFollowRecordsList);
|
|
record.setCustomerFollowRecordsList(customerFollowRecordsList);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //赋值是否置顶
|
|
|
|
+ for (CustomerVo record : records) {
|
|
|
|
+ record.setIsTop(customerIds.contains(record.getId()) ? 1 : 0);
|
|
|
|
+ }
|
|
|
|
+
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|