diff --git a/app/Models/ProductSku.php b/app/Models/ProductSku.php index ed0dc1fb..ee595dce 100644 --- a/app/Models/ProductSku.php +++ b/app/Models/ProductSku.php @@ -20,6 +20,7 @@ class ProductSku extends Model 'cost_price' => Price::class, 'user_price' => Price::class, 'attrs' => JsonArray::class, - 'is_sell' => 'bool', + 'specs' => 'json', + 'online_at' => 'datetime', ]; } diff --git a/app/Models/ProductSpu.php b/app/Models/ProductSpu.php index 5f6f8e0e..36f06a4e 100644 --- a/app/Models/ProductSpu.php +++ b/app/Models/ProductSpu.php @@ -18,6 +18,6 @@ class ProductSpu extends Model 'cost_price' => Price::class, 'user_price' => Price::class, 'attrs' => JsonArray::class, - 'is_sell' => 'bool', + 'online_at' => 'datetime', ]; } diff --git a/database/migrations/2021_11_22_110044_create_product_spus_table.php b/database/migrations/2021_11_22_110044_create_product_spus_table.php index c9b07dfb..de8ce9ab 100644 --- a/database/migrations/2021_11_22_110044_create_product_spus_table.php +++ b/database/migrations/2021_11_22_110044_create_product_spus_table.php @@ -28,10 +28,13 @@ class CreateProductSpusTable extends Migration $table->string('media')->nullable()->comment('媒体地址'); $table->integer('weight')->unsigned()->nullable()->comment('重量:g'); $table->json('attrs')->nullable()->comment('属性文本'); - $table->tinyInteger('is_sell')->unsigned()->default(0)->comment('在售状态'); + $table->integer('stock')->unsigned()->default(0)->comment('库存'); + $table->integer('sales')->unsigned()->default(0)->comment('销量'); + $table->timestamp('online_at')->nullable()->comment('上线时间'); $table->timestamps(); $table->index('category_id'); + $table->index('online_at'); }); } diff --git a/database/migrations/2021_11_24_120232_create_product_skus_table.php b/database/migrations/2021_11_24_120232_create_product_skus_table.php index 992b4acd..586c4b63 100644 --- a/database/migrations/2021_11_24_120232_create_product_skus_table.php +++ b/database/migrations/2021_11_24_120232_create_product_skus_table.php @@ -29,14 +29,15 @@ class CreateProductSkusTable extends Migration $table->string('media')->nullable()->comment('媒体地址'); $table->integer('weight')->unsigned()->nullable()->comment('重量:g'); $table->json('attrs')->nullable()->comment('属性文本'); - $table->tinyInteger('is_sell')->unsigned()->default(0)->comment('在售状态'); - $table->json('spec_items')->nullable()->comment('规格属性'); + $table->json('specs')->nullable()->comment('规格属性'); $table->integer('stock')->unsigned()->default(0)->comment('库存'); - $table->integer('sells')->unsigned()->default(0)->comment('销量'); + $table->integer('sales')->unsigned()->default(0)->comment('销量'); + $table->timestamp('online_at')->nullable()->comment('上线时间'); $table->timestamps(); $table->index('spu_id'); $table->index('category_id'); + $table->index('online_at'); }); }