Merge branch 'master' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-production
This commit is contained in:
		| @@ -66,7 +66,10 @@ export class PpobCallbackController { | |||||||
|       ); |       ); | ||||||
|       // |       // | ||||||
|     } else { |     } else { | ||||||
|  |       console.log('statusapani', response['status']); | ||||||
|  |       console.log('statusapani2', response.toString()); | ||||||
|       if (response['status'].toString() != '20') { |       if (response['status'].toString() != '20') { | ||||||
|  |         console.log("masukkesiniga", "msk") | ||||||
|         //TODO: UPDATE GAGAL |         //TODO: UPDATE GAGAL | ||||||
|         const updateTransaction = |         const updateTransaction = | ||||||
|             await this.transactionService.callbackOrderFailed( |             await this.transactionService.callbackOrderFailed( | ||||||
| @@ -79,7 +82,7 @@ export class PpobCallbackController { | |||||||
|           statusCode: HttpStatus.BAD_REQUEST, |           statusCode: HttpStatus.BAD_REQUEST, | ||||||
|           message: 'failed to proccess', |           message: 'failed to proccess', | ||||||
|         }; |         }; | ||||||
|       } |       } else { | ||||||
|  |  | ||||||
|         //TODO: UPDATE BERHASIL |         //TODO: UPDATE BERHASIL | ||||||
|         const updateTransaction = |         const updateTransaction = | ||||||
| @@ -87,8 +90,14 @@ export class PpobCallbackController { | |||||||
|                 response['refid'], |                 response['refid'], | ||||||
|                 response, |                 response, | ||||||
|             ); |             ); | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |         return { | ||||||
|  |           updateTransaction, | ||||||
|  |           statusCode: HttpStatus.OK, | ||||||
|  |           message: 'success', | ||||||
|  |         }; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|     this.logger.log({ |     this.logger.log({ | ||||||
|       requestQuery: request.query, |       requestQuery: request.query, | ||||||
|     }); |     }); | ||||||
|   | |||||||
| @@ -299,6 +299,22 @@ export class TransactionService { | |||||||
|     orderTransactionDto: OrderTransactionDto, |     orderTransactionDto: OrderTransactionDto, | ||||||
|     currentUser: any, |     currentUser: any, | ||||||
|   ) { |   ) { | ||||||
|  |  | ||||||
|  |     const productData = await this.productService.findOne( | ||||||
|  |         orderTransactionDto.productCode, | ||||||
|  |         'prepaid', | ||||||
|  |     ); | ||||||
|  |  | ||||||
|  |     if (productData.status == 'NOT ACTIVE') { | ||||||
|  |       throw new HttpException( | ||||||
|  |           { | ||||||
|  |             statusCode: HttpStatus.INTERNAL_SERVER_ERROR, | ||||||
|  |             error: `Transaction Failed because product is not active`, | ||||||
|  |           }, | ||||||
|  |           HttpStatus.INTERNAL_SERVER_ERROR, | ||||||
|  |       ); | ||||||
|  |     } else { | ||||||
|  |  | ||||||
|       const trxId = Array(6) |       const trxId = Array(6) | ||||||
|           .fill(null) |           .fill(null) | ||||||
|           .map(() => { |           .map(() => { | ||||||
| @@ -434,11 +450,27 @@ export class TransactionService { | |||||||
|         status: statusTransaction[statusTransaction.SUCCESS], |         status: statusTransaction[statusTransaction.SUCCESS], | ||||||
|       }; |       }; | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   async orderTransactionProd( |   async orderTransactionProd( | ||||||
|     orderTransactionDto: OrderTransactionDto, |     orderTransactionDto: OrderTransactionDto, | ||||||
|     currentUser: any, |     currentUser: any, | ||||||
|   ) { |   ) { | ||||||
|  |  | ||||||
|  |     const productData = await this.productService.findOne( | ||||||
|  |         orderTransactionDto.productCode, | ||||||
|  |         'prepaid', | ||||||
|  |     ); | ||||||
|  |  | ||||||
|  |     if (productData.status == 'NOT ACTIVE') { | ||||||
|  |       throw new HttpException( | ||||||
|  |           { | ||||||
|  |             statusCode: HttpStatus.INTERNAL_SERVER_ERROR, | ||||||
|  |             error: `Transaction Failed because product is not active`, | ||||||
|  |           }, | ||||||
|  |           HttpStatus.INTERNAL_SERVER_ERROR, | ||||||
|  |       ); | ||||||
|  |     } else { | ||||||
|     let status; |     let status; | ||||||
|     const amount = 0; |     const amount = 0; | ||||||
|     //GET USER DATA |     //GET USER DATA | ||||||
| @@ -530,7 +562,6 @@ export class TransactionService { | |||||||
|  |  | ||||||
|     if (supplier.code != 'IRS') { |     if (supplier.code != 'IRS') { | ||||||
|       const parsingResponse = hitSupplier.split(' '); |       const parsingResponse = hitSupplier.split(' '); | ||||||
|       console.log |  | ||||||
|       const newHitSupplier = { |       const newHitSupplier = { | ||||||
|         success: hitSupplier.includes('diproses'), |         success: hitSupplier.includes('diproses'), | ||||||
|         harga: parseInt( |         harga: parseInt( | ||||||
| @@ -653,6 +684,7 @@ export class TransactionService { | |||||||
|       status: status, |       status: status, | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
|  |   } | ||||||
|  |  | ||||||
|   async orderTransactionBillProd( |   async orderTransactionBillProd( | ||||||
|     orderTransactionDto: OrderTransactionDto, |     orderTransactionDto: OrderTransactionDto, | ||||||
| @@ -1169,12 +1201,12 @@ export class TransactionService { | |||||||
|       relations: ['product_price'], |       relations: ['product_price'], | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     const dataMsg = callback.msg; |     // const dataMsg = callback.msg; | ||||||
|     const failedReason = dataMsg.split('.'); |     // const failedReason = dataMsg.split('.'); | ||||||
|  |  | ||||||
|     dataTransaction.status = statusTransaction.FAILED; |     // dataTransaction.status = statusTransaction.FAILED; | ||||||
|     dataTransaction.callback_json = callback; |     // dataTransaction.callback_json = callback; | ||||||
|     dataTransaction.failed_reason = `${failedReason[0]}, ${failedReason[1]}`; |     // dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`; | ||||||
|  |  | ||||||
|     const userData = await this.userService.findExist(dataTransaction.user); |     const userData = await this.userService.findExist(dataTransaction.user); | ||||||
|  |  | ||||||
| @@ -1186,6 +1218,13 @@ export class TransactionService { | |||||||
|       product_price.product.id, |       product_price.product.id, | ||||||
|     ); |     ); | ||||||
|  |  | ||||||
|  |     dataTransaction.status = statusTransaction.FAILED; | ||||||
|  |     dataTransaction.callback_json = callback; | ||||||
|  |     dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`; | ||||||
|  |     if (callback['price'] != dataTransaction.product_price.price) { | ||||||
|  |       dataTransaction.product_price.price = callback['price'] | ||||||
|  |     } | ||||||
|  |  | ||||||
|     //GET COA |     //GET COA | ||||||
|     const coaAccount = await this.coaService.findByUser( |     const coaAccount = await this.coaService.findByUser( | ||||||
|       userData.id, |       userData.id, | ||||||
| @@ -1271,6 +1310,10 @@ export class TransactionService { | |||||||
|     } |     } | ||||||
|     dataTransaction.callback_json = callback; |     dataTransaction.callback_json = callback; | ||||||
|  |  | ||||||
|  |     if (callback['price'] != dataTransaction.product_price.price) { | ||||||
|  |       dataTransaction.product_price.price = callback['price'] | ||||||
|  |     } | ||||||
|  |  | ||||||
|     const userData = await this.userService.findExist(dataTransaction.user); |     const userData = await this.userService.findExist(dataTransaction.user); | ||||||
|  |  | ||||||
|     let supervisorData = []; |     let supervisorData = []; | ||||||
| @@ -1570,6 +1613,7 @@ export class TransactionService { | |||||||
|       ) |       ) | ||||||
|       .leftJoin('transaction.product_price', 'product_price') |       .leftJoin('transaction.product_price', 'product_price') | ||||||
|       .leftJoin('product_price.product', 'product') |       .leftJoin('product_price.product', 'product') | ||||||
|  |         .leftJoin('product.supplier', 'supplier') | ||||||
|         .addSelect('transaction.amount', 'price') |         .addSelect('transaction.amount', 'price') | ||||||
|       .addSelect('transaction.destination') |       .addSelect('transaction.destination') | ||||||
|       .addSelect('transaction.seri_number', 'seri_number') |       .addSelect('transaction.seri_number', 'seri_number') | ||||||
| @@ -1579,7 +1623,9 @@ export class TransactionService { | |||||||
|       .addSelect('transaction.failed_reason', 'failed_reason') |       .addSelect('transaction.failed_reason', 'failed_reason') | ||||||
|       .addSelect('userData.name', 'buyer') |       .addSelect('userData.name', 'buyer') | ||||||
|       .addSelect('product.name', 'name') |       .addSelect('product.name', 'name') | ||||||
|       .addSelect('product.id', 'product_id') |       .addSelect('product_price.price', 'product_price') | ||||||
|  |         .addSelect('product.name', 'supplier_name') | ||||||
|  |         .addSelect('supplier.name', 'supplier_name') | ||||||
|         .orderBy('transaction.created_at', 'DESC'); |         .orderBy('transaction.created_at', 'DESC'); | ||||||
|  |  | ||||||
|     if (startDate && endDate) { |     if (startDate && endDate) { | ||||||
| @@ -1887,10 +1933,21 @@ export class TransactionService { | |||||||
|         .addSelect('COUNT(transactions.id) as total_transaction') |         .addSelect('COUNT(transactions.id) as total_transaction') | ||||||
|         .getRawOne(); |         .getRawOne(); | ||||||
|  |  | ||||||
|  |     // const dataCoa = this.coaRepository | ||||||
|  |     //     .createQueryBuilder('coa') | ||||||
|  |     //     .innerJoin('user', 'user', 'coa.user = user.id') | ||||||
|  |     //     .where( | ||||||
|  |     //         `coa.type = '0' and user.partner_id is not NULL and user.is_active = true and is_rejected = false` | ||||||
|  |     //     ); | ||||||
|  |     // | ||||||
|  |     // const coa = await dataCoa | ||||||
|  |     //     .select('SUM(coa.amount) as total_modal') | ||||||
|  |     //     .getRawOne(); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|  |       total_modal: parseInt(data.total_modal), | ||||||
|       total_amount: parseInt(data.total_amount), |       total_amount: parseInt(data.total_amount), | ||||||
|       total_transaction: parseInt(data.total_transaction), |       total_transaction: parseInt(data.total_transaction), | ||||||
|       total_modal: parseInt(data.total_modal), |  | ||||||
|       total_profit: parseInt(data.total_profit), |       total_profit: parseInt(data.total_profit), | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user