fix(order): 关闭按用户 id 撞库档案 id 的订单归属兜底,避免潜在越权读取

- getOrdersForUser/countOrdersForUser 仅按 companions.user_id 关联本人档案,不再使用 companions.id = 用户 id

- 补充回归断言;116 套件/758 用例全绿;线上已验证用户订单仍正常
这个提交包含在:
xcbyy
2026-10-22 11:33:47 +08:00
父节点 ab600e1c82
当前提交 32defce50c
共有 2 个文件被更改,包括 6 次插入 和 4 次删除

查看文件

@@ -1530,12 +1530,12 @@ export class MysqlRepository {
buyer_id = ?
OR expert_id = ?
OR claimed_by = ?
OR companion_name IN (SELECT name FROM companions WHERE user_id = ? OR id = ?)
OR companion_name IN (SELECT name FROM companions WHERE user_id = ?)
)
AND ${statusWhere}
ORDER BY created_at DESC
${limitSql}
`, [uid, uid, uid, uid, uid]);
`, [uid, uid, uid, uid]);
return rows;
}
@@ -1550,10 +1550,10 @@ export class MysqlRepository {
buyer_id = ?
OR expert_id = ?
OR claimed_by = ?
OR companion_name IN (SELECT name FROM companions WHERE user_id = ? OR id = ?)
OR companion_name IN (SELECT name FROM companions WHERE user_id = ?)
)
AND ${statusWhere}
`, [uid, uid, uid, uid, uid]);
`, [uid, uid, uid, uid]);
return Number((rows && rows[0] && rows[0].c) || 0);
}