From 8d15f6f4bed1ef575c98c8867ed5250fb900d644 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 10 May 2023 14:14:10 +0700 Subject: [PATCH 1/4] - Added filter by Partner Trx Id for transaction history --- src/transaction/transaction.controller.ts | 4 ++++ src/transaction/transaction.service.ts | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index 98fed2e..9213032 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -186,6 +186,7 @@ export class TransactionController { @Query('start') startDate: string, @Query('end') endDate: string, @Query('trxId') trxId: string, + @Query('partnerTrxId') partnerTrxId: string, @Request() req, ) { const data = await this.transactionService.transactionHistoryByUser( @@ -194,6 +195,7 @@ export class TransactionController { startDate == 'null' ? null : startDate, endDate == 'null' ? null : endDate, trxId == 'null' ? null : trxId, + partnerTrxId == 'null' ? null : partnerTrxId, pageSize, ); @@ -232,6 +234,7 @@ export class TransactionController { @Query('start') startDate: string, @Query('end') endDate: string, @Query('trxId') trxId: string, + @Query('partnerTrxId') partnerTrxId: string, @Param('id', ParseUUIDPipe) id: string, ) { const data = await this.transactionService.transactionHistoryByUser( @@ -240,6 +243,7 @@ export class TransactionController { startDate == 'null' ? null : startDate, endDate == 'null' ? null : endDate, trxId == 'null' ? null : trxId, + partnerTrxId == 'null' ? null : partnerTrxId, pageSize, ); diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index cdc062a..dc4ceed 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1886,6 +1886,7 @@ export class TransactionService { startDate: string, endDate: string, trxId: string, + partnerTrxId: string, pageSize?: number, ) { const userData = await this.userService.findExist(user); @@ -1966,6 +1967,13 @@ export class TransactionService { trxId: trxId }, ); + } else if (partnerTrxId != null) { + baseQuery.andWhere( + 'transaction.partner_trx_id = :partnerTrxId', + { + partnerTrxId: partnerTrxId + }, + ); } const data = await baseQuery From 401c91f66d21c107c57ffe6cc18958fa1bfe1188 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 10 May 2023 15:00:07 +0700 Subject: [PATCH 2/4] - Added filter by Partner Trx Id for transaction history --- src/transaction/transaction.service.ts | 42 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index dc4ceed..1d04905 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1960,20 +1960,34 @@ export class TransactionService { enDate: new Date(endDate), }, ); - } else if (trxId != null) { - baseQuery.andWhere( - 'transaction.supplier_trx_id = :trxId', - { - trxId: trxId - }, - ); - } else if (partnerTrxId != null) { - baseQuery.andWhere( - 'transaction.partner_trx_id = :partnerTrxId', - { - partnerTrxId: partnerTrxId - }, - ); + } else if (trxId != null || partnerTrxId != null) { + if (trxId != null && partnerTrxId != null) { + baseQuery.andWhere( + 'transaction.supplier_trx_id = :trxId and transaction.partner_trx_id = :partnerTrxId', + { + trxId: trxId, + partnerTrxId: partnerTrxId, + }, + ); + } else { + if (trxId != null) { + baseQuery.andWhere( + 'transaction.supplier_trx_id = :trxId', + { + trxId: trxId + }, + ); + } else if (partnerTrxId != null) { + baseQuery.andWhere( + 'transaction.partner_trx_id = :partnerTrxId', + { + partnerTrxId: partnerTrxId + }, + ); + } + } + + } const data = await baseQuery From f4c25af88678176e23bac998e25afa084a140cd4 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 10 May 2023 16:09:30 +0700 Subject: [PATCH 3/4] - fix insert to table callback_partner when callback to url partner --- src/transaction/transaction.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 1d04905..979974d 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1725,6 +1725,7 @@ export class TransactionService { this.callbackToPartner( userData.partner.id, message, + dataTransaction.supplier_trx_id, dataTransaction.partner_trx_id, dataTransaction.amount, product.code, @@ -1739,6 +1740,7 @@ export class TransactionService { partnerId: string, message: string, trxId: string, + partnerTrxId: string, harga: number, productCode: string, destination: string, @@ -1762,9 +1764,9 @@ export class TransactionService { return false; } - const url = `${partnerData.callback_url}?status=${status}&memberID=${partnerData.code}&trxid=${trxId}&harga=${harga}&product=${productCode}&dest=${destination}&seriNumber=${seriNumber}&message=${message}&saldo=${coaAccount.amount}`; + const url = `${partnerData.callback_url}?status=${status}&memberID=${partnerData.code}&trxid=${partnerTrxId}&harga=${harga}&product=${productCode}&dest=${destination}&seriNumber=${seriNumber}&message=${message}&saldo=${coaAccount.amount}`; const result = await this.callbackPartnerRepository.insert({ - partner_trx_id: partnerId, + partner_trx_id: partnerTrxId, trx_id: trxId, url: url, }); From 253f1af8f8e641f5b5d005fd6e107177409483d7 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 10 May 2023 16:25:16 +0700 Subject: [PATCH 4/4] - fix insert to table callback_partner when callback to url partner --- src/transaction/transaction.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 979974d..6e43b47 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1514,6 +1514,7 @@ export class TransactionService { this.callbackToPartner( userData.partner.id, message, + dataTransaction.supplier_trx_id, dataTransaction.partner_trx_id, dataTransaction.amount, product.code, @@ -1677,6 +1678,7 @@ export class TransactionService { this.callbackToPartner( userData.partner.id, message, + dataTransaction.supplier_trx_id, dataTransaction.partner_trx_id, dataTransaction.amount, product.code, @@ -1712,6 +1714,7 @@ export class TransactionService { await this.callbackToPartner( userData.partner.id, message, + dataTransaction.supplier_trx_id, dataTransaction.partner_trx_id, dataTransaction.amount, product.code, @@ -2759,6 +2762,7 @@ export class TransactionService { this.callbackToPartner( userData.id, message, + billData.trx_id, billData.partner_trx_id, amount + product_price.partner_fee + product_price.mark_up_price, billData.product_code,