Regarding the design and distribution of gift bags, how can the number of gift bags be automatically updated the next day? How to design the database?

  mysql, question

Suppose I set a total of 1,000 gift bags to be distributed, 100 each day. Regardless of whether all 100 gift bags are received or not, the remaining number of gift bags will be re-counted. Starting from the next day, if the remaining number of gift bags is 100, the number of gift bags distributed on the same day will be 100 again. If not, the current number of gift bags will be distributed until all the gift bags are received.
The problem is, how do I automatically update the quantity the next day? The acquisition of time is a difficult problem. A time field should be stored in the database inside. However, the automatic update of time is a problem. Do you understand what I mean?

You’ve confused yourself

Total field for total database records

At the time of each distribution, it is judged whether 100 have been distributed today. If not, they will be distributed. Where did you come from and when did you automatically update it?

configuration table
Id primary key id
Title package name
Nums package distribution total
Day_nums total daily distribution
Max_data activity end time
Ext extension field (it can record the use of the gift package, because I don’t know what function your gift package has)

Gift Package Distribution Log Sheet
Id primary key
Lb_id package primary key
Uid user id
On_time time

Php
//Judge whether 100 gift bags have been distributed today
(select count(*) from logs where on_time = “.date(“Y-m-d”,time()).”)
~ Yes
//Not to be distributed
~ no
//Judge whether the user has received the gift bag today
(select * from logs where uid=$uid and on_time = “.date(“Y-m-d”,time()).”)

~ Yes
 Not issued
 ~ no
 //Package configuration minus 1
 //Write into the gift package distribution log table