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:
@@ -214,11 +214,12 @@ class SettingsController extends Controller
|
||||
|
||||
private function isPanelManagedKey(string $key): bool
|
||||
{
|
||||
return in_array($key, self::PANEL_MANAGED_KEYS, true);
|
||||
return in_array($key, self::PANEL_MANAGED_KEYS, true)
|
||||
|| app(ConfigService::class)->isTradingHoursSettingKey($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* تنظیمات پیشرفته: can_edit=0 (سوپرادمین) + کلیدهای can_edit=1 که کد مستقیم مینویسد.
|
||||
* تنظیمات پیشرفته: ۱۴ دسترسی از سوپرادمین + بقیهٔ can_edit=0 از DB لوکال.
|
||||
*/
|
||||
private function composeSystemSettings($localRows)
|
||||
{
|
||||
@@ -236,10 +237,7 @@ class SettingsController extends Controller
|
||||
if (! is_array($item)) {
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
SuperAdminProgramSettingsOverlay::isRuntime((string) $key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned((string) $key)
|
||||
) {
|
||||
if (! SuperAdminProgramSettingsOverlay::isSuperAdminOwned((string) $key)) {
|
||||
continue;
|
||||
}
|
||||
$value = $item['value'] ?? null;
|
||||
@@ -292,7 +290,8 @@ class SettingsController extends Controller
|
||||
$key = (string) ($row->key ?? '');
|
||||
|
||||
return $this->isEditableCanEdit($row->can_edit ?? null)
|
||||
|| SuperAdminProgramSettingsOverlay::isRuntime($key);
|
||||
|| SuperAdminProgramSettingsOverlay::isRuntime($key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned($key);
|
||||
});
|
||||
|
||||
return $rows
|
||||
@@ -303,8 +302,8 @@ class SettingsController extends Controller
|
||||
|
||||
/**
|
||||
* get_settings ادمین (و پایهٔ publicIndex قبل از فیلتر show_to_user):
|
||||
* can_edit=1 (+ runtime) از DB لوکال
|
||||
* can_edit=0 از سوپرادمین؛ اگر کلید در SA نبود یا value خالی بود → کپی لوکال
|
||||
* can_edit=1 (+ runtime + local-owned) از DB لوکال
|
||||
* فقط ۱۴ دسترسی سوپرادمین از overlay؛ بقیهٔ can_edit=0 از کپی لوکال
|
||||
* اگر سوپرادمین در دسترس نباشد کل جدول لوکال برمیگردد.
|
||||
*/
|
||||
private function composeGetSettings($localRows)
|
||||
@@ -338,10 +337,7 @@ class SettingsController extends Controller
|
||||
continue;
|
||||
}
|
||||
$key = (string) $key;
|
||||
if (
|
||||
SuperAdminProgramSettingsOverlay::isRuntime($key)
|
||||
|| SuperAdminProgramSettingsOverlay::isLocalOwned($key)
|
||||
) {
|
||||
if (! SuperAdminProgramSettingsOverlay::isSuperAdminOwned($key)) {
|
||||
continue;
|
||||
}
|
||||
$value = $item['value'] ?? null;
|
||||
|
||||
@@ -99,9 +99,11 @@ class ReportController extends Controller
|
||||
{
|
||||
// status: open | closed (خارج از ساعت کاری) | no_quote (مظنه در دسترس نیست)
|
||||
$payload = app(ConfigService::class)->applyHomePriceDisplayState($payload);
|
||||
$payload = app(ConfigService::class)->attachTradingHoursSettingsPatch($payload);
|
||||
|
||||
$payload['up'] = $this->buildUpDownPrices();
|
||||
// سقف/کف روز هم وقتی قیمت نباید نمایش داده شود صفر میماند
|
||||
$payload['up'] = ($payload['status'] ?? 'open') === 'open'
|
||||
? $this->buildUpDownPrices()
|
||||
: ['sell' => 0, 'buy' => 0];
|
||||
$payload['last_historical'] = app(ProductDisplayPriceService::class)->resolveHistoricalBasePrice();
|
||||
$payload['gold_ounce'] = $this->resolveGoldOuncePayload();
|
||||
app(ProductDisplayPriceService::class)->cacheLivePricePayload($payload);
|
||||
@@ -476,6 +478,10 @@ class ReportController extends Controller
|
||||
/** اختلاف پکیج ویژه — فقط روی پاسخ مشتری؛ کش مشترک را آلوده نمیکند */
|
||||
protected function personalizeLastPriceForCustomer(array $payload): array
|
||||
{
|
||||
// تنظیمات ساعت کاری همیشه تازه از DB — اگر داخل کش قیمت بماند،
|
||||
// پولینگ بعدی مقدار قبلی را برمیگرداند و تغییر پنل عقب برمیگردد.
|
||||
$payload = app(ConfigService::class)->attachTradingHoursSettingsPatch($payload);
|
||||
|
||||
$customerId = (int) (auth('customer')->id() ?? 0);
|
||||
if ($customerId <= 0) {
|
||||
return $payload;
|
||||
|
||||
Reference in New Issue
Block a user