| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers\setting;
- use app\modules\admin\controllers\BaseController;
- use app\models\Option;
- use app\modules\admin\models\WechatThirdForm;
- use app\utils\ShareQrcode;
- use app\utils\Alipay\alipaySdk\aop\request\AlipayOpenAppQrcodeCreateRequest;
- class AlipayUploadController extends BaseController
- {
- private $url = 'http://chidian.we10.cn/';
- /**
- * 获取小程序码
- *
- * @return void
- */
- public function actionQrcode()
- {
- try {
- $request = new AlipayOpenAppQrcodeCreateRequest();
- $param = [
- 'url_param' => '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,
- ],
- ]);
- }
- }
|