fixed conflict
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
namespace catcher;
|
||||
|
||||
use catcher\command\TestCommand;
|
||||
use catcher\command\publish\WechatCommand;
|
||||
use catcher\command\Tools\BackupCommand;
|
||||
use catcher\command\Tools\CompressPackageCommand;
|
||||
use catcher\command\CreateModuleCommand;
|
||||
@@ -70,8 +70,8 @@ class CatchAdminService extends Service
|
||||
WsWorkerCommand::class,
|
||||
ExportDataCommand::class,
|
||||
MakeMenuCommand::class,
|
||||
TestCommand::class,
|
||||
ExcelTaskCommand::class,
|
||||
WechatCommand::class
|
||||
]);
|
||||
}
|
||||
/**
|
||||
|
164
extend/catcher/command/publish/WechatCommand.php
Normal file
164
extend/catcher/command/publish/WechatCommand.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename WechatCommand.php
|
||||
* @date 2020/6/6
|
||||
* @project https://github.com/yanwenwu/catch-admin
|
||||
* @document http://doc.catchadmin.com
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @copyright By CatchAdmin
|
||||
* @license https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt
|
||||
*/
|
||||
namespace catcher\command\publish;
|
||||
|
||||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\input\Option;
|
||||
use think\console\Output;
|
||||
use catcher\CatchAdmin;
|
||||
|
||||
class WechatCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('publish:wechat')
|
||||
->setDescription('publish wechat config');
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
file_put_contents(config_path() . 'wechat.php', $this->config());
|
||||
|
||||
$this->env();
|
||||
|
||||
$output->warning('wechat publish successfully');
|
||||
}
|
||||
|
||||
protected function config()
|
||||
{
|
||||
return <<<CONFIG
|
||||
<?php
|
||||
|
||||
return [
|
||||
/**
|
||||
* 公众号配置
|
||||
*
|
||||
*/
|
||||
'official_account' => [
|
||||
/**
|
||||
* 账号基本信息,请从微信公众平台/开放平台获取
|
||||
*/
|
||||
'app_id' => env('wechat.official_app_id'), // AppID
|
||||
'secret' => env('wechat.official_secret'), // AppSecret
|
||||
'token' => env('wechat.official_token'), // Token
|
||||
'aes_key' => env('wechat.official_aes_key'), // EncodingAESKey,兼容与安全模式下请一定要填写!!!
|
||||
|
||||
'response_type' => 'array',
|
||||
|
||||
/**
|
||||
* OAuth 配置
|
||||
*
|
||||
* scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login
|
||||
* callback:OAuth授权完成后的回调页地址
|
||||
*/
|
||||
'oauth' => [
|
||||
'scopes' => ['snsapi_userinfo'],
|
||||
'callback' => '/examples/oauth_callback.php',
|
||||
],
|
||||
],
|
||||
|
||||
/**
|
||||
* 小程序
|
||||
*/
|
||||
'mini_program' => [
|
||||
// 更多配置查看 https://www.easywechat.com/docs/master/mini-program/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 开放平台
|
||||
*/
|
||||
'open_platform' => [
|
||||
// 更多配置查看 https://www.easywechat.com/docs/master/open-platform/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 企业微信
|
||||
*/
|
||||
'work' => [
|
||||
// 更多配置查看 https://www.easywechat.com/docs/master/wework/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 企业微信开放平台
|
||||
*/
|
||||
'open_work' => [
|
||||
// 配置 https://www.easywechat.com/docs/master/open-work/index
|
||||
],
|
||||
|
||||
/**
|
||||
* 小微商户
|
||||
*/
|
||||
'micro_merchant' => [
|
||||
// 配置 https://www.easywechat.com/docs/master/micro-merchant/index
|
||||
],
|
||||
|
||||
/**
|
||||
* wechat pay
|
||||
*/
|
||||
'payment' => [
|
||||
'app_id' => 'xxxx',
|
||||
'mch_id' => 'your-mch-id',
|
||||
'key' => 'key-for-signature', // API 密钥
|
||||
|
||||
// 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
|
||||
'cert_path' => 'path/to/your/cert.pem', // XXX: 绝对路径!!!!
|
||||
'key_path' => 'path/to/your/key', // XXX: 绝对路径!!!!
|
||||
|
||||
'notify_url' => '默认的订单回调地址', // 你也可以在下单时单独设置来想覆盖它
|
||||
],
|
||||
|
||||
// 更多配置请查看 https://www.easywechat.com/docs
|
||||
];
|
||||
CONFIG;
|
||||
}
|
||||
|
||||
protected function env()
|
||||
{
|
||||
$filename = file_exists(root_path() . '.env') ? '.env' : '.example.env';
|
||||
|
||||
|
||||
$env = \parse_ini_file(root_path() . $filename, true);
|
||||
|
||||
$env['WECHAT'] = $this->envConfig();
|
||||
|
||||
$dotEnv = '';
|
||||
|
||||
foreach ($env as $key => $e) {
|
||||
if (is_string($e)) {
|
||||
$dotEnv .= sprintf('%s = %s', $key, $e === '1' ? 'true' : ($e === '' ? 'false' : $e)) . PHP_EOL;
|
||||
$dotEnv .= PHP_EOL;
|
||||
} else {
|
||||
$dotEnv .= sprintf('[%s]', $key) . PHP_EOL;
|
||||
foreach ($e as $k => $v) {
|
||||
$dotEnv .= sprintf('%s = %s', $k, $v === '1' ? 'true' : ($v === '' ? 'false' : $v)) . PHP_EOL;
|
||||
}
|
||||
|
||||
$dotEnv .= PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(root_path() . '.env', $dotEnv);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function envConfig()
|
||||
{
|
||||
return [
|
||||
"official_app_id" => null,
|
||||
"official_secret" => null,
|
||||
"official_token" => null,
|
||||
"official_aes_key" => null,
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
namespace catcher\library;
|
||||
|
||||
use think\helper\Str;
|
||||
|
||||
class ParseClass
|
||||
{
|
||||
@@ -11,6 +10,11 @@ class ParseClass
|
||||
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* 获取父类方法
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function parentMethods()
|
||||
{
|
||||
$class = $this->getClass();
|
||||
@@ -28,7 +32,11 @@ class ParseClass
|
||||
return $methods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有方法
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function methods()
|
||||
{
|
||||
$class = $this->getClass();
|
||||
@@ -63,7 +71,12 @@ class ParseClass
|
||||
return $methods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 CLASS
|
||||
*
|
||||
* @return \ReflectionClass
|
||||
* @throws \ReflectionException
|
||||
*/
|
||||
public function getClass()
|
||||
{
|
||||
|
||||
@@ -72,12 +85,22 @@ class ParseClass
|
||||
ucfirst($this->controller));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $method
|
||||
* @return bool
|
||||
*/
|
||||
protected function isMagicMethod($method)
|
||||
{
|
||||
return strpos($method, '__') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $module
|
||||
* @return $this
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @date 2020/6/6
|
||||
*/
|
||||
public function setModule($module)
|
||||
{
|
||||
$composer = \json_decode(file_get_contents(root_path() . 'composer.json'), true);
|
||||
@@ -94,7 +117,14 @@ class ParseClass
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $module
|
||||
* @param $controller
|
||||
* @return $this
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @date 2020/6/6
|
||||
*/
|
||||
public function setRule($module, $controller)
|
||||
{
|
||||
$this->module = $module;
|
||||
|
35
extend/catcher/library/WeChat.php
Normal file
35
extend/catcher/library/WeChat.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @filename WeChat.php
|
||||
* @date 2020/6/7
|
||||
* @project https://github.com/yanwenwu/catch-admin
|
||||
* @document http://doc.catchadmin.com
|
||||
* @author JaguarJack <njphper@gmail.com>
|
||||
* @copyright By CatchAdmin
|
||||
* @license https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt
|
||||
*/
|
||||
namespace catcher\library;
|
||||
|
||||
use EasyWeChat\Factory;
|
||||
use think\helper\Str;
|
||||
|
||||
/**
|
||||
*
|
||||
* @method static officialAccount()
|
||||
* @method static miniProgram()
|
||||
* @method static openPlatform()
|
||||
* @method static work()
|
||||
* @method static openWork()
|
||||
* @method static payment()
|
||||
*
|
||||
* Class WeChat
|
||||
* @package catcher\library
|
||||
*/
|
||||
class WeChat
|
||||
{
|
||||
public static function __callStatic($name, $arguments)
|
||||
{
|
||||
// TODO: Implement __callStatic() method.
|
||||
return Factory::{$name}(\config('wechat.'. Str::snake($name)));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user