feat(wallet): 增强资金流水和信用账本的公共类型过滤,支持游戏结算和账单结算
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

This commit is contained in:
2026-06-30 17:55:16 +08:00
parent f1f68d09d3
commit ed5a983003
8 changed files with 384 additions and 24 deletions

View File

@@ -137,10 +137,15 @@ final class AgentProfileService
$profile->refresh();
$available = max(0, (int) $profile->credit_limit - (int) $profile->allocated_credit);
$totalShareRate = (float) $profile->total_share_rate;
$parentTotalShareRate = $this->parentTotalShareRateForProfile($profile);
return [
'agent_node_id' => (int) $profile->agent_node_id,
'total_share_rate' => (float) $profile->total_share_rate,
'total_share_rate' => $totalShareRate,
'relative_share_rate' => $parentTotalShareRate > 0
? round($totalShareRate / $parentTotalShareRate * 100, 2)
: null,
'credit_limit' => (int) $profile->credit_limit,
'allocated_credit' => (int) $profile->allocated_credit,
'used_credit' => (int) $profile->used_credit,
@@ -154,6 +159,20 @@ final class AgentProfileService
];
}
private function parentTotalShareRateForProfile(AgentProfile $profile): float
{
$node = AgentNode::query()->find((int) $profile->agent_node_id);
if ($node === null || $node->parent_id === null) {
return 0.0;
}
$parentProfile = AgentProfile::query()
->where('agent_node_id', (int) $node->parent_id)
->first();
return $parentProfile !== null ? (float) $parentProfile->total_share_rate : 100.0;
}
public function profileForNode(int $agentNodeId): ?AgentProfile
{
return AgentProfile::query()->where('agent_node_id', $agentNodeId)->first();