added pargar
This commit is contained in:
@@ -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 فقط مقدار را برنمیگرداند
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user