Files
tougao/application/api/job/PromotionSend.php
2026-05-08 15:38:15 +08:00

33 lines
779 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;
/**
* 队列任务:发送 task 下"已 prepare"的邮件,按 min/max_interval 控制节奏。
*
* processNextEmail 内部会自动把下一封邮件 later() 入队(链式延迟),
* 因此本 job 处理完一封即可 delete无需在这里再 dispatch 下一封。
*
* 队列名PromotionSend
*/
class PromotionSend
{
public function fire(Job $job, $data)
{
$taskId = isset($data['task_id']) ? intval($data['task_id']) : 0;
if ($taskId <= 0) {
$job->delete();
return;
}
$service = new PromotionService();
$result = $service->processNextEmail($taskId);
$job->delete();
}
}