Files
tougao/application/api/job/PromotionPrepare.php
2026-05-07 11:45:40 +08:00

51 lines
1.5 KiB
PHP
Raw Permalink 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 app\api\job;
use think\queue\Job;
use app\common\PromotionService;
use app\common\QueueJob;
/**
* 【已废弃 / 兼容保留】
*
* 旧版 task 级 prepare Job新逻辑请使用 PromotionPrepareTask + PromotionPrepareEmail。
*
* 本类仅为兼容队列中可能遗留的旧 payload接收到旧 job 时转发到新的调度器,
* 保证旧消息不会丢失。新代码不应再 push 此 Job。
*/
class PromotionPrepare
{
private $oQueueJob;
public function __construct()
{
$this->oQueueJob = new QueueJob();
}
public function fire(Job $job, $data)
{
$this->oQueueJob->init($job);
$taskId = isset($data['task_id']) ? intval($data['task_id']) : 0;
if ($taskId <= 0) {
$this->oQueueJob->log("PromotionPrepare[deprecated] 无效的 task_id删除任务");
$job->delete();
return;
}
try {
$service = new PromotionService();
$service->enqueuePrepareTask($taskId);
$this->oQueueJob->log("PromotionPrepare[deprecated] forwarded task_id={$taskId} -> PromotionPrepareTask");
$job->delete();
} catch (\Exception $e) {
$this->oQueueJob->handleException($e, $job, "[deprecated] task_id={$taskId}");
} catch (\Throwable $e) {
$this->oQueueJob->handleException($e, $job, "[deprecated] task_id={$taskId}");
} finally {
$this->oQueueJob->finnal();
}
}
}