private function save(WechatQrcode $qr, $str, $type) { $result = $this->api->getQRCode($str, $type); if ($result !== false) { $qr->update(['ticket' => $result['ticket'], 'url' => $result['url']]); //异步下载 $job = (new WechatQrcodeJob($qr->getKey()))->onQueue('wechat'); app('Illuminate\\Contracts\\Bus\\Dispatcher')->dispatch($job); } return $qr; }
/** * Execute the job. * * @return void */ public function handle() { $qr = WechatQrcodeModel::find($this->qrcodeID); if (empty($qr)) { return false; } if (empty($qr->aid)) { $account = $qr->account; $attachment = new Attachment($account->toArray(), $account->getKey()); $a = $attachment->downloadByTicket($qr->ticket); !empty($a) && $qr->update(['aid' => $a['id']]); } }