feat: add AgentNodeIndexController for node listing and remove settlement_cycle field from AgentProfile logic

This commit is contained in:
2026-06-11 18:01:58 +08:00
parent 4d1c2b3d63
commit e14b7b4569
30 changed files with 383 additions and 91 deletions

View File

@@ -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();
}
}