fix: ppob callback

This commit is contained in:
ilham 2022-05-24 00:42:58 +07:00
parent c26294ac50
commit 6f29457720
3 changed files with 16 additions and 4 deletions

View File

@ -43,6 +43,9 @@ export class CheckBillHistory extends BaseModel {
@Column()
product_code: string;
@Column()
status: string;
@ManyToOne(() => ProductHistoryPrice, (product) => product.id)
product_price: ProductHistoryPrice;
}

View File

@ -158,14 +158,19 @@ export class TransactionController {
@Get('check-bill-history')
async getCheckBillHistory(
@Param('id') id: string,
@Query('page') page: number,
@Query('pageSize') pageSize: number,
@Request() req,
) {
const data = await this.transactionService.findAll(
const [data, count] = await this.transactionService.findAll(
req.user.userId,
page,
pageSize,
);
return {
...data,
data,
count,
statusCode: HttpStatus.OK,
message: 'success',
};

View File

@ -887,6 +887,7 @@ export class TransactionService {
product_code: orderTransactionDto.productCode,
partner_trx_id: orderTransactionDto.trx_id,
product_price: product_price,
status: 'PENDING',
});
}
} catch (e) {
@ -1399,9 +1400,9 @@ export class TransactionService {
}
}
async findAll(user: string) {
async findAll(user: string, page, pageSize?) {
try {
return this.checkBillHistoryRepository.find({
return await this.checkBillHistoryRepository.findAndCount({
where: {
user: user,
},
@ -1414,6 +1415,8 @@ export class TransactionService {
'partner_trx_id',
'createdAt',
],
skip: page * (pageSize || 10),
take: pageSize || 10,
order: {
createdAt: 'DESC',
}
@ -1859,6 +1862,7 @@ export class TransactionService {
{
amount: amount + product_price.partner_fee + product_price.mark_up_price,
admin_price: admin,
status: status ? 'SUCCESS' : 'FAILED',
},
);