Files
tougao/application/api/job/PromotionPrepareTask.php
2026-04-24 17:55:58 +08:00

43 lines
1.3 KiB
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;
/**
* 队列任务task 级别的 prepare 调度器。
*
* 职责:遍历 task 下待准备的 promotion_email_log
* 将每封邮件拆成一条 PromotionPrepareEmail 推到 promotion_email 队列,
* 以便并行调用 LLM 生成个性化描述。
*
* 队列名promotion
* 启动 workerphp think queue:listen --queue promotion
*/
class PromotionPrepareTask
{
public function fire(Job $job, $data)
{
$taskId = intval(isset($data['task_id']) ? $data['task_id'] : 0);
$service = new PromotionService();
$result = $service->dispatchPrepareEmails($taskId);
// if (!$taskId) {
// $job->delete();
// return;
// }
// try {
// $result = $service->dispatchPrepareEmails($taskId);
// $service->log('[PromotionPrepareTask] task=' . $taskId
// . ' dispatched=' . $result['dispatched']
// . ' already_done=' . ($result['already_done'] ? 1 : 0)
// . (empty($result['error']) ? '' : ' error=' . $result['error']));
// } catch (\Exception $e) {
// $service->log('[PromotionPrepareTask] task=' . $taskId . ' exception=' . $e->getMessage());
// }
$job->delete();
}
}