feat: shayegan inbound charges workflow and copper kilogram unit enforcement
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?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('shayegan_inbound_charges')) {
|
||||
Schema::create('shayegan_inbound_charges', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('customer_id')->nullable()->index();
|
||||
$table->string('customer_tafsil', 64)->nullable()->index();
|
||||
$table->string('shayegan_number', 64)->nullable()->index();
|
||||
$table->decimal('amount', 18, 4);
|
||||
$table->text('description')->nullable();
|
||||
$table->string('source', 32)->default('webhook')->index();
|
||||
$table->string('status', 20)->default('pending')->index(); // pending, approved, rejected
|
||||
$table->longText('raw_data')->nullable();
|
||||
$table->unsignedBigInteger('approved_by')->nullable()->index();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->unsignedBigInteger('rejected_by')->nullable()->index();
|
||||
$table->timestamp('rejected_at')->nullable();
|
||||
$table->string('reject_reason', 255)->nullable();
|
||||
$table->unsignedBigInteger('withdraw_id')->nullable()->index();
|
||||
$table->unsignedBigInteger('transaction_id')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shayegan_inbound_charges');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('settings')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$exists = DB::table('settings')->where('key', 'shayegan_webhook_secret')->exists();
|
||||
if (! $exists) {
|
||||
$hasMenu = Schema::hasColumn('settings', 'menu');
|
||||
$row = [
|
||||
'key' => 'shayegan_webhook_secret',
|
||||
'value' => 'shayegan_sec_' . bin2hex(random_bytes(12)),
|
||||
'title_fa' => 'کلید امنیتی وبهوک شایگان (X-Shayegan-Key)',
|
||||
'description' => 'کلید محرمانه جهت احراز هویت درخواستهای وبهوک شارژ از شایگان به بورس مس.',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'type' => 'password',
|
||||
];
|
||||
if ($hasMenu) {
|
||||
$row['menu'] = 'accounting_shayegan';
|
||||
}
|
||||
DB::table('settings')->insert($row);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('settings')) {
|
||||
DB::table('settings')->where('key', 'shayegan_webhook_secret')->delete();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('settings')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$row = DB::table('settings')->where('key', 'unit')->first();
|
||||
if ($row) {
|
||||
$val = trim((string) ($row->value ?? ''));
|
||||
if ($val === '' || $val === 'گرم') {
|
||||
DB::table('settings')->where('key', 'unit')->update([
|
||||
'value' => 'کیلوگرم',
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
DB::table('settings')->insert([
|
||||
'key' => 'unit',
|
||||
'value' => 'کیلوگرم',
|
||||
'title_fa' => 'واحد وزن معاملات',
|
||||
'description' => 'واحد اصلی وزن در بورس مس (کیلوگرم).',
|
||||
'can_edit' => 0,
|
||||
'is_active' => 1,
|
||||
'type' => 'text',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user