优化数据归属问题
This commit is contained in:
@@ -48,7 +48,7 @@ class DepositOrder extends Backend
|
||||
$table = strtolower($this->model->getTable());
|
||||
$mainShort = $alias[$table] ?? '';
|
||||
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
|
||||
$where[] = ['user.admin_id', '=', intval(strval($this->auth->id))];
|
||||
$where[] = ['user.admin_id', 'in', $this->scopedAdminIds()];
|
||||
}
|
||||
$this->appendDepositOrderIndexWhere($where, $mainShort);
|
||||
|
||||
@@ -140,7 +140,28 @@ class DepositOrder extends Backend
|
||||
if (!is_numeric(strval($adminIdRaw))) {
|
||||
return false;
|
||||
}
|
||||
return intval(strval($adminIdRaw)) === intval(strval($this->auth->id));
|
||||
return in_array(intval(strval($adminIdRaw)), $this->scopedAdminIds(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前管理员可见的管理员ID集合(本人 + 下级角色组内管理员)
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
private function scopedAdminIds(): array
|
||||
{
|
||||
if (!$this->auth) {
|
||||
return [0];
|
||||
}
|
||||
if ($this->auth->isSuperAdmin()) {
|
||||
return [];
|
||||
}
|
||||
$groupIds = $this->auth->getAdminChildGroups();
|
||||
$adminIds = $groupIds ? $this->auth->getGroupAdmins($groupIds) : [];
|
||||
$adminIds[] = $this->auth->id;
|
||||
$adminIds = array_map(static fn($id) => intval(strval($id)), $adminIds);
|
||||
$adminIds = array_values(array_unique(array_filter($adminIds, static fn($id) => $id > 0)));
|
||||
return $adminIds === [] ? [0] : $adminIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user