You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
excel_handle/app/jobs/DelayQueue.php

42 lines
944 B

4 years ago
<?php
declare (strict_types=1);
namespace app\jobs;
use think\facade\Db;
use think\facade\Cache;
use think\queue\Job;
class DelayQueue
{
/**
* The job handler instance.
* @var mixed
*/
protected $instance;
public function fire(Job $job, $data)
{
//执行业务处理
$result = $this->doJob($job, $data);
if ($result['code'] == 1) {
$job->finish(2, $result['msg']);
} else {
$job->finish(3, $result['msg']);
}
}
private function doJob(Job $job, $data)
{
ini_set('memory_limit', '2048M');
$class = $data['controller'];
$method = $data['action'];
$this->instance = app()->make($class);
if ($this->instance) {
return ['code' => 1, 'msg' => $this->instance->{$method}($data['params'], $job->getJobId())];
}
return ['code' => 0, 'msg' => '处理类不存在'];
}
}