From f725e0fe8b2ba29daa299fc6b9a51d92dacd8562 Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 8 Jun 2026 11:54:36 +0330 Subject: [PATCH] price changes 2 --- .../Controllers/Site/ReportController.php | 54 +------------------ 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/app/Http/Controllers/Site/ReportController.php b/app/Http/Controllers/Site/ReportController.php index 5ced60b..0f467e9 100644 --- a/app/Http/Controllers/Site/ReportController.php +++ b/app/Http/Controllers/Site/ReportController.php @@ -126,10 +126,7 @@ class ReportController extends Controller $price = Price::orderBy('id', 'desc')->first(); $priceValue = $price ? (float) $price->price : 0.0; - if ( - $priceValue <= 0 - || !$this->isPlausibleStoredPrice($priceValue, $config->priceProvider(), $config) - ) { + if ($priceValue <= 0) { return ['sell' => 0, 'buy' => 0]; } @@ -146,50 +143,6 @@ class ReportController extends Controller return $payload; } - /** حداقل fallback zaarbox: ۱M تومن = ۱۰M ریال */ - private const ZAARBOX_MIN_PLAUSIBLE = 10_000_000; - - /** حداکثر fallback zaarbox/مس: ۱۰M تومن = ۱۰۰M ریال */ - private const ZAARBOX_MAX_PLAUSIBLE = 100_000_000; - - /** - * جلوگیری از fallback به قیمت ذخیره‌شدهٔ نامعتبر (مثلاً طلا ~785M روی پروژه مس). - */ - protected function isPlausibleStoredPrice(float $storedPrice, string $priceProvider, ConfigService $config): bool - { - if ($storedPrice <= 0) { - return false; - } - - $up = (float) $config->get('up_price', 0); - $down = (float) $config->get('down_price', 0); - - if ($up > 0 && $down > 0) { - $min = min($up, $down); - $max = max($up, $down); - - // up/down آلوده (مثلاً up=784M و down=23M روی مس) → بازه گشاد اعمال نشود - if ($max <= $min * 10) { - if ($storedPrice < $min * 0.25 || $storedPrice > $max * 4) { - return false; - } - - return true; - } - } - - if (in_array($priceProvider, ['zaarbox', 'main_product'], true)) { - return $storedPrice >= self::ZAARBOX_MIN_PLAUSIBLE - && $storedPrice <= self::ZAARBOX_MAX_PLAUSIBLE; - } - - if ($priceProvider === 'montzar') { - return $storedPrice > 1_000_000 && $storedPrice < 500_000_000; - } - - return $storedPrice < 500_000_000; - } - public function lastPrice() { $config = app(ConfigService::class); @@ -466,10 +419,7 @@ class ReportController extends Controller $lastPrice = Price::latest()->first(); $storedPrice = $lastPrice ? (float) $lastPrice->price : 0.0; - if ( - $storedPrice <= 0 - || !$this->isPlausibleStoredPrice($storedPrice, $priceProvider, $config) - ) { + if ($storedPrice <= 0) { return $this->appendUpPrices([ 'sell' => 0, 'buy' => 0,