diff --git a/.71c131f2ce727b13210eef32232709400762e5fb-audit.json b/.71c131f2ce727b13210eef32232709400762e5fb-audit.json index 3d1c05a..f4c0c95 100644 --- a/.71c131f2ce727b13210eef32232709400762e5fb-audit.json +++ b/.71c131f2ce727b13210eef32232709400762e5fb-audit.json @@ -6,9 +6,14 @@ "auditLog": ".71c131f2ce727b13210eef32232709400762e5fb-audit.json", "files": [ { - "date": 1660880099380, - "name": "2022-08-19-onlinetopup.log", - "hash": "7bb01da8b3e9f89f45c3d0c9cd81b9af84a5f147df18c3a6f123eb377e62c230" + "date": 1660118902222, + "name": "2022-08-10-onlinetopup.log", + "hash": "f3452bb37273fa8d143fc72d0eb29cf38a01111c694585768cc9e22449acfb19" + }, + { + "date": 1660153631005, + "name": "2022-08-11-onlinetopup.log", + "hash": "b04aaa1b43dcd1effc3a3b3d1fd0122fc3ab1e4dcfbfbe0fbc343412ab3ba877" } ], "hashType": "sha256" diff --git a/application/modules/hsm/services/webSocket.js b/application/modules/hsm/services/webSocket.js index 573e235..7d11705 100644 --- a/application/modules/hsm/services/webSocket.js +++ b/application/modules/hsm/services/webSocket.js @@ -13,7 +13,26 @@ let options = { passphrase: "GPqs+Uia78", pfx: fs.readFileSync(ssl_client_pfx), }; -let url = "wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"; + +// init server hsm +let serverNutechPCI = "NUTECH_PCI"; +let serverKCIPCI = "KCI_PCI"; +let serverKCIHSM = "KCI_HSM"; +let serverJepangHSM = "JEPANG_HSM"; +let url; + +if (process.env.HSM_SERVER == serverNutechPCI) { + url = "ws://117.102.86.186/feliqserver/v1/wsapi"; // server nutech tetra +} else if (process.env.HSM_SERVER == serverKCIPCI) { + url = ""; +} else if (process.env.HSM_SERVER == serverKCIHSM) { + url = ""; +} else if (process.env.HSM_SERVER == serverJepangHSM) { + url = "wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"; // server jepang +} else { + // create log + winston.logger.error(`PLEASE SET HSM SERVER ON THE ENVIRONMENT!`); +} const config = { timeout: 1000, //timeout connecting to each server, each try @@ -148,14 +167,23 @@ class WebSocketClient { authHead[1] = 0x9e; // Set API key //const apiKeyBytes = Buffer.from('82002732-9148-34e5-843b-c639a0c88cc5-0TC') // T4 + // const apiKeyBytes = Buffer.from( + // "4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC" + // ); // Nutech Server Jepang + // // Secret setting + // //const secretBytes = Buffer.from('TdtSo/i5ZmbwPr82gt4fElK96lV9ClVo7votHKMIUuo='); // T4 + // const secretBytes = Buffer.from( + // "U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw=" + // ); // Nutech Server Jepang + const apiKeyBytes = Buffer.from( - "4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC" - ); // Nutech + "d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC" + ); // Nutech Server Nutech Tetra // Secret setting //const secretBytes = Buffer.from('TdtSo/i5ZmbwPr82gt4fElK96lV9ClVo7votHKMIUuo='); // T4 const secretBytes = Buffer.from( - "U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw=" - ); // Nutech + "W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY=" + ); // Nutech Server Nutech Tetra const authData = Buffer.concat([authHead, apiKeyBytes, secretBytes]); @@ -229,7 +257,7 @@ setInterval(function () { client.clientAuth(); } // } -}, 59000); +}, 53000); module.exports = { client, diff --git a/application/modules/loadbalance/loadbalance.controller.js b/application/modules/loadbalance/loadbalance.controller.js index 643b19b..cb3455f 100644 --- a/application/modules/loadbalance/loadbalance.controller.js +++ b/application/modules/loadbalance/loadbalance.controller.js @@ -627,7 +627,7 @@ const loadingBalance = async (req, res) => { loadBalanceNumber = await generateLoadBalanceNumber( getPartner, - moment(today).format("YYYYMMDD"), + moment(today).format("YYMMDD"), loadBalanceNoSequence ); @@ -774,15 +774,15 @@ const loadingBalance = async (req, res) => { i_log_name: 21, d_log: now, c_card_number: card_number, - c_source: "CMS - LOAD BALANCE", - c_location: getPartner ? getPartner.terminal_name : null, + c_source: "CMS", + c_location: getPartner ? getPartner.partner_name : null, m_balance_before: parseInt(balance) > 0 ? parseInt(balance) : 0, m_amount: parseInt(amount), m_balance_after: parseInt(balance) + parseInt(amount), j_new_data: { data: data, detail: detail }, j_old_data: null, c_note: `LOAD BALANCE ${amount} FROM ${ - getPartner ? getPartner.terminal_name : null + getPartner ? getPartner.partner_name : null } SUCCESSFULLY`, c_status: "S", d_created: now, @@ -1022,7 +1022,7 @@ const loadingBalanceInsert = async (param) => { loadBalanceNumber = await generateLoadBalanceNumber( getPartner, - moment(today).format("YYYYMMDD"), + moment(today).format("YYMMDD"), loadBalanceNoSequence ); @@ -1331,7 +1331,7 @@ const loadingBalanceUpdate = async (param) => { detailLoadBalance[i] = { i_reservation_balance: element.i_reservation_balance, c_reservation_no: element.c_reservation_no, - i_amount: element.i_reservation_amount, + i_amount: element.i_amount, i_issuer: element.i_issuer, i_issuer_code: element.c_issuer_code, i_issuer_name: element.c_issuer_name, @@ -1367,15 +1367,15 @@ const loadingBalanceUpdate = async (param) => { i_log_name: 21, d_log: now, c_card_number: card_number, - c_source: "CMS - LOAD BALANCE", - c_location: getPartner ? getPartner.terminal_name : null, + c_source: "CMS", + c_location: getPartner ? getPartner.partner_name : null, m_balance_before: parseInt(balance) > 0 ? parseInt(balance) : 0, m_amount: parseInt(amount), 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.terminal_name : null + getPartner ? getPartner.partner_name : null } SUCCESSFULLY`, c_status: "S", d_created: now, @@ -1585,7 +1585,7 @@ const updateReservationAndLoadingBalanceOld = async ( loadBalanceNumber = await generateLoadBalanceNumber( getPartner, - moment(today).format("YYYYMMDD"), + moment(today).format("YYMMDD"), loadBalanceNoSequence ); @@ -1666,15 +1666,15 @@ const updateReservationAndLoadingBalanceOld = async ( i_log_name: 21, d_log: now, c_card_number: dataReservation.c_card_number, - c_source: "CMS - LOAD BALANCE", - c_location: getPartner ? getPartner.terminal_name : null, + 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 ${amount} FROM ${ - getPartner ? getPartner.terminal_name : null + getPartner ? getPartner.partner_name : null } SUCCESSFULLY`, c_status: "S", d_created: now, @@ -1810,15 +1810,15 @@ const updateReservationAndLoadingBalance = async ( i_log_name: 21, d_log: dataLoadingBalance.d_load_balance, c_card_number: cardNumber, - c_source: "CMS - LOAD BALANCE", - c_location: getPartner ? getPartner.terminal_name : null, + 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.terminal_name : null + getPartner ? getPartner.partner_name : null } SUCCESSFULLY`, c_status: "S", d_created: now, @@ -1844,11 +1844,11 @@ const updateReservationAndLoadingBalance = async ( // GENERATE LOAD BALANCE NUMBER const generateLoadBalanceNumber = async (data, date, counter) => { - let code = data.merchant_code ? data.merchant_code : "XXXXXXX"; + let code = data.partner_code ? data.partner_code : "XXX"; - let prefix = "LDB"; + let prefix = "LBL"; let loadBalanceNumber = - prefix + "" + code + "" + "" + date + counter.toString().padStart(3, "0"); + prefix + "" + code + "" + "" + date + counter.toString().padStart(6, "0"); // insert to temp load balance number let insert = await model.insertLoadBalanceNumber(loadBalanceNumber); diff --git a/application/modules/reservebalance/reservebalance.controller.js b/application/modules/reservebalance/reservebalance.controller.js index b89247d..95e2946 100644 --- a/application/modules/reservebalance/reservebalance.controller.js +++ b/application/modules/reservebalance/reservebalance.controller.js @@ -679,7 +679,7 @@ const reservation = async (req, res) => { reservationNumber = await generateReservationNumber( getPartner, - moment(today).format("YYYYMMDD"), + moment(today).format("YYMMDD"), reservationNoSequence ); @@ -790,15 +790,15 @@ const reservation = async (req, res) => { i_log_name: 90, d_log: now, c_card_number: card_number, - c_source: "CMS - RESERVE BALANCE", - c_location: getPartner ? getPartner.terminal_name : null, + c_source: "CMS", + c_location: getPartner ? getPartner.partner_name : null, m_balance_before: balance > 0 ? balance : 0, m_amount: 0, - m_balance_after: parseInt(balance) + parseInt(amount), + m_balance_after: balance > 0 ? balance : 0, j_new_data: data, j_old_data: null, c_note: `RESERVED BALANCE ${amount} FROM ${ - getPartner ? getPartner.terminal_name : null + getPartner ? getPartner.partner_name : null } SUCCESSFULLY`, c_status: "S", d_created: now, @@ -921,11 +921,11 @@ const inquiryReservation = async (req, res) => { // GENERATE RESERVATION NUMBER const generateReservationNumber = async (data, date, counter) => { - let code = data.merchant_code ? data.merchant_code : "XXXXXXX"; + let code = data.partner_code ? data.partner_code : "XXX"; - let prefix = "RSV"; + let prefix = "RBL"; let reservationNumber = - prefix + "" + code + "" + "" + date + counter.toString().padStart(3, "0"); + prefix + "" + code + "" + "" + date + counter.toString().padStart(6, "0"); // insert to temp reservation number let insert = await model.insertReservationNumber(reservationNumber); diff --git a/index.js b/index.js index 9e54e0c..647facc 100644 --- a/index.js +++ b/index.js @@ -76,7 +76,7 @@ cron.schedule('*/1 * * * *', async () => { } }); -cron.schedule('*/2 * * * *', async () => { +cron.schedule('*/15 * * * *', async () => { try { let uniqueCode = helper.getUniqueCode() winston.logger.info(`START-SCHEDULER-FB70 POSTING INVOICE`);