m_id = $m_id; $this->type = $type; $this->type_id = $type_id; $this->survey_id = $survey_id; } /** * Execute the job. * * @return void */ public function handle() { $base_url = env('APP_URL')."/pu/#/questionnaireV3/".$this->survey_id."?merchant_id=".$this->m_id."&type=".$this->type."&type_id=".$this->type_id; $base_url = urlencode($base_url); $url = env('APP_URL')."/survey/auth?url=".$base_url; $pic_path = storage_path('qrcode/'.$this->m_id.'_survey_'.$this->survey_id."_".$this->type.'_'.$this->type_id.'_sharer_qrcode.png'); //二维码图片 QrCode::format('png')->margin(1)->size(300)->generate($url, $pic_path); if(file_exists($pic_path)){ $qrcode = $this->uploadFile($pic_path); if ($this->type && $this->type_id) { SurveyService::where('survey_id', $this->survey_id)->where('type', $this->type)->where('type_id', $this->type_id)->update(['qrcode'=>$qrcode, 'share_url'=>$url]); }else { Survey::where('id', $this->survey_id)->update(['qrcode'=>$qrcode, 'share_url'=>$url]); } unlink($pic_path); } } public function uploadFile($file) { $ossClient = UploadController::getOssClient(); //生成file $object = date('Y').date('m')."/".date('d')."/".basename($file); $url = 'https://'.config('alioss.picture_domain').'/'.$object; try { $ossClient->uploadFile(config('alioss.buckets.picture'), $object, $file); } catch(\OSS\Core\OssException $e) { Log::info($e->getMessage()); return false; } return $url; } }