sql edits
This commit is contained in:
@@ -16,6 +16,21 @@ use Hekmatinasser\Verta\Verta;
|
||||
|
||||
class TahesabController extends Controller
|
||||
{
|
||||
private function tahesabApiUrl(): string
|
||||
{
|
||||
$host = trim((string) $this->Config('tahesab_host'));
|
||||
$port = trim((string) $this->Config('tahesab_port'));
|
||||
|
||||
if ($host !== '' && $port !== '') {
|
||||
$host = rtrim(preg_replace('#^https?://#i', '', $host), '/');
|
||||
|
||||
return 'http://' . $host . ':' . $port . '/';
|
||||
}
|
||||
|
||||
$legacy = trim((string) env('TAHESAB', ''));
|
||||
|
||||
return $legacy !== '' ? $legacy : '';
|
||||
}
|
||||
|
||||
public function storeTrade($data)
|
||||
{
|
||||
@@ -68,7 +83,7 @@ class TahesabController extends Controller
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||
])->post((string)env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
"DoNewSanadBuySaleGOLD" => [
|
||||
1,//Sabte_Kol_Or_Movaghat_1_0
|
||||
(int)$customer->moshtari_code, //Moshtari_Code
|
||||
@@ -159,7 +174,7 @@ class TahesabController extends Controller
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||
])->post((string)env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
"DoNewSanadVKHBank" => [
|
||||
1,//Sabte_Kol_Or_Movaghat_1_0
|
||||
$customer->moshtari_code,//Moshtari_Code
|
||||
@@ -207,7 +222,7 @@ class TahesabController extends Controller
|
||||
// 'DBName' => $this->ConfigService('tahesab_db'),
|
||||
// 'Content-Type' => 'application/json',
|
||||
// 'Authorization' => "Bearer " . $this->ConfigService('tahesab_token'),
|
||||
// ])->post((string)env('TAHESAB'), [
|
||||
// ])->post($this->tahesabApiUrl(), [
|
||||
// "DoNewSanadVKHBank" => [
|
||||
// 1,//Sabte_Kol_Or_Movaghat_1_0
|
||||
// $customer->moshtari_code,//Moshtari_Code
|
||||
@@ -247,7 +262,7 @@ class TahesabController extends Controller
|
||||
// 'DBName' => $this->ConfigService('tahesab_db'),
|
||||
// 'Content-Type' => 'application/json',
|
||||
// 'Authorization' => "Bearer " . $this->ConfigService('tahesab_token'),
|
||||
// ])->post((string)env('TAHESAB'), [
|
||||
// ])->post($this->tahesabApiUrl(), [
|
||||
// "DoNewSanadTalabBedehi" => [
|
||||
// 1,//Sabte_Kol_Or_Movaghat_1_0,
|
||||
// $customer->moshtari_code,//Moshtari_Code
|
||||
@@ -343,7 +358,7 @@ class TahesabController extends Controller
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . $this->Config('tahesab_token'),
|
||||
])->post((string) env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
'DoNewSanadTalabBedehi' => [
|
||||
1, // Sabte_Kol
|
||||
(int) $customer->moshtari_code,
|
||||
@@ -442,7 +457,7 @@ class TahesabController extends Controller
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||
])->post((string)env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
"DoNewSanadBuySaleGOLD" => [
|
||||
1,//Sabte_Kol_Or_Movaghat_1_0
|
||||
(int)$customer->moshtari_code, //Moshtari_Code
|
||||
@@ -499,7 +514,7 @@ class TahesabController extends Controller
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||
])->post((string)env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
"DoNewMoshtari" => [
|
||||
(string)$customer->name,
|
||||
$this->Config('name_fa'),
|
||||
@@ -531,7 +546,7 @@ class TahesabController extends Controller
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||
])->post((string)env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
"DoEditMoshtari" => [
|
||||
$customer->name,
|
||||
$this->Config('name_fa'),
|
||||
@@ -566,7 +581,7 @@ class TahesabController extends Controller
|
||||
'Content-Type' => 'application/json',
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||
])->post((string)env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
"CheckHealth" => []
|
||||
])->json();
|
||||
|
||||
@@ -584,7 +599,7 @@ class TahesabController extends Controller
|
||||
'Content-Type' => 'application/json',
|
||||
'DBName' => $this->Config('tahesab_db'),
|
||||
'Authorization' => "Bearer " . $this->Config('tahesab_token'),
|
||||
])->post((string)env('TAHESAB'), [
|
||||
])->post($this->tahesabApiUrl(), [
|
||||
"DoListAsnad" => [
|
||||
10, /*Count_Last,*/
|
||||
"", /*Moshtari_Code,*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
--
|
||||
-- اصول:
|
||||
-- • چند بار قابل اجرا (idempotent)
|
||||
-- • value / is_active / can_edit ردیفهای موجود دست نخورده
|
||||
-- • value / is_active ردیفهای موجود دست نخورده (بهجز تهحساب: can_edit و value خالی؛ is_store: can_edit=0)
|
||||
-- • فقط INSERT برای کلیدهای جدید + بهروز type / title_fa / description
|
||||
-- • schema (جدول/ستون) فقط با migrate — نه این فایل
|
||||
--
|
||||
@@ -165,7 +165,7 @@ SELECT 'external_order_api_enabled', 'true', 'فعالسازی API سفارش
|
||||
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 'is_store', 'false', 'حالت فروشگاهی', 1, 1, 'فعال = سبد خرید، دستهبندی، حواله، پرگار، تخفیف', 'switch'
|
||||
SELECT 'is_store', 'false', 'حالت فروشگاهی', 0, 1, 'فعال = سبد خرید، دستهبندی، حواله، پرگار، تخفیف', 'switch'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'is_store' LIMIT 1);
|
||||
|
||||
-- Jibit
|
||||
@@ -227,6 +227,14 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
|
||||
SELECT 'group_sms', 'false', 'پیامک گروهی', 1, 1, NULL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'group_sms' LIMIT 1);
|
||||
|
||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||
SELECT 'tahesab_host', '', 'آدرس IP سرور تهحساب', 1, 1, NULL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_host' LIMIT 1);
|
||||
|
||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||
SELECT 'tahesab_port', '', 'پورت سرور تهحساب', 1, 1, NULL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_port' LIMIT 1);
|
||||
|
||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||
SELECT 'tahesab_token', '', 'توکن تهحساب', 1, 1, NULL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_token' LIMIT 1);
|
||||
@@ -239,6 +247,10 @@ INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `de
|
||||
SELECT 'tahesab_bank_account', '', 'حساب بانکی تهحساب', 1, 1, NULL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_bank_account' LIMIT 1);
|
||||
|
||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||
SELECT 'send_to_tahesab', 'false', 'ارسال به تهحساب', 1, 1, NULL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'send_to_tahesab' LIMIT 1);
|
||||
|
||||
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
|
||||
SELECT 'telegram_bot_token', '', 'توکن بات تلگرام', 0, 1, NULL
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'telegram_bot_token' LIMIT 1);
|
||||
@@ -256,7 +268,7 @@ SELECT 'support_messenger_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`)
|
||||
SELECT 'support_messenger', 'bale', 'پیامرسان پشتیبانی', 1, 1, 'bale,telegram,whatsapp,rubika,eitaa,soroush'
|
||||
SELECT 'support_messenger', '', 'پیامرسان پشتیبانی', 1, 1, 'bale,telegram,whatsapp,rubika,eitaa,soroush'
|
||||
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'support_messenger' LIMIT 1);
|
||||
|
||||
-- min/max قیمت روز (سیستم)
|
||||
@@ -438,7 +450,7 @@ WHERE `key` = 'main_product';
|
||||
-- =============================================================================
|
||||
|
||||
-- longtext
|
||||
UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_about');
|
||||
UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN ('text_rule', 'text_about', 'support_messenger_text');
|
||||
|
||||
-- select (+ گزینهها در description)
|
||||
UPDATE `settings` SET `type` = 'select', `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE `key` = 'price_provider';
|
||||
@@ -463,7 +475,7 @@ UPDATE `settings` SET `type` = 'number' WHERE `key` IN (
|
||||
'fee_single', 'buy_fee', 'sell_fee', 'fee_cash', 'fee_service_charge_percentage', 'fee_free',
|
||||
'min_withdraw', 'min_first_buy', 'minimum_sell',
|
||||
'montzar_product_id', 'balance_report_exclude_customer_id', 'gift_for_referrer',
|
||||
'gift_for_referral', 'up_price', 'down_price', 'payping_fin_customer_id'
|
||||
'gift_for_referral', 'up_price', 'down_price', 'payping_fin_customer_id', 'tahesab_port'
|
||||
);
|
||||
|
||||
-- text (بقیه — URL، توکن، کلید API، ساعت، ...)
|
||||
@@ -474,7 +486,7 @@ UPDATE `settings` SET `type` = 'text' WHERE `key` IN (
|
||||
'montzar_token', 'montzar_diff', 'montzar_live_price', 'montzar_mazaneh',
|
||||
'montzar_truly_buy_mazaneh', 'montzar_truly_sell_mazaneh', 'startDay', 'endDay',
|
||||
'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_host', 'tahesab_token', 'tahesab_db',
|
||||
'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',
|
||||
@@ -584,7 +596,7 @@ DELETE FROM `settings` WHERE `key` IN (
|
||||
DELETE FROM `const` WHERE `key` = 'log' OR `key` LIKE 'goldir%';
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- metadata — فقط type / title_fa / description (بدون value / is_active / can_edit)
|
||||
-- metadata — type / title_fa / description (+ can_edit تهحساب)
|
||||
-- ---------------------------------------------------------------------------
|
||||
UPDATE `settings` SET `description` = NULL
|
||||
WHERE LOWER(TRIM(COALESCE(`description`, ''))) IN ('true', 'false', '0', '1', 'yes', 'no', 'in server')
|
||||
@@ -622,7 +634,7 @@ WHERE `key` = 'support_messenger_id';
|
||||
|
||||
UPDATE `settings` SET
|
||||
`title_fa` = 'متن پشتیبانی پیامرسان',
|
||||
`type` = 'text',
|
||||
`type` = 'longtext',
|
||||
`description` = 'متن دکمه یا توضیح پشتیبانی در اپ کاربر'
|
||||
WHERE `key` = 'support_messenger_text';
|
||||
|
||||
@@ -632,6 +644,43 @@ UPDATE `settings` SET
|
||||
`description` = 'bale,telegram,whatsapp,rubika,eitaa,soroush'
|
||||
WHERE `key` = 'support_messenger';
|
||||
|
||||
UPDATE `settings` SET
|
||||
`title_fa` = 'آدرس IP سرور تهحساب',
|
||||
`type` = 'text',
|
||||
`description` = NULL
|
||||
WHERE `key` = 'tahesab_host';
|
||||
|
||||
UPDATE `settings` SET
|
||||
`title_fa` = 'پورت سرور تهحساب',
|
||||
`type` = 'number',
|
||||
`description` = NULL
|
||||
WHERE `key` = 'tahesab_port';
|
||||
|
||||
UPDATE `settings` SET
|
||||
`title_fa` = 'نام دیتابیس تهحساب',
|
||||
`type` = 'text',
|
||||
`description` = 'مثال: TahesabDB'
|
||||
WHERE `key` = 'tahesab_db';
|
||||
|
||||
UPDATE `settings` SET
|
||||
`title_fa` = 'حساب بانکی تهحساب',
|
||||
`type` = 'text',
|
||||
`description` = 'نام حساب بانکی در سند واریز'
|
||||
WHERE `key` = 'tahesab_bank_account';
|
||||
|
||||
-- تهحساب: قابل ویرایش + مقدار پیشفرض خالی
|
||||
UPDATE `settings` SET `can_edit` = 1
|
||||
WHERE `key` LIKE 'tahesab_%' OR `key` = 'send_to_tahesab';
|
||||
|
||||
UPDATE `settings` SET `value` = ''
|
||||
WHERE `key` IN ('tahesab_host', 'tahesab_port', 'tahesab_token', 'tahesab_db', 'tahesab_bank_account');
|
||||
|
||||
UPDATE `settings` SET `value` = 'false'
|
||||
WHERE `key` = 'send_to_tahesab' AND TRIM(COALESCE(`value`, '')) = '';
|
||||
|
||||
-- is_store فقط از دیتابیس/دیپلوی — در پنل قابل ویرایش نیست
|
||||
UPDATE `settings` SET `can_edit` = 0 WHERE `key` = 'is_store';
|
||||
|
||||
-- پاکسازی title_fa / description از نام پروژه یا ارجاع کد
|
||||
UPDATE `settings` SET `title_fa` = 'حالت فروشگاهی'
|
||||
WHERE `key` = 'is_store' AND (`title_fa` LIKE '%قطره%' OR `title_fa` LIKE '%کشکول%');
|
||||
|
||||
Reference in New Issue
Block a user