About the design release package, the next day automatically update the number of packages how to implement? How is the database designed?

Source: Internet
Author: User
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?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.