1.优化充值跳转链接的问题
2.优化后台渠道管理页面的显示样式
This commit is contained in:
@@ -9,13 +9,14 @@ use support\think\Db;
|
||||
|
||||
/**
|
||||
* 后台管理员渠道数据范围:
|
||||
* - 账号 channel_id 或角色组 channel_id 任一绑定 → 仅可读对应渠道(优先于「查看所有渠道」)
|
||||
* - 均未绑定且拥有 viewAllChannels → 全平台只读
|
||||
* - 账号或角色组绑定 channel_id → 仅该批渠道(读+写)
|
||||
* - 均未绑定且拥有渠道模块基础权限(channel/index、edit 等)→ 全部渠道(读+写)
|
||||
* - 均未绑定且无渠道模块权限 → 不可见
|
||||
*/
|
||||
class AdminChannelScopeService
|
||||
{
|
||||
/**
|
||||
* 是否具备全平台只读范围(超管 / 未绑定任何渠道且拥有查看所有渠道)
|
||||
* 是否具备全平台只读范围(其它菜单按 admin 收窄时跳过):超管 / 未绑定渠道且拥有渠道模块权限
|
||||
*/
|
||||
public static function hasGlobalReadScope(Auth $auth): bool
|
||||
{
|
||||
@@ -29,7 +30,7 @@ class AdminChannelScopeService
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::hasViewAllChannelsPermission($auth);
|
||||
return self::hasAnyChannelMenuPermission($auth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,24 @@ class AdminChannelScopeService
|
||||
* @return array<int, int>|null
|
||||
*/
|
||||
public static function readableChannelIds(Auth $auth): ?array
|
||||
{
|
||||
return self::resolveScopedChannelIds($auth);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可写渠道 ID 列表;null 表示不限制(全部渠道)
|
||||
*
|
||||
* @return array<int, int>|null
|
||||
*/
|
||||
public static function writableChannelIds(Auth $auth): ?array
|
||||
{
|
||||
return self::resolveScopedChannelIds($auth);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, int>|null
|
||||
*/
|
||||
private static function resolveScopedChannelIds(Auth $auth): ?array
|
||||
{
|
||||
if (!$auth->isLogin()) {
|
||||
return [0];
|
||||
@@ -51,13 +70,55 @@ class AdminChannelScopeService
|
||||
return $ids;
|
||||
}
|
||||
|
||||
if (self::hasViewAllChannelsPermission($auth)) {
|
||||
if (self::hasAnyChannelMenuPermission($auth)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否拥有渠道管理模块相关权限(菜单或任一 channel/* 按钮)
|
||||
*/
|
||||
public static function hasAnyChannelMenuPermission(Auth $auth): bool
|
||||
{
|
||||
if (!$auth->isLogin()) {
|
||||
return false;
|
||||
}
|
||||
if ($auth->isSuperAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$checkNodes = [
|
||||
'channel',
|
||||
'channel/index',
|
||||
'channel/add',
|
||||
'channel/edit',
|
||||
'channel/del',
|
||||
'channel/manualSettle',
|
||||
'channel/batchSettlePending',
|
||||
'channel/settleStats',
|
||||
];
|
||||
foreach ($checkNodes as $node) {
|
||||
if ($auth->check($node)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$ruleList = $auth->getRuleList();
|
||||
foreach ($ruleList as $name) {
|
||||
if (!is_string($name) || $name === '') {
|
||||
continue;
|
||||
}
|
||||
$lower = strtolower($name);
|
||||
if ($lower === 'channel' || str_starts_with($lower, 'channel/')) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员实际绑定的渠道(角色组 channel_id + 账号 admin.channel_id,去重)
|
||||
*
|
||||
@@ -124,30 +185,6 @@ class AdminChannelScopeService
|
||||
return array_values(array_unique($ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否拥有「查看所有渠道」按钮权限
|
||||
*/
|
||||
public static function hasViewAllChannelsPermission(Auth $auth): bool
|
||||
{
|
||||
if (!$auth->isLogin()) {
|
||||
return false;
|
||||
}
|
||||
$nodes = ['channel/viewAllChannels', 'channel/viewallchannels'];
|
||||
foreach ($nodes as $node) {
|
||||
if ($auth->check($node)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$ruleList = $auth->getRuleList();
|
||||
foreach ($nodes as $node) {
|
||||
if (in_array(strtolower($node), $ruleList, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表按 channel_id 过滤时使用的 ID;null=不过滤
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user