Php: how to approach renewal of membership in premium classes?

:

There are 4 elements:

30day pass
60day pass
180day pass
365day pass

There is a monthly (30-day) credit card. therefore, if you use the loan before the end of the month, you need to purchase another 30-day pass or wait for the next extension period.

A person buys a 30-day pass today, the date of purchase is recorded in the database. The date of recording is also recorded.

if ($todaysdate >= $expirydate) //DONE. 

but who goes 60 days and 180 days?

We have a purchase date and expiration date. every 30 days, the loan should be reset within the next month.

I really lost how best to approach this problem.

+3
source share
4 answers

( cron), , ​​ , reset, 0 , , .

, 30, 60 90 .

. php + cronjob.

0

cron mysql

cron

define (DAY_AMOUNT ,30);

SELECT mem_id  DATEDIFF(CURDATE(),mem_date) AS daypass FROM table
 WHERE ((DATEDIFF(CURDATE(),mem_date))=".DAY_AMOUNT."

, , , 30 .

+1

, :

pass: (id, user_id, start_time, end_time, credit)

, :

update user join
  (select user_id, sum(credit) as credit from pass
    group by user_id where end_time <= now() and not flushed) b
  set user.credit = max(user.credit - b.credit, 0)
  where user.user_id = b.user_id

update pass set flushed = 1 where end_time <= now() and not flushed

end_time <= now(), , reset . , , , , ( ).

, - , X (30/60/90 ) , reset .

btw, , , ​​ recurly chargify.

0

, , .

, unix. 30 - 2592000, , , - , ( ).

$months = 2; $expiry_date = time() + 2529000*$months;

.

-, (, cron).

, , ( ), . , , .

0

Source: https://habr.com/ru/post/1727922/


All Articles