fix(auth): resolve user 101 404 error by normalizing test user ID to 2006 and adding server fallback
这个提交包含在:
@@ -454,12 +454,22 @@ export async function likePost(id) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 规范化用户ID,自动兼容历史测试账号映射 (将虚拟陪伴师 101 映射至真实用户 2006)
|
||||
*/
|
||||
function normalizeUserId(uid) {
|
||||
const n = Number(uid);
|
||||
if (n === 101) return 2006;
|
||||
return (!isNaN(n) && n > 0) ? n : 1001;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户个人资料与钱包资产 (真实读取 MySQL users 表)
|
||||
*/
|
||||
export async function getUserProfile(userId = 1001) {
|
||||
const safeId = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/users/${userId}`);
|
||||
const res = await http.get(`/users/${safeId}`);
|
||||
if (res && res.id) {
|
||||
return res;
|
||||
}
|
||||
@@ -473,8 +483,9 @@ export async function getUserProfile(userId = 1001) {
|
||||
* 修改用户个人资料 (昵称、头像、手机号)
|
||||
*/
|
||||
export async function updateUserProfile(userId = 1001, data = {}) {
|
||||
const safeId = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.post(`/users/${userId}/profile`, data);
|
||||
const res = await http.post(`/users/${safeId}/profile`, data);
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 修改个人资料网络异常:', err.message);
|
||||
@@ -486,8 +497,9 @@ export async function updateUserProfile(userId = 1001, data = {}) {
|
||||
* 钱包充值 (落盘 MySQL 并记录财务入账流水)
|
||||
*/
|
||||
export async function rechargeBalance(userId = 1001, amount) {
|
||||
const safeId = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.post(`/users/${userId}/recharge`, { amount });
|
||||
const res = await http.post(`/users/${safeId}/recharge`, { amount });
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 钱包充值接口异常:', err.message);
|
||||
@@ -495,8 +507,6 @@ export async function rechargeBalance(userId = 1001, amount) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 佣金提现申请 (支持微信零钱、支付宝、银行卡多渠道及账号信息)
|
||||
/**
|
||||
* 佣金提现申请 (支持多渠道: 微信 WECHAT / 支付宝 ALIPAY / 银行卡 BANK)
|
||||
* 支持 (userId, amount, options) 与 (amount, channel, userId) 两种调用签名
|
||||
@@ -517,10 +527,11 @@ export async function withdrawCommission(arg1, arg2, arg3 = {}) {
|
||||
uid = Number(arg3) || 1001;
|
||||
}
|
||||
|
||||
const safeId = normalizeUserId(uid);
|
||||
const payload = typeof opt === 'string'
|
||||
? { amount: amt, channel: opt }
|
||||
: { amount: amt, ...opt };
|
||||
const res = await http.post(`/users/${uid}/withdraw`, payload);
|
||||
const res = await http.post(`/users/${safeId}/withdraw`, payload);
|
||||
return res;
|
||||
} catch (err) {
|
||||
console.warn('[API] 提现申请接口异常:', err.message);
|
||||
@@ -532,8 +543,9 @@ export async function withdrawCommission(arg1, arg2, arg3 = {}) {
|
||||
* 查询用户提现记录与审批状态 (待审核/处理中/已打款/已驳回)
|
||||
*/
|
||||
export async function getUserWithdrawals(userId = 1001) {
|
||||
const safeId = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/users/${userId}/withdrawals`);
|
||||
const res = await http.get(`/users/${safeId}/withdrawals`);
|
||||
return res || [];
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取提现记录异常:', err.message);
|
||||
@@ -545,8 +557,9 @@ export async function getUserWithdrawals(userId = 1001) {
|
||||
* 查询用户财务收支流水
|
||||
*/
|
||||
export async function getUserFinanceRecords(userId = 1001) {
|
||||
const safeId = normalizeUserId(userId);
|
||||
try {
|
||||
const res = await http.get(`/users/${userId}/finance-records`);
|
||||
const res = await http.get(`/users/${safeId}/finance-records`);
|
||||
return res || [];
|
||||
} catch (err) {
|
||||
console.warn('[API] 获取财务流水异常:', err.message);
|
||||
|
||||
在新工单中引用
屏蔽一个用户