This commit is contained in:
2026-06-06 17:05:39 +03:30
parent 5b36f2847f
commit 60ddb9d78c
8 changed files with 204 additions and 5 deletions
+1
View File
@@ -43,6 +43,7 @@ class Customer extends Authenticatable implements JWTSubject
'type', 'type',
'referral_id', 'referral_id',
'referral_to_id', 'referral_to_id',
'total_referrals',
'credential_id', 'credential_id',
'moshtari_code', 'moshtari_code',
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTotalReferralsToCustomersTable extends Migration
{
public function up()
{
if (Schema::hasColumn('customers', 'total_referrals')) {
return;
}
Schema::table('customers', function (Blueprint $table) {
$table->unsignedInteger('total_referrals')->default(0)->after('referral_to_id');
});
}
public function down()
{
if (!Schema::hasColumn('customers', 'total_referrals')) {
return;
}
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('total_referrals');
});
}
}
@@ -1,8 +1,8 @@
-- ============================================================================= -- =============================================================================
-- عبایی گلد — ادغام settings با کاتالوگ واحد -- abaeigold — ادغام settings با کاتالوگ واحد
-- --
-- منبع مقادیر: abaeigold_client.json -- منبع مقادیر: abaeigold_client.json
-- قالب کلیدها: goldali (101 کلید) -- قالب کلیدها: goldali (104 کلید)
-- --
-- قوانین: -- قوانین:
-- • کلید مشترک → value از کلاینت، metadata از کاتالوگ -- • کلید مشترک → value از کلاینت، metadata از کاتالوگ
@@ -10,7 +10,7 @@
-- • هر setting با value پر → is_active=1 (الزام ConfigService) -- • هر setting با value پر → is_active=1 (الزام ConfigService)
-- • کلیدهای اضافی کلاینت → DELETE -- • کلیدهای اضافی کلاینت → DELETE
-- --
-- قبل از اجرا: USE دیتابیس عبایی گلد + بکاپ -- قبل از اجرا: USE دیتابیس abaeigold + بکاپ
-- ============================================================================= -- =============================================================================
START TRANSACTION; START TRANSACTION;
@@ -289,6 +289,15 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
SELECT 'startDay', '10:00', 'شروع بازه معامله', 1, 1, NULL, 'text' SELECT 'startDay', '10:00', 'شروع بازه معامله', 1, 1, NULL, 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'startDay' LIMIT 1); WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'startDay' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger', '', 'پیام‌رسان پشتیبانی', 1, 0, 'bale,telegram,whatsapp,rubika,eitaa,soroush', 'select'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger_id', '', 'شناسه پشتیبانی پیام‌رسان', 1, 0, 'بله: یوزرنیم ble.ir | تلگرام: یوزرنیم | واتساپ: شماره با کد کشور | روبیکا/ایتا/سروش: یوزرنیم', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger_text', '', 'متن پشتیبانی پیام‌رسان', 1, 0, 'متن دکمه یا توضیح پشتیبانی در اپ کاربر', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_text' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'tabanGohar_price', 'false', 'قیمت تابان گوهر', 1, 1, NULL, 'switch' SELECT 'tabanGohar_price', 'false', 'قیمت تابان گوهر', 1, 1, NULL, 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tabanGohar_price' LIMIT 1); 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`, `type`) INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
@@ -1122,6 +1131,33 @@ UPDATE `settings` SET
`is_active` = 1, `is_active` = 1,
`updated_at` = NOW() `updated_at` = NOW()
WHERE `key` = 'startDay'; WHERE `key` = 'startDay';
UPDATE `settings` SET
`title_fa` = 'پیام‌رسان پشتیبانی',
`can_edit` = 1,
`type` = 'select',
`description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush',
`value` = '',
`is_active` = 0,
`updated_at` = NOW()
WHERE `key` = 'support_messenger';
UPDATE `settings` SET
`title_fa` = 'شناسه پشتیبانی پیام‌رسان',
`can_edit` = 1,
`type` = 'text',
`description` = 'بله: یوزرنیم ble.ir | تلگرام: یوزرنیم | واتساپ: شماره با کد کشور | روبیکا/ایتا/سروش: یوزرنیم',
`value` = '',
`is_active` = 0,
`updated_at` = NOW()
WHERE `key` = 'support_messenger_id';
UPDATE `settings` SET
`title_fa` = 'متن پشتیبانی پیام‌رسان',
`can_edit` = 1,
`type` = 'text',
`description` = 'متن دکمه یا توضیح پشتیبانی در اپ کاربر',
`value` = '',
`is_active` = 0,
`updated_at` = NOW()
WHERE `key` = 'support_messenger_text';
UPDATE `settings` SET UPDATE `settings` SET
`title_fa` = 'قیمت تابان گوهر', `title_fa` = 'قیمت تابان گوهر',
`can_edit` = 1, `can_edit` = 1,
@@ -1366,6 +1402,9 @@ WHERE `key` NOT IN (
'server_url', 'server_url',
'show_last_price', 'show_last_price',
'startDay', 'startDay',
'support_messenger',
'support_messenger_id',
'support_messenger_text',
'tabanGohar_price', 'tabanGohar_price',
'tahesab_bank_account', 'tahesab_bank_account',
'tahesab_db', 'tahesab_db',
@@ -1,5 +1,5 @@
-- ============================================================================= -- =============================================================================
-- عبایی گلد — ادغام const با کاتالوگ واحد -- abaeigold — ادغام const با کاتالوگ واحد
-- --
-- منبع مقادیر: abaeigold_client.json -- منبع مقادیر: abaeigold_client.json
-- قالب: 10 کلید goldali -- قالب: 10 کلید goldali
@@ -42,6 +42,15 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
SELECT 'bale_bot_token', '', 'توکن بات بله', 0, 0, NULL, 'text' SELECT 'bale_bot_token', '', 'توکن بات بله', 0, 0, NULL, 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'bale_bot_token' LIMIT 1); WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'bale_bot_token' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`) INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger_id', '', 'شناسه پشتیبانی پیام‌رسان', 1, 0, 'بله: یوزرنیم ble.ir | تلگرام: یوزرنیم | واتساپ: شماره با کد کشور | روبیکا/ایتا/سروش: یوزرنیم', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger_text', '', 'متن پشتیبانی پیام‌رسان', 1, 0, 'متن دکمه یا توضیح پشتیبانی در اپ کاربر', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_text' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger', 'bale', 'پیام‌رسان پشتیبانی', 1, 1, 'bale,telegram,whatsapp,rubika,eitaa,soroush', 'select'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'buy_fee', '0', 'سود/اختلاف خرید (ریال)', 1, 1, 'اگر خالی باشد از fee_single', 'number' SELECT 'buy_fee', '0', 'سود/اختلاف خرید (ریال)', 1, 1, 'اگر خالی باشد از fee_single', 'number'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'buy_fee' LIMIT 1); 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`) INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
@@ -384,6 +393,33 @@ UPDATE `settings` SET
`is_active` = 0, `is_active` = 0,
`updated_at` = NOW() `updated_at` = NOW()
WHERE `key` = 'bale_bot_token'; WHERE `key` = 'bale_bot_token';
UPDATE `settings` SET
`title_fa` = 'شناسه پشتیبانی پیام‌رسان',
`can_edit` = 1,
`type` = 'text',
`description` = 'بله: یوزرنیم ble.ir | تلگرام: یوزرنیم | واتساپ: شماره با کد کشور | روبیکا/ایتا/سروش: یوزرنیم',
`value` = '',
`is_active` = 0,
`updated_at` = NOW()
WHERE `key` = 'support_messenger_id';
UPDATE `settings` SET
`title_fa` = 'متن پشتیبانی پیام‌رسان',
`can_edit` = 1,
`type` = 'text',
`description` = 'متن دکمه یا توضیح پشتیبانی در اپ کاربر',
`value` = '',
`is_active` = 0,
`updated_at` = NOW()
WHERE `key` = 'support_messenger_text';
UPDATE `settings` SET
`title_fa` = 'پیام‌رسان پشتیبانی',
`can_edit` = 1,
`type` = 'select',
`description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush',
`value` = 'bale',
`is_active` = 1,
`updated_at` = NOW()
WHERE `key` = 'support_messenger';
UPDATE `settings` SET UPDATE `settings` SET
`title_fa` = 'سود/اختلاف خرید (ریال)', `title_fa` = 'سود/اختلاف خرید (ریال)',
`can_edit` = 1, `can_edit` = 1,
@@ -1263,6 +1299,8 @@ WHERE `key` NOT IN (
'bace_url', 'bace_url',
'balance_report_exclude_customer_id', 'balance_report_exclude_customer_id',
'bale_bot_token', 'bale_bot_token',
'support_messenger_id',
'support_messenger_text',
'buy_fee', 'buy_fee',
'charge_notif', 'charge_notif',
'chart_id', 'chart_id',
@@ -1345,6 +1383,7 @@ WHERE `key` NOT IN (
'server_url', 'server_url',
'show_last_price', 'show_last_price',
'startDay', 'startDay',
'support_messenger',
'tabanGohar_price', 'tabanGohar_price',
'tahesab_bank_account', 'tahesab_bank_account',
'tahesab_db', 'tahesab_db',
@@ -1384,4 +1423,8 @@ WHERE r.`key` = 'referral_id'
DELETE FROM `settings` WHERE `key` = 'is_requaire_referral'; DELETE FROM `settings` WHERE `key` = 'is_requaire_referral';
-- legacy bale_support_* → support_messenger_*
UPDATE `settings` SET `key` = 'support_messenger_id' WHERE `key` = 'bale_support_id';
UPDATE `settings` SET `key` = 'support_messenger_text' WHERE `key` = 'bale_support_text';
COMMIT; COMMIT;
@@ -0,0 +1,50 @@
-- کلیدهای پشتیبانی پیام‌رسان (support_messenger + id + text)
-- یک بار روی هر دیتابیس فعال: USE دیتابیس + بکاپ
START TRANSACTION;
-- rename کلیدهای قدیمی bale_support_*
UPDATE `settings` SET `key` = 'support_messenger_id' WHERE `key` = 'bale_support_id';
UPDATE `settings` SET `key` = 'support_messenger_text' WHERE `key` = 'bale_support_text';
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger_id', '', 'شناسه پشتیبانی پیام‌رسان', 1, 0, 'بله: یوزرنیم ble.ir | تلگرام: یوزرنیم | واتساپ: شماره با کد کشور | روبیکا/ایتا/سروش: یوزرنیم', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger_text', '', 'متن پشتیبانی پیام‌رسان', 1, 0, 'متن دکمه یا توضیح پشتیبانی در اپ کاربر', 'text'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_text' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'support_messenger', 'bale', 'پیام‌رسان پشتیبانی', 1, 1, 'bale,telegram,whatsapp,rubika,eitaa,soroush', 'select'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger' LIMIT 1);
UPDATE `settings` SET
`title_fa` = 'شناسه پشتیبانی پیام‌رسان',
`can_edit` = 1,
`type` = 'text',
`description` = 'بله: یوزرنیم ble.ir | تلگرام: یوزرنیم | واتساپ: شماره با کد کشور | روبیکا/ایتا/سروش: یوزرنیم',
`updated_at` = NOW()
WHERE `key` = 'support_messenger_id';
UPDATE `settings` SET
`title_fa` = 'متن پشتیبانی پیام‌رسان',
`can_edit` = 1,
`type` = 'text',
`description` = 'متن دکمه یا توضیح پشتیبانی در اپ کاربر',
`updated_at` = NOW()
WHERE `key` = 'support_messenger_text';
UPDATE `settings` SET
`title_fa` = 'پیام‌رسان پشتیبانی',
`can_edit` = 1,
`type` = 'select',
`description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush',
`value` = COALESCE(NULLIF(TRIM(`value`), ''), 'bale'),
`is_active` = 1,
`updated_at` = NOW()
WHERE `key` = 'support_messenger';
COMMIT;
-- مقادیر support_messenger: bale | telegram | whatsapp | rubika | eitaa | soroush
@@ -0,0 +1,23 @@
-- تعداد دعوت‌های هر معرف — AuthController::register → increment('total_referrals')
-- یک بار روی سرور: USE دیتابیس + بکاپ
START TRANSACTION;
ALTER TABLE `customers`
ADD COLUMN `total_referrals` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `referral_to_id`;
-- هم‌تراز با تعداد ثبت‌نام‌های واقعی (اختیاری ولی توصیه می‌شود)
UPDATE `customers` AS c
SET c.`total_referrals` = (
SELECT COUNT(*)
FROM (
SELECT `id`
FROM `customers`
WHERE `referral_to_id` = c.`referral_id`
AND `deleted_at` IS NULL
) AS r
)
WHERE c.`referral_id` IS NOT NULL
AND TRIM(c.`referral_id`) <> '';
COMMIT;
+14 -1
View File
@@ -192,6 +192,18 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
SELECT 'bale_bot_token', '', 'توکن بات بله', 0, 1, NULL SELECT 'bale_bot_token', '', 'توکن بات بله', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'bale_bot_token' LIMIT 1); WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'bale_bot_token' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'support_messenger_id', '', 'شناسه پشتیبانی پیام‌رسان', 1, 0, 'بله: یوزرنیم ble.ir | تلگرام: یوزرنیم | واتساپ: شماره با کد کشور | روبیکا/ایتا/سروش: یوزرنیم'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_id' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'support_messenger_text', '', 'متن پشتیبانی پیام‌رسان', 1, 0, 'متن دکمه یا توضیح پشتیبانی در اپ کاربر'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger_text' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'support_messenger', 'bale', 'پیام‌رسان پشتیبانی', 1, 1, 'bale,telegram,whatsapp,rubika,eitaa,soroush'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger' LIMIT 1);
-- min/max قیمت روز (سیستم) -- min/max قیمت روز (سیستم)
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'up_price', '0', 'بیشترین قیمت امروز', 0, 1, 'ReportController' SELECT 'up_price', '0', 'بیشترین قیمت امروز', 0, 1, 'ReportController'
@@ -340,6 +352,7 @@ UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_abo
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,etehadie,taban_gohar' 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` = '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` = 'sepal,' WHERE `key` = 'payping_gateway_name';
UPDATE `settings` SET `type` = 'select', `description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush' WHERE `key` = 'support_messenger';
-- switch -- switch
UPDATE `settings` SET `type` = 'switch' WHERE `key` IN ( UPDATE `settings` SET `type` = 'switch' WHERE `key` IN (
@@ -371,7 +384,7 @@ UPDATE `settings` SET `type` = 'text' WHERE `key` IN (
'payping_start_url', 'payping_verify_url', 'payping_gateway_items', 'payping_fin_url', 'payping_start_url', 'payping_verify_url', 'payping_gateway_items', 'payping_fin_url',
'payping_fin_token', 'payping_gateway_item', 'tahesab_token', 'tahesab_db', 'payping_fin_token', 'payping_gateway_item', 'tahesab_token', 'tahesab_db',
'node_client_id', 'node_shared_secret', 'node_client_id', 'node_shared_secret',
'tahesab_bank_account', 'telegram_bot_token', 'bale_bot_token', 'referral_limit', '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', 'referral_bonus_amount', 'metal_type', 'montify_name', 'price_extreme_date',
'liman_token' 'liman_token'
); );