diff --git a/application/modules/loadbalance/loadbalance.controller.js b/application/modules/loadbalance/loadbalance.controller.js index 865b2f4..778f730 100644 --- a/application/modules/loadbalance/loadbalance.controller.js +++ b/application/modules/loadbalance/loadbalance.controller.js @@ -1192,7 +1192,9 @@ const loadingBalanceInsert = async (param) => { // log info winston.logger.info( - `${uniqueCode} REQUEST load balance insert: ${JSON.stringify(param)}` + `${uniqueCode} [ REQUEST LOADING-BALANCE-INSERT ]: ${JSON.stringify( + param + )}` ); // time @@ -1213,14 +1215,18 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}` + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( + result + )}` ); return result; } // log warn - winston.logger.warn(`${uniqueCode} checking reservation status...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking reservation status...` + ); // check reservation status for (let index = 0; index < reservation_number.length; index++) { @@ -1238,7 +1244,7 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify( + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( result )}` ); @@ -1268,7 +1274,7 @@ const loadingBalanceInsert = async (param) => { // log info winston.logger.info( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify( + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( result )}` ); @@ -1279,7 +1285,9 @@ const loadingBalanceInsert = async (param) => { } // log warn - winston.logger.warn(`${uniqueCode} checking last log history...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking last log history...` + ); // get last history by card number let lastHistory = await model.getLastHistory(card_number); @@ -1288,13 +1296,17 @@ const loadingBalanceInsert = async (param) => { // if last history card is topup (21 = log name id for topup) if (lastHistory.i_log_name == 21 && lastHistory.c_source == 'CMS') { // log warn - winston.logger.warn(`${uniqueCode} inserting fraud transaction...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: inserting fraud transaction...` + ); // insert reservation transaction to fraud table await model.insertFraudTransaction(reservation_number); // log warn - winston.logger.warn(`${uniqueCode} suspending reservation...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: suspending reservation...` + ); // update reservation with suspend status await model.suspendReservation(reservation_number, now); @@ -1307,7 +1319,7 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify( + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( result )}` ); @@ -1317,7 +1329,9 @@ const loadingBalanceInsert = async (param) => { } // log warn - winston.logger.warn(`${uniqueCode} checking fraud transaction...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking fraud transaction...` + ); // get data fraud by card number and status fraud is not closed let fraudTransaction = await model.getFraudTransaction(card_number); @@ -1330,7 +1344,9 @@ const loadingBalanceInsert = async (param) => { } // log warn - winston.logger.warn(`${uniqueCode} checking reservation pending...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking reservation pending...` + ); // get total reservation pending without fraud let getReservationPending = await model.getReservationPendingWithoutFraud( @@ -1348,14 +1364,18 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}` + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( + result + )}` ); return result; } // log warn - winston.logger.warn(`${uniqueCode} checking total topup amount...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking total topup amount...` + ); // check total topup and request topup let amountTopup = 0; @@ -1372,7 +1392,9 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}` + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( + result + )}` ); return result; @@ -1385,7 +1407,9 @@ const loadingBalanceInsert = async (param) => { let maxLoop = 0; do { // log debug - winston.logger.debug(`${uniqueCode} getting loading balance sequence...`); + winston.logger.debug( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: getting loading balance sequence...` + ); // get loading balance getLoadBalanceSequence = await model.getLoadBalanceSequence( @@ -1397,7 +1421,9 @@ const loadingBalanceInsert = async (param) => { : 1; // log warn - winston.logger.warn(`${uniqueCode} generating load balance number...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: generating load balance number...` + ); loadBalanceNumber = await generateLoadBalanceNumber( getPartner, @@ -1407,13 +1433,13 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} load balance number is ${loadBalanceNumber}.` + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: load balance number is ${loadBalanceNumber}.` ); if (maxLoop > 20) { // create log winston.logger.error( - `500 internal server error (max loop) - backend server | ${error.message}` + `[ RESPONSE LOADING-BALANCE-INSERT ]: 500 internal server error (max loop) - backend server | ${error.message}` ); return { @@ -1468,7 +1494,9 @@ const loadingBalanceInsert = async (param) => { }; // log debug - winston.logger.debug(`${uniqueCode} getting reservation detail...`); + winston.logger.debug( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: getting reservation detail...` + ); let detail = []; reservation_number = []; @@ -1488,7 +1516,7 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify( + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( result )}` ); @@ -1535,11 +1563,13 @@ const loadingBalanceInsert = async (param) => { // check data load balance by reservation_number exist or not // log debug winston.logger.debug( - `${uniqueCode} checking load balance transaction has been exists or not...` + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking load balance transaction has been exists or not...` ); // log warn - winston.logger.warn(`${uniqueCode} inserting load balance transaction...`); + winston.logger.warn( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: inserting load balance transaction...` + ); // insert transaction let insertLoadingBalance = await model.insertLoadingBalance( @@ -1556,7 +1586,7 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} AAAAAAAAAAAAAAAAAA [DATA] : ${JSON.stringify( + `${uniqueCode} [DATA] : ${JSON.stringify( data )} [DETAIL] : ${JSON.stringify(detail)} [RSV] : ${JSON.stringify( reservation_number @@ -1582,7 +1612,9 @@ const loadingBalanceInsert = async (param) => { // log info winston.logger.info( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}` + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( + result + )}` ); } else { result = { @@ -1595,7 +1627,9 @@ const loadingBalanceInsert = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}` + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( + result + )}` ); } @@ -1603,7 +1637,7 @@ const loadingBalanceInsert = async (param) => { } catch (error) { // create log winston.logger.error( - `500 internal server error - backend server | ${error.message}` + `[ RESPONSE LOADING-BALANCE-INSERT ]: 500 internal server error - backend server | ${error.message}` ); return { @@ -1643,7 +1677,9 @@ const loadingBalanceUpdate = async (param) => { // log info winston.logger.info( - `${uniqueCode} REQUEST load balance update: ${JSON.stringify(param)}` + `${uniqueCode} [ REQUEST LOADING-BALANCE-UPDATE ]: ${JSON.stringify( + param + )}` ); // time @@ -1651,7 +1687,9 @@ const loadingBalanceUpdate = async (param) => { let today = moment().format('YYYY-MM-DD'); // log debug - winston.logger.debug(`${uniqueCode} checking partner...`); + winston.logger.debug( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: checking partner...` + ); // get partner, merchant, terminal from tid let getPartner = await model.getPartner(mid, tid); @@ -1664,7 +1702,9 @@ const loadingBalanceUpdate = async (param) => { // log warn winston.logger.warn( - `${uniqueCode} RESPONSE load balance update: ${JSON.stringify(result)}` + `${uniqueCode} [ RESPONSE LOADING-BALANCE-UPDATE ]: ${JSON.stringify( + result + )}` ); return result; @@ -1684,7 +1724,9 @@ const loadingBalanceUpdate = async (param) => { }; // log debug - winston.logger.debug(`${uniqueCode} updating load balance transaction...`); + winston.logger.debug( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: updating load balance transaction...` + ); // update transaction await model.updateLoadingBalance( @@ -1700,7 +1742,7 @@ const loadingBalanceUpdate = async (param) => { // log debug winston.logger.debug( - `${uniqueCode} inserting load balance transaction history ${loadBalanceNumber}...` + `${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: inserting load balance transaction history ${loadBalanceNumber}...` ); let findDataLoadBalance = await model.findLoadBalance(loadBalanceNumber); @@ -1785,7 +1827,9 @@ const loadingBalanceUpdate = async (param) => { if (!write_status) { // log debug - winston.logger.debug(`${uniqueCode} inserting log for card history...`); + winston.logger.debug( + `${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: inserting log for card history...` + ); // log card history await model.createLoadBalanceLog({ @@ -1823,14 +1867,16 @@ const loadingBalanceUpdate = async (param) => { // log info winston.logger.info( - `${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}` + `${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify( + result + )}` ); return result; } catch (error) { // create log winston.logger.error( - `500 internal server error - backend server | ${error.message}` + `[ RESPONSE LOADING-BALANCE-UPDATE ]: 500 internal server error - backend server | ${error.message}` ); return {