137 lines
3.7 KiB
PHP
137 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace addons\epay;
|
|
|
|
use addons\epay\library\Service;
|
|
use addons\epay\library\Hook;
|
|
use think\Addons;
|
|
use think\Config;
|
|
use think\Lang;
|
|
use think\Loader;
|
|
|
|
/**
|
|
* 微信支付宝整合插件
|
|
*/
|
|
class Epay extends Addons
|
|
{
|
|
|
|
/**
|
|
* 插件安装方法
|
|
* @return bool
|
|
*/
|
|
public function install()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 插件卸载方法
|
|
* @return bool
|
|
*/
|
|
public function uninstall()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 插件启用方法
|
|
* @return bool
|
|
*/
|
|
public function enable()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 插件禁用方法
|
|
* @return bool
|
|
*/
|
|
public function disable()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// 支持自定义加载
|
|
public function epayConfigInit()
|
|
{
|
|
$this->actionBegin();
|
|
}
|
|
|
|
// 插件方法加载开始
|
|
public function addonActionBegin()
|
|
{
|
|
$this->actionBegin();
|
|
}
|
|
|
|
// 模块控制器方法加载开始
|
|
public function actionBegin()
|
|
{
|
|
//添加命名空间
|
|
if (!class_exists('\Yansongda\Pay\Pay')) {
|
|
|
|
//SDK版本
|
|
$version = Service::getSdkVersion();
|
|
|
|
$libraryDir = ADDON_PATH . 'epay' . DS . 'library' . DS;
|
|
Loader::addNamespace('Yansongda\Pay', $libraryDir . $version . DS . 'Yansongda' . DS . 'Pay' . DS);
|
|
|
|
$checkArr = [
|
|
'\Hyperf\Context\Context' => 'context',
|
|
'\Hyperf\Contract\Castable' => 'contract',
|
|
'\Hyperf\Engine\Constant' => 'engine',
|
|
'\Hyperf\Macroable\Macroable' => 'macroable',
|
|
'\Hyperf\Pimple\Container' => 'pimple',
|
|
'\Hyperf\Utils\Arr' => 'utils',
|
|
];
|
|
foreach ($checkArr as $index => $item) {
|
|
if (!class_exists($index)) {
|
|
Loader::addNamespace(substr($index, 1, strrpos($index, '\\') - 1), $libraryDir . 'hyperf' . DS . $item . DS . 'src' . DS);
|
|
}
|
|
}
|
|
|
|
if (!class_exists('\Yansongda\Supports\Logger')) {
|
|
Loader::addNamespace('Yansongda\Supports', $libraryDir . $version . DS . 'Yansongda' . DS . 'Supports' . DS);
|
|
}
|
|
|
|
// V3需载入辅助函数
|
|
if ($version == Service::SDK_VERSION_V3) {
|
|
require_once $libraryDir . $version . DS . 'Yansongda' . DS . 'Pay' . DS . 'Functions.php';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 应用初始化
|
|
*/
|
|
public function appInit()
|
|
{
|
|
// 公共方法
|
|
require_once __DIR__ . '/helper/helper.php';
|
|
if(!class_exists('\QRcode')){
|
|
require_once __DIR__ .'/library/phpqrcode.php';
|
|
}
|
|
// //全局事件注册
|
|
Hook::register();
|
|
//加载语言包
|
|
Lang::load(glob(APP_PATH. '/api/lang/zh-cn/*/*'));
|
|
//加载第三方类库
|
|
if(!class_exists('\WeChat\Pay')){
|
|
\think\Loader::addNamespace('WeChat',ADDON_PATH . 'epay' . DS . 'library' . DS . 'zoujingli' . DS . 'wechat-developer' . DS . 'WeChat' . DS);
|
|
}
|
|
if(!class_exists('WeMini\Crypt')){
|
|
\think\Loader::addNamespace('WeMini',ADDON_PATH . 'epay' . DS . 'library' . DS . 'zoujingli' . DS . 'wechat-developer' . DS . 'WeMini' . DS);
|
|
}
|
|
if(!class_exists('WePay\Order')){
|
|
\think\Loader::addNamespace('WePay',ADDON_PATH . 'epay' . DS . 'library' . DS . 'zoujingli' . DS . 'wechat-developer' . DS . 'WePay' . DS);
|
|
}
|
|
if(!class_exists('WePayV3\Order')){
|
|
\think\Loader::addNamespace('WePayV3',ADDON_PATH . 'epay' . DS . 'library' . DS . 'zoujingli' . DS . 'wechat-developer' . DS . 'WePayV3' . DS);
|
|
}
|
|
}
|
|
|
|
|
|
}
|