'pages/home/home', 'query_param' => 'a=1', 'describe' => "小程序开发上线使用" ]; $res = ShareQrcode::aliConfigQr($request, $param); if ($res->code !== "10000") { return $this->asJson([ 'code' => 1, 'msg' => $res->sub_msg, ]); } return $this->asJson([ 'code' => 0, 'msg' => 'success', 'data' => $res->qr_code_url_circle_blue, ]); } catch (\Exception $e) { return $this->asJson([ 'code' => 1, 'msg' => $e->getMessage(), ]); } } /** * 登录 * * @return void */ public function actionLogin() { set_time_limit(0); $conf = Option::get(Option::OPTOPN_KEY, get_store_id(), 'alipay')['value']; if($conf){ $conf = json_decode($conf, true); } if(!$conf || empty($conf['app_id'])){ return $this->asJson([ 'code' => 1, 'msg' => '请先配置支付宝AppId', ]); } $appid = $conf['app_id']; $url = $this->url . 'login_alipay.php'; $host = str_replace(['http://', 'https://'], ['', ''], \Yii::$app->request->hostInfo); $ws_url = isset(\Yii::$app->params['ws_url']) ? \Yii::$app->params['ws_url'] : 'ws.cyyvip.com'; $res = http_get($url, [ 'query' => [ 'appid' => $appid, 'http_url' => $host, 'version' => cyy_version(), 'ws_url' => $ws_url, 'store_id' => get_store_id(), ] ]); if ($res->getStatusCode() != 200) { return $this->asJson([ 'code' => 1, 'msg' => '请求出错!', ]); } $content = json_decode((string)$res->getBody()); return $this->asJson($content); } /** * 上传小程序 * * @return void */ public function actionPreview() { set_time_limit(0); $conf = Option::get(Option::OPTOPN_KEY, get_store_id(), 'alipay')['value']; if($conf){ $conf = json_decode($conf, true); } if(!$conf || empty($conf['app_id'])){ return $this->asJson([ 'code' => 1, 'msg' => '请先配置支付宝AppId', ]); } $appid = $conf['app_id']; $url = $this->url . 'preview_alipay.php'; $host = str_replace(['http://', 'https://'], ['', ''], \Yii::$app->request->hostInfo); $res = http_get($url, [ 'query' => [ 'appid' => $appid, 'http_url' => $host, 'version' => cyy_version(), 'store_id' => get_store_id(), ], 'timeout' => 500, ]); if ($res->getStatusCode() != 200) { return $this->asJson([ 'code' => 1, 'msg' => '请求出错!', ]); } $content = json_decode((string)$res->getBody()); return $this->asJson($content); } /** * 上传小程序 * * @return void */ public function actionUpload() { set_time_limit(0); $conf = Option::get(Option::OPTOPN_KEY, get_store_id(), 'alipay')['value']; if($conf){ $conf = json_decode($conf, true); } if(!$conf || empty($conf['app_id'])){ return $this->asJson([ 'code' => 1, 'msg' => '请先配置支付宝AppId', ]); } $appid = $conf['app_id']; $url = $this->url . 'upload_alipay.php'; $host = str_replace(['http://', 'https://'], ['', ''], \Yii::$app->request->hostInfo); $res = http_get($url, [ 'query' => [ 'appid' => $appid, 'http_url' => $host, 'version' => cyy_version(), 'store_id' => get_store_id(), ], 'timeout' => 500, ]); if ($res->getStatusCode() != 200) { return $this->asJson([ 'code' => 1, 'msg' => '请求出错!', ]); } $content = json_decode((string)$res->getBody()); return $this->asJson($content); } public function actionPublic() { $conf = Option::get(Option::OPTOPN_KEY, get_store_id(), 'alipay')['value']; if($conf){ $conf = json_decode($conf, true); } if(!$conf || empty($conf['app_id'])){ return $this->asJson([ 'code' => 1, 'msg' => '请先配置支付宝AppId', ]); } $appid = $conf['app_id']; $link = "https://open.alipay.com/mini/dev/sub/dev-manage?appId={$appid}&bundleId=com.alipay.alipaywallet"; return $this->asJson([ 'code' => 0, 'msg' => '添加成功', 'data' => [ 'link' => $link, ], ]); } }