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.
39 lines
795 B
PHP
39 lines
795 B
PHP
<?php
|
|
|
|
namespace Workerman\Lib;
|
|
|
|
use Workerman\Worker;
|
|
|
|
$bot_loop = new Worker();
|
|
$bot_loop->count = 1;
|
|
$bot_loop->name = 'PlanUnlock';
|
|
function PlanUnlock($plan_id)
|
|
{
|
|
Tool::log('开始执行号源解锁任务', 2);
|
|
$url = Tool::ini('PLAN_UNLOCK');
|
|
$res = Tool::post($url, [
|
|
'plan_id' => $plan_id
|
|
]);
|
|
Tool::log(json_encode($res, JSON_UNESCAPED_UNICODE), 2);
|
|
}
|
|
|
|
function PlanUnlockFunc()
|
|
{
|
|
$db = Db::get();
|
|
$plan = $db->getRow("select * from plans where status = 1 and is_lock=1 and lock_endtime < ?", [
|
|
date('Y-m-d H:i:s')
|
|
]);
|
|
if (!!$plan) {
|
|
PlanUnlock($plan['id']);
|
|
} else {
|
|
Tool::log('号源解锁未检测到任务');
|
|
}
|
|
}
|
|
|
|
$bot_loop->onWorkerStart = function () {
|
|
PlanUnlockFunc();
|
|
Timer::add(10, function () {
|
|
PlanUnlockFunc();
|
|
});
|
|
};
|