|
|
|
@ -44,6 +44,7 @@ public class CustomerViewService {
|
|
|
|
|
static final Integer LEVEL_REGION = 1;
|
|
|
|
|
/**零售公司*/
|
|
|
|
|
static final Integer LEVEL_COMPANY = 2;
|
|
|
|
|
static final Long LEVEL_COMPANY_L = 2L;
|
|
|
|
|
/**客户*/
|
|
|
|
|
static final Integer LEVEL_CUSTOMER = 3;
|
|
|
|
|
|
|
|
|
@ -114,13 +115,16 @@ public class CustomerViewService {
|
|
|
|
|
//会员总数
|
|
|
|
|
Long vipCount = opVipDOMapper.selectVipCount(shopIds, null, null);
|
|
|
|
|
|
|
|
|
|
//设置柱状图list
|
|
|
|
|
List<OpCustomer> newCustimerList = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).collect(Collectors.toList());
|
|
|
|
|
//零售公司店均新增
|
|
|
|
|
List<CustomerViewCompanyVO> shopAverageNewCustomerList = getOrgShopAvgNewCustomerList(newCustimerList, userId);
|
|
|
|
|
customerViewVO.setCompanyShopAverageNewCustomerList(shopAverageNewCustomerList);
|
|
|
|
|
//设置趋势柱状图list
|
|
|
|
|
List<OpCustomer> validCustomerList = customerList.stream().filter(customerDO -> VALID.equals(customerDO.getValidType())).collect(Collectors.toList());
|
|
|
|
|
handleChartData(customerList, validCustomerList, customerViewVO);
|
|
|
|
|
//设置新增好友,好友总数,拉黑数,vip人数,柱状图list等数据
|
|
|
|
|
//设置新增好友,好友总数,拉黑数,vip人数
|
|
|
|
|
setCustomerViewData(customerViewVO, customerCount, validCustomerCount, validDeleteCustomerCount, vipCount, customerList, validCustomerList, selectStartTime, selectEndTime);
|
|
|
|
|
//前十名排行list等
|
|
|
|
|
List<OpCustomer> newCustimerList = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).collect(Collectors.toList());
|
|
|
|
|
List<CustomerViewCompanyVO> orgNewCustomerList = getOrgNewCustomerList(newCustimerList);
|
|
|
|
|
List<CustomerViewShopVO> shopNewCustomerList = getShopNewCustomerList(newCustimerList);
|
|
|
|
|
List<CustomerViewZeroExtendVO> zeroExtendList = getZeroExtendList(newCustimerList, shopIds);
|
|
|
|
@ -141,7 +145,7 @@ public class CustomerViewService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增好友,好友总数,拉黑数,vip人数,柱状图list等数据
|
|
|
|
|
* 新增好友,好友总数,拉黑数,vip人数
|
|
|
|
|
* @param customerViewVO 客户概览VO
|
|
|
|
|
* @param customerCount 好友总数
|
|
|
|
|
* @param validCustomerCount 好友总数(去重)
|
|
|
|
@ -228,7 +232,56 @@ public class CustomerViewService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 柱状图数据
|
|
|
|
|
* 公司店均新增柱状图
|
|
|
|
|
* @param newCustimerList 好友list
|
|
|
|
|
* @param userId 用户id
|
|
|
|
|
* @return 公司店均新增list
|
|
|
|
|
*/
|
|
|
|
|
public List<CustomerViewCompanyVO> getOrgShopAvgNewCustomerList(List<OpCustomer> newCustimerList, Long userId){
|
|
|
|
|
List<CustomerViewCompanyVO> orgShopAvgNewCustomerList = new ArrayList<>();
|
|
|
|
|
//初始化所有零售公司
|
|
|
|
|
List<PrivilageOrganizational> companyList = retailCompanyService.listOfRetailOrg(userId, null, null, null).stream().filter(org -> LEVEL_COMPANY_L.equals(org.getLevel())).distinct().collect(Collectors.toList());
|
|
|
|
|
companyList.forEach(companyDO -> {
|
|
|
|
|
CustomerViewCompanyVO companyVO = new CustomerViewCompanyVO();
|
|
|
|
|
companyVO.setOrgId(companyDO.getId());
|
|
|
|
|
companyVO.setOrgName(companyDO.getName());
|
|
|
|
|
companyVO.setNewCustomerCount(0);
|
|
|
|
|
orgShopAvgNewCustomerList.add(companyVO);
|
|
|
|
|
});
|
|
|
|
|
//店铺id-新增好友数map
|
|
|
|
|
Map<Long, Long> shopIdCountMap = newCustimerList.stream().collect(Collectors.groupingBy(OpCustomer::getShopId, Collectors.counting()));
|
|
|
|
|
//店铺id→零售公司名称
|
|
|
|
|
List<Long> shopIds = newCustimerList.stream().map(OpCustomer::getShopId).collect(Collectors.toList());
|
|
|
|
|
if(CollectionUtils.isEmpty(shopIds)){
|
|
|
|
|
return orgShopAvgNewCustomerList;
|
|
|
|
|
}
|
|
|
|
|
//零售公司id-公司店铺list map
|
|
|
|
|
List<ShopOrgInfoVO> shopOrgInfoList = getOrgInfoByShopIds(shopIds, true, null);
|
|
|
|
|
Map<Long, List<ShopOrgInfoVO>> companyShopListMap = shopOrgInfoList.stream().distinct().collect(Collectors.groupingBy(ShopOrgInfoVO::getCompanyId));
|
|
|
|
|
//每个公司店均新增数
|
|
|
|
|
companyShopListMap.forEach((companyId,companyShopList) -> {
|
|
|
|
|
CustomerViewCompanyVO orgViewDO = new CustomerViewCompanyVO();
|
|
|
|
|
orgViewDO.setOrgId(companyId);
|
|
|
|
|
orgViewDO.setOrgName(companyShopList.get(0).getCompanyName());
|
|
|
|
|
AtomicInteger newCustomerCount = new AtomicInteger(0);
|
|
|
|
|
companyShopList.forEach(companyShopVO -> {
|
|
|
|
|
Long shopId = companyShopVO.getShopId();
|
|
|
|
|
int tmpCount = shopIdCountMap.get(shopId) == null ? 0 : Math.toIntExact(shopIdCountMap.get(shopId));
|
|
|
|
|
newCustomerCount.updateAndGet(v -> v + tmpCount);
|
|
|
|
|
});
|
|
|
|
|
//平均
|
|
|
|
|
if(companyShopList.size() > 0){
|
|
|
|
|
newCustomerCount.updateAndGet(v -> Math.round(v / (float)companyShopList.size()));
|
|
|
|
|
}
|
|
|
|
|
orgViewDO.setNewCustomerCount(newCustomerCount.get());
|
|
|
|
|
orgShopAvgNewCustomerList.stream().filter(orgShopAvg -> orgShopAvg.getOrgName().equals(orgViewDO.getOrgName())).forEach(orgShopAvg -> orgShopAvg.setNewCustomerCount(orgViewDO.getNewCustomerCount()));
|
|
|
|
|
});
|
|
|
|
|
//公司店均
|
|
|
|
|
return orgShopAvgNewCustomerList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 趋势柱状图数据
|
|
|
|
|
* @param customerList 好友list
|
|
|
|
|
* @param validCustomerList 好友(去重)list
|
|
|
|
|
* @param customerViewVO 概览VO
|
|
|
|
@ -272,7 +325,7 @@ public class CustomerViewService {
|
|
|
|
|
//零售公司id-公司店铺list map
|
|
|
|
|
List<ShopOrgInfoVO> shopOrgInfoList = getOrgInfoByShopIds(shopIds, true, null);
|
|
|
|
|
Map<Long, List<ShopOrgInfoVO>> companyShopListMap = shopOrgInfoList.stream().distinct().collect(Collectors.groupingBy(ShopOrgInfoVO::getCompanyId));
|
|
|
|
|
//每个公司新增数
|
|
|
|
|
//每个公司店均新增数
|
|
|
|
|
List<CustomerViewCompanyVO> tmpList = new ArrayList<>();
|
|
|
|
|
companyShopListMap.forEach((companyId,companyShopList) -> {
|
|
|
|
|
CustomerViewCompanyVO orgViewDO = new CustomerViewCompanyVO();
|
|
|
|
|