Suppose I set a total of 1000 packages to be issued, 100 per day, regardless of whether 100 of the day is not all collected, all the remaining number of gift packs, the next day, if the remaining package enough 100, the same day the number of Gift pack is 100, if not enough 100, the current number of gift packs Until all packages are picked up.
The question is, how do I automatically update the number in the day, time acquisition is a problem, should be in the database to save a time field, but the time of the automatic update is a problem, do not know people understand my meaning?
Reply content:
Suppose I set a total of 1000 packages to be issued, 100 per day, regardless of whether 100 of the day is not all collected, all the remaining number of gift packs, the next day, if the remaining package enough 100, the same day the number of Gift pack is 100, if not enough 100, the current number of gift packs Until all packages are picked up.
The question is, how do I automatically update the number in the day, time acquisition is a problem, should be in the database to save a time field, but the time of the automatic update is a problem, do not know people understand my meaning?
You're making yourself dizzy.
Total field of database records
Each time the issuance of the judge whether today has been issued 100, no more than on the hair. What's the time for Automatic Updates?
Configuration table
ID primary Key ID
Title Gift Package Name
Total number of Nums gift packages issued
Day_nums Daily Release Totals
Max_data Activity End Time
Ext extension Field (can record the usefulness of the package, because I do not know what your gift package has)
Gift Pack Issuance Journal table
ID PRIMARY Key
LB_ID Gift Pack Primary key
UID User ID
On_time time
Php
To determine if 100 packages have been issued today.
(SELECT COUNT (*) from logs where On_time = ". Date (" Y-m-d ", Time ()).")
~ Yes
Not issued
~ No
Determine if the user has received the package today
(SELECT * from logs where uid= $uid and on_time = ". Date (" Y-m-d ", Time ()).)
~是 不发放 ~否 // 礼包配置数减1 // 写入礼包发放日志表
Isn't there a job?