Add global admin checks list and deepen check notification links.

Expose GET /admin/checks with order context, and point admin check alerts to the per-order checks page.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-09 16:17:51 +03:30
co-authored by Cursor
parent d4aaa8e997
commit fd187ea2ee
11 changed files with 119 additions and 6 deletions
+25
View File
@@ -4,6 +4,31 @@ import { UpdateCheckStatusDto } from './dto/check.dto';
export declare class ChecksController { export declare class ChecksController {
private readonly checksService; private readonly checksService;
constructor(checksService: ChecksService); constructor(checksService: ChecksService);
findAll(status?: string): Promise<{
orderNumber: string;
customerName: string;
orderStatus: import("@prisma/client").$Enums.OrderStatus;
settlementType: import("@prisma/client").$Enums.SettlementType | null;
id: string;
orderId: string;
row: number;
amount: number;
dueDate: string;
sayadId: string;
checkNumber: string | undefined;
ownerNationalId: string | undefined;
ownerFirstName: string | undefined;
ownerLastName: string | undefined;
bankName: string;
branchName: string | undefined;
frontImage: string | undefined;
backImage: string | undefined;
notes: string | undefined;
mode: string;
status: import("@prisma/client").$Enums.CheckStatus;
createdAt: string;
updatedAt: string;
}[]>;
findByOrder(orderId: string): Promise<{ findByOrder(orderId: string): Promise<{
id: string; id: string;
orderId: string; orderId: string;
+10
View File
@@ -23,6 +23,9 @@ let ChecksController = class ChecksController {
constructor(checksService) { constructor(checksService) {
this.checksService = checksService; this.checksService = checksService;
} }
findAll(status) {
return this.checksService.findAll(status);
}
findByOrder(orderId) { findByOrder(orderId) {
return this.checksService.findByOrder(orderId); return this.checksService.findByOrder(orderId);
} }
@@ -31,6 +34,13 @@ let ChecksController = class ChecksController {
} }
}; };
exports.ChecksController = ChecksController; exports.ChecksController = ChecksController;
__decorate([
(0, common_1.Get)('admin/checks'),
__param(0, (0, common_1.Query)('status')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], ChecksController.prototype, "findAll", null);
__decorate([ __decorate([
(0, common_1.Get)('admin/orders/:orderId/checks'), (0, common_1.Get)('admin/orders/:orderId/checks'),
__param(0, (0, common_1.Param)('orderId')), __param(0, (0, common_1.Param)('orderId')),
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"checks.controller.js","sourceRoot":"","sources":["../../src/checks/checks.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqE;AACrE,qDAAiD;AACjD,0EAAgE;AAChE,wFAA0E;AAE1E,+CAAuD;AAIhD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACE;IAA7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAG7D,WAAW,CAAmB,OAAe;QAC3C,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAGD,YAAY,CACK,IAAmB,EACrB,EAAU,EACf,GAAyB;QAEjC,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AAhBY,4CAAgB;AAI3B;IADC,IAAA,YAAG,EAAC,8BAA8B,CAAC;IACvB,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;;;;mDAE5B;AAGD;IADC,IAAA,cAAK,EAAC,yBAAyB,CAAC;IAE9B,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;qDAAM,gCAAoB;;oDAGlC;2BAfU,gBAAgB;IAF5B,IAAA,mBAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,OAAO,CAAC;qCAE4B,8BAAa;GAD9C,gBAAgB,CAgB5B"} {"version":3,"file":"checks.controller.js","sourceRoot":"","sources":["../../src/checks/checks.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4E;AAC5E,qDAAiD;AACjD,0EAAgE;AAChE,wFAA0E;AAE1E,+CAAuD;AAIhD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACE;IAA7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAG7D,OAAO,CAAkB,MAAe;QACtC,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAGD,WAAW,CAAmB,OAAe;QAC3C,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAGD,YAAY,CACK,IAAmB,EACrB,EAAU,EACf,GAAyB;QAEjC,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AArBY,4CAAgB;AAI3B;IADC,IAAA,YAAG,EAAC,cAAc,CAAC;IACX,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;;;;+CAEvB;AAGD;IADC,IAAA,YAAG,EAAC,8BAA8B,CAAC;IACvB,WAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;;;;mDAE5B;AAGD;IADC,IAAA,cAAK,EAAC,yBAAyB,CAAC;IAE9B,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;qDAAM,gCAAoB;;oDAGlC;2BApBU,gBAAgB;IAF5B,IAAA,mBAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,OAAO,CAAC;qCAE4B,8BAAa;GAD9C,gBAAgB,CAqB5B"}
+25
View File
@@ -26,6 +26,31 @@ export declare class ChecksService {
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
}[]>; }[]>;
findAll(status?: string): Promise<{
orderNumber: string;
customerName: string;
orderStatus: import("@prisma/client").$Enums.OrderStatus;
settlementType: import("@prisma/client").$Enums.SettlementType | null;
id: string;
orderId: string;
row: number;
amount: number;
dueDate: string;
sayadId: string;
checkNumber: string | undefined;
ownerNationalId: string | undefined;
ownerFirstName: string | undefined;
ownerLastName: string | undefined;
bankName: string;
branchName: string | undefined;
frontImage: string | undefined;
backImage: string | undefined;
notes: string | undefined;
mode: string;
status: import("@prisma/client").$Enums.CheckStatus;
createdAt: string;
updatedAt: string;
}[]>;
updateStatus(id: string, adminId: string, dto: UpdateCheckStatusDto): Promise<{ updateStatus(id: string, adminId: string, dto: UpdateCheckStatusDto): Promise<{
id: string; id: string;
orderId: string; orderId: string;
+22
View File
@@ -14,6 +14,7 @@ const common_1 = require("@nestjs/common");
const client_1 = require("@prisma/client"); const client_1 = require("@prisma/client");
const prisma_service_1 = require("../prisma/prisma.service"); const prisma_service_1 = require("../prisma/prisma.service");
const notifications_service_1 = require("../notifications/notifications.service"); const notifications_service_1 = require("../notifications/notifications.service");
const name_1 = require("../common/utils/name");
let ChecksService = class ChecksService { let ChecksService = class ChecksService {
prisma; prisma;
notifications; notifications;
@@ -33,6 +34,27 @@ let ChecksService = class ChecksService {
}); });
return checks.map((c) => this.map(c)); return checks.map((c) => this.map(c));
} }
async findAll(status) {
const where = status && Object.values(client_1.CheckStatus).includes(status)
? { status: status }
: {};
const checks = await this.prisma.check.findMany({
where,
include: {
order: {
include: { user: true },
},
},
orderBy: [{ dueDate: 'asc' }, { createdAt: 'desc' }],
});
return checks.map((c) => ({
...this.map(c),
orderNumber: c.order.orderNumber,
customerName: (0, name_1.joinFullName)(c.order.user.firstName, c.order.user.lastName),
orderStatus: c.order.status,
settlementType: c.order.settlementType,
}));
}
async updateStatus(id, adminId, dto) { async updateStatus(id, adminId, dto) {
const check = await this.prisma.check.findUnique({ const check = await this.prisma.check.findUnique({
where: { id }, where: { id },
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"checks.service.js","sourceRoot":"","sources":["../../src/checks/checks.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA+D;AAC/D,2CAA0D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;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAGgB,8BAAa;QACN,4CAAoB;GAH3C,aAAa,CA2JzB"}
+1 -1
View File
@@ -467,7 +467,7 @@ let OrdersService = class OrdersService {
this.notifications.dispatchAdmin({ this.notifications.dispatchAdmin({
title: isFix ? 'چک‌های اصلاح‌شده رسید' : 'چک‌های سفارش ثبت شد', title: isFix ? 'چک‌های اصلاح‌شده رسید' : 'چک‌های سفارش ثبت شد',
body: `مشتری ${dto.checks.length} چک برای سفارش ${order.orderNumber} ثبت کرد و منتظر بررسی است.`, body: `مشتری ${dto.checks.length} چک برای سفارش ${order.orderNumber} ثبت کرد و منتظر بررسی است.`,
link: `/orders/${id}`, link: `/orders/${id}/checks`,
}); });
} }
return this.findMyOrder(userId, id); return this.findMyOrder(userId, id);
+1 -1
View File
File diff suppressed because one or more lines are too long
+6 -1
View File
@@ -1,4 +1,4 @@
import { Body, Controller, Get, Param, Patch } from '@nestjs/common'; import { Body, Controller, Get, Param, Patch, Query } from '@nestjs/common';
import { ChecksService } from './checks.service'; import { ChecksService } from './checks.service';
import { AuthType } from '../common/decorators/auth.decorators'; import { AuthType } from '../common/decorators/auth.decorators';
import { CurrentUser } from '../common/decorators/current-user.decorator'; import { CurrentUser } from '../common/decorators/current-user.decorator';
@@ -10,6 +10,11 @@ import { UpdateCheckStatusDto } from './dto/check.dto';
export class ChecksController { export class ChecksController {
constructor(private readonly checksService: ChecksService) {} constructor(private readonly checksService: ChecksService) {}
@Get('admin/checks')
findAll(@Query('status') status?: string) {
return this.checksService.findAll(status);
}
@Get('admin/orders/:orderId/checks') @Get('admin/orders/:orderId/checks')
findByOrder(@Param('orderId') orderId: string) { findByOrder(@Param('orderId') orderId: string) {
return this.checksService.findByOrder(orderId); return this.checksService.findByOrder(orderId);
+26
View File
@@ -3,6 +3,7 @@ import { CheckStatus, OrderStatus } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service'; import { PrismaService } from '../prisma/prisma.service';
import { UpdateCheckStatusDto } from './dto/check.dto'; import { UpdateCheckStatusDto } from './dto/check.dto';
import { NotificationsService } from '../notifications/notifications.service'; import { NotificationsService } from '../notifications/notifications.service';
import { joinFullName } from '../common/utils/name';
@Injectable() @Injectable()
export class ChecksService { export class ChecksService {
@@ -24,6 +25,31 @@ export class ChecksService {
return checks.map((c) => this.map(c)); return checks.map((c) => this.map(c));
} }
async findAll(status?: string) {
const where =
status && Object.values(CheckStatus).includes(status as CheckStatus)
? { status: status as CheckStatus }
: {};
const checks = await this.prisma.check.findMany({
where,
include: {
order: {
include: { user: true },
},
},
orderBy: [{ dueDate: 'asc' }, { createdAt: 'desc' }],
});
return checks.map((c) => ({
...this.map(c),
orderNumber: c.order.orderNumber,
customerName: joinFullName(c.order.user.firstName, c.order.user.lastName),
orderStatus: c.order.status,
settlementType: c.order.settlementType,
}));
}
async updateStatus(id: string, adminId: string, dto: UpdateCheckStatusDto) { async updateStatus(id: string, adminId: string, dto: UpdateCheckStatusDto) {
const check = await this.prisma.check.findUnique({ const check = await this.prisma.check.findUnique({
where: { id }, where: { id },
+1 -1
View File
@@ -591,7 +591,7 @@ export class OrdersService {
this.notifications.dispatchAdmin({ this.notifications.dispatchAdmin({
title: isFix ? 'چک‌های اصلاح‌شده رسید' : 'چک‌های سفارش ثبت شد', title: isFix ? 'چک‌های اصلاح‌شده رسید' : 'چک‌های سفارش ثبت شد',
body: `مشتری ${dto.checks.length} چک برای سفارش ${order.orderNumber} ثبت کرد و منتظر بررسی است.`, body: `مشتری ${dto.checks.length} چک برای سفارش ${order.orderNumber} ثبت کرد و منتظر بررسی است.`,
link: `/orders/${id}`, link: `/orders/${id}/checks`,
}); });
} }