mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 16:36:28 +00:00
Compare commits
116 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ceb25c892 | |||
| 2c744a350c | |||
| 270f859e0d | |||
| ba46437d11 | |||
| 255fb13ab7 | |||
| 7685916b19 | |||
| 0d1e4869be | |||
| 052c71220f | |||
| 6234fb5e36 | |||
| 4f72e83710 | |||
| 10f9f3a0bb | |||
| 8a5127a9e8 | |||
| bb666ee512 | |||
| 9ba2e03187 | |||
| f39c92f28d | |||
| 0f36b9f264 | |||
| c7334aa084 | |||
| e714540970 | |||
| dd52e4ce01 | |||
| c22d1b3596 | |||
| e41fa25c05 | |||
| 659531d908 | |||
| 8f8da98f6e | |||
| c8f01db5e9 | |||
| 1be5cc8d0c | |||
| 352ec2822f | |||
| 9910d4d834 | |||
| a2eb984658 | |||
| eac57a3821 | |||
| f4451aaea2 | |||
| 837d1c5d77 | |||
| 74825d277b | |||
| 8c231e9901 | |||
| 56cbc627a2 | |||
| a2a9a8c72f | |||
| 1af459fc4e | |||
| 47dc7eecc9 | |||
| a8d32ada48 | |||
| f7c5cf33f6 | |||
| 870d8aea46 | |||
| b46d3a5b25 | |||
| 5408639d80 | |||
| 9b2ab48e99 | |||
| a35492c124 | |||
| e1f0c60b37 | |||
| 16afd42876 | |||
| 3722be6eeb | |||
| 493f131779 | |||
| f10ff80284 | |||
| f30ee86552 | |||
| e8de33b663 | |||
| 68ebfb0ac2 | |||
| 96c46ad49c | |||
| 10e38babcd | |||
| 8bc68493cf | |||
| 2b1b14548a | |||
| 240bb5fa17 | |||
| 7676ec54ef | |||
| de0a8847b5 | |||
| 4df41a426c | |||
| 3401e425b4 | |||
| 0d29175942 | |||
| 4f03433bb2 | |||
| 1df5f97543 | |||
| a222714bcb | |||
| 2249bbbbaf | |||
| 16fbfdcae1 | |||
| 6b5f92e597 | |||
| baf99a975d | |||
| 70b9ef78cb | |||
| 4169b40e97 | |||
| 3566f63bea | |||
| 066fd49173 | |||
| 2c0ffbd9d6 | |||
| ee46232c7a | |||
| 15131cebb1 | |||
| 6ff785de5a | |||
| 8e997346d2 | |||
| 80dda817fb | |||
| 410ef5ac53 | |||
| d9d5be8921 | |||
| 574092e015 | |||
| 5ece7912f4 | |||
| 2540b1c6c0 | |||
| 4feb7a7724 | |||
| 4994278078 | |||
| c6488f7f69 | |||
| f0bbf54afc | |||
| 7c6ab450be | |||
| 1524d643c6 | |||
| 36b61697dd | |||
| 8366d9b38b | |||
| ed7e0ce127 | |||
| 8d1e2075c3 | |||
| 5df52be111 | |||
| 6e0627fb86 | |||
| 0235cdb7c0 | |||
| a64c38b928 | |||
| 99f004adf2 | |||
| 3e5d73dd56 | |||
| 4481079289 | |||
| 9bc1260bc0 | |||
| df8ad92eba | |||
| 3b8d9d20ff | |||
| 5197966807 | |||
| 966c7b1f60 | |||
| 002f1375e4 | |||
| ada8358c07 | |||
| b587640684 | |||
| 7d56ebbe77 | |||
| 015832c683 | |||
| 79a5c5951b | |||
| c54a030519 | |||
| 775b36cfd2 | |||
| b796bfdd5c | |||
| 25f66afa7b |
@@ -0,0 +1,92 @@
|
|||||||
|
const winston = require("winston");
|
||||||
|
require("winston-daily-rotate-file");
|
||||||
|
const expressWinston = require("express-winston");
|
||||||
|
const fs = require("fs");
|
||||||
|
const moment = require("moment");
|
||||||
|
|
||||||
|
const filename = () => {
|
||||||
|
if (!fs.existsSync(`./expresswinstonlog`)) {
|
||||||
|
fs.mkdirSync(`./expresswinstonlog`);
|
||||||
|
}
|
||||||
|
if (!fs.existsSync(`./expresswinstonlog/${moment().format("YYYY")}`)) {
|
||||||
|
fs.mkdirSync(`./expresswinstonlog/${moment().format("YYYY")}`);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
!fs.existsSync(
|
||||||
|
`./expresswinstonlog/${moment().format("YYYY")}/${moment().format("MM")}`
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
fs.mkdirSync(
|
||||||
|
`./expresswinstonlog/${moment().format("YYYY")}/${moment().format("MM")}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return `expresswinstonlog/${moment().format("YYYY")}-${moment().format(
|
||||||
|
"MM"
|
||||||
|
)}-${moment().format("DD")}.log`;
|
||||||
|
};
|
||||||
|
|
||||||
|
filename();
|
||||||
|
|
||||||
|
const logger = {
|
||||||
|
response: expressWinston.logger({
|
||||||
|
transports: [
|
||||||
|
new winston.transports.DailyRotateFile({
|
||||||
|
filename: "./expresswinstonlog/%DATE%.log",
|
||||||
|
frequency: "24h",
|
||||||
|
datePattern: "YYYY/MM/DD",
|
||||||
|
zippedArchive: true,
|
||||||
|
maxFiles: "1d",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
format: winston.format.combine(
|
||||||
|
winston.format.timestamp(),
|
||||||
|
winston.format.printf((info) => {
|
||||||
|
let body = {};
|
||||||
|
body.id = info.meta.req.id;
|
||||||
|
body.tag = "RES";
|
||||||
|
body.from = info.meta.req.ip;
|
||||||
|
body.method = info.meta.req.method;
|
||||||
|
body.endpoint = info.meta.req.originalUrl;
|
||||||
|
body.time = moment().format();
|
||||||
|
body.responseTime = `${info.meta.responseTime} ms`;
|
||||||
|
|
||||||
|
var header_auth = info.meta.req.headers["authorization"];
|
||||||
|
var issuer_name = "Web"
|
||||||
|
if (!issuer_name)
|
||||||
|
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
||||||
|
|
||||||
|
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
||||||
|
})
|
||||||
|
),
|
||||||
|
responseWhitelist: [...expressWinston.responseWhitelist, "body"],
|
||||||
|
requestWhitelist: [...expressWinston.requestWhitelist, "body", "id", "ip"],
|
||||||
|
}),
|
||||||
|
request: expressWinston.logger({
|
||||||
|
transports: [
|
||||||
|
new winston.transports.DailyRotateFile({
|
||||||
|
filename: "./expresswinstonlog/%DATE%.log",
|
||||||
|
frequency: "24h",
|
||||||
|
datePattern: "YYYY/MM/DD",
|
||||||
|
zippedArchive: true,
|
||||||
|
maxFiles: "1d",
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
format: winston.format.combine(
|
||||||
|
winston.format.timestamp(),
|
||||||
|
winston.format.printf((info) => {
|
||||||
|
let body = {};
|
||||||
|
body.id = info.meta.req.id;
|
||||||
|
body.tag = "REQ";
|
||||||
|
body.from = info.meta.req.ip;
|
||||||
|
body.method = info.meta.req.method;
|
||||||
|
body.endpoint = info.meta.req.originalUrl;
|
||||||
|
body.time = moment().format();
|
||||||
|
return `[${moment().format()}] | ${JSON.stringify(body)}`;
|
||||||
|
})
|
||||||
|
),
|
||||||
|
requestWhitelist: [...expressWinston.requestWhitelist, "body", "id", "ip"],
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { logger, filename };
|
||||||
+112
-74
@@ -1,4 +1,4 @@
|
|||||||
const CryptoJS = require("crypto-js");
|
const CryptoJS = require('crypto-js');
|
||||||
|
|
||||||
// ENCRYPT TEXT
|
// ENCRYPT TEXT
|
||||||
const encryptText = (text) => {
|
const encryptText = (text) => {
|
||||||
@@ -20,6 +20,15 @@ const decryptText = (cipherText) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// CREATE HMAC
|
||||||
|
const createHMAC = async (payload) => {
|
||||||
|
let hash = await CryptoJS.HmacSHA256(
|
||||||
|
payload,
|
||||||
|
process.env.SECRET_KEY
|
||||||
|
).toString();
|
||||||
|
return hash;
|
||||||
|
};
|
||||||
|
|
||||||
// RANDOM UNIQUE CODE
|
// RANDOM UNIQUE CODE
|
||||||
function getUniqueCode() {
|
function getUniqueCode() {
|
||||||
const maxDate = Date.now();
|
const maxDate = Date.now();
|
||||||
@@ -40,44 +49,60 @@ function randomNumberInt() {
|
|||||||
// To check if the first no is not zero
|
// To check if the first no is not zero
|
||||||
if (result.length === 1 && random === 0) result.pop();
|
if (result.length === 1 && random === 0) result.pop();
|
||||||
}
|
}
|
||||||
return parseInt( result.join("") );
|
return parseInt(result.join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// GENERATE XML REQUEST
|
// GENERATE XML REQUEST
|
||||||
function generateXMLRequest(urn, headers, items) {
|
function generateXMLRequest(urn, headers, items) {
|
||||||
let xmlRequest = ''
|
let xmlRequest = '';
|
||||||
|
|
||||||
switch (urn.toUpperCase()) {
|
switch (urn.toUpperCase()) {
|
||||||
case 'ZFMCMS_FI_001':
|
case 'ZFMCMS_FI_001':
|
||||||
|
let xmlItem = '';
|
||||||
let xmlItem = ''
|
|
||||||
|
|
||||||
items.map((item, index) => {
|
items.map((item, index) => {
|
||||||
xmlItem += `<item>
|
xmlItem += `<item>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<ITEMNO_ACC>${String(index+1).padStart(10, '0')}</ITEMNO_ACC>
|
<ITEMNO_ACC>${String(index + 1).padStart(
|
||||||
|
10,
|
||||||
|
'0'
|
||||||
|
)}</ITEMNO_ACC>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<CUSTOMER>${item.c_account_code_topup ? item.c_account_code_topup : ""}</CUSTOMER>
|
<CUSTOMER>${
|
||||||
|
item.c_account_code_topup
|
||||||
|
? item.c_account_code_topup
|
||||||
|
: ''
|
||||||
|
}</CUSTOMER>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<GL_ACCOUNT>${item.c_account_topup ? item.c_account_topup : ""}</GL_ACCOUNT>
|
<GL_ACCOUNT>${
|
||||||
|
item.c_account_topup ? item.c_account_topup : ''
|
||||||
|
}</GL_ACCOUNT>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<BUS_AREA>${item.ba ? item.ba : ""}</BUS_AREA>
|
<BUS_AREA>${item.ba ? item.ba : ''}</BUS_AREA>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<AMT_DOCCUR>${item.amount ? item.amount : ""}</AMT_DOCCUR>
|
<AMT_DOCCUR>${
|
||||||
|
item.amount ? item.amount : ''
|
||||||
|
}</AMT_DOCCUR>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<BLINE_DATE>${item.posting_date ? item.posting_date : ""}</BLINE_DATE>
|
<BLINE_DATE>${
|
||||||
|
item.posting_date ? item.posting_date : ''
|
||||||
|
}</BLINE_DATE>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<COSTCENTER></COSTCENTER>
|
<COSTCENTER></COSTCENTER>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<PROFITCENTER></PROFITCENTER>
|
<PROFITCENTER></PROFITCENTER>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<ALLOC_NMBR>${item.c_invoice_no ? item.c_invoice_no : ""}</ALLOC_NMBR>
|
<ALLOC_NMBR>${
|
||||||
|
item.c_invoice_no ? item.c_invoice_no : ''
|
||||||
|
}</ALLOC_NMBR>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<ITEM_TEXT>${item.item_text ? item.item_text : ""}</ITEM_TEXT>
|
<ITEM_TEXT>${
|
||||||
|
item.item_text ? item.item_text : ''
|
||||||
|
}</ITEM_TEXT>
|
||||||
<!--Optional:-->
|
<!--Optional:-->
|
||||||
<DE_CRE_IND>${item.de_cre}</DE_CRE_IND>
|
<DE_CRE_IND>${item.de_cre}</DE_CRE_IND>
|
||||||
</item>`
|
</item>`;
|
||||||
})
|
});
|
||||||
|
|
||||||
xmlRequest = `<SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'
|
xmlRequest = `<SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'
|
||||||
xmlns:urn='urn:sap-com:document:sap:rfc:functions'>
|
xmlns:urn='urn:sap-com:document:sap:rfc:functions'>
|
||||||
@@ -144,41 +169,38 @@ function generateXMLRequest(urn, headers, items) {
|
|||||||
</C_T_RETURN>
|
</C_T_RETURN>
|
||||||
</urn:${urn}>
|
</urn:${urn}>
|
||||||
</SOAP:Body>
|
</SOAP:Body>
|
||||||
</SOAP:Envelope>`
|
</SOAP:Envelope>`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log('Sorry, we are out of ' + urn + '.');
|
console.log('Sorry, we are out of ' + urn + '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return xmlRequest
|
return xmlRequest;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// POSTING SAP
|
// POSTING SAP
|
||||||
async function postingSAP(url, body, credential){
|
async function postingSAP(url, body, credential) {
|
||||||
try {
|
try {
|
||||||
|
const axios = require('axios');
|
||||||
const axios = require("axios");
|
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
headers : {
|
headers: {
|
||||||
'Content-Type': 'text/xml',
|
'Content-Type': 'text/xml',
|
||||||
'responseType': 'text',
|
responseType: 'text',
|
||||||
},
|
},
|
||||||
auth: {
|
auth: {
|
||||||
username: credential.username,
|
username: credential.username,
|
||||||
password: credential.password
|
password: credential.password,
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
const resp = await axios.post(url, body, config)
|
const resp = await axios.post(url, body, config);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status : resp.status,
|
status: resp.status,
|
||||||
message: "Success",
|
message: 'Success',
|
||||||
data : resp.data
|
data: resp.data,
|
||||||
}
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Error 😨
|
// Error 😨
|
||||||
|
|
||||||
@@ -188,10 +210,10 @@ async function postingSAP(url, body, credential){
|
|||||||
* status code that falls out of the range of 2xx
|
* status code that falls out of the range of 2xx
|
||||||
*/
|
*/
|
||||||
return {
|
return {
|
||||||
status : error.response.status,
|
status: error.response.status,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
data : []
|
data: [],
|
||||||
}
|
};
|
||||||
} else if (error.request) {
|
} else if (error.request) {
|
||||||
/*
|
/*
|
||||||
* The request was made but no response was received, `error.request`
|
* The request was made but no response was received, `error.request`
|
||||||
@@ -199,17 +221,17 @@ async function postingSAP(url, body, credential){
|
|||||||
* of http.ClientRequest in Node.js
|
* of http.ClientRequest in Node.js
|
||||||
*/
|
*/
|
||||||
return {
|
return {
|
||||||
status : 500,
|
status: 500,
|
||||||
message: "can't connect to sap network".toUpperCase(),
|
message: "can't connect to sap network".toUpperCase(),
|
||||||
data : []
|
data: [],
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
// Something happened in setting up the request and triggered an Error
|
// Something happened in setting up the request and triggered an Error
|
||||||
return {
|
return {
|
||||||
status : 500,
|
status: 500,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
data : []
|
data: [],
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,71 +239,87 @@ async function postingSAP(url, body, credential){
|
|||||||
// GET SOAP RESPONSE DATA
|
// GET SOAP RESPONSE DATA
|
||||||
function getXMLData(response) {
|
function getXMLData(response) {
|
||||||
const xml2js = require('xml2js');
|
const xml2js = require('xml2js');
|
||||||
// console.log(xmlString)
|
// console.log(xmlString)
|
||||||
let resSAP = {
|
let resSAP = {
|
||||||
type: '',
|
type: '',
|
||||||
message : '',
|
message: '',
|
||||||
data : {
|
data: {
|
||||||
E_DOCUMENTYEAR: '',
|
E_DOCUMENTYEAR: '',
|
||||||
E_DOCUMENTNUMBER: '',
|
E_DOCUMENTNUMBER: '',
|
||||||
// ITEM: [],
|
// ITEM: [],
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
if(response.status == 200){
|
|
||||||
|
|
||||||
|
if (response.status == 200) {
|
||||||
const options = {
|
const options = {
|
||||||
explicitArray: false,
|
explicitArray: false,
|
||||||
tagNameProcessors: [xml2js.processors.stripPrefix]
|
tagNameProcessors: [xml2js.processors.stripPrefix],
|
||||||
}
|
};
|
||||||
|
|
||||||
xml2js.parseString(response.data, options, (err, result) => {
|
xml2js.parseString(response.data, options, (err, result) => {
|
||||||
|
if (err) throw err;
|
||||||
if (err) throw err
|
|
||||||
|
|
||||||
let soapBody = result.Envelope.Body;
|
let soapBody = result.Envelope.Body;
|
||||||
|
|
||||||
if (soapBody.$) delete soapBody.$
|
if (soapBody.$) delete soapBody.$;
|
||||||
|
|
||||||
resSAP.data.E_DOCUMENTYEAR = soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTYEAR'] ? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTYEAR'] : "0000"
|
resSAP.data.E_DOCUMENTYEAR = soapBody['ZFMCMS_FI_001.Response'][
|
||||||
resSAP.data.E_DOCUMENTNUMBER = soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTNUMBER'] ? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTNUMBER'] : ""
|
'E_DOCUMENTYEAR'
|
||||||
|
]
|
||||||
|
? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTYEAR']
|
||||||
|
: '0000';
|
||||||
|
resSAP.data.E_DOCUMENTNUMBER = soapBody['ZFMCMS_FI_001.Response'][
|
||||||
|
'E_DOCUMENTNUMBER'
|
||||||
|
]
|
||||||
|
? soapBody['ZFMCMS_FI_001.Response']['E_DOCUMENTNUMBER']
|
||||||
|
: '';
|
||||||
|
|
||||||
if(soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']){
|
if (soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']) {
|
||||||
if (!Array.isArray(soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'])) {
|
if (
|
||||||
|
!Array.isArray(
|
||||||
|
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']
|
||||||
|
)
|
||||||
|
) {
|
||||||
// resSAP.data.ITEM.push(soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'])
|
// resSAP.data.ITEM.push(soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'])
|
||||||
resSAP.type = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']['TYPE']
|
resSAP.type =
|
||||||
resSAP.message = "[SAP] " + soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']['MESSAGE_1']
|
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']['TYPE'];
|
||||||
|
resSAP.message =
|
||||||
|
'[SAP] ' +
|
||||||
|
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][
|
||||||
|
'MESSAGE_1'
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
// resSAP.data.ITEM = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']
|
// resSAP.data.ITEM = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item']
|
||||||
resSAP.type = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][0]['TYPE']
|
resSAP.type =
|
||||||
|
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][0]['TYPE'];
|
||||||
|
|
||||||
const indexMessage = soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'].length - 1
|
const indexMessage =
|
||||||
let message = "[SAP] "+ soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][indexMessage]['MESSAGE_1']
|
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'].length - 1;
|
||||||
|
let message =
|
||||||
|
'[SAP] ' +
|
||||||
|
soapBody['ZFMCMS_FI_001.Response']['C_T_RETURN']['item'][
|
||||||
|
indexMessage
|
||||||
|
]['MESSAGE_1'];
|
||||||
|
|
||||||
resSAP.message = message
|
resSAP.message = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
}else {
|
resSAP.type = 'E';
|
||||||
|
resSAP.message = response.message ? response.message : 'aa';
|
||||||
resSAP.type = 'E'
|
|
||||||
resSAP.message = response.message ? response.message : "aa"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return resSAP;
|
||||||
return resSAP
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
encryptText,
|
encryptText,
|
||||||
decryptText,
|
decryptText,
|
||||||
|
createHMAC,
|
||||||
getUniqueCode,
|
getUniqueCode,
|
||||||
randomNumberInt,
|
randomNumberInt,
|
||||||
generateXMLRequest,
|
generateXMLRequest,
|
||||||
postingSAP,
|
postingSAP,
|
||||||
getXMLData
|
getXMLData,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
const moment = require("moment");
|
||||||
|
const winston = require("winston");
|
||||||
|
const loki = require("winston-loki");
|
||||||
|
require("winston-daily-rotate-file");
|
||||||
|
require("dotenv").config();
|
||||||
|
const { combine, timestamp, printf, colorize, align, json } = winston.format;
|
||||||
|
|
||||||
|
const logLevels = {
|
||||||
|
fatal: 0,
|
||||||
|
error: 1,
|
||||||
|
warn: 2,
|
||||||
|
info: 3,
|
||||||
|
debug: 4,
|
||||||
|
trace: 5,
|
||||||
|
};
|
||||||
|
var log;
|
||||||
|
|
||||||
|
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
||||||
|
filename: `./lokiLog/%DATE%-onlinetopup.log`,
|
||||||
|
datePattern: "YYYY-MM-DD",
|
||||||
|
maxFiles: "1d",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (
|
||||||
|
process.env.NODE_ENV == "production" ||
|
||||||
|
process.env.NODE_ENV == "PRODUCTION"
|
||||||
|
) {
|
||||||
|
log = winston.createLogger({
|
||||||
|
levels: logLevels,
|
||||||
|
level: process.env.LOG_LEVEL || "info",
|
||||||
|
exitOnError: false,
|
||||||
|
// format: combine(timestamp(), json()),
|
||||||
|
format: combine(
|
||||||
|
// colorize({ all: true }),
|
||||||
|
timestamp({
|
||||||
|
format: "YYYY-MM-DD HH:mm:ss.SSS",
|
||||||
|
}),
|
||||||
|
align(),
|
||||||
|
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||||
|
),
|
||||||
|
defaultMeta: { service: "topuponline" },
|
||||||
|
transports: [
|
||||||
|
new loki({
|
||||||
|
host: "http://localhost:3100",
|
||||||
|
labels: { app: "topuponline" },
|
||||||
|
json: true,
|
||||||
|
format: json(),
|
||||||
|
replaceTimestamp: true,
|
||||||
|
onConnectionError: (err) => console.error(err),
|
||||||
|
}),
|
||||||
|
new transports.Console({
|
||||||
|
format: format.combine(format.simple(), format.colorize()),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
log = winston.createLogger({
|
||||||
|
transports: [
|
||||||
|
new loki({
|
||||||
|
host: "http://localhost:3100",
|
||||||
|
labels: { app: "topuponline" },
|
||||||
|
handleExceptions: true,
|
||||||
|
handleRejections: true,
|
||||||
|
clearOnError: true,
|
||||||
|
json: true,
|
||||||
|
format: json(),
|
||||||
|
replaceTimestamp: true,
|
||||||
|
onConnectionError: (err) => console.log(`Loki error ${err}`),
|
||||||
|
}),
|
||||||
|
new winston.transports.Console({
|
||||||
|
format: combine(colorize()),
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV != "testing" && process.env.NODE_ENV != "TESTING") {
|
||||||
|
log.add(
|
||||||
|
new winston.transports.Console({
|
||||||
|
// format: winston.format.cli(),
|
||||||
|
format: combine(
|
||||||
|
colorize({ all: true }),
|
||||||
|
timestamp({
|
||||||
|
format: "YYYY-MM-DD HH:mm:ss.SSS",
|
||||||
|
}),
|
||||||
|
align(),
|
||||||
|
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
log,
|
||||||
|
};
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
const client = require("prom-client");
|
||||||
|
|
||||||
|
const topuponline_metrics = new client.Histogram({
|
||||||
|
name: "topuponline",
|
||||||
|
help: "this is the metric for getting request data based on code status",
|
||||||
|
labelNames: [
|
||||||
|
"route",
|
||||||
|
"status_code",
|
||||||
|
"issuer_name",
|
||||||
|
"method",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = { topuponline_metrics };
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
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;
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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 };
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
require('dotenv').config();
|
||||||
|
const redis = require('redis');
|
||||||
|
const moment = require('moment');
|
||||||
|
moment.locale('id');
|
||||||
|
|
||||||
|
let redisClient;
|
||||||
|
(async () => {
|
||||||
|
let redisUrl = process.env.REDIS_URL || 'redis://127.0.0.1:6379';
|
||||||
|
let redisPass = process.env.REDIS_PASSWORD || '';
|
||||||
|
|
||||||
|
redisClient = redis.createClient({
|
||||||
|
url: redisUrl,
|
||||||
|
password: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
redisClient.on('error', (error) => console.error(`Error : ${error}`));
|
||||||
|
|
||||||
|
redisClient.on('connect', () => console.log('Redis is Connected'));
|
||||||
|
|
||||||
|
redisClient.on('ready', () => console.log('Redis is Ready'));
|
||||||
|
|
||||||
|
redisClient.on('reconnecting', () => console.log('Redis is Reconnecting'));
|
||||||
|
|
||||||
|
await redisClient.connect();
|
||||||
|
})();
|
||||||
|
|
||||||
|
const redisMiddleware = async (req, res, next) => {
|
||||||
|
let isRedisReady = await redisClient.isReady;
|
||||||
|
if (!isRedisReady) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
let getValue = await redisClient.get('cardproduct');
|
||||||
|
let parsedValue = JSON.parse(getValue);
|
||||||
|
|
||||||
|
if (getValue) {
|
||||||
|
res.status(200).json({
|
||||||
|
code: 200,
|
||||||
|
message: 'Success get from redis',
|
||||||
|
data: parsedValue,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
res.on('finish', async () => {
|
||||||
|
await redisClient.set('cardproduct', JSON.stringify(res.body), {
|
||||||
|
EX: 10,
|
||||||
|
NX: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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
@@ -1,30 +1,30 @@
|
|||||||
const { param, body, validationResult } = require("express-validator");
|
const { param, body, validationResult } = require('express-validator');
|
||||||
const helper = require("../../helpers/helper");
|
const helper = require('../../helpers/helper');
|
||||||
const winston = require("../../helpers/winston.logger");
|
const winston = require('../../helpers/winston.logger');
|
||||||
const model = require("./history.model");
|
const model = require('./history.model');
|
||||||
const moment = require("moment");
|
const moment = require('moment');
|
||||||
moment.locale("id");
|
moment.locale('id');
|
||||||
|
|
||||||
// VALIDATION
|
// VALIDATION
|
||||||
const validate = (method) => {
|
const validate = (method) => {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "cardHistory":
|
case 'cardHistory':
|
||||||
return [
|
return [
|
||||||
body("data")
|
body('data')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Data is required")
|
.withMessage('Data is required')
|
||||||
.isArray()
|
.isArray()
|
||||||
.withMessage("Data is invalid request format"),
|
.withMessage('Data is invalid request format'),
|
||||||
];
|
];
|
||||||
case "history":
|
case 'history':
|
||||||
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("card_number")
|
body('card_number')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Card Number is required"),
|
.withMessage('Card Number is required'),
|
||||||
];
|
];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -32,10 +32,15 @@ const validate = (method) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// HISTORY FROM CARD
|
// ================================================================= HISTORY FROM CARD =================================================================
|
||||||
|
// *Created By: Mohamad Ihsan*
|
||||||
|
// *Description:*
|
||||||
|
// proses yang digunakan untuk menampilkan history kartu berdasrkan data / content yang tersimpan di dalam kartu
|
||||||
|
|
||||||
const cardHistory = async (req, res) => {
|
const cardHistory = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// generate unique code
|
// generate unique code
|
||||||
|
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||||
let uniqueCode = await helper.getUniqueCode();
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
@@ -44,21 +49,21 @@ const cardHistory = async (req, res) => {
|
|||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} REQUEST card history: ${JSON.stringify(req.body)}`
|
`${uniqueCode} [ REQUEST CARD-HISTORY ]: ${JSON.stringify(req.body)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// check validator
|
// check validator
|
||||||
const err = validationResult(req, res);
|
const err = validationResult(req, res);
|
||||||
if (!err.isEmpty()) {
|
if (!err.isEmpty()) {
|
||||||
result = {
|
result = {
|
||||||
code: "400",
|
code: '400',
|
||||||
message: err.errors[0].msg,
|
message: err.errors[0].msg,
|
||||||
data: {},
|
data: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE card history: ${JSON.stringify(result)}`
|
`${uniqueCode} [ RESPONSE CARD-HISTORY ]: ${JSON.stringify(result)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
@@ -76,44 +81,66 @@ const cardHistory = async (req, res) => {
|
|||||||
let indexHistory = 0;
|
let indexHistory = 0;
|
||||||
let checkReskaFormat;
|
let checkReskaFormat;
|
||||||
let checkKCIFormat;
|
let checkKCIFormat;
|
||||||
|
|
||||||
|
// lakukan perulangan data array yang dikirim dari client
|
||||||
for (let index = 0; index < data.length; index++) {
|
for (let index = 0; index < data.length; index++) {
|
||||||
element = data[index];
|
element = data[index];
|
||||||
|
|
||||||
if (element != "00000000000000000000000000000000") {
|
if (element != '00000000000000000000000000000000') {
|
||||||
date = moment(
|
date = moment(
|
||||||
new Date((parseInt(element.slice(0, 8), 16) + 946684800) * 1000)
|
new Date((parseInt(element.slice(0, 8), 16) + 946684800) * 1000)
|
||||||
).format("YYYY-MM-DD HH:mm:ss");
|
).format('YYYY-MM-DD HH:mm:ss');
|
||||||
nominal = parseInt(element.slice(8, 16), 16);
|
nominal = parseInt(element.slice(8, 16), 16);
|
||||||
mid = element.slice(16, 20);
|
mid = element.slice(16, 20);
|
||||||
tid = element.slice(20, 24);
|
tid = element.slice(20, 24);
|
||||||
|
|
||||||
|
// blok yang menandakan konten untuk reska
|
||||||
checkReskaFormat = element.slice(14, 20);
|
checkReskaFormat = element.slice(14, 20);
|
||||||
|
|
||||||
|
// blok yang menandakan konten untuk KCI
|
||||||
checkKCIFormat = element.slice(26, 28);
|
checkKCIFormat = element.slice(26, 28);
|
||||||
|
|
||||||
if (checkReskaFormat == "000000") {
|
// jika blok untuk reska itu 000000 maka state bahwa itu transaki deduct dari sistem reska
|
||||||
istopup = "Deduct";
|
if (checkReskaFormat == '000000') {
|
||||||
|
istopup = 'Deduct';
|
||||||
|
|
||||||
|
// get nominal dari blok konten yang dikirim
|
||||||
nominal = parseInt(element.slice(20, 24), 16);
|
nominal = parseInt(element.slice(20, 24), 16);
|
||||||
|
|
||||||
date = element.slice(4, 8) + '-' + element.slice(2, 4) + '-' + element.slice(0, 2) + ' ' + element.slice(8, 10) + ':' + element.slice(10, 12) + ':' + element.slice(12, 14);
|
// get date dari blok konten yang dikirim
|
||||||
|
date =
|
||||||
|
element.slice(4, 8) +
|
||||||
|
'-' +
|
||||||
|
element.slice(2, 4) +
|
||||||
|
'-' +
|
||||||
|
element.slice(0, 2) +
|
||||||
|
' ' +
|
||||||
|
element.slice(8, 10) +
|
||||||
|
':' +
|
||||||
|
element.slice(10, 12) +
|
||||||
|
':' +
|
||||||
|
element.slice(12, 14);
|
||||||
|
|
||||||
// get terminal name
|
// get terminal name
|
||||||
terminalName = "PARKIR RESKA";
|
terminalName = 'PARKIR RESKA';
|
||||||
console.log('HAHAHHAHAHAHHAHAHAHAHAHHA');
|
} else if (checkKCIFormat == '00') {
|
||||||
} else if (checkKCIFormat == "00") {
|
// jika blok untuk KCI itu 00 maka state bahwa itu transaksi dari sistem KCI
|
||||||
|
// ambil konten di blok ke 25 dan 26, jika konten nya == 0 maka itu transaksi topup, dan jika bukan 0 maka itu transaksi deduct
|
||||||
istopup =
|
istopup =
|
||||||
parseInt(element.slice(24, 26), 16) == 0 ? "Topup" : "Deduct";
|
parseInt(element.slice(24, 26), 16) == 0 ? 'Topup' : 'Deduct';
|
||||||
|
|
||||||
// get terminal name
|
// get terminal name
|
||||||
terminalName = await model.getTerminalKCIExisting(mid);
|
terminalName = await model.getTerminalKCIExisting(mid);
|
||||||
terminalName = terminalName ? terminalName.merchant_name : "";
|
terminalName = terminalName ? terminalName.merchant_name : '';
|
||||||
} else {
|
} else {
|
||||||
|
// jika bukan blok reska dan KCI maka cek dari tid mid dari sistem CMS
|
||||||
|
// ambil konten di blok ke 25 dan 26, jika konten nya == 0 maka itu transaksi topup, dan jika bukan 0 maka itu transaksi deduct
|
||||||
istopup =
|
istopup =
|
||||||
parseInt(element.slice(24, 26), 16) == 0 ? "Topup" : "Deduct";
|
parseInt(element.slice(24, 26), 16) == 0 ? 'Topup' : 'Deduct';
|
||||||
|
|
||||||
// get terminal name
|
// get terminal name
|
||||||
terminalName = await model.getPartnerPartialMIDTID(mid, tid);
|
terminalName = await model.getPartnerPartialMIDTID(mid, tid);
|
||||||
terminalName = terminalName ? terminalName.merchant_name : "";
|
terminalName = terminalName ? terminalName.merchant_name : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
history[indexHistory] = {
|
history[indexHistory] = {
|
||||||
@@ -128,74 +155,132 @@ const cardHistory = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
code: "00",
|
code: '00',
|
||||||
message: "success",
|
message: 'success',
|
||||||
data: history,
|
data: history,
|
||||||
};
|
};
|
||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} RESPONSE card history: ${JSON.stringify(result)}`
|
`${uniqueCode} [ RESPONSE CARD-HISTORY ]: ${JSON.stringify(result)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// create log
|
// create log
|
||||||
winston.logger.error(
|
winston.logger.error(
|
||||||
`500 internal server error - backend server | ${error.message}`
|
`[ RESPONSE CARD-HISTORY ]: 500 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
code: "500",
|
code: '500',
|
||||||
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: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// HISTORY FROM CMS
|
// ================================================================= HISTORY FROM CMS =================================================================
|
||||||
|
// *Created By: Mohamad Ihsan*
|
||||||
|
// *Description:*
|
||||||
|
// proses yang digunakan untuk menampilkan history kartu berdasrkan log di sistem CMS
|
||||||
|
|
||||||
const history = async (req, res) => {
|
const history = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// check validator
|
// generate unique code
|
||||||
const err = validationResult(req, res);
|
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||||
if (!err.isEmpty()) {
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
return res.status(200).json({
|
let result = {};
|
||||||
code: "400",
|
|
||||||
message: err.errors[0].msg,
|
|
||||||
data: {},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// param
|
// param
|
||||||
let { mid, tid, card_number, start_date, end_date } = req.body;
|
let { mid, tid, card_number, start_date, end_date } = req.body;
|
||||||
|
|
||||||
|
// log info
|
||||||
|
winston.logger.info(
|
||||||
|
`${uniqueCode} [ REQUEST CARD-HISTORY-FROM-CMS ]: ${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 CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
|
}
|
||||||
|
|
||||||
// time
|
// time
|
||||||
let now = moment().format("YYYY-MM-DD HH:mm:ss");
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} [ PROCESSING CARD-HISTORY-FROM-CMS ]: checking parameter start date and end date...`
|
||||||
|
);
|
||||||
|
|
||||||
// validation inquiry date
|
// validation inquiry date
|
||||||
if ((!start_date && end_date) || (start_date && !end_date)) {
|
if ((!start_date && end_date) || (start_date && !end_date)) {
|
||||||
return res.status(200).json({
|
result = {
|
||||||
code: "400",
|
code: '400',
|
||||||
message: "bad request. please check the date!",
|
message: 'bad request. please check the date!',
|
||||||
data: {},
|
data: {},
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} [ PROCESSING CARD-HISTORY-FROM-CMS ]: checking mid and tid is valid or not...`
|
||||||
|
);
|
||||||
|
|
||||||
// get partner, merchant, terminal from tid
|
// get partner, merchant, terminal from tid
|
||||||
let getPartner = await model.getPartner(mid, tid);
|
let getPartner = await model.getPartner(mid, tid);
|
||||||
if (!getPartner) {
|
if (!getPartner) {
|
||||||
return res.status(200).json({
|
result = {
|
||||||
code: "412",
|
code: '412',
|
||||||
message: "terminal id is not valid",
|
message: 'terminal id is not valid',
|
||||||
data: {},
|
data: {},
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// card history and load balance transaction
|
// log debug
|
||||||
let result = await model.historyByCardNumber(
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} [ PROCESSING CARD-HISTORY-FROM-CMS ]: getting history card from log CMS...`
|
||||||
|
);
|
||||||
|
|
||||||
|
// get data history kartu di log sistem CMS
|
||||||
|
let history = await model.historyByCardNumber(
|
||||||
mid,
|
mid,
|
||||||
tid,
|
tid,
|
||||||
card_number,
|
card_number,
|
||||||
@@ -203,26 +288,50 @@ const history = async (req, res) => {
|
|||||||
end_date
|
end_date
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!result) {
|
// jika history tidak ditemukan di log sistem CMS
|
||||||
return res.status(200).json({
|
if (!history) {
|
||||||
code: "422",
|
result = {
|
||||||
|
code: '422',
|
||||||
message: "history doesn't exist",
|
message: "history doesn't exist",
|
||||||
data: [],
|
data: [],
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.json({
|
result = {
|
||||||
code: "00",
|
code: '00',
|
||||||
message: "history has been found.",
|
message: 'history has been found.',
|
||||||
data: result,
|
data: result,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
// log info
|
||||||
|
winston.logger.info(
|
||||||
|
`${uniqueCode} [ RESPONSE CARD-HISTORY-FROM-CMS ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.json(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// create log
|
||||||
|
winston.logger.error(
|
||||||
|
`[ RESPONSE CARD-HISTORY-FROM-CMS ]: 500 internal server error - backend server | ${error.message}`
|
||||||
|
);
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
code: "500",
|
code: '500',
|
||||||
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: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,38 +86,38 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
`${uniqueCode} checking production card number or not...`
|
`${uniqueCode} checking production card number or not...`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (process.env.SERVER_FOR == 'production') {
|
// if (process.env.SERVER_FOR == 'production') {
|
||||||
if (card_number.substring(0, 1) != '1') {
|
// if (card_number.substring(0, 1) != '1') {
|
||||||
result = {
|
// result = {
|
||||||
code: '400',
|
// code: '400',
|
||||||
message: "It's not production card number.",
|
// message: "It's not production card number.",
|
||||||
data: {},
|
// data: {},
|
||||||
};
|
// };
|
||||||
|
|
||||||
// log warn
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
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
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// time
|
// time
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
@@ -192,13 +192,69 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
winston.logger.debug(`${uniqueCode} checking reservation pending...`);
|
winston.logger.debug(`${uniqueCode} checking reservation pending...`);
|
||||||
|
|
||||||
// get total reservation pending
|
// get total reservation pending
|
||||||
let getReservationPending = await model.getReservationPending(
|
let getReservationPending = await model.getReservationPendingV2(
|
||||||
card_number,
|
card_number,
|
||||||
now,
|
now,
|
||||||
flag
|
flag
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// cek disini apakah sebelumnya topup
|
||||||
|
const cardHistory = await model.checkCardHistory(card_number);
|
||||||
|
|
||||||
|
if (cardHistory.length > 0) {
|
||||||
|
if (cardHistory.i_log_name == 21 && cardHistory.c_source == 'CMS') {
|
||||||
|
if (getReservationPending.length > 0) {
|
||||||
|
// insert semua reserve balance ke fraud
|
||||||
|
const dataFraud = [];
|
||||||
|
const rsv = [];
|
||||||
|
for (const item of getReservationPending) {
|
||||||
|
rsv.push(item.c_reservation_no);
|
||||||
|
dataFraud.push({
|
||||||
|
c_card_number: item.c_card_number,
|
||||||
|
c_reservation_no: item.c_reservation_no,
|
||||||
|
i_reservation_amount: parseInt(item.i_reservation_amount),
|
||||||
|
c_reservation_status: item.c_status,
|
||||||
|
c_reservation_flag: item.c_flag,
|
||||||
|
c_reservation_ref_no: item.c_ref_no,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} INSERT TO trx.t_d_froud ${JSON.stringify(dataFraud)}`
|
||||||
|
);
|
||||||
|
const fraud = await model.insertFraud(dataFraud);
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} RESERVE NUMBER FROM trx.t_d_froud ${JSON.stringify(
|
||||||
|
fraud
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} reserve number ${JSON.stringify(rsv)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// update reserve balance
|
||||||
|
await model.updateFraudToReserve(rsv);
|
||||||
|
} else {
|
||||||
|
result = {
|
||||||
|
code: '414',
|
||||||
|
message: "reservation doesn't exist",
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get total reservation pending with compare flag counter on card and the reservation transaction
|
// get total reservation pending with compare flag counter on card and the reservation transaction
|
||||||
|
// where status != -1
|
||||||
let getReservationPendingWithFlagCounter =
|
let getReservationPendingWithFlagCounter =
|
||||||
await model.getReservationPendingWithFlagCounter(card_number, now, flag);
|
await model.getReservationPendingWithFlagCounter(card_number, now, flag);
|
||||||
|
|
||||||
@@ -211,13 +267,22 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
// await model.getReservationPendingWithFlag(card_number, now);
|
// await model.getReservationPendingWithFlag(card_number, now);
|
||||||
|
|
||||||
if (getReservationPendingWithFlagCounter.length > 0) {
|
if (getReservationPendingWithFlagCounter.length > 0) {
|
||||||
if (lastFlag && parseInt(lastFlag) <= parseInt(flag)) {
|
if (lastFlag) {
|
||||||
|
if (parseInt(lastFlag) <= parseInt(flag)) {
|
||||||
let reservationNumberPendingSuccessLoaded = [];
|
let reservationNumberPendingSuccessLoaded = [];
|
||||||
let loadBalanceNumberPendingSuccessLoaded = [];
|
let loadBalanceNumberPendingSuccessLoaded = [];
|
||||||
|
let totalReservationAmount = 0;
|
||||||
|
|
||||||
getReservationPendingWithFlagCounter.forEach((element) => {
|
getReservationPendingWithFlagCounter.forEach((element) => {
|
||||||
reservationNumberPendingSuccessLoaded.push(element.c_reservation_no);
|
reservationNumberPendingSuccessLoaded.push(
|
||||||
loadBalanceNumberPendingSuccessLoaded.push(element.c_load_balance_no);
|
element.c_reservation_no
|
||||||
|
);
|
||||||
|
if (element.c_load_balance_no) {
|
||||||
|
loadBalanceNumberPendingSuccessLoaded.push(
|
||||||
|
element.c_load_balance_no
|
||||||
|
);
|
||||||
|
}
|
||||||
|
totalReservationAmount += parseInt(element.i_reservation_amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
@@ -234,7 +299,9 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
card_number,
|
card_number,
|
||||||
balance,
|
balance,
|
||||||
flag,
|
flag,
|
||||||
uniqueCode
|
uniqueCode,
|
||||||
|
totalReservationAmount,
|
||||||
|
uid
|
||||||
);
|
);
|
||||||
|
|
||||||
if (insertUpdate) {
|
if (insertUpdate) {
|
||||||
@@ -275,6 +342,7 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
// winston.logger.debug(`${uniqueCode} updating flag to server...`);
|
// winston.logger.debug(`${uniqueCode} updating flag to server...`);
|
||||||
@@ -286,7 +354,7 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
winston.logger.debug(`${uniqueCode} checking reservation pending...`);
|
winston.logger.debug(`${uniqueCode} checking reservation pending...`);
|
||||||
|
|
||||||
// reget total reservation pending
|
// reget total reservation pending
|
||||||
getReservationPending = await model.getReservationPending(
|
getReservationPending = await model.getReservationPendingV2(
|
||||||
card_number,
|
card_number,
|
||||||
now,
|
now,
|
||||||
flag
|
flag
|
||||||
@@ -321,14 +389,6 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
i++;
|
i++;
|
||||||
});
|
});
|
||||||
|
|
||||||
// log debug
|
|
||||||
winston.logger.debug(
|
|
||||||
`${uniqueCode} updating status reservation to in progress...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// update status to in progress
|
|
||||||
await model.updateStatusReservation(reservationNumberTemp, now);
|
|
||||||
|
|
||||||
totalReservation = i;
|
totalReservation = i;
|
||||||
if (totalReservation == 0) {
|
if (totalReservation == 0) {
|
||||||
result = {
|
result = {
|
||||||
@@ -347,6 +407,11 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} checking the card number in list fraud transaction or not...`
|
||||||
|
);
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(`${uniqueCode} checking total topup amount...`);
|
winston.logger.debug(`${uniqueCode} checking total topup amount...`);
|
||||||
|
|
||||||
@@ -442,11 +507,24 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} updating status reservation to in progress...${reservationNumberTemp}, ${now}, ${flag}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// update status to in progress
|
||||||
|
let updateStatusReservation = await model.updateStatusReservation(
|
||||||
|
reservationNumberTemp,
|
||||||
|
now,
|
||||||
|
flag
|
||||||
|
);
|
||||||
|
|
||||||
|
if (updateStatusReservation) {
|
||||||
result = {
|
result = {
|
||||||
code: '00',
|
code: '00',
|
||||||
message: 'reservation exists',
|
message: 'reservation exists',
|
||||||
data: {
|
data: {
|
||||||
amount: amountTopup,
|
amount: parseInt(amountTopup),
|
||||||
total_reservation: totalReservation,
|
total_reservation: totalReservation,
|
||||||
reservation_number: reservationNumber,
|
reservation_number: reservationNumber,
|
||||||
},
|
},
|
||||||
@@ -454,8 +532,28 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(result)}`
|
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
result = {
|
||||||
|
code: '434',
|
||||||
|
message: '[434] Failed, please try again later',
|
||||||
|
data: {
|
||||||
|
amount: parseInt(amountTopup),
|
||||||
|
total_reservation: totalReservation,
|
||||||
|
reservation_number: reservationNumber,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log info
|
||||||
|
winston.logger.info(
|
||||||
|
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return res.json(result);
|
return res.json(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -523,38 +621,38 @@ const loadingBalance = async (req, res) => {
|
|||||||
`${uniqueCode} checking production card number or not...`
|
`${uniqueCode} checking production card number or not...`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (process.env.SERVER_FOR == 'production') {
|
// if (process.env.SERVER_FOR == 'production') {
|
||||||
if (card_number.substring(0, 1) != '1') {
|
// if (card_number.substring(0, 1) != '1') {
|
||||||
result = {
|
// result = {
|
||||||
code: '400',
|
// code: '400',
|
||||||
message: "It's not production card number.",
|
// message: "It's not production card number.",
|
||||||
data: {},
|
// data: {},
|
||||||
};
|
// };
|
||||||
|
|
||||||
// log warn
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
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
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// time
|
// time
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
@@ -667,7 +765,7 @@ const loadingBalance = async (req, res) => {
|
|||||||
amountTopup += parseInt(rsv.i_reservation_amount);
|
amountTopup += parseInt(rsv.i_reservation_amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (amount != amountTopup) {
|
if (parseInt(amount) != parseInt(amountTopup)) {
|
||||||
result = {
|
result = {
|
||||||
code: '418',
|
code: '418',
|
||||||
message: 'topup amount is different',
|
message: 'topup amount is different',
|
||||||
@@ -951,8 +1049,8 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
let today = moment().format('YYYY-MM-DD');
|
let today = moment().format('YYYY-MM-DD');
|
||||||
|
|
||||||
// log debug
|
// log warn
|
||||||
winston.logger.debug(`${uniqueCode} checking partner...`);
|
winston.logger.warn(`${uniqueCode} checking partner...`);
|
||||||
|
|
||||||
// get partner, merchant, terminal from tid
|
// get partner, merchant, terminal from tid
|
||||||
let getPartner = await model.getPartner(mid, tid);
|
let getPartner = await model.getPartner(mid, tid);
|
||||||
@@ -971,8 +1069,8 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// log debug
|
// log warn
|
||||||
winston.logger.debug(`${uniqueCode} checking reservation status...`);
|
winston.logger.warn(`${uniqueCode} checking reservation status...`);
|
||||||
|
|
||||||
// check reservation status
|
// check reservation status
|
||||||
for (let index = 0; index < reservation_number.length; index++) {
|
for (let index = 0; index < reservation_number.length; index++) {
|
||||||
@@ -980,6 +1078,7 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
reservation_number[index]
|
reservation_number[index]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// if reservation doesn't exist or has been canceled
|
||||||
if (!reservationStatus) {
|
if (!reservationStatus) {
|
||||||
result = {
|
result = {
|
||||||
code: '414',
|
code: '414',
|
||||||
@@ -997,10 +1096,14 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if there are reservation with status active
|
||||||
if (reservationStatus.c_status == 'A') {
|
if (reservationStatus.c_status == 'A') {
|
||||||
var reservationLoaded = await model.findReservationLoaded(
|
// if there are reservation on load balance table transaction but before process on reservation failed update to LOADED
|
||||||
|
let reservationLoaded = await model.findReservationLoaded(
|
||||||
reservationStatus.i_reservation_balance
|
reservationStatus.i_reservation_balance
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (reservationLoaded) {
|
||||||
let loadBalanceNumberExisting = reservationLoaded.c_load_balance_no;
|
let loadBalanceNumberExisting = reservationLoaded.c_load_balance_no;
|
||||||
let loadDate = reservationLoaded.d_load_balance;
|
let loadDate = reservationLoaded.d_load_balance;
|
||||||
result = {
|
result = {
|
||||||
@@ -1023,15 +1126,67 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// log debug
|
// log warn
|
||||||
winston.logger.debug(`${uniqueCode} checking reservation pending...`);
|
winston.logger.warn(`${uniqueCode} checking last log history...`);
|
||||||
|
|
||||||
// get total reservation pending
|
// get last history by card number
|
||||||
let getReservationPending = await model.getReservationPending(
|
let lastHistory = await model.getLastHistory(card_number);
|
||||||
|
|
||||||
|
if (lastHistory) {
|
||||||
|
// if last history card is topup (21 = log name id for topup)
|
||||||
|
if (lastHistory.i_log_name == 21 && lastHistory.c_source == 'CMS') {
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(`${uniqueCode} inserting fraud transaction...`);
|
||||||
|
|
||||||
|
// insert reservation transaction to fraud table
|
||||||
|
await model.insertFraudTransaction(reservation_number);
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(`${uniqueCode} suspending reservation...`);
|
||||||
|
|
||||||
|
// update reservation with suspend status
|
||||||
|
await model.suspendReservation(reservation_number, now);
|
||||||
|
|
||||||
|
result = {
|
||||||
|
code: '432',
|
||||||
|
message: 'your card number has fraud transaction',
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(`${uniqueCode} checking fraud transaction...`);
|
||||||
|
|
||||||
|
// get data fraud by card number and status fraud is not closed
|
||||||
|
let fraudTransaction = await model.getFraudTransaction(card_number);
|
||||||
|
let fraudReservationNumber = [];
|
||||||
|
|
||||||
|
if (fraudTransaction.length > 0) {
|
||||||
|
fraudTransaction.forEach((rsv) => {
|
||||||
|
fraudReservationNumber.push(rsv.c_reservation_no);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(`${uniqueCode} checking reservation pending...`);
|
||||||
|
|
||||||
|
// get total reservation pending without fraud
|
||||||
|
let getReservationPending = await model.getReservationPendingWithoutFraud(
|
||||||
card_number,
|
card_number,
|
||||||
now,
|
flag,
|
||||||
flag
|
fraudReservationNumber
|
||||||
);
|
);
|
||||||
|
|
||||||
if (getReservationPending.length < 1) {
|
if (getReservationPending.length < 1) {
|
||||||
@@ -1049,8 +1204,8 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// log debug
|
// log warn
|
||||||
winston.logger.debug(`${uniqueCode} checking total topup amount...`);
|
winston.logger.warn(`${uniqueCode} checking total topup amount...`);
|
||||||
|
|
||||||
// check total topup and request topup
|
// check total topup and request topup
|
||||||
let amountTopup = 0;
|
let amountTopup = 0;
|
||||||
@@ -1058,7 +1213,7 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
amountTopup += parseInt(rsv.i_reservation_amount);
|
amountTopup += parseInt(rsv.i_reservation_amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (amount != amountTopup) {
|
if (parseInt(amount) != parseInt(amountTopup)) {
|
||||||
result = {
|
result = {
|
||||||
code: '418',
|
code: '418',
|
||||||
message: 'topup amount is different',
|
message: 'topup amount is different',
|
||||||
@@ -1091,8 +1246,8 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
? parseInt(getLoadBalanceSequence.i_load_balance_no_seq) + 1
|
? parseInt(getLoadBalanceSequence.i_load_balance_no_seq) + 1
|
||||||
: 1;
|
: 1;
|
||||||
|
|
||||||
// log debug
|
// log warn
|
||||||
winston.logger.debug(`${uniqueCode} generating load balance number...`);
|
winston.logger.warn(`${uniqueCode} generating load balance number...`);
|
||||||
|
|
||||||
loadBalanceNumber = await generateLoadBalanceNumber(
|
loadBalanceNumber = await generateLoadBalanceNumber(
|
||||||
getPartner,
|
getPartner,
|
||||||
@@ -1100,6 +1255,11 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
loadBalanceNoSequence
|
loadBalanceNoSequence
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} load balance number is ${loadBalanceNumber}.`
|
||||||
|
);
|
||||||
|
|
||||||
if (maxLoop > 20) {
|
if (maxLoop > 20) {
|
||||||
// create log
|
// create log
|
||||||
winston.logger.error(
|
winston.logger.error(
|
||||||
@@ -1136,8 +1296,8 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
c_tid: getPartner ? getPartner.tid : null,
|
c_tid: getPartner ? getPartner.tid : null,
|
||||||
c_card_number: card_number,
|
c_card_number: card_number,
|
||||||
i_execution_id: execution_id,
|
i_execution_id: execution_id,
|
||||||
i_topup_amount: amount,
|
i_topup_amount: amount ? parseInt(amount) : amount,
|
||||||
m_balance: balance,
|
m_balance: balance ? parseInt(balance) : balance,
|
||||||
c_return_sap: null,
|
c_return_sap: null,
|
||||||
i_load_balance_no_seq: loadBalanceNoSequence,
|
i_load_balance_no_seq: loadBalanceNoSequence,
|
||||||
c_idm: uid,
|
c_idm: uid,
|
||||||
@@ -1161,8 +1321,13 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
winston.logger.debug(`${uniqueCode} getting reservation detail...`);
|
winston.logger.debug(`${uniqueCode} getting reservation detail...`);
|
||||||
|
|
||||||
let detail = [];
|
let detail = [];
|
||||||
for (let index = 0; index < reservation_number.length; index++) {
|
reservation_number = [];
|
||||||
let reservation = await model.findReservation(reservation_number[index]);
|
for (let index = 0; index < getReservationPending.length; index++) {
|
||||||
|
reservation_number.push(getReservationPending[index].c_reservation_no);
|
||||||
|
|
||||||
|
let reservation = await model.findReservation(
|
||||||
|
getReservationPending[index].c_reservation_no
|
||||||
|
);
|
||||||
|
|
||||||
if (!reservation) {
|
if (!reservation) {
|
||||||
result = {
|
result = {
|
||||||
@@ -1223,11 +1388,11 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
`${uniqueCode} checking load balance transaction has been exists or not...`
|
`${uniqueCode} checking load balance transaction has been exists or not...`
|
||||||
);
|
);
|
||||||
|
|
||||||
// log debug
|
// log warn
|
||||||
winston.logger.debug(`${uniqueCode} inserting load balance transaction...`);
|
winston.logger.warn(`${uniqueCode} inserting load balance transaction...`);
|
||||||
|
|
||||||
// insert transaction
|
// insert transaction
|
||||||
await model.insertLoadingBalance(
|
let insertLoadingBalance = await model.insertLoadingBalance(
|
||||||
data,
|
data,
|
||||||
detail,
|
detail,
|
||||||
reservation_number,
|
reservation_number,
|
||||||
@@ -1239,6 +1404,22 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
flag
|
flag
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} AAAAAAAAAAAAAAAAAA [DATA] : ${JSON.stringify(
|
||||||
|
data
|
||||||
|
)} [DETAIL] : ${JSON.stringify(detail)} [RSV] : ${JSON.stringify(
|
||||||
|
reservation_number
|
||||||
|
)} [NOW] : ${JSON.stringify(now)} [WRITE STATUS] : ${JSON.stringify(
|
||||||
|
write_status
|
||||||
|
)} [CARD NUMBER] : ${JSON.stringify(
|
||||||
|
card_number
|
||||||
|
)} [UID] : ${JSON.stringify(uid)} [BALANCE] : ${JSON.stringify(
|
||||||
|
balance
|
||||||
|
)} [FLAG] : ${JSON.stringify(flag)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (insertLoadingBalance > 0) {
|
||||||
result = {
|
result = {
|
||||||
code: '00',
|
code: '00',
|
||||||
message: write_status
|
message: write_status
|
||||||
@@ -1253,6 +1434,20 @@ const loadingBalanceInsert = async (param) => {
|
|||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
result = {
|
||||||
|
code: '433',
|
||||||
|
message: '[433] Failed, please try again later',
|
||||||
|
data: {
|
||||||
|
load_balance_number: loadBalanceNumber,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(result)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -1782,7 +1977,9 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
cardNumber,
|
cardNumber,
|
||||||
balance,
|
balance,
|
||||||
flag,
|
flag,
|
||||||
uniqueCode
|
uniqueCode,
|
||||||
|
totalReservationAmount,
|
||||||
|
uid
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
// log debug
|
// log debug
|
||||||
@@ -1795,17 +1992,18 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
|
|
||||||
// get load balance
|
// get load balance
|
||||||
let dataLoadingBalance = null;
|
let dataLoadingBalance = null;
|
||||||
|
let dataLoadingBalanceDetail = [];
|
||||||
|
|
||||||
|
if (loadBalanceNumber.length > 0) {
|
||||||
let getLastLoadingBalanceFlag = await model.getLastLoadingBalanceFlag(
|
let getLastLoadingBalanceFlag = await model.getLastLoadingBalanceFlag(
|
||||||
loadBalanceNumber
|
loadBalanceNumber
|
||||||
);
|
);
|
||||||
if (getLastLoadingBalanceFlag) {
|
if (getLastLoadingBalanceFlag) {
|
||||||
dataLoadingBalance = getLastLoadingBalanceFlag;
|
dataLoadingBalance = getLastLoadingBalanceFlag;
|
||||||
} else {
|
}
|
||||||
// insert new load balance transaction by data on card and update data reservation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get detail load balance
|
// get detail load balance
|
||||||
let dataLoadingBalanceDetail = [];
|
|
||||||
if (dataLoadingBalance) {
|
if (dataLoadingBalance) {
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
@@ -1821,12 +2019,12 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataLoadingBalance && dataLoadingBalanceDetail.length > 0) {
|
|
||||||
// time
|
// time
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
let today = moment().format('YYYY-MM-DD');
|
let today = moment().format('YYYY-MM-DD');
|
||||||
let getPartner = await model.getPartner(mid, tid);
|
let getPartner = await model.getPartner(mid, tid);
|
||||||
|
|
||||||
|
if (dataLoadingBalance && dataLoadingBalanceDetail.length > 0) {
|
||||||
let data = {
|
let data = {
|
||||||
c_load_balance_no: dataLoadingBalance.c_load_balance_no,
|
c_load_balance_no: dataLoadingBalance.c_load_balance_no,
|
||||||
d_load_balance: dataLoadingBalance.d_load_balance,
|
d_load_balance: dataLoadingBalance.d_load_balance,
|
||||||
@@ -1906,8 +2104,176 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
// insert new load balance transaction by data on card and update data reservation
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} generating and insert new data load balance...`
|
||||||
|
);
|
||||||
|
|
||||||
|
// generate load balance number
|
||||||
|
let newLoadBalanceNumber;
|
||||||
|
let getLoadBalanceSequence;
|
||||||
|
let loadBalanceNoSequence;
|
||||||
|
let maxLoop = 0;
|
||||||
|
do {
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} getting loading balance sequence...`
|
||||||
|
);
|
||||||
|
|
||||||
|
// get loading balance
|
||||||
|
getLoadBalanceSequence = await model.getLoadBalanceSequence(
|
||||||
|
getPartner,
|
||||||
|
today
|
||||||
|
);
|
||||||
|
loadBalanceNoSequence = getLoadBalanceSequence
|
||||||
|
? parseInt(getLoadBalanceSequence.i_load_balance_no_seq) + 1
|
||||||
|
: 1;
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(`${uniqueCode} generating load balance number...`);
|
||||||
|
|
||||||
|
newLoadBalanceNumber = await generateLoadBalanceNumber(
|
||||||
|
getPartner,
|
||||||
|
moment(today).format('YYMMDD'),
|
||||||
|
loadBalanceNoSequence
|
||||||
|
);
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} load balance number is ${newLoadBalanceNumber}.`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (maxLoop > 20) {
|
||||||
|
// create log
|
||||||
|
winston.logger.error(
|
||||||
|
`500 internal server error (max loop) - backend server | ${error.message}`
|
||||||
|
);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxLoop++;
|
||||||
|
} while (newLoadBalanceNumber == 'XX');
|
||||||
|
|
||||||
|
let dataLoadBalance = {
|
||||||
|
c_load_balance_no: newLoadBalanceNumber,
|
||||||
|
d_load_balance: now,
|
||||||
|
c_ref_no: null,
|
||||||
|
i_partner: getPartner.i_partner,
|
||||||
|
c_partner_code: getPartner.partner_code,
|
||||||
|
c_partner_name: getPartner.partner_name,
|
||||||
|
i_merchant: getPartner.i_merchant,
|
||||||
|
c_merchant_code: getPartner.merchant_code,
|
||||||
|
c_merchant_name: getPartner.merchant_name,
|
||||||
|
c_mid: getPartner.mid,
|
||||||
|
i_terminal: getPartner.i_terminal,
|
||||||
|
c_terminal_code: getPartner.terminal_code,
|
||||||
|
c_terminal_name: getPartner.terminal_name,
|
||||||
|
c_tid: getPartner.tid,
|
||||||
|
c_card_number: cardNumber,
|
||||||
|
i_topup_amount: totalReservationAmount,
|
||||||
|
m_balance: balance,
|
||||||
|
c_return_sap: null,
|
||||||
|
i_load_balance_no_seq: loadBalanceNoSequence,
|
||||||
|
c_idm: uid,
|
||||||
|
c_status: 'A',
|
||||||
|
c_status_name: 'SUCCESS',
|
||||||
|
d_create: now,
|
||||||
|
i_create: null,
|
||||||
|
c_create_username: null,
|
||||||
|
c_create_fullname: null,
|
||||||
|
d_modify: null,
|
||||||
|
i_modify: null,
|
||||||
|
c_modify_username: null,
|
||||||
|
c_modify_fullname: null,
|
||||||
|
d_delete: null,
|
||||||
|
i_delete: null,
|
||||||
|
c_delete_username: null,
|
||||||
|
c_delete_fullname: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
// create detaial load balance
|
||||||
|
let detailLoadBalance =
|
||||||
|
await model.createDetailLoadBalanceFromReservation(reservationNumber);
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} detail load balance with reservation no : ${JSON.stringify(
|
||||||
|
reservationNumber
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (detailLoadBalance.length > 0) {
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} AAAAAAAAAAAAAAAAAA1111 [DATA] : ${JSON.stringify(
|
||||||
|
reservationNumber
|
||||||
|
)} [LB] : ${JSON.stringify(dataLoadBalance)} [LBD] : ${JSON.stringify(
|
||||||
|
detailLoadBalance
|
||||||
|
)} [NOW] : ${JSON.stringify(now)} [FLAG] : ${JSON.stringify(flag)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} updating reservation and insert new load balance transaction...`
|
||||||
|
);
|
||||||
|
|
||||||
|
// update reservation and load balance transaction
|
||||||
|
let updateReservationAndInsertLoadingBalance =
|
||||||
|
await model.updateReservationAndInsertLoadingBalance(
|
||||||
|
reservationNumber,
|
||||||
|
dataLoadBalance,
|
||||||
|
detailLoadBalance,
|
||||||
|
now,
|
||||||
|
flag
|
||||||
|
);
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} status insert new load balance and update reservation : ${JSON.stringify(
|
||||||
|
updateReservationAndInsertLoadingBalance
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
// if (updateReservationAndInsertLoadingBalance > 0) {
|
||||||
|
// // log debug
|
||||||
|
// winston.logger.debug(
|
||||||
|
// `${uniqueCode} inserting log for card history...`
|
||||||
|
// );
|
||||||
|
|
||||||
|
// // log card history
|
||||||
|
// await model.createLoadBalanceLog({
|
||||||
|
// i_log_name:21,
|
||||||
|
// d_log: dataLoadingBalance.d_load_balance,
|
||||||
|
// c_card_number: cardNumber,
|
||||||
|
// c_source: 'CMS',
|
||||||
|
// c_location: getPartner ? getPartner.partner_name : null,
|
||||||
|
// m_balance_before: parseInt(dataLoadingBalance.m_balance),
|
||||||
|
// m_amount: parseInt(dataLoadingBalance.i_topup_amount),
|
||||||
|
// m_balance_after: parseInt(balance),
|
||||||
|
// j_new_data: { data: data, detail: dataLoadingBalanceDetail },
|
||||||
|
// j_old_data: null,
|
||||||
|
// c_note: `LOAD BALANCE ${dataLoadingBalance.i_topup_amount} FROM ${
|
||||||
|
// getPartner ? getPartner.partner_name : null
|
||||||
|
// } SUCCESSFULLY`,
|
||||||
|
// c_status: 'S',
|
||||||
|
// d_created: now,
|
||||||
|
// i_create: null,
|
||||||
|
// c_create_username: 'HSM',
|
||||||
|
// c_create_fullname: 'HARDWARE SECURE MODULE',
|
||||||
|
// c_category: 'T',
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// create log
|
// create log
|
||||||
winston.logger.error(
|
winston.logger.error(
|
||||||
@@ -1934,6 +2300,53 @@ const generateLoadBalanceNumber = async (data, date, counter) => {
|
|||||||
return loadBalanceNumber;
|
return loadBalanceNumber;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ================================================================= INQUIRY LOAD BALANCE =================================================================
|
||||||
|
// *Created By: Teddy Setiawan*
|
||||||
|
// *Description:*
|
||||||
|
//
|
||||||
|
const inquiryListLoadingBalance = async (req, res) => {
|
||||||
|
try {
|
||||||
|
// param
|
||||||
|
let {load_balance_number} = req.body;
|
||||||
|
|
||||||
|
// validation parameter inquiry
|
||||||
|
if (!load_balance_number) {
|
||||||
|
return res.status(200).json({
|
||||||
|
code: '400',
|
||||||
|
message:
|
||||||
|
'bad request. please add the load balance number!',
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let byLoadBalanceNumber = await model.inquiryListByLoadNumber(load_balance_number);
|
||||||
|
|
||||||
|
// check result
|
||||||
|
if(byLoadBalanceNumber.length == 0){
|
||||||
|
return res.status(200).json({
|
||||||
|
code: '419',
|
||||||
|
message: "data doesn't exist",
|
||||||
|
data: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
code: '00',
|
||||||
|
message: 'data has been found.',
|
||||||
|
data: byLoadBalanceNumber,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return res.status(200).json({
|
||||||
|
code: '500',
|
||||||
|
message:
|
||||||
|
process.env.NODE_ENV != 'production'
|
||||||
|
? error.message
|
||||||
|
: '500 internal server error - backend server.',
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
validate,
|
validate,
|
||||||
loadingBalanceRequest,
|
loadingBalanceRequest,
|
||||||
@@ -1941,4 +2354,5 @@ module.exports = {
|
|||||||
loadingBalanceInsert,
|
loadingBalanceInsert,
|
||||||
loadingBalanceUpdate,
|
loadingBalanceUpdate,
|
||||||
inquiryLoadingBalance,
|
inquiryLoadingBalance,
|
||||||
|
inquiryListLoadingBalance
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
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,164 +26,164 @@ 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;
|
||||||
@@ -192,37 +191,37 @@ let inquiryListReservation = (partnerID, startDate, endDate) => {
|
|||||||
|
|
||||||
// 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;
|
||||||
@@ -230,33 +229,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;
|
||||||
@@ -268,66 +267,88 @@ 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;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
checkCardNumber,
|
checkCardNumber,
|
||||||
getReservationNumberSequence,
|
getReservationNumberSequence,
|
||||||
@@ -354,4 +375,5 @@ module.exports = {
|
|||||||
insertReservationNumber,
|
insertReservationNumber,
|
||||||
cancelReservation,
|
cancelReservation,
|
||||||
deleteReservationNumberValidate,
|
deleteReservationNumberValidate,
|
||||||
|
inquiryListByRefNumber,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,4 +23,10 @@ router.post(
|
|||||||
controller.inquiryLoadingBalance
|
controller.inquiryLoadingBalance
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/loadbalance-by-load-number/inquiry",
|
||||||
|
auth.authenticateToken,
|
||||||
|
controller.inquiryListLoadingBalance
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,25 +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/paymentrecon/paymentrecon.controller");
|
const controller = require('../modules/paymentrecon/paymentrecon.controller');
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/payment-recon",
|
'/payment-recon',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate("paymentRecon"),
|
controller.validate('paymentRecon'),
|
||||||
controller.paymentRecon
|
controller.paymentRecon
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
|
||||||
"/payment-recon/semi-topup-online",
|
|
||||||
auth.authenticateToken,
|
|
||||||
controller.validate("paymentReconSemiTopupOnline"),
|
|
||||||
controller.paymentReconSemiTopupOnline
|
|
||||||
);
|
|
||||||
|
|
||||||
router.post(
|
|
||||||
"/payment-recon/to-cms",
|
|
||||||
controller.paymentReconToCMS
|
|
||||||
);
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,59 +1,94 @@
|
|||||||
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/reservebalance/reservebalance.controller");
|
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');
|
||||||
|
|
||||||
|
// ================================================================= ROUTE V1 =================================================================
|
||||||
router.post(
|
router.post(
|
||||||
"/reservation/check",
|
'/reservation/check',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate("checkReservation"),
|
controller.validate('checkReservation'),
|
||||||
controller.checkReservation
|
controller.checkReservation
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/reservation/validate",
|
'/reservation/validate',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate("reservationValidate"),
|
controller.validate('reservationValidate'),
|
||||||
controller.reservationValidate
|
controller.reservationValidate
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/reservation",
|
'/reservation',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate("reservation"),
|
prometheusMiddleware,
|
||||||
|
lokiMiddleware,
|
||||||
|
getReservationNumberSequence,
|
||||||
|
controller.validate('reservation'),
|
||||||
controller.reservation
|
controller.reservation
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/reservation/cancel/validate",
|
'/reservation/cancel/validate',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate("cancelReservation"),
|
controller.validate('cancelReservation'),
|
||||||
controller.cancelReservationValidate
|
controller.cancelReservationValidate
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/reservation/cancel",
|
'/reservation/cancel',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate("cancelReservation"),
|
controller.validate('cancelReservation'),
|
||||||
controller.cancelReservation
|
controller.cancelReservation
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/reservation/inquiry-hold",
|
'/reservation/inquiry-hold',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.inquiryReservation
|
controller.inquiryReservation
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/reservation/inquiry/v1",
|
'/reservation/inquiry/v1',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.inquiryReservationByReservation
|
controller.inquiryReservationByReservation
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/list-reservation/inquiry/v1",
|
'/list-reservation/inquiry/v1',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.inquiryListReservationByReservation
|
controller.inquiryListReservationByReservation
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/list-reservation-by-refno/inquiry/v1',
|
||||||
|
auth.authenticateToken,
|
||||||
|
controller.inquiryListReservationByRefNumber
|
||||||
|
);
|
||||||
|
|
||||||
|
// ================================================================= ROUTE V2 =================================================================
|
||||||
|
router.post(
|
||||||
|
'/reservation/validate/v2',
|
||||||
|
auth.authenticateToken,
|
||||||
|
controller.validate('reservationValidate'),
|
||||||
|
controller.reservationValidateV2
|
||||||
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
'/reservation/v2',
|
||||||
|
auth.authenticateToken,
|
||||||
|
prometheusMiddleware,
|
||||||
|
lokiMiddleware,
|
||||||
|
getReservationNumberSequence,
|
||||||
|
controller.validate('reservationV2'),
|
||||||
|
controller.reservationV2
|
||||||
|
);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@@ -1,57 +1,106 @@
|
|||||||
# 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=
|
||||||
|
|
||||||
|
# ================================== 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 +112,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 +134,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="
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+26
-26
@@ -1,4 +1,4 @@
|
|||||||
require("dotenv").config();
|
require('dotenv').config();
|
||||||
|
|
||||||
let host;
|
let host;
|
||||||
let database;
|
let database;
|
||||||
@@ -6,27 +6,27 @@ let port;
|
|||||||
let user;
|
let user;
|
||||||
let password;
|
let password;
|
||||||
|
|
||||||
if (process.env.SERVER_FOR == "local") {
|
if (process.env.SERVER_FOR == 'local') {
|
||||||
host = "localhost";
|
host = process.env.DB_HOST_LOCAL;
|
||||||
database = "postgres";
|
database = process.env.DB_NAME_LOCAL;
|
||||||
|
port = process.env.DB_PORT_LOCAL;
|
||||||
|
user = process.env.DB_USER_LOCAL;
|
||||||
|
password = process.env.DB_PASSWORD_LOCAL;
|
||||||
|
} else if (process.env.SERVER_FOR == 'development') {
|
||||||
|
host = '10.20.14.14';
|
||||||
|
database = 'postgres';
|
||||||
port = 5432;
|
port = 5432;
|
||||||
user = "postgres";
|
user = 'postgres';
|
||||||
password = "postgres";
|
password = 'inhc0mmute_cms';
|
||||||
} else if (process.env.SERVER_FOR == "development") {
|
} else if (process.env.SERVER_FOR == 'production') {
|
||||||
host = "10.20.14.14";
|
host = '10.1.201.75';
|
||||||
database = "postgres";
|
database = 'postgres';
|
||||||
port = 5432;
|
port = 5432;
|
||||||
user = "cms";
|
user = 'postgres';
|
||||||
password = "Cm5kc1#2021";
|
password = 'inhc0mmute_cms';
|
||||||
} else if (process.env.SERVER_FOR == "production") {
|
|
||||||
host = "10.1.201.75";
|
|
||||||
database = "postgres";
|
|
||||||
port = 5432;
|
|
||||||
user = "postgres";
|
|
||||||
password = "inhc0mmute_cms";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// development: {
|
// development: {
|
||||||
// client: "pg",
|
// client: "pg",
|
||||||
// connection: process.env.DB_URL,
|
// connection: process.env.DB_URL,
|
||||||
@@ -36,7 +36,7 @@ if (process.env.SERVER_FOR == "local") {
|
|||||||
// seeds: { directory: "./infrastructure/database/seeds" },
|
// seeds: { directory: "./infrastructure/database/seeds" },
|
||||||
// },
|
// },
|
||||||
development: {
|
development: {
|
||||||
client: "pg",
|
client: 'pg',
|
||||||
connection: {
|
connection: {
|
||||||
host: host,
|
host: host,
|
||||||
database: database,
|
database: database,
|
||||||
@@ -49,21 +49,21 @@ if (process.env.SERVER_FOR == "local") {
|
|||||||
max: 10,
|
max: 10,
|
||||||
},
|
},
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: "./infrastructure/database/migrations",
|
directory: './infrastructure/database/migrations',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
testing: {
|
testing: {
|
||||||
client: "pg",
|
client: 'pg',
|
||||||
connection: process.env.DB_URL,
|
connection: process.env.DB_URL,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: "./infrastructure/database/migrations",
|
directory: './infrastructure/database/migrations',
|
||||||
},
|
},
|
||||||
seeds: { directory: "./infrastructure/database/seeds" },
|
seeds: { directory: './infrastructure/database/seeds' },
|
||||||
},
|
},
|
||||||
|
|
||||||
production: {
|
production: {
|
||||||
client: "pg",
|
client: 'pg',
|
||||||
connection: {
|
connection: {
|
||||||
host: host,
|
host: host,
|
||||||
database: database,
|
database: database,
|
||||||
@@ -76,7 +76,7 @@ if (process.env.SERVER_FOR == "local") {
|
|||||||
max: 10,
|
max: 10,
|
||||||
},
|
},
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: "./infrastructure/database/migrations",
|
directory: './infrastructure/database/migrations',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Generated
+5448
-2016
File diff suppressed because it is too large
Load Diff
@@ -31,14 +31,19 @@
|
|||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-validator": "^6.10.0",
|
"express-validator": "^6.10.0",
|
||||||
|
"express-winston": "^4.2.0",
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"knex": "^0.95.4",
|
"knex": "^0.95.4",
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
"node-cron": "^3.0.1",
|
"node-cron": "^3.0.1",
|
||||||
"pg": "^8.6.0",
|
"pg": "^8.6.0",
|
||||||
"pm2": "^5.2.0",
|
"pm2": "^5.2.0",
|
||||||
|
"prom-client": "^14.2.0",
|
||||||
|
"redis": "^4.6.5",
|
||||||
|
"response-time": "^2.3.2",
|
||||||
"winston": "^3.7.2",
|
"winston": "^3.7.2",
|
||||||
"winston-daily-rotate-file": "^4.7.1",
|
"winston-daily-rotate-file": "^4.7.1",
|
||||||
|
"winston-loki": "^6.0.6",
|
||||||
"ws": "^8.5.0",
|
"ws": "^8.5.0",
|
||||||
"xml2js": "^0.4.23"
|
"xml2js": "^0.4.23"
|
||||||
},
|
},
|
||||||
|
|||||||
+104
-67
@@ -1,28 +1,44 @@
|
|||||||
const express = require("express");
|
const express = require('express');
|
||||||
const bodyParser = require("body-parser");
|
const bodyParser = require('body-parser');
|
||||||
const cors = require("cors");
|
const cors = require('cors');
|
||||||
const helper = require("../application/helpers/helper");
|
const helper = require('../application/helpers/helper');
|
||||||
const winston = require("../application/helpers/winston.logger");
|
const winston = require('../application/helpers/winston.logger');
|
||||||
const authRoute = require("../application/routes/auth.routes");
|
const authRoute = require('../application/routes/auth.routes');
|
||||||
const dongleOrderRoute = require("../application/routes/dongleorder.routes");
|
const dongleOrderRoute = require('../application/routes/dongleorder.routes');
|
||||||
const reservationRoute = require("../application/routes/reservebalance.routes");
|
const reservationRoute = require('../application/routes/reservebalance.routes');
|
||||||
const loadBalanceRoute = require("../application/routes/loadbalance.routes");
|
const loadBalanceRoute = require('../application/routes/loadbalance.routes');
|
||||||
const hsmRoute = require("../application/routes/hsm.routes");
|
const hsmRoute = require('../application/routes/hsm.routes');
|
||||||
const historyRoute = require("../application/routes/history.routes");
|
const historyRoute = require('../application/routes/history.routes');
|
||||||
const paymentReconRoute = require("../application/routes/paymentrecon.routes");
|
const paymentReconRoute = require('../application/routes/paymentrecon.routes');
|
||||||
const invoiceRoute = require("../application/routes/invoiceonline.routes");
|
const invoiceRoute = require('../application/routes/invoiceonline.routes');
|
||||||
const cashinRoute = require("../application/routes/cahsin.routes");
|
const cashinRoute = require('../application/routes/cahsin.routes');
|
||||||
const cron = require("node-cron");
|
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 { logger } = require('../application/helpers/getbodyrequest');
|
||||||
|
const client = require('prom-client');
|
||||||
|
const register = new client.Registry();
|
||||||
|
const {
|
||||||
|
topuponline_metrics,
|
||||||
|
} = require('../application/helpers/prometheusmetrics');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
register.setDefaultLabels({ app: 'topuponline' });
|
||||||
|
client.collectDefaultMetrics({ register });
|
||||||
|
register.registerMetric(topuponline_metrics);
|
||||||
|
|
||||||
|
app.get('/metrics', (req, res) => {
|
||||||
|
res.setHeader('Content-Type', register.contentType);
|
||||||
|
register.metrics().then((data) => res.send(data));
|
||||||
|
});
|
||||||
|
|
||||||
var corsOptions = {
|
var corsOptions = {
|
||||||
origin: [
|
origin: [
|
||||||
"http://localhost:" + process.env.PORT || 3000,
|
'http://localhost:' + process.env.PORT || 3000,
|
||||||
"http://localhost:3000",
|
'http://localhost:3000',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,45 +51,61 @@ app.use(bodyParser.json());
|
|||||||
// parse requests of content-type - application/x-www-form-urlencoded
|
// parse requests of content-type - application/x-www-form-urlencoded
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
|
|
||||||
|
app.use(responseTime());
|
||||||
|
|
||||||
// ============================== ROUTES API ==============================
|
// ============================== ROUTES API ==============================
|
||||||
app.get("/", (req, res) => {
|
app.get('/', async (req, res) => {
|
||||||
|
let data = {
|
||||||
|
card_number: '1234567890',
|
||||||
|
amount: 10000,
|
||||||
|
};
|
||||||
|
|
||||||
|
let chipperData = helper.encryptText(JSON.stringify(data));
|
||||||
|
let decrypData = JSON.parse(helper.decryptText(chipperData));
|
||||||
res.json({
|
res.json({
|
||||||
message: "Welcome to Topup Online Service.",
|
message: 'Welcome to Topup Online Service.',
|
||||||
// data: {
|
data: {
|
||||||
// text: "0nlinet0pupkci",
|
text: '0nlinet0pupkci',
|
||||||
// chiper_text: helper.encryptText("0nlinet0pupkci"),
|
chiper_text: helper.encryptText('0nlinet0pupkci'),
|
||||||
// },
|
chipper_data: chipperData,
|
||||||
|
decrypt_data: decrypData,
|
||||||
|
date: moment().format('YYYYMMDDHHmm'),
|
||||||
|
secret_key: helper.encryptText('0nlinetopupDev'),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use("/api/", authRoute);
|
app.use(logger.request);
|
||||||
app.use("/api/", dongleOrderRoute);
|
app.use(logger.response);
|
||||||
app.use("/api/", historyRoute);
|
|
||||||
app.use("/api/", hsmRoute);
|
app.use('/api/', authRoute);
|
||||||
app.use("/api/", loadBalanceRoute);
|
app.use('/api/', dongleOrderRoute);
|
||||||
app.use("/api/", paymentReconRoute);
|
app.use('/api/', historyRoute);
|
||||||
app.use("/api/", reservationRoute);
|
app.use('/api/', hsmRoute);
|
||||||
app.use("/api/", invoiceRoute);
|
app.use('/api/', loadBalanceRoute);
|
||||||
app.use("/api/", cashinRoute);
|
app.use('/api/', paymentReconRoute);
|
||||||
|
app.use('/api/', reservationRoute);
|
||||||
|
app.use('/api/', invoiceRoute);
|
||||||
|
app.use('/api/', cashinRoute);
|
||||||
|
|
||||||
// ============================== SAP SCHEDULLER =============================
|
// ============================== SAP SCHEDULLER =============================
|
||||||
|
|
||||||
// if (process.env.NODE_ENV.toUpperCase() == "PRODUCTION") {
|
// if (process.env.NODE_ENV.toUpperCase() == "PRODUCTION") {
|
||||||
|
|
||||||
// ===================================================
|
// ===================================================
|
||||||
// SCHEDULER FOR GENERATE INVOICE
|
// SCHEDULER FOR GENERATE INVOICE
|
||||||
// ===================================================
|
// ===================================================
|
||||||
|
|
||||||
const {
|
const {
|
||||||
_generateInvoice,
|
_generateInvoice,
|
||||||
_postingInvoice,
|
_postingInvoice,
|
||||||
} = require("../application/modules/invoiceonline/invoice.controller");
|
} = require('../application/modules/invoiceonline/invoice.controller');
|
||||||
|
|
||||||
// GENERATE + POSTING INVOICE
|
// GENERATE + POSTING INVOICE
|
||||||
cron.schedule("0 1 * * *", async () => {
|
cron.schedule('0 1 * * *', async () => {
|
||||||
try {
|
try {
|
||||||
// let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD");
|
// let ivoiceDate = moment().add(1, 'days').format("YYYY-MM-DD");
|
||||||
let ivoiceDate = moment().format("YYYY-MM-DD");
|
let ivoiceDate = moment().format('YYYY-MM-DD');
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = helper.getUniqueCode();
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
`STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} `
|
`STARTING SCHEDULER-FB70 GENERATE INVOICE ${ivoiceDate} `
|
||||||
@@ -96,10 +128,10 @@ app.use("/api/", cashinRoute);
|
|||||||
`500 internal server error - backend server | ${error.message}`
|
`500 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// RE-TRY POSTING
|
// RE-TRY POSTING
|
||||||
cron.schedule("0 7 * * *", async () => {
|
cron.schedule('0 7 * * *', async () => {
|
||||||
try {
|
try {
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = helper.getUniqueCode();
|
||||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||||
@@ -113,9 +145,9 @@ app.use("/api/", cashinRoute);
|
|||||||
`500 internal server error - backend server | ${error.message}`
|
`500 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cron.schedule("0 12 * * *", async () => {
|
cron.schedule('0 12 * * *', async () => {
|
||||||
try {
|
try {
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = helper.getUniqueCode();
|
||||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||||
@@ -129,9 +161,9 @@ app.use("/api/", cashinRoute);
|
|||||||
`500 internal server error - backend server | ${error.message}`
|
`500 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cron.schedule("0 17 * * *", async () => {
|
cron.schedule('0 17 * * *', async () => {
|
||||||
try {
|
try {
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = helper.getUniqueCode();
|
||||||
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
winston.logger.debug(`STARTING SCHEDULER-FB70 RE-TRY POSTING INVOICE`);
|
||||||
@@ -145,21 +177,22 @@ app.use("/api/", cashinRoute);
|
|||||||
`500 internal server error - backend server | ${error.message}`
|
`500 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ===================================================
|
||||||
// ===================================================
|
// SCHEDULER FOR GENERATE INVOICE
|
||||||
// SCHEDULER FOR GENERATE INVOICE
|
// ===================================================
|
||||||
// ===================================================
|
// cash in
|
||||||
// cash in
|
const {
|
||||||
const {
|
|
||||||
_generateCashIn,
|
_generateCashIn,
|
||||||
} = require("../application/modules/cashin/cahsin.controller");
|
} = require('../application/modules/cashin/cahsin.controller');
|
||||||
|
|
||||||
cron.schedule('30 7 * * *', async () => {
|
cron.schedule('30 7 * * *', async () => {
|
||||||
try {
|
try {
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = helper.getUniqueCode();
|
||||||
winston.logger.info(`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`);
|
winston.logger.info(
|
||||||
|
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||||
|
);
|
||||||
const posting = await _generateCashIn(uniqueCode);
|
const posting = await _generateCashIn(uniqueCode);
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||||
@@ -170,12 +203,14 @@ app.use("/api/", cashinRoute);
|
|||||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cron.schedule('30 12 * * *', async () => {
|
cron.schedule('30 12 * * *', async () => {
|
||||||
try {
|
try {
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = helper.getUniqueCode();
|
||||||
winston.logger.info(`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`);
|
winston.logger.info(
|
||||||
|
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||||
|
);
|
||||||
const posting = await _generateCashIn(uniqueCode);
|
const posting = await _generateCashIn(uniqueCode);
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||||
@@ -186,12 +221,14 @@ app.use("/api/", cashinRoute);
|
|||||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cron.schedule('30 17 * * *', async () => {
|
cron.schedule('30 17 * * *', async () => {
|
||||||
try {
|
try {
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = helper.getUniqueCode();
|
||||||
winston.logger.info(`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`);
|
winston.logger.info(
|
||||||
|
`STARTING SCHEDULER-FB70 GENERATE CASH IN ${uniqueCode}`
|
||||||
|
);
|
||||||
const posting = await _generateCashIn(uniqueCode);
|
const posting = await _generateCashIn(uniqueCode);
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
`END SCHEDULER-FB70 GENERATE CASH IN : ${JSON.stringify(posting)}`
|
||||||
@@ -202,7 +239,7 @@ app.use("/api/", cashinRoute);
|
|||||||
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
`500 SCHEDULER-FB70 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user