feat(M08-A): 接入顾客端个人中心
This commit is contained in:
@@ -137,6 +137,36 @@ export class MemberProfileService {
|
||||
};
|
||||
}
|
||||
|
||||
async getMyProfile(input: {
|
||||
tenantId: string;
|
||||
userId: string;
|
||||
ledgerLimit?: number;
|
||||
}) {
|
||||
const [rows] = await this.pool.execute<MemberRow[]>(
|
||||
`SELECT u.id, u.status, u.nickname, u.phone,
|
||||
u.created_at AS createdAt, u.last_login_at AS lastLoginAt
|
||||
FROM qipai_users u
|
||||
WHERE u.tenant_id = ? AND u.id = ? AND u.user_type = 'CUSTOMER'
|
||||
AND u.deleted_at IS NULL
|
||||
LIMIT 1`,
|
||||
[input.tenantId, input.userId]
|
||||
);
|
||||
if (!rows[0]) throw new MemberProfileError('MEMBER_NOT_FOUND');
|
||||
const actor = {
|
||||
tenantId: input.tenantId,
|
||||
userId: input.userId,
|
||||
access: { roles: ['CUSTOMER'], capabilities: ['profile.read'], storeIds: [] }
|
||||
};
|
||||
return {
|
||||
...await this.memberCard(actor, rows[0]),
|
||||
recentLedger: await this.recentLedger(
|
||||
input.tenantId,
|
||||
String(rows[0].id),
|
||||
input.ledgerLimit ?? 10
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
private async memberCard(actor: MemberActor, row: MemberRow) {
|
||||
const memberId = String(row.id);
|
||||
const [walletRows] = await this.pool.execute<WalletSummaryRow[]>(
|
||||
|
||||
Reference in New Issue
Block a user