fix(companion): 去除合成虚拟大神的假评分/价格/服务(改为诚实档案)

- getCompanionById 对非真实大神档案不再虚构 rating/orderCount/price/voice/服务包,状态为休息中、审核未申请,并返回 isCompanion=false

- 小程序大神详情页对非大神档案隐藏服务与预约入口,显示'该用户尚未认证为大神';移除页面假默认值

- 新增回归护栏 companion-profile-honesty.spec.ts(82 套件/619 用例全绿)
这个提交包含在:
xcbyy
2026-10-19 09:19:15 +08:00
父节点 f1f8952e97
当前提交 85e00e296f
共有 4 个文件被更改,包括 152 次插入 和 52 次删除

查看文件

@@ -770,6 +770,8 @@ export class MysqlRepository {
async getCompanionById(id: number | string): Promise<any> {
let c = await this.resolveCompanionRow(id);
// 是否为"非真实大神档案"的合成资料(用于对其隐藏虚构评分/价格/服务等)
let synthetic = false;
if (!c) {
const rawId = String(id).trim();
const numId = Number(rawId);
@@ -822,30 +824,31 @@ export class MysqlRepository {
c = {
id: userRow?.id || postRow?.user_id || cmtRow?.user_id || (!isNaN(numId) && numId > 0 ? numId : 2005),
user_id: userRow?.id || postRow?.user_id || cmtRow?.user_id || null,
name: postRow?.author || userRow?.nickname || cmtRow?.author || '同城认证达人',
name: postRow?.author || userRow?.nickname || cmtRow?.author || '同城用户',
avatar: postRow?.avatar || userRow?.avatar || cmtRow?.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=300',
gender: userRow?.gender === '男' ? '男' : '女',
age: 22,
gender: userRow?.gender === '男' ? '男' : (userRow?.gender === '女' ? '女' : '保密'),
age: 0,
track: postRow?.category === 'game' ? '线上电竞' : '同城陪吃',
rank_name: postRow?.tag || userRow?.role || '同城认证达人',
hourly_rate: postRow?.category === 'game' ? 88 : 128,
voice_duration: 16,
voice_title: '真实原声介绍',
rating: 4.96,
order_count: Number(userRow?.order_count) || 86,
status: '接单中',
audit_status: '已通过',
tags: postRow?.topics || JSON.stringify(['同城约伴', '随和健谈', '准时守信']),
custom_bio: postRow?.content || userRow?.signature || cmtRow?.content || '专业同城生活陪伴,热情礼貌,守时诚信。',
custom_city: postRow?.location || '北京市 · 朝阳/海淀',
rank_name: postRow?.tag || userRow?.role || '',
hourly_rate: 0,
voice_duration: 0,
voice_title: '',
rating: 0,
order_count: 0,
status: '休息中',
audit_status: '未申请',
tags: postRow?.topics || JSON.stringify([]),
custom_bio: postRow?.content || userRow?.signature || cmtRow?.content || '',
custom_city: postRow?.location || '',
custom_photos: postImages.length > 0 ? postImages : null
};
synthetic = true;
}
if (!c) return null;
const game = c.track === 'OFFLINE_MEAL' ? '美食陪吃' : (c.track === 'OFFLINE_SING' ? '同城陪唱' : (c.track === 'OFFLINE_DRINK' ? '下午茶陪喝' : (c.track === 'OFFLINE_PLAY' ? '同城陪玩' : (c.track || c.game || '同城生活陪伴'))));
const price = Number(c.hourly_rate) || 68;
let parsedTags = ['高颜值', '性格好', '秒回消息', '文明健康'];
let parsedTags = synthetic ? [] : ['高颜值', '性格好', '秒回消息', '文明健康'];
if (c.tags) {
try {
const t = typeof c.tags === 'string' ? JSON.parse(c.tags) : c.tags;
@@ -905,32 +908,35 @@ export class MysqlRepository {
avatar: c.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=300',
coverImage: (c.custom_photos && c.custom_photos[0]) || c.avatar || 'https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=800',
gender: c.gender === '男' ? 'male' : 'female',
age: Number(c.age) || 22,
age: synthetic ? 0 : (Number(c.age) || 22),
game: game,
track: c.track || 'OFFLINE_MEAL',
city: c.custom_city || '北京市 · 朝阳/海淀',
rankTag: c.rank_name || '认证大神',
levelTag: '金牌认证',
price: price,
hourlyRate: price,
rating: Number(c.rating) || 5.0,
orderCount: Number(c.order_count) || 120,
status: c.status || '接单中',
auditStatus,
certStatus,
city: synthetic ? (c.custom_city || '') : (c.custom_city || '北京市 · 朝阳/海淀'),
rankTag: c.rank_name || (synthetic ? '' : '认证大神'),
levelTag: synthetic ? '普通用户' : '金牌认证',
price: synthetic ? 0 : price,
hourlyRate: synthetic ? 0 : price,
rating: synthetic ? 0 : (Number(c.rating) || 5.0),
orderCount: synthetic ? 0 : (Number(c.order_count) || 120),
status: synthetic ? '休息中' : (c.status || '接单中'),
auditStatus: synthetic ? '未申请' : auditStatus,
certStatus: synthetic ? 0 : certStatus,
rejectReason: c.reject_reason || '',
isOnline: c.status === '接单中',
voiceDuration: Number(c.voice_duration) || 15,
isOnline: synthetic ? false : c.status === '接单中',
isCompanion: !synthetic,
voiceDuration: synthetic ? 0 : (Number(c.voice_duration) || 15),
voiceType: 'voice',
voiceTitle: c.voice_title || '语音招呼',
bio: c.custom_bio || '专业同城生活陪伴,热情礼貌,守时诚信。',
voiceTitle: synthetic ? '' : (c.voice_title || '语音招呼'),
bio: c.custom_bio || (synthetic ? '' : '专业同城生活陪伴,热情礼貌,守时诚信。'),
tags: parsedTags,
photos: c.custom_photos || [
c.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=400',
'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=400',
'https://images.unsplash.com/photo-1524504388940-b1c1722653e1?w=400'
],
services: customServices.length > 0 ? customServices : defaultServices
photos: c.custom_photos || (synthetic
? [c.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=400']
: [
c.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=400',
'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=400',
'https://images.unsplash.com/photo-1524504388940-b1c1722653e1?w=400'
]),
services: synthetic ? [] : (customServices.length > 0 ? customServices : defaultServices)
};
}