修改自动推广的相关任务

This commit is contained in:
wangjinlei
2026-05-08 15:38:15 +08:00
parent b1e978ed73
commit 336fa08a18
9 changed files with 116 additions and 151 deletions

View File

@@ -4,7 +4,6 @@ namespace app\api\job;
use think\queue\Job;
use app\common\ExpertFinderService;
use app\common\QueueJob;
/**
* 专家抓取队列任务。
@@ -16,25 +15,16 @@ use app\common\QueueJob;
*/
class FetchExperts
{
private $oQueueJob;
public function __construct()
{
$this->oQueueJob = new QueueJob();
}
public function fire(Job $job, $data)
{
$this->oQueueJob->init($job);
$field = isset($data['field']) ? (string)$data['field'] : '';
if ($field === '') {
$this->oQueueJob->log("FetchExperts 无效的 field删除任务");
$job->delete();
return;
}
try {
$service = new ExpertFinderService();
$service->doFetchForField(
$field,
@@ -42,14 +32,6 @@ class FetchExperts
isset($data['per_page']) ? intval($data['per_page']) : 100,
isset($data['min_year']) ? $data['min_year'] : null
);
$this->oQueueJob->log("FetchExperts 完成 | field={$field}");
$job->delete();
} catch (\Exception $e) {
$this->oQueueJob->handleException($e, $job, "field={$field}");
} catch (\Throwable $e) {
$this->oQueueJob->handleException($e, $job, "field={$field}");
} finally {
$this->oQueueJob->finnal();
}
}
}