|
|
|
@ -1,12 +1,16 @@
|
|
|
|
|
package com.kiisoo.ic.customer.service;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
|
|
|
|
|
import com.kiisoo.ic.customer.entity.*;
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpVipDOMapper;
|
|
|
|
|
import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PoiCustomerContactDataStat;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.PoiCustomerContactDataStatMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -35,6 +39,8 @@ public class CustomerViewService {
|
|
|
|
|
|
|
|
|
|
static final Integer TEN = 10;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RetailCompanyService retailCompanyService;
|
|
|
|
|
/**
|
|
|
|
|
* 用户权限mapper
|
|
|
|
|
*/
|
|
|
|
@ -271,4 +277,81 @@ public class CustomerViewService {
|
|
|
|
|
return zeroExtendList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 零推广list
|
|
|
|
|
* @param newCustimerList 新增好友list
|
|
|
|
|
* @param shopIds 管辖店铺ids
|
|
|
|
|
* @return 零推广list
|
|
|
|
|
*/
|
|
|
|
|
List<CustomerViewZeroExtendVO> getZeroExtendList2(List<OpCustomer> newCustimerList, List<Long> shopIds, int pageNum, int pageSize){
|
|
|
|
|
//有推广的店铺ids
|
|
|
|
|
List<Long> notZeroShopIds = newCustimerList.stream().map(OpCustomer::getShopId).distinct().collect(Collectors.toList());
|
|
|
|
|
//无推广id
|
|
|
|
|
shopIds.removeAll(notZeroShopIds);
|
|
|
|
|
PageHelper.startPage(pageNum,pageSize);
|
|
|
|
|
List<CustomerViewZeroExtendVO> list = opCustomerDOMapper.selectOrgInfoByShopIds(shopIds);
|
|
|
|
|
|
|
|
|
|
AtomicInteger number = new AtomicInteger(1 + ((pageNum-1) * pageSize));
|
|
|
|
|
//求分页总数
|
|
|
|
|
Page<CustomerViewZeroExtendVO> pageList = (Page<CustomerViewZeroExtendVO>)list;
|
|
|
|
|
Long totalSize = pageList.getTotal();
|
|
|
|
|
list.forEach(item -> {
|
|
|
|
|
item.setTotalSize(totalSize);
|
|
|
|
|
item.setNumb(0);
|
|
|
|
|
item.setNumber(number.get());
|
|
|
|
|
number.incrementAndGet();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 找到推广为0
|
|
|
|
|
* @param regionId 大区id
|
|
|
|
|
* @param companyId 公司id
|
|
|
|
|
* @param customerId 客户id
|
|
|
|
|
* @param startTime 开始时间
|
|
|
|
|
* @param endTime 结束时间
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<CustomerViewZeroExtendVO> zeroExtendList(long userId, Long regionId , Long companyId, Long customerId,
|
|
|
|
|
String startTime, String endTime, int pageNum, int pageSize){
|
|
|
|
|
Set<Long> shopIds;
|
|
|
|
|
//根据店铺查询所有扫码客户信息
|
|
|
|
|
if(customerId != null){
|
|
|
|
|
shopIds = getCompanyShop(customerId, userId);
|
|
|
|
|
}else if(companyId != null){
|
|
|
|
|
shopIds = getCompanyShop(companyId, userId);
|
|
|
|
|
} else if(regionId != null){
|
|
|
|
|
shopIds = getCompanyShop(regionId, userId);
|
|
|
|
|
}else{
|
|
|
|
|
//查询用户权限店铺
|
|
|
|
|
shopIds = new HashSet<>(privilageDomainService.listUserDatePermission(userId));
|
|
|
|
|
}
|
|
|
|
|
if(CollectionUtils.isEmpty(shopIds)){
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
//柱状图好友list
|
|
|
|
|
List<OpCustomer> customerList = opCustomerDOMapper.selectCustomerList(new ArrayList<>(shopIds), null, null, startTime, endTime);
|
|
|
|
|
List<CustomerViewZeroExtendVO> zeroExtendList = getZeroExtendList2(customerList, new ArrayList<>(shopIds),pageNum,pageSize);
|
|
|
|
|
return zeroExtendList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Set<Long> getCompanyShop(Long companyId, long userId){
|
|
|
|
|
//找到最小公司
|
|
|
|
|
Set<Long> param = new HashSet<>();
|
|
|
|
|
param.add(companyId);
|
|
|
|
|
Set<Long> minCompany = retailCompanyService.getMinCompany(param);
|
|
|
|
|
|
|
|
|
|
//找到公司店铺
|
|
|
|
|
List<PoiStore> shops = new ArrayList<>();
|
|
|
|
|
minCompany.forEach(item -> {
|
|
|
|
|
shops.addAll(retailCompanyService.selectShopByCompany(companyId));
|
|
|
|
|
});
|
|
|
|
|
//公司店铺和权限做交集
|
|
|
|
|
Set<Long> shopIds = shops.stream().map(p -> p.getId()).collect(Collectors.toSet());
|
|
|
|
|
List<Long> userAllShops = privilageDomainService.listUserDatePermission(userId);
|
|
|
|
|
shopIds.retainAll(userAllShops);
|
|
|
|
|
return shopIds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|