更新 微信推送机器人
parent
155d6605e5
commit
baefa37cc6
@ -0,0 +1,47 @@
|
|||||||
|
<?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 status = ?
|
||||||
|
and appointment_number is not null
|
||||||
|
and wx_day1_sendmsg_status = 0
|
||||||
|
and wx_day1_sendmsg_time <= ?
|
||||||
|
order by wx_day1_sendmsg_time asc", [
|
||||||
|
2, date('Y-m-d H:i:s')
|
||||||
|
]);
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue