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.
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Workerman\Lib;
|
|
|
|
use Workerman\Worker;
|
|
|
|
$bot_loop = new Worker();
|
|
$bot_loop->count = 1;
|
|
$bot_loop->name = 'WxSend';
|
|
function WxSend($order_id)
|
|
{
|
|
Tool::log('开始执行WxSend任务', 2);
|
|
$url = Tool::ini('WX_SEND');
|
|
$res = Tool::post($url, [
|
|
'id' => $order_id
|
|
]);
|
|
Tool::log(json_encode($res, JSON_UNESCAPED_UNICODE), 2);
|
|
}
|
|
|
|
function WxSendFunc()
|
|
{
|
|
$db = Db::get();
|
|
$pay_check = $db->getRow("select * from orders where wx_day1_sendmsg_status = 0
|
|
and status = ?
|
|
and appointment_number is not null
|
|
and wx_day1_sendmsg_time is not null
|
|
and wx_day1_sendmsg_time <= ? and wx_day1_sendmsg_time > ?
|
|
order by wx_day1_sendmsg_time asc", [
|
|
2, date('Y-m-d H:i:s'),date('Y-m-d')." 00:00:01"
|
|
]);
|
|
if (!!$pay_check) {
|
|
Db2::u($db, 'orders', [
|
|
'wx_day1_sendmsg_time' => date('Y-m-d H:i:s'),
|
|
], 'where id = ?', [
|
|
$pay_check['id']
|
|
]);
|
|
WxSend($pay_check['id']);
|
|
} else {
|
|
Tool::log('WxSend未检测到任务');
|
|
}
|
|
}
|
|
|
|
$bot_loop->onWorkerStart = function () {
|
|
WxSendFunc();
|
|
Timer::add(10, function () {
|
|
WxSendFunc();
|
|
});
|
|
};
|