feat: Admin定价管理界面 + 定价DB配置化 (P2)

This commit is contained in:
yuzhiran
2026-06-12 09:52:04 +08:00
parent a55cb56be2
commit d379d181e4
10 changed files with 361 additions and 104 deletions
@@ -163,6 +163,25 @@ export class AdminController {
return { success: true }
}
// --- Pricing Management ---
@Get('pricing')
async getPricing() {
const cfg = await this.configModel.findOne({ key: 'pricing' }).exec()
if (cfg) return cfg.value
return DEFAULT_PRICING
}
@Post('pricing/save')
async savePricing(@Body() body: any) {
await this.configModel.findOneAndUpdate(
{ key: 'pricing' },
{ key: 'pricing', value: body, description: '定价配置' },
{ upsert: true },
).exec()
return { success: true }
}
@Get('questions')
async getQuestions() {
const cfg = await this.configModel.findOne({ key: 'daily_questions' }).exec()
@@ -191,6 +210,24 @@ const DEFAULT_CONFIG = {
},
}
const DEFAULT_PRICING = {
interview: { pricePerSession: 500, creditsPerPurchase: 1 },
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300, creditsPerPurchase: 1 },
resumeDownload: { pricePerDownload: 200, creditsPerPurchase: 1 },
plans: {
growth: {
price: 1990, durationDays: 30,
credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 },
features: ['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题推送', '参考回答思路', '公司真题库', '简历优化 20 次/月', '简历下载 10 次/月'],
},
sprint: {
price: 4990, durationDays: 30,
credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 },
features: ['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '学习路径推荐', '真人导师 1v1 点评(每月 1 次)', '简历精修(每月 1 次)', '内推优先', '简历优化 50 次/月', '简历下载 30 次/月'],
},
},
}
const DEFAULT_QUESTIONS = [
{ position: '通用', category: 'behavioral', question: '请做一个简单的自我介绍,突出你的核心优势和职业目标。', referenceAnswer: '建议结构:1) 基本信息 2) 教育背景与专业方向 3) 实习/项目经历 4) 核心优势 5) 职业目标' },
{ position: '前端工程师', category: 'technical', question: '请用 JavaScript 实现一个深拷贝函数,并说明可能存在的问题。', referenceAnswer: '可使用递归遍历,注意循环引用用 WeakMap 处理,特殊类型如 Date/RegExp/Map/Set 需单独处理。' },