|
|
|
@ -7,10 +7,7 @@ import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.bean.*;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.CompanyStoreDO;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PoiCustomerContactDataStat;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizationalMember;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.*;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.OrganizationalMemberMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.PoiCustomerContactDataStatMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
@ -38,6 +35,13 @@ import java.util.stream.Collectors;
|
|
|
|
|
@Service
|
|
|
|
|
public class RetailCompanyService {
|
|
|
|
|
|
|
|
|
|
/**区域*/
|
|
|
|
|
static final Integer LEVEL_REGION = 1;
|
|
|
|
|
/**零售公司*/
|
|
|
|
|
static final Integer LEVEL_COMPANY = 2;
|
|
|
|
|
/**客户*/
|
|
|
|
|
static final Integer LEVEL_CUSTOMER = 3;
|
|
|
|
|
|
|
|
|
|
private RetailCompanyMapper retailCompanyMapper;
|
|
|
|
|
|
|
|
|
|
private OrganizationalMemberMapper organizationalMemberMapper;
|
|
|
|
@ -110,17 +114,39 @@ public class RetailCompanyService {
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有的组织数据信息
|
|
|
|
|
*/
|
|
|
|
|
public List<PrivilageOrganizational> listOfRetailOrg(long userId){
|
|
|
|
|
public List<PrivilageOrganizational> listOfRetailOrg(long userId, Long regionId, Long companyId, Long customerId){
|
|
|
|
|
QueryWrapper<PrivilageOrganizationalMember> wrapper1 = new QueryWrapper<>();
|
|
|
|
|
wrapper1.eq("user_id",userId);
|
|
|
|
|
List<PrivilageOrganizationalMember> pm = organizationalMemberMapper.selectList(wrapper1);
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> wrapper = new QueryWrapper<>();
|
|
|
|
|
if(pm.isEmpty()) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}else {
|
|
|
|
|
wrapper.eq("type", 1).eq("status", 1).in("id", pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList()));
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(wrapper);
|
|
|
|
|
return privilageOrganizationals;
|
|
|
|
|
List<Long> orgIds = pm.stream().map(PrivilageOrganizationalMember::getOrgId).collect(Collectors.toList());
|
|
|
|
|
List<PrivilageOrganizationalRelationVO> orgRelationList = retailCompanyMapper.selectAllOrgListByOrgIds(orgIds, regionId, companyId, customerId);
|
|
|
|
|
//所以组织list
|
|
|
|
|
List<PrivilageOrganizational> tmpOrgList = new ArrayList<>();
|
|
|
|
|
orgRelationList.forEach(orgRelationVO -> {
|
|
|
|
|
PrivilageOrganizational regionDO = new PrivilageOrganizational();
|
|
|
|
|
regionDO.setId(orgRelationVO.getRegionId());
|
|
|
|
|
regionDO.setName(orgRelationVO.getRegion());
|
|
|
|
|
regionDO.setLevel((long)LEVEL_REGION);
|
|
|
|
|
regionDO.setParentId(0L);
|
|
|
|
|
PrivilageOrganizational companyDO = new PrivilageOrganizational();
|
|
|
|
|
companyDO.setId(orgRelationVO.getCompanyId());
|
|
|
|
|
companyDO.setName(orgRelationVO.getCompany());
|
|
|
|
|
companyDO.setLevel((long)LEVEL_COMPANY);
|
|
|
|
|
companyDO.setParentId(orgRelationVO.getRegionId());
|
|
|
|
|
PrivilageOrganizational customerDO = new PrivilageOrganizational();
|
|
|
|
|
customerDO.setId(orgRelationVO.getCustomerId());
|
|
|
|
|
customerDO.setName(orgRelationVO.getCustomer());
|
|
|
|
|
customerDO.setLevel((long)LEVEL_CUSTOMER);
|
|
|
|
|
customerDO.setParentId(orgRelationVO.getCompanyId());
|
|
|
|
|
tmpOrgList.add(regionDO);
|
|
|
|
|
tmpOrgList.add(companyDO);
|
|
|
|
|
tmpOrgList.add(customerDO);
|
|
|
|
|
});
|
|
|
|
|
List<PrivilageOrganizational> orgList = tmpOrgList.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
return orgList;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|