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.
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!