创建版本

This commit is contained in:
2021-02-22 12:17:00 +08:00
commit af555f49c3
2332 changed files with 369202 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
<?php namespace Gdoo\Wechat\Services;
use Cache;
class MenuService
{
public function GetTreeByMenu($list, $id = 'id', $pid = 'pid', $son = 'sub')
{
$tree = $map = [];
foreach ($list as $item) {
$map[$item[$id]] = $item;
}
foreach ($list as $item) {
if (isset($item[$pid]) && isset($map[$item[$pid]])) {
$map[$item[$pid]][$son][] = &$map[$item[$id]];
} else {
$tree[] = &$map[$item[$id]];
}
}
unset($map);
return $tree;
}
}
@@ -0,0 +1,39 @@
<?php namespace Gdoo\Wechat\Services;
use Cache;
use Gdoo\System\Models\Setting;
use EasyWeChat\Factory;
class WechatService
{
public static function getApp()
{
static $app = null;
if ($app == null) {
$config = static::getConfig();
$app = Factory::officialAccount([
'app_id' => $config['wechat_appid'],
'secret' => $config['wechat_secret'],
'token' => $config['wechat_token'],
'aes_key' => $config['wechat_aeskey'],
'response_type' => 'array',
'log' => [
'level' => 'debug',
'file' => storage_path().'/logs/wechat.log',
],
]);
}
return $app;
}
public static function getConfig()
{
static $config = null;
if ($config == null) {
$config = Setting::where('type', 'wechat')->pluck('value', 'key');
}
return $config;
}
}