feat: add AgentNodeIndexController for node listing and remove settlement_cycle field from AgentProfile logic
This commit is contained in:
@@ -36,9 +36,8 @@ final class AgentNodePresenter
|
||||
'allocated_credit' => (int) $profile->allocated_credit,
|
||||
'used_credit' => (int) $profile->used_credit,
|
||||
'available_credit' => max(0, (int) $profile->credit_limit - (int) $profile->allocated_credit),
|
||||
'rebate_limit' => (float) $profile->rebate_limit,
|
||||
'default_player_rebate' => (float) $profile->default_player_rebate,
|
||||
'settlement_cycle' => AgentSettlementCycle::normalize($profile->settlement_cycle),
|
||||
'rebate_limit' => round((float) $profile->rebate_limit * 100, 4),
|
||||
'default_player_rebate' => round((float) $profile->default_player_rebate * 100, 4),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -126,4 +125,26 @@ final class AgentNodePresenter
|
||||
|
||||
return $roots;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable<AgentNode> $nodes
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public static function list(iterable $nodes): array
|
||||
{
|
||||
$nodeList = $nodes instanceof Collection ? $nodes : collect($nodes);
|
||||
$profiles = AgentProfile::query()
|
||||
->whereIn('agent_node_id', $nodeList->pluck('id'))
|
||||
->get()
|
||||
->keyBy('agent_node_id');
|
||||
|
||||
return $nodeList
|
||||
->map(function (AgentNode $node) use ($profiles): array {
|
||||
$profile = $profiles->get($node->id);
|
||||
|
||||
return self::item($node, $profile instanceof AgentProfile ? $profile : null);
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user