<?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_split_records', function (Blueprint $table) {
            $table->comment('钱包分账记录');
            $table->increments('id');
            $table->unsignedBigInteger('order_id')->comment('订单编号');
            $table->unsignedBigInteger('rule_id')->comment('分账规则配置编号');
            $table->string('split_type')->default('')->comment('分账类型(服务佣金、平台分成、邀请奖励、团队邀请奖励、推荐奖励)');
            $table->decimal('amount')->comment('参与分账金额');
            $table->decimal('split_ratio')->comment('分账比例');
            $table->decimal('split_amount')->comment('分账金额');
            $table->timestamp('entry_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_split_records');
    }
};
