我已经通过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
很有意思!我认为应该是具有多态关系的数据透视表,这可能是一个好方法。像这样的东西:
id - couponable_type - couponable_id - coupon_id - "whatever_data"
------------------------------------------------------------------
1 - category - 1 - 1 - ....
2 - order - 1 - 2 - ....
3 - product - 1 - 1 - ....
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句