123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace App\Http\Api;
- use Alipay\EasySDK\Kernel\Config;
- use App\Services\Login\LoginTokenService;
- use App\Services\OrderService\ComboOrderService;
- use App\Services\OrderService\GoodsOrderService;
- use App\Traits\CommonTrait;
- use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
- use Illuminate\Foundation\Bus\DispatchesJobs;
- use Illuminate\Foundation\Validation\ValidatesRequests;
- use Illuminate\Routing\Controller as BaseController;
- class HttpBaseController extends BaseController
- {
- use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
- use CommonTrait;
- /**
- * 登录的token名称
- *
- * @var string
- */
- public string $sanctumTokenName = 'api';
- /**
- * @var array
- */
- public array $seoData = [
- 'title' => '',
- 'keywords' => '',
- 'description' => '【】。',
- ];
- public function __construct()
- {
- }
- /**
- * 判断该用户是否已经登录
- */
- public function isLoginJson()
- {
- $loginToken = new LoginTokenService('user_access_token');
- $this->tokenInfo = $loginToken->checkLogin();
- if (empty($this->tokenInfo)) {
- abort(401, '你还没有登录,请登录!');
- } else {
- $this->userId = $this->tokenInfo->user_id;
- }
- }
- public function getOptions()
- {
- $configArr = config('alipay');
- $options = new Config();
- $options->protocol = 'https';
- $options->gatewayHost = 'openapi.alipay.com';
- $options->signType = 'RSA2';
- $options->appId = $configArr['app_id'];
- // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
- $options->merchantPrivateKey = $configArr['private_key'];
- $options->alipayCertPath = $configArr['alipay_cert_public_key_rsa2'];//'<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->';
- $options->alipayRootCertPath = $configArr['alipay_root_cert'];//'<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt" -->';
- $options->merchantCertPath = $configArr['app_cert_public_key'];//'<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->';
- //注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
- $options->alipayPublicKey = $configArr['ali_public_key'];
- //可设置异步通知接收服务地址(可选)
- $options->notifyUrl = $configArr['notify_url'];
- //可设置AES密钥,调用AES加解密相关接口时需要(可选)
- // $options->encryptKey = "<-- 请填写您的AES密钥,例如:aa4BtZ4tspm2wnXLb1ThQA== -->";
- return $options;
- }
- /**
- * 判断是否是测试环境
- *
- * @return bool
- */
- public function isTest()
- {
- $url = \request()->getHttpHost();
- if ($url == 'www.yososoft.me' || $url == 'audio.yososoft.me' || $url == 'audio.zhuyou360.com') {
- return $url;
- } else {
- return false;
- }
- }
- }
|