fixing: ppob
This commit is contained in:
		| @@ -9,4 +9,7 @@ export class OrderTransactionDto { | ||||
|  | ||||
|   @IsOptional() | ||||
|   trx_id: string; | ||||
|  | ||||
|   @IsOptional() | ||||
|   bill_trx_id: string; | ||||
| } | ||||
|   | ||||
							
								
								
									
										42
									
								
								src/transaction/entities/check-bill-history.entity.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/transaction/entities/check-bill-history.entity.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| import { Column, Entity, ManyToOne, OneToMany } from 'typeorm'; | ||||
| import { BaseModel } from '../../config/basemodel.entity'; | ||||
| import { statusTransaction, typeTransaction } from '../../helper/enum-list'; | ||||
| import { ProductHistoryPrice } from '../../product/entities/product-history-price.entity'; | ||||
| import { UserDetail } from '../../users/entities/user_detail.entity'; | ||||
| import { TransactionJournal } from './transaction-journal.entity'; | ||||
|  | ||||
| @Entity() | ||||
| export class CheckBillHistory extends BaseModel { | ||||
|   @Column() | ||||
|   trx_id: string; | ||||
|  | ||||
|   @Column() | ||||
|   partner_trx_id: string; | ||||
|  | ||||
|   @Column() | ||||
|   amount: number; | ||||
|  | ||||
|   @Column({ | ||||
|     type: 'uuid', | ||||
|     nullable: true, | ||||
|   }) | ||||
|   user: string; | ||||
|  | ||||
|   @Column({ | ||||
|     nullable: true, | ||||
|   }) | ||||
|   destination: string; | ||||
|  | ||||
|   @Column({ | ||||
|     nullable: true, | ||||
|   }) | ||||
|   request_json: string; | ||||
|  | ||||
|   @Column({ | ||||
|     nullable: true, | ||||
|   }) | ||||
|   callback_json: string; | ||||
|  | ||||
|   @Column() | ||||
|   product_code: string; | ||||
| } | ||||
| @@ -51,9 +51,9 @@ export class PpobCallbackController { | ||||
|   async getMetro(@Req() request: FastifyRequest) { | ||||
|     const response = request.query; | ||||
|  | ||||
|     console.log(response, "INI DIA") | ||||
|     console.log(typeof  response['message'], "INI DIA") | ||||
|  | ||||
|     if (response['message'].include('CEK TAGIHAN')) { | ||||
|     if (response['message'].includes('CEK TAGIHAN')) { | ||||
|       console.log("messagenya tuh",response['message']) | ||||
|     } else { | ||||
|       if (response['status'] != 20) { | ||||
|   | ||||
| @@ -10,10 +10,16 @@ import { CoaService } from './coa.service'; | ||||
| import { ProductModule } from '../product/product.module'; | ||||
| import { UsersModule } from 'src/users/users.module'; | ||||
| import { ConfigurableModule } from '../configurable/configurable.module'; | ||||
| import { CheckBillHistory } from './entities/check-bill-history.entity'; | ||||
|  | ||||
| @Module({ | ||||
|   imports: [ | ||||
|     TypeOrmModule.forFeature([COA, TransactionJournal, Transactions]), | ||||
|     TypeOrmModule.forFeature([ | ||||
|       COA, | ||||
|       TransactionJournal, | ||||
|       Transactions, | ||||
|       CheckBillHistory, | ||||
|     ]), | ||||
|     ProductModule, | ||||
|     ConfigurableModule, | ||||
|     forwardRef(() => UsersModule), | ||||
|   | ||||
| @@ -27,6 +27,8 @@ import { DepositReturnDto } from './dto/deposit_return.dto'; | ||||
| import { UserDetail } from '../users/entities/user_detail.entity'; | ||||
| import { doTransaction } from '../helper/irs-api'; | ||||
| import { ProductHistoryPrice } from '../product/entities/product-history-price.entity'; | ||||
| import axios from 'axios'; | ||||
| import { CheckBillHistory } from './entities/check-bill-history.entity'; | ||||
|  | ||||
| @Injectable() | ||||
| export class TransactionService { | ||||
| @@ -39,6 +41,8 @@ export class TransactionService { | ||||
|     private transactionJournalRepository: Repository<TransactionJournal>, | ||||
|     @InjectRepository(COA) | ||||
|     private coaRepository: Repository<COA>, | ||||
|     @InjectRepository(CheckBillHistory) | ||||
|     private checkBillHistoryRepository: Repository<CheckBillHistory>, | ||||
|     private coaService: CoaService, | ||||
|     private productService: ProductService, | ||||
|     private productHistoryPriceService: ProductHistoryPriceService, | ||||
| @@ -477,6 +481,8 @@ export class TransactionService { | ||||
|       `${coaType[coaType.SALES]}-SYSTEM`, | ||||
|     ); | ||||
|  | ||||
|  | ||||
|  | ||||
|     if (coaAccount.amount < product_price.mark_up_price + product_price.price) { | ||||
|       throw new HttpException( | ||||
|         { | ||||
| @@ -814,21 +820,52 @@ export class TransactionService { | ||||
|       }) | ||||
|       .join(''); | ||||
|  | ||||
|     let hitSupplier = await doTransaction( | ||||
|       'CEK' + orderTransactionDto.productCode.slice(3), | ||||
|       orderTransactionDto.destination, | ||||
|       trxId, | ||||
|       supplier, | ||||
|     ); | ||||
|     let status; | ||||
|  | ||||
|     // let hitSupplier = await doTransaction( | ||||
|     //   'CEKXL1', | ||||
|     //   orderTransactionDto.destination, | ||||
|     //   trxId, | ||||
|     //   supplier, | ||||
|     // ); | ||||
|     try { | ||||
|       let hitSupplier = await doTransaction( | ||||
|         'CEK' + orderTransactionDto.productCode.slice(3), | ||||
|         orderTransactionDto.destination, | ||||
|         trxId, | ||||
|         supplier, | ||||
|       ); | ||||
|       const parsingResponse = hitSupplier.split(' '); | ||||
|       hitSupplier = { | ||||
|         success: hitSupplier.include('diproses'), | ||||
|         msg: hitSupplier, | ||||
|       }; | ||||
|  | ||||
|     return hitSupplier; | ||||
|       if (!hitSupplier.success) { | ||||
|         status = statusTransaction[statusTransaction.FAILED]; | ||||
|         throw new HttpException( | ||||
|           { | ||||
|             statusCode: HttpStatus.INTERNAL_SERVER_ERROR, | ||||
|             error: hitSupplier.msg, | ||||
|           }, | ||||
|           HttpStatus.INTERNAL_SERVER_ERROR, | ||||
|         ); | ||||
|       } else { | ||||
|         status = statusTransaction[statusTransaction.SUCCESS]; | ||||
|  | ||||
|         await this.checkBillHistoryRepository.insert({ | ||||
|           trx_id: trxId, | ||||
|           user: userData.id, | ||||
|           callback_json: JSON.stringify(hitSupplier), | ||||
|           destination: orderTransactionDto.destination, | ||||
|           product_code: orderTransactionDto.productCode, | ||||
|           partner_trx_id: orderTransactionDto.trx_id, | ||||
|         }); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       throw e; | ||||
|     } | ||||
|  | ||||
|     return { | ||||
|       trx_id: trxId, | ||||
|       client_trx_id: orderTransactionDto.trx_id, | ||||
|       product: orderTransactionDto.productCode, | ||||
|       status: status, | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   async createDepositReturn(currentUser, depositReturnDto: DepositReturnDto) { | ||||
| @@ -1060,6 +1097,20 @@ export class TransactionService { | ||||
|     } catch (e) { | ||||
|       throw e; | ||||
|     } | ||||
|  | ||||
|     if (userData.partner) { | ||||
|       const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`; | ||||
|       this.callbackToPartner( | ||||
|         userData.id, | ||||
|         message, | ||||
|         dataTransaction.partner_trx_id, | ||||
|         dataTransaction.amount, | ||||
|         product.code, | ||||
|         dataTransaction.destination, | ||||
|         '-', | ||||
|         'gagal', | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   async callbackOrderSuccess(supplier_trx_id: string, callback: any) { | ||||
| @@ -1131,6 +1182,36 @@ export class TransactionService { | ||||
|     } catch (e) { | ||||
|       throw e; | ||||
|     } | ||||
|  | ||||
|     if (userData.partner) { | ||||
|       const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah berhasil.`; | ||||
|       this.callbackToPartner( | ||||
|         userData.id, | ||||
|         message, | ||||
|         dataTransaction.partner_trx_id, | ||||
|         dataTransaction.amount, | ||||
|         product.code, | ||||
|         dataTransaction.destination, | ||||
|         dataTransaction.seri_number, | ||||
|         'berhasil', | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   async callbackToPartner( | ||||
|     partnerId: string, | ||||
|     message: string, | ||||
|     trxId: string, | ||||
|     harga: number, | ||||
|     productCode: string, | ||||
|     destination: string, | ||||
|     seriNumber: string, | ||||
|     status: string, | ||||
|   ) { | ||||
|     const partnerData = await this.userService.findPartner(partnerId); | ||||
|     const res = await axios.get( | ||||
|       `${partnerData.callback_url}?status=${status}&memberID=${partnerData.code}&trxid=${trxId}&harga=${harga}&product=${productCode}&dest=${destination}&seriNumber=${seriNumber}&message=${message}`, | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   async withdrawBenefit(user) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user