|
|
@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
@ -277,6 +278,7 @@ public class RetailCompanyService {
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
List<PrivilageOrganizational> listOfOrg = retailCompanyMapper.selectList(wrapper);
|
|
|
|
List<PrivilageOrganizational> listOfOrg = retailCompanyMapper.selectList(wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<RetailOrganizationalVO> list = new ArrayList<>();
|
|
|
|
List<RetailOrganizationalVO> list = new ArrayList<>();
|
|
|
|
listOfOrg.parallelStream().forEach(org -> {
|
|
|
|
listOfOrg.parallelStream().forEach(org -> {
|
|
|
|
RetailOrganizationalVO organizationalVO = new RetailOrganizationalVO();
|
|
|
|
RetailOrganizationalVO organizationalVO = new RetailOrganizationalVO();
|
|
|
@ -285,26 +287,28 @@ public class RetailCompanyService {
|
|
|
|
//查询零售公司的门店
|
|
|
|
//查询零售公司的门店
|
|
|
|
List<PoiStore> list1 = selectShopByCompany(org.getId());
|
|
|
|
List<PoiStore> list1 = selectShopByCompany(org.getId());
|
|
|
|
List<Long> stores = list1.stream().map(PoiStore::getId).collect(Collectors.toList());
|
|
|
|
List<Long> stores = list1.stream().map(PoiStore::getId).collect(Collectors.toList());
|
|
|
|
//组织成员
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
//根据门店查询导购人数
|
|
|
|
wrapper1.eq("org_id", org.getId());
|
|
|
|
QueryWrapper<PoiStoreStaff> wrapperStaff = new QueryWrapper<>();
|
|
|
|
List<PrivilageOrganizationalMember> memberList = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
wrapperStaff.in("store_id",stores);
|
|
|
|
|
|
|
|
List<PoiStoreStaff> listStaff = poiStoreStaffDOMapper.selectList(wrapperStaff);
|
|
|
|
|
|
|
|
|
|
|
|
//组织成员的客户个数
|
|
|
|
//组织成员的客户个数
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
wrapper2.in("user_id", memberList.stream().map(PrivilageOrganizationalMember::getUserId).collect(Collectors.toList()));
|
|
|
|
wrapper2.in("user_id", listStaff.stream().map(PoiStoreStaff::getUserId).collect(Collectors.toList()));
|
|
|
|
List<OpSellerCustomerRelation> opRelations = memberList.size() == 0 ? new ArrayList<>() : opSellerCustomerRelationDOMapper.selectList(wrapper2);
|
|
|
|
List<OpSellerCustomerRelation> opRelations = listStaff.size() == 0 ? new ArrayList<>() : opSellerCustomerRelationDOMapper.selectList(wrapper2);
|
|
|
|
long count = opRelations.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
long count = opRelations.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
organizationalVO.setAllCustomer((int) count);
|
|
|
|
organizationalVO.setAllCustomer((int) count);
|
|
|
|
//组织成员的客户有效个数
|
|
|
|
//组织成员的客户有效个数
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper4 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper4 = new QueryWrapper<>();
|
|
|
|
wrapper4.in("user_id", memberList.stream().map(PrivilageOrganizationalMember::getUserId).collect(Collectors.toList()));
|
|
|
|
wrapper4.in("user_id", listStaff.stream().map(PoiStoreStaff::getUserId).collect(Collectors.toList()));
|
|
|
|
wrapper4.eq("type", 1);
|
|
|
|
wrapper4.eq("type", 1);
|
|
|
|
List<OpSellerCustomerRelation> opRelations1 = memberList.size() == 0 ? new ArrayList<>() : opSellerCustomerRelationDOMapper.selectList(wrapper4);
|
|
|
|
List<OpSellerCustomerRelation> opRelations1 = listStaff.size() == 0 ? new ArrayList<>() : opSellerCustomerRelationDOMapper.selectList(wrapper4);
|
|
|
|
long countAble = opRelations1.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
long countAble = opRelations1.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
organizationalVO.setEffectiveCustomer((int) countAble);
|
|
|
|
organizationalVO.setEffectiveCustomer((int) countAble);
|
|
|
|
|
|
|
|
|
|
|
|
//计算新增客户数据
|
|
|
|
//计算新增客户数据
|
|
|
|
newCustomerUser(startTime, endTime, organizationalVO, memberList.stream().map(PrivilageOrganizationalMember::getUserId).collect(Collectors.toList()));
|
|
|
|
newCustomerUser(startTime, endTime, organizationalVO, listStaff.stream().map(PoiStoreStaff::getUserId).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
|
|
//被拉黑的客户数
|
|
|
|
//被拉黑的客户数
|
|
|
|
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
|
|
|
@ -343,28 +347,31 @@ public class RetailCompanyService {
|
|
|
|
if(userIds.size() == 0){
|
|
|
|
if(userIds.size() == 0){
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LocalDate l;
|
|
|
|
//最初时间的总客户人数
|
|
|
|
//最初时间的总客户人数
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
wrapper2.in("user_id", userIds);
|
|
|
|
wrapper2.in("user_id", userIds);
|
|
|
|
wrapper2.lt("create_time", startTime);
|
|
|
|
l = LocalDate.parse(startTime);
|
|
|
|
|
|
|
|
wrapper2.lt("create_time", l.plus(1,ChronoUnit.DAYS));
|
|
|
|
List<OpSellerCustomerRelation> opRelations = opSellerCustomerRelationDOMapper.selectList(wrapper2);
|
|
|
|
List<OpSellerCustomerRelation> opRelations = opSellerCustomerRelationDOMapper.selectList(wrapper2);
|
|
|
|
long count = opRelations.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
long count = opRelations.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
//最初时间的有效总客户人数
|
|
|
|
//最初时间的有效总客户人数
|
|
|
|
wrapper2.in("user_id", userIds);
|
|
|
|
wrapper2.in("user_id", userIds);
|
|
|
|
wrapper2.eq("type", 1);
|
|
|
|
wrapper2.eq("type", 1);
|
|
|
|
wrapper2.lt("create_time", startTime);
|
|
|
|
wrapper2.lt("create_time", l.plus(1,ChronoUnit.DAYS));
|
|
|
|
List<OpSellerCustomerRelation> opRelations2 = opSellerCustomerRelationDOMapper.selectList(wrapper2);
|
|
|
|
List<OpSellerCustomerRelation> opRelations2 = opSellerCustomerRelationDOMapper.selectList(wrapper2);
|
|
|
|
long count2 = opRelations2.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
long count2 = opRelations2.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
//最后时间的总客户人数
|
|
|
|
//最后时间的总客户人数
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper3 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper3 = new QueryWrapper<>();
|
|
|
|
wrapper3.in("user_id", userIds);
|
|
|
|
wrapper3.in("user_id", userIds);
|
|
|
|
wrapper3.lt("create_time", endTime);
|
|
|
|
l = LocalDate.parse(endTime);
|
|
|
|
|
|
|
|
wrapper3.lt("create_time",l.plus(1,ChronoUnit.DAYS));
|
|
|
|
List<OpSellerCustomerRelation> opRelationsEnd = opSellerCustomerRelationDOMapper.selectList(wrapper3);
|
|
|
|
List<OpSellerCustomerRelation> opRelationsEnd = opSellerCustomerRelationDOMapper.selectList(wrapper3);
|
|
|
|
long countEnd = opRelationsEnd.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
long countEnd = opRelationsEnd.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
//最后时间的有效总客户人数
|
|
|
|
//最后时间的有效总客户人数
|
|
|
|
wrapper3.in("user_id", userIds);
|
|
|
|
wrapper3.in("user_id", userIds);
|
|
|
|
wrapper3.eq("type", 1);
|
|
|
|
wrapper3.eq("type", 1);
|
|
|
|
wrapper3.lt("create_time", endTime);
|
|
|
|
wrapper3.lt("create_time",l.plus(1,ChronoUnit.DAYS));
|
|
|
|
List<OpSellerCustomerRelation> opRelationsEnd2 = opSellerCustomerRelationDOMapper.selectList(wrapper3);
|
|
|
|
List<OpSellerCustomerRelation> opRelationsEnd2 = opSellerCustomerRelationDOMapper.selectList(wrapper3);
|
|
|
|
long countEnd2 = opRelationsEnd2.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
long countEnd2 = opRelationsEnd2.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
|
|
|
|
|
|
|
|