diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index f7494cb..3bd2522 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -227,11 +227,17 @@ export class TransactionController { async findDepositReturnConfirmation( @Query('page') page: number, @Query('pageSize') pageSize: number, + @Query('start') startDate: string, + @Query('end') endDate: string, + @Query('sender') sender: string, @Request() req, ) { const data = await this.transactionService.getAllDepositReturnToUser( req.user.userId, page, + sender, + startDate, + endDate, pageSize, ); diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 5ea386e..b96e9c5 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1019,6 +1019,9 @@ export class TransactionService { async getAllDepositReturnToUser( user: string, page: number, + sender: string, + startDate: string, + endDate: string, pageSize?: number, ) { const baseQuery = this.transactionRepository @@ -1041,6 +1044,22 @@ export class TransactionService { 'userData.name', ]); + if (startDate && endDate) { + baseQuery.andWhere( + 'transaction.created_at between :startDate and :enDate', + { + startDate: new Date(startDate), + enDate: new Date(endDate), + }, + ); + } + + if (sender) { + baseQuery.andWhere('transaction.user = :sender', { + sender, + }); + } + const data = await baseQuery .offset(page * (pageSize || 10)) .limit(pageSize || 10)