Anyon e634118a22 refactor(plugin): 迁移 v8 插件化组件体系
将 v6 中直接放在本地 app 的后台与微信能力迁移为 v8 插件组件,并把运行时基础能力沉淀到独立插件包。

主要内容:

- 新增 think-library、system、worker、static、install 等基础插件包。

- 新增 account、payment、wechat-client、wechat-service、wemall、wuma 等业务插件包。

- 移除 v6 的 app/admin 与 app/wechat 本地应用实现,改由插件分发接管。

- 将 Helper 能力彻底并入 System,统一为 plugin\system\helper\* 命名空间。

- 同步插件迁移发布清单与根 route 占位,保证安装发布流程可复现。
2026-05-08 15:30:46 +08:00

142 lines
3.9 KiB
PHP

<?php
declare(strict_types=1);
/**
* +----------------------------------------------------------------------
* | ThinkAdmin Plugin for ThinkAdminDeveloper
* +----------------------------------------------------------------------
* | Copyright (c) 2014~2026 ThinkAdmin [ thinkadmin.top ]
* +----------------------------------------------------------------------
* | Official Website: https://thinkadmin.top
* +----------------------------------------------------------------------
* | Licensed: https://mit-license.org
* | Disclaimer: https://thinkadmin.top/disclaimer
* | Vip Rights: https://thinkadmin.top/vip-introduce
* +----------------------------------------------------------------------
* | Gitee Repository: https://gitee.com/zoujingli/ThinkAdmin
* | Github Repository: https://github.com/zoujingli/ThinkAdmin
* +----------------------------------------------------------------------
*/
namespace plugin\wuma\controller\source;
use plugin\wuma\model\PluginWumaSourceProduce;
use plugin\wuma\model\PluginWumaSourceTemplate;
use think\admin\Controller;
use think\admin\extend\CodeToolkit;
use think\admin\helper\QueryHelper;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
/**
* 溯源模板管理.
* @class Template
*/
class Template extends Controller
{
/**
* 溯源模板管理.
* @menu true
* @auth true
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
*/
public function index()
{
$this->type = $this->get['type'] ?? 'index';
PluginWumaSourceTemplate::mQuery()->layTable(function () {
$this->title = '溯源模板管理';
}, function (QueryHelper $query) {
$query->like('code,name')->like('tags', ',')->dateBetween('create_time');
$query->where(['status' => intval($this->type === 'index')]);
});
}
/**
* 添加溯源模板
* @auth true
*/
public function add()
{
$this->title = '添加溯源模板';
PluginWumaSourceTemplate::mForm('form');
}
/**
* 编辑溯源模板
* @auth true
*/
public function edit()
{
$this->title = '编辑溯源模板';
PluginWumaSourceTemplate::mForm('form');
}
/**
* 复制溯源模板
* @auth true
*/
public function copy()
{
$this->title = '复制溯源模板';
PluginWumaSourceTemplate::mForm('form');
}
/**
* 修改模板状态
* @auth true
*/
public function state()
{
PluginWumaSourceTemplate::mSave();
}
/**
* 删除溯源模板
* @auth true
* @throws DbException
*/
public function remove()
{
$subsql = PluginWumaSourceTemplate::mk()->whereIn('id', str2arr(input('id', '')))->field('code')->buildSql();
$batchs = PluginWumaSourceProduce::mk()->whereRaw("tcode in {$subsql}")->distinct()->column('tcode');
if (count($batchs) > 0) {
$this->error('删除失败,以下模板已经使用!<br><b>' . join('</b><br><b>', $batchs) . '</b>');
}
PluginWumaSourceTemplate::mDelete();
}
/**
* 复制表单处理.
*/
protected function _copy_form_filter(array &$data)
{
if ($this->request->isPost()) {
$data['code'] = CodeToolkit::uniqidDate(16, 'T');
unset($data['id'], $data['create_time']);
}
}
/**
* 表单数据处理.
*/
protected function _form_filter(array &$data)
{
if (empty($data['code'])) {
$data['code'] = CodeToolkit::uniqidDate(16, 'T');
}
}
/**
* 表单结果处理.
*/
protected function _form_result(bool $result)
{
if ($result) {
$this->success('编辑模板成功', 'javascript:history.back()');
}
}
}