To do a similar function: for example, set a date on the 20th of each month, and remind the user of the gift a few days before this date. The date can be set to months, days, or months. Can the reminder time be the same day or the previous week? How to design the background database of this function requires a few features:
For example, if you set a date on the 20th day of each month, you will be reminded of the gift before the date.
The date can be set to months, days, or months. Can the reminder time be the same day or the previous week?
How to design the background database with this function? how many tables are required? How can I check when the message push function is available? Write a scheduled task in the background to keep running?
Reply content:
To do a similar function:
For example, if you set a date on the 20th day of each month, you will be reminded of the gift before the date.
The date can be set to months, days, or months. Can the reminder time be the same day or the previous week?
How to design the background database with this function? how many tables are required? How can I check when the message push function is available? Write a scheduled task in the background to keep running?
Two scheduled tasks and three tables
1. the gift table contains when to send fields and whether to send fields.
2. message table, whether to send, what to send, and who to send
3. messageservice table, which extracts messages from each user
Task 1: scan the task table. if it is not sent and the time has elapsed, insert a piece of data to the message table.
Task 2: scan the message table. if there is a message, send the message according to the system.
You need to determine the application environment. in web access, you need to determine when accessing the application.
A few tables are required to view your specific business requirements. a table with complex business requirements is sufficient. If you set the timing, you must set the script. Or you can use a third-party push Aurora push.
Data Dictionary
1. in the user information table, the is_accept field is used to store the user's message prompts.
2. create a message push configuration table
Id primary key
Task_obj extension field
Title
Content
On_time end time
Status platform enable message prompt
Days reminder a few days in advance (this field can also be set for the user, there is a user information table, let the user decide when to prompt him)
How many times tips pushes
Interval_time push interval (how often is the same user pushed)
3. message push log table
Id primary key id
Uid user ID
Tid message configuration id
On_time push time
4. php business logic
// Obtain all user loops whose is_accept is 1
Foreach {// Obtain the push configuration information table // Determine whether the user has pushed the configuration, // determine the current time-the last time the user pushed> = configure the interval // Determine whether the maximum number of Pushes has been reached/write to the push record table}
5. implementation
For linux, we recommend that you use the curl Command.
In windows, we recommend that you write the process daemon yourself or use urlcron.