From 99efee83fca47009cec5606e2d9141737d36a1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Sat, 11 Dec 2021 17:36:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E9=87=8D=E9=87=8F=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=BA=200=20g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/ProductSku.php | 9 +++++++++ app/Models/ProductSpu.php | 12 ++++++++++++ .../2021_11_22_110044_create_product_spus_table.php | 2 +- .../2021_11_24_120232_create_product_skus_table.php | 2 +- .../2021_12_07_143655_create_orders_table.php | 2 +- ...2021_12_07_143722_create_order_products_table.php | 2 +- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/app/Models/ProductSku.php b/app/Models/ProductSku.php index 464a4a35..b87be2a1 100644 --- a/app/Models/ProductSku.php +++ b/app/Models/ProductSku.php @@ -17,6 +17,15 @@ class ProductSku extends Model use Release; use SkuInfo; + /** + * @var array + */ + protected $attributes = [ + 'weight' => 0, + 'stock' => 0, + 'sales' => 0, + ]; + /** * @var array */ diff --git a/app/Models/ProductSpu.php b/app/Models/ProductSpu.php index 8d7a47c0..f6a7e4ee 100644 --- a/app/Models/ProductSpu.php +++ b/app/Models/ProductSpu.php @@ -11,6 +11,18 @@ class ProductSpu extends Model { use HasDateTimeFormatter; + /** + * @var array + */ + protected $attributes = [ + 'weight' => 0, + 'stock' => 0, + 'sales' => 0, + ]; + + /** + * @var array + */ protected $casts = [ 'images' => JsonArray::class, 'sell_price' => Price::class, 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 516f30b7..e74e2ed1 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 @@ -26,7 +26,7 @@ class CreateProductSpusTable extends Migration $table->bigInteger('cost_price')->unsigned()->default(0)->comment('成本价格:分'); $table->bigInteger('vip_price')->unsigned()->nullable()->comment('会员价格:分'); $table->string('media')->nullable()->comment('媒体地址'); - $table->integer('weight')->unsigned()->nullable()->comment('重量:g'); + $table->integer('weight')->unsigned()->default(0)->comment('重量:g'); $table->json('attrs')->nullable()->comment('属性文本'); $table->integer('stock')->unsigned()->default(0)->comment('库存'); $table->integer('sales')->unsigned()->default(0)->comment('销量'); 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 30b3d866..bc409788 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 @@ -27,7 +27,7 @@ class CreateProductSkusTable extends Migration $table->bigInteger('cost_price')->unsigned()->default(0)->comment('成本价格:分'); $table->bigInteger('vip_price')->unsigned()->nullable()->comment('会员价格:分'); $table->string('media')->nullable()->comment('媒体地址'); - $table->integer('weight')->unsigned()->nullable()->comment('重量:g'); + $table->integer('weight')->unsigned()->default(0)->comment('重量:g'); $table->json('attrs')->nullable()->comment('属性文本'); $table->json('specs')->nullable()->comment('规格属性'); $table->integer('stock')->unsigned()->default(0)->comment('库存'); diff --git a/database/migrations/2021_12_07_143655_create_orders_table.php b/database/migrations/2021_12_07_143655_create_orders_table.php index 56f46d00..a6ce7a04 100644 --- a/database/migrations/2021_12_07_143655_create_orders_table.php +++ b/database/migrations/2021_12_07_143655_create_orders_table.php @@ -23,7 +23,7 @@ class CreateOrdersTable extends Migration $table->unsignedBigInteger('shipping_fee')->default(0)->comment('运费'); $table->unsignedBigInteger('products_total_amount')->comment('商品总额'); $table->unsignedBigInteger('total_amount')->comment('订单总额(支付金额)=商品总额+运费-优惠券金额-会员优惠-减免金额'); - $table->unsignedInteger('weight')->nullable()->comment('订单重量'); + $table->unsignedInteger('weight')->default(0)->comment('订单重量'); $table->string('note')->nullable()->comment('客户备注'); $table->string('remark')->nullable()->comment('订单备注'); // 支付信息 diff --git a/database/migrations/2021_12_07_143722_create_order_products_table.php b/database/migrations/2021_12_07_143722_create_order_products_table.php index 2778dbe1..6af72901 100644 --- a/database/migrations/2021_12_07_143722_create_order_products_table.php +++ b/database/migrations/2021_12_07_143722_create_order_products_table.php @@ -25,7 +25,7 @@ class CreateOrderProductsTable extends Migration $table->string('cover')->nullable()->comment('商品封面'); $table->json('specs')->nullable()->comment('规格属性'); $table->unsignedInteger('quantity')->comment('数量'); - $table->unsignedInteger('weight')->nullable()->comment('重量:g'); + $table->unsignedInteger('weight')->default(0)->comment('重量:g'); $table->unsignedBigInteger('sell_price')->comment('商品价格'); $table->unsignedBigInteger('vip_price')->nullable()->comment('会员价格'); $table->unsignedBigInteger('coupon_disount_amount')->default(0)->comment('优惠券金额');