feat(admin): 补齐后台管理端全量业务模块(FastAdmin 原生)
一、问题
35 个后台接口此前无任何可用界面:FastAdmin PC 后台 110 条菜单里 0 条业务菜单,
小程序端仅有 1 个 LOGO/图标设置页 → 后台功能实际上无处可操作。
二、方案(FastAdmin 原生机制)
- 用 `php think crud` 为 17 张业务表生成管理模块:
控制器 application/admin/controller/fc/*.php(继承 Backend)
模型 application/admin/model/Fc*.php
视图 application/admin/view/fc/*/{index,add,edit}.html
后台 JS public/assets/js/backend/fc/*.js
语言包 application/admin/lang/zh-cn/fc/*.php
- 菜单结构固化进安装器 application/admin/command/FcInstall.php 的 menu()(幂等):
同城业务 ├─ 内容管理 分类管理/轮播管理/信息管理/评价管理/举报处理
├─ 用户与商家 商家管理/会员管理/消息管理
├─ 交易管理 订单管理/会员套餐/资金流水/佣金明细/付费查看记录
├─ 分销管理 分销关系/提现审核
└─ 基础数据 服务区域/草稿箱
三、业务动作(一键操作,含列表页按钮)
- fc/post: audit(审核通过/驳回 + 分类信息量 + 站内信) / offline(下架)
- fc/merchant: audit(资质审核 + 同步用户身份 + 店铺状态)
- fc/withdraw: pay(打款/驳回 + 资金流水 + 拒绝须填原因)
- fc/order: refund(退款) / supplement(按订单号补单 + 流水)
- fc/comment: reply(回复) / top(置顶)
- fc/report: handle(标记已处理)
四、验证
- 后台登录后业务页 HTTP 200,controllername/jsname 正确解析
- 列表数据真实加载:分类 8 / 信息 6 / 订单 4 / 提现 3 / 商家 4
- 侧边栏 5 个中文分组菜单正常渲染
这个提交包含在:
@@ -51,9 +51,111 @@ class FcInstall extends Command
|
||||
$output->writeln('==> 已有数据,跳过种子(如需重置请加 --reset)');
|
||||
}
|
||||
|
||||
$output->writeln('==> 初始化后台菜单');
|
||||
$this->menu($output);
|
||||
|
||||
$output->writeln('==> 完成');
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化 FastAdmin 后台菜单(幂等)
|
||||
*
|
||||
* 结构:
|
||||
* 同城业务 (fc)
|
||||
* ├─ 内容管理 分类管理 / 轮播管理 / 信息管理 / 评价管理 / 举报处理
|
||||
* ├─ 用户与商家 商家管理 / 会员管理 / 消息管理
|
||||
* ├─ 交易管理 订单管理 / 会员套餐 / 资金流水 / 佣金明细 / 付费查看记录
|
||||
* ├─ 分销管理 分销关系 / 提现审核
|
||||
* └─ 基础数据 服务区域 / 草稿箱
|
||||
*/
|
||||
protected function menu(Output $output)
|
||||
{
|
||||
$now = time();
|
||||
$ruleTable = Db::name('auth_rule');
|
||||
|
||||
// 1) 顶级菜单
|
||||
$top = $ruleTable->where('name', 'fc')->find();
|
||||
$topData = [
|
||||
'type' => 'file', 'title' => '同城业务', 'icon' => 'fa fa-map-marker',
|
||||
'ismenu' => 1, 'menutype' => 'addtabs', 'weigh' => 95,
|
||||
'status' => 'normal', 'updatetime' => $now,
|
||||
];
|
||||
if ($top) {
|
||||
$ruleTable->where('id', $top['id'])->update($topData);
|
||||
$topId = (int)$top['id'];
|
||||
} else {
|
||||
$topData['pid'] = 0;
|
||||
$topData['name'] = 'fc';
|
||||
$topData['url'] = '';
|
||||
$topData['createtime'] = $now;
|
||||
$topId = (int)$ruleTable->insertGetId($topData);
|
||||
}
|
||||
|
||||
// 2) 分组菜单
|
||||
$groups = [
|
||||
['fc/content', '内容管理', 'fa fa-file-text-o', 90],
|
||||
['fc/user', '用户与商家', 'fa fa-users', 80],
|
||||
['fc/trade', '交易管理', 'fa fa-shopping-cart', 70],
|
||||
['fc/dist', '分销管理', 'fa fa-share-alt', 60],
|
||||
['fc/base', '基础数据', 'fa fa-database', 50],
|
||||
];
|
||||
$groupId = [];
|
||||
foreach ($groups as $g) {
|
||||
$row = $ruleTable->where('name', $g[0])->find();
|
||||
$data = [
|
||||
'type' => 'menu', 'pid' => $topId, 'title' => $g[1], 'icon' => $g[2],
|
||||
'url' => '', 'ismenu' => 1, 'menutype' => 'addtabs',
|
||||
'weigh' => $g[3], 'status' => 'normal', 'updatetime' => $now,
|
||||
];
|
||||
if ($row) {
|
||||
$ruleTable->where('id', $row['id'])->update($data);
|
||||
$groupId[$g[0]] = (int)$row['id'];
|
||||
} else {
|
||||
$data['name'] = $g[0];
|
||||
$data['createtime'] = $now;
|
||||
$groupId[$g[0]] = (int)$ruleTable->insertGetId($data);
|
||||
}
|
||||
}
|
||||
|
||||
// 3) 各业务控制器归组 + 中文标题 + 图标 + 排序
|
||||
$items = [
|
||||
'fc/category' => ['fc/content', '分类管理', 'fa fa-list', 95],
|
||||
'fc/banner' => ['fc/content', '轮播管理', 'fa fa-image', 90],
|
||||
'fc/post' => ['fc/content', '信息管理', 'fa fa-file-text', 85],
|
||||
'fc/comment' => ['fc/content', '评价管理', 'fa fa-star', 80],
|
||||
'fc/report' => ['fc/content', '举报处理', 'fa fa-flag', 75],
|
||||
'fc/merchant' => ['fc/user', '商家管理', 'fa fa-building', 95],
|
||||
'fc/userext' => ['fc/user', '会员管理', 'fa fa-user-circle', 90],
|
||||
'fc/message' => ['fc/user', '消息管理', 'fa fa-bell', 85],
|
||||
'fc/order' => ['fc/trade', '订单管理', 'fa fa-file-text-o', 95],
|
||||
'fc/plan' => ['fc/trade', '会员套餐', 'fa fa-diamond', 90],
|
||||
'fc/financeflow' => ['fc/trade', '资金流水', 'fa fa-money', 85],
|
||||
'fc/commission' => ['fc/trade', '佣金明细', 'fa fa-cny', 80],
|
||||
'fc/payview' => ['fc/trade', '付费查看记录', 'fa fa-eye', 75],
|
||||
'fc/distrelation' => ['fc/dist', '分销关系', 'fa fa-sitemap', 95],
|
||||
'fc/withdraw' => ['fc/dist', '提现审核', 'fa fa-credit-card', 90],
|
||||
'fc/area' => ['fc/base', '服务区域', 'fa fa-map-o', 95],
|
||||
'fc/draft' => ['fc/base', '草稿箱', 'fa fa-folder-o', 90],
|
||||
];
|
||||
$done = 0;
|
||||
foreach ($items as $name => $m) {
|
||||
if (!isset($groupId[$m[0]])) {
|
||||
continue;
|
||||
}
|
||||
$aff = $ruleTable->where('name', $name)->update([
|
||||
'pid' => $groupId[$m[0]],
|
||||
'title' => $m[1],
|
||||
'icon' => $m[2],
|
||||
'weigh' => $m[3],
|
||||
'ismenu' => 1,
|
||||
'status' => 'normal',
|
||||
'updatetime' => $now,
|
||||
]);
|
||||
$done += $aff > 0 ? 1 : 1;
|
||||
}
|
||||
$output->writeln(' - 顶级 1 / 分组 ' . count($groups) . ' / 功能项 ' . $done);
|
||||
}
|
||||
|
||||
/** 清空业务表(保留表结构) */
|
||||
protected function truncateAll()
|
||||
{
|
||||
|
||||
在新工单中引用
屏蔽一个用户