<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('wallet_refund_records', function (Blueprint $table) {
            $table->comment('钱包退款记录');
            $table->increments('id');
            $table->unsignedBigInteger('order_id')->comment('订单编号');
            $table->unsignedBigInteger('wallet_id')->comment('钱包编号');
            $table->unsignedBigInteger('trans_record_id')->nullable()->comment('交易记录编号');
            $table->string('external_no')->nullable()->comment('外部交易单号');
            $table->string('refund_method')->default('')->comment('退款方式');
            $table->decimal('total_refund_amount')->comment('合计退款金额');
            $table->decimal('actual_refund_amount')->comment('实际退款金额');
            $table->decimal('wallet_balance_refund_amount')->comment('钱包余额退款金额');
            $table->decimal('recharge_balance_refund_amount')->comment('充值余额退款金额');
            $table->timestamp('refund_time')->nullable()->comment('退款时间');
            $table->string('remark')->nullable()->comment('备注');
            $table->string('state')->default('pending')->comment('状态');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('wallet_refund_records');
    }
};
