1.优化渠道管理中直属投注额度和总投注额度

2.管理员管理中三个菜单数据显示限制
This commit is contained in:
2026-05-30 15:53:36 +08:00
parent 16a7ef7413
commit f6197a9af5
13 changed files with 195 additions and 92 deletions

View File

@@ -25,6 +25,7 @@ class Channel extends Backend
'settleStats',
'dividendRecordList',
'directBetRecordList',
'companyBetRecordList',
'settlementBetRecordList',
];
@@ -751,6 +752,7 @@ class Channel extends Backend
}
}
$paidDividendTotal = '0.00';
$companyTotalBetAmount = '0.00';
if ($channelIdList !== []) {
$paidRow = Db::name('agent_commission_record')
->where('channel_id', 'in', $channelIdList)
@@ -758,6 +760,12 @@ class Channel extends Backend
->field('SUM(commission_amount) AS s')
->find();
$paidDividendTotal = bcadd(strval(is_array($paidRow) ? ($paidRow['s'] ?? '0') : '0'), '0', 2);
$companyBetRow = Db::name('game_play_record')
->where('channel_id', 'in', $channelIdList)
->field('SUM(total_amount) AS s')
->find();
$companyTotalBetAmount = bcadd(strval(is_array($companyBetRow) ? ($companyBetRow['s'] ?? '0') : '0'), '0', 2);
}
return $this->success('', [
'channel_total' => $total,
@@ -767,6 +775,7 @@ class Channel extends Backend
'carryover_total' => $carryoverTotal,
'carryover_positive_total' => $carryoverPositiveTotal,
'paid_dividend_total' => $paidDividendTotal,
'company_total_bet_amount' => $companyTotalBetAmount,
]);
}
@@ -779,7 +788,7 @@ class Channel extends Backend
if ($response !== null) {
return $response;
}
if (!$this->auth->check('channel/viewDividendRecords')) {
if (!$this->auth->check('channel/index')) {
return $this->error(__('You have no permission'));
}
@@ -840,7 +849,7 @@ class Channel extends Backend
}
/**
* 渠道直属玩家下注记录(直属投注额列点击)
* 渠道直属玩家下注记录(直属投注额列点击;该渠道名下玩家全部注单
*/
public function directBetRecordList(WebmanRequest $request): Response
{
@@ -848,7 +857,7 @@ class Channel extends Backend
if ($response !== null) {
return $response;
}
if (!$this->auth->check('channel/viewDirectBetRecords')) {
if (!$this->auth->check('channel/index')) {
return $this->error(__('You have no permission'));
}
@@ -861,27 +870,31 @@ class Channel extends Backend
}
/**
* 参与分红口径的下注记录(操作列「查看总投注金额」
* 公司总投注记录下注明细(顶部公司总投注额点击;含未结算,当前账号可见渠道范围
*/
public function settlementBetRecordList(WebmanRequest $request): Response
public function companyBetRecordList(WebmanRequest $request): Response
{
$response = $this->initializeBackend($request);
if ($response !== null) {
return $response;
}
if (!$this->auth->check('channel/viewSettlementBetRecords')) {
if (!$this->auth->check('channel/index')) {
return $this->error(__('You have no permission'));
}
$channelId = (int) ($request->get('channel_id', 0));
if ($channelId <= 0 || !$this->assertChannelAccessible($channelId)) {
return $this->error(__('You have no permission'));
}
return $this->success('', $this->fetchChannelPlayRecordListPayload($request, $channelId, true));
return $this->success('', $this->fetchChannelPlayRecordListPayload($request, 0, false));
}
/**
* @deprecated 请使用 companyBetRecordList
*/
public function settlementBetRecordList(WebmanRequest $request): Response
{
return $this->companyBetRecordList($request);
}
/**
* @param int $channelId 0=当前账号可见全部渠道
* @return array{list: array<int, array<string, mixed>>, total: int, summary: array{record_count:int,total_bet_amount:string,total_win_amount:string}}
*/
private function fetchChannelPlayRecordListPayload(WebmanRequest $request, int $channelId, bool $settledOnly): array
@@ -1054,8 +1067,21 @@ class Channel extends Backend
$query = Db::name('game_play_record')->alias('pr')
->leftJoin('user u', 'u.id = pr.user_id')
->leftJoin('game_record gr', 'gr.id = pr.period_id')
->leftJoin('channel c', 'c.id = pr.channel_id')
->where('pr.channel_id', $channelId);
->leftJoin('channel c', 'c.id = pr.channel_id');
if ($channelId > 0) {
if (!$this->assertChannelAccessible($channelId)) {
$query->where('pr.channel_id', 0);
return $query;
}
$query->where('pr.channel_id', $channelId);
} else {
$scope = $this->readableChannelIds();
if ($scope === []) {
$query->where('pr.channel_id', 0);
} elseif ($scope !== null) {
$query->whereIn('pr.channel_id', $scope);
}
}
if ($settledOnly) {
$query->where('pr.status', 2);
}

View File

@@ -38,9 +38,9 @@ class AdminWallet extends Backend
list($where, $alias, $limit, $order) = $this->queryBuilder();
$table = strtolower($this->model->getTable());
$mainShort = $alias[$table] ?? '';
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
// 非超管仅可查看自己钱包
$where[] = [$mainShort . '.admin_id', '=', intval($this->auth->id ?? 0)];
$scopedAdminIds = $this->getManageableScopeAdminIds();
if ($mainShort !== '' && $scopedAdminIds !== []) {
$where[] = [$mainShort . '.admin_id', 'in', $scopedAdminIds];
}
$res = $this->model
->withJoin($this->withJoinTable, $this->withJoinType)

View File

@@ -37,8 +37,9 @@ class AdminWalletRecord extends Backend
list($where, $alias, $limit, $order) = $this->queryBuilder();
$table = strtolower($this->model->getTable());
$mainShort = $alias[$table] ?? '';
if ($mainShort !== '' && $this->auth && !$this->auth->isSuperAdmin()) {
$where[] = [$mainShort . '.admin_id', '=', intval($this->auth->id ?? 0)];
$scopedAdminIds = $this->getManageableScopeAdminIds();
if ($mainShort !== '' && $scopedAdminIds !== []) {
$where[] = [$mainShort . '.admin_id', 'in', $scopedAdminIds];
}
$res = $this->model

View File

@@ -42,9 +42,9 @@ class AdminWithdrawOrder extends Backend
list($where, $alias, $limit, $order) = $this->queryBuilder();
$table = strtolower($this->model->getTable());
$mainShort = $alias[$table] ?? '';
$channelScope = $this->readableChannelIds();
if ($mainShort !== '' && $channelScope !== null) {
$where[] = [$mainShort . '.channel_id', 'in', $channelScope];
$scopedAdminIds = $this->getManageableScopeAdminIds();
if ($mainShort !== '' && $scopedAdminIds !== []) {
$where[] = [$mainShort . '.admin_id', 'in', $scopedAdminIds];
}
$res = $this->model
->withJoin($this->withJoinTable, $this->withJoinType)
@@ -171,9 +171,9 @@ class AdminWithdrawOrder extends Backend
return $response;
}
$query = Db::name('admin_withdraw_order');
$channelScope = $this->readableChannelIds();
if ($channelScope !== null) {
$query->where('channel_id', 'in', $channelScope);
$scopedAdminIds = $this->getManageableScopeAdminIds();
if ($scopedAdminIds !== []) {
$query->where('admin_id', 'in', $scopedAdminIds);
}
$rows = $query->field(['status', 'amount', 'actual_amount'])->select()->toArray();
$total = count($rows);
@@ -232,16 +232,16 @@ class AdminWithdrawOrder extends Backend
if ($this->auth->isSuperAdmin() || $this->hasGlobalReadScope()) {
return true;
}
$channelId = intval($order['channel_id'] ?? 0);
if ($channelId <= 0) {
$adminId = intval($order['admin_id'] ?? 0);
if ($adminId <= 0) {
return false;
}
$allowed = $this->readableChannelIds();
if ($allowed === null) {
$scopedAdminIds = $this->getManageableScopeAdminIds();
if ($scopedAdminIds === []) {
return true;
}
return in_array($channelId, $allowed, true);
return in_array($adminId, $scopedAdminIds, true);
}
}

View File

@@ -7,6 +7,8 @@ namespace app\common\controller;
use Throwable;
use app\admin\library\Auth;
use app\common\service\AdminChannelScopeService;
use app\common\service\AdminCommissionDistributionService;
use support\think\Db;
use app\common\library\token\TokenExpirationException;
use app\admin\library\traits\Backend as BackendTrait;
use support\Response;
@@ -542,4 +544,49 @@ class Backend extends Api
return array_values(array_unique($paths));
}
/**
* 角色组管理范围内可见的管理员 ID本人 + 代理树下级 + 本人所在组及下级组内管理员)
* 超管或全平台只读范围返回空数组表示不限制
*
* @return int[]
*/
protected function getManageableScopeAdminIds(): array
{
if ($this->auth === null || !$this->auth->isLogin()) {
return [0];
}
if ($this->auth->isSuperAdmin() || $this->hasGlobalReadScope()) {
return [];
}
$operatorId = intval($this->auth->id);
$ids = AdminCommissionDistributionService::getVisibleAdminIdsForOperator($operatorId, false);
$ownGroupIds = Db::name('admin_group_access')->where('uid', $operatorId)->column('group_id');
$childGroupIds = $this->auth->getAdminChildGroups();
$groupIds = array_values(array_unique(array_merge(
array_map(static fn($id) => intval(strval($id)), $ownGroupIds),
array_map(static fn($id) => intval(strval($id)), $childGroupIds)
)));
if ($groupIds !== []) {
$groupAdminIds = Db::name('admin_group_access')
->where('group_id', 'in', $groupIds)
->column('uid');
foreach ($groupAdminIds as $uid) {
$uidInt = intval(strval($uid));
if ($uidInt > 0) {
$ids[] = $uidInt;
}
}
}
if ($operatorId > 0) {
$ids[] = $operatorId;
}
$ids = array_values(array_unique(array_filter($ids, static fn(int $id): bool => $id > 0)));
return $ids === [] ? [0] : $ids;
}
}

View File

@@ -124,7 +124,7 @@ return [
'viewCommissionRecords' => 'View commission records',
'viewDividendRecords' => 'View paid dividend records',
'viewDirectBetRecords' => 'View direct bet records',
'viewSettlementBetRecords' => 'View settlement-scope bets',
'viewSettlementBetRecords' => 'View company bet records',
'viewAllChannels' => 'View all channels',
// 其它中文按钮文案

View File

@@ -56,7 +56,7 @@ return [
'viewCommissionRecords' => '查看代理佣金记录',
'viewDividendRecords' => '查看已分红记录',
'viewDirectBetRecords' => '查看直属投注记录',
'viewSettlementBetRecords' => '查看总投注金额',
'viewSettlementBetRecords' => '查看公司总投注记录',
'viewAllChannels' => '查看所有渠道',
'walletAdjust' => '钱包加减点',
'Markdown文档' => 'Markdown文档',