82 lines
3.9 KiB
PHP
82 lines
3.9 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
// 任务分类
|
|
if (! Schema::hasTable('task_categories')) {
|
|
Schema::create('task_categories', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name', 50)->comment('分类名称');
|
|
$table->string('slug', 50)->comment('标识');
|
|
$table->string('description', 255)->default('')->comment('描述');
|
|
$table->string('icon', 255)->default('')->comment('图标');
|
|
$table->integer('sort')->default(0)->comment('排序');
|
|
$table->tinyInteger('status')->default(1)->comment('状态:0=禁用,1=正常');
|
|
$table->timestamps();
|
|
$table->unique('slug');
|
|
$table->comment('任务分类');
|
|
});
|
|
}
|
|
|
|
// 任务订单(跑腿/代取/租借)
|
|
if (! Schema::hasTable('task_orders')) {
|
|
Schema::create('task_orders', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('order_no', 32)->comment('订单编号');
|
|
$table->unsignedInteger('user_id')->comment('发布用户ID');
|
|
$table->unsignedInteger('runner_id')->nullable()->comment('接单用户ID');
|
|
$table->unsignedBigInteger('category_id')->comment('分类ID');
|
|
$table->string('title', 100)->comment('任务标题');
|
|
$table->text('description')->comment('任务描述');
|
|
$table->json('images')->nullable()->comment('图片列表');
|
|
$table->decimal('price', 10, 2)->default(0)->comment('任务价格/报酬');
|
|
$table->string('address', 255)->default('')->comment('任务地址');
|
|
$table->string('contact_name', 30)->default('')->comment('联系人');
|
|
$table->string('contact_mobile', 20)->default('')->comment('联系电话');
|
|
$table->timestamp('deadline')->nullable()->comment('截止时间');
|
|
$table->tinyInteger('status')->default(0)->comment('状态:0=待接单,1=已接单,2=进行中,3=已完成,4=已取消');
|
|
$table->timestamp('accepted_at')->nullable()->comment('接单时间');
|
|
$table->timestamp('completed_at')->nullable()->comment('完成时间');
|
|
$table->timestamp('cancelled_at')->nullable()->comment('取消时间');
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
$table->unique('order_no');
|
|
$table->index('user_id');
|
|
$table->index('runner_id');
|
|
$table->index('category_id');
|
|
$table->index('status');
|
|
$table->comment('校园任务订单');
|
|
});
|
|
}
|
|
|
|
// 任务竞价/接单报价
|
|
if (! Schema::hasTable('task_bids')) {
|
|
Schema::create('task_bids', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->unsignedBigInteger('task_id')->comment('任务ID');
|
|
$table->unsignedInteger('user_id')->comment('接单人ID');
|
|
$table->decimal('price', 10, 2)->default(0)->comment('报价');
|
|
$table->string('message', 500)->default('')->comment('留言');
|
|
$table->tinyInteger('status')->default(0)->comment('状态:0=待确认,1=已接受,2=已拒绝');
|
|
$table->timestamps();
|
|
$table->index('task_id');
|
|
$table->index('user_id');
|
|
$table->comment('任务竞价');
|
|
});
|
|
}
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('task_bids');
|
|
Schema::dropIfExists('task_orders');
|
|
Schema::dropIfExists('task_categories');
|
|
}
|
|
};
|