|
|
|
@ -2,6 +2,10 @@ package com.kiisoo.ic.store.service;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.kiisoo.ic.activity.entity.PmnActivityInstance;
|
|
|
|
|
import com.kiisoo.ic.activity.entity.PmnActivityStoreRelation;
|
|
|
|
|
import com.kiisoo.ic.activity.service.IPmnActivityInstanceService;
|
|
|
|
|
import com.kiisoo.ic.activity.service.IPmnActivityStoreRelationService;
|
|
|
|
|
import com.kiisoo.ic.customer.service.CustomerViewService;
|
|
|
|
|
import com.kiisoo.ic.domain.entity.PrivilageDomainEntityDO;
|
|
|
|
|
import com.kiisoo.ic.domain.mapper.PrivilageDomainEntityDOMapper;
|
|
|
|
@ -11,11 +15,8 @@ import com.kiisoo.ic.generalize.mapper.PrivilageOrganizationalDomainMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
|
import com.kiisoo.ic.store.bean.PoiStoreDTO;
|
|
|
|
|
import com.kiisoo.ic.store.bean.PoiStoreStaffDTO;
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -57,40 +58,41 @@ public class PoiStoreService {
|
|
|
|
|
private IPmnActivityInstanceService pmnActivityInstanceService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPmnActivityStoreRelationService storeRelationService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据区域id找到店铺集合
|
|
|
|
|
*
|
|
|
|
|
* @param regionId
|
|
|
|
|
*/
|
|
|
|
|
public List<PoiStore> getRegionShop(long regionId){
|
|
|
|
|
public List<PoiStore> getRegionShop(long regionId) {
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectRegionShop(regionId);
|
|
|
|
|
return poiStores;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据区域id找到店铺集合,若没有,则查用户所有店铺
|
|
|
|
|
* @param regionId
|
|
|
|
|
*/
|
|
|
|
|
public List<PoiStore> getRegionShop(long userId,List<Long> customerIds){
|
|
|
|
|
public List<PoiStore> getRegionShop(long userId, List<Long> customerIds) {
|
|
|
|
|
List<PoiStore> poiStores = new ArrayList<>();
|
|
|
|
|
//找到店铺集合
|
|
|
|
|
List<Long> shopsIds = privilageDomainService.listUserDatePermission(userId);
|
|
|
|
|
if(null != customerIds && customerIds.size()>0){
|
|
|
|
|
if (null != customerIds && customerIds.size() > 0) {
|
|
|
|
|
Set<Long> shopIds = new HashSet<>();
|
|
|
|
|
customerIds.forEach(customerId -> {
|
|
|
|
|
Set<Long> shops = customerViewService.getCompanyShop(customerId,userId);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(shops)){
|
|
|
|
|
Set<Long> shops = customerViewService.getCompanyShop(customerId, userId);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(shops)) {
|
|
|
|
|
shopIds.addAll(shops);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if(shopIds.size() > 0){
|
|
|
|
|
if (shopIds.size() > 0) {
|
|
|
|
|
List<PoiStore> regionPoiStores = poiStoreDOMapper.selectBatchIds(shopIds);
|
|
|
|
|
for(PoiStore item : regionPoiStores){
|
|
|
|
|
if(shopsIds.contains(item.getId())){
|
|
|
|
|
for (PoiStore item : regionPoiStores) {
|
|
|
|
|
if (shopsIds.contains(item.getId())) {
|
|
|
|
|
poiStores.add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
poiStores = poiStoreDOMapper.selectBatchIds(shopsIds);
|
|
|
|
|
}
|
|
|
|
|
return poiStores;
|
|
|
|
@ -98,16 +100,15 @@ public class PoiStoreService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据区域id找到店铺集合,若没有,则查用户所有店铺
|
|
|
|
|
* @param regionId
|
|
|
|
|
*/
|
|
|
|
|
public List<PoiStoreDTO> getRegionShopDTO(long userId,List<Long> customerIds, Long scheduleId){
|
|
|
|
|
public List<PoiStoreDTO> getRegionShopDTO(long userId, List<Long> customerIds, Long scheduleId) {
|
|
|
|
|
List<PoiStoreDTO> poiStores = new ArrayList<>();
|
|
|
|
|
//找到店铺集合
|
|
|
|
|
if(null != customerIds && customerIds.size()>0){
|
|
|
|
|
if (null != customerIds && customerIds.size() > 0) {
|
|
|
|
|
Set<Long> cs = new HashSet<>();
|
|
|
|
|
cs.addAll(customerIds);
|
|
|
|
|
Set<Long> joined = new HashSet<>();
|
|
|
|
|
if(scheduleId != null) {
|
|
|
|
|
if (scheduleId != null) {
|
|
|
|
|
List<PmnActivityInstance> instances = pmnActivityInstanceService.list(Wrappers.<PmnActivityInstance>lambdaQuery().eq(PmnActivityInstance::getScheduleId, scheduleId).select(PmnActivityInstance::getId));
|
|
|
|
|
Set<Long> instanceIds = instances.stream().map(PmnActivityInstance::getId).collect(Collectors.toSet());
|
|
|
|
|
List<PmnActivityStoreRelation> relations = storeRelationService.list(Wrappers.<PmnActivityStoreRelation>lambdaQuery().in(PmnActivityStoreRelation::getInstanceId, instanceIds).select(PmnActivityStoreRelation::getStoreId));
|
|
|
|
@ -118,17 +119,18 @@ public class PoiStoreService {
|
|
|
|
|
Set<Long> domainIds = domains.stream().map(PrivilageOrganizationalDomain::getDomainId).collect(Collectors.toSet());
|
|
|
|
|
List<PrivilageDomainEntityDO> entityDOS = privilageDomainEntityDOMapper.selectList(Wrappers.<PrivilageDomainEntityDO>lambdaQuery().in(PrivilageDomainEntityDO::getDomainId, domainIds).eq(PrivilageDomainEntityDO::getType, 3).select(PrivilageDomainEntityDO::getEntityId));
|
|
|
|
|
Set<Long> shopIds = entityDOS.stream().map(PrivilageDomainEntityDO::getEntityId).collect(Collectors.toSet());
|
|
|
|
|
if(joined.size() > 0) {
|
|
|
|
|
if (joined.size() > 0) {
|
|
|
|
|
shopIds.removeAll(joined);
|
|
|
|
|
}
|
|
|
|
|
if(shopIds.size() > 0){
|
|
|
|
|
if (shopIds.size() > 0) {
|
|
|
|
|
poiStores = poiStoreDOMapper.selectDTOBatchIds(shopIds);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
poiStores = poiStoreDOMapper.selectDTOBatchIds(privilageDomainService.listUserDatePermission(userId));
|
|
|
|
|
}
|
|
|
|
|
return poiStores;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询所有店铺
|
|
|
|
|
*
|
|
|
|
@ -141,20 +143,21 @@ public class PoiStoreService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据区域id找到店铺集合,若没有,则查用户所有店铺
|
|
|
|
|
*
|
|
|
|
|
* @param companyId 零售公司ID
|
|
|
|
|
*/
|
|
|
|
|
public List<PoiStore> getStoreByCompanyId(long userId,Long companyId){
|
|
|
|
|
public List<PoiStore> getStoreByCompanyId(long userId, Long companyId) {
|
|
|
|
|
List<PoiStore> poiStores = new ArrayList<>();
|
|
|
|
|
//找到店铺集合
|
|
|
|
|
List<Long> shopsIds = privilageDomainService.listUserDatePermission(userId);
|
|
|
|
|
if(!companyId.equals(0L)){
|
|
|
|
|
Set<Long> shops = customerViewService.getCompanyShop(companyId,userId);
|
|
|
|
|
if(shops.size() > 0){
|
|
|
|
|
if (!companyId.equals(0L)) {
|
|
|
|
|
Set<Long> shops = customerViewService.getCompanyShop(companyId, userId);
|
|
|
|
|
if (shops.size() > 0) {
|
|
|
|
|
List<PoiStore> regionPoiStores = poiStoreDOMapper.selectBatchIds(shops);
|
|
|
|
|
List<PoiStore> intersection = regionPoiStores.stream().filter(item -> shops.contains(item.getId())).collect(toList());
|
|
|
|
|
return intersection;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
poiStores = poiStoreDOMapper.selectBatchIds(shopsIds);
|
|
|
|
|
}
|
|
|
|
|
return poiStores;
|
|
|
|
|