1.优化后端管理员提现方式

2.优化后端
This commit is contained in:
2026-04-23 14:11:55 +08:00
parent aa1299c018
commit 378be9909d
9 changed files with 362 additions and 175 deletions

View File

@@ -3,7 +3,6 @@
namespace app\admin\controller\order;
use app\common\controller\Backend;
use support\think\Db;
use support\Response;
use Webman\Http\Request as WebmanRequest;
@@ -79,8 +78,7 @@ class BetOrder extends Backend
$table = strtolower($this->model->getTable());
$mainShort = $alias[$table] ?? '';
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
$channelIds = $this->getScopedChannelIdsForFilter();
$where[] = [$mainShort . '.channel_id', 'in', $channelIds !== [] ? $channelIds : [0]];
$where[] = ['user.admin_id', '=', intval(strval($this->auth->id))];
}
$res = $this->model
@@ -103,25 +101,4 @@ class BetOrder extends Backend
]);
}
/**
* @return int[]
*/
private function getScopedChannelIdsForFilter(): array
{
if (!$this->auth) {
return [0];
}
if ($this->auth->isSuperAdmin()) {
return [];
}
$admin = Db::name('admin')
->field(['id', 'channel_id'])
->where('id', $this->auth->id)
->find();
$ids = [];
if ($admin && !empty($admin['channel_id'])) {
$ids[] = $admin['channel_id'];
}
return array_values(array_unique($ids));
}
}

View File

@@ -3,7 +3,6 @@
namespace app\admin\controller\order;
use app\common\controller\Backend;
use support\think\Db;
use support\Response;
use Webman\Http\Request as WebmanRequest;
@@ -49,8 +48,7 @@ class DepositOrder extends Backend
$table = strtolower($this->model->getTable());
$mainShort = $alias[$table] ?? '';
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
$channelIds = $this->getScopedChannelIdsForFilter();
$where[] = [$mainShort . '.channel_id', 'in', $channelIds !== [] ? $channelIds : [0]];
$where[] = ['user.admin_id', '=', intval(strval($this->auth->id))];
}
$this->appendDepositOrderIndexWhere($where, $mainShort);
@@ -115,7 +113,7 @@ class DepositOrder extends Backend
->withJoin($this->withJoinTable, $this->withJoinType)
->with($this->withJoinTable)
->visible([
'user' => ['username', 'phone'],
'user' => ['username', 'phone', 'admin_id'],
'channel' => ['name'],
])
->where($this->model->getTable() . '.id', $id)
@@ -131,36 +129,18 @@ class DepositOrder extends Backend
if (!$this->auth || $this->auth->isSuperAdmin()) {
return true;
}
$channelIds = $this->getScopedChannelIdsForFilter();
if ($channelIds === []) {
$userRow = $row['user'] ?? null;
if (!is_array($userRow)) {
return false;
}
$raw = $row['channel_id'] ?? null;
if ($raw === null || $raw === '') {
$adminIdRaw = $userRow['admin_id'] ?? null;
if ($adminIdRaw === null || $adminIdRaw === '') {
return false;
}
if (!is_numeric(strval($raw))) {
if (!is_numeric(strval($adminIdRaw))) {
return false;
}
return in_array(intval(strval($raw)), $channelIds, true);
return intval(strval($adminIdRaw)) === intval(strval($this->auth->id));
}
/**
* @return int[]
*/
private function getScopedChannelIdsForFilter(): array
{
if (!$this->auth) {
return [0];
}
if ($this->auth->isSuperAdmin()) {
return [];
}
$admin = Db::name('admin')->field(['id', 'channel_id'])->where('id', $this->auth->id)->find();
$ids = [];
if ($admin && !empty($admin['channel_id'])) {
$ids[] = $admin['channel_id'];
}
return array_values(array_unique($ids));
}
}

View File

@@ -48,8 +48,7 @@ class WithdrawOrder extends Backend
$table = strtolower($this->model->getTable());
$mainShort = $alias[$table] ?? '';
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
$channelIds = $this->getScopedChannelIdsForFilter();
$where[] = [$mainShort . '.channel_id', 'in', $channelIds !== [] ? $channelIds : [0]];
$where[] = ['user.admin_id', '=', intval(strval($this->auth->id))];
}
$res = $this->model
@@ -386,17 +385,17 @@ class WithdrawOrder extends Backend
if (!$this->auth || $this->auth->isSuperAdmin()) {
return true;
}
$channelIds = $this->getScopedChannelIdsForFilter();
if ($channelIds === []) {
$uidRaw = is_array($row) ? ($row['user_id'] ?? null) : ($row->user_id ?? null);
$uid = $this->intParam($uidRaw);
if ($uid <= 0) {
return false;
}
$raw = is_array($row) ? ($row['channel_id'] ?? null) : ($row->channel_id ?? null);
if ($raw === null || $raw === '') {
// 无归属渠道的数据只有超管可见
$user = Db::name('user')->field(['id', 'admin_id'])->where('id', $uid)->find();
if (!is_array($user)) {
return false;
}
$cid = $this->intParam($raw);
return in_array($cid, $channelIds, true);
$ownerAdminId = $this->intParam($user['admin_id'] ?? 0);
return $ownerAdminId > 0 && $ownerAdminId === $this->intParam($this->auth->id ?? 0);
}
private function intParam($raw): int
@@ -453,22 +452,4 @@ class WithdrawOrder extends Backend
return $negative ? ('-' . $v) : $v;
}
/**
* @return int[]
*/
private function getScopedChannelIdsForFilter(): array
{
if (!$this->auth) {
return [0];
}
if ($this->auth->isSuperAdmin()) {
return [];
}
$admin = Db::name('admin')->field(['id', 'channel_id'])->where('id', $this->auth->id)->find();
$ids = [];
if ($admin && !empty($admin['channel_id'])) {
$ids[] = $admin['channel_id'];
}
return array_values(array_unique($ids));
}
}