I'm basically building a reseller website, in which people can buy (users) from a predefined product list and sell them at a higher price (clients).
I will show you some images to explain better myself. The following image represents a table with several fields, in which I have included only 2 columns.
The point of this table is to allow the user to fully customize the price displayed for his clients.
Let me explain: I want to allow the user to override the default price according to the setting combined.
For example: If a user has the "Global" in scope and "Percentage" in mode. This means that EVERY product will appear with a percentage price increase.
If a user has the "Client" in scope and "Percentage" in mode. This means that every product will appear with a percentage price increase ONLY for the client specified.
But, where's the catch? In overriding. Since the same user can have multiple settings, many of them will match criteria in-between.
See the following picture:
The number 4 is the most specific, hence the one who weights the more and will override the other 3 (if criteria matched).
Example: Imagine I have the following scenario: Imagine there are fertilizers as products. A user wants to sell to "Axel", the client.
For all fertilizers sold, the user will bill 15% of the original price. But, the client "Axel", instead of being billed 15% of the original price, he will be billed 10%.
When I look into the database table, I see that the user has set "Global" as its scope and "Percentage" as mode. Nonetheless, this same criteria is met because the user has also set "Client" as its scope and "Percentage" as mode in another row.
I'd like to "override" that global setting for "Axel" and display the billed 10%
This is the approach I have thought for now:
So this is what I'll be doing.
When I receive a request to add a product to the client I would be doing the following:
SELECT * FROM `table` WHERE scope = 4 && Product_ID = 12 && CLient_ID = 1
If match is not found or value has not been returned, then find this
SELECT * FROM `table` WHERE scope = 3 && Product_ID = 12
If match is not found or value has not been returned, then find this:
SELECT * FROM `table` WHERE scope = 2 && && CLient_ID = 1
If match is not found or value has not been returned, then find this
SELECT * FROM `table` WHERE scope = 1
What is the best way to handle this situation? If it's of any interest I'll be using ASP.NET MVC 5 with this. <br/><br/>Thanks a million and sorry for the long question.
Question
Jose_49
I'm basically building a reseller website, in which people can buy (users) from a predefined product list and sell them at a higher price (clients).
I will show you some images to explain better myself.
The following image represents a table with several fields, in which I have included only 2 columns.
The point of this table is to allow the user to fully customize the price displayed for his clients.
Let me explain: I want to allow the user to override the default price according to the setting combined.
For example: If a user has the "Global" in scope and "Percentage" in mode. This means that EVERY product will appear with a percentage price increase.
If a user has the "Client" in scope and "Percentage" in mode. This means that every product will appear with a percentage price increase ONLY for the client specified.
But, where's the catch? In overriding. Since the same user can have multiple settings, many of them will match criteria in-between.
See the following picture:
The number 4 is the most specific, hence the one who weights the more and will override the other 3 (if criteria matched).
Example:
Imagine I have the following scenario:
Imagine there are fertilizers as products. A user wants to sell to "Axel", the client.
For all fertilizers sold, the user will bill 15% of the original price. But, the client "Axel", instead of being billed 15% of the original price, he will be billed 10%.
When I look into the database table, I see that the user has set "Global" as its scope and "Percentage" as mode. Nonetheless, this same criteria is met because the user has also set "Client" as its scope and "Percentage" as mode in another row.
I'd like to "override" that global setting for "Axel" and display the billed 10%
This is the approach I have thought for now:
So this is what I'll be doing.
When I receive a request to add a product to the client I would be doing the following:
What is the best way to handle this situation? If it's of any interest I'll be using ASP.NET MVC 5 with this. <br/><br/>Thanks a million and sorry for the long question.
Also posted in here:
http://programmers.stackexchange.com/questions/258510/best-approach-for-displaying-a-price-from-a-product-according-the-setup-desi
Link to comment
Share on other sites
3 answers to this question
Recommended Posts