feat: integrate analytics and fragment receipt improvements

This commit is contained in:
hectorzhao
2026-08-03 15:34:41 +08:00
parent 3357ace7e1
commit 530a65de80
89 changed files with 1964 additions and 324 deletions
@@ -26,8 +26,8 @@ export class AdminCertificationController {
constructor(private readonly certifications: CertificationService) {}
@Get()
list(@Query('tenantId') tenantId?: string, @Query('status') status?: string, @Query('keyword') keyword?: string) {
return this.certifications.list(tenantId, status, keyword);
list(@Query('tenantId') tenantId?: string, @Query('status') status?: string, @Query('keyword') keyword?: string, @Query('submittedAtFrom') submittedAtFrom?: string, @Query('submittedAtTo') submittedAtTo?: string) {
return this.certifications.list(tenantId, status, keyword, submittedAtFrom, submittedAtTo);
}
@Get(':id')
@@ -38,6 +38,22 @@ describe('CertificationService', () => {
]);
});
it('filters enterprise certification submissions by Shanghai date range', async () => {
const prisma = createPrismaMock();
const service = new CertificationService(prisma as never);
await service.list(undefined, 'pending', undefined, '2026-08-01', '2026-08-03');
expect(prisma.enterpriseCertification.findMany).toHaveBeenCalledWith(expect.objectContaining({
where: expect.objectContaining({
submittedAt: {
gte: new Date('2026-08-01T00:00:00+08:00'),
lte: new Date('2026-08-03T23:59:59.999+08:00'),
},
}),
}));
});
it('submits certification and marks tenant pending', async () => {
const prisma = createPrismaMock();
const service = new CertificationService(prisma as never);
@@ -1,6 +1,7 @@
import { BadRequestException, Injectable, NotFoundException } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service';
import { shanghaiDateRange } from '../common/shanghai-date-range';
export interface SubmitCertificationDto {
tenantId: string;
@@ -20,11 +21,12 @@ export interface ReviewCertificationDto {
export class CertificationService {
constructor(private readonly prisma: PrismaService) {}
async list(tenantId?: string, status?: string, keyword?: string) {
async list(tenantId?: string, status?: string, keyword?: string, submittedAtFrom?: string, submittedAtTo?: string) {
const records = await this.prisma.enterpriseCertification.findMany({
where: {
tenantId,
status: status && status !== 'all' ? status : undefined,
submittedAt: shanghaiDateRange(submittedAtFrom, submittedAtTo),
OR: keyword ? [
{ companyName: { contains: keyword } },
{ licenseNo: { contains: keyword } },