fixing: callback transaction
This commit is contained in:
		| @@ -37,4 +37,9 @@ export class ProductHistoryPrice extends BaseModel { | ||||
|     default: 0, | ||||
|   }) | ||||
|   admin_price: number; | ||||
|  | ||||
|   @Column({ | ||||
|     default: 0, | ||||
|   }) | ||||
|   partner_fee: number; | ||||
| } | ||||
|   | ||||
| @@ -110,6 +110,8 @@ export class ProductService { | ||||
|           type: productType.NORMAL, | ||||
|           startDate: new Date(), | ||||
|           partner: it[6] != '-' ? partnerData : null, | ||||
|           admin_price: it[8], | ||||
|           partner_fee: it[9], | ||||
|         }); | ||||
|       } else { | ||||
|         let partnerData; | ||||
| @@ -135,6 +137,8 @@ export class ProductService { | ||||
|           startDate: new Date(), | ||||
|           endDate: null, | ||||
|           partner: partnerData, | ||||
|           admin_price: it[8], | ||||
|           partner_fee: it[9], | ||||
|         }); | ||||
|       } | ||||
|     }); | ||||
|   | ||||
| @@ -42,4 +42,7 @@ export class CheckBillHistory extends BaseModel { | ||||
|  | ||||
|   @Column() | ||||
|   product_code: string; | ||||
|  | ||||
|   @ManyToOne(() => ProductHistoryPrice, (product) => product.id) | ||||
|   product_price: ProductHistoryPrice; | ||||
| } | ||||
|   | ||||
| @@ -64,7 +64,7 @@ export class PpobCallbackController { | ||||
|         return { | ||||
|           statusCode: HttpStatus.OK, | ||||
|           message: 'success', | ||||
|         };; | ||||
|         }; | ||||
|       } | ||||
|  | ||||
|       const splitMessage = response['message'].split('","'); | ||||
|   | ||||
| @@ -840,6 +840,10 @@ export class TransactionService { | ||||
|       product.supplier.code, | ||||
|     ); | ||||
|  | ||||
|     let product_price = await this.productHistoryPriceService.findOne( | ||||
|       product.id, | ||||
|       userData.partner?.id, | ||||
|     ); | ||||
|     //HIT API SUPPLIER | ||||
|     const trxId = Array(6) | ||||
|       .fill(null) | ||||
| @@ -858,7 +862,6 @@ export class TransactionService { | ||||
|         supplier, | ||||
|       ); | ||||
|       const parsingResponse = hitSupplier.split(' '); | ||||
|       console.log(hitSupplier,"ini dia") | ||||
|       hitSupplier = { | ||||
|         success: hitSupplier.includes('diproses'), | ||||
|         msg: hitSupplier, | ||||
| @@ -883,6 +886,7 @@ export class TransactionService { | ||||
|           destination: orderTransactionDto.destination, | ||||
|           product_code: orderTransactionDto.productCode, | ||||
|           partner_trx_id: orderTransactionDto.trx_id, | ||||
|           product_price: product_price, | ||||
|         }); | ||||
|       } | ||||
|     } catch (e) { | ||||
| @@ -1793,27 +1797,34 @@ export class TransactionService { | ||||
|   ) { | ||||
|     const billData = await this.findOneBillById(trxId); | ||||
|  | ||||
|     const userData = await this.userService.findExist(billData.user); | ||||
|  | ||||
|     const product_price = await this.productHistoryPriceService.findById( | ||||
|       billData.product_price.id, | ||||
|     ); | ||||
|  | ||||
|     await this.checkBillHistoryRepository.update( | ||||
|       { | ||||
|         trx_id: trxId, | ||||
|       }, | ||||
|       { | ||||
|         amount: amount, | ||||
|         amount: amount + product_price.partner_fee + product_price.mark_up_price, | ||||
|         admin_price: admin, | ||||
|       }, | ||||
|     ); | ||||
|     const userData = await this.userService.findExist(billData.user); | ||||
|  | ||||
|     if (userData.partner) { | ||||
|       const message = status | ||||
|         ? `Bill dari ${billData.destination} adalah ${amount}.` | ||||
|         ? `Bill dari ${billData.destination} adalah ${ | ||||
|             amount + product_price.partner_fee + product_price.mark_up_price | ||||
|           }.` | ||||
|         : ''; | ||||
|       const statusResponse = status ? 'berhasil' : 'gagal'; | ||||
|       this.callbackToPartner( | ||||
|         userData.id, | ||||
|         message, | ||||
|         billData.partner_trx_id, | ||||
|         amount, | ||||
|         amount + product_price.partner_fee + product_price.mark_up_price, | ||||
|         billData.product_code, | ||||
|         billData.destination, | ||||
|         '-', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user