template_id = $template_id; $this->agent_id = $agent_id; } /** * Execute the job. * * @return void * @throws Exception */ public function handle() { $agent = Agent::find($this->agent_id); $template = MiniProgramTemplate::find($this->template_id); if (!$agent || !$template) return; try { # 如果已经有上传成功的版本则不再上传 $not_uploaded = MiniProgramUploadLog::where([ 'is_success' => 0, 'agent_id' => $this->agent_id, 'template_id' => $this->template_id, ])->doesntExist(); if ($not_uploaded) { new UploadMiniProgram($agent, $template); } } catch (GuzzleException | \Exception $e) { throw new Exception($agent->id . '-' . $agent->appid . $e->getMessage()); } } }