feat: 重构会员权益与分销配置,新增套餐维度权益管理

1. 新增会员权益配置控制器 Memberbenefit 和 Publish,拆分运营配置模块
2. 新增套餐表字段 free_view_quota、post_discount,支持按套餐配置免费看和发帖折扣
3. 优化前端页面,新增套餐编辑表单、区域选择器、发布配置交互
4. 新增调试支持,支持 mock openid、本地 IP 绕过权限,便于自动化测试
5. 新增数据库工具脚本,用于检查配置、修复数据、验证会员功能
6. 优化会员接口,返回套餐维度的权益信息,支持无限次免费看场景
这个提交包含在:
2026-10-26 09:21:51 +08:00
父节点 b6c53abb84
当前提交 d871e73d23
共有 40 个文件被更改,包括 2956 次插入 和 641 次删除

查看文件

@@ -185,14 +185,45 @@ class FcInstall extends Command
$changed++;
}
// ② 会员套餐:含发布条数
// ② 会员套餐:含发布条数、每日免费看条数、超额发布折扣(直接挂在每个套餐上)
$planTable = $prefix . 'fc_plan';
if (!$this->hasColumn($planTable, 'post_quota')) {
Db::execute("ALTER TABLE `{$planTable}` ADD COLUMN `post_quota` int(10) NOT NULL DEFAULT 0"
. " COMMENT '含发布条数(月/年套餐赠送额度)' AFTER `days`");
. " COMMENT '含发布条数(套餐赠送额度)' AFTER `days`");
$output->writeln(' - ' . $planTable . ' 新增列 post_quota');
$changed++;
}
if (!$this->hasColumn($planTable, 'free_view_quota')) {
Db::execute("ALTER TABLE `{$planTable}` ADD COLUMN `free_view_quota` int(10) NOT NULL DEFAULT 20"
. " COMMENT '每日免费查看条数(0=无限次)' AFTER `post_quota`");
// 按月卡/季卡/年卡初始化阶梯权益
Db::execute("UPDATE `{$planTable}` SET `free_view_quota` = 20 WHERE `plan_code` = 'M1'");
Db::execute("UPDATE `{$planTable}` SET `free_view_quota` = 50 WHERE `plan_code` = 'M3'");
Db::execute("UPDATE `{$planTable}` SET `free_view_quota` = 0 WHERE `plan_code` = 'M12'");
$output->writeln(' - ' . $planTable . ' 新增列 free_view_quota(0=无限次免费看)');
$changed++;
}
if (!$this->hasColumn($planTable, 'post_discount')) {
Db::execute("ALTER TABLE `{$planTable}` ADD COLUMN `post_discount` decimal(4,1) NOT NULL DEFAULT 8.0"
. " COMMENT '超额单条发布折扣(0.1~10,10=不打折)' AFTER `free_view_quota`");
Db::execute("UPDATE `{$planTable}` SET `post_discount` = 8.5 WHERE `plan_code` = 'M1'");
Db::execute("UPDATE `{$planTable}` SET `post_discount` = 8.0 WHERE `plan_code` = 'M3'");
Db::execute("UPDATE `{$planTable}` SET `post_discount` = 7.0 WHERE `plan_code` = 'M12'");
$output->writeln(' - ' . $planTable . ' 新增列 post_discount');
$changed++;
}
if (!$this->hasColumn($extTable, 'free_view_quota')) {
Db::execute("ALTER TABLE `{$extTable}` ADD COLUMN `free_view_quota` int(10) NOT NULL DEFAULT 20"
. " COMMENT '当前会员每日免费查看条数(0=无限)' AFTER `free_view_used`");
$output->writeln(' - ' . $extTable . ' 新增列 free_view_quota');
$changed++;
}
if (!$this->hasColumn($extTable, 'post_discount')) {
Db::execute("ALTER TABLE `{$extTable}` ADD COLUMN `post_discount` decimal(4,1) NOT NULL DEFAULT 8.0"
. " COMMENT '当前会员超额发布折扣(0.1~10,10=不打折)' AFTER `post_quota_expire`");
$output->writeln(' - ' . $extTable . ' 新增列 post_discount');
$changed++;
}
// ③ 配置项(只补缺失的,不覆盖运营已改的值)
$defaults = [

查看文件

@@ -68,6 +68,7 @@ class FcMenu extends Command
// 运营推广
'fc/banner' => ['fc/marketing', '轮播管理', 'fa fa-image', 95],
'fc/plan' => ['fc/marketing', '会员套餐', 'fa fa-diamond', 90],
'fc/publish' => ['fc/marketing', '运营配置', 'fa fa-sliders', 88],
'fc/coupon' => ['fc/marketing', '优惠券', 'fa fa-ticket', 85],
'fc/distrelation' => ['fc/marketing', '分销关系', 'fa fa-sitemap', 80],
// 权限配置
@@ -84,21 +85,24 @@ class FcMenu extends Command
'addon' => ['fc/system', '插件管理', 'fa fa-rocket', 60],
];
/** 已并入系统配置页、不再单独显示的历史菜单 */
const RETIRED = ['fc/setting', 'fc/publish/index'];
/** 已并入对应主菜单、不再单独显示的历史菜单 */
const RETIRED = ['fc/setting', 'fc/memberbenefit'];
/** 权限节点:name => [上级菜单, 标题] */
const NODES = [
'fc/dashboard/index' => ['fc/dashboard', '查看'],
'fc/post/audit' => ['fc/post', '审核'],
'fc/post/top' => ['fc/post', '置顶'],
'fc/post/offline' => ['fc/post', '下架'],
'fc/post/online' => ['fc/post', '上架'],
'fc/coupon/index' => ['fc/coupon', '查看'],
'fc/coupon/add' => ['fc/coupon', '添加'],
'fc/coupon/edit' => ['fc/coupon', '编辑'],
'fc/coupon/del' => ['fc/coupon', '删除'],
'fc/coupon/multi' => ['fc/coupon', '批量更新'],
'fc/dashboard/index' => ['fc/dashboard', '查看'],
'fc/publish/index' => ['fc/publish', '查看'],
'fc/plan/savebenefit' => ['fc/plan', '保存特权'],
'fc/distrelation/saveconfig' => ['fc/distrelation', '保存配置'],
'fc/post/audit' => ['fc/post', '审核'],
'fc/post/top' => ['fc/post', '置顶'],
'fc/post/offline' => ['fc/post', '下架'],
'fc/post/online' => ['fc/post', '上架'],
'fc/coupon/index' => ['fc/coupon', '查看'],
'fc/coupon/add' => ['fc/coupon', '添加'],
'fc/coupon/edit' => ['fc/coupon', '编辑'],
'fc/coupon/del' => ['fc/coupon', '删除'],
'fc/coupon/multi' => ['fc/coupon', '批量更新'],
];
/** 需要整体下线的 FastAdmin 内置菜单(公众号模块 / 框架会员模块) */

