id(); $table->string('name')->comment('分类名称'); $table->string('image')->nullable()->comment('封面图'); $table->string('description')->nullable()->comment('描述'); $table->unsignedBigInteger('parent_id')->default(0)->comment('父级ID'); $table->unsignedInteger('level')->default(1)->comment('层级'); $table->unsignedInteger('sort')->default(1)->comment('排序 asc'); $table->unsignedTinyInteger('is_enable')->default(1)->comment('状态'); $table->string('path')->default('-')->comment('所有的父级ID'); $table->comment('商品-分类'); }); Schema::create('goods_type', function (Blueprint $table) { $table->id(); $table->string('name'); $table->json('attr')->nullable()->comment('属性[{name: "属性名", values: [可选值]}]'); $table->json('spec')->nullable()->comment('规格[{name: "属性名", values: [可选值]}]'); $table->json('part')->nullable()->comment('配件[{name: "属性名", values: [可选值]}]'); $table->comment('商品-类型'); }); Schema::create('goods_brand', function (Blueprint $table) { $table->id(); $table->string('name')->comment('名称'); $table->string('image')->nullable()->comment('图标'); $table->comment('商品-品牌'); }); Schema::create('goods', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('category_id')->comment('所属分类, 关联 goods_category.id'); $table->unsignedBigInteger('merchant_id')->nullable()->comment('商户ID'); $table->unsignedBigInteger('type_id')->nullable()->comment('所属类别'); $table->unsignedBigInteger('brand_id')->nullable()->comment('所属品牌'); $table->string('name')->comment('商品名称'); $table->string('goods_sn')->comment('编号'); $table->string('cover_image')->nullable()->comment('封面图'); $table->json('images')->nullable()->comment('图片集'); $table->string('description')->nullable()->comment('描述'); $table->json('content')->nullable()->comment('详细'); $table->unsignedInteger('on_sale')->default(0)->comment('是否上架'); $table->unsignedInteger('is_recommend')->default(0)->comment('是否推荐'); $table->unsignedInteger('stock')->default(0)->comment('库存'); $table->unsignedInteger('sold_count')->default(0)->comment('销量'); $table->decimal('price', 12, 2)->comment('售价'); $table->decimal('vip_price', 12, 2)->comment('会员价'); $table->decimal('score_max_amount', 12, 2)->default(0)->comment('积分抵扣最大值'); $table->json('attr')->nullable()->comment('属性[{name, values: [{name, value}]}]'); $table->json('spec')->nullable()->comment('规格[{name, values: [{name, value}]}]'); $table->json('part')->nullable()->comment('配件[{name, values: [{name, value}]}]'); $table->unsignedInteger('check_status')->default(0)->comment('审核状态(0: 未提交, 1: 审核中, 2: 审核通过, 3: 审核不通过)'); $table->string('check_remarks')->nullable()->comment('审核备注'); $table->timestamp('check_at')->nullable()->comment('审核通过时间'); $table->unsignedBigInteger('check_user_id')->nullable()->comment('审核人'); $table->timestamps(); $table->comment('商品'); }); Schema::create('goods_checks', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('goods_id')->comment('所属商品, 关联 goods.id'); $table->unsignedBigInteger('category_id')->comment('所属分类, 关联 goods_category.id'); $table->unsignedBigInteger('merchant_id')->nullable()->comment('商户ID'); $table->unsignedBigInteger('type_id')->nullable()->comment('所属类别'); $table->unsignedBigInteger('brand_id')->nullable()->comment('所属品牌'); $table->string('name')->comment('商品名称'); $table->string('goods_sn')->comment('编号'); $table->string('cover_image')->nullable()->comment('封面图'); $table->json('images')->nullable()->comment('图片集'); $table->string('description')->nullable()->comment('描述'); $table->json('content')->nullable()->comment('详细'); $table->unsignedInteger('on_sale')->default(0)->comment('是否上架'); $table->unsignedInteger('stock')->default(0)->comment('库存'); $table->unsignedInteger('sold_count')->default(0)->comment('销量'); $table->decimal('price', 12, 2)->comment('售价'); $table->decimal('vip_price', 12, 2)->comment('会员价'); $table->decimal('score_max_amount', 12, 2)->default(0)->comment('积分抵扣最大值'); $table->json('attr')->nullable()->comment('属性[{name, values: [{name, value}]}]'); $table->json('spec')->nullable()->comment('规格[{name, values: [{name, value}]}]'); $table->json('part')->nullable()->comment('配件[{name, values: [{name, value}]}]'); $table->unsignedInteger('check_status')->default(0)->comment('审核状态(0: 未提交, 1: 审核中, 2: 审核通过, 3: 审核不通过)'); $table->string('check_remarks')->nullable()->comment('审核备注'); $table->timestamp('check_at')->nullable()->comment('审核通过时间'); $table->unsignedBigInteger('check_user_id')->nullable()->comment('审核人'); $table->timestamps(); $table->comment('商品-上架审核'); }); Schema::create('goods_sku', function (Blueprint $table) { $table->id(); $table->string('sn')->comment('货号'); $table->unsignedBigInteger('goods_id')->comment('所属商品, 关联 goods.id'); $table->string('name')->comment('名称'); $table->decimal('price', 12, 2)->comment('价格'); $table->decimal('vip_price', 12, 2)->comment('会员价'); $table->decimal('score_max_amount', 12, 2)->default(0)->comment('积分抵扣最大值'); $table->unsignedInteger('stock')->comment('库存'); $table->unsignedInteger('sold_count')->default(0)->comment('销量'); $table->json('spec')->nullable()->comment('规格[{name, value, price}]'); $table->comment('商品-SKU'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('goods_sku'); Schema::dropIfExists('goods_checks'); Schema::dropIfExists('goods'); Schema::dropIfExists('goods_category'); Schema::dropIfExists('goods_type'); Schema::dropIfExists('goods_brand'); } }