合伙人 H5 改造
CI / verify (pull_request) Has been cancelled

This commit is contained in:
2026-07-16 15:04:56 +08:00
parent fd5427c7ea
commit f1dc23c54c
21 changed files with 817 additions and 614 deletions
@@ -468,33 +468,56 @@ export class StoreService {
async partnerDashboard(partnerAccountId: bigint) {
const { account, primaryId } = await this.resolvePartnerScope(partnerAccountId);
this.assertPrimaryAccount(account);
const partnerStoreIds = await this.prisma.store.findMany({
where: { partnerAccountId: primaryId },
select: { id: true },
const primaryAccount = await this.prisma.partnerAccount.findUniqueOrThrow({
where: { id: primaryId },
});
const storeIds = partnerStoreIds.map((s) => s.id);
const [storeCount, orderCount, recentStores, pendingAuditCount, recentNotices] = await Promise.all([
this.prisma.store.count({ where: { partnerAccountId: primaryId } }),
this.prisma.order.count({
where: await this.partnerCityService.buildPartnerOrderWhere(primaryId),
}),
const orderCount = await this.prisma.order.count({
where: await this.partnerCityService.buildPartnerOrderWhere(primaryId),
});
let storeWhere: { partnerAccountId: bigint; id?: { in: bigint[] } } = {
partnerAccountId: primaryId,
};
if (this.isSubAccount(account)) {
const storeIds = await this.getStoreIdsCreatedByAccount(partnerAccountId);
if (storeIds.length === 0) {
return {
storeCount: 0,
orderCount,
companyName: primaryAccount.companyName ?? '',
recentStores: [],
pendingAuditCount: 0,
notifications: [],
};
}
storeWhere = { partnerAccountId: primaryId, id: { in: storeIds } };
}
const storeIdsForNotices = (
await this.prisma.store.findMany({
where: storeWhere,
select: { id: true },
})
).map((s) => s.id);
const [storeCount, recentStores, pendingAuditCount, recentNotices] = await Promise.all([
this.prisma.store.count({ where: storeWhere }),
this.prisma.store.findMany({
where: { partnerAccountId: primaryId },
where: storeWhere,
select: { id: true, name: true, status: true, auditStatus: true, createdAt: true },
orderBy: { createdAt: 'desc' },
take: 10,
}),
this.prisma.store.count({
where: { partnerAccountId: primaryId, auditStatus: 'PENDING' },
where: { ...storeWhere, auditStatus: 'PENDING' },
}),
storeIds.length === 0
storeIdsForNotices.length === 0
? Promise.resolve([])
: this.prisma.commonEvent.findMany({
where: {
eventType: 'STORE_AUDIT',
refType: 'STORE',
refId: { in: storeIds },
refId: { in: storeIdsForNotices },
status: { in: ['APPROVED', 'REJECTED'] },
actorType: 'HQ',
},
@@ -515,7 +538,7 @@ export class StoreService {
return {
storeCount,
orderCount,
companyName: account.companyName ?? '',
companyName: primaryAccount.companyName ?? '',
recentStores: serializeBigInt(recentStores),
pendingAuditCount,
notifications: serializeBigInt(