2023_05_08_111932_create_commissions_table.php 1.4 KB
<?php

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

class CreateCommissionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_commissions', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedBigInteger('user_id')->index()->comment('用户ID');
            $table->unsignedBigInteger('invite_user_id')->index()->comment('邀请用户ID');
            $table->decimal('amount', 11)->nullable()->default(0.00)->comment('订单总额');
            $table->decimal('income', 11)->nullable()->default(0.00)->comment('收益');
            $table->tinyInteger('level')->nullable()->default(100)->comment('分佣等级');
            $table->tinyInteger('ratio')->nullable()->default(100)->comment('分佣比例');
            $table->tinyInteger('status')->nullable()->default(1)->comment('状态:1-有效;0-无效');
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `user_commissions` comment '用户-分佣记录' ");
    }

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