<?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('order', function (Blueprint $table) {
            $table->comment('订单');
            $table->increments('id');
            $table->unsignedBigInteger('user_id')->comment('用户编号');
            $table->unsignedBigInteger('coach_id')->comment('技师编号');
            $table->unsignedBigInteger('service_id')->comment('项目编号');
            $table->unsignedBigInteger('channel_id')->nullable()->comment('渠道编号');
            $table->unsignedBigInteger('shop_id')->nullable()->comment('店铺编号');
            $table->unsignedBigInteger('customer_service_id')->nullable()->comment('跟单客服编号');
            $table->string('order_type')->default('')->comment('订单类型');
            $table->string('order_source')->default('PLATFORM')->comment('订单来源');
            $table->decimal('total_amount')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('订单金额');
            $table->decimal('service_amount')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('项目金额');
            $table->decimal('traffic_amount')->default(new \Illuminate\Database\Query\Expression('0.00'))->comment('路程金额');
            $table->json('service_snapshot')->nullable()->comment('项目快照');
            $table->timestamp('service_time')->comment('服务时间');
            $table->integer('distance')->default(new \Illuminate\Database\Query\Expression('0'))->nullable()->comment('目的地距离(米)');
            $table->decimal('latitude')->comment('目的地纬度');
            $table->decimal('longitude')->comment('目的地经度');
            $table->string('location')->default('')->comment('目的地定位地址');
            $table->string('address')->nullable()->comment('目的地详细地址');
            $table->string('area_code')->default('')->comment('目的地行政区划代码');
            $table->string('remark')->nullable()->comment('订单备注');
            $table->string('state')->default('CREATED')->comment('订单状态');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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