<?php

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

class CreateWaybillsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('waybills', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->timestamps();
            $table->enum('status',['未审核','已审核','待重审','待终审','已完结','无模型'])->default('未审核')->index()->comment('状态');
            $table->enum('type',['直发车','专线'])->comment('类型');
            $table->string('waybill_number',50)->unique()->index()->comment('运单号');
            $table->bigInteger('owner_id')->index()->comment('货主');
            $table->string('wms_bill_number',50)->unique()->nullable()->comment('WMS单号');
            $table->string('origination',50)->comment('始发地');
            $table->string('destination',50)->comment('目的地');
            $table->string('recipient',50)->comment('收件人');
            $table->string('recipient_mobile',50)->comment('收件人电话');
            $table->decimal('charge')->comment('收费(元)')->nullable();
            $table->decimal('collect_fee')->nullable()->comment('到付金额');
            $table->text('ordering_remark')->nullable()->comment('下单备注');
            $table->bigInteger('carrier_id')->nullable()->index()->comment('承运商');
            $table->string('carrier_bill')->nullable()->unique()->comment('承运商单号');
            $table->bigInteger('origination_city_id')->nullable()->index()->comment('始发市');
            $table->bigInteger('destination_city_id')->nullable()->index()->comment('目的市');
            $table->decimal('warehouse_weight')->nullable()->comment('仓库计重(抛)');
            $table->bigInteger('warehouse_weight_unit_id')->nullable()->index()->comment('仓库计重单位');
            $table->decimal('carrier_weight')->nullable()->comment('承运商计重(抛)');
            $table->bigInteger('carrier_weight_unit_id')->nullable()->index()->comment('承运商计重单位');
            $table->bigInteger('carType_id')->nullable()->comment('车型');
            $table->decimal('fee')->nullable()->comment('运费');
            $table->decimal('pick_up_fee')->nullable()->comment('提货费');
            $table->decimal('other_fee')->nullable()->comment('其他费用');
            $table->text('dispatch_remark')->nullable()->comment('调度备注');
            $table->bigInteger('waybill_price_model_id')->nullable()->index()->comment('外联计费模型');
        });
    }

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