1.优化充值跳转链接的问题
2.优化后台渠道管理页面的显示样式
This commit is contained in:
@@ -22,7 +22,6 @@ class Channel extends Backend
|
||||
'manualSettlePreview',
|
||||
'channelAdminShareList',
|
||||
'saveChannelAdminShare',
|
||||
'batchSettlePending',
|
||||
'settleStats',
|
||||
'dividendRecordList',
|
||||
'directBetRecordList',
|
||||
@@ -44,13 +43,9 @@ class Channel extends Backend
|
||||
|
||||
protected bool $modelSceneValidate = true;
|
||||
|
||||
/** @var array<int, int> 当前管理员绑定的渠道(写操作范围) */
|
||||
private array $ownChannelIds = [];
|
||||
|
||||
protected function initController(WebmanRequest $request): ?Response
|
||||
{
|
||||
$this->model = new \app\common\model\Channel();
|
||||
$this->ownChannelIds = $this->resolveOwnChannelIds();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -257,7 +252,7 @@ class Channel extends Backend
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除:仅允许删除本人绑定渠道(查看所有渠道不扩大写权限)
|
||||
* 删除:须在可写渠道范围内
|
||||
*/
|
||||
protected function _del(): Response
|
||||
{
|
||||
@@ -685,8 +680,12 @@ class Channel extends Backend
|
||||
}
|
||||
|
||||
$remark = trim((string) $request->post('remark', ''));
|
||||
$handlingFeeByAdmin = $this->parseCommissionSplitHandlingFees($request->post('commission_split'));
|
||||
if ($handlingFeeByAdmin === false) {
|
||||
return $this->error(__('Settlement handling fee rate must be between 0 and 100'));
|
||||
}
|
||||
|
||||
$res = ChannelSettlementService::settleBySuperAdmin((int) $row['id'], intval($this->auth->id), $remark, false);
|
||||
$res = ChannelSettlementService::settleBySuperAdmin((int) $row['id'], intval($this->auth->id), $remark, false, $handlingFeeByAdmin);
|
||||
if (($res['ok'] ?? false) !== true) {
|
||||
return $this->error((string) ($res['msg'] ?? __('Settlement failed')));
|
||||
}
|
||||
@@ -694,7 +693,7 @@ class Channel extends Backend
|
||||
}
|
||||
|
||||
/**
|
||||
* 超管批量结算全部待结算渠道(可作为“提前结算”入口)
|
||||
* 批量结算待结算渠道(需 channel/batchSettlePending;范围=当前账号可写渠道)
|
||||
*/
|
||||
public function batchSettlePending(WebmanRequest $request): Response
|
||||
{
|
||||
@@ -702,11 +701,15 @@ class Channel extends Backend
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
if (!$this->auth->isSuperAdmin()) {
|
||||
if (!$this->canBatchSettle()) {
|
||||
return $this->error(__('You have no permission'));
|
||||
}
|
||||
$scope = AdminChannelScopeService::writableChannelIds($this->auth);
|
||||
if ($scope !== null && $scope === []) {
|
||||
return $this->error(__('You have no permission'));
|
||||
}
|
||||
// 批量按钮语义:手动触发“待结算渠道”结算,不受结算周期到点限制。
|
||||
$res = ChannelSettlementService::settleAllDueChannels(intval($this->auth->id), false);
|
||||
$res = ChannelSettlementService::settleAllDueChannels(intval($this->auth->id), false, $scope);
|
||||
return $this->success(__('Batch settlement completed'), $res);
|
||||
}
|
||||
|
||||
@@ -1003,13 +1006,15 @@ class Channel extends Backend
|
||||
|
||||
private function assertChannelWritable(int $channelId): bool
|
||||
{
|
||||
if ($channelId <= 0) {
|
||||
if ($channelId <= 0 || $this->auth === null) {
|
||||
return false;
|
||||
}
|
||||
if ($this->auth->isSuperAdmin()) {
|
||||
$scope = AdminChannelScopeService::writableChannelIds($this->auth);
|
||||
if ($scope === null) {
|
||||
return Db::name('channel')->where('id', $channelId)->value('id') !== null;
|
||||
}
|
||||
return in_array($channelId, $this->ownChannelIds, true);
|
||||
|
||||
return in_array($channelId, $scope, true);
|
||||
}
|
||||
|
||||
private function assertChannelAccessible(int $channelId): bool
|
||||
@@ -1032,6 +1037,18 @@ class Channel extends Backend
|
||||
return $this->auth->check('channel/manualSettle');
|
||||
}
|
||||
|
||||
private function canBatchSettle(): bool
|
||||
{
|
||||
if ($this->auth === null) {
|
||||
return false;
|
||||
}
|
||||
if ($this->auth->isSuperAdmin()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->auth->check('channel/batchSettlePending');
|
||||
}
|
||||
|
||||
private function buildChannelPlayRecordQuery(int $channelId, bool $settledOnly)
|
||||
{
|
||||
$query = Db::name('game_play_record')->alias('pr')
|
||||
@@ -1412,34 +1429,6 @@ class Channel extends Backend
|
||||
return $chosen;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, int>
|
||||
*/
|
||||
/**
|
||||
* 写操作可作用的渠道(角色组绑定渠道 + 账号 channel_id,不含全平台只读)
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
private function resolveOwnChannelIds(): array
|
||||
{
|
||||
if ($this->auth === null) {
|
||||
return [];
|
||||
}
|
||||
$ids = AdminChannelScopeService::resolveBoundGroupChannelIds($this->auth);
|
||||
if ($ids !== []) {
|
||||
return $ids;
|
||||
}
|
||||
$admin = Db::name('admin')
|
||||
->field(['id', 'channel_id'])
|
||||
->where('id', $this->auth->id)
|
||||
->find();
|
||||
if ($admin && !empty($admin['channel_id'])) {
|
||||
$ids[] = (int) $admin['channel_id'];
|
||||
}
|
||||
|
||||
return array_values(array_unique($ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 佣金归属管理员:取该渠道下 admin.channel_id 匹配的首个管理员(按 id 升序)。
|
||||
*/
|
||||
@@ -1656,6 +1645,16 @@ class Channel extends Backend
|
||||
}
|
||||
|
||||
$mode = isset($data['agent_mode']) ? (string) $data['agent_mode'] : '';
|
||||
if (isset($data['settlement_handling_fee']) && $data['settlement_handling_fee'] !== '' && $data['settlement_handling_fee'] !== null) {
|
||||
$fee = (float) $data['settlement_handling_fee'];
|
||||
if ($fee < 0 || $fee > 100) {
|
||||
return (string) __('Settlement handling fee rate must be between 0 and 100');
|
||||
}
|
||||
$data['settlement_handling_fee'] = number_format($fee, 2, '.', '');
|
||||
} else {
|
||||
$data['settlement_handling_fee'] = '0.00';
|
||||
}
|
||||
|
||||
if ($mode === 'turnover') {
|
||||
if (isset($data['turnover_share_rate']) && $data['turnover_share_rate'] !== '' && $data['turnover_share_rate'] !== null) {
|
||||
$num = (float) $data['turnover_share_rate'];
|
||||
@@ -1714,6 +1713,33 @@ class Channel extends Backend
|
||||
return $negative ? ('-' . $v) : $v;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>|null|false admin_id => 手续费比例(%);false=比例非法
|
||||
*/
|
||||
private function parseCommissionSplitHandlingFees(mixed $splitRaw): array|null|false
|
||||
{
|
||||
if (!is_array($splitRaw) || $splitRaw === []) {
|
||||
return null;
|
||||
}
|
||||
$map = [];
|
||||
foreach ($splitRaw as $item) {
|
||||
if (!is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
$adminId = intval($item['admin_id'] ?? 0);
|
||||
if ($adminId <= 0) {
|
||||
continue;
|
||||
}
|
||||
$rateRaw = $item['handling_fee_rate'] ?? ($item['handling_fee'] ?? '0');
|
||||
$rate = bcadd(strval($rateRaw), '0', 2);
|
||||
if (bccomp($rate, '0', 2) < 0 || bccomp($rate, '100', 2) > 0) {
|
||||
return false;
|
||||
}
|
||||
$map[$adminId] = $rate;
|
||||
}
|
||||
return $map === [] ? null : $map;
|
||||
}
|
||||
|
||||
private function validateLadderRulesField(array &$data): ?string
|
||||
{
|
||||
$rulesRaw = $data['affiliate_ladder_rules'] ?? null;
|
||||
|
||||
Reference in New Issue
Block a user