added pargar

This commit is contained in:
2026-07-05 16:43:34 +03:30
parent 694fddc909
commit 7ac7bbdb90
27 changed files with 1341 additions and 493 deletions
@@ -41,21 +41,6 @@ return new class extends Migration
});
}
if (! Schema::hasTable('pargar_reqasts')) {
Schema::create('pargar_reqasts', function (Blueprint $table) {
$table->id();
$table->string('m')->nullable();
$table->string('route')->nullable();
$table->string('ip')->nullable();
$table->json('data')->nullable();
$table->json('finance_head')->nullable();
$table->json('finance_data')->nullable();
$table->json('response')->nullable();
$table->string('function_name')->nullable();
$table->timestamps();
});
}
if (Schema::hasTable('giftcards') && ! Schema::hasColumn('giftcards', 'use_once')) {
Schema::table('giftcards', function (Blueprint $table) {
$table->unsignedTinyInteger('use_once')->default(0)->after('customer_id');
@@ -80,7 +65,6 @@ return new class extends Migration
Schema::dropIfExists('cart_items');
Schema::dropIfExists('cart');
Schema::dropIfExists('categories');
Schema::dropIfExists('pargar_reqasts');
if (Schema::hasTable('giftcards') && Schema::hasColumn('giftcards', 'use_once')) {
Schema::table('giftcards', function (Blueprint $table) {
@@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::dropIfExists('pargar_reqasts');
}
public function down(): void
{
}
};
@@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('pargar_sync_logs')) {
Schema::create('pargar_sync_logs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('customer_id')->nullable()->index();
$table->float('amount')->nullable();
$table->string('desc')->nullable();
$table->unsignedBigInteger('order_id')->nullable()->index();
$table->unsignedBigInteger('withdraw_id')->nullable()->index();
$table->timestamp('date')->nullable();
$table->string('type')->nullable();
$table->string('sync_status', 20)->default('pending');
$table->text('sync_log')->nullable();
$table->string('pargar_ref')->nullable();
$table->text('res')->nullable();
$table->text('data')->nullable();
$table->timestamps();
});
}
if (Schema::hasTable('customers') && ! Schema::hasColumn('customers', 'pargar_account_id')) {
Schema::table('customers', function (Blueprint $table) {
$table->string('pargar_account_id', 64)->nullable()->after('moshtari_code');
});
}
if (Schema::hasTable('orders') && ! Schema::hasColumn('orders', 'pargar_confirmed_at')) {
Schema::table('orders', function (Blueprint $table) {
$table->timestamp('pargar_confirmed_at')->nullable()->after('pay_at');
});
}
}
public function down(): void
{
Schema::dropIfExists('pargar_sync_logs');
if (Schema::hasTable('customers') && Schema::hasColumn('customers', 'pargar_account_id')) {
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('pargar_account_id');
});
}
if (Schema::hasTable('orders') && Schema::hasColumn('orders', 'pargar_confirmed_at')) {
Schema::table('orders', function (Blueprint $table) {
$table->dropColumn('pargar_confirmed_at');
});
}
}
};
@@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
private const KEY = 'accounting_provider';
public function up(): void
{
if (! DB::table('settings')->where('key', self::KEY)->exists()) {
DB::table('settings')->insert([
'key' => self::KEY,
'value' => 'none',
'title_fa' => 'سیستم حسابداری',
'can_edit' => 0,
'is_active' => 1,
'description' => 'none,pargar,tahesab',
'type' => 'select',
]);
}
$current = trim((string) DB::table('settings')->where('key', self::KEY)->value('value'));
if ($current !== '' && $current !== 'none') {
return;
}
$pargarOn = DB::table('settings')->where('key', 'send_to_pargar')->value('value');
if (in_array(strtolower(trim((string) $pargarOn)), ['true', '1', 'yes'], true)) {
DB::table('settings')->where('key', self::KEY)->update(['value' => 'pargar']);
return;
}
$tahesabOn = DB::table('settings')->where('key', 'send_to_tahesab')->value('value');
if (in_array(strtolower(trim((string) $tahesabOn)), ['true', '1', 'yes'], true)) {
DB::table('settings')->where('key', self::KEY)->update(['value' => 'tahesab']);
}
}
public function down(): void
{
// تنظیمات حسابداری حذف نمی‌شوند — rollback فقط مقدار را برنمی‌گرداند
}
};
+48 -7
View File
@@ -220,7 +220,7 @@ SELECT 'montify_name', '', 'نام فروشگاه در درگاه', 0, 1, NULL,
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montify_name' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'is_store', 'false', 'حالت فروشگاهی', 0, 1, 'فعال = سبد خرید، دسته‌بندی، حواله، پرگار، تخفیف', 'switch'
SELECT 'is_store', 'false', 'حالت فروشگاهی', 0, 1, 'فعال = سبد خرید، دسته‌بندی، حواله، تخفیف', 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'is_store' LIMIT 1);
-- Jibit
@@ -292,7 +292,7 @@ SELECT 'sms_panel', 'true', 'پنل پیامک (کیف پول)', 0, 1, 'روشن
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'sms_panel' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'tahesab_host', '', 'آدرس IP سرور ته‌حساب', 1, 1, NULL
SELECT 'tahesab_host', '', 'آدرس IP سرور ته‌حساب', 0, 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`)
@@ -300,21 +300,41 @@ SELECT 'tahesab_port', '', 'پورت سرور ته‌حساب', 0, 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
SELECT 'tahesab_token', '', 'توکن ته‌حساب', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_token' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'tahesab_db', '', 'دیتابیس ته‌حساب', 1, 1, NULL
SELECT 'tahesab_db', '', 'دیتابیس ته‌حساب', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_db' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'tahesab_bank_account', '', 'حساب بانکی ته‌حساب', 1, 1, NULL
SELECT 'tahesab_bank_account', '', 'حساب بانکی ته‌حساب', 0, 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
SELECT 'send_to_tahesab', 'false', 'ارسال به ته‌حساب (قدیمی)', 0, 0, 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 'accounting_provider', 'none', 'سیستم حسابداری', 0, 1, 'none,pargar,tahesab'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'accounting_provider' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'send_to_pargar', 'false', 'ارسال به پرگار (قدیمی)', 0, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'send_to_pargar' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'pargar_username', '', 'نام کاربری API پرگار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'pargar_username' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'pargar_password', '', 'رمز عبور API پرگار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'pargar_password' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'pargar_api_token', '', 'توکن ثابت API پرگار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'pargar_api_token' 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);
@@ -600,6 +620,7 @@ UPDATE `settings` SET `type` = 'longtext' WHERE `key` IN (
);
-- select (+ گزینه‌ها در description)
UPDATE `settings` SET `type` = 'select', `description` = 'none,pargar,tahesab' WHERE `key` = 'accounting_provider';
UPDATE `settings` SET `type` = 'select', `description` = 'منبع فعال قیمت|montzar,zaarbox,main_product' WHERE `key` = 'price_provider';
UPDATE `settings` SET `type` = 'switch', `title_fa` = 'کد معرف اجباری', `description` = 'روشن = اجباری در ثبت‌نام | خاموش = اختیاری' WHERE `key` = 'referral_id';
UPDATE `settings` SET `type` = 'select', `description` = 'sepal,' WHERE `key` = 'payping_gateway_name';
@@ -611,7 +632,7 @@ UPDATE `settings` SET `type` = 'switch' WHERE `key` IN (
'jibit_verification', 'register_jibit_verify', 'open_register', 'auto_active_customer',
'close_price', 'show_last_price',
'fee_deduct_from_gold',
'send_to_tahesab', 'profit_gold_api_enabled', 'payping_round_toman', 'payping_strict_failed_withdraw',
'profit_gold_api_enabled', 'payping_round_toman', 'payping_strict_failed_withdraw',
'has_page_earn_money', 'charge_notif', 'group_sms', 'sms_panel',
'montzar_closed', 'montzar_open_buy', 'montzar_open_sell',
'payping_fin_sync_enabled', 'external_order_api_enabled', 'is_store', 'wss_enabled',
@@ -645,6 +666,7 @@ UPDATE `settings` SET `type` = 'text' WHERE `key` IN (
'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', 'tahesab_host', 'tahesab_token', 'tahesab_db',
'pargar_username', 'pargar_password', 'pargar_api_token',
'node_client_id', 'node_shared_secret',
'sse_path',
'tahesab_bank_account', 'telegram_bot_token', 'bale_bot_token', 'support_messenger_id',
@@ -1222,6 +1244,25 @@ UPDATE `settings` SET
`description` = 'روشن: مشتری دقیقاً همان مبلغ یا وزنی را که وارد کرده دریافت می‌کند. در فروش، مثلاً ۱۰۰ میلیون ریال درخواست → همان ۱۰۰ میلیون واریز و کارمزد از طلای کیف کسر می‌شود. در خرید، مثلاً ۱۰ گرم درخواست → همان ۱۰ گرم واریز و کارمزد به ریال قابل پرداخت اضافه می‌شود. خاموش (پیش‌فرض): در فروش کارمزد از مبلغ ریالی واریزی کم می‌شود (مشتری مبلغ کمتری می‌گیرد). در خرید کارمزد از وزن طلای واریزی کم می‌شود (مشتری طلای کمتری می‌گیرد).'
WHERE `key` = 'fee_deduct_from_gold';
-- حسابداری: یک select مرکزی + can_edit=0
UPDATE `settings` SET `can_edit` = 0, `is_active` = 0 WHERE `key` IN ('send_to_tahesab', 'send_to_pargar');
UPDATE `settings` SET `can_edit` = 0 WHERE `key` IN (
'accounting_provider',
'tahesab_host', 'tahesab_port', 'tahesab_token', 'tahesab_db', 'tahesab_bank_account',
'pargar_username', 'pargar_password', 'pargar_api_token'
);
UPDATE `settings` SET `title_fa` = 'سیستم حسابداری', `type` = 'select', `description` = 'none,pargar,tahesab'
WHERE `key` = 'accounting_provider';
UPDATE `settings` SET `description` = 'سیستم حسابداری: none=هیچکدام، pargar=API پرگار، tahesab=ارسال خودکار ته‌حساب.' WHERE `key` = 'accounting_provider';
UPDATE `settings` SET `value` = 'pargar'
WHERE `key` = 'accounting_provider'
AND TRIM(COALESCE(`value`, '')) IN ('', 'none')
AND EXISTS (SELECT 1 FROM (SELECT `value` FROM `settings` WHERE `key` = 'send_to_pargar') AS s WHERE s.`value` IN ('true', '1', 'yes'));
UPDATE `settings` SET `value` = 'tahesab'
WHERE `key` = 'accounting_provider'
AND TRIM(COALESCE(`value`, '')) IN ('', 'none')
AND EXISTS (SELECT 1 FROM (SELECT `value` FROM `settings` WHERE `key` = 'send_to_tahesab') AS s WHERE s.`value` IN ('true', '1', 'yes'));
COMMIT;
SELECT 'deploy_settings_const.sql finished' AS status;
@@ -216,7 +216,7 @@ SELECT 'montify_name', '', 'نام فروشگاه در درگاه', 1, 1, NULL,
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'montify_name' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`, `type`)
SELECT 'is_store', 'false', 'حالت فروشگاهی', 0, 1, 'فعال = سبد خرید، دسته‌بندی، حواله، پرگار، تخفیف', 'switch'
SELECT 'is_store', 'false', 'حالت فروشگاهی', 0, 1, 'فعال = سبد خرید، دسته‌بندی، حواله، تخفیف', 'switch'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'is_store' LIMIT 1);
-- Jibit
@@ -288,7 +288,7 @@ SELECT 'sms_panel', 'true', 'پنل پیامک (کیف پول)', 0, 1, 'روشن
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'sms_panel' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'tahesab_host', '', 'آدرس IP سرور ته‌حساب', 1, 1, NULL
SELECT 'tahesab_host', '', 'آدرس IP سرور ته‌حساب', 0, 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`)
@@ -296,21 +296,41 @@ SELECT 'tahesab_port', '', 'پورت سرور ته‌حساب', 0, 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
SELECT 'tahesab_token', '', 'توکن ته‌حساب', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_token' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'tahesab_db', '', 'دیتابیس ته‌حساب', 1, 1, NULL
SELECT 'tahesab_db', '', 'دیتابیس ته‌حساب', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'tahesab_db' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'tahesab_bank_account', '', 'حساب بانکی ته‌حساب', 1, 1, NULL
SELECT 'tahesab_bank_account', '', 'حساب بانکی ته‌حساب', 0, 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
SELECT 'send_to_tahesab', 'false', 'ارسال به ته‌حساب (قدیمی)', 0, 0, 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 'accounting_provider', 'none', 'سیستم حسابداری', 0, 1, 'none,pargar,tahesab'
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'accounting_provider' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'send_to_pargar', 'false', 'ارسال به پرگار (قدیمی)', 0, 0, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'send_to_pargar' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'pargar_username', '', 'نام کاربری API پرگار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'pargar_username' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'pargar_password', '', 'رمز عبور API پرگار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'pargar_password' LIMIT 1);
INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`)
SELECT 'pargar_api_token', '', 'توکن ثابت API پرگار', 0, 1, NULL
WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'pargar_api_token' 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);
@@ -1119,6 +1139,25 @@ UPDATE `settings` SET `type` = 'number' WHERE `key` IN (
'deposit_sms_support_number'
);
-- حسابداری: یک select مرکزی + can_edit=0
UPDATE `settings` SET `can_edit` = 0, `is_active` = 0 WHERE `key` IN ('send_to_tahesab', 'send_to_pargar');
UPDATE `settings` SET `can_edit` = 0 WHERE `key` IN (
'accounting_provider',
'tahesab_host', 'tahesab_port', 'tahesab_token', 'tahesab_db', 'tahesab_bank_account',
'pargar_username', 'pargar_password', 'pargar_api_token'
);
UPDATE `settings` SET `title_fa` = 'سیستم حسابداری', `type` = 'select', `description` = 'none,pargar,tahesab'
WHERE `key` = 'accounting_provider';
UPDATE `settings` SET `description` = 'سیستم حسابداری: none=هیچکدام، pargar=API پرگار، tahesab=ارسال خودکار ته‌حساب.' WHERE `key` = 'accounting_provider';
UPDATE `settings` SET `value` = 'pargar'
WHERE `key` = 'accounting_provider'
AND TRIM(COALESCE(`value`, '')) IN ('', 'none')
AND EXISTS (SELECT 1 FROM (SELECT `value` FROM `settings` WHERE `key` = 'send_to_pargar') AS s WHERE s.`value` IN ('true', '1', 'yes'));
UPDATE `settings` SET `value` = 'tahesab'
WHERE `key` = 'accounting_provider'
AND TRIM(COALESCE(`value`, '')) IN ('', 'none')
AND EXISTS (SELECT 1 FROM (SELECT `value` FROM `settings` WHERE `key` = 'send_to_tahesab') AS s WHERE s.`value` IN ('true', '1', 'yes'));
COMMIT;
SELECT 'deploy_settings_const.sql finished' AS status;