From b1f52eb8a04234d88f20f2e875b04db0a8bc4009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Wed, 8 Dec 2021 14:43:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=92=8C=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=95=86=E5=93=81=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Order.php | 12 ++++ app/Models/OrderProduct.php | 9 +++ .../2021_12_07_143655_create_orders_table.php | 56 +++++++++++++++++++ ..._07_143722_create_order_products_table.php | 50 +++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 app/Models/Order.php create mode 100644 app/Models/OrderProduct.php create mode 100644 database/migrations/2021_12_07_143655_create_orders_table.php create mode 100644 database/migrations/2021_12_07_143722_create_order_products_table.php diff --git a/app/Models/Order.php b/app/Models/Order.php new file mode 100644 index 00000000..cfa16691 --- /dev/null +++ b/app/Models/Order.php @@ -0,0 +1,12 @@ +id(); + $table->unsignedBigInteger('user_id')->comment('用户ID'); + $table->string('sn')->comment('订单编号'); + $table->unsignedBigInteger('user_coupon_id')->nullable()->comment('用户优惠券 ID'); + $table->unsignedBigInteger('discount_amount')->default(0)->comment('商品优惠'); + $table->unsignedBigInteger('vip_amount')->default(0)->comment('会员优惠'); + $table->unsignedBigInteger('reduced_amount')->default(0)->comment('减免金额'); + $table->unsignedBigInteger('shipping_fee')->default(0)->comment('运费'); + $table->unsignedBigInteger('products_total_amount')->comment('商品总额'); + $table->unsignedBigInteger('total_amount')->comment('订单总额(支付金额)=商品总额+运费-会员优惠-商品优惠-减免金额'); + $table->unsignedInteger('weight')->nullable()->comment('订单重量'); + $table->string('note')->nullable()->comment('客户备注'); + $table->string('remark')->nullable()->comment('订单备注'); + // 支付信息 + $table->string('pay_sn')->nullable()->comment('支付单号'); + $table->string('pay_way')->nullable()->comment('支付方式'); + $table->timestamp('pay_at')->nullable()->comment('支付时间'); + // 收货信息 + $table->string('consignee_name')->nullable()->comment('收货人姓名'); + $table->string('consignee_telephone')->nullable()->comment('收货人联系方式'); + $table->string('consignee_zone')->nullable()->comment('收货人所在地区'); + $table->string('consignee_address')->nullable()->comment('收货人详细地址'); + $table->tinyInteger('status')->default(0)->comment('订单状态: 0 待付款, 1 已付款, 9 已完成, 10 已取消'); + $table->timestamp('completed_at')->nullable()->comment('订单完成时间'); + $table->timestamps(); + + $table->unique('sn'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('orders'); + } +} 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 new file mode 100644 index 00000000..b8ab40f1 --- /dev/null +++ b/database/migrations/2021_12_07_143722_create_order_products_table.php @@ -0,0 +1,50 @@ +id(); + $table->unsignedBigInteger('user_id')->comment('用户 ID'); + $table->unsignedBigInteger('order_id')->comment('订单 ID'); + $table->unsignedBigInteger('spu_id')->comment('商品 SPU ID'); + $table->unsignedBigInteger('sku_id')->comment('商品 SKU ID'); + $table->unsignedBigInteger('category_id')->comment('商品分类 ID'); + $table->string('name')->comment('商品名称'); + $table->string('subtitle')->nullable()->comment('商品副标题'); + $table->string('cover')->nullable()->comment('商品封面'); + $table->json('specs')->nullable()->comment('规格属性'); + $table->unsignedInteger('quantity')->comment('数量'); + $table->unsignedInteger('weight')->nullable()->comment('重量:g'); + $table->unsignedBigInteger('sell_price')->comment('商品价格'); + $table->unsignedBigInteger('vip_price')->comment('会员价格'); + $table->unsignedBigInteger('discount_amount')->default(0)->comment('商品优惠'); + $table->unsignedBigInteger('vip_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(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('order_products'); + } +}