fix: 补齐签名导入待审通知并展示通道组成本

This commit is contained in:
hectorzhao
2026-09-05 21:22:18 +08:00
parent 15a1f9d8ed
commit 839dba8d9b
13 changed files with 103 additions and 6 deletions
@@ -43,6 +43,7 @@ function createPrismaMock() {
rechargeOrder: {
findMany: jest.fn().mockResolvedValue([{ id: 'order-1', tenantId: 'tenant-1', amountCents: 1000 }]),
},
reportMaterialImportItem: { count: jest.fn().mockResolvedValue(0) },
smsTemplate: {
count: jest.fn().mockResolvedValue(1),
},
@@ -542,6 +543,7 @@ describe('OperationsService', () => {
enterpriseCertifications: 1,
smsAudits: 2,
signatures: 1,
signatureImports: 0,
drainageInfos: 0,
templates: 1,
total: 5,
@@ -729,6 +731,7 @@ describe('OperationsService', () => {
templates: 1,
signatures: 1,
drainageInfos: 0,
signatureImports: 0,
total: 5,
});
expect(prisma.smsTemplate.count).toHaveBeenCalledWith({ where: { tenantId: 'tenant-1', auditStatus: 'pending' } });
@@ -740,6 +743,16 @@ describe('OperationsService', () => {
expect(prisma.$queryRaw).not.toHaveBeenCalled();
});
it('counts pending signature import rows within the requested tenant', async () => {
const prisma = createPrismaMock();
prisma.reportMaterialImportItem.count.mockResolvedValue(19);
const service = new OperationsService(prisma as never);
await expect(service.pendingAudits('tenant-1')).resolves.toMatchObject({ signatureImports: 19, total: 24 });
expect(prisma.reportMaterialImportItem.count).toHaveBeenCalledWith({
where: { reportType: 'signature', status: 'pending_review', batch: { tenantId: 'tenant-1' } },
});
});
it('rejects invalid send quality dates', async () => {
const service = new OperationsService(createPrismaMock() as never);
await expect(service.sendQuality('2026-02-31')).rejects.toThrow('统计日期无效');
@@ -439,13 +439,17 @@ pendingAudits(tenantId?: string) {
this.prisma.smsDrainageInfo.count({ where: { tenantId, auditStatus: 'pending' } }),
this.prisma.enterpriseCertification.count({ where: { tenantId, status: 'pending' } }),
this.prisma.smsSendTask.count({ where: { tenantId, status: 'pending_review' } }),
]).then(([templates, signatures, drainageInfos, enterpriseCertifications, smsAudits]) => ({
this.prisma.reportMaterialImportItem.count({
where: { reportType: 'signature', status: 'pending_review', batch: { tenantId } },
}),
]).then(([templates, signatures, drainageInfos, enterpriseCertifications, smsAudits, signatureImports]) => ({
templates,
signatures,
drainageInfos,
enterpriseCertifications,
smsAudits,
total: templates + signatures + drainageInfos + enterpriseCertifications + smsAudits,
signatureImports,
total: templates + signatures + drainageInfos + enterpriseCertifications + smsAudits + signatureImports,
}));
}
}