feat(config): add finance rules, activity rules, and real expert application flow
这个提交包含在:
@@ -550,6 +550,57 @@ app.get('/api/companions/:id', async (req: Request, res: Response) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 大神资质与实名入驻真实申请接口
|
||||
app.post('/api/companions/apply', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const { userId, name, idCard, track, hourlyRate, tags, avatar, gender } = req.body;
|
||||
if (!name || !name.trim()) {
|
||||
return res.status(400).json({ code: 40000, message: '真实姓名不能为空' });
|
||||
}
|
||||
if (!idCard || !idCard.trim()) {
|
||||
return res.status(400).json({ code: 40000, message: '身份证号不能为空' });
|
||||
}
|
||||
|
||||
// 微信内容安全检测
|
||||
const sec = contentSecurityService.checkText(`${name} ${track || ''} ${(tags || []).join(' ')}`);
|
||||
if (!sec.pass) {
|
||||
return res.status(400).json({ code: sec.code, message: sec.message });
|
||||
}
|
||||
|
||||
// 校验价格与标签
|
||||
const expertRulesConfig = await repo.getPlatformConfigByKey('expert_rules');
|
||||
const rules = expertRulesConfig?.valueJson || { minHourlyRate: 30, maxHourlyRate: 500, maxTagsCount: 6 };
|
||||
if (hourlyRate) {
|
||||
const rateNum = Number(hourlyRate);
|
||||
if (rateNum < (rules.minHourlyRate || 30) || rateNum > (rules.maxHourlyRate || 500)) {
|
||||
return res.status(400).json({
|
||||
code: 40000,
|
||||
message: `服务单价需在 ¥${rules.minHourlyRate || 30} - ¥${rules.maxHourlyRate || 500} 之间`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const companion = await repo.applyCompanion({
|
||||
userId: Number(userId) || 1001,
|
||||
name: name.trim(),
|
||||
idCard: idCard.trim(),
|
||||
track: track || '同城陪吃',
|
||||
hourlyRate: Number(hourlyRate) || rules.defaultHourlyRate || 88,
|
||||
tags: Array.isArray(tags) ? tags.slice(0, rules.maxTagsCount || 6) : [],
|
||||
avatar,
|
||||
gender
|
||||
});
|
||||
|
||||
res.json({
|
||||
code: 20000,
|
||||
data: companion,
|
||||
message: '大神实名认证申请已提交,等待运营人工审核'
|
||||
});
|
||||
} catch (err: any) {
|
||||
res.status(400).json({ code: 40000, message: err.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/companions/:id/audit', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const companionId = Number(req.params.id);
|
||||
|
||||
在新工单中引用
屏蔽一个用户