|
|
|
@ -41,6 +41,13 @@ public class CustomerViewService {
|
|
|
|
|
|
|
|
|
|
static final Integer TEN = 10;
|
|
|
|
|
|
|
|
|
|
/**区域*/
|
|
|
|
|
static final Integer LEVEL_REGION = 1;
|
|
|
|
|
/**零售公司*/
|
|
|
|
|
static final Integer LEVEL_COMPANY = 2;
|
|
|
|
|
/**客户*/
|
|
|
|
|
static final Integer LEVEL_CUSTOMER = 3;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RetailCompanyService retailCompanyService;
|
|
|
|
|
/**
|
|
|
|
@ -192,6 +199,38 @@ public class CustomerViewService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 店铺组织信息list
|
|
|
|
|
* @param shopIds 店铺ids
|
|
|
|
|
* @param companyFlag 零售公司
|
|
|
|
|
* @param regionFlag 区域
|
|
|
|
|
* @return 店铺组织信息list
|
|
|
|
|
*/
|
|
|
|
|
public List<ShopOrgInfoVO> getOrgInfoByShopIds(List<Long> shopIds, Boolean companyFlag, Boolean regionFlag){
|
|
|
|
|
//店铺-客户组织list
|
|
|
|
|
List<ShopOrgInfoVO> shopOrgInfoList = opCustomerDOMapper.selectCustomerOrgByShopIds(shopIds, LEVEL_CUSTOMER);
|
|
|
|
|
if(companyFlag == null || !companyFlag){
|
|
|
|
|
return shopOrgInfoList;
|
|
|
|
|
}
|
|
|
|
|
//零售公司list
|
|
|
|
|
List<Long> companyIds = shopOrgInfoList.stream().map(ShopOrgInfoVO::getCompanyId).collect(Collectors.toList());
|
|
|
|
|
List<PrivilageOrganizational> companyList = new ArrayList<>();
|
|
|
|
|
if(companyIds.size() > 0){
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> orgWrapper = new QueryWrapper<>();
|
|
|
|
|
orgWrapper.eq("level", LEVEL_COMPANY);
|
|
|
|
|
orgWrapper.in("id", companyIds);
|
|
|
|
|
companyList = retailCompanyMapper.selectList(orgWrapper);
|
|
|
|
|
}
|
|
|
|
|
Map<Long, String> companyNameMap = companyList.stream().collect(Collectors.toMap(PrivilageOrganizational::getId, PrivilageOrganizational::getName));
|
|
|
|
|
shopOrgInfoList.stream().filter(shopOrgDO -> shopOrgDO.getCompanyId() != null).forEach(shopOrgDO -> shopOrgDO.setCompanyName(companyNameMap.get(shopOrgDO.getCompanyId())));
|
|
|
|
|
//区域list
|
|
|
|
|
if(regionFlag == null || !regionFlag){
|
|
|
|
|
return shopOrgInfoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return shopOrgInfoList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 零售公司新增排行list
|
|
|
|
|
* @param newCustimerList 新增好友list
|
|
|
|
@ -206,17 +245,18 @@ public class CustomerViewService {
|
|
|
|
|
if(CollectionUtils.isEmpty(shopIds)){
|
|
|
|
|
return orgNewCustomerList;
|
|
|
|
|
}
|
|
|
|
|
//公司id-公司店铺list map
|
|
|
|
|
Map<Long, List<CustomerViewShopVO>> orgShopListMap = opCustomerDOMapper.selectOrgByShopIds(shopIds).stream().distinct().collect(Collectors.groupingBy(CustomerViewShopVO::getOrgId));
|
|
|
|
|
//零售公司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<>();
|
|
|
|
|
orgShopListMap.forEach((orgId,customerViewShopList) -> {
|
|
|
|
|
companyShopListMap.forEach((companyId,companyShopList) -> {
|
|
|
|
|
CustomerViewCompanyVO orgViewDO = new CustomerViewCompanyVO();
|
|
|
|
|
orgViewDO.setOrgId(orgId);
|
|
|
|
|
orgViewDO.setOrgName(customerViewShopList.get(0).getOrgName());
|
|
|
|
|
orgViewDO.setOrgId(companyId);
|
|
|
|
|
orgViewDO.setOrgName(companyShopList.get(0).getCompanyName());
|
|
|
|
|
AtomicInteger newCustomerCount = new AtomicInteger(0);
|
|
|
|
|
customerViewShopList.forEach(customerViewShopVO -> {
|
|
|
|
|
Long shopId = customerViewShopVO.getShopId();
|
|
|
|
|
companyShopList.forEach(companyShopVO -> {
|
|
|
|
|
Long shopId = companyShopVO.getShopId();
|
|
|
|
|
int tmpCount = shopIdCountMap.get(shopId) == null ? 0 : Math.toIntExact(shopIdCountMap.get(shopId));
|
|
|
|
|
newCustomerCount.updateAndGet(v -> v + tmpCount);
|
|
|
|
|
});
|
|
|
|
@ -262,16 +302,17 @@ public class CustomerViewService {
|
|
|
|
|
List<CustomerViewZeroExtendVO> zeroExtendList = new ArrayList<>();
|
|
|
|
|
//有推广的店铺ids
|
|
|
|
|
List<Long> notZeroShopIds = newCustimerList.stream().map(OpCustomer::getShopId).distinct().collect(Collectors.toList());
|
|
|
|
|
//公司id-公司店铺list map
|
|
|
|
|
Map<Long, List<CustomerViewShopVO>> orgShopListMap = opCustomerDOMapper.selectOrgByShopIds(shopIds).stream().distinct().collect(Collectors.groupingBy(CustomerViewShopVO::getOrgId));
|
|
|
|
|
//零售公司id-公司店铺list map
|
|
|
|
|
List<ShopOrgInfoVO> shopOrgInfoList = getOrgInfoByShopIds(shopIds, true, null);
|
|
|
|
|
Map<Long, List<ShopOrgInfoVO>> companyShopListMap = shopOrgInfoList.stream().distinct().collect(Collectors.groupingBy(ShopOrgInfoVO::getCompanyId));
|
|
|
|
|
|
|
|
|
|
List<CustomerViewZeroExtendVO> tmpZeroExtendList = new ArrayList<>();
|
|
|
|
|
orgShopListMap.forEach((orgId, orgShopRelationList) -> {
|
|
|
|
|
List<Long> tmpShopIds = orgShopRelationList.stream().map(CustomerViewShopVO::getShopId).distinct().collect(Collectors.toList());
|
|
|
|
|
companyShopListMap.forEach((companyId, companyShopList) -> {
|
|
|
|
|
List<Long> tmpShopIds = companyShopList.stream().map(ShopOrgInfoVO::getShopId).distinct().collect(Collectors.toList());
|
|
|
|
|
int tmpShopCount = tmpShopIds.size();
|
|
|
|
|
CustomerViewZeroExtendVO zeroExtendVO = new CustomerViewZeroExtendVO();
|
|
|
|
|
zeroExtendVO.setOrgId(orgId);
|
|
|
|
|
zeroExtendVO.setOrgName(orgShopRelationList.get(0).getOrgName());
|
|
|
|
|
zeroExtendVO.setOrgId(companyId);
|
|
|
|
|
zeroExtendVO.setOrgName(companyShopList.get(0).getCompanyName());
|
|
|
|
|
zeroExtendVO.setAllShopCount(tmpShopCount);
|
|
|
|
|
//推广的店铺
|
|
|
|
|
tmpShopIds.retainAll(notZeroShopIds);
|
|
|
|
|