M
M
Messi2018-05-24 12:51:59
Algorithms
Messi, 2018-05-24 12:51:59

Checking logic depending on schedule?

Can you please tell me an example of implementation or your experience in developing such functionality?
For example, the constant cost of the goods will be 10 rubles, but you need to make it possible to specify the time and cost.
The man put it like this, on Monday the price is 5 rubles, and on Tuesday from 14:00 to 15:00 the price is 1 rub.
How to do it faster?
Create a table in which to write these rules, then sort and apply the latter when checking the cost?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MADSMILEXD, 2018-05-24
@MADSMILEXD

pull up all the prices for the product at once, and then filter from the client,
otherwise you need to think at what price the person will buy the product if he opens the page at 14:50, and clicks buy in a couple of hours
, or take the current time during the request and get all the prices from which the beginning of the period is less than the current date, and the end is greater than

L
Lander, 2018-05-24
@usdglander

I would use the "Strategy" pattern.
You make several pricing strategies, and depending on some conditions, you connect one or another.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question