gpt4 book ai didi

c# - 每月计费周期的最佳模式

转载 作者:太空狗 更新时间:2023-10-29 21:19:40 24 4
gpt4 key购买 nike

我为我的新计费系统编写了一些代码。目的是在每个月的同一天向客户开具账单。 (不是每月的第一天或最后一天)

static bool NeedToBill(DateTime planLastBilled, DateTime cycleDate)
{
// is today the same date as the cycleDate AND is was the planLastBilled not the same day as today?
if (DateTime.UtcNow.Day.Equals(cycleDate.Day) && !DateTime.UtcNow.Day.Equals(planLastBilled))
return true;
else
return false;
}

这两个陷阱是:

  1. 如果他的 cycleDate.Day 是 31 而当月只有 29 天
  2. cycleDate 是 2012 年 2 月 29 日 - 他只会在闰年收到账单

这里有通用的最佳实践吗?

所以好像有很多东西要检查

  1. 这个帐户本月是否已经收费?
  2. 当月是否有循环日
  3. 周期日是否大于或等于当前日期(这是理想的,如果前一天交易失败)

谢谢!

最佳答案

只允许选择 1 - 28 之间的计费日。根据我的经验,这就是大多数信用卡/贷款公司在选择时的处理方式。

关于c# - 每月计费周期的最佳模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5394540/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com