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

@@ -11,6 +11,7 @@
use App\Lottery\ErrorCode;
use App\Support\ApiResponse;
use App\Support\ApiMessage;
use App\Support\ApiValidationErrors;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
@@ -105,6 +106,34 @@ return Application::configure(basePath: dirname(__DIR__))
);
});
$exceptions->render(function (\InvalidArgumentException $e, Request $request) use ($locale) {
if (! $request->is('api/*')) {
return null;
}
$reason = trim($e->getMessage());
if ($reason === '' || str_contains($reason, ' ')) {
return null;
}
$loc = $locale($request);
$msg = ApiMessage::reason($request, $reason);
if ($msg === $reason) {
$business = trans('validation.business.'.$reason, [], $loc);
if ($business === 'validation.business.'.$reason) {
return null;
}
$msg = $business;
}
return ApiResponse::error(
$msg,
ErrorCode::ValidationFailed->value,
null,
422,
);
});
$exceptions->render(function (ModelNotFoundException $e, Request $request) use ($locale) {
if (! $request->is('api/*')) {
return null;
@@ -153,10 +182,7 @@ return Application::configure(basePath: dirname(__DIR__))
}
$status = $e->getStatusCode();
$msg = $e->getMessage();
if ($msg === '') {
$msg = trans('api.client_error', [], $locale($request));
}
$msg = ApiMessage::httpExceptionMessage($request, $status, (string) $e->getMessage());
$code = $status >= 500 ? ErrorCode::InternalError->value : ErrorCode::ClientHttpError->value;
return ApiResponse::error($msg, $code, null, $status);