153 lines
7.4 KiB
SQL
153 lines
7.4 KiB
SQL
-- =============================================================================
|
|
-- گروسی گلد — تکمیل merge (اگر garoosi_gold_settings_update.sql نصفه ماند)
|
|
-- امن برای اجرای مجدد. قبل: USE دیتابیس + بکاپ
|
|
-- =============================================================================
|
|
|
|
START TRANSACTION;
|
|
|
|
SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
|
|
ALTER TABLE `settings`
|
|
MODIFY COLUMN `description` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
|
|
MODIFY COLUMN `title_fa` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
|
|
MODIFY COLUMN `type` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL;
|
|
|
|
-- legacy → referral_id
|
|
UPDATE `settings` AS r
|
|
SET r.`value` = 'required', r.`is_active` = 1, r.`updated_at` = NOW()
|
|
WHERE r.`key` = 'referral_id'
|
|
AND EXISTS (
|
|
SELECT 1 FROM (
|
|
SELECT `value`, `is_active` FROM `settings`
|
|
WHERE `key` = 'is_requaire_referral' LIMIT 1
|
|
) AS leg
|
|
WHERE leg.`is_active` = 1
|
|
AND LOWER(TRIM(COALESCE(leg.`value`, ''))) IN ('true', '1', 'yes')
|
|
)
|
|
AND TRIM(COALESCE(r.`value`, '')) <> 'required';
|
|
|
|
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'
|
|
);
|
|
|
|
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);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'register_jibit_verify', 'تایید کد ملی در ثبتنام', 'false', 1, 0, 1, 'switch'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'register_jibit_verify' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'gift_for_referral', 'پاداش معرفیشده', '0', 1, 0, 1, 'number'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'gift_for_referral' LIMIT 1);
|
|
|
|
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);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'title_pwa', 'عنوان PWA', 'گروسی گلد', 1, 0, 1, 'text'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'title_pwa' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'title_fav', 'عنوان favicon', 'گروسی گلد', 1, 0, 1, 'text'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'title_fav' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'text_rule', 'متن قوانین', '', 1, 0, 1, 'longtext'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'text_rule' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'text_about', 'متن درباره ما', '', 1, 0, 1, 'longtext'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'text_about' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'metal_type', 'نوع فلز', 'gold', 1, 0, 1, 'text'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'metal_type' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'main_product', 'محصول آبشده', '13', 1, 0, 1, 'text'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'main_product' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'zaarbox_api_url', 'آدرس API تابلو Zaarbox', '', 1, 0, 1, 'text'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'zaarbox_api_url' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`)
|
|
SELECT 'zaarbox_price_key', 'شناسه ردیف تابلو (key یا UUID)', '', 1, 0, 1, 'text'
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'zaarbox_price_key' LIMIT 1);
|
|
|
|
INSERT INTO `settings` (`key`, `title_fa`, `value`, `can_edit`, `is_exist`, `is_active`, `type`, `description`, `updated_at`)
|
|
SELECT
|
|
'chart_id',
|
|
'UUID نمودار Zaarbox',
|
|
'8c19e06a-446e-3d56-9cc0-750f7c6cd767',
|
|
1, 0, 1, 'text',
|
|
'خالی = ca3800a0-1f57-3528-b963-178f9168e04f',
|
|
NOW()
|
|
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'chart_id' LIMIT 1);
|
|
|
|
-- پاکسازی description قدیمی / اشتباه
|
|
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%';
|
|
|
|
-- description کاتالوگ
|
|
UPDATE `settings` SET
|
|
`title_fa` = 'کد معرف',
|
|
`type` = 'select',
|
|
`description` = 'required = اجباری|required,'
|
|
WHERE `key` = 'referral_id';
|
|
|
|
-- [super-admin can_edit=0]
|
|
-- UPDATE `settings` SET
|
|
-- `title_fa` = 'منبع قیمت',
|
|
-- `type` = 'select',
|
|
-- `is_active` = 1,
|
|
-- `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product,taban_gohar'
|
|
-- WHERE `key` = 'price_provider';
|
|
|
|
-- [super-admin can_edit=0]
|
|
-- UPDATE `settings` SET
|
|
-- `title_fa` = 'UUID نمودار Zaarbox',
|
|
-- `type` = 'text',
|
|
-- `is_active` = 1,
|
|
-- `can_edit` = 1,
|
|
-- `description` = 'خالی = ca3800a0-1f57-3528-b963-178f9168e04f',
|
|
-- `value` = CASE
|
|
-- WHEN TRIM(COALESCE(`value`, '')) = '' THEN '8c19e06a-446e-3d56-9cc0-750f7c6cd767'
|
|
-- ELSE `value`
|
|
-- END
|
|
-- WHERE `key` = 'chart_id';
|
|
|
|
UPDATE `settings` SET `description` = 'جایگزین: price_provider=main_product' WHERE `key` = 'main_product_price';
|
|
UPDATE `settings` SET `description` = 'true یا price_provider=montzar' WHERE `key` = 'montzar_price';
|
|
UPDATE `settings` SET `description` = 'تعداد سفارش اول بدون کارمزد' WHERE `key` = 'fee_free';
|
|
-- [super-admin can_edit=0]
|
|
-- UPDATE `settings` SET `description` = 'id یا reading_method محصول آبشده' WHERE `key` = 'main_product';
|
|
|
|
UPDATE `settings` SET `type` = 'switch' WHERE `key` IN (
|
|
'group_sms', 'bale_bot_token', 'jibit_verification', 'register_jibit_verify',
|
|
'close_price', 'gift_for_referrer'
|
|
) AND (`type` IS NULL OR TRIM(`type`) = '');
|
|
|
|
UPDATE `settings` SET `type` = 'number' WHERE `key` IN (
|
|
'buy_fee', 'sell_fee', 'gift_for_referrer', 'montzar_product_id'
|
|
) AND (`type` IS NULL OR TRIM(`type`) = '' OR `type` = 'text');
|
|
|
|
UPDATE `settings` SET `type` = 'select', `description` = 'required = اجباری|required,'
|
|
WHERE `key` = 'referral_id' AND (`type` IS NULL OR TRIM(`type`) = '');
|
|
|
|
UPDATE `settings` SET `is_active` = 1 WHERE `key` IN ('zaarbox_api_url', 'zaarbox_price_key', 'chart_id');
|
|
|
|
COMMIT;
|
|
|
|
-- SELECT `key`, `title_fa`, `value`, `description`, `type`, `is_active` FROM `settings` ORDER BY `key`;
|