feat(invite): 重构邀请关系建立流程并优化相关功能

- 新增 bindRefereeRelation 接口替换原有的 createInviteRelation 接口
- 优化邀请参数解析逻辑,支持 uid_xxx 格式的邀请码
- 重构 handleInviteRelation 函数,使用新的绑定推荐关系接口
- 新增 checkAndHandleInviteRelation 和 manualHandleInviteRelation 函数
- 优化首页和订单列表的相关逻辑,以支持新的邀请关系建立流程
- 更新文档中的相关描述,如将"下级成员"改为"团队成员"
This commit is contained in:
2025-08-23 12:18:32 +08:00
parent 0b83e67ac1
commit 7708968f53
9 changed files with 343 additions and 50 deletions

View File

@@ -33,6 +33,20 @@ export interface InviteRelationParam {
inviteTime?: string;
}
/**
* 绑定推荐关系参数
*/
export interface BindRefereeParam {
// 推荐人ID
refereeId: number;
// 被推荐人ID (可选,如果不传则使用当前登录用户)
userId?: number;
// 推荐来源
source?: string;
// 场景值
scene?: string;
}
/**
* 邀请统计数据
*/
@@ -120,7 +134,7 @@ export async function generateInviteCode(inviterId: number) {
}
/**
* 建立邀请关系
* 建立邀请关系 (旧接口,保留兼容性)
*/
export async function createInviteRelation(data: InviteRelationParam) {
const res = await request.post<ApiResult<unknown>>(
@@ -133,6 +147,32 @@ export async function createInviteRelation(data: InviteRelationParam) {
return Promise.reject(new Error(res.message));
}
/**
* 绑定推荐关系 (新接口)
*/
export async function bindRefereeRelation(data: BindRefereeParam) {
try {
const res = await request.post<ApiResult<unknown>>(
'/shop/shop-dealer-referee',
{
refereeId: data.refereeId,
userId: data.userId,
source: data.source || 'qrcode',
scene: data.scene
}
);
if (res.code === 0) {
return res.data;
}
throw new Error(res.message || '绑定推荐关系失败');
} catch (error: any) {
console.error('绑定推荐关系API调用失败:', error);
throw new Error(error.message || '绑定推荐关系失败');
}
}
/**
* 处理邀请场景值
*/