From f88a9b0e5b34d435541b6e6464de9b10c123ca1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Sat, 11 Dec 2021 14:26:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95=E5=92=8C?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=95=86=E5=93=81=E8=A1=A8=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Order.php | 34 +++++++++++++++++++ app/Models/OrderProduct.php | 21 ++++++++++++ .../2021_12_07_143655_create_orders_table.php | 4 +-- ..._07_143722_create_order_products_table.php | 8 ++--- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/app/Models/Order.php b/app/Models/Order.php index cfa16691..ca6ed475 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -9,4 +9,38 @@ class Order extends Model public const STATUS_PENDING = 0; // 待付款 public const STATUS_COMPLETED = 9; // 已完成 public const STATUS_CANCELLED = 10; // 已取消 + + /** + * @var array + */ + protected $fillable = [ + 'user_id', + 'sn', + 'coupon_disount_amount', + 'vip_disount_amount', + 'reduced_amount', + 'shipping_fee', + 'products_total_amount', + 'total_amount', + 'weight', + 'note', + 'remark', + 'pay_sn', + 'pay_way', + 'pay_at', + 'consignee_name', + 'consignee_telephone', + 'consignee_zone', + 'consignee_address', + 'status', + 'completed_at', + ]; + + /** + * 属于此订单的商品 + */ + public function products() + { + return $this->hasMany(OrderProduct::class); + } } diff --git a/app/Models/OrderProduct.php b/app/Models/OrderProduct.php index b63108cb..bd8848f3 100644 --- a/app/Models/OrderProduct.php +++ b/app/Models/OrderProduct.php @@ -6,4 +6,25 @@ use Illuminate\Database\Eloquent\Model; class OrderProduct extends Model { + /** + * @var array + */ + protected $fillable = [ + 'user_id', + 'order_id', + 'spu_id', + 'sku_id', + 'category_id', + 'name', + 'specs', + 'cover', + 'weight', + 'sell_price', + 'vip_price', + 'quantity', + 'coupon_discount_amount', + 'vip_discount_amount', + 'reduced_amount', + 'total_amount', + ]; } 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 648c848c..56f46d00 100644 --- a/database/migrations/2021_12_07_143655_create_orders_table.php +++ b/database/migrations/2021_12_07_143655_create_orders_table.php @@ -17,8 +17,8 @@ class CreateOrdersTable extends Migration $table->id(); $table->unsignedBigInteger('user_id')->comment('用户ID'); $table->string('sn')->comment('订单编号'); - $table->unsignedBigInteger('coupon_amount')->default(0)->comment('优惠券金额'); - $table->unsignedBigInteger('vip_amount')->default(0)->comment('会员优惠'); + $table->unsignedBigInteger('coupon_disount_amount')->default(0)->comment('优惠券折扣金额'); + $table->unsignedBigInteger('vip_disount_amount')->default(0)->comment('会员折扣金额'); $table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额'); $table->unsignedBigInteger('shipping_fee')->default(0)->comment('运费'); $table->unsignedBigInteger('products_total_amount')->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 7c830510..2778dbe1 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 @@ -27,13 +27,11 @@ class CreateOrderProductsTable extends Migration $table->unsignedInteger('quantity')->comment('数量'); $table->unsignedInteger('weight')->nullable()->comment('重量:g'); $table->unsignedBigInteger('sell_price')->comment('商品价格'); - $table->unsignedBigInteger('vip_price')->comment('会员价格'); - $table->unsignedBigInteger('coupon_amount')->default(0)->comment('优惠券金额'); - $table->unsignedBigInteger('vip_amount')->default(0)->comment('会员优惠'); + $table->unsignedBigInteger('vip_price')->nullable()->comment('会员价格'); + $table->unsignedBigInteger('coupon_disount_amount')->default(0)->comment('优惠券金额'); + $table->unsignedBigInteger('vip_discount_amount')->default(0)->comment('会员优惠'); $table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额'); $table->unsignedBigInteger('total_amount')->comment('商品总额(支付金额)=商品价格*数量-优惠券金额-会员优惠-减免金额'); - $table->boolean('is_comment')->default(false)->comment('是否评论'); - $table->timestamp('after_sale_deadline')->nullable()->comment('售后截止时间'); $table->timestamps(); }); }