131 lines
4.7 KiB
PHP
131 lines
4.7 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
if (! Schema::hasTable('digipay_credits')) {
|
|
Schema::create('digipay_credits', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('customer_id')->unique();
|
|
$table->string('status', 20)->default('pending');
|
|
$table->unsignedBigInteger('plan4_remaining_rial')->default(0);
|
|
$table->unsignedBigInteger('plan12_remaining_rial')->default(0);
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
if (! Schema::hasTable('digipay_orders')) {
|
|
Schema::create('digipay_orders', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('customer_id')->index();
|
|
$table->unsignedTinyInteger('plan');
|
|
$table->unsignedBigInteger('amount_rial');
|
|
$table->unsignedBigInteger('fee_rial');
|
|
$table->decimal('grams', 16, 4);
|
|
$table->unsignedBigInteger('gram_price_rial');
|
|
$table->string('status', 20)->default('done');
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
if (! Schema::hasTable('settings')) {
|
|
return;
|
|
}
|
|
|
|
$rows = [
|
|
[
|
|
'key' => 'enable_digipay_installment',
|
|
'value' => 'false',
|
|
'title_fa' => 'خرید اقساطی مس',
|
|
'description' => 'روشن: منوی خرید اقساطی در اپ و صفحه اعتبار دیجیپی در ادمین.',
|
|
'type' => 'switch',
|
|
'show' => 1,
|
|
],
|
|
[
|
|
'key' => 'digipay_onboarding_url',
|
|
'value' => '',
|
|
'title_fa' => 'لینک احراز دیجیپی',
|
|
'description' => 'لینکی که دیجیپی بعد از قرارداد میدهد. کاربر برای احراز هویت به همین آدرس میرود.',
|
|
'type' => 'text',
|
|
'show' => 0,
|
|
],
|
|
[
|
|
'key' => 'digipay_fee_shop_percent',
|
|
'value' => '8',
|
|
'title_fa' => 'کارمزد خرید اقساطی (درصد)',
|
|
'description' => '',
|
|
'type' => 'number',
|
|
'show' => 1,
|
|
],
|
|
[
|
|
'key' => 'digipay_fee_gateway_percent',
|
|
'value' => '5.7',
|
|
'title_fa' => 'کارمزد دیجیپی (درصد)',
|
|
'description' => '',
|
|
'type' => 'number',
|
|
'show' => 1,
|
|
],
|
|
[
|
|
'key' => 'digipay_fee_extra_percent',
|
|
'value' => '2.3',
|
|
'title_fa' => 'کارمزد جانبی اقساط (درصد)',
|
|
'description' => '',
|
|
'type' => 'number',
|
|
'show' => 1,
|
|
],
|
|
[
|
|
'key' => 'digipay_plan4_cap_toman',
|
|
'value' => '30000000',
|
|
'title_fa' => 'سقف اعتبار ۴ قسط (تومان)',
|
|
'description' => '',
|
|
'type' => 'number',
|
|
'show' => 1,
|
|
],
|
|
[
|
|
'key' => 'digipay_plan12_cap_toman',
|
|
'value' => '200000000',
|
|
'title_fa' => 'سقف وام ۱۲ قسط (تومان)',
|
|
'description' => '',
|
|
'type' => 'number',
|
|
'show' => 1,
|
|
],
|
|
];
|
|
|
|
$hasType = Schema::hasColumn('settings', 'type');
|
|
$hasShow = Schema::hasColumn('settings', 'show_to_user');
|
|
|
|
foreach ($rows as $row) {
|
|
if (DB::table('settings')->where('key', $row['key'])->exists()) {
|
|
continue;
|
|
}
|
|
$insert = [
|
|
'key' => $row['key'],
|
|
'value' => $row['value'],
|
|
'title_fa' => $row['title_fa'],
|
|
'description' => $row['description'],
|
|
'can_edit' => 1,
|
|
'is_active' => 1,
|
|
];
|
|
if ($hasType) {
|
|
$insert['type'] = $row['type'];
|
|
}
|
|
if ($hasShow) {
|
|
$insert['show_to_user'] = $row['show'];
|
|
}
|
|
DB::table('settings')->insert($insert);
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('digipay_orders');
|
|
Schema::dropIfExists('digipay_credits');
|
|
}
|
|
};
|