webman_duanju/app/queue/DiscCompensateJob.php

26 lines
696 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\queue;
use app\admin\model\DiscSpinning;
use think\facade\Log;
use think\queue\Job;
class DiscCompensateJob
{
public function fire(Job $job, $data) {
try {
Log::write('准备处理DiscCompensateJob' . json_encode($data, JSON_UNESCAPED_UNICODE));
DiscSpinning::receive1($data);
$job->delete(); // 处理成功删除任务
} catch (\Exception $e) {
if ($job->attempts() < 3) {
$job->release(5); // 重试3次间隔5秒
} else {
$job->delete();
Log::error("大转盘补偿任务最终失败ID={$data['id']}");
}
}
}
}