mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 09:06:27 +00:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9af6f4f823 | |||
| 5259fd89ef | |||
| 0e35368e22 | |||
| 0fdc901193 | |||
| c3a458313e | |||
| 8ed7e738ab | |||
| 11b2ff8721 | |||
| 851f1b14f6 | |||
| 67c33c8e1f | |||
| ad8951c567 | |||
| 5da07d9330 | |||
| a680bc235d | |||
| 269ae0088d | |||
| fe6fe9e72e | |||
| 060c9d0b0b | |||
| 7eff55e7f3 | |||
| 810d432374 | |||
| 687521146e | |||
| e82a09187c | |||
| 3a8e2976f0 | |||
| 530b5eed7e | |||
| e9e9bbf4c8 | |||
| 29c8f60135 | |||
| cc497f606b | |||
| c17e56731f | |||
| f5574250d7 | |||
| 3a85e63c01 | |||
| 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,32 +189,37 @@ const updateAllTransaction = async (
|
|||||||
flag
|
flag
|
||||||
);
|
);
|
||||||
|
|
||||||
// log debug
|
if (update) {
|
||||||
winston.logger.debug(`${uniqueCode} inserting log for card history...`);
|
// log debug
|
||||||
|
winston.logger.debug(`${uniqueCode} inserting log for card history...`);
|
||||||
|
|
||||||
// log card history
|
// log card history
|
||||||
await model.createLoadBalanceLog({
|
await model.createLoadBalanceLog({
|
||||||
i_log_name: 21,
|
i_log_name: 21,
|
||||||
d_log: dataLoadingBalance.d_load_balance,
|
d_log: dataLoadingBalance.d_load_balance,
|
||||||
c_card_number: cardNumber,
|
c_card_number: cardNumber,
|
||||||
c_source: 'CMS',
|
c_source: 'CMS',
|
||||||
c_location: getPartner ? getPartner.partner_name : null,
|
c_location: getPartner ? getPartner.partner_name : null,
|
||||||
m_balance_before: parseInt(dataLoadingBalance.m_balance),
|
m_balance_before: parseInt(dataLoadingBalance.m_balance),
|
||||||
m_amount: parseInt(dataLoadingBalance.i_topup_amount),
|
m_amount: parseInt(dataLoadingBalance.i_topup_amount),
|
||||||
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,
|
||||||
i_create: null,
|
i_create: null,
|
||||||
c_create_username: 'HSM',
|
c_create_username: 'HSM',
|
||||||
c_create_fullname: 'HARDWARE SECURE MODULE',
|
c_create_fullname: 'HARDWARE SECURE MODULE',
|
||||||
c_category: 'T',
|
c_category: 'T',
|
||||||
});
|
});
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -425,7 +430,15 @@ const updateAllTransaction = async (
|
|||||||
const loadingBalanceRequest = async (req, res) => {
|
const loadingBalanceRequest = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// param
|
// param
|
||||||
let { mid, tid, card_number, uid, balance, flag, unique_code } = req.body;
|
// let { mid, tid, card_number, uid, balance, flag, unique_code } = req.body;
|
||||||
|
|
||||||
|
let mid = req.body.mid;
|
||||||
|
let tid = req.body.tid;
|
||||||
|
let card_number = req.body.card_number;
|
||||||
|
let uid = req.body.uid;
|
||||||
|
let balance = req.body.balance;
|
||||||
|
let flag = req.body.flag;
|
||||||
|
let unique_code = req.body.unique_code;
|
||||||
|
|
||||||
// uniqueCode = await helper.getUniqueCode();
|
// uniqueCode = await helper.getUniqueCode();
|
||||||
let uniqueCode = unique_code;
|
let uniqueCode = unique_code;
|
||||||
@@ -705,9 +718,45 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
// let getReservationPendingWithFlag =
|
// let getReservationPendingWithFlag =
|
||||||
// await model.getReservationPendingWithFlag(card_number, now);
|
// await model.getReservationPendingWithFlag(card_number, now);
|
||||||
|
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST DEBUG X ]: ${JSON.stringify(
|
||||||
|
getReservationPendingWithFlagCounter
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// winston.logger.warn(
|
||||||
|
// `${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST DEBUG 1.1 ]: ${JSON.stringify(
|
||||||
|
// getReservationPending
|
||||||
|
// )}`
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
|
// winston.logger.warn(
|
||||||
|
// `${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST DEBUG 2 ]: ${JSON.stringify(req.body)}`
|
||||||
|
// );
|
||||||
|
|
||||||
|
// winston.logger.warn(
|
||||||
|
// `${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST DEBUG 2.1 ]: ${flag}`
|
||||||
|
// );
|
||||||
|
|
||||||
if (getReservationPendingWithFlagCounter.length > 0) {
|
if (getReservationPendingWithFlagCounter.length > 0) {
|
||||||
if (lastFlag) {
|
if (lastFlag) {
|
||||||
if (parseInt(lastFlag) <= parseInt(flag)) {
|
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST DEBUG Y ]: ${card_number}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// manipulasi last flag jika flag kartu sudah kembali ke 0
|
||||||
|
if (parseInt(lastFlag) == 255 && parseInt(flag) == 0) {
|
||||||
|
lastFlag = -1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parseInt(lastFlag) < parseInt(flag)) {
|
||||||
|
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST DEBUG Z ]: ${card_number}`
|
||||||
|
);
|
||||||
|
|
||||||
let reservationNumberPendingSuccessLoaded = [];
|
let reservationNumberPendingSuccessLoaded = [];
|
||||||
let loadBalanceNumberPendingSuccessLoaded = [];
|
let loadBalanceNumberPendingSuccessLoaded = [];
|
||||||
let totalReservationAmount = 0;
|
let totalReservationAmount = 0;
|
||||||
@@ -985,7 +1034,7 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
if (
|
if (
|
||||||
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
|
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
|
||||||
parseInt(balance) + amountTopup >
|
parseInt(balance) + amountTopup >
|
||||||
parseInt(getMaxAmountOnTheCard.c_value)
|
parseInt(getMaxAmountOnTheCard.c_value)
|
||||||
) {
|
) {
|
||||||
amountTopup =
|
amountTopup =
|
||||||
amountTopup - parseInt(rsv.i_reservation_amount);
|
amountTopup - parseInt(rsv.i_reservation_amount);
|
||||||
@@ -1098,7 +1147,7 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
if (
|
if (
|
||||||
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
|
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
|
||||||
parseInt(balance) + amountTopup >
|
parseInt(balance) + amountTopup >
|
||||||
parseInt(getMaxAmountOnTheCard.c_value)
|
parseInt(getMaxAmountOnTheCard.c_value)
|
||||||
) {
|
) {
|
||||||
amountTopup =
|
amountTopup =
|
||||||
amountTopup - parseInt(rsv.i_reservation_amount);
|
amountTopup - parseInt(rsv.i_reservation_amount);
|
||||||
@@ -1557,7 +1606,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,8 +2123,9 @@ 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 ${
|
||||||
} SUCCESSFULLY`,
|
getPartner ? getPartner.partner_name : null
|
||||||
|
} SUCCESSFULLY`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
i_create: null,
|
i_create: null,
|
||||||
@@ -2094,7 +2147,7 @@ const loadingBalanceUpdate = async (param) => {
|
|||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE LOADING-BALANCE-UPDATE ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -119,7 +119,24 @@ const getReservationPendingV2 = (cardNumber, time, flag) => {
|
|||||||
|
|
||||||
// GET RESERVATION PENDING WITH COMPARE FLAG COUNTER
|
// GET RESERVATION PENDING WITH COMPARE FLAG COUNTER
|
||||||
const getReservationPendingWithFlagCounter = (cardNumber, time, flag) => {
|
const getReservationPendingWithFlagCounter = (cardNumber, time, flag) => {
|
||||||
let result = knex('trx.t_d_reservation_balance')
|
let result
|
||||||
|
if (flag == '0' || flag == 0) {
|
||||||
|
result = knex('trx.t_d_reservation_balance')
|
||||||
|
// .sum("i_reservation_amount as total_reservation_amount")
|
||||||
|
// .count("* as total_reservation")
|
||||||
|
.select(
|
||||||
|
'i_reservation_amount',
|
||||||
|
'c_reservation_no',
|
||||||
|
'c_flag',
|
||||||
|
'c_load_balance_no'
|
||||||
|
)
|
||||||
|
.where('c_card_number', cardNumber)
|
||||||
|
.whereIn('c_status', ['P', 'I'])
|
||||||
|
.whereRaw('??::INT <= ??', ['c_flag', parseInt(255)])
|
||||||
|
// .where("d_expired", ">=", time)
|
||||||
|
.where('c_flag', '!=', '-1');
|
||||||
|
} else {
|
||||||
|
result = knex('trx.t_d_reservation_balance')
|
||||||
// .sum("i_reservation_amount as total_reservation_amount")
|
// .sum("i_reservation_amount as total_reservation_amount")
|
||||||
// .count("* as total_reservation")
|
// .count("* as total_reservation")
|
||||||
.select(
|
.select(
|
||||||
@@ -133,6 +150,8 @@ const getReservationPendingWithFlagCounter = (cardNumber, time, flag) => {
|
|||||||
.whereRaw('??::INT < ??', ['c_flag', parseInt(flag)])
|
.whereRaw('??::INT < ??', ['c_flag', parseInt(flag)])
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.where('c_flag', '!=', '-1');
|
.where('c_flag', '!=', '-1');
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -397,11 +416,11 @@ const insertLoadingBalance = async (
|
|||||||
.catch(trx.rollback);
|
.catch(trx.rollback);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
// console.log(result);
|
// console.log("result insertLoadingBalance", result);
|
||||||
return result.rowCount;
|
return result.rowCount;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
// console.log(error.message);
|
// console.log("error.message insertLoadingBalance", error.message);
|
||||||
return error.message;
|
return error.message;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -698,7 +717,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 +729,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;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ const validate = (method) => {
|
|||||||
.withMessage('Amount is required')
|
.withMessage('Amount is required')
|
||||||
.isNumeric()
|
.isNumeric()
|
||||||
.withMessage('Amount is invalid format'),
|
.withMessage('Amount is invalid format'),
|
||||||
|
body('last_balance')
|
||||||
|
.not()
|
||||||
|
.isEmpty()
|
||||||
|
.withMessage('Last Balance is required')
|
||||||
|
.isNumeric()
|
||||||
|
.withMessage('Last Balance is invalid format'),
|
||||||
];
|
];
|
||||||
case 'validateCardRedeem':
|
case 'validateCardRedeem':
|
||||||
return [
|
return [
|
||||||
@@ -45,6 +51,12 @@ const validate = (method) => {
|
|||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage('Card number is required'),
|
.withMessage('Card number is required'),
|
||||||
|
body('is_manual')
|
||||||
|
.not()
|
||||||
|
.isEmpty()
|
||||||
|
.withMessage('Is Manual is required')
|
||||||
|
.isBoolean()
|
||||||
|
.withMessage('Is Manual is invalid format'),
|
||||||
];
|
];
|
||||||
case 'checkBlacklist':
|
case 'checkBlacklist':
|
||||||
return [
|
return [
|
||||||
@@ -103,6 +115,9 @@ const checkLastBalance = async (req, res) => {
|
|||||||
let { card_number } = req.body;
|
let { card_number } = req.body;
|
||||||
let uniqueCode = await helper.getUniqueCode();
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(`${uniqueCode} checking last balance...`);
|
||||||
|
|
||||||
//CHECK IS CARD BLACKLISTED
|
//CHECK IS CARD BLACKLISTED
|
||||||
let cardBlacklist = await validateBlacklist(card_number, uniqueCode);
|
let cardBlacklist = await validateBlacklist(card_number, uniqueCode);
|
||||||
if (cardBlacklist) {
|
if (cardBlacklist) {
|
||||||
@@ -246,39 +261,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');
|
//LOG-INFO
|
||||||
token_api = auth.replace('Bearer ', '');
|
winston.logger.info(
|
||||||
|
`${uniqueCode} [ card_number ]: ${JSON.stringify(card_number)}`
|
||||||
|
);
|
||||||
|
|
||||||
const protocol = req.protocol;
|
let last_balance = 0;
|
||||||
const host = req.headers.host;
|
let getLastBalanceFromCardHistory = await model.getLastBalanceFromCardHistory(card_number);
|
||||||
const current_url = protocol+'://'+host;
|
|
||||||
|
|
||||||
let config = {
|
//LOG-INFO
|
||||||
headers: {
|
winston.logger.info(
|
||||||
'Content-Type': 'application/json',
|
`${uniqueCode} [ getLastBalanceFromCardHistory ]: ${JSON.stringify(getLastBalanceFromCardHistory)}`
|
||||||
'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) {
|
if (getLastBalanceFromCardHistory) {
|
||||||
result = {
|
last_balance = getLastBalanceFromCardHistory.m_balance_after;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
@@ -287,7 +284,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 +294,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
|
||||||
@@ -666,7 +664,7 @@ const validateTopup = async (req, res) => {
|
|||||||
let uniqueCode = await helper.getUniqueCode();
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
let dataCard = {};
|
let dataCard = {};
|
||||||
let result = {};
|
let result = {};
|
||||||
let { card_number, amount } = req.body;
|
let { card_number, amount, last_balance } = req.body;
|
||||||
console.log(
|
console.log(
|
||||||
`${uniqueCode} [ REQUEST VALIDATE-TOPUP ]: ${JSON.stringify(req.body)}`
|
`${uniqueCode} [ REQUEST VALIDATE-TOPUP ]: ${JSON.stringify(req.body)}`
|
||||||
);
|
);
|
||||||
@@ -760,10 +758,11 @@ const validateTopup = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let last_balance = 0;
|
if (last_balance) {
|
||||||
let getLastBalanceFromCardHistory = await model.getLastBalanceFromCardHistory(card_number);
|
let getLastBalanceFromCardHistory = await model.getLastBalanceFromCardHistory(card_number);
|
||||||
if (getLastBalanceFromCardHistory) {
|
if (getLastBalanceFromCardHistory) {
|
||||||
last_balance = getLastBalanceFromCardHistory.m_balance_after;
|
last_balance = getLastBalanceFromCardHistory.m_balance_after;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// last_balance = 2000000;
|
// last_balance = 2000000;
|
||||||
|
|
||||||
@@ -889,8 +888,7 @@ const validateRedeem = async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
let uniqueCode = await helper.getUniqueCode();
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
let result = {};
|
let result = {};
|
||||||
let last_balance = null;
|
let { card_number, is_manual, last_balance } = req.body;
|
||||||
let { card_number } = req.body;
|
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`${uniqueCode} [ REQUEST VALIDATE-REDEEM ]: ${JSON.stringify(req.body)}`
|
`${uniqueCode} [ REQUEST VALIDATE-REDEEM ]: ${JSON.stringify(req.body)}`
|
||||||
@@ -987,12 +985,14 @@ const validateRedeem = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//CHECK CARD LAST_BALANCE
|
if (is_manual) {
|
||||||
const dataLastBalance = await checkLastBalanceCTS(card_number, uniqueCode, req);
|
//CHECK CARD LAST_BALANCE
|
||||||
if(!dataLastBalance.data.status || dataLastBalance.data.status == false) {
|
const dataLastBalance = await checkLastBalanceCTS(card_number, uniqueCode, req);
|
||||||
return res.status(200).json(dataLastBalance);
|
if(!dataLastBalance.data.status || dataLastBalance.data.status == false) {
|
||||||
|
return res.status(200).json(dataLastBalance);
|
||||||
|
}
|
||||||
|
last_balance = dataLastBalance.data.detail.last_balance
|
||||||
}
|
}
|
||||||
last_balance = dataLastBalance.data.detail.last_balance
|
|
||||||
|
|
||||||
//CARD VALID TO REDEEM
|
//CARD VALID TO REDEEM
|
||||||
result = {
|
result = {
|
||||||
@@ -1037,6 +1037,7 @@ const validateReplacement = async (req, res) => {
|
|||||||
let { card_number } = req.body;
|
let { card_number } = req.body;
|
||||||
let dataCardReplacement = {};
|
let dataCardReplacement = {};
|
||||||
let last_balance = null;
|
let last_balance = null;
|
||||||
|
let is_warranty = false;
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`${uniqueCode} [ REQUEST VALIDATE-REDEEM ]: ${JSON.stringify(req.body)}`
|
`${uniqueCode} [ REQUEST VALIDATE-REDEEM ]: ${JSON.stringify(req.body)}`
|
||||||
@@ -1114,7 +1115,11 @@ const validateReplacement = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//is warranty
|
||||||
|
let category_replacement = dataCardReplacement.c_replace_redeem_category_code
|
||||||
|
if(category_replacement == 'W') {
|
||||||
|
is_warranty = true;
|
||||||
|
}
|
||||||
|
|
||||||
last_balance = dataCardReplacement.i_last_balance;
|
last_balance = dataCardReplacement.i_last_balance;
|
||||||
if(last_balance == null) {
|
if(last_balance == null) {
|
||||||
@@ -1152,6 +1157,7 @@ const validateReplacement = async (req, res) => {
|
|||||||
detail: {
|
detail: {
|
||||||
security_code: security_code,
|
security_code: security_code,
|
||||||
last_balance: last_balance,
|
last_balance: last_balance,
|
||||||
|
is_warranty: is_warranty,
|
||||||
unique_code: uniqueCode
|
unique_code: uniqueCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ if (process.env.CLUSTER_NODE.toUpperCase() == 'YES') {
|
|||||||
|
|
||||||
function startExpress() {
|
function startExpress() {
|
||||||
// set port, listen for requests
|
// set port, listen for requests
|
||||||
const PORT = process.env.PORT || 3000;
|
const PORT = parseInt(process.env.PORT) || 3000;
|
||||||
|
|
||||||
// jika settingan running on multiple
|
// jika settingan running on multiple
|
||||||
if (
|
if (
|
||||||
@@ -75,7 +75,7 @@ function startExpress() {
|
|||||||
let ports = PORTS.split(',');
|
let ports = PORTS.split(',');
|
||||||
|
|
||||||
for (let index = 0; index < ports.length; index++) {
|
for (let index = 0; index < ports.length; index++) {
|
||||||
const port = ports[index];
|
const port = parseInt(ports[index]);
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, () => {
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "topuponline",
|
"name": "topuponline",
|
||||||
"version": "1.5.5",
|
"version": "1.6.0",
|
||||||
"description": "update logic set sequence load balance number to handle max loop issue",
|
"description": "handling maximum flag 255",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "nodemon index",
|
"start": "nodemon index",
|
||||||
|
|||||||
Reference in New Issue
Block a user