mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 11:36:28 +00:00
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c5b75058d3 | |||
| 18cab4b93b | |||
| 40990b3498 | |||
| fa43d34c90 | |||
| 5a0d579405 | |||
| 8e9f9dca82 | |||
| c8755f9e2d | |||
| f2e6b31b82 | |||
| 751191e10e | |||
| 33039fab21 | |||
| 2c31a4e425 | |||
| b5b72ecf6c | |||
| b7e5d0c426 | |||
| 82bd1c5276 | |||
| c39675b1ac | |||
| 146e64fc63 | |||
| 058cd6edfc | |||
| 3fb2124534 | |||
| c4f276289a | |||
| f8aacae0ea | |||
| 0e237bd66d | |||
| 8e8704a1a2 | |||
| 25c3d03761 | |||
| 3be8c88db4 | |||
| 983902d08e | |||
| 7a09320404 | |||
| ff245148f6 | |||
| 5a4870408c | |||
| e3ef16753e | |||
| 90aaf3f6f6 | |||
| 0437eaab25 | |||
| 4a98a1c5cd | |||
| 3c927b6385 | |||
| 41bdf42bac | |||
| 986f2de372 | |||
| be1c3c179b | |||
| 1df38dbdf0 | |||
| aae040e908 | |||
| 37a81c826a | |||
| 34ee6cc703 | |||
| 7476de9ebe | |||
| 094d9809ff | |||
| 74993b5e26 | |||
| 5ceb25c892 | |||
| 2c744a350c | |||
| 270f859e0d | |||
| ba46437d11 | |||
| 255fb13ab7 | |||
| 0d1e4869be | |||
| 052c71220f | |||
| 6234fb5e36 | |||
| 4f72e83710 |
@@ -3,6 +3,13 @@ require("winston-daily-rotate-file");
|
|||||||
const expressWinston = require("express-winston");
|
const expressWinston = require("express-winston");
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
|
const winstonLoki = require("../helpers/loki");
|
||||||
|
const knex = require("../../infrastructure/database/knex");
|
||||||
|
const {
|
||||||
|
topuponline_metrics,
|
||||||
|
topuponline_metrics_response_time,
|
||||||
|
topuponline_metrics_load_balance,
|
||||||
|
} = require("../helpers/prometheusmetrics");
|
||||||
|
|
||||||
const filename = () => {
|
const filename = () => {
|
||||||
if (!fs.existsSync(`./expresswinstonlog`)) {
|
if (!fs.existsSync(`./expresswinstonlog`)) {
|
||||||
@@ -28,6 +35,20 @@ const filename = () => {
|
|||||||
|
|
||||||
filename();
|
filename();
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
"/api/reservation",
|
||||||
|
"/api/reservation/v2",
|
||||||
|
"/api/loadbalance/request",
|
||||||
|
"/api/topup1",
|
||||||
|
"/api/topup2",
|
||||||
|
"/api/topup3",
|
||||||
|
"/api/topup4",
|
||||||
|
"/api/topup5",
|
||||||
|
"/api/topup6",
|
||||||
|
"/api/topup7",
|
||||||
|
"/api/topup8",
|
||||||
|
];
|
||||||
|
|
||||||
const logger = {
|
const logger = {
|
||||||
response: expressWinston.logger({
|
response: expressWinston.logger({
|
||||||
transports: [
|
transports: [
|
||||||
@@ -35,13 +56,12 @@ const logger = {
|
|||||||
filename: "./expresswinstonlog/%DATE%.log",
|
filename: "./expresswinstonlog/%DATE%.log",
|
||||||
frequency: "24h",
|
frequency: "24h",
|
||||||
datePattern: "YYYY/MM/DD",
|
datePattern: "YYYY/MM/DD",
|
||||||
zippedArchive: true,
|
|
||||||
maxFiles: "1d",
|
maxFiles: "1d",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
format: winston.format.combine(
|
format: winston.format.combine(
|
||||||
winston.format.timestamp(),
|
winston.format.timestamp(),
|
||||||
winston.format.printf((info) => {
|
winston.format.printf(async (info) => {
|
||||||
let body = {};
|
let body = {};
|
||||||
body.id = info.meta.req.id;
|
body.id = info.meta.req.id;
|
||||||
body.tag = "RES";
|
body.tag = "RES";
|
||||||
@@ -51,16 +71,192 @@ const logger = {
|
|||||||
body.time = moment().format();
|
body.time = moment().format();
|
||||||
body.responseTime = `${info.meta.responseTime} ms`;
|
body.responseTime = `${info.meta.responseTime} ms`;
|
||||||
|
|
||||||
var header_auth = info.meta.req.headers["authorization"];
|
let issuerName;
|
||||||
var issuer_name = "Web"
|
|
||||||
if (!issuer_name)
|
let partnerId = info.meta.req.partner_id_token;
|
||||||
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
|
||||||
|
if (!partnerId) {
|
||||||
|
issuerName = "UNDEFINED";
|
||||||
|
} else {
|
||||||
|
let getIssuerName = await getPartner(info.meta.req.partner_id_token);
|
||||||
|
if (!getIssuerName.c_name) {
|
||||||
|
issuerName = "UNDEFINED";
|
||||||
|
} else {
|
||||||
|
issuerName = getIssuerName.c_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let statusCode = info.meta.res.body.code;
|
||||||
|
let message = info.meta.res.body.message;
|
||||||
|
let url = info.meta.req.originalUrl;
|
||||||
|
|
||||||
|
let date = moment().format("D");
|
||||||
|
let month = moment().format("M");
|
||||||
|
let year = moment().format("Y");
|
||||||
|
|
||||||
|
// Topup Metrics
|
||||||
|
if (
|
||||||
|
url == "/api/topup1" ||
|
||||||
|
url == "/api/topup2" ||
|
||||||
|
url == "/api/topup3" ||
|
||||||
|
url == "/api/topup4" ||
|
||||||
|
url == "/api/topup5" ||
|
||||||
|
url == "/api/topup6" ||
|
||||||
|
url == "/api/topup7" ||
|
||||||
|
url == "/api/topup8"
|
||||||
|
) {
|
||||||
|
let trxId = info.meta.res.body.data.trxID;
|
||||||
|
if (!trxId) {
|
||||||
|
trxId = "UNDEFINED";
|
||||||
|
}
|
||||||
|
|
||||||
|
topuponline_metrics_load_balance
|
||||||
|
.labels({
|
||||||
|
trxId: trxId,
|
||||||
|
route: url,
|
||||||
|
issuer_name: issuerName,
|
||||||
|
date: date,
|
||||||
|
month: month,
|
||||||
|
year: year,
|
||||||
|
})
|
||||||
|
.observe(info.meta.responseTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reservation Loki Logs
|
||||||
|
if (url == "/api/reservation" || url == "/api/reservation/v2") {
|
||||||
|
if (
|
||||||
|
statusCode != "00" &&
|
||||||
|
statusCode != "01" &&
|
||||||
|
statusCode != "02" &&
|
||||||
|
statusCode != "03" &&
|
||||||
|
statusCode != "04"
|
||||||
|
) {
|
||||||
|
console.log(statusCode);
|
||||||
|
winstonLoki.log.error({
|
||||||
|
message: message,
|
||||||
|
labels: {
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
issuer_name: issuerName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let reservation_number = info.meta.res.body.data.reservation_number;
|
||||||
|
let card_number = info.meta.res.body.data.card_number;
|
||||||
|
winstonLoki.log.info({
|
||||||
|
message: message,
|
||||||
|
labels: {
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
issuer_name: issuerName,
|
||||||
|
reservation_number: reservation_number,
|
||||||
|
card_number: card_number,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (url == "/api/topup6" || url == "/api/topup7") {
|
||||||
|
let card_number = info.meta.req.body.card_number;
|
||||||
|
let uid = info.meta.req.body.uid;
|
||||||
|
let trxID = info.meta.res.body.data.trxID;
|
||||||
|
if (
|
||||||
|
statusCode != "00" &&
|
||||||
|
statusCode != "01" &&
|
||||||
|
statusCode != "02" &&
|
||||||
|
statusCode != "03" &&
|
||||||
|
statusCode != "04"
|
||||||
|
) {
|
||||||
|
winstonLoki.log.error({
|
||||||
|
message: message,
|
||||||
|
labels: {
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
issuer_name: issuerName,
|
||||||
|
card_number: card_number,
|
||||||
|
uid: uid,
|
||||||
|
trxID: trxID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
winstonLoki.log.info({
|
||||||
|
message: message,
|
||||||
|
labels: {
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
issuer_name: issuerName,
|
||||||
|
card_number: card_number,
|
||||||
|
uid: uid,
|
||||||
|
trxID: trxID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let trxID = info.meta.res.body.data.trxID;
|
||||||
|
if (
|
||||||
|
statusCode != "00" &&
|
||||||
|
statusCode != "01" &&
|
||||||
|
statusCode != "02" &&
|
||||||
|
statusCode != "03" &&
|
||||||
|
statusCode != "04"
|
||||||
|
) {
|
||||||
|
winstonLoki.log.error({
|
||||||
|
message: message,
|
||||||
|
labels: {
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
issuer_name: issuerName,
|
||||||
|
trxID: trxID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
winstonLoki.log.info({
|
||||||
|
message: message,
|
||||||
|
labels: {
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
issuer_name: issuerName,
|
||||||
|
trxID: trxID,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
topuponline_metrics
|
||||||
|
.labels({
|
||||||
|
issuer_name: issuerName,
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
date: date,
|
||||||
|
month: month,
|
||||||
|
year: year,
|
||||||
|
})
|
||||||
|
.observe(info.meta.responseTime);
|
||||||
|
|
||||||
|
topuponline_metrics_response_time
|
||||||
|
.labels({
|
||||||
|
issuer_name: issuerName,
|
||||||
|
route: url,
|
||||||
|
status_code: statusCode,
|
||||||
|
date: date,
|
||||||
|
month: month,
|
||||||
|
year: year,
|
||||||
|
response_time: info.meta.responseTime,
|
||||||
|
})
|
||||||
|
.observe(info.meta.responseTime);
|
||||||
|
|
||||||
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
skip: (req, res) => {
|
||||||
|
return routes.indexOf(req.originalUrl) === -1;
|
||||||
|
},
|
||||||
responseWhitelist: [...expressWinston.responseWhitelist, "body"],
|
responseWhitelist: [...expressWinston.responseWhitelist, "body"],
|
||||||
requestWhitelist: [...expressWinston.requestWhitelist, "body", "id", "ip"],
|
requestWhitelist: [
|
||||||
|
...expressWinston.requestWhitelist,
|
||||||
|
"body",
|
||||||
|
"id",
|
||||||
|
"ip",
|
||||||
|
"partner_id_token",
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
request: expressWinston.logger({
|
request: expressWinston.logger({
|
||||||
transports: [
|
transports: [
|
||||||
@@ -68,7 +264,6 @@ const logger = {
|
|||||||
filename: "./expresswinstonlog/%DATE%.log",
|
filename: "./expresswinstonlog/%DATE%.log",
|
||||||
frequency: "24h",
|
frequency: "24h",
|
||||||
datePattern: "YYYY/MM/DD",
|
datePattern: "YYYY/MM/DD",
|
||||||
zippedArchive: true,
|
|
||||||
maxFiles: "1d",
|
maxFiles: "1d",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
@@ -89,4 +284,10 @@ const logger = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getPartner = async (id) => {
|
||||||
|
let result = await knex("t_m_partner").where("i_partner", "=", id).first();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = { logger, filename };
|
module.exports = { logger, filename };
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const loki = require("winston-loki");
|
|||||||
require("winston-daily-rotate-file");
|
require("winston-daily-rotate-file");
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
const { combine, timestamp, printf, colorize, align, json } = winston.format;
|
const { combine, timestamp, printf, colorize, align, json } = winston.format;
|
||||||
|
let lokiUrl = process.env.LOKI_URL;
|
||||||
|
|
||||||
const logLevels = {
|
const logLevels = {
|
||||||
fatal: 0,
|
fatal: 0,
|
||||||
@@ -41,7 +42,7 @@ if (
|
|||||||
defaultMeta: { service: "topuponline" },
|
defaultMeta: { service: "topuponline" },
|
||||||
transports: [
|
transports: [
|
||||||
new loki({
|
new loki({
|
||||||
host: "http://localhost:3100",
|
host: lokiUrl,
|
||||||
labels: { app: "topuponline" },
|
labels: { app: "topuponline" },
|
||||||
json: true,
|
json: true,
|
||||||
format: json(),
|
format: json(),
|
||||||
@@ -57,7 +58,7 @@ if (
|
|||||||
log = winston.createLogger({
|
log = winston.createLogger({
|
||||||
transports: [
|
transports: [
|
||||||
new loki({
|
new loki({
|
||||||
host: "http://localhost:3100",
|
host: lokiUrl,
|
||||||
labels: { app: "topuponline" },
|
labels: { app: "topuponline" },
|
||||||
handleExceptions: true,
|
handleExceptions: true,
|
||||||
handleRejections: true,
|
handleRejections: true,
|
||||||
|
|||||||
@@ -3,12 +3,39 @@ const client = require("prom-client");
|
|||||||
const topuponline_metrics = new client.Histogram({
|
const topuponline_metrics = new client.Histogram({
|
||||||
name: "topuponline",
|
name: "topuponline",
|
||||||
help: "this is the metric for getting request data based on code status",
|
help: "this is the metric for getting request data based on code status",
|
||||||
|
labelNames: ["route", "status_code", "issuer_name", "date", "month", "year"],
|
||||||
|
});
|
||||||
|
|
||||||
|
const topuponline_metrics_response_time = new client.Histogram({
|
||||||
|
name: "topuponline_response_time",
|
||||||
|
help: "this is the metric for getting request data based on response time",
|
||||||
labelNames: [
|
labelNames: [
|
||||||
"route",
|
"route",
|
||||||
"status_code",
|
"status_code",
|
||||||
"issuer_name",
|
"issuer_name",
|
||||||
"method",
|
"date",
|
||||||
|
"month",
|
||||||
|
"year",
|
||||||
|
"response_time",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = { topuponline_metrics };
|
const topuponline_metrics_load_balance = new client.Histogram({
|
||||||
|
name: "topuponline_load_balance",
|
||||||
|
help: "this is the metric for getting request data based on response time",
|
||||||
|
labelNames: [
|
||||||
|
"route",
|
||||||
|
"status_code",
|
||||||
|
"issuer_name",
|
||||||
|
"date",
|
||||||
|
"month",
|
||||||
|
"year",
|
||||||
|
"trxId",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
topuponline_metrics,
|
||||||
|
topuponline_metrics_response_time,
|
||||||
|
topuponline_metrics_load_balance,
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
const winstonLoki = require("../helpers/loki");
|
|
||||||
|
|
||||||
const lokiMiddleware = (req, res, next) => {
|
|
||||||
// return console.log(res)
|
|
||||||
res.on("finish", () => {
|
|
||||||
// return console.log(res.body.code)
|
|
||||||
// console.log(`request url = ${req.originalUrl}`);
|
|
||||||
// console.log(res.getHeader("x-response-time"));
|
|
||||||
// console.log(res.statusCode);
|
|
||||||
|
|
||||||
let url = req.originalUrl;
|
|
||||||
let responseTime = Math.round(parseInt(res.getHeader("x-response-time")));
|
|
||||||
let statusCode = res.body.code;
|
|
||||||
let method = req.method;
|
|
||||||
|
|
||||||
if (statusCode != "200" && statusCode != "204") {
|
|
||||||
winstonLoki.log.error({
|
|
||||||
message: "error",
|
|
||||||
labels: {
|
|
||||||
method: method,
|
|
||||||
url: url,
|
|
||||||
responseTime: responseTime,
|
|
||||||
status: statusCode,
|
|
||||||
// data: res.body.data,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
winstonLoki.log.info({
|
|
||||||
message: "success",
|
|
||||||
labels: {
|
|
||||||
method: method,
|
|
||||||
url: url,
|
|
||||||
responseTime: responseTime,
|
|
||||||
status: statusCode,
|
|
||||||
// data: res.body.data,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = lokiMiddleware;
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
const { topuponline_metrics } = require("../helpers/prometheusmetrics");
|
|
||||||
|
|
||||||
const prometheusMiddleware = (req, res, next) => {
|
|
||||||
res.on("finish", () => {
|
|
||||||
let url = req.originalUrl;
|
|
||||||
let responseTime = Math.round(parseInt(res.getHeader("x-response-time")));
|
|
||||||
let statusCode = res.body.code;
|
|
||||||
let method = req.method;
|
|
||||||
|
|
||||||
if (statusCode != "200" && statusCode != "204") {
|
|
||||||
topuponline_metrics
|
|
||||||
.labels({
|
|
||||||
issuer_name: "CMS",
|
|
||||||
method: method,
|
|
||||||
route: url,
|
|
||||||
status_code: statusCode,
|
|
||||||
})
|
|
||||||
.observe(responseTime);
|
|
||||||
} else {
|
|
||||||
topuponline_metrics
|
|
||||||
.labels({
|
|
||||||
issuer_name: "CMS",
|
|
||||||
method: method,
|
|
||||||
route: url,
|
|
||||||
status_code: statusCode,
|
|
||||||
})
|
|
||||||
.observe(responseTime);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = { prometheusMiddleware };
|
|
||||||
@@ -1,23 +1,33 @@
|
|||||||
require("dotenv").config();
|
require('dotenv').config();
|
||||||
const redis = require("redis");
|
const redis = require('redis');
|
||||||
|
const moment = require('moment');
|
||||||
|
moment.locale('id');
|
||||||
|
|
||||||
let redisClient;
|
let redisClient;
|
||||||
(async () => {
|
(async () => {
|
||||||
let redisUrl = process.env.REDIS_URL || "redis://127.0.0.1:6379";
|
let redisUrl = process.env.REDIS_URL || 'redis://127.0.0.1:6379';
|
||||||
let redisPass = process.env.REDIS_PASSWORD || "redispassword";
|
let redisPass = process.env.REDIS_PASSWORD || '';
|
||||||
|
|
||||||
redisClient = redis.createClient({
|
redisClient = redis.createClient({
|
||||||
url: redisUrl,
|
url: redisUrl,
|
||||||
password: redisPass,
|
password: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
redisClient.on("error", (error) => console.error(`Error : ${error}`));
|
redisClient.on('error', (error) =>
|
||||||
|
process.env.NODE_ENV.toUpperCase() != 'PRODUCTION'
|
||||||
|
? console.error(`Error : ${error}`)
|
||||||
|
: ''
|
||||||
|
);
|
||||||
|
|
||||||
redisClient.on("connect", () => console.log("Redis is Connected"));
|
redisClient.on('connect', () => console.log('Redis is Connected'));
|
||||||
|
|
||||||
redisClient.on("ready", () => console.log("Redis is Ready"));
|
redisClient.on('ready', () => console.log('Redis is Ready'));
|
||||||
|
|
||||||
redisClient.on("reconnecting", () => console.log("Redis is Reconnecting"));
|
redisClient.on('reconnecting', () =>
|
||||||
|
process.env.NODE_ENV.toUpperCase() != 'PRODUCTION'
|
||||||
|
? console.log('Redis is Reconnecting')
|
||||||
|
: ''
|
||||||
|
);
|
||||||
|
|
||||||
await redisClient.connect();
|
await redisClient.connect();
|
||||||
})();
|
})();
|
||||||
@@ -27,18 +37,18 @@ const redisMiddleware = async (req, res, next) => {
|
|||||||
if (!isRedisReady) {
|
if (!isRedisReady) {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
let getValue = await redisClient.get("cardproduct");
|
let getValue = await redisClient.get('cardproduct');
|
||||||
let parsedValue = JSON.parse(getValue);
|
let parsedValue = JSON.parse(getValue);
|
||||||
|
|
||||||
if (getValue) {
|
if (getValue) {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: "Success get from redis",
|
message: 'Success get from redis',
|
||||||
data: parsedValue,
|
data: parsedValue,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.on("finish", async () => {
|
res.on('finish', async () => {
|
||||||
await redisClient.set("cardproduct", JSON.stringify(res.body), {
|
await redisClient.set('cardproduct', JSON.stringify(res.body), {
|
||||||
EX: 10,
|
EX: 10,
|
||||||
NX: false,
|
NX: false,
|
||||||
});
|
});
|
||||||
@@ -48,4 +58,69 @@ const redisMiddleware = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = redisMiddleware;
|
const getReservationNumberSequence = async (req, res, next) => {
|
||||||
|
// set default reservation_number_sequence dari partner apapun is null
|
||||||
|
req.reservation_number_sequence = null;
|
||||||
|
|
||||||
|
// cek jika redis is connect
|
||||||
|
let isRedisReady = await redisClient.isReady;
|
||||||
|
// jika tidak connect
|
||||||
|
if (isRedisReady) {
|
||||||
|
// jika connect maka cari sequence dari reservation number sesuai partner yg merequest
|
||||||
|
// format value nya harusnya seperti ini = { date: '2023-01-01', sequence: 1 }
|
||||||
|
// data req.partner_id_token di dapat dari authenticateToken di jwt middleware
|
||||||
|
let getValue = await redisClient.GET(
|
||||||
|
'reservation_number_sequence_' + req.partner_id_token
|
||||||
|
);
|
||||||
|
|
||||||
|
if (getValue) {
|
||||||
|
// parsing data menjadi json format
|
||||||
|
let parsedValue = JSON.parse(getValue);
|
||||||
|
|
||||||
|
// cek apakah tanggal sequence yang di redis sama dengan hari ini atau bukan
|
||||||
|
if (parsedValue.date == moment().format('YYYY-MM-DD')) {
|
||||||
|
// jika tanggal nya sama dengan hari ini maka ambil sequence untuk reservation number yang di generate dari redis
|
||||||
|
req.reservation_number_sequence = parseInt(parsedValue.sequence);
|
||||||
|
|
||||||
|
// langsung update sequence walaupun transaksi insert nya belum selesai
|
||||||
|
// impact menggunakan redis, untuk nomor sequence bisa saja ada yg loncat karena bisa saja ada transaksi insert reservation yang gagal
|
||||||
|
let setValue = {
|
||||||
|
date: moment().format('YYYY-MM-DD'),
|
||||||
|
sequence: parseInt(parsedValue.sequence) + 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
await redisClient.SET(
|
||||||
|
`reservation_number_sequence_${req.partner_id_token}`,
|
||||||
|
JSON.stringify(setValue)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
|
||||||
|
const setReservationNumberSequence = async (partner_id, sequence) => {
|
||||||
|
// cek jika redis is connect
|
||||||
|
let isRedisReady = await redisClient.isReady;
|
||||||
|
// jika tidak connect
|
||||||
|
if (isRedisReady) {
|
||||||
|
// jika connect maka cari sequence dari reservation number sesuai partner yg merequest
|
||||||
|
// format value nya harusnya seperti ini = { date: '2023-01-01', sequence: 1 }
|
||||||
|
|
||||||
|
let setValue = {
|
||||||
|
date: moment().format('YYYY-MM-DD'),
|
||||||
|
sequence: parseInt(sequence),
|
||||||
|
};
|
||||||
|
|
||||||
|
await redisClient.SET(
|
||||||
|
`reservation_number_sequence_${partner_id}`,
|
||||||
|
JSON.stringify(setValue)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
redisMiddleware,
|
||||||
|
getReservationNumberSequence,
|
||||||
|
setReservationNumberSequence,
|
||||||
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -386,7 +386,7 @@ const insertLoadingBalance = async (
|
|||||||
return result.rowCount;
|
return result.rowCount;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error.message);
|
// console.log(error.message);
|
||||||
return error.message;
|
return error.message;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -457,7 +457,7 @@ const updateLoadingBalance = async (
|
|||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error.message);
|
// console.log(error.message);
|
||||||
return error.message;
|
return error.message;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -548,7 +548,7 @@ const insertLoadingBalanceHistoryOnly = async (
|
|||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error.message);
|
// console.log(error.message);
|
||||||
return error.message;
|
return error.message;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -665,7 +665,7 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
return result.rowCount;
|
return result.rowCount;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error.message);
|
// console.log(error.message);
|
||||||
return error.message;
|
return error.message;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -745,7 +745,7 @@ const updateFlag = async (now, cardNumber, uid, balance, flag) => {
|
|||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error.message);
|
// console.log(error.message);
|
||||||
return error.message;
|
return error.message;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -793,14 +793,14 @@ const getReservationPendingWithoutFraud = (
|
|||||||
reservationNumber = []
|
reservationNumber = []
|
||||||
) => {
|
) => {
|
||||||
if (reservationNumber.length > 0) {
|
if (reservationNumber.length > 0) {
|
||||||
let rsv = ``;
|
let rsv = '';
|
||||||
if (reservationNumber.length > 0) {
|
if (reservationNumber.length > 0) {
|
||||||
for (let index = 0; index < reservationNumber.length; index++) {
|
for (let index = 0; index < reservationNumber.length; index++) {
|
||||||
if (index > 0) {
|
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
|
// INSERT FRAUD TRANSACTION
|
||||||
const insertFraudTransaction = (reservationNumber) => {
|
const insertFraudTransaction = (reservationNumber) => {
|
||||||
let rsv = ``;
|
let rsv = '';
|
||||||
if (reservationNumber.length > 0) {
|
if (reservationNumber.length > 0) {
|
||||||
for (let index = 0; index < reservationNumber.length; index++) {
|
for (let index = 0; index < reservationNumber.length; index++) {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
rsv = rsv + `,`;
|
rsv = rsv + ',';
|
||||||
}
|
}
|
||||||
|
|
||||||
rsv = `'` + rsv + reservationNumber[index] + `'`;
|
rsv = rsv + "'" + reservationNumber[index] + "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1019,15 +1019,25 @@ const updateReservationAndInsertLoadingBalance = async (
|
|||||||
.catch(trx.rollback);
|
.catch(trx.rollback);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log(result);
|
// console.log(result);
|
||||||
return result.rowCount;
|
return result.rowCount;
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error.message);
|
// console.log(error.message);
|
||||||
return 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 = {
|
module.exports = {
|
||||||
checkCardNumber,
|
checkCardNumber,
|
||||||
getPartner,
|
getPartner,
|
||||||
@@ -1072,4 +1082,5 @@ module.exports = {
|
|||||||
getReservationPendingWithFlagV2,
|
getReservationPendingWithFlagV2,
|
||||||
createDetailLoadBalanceFromReservation,
|
createDetailLoadBalanceFromReservation,
|
||||||
updateReservationAndInsertLoadingBalance,
|
updateReservationAndInsertLoadingBalance,
|
||||||
|
getTopupPartialStatus,
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,23 @@
|
|||||||
const knex = require("../../../infrastructure/database/knex");
|
const knex = require('../../../infrastructure/database/knex');
|
||||||
|
|
||||||
// CHECK CARD NUMBER
|
// CHECK CARD NUMBER
|
||||||
const checkCardNumber = (cardNumber) => {
|
const checkCardNumber = (cardNumber) => {
|
||||||
let result = knex("t_m_card_product")
|
let result = knex('t_m_card_product')
|
||||||
.where("c_card_number", cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.where("c_status", "!=", "X")
|
.where('c_status', '!=', 'X')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET RESERVATION
|
// GET RESERVATION
|
||||||
const getReservationNumberSequence = (data, date) => {
|
const getReservationNumberSequence = (data, date) => {
|
||||||
console.log('AKU DIPANGGIL');
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
.select('i_reservation_no_seq')
|
||||||
.select("i_reservation_no_seq")
|
.orderBy('i_reservation_no_seq', 'desc')
|
||||||
.orderBy("i_reservation_no_seq", "desc")
|
.whereNotNull('i_reservation_no_seq')
|
||||||
.whereNotNull("i_reservation_no_seq")
|
.where('i_partner', data.i_partner)
|
||||||
.where("i_partner", data.i_partner)
|
.where('i_merchant', data.i_merchant)
|
||||||
.where("i_merchant", data.i_merchant)
|
.whereRaw('??::date = ?', ['d_reservation', date])
|
||||||
.whereRaw("??::date = ?", ["d_reservation", date])
|
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@@ -27,236 +26,310 @@ const getReservationNumberSequence = (data, date) => {
|
|||||||
const getPartner = (mid, tid) => {
|
const getPartner = (mid, tid) => {
|
||||||
let result = knex
|
let result = knex
|
||||||
.select(
|
.select(
|
||||||
"t_m_partner.i_partner",
|
't_m_partner.i_partner',
|
||||||
"t_m_partner.c_code as partner_code",
|
't_m_partner.c_code as partner_code',
|
||||||
"t_m_partner.c_name as partner_name",
|
't_m_partner.c_name as partner_name',
|
||||||
"t_m_merchant.i_merchant",
|
't_m_merchant.i_merchant',
|
||||||
"t_m_merchant.c_code as merchant_code",
|
't_m_merchant.c_code as merchant_code',
|
||||||
"t_m_merchant.c_name as merchant_name",
|
't_m_merchant.c_name as merchant_name',
|
||||||
"t_m_merchant.e_mid as mid",
|
't_m_merchant.e_mid as mid',
|
||||||
"t_m_terminal.i_terminal",
|
't_m_terminal.i_terminal',
|
||||||
"t_m_terminal.c_code as terminal_code",
|
't_m_terminal.c_code as terminal_code',
|
||||||
"t_m_terminal.c_name as terminal_name",
|
't_m_terminal.c_name as terminal_name',
|
||||||
"t_m_terminal.e_tid as tid"
|
't_m_terminal.e_tid as tid'
|
||||||
)
|
)
|
||||||
.from("t_m_terminal")
|
.from('t_m_terminal')
|
||||||
.leftJoin(
|
.leftJoin(
|
||||||
"t_m_merchant",
|
't_m_merchant',
|
||||||
"t_m_terminal.i_merchant",
|
't_m_terminal.i_merchant',
|
||||||
"t_m_merchant.i_merchant"
|
't_m_merchant.i_merchant'
|
||||||
)
|
)
|
||||||
.leftJoin("t_m_partner", "t_m_merchant.i_partner", "t_m_partner.i_partner")
|
.leftJoin('t_m_partner', 't_m_merchant.i_partner', 't_m_partner.i_partner')
|
||||||
.where("t_m_merchant.e_mid", mid)
|
.where('t_m_merchant.e_mid', mid)
|
||||||
.where("t_m_terminal.e_tid", tid)
|
.where('t_m_terminal.e_tid', tid)
|
||||||
.where("t_m_terminal.c_status", "A")
|
.where('t_m_terminal.c_status', 'A')
|
||||||
.where("t_m_merchant.c_status", "A")
|
.where('t_m_merchant.c_status', 'A')
|
||||||
.where("t_m_partner.c_status", "A")
|
.where('t_m_partner.c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET ISSUER FEE
|
// GET ISSUER FEE
|
||||||
const getIssuer = (id, time) => {
|
const getIssuer = (id, time) => {
|
||||||
let result = knex("t_c_partner_fee")
|
let result = knex('t_c_partner_fee')
|
||||||
.select("i_issuer_fee_perc", "i_channel_fee_perc", "i_amount")
|
.select('i_issuer_fee_perc', 'i_channel_fee_perc', 'i_amount')
|
||||||
.where("i_partner", id)
|
.where('i_partner', id)
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.where("d_valid", "<=", time)
|
.where('d_valid', '<=', time)
|
||||||
.orderBy("d_valid", "desc")
|
.orderBy('d_valid', 'desc')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET RESERVATION EXPIRATION DATE FROM GLOBAL PARAMETER
|
// GET RESERVATION EXPIRATION DATE FROM GLOBAL PARAMETER
|
||||||
const getReservationExpirationDateValue = () => {
|
const getReservationExpirationDateValue = () => {
|
||||||
let result = knex("t_m_global_parameter")
|
let result = knex('t_m_global_parameter')
|
||||||
.select("c_value")
|
.select('c_value')
|
||||||
.where("c_code", "HSM_EXP_RSV_VAL")
|
.where('c_code', 'HSM_EXP_RSV_VAL')
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET RESERVATION EXPIRATION DATE MEASURE FROM GLOBAL PARAMETER
|
// GET RESERVATION EXPIRATION DATE MEASURE FROM GLOBAL PARAMETER
|
||||||
const getReservationExpirationDateMeasure = () => {
|
const getReservationExpirationDateMeasure = () => {
|
||||||
let result = knex("t_m_global_parameter")
|
let result = knex('t_m_global_parameter')
|
||||||
.select("c_value")
|
.select('c_value')
|
||||||
.where("c_code", "HSM_EXP_RSV_MEA")
|
.where('c_code', 'HSM_EXP_RSV_MEA')
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET CHECKING CARD PRODUCT FROM GLOBAL PARAMETER
|
// GET CHECKING CARD PRODUCT FROM GLOBAL PARAMETER
|
||||||
const getCheckByCardProductStatusValue = () => {
|
const getCheckByCardProductStatusValue = () => {
|
||||||
let result = knex("t_m_global_parameter")
|
let result = knex('t_m_global_parameter')
|
||||||
.select("c_value")
|
.select('c_value')
|
||||||
.where("c_code", "HSM_CHECK_BY_CARD_PRODUCT_STAT")
|
.where('c_code', 'HSM_CHECK_BY_CARD_PRODUCT_STAT')
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET BI REGULATION STATUS FROM GLOBAL PARAMETER
|
// GET BI REGULATION STATUS FROM GLOBAL PARAMETER
|
||||||
const getBIRegulationStatus = () => {
|
const getBIRegulationStatus = () => {
|
||||||
let result = knex("t_m_global_parameter")
|
let result = knex('t_m_global_parameter')
|
||||||
.select("c_value")
|
.select('c_value')
|
||||||
.where("c_code", "HSM_BI_REGULATION_STAT")
|
.where('c_code', 'HSM_BI_REGULATION_STAT')
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET MAX AMOUNT ON THE CARD FROM GLOBAL PARAMETER
|
// GET MAX AMOUNT ON THE CARD FROM GLOBAL PARAMETER
|
||||||
const getMaxAmountOnTheCard = () => {
|
const getMaxAmountOnTheCard = () => {
|
||||||
let result = knex("t_m_global_parameter")
|
let result = knex('t_m_global_parameter')
|
||||||
.select("c_value")
|
.select('c_value')
|
||||||
.where("c_code", "HSM_BI_MAX_AMOUNT_ON_THE_CARD")
|
.where('c_code', 'HSM_BI_MAX_AMOUNT_ON_THE_CARD')
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET MAX TOPUP PER MONTH FROM GLOBAL PARAMETER
|
// GET MAX TOPUP PER MONTH FROM GLOBAL PARAMETER
|
||||||
const getMaxTopupPerMonth = () => {
|
const getMaxTopupPerMonth = () => {
|
||||||
let result = knex("t_m_global_parameter")
|
let result = knex('t_m_global_parameter')
|
||||||
.select("c_value")
|
.select('c_value')
|
||||||
.where("c_code", "HSM_BI_MAX_TOPUP_PER_MONTH")
|
.where('c_code', 'HSM_BI_MAX_TOPUP_PER_MONTH')
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET MAX RESERVATION FROM GLOBAL PARAMETER
|
// GET MAX RESERVATION FROM GLOBAL PARAMETER
|
||||||
const getMaxReservation = () => {
|
const getMaxReservation = () => {
|
||||||
let result = knex("t_m_global_parameter")
|
let result = knex('t_m_global_parameter')
|
||||||
.select("c_value")
|
.select('c_value')
|
||||||
.where("c_code", "HSM_MAX_RSV_PEN")
|
.where('c_code', 'HSM_MAX_RSV_PEN')
|
||||||
.where("c_status", "A")
|
.where('c_status', 'A')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// INQUIRY BY RESERVATION NUMBER
|
// INQUIRY BY RESERVATION NUMBER
|
||||||
let inquiryByReservationNumber = (reservationNumber) => {
|
let inquiryByReservationNumber = (reservationNumber, show_complete_data) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance');
|
||||||
.select(
|
if (show_complete_data === true) {
|
||||||
"c_reservation_no as reservation_number",
|
result.select(
|
||||||
"d_reservation as reservation_date",
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
"c_ref_no as ref_no",
|
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||||
"c_partner_name as partner_name",
|
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||||
"c_merchant_name as merchant_name",
|
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||||
"c_terminal_name as terminal_name",
|
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||||
"c_card_number as card_number",
|
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||||
"i_reservation_amount as reservation_amount",
|
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||||
"i_issuer_fee as issuer_fee",
|
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||||
"i_channel_fee as channel_fee",
|
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||||
"c_payment_recon_no as payment_recon_no",
|
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||||
"d_payment_recon as recon_date",
|
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||||
"c_status as status_code",
|
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||||
"c_status_name as description"
|
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||||
)
|
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||||
.where("c_reservation_no", reservationNumber)
|
'trx.t_d_reservation_balance.c_payment_recon_no as payment_recon_no',
|
||||||
|
'trx.t_d_reservation_balance.d_payment_recon as recon_date',
|
||||||
|
'trx.t_d_reservation_balance.c_status as status_code',
|
||||||
|
'trx.t_d_reservation_balance.c_status_name as description'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
result.select(
|
||||||
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
|
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||||
|
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||||
|
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||||
|
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||||
|
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||||
|
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||||
|
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||||
|
'trx.t_d_reservation_balance.c_status as status_code',
|
||||||
|
'trx.t_d_reservation_balance.c_status_name as description'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.leftJoin('trx.t_d_load_balance', function () {
|
||||||
|
this.on(
|
||||||
|
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||||
|
'=',
|
||||||
|
'trx.t_d_load_balance.c_load_balance_no'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
result
|
||||||
|
.where('trx.t_d_reservation_balance.c_reservation_no', reservationNumber)
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// INQUIRY LIST RESERVATION
|
// INQUIRY LIST RESERVATION
|
||||||
let inquiryListReservation = (partnerID, startDate, endDate) => {
|
let inquiryListReservation = (partnerID, startDate, endDate) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance');
|
||||||
.select(
|
result.select(
|
||||||
"c_reservation_no as reservation_number",
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
"d_reservation as reservation_date",
|
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||||
"c_ref_no as ref_no",
|
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||||
"c_partner_name as partner_name",
|
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||||
"c_merchant_name as merchant_name",
|
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||||
"c_terminal_name as terminal_name",
|
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||||
"c_card_number as card_number",
|
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||||
"i_reservation_amount as reservation_amount",
|
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||||
"i_issuer_fee as issuer_fee",
|
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||||
"i_channel_fee as channel_fee",
|
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||||
"c_payment_recon_no as payment_recon_no",
|
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||||
"d_payment_recon as recon_date",
|
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||||
"c_status as status_code",
|
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||||
"c_status_name as description"
|
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||||
)
|
'trx.t_d_reservation_balance.c_payment_recon_no as payment_recon_no',
|
||||||
.where("i_partner", partnerID);
|
'trx.t_d_reservation_balance.d_payment_recon as recon_date',
|
||||||
|
'trx.t_d_reservation_balance.c_status as status_code',
|
||||||
|
'trx.t_d_reservation_balance.c_status_name as description'
|
||||||
|
);
|
||||||
|
|
||||||
if (startDate && endDate) {
|
result.leftJoin('trx.t_d_load_balance', function () {
|
||||||
result.whereRaw("??::date >= ?", ["d_reservation", startDate]);
|
this.on(
|
||||||
result.whereRaw("??::date <= ?", ["d_reservation", endDate]);
|
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||||
}
|
'=',
|
||||||
|
'trx.t_d_load_balance.c_load_balance_no'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
result.where('trx.t_d_reservation_balance.i_partner', partnerID);
|
||||||
|
|
||||||
|
if (startDate && endDate) {
|
||||||
|
result.whereRaw('??::date >= ?', [
|
||||||
|
'trx.t_d_reservation_balance.d_reservation',
|
||||||
|
startDate,
|
||||||
|
]);
|
||||||
|
result.whereRaw('??::date <= ?', [
|
||||||
|
'trx.t_d_reservation_balance.d_reservation',
|
||||||
|
endDate,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// INQUIRY BY CARD NUMBER
|
// INQUIRY BY CARD NUMBER
|
||||||
let inquiryByCardNumber = (cardNumber, startDate, endDate) => {
|
let inquiryByCardNumber = (cardNumber, startDate, endDate) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.select(
|
.select(
|
||||||
"c_reservation_no as reservation_number",
|
'c_reservation_no as reservation_number',
|
||||||
"d_reservation as reservation_date",
|
'd_reservation as reservation_date',
|
||||||
"c_ref_no as ref_no",
|
'c_ref_no as ref_no',
|
||||||
"c_partner_name as partner_name",
|
'c_partner_name as partner_name',
|
||||||
"c_merchant_name as merchant_name",
|
'c_merchant_name as merchant_name',
|
||||||
"c_terminal_name as terminal_name",
|
'c_terminal_name as terminal_name',
|
||||||
"c_card_number as card_number",
|
'c_card_number as card_number',
|
||||||
"i_reservation_amount as reservation_amount",
|
'i_reservation_amount as amount',
|
||||||
"i_issuer_fee as issuer_fee",
|
'i_issuer_fee as issuer_fee',
|
||||||
"i_channel_fee as channel_fee",
|
'i_channel_fee as channel_fee',
|
||||||
"c_status as status_code",
|
'c_status as status_code',
|
||||||
"c_status_name as description"
|
'c_status_name as description'
|
||||||
)
|
)
|
||||||
.where("c_card_number", cardNumber);
|
.where('c_card_number', cardNumber);
|
||||||
|
|
||||||
if (startDate && endDate) {
|
if (startDate && endDate) {
|
||||||
result.whereRaw("??::date >= ?", ["d_reservation", startDate]);
|
result.whereRaw('??::date >= ?', ['d_reservation', startDate]);
|
||||||
result.whereRaw("??::date <= ?", ["d_reservation", endDate]);
|
result.whereRaw('??::date <= ?', ['d_reservation', endDate]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET RESERVATION PENDING
|
// GET RESERVATION PENDING
|
||||||
const getReservationPending = (cardNumber, time) => {
|
const getReservationPending = (cardNumber, time) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.count("* as total_reservation")
|
.count('* as total_reservation')
|
||||||
.sum("i_reservation_amount as total_nominal_reservation")
|
.sum('i_reservation_amount as total_nominal_reservation')
|
||||||
.where("c_card_number", cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.where("c_status", "P")
|
.where('c_status', 'P')
|
||||||
|
.whereRaw(
|
||||||
|
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
||||||
|
)
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getReservationPendingV2 = (cardNumber, time) => {
|
||||||
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
|
// .sum("i_reservation_amount as total_reservation_amount")
|
||||||
|
// .count("* as total_reservation")
|
||||||
|
.select(
|
||||||
|
'i_reservation_amount',
|
||||||
|
'c_reservation_no',
|
||||||
|
'c_partner_name',
|
||||||
|
'c_flag',
|
||||||
|
'd_reservation',
|
||||||
|
'c_ref_no',
|
||||||
|
'c_card_number',
|
||||||
|
'c_status'
|
||||||
|
)
|
||||||
|
.where('c_card_number', cardNumber)
|
||||||
|
.where('c_status', 'P')
|
||||||
|
.whereRaw(
|
||||||
|
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
||||||
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
// GET RESERVATION WITH FLAG
|
// GET RESERVATION WITH FLAG
|
||||||
const getReservationWithFlag = (cardNumber, time) => {
|
const getReservationWithFlag = (cardNumber, time) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.count("* as total_reservation")
|
.count('* as total_reservation')
|
||||||
.where("c_card_number", cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.whereIn("c_status", ["P", "I"])
|
.whereIn('c_status', ['P', 'I'])
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.whereNotNull("c_flag")
|
.whereNotNull('c_flag')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// INSERT RESERVATION
|
// INSERT RESERVATION
|
||||||
const insertReservation = (data) => {
|
const insertReservation = (data) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.insert(data)
|
.insert(data)
|
||||||
.onConflict("c_ref_no")
|
.onConflict('c_ref_no')
|
||||||
.ignore();
|
.ignore();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET LAST BALANCE FROM CARD HISTORY
|
// GET LAST BALANCE FROM CARD HISTORY
|
||||||
const getLastBalanceFromCardHistory = (cardNumber) => {
|
const getLastBalanceFromCardHistory = (cardNumber) => {
|
||||||
let result = knex("log.t_log_card")
|
let result = knex('log.t_log_card')
|
||||||
.select("m_balance_after")
|
.select('m_balance_after')
|
||||||
.where("c_card_number", cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.where("c_status", "S")
|
.where('c_status', 'S')
|
||||||
.where("m_balance_after", ">", 0)
|
.where('m_balance_after', '>', 0)
|
||||||
.orderBy("d_log", "desc")
|
.orderBy('d_log', 'desc')
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
@@ -268,66 +341,194 @@ const getAccumulationBalanceInThisMonthFromCardHistory = (
|
|||||||
year,
|
year,
|
||||||
month
|
month
|
||||||
) => {
|
) => {
|
||||||
let result = knex("log.t_log_card")
|
let result = knex('log.t_log_card')
|
||||||
.sum("m_amount as accumulation_balance")
|
.sum('m_amount as accumulation_balance')
|
||||||
.where("c_card_number", cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.where("c_status", "S")
|
.where('c_status', 'S')
|
||||||
.where("m_balance_after", ">", 0)
|
.where('m_balance_after', '>', 0)
|
||||||
.whereRaw("DATE_PART('YEAR', ??) = ?", ["d_log", year])
|
.whereRaw("DATE_PART('YEAR', ??) = ?", ['d_log', year])
|
||||||
.whereRaw("DATE_PART('MONTH', ??) = ?", ["d_log", month])
|
.whereRaw("DATE_PART('MONTH', ??) = ?", ['d_log', month])
|
||||||
.whereIn("i_log_name", [21])
|
.whereIn('i_log_name', [21])
|
||||||
.groupBy("c_card_number")
|
.groupBy('c_card_number')
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CREATE LOG FOR CARD HISTORY
|
// CREATE LOG FOR CARD HISTORY
|
||||||
const createReserveBalanceLog = (data) => {
|
const createReserveBalanceLog = (data) => {
|
||||||
let result = knex("log.t_log_card").insert(data);
|
let result = knex('log.t_log_card').insert(data);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET RESERVATION PENDING AND IN PROGRESS
|
// GET RESERVATION PENDING AND IN PROGRESS
|
||||||
const getReservationWithPendingAndInProgressStatus = (cardNumber) => {
|
const getReservationWithPendingAndInProgressStatus = (cardNumber) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.count("* as total_reservation_pending")
|
.count('* as total_reservation_pending')
|
||||||
.where("c_card_number", cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.whereIn("c_status", ["P", "I"])
|
.whereIn('c_status', ['P', 'I'])
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// GET RESERVATION PENDING AND NOT YET PAYMENT RECON
|
// GET RESERVATION PENDING AND NOT YET PAYMENT RECON
|
||||||
const getReservationCanBeCanceled = (reservation_number) => {
|
const getReservationCanBeCanceled = (reservation_number) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.where("c_reservation_no", reservation_number)
|
.where('c_reservation_no', reservation_number)
|
||||||
|
.first();
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
// GET RESERVATION PENDING AND NOT YET PAYMENT RECON
|
||||||
|
const getReservationCanBeCanceledByRefno = (ref_no) => {
|
||||||
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
|
.where('c_ref_no', ref_no)
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const insertReservationNumber = (reservationNumber) => {
|
const insertReservationNumber = (reservationNumber) => {
|
||||||
let result = knex("trx.t_d_reservation_no_validate")
|
let result = knex('trx.t_d_reservation_no_validate')
|
||||||
.insert({
|
.insert({
|
||||||
c_reservation_no: reservationNumber,
|
c_reservation_no: reservationNumber,
|
||||||
})
|
})
|
||||||
.onConflict("c_reservation_no")
|
.onConflict('c_reservation_no')
|
||||||
.ignore();
|
.ignore();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const cancelReservation = (data, reservationNumber) => {
|
const cancelReservation = (data, reservationNumber) => {
|
||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.update(data)
|
.update(data)
|
||||||
.where("c_reservation_no", reservationNumber);
|
.where('c_reservation_no', reservationNumber);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
const deleteReservationNumberValidate = (reservationNumber) => {
|
const deleteReservationNumberValidate = (reservationNumber) => {
|
||||||
let result = knex("trx.t_d_reservation_no_validate")
|
let result = knex('trx.t_d_reservation_no_validate')
|
||||||
.where("c_reservation_no", reservationNumber)
|
.where('c_reservation_no', reservationNumber)
|
||||||
.del();
|
.del();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// INQUIRY BY REF NUMBER
|
||||||
|
let inquiryListByRefNumber = (refNumber, show_complete_data) => {
|
||||||
|
let result = knex('trx.t_d_reservation_balance');
|
||||||
|
if (show_complete_data === true) {
|
||||||
|
result.select(
|
||||||
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
|
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||||
|
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||||
|
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||||
|
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||||
|
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||||
|
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||||
|
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||||
|
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||||
|
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||||
|
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||||
|
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||||
|
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||||
|
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||||
|
'trx.t_d_reservation_balance.c_status as status_code',
|
||||||
|
'trx.t_d_reservation_balance.c_status_name as description'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
result.select(
|
||||||
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
|
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||||
|
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||||
|
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||||
|
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||||
|
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||||
|
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||||
|
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||||
|
'trx.t_d_reservation_balance.c_status as status_code',
|
||||||
|
'trx.t_d_reservation_balance.c_status_name as description'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.leftJoin('trx.t_d_load_balance', function () {
|
||||||
|
this.on(
|
||||||
|
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||||
|
'=',
|
||||||
|
'trx.t_d_load_balance.c_load_balance_no'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
result.where('trx.t_d_reservation_balance.c_ref_no', refNumber).first();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ================================================================= INQUIRY LOAD BALANCE =================================================================
|
||||||
|
// *Created By: Teddy Setiawan*
|
||||||
|
// *Description:*
|
||||||
|
//
|
||||||
|
|
||||||
|
// INQUIRY BY LOAD BALANCE NUMBER
|
||||||
|
const inquiryListByLoadNumber = (load_balance_number, show_complete_data) => {
|
||||||
|
let result = knex('trx.t_d_reservation_balance');
|
||||||
|
|
||||||
|
if (show_complete_data === true) {
|
||||||
|
result.select(
|
||||||
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
|
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||||
|
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||||
|
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||||
|
'trx.t_d_reservation_balance.c_merchant_name as merchant_name_reservation',
|
||||||
|
'trx.t_d_reservation_balance.c_terminal_name as terminal_name_reservation',
|
||||||
|
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||||
|
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||||
|
'trx.t_d_load_balance.c_merchant_name as merchant_name_load',
|
||||||
|
'trx.t_d_load_balance.c_terminal_name as terminal_name_load',
|
||||||
|
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||||
|
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||||
|
'trx.t_d_reservation_balance.i_issuer_fee as issuer_fee',
|
||||||
|
'trx.t_d_reservation_balance.i_channel_fee as channel_fee',
|
||||||
|
'trx.t_d_reservation_balance.c_payment_recon_no as payment_recon_no',
|
||||||
|
'trx.t_d_reservation_balance.d_payment_recon as recon_date',
|
||||||
|
'trx.t_d_reservation_balance.c_status as status_code',
|
||||||
|
'trx.t_d_reservation_balance.c_status_name as description'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
result.select(
|
||||||
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
|
'trx.t_d_reservation_balance.d_reservation as reservation_date',
|
||||||
|
'trx.t_d_reservation_balance.c_ref_no as ref_no',
|
||||||
|
'trx.t_d_reservation_balance.c_partner_name as partner_name_reservation',
|
||||||
|
'trx.t_d_load_balance.d_load_balance as load_date',
|
||||||
|
'trx.t_d_load_balance.c_partner_name as partner_name_load',
|
||||||
|
'trx.t_d_reservation_balance.c_card_number as card_number',
|
||||||
|
'trx.t_d_reservation_balance.i_reservation_amount as amount',
|
||||||
|
'trx.t_d_reservation_balance.c_status as status_code',
|
||||||
|
'trx.t_d_reservation_balance.c_status_name as description'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
.leftJoin('trx.t_d_load_balance', function () {
|
||||||
|
this.on(
|
||||||
|
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||||
|
'=',
|
||||||
|
'trx.t_d_load_balance.c_load_balance_no'
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.where(
|
||||||
|
'trx.t_d_reservation_balance.c_load_balance_no',
|
||||||
|
load_balance_number
|
||||||
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getGlobalParameter = () => {
|
||||||
|
let result = knex('t_m_global_parameter')
|
||||||
|
.select('c_value')
|
||||||
|
.where('c_code', '=', 'HSM_CANCEL_RESERVATION_LEVEL')
|
||||||
|
.first();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
checkCardNumber,
|
checkCardNumber,
|
||||||
getReservationNumberSequence,
|
getReservationNumberSequence,
|
||||||
@@ -344,6 +545,7 @@ module.exports = {
|
|||||||
inquiryListReservation,
|
inquiryListReservation,
|
||||||
inquiryByCardNumber,
|
inquiryByCardNumber,
|
||||||
getReservationPending,
|
getReservationPending,
|
||||||
|
getReservationPendingV2,
|
||||||
getReservationWithFlag,
|
getReservationWithFlag,
|
||||||
insertReservation,
|
insertReservation,
|
||||||
getLastBalanceFromCardHistory,
|
getLastBalanceFromCardHistory,
|
||||||
@@ -351,7 +553,11 @@ module.exports = {
|
|||||||
createReserveBalanceLog,
|
createReserveBalanceLog,
|
||||||
getReservationWithPendingAndInProgressStatus,
|
getReservationWithPendingAndInProgressStatus,
|
||||||
getReservationCanBeCanceled,
|
getReservationCanBeCanceled,
|
||||||
|
getReservationCanBeCanceledByRefno,
|
||||||
insertReservationNumber,
|
insertReservationNumber,
|
||||||
cancelReservation,
|
cancelReservation,
|
||||||
deleteReservationNumberValidate,
|
deleteReservationNumberValidate,
|
||||||
|
inquiryListByRefNumber,
|
||||||
|
getGlobalParameter,
|
||||||
|
inquiryListByLoadNumber,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,26 +1,13 @@
|
|||||||
const express = require("express");
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const auth = require("../middlewares/jwt.middleware");
|
const auth = require('../middlewares/jwt.middleware');
|
||||||
const controller = require("../modules/loadbalance/loadbalance.controller");
|
const controller = require('../modules/loadbalance/loadbalance.controller');
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/loadbalance/request",
|
'/loadbalance/request',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate("loadingBalanceRequest"),
|
controller.validate('loadingBalanceRequest'),
|
||||||
controller.loadingBalanceRequest
|
controller.loadingBalanceRequest
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
|
||||||
"/loadbalance",
|
|
||||||
auth.authenticateToken,
|
|
||||||
controller.validate("loadingBalance"),
|
|
||||||
controller.loadingBalance
|
|
||||||
);
|
|
||||||
|
|
||||||
router.post(
|
|
||||||
"/loadbalance/inquiry",
|
|
||||||
auth.authenticateToken,
|
|
||||||
controller.inquiryLoadingBalance
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const auth = require('../middlewares/jwt.middleware');
|
const auth = require('../middlewares/jwt.middleware');
|
||||||
|
const {
|
||||||
|
getReservationNumberSequence,
|
||||||
|
} = require('../middlewares/redis.middleware');
|
||||||
const controller = require('../modules/reservebalance/reservebalance.controller');
|
const controller = require('../modules/reservebalance/reservebalance.controller');
|
||||||
|
|
||||||
// ================================================================= ROUTE V1 =================================================================
|
// ================================================================= ROUTE V1 =================================================================
|
||||||
@@ -21,6 +24,7 @@ router.post(
|
|||||||
router.post(
|
router.post(
|
||||||
'/reservation',
|
'/reservation',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
|
getReservationNumberSequence,
|
||||||
controller.validate('reservation'),
|
controller.validate('reservation'),
|
||||||
controller.reservation
|
controller.reservation
|
||||||
);
|
);
|
||||||
@@ -68,8 +72,30 @@ router.post(
|
|||||||
router.post(
|
router.post(
|
||||||
'/reservation/v2',
|
'/reservation/v2',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
|
getReservationNumberSequence,
|
||||||
controller.validate('reservationV2'),
|
controller.validate('reservationV2'),
|
||||||
controller.reservationV2
|
controller.reservationV2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/reservation/cancel/validate/v2',
|
||||||
|
auth.authenticateToken,
|
||||||
|
controller.validate('cancelReservationValidateV2'),
|
||||||
|
controller.cancelReservationValidateV2
|
||||||
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/reservation/cancel/v2',
|
||||||
|
auth.authenticateToken,
|
||||||
|
controller.validate('cancelReservationV2'),
|
||||||
|
controller.cancelReservationV2
|
||||||
|
);
|
||||||
|
|
||||||
|
// router.post(
|
||||||
|
// '/reservation/cancel/v2.1',
|
||||||
|
// auth.authenticateToken,
|
||||||
|
// controller.validate('cancelReservation'),
|
||||||
|
// controller.cancelReservationV2_1
|
||||||
|
// );
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,57 +1,112 @@
|
|||||||
# environment
|
# ================================= ENVIRONMENT =================================
|
||||||
#NODE_ENV=production
|
#NODE_ENV=production
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
#NODE_ENV=testing
|
#NODE_ENV=testing
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
|
||||||
# database
|
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
||||||
DB_URL=postgresql://postgres:postgres@localhost:5432/CMS_DEV
|
# SERVER_FOR=development
|
||||||
|
#SERVER_FOR=production
|
||||||
|
SERVER_FOR=local
|
||||||
|
|
||||||
# crypto
|
# =============================== DATABASE LOCAL =================================
|
||||||
SECRET_KEY=U2FsdGVkX19keaNhiBfdNSWnKA2a8Z5deBu/KkU6BNg=
|
# 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
|
||||||
|
|
||||||
# jwt
|
# ==================================== REDIS =====================================
|
||||||
|
REDIS_URL=redis://localhost:6379
|
||||||
|
REDIS_PASSWORD=
|
||||||
|
|
||||||
|
# ==================================== LOKI =====================================
|
||||||
|
LOKI_URL=http://10.20.14.30: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_EXPIRATION=30d
|
||||||
JWT_REFRESH_EXPIRATION=40d
|
JWT_REFRESH_EXPIRATION=40d
|
||||||
TOKEN_SECRET=U2FsdGVkX1/hnA2S3l0Evi+whG73WiOrplJA5fcfe2o=
|
# FOR PRODUCTION
|
||||||
REFRESH_TOKEN_SECRET=U2FsdGVkX18LvuBcY6prEGXDZhDoBa7O0GAUSzTWzdk=
|
#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 SERVER (YES or NO) ===========================
|
||||||
CHANGE_TO_DRC=YES
|
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)
|
# 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=12
|
NUMBER_SERVER_ACTIVE=1
|
||||||
|
|
||||||
# =================================== KCI =================================
|
# ================================ KONFIGURASI HSM =================================
|
||||||
|
|
||||||
# system code kci profile
|
# system code kci profile
|
||||||
|
# FOR PRODUCTION & DEVELOPMENT
|
||||||
SYSTEM_CODE=90B7
|
SYSTEM_CODE=90B7
|
||||||
|
|
||||||
#SERVICE BLOCK
|
#SERVICE BLOCK
|
||||||
SERVICEBLOCK_SERVICE_MUTUAL="101001A00C2001A0483001A0"
|
# FOR PRODUCTION
|
||||||
SERVICEBLOCK_BLOCK_READ="80008200"
|
# SERVICEBLOCK_SERVICE_MUTUAL="101001D00C2001D0483001D0"
|
||||||
|
# FOR DEVELOPMENT
|
||||||
|
SERVICEBLOCK_SERVICE_MUTUAL="101001A00C2001A0483001A0883001A0"
|
||||||
|
|
||||||
|
SERVICEBLOCK_BLOCK_READ="800082008300"
|
||||||
SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||||
|
|
||||||
# HSM DC (DATA CENTER)
|
# HSM DC (DATA CENTER)
|
||||||
# KCI PCI
|
# HSM SERVER
|
||||||
URL_HSM_SERVER_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
# 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"
|
APIKEY_HSM_SERVER_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||||
SECRETKEY_HSM_SERVER_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
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"
|
URL_HSM_SERVER_2="ws://10.1.201.215:88/feliqserver/v1/wsapi"
|
||||||
APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
APIKEY_HSM_SERVER_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||||
SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
SECRETKEY_HSM_SERVER_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||||
|
|
||||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||||
# KCI PCI
|
# HSM SERVER
|
||||||
|
IP_HSM_SERVER_BACKUP_1="10.1.201.222"
|
||||||
URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||||
APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
APIKEY_HSM_SERVER_BACKUP_1="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||||
SECRETKEY_HSM_SERVER_BACKUP_1="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
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"
|
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"
|
APIKEY_HSM_SERVER_BACKUP_2="bc391562-f880-3b57-9868-36dfa5cbf954-0TC"
|
||||||
SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
||||||
|
|
||||||
|
|
||||||
# =================================== NUTECH =================================
|
# ============================= KONFIGURASI HSM NUTECH =============================
|
||||||
|
|
||||||
# SYSTEM CODE IN HEXA STRING
|
# SYSTEM CODE IN HEXA STRING
|
||||||
# system code nutech profile
|
# system code nutech profile
|
||||||
@@ -63,17 +118,20 @@ SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
|||||||
# SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
# SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||||
|
|
||||||
# HSM DC (DATA CENTER)
|
# HSM DC (DATA CENTER)
|
||||||
# KCI PCI
|
# HSM SERVER
|
||||||
# URL_HSM_SERVER_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
# URL_HSM_SERVER_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||||
# APIKEY_HSM_SERVER_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
# APIKEY_HSM_SERVER_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||||
# SECRETKEY_HSM_SERVER_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
# SECRETKEY_HSM_SERVER_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||||
# JEPANG
|
# 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"
|
# URL_HSM_SERVER_2="wss://gateway04.cyberware.co.jp/feliqserver/v1/wsapi"
|
||||||
# APIKEY_HSM_SERVER_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
# APIKEY_HSM_SERVER_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||||
# SECRETKEY_HSM_SERVER_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
# SECRETKEY_HSM_SERVER_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||||
|
|
||||||
# HSM DRC (DISASTER RECOVERY CENTER)
|
# HSM DRC (DISASTER RECOVERY CENTER)
|
||||||
# KCI PCI
|
# HSM SERVER
|
||||||
# URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
# URL_HSM_SERVER_BACKUP_1="ws://10.1.201.215/feliqserver/v1/wsapi"
|
||||||
# APIKEY_HSM_SERVER_BACKUP_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
# APIKEY_HSM_SERVER_BACKUP_1="d54ff5c4-9709-3bac-9a6e-04b2f4deebae-0TC"
|
||||||
# SECRETKEY_HSM_SERVER_BACKUP_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
# SECRETKEY_HSM_SERVER_BACKUP_1="W8ZiN1o2tNkb1svNlj5Kl8PNohhujaTxeNaGEq2rOWY="
|
||||||
@@ -82,3 +140,5 @@ SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
|||||||
# APIKEY_HSM_SERVER_BACKUP_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
# APIKEY_HSM_SERVER_BACKUP_2="4c6dd075-dbcb-375f-81f7-62990a5d7000-0TC"
|
||||||
# SECRETKEY_HSM_SERVER_BACKUP_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
# SECRETKEY_HSM_SERVER_BACKUP_2="U5xs7nVonhtbQ+XiYATRSg8Nk5sPu1IpVx7X40KyWiw="
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,145 @@
|
|||||||
|
# ================================= 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,33 +1,35 @@
|
|||||||
require("dotenv").config();
|
require('dotenv').config();
|
||||||
const winston = require("./application/helpers/winston.logger");
|
const winston = require('./application/helpers/winston.logger');
|
||||||
const server = require("./server");
|
const server = require('./server');
|
||||||
|
|
||||||
// set port, listen for requests
|
// set port, listen for requests
|
||||||
const PORT = process.env.PORT || 3000;
|
const PORT = process.env.PORT || 3000;
|
||||||
var serverHSMStatus = "HSM SERVER NOT CONNECTED";
|
var serverHSMStatus = 'HSM SERVER NOT CONNECTED';
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||||
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_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}`;
|
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`;
|
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)";
|
var serverActive = 'DC (DATA CENTER)';
|
||||||
if (process.env.CHANGE_TO_DRC == "YES" || process.env.CHANGE_TO_DRC == "yes") {
|
if (process.env.CHANGE_TO_DRC == 'YES' || process.env.CHANGE_TO_DRC == 'yes') {
|
||||||
serverActive = "DRC (DISASTER RECOVERY CENTER)";
|
serverActive = 'DRC (DISASTER RECOVERY CENTER)';
|
||||||
|
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||||
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_BACKUP_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}`;
|
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`;
|
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`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`Server is running on environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
`Server is running on version ${
|
||||||
|
process.env.VERSION
|
||||||
|
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
+14
-11
@@ -16,23 +16,25 @@ const cron = require('node-cron');
|
|||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
moment.locale('id');
|
moment.locale('id');
|
||||||
const responseTime = require("response-time");
|
const responseTime = require('response-time');
|
||||||
const { logger } = require("../application/helpers/getbodyrequest")
|
const { logger } = require('../application/helpers/getbodyrequest');
|
||||||
const client = require("prom-client");
|
const client = require('prom-client');
|
||||||
const register = new client.Registry();
|
const register = new client.Registry();
|
||||||
const {topuponline_metrics} = require("../application/helpers/prometheusmetrics");
|
const {
|
||||||
const {prometheusMiddleware} = require("../application/middlewares/prometheus.middleware")
|
topuponline_metrics, topuponline_metrics_response_time,topuponline_metrics_load_balance
|
||||||
const lokiMiddleware = require("../application/middlewares/loki.middleware")
|
} = require('../application/helpers/prometheusmetrics');
|
||||||
const redisMiddleware = require("../application/middlewares/redis.middleware")
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
register.setDefaultLabels({ app: "topuponline" });
|
let promApp = process.env.PROM_APP || "topuponline";
|
||||||
|
register.setDefaultLabels({ app: promApp });
|
||||||
client.collectDefaultMetrics({ register });
|
client.collectDefaultMetrics({ register });
|
||||||
register.registerMetric(topuponline_metrics);
|
register.registerMetric(topuponline_metrics);
|
||||||
|
register.registerMetric(topuponline_metrics_response_time);
|
||||||
|
register.registerMetric(topuponline_metrics_load_balance);
|
||||||
|
|
||||||
app.get("/metrics", (req, res) => {
|
app.get('/metrics', (req, res) => {
|
||||||
res.setHeader("Content-Type", register.contentType);
|
res.setHeader('Content-Type', register.contentType);
|
||||||
register.metrics().then((data) => res.send(data));
|
register.metrics().then((data) => res.send(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -71,6 +73,7 @@ app.get('/', async (req, res) => {
|
|||||||
chipper_data: chipperData,
|
chipper_data: chipperData,
|
||||||
decrypt_data: decrypData,
|
decrypt_data: decrypData,
|
||||||
date: moment().format('YYYYMMDDHHmm'),
|
date: moment().format('YYYYMMDDHHmm'),
|
||||||
|
secret_key: helper.encryptText('0nlinetopupDev'),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -84,7 +87,7 @@ app.use('/api/', historyRoute);
|
|||||||
app.use('/api/', hsmRoute);
|
app.use('/api/', hsmRoute);
|
||||||
app.use('/api/', loadBalanceRoute);
|
app.use('/api/', loadBalanceRoute);
|
||||||
app.use('/api/', paymentReconRoute);
|
app.use('/api/', paymentReconRoute);
|
||||||
app.use('/api/', prometheusMiddleware, lokiMiddleware, redisMiddleware, reservationRoute);
|
app.use('/api/', reservationRoute);
|
||||||
app.use('/api/', invoiceRoute);
|
app.use('/api/', invoiceRoute);
|
||||||
app.use('/api/', cashinRoute);
|
app.use('/api/', cashinRoute);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user