This commit is contained in:
Fadli 2022-10-28 11:08:07 +07:00
commit 4e9d4e48f9
2 changed files with 325 additions and 299 deletions

View File

@ -3,7 +3,7 @@ import {
Get,
HttpException,
HttpStatus,
Logger,
Logger, Post,
Req,
} from '@nestjs/common';
import { TransactionService } from './transaction.service';
@ -131,4 +131,25 @@ export class PpobCallbackController {
}
}
}
@Public()
@Post('/hemat')
async getHemat(@Req() request: FastifyRequest) {
const response = request.body;
console.log('responsehemat', response);
console.log('responsehemat2', request.body);
if (response['msg'] != 'Transaksi Sukses') {
//TODO: UPDATE GAGAL
await this.transactionService.checkCallbackOrderFailed(
response['data']['idtransaction'],
response,
);
} else {
//TODO: UPDATE BERHASIL
await this.transactionService.checkCallbackOrderSuccess(
response['data']['idtransaction'],
response,
);
}
}
}

View File

@ -1361,13 +1361,9 @@ export class TransactionService {
product_price.product.id,
);
console.log('inipricetable', dataTransaction.product_price.price);
console.log('inipricecallback', callback['price']);
if (callback['message']) {
if (callback['message'].includes('METRO')) {
if (callback['price'] != dataTransaction.product_price.price) {
console.log('mskupdt', 'msk');
dataTransaction.product_price.price = parseInt(callback['price']);
}
}
@ -1463,8 +1459,24 @@ export class TransactionService {
},
});
const product_price = await this.productHistoryPriceService.findById(
dataTransaction.product_price.id,
);
const product = await this.productService.findOneById(
product_price.product.id,
);
const supplier = await this.supplierService.findByCode(
product.supplier.code,
);
dataTransaction.status = statusTransaction.SUCCESS;
if (supplier.code == 'Hemat') {
dataTransaction.seri_number = callback['data']['serial_number'];
dataProductHistoryPrice.price = parseInt(callback['data']['additional']['harga']);
} else {
if (callback['sn']) {
dataTransaction.seri_number = callback['sn'];
console.log('msksn1', dataTransaction.seri_number);
@ -1489,19 +1501,12 @@ export class TransactionService {
}
}
}
}
const userData = await this.userService.findExist(dataTransaction.user);
let supervisorData = [];
const product_price = await this.productHistoryPriceService.findById(
dataTransaction.product_price.id,
);
const product = await this.productService.findOneById(
product_price.product.id,
);
let profit = product_price.mark_up_price;
//GET COA
@ -2121,7 +2126,7 @@ export class TransactionService {
total_transaction: parseInt(data.total_transaction),
total_modal: parseInt(data.total_modal),
total_profit: parseInt(data.total_profit),
total_commission: parseInt(total_expense) - parseInt(data.total_profit),
total_commission: parseInt(data.total_profit) - parseInt(total_expense),
};
}