Commit 809838a8 by 墨竹

feat:门店权限所有门店返回-1

parent 6be234b3
......@@ -250,7 +250,7 @@ public interface StaffApiService {
/**
* 导购gic门店和好办企业门店交集
* 超管返回所有门店
* 所有门店返回所有门店列表
*
* @param clerkId 职员id
* @param wxEnterpriseId wx企业标识
......@@ -260,6 +260,18 @@ public interface StaffApiService {
*/
List<String> getHaoBanStoreRolesByClerkId(String clerkId, String wxEnterpriseId);
/**
* 导购gic门店和好办企业门店交集
* 所有门店返回 -1
*
* @param clerkId 职员id
* @param wxEnterpriseId wx企业标识
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-06-01 11:04:40
*/
List<String> getHaoBanStoreIdsRolesByClerkId(String clerkId, String wxEnterpriseId);
/**
* 门店筛选器id和好办企业门店交集
......
......@@ -104,4 +104,18 @@ public interface TabHaobanStoreRelationMapper {
@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId);
/**
* 查询所有门店分组id
*
* @param wxEnterpriseId wx企业标识
* @param enterpriseId 企业标识
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-06-01 10:34:17
*/
List<String> listStoreGroupIdByWxEnterpriseId(@Param("wxEnterpriseId") String wxEnterpriseId,
@Param("enterpriseId") String enterpriseId);
}
\ No newline at end of file
......@@ -118,4 +118,15 @@ public interface StoreRangeService {
*/
boolean isFlagByStoreId(String storeId, String wxEnterpriseId, String enterpriseId);
/**
* 查询所有门店分组id
*
* @param wxEnterpriseId wx企业标识
* @param enterpriseId 企业标识
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-06-01 10:34:17
*/
List<String> listStoreGroupIdByWxEnterpriseId(String wxEnterpriseId, String enterpriseId);
}
......@@ -272,4 +272,9 @@ public class StoreRangeServiceImpl implements StoreRangeService {
List<String> storeIds = tabHaobanStoreRelationMapper.listStoreIdByStoreIdWxEnterpriseId(storeId, wxEnterpriseId, enterpriseId);
return CollectionUtils.isNotEmpty(storeIds);
}
@Override
public List<String> listStoreGroupIdByWxEnterpriseId(String wxEnterpriseId, String enterpriseId) {
return tabHaobanStoreRelationMapper.listStoreGroupIdByWxEnterpriseId(wxEnterpriseId,enterpriseId);
}
}
......@@ -23,6 +23,7 @@ import com.gic.enterprise.api.service.StoreWidgetService;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.base.api.common.ServiceResponse;
import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.common.utils.RolesListUtils;
import com.gic.haoban.common.utils.StringUtil;
import com.gic.haoban.common.utils.UuidUtil;
import com.gic.haoban.manage.api.dto.*;
......@@ -30,7 +31,6 @@ import com.gic.haoban.manage.api.enums.SecretTypeEnum;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.dao.mapper.StaffDepartmentRelatedMapper;
import com.gic.haoban.manage.service.dao.mapper.StaffMapper;
import com.gic.haoban.manage.service.dao.mapper.WxEnterpriseRelatedMapper;
import com.gic.haoban.manage.service.entity.*;
import com.gic.haoban.manage.service.service.*;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
......@@ -44,7 +44,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -1297,14 +1297,16 @@ public class StaffApiServiceImpl implements StaffApiService {
@Override
public List<String> getHaoBanStoreRolesByClerkId(String clerkId, String wxEnterpriseId) {
if(StringUtils.isBlank(clerkId) || StringUtils.isBlank(wxEnterpriseId)) {
logger.info("参数为空clerkId={},wxEid={}", clerkId,wxEnterpriseId);
logger.info("查询导购权限,clerkId={},wxEnterpriseId={}", clerkId, wxEnterpriseId);
if (StringUtils.isAnyBlank(clerkId, wxEnterpriseId)) {
logger.info("参数为空clerkId={},wxEnterpriseId={}", clerkId, wxEnterpriseId);
return Collections.emptyList();
}
String cacheKey = "hb:clerk:store:"+clerkId +wxEnterpriseId;
Object cache = RedisUtil.getCache(cacheKey) ;
String cacheKey = "hb:clerk:store:" + clerkId + wxEnterpriseId;
Object cache = RedisUtil.getCache(cacheKey);
if (cache != null) {
logger.info("从缓存中获取通道={},{}", cacheKey,JSON.toJSONString(cache));
logger.info("从缓存中获取通道={},{}", cacheKey, JSON.toJSONString(cache));
return (List<String>) cache;
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
......@@ -1312,9 +1314,10 @@ public class StaffApiServiceImpl implements StaffApiService {
logger.info("导购不存在:clerkId:{}", clerkId);
return Collections.emptyList();
}
List<String> enterpriseIdStoreIds = storeRangeService.listStoreIdByWxEnterpriseId(wxEnterpriseId, clerkDTO.getEnterpriseId());
if(CollectionUtils.isEmpty(enterpriseIdStoreIds)) {
logger.info("好办门店空,eid={}", clerkDTO.getEnterpriseId());
String enterpriseId = clerkDTO.getEnterpriseId();
List<String> enterpriseIdStoreIds = storeRangeService.listStoreIdByWxEnterpriseId(wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(enterpriseIdStoreIds)) {
logger.info("好办门店空,eid={}", enterpriseId);
return Collections.emptyList();
}
logger.info("好办门店id数量:{}", enterpriseIdStoreIds.size());
......@@ -1324,16 +1327,70 @@ public class StaffApiServiceImpl implements StaffApiService {
return Collections.emptyList();
}
if (gicStoreIds.contains("-1")) {
//gic管理员返回好办企业
RedisUtil.setCache(cacheKey, enterpriseIdStoreIds , 10L ,TimeUnit.MINUTES);
logger.info("gic超管,clerkId:{}", clerkId);
RedisUtil.setCache(cacheKey, enterpriseIdStoreIds, 10L, TimeUnit.MINUTES);
return enterpriseIdStoreIds;
}
logger.info("gic门店数量:{}", gicStoreIds.size());
//取交集
Sets.SetView<String> intersection = Sets.intersection(Sets.newHashSet(enterpriseIdStoreIds), Sets.newHashSet(gicStoreIds));
List<String> storeList = intersection.stream().collect(Collectors.toList());
List<String> storeList = RolesListUtils.mergeList(enterpriseIdStoreIds, gicStoreIds);
logger.info("该导购权限:clerkId:{},门店数量:{}", clerkId, storeList.size());
RedisUtil.setCache(cacheKey, storeList , 10L ,TimeUnit.MINUTES);
RedisUtil.setCache(cacheKey, storeList, 10L, TimeUnit.MINUTES);
return storeList;
}
@Override
public List<String> getHaoBanStoreIdsRolesByClerkId(String clerkId, String wxEnterpriseId) {
logger.info("查询导购权限,clerkId={},wxEnterpriseId={}", clerkId, wxEnterpriseId);
if (StringUtils.isAnyBlank(clerkId, wxEnterpriseId)) {
logger.info("参数为空clerkId={},wxEnterpriseId={}", clerkId, wxEnterpriseId);
return Collections.emptyList();
}
String cacheKey = "hb:clerk:store:" + clerkId + wxEnterpriseId;
Object cache = RedisUtil.getCache(cacheKey);
if (cache != null) {
logger.info("从缓存中获取通道={},{}", cacheKey, JSON.toJSONString(cache));
return (List<String>) cache;
}
ClerkDTO clerkDTO = clerkService.getClerkByClerkId(clerkId);
if (clerkDTO == null) {
logger.info("导购不存在:clerkId:{}", clerkId);
return Collections.emptyList();
}
String enterpriseId = clerkDTO.getEnterpriseId();
List<String> enterpriseIdStoreIds = storeRangeService.listStoreIdByWxEnterpriseId(wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(enterpriseIdStoreIds)) {
logger.info("好办门店空,eid={}", enterpriseId);
return Collections.emptyList();
}
logger.info("好办门店id数量:{}", enterpriseIdStoreIds.size());
List<String> gicStoreIds = getStoreIdList(clerkDTO);
if (CollectionUtils.isEmpty(gicStoreIds)) {
logger.info("gic门店为空");
return Collections.emptyList();
}
if (gicStoreIds.contains("-1")) {
logger.info("gic超管,clerkId:{}", clerkId);
List<String> storeGroupIds = storeRangeService.listStoreGroupIdByWxEnterpriseId(wxEnterpriseId, enterpriseId);
if (CollectionUtils.isEmpty(storeGroupIds)) {
logger.info("好办门店分组id为空");
return Collections.emptyList();
}
String[] array = storeGroupIds.toArray(new String[0]);
List<StoreGroupDTO> storeGroupDTOS = storeGroupService.listStoreGroup(array, enterpriseId);
List<String> parentGroupIds = storeGroupDTOS.stream().map(StoreGroupDTO::getParentGroupId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(parentGroupIds) && parentGroupIds.contains("0")) {
logger.info("gic是超管,企微包含所有门店,clerkId:{}", clerkId);
enterpriseIdStoreIds = Collections.singletonList("-1");
}
RedisUtil.setCache(cacheKey, enterpriseIdStoreIds, 10L, TimeUnit.MINUTES);
return enterpriseIdStoreIds;
}
logger.info("gic门店数量:{}", gicStoreIds.size());
//取交集
List<String> storeList = RolesListUtils.mergeList(enterpriseIdStoreIds, gicStoreIds);
logger.info("该导购权限:clerkId:{},门店数量:{}", clerkId, storeList.size());
RedisUtil.setCache(cacheKey, storeList, 10L, TimeUnit.MINUTES);
return storeList;
}
......@@ -1341,9 +1398,7 @@ public class StaffApiServiceImpl implements StaffApiService {
public List<String> getHaoBanStoreRolesByStoreWidgetId(String storeWidgetId, String wxEnterpriseId, String enterpriseId) {
List<String> enterpriseIdStoreIds = storeRangeService.listStoreIdByWxEnterpriseId(wxEnterpriseId, enterpriseId);
List<String> storeWidgetIdStoreIds = getStoreWidgetIdStoreIds(storeWidgetId, enterpriseId);
//取交集
Sets.SetView<String> intersection = Sets.intersection(Sets.newHashSet(enterpriseIdStoreIds), Sets.newHashSet(storeWidgetIdStoreIds));
return intersection.stream().collect(Collectors.toList());
return RolesListUtils.mergeList(enterpriseIdStoreIds, storeWidgetIdStoreIds);
}
@Override
......@@ -1369,13 +1424,13 @@ public class StaffApiServiceImpl implements StaffApiService {
/**
* 门店筛选器id企业端获取gic门店id列表
*
* @param clerkId 职员id
* @param clerkDTO 职员dto
* @return {@link List }<{@link String }>
* @author mozhu
* @date 2022-05-06 16:00:05
* @date 2022-06-01 11:08:41
*/
private List<String> getStoreIdList(ClerkDTO clerkDTO) {
String clerkId = clerkDTO.getClerkId() ;
String clerkId = clerkDTO.getClerkId();
Integer superAdmin = clerkDTO.getSuperAdmin();
if (superAdmin != null && superAdmin == 1) {
logger.info("gic超管,clerkId:{}", clerkId);
......@@ -1385,7 +1440,7 @@ public class StaffApiServiceImpl implements StaffApiService {
String enterpriseId = clerkDTO.getEnterpriseId();
EnterpriseSettingDTO enterpriseSetting = enterpriseService.getEnterpriseSettingByEnterpriseId(enterpriseId);
if (enterpriseSetting.getEnableAccessControl() != null && enterpriseSetting.getEnableAccessControl() == 1) {
String storeWidgetId = this.powerService.getStoreWidgetId(new Date() , clerkId) ;
String storeWidgetId = this.powerService.getStoreWidgetId(new Date(), clerkId);
if (StringUtils.isBlank(storeWidgetId)) {
logger.info("导购权限不存在");
return Collections.emptyList();
......@@ -1423,7 +1478,7 @@ public class StaffApiServiceImpl implements StaffApiService {
if (CollectionUtils.isEmpty(storeIdList)) {
return Collections.emptyList();
}
logger.info("门店筛选器查询结果:{}", JSON.toJSONString(storeIdList));
logger.info("门店筛选器查询结果数量:{}", storeIdList.size());
return storeIdList;
}
}
......@@ -223,4 +223,12 @@
and store_id = #{storeId}
and status_flag = 1
</select>
<select id="listStoreGroupIdByWxEnterpriseId" resultType="String">
select store_group_id
from tab_haoban_store_relation
where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
and enterprise_id = #{enterpriseId,jdbcType=VARCHAR}
and status_flag = 1 group by store_group_id
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment