mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-04-29 20:18:13 +08:00
fix: 同步更新主库的代码
This commit is contained in:
parent
7201fcdb8a
commit
25aec0cf8a
@ -1,47 +1,47 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin;
|
||||
|
||||
use think\admin\Plugin;
|
||||
|
||||
/**
|
||||
* 插件服务注册
|
||||
* 插件服务注册.
|
||||
* @class Service
|
||||
* @package app\admin
|
||||
*/
|
||||
class Service extends Plugin
|
||||
{
|
||||
/**
|
||||
* 定义插件名称
|
||||
* 定义插件名称.
|
||||
* @var string
|
||||
*/
|
||||
protected $appName = '系统管理';
|
||||
|
||||
/**
|
||||
* 定义安装包名
|
||||
* 定义安装包名.
|
||||
* @var string
|
||||
*/
|
||||
protected $package = 'zoujingli/think-plugs-admin';
|
||||
|
||||
/**
|
||||
* 定义插件中心菜单
|
||||
* @return array
|
||||
* 定义插件中心菜单.
|
||||
*/
|
||||
public static function menu(): array
|
||||
{
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
@ -24,21 +26,23 @@ use think\admin\model\SystemAuth;
|
||||
use think\admin\model\SystemNode;
|
||||
use think\admin\Plugin;
|
||||
use think\admin\service\AdminService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统权限管理
|
||||
* 系统权限管理.
|
||||
* @class Auth
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Auth extends Controller
|
||||
{
|
||||
/**
|
||||
* 系统权限管理
|
||||
* 系统权限管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -62,7 +66,7 @@ class Auth extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统权限
|
||||
* 删除系统权限.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
@ -70,9 +74,8 @@ class Auth extends Controller
|
||||
SystemAuth::mDelete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加系统权限
|
||||
* 添加系统权限.
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
@ -81,7 +84,7 @@ class Auth extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统权限
|
||||
* 编辑系统权限.
|
||||
* @auth true
|
||||
*/
|
||||
public function edit()
|
||||
@ -90,24 +93,29 @@ class Auth extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单后置数据处理
|
||||
* @param array $data
|
||||
* 表单后置数据处理.
|
||||
*/
|
||||
protected function _form_filter(array $data)
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->title = empty($data['title']) ? "添加访问授权" : "编辑【{$data['title']}】授权";
|
||||
$this->title = empty($data['title']) ? '添加访问授权' : "编辑【{$data['title']}】授权";
|
||||
} elseif ($this->request->post('action') === 'json') {
|
||||
if ($this->app->isDebug()) AdminService::clear();
|
||||
if ($this->app->isDebug()) {
|
||||
AdminService::clear();
|
||||
}
|
||||
$ztree = AdminService::getTree(empty($data['id']) ? [] : SystemNode::mk()->where(['auth' => $data['id']])->column('node'));
|
||||
usort($ztree, static function ($a, $b) {
|
||||
if (explode('-', $a['node'])[0] !== explode('-', $b['node'])[0]) {
|
||||
if (stripos($a['node'], 'plugin-') === 0) return 1;
|
||||
if (stripos($a['node'], 'plugin-') === 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return $a['node'] === $b['node'] ? 0 : ($a['node'] > $b['node'] ? 1 : -1);
|
||||
});
|
||||
[$ps, $cs] = [Plugin::get(), (array)$this->app->config->get('app.app_names', [])];
|
||||
foreach ($ztree as &$n) $n['title'] = lang($cs[$n['node']] ?? (($ps[$n['node']] ?? [])['name'] ?? $n['title']));
|
||||
foreach ($ztree as &$n) {
|
||||
$n['title'] = lang($cs[$n['node']] ?? (($ps[$n['node']] ?? [])['name'] ?? $n['title']));
|
||||
}
|
||||
$this->success('获取权限节点成功!', $ztree);
|
||||
} elseif (empty($data['nodes'])) {
|
||||
$this->error('未配置功能节点!');
|
||||
@ -115,16 +123,15 @@ class Auth extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点更新处理
|
||||
* @param boolean $state
|
||||
* @param array $post
|
||||
* @return void
|
||||
* 节点更新处理.
|
||||
*/
|
||||
protected function _form_result(bool $state, array $post)
|
||||
{
|
||||
if ($state && $this->request->post('action') === 'save') {
|
||||
[$map, $data] = [['auth' => $post['id']], []];
|
||||
foreach ($post['nodes'] ?? [] as $node) $data[] = $map + ['node' => $node];
|
||||
foreach ($post['nodes'] ?? [] as $node) {
|
||||
$data[] = $map + ['node' => $node];
|
||||
}
|
||||
SystemNode::mk()->where($map)->delete();
|
||||
count($data) > 0 && SystemNode::mk()->insertAll($data);
|
||||
sysoplog('系统权限管理', "配置系统权限[{$map['auth']}]授权成功");
|
||||
|
||||
@ -1,41 +1,45 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\model\SystemBase;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 数据字典管理
|
||||
* 数据字典管理.
|
||||
* @class Base
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Base extends Controller
|
||||
{
|
||||
/**
|
||||
* 数据字典管理
|
||||
* 数据字典管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -50,7 +54,7 @@ class Base extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据字典
|
||||
* 添加数据字典.
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
@ -59,7 +63,7 @@ class Base extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑数据字典
|
||||
* 编辑数据字典.
|
||||
* @auth true
|
||||
*/
|
||||
public function edit()
|
||||
@ -67,29 +71,6 @@ class Base extends Controller
|
||||
SystemBase::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->types = SystemBase::types();
|
||||
$this->types[] = '--- ' . lang('新增类型') . ' ---';
|
||||
$this->type = $this->get['type'] ?? ($this->types[0] ?? '-');
|
||||
} else {
|
||||
$map = [];
|
||||
$map[] = ['deleted', '=', 0];
|
||||
$map[] = ['code', '=', $data['code']];
|
||||
$map[] = ['type', '=', $data['type']];
|
||||
$map[] = ['id', '<>', $data['id'] ?? 0];
|
||||
if (SystemBase::mk()->where($map)->count() > 0) {
|
||||
$this->error("数据编码已经存在!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据状态
|
||||
* @auth true
|
||||
@ -103,11 +84,33 @@ class Base extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据记录
|
||||
* 删除数据记录.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
SystemBase::mDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据处理.
|
||||
* @throws DbException
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->types = SystemBase::types();
|
||||
$this->types[] = '--- ' . lang('新增类型') . ' ---';
|
||||
$this->type = $this->get['type'] ?? ($this->types[0] ?? '-');
|
||||
} else {
|
||||
$map = [];
|
||||
$map[] = ['deleted', '=', 0];
|
||||
$map[] = ['code', '=', $data['code']];
|
||||
$map[] = ['type', '=', $data['type']];
|
||||
$map[] = ['id', '<>', $data['id'] ?? 0];
|
||||
if (SystemBase::mk()->where($map)->count() > 0) {
|
||||
$this->error('数据编码已经存在!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
@ -30,13 +32,12 @@ use think\admin\storage\QiniuStorage;
|
||||
use think\admin\storage\TxcosStorage;
|
||||
|
||||
/**
|
||||
* 系统参数配置
|
||||
* 系统参数配置.
|
||||
* @class Config
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Config extends Controller
|
||||
{
|
||||
const themes = [
|
||||
public const themes = [
|
||||
'default' => '默认色0',
|
||||
'white' => '简约白0',
|
||||
'red-1' => '玫瑰红1',
|
||||
@ -50,7 +51,7 @@ class Config extends Controller
|
||||
];
|
||||
|
||||
/**
|
||||
* 系统参数配置
|
||||
* 系统参数配置.
|
||||
* @auth true
|
||||
* @menu true
|
||||
*/
|
||||
@ -68,14 +69,16 @@ class Config extends Controller
|
||||
$this->showErrorMessage = lang("超级管理员账号的密码未修改,建议立即<a data-modal='%s'>修改密码</a>!", [$url]);
|
||||
}
|
||||
uasort($this->plugins, static function ($a, $b) {
|
||||
if ($a['space'] === $b['space']) return 0;
|
||||
if ($a['space'] === $b['space']) {
|
||||
return 0;
|
||||
}
|
||||
return $a['space'] > $b['space'] ? 1 : -1;
|
||||
});
|
||||
$this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改系统参数
|
||||
* 修改系统参数.
|
||||
* @auth true
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
@ -100,20 +103,24 @@ class Config extends Controller
|
||||
RuntimeService::set(null, [$post['xpath'] => 'admin']);
|
||||
}
|
||||
// 修改网站 ICON 图标,替换 public/favicon.ico
|
||||
if (preg_match('#^https?://#', $post['site_icon'] ?? '')) try {
|
||||
if (preg_match('#^https?://#', $post['site_icon'] ?? '')) {
|
||||
try {
|
||||
SystemService::setFavicon($post['site_icon'] ?? '');
|
||||
} catch (\Exception $exception) {
|
||||
trace_file($exception);
|
||||
}
|
||||
}
|
||||
// 数据数据到系统配置表
|
||||
foreach ($post as $k => $v) sysconf($k, $v);
|
||||
sysoplog('系统配置管理', "修改系统参数成功");
|
||||
foreach ($post as $k => $v) {
|
||||
sysconf($k, $v);
|
||||
}
|
||||
sysoplog('系统配置管理', '修改系统参数成功');
|
||||
$this->success('数据保存成功!', admuri('admin/config/index'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件存储
|
||||
* 修改文件存储.
|
||||
* @auth true
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
@ -135,11 +142,15 @@ class Config extends Controller
|
||||
if (!empty($post['storage']['allow_exts'])) {
|
||||
$deny = ['sh', 'asp', 'bat', 'cmd', 'exe', 'php'];
|
||||
$exts = array_unique(str2arr(strtolower($post['storage']['allow_exts'])));
|
||||
if (count(array_intersect($deny, $exts)) > 0) $this->error('禁止上传可执行的文件!');
|
||||
if (count(array_intersect($deny, $exts)) > 0) {
|
||||
$this->error('禁止上传可执行的文件!');
|
||||
}
|
||||
$post['storage']['allow_exts'] = join(',', $exts);
|
||||
}
|
||||
foreach ($post as $name => $value) sysconf($name, $value);
|
||||
sysoplog('系统配置管理', "修改系统存储参数");
|
||||
foreach ($post as $name => $value) {
|
||||
sysconf($name, $value);
|
||||
}
|
||||
sysoplog('系统配置管理', '修改系统存储参数');
|
||||
$this->success('修改文件存储成功!');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
@ -23,36 +25,29 @@ use think\admin\helper\QueryHelper;
|
||||
use think\admin\model\SystemFile;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\Storage;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统文件管理
|
||||
* 系统文件管理.
|
||||
* @class File
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class File extends Controller
|
||||
{
|
||||
/**
|
||||
* 存储类型
|
||||
* 存储类型.
|
||||
* @var array
|
||||
*/
|
||||
protected $types;
|
||||
|
||||
/**
|
||||
* 控制器初始化
|
||||
* @return void
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->types = Storage::types();
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统文件管理
|
||||
* 系统文件管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -66,21 +61,8 @@ class File extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表处理
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function _page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['ctype'] = $this->types[$vo['type']] ?? $vo['type'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统文件
|
||||
* 编辑系统文件.
|
||||
* @auth true
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
@ -88,9 +70,8 @@ class File extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统文件
|
||||
* 删除系统文件.
|
||||
* @auth true
|
||||
* @return void
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
@ -101,10 +82,9 @@ class File extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理重复文件
|
||||
* 清理重复文件.
|
||||
* @auth true
|
||||
* @return void
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws DbException
|
||||
*/
|
||||
public function distinct()
|
||||
{
|
||||
@ -117,4 +97,22 @@ class File extends Controller
|
||||
})->delete();
|
||||
$this->success('清理重复文件成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 控制器初始化.
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
$this->types = Storage::types();
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据列表处理.
|
||||
*/
|
||||
protected function _page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['ctype'] = $this->types[$vo['type']] ?? $vo['type'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,39 +1,46 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\admin\Controller;
|
||||
use think\admin\Exception;
|
||||
use think\admin\model\SystemUser;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\MenuService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 后台界面入口
|
||||
* 后台界面入口.
|
||||
* @class Index
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Index extends Controller
|
||||
{
|
||||
/**
|
||||
* 显示后台首页
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* 显示后台首页.
|
||||
* @throws Exception
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -55,10 +62,9 @@ class Index extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台主题切换
|
||||
* 后台主题切换.
|
||||
* @login true
|
||||
* @return void
|
||||
* @throws \think\admin\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theme()
|
||||
{
|
||||
@ -77,7 +83,7 @@ class Index extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户资料
|
||||
* 修改用户资料.
|
||||
* @login true
|
||||
*/
|
||||
public function info()
|
||||
@ -90,34 +96,12 @@ class Index extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资料修改表单处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _info_form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
unset($data['username'], $data['authorize']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资料修改结果处理
|
||||
* @param bool $status
|
||||
*/
|
||||
protected function _info_form_result(bool $status)
|
||||
{
|
||||
if ($status) {
|
||||
$this->success('用户资料修改成功!', 'javascript:location.reload()');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改当前用户密码
|
||||
* @login true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function pass()
|
||||
{
|
||||
@ -136,7 +120,9 @@ class Index extends Controller
|
||||
'password.confirm:repassword' => '两次输入的密码不一致!',
|
||||
]);
|
||||
$user = SystemUser::mk()->find($id);
|
||||
if (empty($user)) $this->error('用户不存在!');
|
||||
if (empty($user)) {
|
||||
$this->error('用户不存在!');
|
||||
}
|
||||
if (md5($data['oldpassword']) !== $user['password']) {
|
||||
$this->error('旧密码验证失败,请重新输入!');
|
||||
}
|
||||
@ -144,7 +130,7 @@ class Index extends Controller
|
||||
sysoplog('系统用户管理', "修改用户[{$user['id']}]密码成功");
|
||||
// 修改密码同步事件处理
|
||||
$this->app->event->trigger('PluginAdminChangePassword', [
|
||||
'uuid' => intval($user['id']), 'pass' => $data['password']
|
||||
'uuid' => intval($user['id']), 'pass' => $data['password'],
|
||||
]);
|
||||
$this->success('密码修改成功,下次请使用新密码登录!', '');
|
||||
} else {
|
||||
@ -152,4 +138,24 @@ class Index extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资料修改表单处理.
|
||||
*/
|
||||
protected function _info_form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
unset($data['username'], $data['authorize']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 资料修改结果处理.
|
||||
*/
|
||||
protected function _info_form_result(bool $status)
|
||||
{
|
||||
if ($status) {
|
||||
$this->success('用户资料修改成功!', 'javascript:location.reload()');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,24 +1,27 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\admin\Controller;
|
||||
use think\admin\Exception;
|
||||
use think\admin\extend\CodeExtend;
|
||||
use think\admin\model\SystemUser;
|
||||
use think\admin\service\AdminService;
|
||||
@ -27,17 +30,14 @@ use think\admin\service\RuntimeService;
|
||||
use think\admin\service\SystemService;
|
||||
|
||||
/**
|
||||
* 用户登录管理
|
||||
* 用户登录管理.
|
||||
* @class Login
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Login extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 后台登录入口
|
||||
* @return void
|
||||
* @throws \think\admin\Exception
|
||||
* 后台登录入口.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -54,10 +54,12 @@ class Login extends Controller
|
||||
$this->runtimeMode = RuntimeService::check();
|
||||
// 后台背景处理
|
||||
$images = str2arr(sysconf('login_image|raw') ?: '', '|');
|
||||
if (empty($images)) $images = [
|
||||
if (empty($images)) {
|
||||
$images = [
|
||||
SystemService::uri('/static/theme/img/login/bg1.jpg'),
|
||||
SystemService::uri('/static/theme/img/login/bg2.jpg'),
|
||||
];
|
||||
}
|
||||
$this->loginStyle = sprintf('style="background-image:url(%s)" data-bg-transition="%s"', $images[0], join(',', $images));
|
||||
// 更新后台主域名,用于部分无法获取域名的场景调用
|
||||
if ($this->request->domain() !== sysconf('base.site_host|raw')) {
|
||||
@ -108,7 +110,6 @@ class Login extends Controller
|
||||
|
||||
/**
|
||||
* 生成验证码
|
||||
* @return void
|
||||
*/
|
||||
public function captcha()
|
||||
{
|
||||
@ -126,8 +127,7 @@ class Login extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @return void
|
||||
* 退出登录.
|
||||
*/
|
||||
public function out()
|
||||
{
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
@ -24,21 +26,23 @@ use think\admin\model\SystemMenu;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\MenuService;
|
||||
use think\admin\service\NodeService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统菜单管理
|
||||
* 系统菜单管理.
|
||||
* @class Menu
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Menu extends Controller
|
||||
{
|
||||
/**
|
||||
* 系统菜单管理
|
||||
* 系统菜单管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -54,21 +58,73 @@ class Menu extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
* 添加系统菜单.
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->_applyFormToken();
|
||||
SystemMenu::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统菜单.
|
||||
* @auth true
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->_applyFormToken();
|
||||
SystemMenu::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单状态
|
||||
* @auth true
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
SystemMenu::mSave($this->_vali([
|
||||
'status.in:0,1' => '状态值范围异常!',
|
||||
'status.require' => '状态值不能为空!',
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统菜单.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
SystemMenu::mDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理.
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
$data = DataExtend::arr2tree($data);
|
||||
// 回收站过滤有效菜单
|
||||
if ($this->type === 'recycle') foreach ($data as $k1 => &$p1) {
|
||||
if (!empty($p1['sub'])) foreach ($p1['sub'] as $k2 => &$p2) {
|
||||
if (!empty($p2['sub'])) foreach ($p2['sub'] as $k3 => $p3) {
|
||||
if ($p3['status'] > 0) unset($p2['sub'][$k3]);
|
||||
if ($this->type === 'recycle') {
|
||||
foreach ($data as $k1 => &$p1) {
|
||||
if (!empty($p1['sub'])) {
|
||||
foreach ($p1['sub'] as $k2 => &$p2) {
|
||||
if (!empty($p2['sub'])) {
|
||||
foreach ($p2['sub'] as $k3 => $p3) {
|
||||
if ($p3['status'] > 0) {
|
||||
unset($p2['sub'][$k3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($p2['sub']) && ($p2['url'] === '#' or $p2['status'] > 0)) {
|
||||
unset($p1['sub'][$k2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($p1['sub']) && ($p1['url'] === '#' or $p1['status'] > 0)) {
|
||||
unset($data[$k1]);
|
||||
}
|
||||
if (empty($p2['sub']) && ($p2['url'] === '#' or $p2['status'] > 0)) unset($p1['sub'][$k2]);
|
||||
}
|
||||
if (empty($p1['sub']) && ($p1['url'] === '#' or $p1['status'] > 0)) unset($data[$k1]);
|
||||
}
|
||||
// 菜单数据树数据变平化
|
||||
$data = DataExtend::arr2table($data);
|
||||
@ -81,35 +137,14 @@ class Menu extends Controller
|
||||
}
|
||||
|
||||
foreach ($data as &$vo) {
|
||||
if ($vo['url'] !== '#' && !preg_match('/^(https?:)?(\/\/|\\\\)/i', $vo['url'])) {
|
||||
$vo['url'] = trim(url($vo['url']) . ($vo['params'] ? "?{$vo['params']}" : ''), '\\/');
|
||||
if ($vo['url'] !== '#' && !preg_match('/^(https?:)?(\/\/|\\\)/i', $vo['url'])) {
|
||||
$vo['url'] = trim(url($vo['url']) . ($vo['params'] ? "?{$vo['params']}" : ''), '\/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加系统菜单
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->_applyFormToken();
|
||||
SystemMenu::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统菜单
|
||||
* @auth true
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->_applyFormToken();
|
||||
SystemMenu::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $vo
|
||||
* 表单数据处理.
|
||||
*/
|
||||
protected function _form_filter(array &$vo)
|
||||
{
|
||||
@ -130,32 +165,25 @@ class Menu extends Controller
|
||||
/* 列出可选上级菜单 */
|
||||
$menus = SystemMenu::mk()->order('sort desc,id asc')->column('id,pid,icon,url,node,title,params', 'id');
|
||||
$this->menus = DataExtend::arr2table(array_merge($menus, [['id' => '0', 'pid' => '-1', 'url' => '#', 'title' => '顶部菜单']]));
|
||||
if (isset($vo['id'])) foreach ($this->menus as $menu) if ($menu['id'] === $vo['id']) $vo = $menu;
|
||||
foreach ($this->menus as $key => $menu) if ($menu['spt'] >= 3 || $menu['url'] !== '#') unset($this->menus[$key]);
|
||||
if (isset($vo['spt']) && isset($vo['spc']) && in_array($vo['spt'], [1, 2]) && $vo['spc'] > 0) {
|
||||
foreach ($this->menus as $key => $menu) if ($vo['spt'] <= $menu['spt']) unset($this->menus[$key]);
|
||||
if (isset($vo['id'])) {
|
||||
foreach ($this->menus as $menu) {
|
||||
if ($menu['id'] === $vo['id']) {
|
||||
$vo = $menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($this->menus as $key => $menu) {
|
||||
if ($menu['spt'] >= 3 || $menu['url'] !== '#') {
|
||||
unset($this->menus[$key]);
|
||||
}
|
||||
}
|
||||
if (isset($vo['spt'], $vo['spc']) && in_array($vo['spt'], [1, 2]) && $vo['spc'] > 0) {
|
||||
foreach ($this->menus as $key => $menu) {
|
||||
if ($vo['spt'] <= $menu['spt']) {
|
||||
unset($this->menus[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜单状态
|
||||
* @auth true
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
SystemMenu::mSave($this->_vali([
|
||||
'status.in:0,1' => '状态值范围异常!',
|
||||
'status.require' => '状态值不能为空!',
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统菜单
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
SystemMenu::mDelete();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,43 +1,46 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use Ip2Region;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\model\SystemOplog;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 系统日志管理
|
||||
* 系统日志管理.
|
||||
* @class Oplog
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Oplog extends Controller
|
||||
{
|
||||
/**
|
||||
* 系统日志管理
|
||||
* 系统日志管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -52,22 +55,7 @@ class Oplog extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
$region = new Ip2Region();
|
||||
foreach ($data as &$vo) try {
|
||||
$vo['geoisp'] = $region->simple($vo['geoip']);
|
||||
} catch (\Exception $exception) {
|
||||
$vo['geoip'] = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理系统日志
|
||||
* 清理系统日志.
|
||||
* @auth true
|
||||
*/
|
||||
public function clear()
|
||||
@ -80,16 +68,32 @@ class Oplog extends Controller
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
trace_file($exception);
|
||||
$this->error(lang("日志清理失败,%s", [$exception->getMessage()]));
|
||||
$this->error(lang('日志清理失败,%s', [$exception->getMessage()]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统日志
|
||||
* 删除系统日志.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
SystemOplog::mDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理.
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
$region = new \Ip2Region();
|
||||
foreach ($data as &$vo) {
|
||||
try {
|
||||
$vo['geoisp'] = $region->simple($vo['geoip']);
|
||||
} catch (\Exception $exception) {
|
||||
$vo['geoip'] = $exception->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
@ -24,22 +26,24 @@ use think\admin\model\SystemQueue;
|
||||
use think\admin\service\AdminService;
|
||||
use think\admin\service\ProcessService;
|
||||
use think\admin\service\QueueService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 系统任务管理
|
||||
* 系统任务管理.
|
||||
* @class Queue
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class Queue extends Controller
|
||||
{
|
||||
/**
|
||||
* 系统任务管理
|
||||
* 系统任务管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -58,26 +62,6 @@ class Queue extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页数据回调处理
|
||||
* @param array $data
|
||||
* @param array $result
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected function _index_page_filter(array $data, array &$result)
|
||||
{
|
||||
$result['extra'] = ['dos' => 0, 'pre' => 0, 'oks' => 0, 'ers' => 0];
|
||||
SystemQueue::mk()->field('status,count(1) count')->group('status')->select()->map(static function ($item) use (&$result) {
|
||||
if (intval($item['status']) === 1) $result['extra']['pre'] = $item['count'];
|
||||
if (intval($item['status']) === 2) $result['extra']['dos'] = $item['count'];
|
||||
if (intval($item['status']) === 3) $result['extra']['oks'] = $item['count'];
|
||||
if (intval($item['status']) === 4) $result['extra']['ers'] = $item['count'];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启系统任务
|
||||
* @auth true
|
||||
@ -98,12 +82,12 @@ class Queue extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理运行数据
|
||||
* 清理运行数据.
|
||||
* @auth true
|
||||
*/
|
||||
public function clean()
|
||||
{
|
||||
$this->_queue('定时清理系统运行数据', "xadmin:queue clean", 0, [], 0, 3600);
|
||||
$this->_queue('定时清理系统运行数据', 'xadmin:queue clean', 0, [], 0, 3600);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,4 +98,29 @@ class Queue extends Controller
|
||||
{
|
||||
SystemQueue::mDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页数据回调处理.
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function _index_page_filter(array $data, array &$result)
|
||||
{
|
||||
$result['extra'] = ['dos' => 0, 'pre' => 0, 'oks' => 0, 'ers' => 0];
|
||||
SystemQueue::mk()->field('status,count(1) count')->group('status')->select()->map(static function ($item) use (&$result) {
|
||||
if (intval($item['status']) === 1) {
|
||||
$result['extra']['pre'] = $item['count'];
|
||||
}
|
||||
if (intval($item['status']) === 2) {
|
||||
$result['extra']['dos'] = $item['count'];
|
||||
}
|
||||
if (intval($item['status']) === 3) {
|
||||
$result['extra']['oks'] = $item['count'];
|
||||
}
|
||||
if (intval($item['status']) === 4) {
|
||||
$result['extra']['ers'] = $item['count'];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,18 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
@ -22,21 +26,23 @@ use think\admin\model\SystemAuth;
|
||||
use think\admin\model\SystemBase;
|
||||
use think\admin\model\SystemUser;
|
||||
use think\admin\service\AdminService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 系统用户管理
|
||||
* 系统用户管理.
|
||||
* @class User
|
||||
* @package app\admin\controller
|
||||
*/
|
||||
class User extends Controller
|
||||
{
|
||||
/**
|
||||
* 系统用户管理
|
||||
* 系统用户管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -45,12 +51,11 @@ class User extends Controller
|
||||
$this->title = '系统用户管理';
|
||||
$this->bases = SystemBase::items('身份权限');
|
||||
}, function (QueryHelper $query) {
|
||||
|
||||
// 加载对应数据列表
|
||||
$query->where(['is_deleted' => 0, 'status' => intval($this->type === 'index')]);
|
||||
|
||||
// 关联用户身份资料
|
||||
/** @var \think\model\Relation|\think\db\Query $query */
|
||||
/* @var \think\model\Relation|\think\db\Query $query */
|
||||
$query->with(['userinfo' => static function ($query) {
|
||||
$query->field('code,name,content');
|
||||
}]);
|
||||
@ -62,7 +67,7 @@ class User extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加系统用户
|
||||
* 添加系统用户.
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
@ -71,7 +76,7 @@ class User extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑系统用户
|
||||
* 编辑系统用户.
|
||||
* @auth true
|
||||
*/
|
||||
public function edit()
|
||||
@ -100,7 +105,7 @@ class User extends Controller
|
||||
if ($user->isExists() && $user->save(['password' => md5($data['password'])])) {
|
||||
// 修改密码同步事件处理
|
||||
$this->app->event->trigger('PluginAdminChangePassword', [
|
||||
'uuid' => $data['id'], 'pass' => $data['password']
|
||||
'uuid' => $data['id'], 'pass' => $data['password'],
|
||||
]);
|
||||
sysoplog('系统用户管理', "修改用户[{$data['id']}]密码成功");
|
||||
$this->success('密码修改成功,请使用新密码登录!', '');
|
||||
@ -110,43 +115,6 @@ class User extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// 检查资料是否完整
|
||||
empty($data['username']) && $this->error('登录账号不能为空!');
|
||||
if ($data['username'] !== AdminService::getSuperName()) {
|
||||
empty($data['authorize']) && $this->error('未配置权限!');
|
||||
}
|
||||
// 处理上传的权限格式
|
||||
$data['authorize'] = arr2str($data['authorize'] ?? []);
|
||||
if (empty($data['id'])) {
|
||||
// 检查账号是否重复
|
||||
$map = ['username' => $data['username'], 'is_deleted' => 0];
|
||||
if (SystemUser::mk()->where($map)->count() > 0) {
|
||||
$this->error("账号已经存在,请使用其它账号!");
|
||||
}
|
||||
// 新添加的用户密码与账号相同
|
||||
$data['password'] = md5($data['username']);
|
||||
} else {
|
||||
unset($data['username']);
|
||||
}
|
||||
} else {
|
||||
// 权限绑定处理
|
||||
$data['authorize'] = str2arr($data['authorize'] ?? '');
|
||||
$this->auths = SystemAuth::items();
|
||||
$this->bases = SystemBase::items('身份权限');
|
||||
$this->super = AdminService::getSuperName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
* @auth true
|
||||
@ -161,7 +129,7 @@ class User extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除系统用户
|
||||
* 删除系统用户.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
@ -171,7 +139,43 @@ class User extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查输入变量
|
||||
* 表单数据处理.
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
// 检查资料是否完整
|
||||
empty($data['username']) && $this->error('登录账号不能为空!');
|
||||
if ($data['username'] !== AdminService::getSuperName()) {
|
||||
empty($data['authorize']) && $this->error('未配置权限!');
|
||||
}
|
||||
// 处理上传的权限格式
|
||||
$data['authorize'] = arr2str($data['authorize'] ?? []);
|
||||
if (empty($data['id'])) {
|
||||
// 检查账号是否重复
|
||||
$map = ['username' => $data['username'], 'is_deleted' => 0];
|
||||
if (SystemUser::mk()->where($map)->count() > 0) {
|
||||
$this->error('账号已经存在,请使用其它账号!');
|
||||
}
|
||||
// 新添加的用户密码与账号相同
|
||||
$data['password'] = md5($data['username']);
|
||||
} else {
|
||||
unset($data['username']);
|
||||
}
|
||||
} else {
|
||||
// 权限绑定处理
|
||||
$data['authorize'] = str2arr($data['authorize'] ?? '');
|
||||
$this->auths = SystemAuth::items();
|
||||
$this->bases = SystemBase::items('身份权限');
|
||||
$this->super = AdminService::getSuperName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查输入变量.
|
||||
*/
|
||||
private function _checkInput()
|
||||
{
|
||||
|
||||
@ -1,37 +1,38 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
use think\admin\Controller;
|
||||
use think\admin\Exception;
|
||||
use think\admin\service\AdminService;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 扩展插件管理
|
||||
* 扩展插件管理.
|
||||
* @class Plugs
|
||||
* @package app\admin\controller\api
|
||||
*/
|
||||
class Plugs extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 图标选择器
|
||||
* 图标选择器.
|
||||
* @login true
|
||||
*/
|
||||
public function icon()
|
||||
@ -72,23 +73,22 @@ class Plugs extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端脚本变量
|
||||
* @return \think\Response
|
||||
* @throws \think\admin\Exception
|
||||
* 前端脚本变量.
|
||||
* @throws Exception
|
||||
*/
|
||||
public function script(): Response
|
||||
{
|
||||
$token = $this->request->get('uptoken', '');
|
||||
$domain = boolval(AdminService::withUploadUnid($token));
|
||||
return response(join("\r\n", [
|
||||
sprintf("window.taDebug = %s;", $this->app->isDebug() ? 'true' : 'false'),
|
||||
sprintf('window.taDebug = %s;', $this->app->isDebug() ? 'true' : 'false'),
|
||||
sprintf("window.taAdmin = '%s';", sysuri('admin/index/index', [], false, $domain)),
|
||||
sprintf("window.taEditor = '%s';", sysconf('base.editor|raw') ?: 'ckeditor4'),
|
||||
]))->contentType('application/javascript');
|
||||
}
|
||||
|
||||
/**
|
||||
* 优化数据库
|
||||
* 优化数据库.
|
||||
* @login true
|
||||
*/
|
||||
public function optimize()
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
@ -25,9 +27,8 @@ use think\admin\service\AdminService;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 任务监听服务管理
|
||||
* 任务监听服务管理.
|
||||
* @class Queue
|
||||
* @package app\admin\controller\api
|
||||
*/
|
||||
class Queue extends Controller
|
||||
{
|
||||
@ -37,7 +38,8 @@ class Queue extends Controller
|
||||
*/
|
||||
public function stop()
|
||||
{
|
||||
if (AdminService::isSuper()) try {
|
||||
if (AdminService::isSuper()) {
|
||||
try {
|
||||
$message = $this->app->console->call('xadmin:queue', ['stop'])->fetch();
|
||||
if (stripos($message, 'sent end signal to process')) {
|
||||
sysoplog('系统运维管理', '尝试停止任务监听服务');
|
||||
@ -52,6 +54,7 @@ class Queue extends Controller
|
||||
} catch (\Exception $exception) {
|
||||
trace_file($exception);
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
} else {
|
||||
$this->error('请使用超管账号操作!');
|
||||
}
|
||||
@ -63,7 +66,8 @@ class Queue extends Controller
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
if (AdminService::isSuper()) try {
|
||||
if (AdminService::isSuper()) {
|
||||
try {
|
||||
$message = $this->app->console->call('xadmin:queue', ['start'])->fetch();
|
||||
if (stripos($message, 'daemons started successfully for pid')) {
|
||||
sysoplog('系统运维管理', '尝试启动任务监听服务');
|
||||
@ -78,6 +82,7 @@ class Queue extends Controller
|
||||
} catch (\Exception $exception) {
|
||||
trace_file($exception);
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
} else {
|
||||
$this->error('请使用超管账号操作!');
|
||||
}
|
||||
@ -89,7 +94,8 @@ class Queue extends Controller
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
if (AdminService::isSuper()) try {
|
||||
if (AdminService::isSuper()) {
|
||||
try {
|
||||
$message = $this->app->console->call('xadmin:queue', ['status'])->fetch();
|
||||
if (preg_match('/process.*?\d+.*?running/', $message)) {
|
||||
echo "<span class='color-green pointer' data-tips-text='{$message}'>{$this->app->lang->get('已启动')}</span>";
|
||||
@ -98,6 +104,7 @@ class Queue extends Controller
|
||||
}
|
||||
} catch (\Error|\Exception $exception) {
|
||||
echo "<span class='color-red pointer' data-tips-text='{$exception->getMessage()}'>{$this->app->lang->get('异 常')}</span>";
|
||||
}
|
||||
} else {
|
||||
$message = lang('只有超级管理员才能操作!');
|
||||
echo "<span class='color-red pointer' data-tips-text='{$message}'>{$this->app->lang->get('无权限')}</span>";
|
||||
@ -105,7 +112,7 @@ class Queue extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务进度
|
||||
* 查询任务进度.
|
||||
* @login true
|
||||
*/
|
||||
public function progress()
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
@ -25,20 +27,19 @@ use think\admin\service\RuntimeService;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 系统运行管理
|
||||
* 系统运行管理.
|
||||
* @class System
|
||||
* @package app\admin\controller\api
|
||||
*/
|
||||
class System extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 网站压缩发布
|
||||
* 网站压缩发布.
|
||||
* @login true
|
||||
*/
|
||||
public function push()
|
||||
{
|
||||
if (AdminService::isSuper()) try {
|
||||
if (AdminService::isSuper()) {
|
||||
try {
|
||||
RuntimeService::push() && sysoplog('系统运维管理', '刷新发布运行缓存');
|
||||
$this->success('网站缓存加速成功!', 'javascript:location.reload()');
|
||||
} catch (HttpResponseException $exception) {
|
||||
@ -46,18 +47,20 @@ class System extends Controller
|
||||
} catch (\Exception $exception) {
|
||||
trace_file($exception);
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
} else {
|
||||
$this->error('请使用超管账号操作!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理运行缓存
|
||||
* 清理运行缓存.
|
||||
* @login true
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
if (AdminService::isSuper()) try {
|
||||
if (AdminService::isSuper()) {
|
||||
try {
|
||||
RuntimeService::clear() && sysoplog('系统运维管理', '清理网站日志缓存');
|
||||
$this->success('清空日志缓存成功!', 'javascript:location.reload()');
|
||||
} catch (HttpResponseException $exception) {
|
||||
@ -65,18 +68,20 @@ class System extends Controller
|
||||
} catch (\Exception $exception) {
|
||||
trace_file($exception);
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
} else {
|
||||
$this->error('请使用超管账号操作!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前运行模式
|
||||
* 当前运行模式.
|
||||
* @login true
|
||||
*/
|
||||
public function debug()
|
||||
{
|
||||
if (AdminService::isSuper()) if (input('state')) {
|
||||
if (AdminService::isSuper()) {
|
||||
if (input('state')) {
|
||||
RuntimeService::set('product');
|
||||
sysoplog('系统运维管理', '开发模式切换为生产模式');
|
||||
$this->success('已切换为生产模式!', 'javascript:location.reload()');
|
||||
@ -84,14 +89,14 @@ class System extends Controller
|
||||
RuntimeService::set('debug');
|
||||
sysoplog('系统运维管理', '生产模式切换为开发模式');
|
||||
$this->success('已切换为开发模式!', 'javascript:location.reload()');
|
||||
}
|
||||
} else {
|
||||
$this->error('请使用超管账号操作!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改富文本编辑器
|
||||
* @return void
|
||||
* 修改富文本编辑器.
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
public function editor()
|
||||
@ -107,19 +112,22 @@ class System extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理系统配置
|
||||
* 清理系统配置.
|
||||
* @login true
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
if (AdminService::isSuper()) try {
|
||||
if (AdminService::isSuper()) {
|
||||
try {
|
||||
[$tmpdata, $newdata] = [[], []];
|
||||
foreach (SystemConfig::mk()->order('type,name asc')->cursor() as $item) {
|
||||
$tmpdata[$item['type']][$item['name']] = $item['value'];
|
||||
}
|
||||
foreach ($tmpdata as $type => $items) foreach ($items as $name => $value) {
|
||||
foreach ($tmpdata as $type => $items) {
|
||||
foreach ($items as $name => $value) {
|
||||
$newdata[] = ['type' => $type, 'name' => $name, 'value' => $value];
|
||||
}
|
||||
}
|
||||
$this->app->db->transaction(static function () use ($newdata) {
|
||||
SystemConfig::mQuery()->empty()->insertAll($newdata);
|
||||
});
|
||||
@ -131,6 +139,7 @@ class System extends Controller
|
||||
} catch (\Exception $exception) {
|
||||
trace_file($exception);
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
} else {
|
||||
$this->error('请使用超管账号操作!');
|
||||
}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\admin\controller\api;
|
||||
|
||||
@ -29,20 +31,21 @@ use think\admin\storage\LocalStorage;
|
||||
use think\admin\storage\QiniuStorage;
|
||||
use think\admin\storage\TxcosStorage;
|
||||
use think\admin\storage\UpyunStorage;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\file\UploadedFile;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 文件上传接口
|
||||
* 文件上传接口.
|
||||
* @class Upload
|
||||
* @package app\admin\controller\api
|
||||
*/
|
||||
class Upload extends Controller
|
||||
{
|
||||
/**
|
||||
* 文件上传脚本
|
||||
* @return Response
|
||||
* 文件上传脚本.
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
public function index(): Response
|
||||
@ -50,18 +53,22 @@ class Upload extends Controller
|
||||
$data = ['exts' => []];
|
||||
[$uuid, $unid, $exts] = $this->initUnid(false);
|
||||
$allows = str2arr(sysconf('storage.allow_exts|raw'));
|
||||
if (empty($uuid) && $unid > 0) $allows = array_intersect($exts, $allows);
|
||||
foreach ($allows as $ext) $data['exts'][$ext] = Storage::mime($ext);
|
||||
if (empty($uuid) && $unid > 0) {
|
||||
$allows = array_intersect($exts, $allows);
|
||||
}
|
||||
foreach ($allows as $ext) {
|
||||
$data['exts'][$ext] = Storage::mime($ext);
|
||||
}
|
||||
$data['exts'] = json_encode($data['exts'], JSON_UNESCAPED_UNICODE);
|
||||
$data['nameType'] = sysconf('storage.name_type|raw') ?: 'xmd5';
|
||||
return view(dirname(__DIR__, 2) . '/view/api/upload.js', $data)->contentType('application/x-javascript');
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件选择器
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* 文件选择器.
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
@ -69,10 +76,12 @@ class Upload extends Controller
|
||||
SystemFile::mQuery()->layTable(function () {
|
||||
$this->title = '文件选择器';
|
||||
}, function (QueryHelper $query) use ($unid, $uuid) {
|
||||
if ($unid && $uuid) $query->where(function ($query) use ($uuid, $unid) {
|
||||
/** @var \think\db\Query $query */
|
||||
if ($unid && $uuid) {
|
||||
$query->where(function ($query) use ($uuid, $unid) {
|
||||
/* @var \think\db\Query $query */
|
||||
$query->whereOr([['uuid', '=', $uuid], ['unid', '=', $unid]]);
|
||||
}); else {
|
||||
});
|
||||
} else {
|
||||
$query->where($unid ? ['unid' => $unid] : ['uuid' => $uuid]);
|
||||
}
|
||||
$query->where(['status' => 2, 'issafe' => 0])->in('xext#type');
|
||||
@ -81,7 +90,7 @@ class Upload extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传检查
|
||||
* 文件上传检查.
|
||||
*/
|
||||
public function state()
|
||||
{
|
||||
@ -102,22 +111,24 @@ class Upload extends Controller
|
||||
'status.value' => 1,
|
||||
]));
|
||||
$mime = $file->getAttr('mime');
|
||||
if (empty($mime)) $file->setAttr('mime', Storage::mime($file->getAttr('xext')));
|
||||
if (empty($mime)) {
|
||||
$file->setAttr('mime', Storage::mime($file->getAttr('xext')));
|
||||
}
|
||||
$info = Storage::instance($data['uptype'])->info($data['key'], $safe, $name);
|
||||
if (isset($info['url']) && isset($info['key'])) {
|
||||
if (isset($info['url'], $info['key'])) {
|
||||
$file->save(['xurl' => $info['url'], 'isfast' => 1, 'issafe' => $data['safe']]);
|
||||
$extr = ['id' => $file->id ?? 0, 'url' => $info['url'], 'key' => $info['key']];
|
||||
$this->success('文件已经上传', array_merge($data, $extr), 200);
|
||||
} elseif ('local' === $data['uptype']) {
|
||||
} elseif ($data['uptype'] === 'local') {
|
||||
$local = LocalStorage::instance();
|
||||
$data['url'] = $local->url($data['key'], $safe, $name);
|
||||
$data['server'] = $local->upload();
|
||||
} elseif ('qiniu' === $data['uptype']) {
|
||||
} elseif ($data['uptype'] === 'qiniu') {
|
||||
$qiniu = QiniuStorage::instance();
|
||||
$data['url'] = $qiniu->url($data['key'], $safe, $name);
|
||||
$data['token'] = $qiniu->token($data['key'], 3600, $name);
|
||||
$data['server'] = $qiniu->upload();
|
||||
} elseif ('alioss' === $data['uptype']) {
|
||||
} elseif ($data['uptype'] === 'alioss') {
|
||||
$alioss = AliossStorage::instance();
|
||||
$token = $alioss->token($data['key'], 3600, $name);
|
||||
$data['url'] = $token['siteurl'];
|
||||
@ -125,7 +136,7 @@ class Upload extends Controller
|
||||
$data['signature'] = $token['signature'];
|
||||
$data['OSSAccessKeyId'] = $token['keyid'];
|
||||
$data['server'] = $alioss->upload();
|
||||
} elseif ('txcos' === $data['uptype']) {
|
||||
} elseif ($data['uptype'] === 'txcos') {
|
||||
$txcos = TxcosStorage::instance();
|
||||
$token = $txcos->token($data['key'], 3600, $name);
|
||||
$data['url'] = $token['siteurl'];
|
||||
@ -135,14 +146,14 @@ class Upload extends Controller
|
||||
$data['q-signature'] = $token['q-signature'];
|
||||
$data['q-sign-algorithm'] = $token['q-sign-algorithm'];
|
||||
$data['server'] = $txcos->upload();
|
||||
} elseif ('upyun' === $data['uptype']) {
|
||||
} elseif ($data['uptype'] === 'upyun') {
|
||||
$upyun = UpyunStorage::instance();
|
||||
$token = $upyun->token($data['key'], 3600, $name, input('hash', ''));
|
||||
$data['url'] = $token['siteurl'];
|
||||
$data['policy'] = $token['policy'];
|
||||
$data['server'] = $upyun->upload();
|
||||
$data['authorization'] = $token['authorization'];
|
||||
} elseif ('alist' === $data['uptype']) {
|
||||
} elseif ($data['uptype'] === 'alist') {
|
||||
$alist = AlistStorage::instance();
|
||||
$data['url'] = $alist->url($data['key']);
|
||||
$data['server'] = $alist->upload();
|
||||
@ -162,7 +173,6 @@ class Upload extends Controller
|
||||
|
||||
/**
|
||||
* 更新文件状态
|
||||
* @return void
|
||||
*/
|
||||
public function done()
|
||||
{
|
||||
@ -174,7 +184,9 @@ class Upload extends Controller
|
||||
'unid.value' => $unid,
|
||||
]);
|
||||
$file = SystemFile::mk()->where($data)->findOrEmpty();
|
||||
if ($file->isEmpty()) $this->error('文件不存在!');
|
||||
if ($file->isEmpty()) {
|
||||
$this->error('文件不存在!');
|
||||
}
|
||||
if ($file->save(['status' => 2])) {
|
||||
$this->success('更新成功!');
|
||||
} else {
|
||||
@ -183,7 +195,7 @@ class Upload extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件上传入口
|
||||
* 文件上传入口.
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
public function file()
|
||||
@ -251,8 +263,7 @@ class Upload extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传类型
|
||||
* @return boolean
|
||||
* 获取上传类型.
|
||||
*/
|
||||
private function getSafe(): bool
|
||||
{
|
||||
@ -260,8 +271,7 @@ class Upload extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传方式
|
||||
* @return string
|
||||
* 获取上传方式.
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
private function getType(): string
|
||||
@ -269,9 +279,8 @@ class Upload extends Controller
|
||||
$type = strtolower(input('uptype', ''));
|
||||
if (in_array($type, array_keys(Storage::types()))) {
|
||||
return $type;
|
||||
} else {
|
||||
return strtolower(sysconf('storage.type|raw'));
|
||||
}
|
||||
return strtolower(sysconf('storage.type|raw'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,9 +293,8 @@ class Upload extends Controller
|
||||
$file = $this->request->file('file');
|
||||
if ($file instanceof UploadedFile) {
|
||||
return $file;
|
||||
} else {
|
||||
$this->error('读取临时文件失败!');
|
||||
}
|
||||
$this->error('读取临时文件失败!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
throw $exception;
|
||||
} catch (\Exception $exception) {
|
||||
@ -297,8 +305,6 @@ class Upload extends Controller
|
||||
|
||||
/**
|
||||
* 初始化用户状态
|
||||
* @param boolean $check
|
||||
* @return array
|
||||
*/
|
||||
private function initUnid(bool $check = true): array
|
||||
{
|
||||
@ -312,9 +318,7 @@ class Upload extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查图片是否安全
|
||||
* @param string $filename
|
||||
* @return boolean
|
||||
* 检查图片是否安全.
|
||||
*/
|
||||
private function imgNotSafe(string $filename): bool
|
||||
{
|
||||
@ -326,11 +330,17 @@ class Upload extends Controller
|
||||
} else {
|
||||
$hexs = bin2hex(fread($source, $size));
|
||||
}
|
||||
if (is_resource($source)) fclose($source);
|
||||
if (is_resource($source)) {
|
||||
fclose($source);
|
||||
}
|
||||
$bins = hex2bin($hexs);
|
||||
/* 匹配十六进制中的 <% ( ) %> 或 <? ( ) ?> 或 <script | /script> */
|
||||
foreach (['<?php ', '<% ', '<script '] as $key) if (stripos($bins, $key) !== false) return true;
|
||||
$result = preg_match("/(3c25.*?28.*?29.*?253e)|(3c3f.*?28.*?29.*?3f3e)|(3C534352495054)|(2F5343524950543E)|(3C736372697074)|(2F7363726970743E)/is", $hexs);
|
||||
foreach (['<?php ', '<% ', '<script '] as $key) {
|
||||
if (stripos($bins, $key) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$result = preg_match('/(3c25.*?28.*?29.*?253e)|(3c3f.*?28.*?29.*?3f3e)|(3C534352495054)|(2F5343524950543E)|(3C736372697074)|(2F7363726970743E)/is', $hexs);
|
||||
return $result === false || $result > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
$extra = [];
|
||||
$extra['开发人员或在功能调试时使用,系统异常时会显示详细的错误信息,同时还会记录操作日志及数据库 SQL 语句信息。'] = 'Developers may use it during functional debugging. When there are system exceptions, detailed error messages will be displayed, and operation logs and database SQL statement information will also be recorded.';
|
||||
$extra['项目正式部署上线后使用,系统异常时统一显示 “%s”,只记录重要的异常日志信息,强烈推荐上线后使用此模式。'] = 'After the project is officially deployed and launched, it will be used. When there are system exceptions, " %s " will be displayed uniformly, and only important exception log information will be recorded. It is strongly recommended to use this mode after launch.';
|
||||
@ -148,17 +151,17 @@ return array_merge($extra, [
|
||||
'数据编码' => 'Code',
|
||||
'数据名称' => 'Name',
|
||||
'操作账号' => 'User',
|
||||
'操作节点' => "Node",
|
||||
'操作节点' => 'Node',
|
||||
'操作行为' => 'Action',
|
||||
'操作内容' => "Content",
|
||||
'操作内容' => 'Content',
|
||||
'访问地址' => 'Geo IP',
|
||||
'网络服务商' => 'ISP.',
|
||||
'日志清理成功!' => 'Logger Clear Complate.',
|
||||
'成功清理所有日志' => 'Successfully cleared all logs.',
|
||||
// 系统文件管理
|
||||
'文件名称' => 'Name',
|
||||
'文件哈希' => "HASH",
|
||||
'文件大小' => "Size",
|
||||
'文件哈希' => 'HASH',
|
||||
'文件大小' => 'Size',
|
||||
'文件后缀' => 'Exts',
|
||||
'存储方式' => 'Storage Type',
|
||||
'清理重复' => 'Clear Replace',
|
||||
@ -168,30 +171,30 @@ return array_merge($extra, [
|
||||
'秒传' => 'Speedy',
|
||||
'普通' => 'Normal',
|
||||
// 系统菜单管理
|
||||
'图 标' => "Icon",
|
||||
'图 标' => 'Icon',
|
||||
'添加菜单' => 'Add',
|
||||
'禁用菜单' => 'Forbid',
|
||||
'激活菜单' => "Resume",
|
||||
'激活菜单' => 'Resume',
|
||||
'系统菜单' => 'Menus',
|
||||
'菜单名称' => 'Name',
|
||||
'跳转链接' => 'Link',
|
||||
'上级菜单' => 'Parent',
|
||||
'菜单链接' => 'Link',
|
||||
'链接参数' => 'Params',
|
||||
'权限节点' => "Node",
|
||||
'权限节点' => 'Node',
|
||||
'菜单图标' => 'Icon',
|
||||
'选择图标' => 'Select Icon',
|
||||
// 系统权限管理
|
||||
"授 权" => 'Auth',
|
||||
'授 权' => 'Auth',
|
||||
'添加权限' => 'Add',
|
||||
'权限名称' => "Name",
|
||||
'权限名称' => 'Name',
|
||||
'权限描述' => 'Description',
|
||||
'请输入权限描述' => 'Please enter a permission description',
|
||||
// 系统用户管理
|
||||
'账号名称' => 'Username',
|
||||
'添加用户' => 'Add User',
|
||||
'最后登录' => "Last Login Time",
|
||||
'头像' => "Head",
|
||||
'最后登录' => 'Last Login Time',
|
||||
'头像' => 'Head',
|
||||
'登录账号' => 'Username',
|
||||
'用户名称' => 'Nickname',
|
||||
'登录次数' => 'Login Times',
|
||||
|
||||
@ -1,19 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Admin Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-admin
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-admin
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
use think\admin\Library;
|
||||
use think\admin\service\RuntimeService;
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use think\facade\App;
|
||||
|
||||
if (!function_exists('parse_padding')) {
|
||||
function parse_padding($source)
|
||||
{
|
||||
@ -372,7 +374,7 @@ if (!function_exists('echo_value')) {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?php if (\think\facade\App::isDebug()) { ?>
|
||||
<?php if (App::isDebug()) { ?>
|
||||
<?php foreach ($traces as $index => $trace) { ?>
|
||||
<div class="exception">
|
||||
<div class="message">
|
||||
@ -391,7 +393,7 @@ if (!function_exists('echo_value')) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="trace">
|
||||
<h2 data-expand="<?php echo 0 === $index ? '1' : '0'; ?>">Call Stack</h2>
|
||||
<h2 data-expand="<?php echo $index === 0 ? '1' : '0'; ?>">Call Stack</h2>
|
||||
<ol>
|
||||
<li><?php echo sprintf('in %s', parse_file($trace['file'], $trace['line'])); ?></li>
|
||||
<?php foreach ((array)$trace['trace'] as $value) { ?>
|
||||
@ -403,7 +405,7 @@ if (!function_exists('echo_value')) {
|
||||
}
|
||||
|
||||
// Show line
|
||||
if (isset($value['file']) && isset($value['line'])) {
|
||||
if (isset($value['file'], $value['line'])) {
|
||||
echo sprintf(' in %s', parse_file($value['file'], $value['line']));
|
||||
}
|
||||
?>
|
||||
@ -465,7 +467,7 @@ if (!function_exists('echo_value')) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (\think\facade\App::isDebug()) { ?>
|
||||
<?php if (App::isDebug()) { ?>
|
||||
<script>
|
||||
function $(selector, node) {
|
||||
var elements;
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat;
|
||||
|
||||
@ -30,25 +32,23 @@ use think\Request;
|
||||
/**
|
||||
* 组件注册服务
|
||||
* @class Service
|
||||
* @package app\wechat
|
||||
*/
|
||||
class Service extends Plugin
|
||||
{
|
||||
/**
|
||||
* 定义插件名称
|
||||
* 定义插件名称.
|
||||
* @var string
|
||||
*/
|
||||
protected $appName = '微信管理';
|
||||
|
||||
/**
|
||||
* 定义安装包名
|
||||
* 定义安装包名.
|
||||
* @var string
|
||||
*/
|
||||
protected $package = 'zoujingli/think-plugs-wechat';
|
||||
|
||||
/**
|
||||
* 注册组件服务
|
||||
* @return void
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
@ -65,14 +65,14 @@ class Service extends Plugin
|
||||
try {
|
||||
$data = json_decode(CodeExtend::deSafe64($request->param('vars')), true);
|
||||
return PaymentService::notify($data);
|
||||
} catch (\Exception|\Error $exception) {
|
||||
} catch (\Error|\Exception $exception) {
|
||||
return "Error: {$exception->getMessage()}";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加微信配置
|
||||
* 增加微信配置.
|
||||
* @return array[]
|
||||
*/
|
||||
public static function menu(): array
|
||||
@ -102,8 +102,8 @@ class Service extends Plugin
|
||||
'subs' => [
|
||||
['name' => '微信支付行为', 'icon' => 'layui-icon layui-icon-rmb', 'node' => "{$code}/payment.record/index"],
|
||||
['name' => '微信退款管理', 'icon' => 'layui-icon layui-icon-engine', 'node' => "{$code}/payment.refund/index"],
|
||||
]
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\command;
|
||||
|
||||
@ -25,11 +27,15 @@ use think\admin\Command;
|
||||
use think\console\Input;
|
||||
use think\console\input\Argument;
|
||||
use think\console\Output;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 向指定用户推送消息
|
||||
* 向指定用户推送消息.
|
||||
* @class Auto
|
||||
* @package app\wechat\command
|
||||
*/
|
||||
class Auto extends Command
|
||||
{
|
||||
@ -37,7 +43,7 @@ class Auto extends Command
|
||||
private $openid;
|
||||
|
||||
/**
|
||||
* 配置消息指令
|
||||
* 配置消息指令.
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
@ -48,40 +54,43 @@ class Auto extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Input $input
|
||||
* @param Output $output
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$code = $input->getArgument('autocode');
|
||||
$this->openid = $input->getArgument('openid');
|
||||
if (empty($code)) $this->setQueueError('Message Code cannot be empty');
|
||||
if (empty($this->openid)) $this->setQueueError('Wechat Openid cannot be empty');
|
||||
if (empty($code)) {
|
||||
$this->setQueueError('Message Code cannot be empty');
|
||||
}
|
||||
if (empty($this->openid)) {
|
||||
$this->setQueueError('Wechat Openid cannot be empty');
|
||||
}
|
||||
|
||||
// 查询微信消息对象
|
||||
$map = ['code' => $code, 'status' => 1];
|
||||
$data = WechatAuto::mk()->where($map)->find();
|
||||
if (empty($data)) $this->setQueueError('Message Data Query failed');
|
||||
if (empty($data)) {
|
||||
$this->setQueueError('Message Data Query failed');
|
||||
}
|
||||
|
||||
// 发送微信客服消息
|
||||
$this->buildMessage($data->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字处理
|
||||
* @param array $data
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* 关键字处理.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
private function buildMessage(array $data)
|
||||
{
|
||||
@ -104,10 +113,14 @@ class Auto extends Command
|
||||
[$item, $news] = [MediaService::news($data['news_id']), []];
|
||||
if (isset($item['articles']) && is_array($item['articles'])) {
|
||||
$host = sysconf('base.site_host') ?: true;
|
||||
foreach ($item['articles'] as $vo) if (empty($news)) $news[] = [
|
||||
foreach ($item['articles'] as $vo) {
|
||||
if (empty($news)) {
|
||||
$news[] = [
|
||||
'url' => url("@wechat/api.view/item/id/{$vo['id']}", [], false, $host)->build(),
|
||||
'title' => $vo['title'], 'picurl' => $vo['local_url'], 'description' => $vo['digest'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$result = $this->sendMessage('news', ['articles' => $news]);
|
||||
}
|
||||
}
|
||||
@ -132,10 +145,9 @@ class Auto extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送客服消息
|
||||
* 推送客服消息.
|
||||
* @param string $type 消息类型
|
||||
* @param array $data 消息对象
|
||||
* @return array
|
||||
*/
|
||||
private function sendMessage(string $type, array $data): array
|
||||
{
|
||||
|
||||
@ -1,32 +1,36 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\command;
|
||||
|
||||
use app\wechat\model\WechatPaymentRecord;
|
||||
use think\admin\Command;
|
||||
use think\admin\Exception;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\db\exception\DbException;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 微信支付单清理任务
|
||||
* @class Clear
|
||||
* @package app\wechat\command
|
||||
*/
|
||||
class Clear extends Command
|
||||
{
|
||||
@ -38,10 +42,8 @@ class Clear extends Command
|
||||
|
||||
/**
|
||||
* 执行支付单清理任务
|
||||
* @param \think\console\Input $input
|
||||
* @param \think\console\Output $output
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws Exception
|
||||
* @throws DbException
|
||||
*/
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
@ -49,8 +51,10 @@ class Clear extends Command
|
||||
$query->where(['payment_status' => 0]);
|
||||
$query->whereTime('create_time', '<', strtotime('-24 hours'));
|
||||
[$total, $count] = [(clone $query)->count(), 0];
|
||||
if (empty($total)) $this->setQueueSuccess('无需清理24小时未支付!');
|
||||
/** @var \think\Model $item */
|
||||
if (empty($total)) {
|
||||
$this->setQueueSuccess('无需清理24小时未支付!');
|
||||
}
|
||||
/** @var Model $item */
|
||||
foreach ($query->cursor() as $item) {
|
||||
$this->setQueueMessage($total, ++$count, sprintf('开始清理 %s 支付单...', $item->getAttr('code')));
|
||||
$item->delete();
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\command;
|
||||
|
||||
@ -23,28 +25,21 @@ use app\wechat\model\WechatFansTags;
|
||||
use app\wechat\service\FansService;
|
||||
use app\wechat\service\WechatService;
|
||||
use think\admin\Command;
|
||||
use think\admin\Exception;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 微信粉丝管理指令
|
||||
* 微信粉丝管理指令.
|
||||
* @class Fans
|
||||
* @package app\wechat\command
|
||||
*/
|
||||
class Fans extends Command
|
||||
{
|
||||
/**
|
||||
* 配置指令
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('xadmin:fansall');
|
||||
$this->setDescription('Wechat Users Data Synchronize for ThinkAdmin');
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务执行处理
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 任务执行处理.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
@ -52,48 +47,9 @@ class Fans extends Command
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步微信粉丝列表
|
||||
* @param string $next
|
||||
* @param integer $done
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
protected function _list(string $next = '', int $done = 0): string
|
||||
{
|
||||
$appid = WechatService::getAppid();
|
||||
$this->process->message('开始获取微信用户数据');
|
||||
while (is_string($next)) {
|
||||
$result = WechatService::WeChatUser()->getUserList($next);
|
||||
if (is_array($result) && !empty($result['data']['openid'])) {
|
||||
foreach (array_chunk($result['data']['openid'], 100) as $openids) {
|
||||
$info = WechatService::WeChatUser()->getBatchUserInfo($openids);
|
||||
if (is_array($info) && !empty($info['user_info_list'])) {
|
||||
foreach ($info['user_info_list'] as $user) if (isset($user['nickname'])) {
|
||||
$this->queue->message($result['total'], ++$done, "-> 开始获取 {$user['openid']} {$user['nickname']}");
|
||||
FansService::set($user, $appid);
|
||||
$this->queue->message($result['total'], $done, "-> 完成更新 {$user['openid']} {$user['nickname']}", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
$next = $result['total'] > $done ? $result['next_openid'] : null;
|
||||
} else {
|
||||
$next = null;
|
||||
}
|
||||
}
|
||||
$this->process->message($done > 0 ? '微信用户数据获取完成' : '未获取到微信用户数据');
|
||||
$this->process->message('');
|
||||
return sprintf('共获取 %d 个用户数据', $done);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步粉丝黑名单列表
|
||||
* @param string $next
|
||||
* @param integer $done
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* 同步粉丝黑名单列表.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
public function _black(string $next = '', int $done = 0): string
|
||||
{
|
||||
@ -105,7 +61,9 @@ class Fans extends Command
|
||||
|
||||
$result = ['total' => 0];
|
||||
while (!is_null($next) && is_array($result = $wechat->getBlackList($next))) {
|
||||
if (empty($result['data']['openid'])) break;
|
||||
if (empty($result['data']['openid'])) {
|
||||
break;
|
||||
}
|
||||
foreach (array_chunk($result['data']['openid'], 100) as $chunk) {
|
||||
$done += count($chunk);
|
||||
WechatFans::mk()->whereIn('openid', $chunk)->update(['is_black' => 1]);
|
||||
@ -116,18 +74,15 @@ class Fans extends Command
|
||||
$this->output->newLine();
|
||||
if (empty($result['total'])) {
|
||||
return ', 其中黑名单 0 人';
|
||||
} else {
|
||||
return sprintf(', 其中黑名单 %s 人', $result['total']);
|
||||
}
|
||||
return sprintf(', 其中黑名单 %s 人', $result['total']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步粉丝标签列表
|
||||
* @param integer $done
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 同步粉丝标签列表.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function _tags(int $done = 0): string
|
||||
{
|
||||
@ -146,4 +101,48 @@ class Fans extends Command
|
||||
$this->output->newLine();
|
||||
return sprintf(', 获取到 %s 个标签', $done);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置指令.
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('xadmin:fansall');
|
||||
$this->setDescription('Wechat Users Data Synchronize for ThinkAdmin');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步微信粉丝列表.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _list(string $next = '', int $done = 0): string
|
||||
{
|
||||
$appid = WechatService::getAppid();
|
||||
$this->process->message('开始获取微信用户数据');
|
||||
while (is_string($next)) {
|
||||
$result = WechatService::WeChatUser()->getUserList($next);
|
||||
if (is_array($result) && !empty($result['data']['openid'])) {
|
||||
foreach (array_chunk($result['data']['openid'], 100) as $openids) {
|
||||
$info = WechatService::WeChatUser()->getBatchUserInfo($openids);
|
||||
if (is_array($info) && !empty($info['user_info_list'])) {
|
||||
foreach ($info['user_info_list'] as $user) {
|
||||
if (isset($user['nickname'])) {
|
||||
$this->queue->message($result['total'], ++$done, "-> 开始获取 {$user['openid']} {$user['nickname']}");
|
||||
FansService::set($user, $appid);
|
||||
$this->queue->message($result['total'], $done, "-> 完成更新 {$user['openid']} {$user['nickname']}", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$next = $result['total'] > $done ? $result['next_openid'] : null;
|
||||
} else {
|
||||
$next = null;
|
||||
}
|
||||
}
|
||||
$this->process->message($done > 0 ? '微信用户数据获取完成' : '未获取到微信用户数据');
|
||||
$this->process->message('');
|
||||
return sprintf('共获取 %d 个用户数据', $done);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
@ -23,16 +25,18 @@ use think\admin\Controller;
|
||||
use think\admin\extend\CodeExtend;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\service\SystemService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 关注自动回复
|
||||
* 关注自动回复.
|
||||
* @class Auto
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Auto extends Controller
|
||||
{
|
||||
/**
|
||||
* 消息类型
|
||||
* 消息类型.
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
@ -42,12 +46,12 @@ class Auto extends Controller
|
||||
];
|
||||
|
||||
/**
|
||||
* 关注自动回复
|
||||
* 关注自动回复.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -61,18 +65,7 @@ class Auto extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['type'] = $this->types[$vo['type']] ?? $vo['type'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加自动回复
|
||||
* 添加自动回复.
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
@ -82,7 +75,7 @@ class Auto extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑自动回复
|
||||
* 编辑自动回复.
|
||||
* @auth true
|
||||
*/
|
||||
public function edit()
|
||||
@ -91,22 +84,6 @@ class Auto extends Controller
|
||||
WechatAuto::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if (empty($data['code'])) {
|
||||
$data['code'] = CodeExtend::uniqidNumber(18, 'AM');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
$this->defaultImage = SystemService::uri('/static/theme/img/image.png', '__FULL__');
|
||||
} else {
|
||||
$data['content'] = strip_tags($data['content'] ?? '', '<a>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改规则状态
|
||||
* @auth true
|
||||
@ -120,11 +97,36 @@ class Auto extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除自动回复
|
||||
* 删除自动回复.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
WechatAuto::mDelete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理.
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['type'] = $this->types[$vo['type']] ?? $vo['type'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据处理.
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if (empty($data['code'])) {
|
||||
$data['code'] = CodeExtend::uniqidNumber(18, 'AM');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
$this->defaultImage = SystemService::uri('/static/theme/img/image.png', '__FULL__');
|
||||
} else {
|
||||
$data['content'] = strip_tags($data['content'] ?? '', '<a>');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
@ -24,14 +26,13 @@ use think\admin\Controller;
|
||||
use think\admin\storage\LocalStorage;
|
||||
|
||||
/**
|
||||
* 微信授权绑定
|
||||
* 微信授权绑定.
|
||||
* @class Config
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Config extends Controller
|
||||
{
|
||||
/**
|
||||
* 微信授权配置
|
||||
* 微信授权配置.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\admin\Exception
|
||||
@ -43,7 +44,7 @@ class Config extends Controller
|
||||
try {
|
||||
// 生成微信授权链接
|
||||
$source = enbase64url(sysuri('admin/index/index', [], false, true) . '#' . $this->request->url());
|
||||
$authurl = sysconf('wechat.service_authurl|raw') ?: "https://open.cuci.cc/plugin-wechat-service/api.push/auth?source=SOURCE";
|
||||
$authurl = sysconf('wechat.service_authurl|raw') ?: 'https://open.cuci.cc/plugin-wechat-service/api.push/auth?source=SOURCE';
|
||||
$this->authurl = str_replace('source=SOURCE', "source={$source}", $authurl);
|
||||
// 授权成功后的参数保存
|
||||
if (input('?appid') && input('?appkey')) {
|
||||
@ -66,19 +67,23 @@ class Config extends Controller
|
||||
$this->title = '微信授权配置';
|
||||
$this->fetch();
|
||||
} else {
|
||||
foreach ($this->request->post() as $k => $v) sysconf($k, $v);
|
||||
if ($this->request->post('wechat.type') === 'thr') try {
|
||||
foreach ($this->request->post() as $k => $v) {
|
||||
sysconf($k, $v);
|
||||
}
|
||||
if ($this->request->post('wechat.type') === 'thr') {
|
||||
try {
|
||||
WechatService::ThinkServiceConfig()->setApiNotifyUri($this->thrNotify);
|
||||
} catch (\Exception $exception) {
|
||||
$this->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
sysoplog('微信授权配置', '修改微信授权配置成功');
|
||||
$this->success('微信授权修改成功!', admuri('', ['uniqid' => uniqid()]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信授权测试
|
||||
* 微信授权测试.
|
||||
* @auth true
|
||||
*/
|
||||
public function options_test()
|
||||
@ -87,14 +92,14 @@ class Config extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信第三方平台接口配置
|
||||
* 微信第三方平台接口配置.
|
||||
* @auth true
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
public function options_jsonrpc()
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$authUrl = sysconf('wechat.service_authurl|raw') ?: "https://open.cuci.cc/plugin-wechat-service/api.push/auth?source=SOURCE";
|
||||
$authUrl = sysconf('wechat.service_authurl|raw') ?: 'https://open.cuci.cc/plugin-wechat-service/api.push/auth?source=SOURCE';
|
||||
$jsonRpc = sysconf('wechat.service_jsonrpc|raw') ?: 'https://open.cuci.cc/plugin-wechat-service/api.client/jsonrpc?token=TOKEN';
|
||||
Builder::mk()
|
||||
->addTextInput('auth_url', '公众号授权跳转入口', 'Getway', true, '进行微信授权时会跳转到这个页面,由微信管理员扫二维码进行授权。', '^https?://.*?auth.*?source=SOURCE')
|
||||
@ -103,7 +108,7 @@ class Config extends Controller
|
||||
} else {
|
||||
$data = $this->_vali([
|
||||
'auth_url.require' => '授权跳转不能为空!',
|
||||
'json_rpc.require' => '接口地址不能为空!'
|
||||
'json_rpc.require' => '接口地址不能为空!',
|
||||
]);
|
||||
sysconf('wechat.service_authurl', $data['auth_url']);
|
||||
sysconf('wechat.service_jsonrpc', $data['json_rpc']);
|
||||
@ -112,7 +117,7 @@ class Config extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定小程序
|
||||
* 绑定小程序.
|
||||
* @auth true
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
@ -128,14 +133,14 @@ class Config extends Controller
|
||||
} else {
|
||||
sysdata('plugin.wechat.wxapp', $this->_vali([
|
||||
'appid.require' => '小程序ID不能为空!',
|
||||
'appkey.require' => '小程序密钥不能为空!'
|
||||
'appkey.require' => '小程序密钥不能为空!',
|
||||
]));
|
||||
$this->success('参数保存成功!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付配置
|
||||
* 微信支付配置.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\admin\Exception
|
||||
@ -150,10 +155,18 @@ class Config extends Controller
|
||||
$this->mch_ssl_key = $this->data['mch_ssl_key'] ?? '';
|
||||
$this->mch_ssl_p12 = $this->data['mch_ssl_p12'] ?? '';
|
||||
$this->mch_ssl_pay = $this->data['mch_ssl_pay'] ?? '';
|
||||
if (!$local->has($this->mch_ssl_cer, true)) $this->mch_ssl_cer = '';
|
||||
if (!$local->has($this->mch_ssl_key, true)) $this->mch_ssl_key = '';
|
||||
if (!$local->has($this->mch_ssl_p12, true)) $this->mch_ssl_p12 = '';
|
||||
if (!$local->has($this->mch_ssl_pay, true)) $this->mch_ssl_pay = '';
|
||||
if (!$local->has($this->mch_ssl_cer, true)) {
|
||||
$this->mch_ssl_cer = '';
|
||||
}
|
||||
if (!$local->has($this->mch_ssl_key, true)) {
|
||||
$this->mch_ssl_key = '';
|
||||
}
|
||||
if (!$local->has($this->mch_ssl_p12, true)) {
|
||||
$this->mch_ssl_p12 = '';
|
||||
}
|
||||
if (!$local->has($this->mch_ssl_pay, true)) {
|
||||
$this->mch_ssl_pay = '';
|
||||
}
|
||||
$this->fetch();
|
||||
} else {
|
||||
$this->error('抱歉,数据提交地址错误!');
|
||||
@ -161,7 +174,7 @@ class Config extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付修改
|
||||
* 微信支付修改.
|
||||
* @auth true
|
||||
* @throws \think\admin\Exception
|
||||
*/
|
||||
@ -191,8 +204,8 @@ class Config extends Controller
|
||||
$this->error('商户证书 P12 不能为空!');
|
||||
}
|
||||
if (openssl_pkcs12_read($local->get($wechat['mch_ssl_p12'], true), $certs, $wechat['mch_id'])) {
|
||||
$name1 = sprintf("wxpay/%s_%s_cer.pem", $wechat['mch_id'], md5($certs['cert']));
|
||||
$name2 = sprintf("wxpay/%s_%s_key.pem", $wechat['mch_id'], md5($certs['pkey']));
|
||||
$name1 = sprintf('wxpay/%s_%s_cer.pem', $wechat['mch_id'], md5($certs['cert']));
|
||||
$name2 = sprintf('wxpay/%s_%s_key.pem', $wechat['mch_id'], md5($certs['pkey']));
|
||||
$wechat['mch_ssl_cer'] = $local->set($name1, $certs['cert'], true)['url'];
|
||||
$wechat['mch_ssl_key'] = $local->set($name2, $certs['pkey'], true)['url'];
|
||||
$wechat['mch_ssl_type'] = 'pem';
|
||||
@ -225,7 +238,7 @@ class Config extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付测试
|
||||
* 微信支付测试.
|
||||
* @auth true
|
||||
*/
|
||||
public function payment_test()
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
@ -23,22 +25,24 @@ use app\wechat\model\WechatFansTags;
|
||||
use app\wechat\service\WechatService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 微信用户管理
|
||||
* 微信用户管理.
|
||||
* @class Fans
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Fans extends Controller
|
||||
{
|
||||
/**
|
||||
* 微信用户管理
|
||||
* 微信用户管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -51,26 +55,17 @@ class Fans extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) $vo['subscribe_at'] = format_datetime($vo['subscribe_at']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步用户数据
|
||||
* 同步用户数据.
|
||||
* @auth true
|
||||
*/
|
||||
public function sync()
|
||||
{
|
||||
sysoplog('微信授权配置', '创建粉丝用户同步任务');
|
||||
$this->_queue('同步微信用户数据', "xadmin:fansall");
|
||||
$this->_queue('同步微信用户数据', 'xadmin:fansall');
|
||||
}
|
||||
|
||||
/**
|
||||
* 黑名单列表操作
|
||||
* 黑名单列表操作.
|
||||
* @auth true
|
||||
*/
|
||||
public function black()
|
||||
@ -102,7 +97,7 @@ class Fans extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户信息
|
||||
* 删除用户信息.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
@ -111,7 +106,7 @@ class Fans extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空用户数据
|
||||
* 清空用户数据.
|
||||
* @auth true
|
||||
*/
|
||||
public function truncate()
|
||||
@ -126,4 +121,14 @@ class Fans extends Controller
|
||||
$this->error("清空用户数据失败,{$exception->getMessage()}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理.
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['subscribe_at'] = format_datetime($vo['subscribe_at']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
@ -23,17 +25,19 @@ use app\wechat\service\WechatService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\service\SystemService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 回复规则管理
|
||||
* 回复规则管理.
|
||||
* @class Keys
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Keys extends Controller
|
||||
{
|
||||
/**
|
||||
* 消息类型
|
||||
* 消息类型.
|
||||
* @var array
|
||||
*/
|
||||
public $types = [
|
||||
@ -42,17 +46,18 @@ class Keys extends Controller
|
||||
];
|
||||
|
||||
/**
|
||||
* 回复规则管理
|
||||
* 回复规则管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// 关键字二维码生成
|
||||
if ($this->request->get('action') === 'qrc') try {
|
||||
if ($this->request->get('action') === 'qrc') {
|
||||
try {
|
||||
$wechat = WechatService::WeChatQrcode();
|
||||
$result = $wechat->create($this->request->get('keys', ''));
|
||||
$this->success('生成二维码成功!', "javascript:$.previewImage('{$wechat->url($result['ticket'])}')");
|
||||
@ -61,6 +66,7 @@ class Keys extends Controller
|
||||
} catch (\Exception $exception) {
|
||||
$this->error("生成二维码失败,请稍候再试!<br> {$exception->getMessage()}");
|
||||
}
|
||||
}
|
||||
// 数据列表分页处理
|
||||
$this->type = $this->get['type'] ?? 'index';
|
||||
WechatKeys::mQuery()->layTable(function () {
|
||||
@ -73,19 +79,7 @@ class Keys extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表数据处理
|
||||
* @param array $data
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['type'] = $this->types[$vo['type']] ?? $vo['type'];
|
||||
$vo['qrc'] = sysuri('wechat/keys/index') . "?action=qrc&keys={$vo['keys']}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加回复规则
|
||||
* 添加回复规则.
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
@ -95,7 +89,7 @@ class Keys extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑回复规则
|
||||
* 编辑回复规则.
|
||||
* @auth true
|
||||
*/
|
||||
public function edit()
|
||||
@ -117,7 +111,7 @@ class Keys extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除回复规则
|
||||
* 删除回复规则.
|
||||
* @auth true
|
||||
*/
|
||||
public function remove()
|
||||
@ -126,7 +120,7 @@ class Keys extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置订阅回复
|
||||
* 配置订阅回复.
|
||||
* @auth true
|
||||
*/
|
||||
public function subscribe()
|
||||
@ -136,7 +130,7 @@ class Keys extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置默认回复
|
||||
* 配置默认回复.
|
||||
* @auth true
|
||||
*/
|
||||
public function defaults()
|
||||
@ -146,15 +140,27 @@ class Keys extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DbException
|
||||
* 列表数据处理.
|
||||
*/
|
||||
protected function _index_page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo['type'] = $this->types[$vo['type']] ?? $vo['type'];
|
||||
$vo['qrc'] = sysuri('wechat/keys/index') . "?action=qrc&keys={$vo['keys']}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加数据处理.
|
||||
* @throws DbException
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$map = [['keys', '=', $data['keys']], ['id', '<>', $data['id'] ?? 0]];
|
||||
if (WechatKeys::mk()->where($map)->count() > 0) $this->error('关键字已经存在!');
|
||||
if (WechatKeys::mk()->where($map)->count() > 0) {
|
||||
$this->error('关键字已经存在!');
|
||||
}
|
||||
$data['content'] = strip_tags($data['content'] ?? '', '<a>');
|
||||
} elseif ($this->request->isGet()) {
|
||||
$this->defaultImage = SystemService::uri('/static/theme/img/image.png', '__FULL__');
|
||||
|
||||
@ -1,42 +1,46 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
use app\wechat\service\WechatService;
|
||||
use think\admin\Controller;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 微信菜单管理
|
||||
* 微信菜单管理.
|
||||
* @class Menu
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Menu extends Controller
|
||||
{
|
||||
/**
|
||||
* 存储数据名称
|
||||
* 存储数据名称.
|
||||
* @var string
|
||||
*/
|
||||
protected $ckey = 'wechat_menu_data';
|
||||
|
||||
/**
|
||||
* 微信菜单的类型
|
||||
* 微信菜单的类型.
|
||||
* @var array
|
||||
*/
|
||||
protected $menuTypes = [
|
||||
@ -53,13 +57,13 @@ class Menu extends Controller
|
||||
];
|
||||
|
||||
/**
|
||||
* 微信菜单管理
|
||||
* 微信菜单管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -74,7 +78,7 @@ class Menu extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消微信菜单
|
||||
* 取消微信菜单.
|
||||
* @auth true
|
||||
*/
|
||||
public function cancel()
|
||||
@ -91,14 +95,15 @@ class Menu extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑微信菜单
|
||||
* 编辑微信菜单.
|
||||
* @auth true
|
||||
*/
|
||||
public function push()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$data = $this->request->post('data');
|
||||
if (empty($data)) try {
|
||||
if (empty($data)) {
|
||||
try {
|
||||
WechatService::WeChatMenu()->delete();
|
||||
sysoplog('微信菜单管理', '删除微信菜单成功');
|
||||
$this->success('删除微信菜单成功!', '');
|
||||
@ -107,7 +112,9 @@ class Menu extends Controller
|
||||
} catch (\Exception $exception) {
|
||||
sysoplog('微信菜单管理', "删除微信菜单失败:{$exception->getMessage()}");
|
||||
$this->error("删除微信菜单失败,请稍候再试!<br>{$exception->getMessage()}");
|
||||
} else try {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
sysdata($this->ckey, $this->_buildMenuData(json_decode($data, true)));
|
||||
WechatService::WeChatMenu()->create(['button' => sysdata($this->ckey)]);
|
||||
sysoplog('微信菜单管理', '发布微信菜单成功');
|
||||
@ -120,11 +127,10 @@ class Menu extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 菜单数据处理
|
||||
* @param array $list
|
||||
* @return array
|
||||
* 菜单数据处理.
|
||||
*/
|
||||
private function _buildMenuData(array $list): array
|
||||
{
|
||||
@ -143,9 +149,7 @@ class Menu extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 单个微信菜单数据处理
|
||||
* @param array $item
|
||||
* @return array
|
||||
* 单个微信菜单数据处理.
|
||||
*/
|
||||
private function _buildMenuDataItem(array $item): array
|
||||
{
|
||||
@ -158,7 +162,9 @@ class Menu extends Controller
|
||||
case 'pic_photo_or_album':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'key' => $item['key'] ?? $item['type']];
|
||||
case 'click':
|
||||
if (empty($item['key'])) $this->error('匹配规则存在空的选项');
|
||||
if (empty($item['key'])) {
|
||||
$this->error('匹配规则存在空的选项');
|
||||
}
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'key' => $item['key']];
|
||||
case 'view':
|
||||
return ['name' => $item['name'], 'type' => $item['type'], 'url' => $item['url']];
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller;
|
||||
|
||||
@ -24,16 +26,18 @@ use app\wechat\service\MediaService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\admin\service\AdminService;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 微信图文管理
|
||||
* 微信图文管理.
|
||||
* @class News
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class News extends Controller
|
||||
{
|
||||
/**
|
||||
* 微信图文管理
|
||||
* 微信图文管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
*/
|
||||
@ -46,21 +50,7 @@ class News extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文列表数据处理
|
||||
* @param array $data
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
protected function _page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo = MediaService::news($vo['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文选择器
|
||||
* 图文选择器.
|
||||
* @auth true
|
||||
*/
|
||||
public function select()
|
||||
@ -69,7 +59,7 @@ class News extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加微信图文
|
||||
* 添加微信图文.
|
||||
* @auth true
|
||||
*/
|
||||
public function add()
|
||||
@ -91,16 +81,18 @@ class News extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑微信图文
|
||||
* 编辑微信图文.
|
||||
* @auth true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->id = $this->request->get('id');
|
||||
if (empty($this->id)) $this->error('参数错误,请稍候再试!');
|
||||
if (empty($this->id)) {
|
||||
$this->error('参数错误,请稍候再试!');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
if ($this->request->get('output') === 'json') {
|
||||
$this->success('获取数据成功!', MediaService::news($this->id));
|
||||
@ -121,7 +113,7 @@ class News extends Controller
|
||||
|
||||
/**
|
||||
* 删除微信图文
|
||||
* auth true
|
||||
* auth true.
|
||||
*/
|
||||
public function remove()
|
||||
{
|
||||
@ -129,9 +121,20 @@ class News extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文更新操作
|
||||
* @param array $data
|
||||
* @return string
|
||||
* 图文列表数据处理.
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function _page_filter(array &$data)
|
||||
{
|
||||
foreach ($data as &$vo) {
|
||||
$vo = MediaService::news($vo['id']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文更新操作.
|
||||
*/
|
||||
private function _buildArticle(array $data): string
|
||||
{
|
||||
@ -147,7 +150,9 @@ class News extends Controller
|
||||
$id = intval($vo['id']);
|
||||
$result = WechatNewsArticle::mk()->where('id', $id)->update($vo);
|
||||
}
|
||||
if ($result) $ids[] = $id;
|
||||
if ($result) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
return join(',', $ids);
|
||||
}
|
||||
|
||||
@ -1,31 +1,35 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
||||
use app\wechat\service\WechatService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\Exception;
|
||||
use think\Response;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 前端JS获取控制器
|
||||
* 前端JS获取控制器.
|
||||
* @class Js
|
||||
* @package app\wechat\controller\api
|
||||
*/
|
||||
class Js extends Controller
|
||||
{
|
||||
@ -39,11 +43,10 @@ class Js extends Controller
|
||||
protected $fansinfo;
|
||||
|
||||
/**
|
||||
* 生成网页授权的JS内容
|
||||
* @return \think\Response
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 生成网页授权的JS内容.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
@ -66,10 +69,10 @@ class Js extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 给指定地址创建签名参数
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 给指定地址创建签名参数.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sdk()
|
||||
{
|
||||
@ -78,8 +81,7 @@ class Js extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成授权内容
|
||||
* @return string
|
||||
* 生成授权内容.
|
||||
*/
|
||||
private function _buildContent(): string
|
||||
{
|
||||
|
||||
@ -1,36 +1,39 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
||||
use app\wechat\service\LoginService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\Exception;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 微信扫码登录
|
||||
* 微信扫码登录.
|
||||
* @class Login
|
||||
* @package app\wechat\controller\api
|
||||
*/
|
||||
class Login extends Controller
|
||||
{
|
||||
/**
|
||||
* 显示二维码
|
||||
* @return void
|
||||
*/
|
||||
public function qrc()
|
||||
{
|
||||
@ -40,10 +43,10 @@ class Login extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信授权处理
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 微信授权处理.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function oauth()
|
||||
{
|
||||
@ -57,7 +60,7 @@ class Login extends Controller
|
||||
|
||||
/**
|
||||
* 获取授权信息
|
||||
* 用定时器请求这个接口
|
||||
* 用定时器请求这个接口.
|
||||
*/
|
||||
public function query()
|
||||
{
|
||||
|
||||
@ -10,10 +10,25 @@
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
// |+----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
||||
@ -21,35 +36,40 @@ use app\wechat\service\FansService;
|
||||
use app\wechat\service\MediaService;
|
||||
use app\wechat\service\WechatService;
|
||||
use think\admin\Controller;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use WeChat\Exceptions\InvalidDecryptException;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
use WeChat\Receive;
|
||||
|
||||
/**
|
||||
* 微信消息推送处理
|
||||
* 微信消息推送处理.
|
||||
* @class Push
|
||||
* @package app\wechat\controller\api
|
||||
*/
|
||||
class Push extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 公众号 APPID
|
||||
* 公众号 APPID.
|
||||
* @var string
|
||||
*/
|
||||
protected $appid;
|
||||
|
||||
/**
|
||||
* 微信用户 OPENID
|
||||
* 微信用户 OPENID.
|
||||
* @var string
|
||||
*/
|
||||
protected $openid;
|
||||
|
||||
/**
|
||||
* 消息是否加密码
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $encrypt;
|
||||
|
||||
/**
|
||||
* 请求微信 OPENID
|
||||
* 请求微信 OPENID.
|
||||
* @var string
|
||||
*/
|
||||
protected $fromOpenid;
|
||||
@ -62,25 +82,24 @@ class Push extends Controller
|
||||
|
||||
/**
|
||||
* 微信实例对象
|
||||
* @var \WeChat\Receive
|
||||
* @var Receive
|
||||
*/
|
||||
protected $wechat;
|
||||
|
||||
/**
|
||||
* 强制返回JSON消息
|
||||
* @var boolean
|
||||
* 强制返回JSON消息.
|
||||
* @var bool
|
||||
*/
|
||||
protected $forceJson = false;
|
||||
|
||||
/**
|
||||
* 强制客服消息回复
|
||||
* @var boolean
|
||||
* 强制客服消息回复.
|
||||
* @var bool
|
||||
*/
|
||||
protected $forceCustom = false;
|
||||
|
||||
/**
|
||||
* 获取网络出口IP
|
||||
* @return string
|
||||
* 获取网络出口IP.
|
||||
*/
|
||||
public function geoip(): string
|
||||
{
|
||||
@ -88,8 +107,7 @@ class Push extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息推送处理接口
|
||||
* @return string
|
||||
* 消息推送处理接口.
|
||||
*/
|
||||
public function index(): string
|
||||
{
|
||||
@ -115,8 +133,10 @@ class Push extends Controller
|
||||
}
|
||||
$this->fromOpenid = $this->receive['tousername'] ?? '';
|
||||
// 消息类型:text, event, image, voice, shortvideo, location, link
|
||||
if (method_exists($this, ($method = $this->receive['msgtype'] ?? ''))) {
|
||||
if (is_string($result = $this->$method())) return $result;
|
||||
if (method_exists($this, $method = $this->receive['msgtype'] ?? '')) {
|
||||
if (is_string($result = $this->{$method}())) {
|
||||
return $result;
|
||||
}
|
||||
} else {
|
||||
$this->app->log->notice("The {$method} event pushed by wechat was not handled. from {$this->openid}");
|
||||
}
|
||||
@ -127,15 +147,15 @@ class Push extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件消息处理
|
||||
* @return boolean|string
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* 文件消息处理.
|
||||
* @return bool|string
|
||||
* @throws InvalidDecryptException
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function text()
|
||||
{
|
||||
@ -143,15 +163,15 @@ class Push extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件消息处理
|
||||
* @return boolean|string
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* 事件消息处理.
|
||||
* @return bool|string
|
||||
* @throws InvalidDecryptException
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
protected function event()
|
||||
{
|
||||
@ -162,18 +182,22 @@ class Push extends Controller
|
||||
case 'subscribe':
|
||||
[$this->app->event->trigger('WechatFansSubscribe', $this->openid), $this->_setUserInfo(true)];
|
||||
if (isset($this->receive['eventkey']) && is_string($this->receive['eventkey'])) {
|
||||
if (($key = preg_replace('/^qrscene_/i', '', $this->receive['eventkey']))) {
|
||||
if ($key = preg_replace('/^qrscene_/i', '', $this->receive['eventkey'])) {
|
||||
return $this->_keys("WechatKeys#keys#{$key}", false, true);
|
||||
}
|
||||
}
|
||||
return $this->_keys('WechatKeys#keys#subscribe', true, $this->forceCustom);
|
||||
case 'scan':
|
||||
case 'click':
|
||||
if (empty($this->receive['eventkey'])) return false;
|
||||
if (empty($this->receive['eventkey'])) {
|
||||
return false;
|
||||
}
|
||||
return $this->_keys("WechatKeys#keys#{$this->receive['eventkey']}", false, $this->forceCustom);
|
||||
case 'scancode_push':
|
||||
case 'scancode_waitmsg':
|
||||
if (empty($this->receive['scancodeinfo']['scanresult'])) return false;
|
||||
if (empty($this->receive['scancodeinfo']['scanresult'])) {
|
||||
return false;
|
||||
}
|
||||
return $this->_keys("WechatKeys#keys#{$this->receive['scancodeinfo']['scanresult']}", false, $this->forceCustom);
|
||||
case 'view':
|
||||
case 'location':
|
||||
@ -183,18 +207,18 @@ class Push extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 关键字处理
|
||||
* 关键字处理.
|
||||
* @param string $rule 关键字规则
|
||||
* @param boolean $last 重复回复消息处理
|
||||
* @param boolean $custom 是否使用客服消息发送
|
||||
* @return boolean|string
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @param bool $last 重复回复消息处理
|
||||
* @param bool $custom 是否使用客服消息发送
|
||||
* @return bool|string
|
||||
* @throws InvalidDecryptException
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
private function _keys(string $rule, bool $last = false, bool $custom = false)
|
||||
{
|
||||
@ -216,30 +240,44 @@ class Push extends Controller
|
||||
case 'customservice':
|
||||
return $this->_sendMessage('customservice', ['content' => $data['content']]);
|
||||
case 'voice':
|
||||
if (empty($data['voice_url']) || !($mediaId = MediaService::upload($data['voice_url'], 'voice'))) return false;
|
||||
if (empty($data['voice_url']) || !($mediaId = MediaService::upload($data['voice_url'], 'voice'))) {
|
||||
return false;
|
||||
}
|
||||
return $this->_sendMessage('voice', ['media_id' => $mediaId], $custom);
|
||||
case 'image':
|
||||
if (empty($data['image_url']) || !($mediaId = MediaService::upload($data['image_url']))) return false;
|
||||
if (empty($data['image_url']) || !($mediaId = MediaService::upload($data['image_url']))) {
|
||||
return false;
|
||||
}
|
||||
return $this->_sendMessage('image', ['media_id' => $mediaId], $custom);
|
||||
case 'news':
|
||||
[$news, $articles] = [MediaService::news($data['news_id']), []];
|
||||
if (empty($news['articles'])) return false;
|
||||
foreach ($news['articles'] as $vo) $articles[] = [
|
||||
if (empty($news['articles'])) {
|
||||
return false;
|
||||
}
|
||||
foreach ($news['articles'] as $vo) {
|
||||
$articles[] = [
|
||||
'url' => url("@wechat/api.view/item/id/{$vo['id']}", [], false, true)->build(),
|
||||
'title' => $vo['title'], 'picurl' => $vo['local_url'], 'description' => $vo['digest'],
|
||||
];
|
||||
}
|
||||
return $this->_sendMessage('news', ['articles' => $articles], $custom);
|
||||
case 'music':
|
||||
if (empty($data['music_url']) || empty($data['music_title']) || empty($data['music_desc'])) return false;
|
||||
if (empty($data['music_url']) || empty($data['music_title']) || empty($data['music_desc'])) {
|
||||
return false;
|
||||
}
|
||||
$mediaId = $data['music_image'] ? MediaService::upload($data['music_image']) : '';
|
||||
return $this->_sendMessage('music', [
|
||||
'hqmusicurl' => $data['music_url'], 'musicurl' => $data['music_url'],
|
||||
'description' => $data['music_desc'], 'title' => $data['music_title'], 'thumb_media_id' => $mediaId,
|
||||
], $custom);
|
||||
case 'video':
|
||||
if (empty($data['video_url']) || empty($data['video_desc']) || empty($data['video_title'])) return false;
|
||||
if (empty($data['video_url']) || empty($data['video_desc']) || empty($data['video_title'])) {
|
||||
return false;
|
||||
}
|
||||
$video = ['title' => $data['video_title'], 'introduction' => $data['video_desc']];
|
||||
if (!($mediaId = MediaService::upload($data['video_url'], 'video', $video))) return false;
|
||||
if (!($mediaId = MediaService::upload($data['video_url'], 'video', $video))) {
|
||||
return false;
|
||||
}
|
||||
return $this->_sendMessage('video', ['media_id' => $mediaId, 'title' => $data['video_title'], 'description' => $data['video_desc']], $custom);
|
||||
default:
|
||||
return false;
|
||||
@ -250,17 +288,18 @@ class Push extends Controller
|
||||
* 发送消息到微信
|
||||
* @param string $type 消息类型(text|image|voice|video|music|news|mpnews|wxcard)
|
||||
* @param array $data 消息内容数据对象
|
||||
* @param boolean $custom 是否使用客服消息发送
|
||||
* @param bool $custom 是否使用客服消息发送
|
||||
* @return string|void
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidDecryptException
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
private function _sendMessage(string $type, array $data, bool $custom = false)
|
||||
{
|
||||
if ($custom) {
|
||||
WechatService::WeChatCustom()->send(['touser' => $this->openid, 'msgtype' => $type, $type => $data]);
|
||||
} else switch (strtolower($type)) {
|
||||
} else {
|
||||
switch (strtolower($type)) {
|
||||
case 'text': // 发送文本消息
|
||||
return $this->_buildMessage($type, ['Content' => $data['content']]);
|
||||
case 'news': // 发送图文消息
|
||||
@ -277,19 +316,21 @@ class Push extends Controller
|
||||
case 'music': // 发送音乐消息
|
||||
return $this->_buildMessage($type, ['Music' => ['Title' => $data['title'], 'Description' => $data['description'], 'MusicUrl' => $data['musicurl'], 'HQMusicUrl' => $data['musicurl'], 'ThumbMediaId' => $data['thumb_media_id']]]);
|
||||
case 'customservice': // 转交客服消息
|
||||
if ($data['content']) $this->_sendMessage('text', $data, true);
|
||||
if ($data['content']) {
|
||||
$this->_sendMessage('text', $data, true);
|
||||
}
|
||||
return $this->_buildMessage('transfer_customer_service');
|
||||
default:
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息数据生成
|
||||
* 消息数据生成.
|
||||
* @param mixed $type 消息类型
|
||||
* @param array $data 消息内容
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidDecryptException
|
||||
* @throws InvalidDecryptException
|
||||
*/
|
||||
private function _buildMessage(string $type, array $data = []): string
|
||||
{
|
||||
@ -299,8 +340,7 @@ class Push extends Controller
|
||||
|
||||
/**
|
||||
* 同步粉丝状态
|
||||
* @param boolean $state 订阅状态
|
||||
* @return boolean
|
||||
* @param bool $state 订阅状态
|
||||
*/
|
||||
private function _setUserInfo(bool $state): bool
|
||||
{
|
||||
@ -318,16 +358,16 @@ class Push extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组健值全部转小写
|
||||
* @param array $data
|
||||
* @return array
|
||||
* 数组健值全部转小写.
|
||||
*/
|
||||
private function _arrayChangeKeyCase(array $data): array
|
||||
{
|
||||
$data = array_change_key_case($data);
|
||||
foreach ($data as $key => $vo) if (is_array($vo)) {
|
||||
foreach ($data as $key => $vo) {
|
||||
if (is_array($vo)) {
|
||||
$data[$key] = $this->_arrayChangeKeyCase($vo);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
||||
@ -22,21 +24,24 @@ use app\wechat\service\MediaService;
|
||||
use app\wechat\service\PaymentService;
|
||||
use app\wechat\service\WechatService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\Exception;
|
||||
use think\admin\extend\CodeExtend;
|
||||
use think\Response;
|
||||
use WeChat\Contracts\Tools;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 微信测试工具
|
||||
* 微信测试工具.
|
||||
* @class Test
|
||||
* @package app\wechat\controller\api
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
class Test extends Controller
|
||||
{
|
||||
/**
|
||||
* 微信JSAPI支付二维码
|
||||
* @login true
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function jsapiQrc(): Response
|
||||
{
|
||||
@ -47,7 +52,6 @@ class Test extends Controller
|
||||
/**
|
||||
* 显示网页授权二维码
|
||||
* @login true
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function oauthQrc(): Response
|
||||
{
|
||||
@ -58,7 +62,6 @@ class Test extends Controller
|
||||
/**
|
||||
* 显示网页授权二维码
|
||||
* @login true
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function jssdkQrc(): Response
|
||||
{
|
||||
@ -67,9 +70,8 @@ class Test extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信扫码支付模式一二维码显示
|
||||
* 微信扫码支付模式一二维码显示.
|
||||
* @login true
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function scanOneQrc(): Response
|
||||
{
|
||||
@ -80,8 +82,7 @@ class Test extends Controller
|
||||
/**
|
||||
* 扫码支付模式二测试二维码
|
||||
* @login true
|
||||
* @return \think\Response
|
||||
* @throws \think\admin\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function scanTwoQrc(): Response
|
||||
{
|
||||
@ -100,10 +101,10 @@ class Test extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 网页授权测试
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 网页授权测试.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function oauth()
|
||||
{
|
||||
@ -113,10 +114,10 @@ class Test extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* JSSDK测试
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* JSSDK测试.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function jssdk()
|
||||
{
|
||||
@ -127,9 +128,8 @@ class Test extends Controller
|
||||
/**
|
||||
* 微信扫码支付模式一通知处理
|
||||
* -- 注意,需要在微信商户配置支付通知地址
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
public function scanOneNotify(): string
|
||||
{
|
||||
@ -165,17 +165,19 @@ class Test extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信JSAPI支付测试
|
||||
* @return void|string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 微信JSAPI支付测试.
|
||||
* @return string|void
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function jsapi()
|
||||
{
|
||||
// 微信用户信息
|
||||
$this->user = WechatService::getWebOauthInfo($this->request->url(true));
|
||||
if (empty($this->user['openid'])) return '<h3>网页授权获取OPENID失败!</h3>';
|
||||
if (empty($this->user['openid'])) {
|
||||
return '<h3>网页授权获取OPENID失败!</h3>';
|
||||
}
|
||||
// 生成支付参数
|
||||
$oCode = CodeExtend::uniqidDate(18, 'TX');
|
||||
$this->result = PaymentService::create($this->user['openid'], $oCode, "JSAPI 支付测试 {$oCode}", '0.01', PaymentService::WECHAT_GZH);
|
||||
@ -185,9 +187,8 @@ class Test extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付通知接收处理
|
||||
* @return string
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* 支付通知接收处理.
|
||||
* @throws InvalidResponseException
|
||||
*/
|
||||
public function notify(): string
|
||||
{
|
||||
@ -197,9 +198,8 @@ class Test extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建二维码响应对应
|
||||
* 创建二维码响应对应.
|
||||
* @param string $url 二维码内容
|
||||
* @return \think\Response
|
||||
*/
|
||||
private function _buildQrcResponse(string $url): Response
|
||||
{
|
||||
|
||||
@ -1,41 +1,44 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller\api;
|
||||
|
||||
use app\wechat\model\WechatNewsArticle;
|
||||
use app\wechat\service\MediaService;
|
||||
use think\admin\Controller;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
|
||||
/**
|
||||
* 微信图文显示
|
||||
* 微信图文显示.
|
||||
* @class View
|
||||
* @package app\wechat\controller\api
|
||||
*/
|
||||
class View extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* 图文列表展示
|
||||
* @param string|integer $id 图文ID编号
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* 图文列表展示.
|
||||
* @param int|string $id 图文ID编号
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function news($id = 0)
|
||||
{
|
||||
@ -45,9 +48,9 @@ class View extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 文章内容展示
|
||||
* @param string|integer $id 文章ID编号
|
||||
* @throws \think\db\exception\DbException
|
||||
* 文章内容展示.
|
||||
* @param int|string $id 文章ID编号
|
||||
* @throws DbException
|
||||
*/
|
||||
public function item($id = 0)
|
||||
{
|
||||
@ -58,7 +61,7 @@ class View extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本展示
|
||||
* 文本展示.
|
||||
*/
|
||||
public function text()
|
||||
{
|
||||
@ -67,7 +70,7 @@ class View extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片展示
|
||||
* 图片展示.
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
@ -76,7 +79,7 @@ class View extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频展示
|
||||
* 视频展示.
|
||||
*/
|
||||
public function video()
|
||||
{
|
||||
@ -86,7 +89,7 @@ class View extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 语音展示
|
||||
* 语音展示.
|
||||
*/
|
||||
public function voice()
|
||||
{
|
||||
@ -95,7 +98,7 @@ class View extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 音乐展示
|
||||
* 音乐展示.
|
||||
*/
|
||||
public function music()
|
||||
{
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller\payment;
|
||||
|
||||
@ -23,23 +25,24 @@ use app\wechat\model\WechatPaymentRecord;
|
||||
use app\wechat\service\PaymentService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
* 微信支付行为管理
|
||||
* 微信支付行为管理.
|
||||
* @class Record
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Record extends Controller
|
||||
{
|
||||
/**
|
||||
* 微信支付行为管理
|
||||
* 微信支付行为管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@ -47,24 +50,29 @@ class Record extends Controller
|
||||
$this->title = '支付行为管理';
|
||||
}, static function (QueryHelper $query) {
|
||||
$db = WechatFans::mQuery()->like('openid|nickname#nickname')->db();
|
||||
if ($db->getOptions('where')) $query->whereRaw("openid in {$db->field('openid')->buildSql()}");
|
||||
if ($db->getOptions('where')) {
|
||||
$query->whereRaw("openid in {$db->field('openid')->buildSql()}");
|
||||
}
|
||||
$query->like('order_code|order_name#order')->dateBetween('create_time');
|
||||
$query->with(['bindFans'])->equal('payment_status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建退款申请
|
||||
* 创建退款申请.
|
||||
* @auth true
|
||||
* @return void
|
||||
*/
|
||||
public function refund()
|
||||
{
|
||||
try {
|
||||
$data = $this->_vali(['code.require' => '支付号不能为空!']);
|
||||
$recode = WechatPaymentRecord::mk()->where($data)->findOrEmpty();
|
||||
if ($recode->isEmpty()) $this->error('支付单不存在!');
|
||||
if ($recode->getAttr('payment_status') < 1) $this->error('支付单未完成支付!');
|
||||
if ($recode->isEmpty()) {
|
||||
$this->error('支付单不存在!');
|
||||
}
|
||||
if ($recode->getAttr('payment_status') < 1) {
|
||||
$this->error('支付单未完成支付!');
|
||||
}
|
||||
$reason = "来自订单 {$recode['order_code']} 的退款!";
|
||||
sysoplog('微信支付退款', "支付单 {$data['code']} 发起退款!");
|
||||
[$state, $message] = PaymentService::refund($data['code'], strval($recode->getAttr('payment_amount')), $reason);
|
||||
@ -77,13 +85,12 @@ class Record extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理未支付数据
|
||||
* 清理未支付数据.
|
||||
* @auth true
|
||||
* @return void
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
sysoplog('微信支付清理', '创建粉丝未支付数据清理任务');
|
||||
$this->_queue('清理微信未支付数据', "xadmin:fanspay", 0, [], 0, 600);
|
||||
$this->_queue('清理微信未支付数据', 'xadmin:fanspay', 0, [], 0, 600);
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\controller\payment;
|
||||
|
||||
@ -23,23 +25,24 @@ use app\wechat\model\WechatPaymentRecord;
|
||||
use app\wechat\model\WechatPaymentRefund;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\db\Query;
|
||||
|
||||
/**
|
||||
* 支付退款管理
|
||||
* 支付退款管理.
|
||||
* @class Refund
|
||||
* @package app\wechat\controller
|
||||
*/
|
||||
class Refund extends Controller
|
||||
{
|
||||
/**
|
||||
* 支付退款管理
|
||||
* 支付退款管理.
|
||||
* @auth true
|
||||
* @menu true
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
$extra = [];
|
||||
$extra['请选择微信对接方式,其中微信开放平台授权模式需要微信开放平台支持,还需要搭建第三方服务平台托管系统!'] = 'Please select WeChat docking mode, of which WeChat Open platform authorization mode needs WeChat Open platform support, and a third-party service platform hosting system needs to be built!';
|
||||
$extra['使用微信开放平台授权模式时,微信将授权给第三方服务平台托管系统,消息数据使用 %s 通信协议转发。'] = 'When using WeChat Open platform authorization mode, WeChat will authorize the third-party service platform hosting system, and the message data will be forwarded using %s communication protocol.';
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 微信自动回复模型
|
||||
* 微信自动回复模型.
|
||||
*
|
||||
* @property int $create_by 创建人
|
||||
* @property int $id
|
||||
@ -43,14 +45,12 @@ use think\admin\Model;
|
||||
* @property string $video_url 视频URL
|
||||
* @property string $voice_url 语音链接
|
||||
* @class WechatAuto
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatAuto extends Model
|
||||
{
|
||||
/**
|
||||
* 格式化创建时间
|
||||
* 格式化创建时间.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateAtAttr($value): string
|
||||
{
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 微信粉丝用户模型
|
||||
* 微信粉丝用户模型.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $is_black 是否为黑名单状态
|
||||
@ -45,8 +47,5 @@ use think\admin\Model;
|
||||
* @property string $tagid_list 粉丝标签id
|
||||
* @property string $unionid 粉丝unionid
|
||||
* @class WechatFans
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatFans extends Model
|
||||
{
|
||||
}
|
||||
class WechatFans extends Model {}
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 微信粉丝标签模型
|
||||
* 微信粉丝标签模型.
|
||||
*
|
||||
* @property int $count 粉丝总数
|
||||
* @property int $id
|
||||
@ -29,8 +31,5 @@ use think\admin\Model;
|
||||
* @property string $create_at 创建日期
|
||||
* @property string $name 标签名称
|
||||
* @class WechatFansTags
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatFansTags extends Model
|
||||
{
|
||||
}
|
||||
class WechatFansTags extends Model {}
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 微信回复关键词模型
|
||||
* 微信回复关键词模型.
|
||||
*
|
||||
* @property int $create_by 创建人
|
||||
* @property int $id
|
||||
@ -43,14 +45,12 @@ use think\admin\Model;
|
||||
* @property string $video_url 视频URL
|
||||
* @property string $voice_url 语音链接
|
||||
* @class WechatKeys
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatKeys extends Model
|
||||
{
|
||||
/**
|
||||
* 格式化创建时间
|
||||
* 格式化创建时间.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateAtAttr($value): string
|
||||
{
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 微信媒体文件模型
|
||||
* 微信媒体文件模型.
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $appid 公众号ID
|
||||
@ -32,8 +34,5 @@ use think\admin\Model;
|
||||
* @property string $media_url 远程图片链接
|
||||
* @property string $type 媒体类型
|
||||
* @class WechatMedia
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatMedia extends Model
|
||||
{
|
||||
}
|
||||
class WechatMedia extends Model {}
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 微信图文主模型
|
||||
* 微信图文主模型.
|
||||
*
|
||||
* @property int $create_by 创建人
|
||||
* @property int $id
|
||||
@ -31,8 +33,5 @@ use think\admin\Model;
|
||||
* @property string $local_url 永久素材外网URL
|
||||
* @property string $media_id 永久素材MediaID
|
||||
* @class WechatNews
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatNews extends Model
|
||||
{
|
||||
}
|
||||
class WechatNews extends Model {}
|
||||
|
||||
@ -1,27 +1,29 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
use think\admin\Model;
|
||||
|
||||
/**
|
||||
* 微信图文详细模型
|
||||
* 微信图文详细模型.
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $read_num 阅读数量
|
||||
@ -34,8 +36,5 @@ use think\admin\Model;
|
||||
* @property string $local_url 永久素材URL
|
||||
* @property string $title 素材标题
|
||||
* @class WechatNewsArticle
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatNewsArticle extends Model
|
||||
{
|
||||
}
|
||||
class WechatNewsArticle extends Model {}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
@ -23,7 +25,7 @@ use think\admin\Model;
|
||||
use think\model\relation\HasOne;
|
||||
|
||||
/**
|
||||
* 微信支付行为模型
|
||||
* 微信支付行为模型.
|
||||
*
|
||||
* @property float $order_amount 原订单金额
|
||||
* @property float $payment_amount 实际到账金额
|
||||
@ -44,16 +46,14 @@ use think\model\relation\HasOne;
|
||||
* @property string $payment_trade 平台交易编号
|
||||
* @property string $type 交易方式
|
||||
* @property string $update_time 更新时间
|
||||
* @property-read \app\wechat\model\WechatFans $bind_fans
|
||||
* @property-read \app\wechat\model\WechatFans $fans
|
||||
* @property WechatFans $bind_fans
|
||||
* @property WechatFans $fans
|
||||
* @class WechatPaymentRecord
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatPaymentRecord extends Model
|
||||
{
|
||||
/**
|
||||
* 关联用户粉丝数据
|
||||
* @return \think\model\relation\HasOne
|
||||
* 关联用户粉丝数据.
|
||||
*/
|
||||
public function fans(): HasOne
|
||||
{
|
||||
@ -61,8 +61,7 @@ class WechatPaymentRecord extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定用户粉丝数据
|
||||
* @return \think\model\relation\HasOne
|
||||
* 绑定用户粉丝数据.
|
||||
*/
|
||||
public function bindFans(): HasOne
|
||||
{
|
||||
@ -73,9 +72,8 @@ class WechatPaymentRecord extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出时间格式
|
||||
* 格式化输出时间格式.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTimeAttr($value): string
|
||||
{
|
||||
@ -83,9 +81,8 @@ class WechatPaymentRecord extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出时间格式
|
||||
* 格式化输出时间格式.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateTimeAttr($value): string
|
||||
{
|
||||
@ -93,9 +90,8 @@ class WechatPaymentRecord extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出时间格式
|
||||
* 格式化输出时间格式.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getPaymentTimeAttr($value): string
|
||||
{
|
||||
@ -103,8 +99,7 @@ class WechatPaymentRecord extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换数据类型
|
||||
* @return array
|
||||
* 转换数据类型.
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\model;
|
||||
|
||||
@ -22,7 +24,7 @@ use think\admin\Model;
|
||||
use think\model\relation\HasOne;
|
||||
|
||||
/**
|
||||
* 微信支付退款模型
|
||||
* 微信支付退款模型.
|
||||
*
|
||||
* @property float $refund_amount 实际到账金额
|
||||
* @property int $id
|
||||
@ -37,15 +39,13 @@ use think\model\relation\HasOne;
|
||||
* @property string $refund_time 支付完成时间
|
||||
* @property string $refund_trade 平台交易编号
|
||||
* @property string $update_time 更新时间
|
||||
* @property-read \app\wechat\model\WechatPaymentRecord $record
|
||||
* @property WechatPaymentRecord $record
|
||||
* @class WechatPaymentRefund
|
||||
* @package app\wechat\model
|
||||
*/
|
||||
class WechatPaymentRefund extends Model
|
||||
{
|
||||
/**
|
||||
* 关联支付订单
|
||||
* @return \think\model\relation\HasOne
|
||||
* 关联支付订单.
|
||||
*/
|
||||
public function record(): HasOne
|
||||
{
|
||||
@ -53,9 +53,8 @@ class WechatPaymentRefund extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出时间格式
|
||||
* 格式化输出时间格式.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateTimeAttr($value): string
|
||||
{
|
||||
@ -63,9 +62,8 @@ class WechatPaymentRefund extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出时间格式
|
||||
* 格式化输出时间格式.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdateTimeAttr($value): string
|
||||
{
|
||||
@ -73,9 +71,8 @@ class WechatPaymentRefund extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化输出时间格式
|
||||
* 格式化输出时间格式.
|
||||
* @param mixed $value
|
||||
* @return string
|
||||
*/
|
||||
public function getRefundTimeAttr($value): string
|
||||
{
|
||||
|
||||
@ -1,38 +1,39 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
||||
use app\wechat\model\WechatAuto;
|
||||
use think\admin\Exception;
|
||||
use think\admin\Service;
|
||||
use think\admin\service\QueueService;
|
||||
|
||||
/**
|
||||
* 关注自动回复服务
|
||||
* @class AutoService
|
||||
* @package app\wechat\service
|
||||
*/
|
||||
class AutoService extends Service
|
||||
{
|
||||
/**
|
||||
* 注册微信用户推送任务
|
||||
* @param string $openid
|
||||
* @throws \think\admin\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function register(string $openid)
|
||||
{
|
||||
@ -43,16 +44,13 @@ class AutoService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析配置时间格式
|
||||
* @param string $time
|
||||
* @return int
|
||||
* 解析配置时间格式.
|
||||
*/
|
||||
private static function parseTimeString(string $time): int
|
||||
{
|
||||
if (preg_match('|^.*?(\d{2}).*?(\d{2}).*?(\d{2}).*?$|', $time, $vars)) {
|
||||
return intval($vars[1]) * 3600 * intval($vars[2]) * 60 + intval($vars[3]);
|
||||
} else {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
||||
@ -23,18 +25,15 @@ use think\admin\Library;
|
||||
use think\admin\Service;
|
||||
|
||||
/**
|
||||
* 微信粉丝信息
|
||||
* 微信粉丝信息.
|
||||
* @class FansService
|
||||
* @package app\wechat\service
|
||||
*/
|
||||
class FansService extends Service
|
||||
{
|
||||
|
||||
/**
|
||||
* 增加或更新粉丝信息
|
||||
* 增加或更新粉丝信息.
|
||||
* @param array $user 粉丝信息
|
||||
* @param string $appid 微信APPID
|
||||
* @return boolean
|
||||
*/
|
||||
public static function set(array $user, string $appid = ''): bool
|
||||
{
|
||||
@ -44,17 +43,21 @@ class FansService extends Service
|
||||
if (isset($user['tagid_list']) && is_array($user['tagid_list'])) {
|
||||
$user['tagid_list'] = arr2str($user['tagid_list']);
|
||||
}
|
||||
if ($appid !== '') $user['appid'] = $appid;
|
||||
if ($appid !== '') {
|
||||
$user['appid'] = $appid;
|
||||
}
|
||||
unset($user['privilege'], $user['groupid']);
|
||||
foreach ($user as $k => $v) if ($v === '') unset($user[$k]);
|
||||
foreach ($user as $k => $v) {
|
||||
if ($v === '') {
|
||||
unset($user[$k]);
|
||||
}
|
||||
}
|
||||
Library::$sapp->event->trigger('WechatFansUpdate', $user);
|
||||
return !!WechatFans::mUpdate($user, 'openid');
|
||||
return (bool)WechatFans::mUpdate($user, 'openid');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取粉丝信息
|
||||
* @param string $openid
|
||||
* @return array
|
||||
* 获取粉丝信息.
|
||||
*/
|
||||
public static function get(string $openid): array
|
||||
{
|
||||
|
||||
@ -1,38 +1,42 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
||||
use think\admin\Exception;
|
||||
use think\admin\Library;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 微信扫码登录服务
|
||||
* @class LoginService
|
||||
* @package app\wechat\service
|
||||
*/
|
||||
class LoginService
|
||||
{
|
||||
private const expire = 3600;
|
||||
|
||||
private const prefix = 'wxlogin';
|
||||
|
||||
/**
|
||||
* 生成请求编号
|
||||
* @return string
|
||||
* 生成请求编号.
|
||||
*/
|
||||
public static function gcode(): string
|
||||
{
|
||||
@ -42,7 +46,6 @@ class LoginService
|
||||
/**
|
||||
* 生成授权码
|
||||
* @param string $code 请求编号
|
||||
* @return string
|
||||
*/
|
||||
public static function gauth(string $code): string
|
||||
{
|
||||
@ -52,9 +55,8 @@ class LoginService
|
||||
/**
|
||||
* 生成授权二维码
|
||||
* @param string $code 请求编号
|
||||
* @param integer $mode 授权模式
|
||||
* @param boolean|string $domain
|
||||
* @return array
|
||||
* @param int $mode 授权模式
|
||||
* @param bool|string $domain
|
||||
*/
|
||||
public static function qrcode(string $code, int $mode = 0, $domain = true): array
|
||||
{
|
||||
@ -64,13 +66,12 @@ class LoginService
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起网页授权处理
|
||||
* 发起网页授权处理.
|
||||
* @param string $auth 授权编号
|
||||
* @param integer $mode 授权模式
|
||||
* @return boolean
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @param int $mode 授权模式
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function oauth(string $auth = '', int $mode = 0): bool
|
||||
{
|
||||
@ -86,9 +87,8 @@ class LoginService
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否授权
|
||||
* 检查是否授权.
|
||||
* @param string $code 请求编号
|
||||
* @return ?array
|
||||
*/
|
||||
public static function query(string $code): ?array
|
||||
{
|
||||
@ -96,9 +96,7 @@ class LoginService
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除授权缓存
|
||||
* @param string $code
|
||||
* @return bool
|
||||
* 删除授权缓存.
|
||||
*/
|
||||
public static function remove(string $code): bool
|
||||
{
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
||||
@ -27,59 +29,75 @@ use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
|
||||
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
|
||||
use Endroid\QrCode\Writer\PngWriter;
|
||||
use Endroid\QrCode\Writer\Result\ResultInterface;
|
||||
use think\admin\Exception;
|
||||
use think\admin\Service;
|
||||
use think\admin\Storage;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use WeChat\Contracts\MyCurlFile;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 微信素材管理
|
||||
* 微信素材管理.
|
||||
* @class MediaService
|
||||
* @package app\wechat\service
|
||||
*/
|
||||
class MediaService extends Service
|
||||
{
|
||||
/**
|
||||
* 通过图文ID读取图文信息
|
||||
* 通过图文ID读取图文信息.
|
||||
* @param mixed $id 本地图文ID
|
||||
* @param mixed $map 额外的查询条件
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public static function news($id, $map = []): array
|
||||
{
|
||||
// 文章主体数据
|
||||
$data = WechatNews::mk()->where(['id' => $id, 'is_deleted' => 0])->where($map)->findOrEmpty()->toArray();
|
||||
if (empty($data)) return [];
|
||||
if (empty($data)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 文章内容编号
|
||||
$data['articles'] = [];
|
||||
$aids = $data['articleids'] = str2arr($data['article_id']);
|
||||
if (empty($aids)) return $data;
|
||||
if (empty($aids)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 文章内容列表
|
||||
$items = WechatNewsArticle::mk()->whereIn('id', $aids)->withoutField('create_by,create_at')->select()->toArray();
|
||||
foreach ($aids as $aid) foreach ($items as $item) if (intval($item['id']) === intval($aid)) $data['articles'][] = $item;
|
||||
foreach ($aids as $aid) {
|
||||
foreach ($items as $item) {
|
||||
if (intval($item['id']) === intval($aid)) {
|
||||
$data['articles'][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回文章内容
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片永久素材
|
||||
* 上传图片永久素材.
|
||||
* @param string $url 文件地址
|
||||
* @param string $type 文件类型
|
||||
* @param array $video 视频信息
|
||||
* @return string media_id
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function upload(string $url, string $type = 'image', array $video = []): string
|
||||
{
|
||||
$map = ['md5' => md5($url), 'appid' => WechatService::getAppid()];
|
||||
if (($mediaId = WechatMedia::mk()->where($map)->value('media_id'))) return $mediaId;
|
||||
if ($mediaId = WechatMedia::mk()->where($map)->value('media_id')) {
|
||||
return $mediaId;
|
||||
}
|
||||
$result = WechatService::WeChatMedia()->addMaterial(static::buildCurlFile($url), $type, $video);
|
||||
WechatMedia::mUpdate([
|
||||
'md5' => $map['md5'],
|
||||
@ -93,24 +111,8 @@ class MediaService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 CURL 文件对象
|
||||
* @param string $local 文件路径或网络地址
|
||||
* @return MyCurlFile
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
*/
|
||||
private static function buildCurlFile(string $local): MyCurlFile
|
||||
{
|
||||
if (file_exists($local)) {
|
||||
return new MyCurlFile($local);
|
||||
} else {
|
||||
return new MyCurlFile(Storage::down($local)['file']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二维码内容接口
|
||||
* 获取二维码内容接口.
|
||||
* @param string $text 二维码文本内容
|
||||
* @return \Endroid\QrCode\Writer\Result\ResultInterface
|
||||
*/
|
||||
public static function getQrcode(string $text): ResultInterface
|
||||
{
|
||||
@ -121,4 +123,17 @@ class MediaService extends Service
|
||||
->errorCorrectionLevel(new ErrorCorrectionLevelHigh())
|
||||
->build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建 CURL 文件对象
|
||||
* @param string $local 文件路径或网络地址
|
||||
* @throws LocalCacheException
|
||||
*/
|
||||
private static function buildCurlFile(string $local): MyCurlFile
|
||||
{
|
||||
if (file_exists($local)) {
|
||||
return new MyCurlFile($local);
|
||||
}
|
||||
return new MyCurlFile(Storage::down($local)['file']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\wechat\service;
|
||||
|
||||
@ -24,30 +26,26 @@ use think\admin\Exception;
|
||||
use think\admin\extend\CodeExtend;
|
||||
use think\admin\Library;
|
||||
use think\Response;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
use WePayV3\Order;
|
||||
|
||||
/**
|
||||
* 微信V3支付服务
|
||||
* @class PaymentService
|
||||
* @package app\wechat\service
|
||||
*/
|
||||
class PaymentService
|
||||
{
|
||||
// 微信支付类型
|
||||
public const WECHAT_APP = 'wechat_app';
|
||||
public const WECHAT_GZH = 'wechat_gzh';
|
||||
public const WECHAT_XCX = 'wechat_xcx';
|
||||
public const WECHAT_WAP = 'wechat_wap';
|
||||
public const WECHAT_QRC = 'wechat_qrc';
|
||||
|
||||
// 微信支付类型转换
|
||||
private const tradeTypes = [
|
||||
self::WECHAT_APP => 'APP',
|
||||
self::WECHAT_WAP => 'MWEB',
|
||||
self::WECHAT_GZH => 'JSAPI',
|
||||
self::WECHAT_XCX => 'JSAPI',
|
||||
self::WECHAT_QRC => 'NATIVE',
|
||||
];
|
||||
public const WECHAT_GZH = 'wechat_gzh';
|
||||
|
||||
public const WECHAT_XCX = 'wechat_xcx';
|
||||
|
||||
public const WECHAT_WAP = 'wechat_wap';
|
||||
|
||||
public const WECHAT_QRC = 'wechat_qrc';
|
||||
|
||||
// 微信支付类型名称
|
||||
public const tradeTypeNames = [
|
||||
@ -58,8 +56,17 @@ class PaymentService
|
||||
self::WECHAT_QRC => '二维码支付',
|
||||
];
|
||||
|
||||
// 微信支付类型转换
|
||||
private const tradeTypes = [
|
||||
self::WECHAT_APP => 'APP',
|
||||
self::WECHAT_WAP => 'MWEB',
|
||||
self::WECHAT_GZH => 'JSAPI',
|
||||
self::WECHAT_XCX => 'JSAPI',
|
||||
self::WECHAT_QRC => 'NATIVE',
|
||||
];
|
||||
|
||||
/**
|
||||
* 创建微信支付订单
|
||||
* 创建微信支付订单.
|
||||
* @param string $openid 用户标识
|
||||
* @param string $oCode 订单单号
|
||||
* @param string $oName 订单标题
|
||||
@ -67,8 +74,7 @@ class PaymentService
|
||||
* @param string $pType 支付类型
|
||||
* @param ?string $pAmount 支付金额(元)
|
||||
* @param ?string $pRemark 支付描述
|
||||
* @return array
|
||||
* @throws \think\admin\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function create(string $openid, string $oCode, string $oName, string $oAmount, string $pType, ?string $pAmount = null, ?string $pRemark = null): array
|
||||
{
|
||||
@ -78,13 +84,14 @@ class PaymentService
|
||||
return ['code' => 1, 'info' => '已完成支付!', 'data' => [], 'params' => []];
|
||||
}
|
||||
// 检查剩余支付金额
|
||||
$pAmount = floatval(is_null($pAmount) ? (floatval($oAmount) - $oPayed) : $pAmount);
|
||||
if ($oPayed + $pAmount > floatval($oAmount)) {
|
||||
$pAmount = strval(is_null($pAmount) ? (bcsub(strval($oAmount), strval($oPayed), 2)) : $pAmount);
|
||||
if (bccomp(bcadd(strval($oPayed), $pAmount, 2), strval($oAmount), 2) > 0) {
|
||||
return ['code' => 0, 'info' => '支付总额超出!', 'data' => [], 'params' => []];
|
||||
}
|
||||
$config = WechatService::getConfig(true);
|
||||
do $pCode = CodeExtend::uniqidNumber(16, 'P');
|
||||
while (WechatPaymentRecord::mk()->master()->where(['code' => $pCode])->findOrEmpty()->isExists());
|
||||
do {
|
||||
$pCode = CodeExtend::uniqidNumber(16, 'P');
|
||||
} while (WechatPaymentRecord::mk()->master()->where(['code' => $pCode])->findOrEmpty()->isExists());
|
||||
$data = [
|
||||
'appid' => $config['appid'],
|
||||
'mchid' => $config['mch_id'],
|
||||
@ -115,9 +122,8 @@ class PaymentService
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信支付订单
|
||||
* 查询微信支付订单.
|
||||
* @param string $pCode 订单单号
|
||||
* @return array
|
||||
*/
|
||||
public static function query(string $pCode): array
|
||||
{
|
||||
@ -141,9 +147,7 @@ class PaymentService
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付结果处理
|
||||
* @param array|null $data
|
||||
* @return \think\Response
|
||||
* 支付结果处理.
|
||||
*/
|
||||
public static function notify(?array $data = null): Response
|
||||
{
|
||||
@ -159,7 +163,9 @@ class PaymentService
|
||||
}
|
||||
// 订单支付通知处理
|
||||
if ($data['scen'] === 'order' && isset($result['trade_state']) && $result['trade_state'] == 'SUCCESS') {
|
||||
if ($data['order'] !== $result['out_trade_no']) return response('error', 500);
|
||||
if ($data['order'] !== $result['out_trade_no']) {
|
||||
return response('error', 500);
|
||||
}
|
||||
$extra = [
|
||||
'openid' => $result['payer']['openid'] ?? null,
|
||||
'payment_bank' => $result['bank_type'],
|
||||
@ -172,9 +178,13 @@ class PaymentService
|
||||
return response('error', 500);
|
||||
}
|
||||
} elseif ($data['scen'] === 'refund' && isset($result['refund_status']) && $result['refund_status'] == 'SUCCESS') {
|
||||
if ($data['order'] !== $result['out_refund_no']) return response('error', 500);
|
||||
if ($data['order'] !== $result['out_refund_no']) {
|
||||
return response('error', 500);
|
||||
}
|
||||
$refund = WechatPaymentRefund::mk()->where(['code' => $result['out_refund_no']])->findOrEmpty();
|
||||
if ($refund->isEmpty()) return response('error', 500);
|
||||
if ($refund->isEmpty()) {
|
||||
return response('error', 500);
|
||||
}
|
||||
$refund->save([
|
||||
'refund_time' => date('Y-m-d H:i:s', strtotime($result['success_time'])),
|
||||
'refund_trade' => $result['refund_id'],
|
||||
@ -193,14 +203,13 @@ class PaymentService
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建支付单退款
|
||||
* 创建支付单退款.
|
||||
* @param string $pcode 支付单号
|
||||
* @param string $amount 退款金额
|
||||
* @param string $reason 退款原因
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function refund(string $pcode, string $amount, string $reason = ''): array
|
||||
{
|
||||
@ -209,12 +218,13 @@ class PaymentService
|
||||
if ($record->getAttr('refund_amount') >= $record->getAttr('payment_amount')) {
|
||||
return [1, '该订单已完成退款!'];
|
||||
}
|
||||
if ($record->getAttr('refund_amount') + floatval($amount) > $record->getAttr('payment_amount')) {
|
||||
if (bccomp(bcadd(strval($record->getAttr('refund_amount')), strval($amount), 2), strval($record->getAttr('payment_amount')), 2) > 0) {
|
||||
return [0, '退款大于支付金额!'];
|
||||
}
|
||||
// 创建支付退款申请
|
||||
do $check = ['code' => $rcode = CodeExtend::uniqidNumber(16, 'R')];
|
||||
while (($model = WechatPaymentRefund::mk()->master()->where($check)->findOrEmpty())->isExists());
|
||||
do {
|
||||
$check = ['code' => $rcode = CodeExtend::uniqidNumber(16, 'R')];
|
||||
} while (($model = WechatPaymentRefund::mk()->master()->where($check)->findOrEmpty())->isExists());
|
||||
// 初始化退款申请记录
|
||||
$model->save(['code' => $rcode, 'record_code' => $pcode, 'refund_amount' => $amount, 'refund_remark' => $reason]);
|
||||
$options = [
|
||||
@ -222,33 +232,36 @@ class PaymentService
|
||||
'out_refund_no' => $rcode,
|
||||
'notify_url' => static::withNotifyUrl($rcode, 'refund'),
|
||||
'amount' => [
|
||||
'refund' => intval(floatval($amount) * 100),
|
||||
'refund' => intval(strval(bcmul(strval($amount), '100', 0))),
|
||||
'total' => intval($record->getAttr('payment_amount') * 100),
|
||||
'currency' => 'CNY'
|
||||
]
|
||||
'currency' => 'CNY',
|
||||
],
|
||||
];
|
||||
if (strlen($reason) > 0) $options['reason'] = $reason;
|
||||
if (strlen($reason) > 0) {
|
||||
$options['reason'] = $reason;
|
||||
}
|
||||
$result = static::withPayment()->createRefund($options);
|
||||
if (in_array($result['code'] ?? $result['status'], ['SUCCESS', 'PROCESSING'])) {
|
||||
return self::refundSyncByQuery($rcode);
|
||||
} else {
|
||||
return [0, $result['message'] ?? $result['status']];
|
||||
}
|
||||
return [0, $result['message'] ?? $result['status']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步退款统计状态
|
||||
* @param string $pCode
|
||||
* @return \app\wechat\model\WechatPaymentRecord
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function refundSync(string $pCode): WechatPaymentRecord
|
||||
{
|
||||
$record = WechatPaymentRecord::mk()->where(['code' => $pCode])->findOrEmpty();
|
||||
if ($record->isEmpty()) throw new Exception('支付单不存在!');
|
||||
if ($record->getAttr('payment_status') < 1) throw new Exception("支付未完成!");
|
||||
if ($record->isEmpty()) {
|
||||
throw new Exception('支付单不存在!');
|
||||
}
|
||||
if ($record->getAttr('payment_status') < 1) {
|
||||
throw new Exception('支付未完成!');
|
||||
}
|
||||
// 最近一条记录,同步查询刷新
|
||||
$map = ['record_code' => $pCode];
|
||||
$last = WechatPaymentRefund::mk()->where($map)->order('id desc')->findOrEmpty();
|
||||
@ -264,17 +277,19 @@ class PaymentService
|
||||
|
||||
/**
|
||||
* 同步退款状态
|
||||
* @param string $rCode
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function refundSyncByQuery(string $rCode): array
|
||||
{
|
||||
$refund = WechatPaymentRefund::mk()->where(['code' => $rCode])->findOrEmpty();
|
||||
if ($refund->isEmpty()) return [0, '退款不存在!'];
|
||||
if ($refund->getAttr('refund_status')) return [1, '退款已完成!'];
|
||||
if ($refund->isEmpty()) {
|
||||
return [0, '退款不存在!'];
|
||||
}
|
||||
if ($refund->getAttr('refund_status')) {
|
||||
return [1, '退款已完成!'];
|
||||
}
|
||||
$result = static::withPayment()->queryRefund($rCode);
|
||||
$extra = [
|
||||
'refund_trade' => $result['refund_id'],
|
||||
@ -289,17 +304,20 @@ class PaymentService
|
||||
$refund->save($extra);
|
||||
// 同步支付订单
|
||||
static::refundSync($refund->getAttr('record_code'));
|
||||
if ($result['status'] === 'SUCCESS') return [1, '退款已完成!'];
|
||||
if ($result['status'] === 'PROCESSING') return [1, '退款处理中!'];
|
||||
if ($result['status'] === 'SUCCESS') {
|
||||
return [1, '退款已完成!'];
|
||||
}
|
||||
if ($result['status'] === 'PROCESSING') {
|
||||
return [1, '退款处理中!'];
|
||||
}
|
||||
return [0, $result['message'] ?? $result['status']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否完成支付
|
||||
* 判断是否完成支付.
|
||||
* @param string $oCode 原订单单号
|
||||
* @param string $oAmount 需支付金额
|
||||
* @param ?float $oPayed 已支付金额[赋值]
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isPayed(string $oCode, string $oAmount, ?float &$oPayed = null): bool
|
||||
{
|
||||
@ -307,10 +325,9 @@ class PaymentService
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已支付金额
|
||||
* 获取已支付金额.
|
||||
* @param string $oCode 原订单单号
|
||||
* @param ?float $oPayed 已支付金额[赋值]
|
||||
* @return float
|
||||
*/
|
||||
public static function withPayed(string $oCode, ?float &$oPayed = null): float
|
||||
{
|
||||
@ -319,12 +336,10 @@ class PaymentService
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化支付实现
|
||||
* @param array|null $config
|
||||
* @return \WePayV3\Order
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* 初始化支付实现.
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static function withPayment(?array $config = null): Order
|
||||
{
|
||||
@ -335,8 +350,6 @@ class PaymentService
|
||||
* 获取支付通知地址
|
||||
* @param string $order 订单单号
|
||||
* @param string $scene 支付场景
|
||||
* @param array $extra
|
||||
* @return string
|
||||
*/
|
||||
protected static function withNotifyUrl(string $order, string $scene = 'order', array $extra = []): string
|
||||
{
|
||||
@ -346,7 +359,7 @@ class PaymentService
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建支付行为
|
||||
* 创建支付行为.
|
||||
* @param string $openid 用户编号
|
||||
* @param string $oCode 订单单号
|
||||
* @param string $oName 订单标题
|
||||
@ -354,21 +367,22 @@ class PaymentService
|
||||
* @param string $pType 支付平台
|
||||
* @param string $pCode 子支付单号
|
||||
* @param string $pAmount 子支付金额
|
||||
* @return array
|
||||
* @throws \think\admin\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static function createPaymentAction(string $openid, string $oCode, string $oName, string $oAmount, string $pType, string $pCode, string $pAmount): array
|
||||
{
|
||||
// 检查是否已经支付
|
||||
if (static::withPayed($oCode, $oPayed) >= floatval($oAmount)) {
|
||||
throw new Exception("已经完成支付", 1);
|
||||
if (bccomp(strval(self::withPayed($oCode, $oPayed)), strval($oAmount), 2) >= 0) {
|
||||
throw new Exception('已经完成支付', 1);
|
||||
}
|
||||
if ($oPayed + floatval($pAmount) > floatval($oAmount)) {
|
||||
if (bccomp(bcadd(strval($oPayed), strval($pAmount), 2), strval($oAmount), 2) > 0) {
|
||||
throw new Exception('总支付超出金额', 0);
|
||||
}
|
||||
$map = ['order_code' => $oCode, 'payment_status' => 1];
|
||||
$model = WechatPaymentRecord::mk()->where($map)->findOrEmpty();
|
||||
if ($model->isExists()) throw new Exception("已经完成支付", 1);
|
||||
if ($model->isExists()) {
|
||||
throw new Exception('已经完成支付', 1);
|
||||
}
|
||||
// 写入订单支付行为
|
||||
$model->save([
|
||||
'type' => $pType,
|
||||
@ -383,20 +397,26 @@ class PaymentService
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新创建支付行为
|
||||
* 更新创建支付行为.
|
||||
* @param string $pCode 商户订单单号
|
||||
* @param string $pTrade 平台交易单号
|
||||
* @param string $pAmount 实际到账金额
|
||||
* @param array $extra 订单扩展数据
|
||||
* @return boolean|array
|
||||
* @return array|bool
|
||||
*/
|
||||
protected static function updatePaymentAction(string $pCode, string $pTrade, string $pAmount, array $extra = [])
|
||||
{
|
||||
// 更新支付记录
|
||||
$model = WechatPaymentRecord::mk()->where(['code' => $pCode])->findOrEmpty();
|
||||
if ($model->isEmpty()) return false;
|
||||
if ($model->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// 更新支付行为
|
||||
foreach ($extra as $k => $v) if (is_null($v)) unset($extra[$k]);
|
||||
foreach ($extra as $k => $v) {
|
||||
if (is_null($v)) {
|
||||
unset($extra[$k]);
|
||||
}
|
||||
}
|
||||
$model->save($extra + ['payment_trade' => $pTrade, 'payment_status' => 1, 'payment_amount' => $pAmount]);
|
||||
// 触发支付成功事件
|
||||
Library::$sapp->event->trigger('WechatPaymentSuccess', $model->refresh()->toArray());
|
||||
|
||||
@ -1,6 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | ThinkAdmin Plugin for ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
* | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | 官方网站: https://thinkadmin.top
|
||||
* +----------------------------------------------------------------------
|
||||
* | 开源协议 ( https://mit-license.org )
|
||||
* | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* | 会员特权 ( https://thinkadmin.top/vip-introduce )
|
||||
* +----------------------------------------------------------------------
|
||||
* | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
// | Wechat Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 Anyon <zoujingli@qq.com>
|
||||
@ -10,8 +26,7 @@
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-wechat
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// || github 代码仓库:https://github.com/zoujingli/think-plugs-wechat
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\wechat\service;
|
||||
@ -23,11 +38,12 @@ use think\admin\Service;
|
||||
use think\admin\storage\LocalStorage;
|
||||
use think\exception\HttpResponseException;
|
||||
use think\Response;
|
||||
use WeChat\Exceptions\InvalidResponseException;
|
||||
use WeChat\Exceptions\LocalCacheException;
|
||||
|
||||
/**
|
||||
* 微信接口调度服务
|
||||
* @class WechatService
|
||||
* @package app\wechat\serivce
|
||||
*
|
||||
* @method \WeChat\Card WeChatCard() static 微信卡券管理
|
||||
* @method \WeChat\Custom WeChatCustom() static 微信客服消息
|
||||
@ -103,13 +119,10 @@ use think\Response;
|
||||
*/
|
||||
class WechatService extends Service
|
||||
{
|
||||
|
||||
/**
|
||||
* 静态初始化对象
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
* @throws \think\admin\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function __callStatic(string $name, array $arguments)
|
||||
{
|
||||
@ -120,9 +133,8 @@ class WechatService extends Service
|
||||
if (sysconf('wechat.type') === 'api' || in_array($type, ['WePay', 'WePayV3'])) {
|
||||
if (class_exists($class)) {
|
||||
return new $class($type === 'WeMini' ? static::getWxconf() : static::getConfig());
|
||||
} else {
|
||||
throw new Exception("抱歉,接口模式无法实例 {$class} 对象!");
|
||||
}
|
||||
throw new Exception("抱歉,接口模式无法实例 {$class} 对象!");
|
||||
} else {
|
||||
[$appid, $appkey] = [sysconf('wechat.thr_appid'), sysconf('wechat.thr_appkey')];
|
||||
$data = ['class' => $name, 'appid' => $appid, 'time' => time(), 'nostr' => uniqid()];
|
||||
@ -135,52 +147,34 @@ class WechatService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析调用对象名称
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
private static function parseName(string $name): array
|
||||
{
|
||||
foreach (['WeChat', 'WeMini', 'WeOpen', 'WePayV3', 'WePay', 'ThinkService'] as $type) {
|
||||
if (strpos($name, $type) === 0) {
|
||||
[, $base] = explode($type, $name);
|
||||
return [$type, $base, "\\{$type}\\{$base}"];
|
||||
}
|
||||
}
|
||||
return ['-', '-', $name];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前微信APPID
|
||||
* @return string
|
||||
* @throws \think\admin\Exception
|
||||
* 获取当前微信APPID.
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getAppid(): string
|
||||
{
|
||||
if (static::getType() === 'api') {
|
||||
return sysconf('wechat.appid');
|
||||
} else {
|
||||
return sysconf('wechat.thr_appid');
|
||||
}
|
||||
return sysconf('wechat.thr_appid');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口授权模式
|
||||
* @return string
|
||||
* @throws \think\admin\Exception
|
||||
* 获取接口授权模式.
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getType(): string
|
||||
{
|
||||
$type = strtolower(sysconf('wechat.type'));
|
||||
if (in_array($type, ['api', 'thr'])) return $type;
|
||||
if (in_array($type, ['api', 'thr'])) {
|
||||
return $type;
|
||||
}
|
||||
throw new Exception('请在后台配置微信对接授权模式');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公众号配置参数
|
||||
* @param boolean $ispay 获取支付参数
|
||||
* @return array
|
||||
* @throws \think\admin\Exception
|
||||
* 获取公众号配置参数.
|
||||
* @param bool $ispay 获取支付参数
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getConfig(bool $ispay = false): array
|
||||
{
|
||||
@ -195,10 +189,9 @@ class WechatService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取小程序配置参数
|
||||
* @param boolean $ispay 获取支付参数
|
||||
* @return array
|
||||
* @throws \think\admin\Exception
|
||||
* 获取小程序配置参数.
|
||||
* @param bool $ispay 获取支付参数
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getWxconf(bool $ispay = false): array
|
||||
{
|
||||
@ -212,10 +205,8 @@ class WechatService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理支付证书配置
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws \think\admin\Exception
|
||||
* 处理支付证书配置.
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function withWxpayCert(array $options): array
|
||||
{
|
||||
@ -224,8 +215,8 @@ class WechatService extends Service
|
||||
if (empty($data['mch_id'])) {
|
||||
throw new Exception('无效的支付配置!');
|
||||
}
|
||||
$name1 = sprintf("wxpay/%s_%s_cer.pem", $data['mch_id'], md5($data['ssl_cer_text']));
|
||||
$name2 = sprintf("wxpay/%s_%s_key.pem", $data['mch_id'], md5($data['ssl_key_text']));
|
||||
$name1 = sprintf('wxpay/%s_%s_cer.pem', $data['mch_id'], md5($data['ssl_cer_text']));
|
||||
$name2 = sprintf('wxpay/%s_%s_key.pem', $data['mch_id'], md5($data['ssl_key_text']));
|
||||
$local = LocalStorage::instance();
|
||||
if ($local->has($name1, true) && $local->has($name2, true)) {
|
||||
$sslCer = $local->path($name1, true);
|
||||
@ -247,8 +238,7 @@ class WechatService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话名称
|
||||
* @return string
|
||||
* 获取会话名称.
|
||||
*/
|
||||
public static function getSsid(): string
|
||||
{
|
||||
@ -258,14 +248,13 @@ class WechatService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过网页授权获取粉丝信息
|
||||
* 通过网页授权获取粉丝信息.
|
||||
* @param string $source 回跳URL地址
|
||||
* @param integer $isfull 获取资料模式
|
||||
* @param boolean $redirect 是否直接跳转
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @param int $isfull 获取资料模式
|
||||
* @param bool $redirect 是否直接跳转
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getWebOauthInfo(string $source, int $isfull = 0, bool $redirect = true): array
|
||||
{
|
||||
@ -290,7 +279,8 @@ class WechatService extends Service
|
||||
$location = strstr("{$source}?", '?', true) . '?' . http_build_query($params);
|
||||
$oauthurl = $wechat->getOauthRedirect($location, $appid, $isfull ? 'snsapi_userinfo' : 'snsapi_base');
|
||||
throw new HttpResponseException(static::createRedirect($oauthurl, $redirect));
|
||||
} elseif (($token = $wechat->getOauthAccessToken($getVars['code'])) && isset($token['openid'])) {
|
||||
}
|
||||
if (($token = $wechat->getOauthAccessToken($getVars['code'])) && isset($token['openid'])) {
|
||||
$openid = $token['openid'];
|
||||
// 如果是虚拟账号,不保存会话信息,下次重新授权
|
||||
if (empty($token['is_snapshotuser'])) {
|
||||
@ -311,11 +301,11 @@ class WechatService extends Service
|
||||
}
|
||||
if ($getVars['rcode']) {
|
||||
throw new HttpResponseException(static::createRedirect(debase64url($getVars['rcode']), $redirect));
|
||||
} elseif ((empty($isfull) && !empty($openid)) || (!empty($isfull) && !empty($openid) && !empty($userinfo))) {
|
||||
return ['openid' => $openid, 'fansinfo' => $userinfo];
|
||||
} else {
|
||||
throw new Exception('Query params [rcode] not find.');
|
||||
}
|
||||
if ((empty($isfull) && !empty($openid)) || (!empty($isfull) && !empty($openid) && !empty($userinfo))) {
|
||||
return ['openid' => $openid, 'fansinfo' => $userinfo];
|
||||
}
|
||||
throw new Exception('Query params [rcode] not find.');
|
||||
} else {
|
||||
$result = static::ThinkServiceConfig()->oauth(self::getSsid(), $source, $isfull);
|
||||
[$openid, $userinfo] = [$result['openid'] ?? '', $result['fans'] ?? []];
|
||||
@ -333,34 +323,45 @@ class WechatService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* 网页授权链接跳转
|
||||
* @param string $location 跳转链接
|
||||
* @param boolean $redirect 强制跳转
|
||||
* @return \think\Response
|
||||
*/
|
||||
private static function createRedirect(string $location, bool $redirect = true): Response
|
||||
{
|
||||
return $redirect ? redirect($location) : response(join(";\n", [
|
||||
sprintf("sessionStorage.setItem('wechat.session','%s')", self::getSsid()),
|
||||
sprintf("location.replace('%s')", $location), ''
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信网页JSSDK签名参数
|
||||
* 获取微信网页JSSDK签名参数.
|
||||
* @param null|string $location 签名地址
|
||||
* @return array
|
||||
* @throws \WeChat\Exceptions\InvalidResponseException
|
||||
* @throws \WeChat\Exceptions\LocalCacheException
|
||||
* @throws \think\admin\Exception
|
||||
* @throws InvalidResponseException
|
||||
* @throws LocalCacheException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function getWebJssdkSign(?string $location = null): array
|
||||
{
|
||||
$location = $location ?: Library::$sapp->request->url(true);
|
||||
if (static::getType() === 'api') {
|
||||
return static::WeChatScript()->getJsSign($location);
|
||||
} else {
|
||||
}
|
||||
return static::ThinkServiceConfig()->jsSign($location);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析调用对象名称.
|
||||
*/
|
||||
private static function parseName(string $name): array
|
||||
{
|
||||
foreach (['WeChat', 'WeMini', 'WeOpen', 'WePayV3', 'WePay', 'ThinkService'] as $type) {
|
||||
if (strpos($name, $type) === 0) {
|
||||
[, $base] = explode($type, $name);
|
||||
return [$type, $base, "\\{$type}\\{$base}"];
|
||||
}
|
||||
}
|
||||
return ['-', '-', $name];
|
||||
}
|
||||
|
||||
/**
|
||||
* 网页授权链接跳转.
|
||||
* @param string $location 跳转链接
|
||||
* @param bool $redirect 强制跳转
|
||||
*/
|
||||
private static function createRedirect(string $location, bool $redirect = true): Response
|
||||
{
|
||||
return $redirect ? redirect($location) : response(join(";\n", [
|
||||
sprintf("sessionStorage.setItem('wechat.session','%s')", self::getSsid()),
|
||||
sprintf("location.replace('%s')", $location), '',
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +1,22 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | Payment Plugin for ThinkAdmin
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | 官方网站: https://thinkadmin.top
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | 开源协议 ( https://mit-license.org )
|
||||
* // | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* // | 会员免费 ( https://thinkadmin.top/vip-introduce )
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* // +----------------------------------------------------------------------
|
||||
*/
|
||||
use think\admin\service\RuntimeService;
|
||||
|
||||
// 加载基础文件
|
||||
|
||||
@ -1,16 +1,4 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
/*! 应用根路径,静态插件库路径,动态插件库路径 */
|
||||
let srcs = document.scripts[document.scripts.length - 1].src.split('/');
|
||||
|
||||
@ -1,16 +1,4 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
$(function () {
|
||||
|
||||
|
||||
@ -1,16 +1,4 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define(function () {
|
||||
|
||||
|
||||
@ -1,16 +1,4 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define(function () {
|
||||
|
||||
|
||||
@ -1,16 +1,4 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
define(function () {
|
||||
|
||||
|
||||
@ -1,17 +1,5 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 默认盒边框样式
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 新样式
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
fieldset {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
> .layui-layout-admin {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-black-1 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-blue-1 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-green-1 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-red-1 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
> .layui-layout-admin {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-black-2 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-blue-2 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-green-2 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-red-2 {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
.layui-layout-theme-white > .layui-layout-admin {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
::selection {
|
||||
|
||||
@ -1,17 +1,5 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
@font-face {
|
||||
|
||||
@ -1,18 +1,6 @@
|
||||
@charset "UTF-8";
|
||||
@import "_config.less";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2024 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
body, html {
|
||||
|
||||
@ -1,17 +1,5 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
::-webkit-scrollbar {
|
||||
|
||||
31
think
Executable file → Normal file
31
think
Executable file → Normal file
@ -1,20 +1,23 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | Static Plugin for ThinkAdmin
|
||||
// +----------------------------------------------------------------------
|
||||
// | 版权所有 2014~2025 ThinkAdmin [ thinkadmin.top ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | 官方网站: https://thinkadmin.top
|
||||
// +----------------------------------------------------------------------
|
||||
// | 开源协议 ( https://mit-license.org )
|
||||
// | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
// +----------------------------------------------------------------------
|
||||
// | gitee 代码仓库:https://gitee.com/zoujingli/think-plugs-static
|
||||
// | github 代码仓库:https://github.com/zoujingli/think-plugs-static
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | Payment Plugin for ThinkAdmin
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | 版权所有 2014~2026 ThinkAdmin [ thinkadmin.top ]
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | 官方网站: https://thinkadmin.top
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | 开源协议 ( https://mit-license.org )
|
||||
* // | 免责声明 ( https://thinkadmin.top/disclaimer )
|
||||
* // | 会员免费 ( https://thinkadmin.top/vip-introduce )
|
||||
* // +----------------------------------------------------------------------
|
||||
* // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||||
* // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||||
* // +----------------------------------------------------------------------
|
||||
*/
|
||||
use think\admin\service\RuntimeService;
|
||||
|
||||
// 加载基础文件
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user