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:
2026-06-14 21:13:27 +08:00
parent 395e1c7400
commit 5b6d4cb74d
56 changed files with 1558 additions and 222 deletions

View File

@@ -79,7 +79,7 @@ final class ApiValidationErrors
$businessKey = 'validation.business.'.$trimmed;
$businessLine = trans($businessKey, ['attribute' => $attribute], $locale);
if ($businessLine !== $businessKey) {
return $businessLine;
return self::refineBusinessLine($field, $trimmed, $businessLine, $locale);
}
$customLine = self::customRuleLine($field, $trimmed, $attribute, $locale);
@@ -105,6 +105,54 @@ final class ApiValidationErrors
return $trimmed;
}
private static function refineBusinessLine(string $field, string $rule, string $line, string $locale): string
{
if ($rule === 'exceeds_limit') {
$flat = self::flatFieldName($field);
$specificKey = match ($flat) {
'rebate_rate', 'extra_rebate_rate' => 'validation.business.exceeds_player_rebate_limit',
'rebate_limit' => 'validation.business.exceeds_parent_rebate',
'default_player_rebate' => 'validation.business.exceeds_default_rebate_limit',
'total_share_rate', 'relative_share_rate' => 'validation.business.exceeds_parent',
default => null,
};
if ($specificKey !== null) {
$specific = trans($specificKey, [], $locale);
if ($specific !== $specificKey) {
return $specific;
}
}
}
if ($rule === 'exceeds_available' && self::flatFieldName($field) === 'credit_limit') {
$specific = trans('validation.business.exceeds_available', [], $locale);
if ($specific !== 'validation.business.exceeds_available') {
return $specific;
}
}
$flat = self::flatFieldName($field);
$contextKey = match (true) {
$flat === 'bill' && in_array($rule, ['not_payable', 'not_confirmable', 'not_eligible', 'no_unpaid', 'locked'], true)
=> 'validation.business.'.$rule.'_bill',
$flat === 'period' && $rule === 'completed'
=> 'validation.business.completed_period',
$flat === 'credit' && in_array($rule, ['insufficient', 'overdue'], true)
=> 'validation.business.'.$rule.'_credit',
$flat === 'amount' && $rule === 'zero'
=> 'validation.business.zero_amount',
default => null,
};
if ($contextKey !== null) {
$specific = trans($contextKey, [], $locale);
if ($specific !== $contextKey) {
return $specific;
}
}
return $line;
}
private static function exactMessage(string $message, string $locale): ?string
{
$map = trans('validation.exact', [], $locale);