feat(wallet): 增强资金流水和信用账本的公共类型过滤,支持游戏结算和账单结算
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user