一年后积分到期的公式
我正在编写一个使用 Credit 的 C# 网站。 客户将购买 x 美元的信用额度,如果在 12 个月内未使用,该信用额度就会过期。
我无法找出数学公式来计算应该过期多少?
IE。客户可以在 2011 年 6 月 1 日购买 50 美元的信用额度。然后在 2011 年 7 月 1 日花费 40 美元,然后在 2012 年 4 月 1 日再购买 60 美元积分,
您能帮我制定一个可以用来执行此操作的公式吗?
我可以每天运行一项服务来检查每个客户的信用和购买日期。
I am writting a C# website that uses Credit.
A customer will buy $x amount of credit and if it is not used within 12 months it expires.
I cant figure out a mathematic formula to work out how much should be expired?
IE. A customer may buy $50 of credit on june 1/2011. Then spend $40 july 1/2011, then buy another $60 credit April 1/2012
can you help me with a formula I can use to do this?
I can run a service every day to check the credit and date purchased for every customer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在这里,我可以向您解释礼券的完整概念,此外,我还为我的项目实现了相同的概念。
请参阅下图以获得正确的理解:
步骤:
逻辑使用优惠券可扣除..
逻辑是根据图像
步骤
if ($52>$210) = false
如果您获得的任何金额大于优惠券金额,则例如
优惠券金额为 $100 且购买金额是 $75 那么我们的 if($100>$75) 条件将为 true
在这里,您将减去金额并更新余额。25 美元作为优惠券余额
根据您的到期逻辑,您可以每天运行该服务来检查今天每张优惠券的到期情况,如果您发现任何优惠券,只需将余额更新为每天中午 12:00 0..
here i can explain you the complete concept for gift vouchers, and additionally i have implemented the same for my project..
Please refer the image below for proper understanding:
Steps:
the logic for deduction on using the voucher..
Logic is here as per the image
steps
if ($52>$210) = false
if you get any amount greater than voucher amount then eg
voucher amount is $100 and purchased amount is $75 then our if($100>$75) condition will be true
here you will subtract the amount and update with the balance.. $25 as voucher balance
Coming to your logic of expiry you can run the service daily to check the expiry of each voucher on todays date, if you find any voucher just update the balance to 0 at 12:00 am everyday..
在这种情况下,您不能只存储余额 - 您需要保留他们在过去一年内所有信用购买的列表,并且每当他们消费时,您都需要从他们最早的信用中扣除。
请注意,在许多州,持有过期的礼品卡是违法的,所以要小心这一点!
You can't just store a balance in this case--you need to keep a list of all of their credit purchases within the last year, and whenever they spend, you need to deduct from their oldest credit(s).
Note that it's illegal in many states to have gift cards that expire, so be careful with this one!
有多种方法可以处理这个问题。我见过所有固定金额的卡都会过期(本质上是一笔持有费用——我认为很多预付卡都会这样做,比如每月 4 美元,如果你在那个月使用过的话,可能什么都没有)。其他人只是简单地取期末余额的百分比,我喜欢的一种特殊方式是使用简单的每日值。
因此,为简单起见,假设您在第一天有 100 美元,在第 180 天取出 40 美元,因此在这一年的剩余时间里有 60 美元。在这种情况下,公式将类似于
[$100 * (180/365 * (年百分比率))] + [$60 * (185/365 * (年百分比率))]
只是仅供参考,但通常有规则和关于如何进行这些计算的具体规定(如果允许的话)
There are a number of ways to handle this. I've seen everything for a fixed amount expiring (essentially a holding charge - I think many prepaid cards will do this, something like $4 a month, with maybe nothing if you've used it during that month). Others simply take a % of ending balance, One particular way I like is using simple daily values.
So for simplicity, say you have $100 on day 1, and at day 180 you take out 40, thus have $60 - for the remainder of the year. In this case the formula would be something like
[$100 * (180/365 * (Yearly % Rate))] + [$60 * (185/365 * (Yearly % Rate))]
Just an FYI, but there are typically rules and regulation regarding exactly how these calculations should be done (if allowed at all)