67 lines
1.1 KiB
PHP
67 lines
1.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\common\service\pay;
|
|
|
|
use app\common\model\user\UserAuth;
|
|
use Webman\Config;
|
|
use Yansongda\Pay\Pay;
|
|
|
|
/**
|
|
* 支付
|
|
* Class PayService
|
|
* @package app\common\server
|
|
*/
|
|
class PayService extends BasePayService
|
|
{
|
|
/**
|
|
* 授权信息
|
|
* @var UserAuth|array|\think\Model
|
|
*/
|
|
protected $auth;
|
|
|
|
|
|
/**
|
|
* Pay配置
|
|
* @var
|
|
*/
|
|
public $config;
|
|
|
|
|
|
/**
|
|
* Pay实例
|
|
* @var
|
|
*/
|
|
public $wechat;
|
|
public $alipay;
|
|
|
|
|
|
/**
|
|
* 当前使用客户端
|
|
* @var
|
|
*/
|
|
protected $terminal;
|
|
|
|
|
|
/**
|
|
* 初始化微信支付配置
|
|
* @param $terminal //用户终端
|
|
* @param null $userId //用户id(获取授权openid)
|
|
*/
|
|
public function __construct($terminal=0, $userId = null)
|
|
{
|
|
$this->terminal = $terminal;
|
|
$config = Config::get('payment');
|
|
Pay::config($config);
|
|
if ($userId !== null) {
|
|
$this->auth = UserAuth::where(['user_id' => $userId, 'terminal' => $terminal])->findOrEmpty();
|
|
}
|
|
$this->wechat=Pay::wechat();
|
|
$this->alipay=Pay::alipay();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |