fix(settings): honor last-price switch and overlay only SuperAdmin access flags

Stored DB prices were treated as live quotes, and SuperAdmin overlay overwrote tenant keys like trading hours. Keep overlay to the 14 access flags and hide fallback prices when the panel says so.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-25 03:01:07 +03:30
co-authored by Cursor
parent 8984899042
commit b21b136711
9 changed files with 327 additions and 97 deletions
@@ -3,7 +3,6 @@
namespace App\Console\Commands;
use App\Models\Setting;
use App\Services\SuperAdminProgramSettingsClient;
use App\Services\SuperAdminProgramSettingsOverlay;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
@@ -16,7 +15,8 @@ use Illuminate\Support\Facades\Schema;
* قواعد سخت:
* 1) value غیرخالی لوکال هرگز عوض نمی‌شود (مگر --force-overwrite).
* 2) پیش‌فرض‌های seed/deploy (مثل limangold.ir) هرگز به‌عنوان مقدار واقعی نوشته نمی‌شوند.
* 3) با --fill-from-superadmin برای خالی/غایب: اول SA واقعی، بعد بکاپ واقعی.
* 3) --fill-from-superadmin دیگر کلیدهای غیر دسترسی را از سوپرادمین نمی‌خواند
* (سوپرادمین فقط ۱۴ دسترسی را مالک است).
*
* کلیدهای گروه «دسترسی مشتری به قابلیت‌ها» و runtime رد می‌شوند.
*/
@@ -78,7 +78,10 @@ class SettingsRestoreFromBackupCommand extends Command
}
$backupRows = $this->readBackup($table);
$superAdminValues = $fillFromSuperAdmin ? $this->superAdminValues() : [];
$superAdminValues = [];
if ($fillFromSuperAdmin) {
$this->warn('--fill-from-superadmin نادیده گرفته شد: سوپرادمین فقط دسترسی‌ها را دارد، نه بقیهٔ تنظیمات.');
}
if ($backupRows === [] && $superAdminValues === []) {
$this->warn('هیچ کلید قابل بازگردانی پیدا نشد.');
@@ -332,37 +335,6 @@ class SettingsRestoreFromBackupCommand extends Command
return $rows;
}
/**
* @return array<string, string>
*/
private function superAdminValues(): array
{
$items = app(SuperAdminProgramSettingsClient::class)->fetchItems();
if (! is_array($items)) {
$this->warn('سوپرادمین در دسترس نبود — فالبک نادیده گرفته شد.');
return [];
}
$values = [];
foreach ($items as $item) {
if (! is_array($item)) {
continue;
}
$key = trim((string) ($item['key'] ?? ''));
if ($key === '' || ! $this->isRestorable($key)) {
continue;
}
$value = $item['value'] ?? null;
if ($value === null || trim((string) $value) === '') {
continue;
}
$values[$key] = trim((string) $value);
}
return $values;
}
private function isRestorable(string $key): bool
{
if (SuperAdminProgramSettingsOverlay::isSuperAdminOwned($key)) {