fixing: check bill

This commit is contained in:
ilham 2022-05-17 12:26:25 +07:00
parent 0f0d80f118
commit 9ee5b65dfc
3 changed files with 46 additions and 6 deletions

View File

@ -13,9 +13,12 @@ export class CheckBillHistory extends BaseModel {
@Column() @Column()
partner_trx_id: string; partner_trx_id: string;
@Column() @Column({ nullable: true })
amount: number; amount: number;
@Column({ nullable: true })
admin_price: number;
@Column({ @Column({
type: 'uuid', type: 'uuid',
nullable: true, nullable: true,

View File

@ -54,7 +54,31 @@ export class PpobCallbackController {
console.log(typeof response['message'], "INI DIA") console.log(typeof response['message'], "INI DIA")
if (response['message'].includes('CEK TAGIHAN')) { if (response['message'].includes('CEK TAGIHAN')) {
console.log("messagenya tuh",response['message'])
if (response['status'] != 20) {
//TODO: UPDATE GAGAL
const updateTransaction =
await this.transactionService.callbackOrderFailed(
response['refid'],
response,
);
return {
updateTransaction,
statusCode: HttpStatus.BAD_REQUEST,
message: 'failed to proccess',
};
}
const splitMessage = response['message'].split('","');
console.log("masuk sini")
//TODO: UPDATE BERHASIL
await this.transactionService.updateBill(
response['refid'],
splitMessage[3].replace(/^\D+/g, ''),
splitMessage[4].replace(/^\D+/g, ''),
);
//
} else { } else {
if (response['status'] != 20) { if (response['status'] != 20) {
//TODO: UPDATE GAGAL //TODO: UPDATE GAGAL

View File

@ -488,7 +488,7 @@ export class TransactionService {
id: orderTransactionDto.bill_trx_id id: orderTransactionDto.bill_trx_id
}, },
}); });
product_price.price = billId.amount product_price.price = billId.amount;
} catch (e) { } catch (e) {
if (e instanceof EntityNotFoundError) { if (e instanceof EntityNotFoundError) {
throw new HttpException( throw new HttpException(
@ -533,7 +533,7 @@ export class TransactionService {
if (supplier.code != 'IRS') { if (supplier.code != 'IRS') {
const parsingResponse = hitSupplier.split(' '); const parsingResponse = hitSupplier.split(' ');
hitSupplier = { hitSupplier = {
success: hitSupplier.include('diproses'), success: hitSupplier.includes('diproses'),
harga: parseInt( harga: parseInt(
parsingResponse[parsingResponse.length - 2].replaceAll('.', ''), parsingResponse[parsingResponse.length - 2].replaceAll('.', ''),
), ),
@ -723,7 +723,7 @@ export class TransactionService {
if (supplier.code != 'IRS') { if (supplier.code != 'IRS') {
const parsingResponse = hitSupplier.split(' '); const parsingResponse = hitSupplier.split(' ');
hitSupplier = { hitSupplier = {
success: hitSupplier.include('diproses'), success: hitSupplier.includes('diproses'),
harga: parseInt( harga: parseInt(
parsingResponse[parsingResponse.length - 2].replaceAll('.', ''), parsingResponse[parsingResponse.length - 2].replaceAll('.', ''),
), ),
@ -853,8 +853,9 @@ export class TransactionService {
supplier, supplier,
); );
const parsingResponse = hitSupplier.split(' '); const parsingResponse = hitSupplier.split(' ');
console.log(hitSupplier,"ini dia")
hitSupplier = { hitSupplier = {
success: hitSupplier.include('diproses'), success: hitSupplier.includes('diproses'),
msg: hitSupplier, msg: hitSupplier,
}; };
@ -1779,4 +1780,16 @@ export class TransactionService {
return transaction; return transaction;
} }
async updateBill(trxId: string, amount: number, admin: number) {
await this.checkBillHistoryRepository.update(
{
trx_id: trxId,
},
{
amount: amount,
admin_price: admin,
},
);
}
} }