From e3bc50e2c6034c01dee000923c0b48156ce3dba3 Mon Sep 17 00:00:00 2001 From: mohammad sedighi Date: Fri, 12 Jun 2026 16:06:37 +0330 Subject: [PATCH] new check for kashkol --- .../Controllers/Site/ReportController.php | 36 ++----------------- app/Services/ConfigService.php | 13 ++++--- app/Services/ProductDisplayPriceService.php | 2 -- config/price_providers.php | 2 +- database/sql/deploy_settings_const.sql | 24 ++++++------- .../sql/remove_taban_gohar_price_provider.sql | 23 ++++++++++++ 6 files changed, 46 insertions(+), 54 deletions(-) create mode 100644 database/sql/remove_taban_gohar_price_provider.sql diff --git a/app/Http/Controllers/Site/ReportController.php b/app/Http/Controllers/Site/ReportController.php index fe925a6..22e781a 100644 --- a/app/Http/Controllers/Site/ReportController.php +++ b/app/Http/Controllers/Site/ReportController.php @@ -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, diff --git a/app/Services/ConfigService.php b/app/Services/ConfigService.php index 40b7ad5..c0089cf 100644 --- a/app/Services/ConfigService.php +++ b/app/Services/ConfigService.php @@ -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'; diff --git a/app/Services/ProductDisplayPriceService.php b/app/Services/ProductDisplayPriceService.php index e1bb7a8..f1bc393 100644 --- a/app/Services/ProductDisplayPriceService.php +++ b/app/Services/ProductDisplayPriceService.php @@ -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)) { diff --git a/config/price_providers.php b/config/price_providers.php index bd09228..2154c50 100644 --- a/config/price_providers.php +++ b/config/price_providers.php @@ -4,7 +4,7 @@ * پیش‌فرض وقتی کلید در جدول settings نیست. * * منبع قیمت: یک کلید → price_provider - * montzar | taban_gohar | main_product | zaarbox + * montzar | main_product | zaarbox * * سازگاری قدیمی (بدون price_provider): * montzar_price=true → montzar diff --git a/database/sql/deploy_settings_const.sql b/database/sql/deploy_settings_const.sql index b4adff3..67c0cd0 100644 --- a/database/sql/deploy_settings_const.sql +++ b/database/sql/deploy_settings_const.sql @@ -93,10 +93,6 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de SELECT 'chart_id', '', 'UUID نمودار Zaarbox', 1, 1, 'خالی = ca3800a0-1f57-3528-b963-178f9168e04f' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'chart_id' LIMIT 1); -INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) -SELECT 'etehadie_api_url', 'https://price.zaarbox.ir/api/free', 'آدرس API اتحادیه (پشتیبان)', 1, 1, NULL -WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'etehadie_api_url' LIMIT 1); - INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) SELECT 'show_last_price', 'true', 'نمایش آخرین قیمت DB اگر API قطع شد', 1, 1, NULL WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'show_last_price' LIMIT 1); @@ -105,10 +101,6 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de SELECT 'main_product_price', 'false', 'قیمت از محصول (legacy)', 1, 1, 'از price_provider استفاده کنید' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product_price' LIMIT 1); -INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) -SELECT 'tabanGohar_price', 'false', 'قیمت تابان گوهر', 1, 1, NULL -WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tabanGohar_price' LIMIT 1); - INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) SELECT 'montzar_price', 'false', 'قیمت از همکار (montzar)', 1, 1, 'معمولاً false وقتی price_provider=zaarbox' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_price' LIMIT 1); @@ -325,7 +317,7 @@ WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_item' -- ============================================================================= UPDATE `settings` SET `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'منبع قیمت'), `can_edit` = 1, - `description` = 'zaarbox | main_product | montzar | etehadie | taban_gohar' + `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE `key` = 'price_provider'; UPDATE `settings` SET `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'محصول / UUID تابلو'), `can_edit` = 1 @@ -419,7 +411,7 @@ WHERE `key` = 'main_product'; UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_about'); -- select (+ گزینه‌ها در description) -UPDATE `settings` SET `type` = 'select', `description` = 'montzar,zaarbox,main_product,etehadie,taban_gohar' WHERE `key` = 'price_provider'; +UPDATE `settings` SET `type` = 'select', `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE `key` = 'price_provider'; UPDATE `settings` SET `type` = 'select', `description` = 'required = اجباری؛ خالی = اختیاری|required,', `can_edit` = 1 WHERE `key` = 'referral_id'; UPDATE `settings` SET `type` = 'select', `description` = 'sepal,' WHERE `key` = 'payping_gateway_name'; UPDATE `settings` SET `type` = 'select', `description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush' WHERE `key` = 'support_messenger'; @@ -427,7 +419,7 @@ UPDATE `settings` SET `type` = 'select', `description` = 'bale,telegram,whatsapp -- switch UPDATE `settings` SET `type` = 'switch' WHERE `key` IN ( 'jibit_verification', 'register_jibit_verify', 'open_register', 'auto_active_customer', - 'close_price', 'montzar_price', 'main_product_price', 'tabanGohar_price', 'show_last_price', + 'close_price', 'montzar_price', 'main_product_price', 'show_last_price', 'send_to_tahesab', 'profit_gold_api_enabled', 'payping_round_toman', 'payping_strict_failed_withdraw', 'has_page_earn_money', 'has_page_fund', 'has_page_permission', 'has_page_price_trigger', 'has_page_physical_gold', 'has_chat', 'charge_notif', 'group_sms', 'display_montzar', @@ -469,7 +461,7 @@ UPDATE `settings` SET `type` = 'text' WHERE `type` IS NULL OR TRIM(`type`) = ''; -- کلیدهای modular اضافی (INSERT اگر نبود) -- --------------------------------------------------------------------------- INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`, `description`) -SELECT 'price_provider', 'منبع قیمت', 'montzar', 1, 0, 1, 'select', 'منبع فعال قیمت|montzar,zaarbox,main_product,taban_gohar,etehadie' +SELECT 'price_provider', 'منبع قیمت', 'montzar', 1, 0, 1, 'select', 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_provider' LIMIT 1); INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`) @@ -551,7 +543,8 @@ WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman' LIMIT 1); DELETE FROM `settings` WHERE `key` IN ( 'test', 'test2', 'test22', 'test3', 'test33', 'longtest', 'longtest2', 'is_requaire_referral', 'send_to_goldir', 'goldir_price', 'liman_token', - 'melted_product_id', 'display_montzar' + 'melted_product_id', 'display_montzar', 'tabanGohar_price', 'etehadie_api_url', + 'price_method', 'price_primary_source' ); DELETE FROM `const` WHERE `key` = 'log' OR `key` LIKE 'goldir%'; @@ -563,9 +556,12 @@ UPDATE `settings` SET `description` = NULL WHERE LOWER(TRIM(COALESCE(`description`, ''))) IN ('true', 'false', '0', '1', 'yes', 'no', 'in server') OR TRIM(COALESCE(`description`, '')) LIKE 'count of%'; -UPDATE `settings` SET `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product,taban_gohar,etehadie' +UPDATE `settings` SET `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE `key` = 'price_provider'; +UPDATE `settings` SET `value` = 'montzar' +WHERE `key` = 'price_provider' AND LOWER(TRIM(`value`)) IN ('taban_gohar', 'etehadie'); + UPDATE `settings` SET `description` = 'required = اجباری|required,', `title_fa` = 'کد معرف', `type` = 'select' WHERE `key` = 'referral_id'; diff --git a/database/sql/remove_taban_gohar_price_provider.sql b/database/sql/remove_taban_gohar_price_provider.sql new file mode 100644 index 0000000..9403ae5 --- /dev/null +++ b/database/sql/remove_taban_gohar_price_provider.sql @@ -0,0 +1,23 @@ +-- حذف تابان‌گوهر و منابع قیمت legacy — برای همه پروژه‌ها (ابشده خانگی، گلد علی، قطره، کشکول) +-- قبل از اجرا: بکاپ DB + +START TRANSACTION; + +DELETE FROM `settings` WHERE `key` IN ( + 'tabanGohar_price', + 'etehadie_api_url', + 'price_method', + 'price_primary_source' +); + +UPDATE `settings` +SET + `value` = CASE + WHEN LOWER(TRIM(`value`)) IN ('taban_gohar', 'etehadie') THEN 'montzar' + ELSE `value` + END, + `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product', + `type` = 'select' +WHERE `key` = 'price_provider'; + +COMMIT;