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