This commit is contained in:
2026-06-06 16:05:40 +03:30
parent 08f2f475ed
commit 5b36f2847f
16 changed files with 214 additions and 102 deletions
@@ -1,12 +1,13 @@
-- =============================================================================
-- عبایی گلد — ادغام settings با کاتالوگ goldAliii
-- عبایی گلد — ادغام settings با کاتالوگ واحد
--
-- منبع مقادیر: abaeigold_client.json
-- قالب کلیدها: goldali (102 کلید)
-- قالب کلیدها: goldali (101 کلید)
--
-- قوانین:
-- • کلید مشترک → value از کلاینت، metadata از کاتالوگ
-- • کلید کاتالوگ بدون مقدار در کلاینت → value=''، is_active=0
-- • هر setting با value پر → is_active=1 (الزام ConfigService)
-- • کلیدهای اضافی کلاینت → DELETE
--
-- قبل از اجرا: USE دیتابیس عبایی گلد + بکاپ
@@ -75,13 +76,13 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
SELECT 'external_order_api_enabled', '', 'فعال‌سازی API سفارش خارجی (get_wallet / order)', 1, 0, 'true + node_client_id + node_shared_secret', NULL
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 'fee_cash', '500000', 'اختلاف ریالی هر گرم (سفارش)', 1, 1, 'goldAliii: 0', 'number'
SELECT 'fee_cash', '500000', 'اختلاف ریالی هر گرم (سفارش)', 1, 1, 'مقدار نمونه: 0', '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_free', '0', 'تعداد سفارش اول بدون کارمزد', 1, 1, NULL, 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_free' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'fee_service_charge_percentage', '0.005', 'درصد کارمزد سفارش', 1, 1, 'goldAliii: 7%', 'number'
SELECT 'fee_service_charge_percentage', '0.005', 'درصد کارمزد سفارش', 1, 1, 'مقدار نمونه: 0.07', '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 'fee_single', '500000', 'اختلاف قیمت پایه (ریال)', 1, 1, 'پیش‌فرض Laravel fee.single', 'number'
@@ -114,9 +115,6 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
SELECT 'has_page_price_trigger', 'true', 'صفحه هشدار قیمت', 1, 1, NULL, 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'has_page_price_trigger' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'is_requaire_referral', 'true', 'کد معرف اجباری (قدیمی)', 1, 1, NULL, 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'is_requaire_referral' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'jibit_verification', 'false', 'تأیید کارت بانکی با جیبیت', 1, 1, 'true/false — BankAccountController', 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'jibit_verification' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
@@ -177,7 +175,7 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
SELECT 'montzar_password', '09901810700', 'رمز API همکار', 1, 1, NULL, 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_password' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'montzar_price', 'true', 'قیمت از همکار (montzar)', 1, 1, 'گلد علی: false — zaarbox فعال', 'switch'
SELECT 'montzar_price', 'true', 'قیمت از همکار (montzar)', 1, 1, 'معمولاً false وقتی price_provider=zaarbox', 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montzar_price' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'montzar_product_id', '25', 'کد محصول همکار', 1, 1, NULL, 'number'
@@ -261,13 +259,13 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
SELECT 'referral_count_for_gift', '', 'تعداد معرف برای هدیه', 1, 0, NULL, 'number'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'referral_count_for_gift' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'referral_id', 'required', 'الزام کد معرف', 0, 1, 'required,', 'select'
SELECT 'referral_id', 'required', 'الزام کد معرف', 1, 1, 'required = اجباری؛ خالی = اختیاری|required,', 'select'
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 'referral_limit', '', 'محدودیت دعوت', 1, 0, NULL, 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'referral_limit' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'register_jibit_verify', '', 'تأیید کدملی/موبایل در ثبت‌نام', 1, 0, 'AuthController', 'switch'
SELECT 'register_jibit_verify', 'true', 'تأیید کدملی/موبایل در ثبت‌نام', 1, 1, 'AuthController', 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'register_jibit_verify' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'register_referral_bonus_message', '', 'پیام پاداش در SMS ثبت‌نام', 1, 0, NULL, 'text'
@@ -489,7 +487,7 @@ UPDATE `settings` SET
`title_fa` = 'اختلاف ریالی هر گرم (سفارش)',
`can_edit` = 1,
`type` = 'number',
`description` = 'goldAliii: 0',
`description` = 'مقدار نمونه: 0',
`value` = '500000',
`is_active` = 1,
`updated_at` = NOW()
@@ -507,7 +505,7 @@ UPDATE `settings` SET
`title_fa` = 'درصد کارمزد سفارش',
`can_edit` = 1,
`type` = 'number',
`description` = 'goldAliii: 7%',
`description` = 'مقدار نمونه: 0.07',
`value` = '0.005',
`is_active` = 1,
`updated_at` = NOW()
@@ -602,15 +600,6 @@ UPDATE `settings` SET
`is_active` = 1,
`updated_at` = NOW()
WHERE `key` = 'has_page_price_trigger';
UPDATE `settings` SET
`title_fa` = 'کد معرف اجباری (قدیمی)',
`can_edit` = 1,
`type` = 'switch',
`description` = NULL,
`value` = 'true',
`is_active` = 1,
`updated_at` = NOW()
WHERE `key` = 'is_requaire_referral';
UPDATE `settings` SET
`title_fa` = 'تأیید کارت بانکی با جیبیت',
`can_edit` = 1,
@@ -795,7 +784,7 @@ UPDATE `settings` SET
`title_fa` = 'قیمت از همکار (montzar)',
`can_edit` = 1,
`type` = 'switch',
`description` = 'گلد علی: false — zaarbox فعال',
`description` = 'معمولاً false وقتی price_provider=zaarbox',
`value` = 'true',
`is_active` = 1,
`updated_at` = NOW()
@@ -1045,9 +1034,9 @@ UPDATE `settings` SET
WHERE `key` = 'referral_count_for_gift';
UPDATE `settings` SET
`title_fa` = 'الزام کد معرف',
`can_edit` = 0,
`can_edit` = 1,
`type` = 'select',
`description` = 'required,',
`description` = 'required = اجباری؛ خالی = اختیاری|required,',
`value` = 'required',
`is_active` = 1,
`updated_at` = NOW()
@@ -1066,8 +1055,8 @@ UPDATE `settings` SET
`can_edit` = 1,
`type` = 'switch',
`description` = 'AuthController',
`value` = '',
`is_active` = 0,
`value` = 'true',
`is_active` = 1,
`updated_at` = NOW()
WHERE `key` = 'register_jibit_verify';
UPDATE `settings` SET
@@ -1263,6 +1252,28 @@ UPDATE `settings` SET
`updated_at` = NOW()
WHERE `key` LIKE 'logo_login%' AND `key` <> 'logo_login';
-- 3b) legacy is_requaire_referral → referral_id (قبل از DELETE)
-- legacy is_requaire_referral → 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';
-- 4) DELETE extras
DELETE FROM `settings`
@@ -1297,7 +1308,6 @@ WHERE `key` NOT IN (
'has_page_permission',
'has_page_physical_gold',
'has_page_price_trigger',
'is_requaire_referral',
'jibit_verification',
'key',
'logo_login',
@@ -1373,4 +1383,15 @@ WHERE `key` NOT IN (
DELETE FROM `settings` WHERE `key` = 'price_method';
-- 4b) حذف کلیدهای legacy
DELETE FROM `settings` WHERE `key` = 'is_requaire_referral';
-- 5) is_active — ConfigService فقط وقتی is_active=1 و value پر باشد می‌خواند
UPDATE `settings` SET
`is_active` = 1,
`updated_at` = NOW()
WHERE TRIM(COALESCE(`value`, '')) <> '';
COMMIT;