mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 11:06:28 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 301696661d | |||
| 9fa469fc67 | |||
| 02fa5cb909 | |||
| 3dfd2a50d4 | |||
| d51325cd81 | |||
| 99ebab8591 |
@@ -27,7 +27,13 @@ var logger;
|
|||||||
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
||||||
filename: `application/logs/%DATE%-onlinetopup.log`,
|
filename: `application/logs/%DATE%-onlinetopup.log`,
|
||||||
datePattern: "YYYY-MM-DD",
|
datePattern: "YYYY-MM-DD",
|
||||||
maxFiles: "90d",
|
maxFiles: "60d",
|
||||||
|
});
|
||||||
|
|
||||||
|
const fileRotateTransportDebug = new winston.transports.DailyRotateFile({
|
||||||
|
filename: `application/logs/debug/%DATE%-onlinetopup.log`,
|
||||||
|
datePattern: "YYYY-MM-DD",
|
||||||
|
maxFiles: "30d",
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
// If we're not in production then log to the `console` with the format:
|
// If we're not in production then log to the `console` with the format:
|
||||||
@@ -54,6 +60,7 @@ if (
|
|||||||
defaultMeta: { service: "topuponline-service" },
|
defaultMeta: { service: "topuponline-service" },
|
||||||
transports: [
|
transports: [
|
||||||
fileRotateTransport,
|
fileRotateTransport,
|
||||||
|
fileRotateTransportDebug,
|
||||||
//
|
//
|
||||||
// - Write all logs with importance level of `error` or less to `error.log`
|
// - Write all logs with importance level of `error` or less to `error.log`
|
||||||
// - Write all logs with importance level of `info` or less to `onlinetopup.log`
|
// - Write all logs with importance level of `info` or less to `onlinetopup.log`
|
||||||
@@ -84,6 +91,7 @@ if (
|
|||||||
defaultMeta: { service: "topuponline-service" },
|
defaultMeta: { service: "topuponline-service" },
|
||||||
transports: [
|
transports: [
|
||||||
fileRotateTransport,
|
fileRotateTransport,
|
||||||
|
fileRotateTransportDebug,
|
||||||
//
|
//
|
||||||
// - Write all logs with importance level of `error` or less to `error.log`
|
// - Write all logs with importance level of `error` or less to `error.log`
|
||||||
// - Write all logs with importance level of `info` or less to `onlinetopup.log`
|
// - Write all logs with importance level of `info` or less to `onlinetopup.log`
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ const updateAllTransaction = async (
|
|||||||
);
|
);
|
||||||
|
|
||||||
// update reservation and load balance transaction
|
// update reservation and load balance transaction
|
||||||
await model.updateReservationAndLoadingBalance(
|
const update = await model.updateReservationAndLoadingBalance(
|
||||||
reservationNumber,
|
reservationNumber,
|
||||||
data,
|
data,
|
||||||
dataLoadingBalanceDetail,
|
dataLoadingBalanceDetail,
|
||||||
@@ -189,6 +189,7 @@ const updateAllTransaction = async (
|
|||||||
flag
|
flag
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (update) {
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(`${uniqueCode} inserting log for card history...`);
|
winston.logger.debug(`${uniqueCode} inserting log for card history...`);
|
||||||
|
|
||||||
@@ -204,7 +205,8 @@ const updateAllTransaction = async (
|
|||||||
m_balance_after: parseInt(balance),
|
m_balance_after: parseInt(balance),
|
||||||
j_new_data: { data: data, detail: dataLoadingBalanceDetail },
|
j_new_data: { data: data, detail: dataLoadingBalanceDetail },
|
||||||
j_old_data: null,
|
j_old_data: null,
|
||||||
c_note: `LOAD BALANCE ${dataLoadingBalance.i_topup_amount} FROM ${getPartner ? getPartner.partner_name : null
|
c_note: `LOAD BALANCE ${dataLoadingBalance.i_topup_amount} FROM ${
|
||||||
|
getPartner ? getPartner.partner_name : null
|
||||||
} SUCCESSFULLY`,
|
} SUCCESSFULLY`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
@@ -215,6 +217,9 @@ const updateAllTransaction = async (
|
|||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// insert new load balance transaction by data on card and update data reservation
|
// insert new load balance transaction by data on card and update data reservation
|
||||||
|
|
||||||
@@ -1557,7 +1562,10 @@ const loadingBalanceInsert = async (req, param) => {
|
|||||||
req.partner_id_token,
|
req.partner_id_token,
|
||||||
loadBalanceNoSequence + 1
|
loadBalanceNoSequence + 1
|
||||||
);
|
);
|
||||||
console.log('Masuk kondisi !loadBalanceNoSequence', loadBalanceNoSequence);
|
console.log(
|
||||||
|
'Masuk kondisi !loadBalanceNoSequence',
|
||||||
|
loadBalanceNoSequence
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Percobaan 1
|
// Percobaan 1
|
||||||
@@ -2071,7 +2079,8 @@ const loadingBalanceUpdate = async (param) => {
|
|||||||
m_balance_after: parseInt(balance) + parseInt(amount),
|
m_balance_after: parseInt(balance) + parseInt(amount),
|
||||||
j_new_data: { data: dataLoadBalance, detail: detailLoadBalance },
|
j_new_data: { data: dataLoadBalance, detail: detailLoadBalance },
|
||||||
j_old_data: null,
|
j_old_data: null,
|
||||||
c_note: `LOAD BALANCE ${amount} FROM ${getPartner ? getPartner.partner_name : null
|
c_note: `LOAD BALANCE ${amount} FROM ${
|
||||||
|
getPartner ? getPartner.partner_name : null
|
||||||
} SUCCESSFULLY`,
|
} SUCCESSFULLY`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
|
|||||||
@@ -698,7 +698,7 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
.whereIn('c_reservation_no', reservationNumber);
|
.whereIn('c_reservation_no', reservationNumber);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
winston.logger.debug(`${reservationNumber} commit transaction`);
|
// winston.logger.debug(`${reservationNumber} commit transaction`);
|
||||||
trx.commit();
|
trx.commit();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@@ -710,18 +710,18 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
winston.logger.debug(
|
// winston.logger.debug(
|
||||||
`${reservationNumber} result success ${JSON.stringify(result)}}`
|
// `${reservationNumber} result success ${JSON.stringify(result)}}`
|
||||||
);
|
// );
|
||||||
// console.log(result);
|
// console.log(result);
|
||||||
return result.rowCount;
|
return true;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
`${reservationNumber} result error: ${error.message}`
|
`${reservationNumber} result error: ${error.message}`
|
||||||
);
|
);
|
||||||
// console.log(error.message);
|
// console.log(error.message);
|
||||||
return error.message;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -246,39 +246,21 @@ const validateBlacklist = async (card_number, uniqueCode) => {
|
|||||||
const checkLastBalanceCTS = async (card_number, uniqueCode, req) => {
|
const checkLastBalanceCTS = async (card_number, uniqueCode, req) => {
|
||||||
let result = {};
|
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
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const dataPost = { 'card_number': card_number }
|
|
||||||
const url = current_url + `/api/pos/card-lastbalance`;
|
|
||||||
const resp = await axios.post(url, dataPost, config);
|
|
||||||
|
|
||||||
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
|
//LOG-INFO
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} [ RESPONSE GET LAST-BALANCE FROM CTS ]: ${JSON.stringify(result)}`
|
`${uniqueCode} [ card_number ]: ${JSON.stringify(card_number)}`
|
||||||
);
|
);
|
||||||
return result;
|
|
||||||
|
let last_balance = 0;
|
||||||
|
let getLastBalanceFromCardHistory = await model.getLastBalanceFromCardHistory(card_number);
|
||||||
|
|
||||||
|
//LOG-INFO
|
||||||
|
winston.logger.info(
|
||||||
|
`${uniqueCode} [ getLastBalanceFromCardHistory ]: ${JSON.stringify(getLastBalanceFromCardHistory)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (getLastBalanceFromCardHistory) {
|
||||||
|
last_balance = getLastBalanceFromCardHistory.m_balance_after;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
@@ -287,7 +269,7 @@ const checkLastBalanceCTS = async (card_number, uniqueCode, req) => {
|
|||||||
data: {
|
data: {
|
||||||
status: true,
|
status: true,
|
||||||
detail: {
|
detail: {
|
||||||
last_balance: resp.data.data.detail.last_balance
|
last_balance: last_balance
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -297,6 +279,7 @@ const checkLastBalanceCTS = async (card_number, uniqueCode, req) => {
|
|||||||
`${uniqueCode} [ RESPONSE GET LAST-BALANCE FROM CTS ]: ${JSON.stringify(result)}`
|
`${uniqueCode} [ RESPONSE GET LAST-BALANCE FROM CTS ]: ${JSON.stringify(result)}`
|
||||||
);
|
);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//VALIDATE CARD PRODUCT
|
//VALIDATE CARD PRODUCT
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "topuponline",
|
"name": "topuponline",
|
||||||
"version": "1.5.5",
|
"version": "1.5.7",
|
||||||
"description": "update logic set sequence load balance number to handle max loop issue",
|
"description": "change file rotate log from 90 days to 60 days",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "nodemon index",
|
"start": "nodemon index",
|
||||||
|
|||||||
Reference in New Issue
Block a user