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
1.1 KiB
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('开始执行PayCheck任务', 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 and (source IS NULL or source not like ?) order by paycheck_time asc", [
1,'%线下体检预约%'
]);
if (!!$pay_check and strtotime($pay_check['paycheck_time'])<strtotime($pay_check['created_at']) + 60) {
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('PayCheck未检测到任务');
}
}
$bot_loop->onWorkerStart = function () {
PayCheckFunc();
Timer::add(10, function () {
PayCheckFunc();
});
};