fixing: check bill
This commit is contained in:
@@ -1781,7 +1781,14 @@ export class TransactionService {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
async updateBill(trxId: string, amount: number, admin: number) {
|
||||
async updateBill(
|
||||
trxId: string,
|
||||
amount: number,
|
||||
admin: number,
|
||||
status: boolean,
|
||||
) {
|
||||
const billData = await this.findOneBillById(trxId);
|
||||
|
||||
await this.checkBillHistoryRepository.update(
|
||||
{
|
||||
trx_id: trxId,
|
||||
@@ -1791,5 +1798,45 @@ export class TransactionService {
|
||||
admin_price: admin,
|
||||
},
|
||||
);
|
||||
const userData = await this.userService.findExist(billData.user);
|
||||
|
||||
if (userData.partner) {
|
||||
const message = status
|
||||
? `Bill dari ${billData.destination} adalah ${amount}.`
|
||||
: '';
|
||||
const statusResponse = status ? 'berhasil' : 'gagal';
|
||||
this.callbackToPartner(
|
||||
userData.id,
|
||||
message,
|
||||
billData.partner_trx_id,
|
||||
amount,
|
||||
billData.product_code,
|
||||
billData.destination,
|
||||
'-',
|
||||
statusResponse,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async findOneBillById(trxId: string) {
|
||||
try {
|
||||
return await this.checkBillHistoryRepository.findOneOrFail({
|
||||
where:{
|
||||
trx_id: trxId,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof EntityNotFoundError) {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.NOT_FOUND,
|
||||
error: 'Bill not found',
|
||||
},
|
||||
HttpStatus.NOT_FOUND,
|
||||
);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user