fix(referral): auto-create profile for legacy users on getMyInfo
Users registered before referral-service was deployed have no profile row. getMyInfo() now auto-provisions a profile on first access instead of throwing NotFoundException. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
13ab4ba1f3
commit
825e619224
|
|
@ -107,13 +107,16 @@ export class ReferralService {
|
||||||
return { referralCode: saved.referralCode };
|
return { referralCode: saved.referralCode };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取我的推荐信息 */
|
/** 获取我的推荐信息(老用户自动补建档案) */
|
||||||
async getMyInfo(userId: string): Promise<ReferralInfo> {
|
async getMyInfo(userId: string): Promise<ReferralInfo> {
|
||||||
const profile = await this.profileRepo.findByUserId(userId);
|
let profile = await this.profileRepo.findByUserId(userId);
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
throw new NotFoundException('推荐档案不存在');
|
// 推荐服务上线前注册的老用户,按需自动创建推荐档案
|
||||||
|
this.logger.log(`老用户自动补建推荐档案: userId=${userId}`);
|
||||||
|
await this.createProfile({ userId, usedCode: null });
|
||||||
|
profile = await this.profileRepo.findByUserId(userId);
|
||||||
}
|
}
|
||||||
return this.toInfo(profile);
|
return this.toInfo(profile!);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 验证推荐码是否有效 */
|
/** 验证推荐码是否有效 */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue