find all payments

This commit is contained in:
2026-01-19 11:44:28 +03:30
parent 013b543503
commit 3b76081fed
3 changed files with 20 additions and 3 deletions
@@ -42,12 +42,20 @@ export class PaymentController {
@ApiBearerAuth() @ApiBearerAuth()
@Get('public/payments') @Get('public/payments')
@ApiOperation({ summary: 'get all payments as admin' }) @ApiOperation({ summary: 'get all payments as user' })
findAllByUser(@UserId() userId: string, @Query() dto: FindPaymentsDto) { findAllByUser(@UserId() userId: string, @Query() dto: FindPaymentsDto) {
return this.paymentsService.findAllByUser(dto, userId); return this.paymentsService.findAllByUser(dto, userId);
} }
/*===============Admin=============== */ /*=============== Admin =============== */
@ApiBearerAuth()
@Get('public/payments')
@ApiOperation({ summary: 'get all payments as user' })
findAll(@Query() dto: FindPaymentsDto) {
return this.paymentsService.findAll(dto);
}
@Post('admin/payments/:paymentId/verify/cash') @Post('admin/payments/:paymentId/verify/cash')
@UseGuards(AuthGuard) @UseGuards(AuthGuard)
@@ -55,6 +55,11 @@ export class FindPaymentsDto {
@IsString() @IsString()
search?: string; search?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
orderId?: string;
@ApiPropertyOptional({ format: 'date-time' }) @ApiPropertyOptional({ format: 'date-time' })
@IsOptional() @IsOptional()
@IsDateString() @IsDateString()
@@ -25,7 +25,8 @@ export class PaymentRepository extends EntityRepository<Payment> {
order = 'desc', order = 'desc',
userId, userId,
from, from,
to to,
orderId
} = opts; } = opts;
const offset = (page - 1) * limit; const offset = (page - 1) * limit;
@@ -53,6 +54,9 @@ export class PaymentRepository extends EntityRepository<Payment> {
where.order = { user: { id: userId } }; where.order = { user: { id: userId } };
} }
if (orderId) {
where.order = { id: orderId }
}
// Filter by date range // Filter by date range
if (from || to) { if (from || to) {
where.createdAt = {}; where.createdAt = {};