feat: add access number routing and admin list improvements

This commit is contained in:
hectorzhao
2026-07-15 15:45:27 +08:00
parent 27c464246b
commit 3e114ee729
19 changed files with 547 additions and 508 deletions
+19
View File
@@ -114,4 +114,23 @@ describe('TenantsService', () => {
_sum: { amountCents: true },
}));
});
it('sorts management rows by today spend descending with a stable name tie-breaker', async () => {
const prisma = createPrismaMock();
prisma.tenant.findMany.mockResolvedValue([
{ id: 'tenant-1', name: '乙企业', code: 'T1', status: 'active', enterpriseCertifications: [] },
{ id: 'tenant-2', name: '甲企业', code: 'T2', status: 'active', enterpriseCertifications: [] },
{ id: 'tenant-3', name: '丙企业', code: 'T3', status: 'active', enterpriseCertifications: [] },
]);
prisma.smsMessageRecord.groupBy.mockResolvedValue([
{ tenantId: 'tenant-1', _sum: { amountCents: 300 } },
{ tenantId: 'tenant-2', _sum: { amountCents: 300 } },
{ tenantId: 'tenant-3', _sum: { amountCents: 500 } },
]);
const service = new TenantsService(prisma as never);
const rows = await service.listManagementRows();
expect(rows.map((row) => row.id)).toEqual(['tenant-3', 'tenant-2', 'tenant-1']);
});
});