Answer the question
In order to leave comments, you need to log in
How to keep paid tariffs purchased by the user in the database?
There is a service where Free (B), Paid 1 (P1) and Paid 2 (P2) modes are available. (In fact, there are more tariffs)
At any time, the user can purchase one of the Paid modes for 1 month or more.
Maybe, without waiting for the expiration of P1, upgrade to a more expensive P2.
Tasks:
Answer the question
In order to leave comments, you need to log in
DBMS was not specified.
In the general case, in my opinion, it will be something like this: Table of users (with the id of the currently
active tariff). By default, all users are free.
Tariff table.
Since one user can have many tariffs, NM connection, we need a connection table:
user_tariff (user id, tariff id, start date, end time, is_active attribute)
Jobs check users for active tariffs, if the time is up, change the tariff to that , which has time left, set the is_active flag to 0, change the active tariff in the users table. You can also keep a log of which user, when, from which to which tariff they transferred.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question