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() @Column()
product_code: string; product_code: string;
@Column()
status: string;
@ManyToOne(() => ProductHistoryPrice, (product) => product.id) @ManyToOne(() => ProductHistoryPrice, (product) => product.id)
product_price: ProductHistoryPrice; product_price: ProductHistoryPrice;
} }

View File

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

View File

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