new check for kashkol

This commit is contained in:
2026-06-12 16:06:37 +03:30
parent 80bcfbf5cf
commit e3bc50e2c6
6 changed files with 46 additions and 54 deletions
+3 -33
View File
@@ -138,7 +138,6 @@ class ReportController extends Controller
$montzar_price = 0;
$zaarbox_price = 0;
$tgn = 0;
$pr_price = 0;
$open_buy = true;
@@ -207,7 +206,6 @@ class ReportController extends Controller
*/
$settings = Setting::whereIn('key', [
'fee_single',
'tabanGohar_price',
'main_product_price',
'buy_fee',
'sell_fee',
@@ -215,7 +213,6 @@ class ReportController extends Controller
$settingsMap = $settings->pluck('value', 'key');
$show_last_price = $config->getBool('show_last_price', false);
$taban_gohar_price = $settingsMap->get('tabanGohar_price');
$main_product_price = $settingsMap->get('main_product_price');
$difference = (float) $settingsMap->get('fee_single', 0);
@@ -341,30 +338,6 @@ class ReportController extends Controller
}
}
/*
|--------------------------------------------------------------------------
| Taban Gohar
|--------------------------------------------------------------------------
*/
if ($toBool($taban_gohar_price) && !$closed) {
try {
$taban_gohar = Http::withOptions([
'curl' => [
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
CURLOPT_TCP_FASTOPEN => 1,
],
])
->withoutVerifying()
->timeout(2)
->get('https://tabangohar.com/GheymatKhan/prices_in_table.html')
->json();
$tgn = (int) $taban_gohar['c'] * 10;
} catch (\Throwable $e) {
$tgn = 0;
}
}
/*
|--------------------------------------------------------------------------
| انتخاب قیمت اصلی (همان price_provider)
@@ -376,9 +349,6 @@ class ReportController extends Controller
} elseif ($priceProvider === 'montzar' && ($montzar_price ?? 0) !== 0 && !$closed) {
$priceValue = (int) $montzar_price;
$priceSource = 'montzar';
} elseif ($priceProvider === 'taban_gohar' && $toBool($taban_gohar_price) && ($tgn ?? 0) !== 0 && !$closed) {
$priceValue = $tgn;
$priceSource = 'taban_gohar';
} elseif ($priceProvider === 'main_product' && ($pr_price ?? 0) !== 0 && !$closed) {
$priceValue = $pr_price;
$priceSource = 'main_product';
@@ -395,7 +365,7 @@ class ReportController extends Controller
'price_last' => 0,
'price' => 0,
'main_product' => $pr_price ?? 0,
'taban_gohar' => $tgn ?? 0,
'taban_gohar' => 0,
'montzar' => $montzar_price ?? 0,
'zaarbox' => $zaarbox_price ?? 0,
'closed' => true,
@@ -413,7 +383,7 @@ class ReportController extends Controller
'price_last' => 0,
'price' => 0,
'main_product' => $pr_price ?? 0,
'taban_gohar' => $tgn ?? 0,
'taban_gohar' => 0,
'montzar' => $montzar_price ?? 0,
'zaarbox' => $zaarbox_price ?? 0,
'closed' => true,
@@ -525,7 +495,7 @@ class ReportController extends Controller
'price_last' => $priceLast,
'price' => $priceValue,
'main_product' => $pr_price ?? 0,
'taban_gohar' => $tgn ?? 0,
'taban_gohar' => 0,
'montzar' => $montzar_price ?? 0,
'zaarbox' => $zaarbox_price ?? 0,
'closed' => false,
+9 -4
View File
@@ -10,7 +10,7 @@ use App\Models\Setting;
class ConfigService
{
public const PRICE_PROVIDERS = ['montzar', 'taban_gohar', 'main_product', 'zaarbox'];
public const PRICE_PROVIDERS = ['montzar', 'main_product', 'zaarbox'];
public function Config($name)
{
@@ -99,12 +99,13 @@ class ConfigService
}
/**
* تنها منبع فعال قیمت — montzar | taban_gohar | main_product | zaarbox
* تنها منبع فعال قیمت — montzar | main_product | zaarbox
*
* اولویت:
* 1) price_provider (یا price_primary_source قدیمی)
* 1) price_provider (یا price_primary_source قدیمی) — فقط مقادیر معتبر
* 2) montzar_price=true → montzar (ابشده خانگی و پروژه‌های فعلی)
* 3) پیش‌فرض فایل: montzar
* 3) main_product_price=true → main_product (legacy)
* 4) پیش‌فرض فایل: montzar
*/
public function priceProvider(): string
{
@@ -119,6 +120,10 @@ class ConfigService
return 'montzar';
}
if ($this->getBool('main_product_price', false)) {
return 'main_product';
}
$default = strtolower((string) config('price_providers.price_provider', 'montzar'));
return in_array($default, self::PRICE_PROVIDERS, true) ? $default : 'montzar';
@@ -274,8 +274,6 @@ class ProductDisplayPriceService
if ($main) {
$price = (int) (($main->price ?? 0) + ($main->price_profit ?? 0));
}
} elseif ($provider === 'taban_gohar') {
$price = $config->getInt('taban_gohar_live_price', 0);
}
if ($price <= 0 && $config->getBool('show_last_price', false)) {