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.

44 lines
925 B
PHP

<?php
namespace Workerman\Lib;
use Workerman\Worker;
$bot_loop = new Worker();
$bot_loop->count = 1;
$bot_loop->name = 'PayCheck';
function PayCheck($order_number)
{
Tool::log('开始执行任务', 2);
$url = Tool::ini('PAY_CHECK');
$res = Tool::post($url, [
'order_number' => $order_number
]);
Tool::log(json_encode($res, JSON_UNESCAPED_UNICODE), 2);
}
function PayCheckFunc()
{
$db = Db::get();
$pay_check = $db->getRow("select * from orders where status = ? and order_number is not null order by paycheck_time asc", [
1,
]);
if (!!$pay_check ) {
Db2::u($db, 'orders', [
'paycheck_time' => date('Y-m-d H:i:s'),
], 'where id = ?', [
$pay_check['id']
]);
PayCheck($pay_check['order_number']);
} else {
Tool::log('未检测到任务');
}
}
$bot_loop->onWorkerStart = function () {
PayCheckFunc();
Timer::add(10, function () {
PayCheckFunc();
});
};