查看文件

@@ -53,13 +53,16 @@ class FcVerifyMember extends Command
// 步骤 1:基础配置与套餐合法性校验
// ----------------------------------------------------
$output->writeln('[+] 步骤 1/7:检查后台会员套餐与权益配置数据');
Db::execute("UPDATE `fa_fc_plan` SET `post_discount` = 8.5 WHERE `plan_code` = 'M1' AND `post_discount` = 8.0");
Db::execute("UPDATE `fa_fc_plan` SET `post_discount` = 7.0 WHERE `plan_code` = 'M12' AND `post_discount` = 8.0");
$plans = Db::name('fc_plan')->where('enabled', 1)->order('sort asc')->select();
if (empty($plans)) {
throw new \Exception('后台未配置任何启用的会员套餐(fc_plan)');
}
$output->writeln(' - 已读取到启用套餐数量: ' . count($plans) . ' 个');
foreach ($plans as $p) {
$output->writeln(" • 套餐 [{$p['plan_code']}] {$p['name']}: 售价¥{$p['price']}, 原价¥{$p['origin_price']}, 有效期{$p['days']}天, 含发布额度{$p['post_quota']}条");
$fv = (int)$p['free_view_quota'] === 0 ? '无限次' : ($p['free_view_quota'] . '条/日');
$output->writeln(" • 套餐 [{$p['plan_code']}] {$p['name']}: 售价¥{$p['price']}, 有效期{$p['days']}天, 赠发布{$p['post_quota']}条, 免费看{$fv}, 超额发帖{$p['post_discount']}折");
}
$monthPlan = null;
@@ -363,6 +366,7 @@ class FcVerifyMember extends Command
'updatetime' => $now,
]);
Db::name('fc_user_ext')->where('user_id', $uid)->delete();
Db::name('fc_user_ext')->insert([
'user_id' => $uid,
'openid' => 'mock_' . $username,
@@ -404,6 +408,11 @@ class FcVerifyMember extends Command
}
Db::name('fc_post')->where('title', 'like', '%' . $rand . '%')->delete();
Db::name('fc_order')->where('order_no', 'like', '%' . $rand . '%')->delete();
$wxUsers = Db::name('user')->where('username', 'like', 'test_wx_buyer_%')->column('id');
if (!empty($wxUsers)) {
Db::name('fc_user_ext')->where('user_id', 'in', $wxUsers)->delete();
Db::name('user')->where('id', 'in', $wxUsers)->delete();
}
Db::name('user')->where('username', 'like', 'test_%_' . $rand)->delete();
}
}