mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 11:36:28 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e30c78beb7 | |||
| 1d2e92b85f | |||
| 51cb6c1212 | |||
| 6c93cff3bb | |||
| b24335043a | |||
| ac2ea55b5d | |||
| f3e9097bfa | |||
| 0dcec2a6ad | |||
| f8f974eb11 | |||
| 29981e9757 | |||
| a59a9090a7 | |||
| ca17c397c5 | |||
| ff1a80f3b5 | |||
| 4bda7458b4 | |||
| d4d61d1d79 | |||
| 80557a53e8 | |||
| 920a6d4ccd |
@@ -70,12 +70,12 @@ const authenticateToken = async (req, res, next) => {
|
|||||||
if (authHeader) {
|
if (authHeader) {
|
||||||
let token = authHeader && authHeader.split(' ')[1];
|
let token = authHeader && authHeader.split(' ')[1];
|
||||||
|
|
||||||
winston.logger.info(
|
// winston.logger.info(
|
||||||
`${uniqueCode} [ AUTHENTICATE TOKEN ]: ${JSON.stringify({
|
// `000000000000 [ AUTHENTICATE TOKEN ]: ${JSON.stringify({
|
||||||
token: token,
|
// token: token,
|
||||||
ip: ip,
|
// ip: ip,
|
||||||
})}`
|
// })}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return res.json({
|
return res.json({
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
|
|
||||||
// GET PARTNER, MERCHANT, TERMINAL FROM TID
|
// GET PARTNER, MERCHANT, TERMINAL FROM TID
|
||||||
const generateInvoice = async (invoiceDate, repost, trx) => {
|
const generateInvoice = async (invoiceDate, repost, trx) => {
|
||||||
|
let result = await trx.select(
|
||||||
let result = await trx.select(trx.raw(`* FROM payment.sp_payment_req_topup_online('${invoiceDate}', ${repost})`))
|
trx.raw(
|
||||||
|
`* FROM payment.sp_payment_req_topup_online('${invoiceDate}', ${repost})`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const insertPostingEt = async (code, dataCashIn, trx) => {
|
const insertPostingEt = async (code, dataCashIn, trx) => {
|
||||||
let type = ['S', 'H']
|
let type = ['S', 'H'];
|
||||||
let et = []
|
let et = [];
|
||||||
let posting_et = []
|
let posting_et = [];
|
||||||
type.forEach((item, index) => {
|
type.forEach((item, index) => {
|
||||||
let data = {
|
let data = {
|
||||||
file_name: code,
|
file_name: code,
|
||||||
@@ -25,41 +26,55 @@ const insertPostingEt = async (code, dataCashIn, trx) => {
|
|||||||
reference: code,
|
reference: code,
|
||||||
amount: dataCashIn.amount,
|
amount: dataCashIn.amount,
|
||||||
ba: dataCashIn.ba,
|
ba: dataCashIn.ba,
|
||||||
indeks: (index+1),
|
indeks: index + 1,
|
||||||
totalidx: type.length,
|
totalidx: type.length,
|
||||||
doc_header_text: code,
|
doc_header_text: code,
|
||||||
pos_status : 4
|
pos_status: 4,
|
||||||
}
|
};
|
||||||
|
|
||||||
if (item == 'H') {
|
if (item == 'H') {
|
||||||
data = {...data, ...{
|
data = {
|
||||||
|
...data,
|
||||||
|
...{
|
||||||
text: `Cash-in CMS ${code}`,
|
text: `Cash-in CMS ${code}`,
|
||||||
debit_kredit: item,
|
debit_kredit: item,
|
||||||
account: dataCashIn.c_account_topup,
|
account: dataCashIn.c_account_topup,
|
||||||
customer: null
|
customer: null,
|
||||||
}}
|
},
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
data = {...data, ...{
|
data = {
|
||||||
|
...data,
|
||||||
|
...{
|
||||||
text: `Cash-in CMS ${code}`,
|
text: `Cash-in CMS ${code}`,
|
||||||
debit_kredit: item,
|
debit_kredit: item,
|
||||||
account: null,
|
account: null,
|
||||||
customer: dataCashIn.c_account_code_topup
|
customer: dataCashIn.c_account_code_topup,
|
||||||
}}
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
et.push(data)
|
et.push(data);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
posting_et = await trx('public.posting_et').insert(et, ['indeks', 'customer', 'account', 'ba', 'fiscal_year', 'amount', 'no_dok', 'text', 'debit_kredit'])
|
posting_et = await trx('public.posting_et').insert(et, [
|
||||||
|
'indeks',
|
||||||
|
'customer',
|
||||||
|
'account',
|
||||||
|
'ba',
|
||||||
|
'fiscal_year',
|
||||||
|
'amount',
|
||||||
|
'no_dok',
|
||||||
|
'text',
|
||||||
|
'debit_kredit',
|
||||||
|
]);
|
||||||
|
|
||||||
return posting_et[0]
|
return posting_et[0];
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const getPostingEt = async (trx) => {
|
const getPostingEt = async (trx) => {
|
||||||
|
const result = await trx('public.posting_et AS pe')
|
||||||
const result = await trx('public.posting_et AS pe').select([
|
.select([
|
||||||
'doc_header_text',
|
'doc_header_text',
|
||||||
'ba',
|
'ba',
|
||||||
'doc_date',
|
'doc_date',
|
||||||
@@ -72,90 +87,132 @@ const getPostingEt = async(trx) => {
|
|||||||
'tcode',
|
'tcode',
|
||||||
'amount',
|
'amount',
|
||||||
trx.raw(`'IDR' AS currency`),
|
trx.raw(`'IDR' AS currency`),
|
||||||
trx.raw(`(SELECT customer FROM public.posting_et where reference = pe.reference and debit_kredit = 'S') as customer`),
|
trx.raw(
|
||||||
trx.raw(`(SELECT account FROM public.posting_et where reference = pe.reference and debit_kredit = 'H') as account `),
|
`(SELECT customer FROM public.posting_et where reference = pe.reference and debit_kredit = 'S') as customer`
|
||||||
trx.raw(`(SELECT text FROM public.posting_et where reference = pe.reference and debit_kredit = 'S') as text1`),
|
),
|
||||||
trx.raw(`(SELECT text FROM public.posting_et where reference = pe.reference and debit_kredit = 'H') as text2`)
|
trx.raw(
|
||||||
|
`(SELECT account FROM public.posting_et where reference = pe.reference and debit_kredit = 'H') as account `
|
||||||
|
),
|
||||||
|
trx.raw(
|
||||||
|
`(SELECT text FROM public.posting_et where reference = pe.reference and debit_kredit = 'S') as text1`
|
||||||
|
),
|
||||||
|
trx.raw(
|
||||||
|
`(SELECT text FROM public.posting_et where reference = pe.reference and debit_kredit = 'H') as text2`
|
||||||
|
),
|
||||||
])
|
])
|
||||||
.where('tcode', '=', "FB70")
|
.where('tcode', '=', 'FB70')
|
||||||
// .where('reference', '=', reference)
|
// .where('reference', '=', reference)
|
||||||
.whereIn('pos_status', ["4"])
|
.whereIn('pos_status', ['4'])
|
||||||
|
|
||||||
.groupBy(['doc_header_text', 'ba', 'doc_header_text', 'tcode', 'ba', 'amount', 'posting_date', 'doc_date', 'doc_type', 'fiscal_year', 'reference', 'no_dok'])
|
.groupBy([
|
||||||
|
'doc_header_text',
|
||||||
|
'ba',
|
||||||
|
'doc_header_text',
|
||||||
|
'tcode',
|
||||||
|
'ba',
|
||||||
|
'amount',
|
||||||
|
'posting_date',
|
||||||
|
'doc_date',
|
||||||
|
'doc_type',
|
||||||
|
'fiscal_year',
|
||||||
|
'reference',
|
||||||
|
'no_dok',
|
||||||
|
]);
|
||||||
|
|
||||||
return result
|
return result;
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const setReturnSAP = async (code, resSAP, trx) => {
|
const setReturnSAP = async (code, resSAP, trx) => {
|
||||||
let t_cash_in = []
|
let t_cash_in = [];
|
||||||
let reserveBalance = []
|
let reserveBalance = [];
|
||||||
|
|
||||||
if (resSAP.type == 'S') {
|
if (resSAP.type == 'S') {
|
||||||
// update invoice
|
// update invoice
|
||||||
t_cash_in = await trx('payment.t_d_cash_in').update({
|
t_cash_in = await trx('payment.t_d_cash_in')
|
||||||
|
.update(
|
||||||
|
{
|
||||||
c_return_sap: resSAP.data.E_DOCUMENTNUMBER,
|
c_return_sap: resSAP.data.E_DOCUMENTNUMBER,
|
||||||
c_return_year_sap: resSAP.data.E_DOCUMENTYEAR
|
c_return_year_sap: resSAP.data.E_DOCUMENTYEAR,
|
||||||
}, ['c_cash_in_no','c_return_sap'])
|
},
|
||||||
|
['c_cash_in_no', 'c_return_sap']
|
||||||
|
)
|
||||||
.where({
|
.where({
|
||||||
c_cash_in_no: code
|
c_cash_in_no: code,
|
||||||
});
|
});
|
||||||
|
|
||||||
// update load balance
|
// update load balance
|
||||||
reserveBalance = await trx('trx.t_d_reservation_balance').update({
|
reserveBalance = await trx('trx.t_d_reservation_balance')
|
||||||
|
.update(
|
||||||
|
{
|
||||||
c_return_cash_in_sap: resSAP.data.E_DOCUMENTNUMBER,
|
c_return_cash_in_sap: resSAP.data.E_DOCUMENTNUMBER,
|
||||||
c_cash_in_no: code
|
c_cash_in_no: code,
|
||||||
}, ['c_cash_in_no', 'c_return_sap'])
|
},
|
||||||
.whereRaw(`c_reservation_no IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail tdcid LEFT JOIN payment.t_d_cash_in tdci ON tdcid.i_cash_in = tdci.i_cash_in WHERE tdci.c_cash_in_no = '${code}')`)
|
['c_cash_in_no', 'c_return_sap']
|
||||||
|
)
|
||||||
|
.whereRaw(
|
||||||
|
`c_reservation_no IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail tdcid LEFT JOIN payment.t_d_cash_in tdci ON tdcid.i_cash_in = tdci.i_cash_in WHERE tdci.c_cash_in_no = '${code}')`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
let text = resSAP.message;
|
let text = resSAP.message;
|
||||||
let result = text.toUpperCase();
|
let result = text.toUpperCase();
|
||||||
if(result.includes("ALREADY")){
|
if (result.includes('ALREADY')) {
|
||||||
let result = text.toUpperCase().split('-');
|
let result = text.toUpperCase().split('-');
|
||||||
let doc_number = result[1].trim().split(" ")[0]
|
let doc_number = result[1].trim().split(' ')[0];
|
||||||
// update invoice
|
// update invoice
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
let year = d.getFullYear();
|
let year = d.getFullYear();
|
||||||
t_cash_in = await trx('payment.t_d_cash_in').update({
|
t_cash_in = await trx('payment.t_d_cash_in')
|
||||||
|
.update(
|
||||||
|
{
|
||||||
c_return_sap: doc_number,
|
c_return_sap: doc_number,
|
||||||
c_return_year_sap: year
|
c_return_year_sap: year,
|
||||||
}, ['c_cash_in_no','c_return_sap'])
|
},
|
||||||
|
['c_cash_in_no', 'c_return_sap']
|
||||||
|
)
|
||||||
.where({
|
.where({
|
||||||
c_cash_in_no: code
|
c_cash_in_no: code,
|
||||||
});
|
});
|
||||||
|
|
||||||
// update load balance
|
// update load balance
|
||||||
reserveBalance = await trx('trx.t_d_reservation_balance').update({
|
reserveBalance = await trx('trx.t_d_reservation_balance')
|
||||||
|
.update(
|
||||||
|
{
|
||||||
c_return_cash_in_sap: resSAP.data.E_DOCUMENTNUMBER,
|
c_return_cash_in_sap: resSAP.data.E_DOCUMENTNUMBER,
|
||||||
c_cash_in_no: code
|
c_cash_in_no: code,
|
||||||
}, ['c_cash_in_no', 'c_return_sap'])
|
},
|
||||||
.whereRaw(`c_reservation_no IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail tdcid LEFT JOIN payment.t_d_cash_in tdci ON tdcid.i_cash_in = tdci.i_cash_in WHERE tdci.c_cash_in_no = '${code}')`)
|
['c_cash_in_no', 'c_return_sap']
|
||||||
|
)
|
||||||
|
.whereRaw(
|
||||||
|
`c_reservation_no IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail tdcid LEFT JOIN payment.t_d_cash_in tdci ON tdcid.i_cash_in = tdci.i_cash_in WHERE tdci.c_cash_in_no = '${code}')`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update posting et
|
// update posting et
|
||||||
const posting_et = await trx('public.posting_et').update({
|
const posting_et = await trx('public.posting_et')
|
||||||
|
.update(
|
||||||
|
{
|
||||||
pos_status: resSAP.type == 'S' ? 0 : 4,
|
pos_status: resSAP.type == 'S' ? 0 : 4,
|
||||||
status0: resSAP.type,
|
status0: resSAP.type,
|
||||||
no_doksap : resSAP.data.E_DOCUMENTNUMBER ? resSAP.data.E_DOCUMENTNUMBER : null,
|
no_doksap: resSAP.data.E_DOCUMENTNUMBER
|
||||||
status1 : resSAP.message ? resSAP.message : null
|
? resSAP.data.E_DOCUMENTNUMBER
|
||||||
}, ['file_name','status0']).where({
|
: null,
|
||||||
no_dok: code
|
status1: resSAP.message ? resSAP.message : null,
|
||||||
})
|
},
|
||||||
|
['file_name', 'status0']
|
||||||
|
)
|
||||||
|
.where({
|
||||||
|
no_dok: code,
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cash_in: t_cash_in[0],
|
cash_in: t_cash_in[0],
|
||||||
reserveBalance: reserveBalance[0],
|
reserveBalance: reserveBalance[0],
|
||||||
posting_et : posting_et[0]
|
posting_et: posting_et[0],
|
||||||
}
|
};
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const getRecon = async (trx) => {
|
const getRecon = async (trx) => {
|
||||||
|
|
||||||
let sql = `SELECT
|
let sql = `SELECT
|
||||||
tdi.c_invoice_no,
|
tdi.c_invoice_no,
|
||||||
'FB70' AS tcode,
|
'FB70' AS tcode,
|
||||||
@@ -200,141 +257,162 @@ const getRecon = async (trx) => {
|
|||||||
SELECT c_reservation_no FROM payment.t_d_payment_recon tdpr WHERE tdpr.c_status = 'S'
|
SELECT c_reservation_no FROM payment.t_d_payment_recon tdpr WHERE tdpr.c_status = 'S'
|
||||||
)
|
)
|
||||||
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, tdpr.d_payment, b_past_month
|
GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, tdpr.d_payment, b_past_month
|
||||||
ORDER BY tdpr.d_payment`
|
ORDER BY tdpr.d_payment`;
|
||||||
let result = await trx.raw(sql)
|
let result = await trx.raw(sql);
|
||||||
|
|
||||||
return result.rows
|
return result.rows;
|
||||||
}
|
};
|
||||||
|
|
||||||
const getReserve = async (trx, code, date, invoice) => {
|
const getReserve = async (trx, code, date, invoice) => {
|
||||||
|
const res = await trx
|
||||||
const res = await trx.select([
|
.select([
|
||||||
"tdrb.c_reservation_no",
|
'tdrb.c_reservation_no',
|
||||||
"tdrb.i_reservation_amount",
|
'tdrb.i_reservation_amount',
|
||||||
"tdpr.c_payment_recon_no",
|
'tdpr.c_payment_recon_no',
|
||||||
"tdpr.d_payment",
|
'tdpr.d_payment',
|
||||||
"tdpr.d_payment_recon",
|
'tdpr.d_payment_recon',
|
||||||
"tdrb.c_partner_code",
|
'tdrb.c_partner_code',
|
||||||
"tdrb.c_partner_name",
|
'tdrb.c_partner_name',
|
||||||
"tdrb.c_load_balance_no",
|
'tdrb.c_load_balance_no',
|
||||||
"tdi.c_invoice_no"
|
'tdi.c_invoice_no',
|
||||||
])
|
])
|
||||||
.from("trx.t_d_reservation_balance AS tdrb")
|
.from('trx.t_d_reservation_balance AS tdrb')
|
||||||
.leftJoin('trx.t_d_load_balance as tdlb', function () {
|
.leftJoin('trx.t_d_load_balance as tdlb', function () {
|
||||||
this.on('tdrb.c_load_balance_no', '=', 'tdlb.c_load_balance_no')
|
this.on('tdrb.c_load_balance_no', '=', 'tdlb.c_load_balance_no');
|
||||||
})
|
})
|
||||||
.leftJoin('payment.t_d_invoice as tdi', function () {
|
.leftJoin('payment.t_d_invoice as tdi', function () {
|
||||||
this.on('tdi.c_invoice_no', '=', 'tdlb.c_invoice_no')
|
this.on('tdi.c_invoice_no', '=', 'tdlb.c_invoice_no').orOn(
|
||||||
.orOn('tdi.c_invoice_no', '=', 'tdrb.c_invoice_no')
|
'tdi.c_invoice_no',
|
||||||
|
'=',
|
||||||
|
'tdrb.c_invoice_no'
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.leftJoin('payment.t_d_payment_recon as tdpr', function () {
|
.leftJoin('payment.t_d_payment_recon as tdpr', function () {
|
||||||
this.on('tdpr.c_reservation_no', '=', 'tdrb.c_reservation_no')
|
this.on('tdpr.c_reservation_no', '=', 'tdrb.c_reservation_no');
|
||||||
})
|
})
|
||||||
.where("tdrb.c_status", "=", "A")
|
.where('tdrb.c_status', '=', 'A')
|
||||||
.where("tdi.c_status", "!=", "X")
|
.where('tdi.c_status', '!=', 'X')
|
||||||
.where("tdrb.c_partner_code", "=", code)
|
.where('tdrb.c_partner_code', '=', code)
|
||||||
.where("tdpr.d_payment", "=", date)
|
.where('tdpr.d_payment', '=', date)
|
||||||
.where("tdi.c_invoice_no", "=", invoice)
|
.where('tdi.c_invoice_no', '=', invoice)
|
||||||
.where("tdpr.c_status", "=", "S")
|
.where('tdpr.c_status', '=', 'S')
|
||||||
.whereNotNull("tdi.c_return_sap")
|
.whereNotNull('tdi.c_return_sap')
|
||||||
.whereNotNull("tdrb.c_load_balance_no")
|
.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)`)
|
.whereRaw(
|
||||||
return res
|
`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)`
|
||||||
}
|
);
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
const getPartnerRecon = async (trx) => {
|
const getPartnerRecon = async (trx) => {
|
||||||
|
const res = await trx
|
||||||
const res = await trx.select([
|
.select([
|
||||||
"tdpr.c_partner_code",
|
'tdpr.c_partner_code',
|
||||||
"tdrb.c_partner_name",
|
'tdrb.c_partner_name',
|
||||||
"tdi.c_invoice_no",
|
'tdi.c_invoice_no',
|
||||||
"tdi.d_invoice_date",
|
'tdi.d_invoice_date',
|
||||||
trx.raw("to_char(tdpr.d_payment, 'YYYY-MM-DD') AS d_payment"),
|
trx.raw("to_char(tdpr.d_payment, 'YYYY-MM-DD') AS d_payment"),
|
||||||
trx.raw("SUM(tdrb.i_reservation_amount) AS amount"),
|
trx.raw('SUM(tdrb.i_reservation_amount) AS amount'),
|
||||||
"tmp.c_account_topup",
|
'tmp.c_account_topup',
|
||||||
"tmp.c_account_code_topup",
|
'tmp.c_account_code_topup',
|
||||||
"i_company",
|
'i_company',
|
||||||
"i_holding",
|
'i_holding',
|
||||||
trx.raw(`CASE
|
trx.raw(`CASE
|
||||||
WHEN to_char(tdpr.d_payment, 'MM') = to_char(tdi.d_invoice_date, 'MM')
|
WHEN to_char(tdpr.d_payment, 'MM') >= to_char(tdi.d_invoice_date, 'MM')
|
||||||
THEN 'IP'
|
THEN 'IP'
|
||||||
ELSE
|
ELSE
|
||||||
'OP'
|
'OP'
|
||||||
END c_in_period`),
|
END c_in_period`),
|
||||||
])
|
])
|
||||||
.from("trx.t_d_reservation_balance AS tdrb")
|
.from('trx.t_d_reservation_balance AS tdrb')
|
||||||
.leftJoin('trx.t_d_load_balance as tdlb', function () {
|
.leftJoin('trx.t_d_load_balance as tdlb', function () {
|
||||||
this.on('tdrb.c_load_balance_no', '=', 'tdlb.c_load_balance_no')
|
this.on('tdrb.c_load_balance_no', '=', 'tdlb.c_load_balance_no');
|
||||||
})
|
})
|
||||||
.leftJoin('payment.t_d_invoice as tdi', function () {
|
.leftJoin('payment.t_d_invoice as tdi', function () {
|
||||||
this
|
this.on('tdi.c_invoice_no', '=', 'tdlb.c_invoice_no').orOn(
|
||||||
.on('tdi.c_invoice_no', '=', 'tdlb.c_invoice_no')
|
'tdi.c_invoice_no',
|
||||||
.orOn('tdi.c_invoice_no', '=', 'tdrb.c_invoice_no')
|
'=',
|
||||||
|
'tdrb.c_invoice_no'
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.leftJoin('payment.t_d_payment_recon as tdpr', function () {
|
.leftJoin('payment.t_d_payment_recon as tdpr', function () {
|
||||||
this.on('tdpr.c_reservation_no', '=', 'tdrb.c_reservation_no')
|
this.on('tdpr.c_reservation_no', '=', 'tdrb.c_reservation_no');
|
||||||
})
|
})
|
||||||
.leftJoin('public.t_m_partner as tmp', function () {
|
.leftJoin('public.t_m_partner as tmp', function () {
|
||||||
this.on('tmp.i_partner', '=', 'tdrb.i_partner')
|
this.on('tmp.i_partner', '=', 'tdrb.i_partner');
|
||||||
})
|
})
|
||||||
|
|
||||||
.where("tdrb.c_status", "=", "A")
|
.where('tdrb.c_status', '=', 'A')
|
||||||
.where("tdi.c_status", "!=", "X")
|
.where('tdi.c_status', '!=', 'X')
|
||||||
.where("tdpr.c_status", "=", "S")
|
.where('tdpr.c_status', '=', 'S')
|
||||||
.whereNotNull("tdi.c_return_sap")
|
.whereNotNull('tdi.c_return_sap')
|
||||||
.whereNotNull("tdrb.c_load_balance_no")
|
.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)`)
|
.whereRaw(
|
||||||
.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"])
|
`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',
|
||||||
|
]);
|
||||||
// .toSql()
|
// .toSql()
|
||||||
|
|
||||||
return res
|
return res;
|
||||||
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const generateCode = async (trx, c_partner_code, d_payment_recon) => {
|
const generateCode = async (trx, c_partner_code, d_payment_recon) => {
|
||||||
let code = ""
|
let code = '';
|
||||||
let prefix = `CIN${c_partner_code}${d_payment_recon}`
|
let prefix = `CIN${c_partner_code}${d_payment_recon}`;
|
||||||
|
|
||||||
let result =await trx.select([trx.raw(`substring(c_cash_in_no, 13, 3) AS code`)])
|
let result = await trx
|
||||||
.from("payment.t_d_cash_in")
|
.select([trx.raw(`substring(c_cash_in_no, 13, 3) AS code`)])
|
||||||
|
.from('payment.t_d_cash_in')
|
||||||
.whereRaw(`substring(c_cash_in_no, 1, 12) = '${prefix}'`)
|
.whereRaw(`substring(c_cash_in_no, 1, 12) = '${prefix}'`)
|
||||||
// .where("d_project_date", projectDate)
|
// .where("d_project_date", projectDate)
|
||||||
.orderBy('c_cash_in_no', 'DESC')
|
.orderBy('c_cash_in_no', 'DESC')
|
||||||
.first()
|
.first();
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
let counter = parseInt(result.code)+1
|
let counter = parseInt(result.code) + 1;
|
||||||
counter = String(counter).padStart(3, '0');
|
counter = String(counter).padStart(3, '0');
|
||||||
code = `${prefix}${counter}`
|
code = `${prefix}${counter}`;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
code = `${prefix}001`
|
code = `${prefix}001`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code
|
return code;
|
||||||
}
|
};
|
||||||
|
|
||||||
const insertCashInDetail = async (trx, data) => {
|
const insertCashInDetail = async (trx, data) => {
|
||||||
let result = []
|
let result = [];
|
||||||
if (data.length > 0) {
|
if (data.length > 0) {
|
||||||
result = await trx('payment.t_d_cash_in_detail').insert(data,["*"])
|
result = await trx('payment.t_d_cash_in_detail').insert(data, ['*']);
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
const updateIntoReserve = async (trx, dataReserve, reserveNo) => {
|
const updateIntoReserve = async (trx, dataReserve, reserveNo) => {
|
||||||
let result = await trx('trx.t_d_reservation_balance').update(dataReserve, ["*"]).where({c_reservation_no: reserveNo})
|
let result = await trx('trx.t_d_reservation_balance')
|
||||||
return result
|
.update(dataReserve, ['*'])
|
||||||
}
|
.where({ c_reservation_no: reserveNo });
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
const insertCashIn = async (trx, data) => {
|
const insertCashIn = async (trx, data) => {
|
||||||
let result = await trx('payment.t_d_cash_in').insert(data,["*"])
|
let result = await trx('payment.t_d_cash_in').insert(data, ['*']);
|
||||||
return result[0]
|
return result[0];
|
||||||
}
|
};
|
||||||
|
|
||||||
const writePaynentHistory = async (data, message, i_log_name, trx) => {
|
const writePaynentHistory = async (data, message, i_log_name, trx) => {
|
||||||
console.log(data)
|
console.log(data);
|
||||||
const result = await trx('log.t_log_invoice').insert({
|
const result = await trx('log.t_log_invoice').insert(
|
||||||
|
{
|
||||||
// i_log_name : 102,
|
// i_log_name : 102,
|
||||||
i_log_name: 119,
|
i_log_name: 119,
|
||||||
d_log: trx.raw('NOW()'),
|
d_log: trx.raw('NOW()'),
|
||||||
@@ -347,13 +425,13 @@ const writePaynentHistory = async (data, message, i_log_name, trx) => {
|
|||||||
d_created: trx.raw('NOW()'),
|
d_created: trx.raw('NOW()'),
|
||||||
m_amount: data.amount,
|
m_amount: data.amount,
|
||||||
m_mdr_amount: 0,
|
m_mdr_amount: 0,
|
||||||
m_mdr_net : data.amount
|
m_mdr_net: data.amount,
|
||||||
|
},
|
||||||
|
['i_log_name', 'c_note']
|
||||||
|
);
|
||||||
|
|
||||||
}, ['i_log_name', 'c_note'])
|
return result;
|
||||||
|
};
|
||||||
return result
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
generateInvoice,
|
generateInvoice,
|
||||||
@@ -368,5 +446,5 @@ module.exports = {
|
|||||||
getReserve,
|
getReserve,
|
||||||
getPartnerRecon,
|
getPartnerRecon,
|
||||||
insertCashIn,
|
insertCashIn,
|
||||||
updateIntoReserve
|
updateIntoReserve,
|
||||||
};
|
};
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
const { default: axios } = require('axios');
|
||||||
const helper = require('../../helpers/helper');
|
const helper = require('../../helpers/helper');
|
||||||
const winston = require('../../helpers/winston.logger');
|
const winston = require('../../helpers/winston.logger');
|
||||||
const generate = require('./utils/utils');
|
const generate = require('./utils/utils');
|
||||||
@@ -33,6 +34,7 @@ const controller = async (req, res) => {
|
|||||||
let uniqueCode = await helper.getUniqueCode();
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
uniqueCode = uniqueCode + '' + counterDirect;
|
uniqueCode = uniqueCode + '' + counterDirect;
|
||||||
let result = {};
|
let result = {};
|
||||||
|
let usingHSMNumber = 1;
|
||||||
|
|
||||||
// set connection HSM server
|
// set connection HSM server
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||||
@@ -43,12 +45,14 @@ const controller = async (req, res) => {
|
|||||||
// winston.logger.error(`request to HSM server 2`);
|
// winston.logger.error(`request to HSM server 2`);
|
||||||
|
|
||||||
if (client2.clientAuthenticated == false) {
|
if (client2.clientAuthenticated == false) {
|
||||||
|
usingHSMNumber = 1;
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} ================================== REDIRECT USING HSM SERVER 1 ==================================}`
|
`${uniqueCode} ================================== REDIRECT USING HSM SERVER 1 ==================================}`
|
||||||
);
|
);
|
||||||
useClient = client;
|
useClient = client;
|
||||||
} else {
|
} else {
|
||||||
|
usingHSMNumber = 2;
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} ================================== USING HSM SERVER 2 ==================================}`
|
`${uniqueCode} ================================== USING HSM SERVER 2 ==================================}`
|
||||||
@@ -57,12 +61,14 @@ const controller = async (req, res) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (client.clientAuthenticated == false) {
|
if (client.clientAuthenticated == false) {
|
||||||
|
usingHSMNumber = 2;
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} ================================== REDIRECT USING HSM SERVER 2 ==================================}`
|
`${uniqueCode} ================================== REDIRECT USING HSM SERVER 2 ==================================}`
|
||||||
);
|
);
|
||||||
useClient = client2;
|
useClient = client2;
|
||||||
} else {
|
} else {
|
||||||
|
usingHSMNumber = 1;
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} ================================== USING HSM SERVER 1 ==================================}`
|
`${uniqueCode} ================================== USING HSM SERVER 1 ==================================}`
|
||||||
@@ -137,20 +143,34 @@ const controller = async (req, res) => {
|
|||||||
await _sleep(10);
|
await _sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (_timeOut) {
|
if (_timeOut) {
|
||||||
// result = {
|
let url = `http://${process.env.IP_HSM_SERVER_1}/feliqserver/v1/api/hsm/refresh`;
|
||||||
// code: "5001",
|
if (usingHSMNumber == 2) {
|
||||||
// message: "Timeout",
|
url = `http://${process.env.IP_HSM_SERVER_2}/feliqserver/v1/api/hsm/refresh`;
|
||||||
// data: {},
|
}
|
||||||
// };
|
|
||||||
|
|
||||||
// // log warn
|
let response = await axios({
|
||||||
// winston.logger.warn(
|
url: url,
|
||||||
// `${uniqueCode} response HSM - auth1v2: ${JSON.stringify(result)}`
|
method: 'get',
|
||||||
// );
|
});
|
||||||
|
|
||||||
// return res.status(200).send(result);
|
result = {
|
||||||
// }
|
code: '5001',
|
||||||
|
message: 'Timeout',
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE LOADING-BALANCE TOPUP-1 ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)} and refresh HSM ${usingHSMNumber} response status: ${
|
||||||
|
response.status
|
||||||
|
} | response text: ${response.statusText}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).send(result);
|
||||||
|
}
|
||||||
|
|
||||||
_stopMessage = 0;
|
_stopMessage = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1474,18 +1474,18 @@ const loadingBalanceInsert = async (req, param) => {
|
|||||||
loadBalanceNoSequence
|
loadBalanceNoSequence
|
||||||
);
|
);
|
||||||
|
|
||||||
if (loadBalanceNumber != 'XX') {
|
// if (loadBalanceNumber != 'XX') {
|
||||||
// set sequence to redis
|
// set sequence to redis
|
||||||
// await setLoadBalanceNumberSequence(
|
// await setLoadBalanceNumberSequence(
|
||||||
// req.partner_id_token,
|
// req.partner_id_token,
|
||||||
// loadBalanceNoSequence
|
// loadBalanceNoSequence
|
||||||
// );
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
// winston.logger.warn(
|
winston.logger.debug(
|
||||||
// `${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: load balance number is ${loadBalanceNumber}.`
|
`${uniqueCode} [ PROCESSING LOADING-BALANCE-INSERT ]: load balance number sequence is ${loadBalanceNoSequence}.`
|
||||||
// );
|
);
|
||||||
|
|
||||||
if (maxLoop > maxLoopParameter) {
|
if (maxLoop > maxLoopParameter) {
|
||||||
// create log
|
// create log
|
||||||
|
|||||||
@@ -111,7 +111,11 @@ const checkReservation = async (req, res) => {
|
|||||||
let { mid, tid, card_number } = req.body;
|
let { mid, tid, card_number } = req.body;
|
||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
// winston.logger.info(
|
||||||
|
// `${uniqueCode} [ REQUEST RESERVATION-CHECK ]: ${JSON.stringify(req.body)}`
|
||||||
|
// );
|
||||||
|
|
||||||
|
console.log(
|
||||||
`${uniqueCode} [ REQUEST RESERVATION-CHECK ]: ${JSON.stringify(req.body)}`
|
`${uniqueCode} [ REQUEST RESERVATION-CHECK ]: ${JSON.stringify(req.body)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -125,11 +129,11 @@ const checkReservation = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
// `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
||||||
result
|
// result
|
||||||
)}`
|
// )}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
@@ -153,11 +157,11 @@ const checkReservation = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
// `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
||||||
result
|
// result
|
||||||
)}`
|
// )}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
@@ -171,11 +175,11 @@ const checkReservation = async (req, res) => {
|
|||||||
data: {},
|
data: {},
|
||||||
};
|
};
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
// `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
||||||
result
|
// result
|
||||||
)}`
|
// )}`
|
||||||
);
|
// );
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,11 +200,11 @@ const checkReservation = async (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
// `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(
|
||||||
result
|
// result
|
||||||
)}`
|
// )}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
@@ -236,7 +240,11 @@ const checkReservation = async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
// winston.logger.info(
|
||||||
|
// `${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(result)}`
|
||||||
|
// );
|
||||||
|
|
||||||
|
console.log(
|
||||||
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(result)}`
|
`${uniqueCode} [ RESPONSE RESERVATION-CHECK ]: ${JSON.stringify(result)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -617,6 +625,11 @@ const reservationValidate = async (req, res) => {
|
|||||||
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
||||||
|
|
||||||
if (getIssuer) {
|
if (getIssuer) {
|
||||||
|
// per tanggal 1 November 2023 fee sharing mulai menggunakan amount nominal dan bukan persentase lagi
|
||||||
|
if (today >= '2023-11-01') {
|
||||||
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
|
channelFee = getIssuer.i_channel_fee_nominal;
|
||||||
|
} else {
|
||||||
// ======================= KHUSUS LRT JABODEBEK =============================
|
// ======================= KHUSUS LRT JABODEBEK =============================
|
||||||
if (getPartner.partner_code == 'P05') {
|
if (getPartner.partner_code == 'P05') {
|
||||||
issuerFee = getIssuer.i_issuer_fee_nominal;
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
@@ -629,6 +642,7 @@ const reservationValidate = async (req, res) => {
|
|||||||
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// if (!getIssuer) {
|
// if (!getIssuer) {
|
||||||
// return res.status(200).json({
|
// return res.status(200).json({
|
||||||
// code: "403",
|
// code: "403",
|
||||||
@@ -1046,6 +1060,11 @@ const reservationValidateV2 = async (req, res) => {
|
|||||||
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
||||||
|
|
||||||
if (getIssuer) {
|
if (getIssuer) {
|
||||||
|
// per tanggal 1 November 2023 fee sharing mulai menggunakan amount nominal dan bukan persentase lagi
|
||||||
|
if (today >= '2023-11-01') {
|
||||||
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
|
channelFee = getIssuer.i_channel_fee_nominal;
|
||||||
|
} else {
|
||||||
// ======================= KHUSUS LRT JABODEBEK =============================
|
// ======================= KHUSUS LRT JABODEBEK =============================
|
||||||
if (getPartner.partner_code == 'P05') {
|
if (getPartner.partner_code == 'P05') {
|
||||||
issuerFee = getIssuer.i_issuer_fee_nominal;
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
@@ -1058,6 +1077,7 @@ const reservationValidateV2 = async (req, res) => {
|
|||||||
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (!getIssuer) {
|
// if (!getIssuer) {
|
||||||
// return res.status(200).json({
|
// return res.status(200).json({
|
||||||
@@ -1497,6 +1517,11 @@ const reservation = async (req, res) => {
|
|||||||
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
||||||
|
|
||||||
if (getIssuer) {
|
if (getIssuer) {
|
||||||
|
// per tanggal 1 November 2023 fee sharing mulai menggunakan amount nominal dan bukan persentase lagi
|
||||||
|
if (today >= '2023-11-01') {
|
||||||
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
|
channelFee = getIssuer.i_channel_fee_nominal;
|
||||||
|
} else {
|
||||||
// ======================= KHUSUS LRT JABODEBEK =============================
|
// ======================= KHUSUS LRT JABODEBEK =============================
|
||||||
if (getPartner.partner_code == 'P05') {
|
if (getPartner.partner_code == 'P05') {
|
||||||
issuerFee = getIssuer.i_issuer_fee_nominal;
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
@@ -1509,6 +1534,7 @@ const reservation = async (req, res) => {
|
|||||||
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (!getIssuer) {
|
// if (!getIssuer) {
|
||||||
// return res.status(200).json({
|
// return res.status(200).json({
|
||||||
@@ -2298,6 +2324,11 @@ const reservationV2 = async (req, res) => {
|
|||||||
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
let getIssuer = await model.getIssuer(getPartner.i_partner, now);
|
||||||
|
|
||||||
if (getIssuer) {
|
if (getIssuer) {
|
||||||
|
// per tanggal 1 November 2023 fee sharing mulai menggunakan amount nominal dan bukan persentase lagi
|
||||||
|
if (today >= '2023-11-01') {
|
||||||
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
|
channelFee = getIssuer.i_channel_fee_nominal;
|
||||||
|
} else {
|
||||||
// ======================= KHUSUS LRT JABODEBEK =============================
|
// ======================= KHUSUS LRT JABODEBEK =============================
|
||||||
if (getPartner.partner_code == 'P05') {
|
if (getPartner.partner_code == 'P05') {
|
||||||
issuerFee = getIssuer.i_issuer_fee_nominal;
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
@@ -2310,6 +2341,7 @@ const reservationV2 = async (req, res) => {
|
|||||||
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (!getIssuer) {
|
// if (!getIssuer) {
|
||||||
// return res.status(200).json({
|
// return res.status(200).json({
|
||||||
@@ -4218,6 +4250,8 @@ const getFeeSharing = async (req, res) => {
|
|||||||
// datetime
|
// datetime
|
||||||
if (!datetime) {
|
if (!datetime) {
|
||||||
datetime = moment().format('YYYY-MM-DD');
|
datetime = moment().format('YYYY-MM-DD');
|
||||||
|
} else {
|
||||||
|
datetime = moment(datetime).format('YYYY-MM-DD');
|
||||||
}
|
}
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
@@ -4253,6 +4287,11 @@ const getFeeSharing = async (req, res) => {
|
|||||||
let getIssuer = await model.getIssuer(getPartner.i_partner, datetime);
|
let getIssuer = await model.getIssuer(getPartner.i_partner, datetime);
|
||||||
|
|
||||||
if (getIssuer) {
|
if (getIssuer) {
|
||||||
|
// per tanggal 1 November 2023 fee sharing mulai menggunakan amount nominal dan bukan persentase lagi
|
||||||
|
if (datetime >= '2023-11-01') {
|
||||||
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
|
channelFee = getIssuer.i_channel_fee_nominal;
|
||||||
|
} else {
|
||||||
// ======================= KHUSUS LRT JABODEBEK =============================
|
// ======================= KHUSUS LRT JABODEBEK =============================
|
||||||
if (getPartner.partner_code == 'P05') {
|
if (getPartner.partner_code == 'P05') {
|
||||||
issuerFee = getIssuer.i_issuer_fee_nominal;
|
issuerFee = getIssuer.i_issuer_fee_nominal;
|
||||||
@@ -4265,6 +4304,7 @@ const getFeeSharing = async (req, res) => {
|
|||||||
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
(getIssuer.i_channel_fee_perc / 100) * parseInt(getIssuer.i_amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
code: '00',
|
code: '00',
|
||||||
|
|||||||
@@ -1,8 +1,22 @@
|
|||||||
# ================================= ENVIRONMENT =================================
|
# ================================= ENVIRONMENT =================================
|
||||||
#NODE_ENV=production
|
#NODE_ENV=production
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
CUSTOM_MODE_NODE_ENV=devprod
|
||||||
#NODE_ENV=testing
|
#NODE_ENV=testing
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
VERSION=v1.4.6
|
||||||
|
|
||||||
|
# ===================== CLUSTER NODE (YES or NO) ===========================
|
||||||
|
CLUSTER_NODE=NO
|
||||||
|
|
||||||
|
# ===================== CLUSTER WITH RUNNING ON MULTIPLE PORT (YES or NO) ===========================
|
||||||
|
RUNNING_ON_MULTIPLE_PORT=NO
|
||||||
|
|
||||||
|
# PISAHKAN DENGAN MENGGUNAKAN SEPARATOR KOMA TANPA SPASI
|
||||||
|
PORTS=3001,3002,3003,3004
|
||||||
|
|
||||||
|
# ===================== CLUSTER NODE STICKY SESSION(YES or NO) ===========================
|
||||||
|
CLUSTER_NODE_STICKY_SESSION=YES
|
||||||
|
|
||||||
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
# =========================== KONFIGURASI UNTUK SERVER ===========================
|
||||||
# SERVER_FOR=development
|
# SERVER_FOR=development
|
||||||
@@ -29,9 +43,9 @@ DB_USER_POOLING=postgres
|
|||||||
DB_PASSWORD_POOLING=inhc0mmute_cms
|
DB_PASSWORD_POOLING=inhc0mmute_cms
|
||||||
|
|
||||||
# ==================================== LOKI =====================================
|
# ==================================== LOKI =====================================
|
||||||
LOKI_URL=http://10.20.14.30:3100
|
LOKI_URL=http://localhost:3100
|
||||||
|
|
||||||
# ==================================== APP PROMETHEUS =====================================
|
# =============================== APP PROMETHEUS =================================
|
||||||
PROM_APP = topuponline
|
PROM_APP = topuponline
|
||||||
|
|
||||||
# ================================== SECRET KEY ==================================
|
# ================================== SECRET KEY ==================================
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ const totalCPUs = require('node:os').cpus().length;
|
|||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const winston = require('./application/helpers/winston.logger');
|
const winston = require('./application/helpers/winston.logger');
|
||||||
const app = require('./server');
|
const app = require('./server');
|
||||||
// const sticky = require('sticky-session');
|
const sticky = require('sticky-session');
|
||||||
|
|
||||||
// set port, listen for requests
|
|
||||||
const PORT = process.env.PORT || 3000;
|
|
||||||
var serverHSMStatus = 'HSM SERVER NOT CONNECTED';
|
var serverHSMStatus = 'HSM SERVER NOT CONNECTED';
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||||
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_1}`;
|
serverHSMStatus = `SERVER 1 CONNECTED on ip ${process.env.IP_HSM_SERVER_1}`;
|
||||||
@@ -32,7 +30,7 @@ if (process.env.CHANGE_TO_DRC == 'YES' || process.env.CHANGE_TO_DRC == 'yes') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// jika mau di cluster gunakan script berikut:
|
// jika mau di cluster gunakan script berikut:
|
||||||
|
if (process.env.CLUSTER_NODE.toUpperCase() == 'YES') {
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
console.log(`Number of CPUs is ${totalCPUs}`);
|
console.log(`Number of CPUs is ${totalCPUs}`);
|
||||||
console.log(`Master ${process.pid} is running`);
|
console.log(`Master ${process.pid} is running`);
|
||||||
@@ -48,34 +46,93 @@ if (cluster.isMaster) {
|
|||||||
console.log('with code: ' + code);
|
console.log('with code: ' + code);
|
||||||
cluster.fork();
|
cluster.fork();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// console.log(`worker pid=${process.pid}`);
|
||||||
} else {
|
} else {
|
||||||
startExpress();
|
startExpress();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
// console.log(`worker pid=${process.pid}`);
|
|
||||||
|
|
||||||
// jika tidak mau di cluster langsung call function startExpress
|
// jika tidak mau di cluster langsung call function startExpress
|
||||||
// startExpress();
|
startExpress();
|
||||||
|
}
|
||||||
|
|
||||||
function startExpress() {
|
function startExpress() {
|
||||||
app.listen(PORT, () => {
|
// set port, listen for requests
|
||||||
|
const PORT = process.env.PORT || 3000;
|
||||||
|
|
||||||
|
// jika settingan running on multiple
|
||||||
|
if (
|
||||||
|
process.env.RUNNING_ON_MULTIPLE_PORT.toUpperCase() == 'YES' &&
|
||||||
|
process.env.CLUSTER_NODE.toUpperCase() == 'NO'
|
||||||
|
) {
|
||||||
|
const PORTS = process.env.PORTS;
|
||||||
|
|
||||||
|
if (!PORTS) {
|
||||||
|
winston.logger.warn(
|
||||||
|
`Running on multiple port is active but the ports not yet set in .env`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
let ports = PORTS.split(',');
|
||||||
|
|
||||||
|
for (let index = 0; index < ports.length; index++) {
|
||||||
|
const port = ports[index];
|
||||||
|
|
||||||
|
app.listen(port, () => {
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`Server is running on version ${
|
`Server is running on version ${
|
||||||
process.env.VERSION
|
process.env.VERSION
|
||||||
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${port} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (
|
||||||
|
process.env.RUNNING_ON_MULTIPLE_PORT.toUpperCase() == 'YES' &&
|
||||||
|
process.env.CLUSTER_NODE.toUpperCase() == 'YES'
|
||||||
|
) {
|
||||||
|
winston.logger.warn(
|
||||||
|
`If you want running the service on multiple port, please set CLUSTER_NODE = NO in .env file `
|
||||||
|
);
|
||||||
|
} else if (
|
||||||
|
process.env.CLUSTER_NODE_STICKY_SESSION.toUpperCase() == 'YES' &&
|
||||||
|
process.env.CLUSTER_NODE.toUpperCase() == 'YES'
|
||||||
|
) {
|
||||||
|
winston.logger.warn(
|
||||||
|
`If you want running the service with sticky session, please set CLUSTER_NODE = NO in .env file `
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// const server = app.listen(PORT, () => {
|
let message = `Server is running on version ${
|
||||||
// console.log(
|
process.env.VERSION
|
||||||
// `Worker ${process.pid} started. Listening on port ${
|
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||||
// server.address().port
|
|
||||||
// }`
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // Use sticky-session with the server instance
|
if (process.env.CLUSTER_NODE.toUpperCase() == 'YES') {
|
||||||
// sticky.listen(server);
|
message = `Server is running with cluster node on version ${
|
||||||
|
process.env.VERSION
|
||||||
|
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||||
|
} else if (process.env.CLUSTER_NODE_STICKY_SESSION.toUpperCase() == 'YES') {
|
||||||
|
message = `Server is running with sticky session on version ${
|
||||||
|
process.env.VERSION
|
||||||
|
} environment: ${process.env.NODE_ENV.toUpperCase()} port: ${PORT} on ${serverActive}. HSM STATUS : ${serverHSMStatus} `;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.CLUSTER_NODE_STICKY_SESSION.toUpperCase() == 'YES') {
|
||||||
|
const server = app.listen(PORT, () => {
|
||||||
|
console.log(
|
||||||
|
`Worker ${process.pid} started. Listening on port ${
|
||||||
|
server.address().port
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
winston.logger.info(message);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Use sticky-session with the server instance
|
||||||
|
sticky.listen(server);
|
||||||
|
} else {
|
||||||
|
app.listen(PORT, () => {
|
||||||
|
winston.logger.info(message);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use sticky-session to handle sticky sessions
|
// Use sticky-session to handle sticky sessions
|
||||||
|
|||||||
Reference in New Issue
Block a user