You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
775 B
PHP
38 lines
775 B
PHP
<?php
|
|
|
|
namespace Workerman\Lib;
|
|
|
|
use Workerman\Worker;
|
|
|
|
$bot_loop = new Worker();
|
|
$bot_loop->count = 1;
|
|
$bot_loop->name = 'OrderCancel';
|
|
function OrderCancel()
|
|
{
|
|
Tool::log('开始执行任务', 2);
|
|
$url = Tool::ini('ORDER_CANCEL');
|
|
$res = Tool::post($url);
|
|
Tool::log(json_encode($res, JSON_UNESCAPED_UNICODE), 2);
|
|
}
|
|
|
|
function OrderCancelFunc()
|
|
{
|
|
$db = Db::get();
|
|
$order_cancel_count = $db->getRow("select count(1) as c from orders where status = ? and created_at < ?", [
|
|
1,
|
|
date('Y-m-d H:i:s', time() - 60 * 20)
|
|
]);
|
|
if ($order_cancel_count['c'] > 0) {
|
|
OrderCancel();
|
|
} else {
|
|
Tool::log('未检测到任务');
|
|
}
|
|
}
|
|
|
|
$bot_loop->onWorkerStart = function () {
|
|
OrderCancelFunc();
|
|
Timer::add(10, function () {
|
|
OrderCancelFunc();
|
|
});
|
|
};
|