Merge branch 'master' of https://gitlab.com/empatnusabangsa/ppob/ppob-backend into devops-production
This commit is contained in:
commit
9f2aee624a
|
@ -66,7 +66,10 @@ export class PpobCallbackController {
|
|||
);
|
||||
//
|
||||
} else {
|
||||
console.log('statusapani', response['status']);
|
||||
console.log('statusapani2', response.toString());
|
||||
if (response['status'].toString() != '20') {
|
||||
console.log("masukkesiniga", "msk")
|
||||
//TODO: UPDATE GAGAL
|
||||
const updateTransaction =
|
||||
await this.transactionService.callbackOrderFailed(
|
||||
|
@ -79,7 +82,7 @@ export class PpobCallbackController {
|
|||
statusCode: HttpStatus.BAD_REQUEST,
|
||||
message: 'failed to proccess',
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
||||
//TODO: UPDATE BERHASIL
|
||||
const updateTransaction =
|
||||
|
@ -87,8 +90,14 @@ export class PpobCallbackController {
|
|||
response['refid'],
|
||||
response,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
updateTransaction,
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'success',
|
||||
};
|
||||
}
|
||||
}
|
||||
this.logger.log({
|
||||
requestQuery: request.query,
|
||||
});
|
||||
|
|
|
@ -299,6 +299,22 @@ export class TransactionService {
|
|||
orderTransactionDto: OrderTransactionDto,
|
||||
currentUser: any,
|
||||
) {
|
||||
|
||||
const productData = await this.productService.findOne(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
);
|
||||
|
||||
if (productData.status == 'NOT ACTIVE') {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
error: `Transaction Failed because product is not active`,
|
||||
},
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
} else {
|
||||
|
||||
const trxId = Array(6)
|
||||
.fill(null)
|
||||
.map(() => {
|
||||
|
@ -434,11 +450,27 @@ export class TransactionService {
|
|||
status: statusTransaction[statusTransaction.SUCCESS],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async orderTransactionProd(
|
||||
orderTransactionDto: OrderTransactionDto,
|
||||
currentUser: any,
|
||||
) {
|
||||
|
||||
const productData = await this.productService.findOne(
|
||||
orderTransactionDto.productCode,
|
||||
'prepaid',
|
||||
);
|
||||
|
||||
if (productData.status == 'NOT ACTIVE') {
|
||||
throw new HttpException(
|
||||
{
|
||||
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
error: `Transaction Failed because product is not active`,
|
||||
},
|
||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
} else {
|
||||
let status;
|
||||
const amount = 0;
|
||||
//GET USER DATA
|
||||
|
@ -530,16 +562,15 @@ export class TransactionService {
|
|||
|
||||
if (supplier.code != 'IRS') {
|
||||
const parsingResponse = hitSupplier.split(' ');
|
||||
console.log
|
||||
const newHitSupplier = {
|
||||
success: hitSupplier.includes('diproses'),
|
||||
harga: parseInt(
|
||||
parsingResponse[parsingResponse.length - 2].replace(/\./g,' '),
|
||||
parsingResponse[parsingResponse.length - 2].replace(/\./g, ' '),
|
||||
),
|
||||
msg: hitSupplier,
|
||||
};
|
||||
hitSupplier = newHitSupplier;
|
||||
if(orderTransactionDto.bill_trx_id !== null){
|
||||
if (orderTransactionDto.bill_trx_id !== null) {
|
||||
hitSupplier.harga = product_price.price;
|
||||
}
|
||||
}
|
||||
|
@ -653,6 +684,7 @@ export class TransactionService {
|
|||
status: status,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async orderTransactionBillProd(
|
||||
orderTransactionDto: OrderTransactionDto,
|
||||
|
@ -1169,12 +1201,12 @@ export class TransactionService {
|
|||
relations: ['product_price'],
|
||||
});
|
||||
|
||||
const dataMsg = callback.msg;
|
||||
const failedReason = dataMsg.split('.');
|
||||
// const dataMsg = callback.msg;
|
||||
// const failedReason = dataMsg.split('.');
|
||||
|
||||
dataTransaction.status = statusTransaction.FAILED;
|
||||
dataTransaction.callback_json = callback;
|
||||
dataTransaction.failed_reason = `${failedReason[0]}, ${failedReason[1]}`;
|
||||
// dataTransaction.status = statusTransaction.FAILED;
|
||||
// dataTransaction.callback_json = callback;
|
||||
// dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`;
|
||||
|
||||
const userData = await this.userService.findExist(dataTransaction.user);
|
||||
|
||||
|
@ -1186,6 +1218,13 @@ export class TransactionService {
|
|||
product_price.product.id,
|
||||
);
|
||||
|
||||
dataTransaction.status = statusTransaction.FAILED;
|
||||
dataTransaction.callback_json = callback;
|
||||
dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`;
|
||||
if (callback['price'] != dataTransaction.product_price.price) {
|
||||
dataTransaction.product_price.price = callback['price']
|
||||
}
|
||||
|
||||
//GET COA
|
||||
const coaAccount = await this.coaService.findByUser(
|
||||
userData.id,
|
||||
|
@ -1271,6 +1310,10 @@ export class TransactionService {
|
|||
}
|
||||
dataTransaction.callback_json = callback;
|
||||
|
||||
if (callback['price'] != dataTransaction.product_price.price) {
|
||||
dataTransaction.product_price.price = callback['price']
|
||||
}
|
||||
|
||||
const userData = await this.userService.findExist(dataTransaction.user);
|
||||
|
||||
let supervisorData = [];
|
||||
|
@ -1570,6 +1613,7 @@ export class TransactionService {
|
|||
)
|
||||
.leftJoin('transaction.product_price', 'product_price')
|
||||
.leftJoin('product_price.product', 'product')
|
||||
.leftJoin('product.supplier', 'supplier')
|
||||
.addSelect('transaction.amount', 'price')
|
||||
.addSelect('transaction.destination')
|
||||
.addSelect('transaction.seri_number', 'seri_number')
|
||||
|
@ -1579,7 +1623,9 @@ export class TransactionService {
|
|||
.addSelect('transaction.failed_reason', 'failed_reason')
|
||||
.addSelect('userData.name', 'buyer')
|
||||
.addSelect('product.name', 'name')
|
||||
.addSelect('product.id', 'product_id')
|
||||
.addSelect('product_price.price', 'product_price')
|
||||
.addSelect('product.name', 'supplier_name')
|
||||
.addSelect('supplier.name', 'supplier_name')
|
||||
.orderBy('transaction.created_at', 'DESC');
|
||||
|
||||
if (startDate && endDate) {
|
||||
|
@ -1887,10 +1933,21 @@ export class TransactionService {
|
|||
.addSelect('COUNT(transactions.id) as total_transaction')
|
||||
.getRawOne();
|
||||
|
||||
// const dataCoa = this.coaRepository
|
||||
// .createQueryBuilder('coa')
|
||||
// .innerJoin('user', 'user', 'coa.user = user.id')
|
||||
// .where(
|
||||
// `coa.type = '0' and user.partner_id is not NULL and user.is_active = true and is_rejected = false`
|
||||
// );
|
||||
//
|
||||
// const coa = await dataCoa
|
||||
// .select('SUM(coa.amount) as total_modal')
|
||||
// .getRawOne();
|
||||
|
||||
return {
|
||||
total_modal: parseInt(data.total_modal),
|
||||
total_amount: parseInt(data.total_amount),
|
||||
total_transaction: parseInt(data.total_transaction),
|
||||
total_modal: parseInt(data.total_modal),
|
||||
total_profit: parseInt(data.total_profit),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user