fix(settings): honor per-day trading hours and refresh SuperAdmin overlay
Use trading_hours_by_day for close_price gates, prefer public SuperAdmin fetch, and add refresh endpoint/command so stale last-good cache no longer keeps switches like enable_automation off. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -71,6 +71,46 @@ class SuperAdminProgramSettingsOverlay
|
||||
|
||||
private static bool $loaded = false;
|
||||
|
||||
/** پاک کردن کش last-good و memo درخواست — برای دکمهٔ همگامسازی تنظیمات پیشرفته */
|
||||
public function flushCache(): void
|
||||
{
|
||||
self::$memo = null;
|
||||
self::$loaded = false;
|
||||
try {
|
||||
Cache::forget(self::LAST_GOOD_CACHE_KEY);
|
||||
} catch (\Throwable $e) {
|
||||
// کش در دسترس نیست
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* کش را پاک میکند و دوباره از سوپرادمین میخواند.
|
||||
*
|
||||
* @return array{ok: bool, count: int, enable_automation: string|null, source: string}
|
||||
*/
|
||||
public function refreshFromSuperAdmin(): array
|
||||
{
|
||||
$this->flushCache();
|
||||
$map = $this->catalogMap();
|
||||
if ($map === null) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'count' => 0,
|
||||
'enable_automation' => null,
|
||||
'source' => 'unavailable',
|
||||
];
|
||||
}
|
||||
|
||||
$auto = $map['enable_automation']['value'] ?? null;
|
||||
|
||||
return [
|
||||
'ok' => true,
|
||||
'count' => count($map),
|
||||
'enable_automation' => $auto === null || $auto === '' ? null : (string) $auto,
|
||||
'source' => 'superadmin',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* همهٔ کلیدهای سوپرادمین (حتی value خالی). null = سوپرادمین در دسترس نبود.
|
||||
*
|
||||
@@ -122,6 +162,11 @@ class SuperAdminProgramSettingsOverlay
|
||||
$this->rememberLastGood($items);
|
||||
} else {
|
||||
$items = $this->lastGoodItems();
|
||||
if ($items !== null) {
|
||||
\Illuminate\Support\Facades\Log::warning('SuperAdmin program-settings using last-good cache', [
|
||||
'count' => count($items),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($items === null) {
|
||||
|
||||
Reference in New Issue
Block a user