订单和订单商品表
parent
a06072408b
commit
b1f52eb8a0
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Order extends Model
|
||||
{
|
||||
public const STATUS_PENDING = 0; // 待付款
|
||||
public const STATUS_COMPLETED = 9; // 已完成
|
||||
public const STATUS_CANCELLED = 10; // 已取消
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class OrderProduct extends Model
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateOrdersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('orders', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateOrderProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('order_products', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue