| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\client\models\v1;
- use app\models\AggregateQrcode;
- use app\models\Option;
- use app\models\WechatConfig;
- use EasyWeChat\Factory;
- use yii\base\Model;
- class AggregateQrcodeForm extends Model
- {
- public $id;
- public $store_id;
- //获取支付宝配置信息
- public function rules()
- {
- return [
- [["id", "store_id"],'integer']
- ];
- }
- public function AliConfig(){
- $qrcode = AggregateQrcode::findOne($this->id);
- //支付宝配置
- $value = Option::get(Option::OPTOPN_KEY, $qrcode->store_id, 'alipay');
- $ali_config = json_decode($value['value'],true);
- $url = "https://ds.alipay.com/?scheme=".urlencode("alipays://platformapi/startapp?appId={$ali_config['app_id']}&page={$qrcode->ali_url}&query=id=").$this->id;
- return [
- 'code'=>0,
- 'msg'=>"获取成功",
- 'data'=>[
- 'url'=>$url
- ]
- ];
- }
- //获取微信配置信息
- public function wxConfig(){
- $qrcode = AggregateQrcode::findOne($this->id);
- $wechatConfig = WechatConfig::find()->where(['store_id' => $qrcode->store_id])->select('id,store_id,app_id,app_secret,gh_id')->asArray()->one();
- $config = [
- 'app_id' => $wechatConfig['app_id'],
- 'secret' => $wechatConfig['app_secret'],
- 'response_type' => 'array',
- ];
- $app = Factory::officialAccount($config);
- $wxConfig = $app->jssdk->buildConfig([], $debug = false, $beta = false, $json = true);
- $wxConfig = json_encode($wxConfig);
- $wxConfig['gh_id'] = $wechatConfig['gh_id'];
- return [
- 'code'=>0,
- 'msg'=>"获取成功",
- 'data'=>$wxConfig
- ];
- }
- }
|