diff --git a/bot/bot/bot_payCheck.php b/bot/bot/bot_payCheck.php new file mode 100644 index 0000000..076d9f4 --- /dev/null +++ b/bot/bot/bot_payCheck.php @@ -0,0 +1,43 @@ +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(); + }); +};