feat: enhance admin role management and reconciliation features
- Updated AGENTS.md to clarify site admin roles and their associated permissions. - Refactored reconciliation controllers to include admin user validation and improved access control based on admin roles. - Enhanced AdminReconcileJobService to support player-specific reconciliation and site-based job creation. - Removed deprecated rebate commission report functionality from the API and related services. - Improved dashboard overview builders to accommodate new site operator roles and their specific functionalities.
This commit is contained in:
@@ -4,11 +4,17 @@ namespace App\Services\Admin;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\Player;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\ReconcileJob;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\ReconcileItem;
|
||||
use App\Lottery\ErrorCode;
|
||||
use App\Services\AuditLogger;
|
||||
use App\Support\AdminReconcileScope;
|
||||
use App\Support\AdminScopePolicy;
|
||||
use App\Support\AdminSiteScope;
|
||||
use App\Support\ApiMessage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Services\Wallet\WalletTransferReconcileDetector;
|
||||
|
||||
@@ -102,6 +108,23 @@ final class AdminReconcileJobService
|
||||
$periodEnd ??= now()->endOfDay();
|
||||
$periodStart ??= $periodEnd->copy()->startOfDay();
|
||||
|
||||
$player = null;
|
||||
if ($playerId !== null) {
|
||||
$player = Player::query()->find($playerId);
|
||||
if ($player === null || ! AdminSiteScope::playerAccessible($admin, $player)) {
|
||||
abort(ApiMessage::errorResponse(
|
||||
$request,
|
||||
'admin.site_player_access_denied',
|
||||
ErrorCode::AdminForbidden->value,
|
||||
null,
|
||||
403,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$scope = AdminScopePolicy::resolveContext($request, $admin);
|
||||
$adminSiteId = AdminReconcileScope::resolveAdminSiteIdForJob($admin, $player);
|
||||
|
||||
[$items] = $this->detector->scanItems(
|
||||
$periodStart,
|
||||
$periodEnd,
|
||||
@@ -109,9 +132,17 @@ final class AdminReconcileJobService
|
||||
staleMinutes: 15,
|
||||
playerId: $playerId,
|
||||
includeMainSiteCheck: true,
|
||||
scope: $scope,
|
||||
);
|
||||
|
||||
$job = $this->detector->persistJob($items, $periodStart, $periodEnd, (int) $admin->getKey());
|
||||
$job = $this->detector->persistJob(
|
||||
$items,
|
||||
$periodStart,
|
||||
$periodEnd,
|
||||
(int) $admin->getKey(),
|
||||
$adminSiteId,
|
||||
$playerId,
|
||||
);
|
||||
|
||||
AuditLogger::recordForAdmin(
|
||||
$admin,
|
||||
|
||||
Reference in New Issue
Block a user