Files
boursecu_server/database/sql/garoosi_gold_settings_update.sql
T
2026-06-07 10:57:50 +03:30

227 lines
19 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================================
-- گروسی گلد (garoosigold) — به‌روزرسانی settings + const برای ماژول modular
--
-- اصول:
-- • value توکن‌ها، URLها، feeها و montzar_* عمداً عوض نمی‌شود
-- • فقط title_fa / type / is_active / can_edit و INSERT کلیدهای جدید
-- • قبل از اجرا: بکاپ + USE دیتابیس_خودتان;
-- =============================================================================
START TRANSACTION;
-- ---------------------------------------------------------------------------
-- ۱) اصلاح باگ‌های شناخته‌شده
-- ---------------------------------------------------------------------------
-- کلید خراب logo_login\r\n
UPDATE `settings`
SET `key` = 'logo_login', `value` = 'logo_login'
WHERE `key` LIKE 'logo_login%';
-- montzar_closed تکراری (id قدیمی با value=true؛ ردیف switch جدیدتر را نگه می‌داریم)
DELETE s1 FROM `settings` s1
INNER JOIN `settings` s2
ON s1.`key` = s2.`key` AND s1.`id` < s2.`id`
WHERE s1.`key` = 'montzar_closed';
-- عنوان اشتباه product_auto_close_open_on_list
UPDATE `settings`
SET `title_fa` = 'باز/بسته خودکار محصول در لیست'
WHERE `key` = 'product_auto_close_open_on_list';
-- ---------------------------------------------------------------------------
-- ۲) title_fa و type برای کلیدهای موجود (value دست نخورده)
-- ---------------------------------------------------------------------------
UPDATE `settings` SET `title_fa` = 'نام فارسی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'name_fa';
UPDATE `settings` SET `title_fa` = 'نام انگلیسی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'name_en';
UPDATE `settings` SET `title_fa` = 'آدرس اپ (کاربر)', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'app_url';
UPDATE `settings` SET `title_fa` = 'آدرس پایه سرور', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'bace_url';
UPDATE `settings` SET `title_fa` = 'لوگوی ورود', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'logo_login';
UPDATE `settings` SET `title_fa` = 'لوگوی ثبت‌نام', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'logo_register';
UPDATE `settings` SET `title_fa` = 'آدرس پنل ادمین', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'admin_url';
UPDATE `settings` SET `title_fa` = 'توکن ته‌حساب', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'tahesab_token';
UPDATE `settings` SET `title_fa` = 'دیتابیس ته‌حساب', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'tahesab_db';
UPDATE `settings` SET `title_fa` = 'کد معرف اجباری (قدیمی)', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'is_requaire_referral';
UPDATE `settings` SET `title_fa` = 'صفحه کسب درآمد', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_earn_money';
UPDATE `settings` SET `title_fa` = 'صفحه صندوق', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_fund';
UPDATE `settings` SET `title_fa` = 'صفحه مجوزها', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_permission';
UPDATE `settings` SET `title_fa` = 'صفحه هشدار قیمت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_price_trigger';
UPDATE `settings` SET `title_fa` = 'صفحه طلای فیزیکی', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_page_physical_gold';
UPDATE `settings` SET `title_fa` = 'رنگ اصلی', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'color_primary';
UPDATE `settings` SET `title_fa` = 'رنگ ثانویه', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'color_secondary';
UPDATE `settings` SET `title_fa` = 'کارمزد درصدی', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_service_charge_percentage';
UPDATE `settings` SET `title_fa` = 'چت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'has_chat';
UPDATE `settings` SET `title_fa` = 'آدرس API', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'server_url';
UPDATE `settings` SET `title_fa` = 'کلید اپ', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'key';
UPDATE `settings` SET `title_fa` = 'توکن لیمان', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'liman_token';
UPDATE `settings` SET `title_fa` = 'توکن بات تلگرام', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'telegram_bot_token';
UPDATE `settings` SET `title_fa` = 'کارمزد ریالی', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_cash';
UPDATE `settings` SET `title_fa` = 'اختلاف با قیمت واقعی', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_single';
UPDATE `settings` SET `title_fa` = 'ارسال اسناد به ته‌حساب', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'send_to_tahesab';
UPDATE `settings` SET `title_fa` = 'تعداد سفارش اول بدون کارمزد', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'fee_free';
UPDATE `settings` SET `title_fa` = 'پیامک شارژ ادمین', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'charge_notif';
UPDATE `settings` SET `title_fa` = 'فعال‌سازی خودکار کاربر', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'auto_active_customer';
UPDATE `settings` SET `title_fa` = 'ثبت‌نام باز', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'open_register';
UPDATE `settings` SET `title_fa` = 'دریافت قیمت از تابان‌گوهر', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'tabanGohar_price';
UPDATE `settings` SET `title_fa` = 'دریافت قیمت از محصولات', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'main_product_price';
UPDATE `settings` SET `title_fa` = 'حساب بانکی ته‌حساب', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'tahesab_bank_account';
UPDATE `settings` SET `title_fa` = 'کد معرف', `type` = 'select', `is_active` = COALESCE(`is_active`, 1), `description` = 'required,' WHERE `key` = 'referral_id';
UPDATE `settings` SET `title_fa` = 'پیامک گروهی', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'group_sms';
UPDATE `settings` SET `title_fa` = 'توکن بات بله', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'bale_bot_token';
UPDATE `settings` SET `title_fa` = 'تایید کارت با جیبیت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'jibit_verification';
UPDATE `settings` SET `title_fa` = 'پاداش معرف', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'gift_for_referrer';
UPDATE `settings` SET `title_fa` = 'نمایش همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'display_montzar';
UPDATE `settings` SET `title_fa` = 'بستن قیمت در ساعات مشخص', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'close_price';
UPDATE `settings` SET `title_fa` = 'ساعت شروع', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'startDay';
UPDATE `settings` SET `title_fa` = 'ساعت پایان', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'endDay';
UPDATE `settings` SET `title_fa` = 'آدرس API همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_base_url';
UPDATE `settings` SET `title_fa` = 'توکن همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_token';
UPDATE `settings` SET `title_fa` = 'بسته بودن سرویس همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_closed';
UPDATE `settings` SET `title_fa` = 'باز بودن خرید همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_open_buy';
UPDATE `settings` SET `title_fa` = 'باز بودن فروش همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_open_sell';
UPDATE `settings` SET `title_fa` = 'اختلاف قیمت همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_diff';
UPDATE `settings` SET `title_fa` = 'مظنه همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_mazaneh';
UPDATE `settings` SET `title_fa` = 'مظنه خرید واقعی همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_truly_buy_mazaneh';
UPDATE `settings` SET `title_fa` = 'مظنه فروش واقعی همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_truly_sell_mazaneh';
UPDATE `settings` SET `title_fa` = 'پاسخ سفارش همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_order_response';
UPDATE `settings` SET `title_fa` = 'لاگ محصول همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_last_product_log';
UPDATE `settings` SET `title_fa` = 'نشان دادن آخرین قیمت', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'show_last_price';
UPDATE `settings` SET `title_fa` = 'قیمت لحظه‌ای همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1), `can_edit` = 0 WHERE `key` = 'montzar_live_price';
UPDATE `settings` SET `title_fa` = 'بروزرسانی قیمت در لیست', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'product_update_price_on_list';
UPDATE `settings` SET `title_fa` = 'شماره همراه همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_mobile';
UPDATE `settings` SET `title_fa` = 'کلمه عبور همکار', `type` = 'text', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_password';
UPDATE `settings` SET `title_fa` = 'کد محصول همکار', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_product_id';
UPDATE `settings` SET `title_fa` = 'دریافت قیمت از همکار', `type` = 'switch', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'montzar_price';
UPDATE `settings` SET `title_fa` = 'سود خرید', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'buy_fee';
UPDATE `settings` SET `title_fa` = 'سود فروش', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'sell_fee';
UPDATE `settings` SET `title_fa` = 'کد محصول آبشده', `type` = 'number', `is_active` = COALESCE(`is_active`, 1) WHERE `key` = 'melted_product_id';
-- alias کارمزد برای بکند قدیمی (value از fee_service_charge_percentage کپی می‌شود)
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
SELECT
'service_charge_percentage',
'کارمزد درصدی (alias)',
COALESCE(
(SELECT `value` FROM `settings` WHERE `key` = 'fee_service_charge_percentage' LIMIT 1),
'0.005'
),
0, 0, 1, 'number'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'service_charge_percentage' LIMIT 1);
-- ---------------------------------------------------------------------------
-- ۳) فقط کلید ضروری modular
-- ---------------------------------------------------------------------------
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'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_provider' LIMIT 1);
-- ---------------------------------------------------------------------------
-- ۴) حذف کلیدهای اضافی / تست
-- ---------------------------------------------------------------------------
DELETE FROM `settings` WHERE `key` IN (
'test', 'test2', 'test22', 'test3', 'test33', 'longtest', 'longtest2',
'send_to_goldir',
'title_pwa', 'title_fav', 'text_rule', 'text_about',
'min_withdraw', 'min_first_buy', 'minimum_sell',
'gift_for_referral', 'referral_count_for_gift', 'referral_bonus_amount',
'profit_gold_api_enabled', 'register_jibit_verify', 'metal_type',
'support_messenger', 'support_messenger_id', 'support_messenger_text',
'payping_start_url', 'payping_verify_url', 'payping_gateway_name',
'payping_gateway_items', 'payping_round_toman', 'payping_strict_failed_withdraw',
'payping_fin_sync_enabled', 'external_order_api_enabled',
'balance_report_exclude_customer_id',
'zaarbox_api_url', 'zaarbox_price_key', 'chart_id', 'etehadie_api_url'
);
-- type پیش‌فرض برای ردیف‌های بدون type
UPDATE `settings` SET `type` = 'text' WHERE `type` IS NULL OR TRIM(`type`) = '';
UPDATE `settings` SET `type` = 'switch' WHERE `key` IN (
'is_requaire_referral', 'has_page_earn_money', 'has_page_fund', 'has_page_permission',
'has_page_price_trigger', 'has_page_physical_gold', 'has_chat', 'charge_notif',
'auto_active_customer', 'open_register', 'send_to_tahesab', 'tabanGohar_price',
'main_product_price', 'group_sms', 'jibit_verification', 'display_montzar',
'close_price', 'montzar_price', 'show_last_price', 'product_update_price_on_list',
'product_auto_close_open_on_list', 'goldir_price'
);
UPDATE `settings` SET `type` = 'number' WHERE `key` IN (
'fee_single', 'buy_fee', 'sell_fee', 'fee_cash', 'fee_service_charge_percentage',
'fee_free', 'montzar_product_id', 'melted_product_id', 'service_charge_percentage'
);
-- ---------------------------------------------------------------------------
-- ۵) const — عنوان + کلیدهای لازم (value موجود حفظ می‌شود)
-- ---------------------------------------------------------------------------
UPDATE `const` SET `title_fa` = 'قیمت صفحه اصلی' WHERE `key` = 'main_product' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'بنر هدر' WHERE `key` = 'header_banner' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'بسته بودن اپ' WHERE `key` = 'app_closed' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'شمارنده جیبیت' WHERE `key` = 'jibit_counter' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'لاگ آخرین سفارش' WHERE `key` = 'last_order_log' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'لیست قیمت (JSON)' WHERE `key` = 'price' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'ضریب گرم' WHERE `key` = 'gram' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
UPDATE `const` SET `title_fa` = 'اختلاف لیمان' WHERE `key` = 'liman_diff' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = '');
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'gram', '1', 'ضریب گرم'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'gram' LIMIT 1);
INSERT INTO `const` (`key`, `value`, `title_fa`)
SELECT 'liman_diff', '0', 'اختلاف لیمان'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'liman_diff' LIMIT 1);
INSERT INTO `const` (`key`, `value_json`, `title_fa`)
SELECT 'price', '[]', 'لیست قیمت (JSON)'
WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'price' LIMIT 1);
-- goldir_* در const قدیمی است؛ قیمت از montzar_* در settings می‌آید
DELETE FROM `const` WHERE `key` IN (
'goldir', 'goldir_password', 'goldir_mobile', 'goldir_order_response',
'goldir_price', 'goldir_diff', 'goldir_mazaneh',
'goldir_truly_buy_mazaneh', 'goldir_truly_sell_mazaneh',
'goldir_closed', 'goldir_open_buy', 'goldir_open_sell',
'log'
);
-- ⚠ app_closed الان true است — اگر اپ باید باز باشد بعد از اجرا دستی false کنید:
-- UPDATE `const` SET `value` = 'false' WHERE `key` = 'app_closed';
-- ---------------------------------------------------------------------------
-- ۶) products — ستون محدودیت مبلغ سفارش (بدون seed؛ مقدار از ادمین)
-- ---------------------------------------------------------------------------
SET @db = DATABASE();
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'order_limit_enabled') = 0,
'ALTER TABLE `products` ADD COLUMN `order_limit_enabled` TINYINT(1) NOT NULL DEFAULT 0 AFTER `percent_fee_buy`',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'min_order_cash') = 0,
'ALTER TABLE `products` ADD COLUMN `min_order_cash` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `order_limit_enabled`',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'max_order_cash') = 0,
'ALTER TABLE `products` ADD COLUMN `max_order_cash` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `min_order_cash`',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
COMMIT;
-- بعد از اجرا:
-- SELECT `key`, `title_fa`, `value`, `type`, `is_active` FROM `settings` ORDER BY `key`;
-- SELECT `key`, `value`, `title_fa` FROM `const` ORDER BY `key`;
-- SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'products' AND COLUMN_NAME LIKE 'order_limit%' OR COLUMN_NAME LIKE '%order_cash%';