<?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_trans_records', function (Blueprint $table) {
            $table->comment('钱包交易记录');
            $table->increments('id');
            $table->unsignedBigInteger('wallet_id')->comment('钱包编号');
            $table->unsignedBigInteger('owner_id')->comment('业务类型编号');
            $table->string('owner_type')->default('')->comment('业务类型(profit:分账 recharge:充值 withdraw:提现 refund:退款 payment:支付 gift:赠送 breach:违约 compensation:补偿)');
            $table->string('trans_type')->default('')->comment('交易类型(income:收入 expense:支出)');
            $table->string('storage_type')->default('')->comment('存储类型(balance:余额 recharge:充值)');
            $table->decimal('amount')->comment('交易金额');
            $table->decimal('before_balance')->comment('交易前余额');
            $table->decimal('after_balance')->comment('交易后余额');
            $table->decimal('before_recharge_balance')->comment('交易前充值余额');
            $table->decimal('after_recharge_balance')->comment('交易后充值余额');
            $table->dateTime('trans_time')->comment('交易时间');
            $table->string('remark')->nullable()->comment('备注');
            $table->string('state')->default('')->comment('交易状态(processing:进行中 success:成功 fail:失败 cancel:取消)');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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