mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 11:06:28 +00:00
update
This commit is contained in:
@@ -245,54 +245,22 @@ const validateBlacklist = async (card_number, uniqueCode) => {
|
||||
//CHECK LAST BALANCE CTR
|
||||
const checkLastBalanceCTS = async (card_number, uniqueCode, req) => {
|
||||
let result = {};
|
||||
|
||||
let auth = req.header('Authorization');
|
||||
token_api = auth.replace('Bearer ', '');
|
||||
|
||||
const protocol = req.protocol;
|
||||
const host = req.headers.host;
|
||||
const current_url = protocol+'://'+host;
|
||||
|
||||
let config = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + token_api
|
||||
},
|
||||
};
|
||||
|
||||
//LOG-INFO
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE config ]: ${JSON.stringify(config)}`
|
||||
`${uniqueCode} [ card_number ]: ${JSON.stringify(card_number)}`
|
||||
);
|
||||
|
||||
const dataPost = { 'card_number': card_number }
|
||||
const url = current_url + `/api/pos/card-lastbalance`;
|
||||
let last_balance = 0;
|
||||
let getLastBalanceFromCardHistory = await model.getLastBalanceFromCardHistory(card_number);
|
||||
|
||||
//LOG-INFO
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE url ]: ${JSON.stringify(url)}`
|
||||
`${uniqueCode} [ getLastBalanceFromCardHistory ]: ${JSON.stringify(getLastBalanceFromCardHistory)}`
|
||||
);
|
||||
|
||||
const resp = await axios.post(url, dataPost, config);
|
||||
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE resp.data ]: ${JSON.stringify(resp.data)}`
|
||||
);
|
||||
|
||||
if(resp.data.data == undefined || resp.data.data.detail.last_balance == undefined) {
|
||||
result = {
|
||||
code: '446',
|
||||
message: 'Card number not exist in CTS to get last balance',
|
||||
data: {
|
||||
status: false,
|
||||
detail: {
|
||||
last_balance: last_balance
|
||||
}
|
||||
}
|
||||
};
|
||||
//LOG-INFO
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE GET LAST-BALANCE FROM CTS ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
return result;
|
||||
if (getLastBalanceFromCardHistory) {
|
||||
last_balance = getLastBalanceFromCardHistory.m_balance_after;
|
||||
}
|
||||
|
||||
result = {
|
||||
@@ -301,7 +269,7 @@ const checkLastBalanceCTS = async (card_number, uniqueCode, req) => {
|
||||
data: {
|
||||
status: true,
|
||||
detail: {
|
||||
last_balance: resp.data.data.detail.last_balance
|
||||
last_balance: last_balance
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -311,6 +279,7 @@ const checkLastBalanceCTS = async (card_number, uniqueCode, req) => {
|
||||
`${uniqueCode} [ RESPONSE GET LAST-BALANCE FROM CTS ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
return result;
|
||||
|
||||
};
|
||||
|
||||
//VALIDATE CARD PRODUCT
|
||||
|
||||
Reference in New Issue
Block a user