feat: enhance agent management and validation logic
- Updated AGENTS.md to clarify agent account restrictions and permissions. - Implemented checks in AgentNodeAdminUserStoreController and AgentNodeRoleStoreController to restrict admin user and role creation to the agent's own node. - Enhanced validation in AdminPlayerStoreController and AdminPlayerUpdateController to enforce credit limit and rebate rate rules based on player funding mode. - Refactored various request classes to utilize shared admin account field rules for consistency. - Improved error handling in services related to credit allocation and rebate limits to ensure proper validation and messaging.
This commit is contained in:
@@ -12,7 +12,9 @@ final class RebateLimitValidator
|
||||
{
|
||||
$profile = AgentProfile::query()->where('agent_node_id', $agent->id)->first();
|
||||
if ($profile === null) {
|
||||
return;
|
||||
throw ValidationException::withMessages([
|
||||
'rebate_rate' => ['agent_profile_required'],
|
||||
]);
|
||||
}
|
||||
|
||||
// Both $rebateRate and $profile->rebate_limit are ratios (0-1)
|
||||
@@ -23,10 +25,38 @@ final class RebateLimitValidator
|
||||
]);
|
||||
}
|
||||
|
||||
if ($extraRebateRate > $limit) {
|
||||
throw ValidationException::withMessages([
|
||||
'extra_rebate_rate' => ['exceeds_limit'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($extraRebateRate > 0 && ! $profile->can_grant_extra_rebate) {
|
||||
throw ValidationException::withMessages([
|
||||
'extra_rebate_rate' => ['not_allowed'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($limit > 0 && ($rebateRate + $extraRebateRate) > $limit + 1e-9) {
|
||||
throw ValidationException::withMessages([
|
||||
'rebate_rate' => ['exceeds_limit'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function assertChildRebateLimitWithinParent(AgentNode $parent, float $childRebateLimitRatio): void
|
||||
{
|
||||
$profile = AgentProfile::query()->where('agent_node_id', $parent->id)->first();
|
||||
if ($profile === null) {
|
||||
throw ValidationException::withMessages([
|
||||
'rebate_limit' => ['parent_profile_required'],
|
||||
]);
|
||||
}
|
||||
|
||||
if ($childRebateLimitRatio > (float) $profile->rebate_limit) {
|
||||
throw ValidationException::withMessages([
|
||||
'rebate_limit' => ['exceeds_parent'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user