Merge branch 'development' into 'devops-staging'

Development

See merge request empatnusabangsa/ppob/ppob-backend!165
This commit is contained in:
ilham dwi pratama 2022-05-21 07:39:42 +00:00
commit 4d631be1e8
5 changed files with 32 additions and 10 deletions

View File

@ -37,4 +37,9 @@ export class ProductHistoryPrice extends BaseModel {
default: 0,
})
admin_price: number;
@Column({
default: 0,
})
partner_fee: number;
}

View File

@ -110,6 +110,8 @@ export class ProductService {
type: productType.NORMAL,
startDate: new Date(),
partner: it[6] != '-' ? partnerData : null,
admin_price: it[8],
partner_fee: it[9],
});
} else {
let partnerData;
@ -135,6 +137,8 @@ export class ProductService {
startDate: new Date(),
endDate: null,
partner: partnerData,
admin_price: it[8],
partner_fee: it[9],
});
}
});

View File

@ -42,4 +42,7 @@ export class CheckBillHistory extends BaseModel {
@Column()
product_code: string;
@ManyToOne(() => ProductHistoryPrice, (product) => product.id)
product_price: ProductHistoryPrice;
}

View File

@ -64,7 +64,7 @@ export class PpobCallbackController {
return {
statusCode: HttpStatus.OK,
message: 'success',
};;
};
}
const splitMessage = response['message'].split('","');

View File

@ -316,7 +316,7 @@ export class TransactionService {
//GET PRODUCT
const product = await this.productService.findOne(
orderTransactionDto.productCode,
'prepaid',
'prepaid'
);
const product_price = await this.productHistoryPriceService.findOne(
@ -677,7 +677,7 @@ export class TransactionService {
product.supplier.code,
);
const product_price = await this.productHistoryPriceService.findOne(
let product_price = await this.productHistoryPriceService.findOne(
product.id,
userData.partner?.id,
);
@ -840,6 +840,10 @@ export class TransactionService {
product.supplier.code,
);
let product_price = await this.productHistoryPriceService.findOne(
product.id,
userData.partner?.id,
);
//HIT API SUPPLIER
const trxId = Array(6)
.fill(null)
@ -852,14 +856,12 @@ export class TransactionService {
try {
let hitSupplier = await doTransaction(
`CEK${orderTransactionDto.productCode.slice(3)}`,
'CEK' + orderTransactionDto.productCode.slice(3),
orderTransactionDto.destination,
trxId,
supplier,
);
const parsingResponse = hitSupplier.split(' ');
console.log(hitSupplier, 'ini dia');
hitSupplier = {
success: hitSupplier.includes('diproses'),
msg: hitSupplier,
@ -884,6 +886,7 @@ export class TransactionService {
destination: orderTransactionDto.destination,
product_code: orderTransactionDto.productCode,
partner_trx_id: orderTransactionDto.trx_id,
product_price: product_price,
});
}
} catch (e) {
@ -1813,27 +1816,34 @@ export class TransactionService {
) {
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(
{
trx_id: trxId,
},
{
amount: amount,
amount: amount + product_price.partner_fee + product_price.mark_up_price,
admin_price: admin,
},
);
const userData = await this.userService.findExist(billData.user);
if (userData.partner) {
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';
this.callbackToPartner(
userData.id,
message,
billData.partner_trx_id,
amount,
amount + product_price.partner_fee + product_price.mark_up_price,
billData.product_code,
billData.destination,
'-',