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()
@Get('public/payments')
@ApiOperation({ summary: 'get all payments as admin' })
@ApiOperation({ summary: 'get all payments as user' })
findAllByUser(@UserId() userId: string, @Query() dto: FindPaymentsDto) {
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')
@UseGuards(AuthGuard)
@@ -55,6 +55,11 @@ export class FindPaymentsDto {
@IsString()
search?: string;
@ApiPropertyOptional()
@IsOptional()
@IsString()
orderId?: string;
@ApiPropertyOptional({ format: 'date-time' })
@IsOptional()
@IsDateString()
@@ -25,7 +25,8 @@ export class PaymentRepository extends EntityRepository<Payment> {
order = 'desc',
userId,
from,
to
to,
orderId
} = opts;
const offset = (page - 1) * limit;
@@ -53,6 +54,9 @@ export class PaymentRepository extends EntityRepository<Payment> {
where.order = { user: { id: userId } };
}
if (orderId) {
where.order = { id: orderId }
}
// Filter by date range
if (from || to) {
where.createdAt = {};