WokerTask/app/task/TaskCompanyAuthNotifyCron.php

43 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2023-12-27 14:06:33 +08:00
<?php
namespace app\task;
use app\common\logic\RedisLogic;
use app\common\model\Company;
use app\common\model\task\Task as TaskTask;
use think\cache\driver\Redis;
use think\facade\Log;
use yunwuxin\cron\Task;
class TaskCompanyAuthNotifyCron extends Task
{
public function configure()
{
$this->everyMinute();
// $this->everyMinute();
}
/**
* 监听企业认证回调 is_callback=1 表示回调成功
*/
protected function execute()
{
$redis = RedisLogic::getInstance();
//...具体的任务执行
$companyIdList = $redis->keys('authentication_company_id_*');
foreach ($companyIdList as $key) {
$data = $redis->get($key);
if (!empty($data)) {
$data = json_decode($data, true);
if ($data['is_callback'] == 1) {
$redis->del($key);
} else {
if (time() - $data['timing'] > 300) {
$companyInfo = Company::find(['id' => $data['company_id']]);
Log::info($companyInfo['company_name'].'企业认证回调超时');
}
}
}
}
}
}