- 框架初始化
 - 安装插件
 - 修复PHP8.4报错
This commit is contained in:
2025-04-19 17:21:20 +08:00
commit c6a4e1f5f6
5306 changed files with 967782 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
namespace addons\shopro\facade;
use addons\shopro\library\activity\Activity as ActivityManager;
use app\admin\model\shopro\activity\Activity as ActivityModel;
/**
* @see RedisManager
*
*/
class Activity extends Base
{
public static function getFacadeClass()
{
if (!isset($GLOBALS['SPACTIVITY'])) {
$GLOBALS['SPACTIVITY'] = new ActivityManager(ActivityModel::class);
}
return $GLOBALS['SPACTIVITY'];
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace addons\shopro\facade;
use addons\shopro\library\activity\ActivityRedis as ActivityRedisManager;
/**
* @see RedisManager
*
*/
class ActivityRedis extends Base
{
public static function getFacadeClass()
{
if (!isset($GLOBALS['SPACTIVITYREDIS'])) {
$GLOBALS['SPACTIVITYREDIS'] = new ActivityRedisManager();
}
return $GLOBALS['SPACTIVITYREDIS'];
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace addons\shopro\facade;
/**
* @see RedisManager
*
*/
class Base
{
public static function getFacadeClass()
{
error_stop('facade 初始化失败');
}
public static function instance()
{
return static::getFacadeClass();
}
public static function __callStatic($funcname, $arguments)
{
return static::instance()->{$funcname}(...$arguments);
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace addons\shopro\facade;
use addons\shopro\library\HttpClient as HttpClientManager;
/**
* @see HttpClientManager
*
*/
class HttpClient extends Base
{
public static function getFacadeClass()
{
if (!isset($GLOBALS['SPHTTPCLIENT'])) {
$GLOBALS['SPHTTPCLIENT'] = new HttpClientManager();
}
return $GLOBALS['SPHTTPCLIENT'];
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace addons\shopro\facade;
use addons\shopro\library\Redis as RedisManager;
/**
* @see RedisManager
*
*/
class Redis extends Base
{
public static function getFacadeClass()
{
if (!isset($GLOBALS['SPREDIS'])) {
$GLOBALS['SPREDIS'] = (new RedisManager())->getRedis();
}
return $GLOBALS['SPREDIS'];
}
}

View File

@@ -0,0 +1,150 @@
<?php
namespace addons\shopro\facade;
use think\Cache;
class Wechat extends Base
{
public static function getFacadeClass()
{
return self::officialAccount(); // 默认是公众号
}
/**
* 公众号
*
* @return \EasyWeChat\OfficialAccount\Application
*/
public static function officialAccount()
{
if (isset($GLOBALS['WECHAT']['OFFICIALACCOUNT'])) {
return $GLOBALS['WECHAT']['OFFICIALACCOUNT'];
}
$defaultConfig = self::defaultConfig();
$officialAccount = sheep_config('shop.platform.WechatOfficialAccount', false);
$config = array_merge($defaultConfig, [
'app_id' => $officialAccount['app_id'],
'secret' => $officialAccount['secret'],
]);
$app = new \EasyWeChat\OfficialAccount\Application($config);
$GLOBALS['WECHAT']['OFFICIALACCOUNT'] = $app;
return $GLOBALS['WECHAT']['OFFICIALACCOUNT'];
}
/**
* 公众号管理
*
* @return \EasyWeChat\OfficialAccount\Application
*/
public static function officialAccountManage()
{
if (isset($GLOBALS['WECHAT']['OFFICIALACCOUNT_MANAGE'])) {
return $GLOBALS['WECHAT']['OFFICIALACCOUNT_MANAGE'];
}
$defaultConfig = self::defaultConfig();
$officialAccount = sheep_config('wechat.officialAccount', false);
$config = array_merge($defaultConfig, [
'app_id' => $officialAccount['app_id'],
'secret' => $officialAccount['secret'],
'token' => $officialAccount['token'],
'aes_key' => $officialAccount['aes_key'],
]);
$app = new \EasyWeChat\OfficialAccount\Application($config);
$GLOBALS['WECHAT']['OFFICIALACCOUNT_MANAGE'] = $app;
return $GLOBALS['WECHAT']['OFFICIALACCOUNT_MANAGE'];
}
/**
* 小程序
*
* @return \EasyWeChat\MiniProgram\Application
*/
public static function miniProgram()
{
if (isset($GLOBALS['WECHAT']['MINIPROGRAM'])) {
return $GLOBALS['WECHAT']['MINIPROGRAM'];
}
$defaultConfig = self::defaultConfig();
$miniProgram = sheep_config('shop.platform.WechatMiniProgram', false);
$config = array_merge($defaultConfig, [
'app_id' => $miniProgram['app_id'],
'secret' => $miniProgram['secret'],
]);
$app = new \EasyWeChat\MiniProgram\Application($config);
$GLOBALS['WECHAT']['MINIPROGRAM'] = $app;
return $GLOBALS['WECHAT']['MINIPROGRAM'];
}
/**
* 小程序
*
* @return \EasyWeChat\OpenPlatform\Application
*/
public static function openPlatform()
{
if (isset($GLOBALS['WECHAT']['OPENPLATFORM'])) {
return $GLOBALS['WECHAT']['OPENPLATFORM'];
}
$defaultConfig = self::defaultConfig();
$openPlatform = sheep_config('shop.platform.App', false);
$config = array_merge($defaultConfig, [
'app_id' => $openPlatform['app_id'],
'secret' => $openPlatform['secret'],
]);
$app = new \EasyWeChat\OpenPlatform\Application($config);
$GLOBALS['WECHAT']['OPENPLATFORM'] = $app;
return $GLOBALS['WECHAT']['OPENPLATFORM'];
}
protected static function defaultConfig () {
return [
'response_type' => 'array',
// 日志配置 level: 日志级别, 可选为debug/info/notice/warning/error/critical/alert/emergency path日志文件位置(绝对路径!!!),要求可写权限
'log' => [
'default' => config('app_debug') ? 'dev' : 'prod', // 默认使用的 channel生产环境可以改为下面的 prod
'channels' => [
// 测试环境
'dev' => [
'driver' => 'single',
'path' => RUNTIME_PATH . 'log/wechat/easywechat-dev.log',
'level' => 'debug',
],
// 生产环境
'prod' => [
'driver' => 'daily',
'path' => RUNTIME_PATH . 'log/wechat/easywechat-prod.log',
'level' => 'info',
]
]
],
'http' => [
'connect_timeout' => 5,
'max_retries' => 1,
'retry_delay' => 500,
'timeout' => 5,
'verify' => ROOT_PATH . 'addons/shopro/library/cacert.pem',
// 'base_uri' => 'https://api.weixin.qq.com/', // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
],
];
}
}