feat(credit): 实时同步代理已用额度,覆盖玩家下注/结算全流程
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

- PlayerCreditService 在下注占用、输赢结算、撤单释放等关键节点触发 AgentUsedCreditSyncService
- AgentProfileService::present 与 AgentDashboardOverviewBuilder 查询前主动同步 used_credit
- 确保代理链 used_credit(团队已用风险)实时反映下级玩家信用占用状态
This commit is contained in:
2026-06-30 15:15:15 +08:00
parent 200269196e
commit f1f68d09d3
6 changed files with 390 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ use App\Models\AgentProfile;
use App\Models\Player;
use App\Support\AdminScopeContext;
use App\Support\AdminScopeContextResolver;
use App\Services\Agent\AgentUsedCreditSyncService;
use App\Services\AgentSettlement\ShareLedgerScopedProfitAggregator;
use App\Support\AdminAgentSettlementScope;
use Carbon\Carbon;
@@ -20,6 +21,7 @@ final class AgentDashboardOverviewBuilder
public function __construct(
private readonly AdminReportQueryService $reportQuery,
private readonly ShareLedgerScopedProfitAggregator $shareProfitAggregator,
private readonly AgentUsedCreditSyncService $usedCreditSync,
) {}
/**
@@ -36,6 +38,7 @@ final class AgentDashboardOverviewBuilder
return null;
}
$this->usedCreditSync->syncForAgentId((int) $node->id);
$profile = AgentProfile::query()->where('agent_node_id', $node->id)->first();
$subtreeIds = AgentNode::query()
->where('path', 'like', $node->path.'%')