mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 17:16:28 +00:00
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bbdb4c2963 | |||
| 33f3b64d17 | |||
| 5ff0cae4d6 | |||
| c80b12ba53 | |||
| e3673f738c | |||
| f7d7d0efce | |||
| 30c32ca293 | |||
| 4d47090994 | |||
| 3fefaed395 | |||
| b1be54d5ba | |||
| 536d1a5c94 | |||
| 5d8369edd8 | |||
| 3c26dd6e23 | |||
| 0baf1332b6 | |||
| 5aca4559c2 | |||
| 21a45058f0 | |||
| edc70c3e6b | |||
| 4bb2facddb | |||
| 466c18fe21 | |||
| ed11c6ccc4 | |||
| 3515b5459f | |||
| e4cf444b83 | |||
| ddf01d2246 | |||
| 1fb0913eb5 | |||
| 293602bed2 | |||
| 87461a4a14 | |||
| fbcae2e596 | |||
| c7f816a449 | |||
| eeab7627ae | |||
| 9052668cbc | |||
| f615e9207f | |||
| 1ba983e745 | |||
| 8f254758dd | |||
| e7c4388956 | |||
| 3d31e6f6a5 | |||
| 1b3991c82f | |||
| 38edd07d65 | |||
| fff4915078 | |||
| 820f833844 | |||
| 1bd85ba888 | |||
| cab77e8872 | |||
| 7b52cebeb7 | |||
| 4c3496e9f2 | |||
| 529d6d7ffc | |||
| 5ca30fbfc4 | |||
| d3729ab906 | |||
| 95bfc120c5 | |||
| 9e98533ffb | |||
| 0ab80c0ac4 | |||
| ef274a483c | |||
| d129ad7a2f | |||
| 1f127807d3 | |||
| 1014e4374a | |||
| 88c3b9bc4a | |||
| ffa6830734 | |||
| 5a63ca6ea1 | |||
| b942d114ad | |||
| 7c66ebe702 | |||
| 6b0d67ee60 | |||
| 7805bc902b | |||
| 95f4a03e81 | |||
| 4c7230ba6b | |||
| 1b2eff69b4 | |||
| e3ab361b24 | |||
| 14026e8bf0 | |||
| 3c1fc92d59 | |||
| a333ddb58f | |||
| f2c5d65ec0 | |||
| bcb9225466 | |||
| 90dfdc8857 | |||
| 476235440c | |||
| 04885f22d6 | |||
| 3b68ab9ab3 | |||
| a3a4772f77 | |||
| 6ef43923e1 | |||
| 47af9992be | |||
| ede3aacef3 | |||
| a6b17139bf | |||
| 7a7f18701d | |||
| e34434f96c | |||
| 9cbc467904 | |||
| 0a5e82dbbb | |||
| 6c7131c944 |
+16
-16
@@ -1,8 +1,8 @@
|
||||
const moment = require("moment");
|
||||
const winston = require("winston");
|
||||
const loki = require("winston-loki");
|
||||
require("winston-daily-rotate-file");
|
||||
require("dotenv").config();
|
||||
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;
|
||||
let lokiUrl = process.env.LOKI_URL;
|
||||
|
||||
@@ -18,32 +18,32 @@ var log;
|
||||
|
||||
const fileRotateTransport = new winston.transports.DailyRotateFile({
|
||||
filename: `./lokiLog/%DATE%-onlinetopup.log`,
|
||||
datePattern: "YYYY-MM-DD",
|
||||
maxFiles: "1d",
|
||||
datePattern: 'YYYY-MM-DD',
|
||||
maxFiles: '1d',
|
||||
});
|
||||
|
||||
if (
|
||||
process.env.NODE_ENV == "production" ||
|
||||
process.env.NODE_ENV == "PRODUCTION"
|
||||
process.env.NODE_ENV == 'production' ||
|
||||
process.env.NODE_ENV == 'PRODUCTION'
|
||||
) {
|
||||
log = winston.createLogger({
|
||||
levels: logLevels,
|
||||
level: process.env.LOG_LEVEL || "info",
|
||||
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",
|
||||
format: 'YYYY-MM-DD HH:mm:ss.SSS',
|
||||
}),
|
||||
align(),
|
||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||
),
|
||||
defaultMeta: { service: "topuponline" },
|
||||
defaultMeta: { service: 'topuponline' },
|
||||
transports: [
|
||||
new loki({
|
||||
host: lokiUrl,
|
||||
labels: { app: "topuponline" },
|
||||
labels: { app: 'topuponline' },
|
||||
json: true,
|
||||
format: json(),
|
||||
replaceTimestamp: true,
|
||||
@@ -59,7 +59,7 @@ if (
|
||||
transports: [
|
||||
new loki({
|
||||
host: lokiUrl,
|
||||
labels: { app: "topuponline" },
|
||||
labels: { app: 'topuponline' },
|
||||
handleExceptions: true,
|
||||
handleRejections: true,
|
||||
clearOnError: true,
|
||||
@@ -75,14 +75,14 @@ if (
|
||||
});
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV != "testing" && process.env.NODE_ENV != "TESTING") {
|
||||
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",
|
||||
format: 'YYYY-MM-DD HH:mm:ss.SSS',
|
||||
}),
|
||||
align(),
|
||||
printf((info) => `[${info.timestamp}] ${info.level}: ${info.message}`)
|
||||
|
||||
@@ -75,10 +75,14 @@ const loginPartnerUser = async (req, res, next) => {
|
||||
let { email, password } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST LOGIN-PARTNER-USER ]: ${JSON.stringify({
|
||||
email: email,
|
||||
})}`
|
||||
// winston.logger.info(
|
||||
// `${uniqueCode} [ REQUEST LOGIN-PARTNER-USER ]: ${JSON.stringify({
|
||||
// email: email,
|
||||
// })}`
|
||||
// );
|
||||
|
||||
console.log(
|
||||
`${uniqueCode} [ REQUEST LOGIN-PARTNER-USER ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
// validate
|
||||
@@ -201,9 +205,9 @@ const loginPartnerUser = async (req, res, next) => {
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE LOGIN-PARTNER-USER ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
// winston.logger.info(
|
||||
// `${uniqueCode} [ RESPONSE LOGIN-PARTNER-USER ]: ${JSON.stringify(result)}`
|
||||
// );
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
@@ -705,11 +709,11 @@ const refreshTokenPartnerUser = async (req, res) => {
|
||||
let refresh_token = req.header('refresh_token');
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST REFRESH-TOKEN-PARTNER-USER ]: ${JSON.stringify(
|
||||
req.body
|
||||
)}`
|
||||
);
|
||||
// winston.logger.info(
|
||||
// `${uniqueCode} [ REQUEST REFRESH-TOKEN-PARTNER-USER ]: ${JSON.stringify(
|
||||
// req.body
|
||||
// )}`
|
||||
// );
|
||||
|
||||
// validate
|
||||
let err = validationResult(req);
|
||||
@@ -837,11 +841,11 @@ const refreshTokenPartnerUser = async (req, res) => {
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE REFRESH-TOKEN-PARTNER-USER ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
// winston.logger.info(
|
||||
// `${uniqueCode} [ RESPONSE REFRESH-TOKEN-PARTNER-USER ]: ${JSON.stringify(
|
||||
// result
|
||||
// )}`
|
||||
// );
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const { param, body, validationResult } = require("express-validator");
|
||||
const helper = require("../../helpers/helper");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const model = require("./cahsin.model");
|
||||
const moment = require("moment");
|
||||
const knex = require("../../../infrastructure/database/knex");
|
||||
const { param, body, validationResult } = require('express-validator');
|
||||
const helper = require('../../helpers/helper');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const model = require('./cahsin.model');
|
||||
const moment = require('moment');
|
||||
const knex = require('../../../infrastructure/database/knex');
|
||||
|
||||
moment.locale("id");
|
||||
moment.locale('id');
|
||||
|
||||
var result = {};
|
||||
var uniqueCode;
|
||||
@@ -13,14 +13,32 @@ var uniqueCode;
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case "generateInvoice":
|
||||
case 'generateInvoice':
|
||||
return [
|
||||
body('trx_date').notEmpty().withMessage('trx_date is required!').isISO8601().withMessage('invalid trx_date format YYYY-MM-DD !').escape().trim(),
|
||||
body('repost').notEmpty().withMessage('repost is required!').isBoolean().withMessage('repost must boolean!').escape().trim(),
|
||||
body('trx_date')
|
||||
.notEmpty()
|
||||
.withMessage('trx_date is required!')
|
||||
.isISO8601()
|
||||
.withMessage('invalid trx_date format YYYY-MM-DD !')
|
||||
.escape()
|
||||
.trim(),
|
||||
body('repost')
|
||||
.notEmpty()
|
||||
.withMessage('repost is required!')
|
||||
.isBoolean()
|
||||
.withMessage('repost must boolean!')
|
||||
.escape()
|
||||
.trim(),
|
||||
];
|
||||
case "postingInvoice":
|
||||
case 'postingInvoice':
|
||||
return [
|
||||
body('trx_date').notEmpty().withMessage('trx_date is required!').isISO8601().withMessage('invalid trx_date format YYYY-MM-DD !').escape().trim(),
|
||||
body('trx_date')
|
||||
.notEmpty()
|
||||
.withMessage('trx_date is required!')
|
||||
.isISO8601()
|
||||
.withMessage('invalid trx_date format YYYY-MM-DD !')
|
||||
.escape()
|
||||
.trim(),
|
||||
];
|
||||
default:
|
||||
break;
|
||||
@@ -29,7 +47,6 @@ const validate = (method) => {
|
||||
|
||||
// POSTING INVOICE
|
||||
const apiGenerateCahsIn = async (req, res) => {
|
||||
|
||||
try {
|
||||
// generate unique code
|
||||
uniqueCode = helper.getUniqueCode();
|
||||
@@ -44,7 +61,7 @@ const apiGenerateCahsIn = async (req, res) => {
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: "400",
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
@@ -57,40 +74,38 @@ const apiGenerateCahsIn = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
const cashIn = await _generateCashIn(uniqueCode)
|
||||
const cashIn = await _generateCashIn(uniqueCode);
|
||||
|
||||
result = {
|
||||
code: "200",
|
||||
message: "Succes posting",
|
||||
data: cashIn
|
||||
code: '200',
|
||||
message: 'Succes posting',
|
||||
data: cashIn,
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// RETRY POSTING INVOICE
|
||||
const apiPostingCahsIn = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
uniqueCode = helper.getUniqueCode()
|
||||
let { body } = req
|
||||
uniqueCode = helper.getUniqueCode();
|
||||
let { body } = req;
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} REQUEST posting cash in : ${JSON.stringify(req.body)}`
|
||||
@@ -100,184 +115,248 @@ const apiPostingCahsIn = async (req, res) => {
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: "400",
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE generate posting cash in : ${JSON.stringify(result)}`
|
||||
`${uniqueCode} RESPONSE generate posting cash in : ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// return uniqueCode
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} RE-TRY POSTING CAHS IN`)
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} RE-TRY POSTING CAHS IN`);
|
||||
|
||||
const invoice = await _postingCashIn(uniqueCode)
|
||||
const invoice = await _postingCashIn(uniqueCode);
|
||||
|
||||
result = {
|
||||
code: "200",
|
||||
message: "Succes",
|
||||
code: '200',
|
||||
message: 'Succes',
|
||||
data: invoice,
|
||||
}
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: '500',
|
||||
message:
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const _generateCashIn = async (uniqueCode) => {
|
||||
|
||||
let partnerRecon = await model.getPartnerRecon(knex)
|
||||
let partnerRecon = await model.getPartnerRecon(knex);
|
||||
// return partnerRecon
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} getPartner Recon cash in : ${JSON.stringify(partnerRecon)}`)
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} getPartner Recon cash in : ${JSON.stringify(
|
||||
partnerRecon
|
||||
)}`
|
||||
);
|
||||
|
||||
for (const item of partnerRecon) {
|
||||
let reserve = []
|
||||
let code = ""
|
||||
await knex.transaction(async trx => {
|
||||
code = await model.generateCode(trx, item.c_partner_code, moment().format("YYMMDD"))
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} generate cash in : ${code}`)
|
||||
let reserve = [];
|
||||
let code = '';
|
||||
await knex.transaction(async (trx) => {
|
||||
code = await model.generateCode(
|
||||
trx,
|
||||
item.c_partner_code,
|
||||
moment().format('YYMMDD')
|
||||
);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} generate cash in : ${code}`
|
||||
);
|
||||
|
||||
// Cash-in
|
||||
let dataCahsIn = {
|
||||
c_partner_code: item.c_partner_code,
|
||||
c_partner_name: item.c_partner_name,
|
||||
c_cash_in_no: code,
|
||||
c_in_period: item.c_in_period,
|
||||
d_credit: item.d_payment,
|
||||
c_invoice_no: item.c_invoice_no,
|
||||
i_amount: item.amount,
|
||||
};
|
||||
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
|
||||
// CASH-IN DETAIL
|
||||
let data = [];
|
||||
const reserv = await model.getReserve(
|
||||
trx,
|
||||
item.c_partner_code,
|
||||
item.d_payment,
|
||||
item.c_invoice_no
|
||||
);
|
||||
|
||||
// Insert cahs in
|
||||
const dataCahsIn = {
|
||||
c_partner_code : item.c_partner_code,
|
||||
c_partner_name : item.c_partner_name,
|
||||
c_cash_in_no : code,
|
||||
c_in_period : item.c_in_period,
|
||||
d_credit : item.d_payment,
|
||||
c_invoice_no : item.c_invoice_no,
|
||||
i_amount : item.amount
|
||||
//TOTAL AMOUNT CASH-IN
|
||||
let cashInAmount = 0;
|
||||
for (const itemCI of reserv) {
|
||||
cashInAmount += parseInt(itemCI.i_reservation_amount);
|
||||
}
|
||||
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN ${code} DATA : ${JSON.stringify(dataCahsIn)}`)
|
||||
const cashIn = await model.insertCashIn(trx, dataCahsIn)
|
||||
dataCahsIn.i_amount = cashInAmount;
|
||||
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN HISTORY ${code} DATA : ${JSON.stringify(dataCahsIn)}`)
|
||||
const paymentyHistory = await model.writePaynentHistory(dataCahsIn, "SUCCESSFULLY", 0, trx)
|
||||
//INSERT CASH-IN
|
||||
const cashIn = await model.insertCashIn(trx, dataCahsIn);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN HISTORY ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
const paymentyHistory = await model.writePaynentHistory(
|
||||
dataCahsIn,
|
||||
'SUCCESSFULLY',
|
||||
0,
|
||||
trx
|
||||
);
|
||||
|
||||
// Insert cahs in detail
|
||||
let data = []
|
||||
const reserv = await model.getReserve(trx, item.c_partner_code, item.d_payment, item.c_invoice_no)
|
||||
for (const detail of reserv) {
|
||||
data.push({
|
||||
i_cash_in : cashIn.i_cash_in,
|
||||
c_reservation_no : detail.c_reservation_no,
|
||||
m_amount : detail.i_reservation_amount,
|
||||
c_payment_recon_no : detail.c_payment_recon_no,
|
||||
d_payment : detail.d_payment,
|
||||
d_payment_recon : detail.d_payment_recon,
|
||||
c_load_balance_no : detail.c_load_balance_no
|
||||
})
|
||||
|
||||
let reserveNo = detail.c_reservation_no
|
||||
|
||||
// data.push({
|
||||
// i_cash_in: cashIn.i_cash_in,
|
||||
// c_reservation_no: detail.c_reservation_no,
|
||||
// m_amount: detail.i_reservation_amount,
|
||||
// c_payment_recon_no: detail.c_payment_recon_no,
|
||||
// d_payment: detail.d_payment,
|
||||
// d_payment_recon: detail.d_payment_recon,
|
||||
// c_load_balance_no: detail.c_load_balance_no,
|
||||
// });
|
||||
let temp = {
|
||||
i_cash_in: cashIn.i_cash_in,
|
||||
c_reservation_no: detail.c_reservation_no,
|
||||
m_amount: detail.i_reservation_amount,
|
||||
c_payment_recon_no: detail.c_payment_recon_no,
|
||||
d_payment: detail.d_payment,
|
||||
d_payment_recon: detail.d_payment_recon,
|
||||
c_load_balance_no: detail.c_load_balance_no,
|
||||
};
|
||||
|
||||
let reserveNo = detail.c_reservation_no;
|
||||
let dataReserve = {
|
||||
c_cash_in_no : cashIn.c_cash_in_no,
|
||||
d_credit : cashIn.d_credit,
|
||||
c_in_period : cashIn.c_in_period,
|
||||
}
|
||||
c_cash_in_no: cashIn.c_cash_in_no,
|
||||
d_credit: cashIn.d_credit,
|
||||
c_in_period: cashIn.c_in_period,
|
||||
};
|
||||
|
||||
await model.updateIntoReserve(trx, dataReserve, reserveNo)
|
||||
|
||||
await model.updateIntoReserve(trx, dataReserve, reserveNo);
|
||||
await model.insertCashInDetail(trx, temp);
|
||||
}
|
||||
await wait(5000)
|
||||
winston.logger.info(`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN TO RESERVE ${code} DATA : ${JSON.stringify(dataCahsIn)}`)
|
||||
await model.insertCashInDetail(trx, data)
|
||||
// await model.insertPostingEt(code, item, trx)
|
||||
|
||||
})
|
||||
await wait(5000);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN TO RESERVE ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
// await model.insertCashInDetail(trx, data);
|
||||
// await model.insertPostingEt(code, item, trx)
|
||||
});
|
||||
}
|
||||
|
||||
return partnerRecon
|
||||
|
||||
}
|
||||
return partnerRecon;
|
||||
};
|
||||
|
||||
const _postingCashIn = async (uniqueCode) => {
|
||||
let data = []
|
||||
let postingEt = await model.getPostingEt(knex)
|
||||
let data = [];
|
||||
let postingEt = await model.getPostingEt(knex);
|
||||
|
||||
for (const item of postingEt) {
|
||||
await knex.transaction(async trx => {
|
||||
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} GET POSTING ET : ${JSON.stringify(item)}`)
|
||||
|
||||
let xmlHeader = {
|
||||
doc_header_text : item.doc_header_text ? item.doc_header_text : "",
|
||||
ba: item.ba ? item.ba : "",
|
||||
doc_date : item.doc_date ? item.doc_date : "",
|
||||
posting_date : item.posting_date ? item.posting_date : "",
|
||||
fisc_year : item.fiscal_year ? item.fiscal_year : "",
|
||||
fisc_period : item.fis_period ? item.fis_period: "",
|
||||
doc_type: item.doc_type ? item.doc_type : "",
|
||||
c_invoice_no : item.reference ? item.reference : ""
|
||||
}
|
||||
await knex.transaction(async (trx) => {
|
||||
winston.logger.info(
|
||||
`SCHEDULER-RETRY-${uniqueCode} GET POSTING ET : ${JSON.stringify(item)}`
|
||||
);
|
||||
|
||||
let xmlItem = ['S', 'H'].map(key => {
|
||||
let xmlHeader = {
|
||||
doc_header_text: item.doc_header_text ? item.doc_header_text : '',
|
||||
ba: item.ba ? item.ba : '',
|
||||
doc_date: item.doc_date ? item.doc_date : '',
|
||||
posting_date: item.posting_date ? item.posting_date : '',
|
||||
fisc_year: item.fiscal_year ? item.fiscal_year : '',
|
||||
fisc_period: item.fis_period ? item.fis_period : '',
|
||||
doc_type: item.doc_type ? item.doc_type : '',
|
||||
c_invoice_no: item.reference ? item.reference : '',
|
||||
};
|
||||
|
||||
let xmlItem = ['S', 'H'].map((key) => {
|
||||
return {
|
||||
c_account_code_topup : key == 'S' ? item.customer : "",
|
||||
c_account_topup : key == 'H' ? item.account : "",
|
||||
ba : item.ba,
|
||||
amount : item.amount,
|
||||
posting_date : item.posting_date,
|
||||
c_invoice_no : item.reference,
|
||||
item_text :key == 'S' ? item.text1 : item.text2,
|
||||
de_cre : key
|
||||
}
|
||||
c_account_code_topup: key == 'S' ? item.customer : '',
|
||||
c_account_topup: key == 'H' ? item.account : '',
|
||||
ba: item.ba,
|
||||
amount: item.amount,
|
||||
posting_date: item.posting_date,
|
||||
c_invoice_no: item.reference,
|
||||
item_text: key == 'S' ? item.text1 : item.text2,
|
||||
de_cre: key,
|
||||
};
|
||||
});
|
||||
|
||||
let xmlRequest = helper.generateXMLRequest('ZFMCMS_FI_001', xmlHeader, xmlItem)
|
||||
console.log(xmlRequest)
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} REQUEST posting ${item.reference} to SAP : ${xmlRequest}`);
|
||||
|
||||
const url = 'http://piqas.kereta-api.co.id:51500/XISOAPAdapter/MessageServlet?senderParty=&senderService=KCI_ETICKETING_2&receiverParty=&receiverService=&interface=SI_KCI_CMS_FI01&interfaceNamespace=urn:Posting_ETicketing_2'
|
||||
let xmlRequest = helper.generateXMLRequest(
|
||||
'ZFMCMS_FI_001',
|
||||
xmlHeader,
|
||||
xmlItem
|
||||
);
|
||||
console.log(xmlRequest);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-RETRY-${uniqueCode} REQUEST posting ${item.reference} to SAP : ${xmlRequest}`
|
||||
);
|
||||
|
||||
const response = await helper.postingSAP(url, xmlRequest)
|
||||
const url =
|
||||
'http://piqas.kereta-api.co.id:51500/XISOAPAdapter/MessageServlet?senderParty=&senderService=KCI_ETICKETING_2&receiverParty=&receiverService=&interface=SI_KCI_CMS_FI01&interfaceNamespace=urn:Posting_ETicketing_2';
|
||||
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} RESPONSE posting ${item.reference} to SAP : ${JSON.stringify(response)}`);
|
||||
const response = await helper.postingSAP(url, xmlRequest);
|
||||
|
||||
const resSAP = helper.getXMLData(response)
|
||||
winston.logger.info(
|
||||
`SCHEDULER-RETRY-${uniqueCode} RESPONSE posting ${
|
||||
item.reference
|
||||
} to SAP : ${JSON.stringify(response)}`
|
||||
);
|
||||
|
||||
const resSAP = helper.getXMLData(response);
|
||||
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} TRANSACTION 2`);
|
||||
// UPDATE CMS
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} SET resposn FB70 to CMS : ${JSON.stringify(resSAP)}`)
|
||||
winston.logger.info(
|
||||
`SCHEDULER-RETRY-${uniqueCode} SET resposn FB70 to CMS : ${JSON.stringify(
|
||||
resSAP
|
||||
)}`
|
||||
);
|
||||
|
||||
const cms = await model.setReturnSAP(item.no_dok, resSAP, trx)
|
||||
|
||||
winston.logger.info(`SCHEDULER-RETRY-${uniqueCode} RESULT CMS : ${JSON.stringify(cms)}`)
|
||||
const cms = await model.setReturnSAP(item.no_dok, resSAP, trx);
|
||||
|
||||
})
|
||||
winston.logger.info(
|
||||
`SCHEDULER-RETRY-${uniqueCode} RESULT CMS : ${JSON.stringify(cms)}`
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return postingEt
|
||||
|
||||
}
|
||||
return postingEt;
|
||||
};
|
||||
|
||||
function wait(milliseconds) {
|
||||
return new Promise(resolve => setTimeout(resolve, milliseconds));
|
||||
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
validate,
|
||||
apiGenerateCahsIn,
|
||||
apiPostingCahsIn,
|
||||
_postingCashIn,
|
||||
_generateCashIn
|
||||
};
|
||||
_generateCashIn,
|
||||
};
|
||||
|
||||
@@ -305,6 +305,65 @@ const getReserve = async (trx, code, date, invoice) => {
|
||||
};
|
||||
|
||||
const getPartnerRecon = async (trx) => {
|
||||
// const res = await trx
|
||||
// .select([
|
||||
// 'tdpr.c_partner_code',
|
||||
// 'tdrb.c_partner_name',
|
||||
// 'tdi.c_invoice_no',
|
||||
// 'tdi.d_invoice_date',
|
||||
// trx.raw("to_char(tdpr.d_payment, 'YYYY-MM-DD') AS d_payment"),
|
||||
// trx.raw('SUM(tdrb.i_reservation_amount) AS amount'),
|
||||
// 'tmp.c_account_topup',
|
||||
// 'tmp.c_account_code_topup',
|
||||
// 'i_company',
|
||||
// 'i_holding',
|
||||
// trx.raw(`CASE
|
||||
// WHEN to_char(tdpr.d_payment, 'MM') >= to_char(tdi.d_invoice_date, 'MM')
|
||||
// THEN 'IP'
|
||||
// ELSE
|
||||
// 'OP'
|
||||
// END c_in_period`),
|
||||
// ])
|
||||
// .from('trx.t_d_reservation_balance AS tdrb')
|
||||
// .leftJoin('trx.t_d_load_balance as tdlb', function () {
|
||||
// this.on('tdrb.c_load_balance_no', '=', 'tdlb.c_load_balance_no');
|
||||
// })
|
||||
// .leftJoin('payment.t_d_invoice as tdi', function () {
|
||||
// this.on('tdi.c_invoice_no', '=', 'tdlb.c_invoice_no').orOn(
|
||||
// 'tdi.c_invoice_no',
|
||||
// '=',
|
||||
// 'tdrb.c_invoice_no'
|
||||
// );
|
||||
// })
|
||||
// .leftJoin('payment.t_d_payment_recon as tdpr', function () {
|
||||
// this.on('tdpr.c_reservation_no', '=', 'tdrb.c_reservation_no');
|
||||
// })
|
||||
// .leftJoin('public.t_m_partner as tmp', function () {
|
||||
// this.on('tmp.i_partner', '=', 'tdrb.i_partner');
|
||||
// })
|
||||
|
||||
// .where('tdrb.c_status', '=', 'A')
|
||||
// .where('tdi.c_status', '!=', 'X')
|
||||
// .where('tdpr.c_status', '=', 'S')
|
||||
// .whereNotNull('tdi.c_return_sap')
|
||||
// .whereNotNull('tdrb.c_load_balance_no')
|
||||
// .whereRaw(
|
||||
// `tdrb.c_reservation_no in (SELECT c_reservation_no FROM payment.t_d_payment_recon where c_status = 'S' ) AND tdrb.c_reservation_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`
|
||||
// )
|
||||
// .groupBy([
|
||||
// 'tdpr.c_partner_code',
|
||||
// 'tdrb.c_partner_name',
|
||||
// 'tdi.c_invoice_no',
|
||||
// 'tdi.d_invoice_date',
|
||||
// 'tdpr.d_payment',
|
||||
// 'tmp.c_account_topup',
|
||||
// 'tmp.c_account_code_topup',
|
||||
// 'tdi.i_company',
|
||||
// 'i_holding',
|
||||
// ])
|
||||
// .limit(1);
|
||||
// .toSql()
|
||||
|
||||
const res = await trx
|
||||
.select([
|
||||
'tdpr.c_partner_code',
|
||||
@@ -312,13 +371,14 @@ const getPartnerRecon = async (trx) => {
|
||||
'tdi.c_invoice_no',
|
||||
'tdi.d_invoice_date',
|
||||
trx.raw("to_char(tdpr.d_payment, 'YYYY-MM-DD') AS d_payment"),
|
||||
trx.raw('SUM(tdrb.i_reservation_amount) AS amount'),
|
||||
trx.raw('coalesce(SUM(tdrb.i_reservation_amount),0) AS amount'),
|
||||
// trx.raw('coalesce(SUM(tdcid.m_amount),0) AS amount_cash_in'),
|
||||
'tmp.c_account_topup',
|
||||
'tmp.c_account_code_topup',
|
||||
'i_company',
|
||||
'i_holding',
|
||||
trx.raw(`CASE
|
||||
WHEN to_char(tdpr.d_payment, 'MM') >= to_char(tdi.d_invoice_date, 'MM')
|
||||
WHEN to_char(tdpr.d_payment, 'YYYYMM') >= to_char(tdi.d_invoice_date, 'YYYYMM')
|
||||
THEN 'IP'
|
||||
ELSE
|
||||
'OP'
|
||||
@@ -341,15 +401,16 @@ const getPartnerRecon = async (trx) => {
|
||||
.leftJoin('public.t_m_partner as tmp', function () {
|
||||
this.on('tmp.i_partner', '=', 'tdrb.i_partner');
|
||||
})
|
||||
// .leftJoin('payment.t_d_cash_in_detail as tdcid', function () {
|
||||
// this.on('tdcid.c_reservation_no', '=', 'tdrb.c_reservation_no');
|
||||
// })
|
||||
|
||||
.where('tdrb.c_status', '=', 'A')
|
||||
.where('tdi.c_status', '!=', 'X')
|
||||
.where('tdpr.c_status', '=', 'S')
|
||||
.whereNotNull('tdi.c_return_sap')
|
||||
.whereNotNull('tdrb.c_load_balance_no')
|
||||
.whereRaw(
|
||||
`tdrb.c_reservation_no in (SELECT c_reservation_no FROM payment.t_d_payment_recon where c_status = 'S' ) AND tdrb.c_reservation_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`
|
||||
)
|
||||
.whereNull('tdrb.c_cash_in_no')
|
||||
.groupBy([
|
||||
'tdpr.c_partner_code',
|
||||
'tdrb.c_partner_name',
|
||||
@@ -361,7 +422,9 @@ const getPartnerRecon = async (trx) => {
|
||||
'tdi.i_company',
|
||||
'i_holding',
|
||||
]);
|
||||
// .toSql()
|
||||
// .havingRaw(
|
||||
// 'coalesce(SUM(tdrb.i_reservation_amount),0) > coalesce(SUM(tdcid.m_amount),0)'
|
||||
// );
|
||||
|
||||
return res;
|
||||
};
|
||||
@@ -391,9 +454,14 @@ const generateCode = async (trx, c_partner_code, d_payment_recon) => {
|
||||
|
||||
const insertCashInDetail = async (trx, data) => {
|
||||
let result = [];
|
||||
if (data.length > 0) {
|
||||
// if (data.length > 0) {
|
||||
// result = await trx('payment.t_d_cash_in_detail').insert(data, ['*']);
|
||||
// }
|
||||
|
||||
if (data) {
|
||||
result = await trx('payment.t_d_cash_in_detail').insert(data, ['*']);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
@@ -530,6 +530,16 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// get parameter setting pengecekkan nomor kartu dengan card product di CMS
|
||||
let getCheckByCardProductStatusValue =
|
||||
await model.getCheckByCardProductStatusValue();
|
||||
@@ -1251,6 +1261,16 @@ const loadingBalanceInsert = async (req, param) => {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log warn
|
||||
// winston.logger.warn(
|
||||
// `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: checking reservation status...`
|
||||
@@ -1761,6 +1781,16 @@ const loadingBalanceUpdate = async (param) => {
|
||||
return result;
|
||||
}
|
||||
|
||||
// if (getPartner.i_partner != req.partner_id_token) {
|
||||
// result = {
|
||||
// code: '412',
|
||||
// message: 'partner is not match',
|
||||
// data: {},
|
||||
// };
|
||||
|
||||
// return res.status(200).json(result);
|
||||
// }
|
||||
|
||||
let data = {
|
||||
d_load_balance: now,
|
||||
c_ref_no: ref_no,
|
||||
|
||||
@@ -119,6 +119,9 @@ const checkReservation = async (req, res) => {
|
||||
`${uniqueCode} [ REQUEST RESERVATION-CHECK ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -209,6 +212,28 @@ const checkReservation = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {
|
||||
body: req.body,
|
||||
partner_id_token: req.partner_id_token,
|
||||
partner_user_id_token: req.partner_user_id_token,
|
||||
headers: req.headers,
|
||||
},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// lakukan pencarian ke table reservasion, apakah nomor kartu yang di request masih mempunyai transaksi reservasi saldo yang status nya masih pending atau in progress
|
||||
// winston.logger.debug(
|
||||
@@ -288,6 +313,9 @@ const reservationValidate = async (req, res) => {
|
||||
)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -388,6 +416,16 @@ const reservationValidate = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -708,6 +746,9 @@ const reservationValidateV2 = async (req, res) => {
|
||||
)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
// card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -808,6 +849,16 @@ const reservationValidateV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -1179,6 +1230,9 @@ const reservation = async (req, res) => {
|
||||
`${uniqueCode} [ REQUEST RESERVATION ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -1269,6 +1323,16 @@ const reservation = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -1829,6 +1893,9 @@ const reservationV2 = async (req, res) => {
|
||||
`${uniqueCode} [ REQUEST RESERVATION-V2 ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// trim card number
|
||||
// card_number = card_number.trim();
|
||||
|
||||
// check validator
|
||||
let err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
@@ -2057,6 +2124,16 @@ const reservationV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// get settingan dari parameter apakah nomor kartu yang di request harus di cek dengan data card product CMS atau tidak
|
||||
// winston.logger.debug(
|
||||
@@ -2697,6 +2774,16 @@ const cancelReservationValidate = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -2882,6 +2969,16 @@ const cancelReservation = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -3358,6 +3455,16 @@ const cancelReservationValidateV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let getReservationCanBeCanceled;
|
||||
|
||||
// jika cancelation reservation dilakukan dengan menggunakan ref no
|
||||
@@ -3776,6 +3883,16 @@ const cancelReservationV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -4022,6 +4139,16 @@ const cancelReservationV2_1 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
// proses pengecekkan status reservation number yang di request
|
||||
// winston.logger.debug(
|
||||
@@ -4279,6 +4406,16 @@ const getFeeSharing = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (getPartner.i_partner != req.partner_id_token) {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// set default issuer fee
|
||||
let issuerFee = 0;
|
||||
let channelFee = 0;
|
||||
@@ -4333,6 +4470,51 @@ const getFeeSharing = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
const decrpytRequest = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||
let uniqueCode = await helper.getUniqueCode();
|
||||
let result = {};
|
||||
|
||||
let { reservation_data } = req.body;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ REQUEST DECRYPT ]: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
reservationData = helper.decryptText(reservation_data);
|
||||
// parsing data to json format
|
||||
parseData = JSON.parse(reservationData);
|
||||
result = {
|
||||
code: '00',
|
||||
message: 'decrypted successfully.',
|
||||
data: parseData,
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.info(
|
||||
`${uniqueCode} [ RESPONSE DECRYPT ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
result = {
|
||||
code: '500',
|
||||
message: 'decrypted failed.',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.error(
|
||||
`${uniqueCode} [ RESPONSE DECRYPT ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validate,
|
||||
checkReservation,
|
||||
@@ -4349,4 +4531,5 @@ module.exports = {
|
||||
cancelReservationV2,
|
||||
cancelReservationV2_1,
|
||||
getFeeSharing,
|
||||
decrpytRequest,
|
||||
};
|
||||
|
||||
@@ -98,6 +98,12 @@ router.post(
|
||||
controller.getFeeSharing
|
||||
);
|
||||
|
||||
router.post(
|
||||
'/reservation/decrypt',
|
||||
auth.authenticateToken,
|
||||
controller.decrpytRequest
|
||||
);
|
||||
|
||||
// router.post(
|
||||
// '/reservation/cancel/v2.1',
|
||||
// auth.authenticateToken,
|
||||
|
||||
@@ -42,6 +42,9 @@ DB_PORT_POOLING=5432
|
||||
DB_USER_POOLING=postgres
|
||||
DB_PASSWORD_POOLING=inhc0mmute_cms
|
||||
|
||||
# ==================================== LOKI =====================================
|
||||
LOKI_URL=http://10.20.14.30:3100
|
||||
|
||||
# ==================================== LOKI =====================================
|
||||
LOKI_URL=http://localhost:3100
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
@@ -51,6 +51,9 @@ var corsOptions = {
|
||||
// app.use(cors(corsOptions));
|
||||
app.use(cors(corsOptions));
|
||||
|
||||
// add static file
|
||||
app.use(express.static('public'));
|
||||
|
||||
// parse requests of content-type - application/json
|
||||
app.use(bodyParser.json());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user