Files
tougao/application/api/job/PromotionPrepare.php
wangjinlei ae221e6be6 1
2026-04-16 13:30:31 +08:00

38 lines
962 B
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 app\api\job;
use think\queue\Job;
use app\common\PromotionService;
/**
* 队列任务:对单个 promotion_task 执行 prepareTask预生成 subject/body
*
* 队列名promotion
* 启动 workerphp think queue:listen --queue promotion
*/
class PromotionPrepare
{
public function fire(Job $job, $data)
{
$taskId = intval(isset($data['task_id']) ? $data['task_id'] : 0);
$service = new PromotionService();
if (!$taskId) {
$job->delete();
return;
}
try {
$result = $service->prepareTask($taskId);
$service->log('[PromotionPrepare] task=' . $taskId
. ' prepared=' . $result['prepared']
. ' failed=' . $result['failed']);
} catch (\Exception $e) {
$service->log('[PromotionPrepare] task=' . $taskId . ' exception=' . $e->getMessage());
}
$job->delete();
}
}