added zarin

This commit is contained in:
2026-07-23 20:24:58 +03:30
parent d8b685524b
commit 8a4a406e66
17 changed files with 2007 additions and 10 deletions
@@ -0,0 +1,49 @@
<?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('zarin')) {
Schema::create('zarin', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('customer_id')->nullable()->index();
$table->unsignedBigInteger('order_id')->nullable()->index();
$table->unsignedBigInteger('withdraw_id')->nullable()->index();
$table->decimal('amount', 18, 4)->nullable();
$table->string('desc')->nullable();
$table->string('type', 32)->nullable();
$table->timestamp('date')->nullable();
$table->string('zarin_id')->nullable()->index();
$table->string('sh_factor')->nullable();
$table->string('factor_number')->nullable();
$table->longText('data')->nullable();
$table->longText('res')->nullable();
$table->string('sync_status', 20)->default('pending');
$table->text('sync_log')->nullable();
$table->timestamps();
});
}
if (Schema::hasTable('products') && ! Schema::hasColumn('products', 'finance_p_name')) {
Schema::table('products', function (Blueprint $table) {
$table->string('finance_p_name')->nullable()->after('group_type');
});
}
}
public function down(): void
{
Schema::dropIfExists('zarin');
if (Schema::hasTable('products') && Schema::hasColumn('products', 'finance_p_name')) {
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('finance_p_name');
});
}
}
};
@@ -0,0 +1,92 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* کلیدهای اتصال زرین — فقط از settings، can_edit=0 (مثل ته‌حساب/پرگار).
* value ردیف موجود را تغییر نمی‌دهد.
*/
return new class extends Migration
{
private const KEYS = [
'zarin_api' => [
'value' => '',
'title_fa' => 'آدرس API زرین',
'description' => 'آدرس پایه وب‌سرویس زرین (بدون /ZarrinService/accounting).',
'type' => 'text',
],
'zarin_token' => [
'value' => '',
'title_fa' => 'توکن زرین',
'description' => 'توکن مکمل API زرین که در نرم‌افزار زرین تعریف می‌شود.',
'type' => 'text',
],
'zarin_noe_kar' => [
'value' => '16',
'title_fa' => 'نوع کار پیش‌فرض زرین',
'description' => 'کد noeKar هنگام ساخت کار ساخته در زرین.',
'type' => 'number',
],
'zarin_gorohe_kar' => [
'value' => '52',
'title_fa' => 'گروه کار پیش‌فرض زرین',
'description' => 'کد gorooheKar هنگام ساخت/جستجوی کار در زرین. برای جداسازی چند پنل روی یک زرین، برای هر پنل مقدار متفاوت بگذارید.',
'type' => 'number',
],
'zarin_name_g' => [
'value' => '',
'title_fa' => 'نام گروه حساب مشتریان زرین',
'description' => 'پارامتر nameG در addhesab. اگر چند پنل یک توکن زرین دارند، برای هر پنل نام گروه متفاوت بگذارید. خالی = نام برند (name_fa).',
'type' => 'text',
],
'zarin_uid_prefix' => [
'value' => '',
'title_fa' => 'پیشوند عددی uid زرین',
'description' => 'فقط عدد. وقتی چند پنل یک زرین دارند باید متفاوت باشد تا uid تکراری نشود. مثال: 11 برای این پنل، 12 برای پنل دیگر.',
'type' => 'text',
],
];
public function up(): void
{
foreach (self::KEYS as $key => $meta) {
$exists = DB::table('settings')->where('key', $key)->exists();
if (! $exists) {
DB::table('settings')->insert([
'key' => $key,
'value' => $meta['value'],
'title_fa' => $meta['title_fa'],
'can_edit' => 0,
'is_active' => 1,
'description' => $meta['description'],
'type' => $meta['type'],
]);
continue;
}
// فقط متادیتا — value دست‌نخورده
DB::table('settings')->where('key', $key)->update([
'title_fa' => $meta['title_fa'],
'description' => $meta['description'],
'type' => $meta['type'],
'can_edit' => 0,
'is_active' => 1,
]);
}
if (DB::table('settings')->where('key', 'accounting_provider')->exists()) {
DB::table('settings')->where('key', 'accounting_provider')->update([
'title_fa' => 'سیستم حسابداری',
'type' => 'select',
'can_edit' => 0,
'description' => 'none,pargar,tahesab,zarin',
]);
}
}
public function down(): void
{
// کلیدهای حسابداری حذف نمی‌شوند
}
};