webman/process/Task.php

63 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace process;
use App\Utils\API\SendCode;
use app\model\UserPhone;
use app\dao\UserRewardDao;
use Workerman\Crontab\Crontab;
use app\model\GetLodeLog;
/**
* 查询用户是否在线类
*/
class Task
{
public function onWorkerStart()
{
// // 每秒钟执行一次
// new Crontab('*/1 * * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每5秒执行一次
// new Crontab('*/5 * * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每分钟执行一次
// new Crontab('0 */1 * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每5分钟执行一次
// new Crontab('0 */5 * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每分钟的第一秒执行
// new Crontab('1 * * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每天的7点50执行注意这里省略了秒位
// new Crontab('50 7 * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每5秒执行一次
new Crontab('*/1 * * * * *', function () {
$GetLodeLog = GetLodeLog::where('status', 0)->get();
foreach ($GetLodeLog as $key => $value) {
$res = SendCode::get_code($value->phone);
var_dump($res);
if ($res['status'] == 1 && $res['scanCode'] != null) {
$value->status = 1;
$value->code = $res['scanCode'];
$value->save();
}
}
});
}
}