【发布时间】:2020-02-06 22:43:35
【问题描述】:
我通过 Laravel 创建了一个简单的电子商务,对 COUPON 数据库设计有一些疑问,我需要如下:
1- 我需要一张普通的优惠券进行结帐(当用户添加他需要的所有产品然后放入优惠券时,这将从总价中打折)。我已经完成了:
Schema::create('coupons', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('code');
$table->enum('type', ['percentage', 'numeric']);
$table->integer('value');
$table->integer('count')->nullable();
$table->date('expired_at');
$table->timestamps();
});
2- 我需要为单个类别的产品打折(为属于 T 恤类别的所有产品打折)。
How the design structure of this point?
3- 我需要为特定产品打折。
How the design structure of this point?
有人可以帮我解决这个问题吗?好困惑!
更新:
产品表:
id - name - price - quantity - category_id - brand_id - created_at
分类表
id - category_name - created_at
订单表
id - status - user_id - address_id - coupon_id - created_at
order_product 数据透视表
order_id - product_id - quantity
【问题讨论】: