V
V
Vitaly2014-04-04 18:43:29
Database design
Vitaly, 2014-04-04 18:43:29

How to fix the design of the subscription-billing system for a hosting company?

I can not develop the correct database design for the billing system in any way. My head is already boiling ..
Briefly, what is needed:
User can buy / renew hosting
User can buy / renew domains
User can register in the cloud and add several servers there
User can add plugins to their products.
Usage example:
A user buys a domain.
The user registers in the cloud and creates two servers.
Every first day of the month, an invoice is generated for using the cloud.
The user decides that he needs the maintenance of one of the servers in the cloud - he adds the "server maintenance" addon for the 1st server.
Removes this addon after 10 days.
At some time, he decides that he does not need the cloud, and deletes the cloud.
So I sit and think .. how to reflect all this beautifully in the database, so that it would be convenient to work with it?
It's something like "design tables for me" :(
So far I've come up with this:
clouds are products.. servers are subproducts. addons are also subproducts of anything.
Then, for example, the structure of the products table might look like this: id, parent_id, name, data, first_period, first_price, second_period, second_price, rebill_times, status
and for the case with two servers and an addon it would be:
Products:
1 0 cloud {location: "cloud_location"} 26d 0 1m 0 0 active
2 1 cloud.server {server_id: "abc"} 26d 0 1m 0 0 active
3 1 cloud.server {server_id: "def"} 26d 0 1m
0 0 active
Next, I'm going to make the Orders table: id product_id pay_date due_date status
Each time it is added to the Products table, an Order must be created in accordance with the first_period
Well, after each cron pass through the Orders table, make new records in it in accordance with the second_period ..
Next, the Access table: id product_id, start_date end_date
In case of a successful order, access will be filled with access to a specific product.
Well, with an unpaid order - the record will be deleted
Well, I’m thinking .. but how to activate the products correctly .. i.e. hosting and domains must be paid first .. but the cloud can be used immediately .. and payment at the beginning of the month ..
I decided that I would just create an order every time, and if it is zero, then immediately activate the product - if not, then wait payment. But the problem is that the price in the cloud is dynamic and depends on the use. for each order, you need to get the current price if it is 0 ..
In general, help pliz .. I want to do everything right.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question