fixed price

This commit is contained in:
2026-06-28 10:46:09 +03:30
parent e21e97988c
commit dec13e8537
4 changed files with 106 additions and 22 deletions
+41 -3
View File
@@ -487,11 +487,49 @@ class ConfigService
$closed = $this->isOutsideTradingHours($now);
Cnt::where('key', 'app_closed')->update(['value' => $closed ? 'true' : 'false']);
if ($closed) {
$this->UpdateConfig('montzar_closed', 'true');
return $closed;
}
/**
* montzar_closed فقط وضعیت sync زنده است — نباید به‌تنهایی سفارش را ببندد.
* اگر sync خطا داد ولی montzar_live_price و open_buy/sell معتبرند، معامله باز بماند.
*/
public function applyMontzarSyncFailure(): void
{
$staleLive = $this->getInt('montzar_live_price', 0);
$stillOpen = $this->getBool('montzar_open_buy', false)
|| $this->getBool('montzar_open_sell', false);
$this->UpdateConfig(
'montzar_closed',
($staleLive > 0 && $stillOpen) ? 'false' : 'true'
);
}
public function assertMontzarOrderAllowed(int $direction): void
{
if (!$this->usesMontzarPricing()) {
return;
}
return $closed;
$direction = (int) $direction;
$openBuy = $this->getBool('montzar_open_buy', true);
$openSell = $this->getBool('montzar_open_sell', true);
if ($direction === 1 && !$openBuy) {
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
}
if ($direction === 2 && !$openSell) {
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
}
if ($this->getBool('montzar_closed', false)) {
$basePrice = app(ProductDisplayPriceService::class)->resolveOrderBasePrice();
if ($basePrice <= 0) {
throw new UnprocessableEntityHttpException('عدم ارائه سرویس.');
}
}
}
public function formatTradingTimeForDisplay(string $time): string