feat(admin): 信息置顶 + 发布与费用配置(免费/付费开关、单条与月年卡价格含条数)
需求落地: - 置顶:fc/post 新增 top 动作(批量置顶/取消置顶 + 站内消息通知),列表加「置顶/取消置顶」工具栏按钮、 行内按钮与置顶状态徽章;置顶信息在用户端首页与「我的发布」中优先展示(Home::feed 按 is_top desc) - 发布与费用配置(新增页面:同城业务 → 基础数据 → 发布与费用配置,fc/publish): 发布模式(免费发布 / 付费发布)、会员单条发布价格、按月(价格 + 含条数)、按年(价格 + 含条数); 真源为 fc_config 的 post.*,保存时同步 fc_plan 的月卡(M1)/年卡(M12) 价格与 post_quota - FcInstall:新增 post.* 六项配置(默认免费发布,避免上线即撞付费墙);fc_user_ext 加 post_quota_left / post_quota_expire(套餐额度与有效期)、fc_plan 加 post_quota;新增 upgradePublish() 幂等升级老库并同步月/年卡 - tools/verify-api.mjs:新增 P9 发布配置 / P8 我的发布 契约校验,P1 发布改为「免费模式/额度内发布」并按付费模式容错 - 语言包与视图同步中文,均通过 php -l 与 node --check
这个提交包含在:
@@ -145,12 +145,44 @@ async function userHome() {
|
||||
let newPostId = 0
|
||||
|
||||
async function userPost() {
|
||||
const created = await ok200('P1 POST /post/create', 'POST', '/post/create',
|
||||
{ categoryId: 3, title: '接口验证·九成新显示器转让', content: '接口端到端验证用数据,可忽略。',
|
||||
contact: '验证账号', phone: '13800001111', area: '南明区', address: '花果园',
|
||||
price: 300, priceUnit: '元', tags: '验证,自提' },
|
||||
true, (d) => (d && d.postId && Number(d.auditStatus) === 0 ? '' : 'postId/auditStatus 不符(BR-04 应为 0)'))
|
||||
newPostId = created && created.postId ? Number(created.postId) : 0
|
||||
// P9 发布配置:发布模式(免费/付费)+ 单条与月/年卡价格条数 + 我的额度(v1.0.7)
|
||||
const pub = await ok200('P9 GET /post/publish-config', 'GET', '/post/publish-config', null, true,
|
||||
(d) => (d && ['free', 'paid'].indexOf(d.mode) > -1 && typeof d.singlePrice === 'number'
|
||||
&& typeof d.monthPrice === 'number' && typeof d.monthQuota === 'number'
|
||||
&& typeof d.yearPrice === 'number' && typeof d.yearQuota === 'number'
|
||||
&& typeof d.quotaLeft === 'number' ? '' : '缺 mode/价格/含条数/额度字段'))
|
||||
|
||||
// 能否免费发布:免费模式 / 有套餐额度 / 今日免费额度未用完
|
||||
const canFreePost = !!pub && (pub.mode === 'free'
|
||||
|| Number(pub.quotaLeft) > 0
|
||||
|| (Number(pub.freePerDay) - Number(pub.freeUsedToday)) > 0)
|
||||
|
||||
if (canFreePost) {
|
||||
const created = await ok200('P1 POST /post/create', 'POST', '/post/create',
|
||||
{ categoryId: 3, title: '接口验证·九成新显示器转让', content: '接口端到端验证用数据,可忽略。',
|
||||
contact: '验证账号', phone: '13800001111', area: '南明区', address: '花果园',
|
||||
price: 300, priceUnit: '元', tags: '验证,自提', plan: 'free' },
|
||||
true, (d) => (d && d.postId && Number(d.auditStatus) === 0 ? '' : 'postId/auditStatus 不符(BR-04 应为 0)'))
|
||||
newPostId = created && created.postId ? Number(created.postId) : 0
|
||||
} else {
|
||||
await expectFail('P1 · 付费模式下无额度须选发布方式', 'POST', '/post/create',
|
||||
{ categoryId: 3, title: '接口验证·无额度', content: 'x' }, true, '请选择发布方式')
|
||||
check('闭环 · 用户发布', false, '付费模式下本账号无发布额度,跳过闭环')
|
||||
}
|
||||
|
||||
// P8 我的发布:状态计数 + 列表契约(v1.0.7 起「我的发布」有独立接口)
|
||||
await ok200('P8 GET /post/mine', 'GET', '/post/mine?page=1&size=10', null, true,
|
||||
(d) => (!isPager(d) ? '分页结构不符'
|
||||
: (d.counts && typeof d.counts.all === 'number' && typeof d.counts.pending === 'number'
|
||||
&& typeof d.counts.passed === 'number' && typeof d.counts.rejected === 'number'
|
||||
&& typeof d.counts.offline === 'number' ? '' : '缺 counts(全部/待审核/已通过/已驳回/已下架)')))
|
||||
if (newPostId) {
|
||||
const mine = await call('GET', '/post/mine?status=pending&page=1&size=50', null, true)
|
||||
check('P8 · 刚发布的信息出现在「我的发布 → 待审核」',
|
||||
mine.json && mine.json.code === 0
|
||||
&& (mine.json.data.list || []).some((x) => Number(x.id) === newPostId),
|
||||
'未找到 #' + newPostId)
|
||||
}
|
||||
|
||||
await expectFail('P1 · 分类必填 (BR-03)', 'POST', '/post/create', { title: 'x', content: 'x' }, true, '分类不能为空')
|
||||
await expectFail('P1 · 标题必填 (BR-03)', 'POST', '/post/create', { categoryId: 3, content: 'x' }, true, '标题不能为空')
|
||||
|
||||
在新工单中引用
屏蔽一个用户