购物车和各种折扣。在数据库中存储的折扣,并把它应用到订购计算折扣、把它、购物车、数据库中

由网友(萌妹子的眼泪是水滴i)分享简介:目前,我正在寻找最佳实践申请优惠到购物车/订单。所以,我打算执行此类折扣为... Currently, I'm looking for best practice to "applying discounts" to cart/order.So, I'm planning to implement such ki...

目前,我正在寻找最佳实践申请优惠到购物车/订单。 所以,我打算执行此类折扣为...

Currently, I'm looking for best practice to "applying discounts" to cart/order. So, I'm planning to implement such kind of discounts as...

固定用户的折扣(例如,我想给10%的折扣,我最喜欢的顾客)

fixed user's discount (for example, I'd like to give 10% discount to my favourite customer)

优惠项目数量(例如,你买10个不同颜色的笔,你会得到1.5%的优惠)

discount for number of items (for example, you're buying 10 different colored pens and you'll be getting discount of 1.5%)

优惠券(例如,促销行动中,我们已经产生100优惠券,10%的折扣,每。优惠券只为一个为了工作和到期YYYY-MM-DD)

discount for coupon (for example, during promo action we've produced 100 coupons with 10% discount each. Coupons work only for one order and expire on yyyy-mm-dd)

present购买项目或项目组的(例如,你买的笔,纸和商店$ P $的列表psents一个削给你)

present for purchasing item or group of items (for example, you're buying pen, list of paper and shop presents a sharpener to you)

折扣总价的基础上(例如,你买10笔刚开没有折扣,那么你将5个笔获得5%的折扣)

discount for total order price (for example, you're buying 10 pens and gettin no discount, then you're adding 5 more pens and getting 5% discount)

只有一个折扣可以适用于特定项目。我们总是将最大的优惠。最赚钱的折扣的用户。

Only one discount could be applied to specific item. We're always applying biggest discount. The most profitable discount for user.

在那旁边管理员应该能够修改特定的顺序物品的价格,并取消折扣按此顺序。

Beside that admin should be able to modify items price in specific order and cancel discounts in this order.

老实说,这是我的第一个电子商务应用程序,并在我看来,以实现所有这些类型的disounts的pretty的硬任务。

Frankly speaking, it is my first ecommerce application and it seems to me pretty hard task to implement all these kinds of disounts.

好了,现在让我告诉你我是如何去落实?

Ok, now let me tell you how I'm going to implement...

固定用户的折扣这仅仅是一个包含有关优惠信息,用户表中的字段。它被手动设置,通过控制面板或自动由cron具有总订单SUMM超过了N使用。

fixed user's discount It is just a field in users table which contains information about discount. It is being set manually through control panel or automatically by cron for uses having total order summ over that N.

优惠项目数量我要创建更多的表存储项目组这样的折扣的。此外,我还需要多一个表来连接这个群体在店里的物品。

discount for number of items I'm going to create additional table storing items' groups of such discounts. Also I'll need one more table to connect this groups with items in shop.

优惠券只是一个包含字段到期日,优惠券,优惠券折扣的状态券表,也许USER_ID(优惠券的所有者)。也许我还将实施优惠券项目的类别。

discount for coupon Just a table with coupons containing field with expire day, status of coupon, coupon discount and maybe user_id (owner of coupon). Probably I will also implement coupons for categories of items.

present购买项目或项目组的这是在屁股真正的痛苦,我完全不知道如何实现。请帮帮忙!

present for purchasing item or group of items It is real pain in the ass and I totally don't know how implement. Please help!

折扣总价的基础上 pretty的方便,恕我直言。

discount for total order price Pretty easy, imho.

好了,现在我正在寻找可以存放各种折扣的数据库中的最佳实践。此外,我正在寻找OOP实践应用此折扣的购物车。任何帮助AP preciated!

Ok, now I looking for best practices of storing this kinds of discounts in DB. Also I'm looking for OOP practices to applying this discounts to Cart. Any help is appreciated!

PS:对不起,这么长的帖子,但我认为这将是有趣的不仅是对我

PS: Sorry for such long post, but I think that it will be interesting not only for me.

感谢你。

推荐答案

为present购买项目的项目要求或一组基本的解决办法是有一些像一个包和一个bundleItem表。

A basic solution for the present for purchasing item or group of items requirement is to have something like a bundle and a bundleItem table.

bundle table.
id                     int   primary key
giftproductId          int   foreign key - product table

bundleitem table.
id                     int   primary key
bundleid               int   foreign key - bundle table
requiredproductid      int   foreign key - product table

您束表中包含的礼品项目ID和bundleitem表保存相关联的所有用户必须为符合资格的礼物,被捆绑的项目。

Your bundle table contains the gift item id and the bundleitem table holds all the items associated to the bundle which the user must order to qualify for the gift.

您'捆绑'类将包含这些要求的产品项目的数组,礼物项目和方法,需要一个购物车对象,并检查车是否包含了这个特定的捆绑优惠每一个需要的产品 - 有点像在fo​​reach循环简单​​的foreach ...

Your 'Bundle' class would contain an array of these required product items, the gift item and a method which takes a shopping cart object and checks to see whether the cart contains every required product for this particular bundle offer - something like a simple foreach within a foreach loop...

这是一个简单的解决方案,事情可能会变得复杂取决于这些礼品如规则如果我订购2笔和纸2列出了我能得到2刀? - !祝你好运吧。

This is a simple solution things can get complex depending on the rules for these gift items e.g. if I order 2 pens and 2 lists of paper do I get 2 sharpeners? - Good luck with it!

阅读全文

相关推荐

最新文章