<?php

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

class CreateServiceOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('service_order', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id')->comment('用户ID');
            $table->string('order_sn')->default('')->comment('订单编号');
            $table->tinyInteger('pay_type')->comment('支付类型');
            $table->string('transaction_id')->default('')->comment('商户订单号');
            $table->bigInteger('project_id')->comment('项目ID');
            $table->bigInteger('area_id')->comment('区域ID');
            $table->string('project_name')->default('')->comment('项目名称');
            $table->string('project_icon')->default('')->comment('项目图标');
            $table->integer('pay_price')->default('0')->nullable()->comment('支付金额');
            $table->integer('balance_price')->default('0')->nullable()->comment('余额金额');
            $table->integer('discount_price')->default('0')->nullable()->comment('折扣金额');
            $table->integer('coupon_price')->default('0')->nullable()->comment('优惠金额');
            $table->integer('car_price')->default('0')->nullable()->comment('车费金额');
            $table->integer('material_price')->default('0')->nullable()->comment('物料金额');
            $table->integer('service_price')->default('0')->nullable()->comment('服务金额');
            $table->bigInteger('coach_id')->nullable()->comment('技师ID');
            $table->timestamp('start_time')->nullable()->comment('开始时间');
            $table->timestamp('end_time')->nullable()->comment('结束时间');
            $table->integer('time_long')->nullable()->comment('服务时长');
            $table->integer('true_time_long')->nullable()->comment('真实服务时长');
            $table->integer('payment_time')->nullable()->comment('入账时间');
            $table->text('remark')->nullable()->comment('备注');
            $table->timestamp('pay_time')->nullable()->comment('支付时间');
            $table->timestamp('receiving_time')->nullable()->comment('接单时间');
            $table->timestamp('depart_time')->nullable()->comment('出发时间');
            $table->timestamp('arrive_time')->nullable()->comment('到达时间');
            $table->timestamp('over_time')->nullable()->comment('撤离时间');
            $table->timestamp('refund_time')->nullable()->comment('退款时间');
            $table->text('refund_text')->nullable()->comment('退款原因');
            $table->decimal('distance')->nullable()->comment('相隔距离');
            $table->tinyInteger('is_show')->default('1')->comment('展示订单');
            $table->string('depart_lng')->nullable()->comment('出发经度');
            $table->string('depart_lat')->nullable()->comment('出发纬度');
            $table->string('depart_address')->nullable()->comment('出发地址');
            $table->string('arrive_img')->nullable()->comment('到达图片');
            $table->integer('arrive_lng')->nullable()->comment('到达经度');
            $table->integer('arrive_lat')->nullable()->comment('到达纬度');
            $table->string('arrive_address')->nullable()->comment('到达地址');
            $table->string('address')->nullable()->comment('目的地地址');
            $table->string('real_address')->nullable()->comment('目的地真实地址');
            $table->integer('address_lng')->nullable()->comment('目的地经度');
            $table->integer('address_lat')->nullable()->comment('目的地纬度');
            $table->string('over_img')->nullable()->comment('撤离图片');
            $table->integer('over_lng')->nullable()->comment('撤离经度');
            $table->integer('over_lat')->nullable()->comment('撤离纬度');
            $table->string('over_address')->nullable()->comment('撤离地址');
            $table->integer('agent_commission_ratio')->nullable()->comment('代理佣金比例');
            $table->decimal('agent_commission_price')->nullable()->comment('代理佣金金额');
            $table->integer('coach_commission_ratio')->nullable()->comment('技师佣金比例');
            $table->decimal('coach_commission_price')->nullable()->comment('技师佣金金额');
            $table->decimal('company_price')->nullable()->comment('平台金额');
            $table->decimal('retail_price')->nullable()->comment('分销金额');
            $table->bigInteger('coupon_id')->nullable()->comment('优惠卷ID');
            $table->bigInteger('channel_id')->nullable()->comment('渠道ID');
            $table->bigInteger('channel_cate_id')->nullable()->comment('渠道ID');
            $table->tinyInteger('extend_order')->default('0')->comment('加钟订单');
            $table->tinyInteger('extend_order_id')->default('0')->comment('加钟订单ID');
            $table->bigInteger('store_id')->nullable()->comment('店铺ID');
            $table->tinyInteger('type')->default('0')->comment('订单类型');
            $table->tinyInteger('status')->default('0')->comment('订单状态 0:未支付 1:已支付(待接单) 2:已接单 3:已出发 4:已到达 5:开始服务(服务中) 6:服务结束 7:已撤离 8:已评价 9:取消订单(退款中) 10:已退款');
            $table->tinyInteger('user_del')->default('0')->comment('用户删除');
            $table->tinyInteger('user_end')->default('0')->comment('用户结束订单');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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