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:40:03 +00:00
commit c2988d30a9
5 changed files with 32 additions and 10 deletions

View File

@ -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;
} }

View File

@ -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],
}); });
} }
}); });

View File

@ -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;
} }

View File

@ -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('","');

View File

@ -316,7 +316,7 @@ export class TransactionService {
//GET PRODUCT //GET PRODUCT
const product = await this.productService.findOne( const product = await this.productService.findOne(
orderTransactionDto.productCode, orderTransactionDto.productCode,
'prepaid', 'prepaid'
); );
const product_price = await this.productHistoryPriceService.findOne( const product_price = await this.productHistoryPriceService.findOne(
@ -677,7 +677,7 @@ export class TransactionService {
product.supplier.code, product.supplier.code,
); );
const product_price = await this.productHistoryPriceService.findOne( let product_price = await this.productHistoryPriceService.findOne(
product.id, product.id,
userData.partner?.id, userData.partner?.id,
); );
@ -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)
@ -852,14 +856,12 @@ export class TransactionService {
try { try {
let hitSupplier = await doTransaction( let hitSupplier = await doTransaction(
`CEK${orderTransactionDto.productCode.slice(3)}`, 'CEK' + orderTransactionDto.productCode.slice(3),
orderTransactionDto.destination, orderTransactionDto.destination,
trxId, trxId,
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,
@ -884,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) {
@ -1813,27 +1816,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,
'-', '-',