This commit is contained in:
2026-07-02 00:29:48 +03:30
parent ffab326aa0
commit 24edbf3ff3
4 changed files with 148 additions and 18 deletions
@@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
private const KEY = 'fee_deduct_from_gold';
private const TITLE_FA = 'اعمال مبلغ دقیق در معامله مشتری';
private const DESCRIPTION = 'روشن: مشتری دقیقاً همان مبلغ یا وزنی را که وارد کرده دریافت می‌کند. در فروش، مثلاً ۱۰۰ میلیون ریال درخواست → همان ۱۰۰ میلیون واریز و کارمزد از طلای کیف کسر می‌شود. در خرید، مثلاً ۱۰ گرم درخواست → همان ۱۰ گرم واریز و کارمزد به ریال قابل پرداخت اضافه می‌شود. خاموش (پیش‌فرض): در فروش کارمزد از مبلغ ریالی واریزی کم می‌شود (مشتری مبلغ کمتری می‌گیرد). در خرید کارمزد از وزن طلای واریزی کم می‌شود (مشتری طلای کمتری می‌گیرد).';
public function up(): void
{
if (!Schema::hasTable('settings')) {
return;
}
$payload = [
'title_fa' => self::TITLE_FA,
'description' => self::DESCRIPTION,
'can_edit' => 1,
'updated_at' => now(),
];
if (Schema::hasColumn('settings', 'type')) {
$payload['type'] = 'switch';
}
$exists = DB::table('settings')->where('key', self::KEY)->exists();
if ($exists) {
DB::table('settings')->where('key', self::KEY)->update($payload);
return;
}
$insert = array_merge($payload, [
'key' => self::KEY,
'value' => 'false',
'is_active' => 1,
'created_at' => now(),
]);
if (Schema::hasColumn('settings', 'is_exist')) {
$insert['is_exist'] = 0;
}
DB::table('settings')->insert($insert);
}
public function down(): void
{
// متادیتا را عمداً برنمی‌گردانیم — value مشتری حفظ شود.
}
};