Compare commits

...

6 Commits

Author SHA1 Message Date
ihsan 301696661d Merge branch 'develop' of https://github.com/mohamadihsan/topuponline into develop_v1.5.7 2025-03-03 13:59:31 +07:00
ihsan 9fa469fc67 change file rotate log time 2025-03-03 13:57:55 +07:00
lutfi 02fa5cb909 update 2025-01-24 18:12:26 +07:00
lutfi 3dfd2a50d4 update 2025-01-24 17:56:56 +07:00
ihsan d51325cd81 update version info 2025-01-16 15:13:31 +07:00
ihsan 99ebab8591 bug fixed autocomplete transaction 2025-01-16 15:12:30 +07:00
5 changed files with 71 additions and 71 deletions
+9 -1
View File
@@ -27,7 +27,13 @@ var logger;
const fileRotateTransport = new winston.transports.DailyRotateFile({
filename: `application/logs/%DATE%-onlinetopup.log`,
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:
@@ -54,6 +60,7 @@ if (
defaultMeta: { service: "topuponline-service" },
transports: [
fileRotateTransport,
fileRotateTransportDebug,
//
// - 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`
@@ -84,6 +91,7 @@ if (
defaultMeta: { service: "topuponline-service" },
transports: [
fileRotateTransport,
fileRotateTransportDebug,
//
// - 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`
@@ -181,7 +181,7 @@ const updateAllTransaction = async (
);
// update reservation and load balance transaction
await model.updateReservationAndLoadingBalance(
const update = await model.updateReservationAndLoadingBalance(
reservationNumber,
data,
dataLoadingBalanceDetail,
@@ -189,32 +189,37 @@ const updateAllTransaction = async (
flag
);
// log debug
winston.logger.debug(`${uniqueCode} inserting log for card history...`);
if (update) {
// log debug
winston.logger.debug(`${uniqueCode} inserting log for card history...`);
// log card history
await model.createLoadBalanceLog({
i_log_name: 21,
d_log: dataLoadingBalance.d_load_balance,
c_card_number: cardNumber,
c_source: 'CMS',
c_location: getPartner ? getPartner.partner_name : null,
m_balance_before: parseInt(dataLoadingBalance.m_balance),
m_amount: parseInt(dataLoadingBalance.i_topup_amount),
m_balance_after: parseInt(balance),
j_new_data: { data: data, detail: dataLoadingBalanceDetail },
j_old_data: null,
c_note: `LOAD BALANCE ${dataLoadingBalance.i_topup_amount} FROM ${getPartner ? getPartner.partner_name : null
// log card history
await model.createLoadBalanceLog({
i_log_name: 21,
d_log: dataLoadingBalance.d_load_balance,
c_card_number: cardNumber,
c_source: 'CMS',
c_location: getPartner ? getPartner.partner_name : null,
m_balance_before: parseInt(dataLoadingBalance.m_balance),
m_amount: parseInt(dataLoadingBalance.i_topup_amount),
m_balance_after: parseInt(balance),
j_new_data: { data: data, detail: dataLoadingBalanceDetail },
j_old_data: null,
c_note: `LOAD BALANCE ${dataLoadingBalance.i_topup_amount} FROM ${
getPartner ? getPartner.partner_name : null
} SUCCESSFULLY`,
c_status: 'S',
d_created: now,
i_create: null,
c_create_username: 'HSM',
c_create_fullname: 'HARDWARE SECURE MODULE',
c_category: 'T',
});
c_status: 'S',
d_created: now,
i_create: null,
c_create_username: 'HSM',
c_create_fullname: 'HARDWARE SECURE MODULE',
c_category: 'T',
});
return true;
return true;
} else {
return false;
}
} else {
// insert new load balance transaction by data on card and update data reservation
@@ -985,7 +990,7 @@ const loadingBalanceRequest = async (req, res) => {
if (
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
parseInt(balance) + amountTopup >
parseInt(getMaxAmountOnTheCard.c_value)
parseInt(getMaxAmountOnTheCard.c_value)
) {
amountTopup =
amountTopup - parseInt(rsv.i_reservation_amount);
@@ -1098,7 +1103,7 @@ const loadingBalanceRequest = async (req, res) => {
if (
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
parseInt(balance) + amountTopup >
parseInt(getMaxAmountOnTheCard.c_value)
parseInt(getMaxAmountOnTheCard.c_value)
) {
amountTopup =
amountTopup - parseInt(rsv.i_reservation_amount);
@@ -1557,7 +1562,10 @@ const loadingBalanceInsert = async (req, param) => {
req.partner_id_token,
loadBalanceNoSequence + 1
);
console.log('Masuk kondisi !loadBalanceNoSequence', loadBalanceNoSequence);
console.log(
'Masuk kondisi !loadBalanceNoSequence',
loadBalanceNoSequence
);
}
// Percobaan 1
@@ -2071,8 +2079,9 @@ const loadingBalanceUpdate = async (param) => {
m_balance_after: parseInt(balance) + parseInt(amount),
j_new_data: { data: dataLoadBalance, detail: detailLoadBalance },
j_old_data: null,
c_note: `LOAD BALANCE ${amount} FROM ${getPartner ? getPartner.partner_name : null
} SUCCESSFULLY`,
c_note: `LOAD BALANCE ${amount} FROM ${
getPartner ? getPartner.partner_name : null
} SUCCESSFULLY`,
c_status: 'S',
d_created: now,
i_create: null,
@@ -698,7 +698,7 @@ const updateReservationAndLoadingBalance = async (
.whereIn('c_reservation_no', reservationNumber);
})
.then(() => {
winston.logger.debug(`${reservationNumber} commit transaction`);
// winston.logger.debug(`${reservationNumber} commit transaction`);
trx.commit();
})
.catch((error) => {
@@ -710,18 +710,18 @@ const updateReservationAndLoadingBalance = async (
});
})
.then((result) => {
winston.logger.debug(
`${reservationNumber} result success ${JSON.stringify(result)}}`
);
// winston.logger.debug(
// `${reservationNumber} result success ${JSON.stringify(result)}}`
// );
// console.log(result);
return result.rowCount;
return true;
})
.catch((error) => {
winston.logger.debug(
`${reservationNumber} result error: ${error.message}`
);
// console.log(error.message);
return error.message;
return false;
});
};
+16 -33
View File
@@ -245,40 +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
},
};
const dataPost = { 'card_number': card_number }
const url = current_url + `/api/pos/card-lastbalance`;
const resp = await axios.post(url, dataPost, config);
//LOG-INFO
winston.logger.info(
`${uniqueCode} [ card_number ]: ${JSON.stringify(card_number)}`
);
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;
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 = {
@@ -287,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
}
}
};
@@ -297,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
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "topuponline",
"version": "1.5.5",
"description": "update logic set sequence load balance number to handle max loop issue",
"version": "1.5.7",
"description": "change file rotate log from 90 days to 60 days",
"main": "index.js",
"scripts": {
"start": "nodemon index",