修改订单和订单商品表结构
parent
6aa576e8d9
commit
f88a9b0e5b
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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('商品总额');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue