产品动态折扣 [英] Dynamic Discount on Products

查看:62
本文介绍了产品动态折扣的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在现实世界中,您所购买产品的折扣非常有趣.例如,卖方通过以下方式为其产品提供折扣:

In the real world the discount on products you purchase is quite interesting. For example a seller offers a discount on his products in the following way:

  • 购买一个数量不会有折扣
  • 购买2个,他提供10%的折扣
  • 购买4和5的Disount将占20%
  • 6岁及以上的人占22%

在电子商务应用程序中完成此操作的最佳方法是什么?

What is the best way to accomplish this in an eCommerce application?

推荐答案

对指数或近似值取上限函数.例如,折扣= MaxDiscount *(1-(N-1)/N),其中N是项目数.1件商品的折扣为0,2件商品的折扣为最大商品的1/2,大量商品将接近MaxDiscount.使用上限函数将折扣设置为整数.

Take a ceiling function of the exponent or approximation thereof. For example Discount = MaxDiscount * (1 - (N-1)/N), where N is number of items. for 1 item discount is 0, for 2 items discount is 1/2 of the max, for large number of item it will approach MaxDiscount. Use ceiling function to you want discount to be integer number.

这篇关于产品动态折扣的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