feat(agent-profile): 限制代理及玩家返点和分成范围,增强权限校验
- 添加ensureSuperAdmin方法,限制管理员设置操作权限 - 在AdminSettingController接口中新增权限检查,防止非超级管理员操作 - AdminPlayerIndexController新增direct agent筛选支持 - AdminPlayerUpdateController新增对信用玩家默认币别变更的拒绝逻辑 - 新增WalletSettlementBillsController,实现玩家信用盘账期账单摘要接口 - AgentProfileService调整,新增返点限额和分享比例自动下调机制,保持子代理及玩家配置不超父级 - AgentProfileService增加can_grant_extra_rebate权限继承限制,阻止无权限代理开启 - AgentSettlementPeriodCloseService增加玩家账单回水信用释放逻辑,确保信用额度同步 - PlayerCreditService新增释放账单回水对应信用逻辑,维护账期信用一致性 - TicketPlacementService和TicketPreviewService新增信用玩家投注币别匹配校验,防止币别不符 - PlayerLedgerLogsService优化信用额度计算,增加可用额度上下限限制,防止负值和超限 - 调整后台管理导航,仅超管可见设置入口,强化权限隔离 - 路由新增玩家信用账单查询接口 - 补充多项AgentProfile相关单元测试覆盖额度限制、返点继承、返点下调场景及权限限制 - 增加站点管理员登录测试,验证系统设置菜单不可见,提升用户权限体验
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
namespace App\Services\AgentSettlement;
|
||||
|
||||
use App\Models\AgentNode;
|
||||
use App\Models\Player;
|
||||
use App\Services\Agent\AgentCreditAllocatedSyncService;
|
||||
use App\Services\Player\PlayerCreditService;
|
||||
use App\Support\AgentSettlementPeriodWindow;
|
||||
use App\Support\AgentSettlementProductionGuard;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -18,6 +20,7 @@ final class AgentSettlementPeriodCloseService
|
||||
private readonly UnsettledTicketPeriodWarning $unsettledWarning,
|
||||
private readonly PlatformRoundingAdjuster $platformRounding,
|
||||
private readonly AgentCreditAllocatedSyncService $allocatedSync,
|
||||
private readonly PlayerCreditService $playerCreditService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -63,6 +66,7 @@ final class AgentSettlementPeriodCloseService
|
||||
$roundingDiff = $this->platformRounding->apply($periodId, $aggregate);
|
||||
|
||||
$rebateStats = $this->periodCloseRebate->dispatchAndAllocate($periodId, $adminSiteId, $periodStart, $periodEnd);
|
||||
$this->releasePlayerBillRebatesFromCredit($periodId);
|
||||
|
||||
$unsettled = $this->unsettledWarning->countForSite($adminSiteId, $periodStart, $periodEnd);
|
||||
|
||||
@@ -100,6 +104,28 @@ final class AgentSettlementPeriodCloseService
|
||||
});
|
||||
}
|
||||
|
||||
/** 玩家亏损账单里的回水已抵扣应付额,应同步释放同等已用信用。 */
|
||||
private function releasePlayerBillRebatesFromCredit(int $periodId): void
|
||||
{
|
||||
$bills = DB::table('settlement_bills')
|
||||
->where('settlement_period_id', $periodId)
|
||||
->where('bill_type', 'player')
|
||||
->where('owner_type', 'player')
|
||||
->where('gross_win_loss', '>', 0)
|
||||
->where('rebate_amount', '>', 0)
|
||||
->get(['id', 'owner_id', 'gross_win_loss', 'rebate_amount']);
|
||||
|
||||
foreach ($bills as $bill) {
|
||||
$player = Player::query()->find((int) $bill->owner_id);
|
||||
if ($player === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rebateMinor = min((int) $bill->gross_win_loss, (int) $bill->rebate_amount);
|
||||
$this->playerCreditService->releaseRebateInBill($player, $rebateMinor, (int) $bill->id);
|
||||
}
|
||||
}
|
||||
|
||||
/** 关账后按真理源重算各代理「已下发额度」,避免与直属玩家/下级代理授信脱节。 */
|
||||
private function reconcileAllocatedCreditForSite(int $adminSiteId): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user