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:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\SuperAdminProgramSettingsOverlay;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SuperAdminProgramSettingsRefreshCommand extends Command
|
||||
{
|
||||
protected $signature = 'superadmin:refresh-program-settings
|
||||
{--clear-only : فقط کش last-good را پاک کن}';
|
||||
|
||||
protected $description = 'کش overlay تنظیمات سوپرادمین را پاک/تازه میکند (مثلاً بعد از تغییر enable_automation)';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$overlay = app(SuperAdminProgramSettingsOverlay::class);
|
||||
|
||||
if ($this->option('clear-only')) {
|
||||
$overlay->flushCache();
|
||||
$this->line('cleared SuperAdmin program-settings cache');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$result = $overlay->refreshFromSuperAdmin();
|
||||
if (! ($result['ok'] ?? false)) {
|
||||
$this->error('fetch from SuperAdmin failed — cache cleared; next HTTP request will retry');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$this->info('fetched '.(int) ($result['count'] ?? 0).' setting(s) from SuperAdmin');
|
||||
if (($result['enable_automation'] ?? null) !== null) {
|
||||
$this->line('enable_automation='.$result['enable_automation']);
|
||||
} else {
|
||||
$this->warn('enable_automation missing in SuperAdmin response');
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user