定期计费系统 [英] recurrning billing system

查看:50
本文介绍了定期计费系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个涉及定期计费的应用程序.在开始之前,我有几个问题,请帮忙.

I am building an application where recurring billing is involved. I have few questions before starting this, please help..

何时有任何会员注册并接受未来11个月的付款?我应该如何用php处理呢?我应该将这存储在另一个sql表中还是放在一行中?万一我想将它们存储在sql表中,接下来的11个月应该获得什么php函数?

When Any Member signups and accept to pay for next 11 months? How should I process this with php? should I store this is another my sql table or in a single row? What php function should I get to get next 11 months in case I want to store those in my sql table?

我应该如何运行cronjob?检查month_due表并获取其成员在本月待决的所有成员吗?

How should i run cronjob? Check monthly_due table and get all member whose members are pending for current month?

推荐答案

我当然会将您的订阅与会员信息分开存储.这不仅可以让您完整记录所有订阅,而且在需要可变长度的订阅时也有帮助.您的表结构可能是这样的:

I would certainly store your subscriptions separately from your members info. Not only will this allow you a complete record of all subscriptions but will also help if you need to have variable length subscriptions. Your tables structure might be something like this:

subscriptions
-------------
subscription_id  integer
member_id        integer
start_date       date
end_date         date
date_paid        datetime

然后,您可以直接使用SQL查找即将到期的订阅等.因此,要查找在接下来的7天内到期的任何订阅,您可能会遇到类似的情况

Then you can use SQL directly to find subscriptions about to expire etc. So to find any subscriptions due to expire within the next seven days you could have something like

SELECT
  member_id,
  MAX(end_date) as expires_date
FROM
  subscriptions
GROUP BY
  member_id
HAVING
  expires_date < DATE_ADD( CURDATE() INTERVAL 7 DAY )

这篇关于定期计费系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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