find all payments
This commit is contained in:
@@ -42,13 +42,21 @@ 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)
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
|
|||||||
@@ -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 = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user