|
|
@ -37,11 +37,17 @@ import java.util.stream.Collectors;
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class RetailCompanyService {
|
|
|
|
public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
/**区域*/
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 区域
|
|
|
|
|
|
|
|
*/
|
|
|
|
static final Integer LEVEL_REGION = 1;
|
|
|
|
static final Integer LEVEL_REGION = 1;
|
|
|
|
/**零售公司*/
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 零售公司
|
|
|
|
|
|
|
|
*/
|
|
|
|
static final Integer LEVEL_COMPANY = 2;
|
|
|
|
static final Integer LEVEL_COMPANY = 2;
|
|
|
|
/**客户*/
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 客户
|
|
|
|
|
|
|
|
*/
|
|
|
|
static final Integer LEVEL_CUSTOMER = 3;
|
|
|
|
static final Integer LEVEL_CUSTOMER = 3;
|
|
|
|
|
|
|
|
|
|
|
|
private RetailCompanyMapper retailCompanyMapper;
|
|
|
|
private RetailCompanyMapper retailCompanyMapper;
|
|
|
@ -59,7 +65,7 @@ public class RetailCompanyService {
|
|
|
|
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
|
|
|
|
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
public RetailCompanyService(RetailCompanyMapper retailCompanyMapper,OrganizationalMemberMapper organizationalMemberMapper,OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper,PoiCustomerContactDataStatMapper poiCustomerContactDataStatMapper,PoiStoreDOMapper poiStoreDOMapper,PrivilageUserDOMapper privilageUserDOMapper,PoiStoreStaffDOMapper poiStoreStaffDOMapper){
|
|
|
|
public RetailCompanyService(RetailCompanyMapper retailCompanyMapper, OrganizationalMemberMapper organizationalMemberMapper, OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper, PoiCustomerContactDataStatMapper poiCustomerContactDataStatMapper, PoiStoreDOMapper poiStoreDOMapper, PrivilageUserDOMapper privilageUserDOMapper, PoiStoreStaffDOMapper poiStoreStaffDOMapper) {
|
|
|
|
this.retailCompanyMapper = retailCompanyMapper;
|
|
|
|
this.retailCompanyMapper = retailCompanyMapper;
|
|
|
|
this.organizationalMemberMapper = organizationalMemberMapper;
|
|
|
|
this.organizationalMemberMapper = organizationalMemberMapper;
|
|
|
|
this.opSellerCustomerRelationDOMapper = opSellerCustomerRelationDOMapper;
|
|
|
|
this.opSellerCustomerRelationDOMapper = opSellerCustomerRelationDOMapper;
|
|
|
@ -72,28 +78,31 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 找到用户公司
|
|
|
|
* 找到用户公司
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param parentId 父区域id
|
|
|
|
* @param parentId 父区域id
|
|
|
|
* @param userId 用户id
|
|
|
|
* @param userId 用户id
|
|
|
|
* @param level 等级
|
|
|
|
* @param level 等级
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PrivilageOrganizational> getUserOrg(Long parentId, long userId, int level){
|
|
|
|
public List<PrivilageOrganizational> getUserOrg(Long parentId, long userId, int level) {
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
if(!check(userId)){
|
|
|
|
wrapper1.eq("user_id", userId);
|
|
|
|
wrapper1.eq("user_id",userId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PrivilageOrganizational p = new PrivilageOrganizational();
|
|
|
|
PrivilageOrganizational p = new PrivilageOrganizational();
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
if(pm.isEmpty()) {
|
|
|
|
if(check(userId)){
|
|
|
|
return null;
|
|
|
|
wrapper.eq("level",level).eq("type",1).eq("status", 1);
|
|
|
|
}else {
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
wrapper.eq("type", 1).eq("status", 1).eq("level",level).
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pm.isEmpty()) {
|
|
|
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
wrapper.eq("type", 1).eq("status", 1).eq("level", level).
|
|
|
|
in("id", pm.stream().map(PrivilageOrganizationalMember::getOrgId).
|
|
|
|
in("id", pm.stream().map(PrivilageOrganizationalMember::getOrgId).
|
|
|
|
collect(Collectors.toList()));
|
|
|
|
collect(Collectors.toList()));
|
|
|
|
if(null != parentId){
|
|
|
|
if (null != parentId) {
|
|
|
|
wrapper.eq("parent_id",parentId);
|
|
|
|
wrapper.eq("parent_id", parentId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -102,27 +111,29 @@ public class RetailCompanyService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询所有的大区信息
|
|
|
|
* 查询所有的大区信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PrivilageOrganizational> listOfBigRetailCompany(long userId){
|
|
|
|
public List<PrivilageOrganizational> listOfBigRetailCompany(long userId) {
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
if(!check(userId)){
|
|
|
|
wrapper1.eq("user_id", userId);
|
|
|
|
wrapper1.eq("user_id",userId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
if(pm.isEmpty()) {
|
|
|
|
if(check(userId)){
|
|
|
|
return null;
|
|
|
|
wrapper.eq("type", 1).eq("level", 1).eq("status", 1);
|
|
|
|
}else {
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
wrapper.eq("type", 1).eq("level",1).eq("status", 1).in("id", pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList()));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pm.isEmpty()) {
|
|
|
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
wrapper.eq("type", 1).eq("level", 1).eq("status", 1).in("id", pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList()));
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean check(long userId){
|
|
|
|
public boolean check(long userId) {
|
|
|
|
//根据userId查询角色
|
|
|
|
//根据userId查询角色
|
|
|
|
PrivilageRoleDO p = privilageUserDOMapper.selecctRoleByUserId(userId);
|
|
|
|
PrivilageRoleDO p = privilageUserDOMapper.selecctRoleByUserId(userId);
|
|
|
|
if(p.getCode().equals(RoleEnum.ROLE_CODE_GLY.getRoleCode()) || p.getCode().equals(RoleEnum.ROLE_CODE_ALL_YYRY.getRoleCode()) ){
|
|
|
|
if (p.getCode().equals(RoleEnum.ROLE_CODE_GLY.getRoleCode()) || p.getCode().equals(RoleEnum.ROLE_CODE_ALL_YYRY.getRoleCode())) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -131,15 +142,16 @@ public class RetailCompanyService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询所有的组织数据信息
|
|
|
|
* 查询所有的组织数据信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PrivilageOrganizational> listOfRetailOrg(long userId, Long regionId, Long companyId, Long customerId){
|
|
|
|
public List<PrivilageOrganizational> listOfRetailOrg(long userId, Long regionId, Long companyId, Long customerId) {
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
if(!check(userId)){
|
|
|
|
wrapper1.eq("user_id", userId);
|
|
|
|
wrapper1.eq("user_id",userId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
if(pm.isEmpty()) {
|
|
|
|
if(check(userId)){
|
|
|
|
|
|
|
|
return retailCompanyMapper.selectList(null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pm.isEmpty()) {
|
|
|
|
return new ArrayList<>();
|
|
|
|
return new ArrayList<>();
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
List<Long> orgIds = pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList());
|
|
|
|
List<Long> orgIds = pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList());
|
|
|
|
List<PrivilageOrganizationalRelationVO> orgRelationList = retailCompanyMapper.selectAllOrgListByOrgIds(orgIds, regionId, companyId, customerId);
|
|
|
|
List<PrivilageOrganizationalRelationVO> orgRelationList = retailCompanyMapper.selectAllOrgListByOrgIds(orgIds, regionId, companyId, customerId);
|
|
|
|
//所以组织list
|
|
|
|
//所以组织list
|
|
|
@ -148,17 +160,17 @@ public class RetailCompanyService {
|
|
|
|
PrivilageOrganizational regionDO = new PrivilageOrganizational();
|
|
|
|
PrivilageOrganizational regionDO = new PrivilageOrganizational();
|
|
|
|
regionDO.setId(orgRelationVO.getRegionId());
|
|
|
|
regionDO.setId(orgRelationVO.getRegionId());
|
|
|
|
regionDO.setName(orgRelationVO.getRegion());
|
|
|
|
regionDO.setName(orgRelationVO.getRegion());
|
|
|
|
regionDO.setLevel((long)LEVEL_REGION);
|
|
|
|
regionDO.setLevel((long) LEVEL_REGION);
|
|
|
|
regionDO.setParentId(0L);
|
|
|
|
regionDO.setParentId(0L);
|
|
|
|
PrivilageOrganizational companyDO = new PrivilageOrganizational();
|
|
|
|
PrivilageOrganizational companyDO = new PrivilageOrganizational();
|
|
|
|
companyDO.setId(orgRelationVO.getCompanyId());
|
|
|
|
companyDO.setId(orgRelationVO.getCompanyId());
|
|
|
|
companyDO.setName(orgRelationVO.getCompany());
|
|
|
|
companyDO.setName(orgRelationVO.getCompany());
|
|
|
|
companyDO.setLevel((long)LEVEL_COMPANY);
|
|
|
|
companyDO.setLevel((long) LEVEL_COMPANY);
|
|
|
|
companyDO.setParentId(orgRelationVO.getRegionId());
|
|
|
|
companyDO.setParentId(orgRelationVO.getRegionId());
|
|
|
|
PrivilageOrganizational customerDO = new PrivilageOrganizational();
|
|
|
|
PrivilageOrganizational customerDO = new PrivilageOrganizational();
|
|
|
|
customerDO.setId(orgRelationVO.getCustomerId());
|
|
|
|
customerDO.setId(orgRelationVO.getCustomerId());
|
|
|
|
customerDO.setName(orgRelationVO.getCustomer());
|
|
|
|
customerDO.setName(orgRelationVO.getCustomer());
|
|
|
|
customerDO.setLevel((long)LEVEL_CUSTOMER);
|
|
|
|
customerDO.setLevel((long) LEVEL_CUSTOMER);
|
|
|
|
customerDO.setParentId(orgRelationVO.getCompanyId());
|
|
|
|
customerDO.setParentId(orgRelationVO.getCompanyId());
|
|
|
|
tmpOrgList.add(regionDO);
|
|
|
|
tmpOrgList.add(regionDO);
|
|
|
|
tmpOrgList.add(companyDO);
|
|
|
|
tmpOrgList.add(companyDO);
|
|
|
@ -172,34 +184,36 @@ public class RetailCompanyService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询所有的零售公司信息
|
|
|
|
* 查询所有的零售公司信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PrivilageOrganizational> listOfRetailCompany(long userId,Long bigRegionId){
|
|
|
|
public List<PrivilageOrganizational> listOfRetailCompany(long userId, Long bigRegionId) {
|
|
|
|
if (bigRegionId == null || bigRegionId == 0L){
|
|
|
|
if (bigRegionId == null || bigRegionId == 0L) {
|
|
|
|
bigRegionId = null;
|
|
|
|
bigRegionId = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
if(!check(userId)){
|
|
|
|
wrapper1.eq("user_id", userId);
|
|
|
|
wrapper1.eq("user_id",userId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
if(pm.isEmpty()) {
|
|
|
|
if(check(userId)){
|
|
|
|
return null;
|
|
|
|
wrapper.eq("type", 1).eq("level", 2).eq("status", 1);
|
|
|
|
}else {
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
wrapper.eq("type", 1).eq("level",2).eq("status", 1).in("id", pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList()));
|
|
|
|
}
|
|
|
|
if (bigRegionId != null){
|
|
|
|
if (pm.isEmpty()) {
|
|
|
|
wrapper.eq("parent_id",bigRegionId);
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
wrapper.eq("type", 1).eq("level", 2).eq("status", 1).in("id", pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
if (bigRegionId != null) {
|
|
|
|
|
|
|
|
wrapper.eq("parent_id", bigRegionId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(wrapper);
|
|
|
|
return retailCompanyMapper.selectList(wrapper);
|
|
|
|
return privilageOrganizationals;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询零售公司下的店铺
|
|
|
|
* 查询零售公司下的店铺
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param orgId 零售公司id
|
|
|
|
* @param orgId 零售公司id
|
|
|
|
* @return 门店信息
|
|
|
|
* @return 门店信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PoiStore> selectShopByCompany(Long orgId){
|
|
|
|
public List<PoiStore> selectShopByCompany(Long orgId) {
|
|
|
|
//查询客户
|
|
|
|
//查询客户
|
|
|
|
Set<Long> companyIds = new HashSet<>();
|
|
|
|
Set<Long> companyIds = new HashSet<>();
|
|
|
|
companyIds.add(orgId);
|
|
|
|
companyIds.add(orgId);
|
|
|
@ -209,10 +223,11 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询零售公司下的店铺
|
|
|
|
* 查询零售公司下的店铺
|
|
|
|
* @param orgId 零售公司id
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param bigRegionId 零售公司id
|
|
|
|
* @return 门店信息
|
|
|
|
* @return 门店信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PoiStore> selectShopByBigRegion(Long bigRegionId){
|
|
|
|
public List<PoiStore> selectShopByBigRegion(Long bigRegionId) {
|
|
|
|
//查询零售公司
|
|
|
|
//查询零售公司
|
|
|
|
Set<Long> bigRegionIds = new HashSet<>();
|
|
|
|
Set<Long> bigRegionIds = new HashSet<>();
|
|
|
|
bigRegionIds.add(bigRegionId);
|
|
|
|
bigRegionIds.add(bigRegionId);
|
|
|
@ -225,35 +240,38 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询客户公司下的店铺
|
|
|
|
* 查询客户公司下的店铺
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param orgId 零售公司id
|
|
|
|
* @param orgId 零售公司id
|
|
|
|
* @return 门店信息
|
|
|
|
* @return 门店信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PoiStore> selectCustomerShopByCompany(Long orgId){
|
|
|
|
public List<PoiStore> selectCustomerShopByCompany(Long orgId) {
|
|
|
|
return poiStoreDOMapper.selectCustomerShopByCompany(orgId);
|
|
|
|
return poiStoreDOMapper.selectCustomerShopByCompany(orgId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询零售公司下的店铺
|
|
|
|
* 查询零售公司下的店铺
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param shopId 零售公司id
|
|
|
|
* @param shopId 零售公司id
|
|
|
|
* @return 门店信息
|
|
|
|
* @return 门店信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public List<PrivilageUserDO> selectSellerByShop(Long shopId){
|
|
|
|
public List<PrivilageUserDO> selectSellerByShop(Long shopId) {
|
|
|
|
return poiStoreDOMapper.selectSellerByShop(shopId);
|
|
|
|
return poiStoreDOMapper.selectSellerByShop(shopId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询所有零售公司的推广数据
|
|
|
|
* 查询所有零售公司的推广数据
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param startTime 日期
|
|
|
|
* @param startTime 日期
|
|
|
|
* @param endTime 日期
|
|
|
|
* @param endTime 日期
|
|
|
|
* @param orgId 零售公司
|
|
|
|
* @param orgId 零售公司
|
|
|
|
* @return 零售公司的推广数据
|
|
|
|
* @return 零售公司的推广数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public OrganizationVO generalizeOfRetail(String startTime,String endTime,Long orgId,int pageNum,int pageSize){
|
|
|
|
public OrganizationVO generalizeOfRetail(String startTime, String endTime, Long orgId, int pageNum, int pageSize) {
|
|
|
|
//零售公司信息
|
|
|
|
//零售公司信息
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
wrapper.eq("type",1).eq("status",1);
|
|
|
|
wrapper.eq("type", 1).eq("status", 1);
|
|
|
|
if(orgId != null){
|
|
|
|
if (orgId != null) {
|
|
|
|
wrapper.eq("id",orgId);
|
|
|
|
wrapper.eq("id", orgId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
List<PrivilageOrganizational> listOfOrg = retailCompanyMapper.selectList(wrapper);
|
|
|
|
List<PrivilageOrganizational> listOfOrg = retailCompanyMapper.selectList(wrapper);
|
|
|
@ -269,36 +287,36 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
//组织成员
|
|
|
|
//组织成员
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
wrapper1.eq("org_id",org.getId());
|
|
|
|
wrapper1.eq("org_id", org.getId());
|
|
|
|
List<PrivilageOrganizationalMember> memberList = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
List<PrivilageOrganizationalMember> memberList = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
//组织成员的客户个数
|
|
|
|
//组织成员的客户个数
|
|
|
|
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", memberList.stream().map(PrivilageOrganizationalMember::getUserId).collect(Collectors.toList()));
|
|
|
|
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();
|
|
|
|
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", memberList.stream().map(PrivilageOrganizationalMember::getUserId).collect(Collectors.toList()));
|
|
|
|
wrapper4.eq("type",1);
|
|
|
|
wrapper4.eq("type", 1);
|
|
|
|
List<OpSellerCustomerRelation> opRelations1 = opSellerCustomerRelationDOMapper.selectList(wrapper4);
|
|
|
|
List<OpSellerCustomerRelation> opRelations1 = 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, memberList.stream().map(PrivilageOrganizationalMember::getUserId).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
|
|
|
|
//被拉黑的客户数
|
|
|
|
//被拉黑的客户数
|
|
|
|
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
|
|
|
|
if(stores.isEmpty()){
|
|
|
|
if (stores.isEmpty()) {
|
|
|
|
stores.add(-1L);
|
|
|
|
stores.add(-1L);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wrapper3.in("store_id",stores);
|
|
|
|
wrapper3.in("store_id", stores);
|
|
|
|
List<PoiCustomerContactDataStat> dataStats = poiCustomerContactDataStatMapper.selectList(wrapper3);
|
|
|
|
List<PoiCustomerContactDataStat> dataStats = poiCustomerContactDataStatMapper.selectList(wrapper3);
|
|
|
|
long allAge = dataStats.stream().mapToLong(PoiCustomerContactDataStat::getNegativeFeedbackCnt).sum();
|
|
|
|
long allAge = dataStats.stream().mapToLong(PoiCustomerContactDataStat::getNegativeFeedbackCnt).sum();
|
|
|
|
|
|
|
|
|
|
|
|
organizationalVO.setDelCustomer((int) allAge);
|
|
|
|
organizationalVO.setDelCustomer((int) allAge);
|
|
|
|
organizationalVO.setDelRate(check(allAge,count));
|
|
|
|
organizationalVO.setDelRate(check(allAge, count));
|
|
|
|
list.add(organizationalVO);
|
|
|
|
list.add(organizationalVO);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
OrganizationVO vo = new OrganizationVO();
|
|
|
|
OrganizationVO vo = new OrganizationVO();
|
|
|
@ -316,33 +334,34 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 计算新增客户数和新增有效客户数
|
|
|
|
* 计算新增客户数和新增有效客户数
|
|
|
|
* @param startTime 开始时间
|
|
|
|
*
|
|
|
|
* @param endTime 结束时间
|
|
|
|
* @param startTime 开始时间
|
|
|
|
|
|
|
|
* @param endTime 结束时间
|
|
|
|
* @param organizationalVO 封装实体
|
|
|
|
* @param organizationalVO 封装实体
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void newCustomerUser(String startTime, String endTime, DataVO organizationalVO, List<Long> userIds){
|
|
|
|
private void newCustomerUser(String startTime, String endTime, DataVO organizationalVO, List<Long> userIds) {
|
|
|
|
//最初时间的总客户人数
|
|
|
|
//最初时间的总客户人数
|
|
|
|
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);
|
|
|
|
wrapper2.lt("create_time", startTime);
|
|
|
|
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", startTime);
|
|
|
|
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);
|
|
|
|
wrapper3.lt("create_time", endTime);
|
|
|
|
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", endTime);
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
@ -353,32 +372,33 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
organizationalVO.setNewCustomer((int) (countEnd - count));
|
|
|
|
organizationalVO.setNewCustomer((int) (countEnd - count));
|
|
|
|
organizationalVO.setNewEffectiveCustomer((int) (countEnd2 - count2));
|
|
|
|
organizationalVO.setNewEffectiveCustomer((int) (countEnd2 - count2));
|
|
|
|
organizationalVO.setAvgNewCustomer(check(countEnd - count,days));
|
|
|
|
organizationalVO.setAvgNewCustomer(check(countEnd - count, days));
|
|
|
|
organizationalVO.setAvgNewEffectiveCustomer(check(countEnd2 - count2,days));
|
|
|
|
organizationalVO.setAvgNewEffectiveCustomer(check(countEnd2 - count2, days));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void newCustomerStore(String startTime, String endTime, DataVO organizationalVO, List<Long> storeIds){
|
|
|
|
|
|
|
|
|
|
|
|
private void newCustomerStore(String startTime, String endTime, DataVO organizationalVO, List<Long> storeIds) {
|
|
|
|
//最初时间的总客户人数
|
|
|
|
//最初时间的总客户人数
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
wrapper2.in("store_id",storeIds);
|
|
|
|
wrapper2.in("store_id", storeIds);
|
|
|
|
wrapper2.lt("create_time",startTime);
|
|
|
|
wrapper2.lt("create_time", startTime);
|
|
|
|
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("store_id",storeIds);
|
|
|
|
wrapper2.in("store_id", storeIds);
|
|
|
|
wrapper2.eq("type",1);
|
|
|
|
wrapper2.eq("type", 1);
|
|
|
|
wrapper2.lt("create_time",startTime);
|
|
|
|
wrapper2.lt("create_time", startTime);
|
|
|
|
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("store_id",storeIds);
|
|
|
|
wrapper3.in("store_id", storeIds);
|
|
|
|
wrapper3.lt("create_time",endTime);
|
|
|
|
wrapper3.lt("create_time", endTime);
|
|
|
|
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("store_id",storeIds);
|
|
|
|
wrapper3.in("store_id", storeIds);
|
|
|
|
wrapper3.eq("type",1);
|
|
|
|
wrapper3.eq("type", 1);
|
|
|
|
wrapper3.lt("create_time",endTime);
|
|
|
|
wrapper3.lt("create_time", endTime);
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
@ -389,38 +409,40 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
organizationalVO.setNewCustomer((int) (countEnd - count));
|
|
|
|
organizationalVO.setNewCustomer((int) (countEnd - count));
|
|
|
|
organizationalVO.setNewEffectiveCustomer((int) (countEnd2 - count2));
|
|
|
|
organizationalVO.setNewEffectiveCustomer((int) (countEnd2 - count2));
|
|
|
|
organizationalVO.setAvgNewCustomer(check(countEnd - count,days));
|
|
|
|
organizationalVO.setAvgNewCustomer(check(countEnd - count, days));
|
|
|
|
organizationalVO.setAvgNewEffectiveCustomer(check(countEnd2 - count2,days));
|
|
|
|
organizationalVO.setAvgNewEffectiveCustomer(check(countEnd2 - count2, days));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 除法计算
|
|
|
|
* 除法计算
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param l1 被除数
|
|
|
|
* @param l1 被除数
|
|
|
|
* @param l2 除数
|
|
|
|
* @param l2 除数
|
|
|
|
* @return 值
|
|
|
|
* @return 值
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Integer check(Long l1,Long l2){
|
|
|
|
public Integer check(Long l1, Long l2) {
|
|
|
|
if(l2 == null || l1 == null || l2 == 0){
|
|
|
|
if (l2 == null || l1 == null || l2 == 0) {
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
return Math.round((l1 / l2) * 100);
|
|
|
|
return Math.round((l1 / l2) * 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询门店推广数据
|
|
|
|
* 查询门店推广数据
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param startTime 日期
|
|
|
|
* @param startTime 日期
|
|
|
|
* @param endTime 日期
|
|
|
|
* @param endTime 日期
|
|
|
|
* @param orgId 零售公司id
|
|
|
|
* @param orgId 零售公司id
|
|
|
|
* @param shopId 门店id
|
|
|
|
* @param shopId 门店id
|
|
|
|
* @param pageNum 页码
|
|
|
|
* @param pageNum 页码
|
|
|
|
* @param pageSize 页面显示个数
|
|
|
|
* @param pageSize 页面显示个数
|
|
|
|
* @return 门店推广数据
|
|
|
|
* @return 门店推广数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public OrganizationVO generalizeOfStore(String startTime, String endTime, Long orgId, Long shopId, int pageNum, int pageSize){
|
|
|
|
public OrganizationVO generalizeOfStore(String startTime, String endTime, Long orgId, Long shopId, int pageNum, int pageSize) {
|
|
|
|
//根据零售公司查询门店
|
|
|
|
//根据零售公司查询门店
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
List<CompanyStoreDO> list = retailCompanyMapper.selectShopIdByRetail(orgId,shopId);
|
|
|
|
List<CompanyStoreDO> list = retailCompanyMapper.selectShopIdByRetail(orgId, shopId);
|
|
|
|
|
|
|
|
|
|
|
|
List<StoreOrganizationalVO> list1 = new ArrayList<>();
|
|
|
|
List<StoreOrganizationalVO> list1 = new ArrayList<>();
|
|
|
|
list.forEach(li -> {
|
|
|
|
list.forEach(li -> {
|
|
|
@ -428,21 +450,21 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
//查询所有的客户
|
|
|
|
//查询所有的客户
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper = new QueryWrapper<>();
|
|
|
|
wrapper.eq("store_id",li.getShopId());
|
|
|
|
wrapper.eq("store_id", li.getShopId());
|
|
|
|
long count = opSellerCustomerRelationDOMapper.selectCount(wrapper);
|
|
|
|
long count = opSellerCustomerRelationDOMapper.selectCount(wrapper);
|
|
|
|
//查询所有的有效客户
|
|
|
|
//查询所有的有效客户
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
wrapper2.eq("store_id",li.getShopId());
|
|
|
|
wrapper2.eq("store_id", li.getShopId());
|
|
|
|
wrapper2.eq("type",1);
|
|
|
|
wrapper2.eq("type", 1);
|
|
|
|
long countAble = opSellerCustomerRelationDOMapper.selectCount(wrapper2);
|
|
|
|
long countAble = opSellerCustomerRelationDOMapper.selectCount(wrapper2);
|
|
|
|
//计算新客户数据
|
|
|
|
//计算新客户数据
|
|
|
|
newCustomerStore(startTime,endTime,storeOrganizationalVO, Collections.singletonList(li.getShopId()));
|
|
|
|
newCustomerStore(startTime, endTime, storeOrganizationalVO, Collections.singletonList(li.getShopId()));
|
|
|
|
//查询店铺的名称
|
|
|
|
//查询店铺的名称
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(li.getShopId());
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(li.getShopId());
|
|
|
|
|
|
|
|
|
|
|
|
//被拉黑的客户数
|
|
|
|
//被拉黑的客户数
|
|
|
|
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
|
|
|
|
wrapper3.eq("store_id",li.getShopId());
|
|
|
|
wrapper3.eq("store_id", li.getShopId());
|
|
|
|
List<PoiCustomerContactDataStat> dataStats = poiCustomerContactDataStatMapper.selectList(wrapper3);
|
|
|
|
List<PoiCustomerContactDataStat> dataStats = poiCustomerContactDataStatMapper.selectList(wrapper3);
|
|
|
|
long allAge = dataStats.stream().mapToLong(PoiCustomerContactDataStat::getNegativeFeedbackCnt).sum();
|
|
|
|
long allAge = dataStats.stream().mapToLong(PoiCustomerContactDataStat::getNegativeFeedbackCnt).sum();
|
|
|
|
|
|
|
|
|
|
|
@ -452,7 +474,7 @@ public class RetailCompanyService {
|
|
|
|
storeOrganizationalVO.setEffectiveCustomer((int) countAble);
|
|
|
|
storeOrganizationalVO.setEffectiveCustomer((int) countAble);
|
|
|
|
storeOrganizationalVO.setDelCustomer((int) allAge);
|
|
|
|
storeOrganizationalVO.setDelCustomer((int) allAge);
|
|
|
|
storeOrganizationalVO.setCompanyName(li.getCompanyName());
|
|
|
|
storeOrganizationalVO.setCompanyName(li.getCompanyName());
|
|
|
|
storeOrganizationalVO.setDelRate(check(allAge,count));
|
|
|
|
storeOrganizationalVO.setDelRate(check(allAge, count));
|
|
|
|
list1.add(storeOrganizationalVO);
|
|
|
|
list1.add(storeOrganizationalVO);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
OrganizationVO vo = new OrganizationVO();
|
|
|
|
OrganizationVO vo = new OrganizationVO();
|
|
|
@ -470,42 +492,43 @@ public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询导购的推广数据
|
|
|
|
* 查询导购的推广数据
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param startTime 日期
|
|
|
|
* @param startTime 日期
|
|
|
|
* @param endTime 日期
|
|
|
|
* @param endTime 日期
|
|
|
|
* @param orgId 零售哦给弄死id
|
|
|
|
* @param orgId 零售哦给弄死id
|
|
|
|
* @param shopId 门店id
|
|
|
|
* @param shopId 门店id
|
|
|
|
* @param sellerId 导购id
|
|
|
|
* @param sellerId 导购id
|
|
|
|
* @param pageNum 页码
|
|
|
|
* @param pageNum 页码
|
|
|
|
* @param pageSize 页面个数
|
|
|
|
* @param pageSize 页面个数
|
|
|
|
* @return 导购的推广数据
|
|
|
|
* @return 导购的推广数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public OrganizationVO generalizeOfSeller(String startTime, String endTime, Long orgId, Long shopId,Long sellerId, int pageNum, int pageSize){
|
|
|
|
public OrganizationVO generalizeOfSeller(String startTime, String endTime, Long orgId, Long shopId, Long sellerId, int pageNum, int pageSize) {
|
|
|
|
//根据零售公司查询门店
|
|
|
|
//根据零售公司查询门店
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
List<Long> sellerIds = retailCompanyMapper.selectSellerIdsByShop(orgId,shopId,sellerId);
|
|
|
|
List<Long> sellerIds = retailCompanyMapper.selectSellerIdsByShop(orgId, shopId, sellerId);
|
|
|
|
List<SellerOrganizationalVO> list = new ArrayList<>();
|
|
|
|
List<SellerOrganizationalVO> list = new ArrayList<>();
|
|
|
|
sellerIds.forEach(seller -> {
|
|
|
|
sellerIds.forEach(seller -> {
|
|
|
|
SellerOrganizationalVO sellerOrganizationalVO = new SellerOrganizationalVO();
|
|
|
|
SellerOrganizationalVO sellerOrganizationalVO = new SellerOrganizationalVO();
|
|
|
|
|
|
|
|
|
|
|
|
//查询所有的客户
|
|
|
|
//查询所有的客户
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper = new QueryWrapper<>();
|
|
|
|
wrapper.eq("user_id",seller);
|
|
|
|
wrapper.eq("user_id", seller);
|
|
|
|
long count = opSellerCustomerRelationDOMapper.selectCount(wrapper);
|
|
|
|
long count = opSellerCustomerRelationDOMapper.selectCount(wrapper);
|
|
|
|
|
|
|
|
|
|
|
|
//查询导购信息
|
|
|
|
//查询导购信息
|
|
|
|
PrivilageUserDO privilageUserDO = privilageUserDOMapper.selectById(seller);
|
|
|
|
PrivilageUserDO privilageUserDO = privilageUserDOMapper.selectById(seller);
|
|
|
|
QueryWrapper<PoiStoreStaff> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PoiStoreStaff> wrapper1 = new QueryWrapper<>();
|
|
|
|
wrapper1.eq("user_id",seller).last("limit 1");
|
|
|
|
wrapper1.eq("user_id", seller).last("limit 1");
|
|
|
|
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectOne(wrapper1);
|
|
|
|
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectOne(wrapper1);
|
|
|
|
//计算新客户数据
|
|
|
|
//计算新客户数据
|
|
|
|
newCustomerUser(startTime,endTime,sellerOrganizationalVO, Collections.singletonList(seller));
|
|
|
|
newCustomerUser(startTime, endTime, sellerOrganizationalVO, Collections.singletonList(seller));
|
|
|
|
//查询导购所属公司门店
|
|
|
|
//查询导购所属公司门店
|
|
|
|
CompanyStoreDO companyStoreDO = poiStoreDOMapper.selectCompanyStore(seller);
|
|
|
|
CompanyStoreDO companyStoreDO = poiStoreDOMapper.selectCompanyStore(seller);
|
|
|
|
sellerOrganizationalVO.setShopName(companyStoreDO == null ? null : companyStoreDO.getShopName());
|
|
|
|
sellerOrganizationalVO.setShopName(companyStoreDO == null ? null : companyStoreDO.getShopName());
|
|
|
|
sellerOrganizationalVO.setShopCode(companyStoreDO == null ? null : companyStoreDO.getShopCode());
|
|
|
|
sellerOrganizationalVO.setShopCode(companyStoreDO == null ? null : companyStoreDO.getShopCode());
|
|
|
|
sellerOrganizationalVO.setSellerCode(poiStoreStaff == null ? null : poiStoreStaff.getStaffCode());
|
|
|
|
sellerOrganizationalVO.setSellerCode(poiStoreStaff == null ? null : poiStoreStaff.getStaffCode());
|
|
|
|
sellerOrganizationalVO.setCompanyName(companyStoreDO == null ? null : companyStoreDO.getCompanyName());
|
|
|
|
sellerOrganizationalVO.setCompanyName(companyStoreDO == null ? null : companyStoreDO.getCompanyName());
|
|
|
|
sellerOrganizationalVO.setSellerName(privilageUserDO == null ? null :privilageUserDO.getName());
|
|
|
|
sellerOrganizationalVO.setSellerName(privilageUserDO == null ? null : privilageUserDO.getName());
|
|
|
|
sellerOrganizationalVO.setAllCustomer((int) count);
|
|
|
|
sellerOrganizationalVO.setAllCustomer((int) count);
|
|
|
|
list.add(sellerOrganizationalVO);
|
|
|
|
list.add(sellerOrganizationalVO);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -526,7 +549,7 @@ public class RetailCompanyService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 找到最小公司集合
|
|
|
|
* 找到最小公司集合
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void getMinCompany(Set<Long> companys,Set<Long> needs){
|
|
|
|
public void getMinCompany(Set<Long> companys, Set<Long> needs) {
|
|
|
|
companys.forEach(item -> {
|
|
|
|
companys.forEach(item -> {
|
|
|
|
getMinCompany(item, needs);
|
|
|
|
getMinCompany(item, needs);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -535,14 +558,14 @@ public class RetailCompanyService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 找到最小公司集合
|
|
|
|
* 找到最小公司集合
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void getMinCompany(Long company,Set<Long> needs){
|
|
|
|
public void getMinCompany(Long company, Set<Long> needs) {
|
|
|
|
QueryWrapper<PrivilageOrganizational> q = new QueryWrapper();
|
|
|
|
QueryWrapper<PrivilageOrganizational> q = new QueryWrapper();
|
|
|
|
q.eq("parent_id", company);
|
|
|
|
q.eq("parent_id", company);
|
|
|
|
List<PrivilageOrganizational> listOfOrg = retailCompanyMapper.selectList(q);
|
|
|
|
List<PrivilageOrganizational> listOfOrg = retailCompanyMapper.selectList(q);
|
|
|
|
Set<Long> companys = listOfOrg.stream().map(item -> item.getId()).collect(Collectors.toSet());
|
|
|
|
Set<Long> companys = listOfOrg.stream().map(item -> item.getId()).collect(Collectors.toSet());
|
|
|
|
if(companys.size() > 0) {
|
|
|
|
if (companys.size() > 0) {
|
|
|
|
getMinCompany(companys, needs);
|
|
|
|
getMinCompany(companys, needs);
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
needs.add(company);
|
|
|
|
needs.add(company);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|