asJson([ 'code' => 1, 'msg' => '请先配置服务商设置应用appid', ]); } $appid = Option::get('ali_template_appid', 0, 'saas')['value'] ?? ''; $ali_template_store_id = Option::get('ali_template_store_id', 0, 'saas')['value'] ?? ''; $ali_template_mini_id = Option::get('ali_template_mini_id', 0, 'saas')['value'] ?? ''; if (empty($appid)) { return $this->asJson([ 'code' => 1, 'msg' => '请先配置三方平台支付宝模板appid', ]); } $url = $this->url . 'template/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' => [ 'store_id' => $ali_template_store_id, 'mini_id' => $ali_template_mini_id, 'appid' => $appid, 'http_url' => $host, 'version' => cyy_version(), 'ws_url' => $ws_url, 'shopId' => $alipay_appid, ] ]); 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); $appid = Option::get('ali_template_appid', 0, 'saas')['value'] ?? ''; if (empty($appid)) { return $this->asJson([ 'code' => 1, 'msg' => '请先配置三方平台支付宝模板appid', ]); } $url = $this->url . 'template/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(), ], 'timeout' => 500, ]); if ($res->getStatusCode() != 200) { return $this->asJson([ 'code' => 1, 'msg' => '请求出错!', ]); } $content = json_decode((string)$res->getBody()); return $this->asJson($content); } public function actionAddTemplate() { $alipay_appid = Option::get('alipay_appid', 0, 'saas')['value'] ?? ''; $appid = Option::get('ali_template_appid', 0, 'saas')['value'] ?? ''; $link = "https://open.alipay.com/develop/isv/sub/template/detail?appId={$alipay_appid}&templateId={$appid}&bundleId=com.alipay.alipaywallet"; return $this->asJson([ 'code' => 0, 'msg' => '添加成功', 'data' => [ 'link' => $link, ], ]); } }