Home >Backend Development >PHP Problem >How to automatically close orders in php

How to automatically close orders in php

藏色散人
藏色散人Original
2020-08-31 10:00:503007browse

php method to automatically close orders: first read the last order cleaning time; then compare it with the current system time, if it exceeds the scheduled cleaning time, perform the cleaning operation; finally delete the expired order in the order table Just place an order.

How to automatically close orders in php

Recommended: "PHP Video Tutorial"

PHP automatically closes orders/executes scheduled tasks

Method 1:

You can consider triggering a scheduled cleanup operation when inserting a new order. Specifically, read the last order cleanup time, and then compare it with the current system time. If the scheduled cleanup is exceeded, time (for example, 30 minutes), perform a cleanup operation and delete expired orders in the order table.

These configuration data can be saved in the system configuration table, such as:

conf(conf_name, conf_value)order_last_clean_time: 1493101925

(Last order cleaning time)

order_cron_clean_time: 30 minutes

(Duration of scheduled cleaning)

order_expire_time: 30 minutes

(Orders that have not been paid for more than 30 minutes are considered expired)

Method 2:

Option:

1;Task Scheduling Service , add automatic execution code to check whether the order has expired, and cancel it if it expires;

2; Linux scheduled task: execute PHP script execution. The principle is the same as above

3; mysql database event, each order adds a listening event, and the event is canceled if the payment is completed.

If payment is not made; execute the event according to the agreed event and cancel the order;

The above is the detailed content of How to automatically close orders in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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