Table of Contents
Reply content:
Home Backend Development PHP Tutorial How to implement a function similar to gift reminder?

How to implement a function similar to gift reminder?

Aug 04, 2016 am 09:21 AM
php

To make a similar function:
For example, set a date on the 20th of every month, and remind the user to give gifts a few days before this date.
The date can be set to the day of the month, the day of the month, etc. Can the reminder time be a reminder for the current day, a reminder for the previous week, etc.?

How to design the backend database with this kind of function? How many tables are needed? Now that the message push function is available, how to detect when it will be pushed? Write a scheduled task in the background to run continuously?

Reply content:

To make a similar function:
For example, set a date on the 20th of every month, and remind the user to give gifts a few days before this date.
The date can be set to the day of the month, the day of the month, etc. Can the reminder time be a reminder for the current day, a reminder for the previous week, etc.?

How to design the backend database for this kind of function? How many tables are needed? Now that the message push function is available, how to detect when it will be pushed? Write a scheduled task in the background to run continuously?

Two scheduled tasks, three tables
1. Gift table, which contains fields for when to send and whether to send. 2. Message table, whether to send, what is sent, and to whom
3. Message person table, each Extract personal messages
Task one, scan the task table, if it has not been sent and the time is up, insert a piece of data into the message table
Task two, scan the message table, if there is a message, send it according to the system,,,,, he is a A public watch is not necessarily used for giving out gifts

It is necessary to judge the application environment, during web access, and when users access it.

Several tables are needed to see your specific business needs. One information table with uncomplicated business needs is enough. If you set up timing, you definitely need to set up a script. Or you can use a third party to push Jiguang Push

Data Dictionary

1 The user information table uses the field is_accept to store whether the user has enabled message prompts

2 Create a message push configuration table

id primary key
task_obj extended field
title title
content content
on_time end time
status whether the platform enables message prompts
days reminder a few days in advance (this field can also be set for the user, user information exists Table, let the user decide when to prompt him)
tips how many times to push
interval_time push interval (how often does the same user push)
3 message push log table
id primary key id
uid user id
tid message configuration id
on_time send Push time

4 php business logic

//Get all users whose user table is_accept is 1 loop

<code> foreach{
      //获取推送配置信息表
      //判断用户是否已推送,
      //判断 当前时间-用户上次推送时间>=配置间隔时间
      //判断是否已达到最大推送次数
      //写入推送记录表
      }</code>
Copy after login
5 Implementation

If it is a Linux system, it is recommended to use the system command curl
For a Windows system, it is recommended to write the process daemon yourself, or use urlcron

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles