How can I achieve automatic update of the number of gift packs on the next day when designing gift packs? How to design a database?

Source: Internet
Author: User
Suppose I set a total of 1000 gift packs, 100 each day. no matter whether all the 100 gift packs are received on the day, I re-count the remaining number of gift packs. The next day, if the remaining number of gift packs is 100, the number of new gift packs will be 100 on the same day. if the number is not 100, the current number of gift packs will be issued... suppose I set a total of 1000 gift packs, 100 each day. no matter whether all the 100 gift packs are received on the day, I re-count the remaining number of gift packs. The next day, if the remaining number of gift packs is 100, the number of new gift packs will be 100 on the same day. if not, the current number of gift packs will be issued until all the gift packs are received.
The problem is, how can I automatically update the quantity in the next day? Time acquisition is a problem. I should store a time field in the database, but automatic time update is a problem, do you understand what I mean?

Reply content:

Suppose I set a total of 1000 gift packs, 100 each day. no matter whether all the 100 gift packs are received on the day, I re-count the remaining number of gift packs. The next day, if the remaining number of gift packs is 100, the number of new gift packs will be 100 on the same day. if not, the current number of gift packs will be issued until all the gift packs are received.
The problem is, how can I automatically update the quantity in the next day? Time acquisition is a problem. I should store a time field in the database, but automatic time update is a problem, do you understand what I mean?

You fainted yourself.

Total database records Field

Each time you issue a service, you can determine whether or not 100 emails have been sent today. Where can I start automatic update?

Configuration Table
Id primary key id
Title gift bag name
Total nums gift packs
Day_nums total number of daily releases
Max_data activity end time
Ext extension field (you can record the use of the gift bag, because I don't know what features your gift bag has)

Gift bag issuance log table
Id primary key
Primary key of the lb_id package
Uid user ID
On_time time

Php
// Determine whether 100 gift packs have been issued today
(Select count (*) from logs where on_time = ". date (" Y-m-d ", time ()).")
~ Yes
// Do not issue
~ No
// Determine whether the user has received the gift package today
(Select * from logs where uid = $ uid and on_time = ". date (" Y-m-d ", time ()).")

~ Yes, no issue ~ No // decrease the number of gift packs by 1 // write the gift packs issuance log table

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.