mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 00:26:27 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2863392518 |
@@ -10,6 +10,7 @@ const {
|
||||
topuponline_metrics_response_time,
|
||||
topuponline_metrics_load_balance,
|
||||
} = require("../helpers/prometheusmetrics");
|
||||
const helper = require("../helpers/helper");
|
||||
|
||||
const filename = () => {
|
||||
if (!fs.existsSync(`./expresswinstonlog`)) {
|
||||
@@ -131,13 +132,18 @@ const logger = {
|
||||
statusCode != "03" &&
|
||||
statusCode != "04"
|
||||
) {
|
||||
console.log(statusCode);
|
||||
let rsvData = info.meta.req.body.reservation_data;
|
||||
let encryptRsvData = helper.decryptText(rsvData);
|
||||
let encryptRes = JSON.parse(encryptRsvData);
|
||||
let { card_number } = encryptRes;
|
||||
|
||||
winstonLoki.log.error({
|
||||
message: message,
|
||||
labels: {
|
||||
route: url,
|
||||
status_code: statusCode,
|
||||
issuer_name: issuerName,
|
||||
card_number: card_number,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -13,23 +13,13 @@ let redisClient;
|
||||
password: '',
|
||||
});
|
||||
|
||||
redisClient.on('error', (error) =>
|
||||
// process.env.NODE_ENV.toUpperCase() != 'PRODUCTION'
|
||||
// ? console.error(`Error : ${error}`)
|
||||
// : ''
|
||||
process.env.NODE_ENV.toUpperCase() != 'PRODUCTION' ? '' : ''
|
||||
);
|
||||
redisClient.on('error', (error) => {});
|
||||
|
||||
redisClient.on('connect', () => console.log('Redis is Connected'));
|
||||
|
||||
redisClient.on('ready', () => console.log('Redis is Ready'));
|
||||
|
||||
redisClient.on('reconnecting', () =>
|
||||
// process.env.NODE_ENV.toUpperCase() != 'PRODUCTION'
|
||||
// ? console.log('Redis is Reconnecting')
|
||||
// : ''
|
||||
process.env.NODE_ENV.toUpperCase() != 'PRODUCTION' ? '' : ''
|
||||
);
|
||||
redisClient.on('reconnecting', () => {});
|
||||
|
||||
await redisClient.connect();
|
||||
})();
|
||||
|
||||
@@ -42,7 +42,7 @@ const cardHistory = async (req, res) => {
|
||||
// generate unique code
|
||||
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||
let uniqueCode = await helper.getUniqueCode();
|
||||
let result = [];
|
||||
let result = {};
|
||||
|
||||
// param
|
||||
let { data } = req.body;
|
||||
@@ -58,7 +58,7 @@ const cardHistory = async (req, res) => {
|
||||
result = {
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: [],
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
@@ -178,7 +178,7 @@ const cardHistory = async (req, res) => {
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
data: [],
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
const helper = require('../../helpers/helper');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const helper = require("../../helpers/helper");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
let useClient;
|
||||
var counterDirect = 0;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -31,11 +31,11 @@ const controller = async (req, res) => {
|
||||
let { body } = req;
|
||||
// uniqueCode = body.unique_code;
|
||||
let uniqueCode = await helper.getUniqueCode();
|
||||
uniqueCode = uniqueCode + '' + counterDirect;
|
||||
uniqueCode = uniqueCode+''+counterDirect;
|
||||
let result = {};
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -74,15 +74,11 @@ const controller = async (req, res) => {
|
||||
}
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-1 ]: STARTING TOP UP...`
|
||||
);
|
||||
winston.logger.info(`${uniqueCode} REQUEST load balance - STARTING...`);
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-1 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
`${uniqueCode} request HSM - auth1v2: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
let felicaPollingResponse = Buffer.from(
|
||||
@@ -111,7 +107,7 @@ const controller = async (req, res) => {
|
||||
_timeOut = true;
|
||||
}, 10000);
|
||||
|
||||
useClient.ws.on('message', (message) => {
|
||||
useClient.ws.on("message", (message) => {
|
||||
let __validasi = generate.buf2hex(message).slice(14, 30);
|
||||
while (
|
||||
message[2] == 1 &&
|
||||
@@ -123,9 +119,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-1 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
`${uniqueCode} HSM - message Auth1v2: ${generate.buf2hex(message)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -161,8 +155,8 @@ const controller = async (req, res) => {
|
||||
|
||||
if (respData1) {
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'Request Authenticate 1 Success',
|
||||
code: "00",
|
||||
message: "Request Authenticate 1 Success",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -173,8 +167,8 @@ const controller = async (req, res) => {
|
||||
};
|
||||
} else {
|
||||
result = {
|
||||
code: '5004',
|
||||
message: 'Empty Data from HSM',
|
||||
code: "5004",
|
||||
message: "Empty Data from HSM",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -187,24 +181,22 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-1 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - auth1v2: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-1 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: '5001',
|
||||
code: "5001",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,13 +27,11 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-2 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
`${uniqueCode} request HSM - auth2v2: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -62,16 +60,14 @@ const controller = async (req, res) => {
|
||||
|
||||
if (auth2v2requestData[0] != 0x41) {
|
||||
result = {
|
||||
code: '5003',
|
||||
message: 'Wrong Respone from Card',
|
||||
code: "5003",
|
||||
message: "Wrong Respone from Card",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-2 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - auth2v2: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -88,7 +84,7 @@ const controller = async (req, res) => {
|
||||
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
useClient.ws.on('message', (message) => {
|
||||
useClient.ws.on("message", (message) => {
|
||||
while (
|
||||
message[2] == 2 &&
|
||||
message[0] == _validationTrxID[0] &&
|
||||
@@ -100,9 +96,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-2 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
`${uniqueCode} HSM - message Auth2v2: ${generate.buf2hex(message)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -122,8 +116,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'Request Authenticate 2 Success',
|
||||
code: "00",
|
||||
message: "Request Authenticate 2 Success",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -134,24 +128,22 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-2 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - auth2v2: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-2 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: '5001',
|
||||
code: "5001",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,13 +27,11 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-3 ]: request to HSM ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
`${uniqueCode} request auth2v2 Resp: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -64,16 +62,14 @@ const controller = async (req, res) => {
|
||||
|
||||
if (auth2v2responseSetData[0] != 0x43) {
|
||||
result = {
|
||||
code: '5003',
|
||||
message: 'Wrong Respone from Card',
|
||||
code: "5003",
|
||||
message: "Wrong Respone from Card",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-3 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - auth2v2 resp: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -91,7 +87,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on('message', (message) => {
|
||||
useClient.ws.on("message", (message) => {
|
||||
while (
|
||||
message[2] == 3 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -103,7 +99,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-3 ]: message from HSM ${generate.buf2hex(
|
||||
`${uniqueCode} HSM - message auth2v2 Resp: ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -125,8 +121,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'Request Authenticate Resp Success',
|
||||
code: "00",
|
||||
message: "Request Authenticate Resp Success",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -137,24 +133,22 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-3 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - auth2v2 resp: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-3 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: '5001',
|
||||
code: "5001",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,13 +27,11 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-8 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
`${uniqueCode} request HSM - end transaction: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -72,7 +70,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on('message', (message) => {
|
||||
useClient.ws.on("message", (message) => {
|
||||
while (
|
||||
message[2] == 6 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -84,7 +82,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-8 ]: message from HSM ${generate.buf2hex(
|
||||
`${uniqueCode} HSM - message end transaction: ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -106,34 +104,35 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'End Transaction Success',
|
||||
code: "00",
|
||||
message: "End Transaction Success",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(`${uniqueCode} RESPONSE load balance - END...`);
|
||||
|
||||
// log debug
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-8 ]: ENDING TOP UP... ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} response HSM - end transaction: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-8 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: '5001',
|
||||
code: "5001",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,13 +27,11 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-4 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
`${uniqueCode} request HSM - read data: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -72,7 +70,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on('message', (message) => {
|
||||
useClient.ws.on("message", (message) => {
|
||||
while (
|
||||
message[2] == 4 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -86,9 +84,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-4 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
`${uniqueCode} HSM - message read data: ${generate.buf2hex(message)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -108,8 +104,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'Read Succeess',
|
||||
code: "00",
|
||||
message: "Read Succeess",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -120,24 +116,22 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-4 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - read data: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-4 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: '5001',
|
||||
code: "5001",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
}
|
||||
|
||||
const controller = async (req, res) => {
|
||||
@@ -27,13 +27,11 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-5 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
`${uniqueCode} request HSM - read data resp: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -60,16 +58,14 @@ const controller = async (req, res) => {
|
||||
let _stopMessage = 1;
|
||||
if (packet[0] != 0x45) {
|
||||
result = {
|
||||
code: '03',
|
||||
message: 'Respone Card Wrong',
|
||||
code: "03",
|
||||
message: "Respone Card Wrong",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-5 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - read data resp: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -83,7 +79,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on('message', (message) => {
|
||||
useClient.ws.on("message", (message) => {
|
||||
while (
|
||||
message[2] == 5 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -97,7 +93,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-5 ]: message from HSM ${generate.buf2hex(
|
||||
`${uniqueCode} HSM - message read data resp: ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -119,8 +115,8 @@ const controller = async (req, res) => {
|
||||
respData1 = generate.getResponseData(respData);
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'Read Succeess',
|
||||
code: "00",
|
||||
message: "Read Succeess",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -131,24 +127,22 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-5 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - read data resp: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-5 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: '5001',
|
||||
code: "5001",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,13 +98,6 @@ const controller = async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-6 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -116,14 +109,17 @@ const controller = async (req, res) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-6 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - write topup: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} request HSM - write topup: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
let transactionId = Buffer.from(generate.hexToBytes(trxID));
|
||||
let trxrequestData = Buffer.from(generate.hexToBytes(requestData));
|
||||
let _stopMessage = 1;
|
||||
@@ -163,7 +159,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-6 ]: message from HSM ${generate.buf2hex(
|
||||
`${uniqueCode} HSM - message write topup: ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
);
|
||||
@@ -186,7 +182,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-6 ]: inserting load balance transaction...`
|
||||
`${uniqueCode} HSM - inserting load balance transaction...`
|
||||
);
|
||||
|
||||
let data = {
|
||||
@@ -236,16 +232,14 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-6 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - write topup: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-6 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
const { param, body, validationResult } = require('express-validator');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const loadBalance = require('../loadbalance/loadbalance.controller');
|
||||
const { param, body, validationResult } = require("express-validator");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const loadBalance = require("../loadbalance/loadbalance.controller");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require('dotenv').config();
|
||||
require("dotenv").config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
}
|
||||
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case 'topupResponse':
|
||||
case "topupResponse":
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('uid').not().isEmpty().withMessage('UID is required'),
|
||||
body('flag').not().isEmpty().withMessage('Flag is required'),
|
||||
body('card_number')
|
||||
body("mid").not().isEmpty().withMessage("MID is required"),
|
||||
body("tid").not().isEmpty().withMessage("TID is required"),
|
||||
body("uid").not().isEmpty().withMessage("UID is required"),
|
||||
body("flag").not().isEmpty().withMessage("Flag is required"),
|
||||
body("card_number")
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Card Number is required'),
|
||||
body('amount')
|
||||
.withMessage("Card Number is required"),
|
||||
body("amount")
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Amount is required')
|
||||
.withMessage("Amount is required")
|
||||
.isNumeric()
|
||||
.withMessage('Amount is invalid format'),
|
||||
body('reservation_number')
|
||||
.withMessage("Amount is invalid format"),
|
||||
body("reservation_number")
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Reservation Number is required')
|
||||
.withMessage("Reservation Number is required")
|
||||
.isArray()
|
||||
.withMessage('Reservation Number is invalid request format'),
|
||||
body('load_balance_number')
|
||||
.withMessage("Reservation Number is invalid request format"),
|
||||
body("load_balance_number")
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Load Balance Number is required'),
|
||||
.withMessage("Load Balance Number is required"),
|
||||
];
|
||||
default:
|
||||
break;
|
||||
@@ -79,7 +79,7 @@ const controller = async (req, res) => {
|
||||
let result = {};
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -111,9 +111,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE TOPUP-7 ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
`${uniqueCode} request HSM - topup resp: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
let transactionId = Buffer.from(generate.hexToBytes(trxID));
|
||||
@@ -121,16 +119,14 @@ const controller = async (req, res) => {
|
||||
let _stopMessage = 1;
|
||||
if (packet[0] != 0x47) {
|
||||
result = {
|
||||
code: '03',
|
||||
message: 'Respone Card Wrong',
|
||||
code: "03",
|
||||
message: "Respone Card Wrong",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-7 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} response HSM - topup resp: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
@@ -144,7 +140,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on('message', (message) => {
|
||||
useClient.ws.on("message", (message) => {
|
||||
while (
|
||||
message[2] == 5 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -158,9 +154,7 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-7 ]: message from HSM ${generate.buf2hex(
|
||||
message
|
||||
)}`
|
||||
`${uniqueCode} HSM - message topup resp: ${generate.buf2hex(message)}`
|
||||
);
|
||||
|
||||
respData = message;
|
||||
@@ -192,7 +186,7 @@ const controller = async (req, res) => {
|
||||
amount: amount,
|
||||
reservation_number: reservation_number,
|
||||
ref_no: ref_no,
|
||||
write_status: 'FW',
|
||||
write_status: "FW",
|
||||
uid: uid,
|
||||
balance: parseInt(balance) + parseInt(amount),
|
||||
flag: parseInt(flag),
|
||||
@@ -202,15 +196,15 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-7 ]: updating load balance transaction is FW...`
|
||||
`${uniqueCode} HSM - updating load balance transaction...`
|
||||
);
|
||||
|
||||
// update data load balance
|
||||
await loadBalance.loadingBalanceUpdate(data);
|
||||
|
||||
result = {
|
||||
code: '5002',
|
||||
message: 'failed from HSM',
|
||||
code: "5002",
|
||||
message: "failed from HSM",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respData1.slice(6, 10),
|
||||
@@ -219,11 +213,6 @@ const controller = async (req, res) => {
|
||||
},
|
||||
};
|
||||
} else {
|
||||
// jika sudah mencapai maksimum counting flag, maka reset flag ke awal
|
||||
if (flag >= 255) {
|
||||
flag = -1;
|
||||
}
|
||||
|
||||
data = {
|
||||
mid: mid,
|
||||
tid: tid,
|
||||
@@ -241,16 +230,16 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE TOPUP-7 ]: updating load balance transaction...`
|
||||
`${uniqueCode} HSM - updating load balance transaction...`
|
||||
);
|
||||
|
||||
// update data load balance
|
||||
let update = await loadBalance.loadingBalanceUpdate(data);
|
||||
if (update) {
|
||||
if (update.code == '00') {
|
||||
if (update.code == "00") {
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'Topup Succeess',
|
||||
code: "00",
|
||||
message: "Topup Succeess",
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -268,8 +257,8 @@ const controller = async (req, res) => {
|
||||
}
|
||||
} else {
|
||||
result = {
|
||||
code: '423',
|
||||
message: 'update/insert failed',
|
||||
code: "423",
|
||||
message: "update/insert failed",
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
@@ -277,24 +266,22 @@ const controller = async (req, res) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-7 ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} HSM - message topup resp: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).send(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE TOPUP-7 ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: '5001',
|
||||
code: "5001",
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -505,24 +505,6 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
// get parameter setting pengecekkan nomor kartu dengan card product di CMS
|
||||
let getCheckByCardProductStatusValue =
|
||||
await model.getCheckByCardProductStatusValue();
|
||||
|
||||
// check value global parameter
|
||||
if (!getCheckByCardProductStatusValue) {
|
||||
result = {
|
||||
code: '439',
|
||||
message: 'HSM_CHECK_BY_CARD_PRODUCT_STAT in global parameter not found',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let checkByCardProductStatusValue =
|
||||
getCheckByCardProductStatusValue.c_value;
|
||||
|
||||
@@ -710,13 +692,7 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
result = {
|
||||
code: '01',
|
||||
message: 'your card number has been cleared successfully',
|
||||
data: {
|
||||
load_balance_number: loadBalanceNumberPendingSuccessLoaded[0],
|
||||
amount: parseInt(totalReservationAmount),
|
||||
total_reservation: getReservationPendingWithFlagCounter.length,
|
||||
reservation_number: reservationNumberPendingSuccessLoaded,
|
||||
partial_topup: false,
|
||||
},
|
||||
data: {},
|
||||
};
|
||||
} else {
|
||||
result = {
|
||||
@@ -775,7 +751,6 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let partialTopup = false;
|
||||
let totalReservation = 0;
|
||||
let amountTopup = 0;
|
||||
let reservationNumber = [];
|
||||
@@ -841,48 +816,7 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
|
||||
// get BI regulation status
|
||||
const getBIRegulationStatus = await model.getBIRegulationStatus();
|
||||
|
||||
// check value global parameter
|
||||
if (!getBIRegulationStatus) {
|
||||
result = {
|
||||
code: '439',
|
||||
message: 'HSM_BI_REGULATION_STAT in global parameter not found',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getBIRegulationStatus.c_value == 'A') {
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} checking topup partial status...`);
|
||||
|
||||
// check topup partial status
|
||||
const getTopupPartialStatus = await model.getTopupPartialStatus();
|
||||
|
||||
// check value global parameter
|
||||
if (!getTopupPartialStatus) {
|
||||
result = {
|
||||
code: '439',
|
||||
message: 'HSM_TOPUP_PARTIAL_STAT in global parameter not found',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-REQUEST ]: checking max balance on the card...`
|
||||
@@ -890,97 +824,25 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
|
||||
// get max saldo on the card
|
||||
const getMaxAmountOnTheCard = await model.getMaxAmountOnTheCard();
|
||||
|
||||
// check value global parameter
|
||||
if (!getMaxAmountOnTheCard) {
|
||||
result = {
|
||||
code: '439',
|
||||
message:
|
||||
'HSM_BI_MAX_AMOUNT_ON_THE_CARD in global parameter not found',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getMaxAmountOnTheCard.c_value) {
|
||||
if (
|
||||
parseInt(balance) + parseInt(amountTopup) >
|
||||
parseInt(getMaxAmountOnTheCard.c_value)
|
||||
) {
|
||||
// if topup partial is active
|
||||
if (getTopupPartialStatus.c_value == 'A') {
|
||||
// reset reservation data
|
||||
partialTopup = true;
|
||||
totalReservation = 0;
|
||||
amountTopup = 0;
|
||||
reservationNumber = [];
|
||||
reservationNumberTemp = [];
|
||||
i = 0;
|
||||
result = {
|
||||
code: '416',
|
||||
message: 'your card number has reached the maximum balance',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// sum amount can be topup
|
||||
getReservationPending.forEach((rsv) => {
|
||||
if (
|
||||
parseInt(balance) + parseInt(amountTopup) <=
|
||||
parseInt(getMaxAmountOnTheCard.c_value)
|
||||
) {
|
||||
amountTopup += parseInt(rsv.i_reservation_amount);
|
||||
if (
|
||||
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
|
||||
parseInt(balance) + amountTopup >
|
||||
parseInt(getMaxAmountOnTheCard.c_value)
|
||||
) {
|
||||
amountTopup =
|
||||
amountTopup - parseInt(rsv.i_reservation_amount);
|
||||
i--;
|
||||
} else {
|
||||
reservationNumber.push(rsv.c_reservation_no);
|
||||
reservationNumberTemp.push(rsv.c_reservation_no);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
});
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
totalReservation = i;
|
||||
if (totalReservation == 0) {
|
||||
result = {
|
||||
code: '414',
|
||||
message:
|
||||
"reservation doesn't exist. Lowest amount exceeds the maximum balance",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
} else {
|
||||
result = {
|
||||
code: '416',
|
||||
message: 'your card number has reached the maximum balance',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1004,96 +866,25 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
|
||||
// validate max topup per month
|
||||
const getMaxTopupPerMonth = await model.getMaxTopupPerMonth();
|
||||
|
||||
// check value global parameter
|
||||
if (!getMaxTopupPerMonth) {
|
||||
result = {
|
||||
code: '439',
|
||||
message: 'HSM_BI_MAX_TOPUP_PER_MONTH in global parameter not found',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getMaxTopupPerMonth.c_value) {
|
||||
if (
|
||||
parseInt(accumulatedBalance) + parseInt(amountTopup) >
|
||||
parseInt(getMaxTopupPerMonth.c_value)
|
||||
) {
|
||||
// if topup partial is active
|
||||
if (getTopupPartialStatus.c_value == 'A') {
|
||||
// reset reservation data
|
||||
partialTopup = true;
|
||||
totalReservation = 0;
|
||||
amountTopup = 0;
|
||||
reservationNumber = [];
|
||||
reservationNumberTemp = [];
|
||||
i = 0;
|
||||
result = {
|
||||
code: '417',
|
||||
message: 'your card number has been limit top up for this month',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// sum amount can be topup
|
||||
getReservationPending.forEach((rsv) => {
|
||||
if (
|
||||
parseInt(balance) + parseInt(amountTopup) <=
|
||||
parseInt(getMaxAmountOnTheCard.c_value)
|
||||
) {
|
||||
amountTopup += parseInt(rsv.i_reservation_amount);
|
||||
if (
|
||||
amountTopup > parseInt(getMaxAmountOnTheCard.c_value) ||
|
||||
parseInt(balance) + amountTopup >
|
||||
parseInt(getMaxAmountOnTheCard.c_value)
|
||||
) {
|
||||
amountTopup =
|
||||
amountTopup - parseInt(rsv.i_reservation_amount);
|
||||
i--;
|
||||
} else {
|
||||
reservationNumber.push(rsv.c_reservation_no);
|
||||
reservationNumberTemp.push(rsv.c_reservation_no);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
});
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
totalReservation = i;
|
||||
if (totalReservation == 0) {
|
||||
result = {
|
||||
code: '417',
|
||||
message:
|
||||
"reservation doesn't exist. Lowest amount exceeds the limit top up for this month",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
} else {
|
||||
result = {
|
||||
code: '417',
|
||||
message: 'your card number has been limit top up for this month',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-REQUEST ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1118,7 +909,6 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
amount: parseInt(amountTopup),
|
||||
total_reservation: totalReservation,
|
||||
reservation_number: reservationNumber,
|
||||
partial_topup: partialTopup,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1136,7 +926,6 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
amount: parseInt(amountTopup),
|
||||
total_reservation: totalReservation,
|
||||
reservation_number: reservationNumber,
|
||||
partial_topup: partialTopup,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1192,9 +981,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
param
|
||||
)}`
|
||||
`${uniqueCode} REQUEST load balance insert: ${JSON.stringify(param)}`
|
||||
);
|
||||
|
||||
// time
|
||||
@@ -1215,18 +1002,14 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking reservation status...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} checking reservation status...`);
|
||||
|
||||
// check reservation status
|
||||
for (let index = 0; index < reservation_number.length; index++) {
|
||||
@@ -1244,7 +1027,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -1274,7 +1057,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -1285,9 +1068,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
}
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking last log history...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} checking last log history...`);
|
||||
|
||||
// get last history by card number
|
||||
let lastHistory = await model.getLastHistory(card_number);
|
||||
@@ -1296,17 +1077,13 @@ 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} [ PROCESSING LOADING-BALANCE-INSERT ]: inserting fraud transaction...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} inserting fraud transaction...`);
|
||||
|
||||
// insert reservation transaction to fraud table
|
||||
await model.insertFraudTransaction(reservation_number);
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: suspending reservation...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} suspending reservation...`);
|
||||
|
||||
// update reservation with suspend status
|
||||
await model.suspendReservation(reservation_number, now);
|
||||
@@ -1319,7 +1096,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -1329,9 +1106,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
}
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking fraud transaction...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} checking fraud transaction...`);
|
||||
|
||||
// get data fraud by card number and status fraud is not closed
|
||||
let fraudTransaction = await model.getFraudTransaction(card_number);
|
||||
@@ -1344,9 +1119,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
}
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking reservation pending...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} checking reservation pending...`);
|
||||
|
||||
// get total reservation pending without fraud
|
||||
let getReservationPending = await model.getReservationPendingWithoutFraud(
|
||||
@@ -1364,18 +1137,14 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking total topup amount...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} checking total topup amount...`);
|
||||
|
||||
// check total topup and request topup
|
||||
let amountTopup = 0;
|
||||
@@ -1392,9 +1161,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return result;
|
||||
@@ -1407,9 +1174,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
let maxLoop = 0;
|
||||
do {
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: getting loading balance sequence...`
|
||||
);
|
||||
winston.logger.debug(`${uniqueCode} getting loading balance sequence...`);
|
||||
|
||||
// get loading balance
|
||||
getLoadBalanceSequence = await model.getLoadBalanceSequence(
|
||||
@@ -1421,9 +1186,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
: 1;
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: generating load balance number...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} generating load balance number...`);
|
||||
|
||||
loadBalanceNumber = await generateLoadBalanceNumber(
|
||||
getPartner,
|
||||
@@ -1433,13 +1196,13 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: load balance number is ${loadBalanceNumber}.`
|
||||
`${uniqueCode} load balance number is ${loadBalanceNumber}.`
|
||||
);
|
||||
|
||||
if (maxLoop > 20) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE-INSERT ]: 500 internal server error (max loop) - backend server | ${error.message}`
|
||||
`500 internal server error (max loop) - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -1494,9 +1257,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
};
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: getting reservation detail...`
|
||||
);
|
||||
winston.logger.debug(`${uniqueCode} getting reservation detail...`);
|
||||
|
||||
let detail = [];
|
||||
reservation_number = [];
|
||||
@@ -1516,7 +1277,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -1563,13 +1324,11 @@ const loadingBalanceInsert = async (param) => {
|
||||
// check data load balance by reservation_number exist or not
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking load balance transaction has been exists or not...`
|
||||
`${uniqueCode} checking load balance transaction has been exists or not...`
|
||||
);
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: inserting load balance transaction...`
|
||||
);
|
||||
winston.logger.warn(`${uniqueCode} inserting load balance transaction...`);
|
||||
|
||||
// insert transaction
|
||||
let insertLoadingBalance = await model.insertLoadingBalance(
|
||||
@@ -1586,7 +1345,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [DATA] : ${JSON.stringify(
|
||||
`${uniqueCode} AAAAAAAAAAAAAAAAAA [DATA] : ${JSON.stringify(
|
||||
data
|
||||
)} [DETAIL] : ${JSON.stringify(detail)} [RSV] : ${JSON.stringify(
|
||||
reservation_number
|
||||
@@ -1612,9 +1371,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||
);
|
||||
} else {
|
||||
result = {
|
||||
@@ -1627,9 +1384,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1637,7 +1392,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE-INSERT ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return {
|
||||
@@ -1677,9 +1432,7 @@ const loadingBalanceUpdate = async (param) => {
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST LOADING-BALANCE-UPDATE ]: ${JSON.stringify(
|
||||
param
|
||||
)}`
|
||||
`${uniqueCode} REQUEST load balance update: ${JSON.stringify(param)}`
|
||||
);
|
||||
|
||||
// time
|
||||
@@ -1687,9 +1440,7 @@ const loadingBalanceUpdate = async (param) => {
|
||||
let today = moment().format('YYYY-MM-DD');
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: checking partner...`
|
||||
);
|
||||
winston.logger.debug(`${uniqueCode} checking partner...`);
|
||||
|
||||
// get partner, merchant, terminal from tid
|
||||
let getPartner = await model.getPartner(mid, tid);
|
||||
@@ -1702,9 +1453,7 @@ const loadingBalanceUpdate = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-UPDATE ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} RESPONSE load balance update: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return result;
|
||||
@@ -1724,9 +1473,7 @@ const loadingBalanceUpdate = async (param) => {
|
||||
};
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: updating load balance transaction...`
|
||||
);
|
||||
winston.logger.debug(`${uniqueCode} updating load balance transaction...`);
|
||||
|
||||
// update transaction
|
||||
await model.updateLoadingBalance(
|
||||
@@ -1742,7 +1489,7 @@ const loadingBalanceUpdate = async (param) => {
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: inserting load balance transaction history ${loadBalanceNumber}...`
|
||||
`${uniqueCode} inserting load balance transaction history ${loadBalanceNumber}...`
|
||||
);
|
||||
|
||||
let findDataLoadBalance = await model.findLoadBalance(loadBalanceNumber);
|
||||
@@ -1827,9 +1574,7 @@ const loadingBalanceUpdate = async (param) => {
|
||||
|
||||
if (!write_status) {
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING LOADING-BALANCE-UPDATE ]: inserting log for card history...`
|
||||
);
|
||||
winston.logger.debug(`${uniqueCode} inserting log for card history...`);
|
||||
|
||||
// log card history
|
||||
await model.createLoadBalanceLog({
|
||||
@@ -1867,16 +1612,14 @@ const loadingBalanceUpdate = async (param) => {
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE LOADING-BALANCE-INSERT ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`[ RESPONSE LOADING-BALANCE-UPDATE ]: 500 internal server error - backend server | ${error.message}`
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return {
|
||||
|
||||
@@ -386,7 +386,7 @@ const insertLoadingBalance = async (
|
||||
return result.rowCount;
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log(error.message);
|
||||
console.log(error.message);
|
||||
return error.message;
|
||||
});
|
||||
};
|
||||
@@ -457,7 +457,7 @@ const updateLoadingBalance = async (
|
||||
return result;
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log(error.message);
|
||||
console.log(error.message);
|
||||
return error.message;
|
||||
});
|
||||
};
|
||||
@@ -548,7 +548,7 @@ const insertLoadingBalanceHistoryOnly = async (
|
||||
return result;
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log(error.message);
|
||||
console.log(error.message);
|
||||
return error.message;
|
||||
});
|
||||
};
|
||||
@@ -665,7 +665,7 @@ const updateReservationAndLoadingBalance = async (
|
||||
return result.rowCount;
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log(error.message);
|
||||
console.log(error.message);
|
||||
return error.message;
|
||||
});
|
||||
};
|
||||
@@ -745,7 +745,7 @@ const updateFlag = async (now, cardNumber, uid, balance, flag) => {
|
||||
return result;
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log(error.message);
|
||||
console.log(error.message);
|
||||
return error.message;
|
||||
});
|
||||
};
|
||||
@@ -793,14 +793,14 @@ const getReservationPendingWithoutFraud = (
|
||||
reservationNumber = []
|
||||
) => {
|
||||
if (reservationNumber.length > 0) {
|
||||
let rsv = '';
|
||||
let rsv = ``;
|
||||
if (reservationNumber.length > 0) {
|
||||
for (let index = 0; index < reservationNumber.length; index++) {
|
||||
if (index > 0) {
|
||||
rsv = rsv + ',';
|
||||
rsv = rsv + `,`;
|
||||
}
|
||||
|
||||
rsv = rsv + "'" + reservationNumber[index] + "'";
|
||||
rsv = `'` + rsv + reservationNumber[index] + `'`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -862,14 +862,14 @@ const getLastHistory = (cardNumber) => {
|
||||
|
||||
// INSERT FRAUD TRANSACTION
|
||||
const insertFraudTransaction = (reservationNumber) => {
|
||||
let rsv = '';
|
||||
let rsv = ``;
|
||||
if (reservationNumber.length > 0) {
|
||||
for (let index = 0; index < reservationNumber.length; index++) {
|
||||
if (index > 0) {
|
||||
rsv = rsv + ',';
|
||||
rsv = rsv + `,`;
|
||||
}
|
||||
|
||||
rsv = rsv + "'" + reservationNumber[index] + "'";
|
||||
rsv = `'` + rsv + reservationNumber[index] + `'`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,25 +1019,15 @@ const updateReservationAndInsertLoadingBalance = async (
|
||||
.catch(trx.rollback);
|
||||
})
|
||||
.then((result) => {
|
||||
// console.log(result);
|
||||
console.log(result);
|
||||
return result.rowCount;
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log(error.message);
|
||||
console.log(error.message);
|
||||
return error.message;
|
||||
});
|
||||
};
|
||||
|
||||
// GET TOPUP PARTIAL STATUS FROM GLOBAL PARAMETER
|
||||
const getTopupPartialStatus = () => {
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', '=', 'HSM_TOPUP_PARTIAL_STAT')
|
||||
.first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
checkCardNumber,
|
||||
getPartner,
|
||||
@@ -1082,5 +1072,4 @@ module.exports = {
|
||||
getReservationPendingWithFlagV2,
|
||||
createDetailLoadBalanceFromReservation,
|
||||
updateReservationAndInsertLoadingBalance,
|
||||
getTopupPartialStatus,
|
||||
};
|
||||
|
||||
@@ -1,442 +0,0 @@
|
||||
const moment = require("moment");
|
||||
moment.locale("id");
|
||||
const model = require("../pooling/pooling.model");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
|
||||
const pooling = async (req, res) => {
|
||||
try {
|
||||
let { batch } = req.body;
|
||||
// return console.log(batch);
|
||||
let dataInsert = [];
|
||||
if (batch) {
|
||||
let { data } = req.body;
|
||||
|
||||
if (!data) {
|
||||
return res.status(200).json({
|
||||
code: "409",
|
||||
message: "Data is required",
|
||||
data: [],
|
||||
});
|
||||
}
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let resObj = {
|
||||
c_card_number: data[i].card_number,
|
||||
c_idm: data[i].uid,
|
||||
};
|
||||
dataInsert.push(resObj);
|
||||
}
|
||||
|
||||
await model.insertDataPooling("raw", dataInsert);
|
||||
} else {
|
||||
let { card_number, uid } = req.body;
|
||||
|
||||
if (!card_number) {
|
||||
return res.status(200).json({
|
||||
code: "409",
|
||||
message: "Card Number is required",
|
||||
data: [],
|
||||
});
|
||||
}
|
||||
|
||||
if (!uid) {
|
||||
return res.status(200).json({
|
||||
code: "409",
|
||||
message: "uid is required",
|
||||
data: [],
|
||||
});
|
||||
}
|
||||
|
||||
let obj = {
|
||||
c_card_number: card_number,
|
||||
c_idm: uid,
|
||||
};
|
||||
|
||||
await model.insertDataPooling("raw", obj);
|
||||
}
|
||||
|
||||
let dataPooling = await model.getDataPooling();
|
||||
|
||||
if (dataPooling.length == 0) {
|
||||
return res.status(200).json({
|
||||
code: "00",
|
||||
message: "No Pooling Data",
|
||||
data: [],
|
||||
});
|
||||
}
|
||||
|
||||
let valid = [];
|
||||
let invalid = [];
|
||||
let validCardNo = [];
|
||||
let invalidCardNo = [];
|
||||
|
||||
// Validate data
|
||||
for (let i = 0; i < dataPooling.length; i++) {
|
||||
let cardno = dataPooling[i].c_card_number;
|
||||
let uid = dataPooling[i].c_idm;
|
||||
// Check duplikat card number
|
||||
let checkCardNo = await model.checkCardProduct(cardno, uid);
|
||||
let dataObject = {
|
||||
c_card_number: cardno,
|
||||
c_idm: uid,
|
||||
};
|
||||
|
||||
if (!checkCardNo) {
|
||||
valid.push(dataObject);
|
||||
validCardNo.push(cardno);
|
||||
} else {
|
||||
invalid.push(dataObject);
|
||||
invalidCardNo.push(cardno);
|
||||
}
|
||||
}
|
||||
|
||||
if (valid.length > 0) {
|
||||
await model.insertDataPooling("valid", valid, validCardNo);
|
||||
}
|
||||
|
||||
if (invalid.length > 0) {
|
||||
await model.insertDataPooling("invalid", invalid, invalidCardNo);
|
||||
}
|
||||
|
||||
let dataInsertCardNumber = await model.getDataValid();
|
||||
|
||||
if (dataInsertCardNumber.length == 0) {
|
||||
return res.status(200).json({
|
||||
code: "409",
|
||||
message: "No data valid",
|
||||
data: [],
|
||||
});
|
||||
}
|
||||
|
||||
let insertCardProduct = [];
|
||||
let cardNumber = [];
|
||||
for (let i = 0; i < dataInsertCardNumber.length; i++) {
|
||||
let cardno = dataInsertCardNumber[i].c_card_number;
|
||||
let uid = dataInsertCardNumber[i].c_idm;
|
||||
let obj = {
|
||||
c_card_number: cardno,
|
||||
c_idm: uid,
|
||||
};
|
||||
cardNumber.push(cardno);
|
||||
insertCardProduct.push(obj);
|
||||
}
|
||||
|
||||
let insertingCardNumber = await model.insertCardNumber(insertCardProduct);
|
||||
if (insertingCardNumber == "success") {
|
||||
let flagValid = await model.updateDataValid(dataCardNumber);
|
||||
if (flagValid == "error") {
|
||||
await model.deleteCardNumber(dataCardNumber);
|
||||
}
|
||||
}
|
||||
console.log(insertingCardNumber);
|
||||
if (insertingCardNumber == "error") {
|
||||
return res.status(200).json({
|
||||
code: "409",
|
||||
message: "Fail insert data card product",
|
||||
data: [],
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json({
|
||||
code: "00",
|
||||
message: "Success",
|
||||
data: [],
|
||||
});
|
||||
} catch (error) {
|
||||
return res.status(200).json({
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const validateData = async (req, res) => {
|
||||
let result = {};
|
||||
try {
|
||||
let data = await model.getDataPooling();
|
||||
|
||||
if (data.length == 0) {
|
||||
result = {
|
||||
code: "00",
|
||||
message: "No Pooling Data",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.warn(
|
||||
`[ RESPONSE VALIDATE-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let valid = [];
|
||||
let invalid = [];
|
||||
let validCardNo = [];
|
||||
let invalidCardNo = [];
|
||||
|
||||
winston.logger.debug(
|
||||
`[ PROCESSING VALIDATE-POOLING ]: checking and separating valid and invalid data...`
|
||||
);
|
||||
|
||||
// Validate data
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let cardno = data[i].c_card_number;
|
||||
let uid = data[i].c_idm;
|
||||
// Check duplikat card number
|
||||
let checkCardNo = await model.checkCardProduct(cardno, uid);
|
||||
let dataObject = {
|
||||
c_card_number: cardno,
|
||||
c_idm: uid,
|
||||
};
|
||||
|
||||
if (!checkCardNo) {
|
||||
valid.push(dataObject);
|
||||
validCardNo.push(cardno);
|
||||
} else {
|
||||
invalid.push(dataObject);
|
||||
invalidCardNo.push(cardno);
|
||||
}
|
||||
}
|
||||
|
||||
winston.logger.debug(`[ PROCESSING VALIDATE-POOLING ]: inserting data...`);
|
||||
|
||||
if (valid.length > 0) {
|
||||
await model.insertDataPooling("valid", valid, validCardNo);
|
||||
}
|
||||
|
||||
if (invalid.length > 0) {
|
||||
await model.insertDataPooling("invalid", invalid, invalidCardNo);
|
||||
}
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Validate success",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.info(
|
||||
`[ RESPONSE VALIDATE-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
result = {
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
};
|
||||
|
||||
winston.logger.error(
|
||||
`[ RESPONSE VALIDATE-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
};
|
||||
|
||||
const insertCardProduct = async (req, res) => {
|
||||
let result = {};
|
||||
try {
|
||||
let data = await model.getDataValid();
|
||||
|
||||
if (data.length == 0) {
|
||||
result = {
|
||||
code: "409",
|
||||
message: "No data valid",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.info(
|
||||
`[ RESPONSE INSERT-CARD-PRODUCT ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let dataInsert = [];
|
||||
let dataCardNumber = [];
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let cardno = data[i].c_card_number;
|
||||
let uid = data[i].c_idm;
|
||||
let obj = {
|
||||
c_card_number: cardno,
|
||||
c_idm: uid,
|
||||
};
|
||||
dataCardNumber.push(cardno);
|
||||
dataInsert.push(obj);
|
||||
}
|
||||
|
||||
winston.logger.debug(
|
||||
`[ PROCESSING INSERT-CARD-PRODUCT ]: inserting data...`
|
||||
);
|
||||
|
||||
let insertCardNumber = await model.insertCardNumber(dataInsert);
|
||||
if (insertCardNumber == "success") {
|
||||
let flagValid = await model.updateDataValid(dataCardNumber);
|
||||
if (flagValid == "error") {
|
||||
await model.deleteCardNumber(dataCardNumber);
|
||||
}
|
||||
}
|
||||
|
||||
if (insertCardNumber == "error") {
|
||||
result = {
|
||||
code: "409",
|
||||
message: "Fail insert data card product",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.warn(
|
||||
`[ RESPONSE INSERT-CARD-PRODUCT ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Success",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.info(
|
||||
`[ RESPONSE INSERT-CARD-PRODUCT ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
result = {
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.error(
|
||||
`[ RESPONSE INSERT-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
};
|
||||
|
||||
const insertPooling = async (req, res) => {
|
||||
let result = {};
|
||||
try {
|
||||
let { batch } = req.body;
|
||||
|
||||
let dataInsert = [];
|
||||
if (batch) {
|
||||
let { data } = req.body;
|
||||
|
||||
winston.logger.warn(
|
||||
`[ REQUEST INSERT-POOLING ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
if (!data) {
|
||||
result = {
|
||||
code: "409",
|
||||
message: "Data is required",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.warn(
|
||||
`[ RESPONSE INSERT-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let resObj = {
|
||||
c_card_number: data[i].card_number,
|
||||
c_idm: data[i].uid,
|
||||
};
|
||||
dataInsert.push(resObj);
|
||||
}
|
||||
|
||||
winston.logger.debug(`[ PROCESSING INSERT-POOLING ]: inserting data...`);
|
||||
|
||||
await model.insertDataPooling("raw", dataInsert);
|
||||
} else {
|
||||
let { card_number, uid } = req.body;
|
||||
|
||||
winston.logger.warn(
|
||||
`[ REQUEST INSERT-POOLING ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
if (!card_number) {
|
||||
result = {
|
||||
code: "409",
|
||||
message: "Card Number is required",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.warn(
|
||||
`[ RESPONSE INSERT-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (!uid) {
|
||||
result = {
|
||||
code: "409",
|
||||
message: "uid is required",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.warn(
|
||||
`[ RESPONSE INSERT-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let obj = {
|
||||
c_card_number: card_number,
|
||||
c_idm: uid,
|
||||
};
|
||||
|
||||
winston.logger.debug(`[ PROCESSING INSERT-POOLING ]: inserting data...`);
|
||||
|
||||
await model.insertDataPooling("raw", obj);
|
||||
}
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Success insert data",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.info(
|
||||
`[ RESPONSE INSERT-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
result = {
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: [],
|
||||
};
|
||||
|
||||
winston.logger.error(
|
||||
`[ RESPONSE INSERT-POOLING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = { pooling, validateData, insertCardProduct, insertPooling };
|
||||
@@ -1,155 +0,0 @@
|
||||
require("dotenv").config();
|
||||
let host = process.env.DB_HOST_POOLING;
|
||||
let user = process.env.DB_USER_POOLING;
|
||||
let name = process.env.DB_NAME_POOLING;
|
||||
let password = process.env.DB_PASSWORD_POOLING;
|
||||
const dbPooling = require("knex")({
|
||||
client: "pg",
|
||||
connection: {
|
||||
host: host,
|
||||
user: user,
|
||||
password: password,
|
||||
database: name,
|
||||
},
|
||||
});
|
||||
const knex = require("../../../infrastructure/database/knex");
|
||||
const moment = require("moment");
|
||||
moment.locale("id");
|
||||
|
||||
const insertData = (table, data) => {
|
||||
let result = knex(table).insert(data);
|
||||
return result;
|
||||
};
|
||||
|
||||
const insertDataPooling = async (table, data, cardno) => {
|
||||
if (table == "raw") {
|
||||
await dbPooling(table).insert(data);
|
||||
} else if (table == "valid") {
|
||||
await dbPooling.transaction(async (trx) => {
|
||||
try {
|
||||
await trx(table).insert(data);
|
||||
await trx("raw")
|
||||
.whereIn("c_card_number", cardno)
|
||||
.update({
|
||||
b_validate: true,
|
||||
d_validate: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
});
|
||||
await trx.commit();
|
||||
} catch (error) {
|
||||
await trx.rollback();
|
||||
}
|
||||
});
|
||||
} else if (table == "invalid") {
|
||||
await dbPooling.transaction(async (trx) => {
|
||||
try {
|
||||
await trx(table).insert(data);
|
||||
await trx("raw")
|
||||
.whereIn("c_card_number", cardno)
|
||||
.update({
|
||||
b_validate: true,
|
||||
d_validate: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
});
|
||||
await trx.commit();
|
||||
} catch (error) {
|
||||
await trx.rollback();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
await dbPooling(table).insert(data);
|
||||
}
|
||||
};
|
||||
|
||||
const checkCardProduct = (card_number, uid) => {
|
||||
let result = knex("t_m_card_product")
|
||||
.where("c_card_number", "=", card_number)
|
||||
.where("c_idm", "=", uid)
|
||||
.first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const pooling = async (valid, invalid, dataDelete) => {
|
||||
let sts;
|
||||
await dbPooling.transaction(async (trx2) => {
|
||||
try {
|
||||
if (valid.length > 0) {
|
||||
await trx2("valid").insert(valid);
|
||||
}
|
||||
if (invalid.length > 0) {
|
||||
await trx2("invalid").insert(invalid);
|
||||
}
|
||||
await trx2("pooling").whereIn("c_card_number", dataDelete).del();
|
||||
|
||||
await trx2.commit();
|
||||
sts = "success";
|
||||
} catch (error) {
|
||||
sts = "error";
|
||||
await trx2.rollback();
|
||||
}
|
||||
});
|
||||
return sts;
|
||||
};
|
||||
|
||||
const insertCardNumber = async (data) => {
|
||||
let sts;
|
||||
await knex.transaction(async (trx) => {
|
||||
try {
|
||||
await trx("t_m_card_product").insert(data);
|
||||
await trx.commit();
|
||||
sts = "success";
|
||||
} catch (error) {
|
||||
sts = "error";
|
||||
await trx.rollback();
|
||||
}
|
||||
});
|
||||
return sts;
|
||||
};
|
||||
|
||||
const updateDataValid = async (data) => {
|
||||
let sts;
|
||||
await dbPooling.transaction(async (trx) => {
|
||||
try {
|
||||
await trx("valid")
|
||||
.whereIn("c_card_number", data)
|
||||
.update({
|
||||
b_sync: true,
|
||||
d_sync: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
});
|
||||
await trx.commit();
|
||||
sts = "success";
|
||||
} catch (error) {
|
||||
await trx.rollback();
|
||||
sts = "error";
|
||||
}
|
||||
});
|
||||
return sts;
|
||||
};
|
||||
|
||||
const getDataPooling = () => {
|
||||
let result = dbPooling("raw").where("b_validate", "=", false);
|
||||
return result;
|
||||
};
|
||||
|
||||
const getDataValid = () => {
|
||||
let result = dbPooling("valid").where("b_sync", "=", false);
|
||||
return result;
|
||||
};
|
||||
|
||||
const deleteCardNumber = (data) => {
|
||||
let result = knex("t_m_card_product")
|
||||
.whereIn("c_card_number", "=", data)
|
||||
.del();
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
deleteCardNumber,
|
||||
updateDataValid,
|
||||
getDataValid,
|
||||
insertDataPooling,
|
||||
insertCardNumber,
|
||||
pooling,
|
||||
insertData,
|
||||
checkCardProduct,
|
||||
getDataPooling,
|
||||
};
|
||||
@@ -85,11 +85,6 @@ const validate = (method) => {
|
||||
.isEmpty()
|
||||
.withMessage('Cancel Reservation data is required'),
|
||||
];
|
||||
case 'getFeeSharing':
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -632,10 +627,7 @@ const reservationValidate = async (req, res) => {
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'validation successfully.',
|
||||
data: {
|
||||
issuer_fee: issuerFee,
|
||||
channel_fee: channelFee,
|
||||
},
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log info
|
||||
@@ -1089,8 +1081,6 @@ const reservationValidateV2 = async (req, res) => {
|
||||
reservation_detail: {
|
||||
card_number: card_number,
|
||||
amount: amount,
|
||||
issuer_fee: issuerFee,
|
||||
channel_fee: channelFee,
|
||||
},
|
||||
reservation_pending: dataReservationPending,
|
||||
},
|
||||
@@ -1121,7 +1111,7 @@ const reservationValidateV2 = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
// ================================================================= RESERVATION V1 =================================================================
|
||||
// ================================================================= RESERVATION =================================================================
|
||||
// *Created By: Mohamad Ihsan*
|
||||
// *Description:*
|
||||
// proses insert data transaksi reservasi saldo. Proses ini dilakukan setelah melakukan reservation validate dengan response code 00. Output dari proses ini adalah kode reservation number dan informasi reservasi saldo yang dilakukan
|
||||
@@ -1134,8 +1124,7 @@ const reservation = async (req, res) => {
|
||||
let result = {};
|
||||
|
||||
// param
|
||||
let { mid, tid, card_number, amount, ref_no, customer_name, phone_number } =
|
||||
req.body;
|
||||
let { mid, tid, card_number, amount, ref_no } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
@@ -1577,19 +1566,6 @@ const reservation = async (req, res) => {
|
||||
|
||||
let expired = moment(now).add(time, measure).format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
// -------------------------------- NOTES --------------------------------
|
||||
// for LRT JABO => customer_name diisi Device Name (versi penamaan LRT Jabo) dan phone_number diisi Device Code (versi kode LRT Jabo) sesuai MOM BI-WEEKLY MEETING (08/05/2023)
|
||||
let customerName = customer_name;
|
||||
let phoneNumber = phone_number;
|
||||
|
||||
if (!customerName || customerName == '' || customerName == '-') {
|
||||
customerName = getPartner ? getPartner.terminal_name : '';
|
||||
}
|
||||
|
||||
if (!phoneNumber || phoneNumber == '' || phoneNumber == '-') {
|
||||
phoneNumber = mid + '_' + tid;
|
||||
}
|
||||
|
||||
// binding data
|
||||
let data = {
|
||||
c_reservation_no: reservationNumber,
|
||||
@@ -1636,8 +1612,6 @@ const reservation = async (req, res) => {
|
||||
c_delete_username: null,
|
||||
c_delete_fullname: null,
|
||||
c_flag: '-1',
|
||||
c_customer_name: customerName,
|
||||
c_phone_number: phoneNumber,
|
||||
};
|
||||
|
||||
// log debug
|
||||
@@ -1660,7 +1634,7 @@ const reservation = async (req, res) => {
|
||||
await model.deleteReservationNumberValidate(reservationNumber);
|
||||
|
||||
result = {
|
||||
code: '424',
|
||||
code: '432',
|
||||
message: 'refno is duplicate',
|
||||
data: {},
|
||||
};
|
||||
@@ -1754,14 +1728,7 @@ const reservationV2 = async (req, res) => {
|
||||
let result = {};
|
||||
|
||||
// param
|
||||
let {
|
||||
reservation_data,
|
||||
ref_no,
|
||||
customer_name,
|
||||
phone_number,
|
||||
amount,
|
||||
card_number,
|
||||
} = req.body;
|
||||
let { reservation_data, ref_no } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
@@ -1836,47 +1803,11 @@ const reservationV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (card_number) {
|
||||
if (reservationData.card_number != card_number) {
|
||||
result = {
|
||||
code: '441',
|
||||
message:
|
||||
'bad request. card number requested is different with reservation data.',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (amount) {
|
||||
if (reservationData.amount != amount) {
|
||||
result = {
|
||||
code: '442',
|
||||
message:
|
||||
'bad request. amount requested is different with reservation data.',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
// extract reseravtion data
|
||||
let mid = reservationData.mid;
|
||||
let tid = reservationData.tid;
|
||||
card_number = reservationData.card_number;
|
||||
amount = reservationData.amount;
|
||||
let card_number = reservationData.card_number;
|
||||
let amount = reservationData.amount;
|
||||
let transactionDate = reservationData.transaction_date;
|
||||
let securityCode = reservationData.security_code;
|
||||
|
||||
@@ -2371,19 +2302,6 @@ const reservationV2 = async (req, res) => {
|
||||
|
||||
let expired = moment(now).add(time, measure).format('YYYY-MM-DD HH:mm:ss');
|
||||
|
||||
// -------------------------------- NOTES --------------------------------
|
||||
// for LRT JABO => customer_name diisi Device Name (versi penamaan LRT Jabo) dan phone_number diisi Device Code (versi kode LRT Jabo) sesuai MOM BI-WEEKLY MEETING (08/05/2023)
|
||||
let customerName = customer_name;
|
||||
let phoneNumber = phone_number;
|
||||
|
||||
if (!customerName || customerName == '' || customerName == '-') {
|
||||
customerName = getPartner ? getPartner.terminal_name : '';
|
||||
}
|
||||
|
||||
if (!phoneNumber || phoneNumber == '' || phoneNumber == '-') {
|
||||
phoneNumber = mid + '_' + tid;
|
||||
}
|
||||
|
||||
// binding data
|
||||
let data = {
|
||||
c_reservation_no: reservationNumber,
|
||||
@@ -2430,8 +2348,6 @@ const reservationV2 = async (req, res) => {
|
||||
c_delete_username: null,
|
||||
c_delete_fullname: null,
|
||||
c_flag: '-1',
|
||||
c_customer_name: customerName,
|
||||
c_phone_number: phoneNumber,
|
||||
};
|
||||
|
||||
// log debug
|
||||
@@ -2454,7 +2370,7 @@ const reservationV2 = async (req, res) => {
|
||||
await model.deleteReservationNumberValidate(reservationNumber);
|
||||
|
||||
result = {
|
||||
code: '424',
|
||||
code: '432',
|
||||
message: 'refno is duplicate',
|
||||
data: {},
|
||||
};
|
||||
@@ -3175,18 +3091,6 @@ const inquiryListReservationByReservation = async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
// check date range max 1 month
|
||||
let diff = moment(end_date).diff(moment(start_date), 'months', true);
|
||||
|
||||
if (diff >= 1) {
|
||||
return res.status(200).json({
|
||||
code: '400',
|
||||
message:
|
||||
'bad request. We only allow data requests for 1 month. please change your date range parameter request!',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
// check reservation
|
||||
let listReservation = await model.inquiryListReservation(
|
||||
req.partner_id_token,
|
||||
@@ -3384,7 +3288,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
||||
// check value global parameter
|
||||
if (!getGlobalParameter) {
|
||||
result = {
|
||||
code: '439',
|
||||
code: '493',
|
||||
message: 'HSM_CANCEL_RESERVATION_LEVEL in global parameter not found',
|
||||
data: {},
|
||||
};
|
||||
@@ -3533,13 +3437,13 @@ const cancelReservationValidateV2 = async (req, res) => {
|
||||
|
||||
// create security code yang isinya data reservasi yang akan di compare nantinya saat melakukan insert reservation
|
||||
let securityCode = await helper.createHMAC(
|
||||
mid + '|' + tid + '|' + reservationNumber
|
||||
mid + '|' + tid + '|' + reservation_number
|
||||
);
|
||||
|
||||
let reservationData = {
|
||||
mid: mid,
|
||||
tid: tid,
|
||||
reservation_number: reservationNumber,
|
||||
reservation_number: reservation_number,
|
||||
transaction_date: now,
|
||||
security_code: securityCode,
|
||||
};
|
||||
@@ -4152,96 +4056,6 @@ const cancelReservationV2_1 = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
// ================================================================= GET FEE SHARING =================================================================
|
||||
// *Created By: Mohamad Ihsan*
|
||||
// *Description:*
|
||||
// proses fee sharing
|
||||
|
||||
const getFeeSharing = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||
let uniqueCode = await helper.getUniqueCode();
|
||||
let result = {};
|
||||
|
||||
// param
|
||||
let { datetime, mid, tid } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST GET-FEE-SHARING ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// datetime
|
||||
if (!datetime) {
|
||||
datetime = moment().format('YYYY-MM-DD');
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan data partner berdasarkan mid dan tid yang di request, apakah terdaftar di sistem CMS atau tidak
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} [ PROCESSING GET-FEE-SHARING ] checking partner...`
|
||||
);
|
||||
|
||||
// get partner, merchant, terminal from tid
|
||||
let getPartner = await model.getPartner(mid, tid);
|
||||
|
||||
// jika partner (mid atau tid) tidak ditemukan atau tidak terdaftar di sistem CMS
|
||||
if (!getPartner) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'terminal id is not valid',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE GET-FEE-SHARING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// set default issuer fee
|
||||
let issuerFee = 0;
|
||||
let channelFee = 0;
|
||||
|
||||
// get issuer fee dan channel fee dari table public.t_c_partner_fee
|
||||
let getIssuer = await model.getIssuer(getPartner.i_partner, datetime);
|
||||
if (getIssuer) {
|
||||
issuerFee =
|
||||
(getIssuer.i_issuer_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
||||
channelFee =
|
||||
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
||||
}
|
||||
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'fee sharing has been found.',
|
||||
data: {
|
||||
issuer_fee: issuerFee,
|
||||
channel_fee: channelFee,
|
||||
},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE GET-FEE-SHARING ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validate,
|
||||
checkReservation,
|
||||
@@ -4257,5 +4071,4 @@ module.exports = {
|
||||
cancelReservationValidateV2,
|
||||
cancelReservationV2,
|
||||
cancelReservationV2_1,
|
||||
getFeeSharing,
|
||||
};
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const auth = require("../middlewares/jwt.middleware");
|
||||
const controller = require("../modules/pooling/pooling.controller");
|
||||
|
||||
router.post(
|
||||
"/validate-pooling",
|
||||
auth.authenticateToken,
|
||||
controller.validateData
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/insert-pooling",
|
||||
auth.authenticateToken,
|
||||
controller.insertPooling
|
||||
);
|
||||
|
||||
router.post(
|
||||
"/insert-card-product",
|
||||
auth.authenticateToken,
|
||||
controller.insertCardProduct
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
@@ -91,13 +91,6 @@ router.post(
|
||||
controller.cancelReservationV2
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/reservation/fee-sharing',
|
||||
auth.authenticateToken,
|
||||
controller.validate('getFeeSharing'),
|
||||
controller.getFeeSharing
|
||||
);
|
||||
|
||||
// router.post(
|
||||
// '/reservation/cancel/v2.1',
|
||||
// auth.authenticateToken,
|
||||
|
||||
@@ -21,13 +21,6 @@ DB_PASSWORD_LOCAL=postgres
|
||||
REDIS_URL=redis://localhost:6379
|
||||
REDIS_PASSWORD=
|
||||
|
||||
# ==================================== DB POOLING =====================================
|
||||
DB_HOST_POOLING=10.20.14.14
|
||||
DB_NAME_POOLING=postgres
|
||||
DB_PORT_POOLING=5432
|
||||
DB_USER_POOLING=postgres
|
||||
DB_PASSWORD_POOLING=inhc0mmute_cms
|
||||
|
||||
# ==================================== LOKI =====================================
|
||||
LOKI_URL=http://10.20.14.30:3100
|
||||
|
||||
|
||||
@@ -1,145 +0,0 @@
|
||||
# ================================= ENVIRONMENT =================================
|
||||
#NODE_ENV=production
|
||||
NODE_ENV=development
|
||||
#NODE_ENV=testing
|
||||
PORT=3000
|
||||
VERSION=v1.3.7
|
||||
|
||||
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
||||
# SERVER_FOR=development
|
||||
#SERVER_FOR=production
|
||||
SERVER_FOR=local
|
||||
|
||||
# =============================== DATABASE LOCAL =================================
|
||||
# DB_URL=postgresql://postgres:postgres@localhost:5432/CMS_DEV
|
||||
DB_HOST_LOCAL=localhost
|
||||
DB_NAME_LOCAL=CMS_DEV
|
||||
DB_PORT_LOCAL=5432
|
||||
DB_USER_LOCAL=postgres
|
||||
DB_PASSWORD_LOCAL=postgres
|
||||
|
||||
# ==================================== REDIS =====================================
|
||||
REDIS_URL=redis://localhost:6379
|
||||
REDIS_PASSWORD=
|
||||
|
||||
# ==================================== LOKI =====================================
|
||||
LOKI_URL=http://localhost:3100
|
||||
|
||||
# =============================== APP PROMETHEUS =================================
|
||||
PROM_APP = topuponline
|
||||
|
||||
# ================================== SECRET KEY ==================================
|
||||
# FOR PRODUCTION
|
||||
#SECRET_KEY=U2FsdGVkX19keaNhiBfdNSWnKA2a8Z5deBu/KkU6BNg=
|
||||
# FOR DEVELOPMENT
|
||||
SECRET_KEY=U2FsdGVkX18tPlf9nVJEx7KwTdFsGPO/RK6A0HRYDeg=
|
||||
|
||||
# ===================================== JWT =======================================
|
||||
JWT_EXPIRATION=30d
|
||||
JWT_REFRESH_EXPIRATION=40d
|
||||
# FOR PRODUCTION
|
||||
#TOKEN_SECRET=101001D00C2001D0483001D0
|
||||
#REFRESH_TOKEN_SECRET=101001D00C2001D0483001D0800082008300800081008200
|
||||
# FOR DEVELOPMENT
|
||||
TOKEN_SECRET=101001A00C2001A0483001A0883001A0
|
||||
REFRESH_TOKEN_SECRET=101001A00C2001A0483001A0883001A0800082008300800081008200
|
||||
|
||||
|
||||
# ===================== CHANGE TO DRC SERVER (YES or NO) ===========================
|
||||
CHANGE_TO_DRC=YES
|
||||
|
||||
# HIGH AVABILITY (1 = SERVER_HSM_1 ONLY RUNNING, 2 = SERVER_HSM_2 ONLY RUNNING, 12 = SERVER_HSM_1 && SERVER_HSM_2 RUNNING)
|
||||
NUMBER_SERVER_ACTIVE=1
|
||||
|
||||
# ================================ KONFIGURASI HSM =================================
|
||||
|
||||
# system code kci profile
|
||||
# FOR PRODUCTION & DEVELOPMENT
|
||||
SYSTEM_CODE=90B7
|
||||
|
||||
#SERVICE BLOCK
|
||||
# FOR PRODUCTION
|
||||
# SERVICEBLOCK_SERVICE_MUTUAL="101001D00C2001D0483001D0"
|
||||
# FOR DEVELOPMENT
|
||||
SERVICEBLOCK_SERVICE_MUTUAL="101001A00C2001A0483001A0883001A0"
|
||||
|
||||
SERVICEBLOCK_BLOCK_READ="800082008300"
|
||||
SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_1="ws://182.253.34.129/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# URL_HSM_SERVER_2="ws://182.253.34.129:88/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# # HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# # HSM SERVER
|
||||
# URL_HSM_SERVER_BACKUP_1="ws://182.253.34.129/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
# URL_HSM_SERVER_BACKUP_2="ws://182.253.34.129:88/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# HSM SERVER
|
||||
IP_HSM_SERVER_1="10.1.201.222"
|
||||
URL_HSM_SERVER_1="ws://10.1.201.222/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
IP_HSM_SERVER_2="10.1.201.215"
|
||||
URL_HSM_SERVER_2="ws://10.1.201.215:88/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# HSM SERVER
|
||||
IP_HSM_SERVER_BACKUP_1="10.1.201.222"
|
||||
URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_BACKUP_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
IP_HSM_SERVER_BACKUP_2="10.1.201.215"
|
||||
URL_HSM_SERVER_BACKUP_2="ws://10.1.201.215:88/feliqserver/v1/wsapi"
|
||||
APIKEY_HSM_SERVER_BACKUP_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||
SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||
|
||||
|
||||
# ============================= KONFIGURASI HSM NUTECH =============================
|
||||
|
||||
# SYSTEM CODE IN HEXA STRING
|
||||
# system code nutech profile
|
||||
# SYSTEM_CODE=939E
|
||||
|
||||
#SERVICE BLOCK
|
||||
# SERVICEBLOCK_SERVICE_MUTUAL="102001A04C2001A0882001A0"
|
||||
# SERVICEBLOCK_BLOCK_READ="80008200"
|
||||
# SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||
|
||||
# HSM DC (DATA CENTER)
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||
# JEPANG
|
||||
# URL_HSM_SERVER_1="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_1="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_1="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
# URL_HSM_SERVER_2="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
|
||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||
# HSM SERVER
|
||||
# URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||
# JEPANG
|
||||
# URL_HSM_SERVER_BACKUP_2="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||
# APIKEY_HSM_SERVER_BACKUP_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||
# SECRETKEY_HSM_SERVER_BACKUP_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||
|
||||
|
||||
|
||||
@@ -1,60 +1,33 @@
|
||||
require('dotenv').config();
|
||||
const cluster = require('node:cluster');
|
||||
const totalCPUs = require('node:os').cpus().length;
|
||||
const process = require('node:process');
|
||||
const winston = require('./application/helpers/winston.logger');
|
||||
const server = require('./server');
|
||||
require("dotenv").config();
|
||||
const winston = require("./application/helpers/winston.logger");
|
||||
const server = require("./server");
|
||||
|
||||
// set port, listen for requests
|
||||
const PORT = process.env.PORT || 3000;
|
||||
var serverHSMStatus = 'HSM SERVER NOT CONNECTED';
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var serverHSMStatus = "HSM SERVER NOT CONNECTED";
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_1}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
serverHSMStatus = `SERVER 2 CONNECTED on ip ${process.env.IP_HSM_SERVER_2}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
serverHSMStatus = `SERVER 1 on ip ${process.env.IP_HSM_SERVER_1} AND SERVER 2 on ip ${process.env.IP_HSM_SERVER_2} CONNECTED`;
|
||||
}
|
||||
|
||||
var serverActive = 'DC (DATA CENTER)';
|
||||
if (process.env.CHANGE_TO_DRC == 'YES' || process.env.CHANGE_TO_DRC == 'yes') {
|
||||
serverActive = 'DRC (DISASTER RECOVERY CENTER)';
|
||||
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var serverActive = "DC (DATA CENTER)";
|
||||
if (process.env.CHANGE_TO_DRC == "YES" || process.env.CHANGE_TO_DRC == "yes") {
|
||||
serverActive = "DRC (DISASTER RECOVERY CENTER)";
|
||||
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_BACKUP_1}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
serverHSMStatus = `SERVER 2 CONNECTED on ip ${process.env.IP_HSM_SERVER_BACKUP_2}`;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
serverHSMStatus = `SERVER 1 on ip ${process.env.IP_HSM_SERVER_BACKUP_1} AND SERVER 2 on ip ${process.env.IP_HSM_SERVER_BACKUP_2} CONNECTED`;
|
||||
}
|
||||
}
|
||||
|
||||
if (cluster.isMaster) {
|
||||
console.log(`Number of CPUs is ${totalCPUs}`);
|
||||
console.log(`Master ${process.pid} is running`);
|
||||
|
||||
// Fork workers.
|
||||
for (let i = 0; i < totalCPUs; i++) {
|
||||
cluster.fork();
|
||||
}
|
||||
|
||||
cluster.on('exit', (worker, code, signal) => {
|
||||
console.log(`worker ${worker.process.pid} died`);
|
||||
console.log("Let's fork another worker!");
|
||||
cluster.fork();
|
||||
});
|
||||
} else {
|
||||
startExpress();
|
||||
}
|
||||
|
||||
console.log(`worker pid=${process.pid}`);
|
||||
|
||||
function startExpress() {
|
||||
server.listen(PORT, () => {
|
||||
winston.logger.info(
|
||||
`Server is running on version ${
|
||||
process.env.VERSION
|
||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
||||
);
|
||||
});
|
||||
}
|
||||
server.listen(PORT, () => {
|
||||
winston.logger.info(
|
||||
`Server is running on environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
||||
);
|
||||
});
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ module.exports = {
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 30,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
|
||||
+147
-137
@@ -12,7 +12,6 @@ const historyRoute = require('../application/routes/history.routes');
|
||||
const paymentReconRoute = require('../application/routes/paymentrecon.routes');
|
||||
const invoiceRoute = require('../application/routes/invoiceonline.routes');
|
||||
const cashinRoute = require('../application/routes/cahsin.routes');
|
||||
const pooling = require('../application/routes/pooling.routes');
|
||||
const cron = require('node-cron');
|
||||
const moment = require('moment');
|
||||
require('dotenv').config();
|
||||
@@ -22,14 +21,12 @@ const { logger } = require('../application/helpers/getbodyrequest');
|
||||
const client = require('prom-client');
|
||||
const register = new client.Registry();
|
||||
const {
|
||||
topuponline_metrics,
|
||||
topuponline_metrics_response_time,
|
||||
topuponline_metrics_load_balance,
|
||||
topuponline_metrics, topuponline_metrics_response_time,topuponline_metrics_load_balance
|
||||
} = require('../application/helpers/prometheusmetrics');
|
||||
|
||||
const app = express();
|
||||
|
||||
let promApp = process.env.PROM_APP || 'topuponline';
|
||||
let promApp = process.env.PROM_APP || "topuponline";
|
||||
register.setDefaultLabels({ app: promApp });
|
||||
client.collectDefaultMetrics({ register });
|
||||
register.registerMetric(topuponline_metrics);
|
||||
@@ -61,9 +58,23 @@ app.use(responseTime());
|
||||
|
||||
// ============================== ROUTES API ==============================
|
||||
app.get('/', async (req, res) => {
|
||||
let data = {
|
||||
card_number: '1234567890',
|
||||
amount: 10000,
|
||||
};
|
||||
|
||||
let chipperData = helper.encryptText(JSON.stringify(data));
|
||||
let decrypData = JSON.parse(helper.decryptText(chipperData));
|
||||
res.json({
|
||||
message: 'Welcome to Topup Online Service.',
|
||||
data: {},
|
||||
data: {
|
||||
text: '0nlinet0pupkci',
|
||||
chiper_text: helper.encryptText('0nlinet0pupkci'),
|
||||
chipper_data: chipperData,
|
||||
decrypt_data: decrypData,
|
||||
date: moment().format('YYYYMMDDHHmm'),
|
||||
secret_key: helper.encryptText('0nlinetopupDev'),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,7 +90,6 @@ app.use('/api/', paymentReconRoute);
|
||||
app.use('/api/', reservationRoute);
|
||||
app.use('/api/', invoiceRoute);
|
||||
app.use('/api/', cashinRoute);
|
||||
app.use('/api/', pooling);
|
||||
|
||||
// ============================== SAP SCHEDULLER =============================
|
||||
|
||||
@@ -89,150 +99,150 @@ app.use('/api/', pooling);
|
||||
// SCHEDULER FOR GENERATE INVOICE
|
||||
// ===================================================
|
||||
|
||||
// const {
|
||||
// _generateInvoice,
|
||||
// _postingInvoice,
|
||||
// } = require('../application/modules/invoiceonline/invoice.controller');
|
||||
const {
|
||||
_generateInvoice,
|
||||
_postingInvoice,
|
||||
} = require('../application/modules/invoiceonline/invoice.controller');
|
||||
|
||||
// GENERATE + POSTING INVOICE
|
||||
// cron.schedule('0 1 * * *', async () => {
|
||||
// try {
|
||||
// // let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD");
|
||||
// let ivoiceDate = moment().format('YYYY-MM-DD');
|
||||
// let uniqueCode = helper.getUniqueCode();
|
||||
// winston.logger.debug(
|
||||
// `STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} `
|
||||
// );
|
||||
// const generate = await _generateInvoice(ivoiceDate, uniqueCode, false);
|
||||
// winston.logger.debug(
|
||||
// `END SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} : ${JSON.stringify(
|
||||
// generate
|
||||
// )}`
|
||||
// );
|
||||
// const reGenerate = await _generateInvoice(ivoiceDate, uniqueCode, true);
|
||||
// winston.logger.debug(
|
||||
// `END SCHEDULER-FB70 RE-GENERATE INVOICE THAT HAVE BEEN DELETED ${ivoiceDate} : ${JSON.stringify(
|
||||
// generate
|
||||
// )}`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// // create log
|
||||
// winston.logger.error(
|
||||
// `500 internal server error - backend server | ${error.message}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
cron.schedule('0 1 * * *', async () => {
|
||||
try {
|
||||
// let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD");
|
||||
let ivoiceDate = moment().format('YYYY-MM-DD');
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(
|
||||
`STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} `
|
||||
);
|
||||
const generate = await _generateInvoice(ivoiceDate, uniqueCode, false);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} : ${JSON.stringify(
|
||||
generate
|
||||
)}`
|
||||
);
|
||||
const reGenerate = await _generateInvoice(ivoiceDate, uniqueCode, true);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-GENERATE INVOICE THAT HAVE BEEN DELETED ${ivoiceDate} : ${JSON.stringify(
|
||||
generate
|
||||
)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// RE-TRY POSTING
|
||||
// cron.schedule('0 7 * * *', async () => {
|
||||
// try {
|
||||
// let uniqueCode = helper.getUniqueCode();
|
||||
// winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
// const posting = await _postingInvoice(uniqueCode);
|
||||
// winston.logger.debug(
|
||||
// `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// // create log
|
||||
// winston.logger.error(
|
||||
// `500 internal server error - backend server | ${error.message}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
cron.schedule('0 7 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// cron.schedule('0 12 * * *', async () => {
|
||||
// try {
|
||||
// let uniqueCode = helper.getUniqueCode();
|
||||
// winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
// const posting = await _postingInvoice(uniqueCode);
|
||||
// winston.logger.debug(
|
||||
// `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// // create log
|
||||
// winston.logger.error(
|
||||
// `500 internal server error - backend server | ${error.message}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
cron.schedule('0 12 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// cron.schedule('0 17 * * *', async () => {
|
||||
// try {
|
||||
// let uniqueCode = helper.getUniqueCode();
|
||||
// winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
// const posting = await _postingInvoice(uniqueCode);
|
||||
// winston.logger.debug(
|
||||
// `END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// // create log
|
||||
// winston.logger.error(
|
||||
// `500 internal server error - backend server | ${error.message}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
cron.schedule('0 17 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||
const posting = await _postingInvoice(uniqueCode);
|
||||
winston.logger.debug(
|
||||
`END SCHEDULER-FB70 RE-TRY POSTING INVOICE : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// ===================================================
|
||||
// SCHEDULER FOR GENERATE INVOICE
|
||||
// ===================================================
|
||||
// cash in
|
||||
// const {
|
||||
// _generateCashIn,
|
||||
// } = require('../application/modules/cashin/cahsin.controller');
|
||||
const {
|
||||
_generateCashIn,
|
||||
} = require('../application/modules/cashin/cahsin.controller');
|
||||
|
||||
// cron.schedule('30 7 * * *', async () => {
|
||||
// try {
|
||||
// let uniqueCode = helper.getUniqueCode();
|
||||
// winston.logger.info(
|
||||
// `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
// );
|
||||
// const posting = await _generateCashIn(uniqueCode);
|
||||
// winston.logger.info(
|
||||
// `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// // create log
|
||||
// winston.logger.error(
|
||||
// `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
cron.schedule('30 7 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(
|
||||
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// cron.schedule('30 12 * * *', async () => {
|
||||
// try {
|
||||
// let uniqueCode = helper.getUniqueCode();
|
||||
// winston.logger.info(
|
||||
// `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
// );
|
||||
// const posting = await _generateCashIn(uniqueCode);
|
||||
// winston.logger.info(
|
||||
// `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// // create log
|
||||
// winston.logger.error(
|
||||
// `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
cron.schedule('30 12 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(
|
||||
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// cron.schedule('30 17 * * *', async () => {
|
||||
// try {
|
||||
// let uniqueCode = helper.getUniqueCode();
|
||||
// winston.logger.info(
|
||||
// `STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
// );
|
||||
// const posting = await _generateCashIn(uniqueCode);
|
||||
// winston.logger.info(
|
||||
// `END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
// );
|
||||
// } catch (error) {
|
||||
// // create log
|
||||
// winston.logger.error(
|
||||
// `500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
cron.schedule('30 17 * * *', async () => {
|
||||
try {
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
winston.logger.info(
|
||||
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||
);
|
||||
const posting = await _generateCashIn(uniqueCode);
|
||||
winston.logger.info(
|
||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||
);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user