response->format = \yii\web\Response::FORMAT_RAW; $store = Store::find()->where([ 'id' => $store_id ])->one(); if (!$store){ throw new Exception('门店不存在'); } // if (!$store->qr_code) { // $response = WechatService::getInstance()->app->app_code->getUnlimit($scene, [ // 'page' => 'pages/home/home', // 'check_path' => false, // ]); // // if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) { // $path = 'uploads/STORE_QR_CODE/' . date('Ymd'); // $filename = $response->save('uploads/STORE_QR_CODE/' . date('Ymd'), 'STORE_QR_CODE_' . $store_id); // // $realpath = FuncHelper::getRealFilepath('service', $path . '/' . $filename); // // $uploadService = new UploadService(); // $url = $uploadService->saveFile($realpath); // // $store->setAttributes(['qr_code' => $url]); // $store->save(); // } // } if (!$store->qr_code) { $weappService = new WeappService(); $url= $weappService->getQrcode($scene); $store->qr_code=$url; $store->saveOrFail(); } return $store->qr_code; } }