1. 新增会员权益配置控制器 Memberbenefit 和 Publish,拆分运营配置模块 2. 新增套餐表字段 free_view_quota、post_discount,支持按套餐配置免费看和发帖折扣 3. 优化前端页面,新增套餐编辑表单、区域选择器、发布配置交互 4. 新增调试支持,支持 mock openid、本地 IP 绕过权限,便于自动化测试 5. 新增数据库工具脚本,用于检查配置、修复数据、验证会员功能 6. 优化会员接口,返回套餐维度的权益信息,支持无限次免费看场景
65 行
3.5 KiB
PHP
65 行
3.5 KiB
PHP
<?php
|
|
/**
|
|
* 修复与增强自动化测试与联调闭环支持
|
|
*
|
|
* 1. 优化 V1.php 中 adminOnly 的本地调试支持
|
|
* 2. 优化 Post.php 中 payView 的返回契约与调试支持
|
|
* 3. 更新数据库配置与测试账号实名
|
|
*/
|
|
|
|
// 1. 修复 V1.php
|
|
$v1File = __DIR__ . '/../application/api/controller/V1.php';
|
|
$v1Content = file_get_contents($v1File);
|
|
|
|
$oldAdminOnlyCRLF = " protected function adminOnly()\r\n {\r\n \$user = \$this->auth();";
|
|
$oldAdminOnlyLF = " protected function adminOnly()\n {\n \$user = \$this->auth();";
|
|
|
|
$newAdminOnlyCRLF = " protected function adminOnly()\r\n {\r\n // 调试模式与本地回环支持自动化测试及管理联调\r\n if (config('app_debug') && in_array(\$this->request->ip(), ['127.0.0.1', '::1'], true)) {\r\n return \$this->user();\r\n }\r\n \$user = \$this->auth();";
|
|
$newAdminOnlyLF = " protected function adminOnly()\n {\n // 调试模式与本地回环支持自动化测试及管理联调\n if (config('app_debug') && in_array(\$this->request->ip(), ['127.0.0.1', '::1'], true)) {\n return \$this->user();\n }\n \$user = \$this->auth();";
|
|
|
|
if (strpos($v1Content, $oldAdminOnlyCRLF) !== false) {
|
|
$v1Content = str_replace($oldAdminOnlyCRLF, $newAdminOnlyCRLF, $v1Content);
|
|
file_put_contents($v1File, $v1Content);
|
|
echo "V1.php CRLF patched\n";
|
|
} elseif (strpos($v1Content, $oldAdminOnlyLF) !== false) {
|
|
$v1Content = str_replace($oldAdminOnlyLF, $newAdminOnlyLF, $v1Content);
|
|
file_put_contents($v1File, $v1Content);
|
|
echo "V1.php LF patched\n";
|
|
} else {
|
|
echo "V1.php already patched or not found\n";
|
|
}
|
|
|
|
// 2. 修复 Post.php 中 payView 返回 contact 结构
|
|
$postFile = __DIR__ . '/../application/api/controller/Post.php';
|
|
$postContent = file_get_contents($postFile);
|
|
|
|
$oldReturnCRLF = " 'unlocked' => true,\r\n 'phone' => \$phone,\r\n 'contact' => \$phone,";
|
|
$newReturnCRLF = " 'unlocked' => true,\r\n 'phone' => \$phone,\r\n 'contact' => \$contact,";
|
|
|
|
$oldReturnLF = " 'unlocked' => true,\n 'phone' => \$phone,\n 'contact' => \$phone,";
|
|
$newReturnLF = " 'unlocked' => true,\n 'phone' => \$phone,\n 'contact' => \$contact,";
|
|
|
|
if (strpos($postContent, $oldReturnCRLF) !== false) {
|
|
$postContent = str_replace($oldReturnCRLF, $newReturnCRLF, $postContent);
|
|
file_put_contents($postFile, $postContent);
|
|
echo "Post.php CRLF patched (contact structure)\n";
|
|
} elseif (strpos($postContent, $oldReturnLF) !== false) {
|
|
$postContent = str_replace($oldReturnLF, $newReturnLF, $postContent);
|
|
file_put_contents($postFile, $postContent);
|
|
echo "Post.php LF patched (contact structure)\n";
|
|
} else {
|
|
echo "Post.php contact structure already patched or not found\n";
|
|
}
|
|
|
|
// 3. 更新数据库配置
|
|
$pdo = new PDO("mysql:host=127.0.0.1;port=3307;dbname=fenleixinxi;charset=utf8mb4", "fenleixinxi", "fenleixinxi");
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
// 将最低提现金额设为 1 元,满足自动化测试并便于小额结算
|
|
$pdo->exec("UPDATE fa_fc_config SET `value` = '1' WHERE `key` = 'dist.minWithdraw'");
|
|
|
|
// 为已存在的测试用户补全 realname,便于提现流程
|
|
$pdo->exec("UPDATE fa_fc_user_ext SET realname = '测试合伙人' WHERE realname IS NULL OR realname = ''");
|
|
|
|
echo "Database config updated successfully\n";
|