runTimedStep('极速28开奖处理', fn () => PcIssueService::index()); // 提前60秒秒提醒封盘倒数 $this->runTimedStep('加拿大28封盘倒计时', fn () => IssueService::syncCountdownIssue()); // 停止下注 //封盘 $this->runTimedStep('加拿大28封盘', fn () => IssueService::syncCloseIssue()); // 获取最新的期号 $this->runTimedStep('加拿大28开奖同步', fn () => IssueService::getLatestIssue()); //随机虚拟投注 $this->runTimedStep('虚拟投注', fn () => BetService::randomVirtualBetting(3)); // 重要:使用类名而不是 self(),避免递归 FiveSecondTaskJob::dispatch()->delay(now()->addSeconds(15)); // Log::error('📅 下一个15秒任务已安排'); } catch (Exception $e) { try { throw new Exception('❌ 15秒任务执行异常: ' . $e->getMessage()); }catch (Exception $e) { LogService::error($e); } // 异常后15秒重试 FiveSecondTaskJob::dispatch()->delay(now()->addSeconds(15)); } } private function runTimedStep(string $step, callable $callback): void { $startedAt = microtime(true); $completed = false; $context = [ 'step' => $step, 'job_id' => $this->job?->getJobId(), 'attempt' => $this->attempts(), 'process_id' => getmypid(), ]; Log::channel('issue')->info('PC28任务步骤开始', $context); try { $callback(); $completed = true; } finally { Log::channel('issue')->info('PC28任务步骤结束', $context + [ 'elapsed_ms' => round((microtime(true) - $startedAt) * 1000, 1), 'status' => $completed ? 'completed' : 'failed', ]); } } // 可选:失败处理 public function failed(\Throwable $exception) { Log::error('任务失败: ' . $exception->getMessage()); // 可选:重新分发或通知 dispatch(new self())->delay(now()->addSeconds(15)); } }