mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 19:06:40 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ba9345e0a5 |
@@ -1,25 +1,23 @@
|
|||||||
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 || '';
|
let redisPass = process.env.REDIS_PASSWORD || "redispassword";
|
||||||
|
|
||||||
redisClient = redis.createClient({
|
redisClient = redis.createClient({
|
||||||
url: redisUrl,
|
url: redisUrl,
|
||||||
password: '',
|
password: redisPass,
|
||||||
});
|
});
|
||||||
|
|
||||||
redisClient.on('error', (error) => console.error(`Error : ${error}`));
|
redisClient.on("error", (error) => 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", () => console.log("Redis is Reconnecting"));
|
||||||
|
|
||||||
await redisClient.connect();
|
await redisClient.connect();
|
||||||
})();
|
})();
|
||||||
@@ -29,18 +27,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,
|
||||||
});
|
});
|
||||||
@@ -50,69 +48,4 @@ const redisMiddleware = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getReservationNumberSequence = async (req, res, next) => {
|
module.exports = redisMiddleware;
|
||||||
// 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,
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,55 +1,55 @@
|
|||||||
const { param, body, validationResult } = require("express-validator");
|
const { param, body, validationResult } = require('express-validator');
|
||||||
const winston = require("../../helpers/winston.logger");
|
const winston = require('../../helpers/winston.logger');
|
||||||
const generate = require("./utils/utils");
|
const generate = require('./utils/utils');
|
||||||
const loadBalance = require("../loadbalance/loadbalance.controller");
|
const loadBalance = require('../loadbalance/loadbalance.controller');
|
||||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
require("dotenv").config();
|
require('dotenv').config();
|
||||||
|
|
||||||
let useClient;
|
let useClient;
|
||||||
|
|
||||||
// set connection HSM server
|
// set connection HSM server
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||||
var { client } = require("./services/webSocket");
|
var { client } = require('./services/webSocket');
|
||||||
|
|
||||||
useClient = client;
|
useClient = client;
|
||||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||||
var { client2 } = require("./services/webSocket2");
|
var { client2 } = require('./services/webSocket2');
|
||||||
|
|
||||||
useClient = client2;
|
useClient = client2;
|
||||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||||
var { client } = require("./services/webSocket");
|
var { client } = require('./services/webSocket');
|
||||||
var { client2 } = require("./services/webSocket2");
|
var { client2 } = require('./services/webSocket2');
|
||||||
}
|
}
|
||||||
|
|
||||||
// VALIDATION
|
// VALIDATION
|
||||||
const validate = (method) => {
|
const validate = (method) => {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "topupResponse":
|
case 'topupResponse':
|
||||||
return [
|
return [
|
||||||
body("mid").not().isEmpty().withMessage("MID is required"),
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||||
body("tid").not().isEmpty().withMessage("TID is required"),
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||||
body("uid").not().isEmpty().withMessage("UID is required"),
|
body('uid').not().isEmpty().withMessage('UID is required'),
|
||||||
body("flag").not().isEmpty().withMessage("Flag is required"),
|
body('flag').not().isEmpty().withMessage('Flag is required'),
|
||||||
body("card_number")
|
body('card_number')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Card Number is required"),
|
.withMessage('Card Number is required'),
|
||||||
body("amount")
|
body('amount')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Amount is required")
|
.withMessage('Amount is required')
|
||||||
.isNumeric()
|
.isNumeric()
|
||||||
.withMessage("Amount is invalid format"),
|
.withMessage('Amount is invalid format'),
|
||||||
body("reservation_number")
|
body('reservation_number')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Reservation Number is required")
|
.withMessage('Reservation Number is required')
|
||||||
.isArray()
|
.isArray()
|
||||||
.withMessage("Reservation Number is invalid request format"),
|
.withMessage('Reservation Number is invalid request format'),
|
||||||
body("load_balance_number")
|
body('load_balance_number')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Load Balance Number is required"),
|
.withMessage('Load Balance Number is required'),
|
||||||
];
|
];
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -79,7 +79,7 @@ const controller = async (req, res) => {
|
|||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
// set connection HSM server
|
// set connection HSM server
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||||
// set request to HSM server 2
|
// set request to HSM server 2
|
||||||
if (uniqueCode) {
|
if (uniqueCode) {
|
||||||
if (parseInt(uniqueCode) % 2 == 0) {
|
if (parseInt(uniqueCode) % 2 == 0) {
|
||||||
@@ -119,8 +119,8 @@ const controller = async (req, res) => {
|
|||||||
let _stopMessage = 1;
|
let _stopMessage = 1;
|
||||||
if (packet[0] != 0x47) {
|
if (packet[0] != 0x47) {
|
||||||
result = {
|
result = {
|
||||||
code: "03",
|
code: '03',
|
||||||
message: "Respone Card Wrong",
|
message: 'Respone Card Wrong',
|
||||||
data: {},
|
data: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ const controller = async (req, res) => {
|
|||||||
let respData = null;
|
let respData = null;
|
||||||
let respData1 = null;
|
let respData1 = null;
|
||||||
|
|
||||||
useClient.ws.on("message", (message) => {
|
useClient.ws.on('message', (message) => {
|
||||||
while (
|
while (
|
||||||
message[2] == 5 &&
|
message[2] == 5 &&
|
||||||
message[0] == transactionId[0] &&
|
message[0] == transactionId[0] &&
|
||||||
@@ -186,7 +186,7 @@ const controller = async (req, res) => {
|
|||||||
amount: amount,
|
amount: amount,
|
||||||
reservation_number: reservation_number,
|
reservation_number: reservation_number,
|
||||||
ref_no: ref_no,
|
ref_no: ref_no,
|
||||||
write_status: "FW",
|
write_status: 'FW',
|
||||||
uid: uid,
|
uid: uid,
|
||||||
balance: parseInt(balance) + parseInt(amount),
|
balance: parseInt(balance) + parseInt(amount),
|
||||||
flag: parseInt(flag),
|
flag: parseInt(flag),
|
||||||
@@ -203,8 +203,8 @@ const controller = async (req, res) => {
|
|||||||
await loadBalance.loadingBalanceUpdate(data);
|
await loadBalance.loadingBalanceUpdate(data);
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
code: "5002",
|
code: '5002',
|
||||||
message: "failed from HSM",
|
message: 'failed from HSM',
|
||||||
data: {
|
data: {
|
||||||
trxID: generate.buf2hex(transactionId),
|
trxID: generate.buf2hex(transactionId),
|
||||||
responseCode: respData1.slice(6, 10),
|
responseCode: respData1.slice(6, 10),
|
||||||
@@ -213,6 +213,11 @@ const controller = async (req, res) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
// jika sudah mencapai maksimum counting flag, maka reset flag ke awal
|
||||||
|
if (flag >= 255) {
|
||||||
|
flag = -1;
|
||||||
|
}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
mid: mid,
|
mid: mid,
|
||||||
tid: tid,
|
tid: tid,
|
||||||
@@ -236,10 +241,10 @@ const controller = async (req, res) => {
|
|||||||
// update data load balance
|
// update data load balance
|
||||||
let update = await loadBalance.loadingBalanceUpdate(data);
|
let update = await loadBalance.loadingBalanceUpdate(data);
|
||||||
if (update) {
|
if (update) {
|
||||||
if (update.code == "00") {
|
if (update.code == '00') {
|
||||||
result = {
|
result = {
|
||||||
code: "00",
|
code: '00',
|
||||||
message: "Topup Succeess",
|
message: 'Topup Succeess',
|
||||||
data: {
|
data: {
|
||||||
trxID: generate.buf2hex(transactionId),
|
trxID: generate.buf2hex(transactionId),
|
||||||
responseCode: respCode,
|
responseCode: respCode,
|
||||||
@@ -257,8 +262,8 @@ const controller = async (req, res) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = {
|
result = {
|
||||||
code: "423",
|
code: '423',
|
||||||
message: "update/insert failed",
|
message: 'update/insert failed',
|
||||||
data: {},
|
data: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -277,11 +282,11 @@ const controller = async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
code: "5001",
|
code: '5001',
|
||||||
message:
|
message:
|
||||||
process.env.NODE_ENV != "production"
|
process.env.NODE_ENV != 'production'
|
||||||
? error.message
|
? error.message
|
||||||
: "500 internal server error - backend server.",
|
: '500 internal server error - backend server.',
|
||||||
data: {},
|
data: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ const winston = require('../../helpers/winston.logger');
|
|||||||
const model = require('./reservebalance.model');
|
const model = require('./reservebalance.model');
|
||||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const {
|
|
||||||
setReservationNumberSequence,
|
|
||||||
} = require('../../middlewares/redis.middleware');
|
|
||||||
moment.locale('id');
|
moment.locale('id');
|
||||||
|
|
||||||
// variable yang digunakan untuk melakukan perulangan proses generate reservation number jika reservation number yang di generate sudah digunakan orang lain
|
// variable yang digunakan untuk melakukan perulangan proses generate reservation number jika reservation number yang di generate sudah digunakan orang lain
|
||||||
@@ -73,13 +70,6 @@ const validate = (method) => {
|
|||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage('Reservation Number is required'),
|
.withMessage('Reservation Number is required'),
|
||||||
];
|
];
|
||||||
case 'cancelReservationV2':
|
|
||||||
return [
|
|
||||||
body('cancel_reservation_data')
|
|
||||||
.not()
|
|
||||||
.isEmpty()
|
|
||||||
.withMessage('Cancel Reservation data is required'),
|
|
||||||
];
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -153,21 +143,23 @@ const checkReservation = async (req, res) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak
|
// jika settingan bukan diperuntukan untuk production, bisa development atau local atau yang lainnya dan kemudian kartu yang di request merupakan kartu production maka akan di tolak
|
||||||
if (card_number.substring(0, 1) == '1') {
|
// if (card_number.substring(0, 1) == '1') {
|
||||||
result = {
|
// result = {
|
||||||
code: '400',
|
// code: '400',
|
||||||
message:
|
// message:
|
||||||
"It's production card number. Please use the development card number.",
|
// "It's production card number. Please use the development card number.",
|
||||||
data: {},
|
// data: {},
|
||||||
};
|
// };
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
// // log warn
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
// winston.logger.warn(
|
||||||
result
|
// `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
||||||
)}`
|
// result
|
||||||
);
|
// )}`
|
||||||
return res.status(200).json(result);
|
// );
|
||||||
}
|
|
||||||
|
// return res.status(200).json(result);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
@@ -1022,24 +1014,12 @@ const reservationValidateV2 = async (req, res) => {
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// log debug
|
|
||||||
// process enkripsi data reservasi dengan HMAC yang nanti nya akan di kirim ke end point reservation api sebagai pembanding bahwa data yang sudah di enkripsi tidak dimanipulasi
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} [ PROCESSING RESERVATION-VALIDATE-V2 ] generating security code from data reservation`
|
|
||||||
);
|
|
||||||
|
|
||||||
// create security code yang isinya data reservasi yang akan di compare nantinya saat melakukan insert reservation
|
|
||||||
let securityCode = await helper.createHMAC(
|
|
||||||
mid + '|' + tid + '|' + card_number + '|' + amount
|
|
||||||
);
|
|
||||||
|
|
||||||
let reservationData = {
|
let reservationData = {
|
||||||
mid: mid,
|
mid: mid,
|
||||||
tid: tid,
|
tid: tid,
|
||||||
card_number: card_number,
|
card_number: card_number,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
transaction_date: now,
|
transaction_date: now,
|
||||||
security_code: securityCode,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
@@ -1053,6 +1033,19 @@ const reservationValidateV2 = async (req, res) => {
|
|||||||
// enkripsi data reservasi sebelum melakukan transaksi reservasi
|
// enkripsi data reservasi sebelum melakukan transaksi reservasi
|
||||||
let hash = helper.encryptText(JSON.stringify(reservationData));
|
let hash = helper.encryptText(JSON.stringify(reservationData));
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
// process enkripsi data reservasi dengan HMAC yang nanti nya akan di kirim ke end point reservation api sebagai pembanding bahwa data yang sudah di enkripsi tidak dimanipulasi
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} [ PROCESSING RESERVATION-VALIDATE-V2 ] generating security code from data reservation: ${JSON.stringify(
|
||||||
|
reservationData
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// create security code yang isinya data reservasi yang akan di compare nantinya saat melakukan insert reservation
|
||||||
|
let securityCode = await helper.createHMAC(
|
||||||
|
mid + '|' + tid + '|' + card_number + '|' + amount
|
||||||
|
);
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
code: '00',
|
code: '00',
|
||||||
message: 'validation successfully.',
|
message: 'validation successfully.',
|
||||||
@@ -1060,6 +1053,7 @@ const reservationValidateV2 = async (req, res) => {
|
|||||||
card_number: card_number,
|
card_number: card_number,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
reservation_data: hash,
|
reservation_data: hash,
|
||||||
|
security_code: securityCode,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1461,8 +1455,7 @@ const reservation = async (req, res) => {
|
|||||||
// generate reservation number
|
// generate reservation number
|
||||||
let reservationNumber;
|
let reservationNumber;
|
||||||
let getReservationNumberSequence;
|
let getReservationNumberSequence;
|
||||||
// req.reservation_number_sequence adalah value yang di dapat dari redis middleware (cacheReservationNumberSequence)
|
let reservationNoSequence;
|
||||||
let reservationNoSequence = req.reservation_number_sequence;
|
|
||||||
let maxLoop = 0;
|
let maxLoop = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -1474,16 +1467,14 @@ const reservation = async (req, res) => {
|
|||||||
`${uniqueCode} [ PROCESSING RESERVATION ] checking reservation sequence...`
|
`${uniqueCode} [ PROCESSING RESERVATION ] checking reservation sequence...`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!reservationNoSequence) {
|
// get reservation
|
||||||
// get reservation
|
getReservationNumberSequence = await model.getReservationNumberSequence(
|
||||||
getReservationNumberSequence = await model.getReservationNumberSequence(
|
getPartner,
|
||||||
getPartner,
|
today
|
||||||
today
|
);
|
||||||
);
|
reservationNoSequence = getReservationNumberSequence
|
||||||
reservationNoSequence = getReservationNumberSequence
|
? parseInt(getReservationNumberSequence.i_reservation_no_seq) + 1
|
||||||
? parseInt(getReservationNumberSequence.i_reservation_no_seq) + 1
|
: 1;
|
||||||
: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
@@ -1705,7 +1696,7 @@ const reservationV2 = async (req, res) => {
|
|||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
// param
|
// param
|
||||||
let { reservation_data, ref_no } = req.body;
|
let { reservation_data, security_code, ref_no } = req.body;
|
||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
@@ -1786,9 +1777,8 @@ const reservationV2 = async (req, res) => {
|
|||||||
let card_number = reservationData.card_number;
|
let card_number = reservationData.card_number;
|
||||||
let amount = reservationData.amount;
|
let amount = reservationData.amount;
|
||||||
let transactionDate = reservationData.transaction_date;
|
let transactionDate = reservationData.transaction_date;
|
||||||
let securityCode = reservationData.security_code;
|
|
||||||
|
|
||||||
if (securityCode) {
|
if (security_code) {
|
||||||
// log debug
|
// log debug
|
||||||
// process enkripsi data reservasi dengan HMAC sebagai pembanding bahwa data yang di decrypt valid
|
// process enkripsi data reservasi dengan HMAC sebagai pembanding bahwa data yang di decrypt valid
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
@@ -1796,11 +1786,11 @@ const reservationV2 = async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// create security code yang isinya data reservasi yang akan di compare nantinya saat melakukan insert reservation
|
// create security code yang isinya data reservasi yang akan di compare nantinya saat melakukan insert reservation
|
||||||
let securityCodeCompare = await helper.createHMAC(
|
let securityCode = await helper.createHMAC(
|
||||||
mid + '|' + tid + '|' + card_number + '|' + amount
|
mid + '|' + tid + '|' + card_number + '|' + amount
|
||||||
);
|
);
|
||||||
|
|
||||||
if (securityCode !== securityCodeCompare) {
|
if (security_code !== securityCode) {
|
||||||
result = {
|
result = {
|
||||||
code: '437',
|
code: '437',
|
||||||
message: 'bad request. reservation data has been changed.',
|
message: 'bad request. reservation data has been changed.',
|
||||||
@@ -1826,7 +1816,6 @@ const reservationV2 = async (req, res) => {
|
|||||||
card_number: card_number,
|
card_number: card_number,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
transaction_date: transactionDate,
|
transaction_date: transactionDate,
|
||||||
security_code: securityCode,
|
|
||||||
}
|
}
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -2171,40 +2160,26 @@ const reservationV2 = async (req, res) => {
|
|||||||
// generate reservation number
|
// generate reservation number
|
||||||
let reservationNumber;
|
let reservationNumber;
|
||||||
let getReservationNumberSequence;
|
let getReservationNumberSequence;
|
||||||
// req.reservation_number_sequence adalah value yang di dapat dari redis middleware (cacheReservationNumberSequence)
|
let reservationNoSequence;
|
||||||
let reservationNoSequence = req.reservation_number_sequence;
|
|
||||||
|
|
||||||
let maxLoop = 0;
|
let maxLoop = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
await _sleep(helper.randomNumberInt());
|
await _sleep(helper.randomNumberInt());
|
||||||
|
|
||||||
if (maxLoop > 0) {
|
|
||||||
reservationNoSequence = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
// proses pencarian sequence terakhir dari transaksi reservasi saldo berdasarkan partner di hari ini
|
// proses pencarian sequence terakhir dari transaksi reservasi saldo berdasarkan partner di hari ini
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
`${uniqueCode} [ PROCESSING RESERVATION-V2 ] checking reservation sequence...`
|
`${uniqueCode} [ PROCESSING RESERVATION-V2 ] checking reservation sequence...`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!reservationNoSequence) {
|
// get reservation
|
||||||
// get reservation
|
getReservationNumberSequence = await model.getReservationNumberSequence(
|
||||||
getReservationNumberSequence = await model.getReservationNumberSequence(
|
getPartner,
|
||||||
getPartner,
|
today
|
||||||
today
|
);
|
||||||
);
|
reservationNoSequence = getReservationNumberSequence
|
||||||
reservationNoSequence = getReservationNumberSequence
|
? parseInt(getReservationNumberSequence.i_reservation_no_seq) + 1
|
||||||
? parseInt(getReservationNumberSequence.i_reservation_no_seq) + 1
|
: 1;
|
||||||
: 1;
|
|
||||||
|
|
||||||
// set sequence to redis
|
|
||||||
await setReservationNumberSequence(
|
|
||||||
req.partner_id_token,
|
|
||||||
reservationNoSequence
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
@@ -2942,57 +2917,26 @@ const inquiryReservation = async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ================================================================= INQUIRY RESERVATION BY REF NUMBER =================================================================
|
|
||||||
// *Created By: Teddy Setiawan*
|
|
||||||
// *Description:*
|
|
||||||
//
|
|
||||||
|
|
||||||
const inquiryReservationByReservation = async (req, res) => {
|
const inquiryReservationByReservation = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// param
|
// param
|
||||||
let { reservation_number, ref_no, load_balance_number } = req.body;
|
let { reservation_number } = req.body;
|
||||||
|
|
||||||
let result;
|
// validation parameter inquiry
|
||||||
|
if (!reservation_number) {
|
||||||
if (req.query.search === 'ref-no') {
|
return res.status(200).json({
|
||||||
// validation parameter inquiry
|
code: '400',
|
||||||
if (!ref_no) {
|
message: 'bad request. please add the reservation number!',
|
||||||
return res.status(200).json({
|
data: {},
|
||||||
code: '400',
|
});
|
||||||
message: 'bad request. please add the ref number!',
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// check reservation
|
|
||||||
result = await model.inquiryListByRefNumber(ref_no);
|
|
||||||
} else if (req.query.search === 'load-balance-number') {
|
|
||||||
// validation parameter inquiry
|
|
||||||
if (!load_balance_number) {
|
|
||||||
return res.status(200).json({
|
|
||||||
code: '400',
|
|
||||||
message: 'bad request. please add the load balance number!',
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// check reservation
|
|
||||||
result = await model.inquiryListByLoadNumber(load_balance_number);
|
|
||||||
} else {
|
|
||||||
// validation parameter inquiry
|
|
||||||
if (!reservation_number) {
|
|
||||||
return res.status(200).json({
|
|
||||||
code: '400',
|
|
||||||
message: 'bad request. please add the reservation number!',
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// check reservation
|
|
||||||
result = await model.inquiryByReservationNumber(reservation_number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result) {
|
// check reservation
|
||||||
|
let byReservationNumber = await model.inquiryByReservationNumber(
|
||||||
|
reservation_number
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!byReservationNumber) {
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
code: '414',
|
code: '414',
|
||||||
message: "reservation doesn't exist",
|
message: "reservation doesn't exist",
|
||||||
@@ -3003,7 +2947,7 @@ const inquiryReservationByReservation = async (req, res) => {
|
|||||||
return res.json({
|
return res.json({
|
||||||
code: '00',
|
code: '00',
|
||||||
message: 'reservation has been found.',
|
message: 'reservation has been found.',
|
||||||
data: result,
|
data: byReservationNumber,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
@@ -3074,593 +3018,6 @@ const inquiryListReservationByReservation = async (req, res) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ================================================================= CANCEL RESERVATION V2 =================================================================
|
|
||||||
// *Created By: Teddy Setiawan*
|
|
||||||
// *Description:*
|
|
||||||
//
|
|
||||||
const cancelReservationValidateV2 = 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 { mid, tid, reservation_number } = req.body;
|
|
||||||
|
|
||||||
// log info
|
|
||||||
winston.logger.info(
|
|
||||||
`${uniqueCode} [ REQUEST CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
req.body
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
// check validator
|
|
||||||
const err = validationResult(req, res);
|
|
||||||
if (!err.isEmpty()) {
|
|
||||||
result = {
|
|
||||||
code: '400',
|
|
||||||
message: err.errors[0].msg,
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 CANCEL-RESERVATION-VALIDATE ]: checking partner...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// get partner, merchant, terminal from tid
|
|
||||||
let getPartner = await model.getPartner(mid, tid);
|
|
||||||
if (!getPartner) {
|
|
||||||
result = {
|
|
||||||
code: '412',
|
|
||||||
message: 'terminal id is not valid',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// log debug
|
|
||||||
// proses pengecekkan status reservation number yang di request
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE ]: getting reservation by reservation number...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// get reservation berdasarkan reservation number yang di request
|
|
||||||
let getReservationCanBeCanceled = await model.getReservationCanBeCanceled(
|
|
||||||
reservation_number
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!getReservationCanBeCanceled) {
|
|
||||||
result = {
|
|
||||||
code: '414',
|
|
||||||
message: "Reservation doesn't exist.",
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get value global parameter
|
|
||||||
let getGlobalParameter = await model.getGlobalParameter();
|
|
||||||
// check value global parameter
|
|
||||||
if (!getGlobalParameter) {
|
|
||||||
result = {
|
|
||||||
code: '493',
|
|
||||||
message: 'HSM_CANCEL_RESERVATION_LEVEL in global parameter not found',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
// validasi sesuai value global parameter
|
|
||||||
if (getGlobalParameter.c_value == 'PARTNER') {
|
|
||||||
if (getPartner.i_partner != getReservationCanBeCanceled.i_partner) {
|
|
||||||
result = {
|
|
||||||
code: '438',
|
|
||||||
message: 'Can not be canceled on different source',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
} else if (getGlobalParameter.c_value == 'MERCHANT') {
|
|
||||||
if (getPartner.i_merchant != getReservationCanBeCanceled.i_merchant) {
|
|
||||||
result = {
|
|
||||||
code: '438',
|
|
||||||
message: 'Can not be canceled on different source',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
} else if (getGlobalParameter.c_value == 'TERMINAL') {
|
|
||||||
if (getPartner.i_terminal != getReservationCanBeCanceled.i_terminal) {
|
|
||||||
result = {
|
|
||||||
code: '438',
|
|
||||||
message: 'Can not be canceled on different source',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// jika data reservasi ditemukan
|
|
||||||
if (getReservationCanBeCanceled) {
|
|
||||||
// jika status dari reservation number yang di request adalah I = In Progress atau A = Loaded, maka proses cancel reservasi akan di tolak
|
|
||||||
if (
|
|
||||||
getReservationCanBeCanceled.c_status == 'I' ||
|
|
||||||
getReservationCanBeCanceled.c_status == 'A'
|
|
||||||
) {
|
|
||||||
result = {
|
|
||||||
code: '429',
|
|
||||||
message: 'can not be cancelled. The transaction has been loaded.',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} else if (getReservationCanBeCanceled.c_status == 'X') {
|
|
||||||
// jika status dari reservation number yang di request adalah X = Deleted, maka proses cancel reservasi akan di tolak
|
|
||||||
let cancelDate = getReservationCanBeCanceled.d_cancel
|
|
||||||
? moment(getReservationCanBeCanceled.d_cancel).format(
|
|
||||||
'DD-MM-YYYY HH:mm:ss'
|
|
||||||
)
|
|
||||||
: '';
|
|
||||||
result = {
|
|
||||||
code: '430',
|
|
||||||
message: `can not be cancelled. The transaction has been canceled at ${cancelDate}.`,
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} RESPONSE cancel reservation validate: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} else if (getReservationCanBeCanceled.c_payment_recon_no) {
|
|
||||||
// jika reservation number yang di request sudah dilakukan payment recon, maka proses cancel reservasi akan di tolak
|
|
||||||
result = {
|
|
||||||
code: '430',
|
|
||||||
message: `can not be cancelled. The transaction has been recon.`,
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// jika reservation number yang di request tidak ditemukan di sistem CMS
|
|
||||||
result = {
|
|
||||||
code: '414',
|
|
||||||
message: "Reservation doesn't exist.",
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// time
|
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
||||||
|
|
||||||
// create security code yang isinya data reservasi yang akan di compare nantinya saat melakukan insert reservation
|
|
||||||
let securityCode = await helper.createHMAC(
|
|
||||||
mid + '|' + tid + '|' + reservation_number
|
|
||||||
);
|
|
||||||
|
|
||||||
let reservationData = {
|
|
||||||
mid: mid,
|
|
||||||
tid: tid,
|
|
||||||
reservation_number: reservation_number,
|
|
||||||
transaction_date: now,
|
|
||||||
security_code: securityCode,
|
|
||||||
};
|
|
||||||
|
|
||||||
// log debug
|
|
||||||
// process enkripsi data reservasi dengan AES yang nanti nya akan di kirim ke end point reservation api untuk menyimpan data reservasi
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} [ PROCESSING RESERVATION-VALIDATE-V2 ] encrypting data reservation: ${JSON.stringify(
|
|
||||||
reservationData
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
// enkripsi data reservasi sebelum melakukan transaksi reservasi
|
|
||||||
let hash = helper.encryptText(JSON.stringify(reservationData));
|
|
||||||
|
|
||||||
result = {
|
|
||||||
code: '00',
|
|
||||||
message: 'reservation can be canceled.',
|
|
||||||
data: {
|
|
||||||
cancel_reservation_data: hash,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log info
|
|
||||||
winston.logger.info(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} catch (error) {
|
|
||||||
// create log
|
|
||||||
winston.logger.error(
|
|
||||||
`[ RESPONSE CANCEL-RESERVATION-VALIDATE ]: 500 internal server error - backend server | ${error.message}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json({
|
|
||||||
code: '500',
|
|
||||||
message:
|
|
||||||
process.env.NODE_ENV != 'production'
|
|
||||||
? error.message
|
|
||||||
: '500 internal server error - backend server.',
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const cancelReservationV2 = 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 { cancel_reservation_data } = req.body;
|
|
||||||
|
|
||||||
// log info
|
|
||||||
winston.logger.info(
|
|
||||||
`${uniqueCode} [ REQUEST CANCEL-RESERVATION ]: ${JSON.stringify(
|
|
||||||
req.body
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
// check validator
|
|
||||||
const err = validationResult(req, res);
|
|
||||||
if (!err.isEmpty()) {
|
|
||||||
result = {
|
|
||||||
code: '400',
|
|
||||||
message: err.errors[0].msg,
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
let cancelReservationData;
|
|
||||||
|
|
||||||
try {
|
|
||||||
cancelReservationData = helper.decryptText(cancel_reservation_data);
|
|
||||||
} catch (error) {}
|
|
||||||
|
|
||||||
if (!cancelReservationData) {
|
|
||||||
result = {
|
|
||||||
code: '435',
|
|
||||||
message: 'bad request. reservation data is invalid.',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// parsing data to json format
|
|
||||||
cancelReservationData = JSON.parse(cancelReservationData);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!cancelReservationData.mid ||
|
|
||||||
!cancelReservationData.tid ||
|
|
||||||
!cancelReservationData.reservation_number ||
|
|
||||||
!cancelReservationData.transaction_date
|
|
||||||
) {
|
|
||||||
result = {
|
|
||||||
code: '436',
|
|
||||||
message: 'bad request. reservation data is empty.',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-V2 ]: ${JSON.stringify(result)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 CANCEL-RESERVATION ]: checking partner...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// get partner, merchant, terminal from tid
|
|
||||||
let getPartner = await model.getPartner(
|
|
||||||
cancelReservationData.mid,
|
|
||||||
cancelReservationData.tid
|
|
||||||
);
|
|
||||||
if (!getPartner) {
|
|
||||||
result = {
|
|
||||||
code: '412',
|
|
||||||
message: 'terminal id is not valid',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// log debug
|
|
||||||
// proses pengecekkan status reservation number yang di request
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION ]: getting reservation by reservation number...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// get reservation pending & in progress status
|
|
||||||
let getReservationCanBeCanceled = await model.getReservationCanBeCanceled(
|
|
||||||
cancelReservationData.reservation_number
|
|
||||||
);
|
|
||||||
if (getReservationCanBeCanceled) {
|
|
||||||
if (
|
|
||||||
getReservationCanBeCanceled.c_status == 'I' ||
|
|
||||||
getReservationCanBeCanceled.c_status == 'A'
|
|
||||||
) {
|
|
||||||
result = {
|
|
||||||
code: '429',
|
|
||||||
message: 'can not be cancelled. The transaction has been loaded.',
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} else if (getReservationCanBeCanceled.c_status == 'X') {
|
|
||||||
let cancelDate = getReservationCanBeCanceled.d_cancel
|
|
||||||
? moment(getReservationCanBeCanceled.d_cancel).format(
|
|
||||||
'DD-MM-YYYY HH:mm:ss'
|
|
||||||
)
|
|
||||||
: '';
|
|
||||||
result = {
|
|
||||||
code: '430',
|
|
||||||
message: `can not be cancelled. The transaction has been canceled at ${cancelDate}.`,
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} else if (getReservationCanBeCanceled.c_payment_recon_no) {
|
|
||||||
result = {
|
|
||||||
code: '430',
|
|
||||||
message: `can not be cancelled. The transaction has been recon.`,
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = {
|
|
||||||
code: '414',
|
|
||||||
message: "Reservation doesn't exist.",
|
|
||||||
data: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log warn
|
|
||||||
winston.logger.warn(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION ]: ${JSON.stringify(
|
|
||||||
result
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// log debug
|
|
||||||
// proses pencarian saldo terakhir dari nomor kartu yang di request berdasarkan data log hitory
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION ]: getting last balance on the card by card history...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// get last balance on the card
|
|
||||||
let balance = 0;
|
|
||||||
let getLastBalanceFromCardHistory =
|
|
||||||
await model.getLastBalanceFromCardHistory(
|
|
||||||
getReservationCanBeCanceled.c_card_number
|
|
||||||
);
|
|
||||||
if (getLastBalanceFromCardHistory) {
|
|
||||||
balance = getLastBalanceFromCardHistory.m_balance_after;
|
|
||||||
}
|
|
||||||
|
|
||||||
// time
|
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
||||||
|
|
||||||
// binding data
|
|
||||||
let data = {
|
|
||||||
c_status: 'X',
|
|
||||||
c_status_name: 'CANCELED',
|
|
||||||
d_cancel: now,
|
|
||||||
};
|
|
||||||
|
|
||||||
// log debug
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION ]: updating reservation to status cancel...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// cancel transaction
|
|
||||||
await model.cancelReservation(
|
|
||||||
data,
|
|
||||||
cancelReservationData.reservation_number
|
|
||||||
);
|
|
||||||
|
|
||||||
// log debug
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION ]: inserting log for card history...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// log card history
|
|
||||||
await model.createReserveBalanceLog({
|
|
||||||
i_log_name: 110,
|
|
||||||
d_log: now,
|
|
||||||
c_card_number: getReservationCanBeCanceled.c_card_number,
|
|
||||||
c_source: 'CMS',
|
|
||||||
c_location: getPartner ? getPartner.partner_name : null,
|
|
||||||
m_balance_before: balance > 0 ? balance : 0,
|
|
||||||
m_amount: 0,
|
|
||||||
m_balance_after: balance > 0 ? balance : 0,
|
|
||||||
j_new_data: data,
|
|
||||||
j_old_data: getReservationCanBeCanceled,
|
|
||||||
c_note: `CANCEL RESERVE BALANCE ${
|
|
||||||
getReservationCanBeCanceled.i_reservation_amount
|
|
||||||
} FROM ${getPartner ? getPartner.partner_name : null}`,
|
|
||||||
c_status: 'S',
|
|
||||||
d_created: now,
|
|
||||||
i_create: null,
|
|
||||||
c_create_username: 'HSM',
|
|
||||||
c_create_fullname: 'HARDWARE SECURE MODULE',
|
|
||||||
c_category: 'T',
|
|
||||||
});
|
|
||||||
|
|
||||||
result = {
|
|
||||||
code: '00',
|
|
||||||
message: 'reservation successfully canceled.',
|
|
||||||
data: {
|
|
||||||
reservation_number: getReservationCanBeCanceled.c_reservation_no,
|
|
||||||
reservation_amount: getReservationCanBeCanceled.i_reservation_amount,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// log info
|
|
||||||
winston.logger.info(
|
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION ]: ${JSON.stringify(result)}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json(result);
|
|
||||||
} catch (error) {
|
|
||||||
// create log
|
|
||||||
winston.logger.error(
|
|
||||||
`[ RESPONSE CANCEL-RESERVATION ]: 500 internal server error - backend server | ${error.message}`
|
|
||||||
);
|
|
||||||
|
|
||||||
return res.status(200).json({
|
|
||||||
code: '500',
|
|
||||||
message:
|
|
||||||
process.env.NODE_ENV != 'production'
|
|
||||||
? error.message
|
|
||||||
: '500 internal server error - backend server.',
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
validate,
|
validate,
|
||||||
checkReservation,
|
checkReservation,
|
||||||
@@ -3673,6 +3030,4 @@ module.exports = {
|
|||||||
inquiryReservation,
|
inquiryReservation,
|
||||||
inquiryReservationByReservation,
|
inquiryReservationByReservation,
|
||||||
inquiryListReservationByReservation,
|
inquiryListReservationByReservation,
|
||||||
cancelReservationValidateV2,
|
|
||||||
cancelReservationV2,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
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) => {
|
||||||
let result = knex('trx.t_d_reservation_balance')
|
console.log('AKU DIPANGGIL');
|
||||||
.select('i_reservation_no_seq')
|
let result = knex("trx.t_d_reservation_balance")
|
||||||
.orderBy('i_reservation_no_seq', 'desc')
|
.select("i_reservation_no_seq")
|
||||||
.whereNotNull('i_reservation_no_seq')
|
.orderBy("i_reservation_no_seq", "desc")
|
||||||
.where('i_partner', data.i_partner)
|
.whereNotNull("i_reservation_no_seq")
|
||||||
.where('i_merchant', data.i_merchant)
|
.where("i_partner", data.i_partner)
|
||||||
.whereRaw('??::date = ?', ['d_reservation', date])
|
.where("i_merchant", data.i_merchant)
|
||||||
|
.whereRaw("??::date = ?", ["d_reservation", date])
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@@ -26,202 +27,202 @@ 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) => {
|
||||||
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 reservation_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_payment_recon_no as payment_recon_no',
|
"c_payment_recon_no as payment_recon_no",
|
||||||
'd_payment_recon as recon_date',
|
"d_payment_recon as recon_date",
|
||||||
'c_status as status_code',
|
"c_status as status_code",
|
||||||
'c_status_name as description'
|
"c_status_name as description"
|
||||||
)
|
)
|
||||||
.where('c_reservation_no', reservationNumber)
|
.where("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(
|
.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 reservation_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_payment_recon_no as payment_recon_no',
|
"c_payment_recon_no as payment_recon_no",
|
||||||
'd_payment_recon as recon_date',
|
"d_payment_recon as recon_date",
|
||||||
'c_status as status_code',
|
"c_status as status_code",
|
||||||
'c_status_name as description'
|
"c_status_name as description"
|
||||||
)
|
)
|
||||||
.where('i_partner', partnerID);
|
.where("i_partner", partnerID);
|
||||||
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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 reservation_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")
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
@@ -229,33 +230,33 @@ const getReservationPending = (cardNumber, time) => {
|
|||||||
|
|
||||||
// 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;
|
||||||
@@ -267,140 +268,66 @@ 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();
|
.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) => {
|
|
||||||
let result = knex('trx.t_d_reservation_balance')
|
|
||||||
.select(
|
|
||||||
'c_reservation_no as reservation_number',
|
|
||||||
'd_reservation as reservation_date',
|
|
||||||
'c_ref_no as ref_no',
|
|
||||||
'c_partner_name as partner_name',
|
|
||||||
'c_merchant_name as merchant_name',
|
|
||||||
'c_terminal_name as terminal_name',
|
|
||||||
'c_card_number as card_number',
|
|
||||||
'i_reservation_amount as reservation_amount',
|
|
||||||
'i_issuer_fee as issuer_fee',
|
|
||||||
'i_channel_fee as channel_fee',
|
|
||||||
'c_status as status_code',
|
|
||||||
'c_status_name as description'
|
|
||||||
)
|
|
||||||
.where('c_ref_no', refNumber);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ================================================================= INQUIRY LOAD BALANCE =================================================================
|
|
||||||
// *Created By: Teddy Setiawan*
|
|
||||||
// *Description:*
|
|
||||||
//
|
|
||||||
|
|
||||||
// INQUIRY BY LOAD BALANCE NUMBER
|
|
||||||
const inquiryListByLoadNumber = (load_balance_number) => {
|
|
||||||
let result = knex('trx.t_d_reservation_balance')
|
|
||||||
.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 reservation_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'
|
|
||||||
)
|
|
||||||
.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,
|
||||||
@@ -427,7 +354,4 @@ module.exports = {
|
|||||||
insertReservationNumber,
|
insertReservationNumber,
|
||||||
cancelReservation,
|
cancelReservation,
|
||||||
deleteReservationNumberValidate,
|
deleteReservationNumberValidate,
|
||||||
inquiryListByRefNumber,
|
|
||||||
getGlobalParameter,
|
|
||||||
inquiryListByLoadNumber,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
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(
|
router.post(
|
||||||
'/loadbalance',
|
"/loadbalance",
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate('loadingBalance'),
|
controller.validate("loadingBalance"),
|
||||||
controller.loadingBalance
|
controller.loadingBalance
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/loadbalance/inquiry',
|
"/loadbalance/inquiry",
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.inquiryLoadingBalance
|
controller.inquiryLoadingBalance
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
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 lokiMiddleware = require('../middlewares/loki.middleware');
|
|
||||||
const {
|
|
||||||
prometheusMiddleware,
|
|
||||||
} = require('../middlewares/prometheus.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 =================================================================
|
||||||
@@ -28,9 +21,6 @@ router.post(
|
|||||||
router.post(
|
router.post(
|
||||||
'/reservation',
|
'/reservation',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
prometheusMiddleware,
|
|
||||||
lokiMiddleware,
|
|
||||||
getReservationNumberSequence,
|
|
||||||
controller.validate('reservation'),
|
controller.validate('reservation'),
|
||||||
controller.reservation
|
controller.reservation
|
||||||
);
|
);
|
||||||
@@ -78,25 +68,8 @@ router.post(
|
|||||||
router.post(
|
router.post(
|
||||||
'/reservation/v2',
|
'/reservation/v2',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
prometheusMiddleware,
|
|
||||||
lokiMiddleware,
|
|
||||||
getReservationNumberSequence,
|
|
||||||
controller.validate('reservationV2'),
|
controller.validate('reservationV2'),
|
||||||
controller.reservationV2
|
controller.reservationV2
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
|
||||||
'/reservation/cancel/validate/v2',
|
|
||||||
auth.authenticateToken,
|
|
||||||
controller.validate('cancelReservation'),
|
|
||||||
controller.cancelReservationValidateV2
|
|
||||||
);
|
|
||||||
|
|
||||||
router.post(
|
|
||||||
'/reservation/cancel/v2',
|
|
||||||
auth.authenticateToken,
|
|
||||||
controller.validate('cancelReservationV2'),
|
|
||||||
controller.cancelReservationV2
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,106 +1,57 @@
|
|||||||
# ================================= ENVIRONMENT =================================
|
# environment
|
||||||
#NODE_ENV=production
|
#NODE_ENV=production
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
#NODE_ENV=testing
|
#NODE_ENV=testing
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
|
||||||
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
# database
|
||||||
# SERVER_FOR=development
|
DB_URL=postgresql://postgres:postgres@localhost:5432/CMS_DEV
|
||||||
#SERVER_FOR=production
|
|
||||||
SERVER_FOR=local
|
|
||||||
|
|
||||||
# =============================== DATABASE LOCAL =================================
|
# crypto
|
||||||
# DB_URL=postgresql://postgres:postgres@localhost:5432/CMS_DEV
|
SECRET_KEY=U2FsdGVkX19keaNhiBfdNSWnKA2a8Z5deBu/KkU6BNg=
|
||||||
DB_HOST_LOCAL=localhost
|
|
||||||
DB_NAME_LOCAL=CMS_DEV
|
|
||||||
DB_PORT_LOCAL=5432
|
|
||||||
DB_USER_LOCAL=postgres
|
|
||||||
DB_PASSWORD_LOCAL=postgres
|
|
||||||
|
|
||||||
# ==================================== REDIS =====================================
|
# jwt
|
||||||
REDIS_URL=redis://localhost:6379
|
|
||||||
REDIS_PASSWORD=
|
|
||||||
|
|
||||||
# ================================== 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
|
||||||
# FOR PRODUCTION
|
TOKEN_SECRET=U2FsdGVkX1/hnA2S3l0Evi+whG73WiOrplJA5fcfe2o=
|
||||||
#TOKEN_SECRET=101001D00C2001D0483001D0
|
REFRESH_TOKEN_SECRET=U2FsdGVkX18LvuBcY6prEGXDZhDoBa7O0GAUSzTWzdk=
|
||||||
#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=1
|
NUMBER_SERVER_ACTIVE=12
|
||||||
|
|
||||||
# ================================ KONFIGURASI HSM =================================
|
# =================================== KCI =================================
|
||||||
|
|
||||||
# system code kci profile
|
# system code kci profile
|
||||||
# FOR PRODUCTION & DEVELOPMENT
|
|
||||||
SYSTEM_CODE=90B7
|
SYSTEM_CODE=90B7
|
||||||
|
|
||||||
#SERVICE BLOCK
|
#SERVICE BLOCK
|
||||||
# FOR PRODUCTION
|
SERVICEBLOCK_SERVICE_MUTUAL="101001A00C2001A0483001A0"
|
||||||
# SERVICEBLOCK_SERVICE_MUTUAL="101001D00C2001D0483001D0"
|
SERVICEBLOCK_BLOCK_READ="80008200"
|
||||||
# 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)
|
||||||
# HSM SERVER
|
# KCI PCI
|
||||||
# URL_HSM_SERVER_1="ws://182.253.34.129/feliqserver/v1/wsapi"
|
URL_HSM_SERVER_1="ws://10.1.201.215/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)
|
||||||
# HSM SERVER
|
# KCI PCI
|
||||||
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="
|
||||||
|
|
||||||
|
|
||||||
# ============================= KONFIGURASI HSM NUTECH =============================
|
# =================================== NUTECH =================================
|
||||||
|
|
||||||
# SYSTEM CODE IN HEXA STRING
|
# SYSTEM CODE IN HEXA STRING
|
||||||
# system code nutech profile
|
# system code nutech profile
|
||||||
@@ -112,20 +63,17 @@ SECRETKEY_HSM_SERVER_BACKUP_2="xWW2o+lpAqDLIN85uHZdfuDQhhd7jCXp4w1rXhCkYEk="
|
|||||||
# SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
# SERVICEBLOCK_BLOCK_WRITE="800081008200"
|
||||||
|
|
||||||
# HSM DC (DATA CENTER)
|
# HSM DC (DATA CENTER)
|
||||||
# HSM SERVER
|
# KCI PCI
|
||||||
# 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)
|
||||||
# HSM SERVER
|
# KCI PCI
|
||||||
# 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="
|
||||||
@@ -134,5 +82,3 @@ 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="
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -16,22 +16,23 @@ 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 {
|
const {topuponline_metrics} = require("../application/helpers/prometheusmetrics");
|
||||||
topuponline_metrics,
|
const {prometheusMiddleware} = require("../application/middlewares/prometheus.middleware")
|
||||||
} = require('../application/helpers/prometheusmetrics');
|
const lokiMiddleware = require("../application/middlewares/loki.middleware")
|
||||||
|
const redisMiddleware = require("../application/middlewares/redis.middleware")
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
register.setDefaultLabels({ app: 'topuponline' });
|
register.setDefaultLabels({ app: "topuponline" });
|
||||||
client.collectDefaultMetrics({ register });
|
client.collectDefaultMetrics({ register });
|
||||||
register.registerMetric(topuponline_metrics);
|
register.registerMetric(topuponline_metrics);
|
||||||
|
|
||||||
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));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,7 +71,6 @@ 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 +84,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/', reservationRoute);
|
app.use('/api/', prometheusMiddleware, lokiMiddleware, redisMiddleware, reservationRoute);
|
||||||
app.use('/api/', invoiceRoute);
|
app.use('/api/', invoiceRoute);
|
||||||
app.use('/api/', cashinRoute);
|
app.use('/api/', cashinRoute);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user