mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 23:36:28 +00:00
Merge branch 'main' of https://github.com/mohamadihsan/topuponline into nuranggi
This commit is contained in:
@@ -8,7 +8,6 @@ const { default: axios } = require("axios");
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
moment.locale("id");
|
||||
|
||||
var maxLoopParameter = 100;
|
||||
var dataReconQueue = [];
|
||||
var isProccessingRecon = false;
|
||||
|
||||
@@ -74,6 +73,352 @@ const validate = (method) => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const paymentRecon = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
let result = {};
|
||||
|
||||
// param
|
||||
let { date, bank_ref, reservation_number, amount } = req.body;
|
||||
let partner_id = req.partner_id_token;
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} REQUEST payment recon: ${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 payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// time
|
||||
let now = moment().format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} checking partner...`);
|
||||
|
||||
// get partner, merchant, terminal from tid
|
||||
let getPartner = await model.getPartnerByID(partner_id);
|
||||
if (!getPartner) {
|
||||
result = {
|
||||
code: "426",
|
||||
message: "Partner doesn't exists.",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// check ref no and amount
|
||||
let checkReservationNumberAndAmountAlreadyRecon =
|
||||
await model.checkReservationNumberAndAmountAlreadyRecon(
|
||||
reservation_number
|
||||
);
|
||||
if (checkReservationNumberAndAmountAlreadyRecon) {
|
||||
result = {
|
||||
code: "04",
|
||||
message: `success. Transaction has been recon at ${checkReservationNumberAndAmountAlreadyRecon.d_payment_recon}`,
|
||||
data: {
|
||||
payment_recon_no:
|
||||
checkReservationNumberAndAmountAlreadyRecon.c_payment_recon_no,
|
||||
recon_date:
|
||||
checkReservationNumberAndAmountAlreadyRecon.d_payment_recon,
|
||||
},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let partnerCode = getPartner.partner_code;
|
||||
let PaymentReconNumber;
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} generating payment recon number...`);
|
||||
|
||||
// loop 1
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(partnerCode, now);
|
||||
|
||||
if (PaymentReconNumber == "XX") {
|
||||
// loop 2
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(partnerCode, now);
|
||||
|
||||
if (PaymentReconNumber == "XX") {
|
||||
// loop 3
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(partnerCode, now);
|
||||
|
||||
if (PaymentReconNumber == "XX") {
|
||||
// loop 4
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(
|
||||
partnerCode,
|
||||
now
|
||||
);
|
||||
|
||||
if (PaymentReconNumber == "XX") {
|
||||
// loop 5
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(
|
||||
partnerCode,
|
||||
now
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PaymentReconNumber == "XX") {
|
||||
// create log
|
||||
winston.logger.error(`server is busy. please try again.`);
|
||||
|
||||
result = {
|
||||
code: "500",
|
||||
message: "server is busy. please try again.",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// check ref no and amount
|
||||
let check = await model.checkReservationNumberAndAmount(reservation_number);
|
||||
if (!check) {
|
||||
result = {
|
||||
code: "427",
|
||||
message: "transaction doesn't exists",
|
||||
data: {
|
||||
payment_recon_no: PaymentReconNumber,
|
||||
recon_date: now,
|
||||
},
|
||||
};
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
now,
|
||||
getPartner.partner_code,
|
||||
PaymentReconNumber,
|
||||
bank_ref,
|
||||
reservation_number,
|
||||
amount,
|
||||
"F",
|
||||
"FAILED",
|
||||
result.code,
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let totalTransactions = check.total_transaction;
|
||||
|
||||
if (totalTransactions > 1) {
|
||||
result = {
|
||||
code: "424",
|
||||
message: "Duplicate Ref No.",
|
||||
data: {
|
||||
payment_recon_no: PaymentReconNumber,
|
||||
recon_date: now,
|
||||
},
|
||||
};
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
now,
|
||||
getPartner.partner_code,
|
||||
PaymentReconNumber,
|
||||
bank_ref,
|
||||
reservation_number,
|
||||
amount,
|
||||
"F",
|
||||
"FAILED",
|
||||
result.code,
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let totalAmount = check.total_amount;
|
||||
|
||||
if (parseInt(totalAmount) != parseInt(amount)) {
|
||||
result = {
|
||||
code: "425",
|
||||
message: "Total amount is different.",
|
||||
data: {
|
||||
payment_recon_no: PaymentReconNumber,
|
||||
recon_date: now,
|
||||
},
|
||||
};
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
now,
|
||||
getPartner.partner_code,
|
||||
PaymentReconNumber,
|
||||
bank_ref,
|
||||
reservation_number,
|
||||
amount,
|
||||
"F",
|
||||
"FAILED",
|
||||
result.code,
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let data = {
|
||||
reservation_number: reservation_number,
|
||||
payment_recon_no: PaymentReconNumber,
|
||||
date: date,
|
||||
time: now,
|
||||
};
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} updating payment recon number...`);
|
||||
|
||||
let update = await model.updatePaymentReconNo(data);
|
||||
if (!update) {
|
||||
result = {
|
||||
code: "428",
|
||||
message:
|
||||
"failed recon. The other transaction with same data is running.",
|
||||
data: {
|
||||
payment_recon_no: PaymentReconNumber,
|
||||
recon_date: now,
|
||||
},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "success",
|
||||
data: {
|
||||
payment_recon_no: PaymentReconNumber,
|
||||
recon_date: now,
|
||||
},
|
||||
};
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
now,
|
||||
getPartner.partner_code,
|
||||
PaymentReconNumber,
|
||||
bank_ref,
|
||||
reservation_number,
|
||||
amount,
|
||||
"S",
|
||||
"SUCCESS",
|
||||
result.code,
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
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: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// PAYMENT RECON
|
||||
const paymentReconQueue = async (req, res) => {
|
||||
try {
|
||||
@@ -133,8 +478,11 @@ const paymentReconQueue = async (req, res) => {
|
||||
let PaymentReconNumber;
|
||||
|
||||
while (dataReconQueue.length != 0) {
|
||||
console.log('HAHAHA');
|
||||
if (dataReconQueue[0] == reservation_number && isProccessingRecon == false) {
|
||||
console.log("HAHAHA");
|
||||
if (
|
||||
dataReconQueue[0] == reservation_number &&
|
||||
isProccessingRecon == false
|
||||
) {
|
||||
isProccessingRecon == true;
|
||||
PaymentReconNumber = await generatePaymentReconNumber(
|
||||
partnerCode,
|
||||
@@ -142,8 +490,8 @@ const paymentReconQueue = async (req, res) => {
|
||||
);
|
||||
if (PaymentReconNumber != "XX") {
|
||||
queue.reconFinish(dataReconQueue);
|
||||
isProccessingRecon == false
|
||||
|
||||
isProccessingRecon == false;
|
||||
|
||||
// check ref no and amount
|
||||
let checkReservationNumberAndAmountAlreadyRecon =
|
||||
await model.checkReservationNumberAndAmountAlreadyRecon(
|
||||
@@ -160,20 +508,20 @@ const paymentReconQueue = async (req, res) => {
|
||||
checkReservationNumberAndAmountAlreadyRecon.d_payment_recon,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} checking reservation canceled status...`
|
||||
);
|
||||
|
||||
|
||||
// check reservation status
|
||||
let checkReservationCanceledStatus =
|
||||
await model.checkReservationCanceledStatus(reservation_number);
|
||||
@@ -186,12 +534,12 @@ const paymentReconQueue = async (req, res) => {
|
||||
recon_date: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
@@ -207,20 +555,20 @@ const paymentReconQueue = async (req, res) => {
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} checking total transaction and amount by reservation number...`
|
||||
);
|
||||
|
||||
|
||||
// check ref no and amount
|
||||
let check = await model.checkReservationNumberAndAmount(
|
||||
reservation_number
|
||||
@@ -234,12 +582,12 @@ const paymentReconQueue = async (req, res) => {
|
||||
recon_date: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
@@ -255,17 +603,17 @@ const paymentReconQueue = async (req, res) => {
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
|
||||
let totalTransactions = check.total_transaction;
|
||||
|
||||
|
||||
if (totalTransactions > 1) {
|
||||
result = {
|
||||
code: "424",
|
||||
@@ -275,12 +623,12 @@ const paymentReconQueue = async (req, res) => {
|
||||
recon_date: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
@@ -296,17 +644,17 @@ const paymentReconQueue = async (req, res) => {
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
|
||||
let totalAmount = check.total_amount;
|
||||
|
||||
|
||||
if (parseInt(totalAmount) != parseInt(amount)) {
|
||||
result = {
|
||||
code: "425",
|
||||
@@ -316,12 +664,12 @@ const paymentReconQueue = async (req, res) => {
|
||||
recon_date: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
@@ -337,25 +685,27 @@ const paymentReconQueue = async (req, res) => {
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
|
||||
let data = {
|
||||
reservation_number: reservation_number,
|
||||
payment_recon_no: PaymentReconNumber,
|
||||
date: date,
|
||||
time: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
};
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} updating payment recon number...`);
|
||||
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} updating payment recon number...`
|
||||
);
|
||||
|
||||
let update = await model.updatePaymentReconNo(data);
|
||||
if (!update) {
|
||||
result = {
|
||||
@@ -367,20 +717,20 @@ const paymentReconQueue = async (req, res) => {
|
||||
recon_date: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(
|
||||
`${uniqueCode} inserting payment recon transaction...`
|
||||
);
|
||||
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "success",
|
||||
@@ -389,7 +739,7 @@ const paymentReconQueue = async (req, res) => {
|
||||
recon_date: moment().format("YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
// insert payment recon transaction
|
||||
await model.insertPaymentReconTransaction(
|
||||
date,
|
||||
@@ -405,16 +755,15 @@ const paymentReconQueue = async (req, res) => {
|
||||
result.message.toUpperCase(),
|
||||
result.data
|
||||
);
|
||||
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
// create log
|
||||
@@ -433,7 +782,7 @@ const paymentReconQueue = async (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
const paymentRecon = async (req, res) => {
|
||||
const paymentReconOri = async (req, res) => {
|
||||
try {
|
||||
// generate unique code
|
||||
let uniqueCode = helper.getUniqueCode();
|
||||
@@ -488,30 +837,6 @@ const paymentRecon = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let partnerCode = getPartner.partner_code;
|
||||
let PaymentReconNumber;
|
||||
let maxLoop = 0;
|
||||
do {
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(partnerCode, now);
|
||||
|
||||
maxLoop++;
|
||||
} while (PaymentReconNumber == "XX" || (maxLoop > maxLoopParameter));
|
||||
|
||||
if (maxLoop > maxLoopParameter) {
|
||||
// create log
|
||||
winston.logger.error(`server is busy. please try again.`);
|
||||
|
||||
return {
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "server is busy. please try again.",
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
|
||||
// check ref no and amount
|
||||
let checkReservationNumberAndAmountAlreadyRecon =
|
||||
await model.checkReservationNumberAndAmountAlreadyRecon(
|
||||
@@ -537,6 +862,39 @@ const paymentRecon = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let partnerCode = getPartner.partner_code;
|
||||
let PaymentReconNumber;
|
||||
let maxLoop = 0;
|
||||
let maxLoopParameter = 10;
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} generating payment recon number...`);
|
||||
|
||||
do {
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(partnerCode, now);
|
||||
|
||||
maxLoop++;
|
||||
} while (PaymentReconNumber == "XX" && maxLoop <= maxLoopParameter);
|
||||
|
||||
if (maxLoop > maxLoopParameter) {
|
||||
// create log
|
||||
winston.logger.error(`server is busy. please try again.`);
|
||||
|
||||
result = {
|
||||
code: "500",
|
||||
message: "server is busy. please try again.",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE payment recon: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// check ref no and amount
|
||||
let check = await model.checkReservationNumberAndAmount(reservation_number);
|
||||
if (!check) {
|
||||
@@ -802,26 +1160,28 @@ const paymentReconSemiTopupOnline = async (req, res) => {
|
||||
let partnerCode = getPartner.partner_code;
|
||||
let PaymentReconNumber;
|
||||
let maxLoop = 0;
|
||||
let maxLoopParameter = 20;
|
||||
|
||||
do {
|
||||
await _sleep(helper.randomNumberInt());
|
||||
PaymentReconNumber = await generatePaymentReconNumber(partnerCode, now);
|
||||
|
||||
if (maxLoop > maxLoopParameter) {
|
||||
// create log
|
||||
winston.logger.error(`server is busy. please try again.`);
|
||||
|
||||
return {
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "server is busy. please try again.",
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
|
||||
maxLoop++;
|
||||
} while (PaymentReconNumber == "XX");
|
||||
} while (PaymentReconNumber == "XX" && maxLoop <= maxLoopParameter);
|
||||
|
||||
if (maxLoop > maxLoopParameter) {
|
||||
// create log
|
||||
winston.logger.error(`server is busy. please try again.`);
|
||||
|
||||
return {
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "server is busy. please try again.",
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
|
||||
// check ref no and amount
|
||||
let checkReservationNumberAndAmountAlreadyRecon =
|
||||
@@ -1163,6 +1523,7 @@ const generatePaymentReconNumber = async (partnerCode, reconDate) => {
|
||||
partnerCode,
|
||||
reconDate
|
||||
);
|
||||
|
||||
if (getLastCounterPaymentReconNo) {
|
||||
counter = (
|
||||
parseInt(
|
||||
@@ -1175,11 +1536,15 @@ const generatePaymentReconNumber = async (partnerCode, reconDate) => {
|
||||
} else {
|
||||
counter = counter.padStart(6, "0");
|
||||
}
|
||||
|
||||
let paymentReconNumber;
|
||||
paymentReconNumber = `RC${partnerCode}${moment(reconDate).format(
|
||||
"YYMMDD"
|
||||
)}${counter}`;
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`Payment Recon Number: ${paymentReconNumber}`);
|
||||
|
||||
// insert to tempPaymentReconNumber
|
||||
let insert = await model.insertPaymentReconNumber(paymentReconNumber);
|
||||
if (insert.rowCount < 1) {
|
||||
|
||||
+19
-19
@@ -1,31 +1,31 @@
|
||||
require("dotenv").config();
|
||||
|
||||
module.exports = {
|
||||
development: {
|
||||
client: "pg",
|
||||
connection: process.env.DB_URL,
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
seeds: { directory: "./infrastructure/database/seeds" },
|
||||
},
|
||||
// development: {
|
||||
// client: "pg",
|
||||
// connection: {
|
||||
// host : '10.1.201.95',
|
||||
// database: "postgres",
|
||||
// user: "cms",
|
||||
// password: "Cm5kc1#2021",
|
||||
// },
|
||||
// // connection: process.env.DB_URL,
|
||||
// pool: {
|
||||
// min: 2,
|
||||
// max: 10,
|
||||
// },
|
||||
// connection: process.env.DB_URL,
|
||||
// migrations: {
|
||||
// directory: "./infrastructure/database/migrations",
|
||||
// },
|
||||
// seeds: { directory: "./infrastructure/database/seeds" },
|
||||
// },
|
||||
development: {
|
||||
client: "pg",
|
||||
connection: {
|
||||
host : '10.1.201.95',
|
||||
database: "postgres",
|
||||
user: "cms",
|
||||
password: "Cm5kc1#2021",
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
},
|
||||
|
||||
testing: {
|
||||
client: "pg",
|
||||
|
||||
Reference in New Issue
Block a user