From 1abddfbab86c46bd365246d1203c8a3f97f03f52 Mon Sep 17 00:00:00 2001 From: adonis Date: Sun, 14 Jun 2026 12:01:20 +0330 Subject: [PATCH] fix price force refresh --- .../Controllers/Admin/CategoryController.php | 20 +- .../Controllers/Site/ReportController.php | 2 +- app/Services/CategoryService.php | 29 +++ app/Services/LivePriceCacheService.php | 33 +++- app/Services/MontzarService.php | 11 +- database/sql/deploy_settings_const.sql | 171 ++++++++++++++++-- 6 files changed, 229 insertions(+), 37 deletions(-) diff --git a/app/Http/Controllers/Admin/CategoryController.php b/app/Http/Controllers/Admin/CategoryController.php index cb8ebb8..284dfa4 100644 --- a/app/Http/Controllers/Admin/CategoryController.php +++ b/app/Http/Controllers/Admin/CategoryController.php @@ -74,7 +74,7 @@ class CategoryController extends Controller $category->name = $name; } - foreach (['active', 'show_in_filter', 'show_in_select', 'sort_order'] as $field) { + foreach (['active', 'show_in_select', 'sort_order'] as $field) { if ($request->has($field)) { $category->{$field} = $field === 'sort_order' ? (int) $request->input($field) @@ -100,22 +100,18 @@ class CategoryController extends Controller ]); } - /** تب فیلتر اپ کاربر */ - public function clientIndex(Request $request) + /** تب فیلتر اپ کاربر — خودکار از محصولات فعال */ + public function clientIndex(Request $request, CategoryService $categoryService) { - $query = Category::query() - ->where('active', 1) - ->where('show_in_filter', 1); + $categories = $categoryService->clientFilterCategories(); if ($request->filled('search')) { - $query->where('name', 'like', '%' . $request->search . '%'); + $needle = trim((string) $request->search); + $categories = $categories->filter( + static fn ($category) => str_contains((string) $category->name, $needle) + )->values(); } - $categories = $query - ->orderBy('sort_order') - ->orderBy('id') - ->get(['id', 'name', 'sort_order']); - return response()->json($categories); } diff --git a/app/Http/Controllers/Site/ReportController.php b/app/Http/Controllers/Site/ReportController.php index 9b840e4..af5c0e6 100644 --- a/app/Http/Controllers/Site/ReportController.php +++ b/app/Http/Controllers/Site/ReportController.php @@ -148,7 +148,7 @@ class ReportController extends Controller $dbBuilt = $cache->buildFromDatabase(); if (($dbBuilt['price'] ?? 0) > 0) { - return $dbBuilt; + return $cache->put($dbBuilt); } } diff --git a/app/Services/CategoryService.php b/app/Services/CategoryService.php index 8fa0856..f313b84 100644 --- a/app/Services/CategoryService.php +++ b/app/Services/CategoryService.php @@ -123,4 +123,33 @@ class CategoryService return $created; } + + /** + * تب‌های فیلتر اپ — فقط دسته‌های فعال که حداقل یک محصول فعال دارند. + * show_in_filter دستی لازم نیست؛ از همان منطق نمایش محصولات مشتق می‌شود. + */ + public function clientFilterCategories(): Collection + { + $groupsWithProducts = Product::query() + ->where('active', 1) + ->whereNotNull('group_type') + ->where('group_type', '!=', '') + ->distinct() + ->pluck('group_type') + ->map(static fn ($name) => trim((string) $name)) + ->filter() + ->unique() + ->values(); + + if ($groupsWithProducts->isEmpty()) { + return collect(); + } + + return Category::query() + ->where('active', 1) + ->whereIn('name', $groupsWithProducts) + ->orderBy('sort_order') + ->orderBy('id') + ->get(['id', 'name', 'sort_order']); + } } diff --git a/app/Services/LivePriceCacheService.php b/app/Services/LivePriceCacheService.php index 7ad777f..650c1d4 100644 --- a/app/Services/LivePriceCacheService.php +++ b/app/Services/LivePriceCacheService.php @@ -44,6 +44,11 @@ class LivePriceCacheService $display = app(ProductDisplayPriceService::class); $last = Price::orderByDesc('id')->first(); $base = $last ? (int) $last->price : 0; + $provider = $config->priceProvider(); + + $montzarPrice = 0; + $zaarboxPrice = 0; + $mainProductPrice = 0; if ($base <= 0) { $payload = [ @@ -60,17 +65,33 @@ class LivePriceCacheService } else { $diffBuy = (int) $config->displayBuySpreadRial(); $diffSell = (int) $config->displaySellSpreadRial(); - $buy = (int) ceil($base + $diffBuy); - $sell = max(0, (int) ceil($base - $diffSell)); + $openBuy = true; + $openSell = true; + + if ($provider === 'montzar') { + $montzarPrice = $config->getInt('montzar_live_price', 0) ?: $base; + $montzarDiff = (int) $config->getInt('montzar_diff', 0); + $diffBuy += $montzarDiff; + $diffSell += $montzarDiff; + $openBuy = $config->getBool('montzar_open_buy', true); + $openSell = $config->getBool('montzar_open_sell', true); + } elseif ($provider === 'zaarbox') { + $zaarboxPrice = $base; + } elseif ($provider === 'main_product') { + $mainProductPrice = $base; + } + + $buy = $openBuy ? (int) ceil($base + $diffBuy) : 0; + $sell = $openSell ? max(0, (int) ceil($base - $diffSell)) : 0; $payload = [ 'sell' => $sell, 'buy' => $buy, 'price_last' => $buy, 'price' => $base, - 'main_product' => 0, - 'montzar' => 0, - 'zaarbox' => 0, + 'main_product' => $mainProductPrice, + 'montzar' => $montzarPrice, + 'zaarbox' => $zaarboxPrice, 'closed' => false, 'time' => now(), ]; @@ -84,6 +105,8 @@ class LivePriceCacheService : ['sell' => $payload['sell'] ?? 0, 'buy' => $payload['buy'] ?? 0]; $payload['last_historical'] = $display->resolveHistoricalBasePrice(); + $display->cacheLivePricePayload($payload); + return $payload; } } diff --git a/app/Services/MontzarService.php b/app/Services/MontzarService.php index 8cdb8ec..10b729d 100644 --- a/app/Services/MontzarService.php +++ b/app/Services/MontzarService.php @@ -4,6 +4,7 @@ namespace App\Services; use App\Models\Cnt; use App\Models\Order; +use App\Models\Setting; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Schema; @@ -44,10 +45,18 @@ class MontzarService $token = $response['access_token'] ?? $response['token'] ?? null; if (!$token) { + Log::error('Montzar login failed', [ + 'base_url' => $this->baseUrl(), + 'mobile' => $this->config()->Config('montzar_mobile'), + 'response' => $response, + ]); throw new \Exception('Montzar login failed: ' . json_encode($response, JSON_UNESCAPED_UNICODE)); } - $this->config()->UpdateConfig('montzar_token', $token); + Setting::updateOrCreate( + ['key' => 'montzar_token'], + ['value' => $token, 'is_active' => 1] + ); return $token; } diff --git a/database/sql/deploy_settings_const.sql b/database/sql/deploy_settings_const.sql index aa5b3ae..15ec117 100644 --- a/database/sql/deploy_settings_const.sql +++ b/database/sql/deploy_settings_const.sql @@ -76,6 +76,39 @@ UPDATE `settings` SET `key` = 'support_messenger_text' WHERE `key` = 'bale_suppo -- SETTINGS — کلیدهای جدید (INSERT فقط اگر key نبود) -- ============================================================================= +-- کلیدهای پایه برند (هر DB — value خالی؛ از پنل پر می‌شود) +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'name_fa', '', 'نام فارسی اپ', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'name_fa' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'app_url', '', 'آدرس اپ (کاربر)', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'app_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'admin_url', '', 'آدرس پنل ادمین', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'admin_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'logo_login', '', 'لوگوی صفحه ورود', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'logo_login' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'logo_register', '', 'لوگوی ثبت‌نام', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'logo_register' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'has_page_earn_money', 'false', 'صفحه کسب درآمد', 1, 1, NULL, 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'has_page_earn_money' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'default_vc_number', '', 'پیشوند شماره حواله (پرگار)', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'default_vc_number' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'montzar_order_response', '[]', 'پاسخ سفارش همکار', 0, 1, NULL, 'longtext' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_order_response' LIMIT 1); + -- قیمت zaarbox (اگر از قبل دارید value دست نخورده) INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) SELECT 'chart_use_local_data', 'false', 'نمودار از داده خود سایت', 1, 1, @@ -147,10 +180,6 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de SELECT 'montzar_truly_sell_mazaneh', '0', 'مظنه فروش همکار', 0, 1, NULL WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_truly_sell_mazaneh' LIMIT 1); -INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) -SELECT 'display_montzar', 'false', 'نمایش بلوک همکار در UI', 1, 1, NULL -WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'display_montzar' LIMIT 1); - -- API خارجی Node (HMAC) INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) SELECT 'node_client_id', '', 'شناسه کلاینت API خارجی (X-Client-Id)', 1, 1, NULL @@ -164,6 +193,10 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de SELECT 'external_order_api_enabled', 'true', 'فعال‌سازی API سفارش خارجی (get_wallet / order)', 1, 1, 'true + node_client_id + node_shared_secret' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'external_order_api_enabled' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'montify_name', '', 'نام فروشگاه در درگاه', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montify_name' LIMIT 1); + INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) SELECT 'is_store', 'false', 'حالت فروشگاهی', 0, 1, 'فعال = سبد خرید، دسته‌بندی، حواله، پرگار، تخفیف', 'switch' WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'is_store' LIMIT 1); @@ -284,14 +317,6 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de SELECT 'price_extreme_date', '', 'تاریخ min/max روز', 0, 1, NULL WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_extreme_date' LIMIT 1); -INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) -SELECT 'product_update_price_on_list', 'true', 'بروز قیمت در لیست محصول', 1, 1, NULL -WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'product_update_price_on_list' LIMIT 1); - -INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) -SELECT 'product_auto_close_open_on_list', 'true', 'باز/بسته خودکار محصول', 1, 1, NULL -WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'product_auto_close_open_on_list' LIMIT 1); - INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) SELECT 'metal_type', 'طلای آبشده', 'عنوان فلز در UI', 1, 1, NULL WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'metal_type' LIMIT 1); @@ -317,6 +342,86 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de SELECT 'payping_gateway_item', 'gp1Q', 'item تکی (legacy)', 1, 1, NULL WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_item' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'payping_start_url', 'https://payping.limangold.ir/payment/start', 'آدرس شروع درگاه', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_start_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'payping_verify_url', 'https://payping.limangold.ir/payment/verify', 'آدرس تأیید درگاه', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_verify_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'payping_gateway_name', '', 'نام gateway درگاه', 1, 1, 'sepal,', 'select' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_name' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'payping_gateway_items', '', 'لیست item (چرخشی)', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_items' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'payping_round_toman', 'false', 'گرد کردن مبلغ به تومان', 1, 1, NULL, 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_round_toman' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'payping_strict_failed_withdraw', 'false', 'اولویت تراکنش ناموفق', 1, 1, NULL, 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_strict_failed_withdraw' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'open_register', 'true', 'ثبت‌نام باز', 1, 1, NULL, 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'open_register' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'referral_id', 'required', 'کد معرف اجباری', 1, 1, 'روشن = اجباری در ثبت‌نام | خاموش = اختیاری', 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'referral_id' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'fee_single', '500000', 'اختلاف پایه نمایش', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_single' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'buy_fee', '', 'سود خرید نمایش', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'buy_fee' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'sell_fee', '', 'سود فروش نمایش', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'sell_fee' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'fee_cash', '500000', 'کارمزد ریالی سفارش (legacy)', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_cash' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'fee_service_charge_percentage', '0.005', 'درصد کارمزد سفارش', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_service_charge_percentage' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'min_withdraw', '', 'حداقل برداشت (ریال)', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'min_withdraw' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'min_first_buy', '', 'حداقل اولین خرید (ریال)', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'min_first_buy' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'minimum_sell', '', 'حداقل فروش', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'minimum_sell' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'referral_bonus_amount', '', 'مبلغ پاداش معرف', 1, 1, NULL, 'text' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'referral_bonus_amount' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'balance_report_exclude_customer_id', '', 'حذف مشتری از تراز', 1, 1, NULL, 'number' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'balance_report_exclude_customer_id' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'montzar_closed', 'false', 'بسته بودن همکار', 1, 1, NULL, 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_closed' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) +SELECT 'price_from_nasiryan', 'false', 'قیمت از نصیریان', 1, 0, NULL, 'switch' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_from_nasiryan' LIMIT 1); + -- ============================================================================= -- عنوان فارسی (فقط اگر title_fa خالی باشد) -- ============================================================================= @@ -433,6 +538,10 @@ INSERT INTO `const` (`key`, `value`, `title_fa`) SELECT 'price', '[]', 'لیست قیمت TGJU (JSON)' WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'price' LIMIT 1); +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'main_product', '', 'محصول آبشده (fallback)' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'main_product' LIMIT 1); + UPDATE `const` SET `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'شمارنده جیبیت') WHERE `key` = 'jibit_counter'; @@ -450,7 +559,7 @@ WHERE `key` = 'main_product'; -- ============================================================================= -- longtext -UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_about', 'support_messenger_text'); +UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_about', 'support_messenger_text', 'montzar_order_response'); -- select (+ گزینه‌ها در description) UPDATE `settings` SET `type` = 'select', `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE `key` = 'price_provider'; @@ -490,7 +599,7 @@ UPDATE `settings` SET `type` = 'text' WHERE `key` IN ( 'node_client_id', 'node_shared_secret', 'tahesab_bank_account', 'telegram_bot_token', 'bale_bot_token', 'support_messenger_id', 'support_messenger_text', 'referral_limit', 'referral_bonus_amount', 'metal_type', 'montify_name', 'price_extreme_date', - 'liman_token' + 'default_vc_number', 'liman_token' ); -- پیش‌فرض برای ردیف‌های بدون type @@ -577,6 +686,34 @@ INSERT INTO `const` (`key`, `value`, `title_fa`) SELECT 'liman', '', 'توکن fin (legacy)' WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman' LIMIT 1); +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'nasiryan', '', 'توکن API نصیریان' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'nasiryan' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'nasiryan_price', '0', 'قیمت لحظه‌ای نصیریان' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'nasiryan_price' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'nasiryan_diff', '0', 'اختلاف قیمت نصیریان' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'nasiryan_diff' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'nasiryan_mazaneh', '0', 'مظنه نصیریان' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'nasiryan_mazaneh' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'nasiryan_truly_buy_mazaneh', '0', 'مظنه خرید نصیریان' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'nasiryan_truly_buy_mazaneh' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'nasiryan_truly_sell_mazaneh', '0', 'مظنه فروش نصیریان' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'nasiryan_truly_sell_mazaneh' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'nasiryan_closed', 'true', 'بسته بودن نصیریان' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'nasiryan_closed' LIMIT 1); + -- --------------------------------------------------------------------------- -- پاکسازی کلیدهای legacy / تست -- --------------------------------------------------------------------------- @@ -584,13 +721,11 @@ DELETE FROM `settings` WHERE `key` IN ( 'test', 'test2', 'test22', 'test3', 'test33', 'longtest', 'longtest2', 'test*', 'is_requaire_referral', 'send_to_goldir', 'goldir_price', 'liman_token', 'melted_product_id', 'display_montzar', 'tabanGohar_price', 'etehadie_api_url', - 'price_method', 'price_primary_source', 'main_product_price', 'montzar_price', + 'price_method', 'price_primary_source', 'has_page_fund', 'has_page_permission', 'has_page_price_trigger', 'has_page_physical_gold', 'has_chat', 'product_update_price_on_list', 'product_auto_close_open_on_list', 'referral_count_for_gift', 'store_status', - 'name_en', 'bace_url', 'server_url', 'key', 'color_primary', 'color_secondary', - 'logo_register', 'logo_login', 'title_pwa', 'title_fav', 'text_rule', 'text_about', - 'payping_gateway_item' + 'name_en', 'bace_url', 'server_url', 'key', 'color_primary', 'color_secondary' ); DELETE FROM `const` WHERE `key` = 'log' OR `key` LIKE 'goldir%';