feat(admin): HQ手机号编辑、合伙人子账号日志与子账号H5体验
支持 HQ 账户改手机号(格式校验)、合伙人日志包含子账号且子账号不显示主账号信息;改手机号时清除微信绑定。合伙人 H5 子账号页签与我的页、录入门店底部按钮及上传失败提示。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -64,23 +64,39 @@ export class AdminPartnerLogsService {
|
||||
return where;
|
||||
}
|
||||
|
||||
private async expandPrimaryWithChildren(primaryIds: bigint[]): Promise<bigint[]> {
|
||||
if (!primaryIds.length) return [];
|
||||
const children = await this.prisma.partnerAccount.findMany({
|
||||
where: { parentAccountId: { in: primaryIds } },
|
||||
select: { id: true },
|
||||
});
|
||||
return [...primaryIds, ...children.map((c) => c.id)];
|
||||
}
|
||||
|
||||
private async resolvePartnerAccountIds(
|
||||
query: AdminPartnerLogsQueryDto,
|
||||
): Promise<bigint[] | undefined> {
|
||||
if (query.partnerAccountId) return [BigInt(query.partnerAccountId)];
|
||||
if (query.partnerId) return [BigInt(query.partnerId)];
|
||||
if (query.partnerId) {
|
||||
return this.expandPrimaryWithChildren([BigInt(query.partnerId)]);
|
||||
}
|
||||
|
||||
const accountWhere: Prisma.PartnerAccountWhereInput = { isPrimary: 1 };
|
||||
if (query.companyName) accountWhere.companyName = { contains: query.companyName };
|
||||
if (query.phone) accountWhere.phone = { contains: query.phone };
|
||||
|
||||
if (query.companyName || query.phone) {
|
||||
if (query.phone) {
|
||||
const accounts = await this.prisma.partnerAccount.findMany({
|
||||
where: accountWhere,
|
||||
where: { phone: { contains: query.phone } },
|
||||
select: { id: true },
|
||||
take: 200,
|
||||
});
|
||||
return accounts.map((a) => a.id);
|
||||
}
|
||||
|
||||
if (query.companyName) {
|
||||
const primaries = await this.prisma.partnerAccount.findMany({
|
||||
where: { isPrimary: 1, companyName: { contains: query.companyName } },
|
||||
select: { id: true },
|
||||
take: 100,
|
||||
});
|
||||
return accounts.map((a) => a.id);
|
||||
return this.expandPrimaryWithChildren(primaries.map((a) => a.id));
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -102,7 +118,16 @@ export class AdminPartnerLogsService {
|
||||
const accounts = accountIds.length
|
||||
? await this.prisma.partnerAccount.findMany({
|
||||
where: { id: { in: accountIds } },
|
||||
select: { id: true, name: true, phone: true, companyName: true },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
phone: true,
|
||||
companyName: true,
|
||||
isPrimary: true,
|
||||
parentAccountId: true,
|
||||
staffRole: true,
|
||||
parent: { select: { id: true, companyName: true } },
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
@@ -110,13 +135,19 @@ export class AdminPartnerLogsService {
|
||||
|
||||
return rows.map((row) => {
|
||||
const account = accountMap.get(row.partnerAccountId.toString());
|
||||
const isSubAccount = !!account?.parentAccountId;
|
||||
const primaryId = isSubAccount
|
||||
? account?.parent?.id?.toString() ?? null
|
||||
: account?.id.toString() ?? null;
|
||||
return {
|
||||
id: row.id.toString(),
|
||||
partnerId: row.partnerAccountId.toString(),
|
||||
partnerId: primaryId ?? row.partnerAccountId.toString(),
|
||||
partnerAccountId: row.partnerAccountId.toString(),
|
||||
accountName: account?.name ?? null,
|
||||
accountPhone: account?.phone ?? null,
|
||||
companyName: account?.companyName ?? null,
|
||||
companyName: isSubAccount ? null : account?.companyName ?? null,
|
||||
isSubAccount,
|
||||
staffRole: account?.staffRole ?? null,
|
||||
category: resolvePartnerLogCategory(row.eventName),
|
||||
eventName: row.eventName,
|
||||
clientApp: row.clientApp,
|
||||
|
||||
Reference in New Issue
Block a user