feat: 对接真实数据并移除前端假数据

本次提交完成多模块真实数据对接,移除前端硬编码假数据:
- 新增后端接口:区域列表、未读消息数、详情页评价列表、最低提现金额
- 前端对应修改:移除首页/列表/详情页硬编码区域选项、未读消息数、评价内容,分销页最低提现金额
- 修复登录页微信授权不伪造code、营业执照不伪造文件名,避免绕过校验
- 新增集成测试用例,验证真实数据对接正确性
这个提交包含在:
2026-10-19 11:48:41 +08:00
父节点 63fdfe87d7
当前提交 81a48feaad
共有 25 个文件被更改,包括 383 次插入 和 40 次删除

查看文件

@@ -16,7 +16,7 @@ class Distribution extends V1
{
/**
* D1 分销概览
* GET /api/v1/distribution/overview → {totalCommission,settled,withdrawable,todayCommission,teamCount,l1Count,l2Count,inviteCode,posterUrl}
* GET /api/v1/distribution/overview → {totalCommission,settled,withdrawable,todayCommission,teamCount,l1Count,l2Count,inviteCode,posterUrl,minWithdraw}
*/
public function overview()
{
@@ -48,6 +48,8 @@ class Distribution extends V1
'l2Count' => $l2,
'inviteCode' => (string)$ext['invite_code'],
'posterUrl' => '',
// 最低提现金额(后台「分销设置」下发,替代前端写死的 50)
'minWithdraw' => (float)$this->cfg('dist.minWithdraw', 50),
]);
}

查看文件

@@ -11,6 +11,7 @@ use think\Db;
* GET /api/v1/home/categories H2 分类导航
* GET /api/v1/home/search/hot H3 热门搜索
* GET /api/v1/home/feed H4 信息流(支持 lat/lng + sort=nearby 距离排序)
* GET /api/v1/home/areas H5 区域列表(用户端下拉筛选,读后台「区域管理」)
*/
class Home extends V1
{
@@ -81,6 +82,26 @@ class Home extends V1
$this->ok(array_values($keywords));
}
/**
* H5 区域列表(用户端筛选用)
* GET /api/v1/home/areas → [string]
* 规则:仅 enabled=1,按 sort asc;与后台「区域管理」(fc_area) 同源,
* 前端首页/信息列表/发布页的「区域」选项均由此下发,不再前端写死。
*/
public function areas()
{
$rows = Db::name('fc_area')
->where('enabled', 1)
->order('sort asc')
->select();
$list = [];
foreach ($rows as $row) {
$list[] = (string)$row['name'];
}
$this->ok($list);
}
/**
* H4 信息流
* GET /api/v1/home/feed {categoryId?,keyword?,area?,sort?,lat?,lng?,page,size}

查看文件

@@ -9,6 +9,7 @@ use think\Db;
* 路由:
* GET /api/v1/message/list M1 消息列表
* POST /api/v1/message/:id/read M2 标记已读
* GET /api/v1/message/unread-count M3 未读消息数(首页角标)
*
* 说明:user_id=0 表示全体广播消息,用户可见。
*/
@@ -68,4 +69,23 @@ class Message extends V1
$this->ok(['read' => true]);
}
/**
* M3 未读消息数(首页消息角标)
* GET /api/v1/message/unread-count → {count}
* 规则:统计当前用户可见(user_id = 本人 或 0 广播)且 isread=0 的消息条数,
* 替代前端原先写死的角标数字。
*/
public function unreadCount()
{
$user = $this->auth();
$uid = (int)$user['id'];
$count = (int)Db::name('fc_message')
->where('user_id', 'in', [$uid, 0])
->where('isread', 0)
->count();
$this->ok(['count' => $count]);
}
}

查看文件

@@ -17,6 +17,7 @@ use think\Db;
* GET /api/v1/post/:id P5 信息详情
* POST /api/v1/post/:id/pay-view P6 付费查看联系方式
* POST /api/v1/post/:id/comment P7 发表评价
* GET /api/v1/post/:id/comments P10 评价列表(详情页「用户评价」)
*
* 计费口径(后台「发布与费用配置」维护,真源=fc_config);
* 金额一律由服务端按配置计算,**不接受客户端传入金额**;
@@ -809,6 +810,42 @@ class Post extends V1
$this->ok(['commentId' => $commentId]);
}
/**
* P10 评价列表(详情页「用户评价」)
* GET /api/v1/post/:id/comments → [{id,user,score,content,reply,createdAt}]
* 规则:仅 status=1(正常/审核通过)的评价;置顶优先,其余按时间倒序。
* 替代前端详情页原先写死的两条假评价。
*/
public function comments()
{
$id = $this->routeId();
if ($id <= 0) {
$this->fail('信息不存在', 404);
}
$rows = Db::name('fc_comment')->alias('co')
->join('user u', 'u.id = co.user_id', 'LEFT')
->where('co.post_id', $id)
->where('co.status', 1)
->field('co.id, co.score, co.content, co.reply, co.top, co.createtime, u.nickname AS nickname')
->order('co.top desc, co.id desc')
->select();
$list = [];
foreach ($rows as $row) {
$list[] = [
'id' => (int)$row['id'],
'user' => (string)$row['nickname'],
'score' => (int)$row['score'],
'content' => (string)$row['content'],
'reply' => (string)$row['reply'],
'createdAt' => $this->iso($row['createtime']),
];
}
$this->ok($list);
}
/**
* 读取路由 :id 参数(兼容 POST 体/查询串传入)
* @return int