mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 17:26:28 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9e876fee67 | |||
| 3e5d29e8d5 | |||
| c8682214e4 | |||
| 388e2fc22c | |||
| 43d839ddbf | |||
| 503ecdfd6e | |||
| 79d4269b70 | |||
| 603a74a5b7 | |||
| c9a08d6832 | |||
| 308fef3ecd | |||
| 31d007dd67 | |||
| 6fe3ecc89f | |||
| b6b043b0a2 | |||
| bbdb4c2963 | |||
| 33f3b64d17 | |||
| e3673f738c | |||
| f7d7d0efce |
@@ -172,104 +172,131 @@ const _generateCashIn = async (uniqueCode) => {
|
||||
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}`
|
||||
);
|
||||
try {
|
||||
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
|
||||
);
|
||||
|
||||
//TOTAL AMOUNT CASH-IN
|
||||
let cashInAmount = 0;
|
||||
for (const itemCI of reserv) {
|
||||
cashInAmount += parseInt(itemCI.i_reservation_amount);
|
||||
}
|
||||
dataCahsIn.i_amount = cashInAmount;
|
||||
|
||||
//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
|
||||
);
|
||||
|
||||
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 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,
|
||||
// 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
|
||||
);
|
||||
|
||||
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,
|
||||
};
|
||||
//TOTAL AMOUNT CASH-IN
|
||||
let cashInAmount = 0;
|
||||
for (const itemCI of reserv) {
|
||||
cashInAmount += parseInt(itemCI.i_reservation_amount);
|
||||
}
|
||||
dataCahsIn.i_amount = cashInAmount;
|
||||
|
||||
await model.updateIntoReserve(trx, dataReserve, reserveNo);
|
||||
await model.insertCashInDetail(trx, temp);
|
||||
if(cashInAmount > 0) {
|
||||
//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
|
||||
);
|
||||
|
||||
let m_amount = 0;
|
||||
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 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,
|
||||
};
|
||||
m_amount += parseInt(detail.i_reservation_amount);
|
||||
|
||||
if(m_amount <= detail.invoice_amount) {
|
||||
await model.updateIntoReserve(trx, dataReserve, reserveNo);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} CASH-IN UPDATE RESERVE BALANCE ${reserveNo} DATA : ${JSON.stringify(
|
||||
dataReserve
|
||||
)}`
|
||||
);
|
||||
await model.insertCashInDetail(trx, temp);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN DETAIL, ID CASH-IN ${cashIn.i_cash_in} : ${JSON.stringify(
|
||||
temp
|
||||
)}`
|
||||
);
|
||||
} else {
|
||||
await trx.rollback();
|
||||
winston.logger.info(
|
||||
`${uniqueCode} ROLLBACK CASH-IN: AMOUNT CASH-IN > TOTAL INVOICE. AMOUNT ${m_amount} > INVOICE AMOUNT (${detail.invoice_amount}) : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
await wait(10000);
|
||||
winston.logger.info(
|
||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN TO RESERVE ${code} DATA : ${JSON.stringify(
|
||||
dataCahsIn
|
||||
)}`
|
||||
);
|
||||
}
|
||||
await trx.commit();
|
||||
|
||||
} catch (error) {
|
||||
sts = "error";
|
||||
await trx.rollback();
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
@@ -275,6 +275,7 @@ const getReserve = async (trx, code, date, invoice) => {
|
||||
'tdrb.c_partner_name',
|
||||
'tdrb.c_load_balance_no',
|
||||
'tdi.c_invoice_no',
|
||||
'tdi.m_amount as invoice_amount'
|
||||
])
|
||||
.from('trx.t_d_reservation_balance AS tdrb')
|
||||
.leftJoin('trx.t_d_load_balance as tdlb', function () {
|
||||
|
||||
@@ -456,6 +456,18 @@ const loadingBalanceRequest = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let cardBlacklist = await model.getCardBlacklist(card_number);
|
||||
if (cardBlacklist) {
|
||||
if(cardBlacklist.c_status == 'B') {
|
||||
result = {
|
||||
code: '445',
|
||||
message: 'Card is Blacklisted',
|
||||
data: {},
|
||||
};
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
// log debug
|
||||
// winston.logger.debug(
|
||||
// `${uniqueCode} [ PROCESSING LOADING-BALANCE-REQUEST ]: checking production card number or not...`
|
||||
|
||||
@@ -56,6 +56,15 @@ const getIssuer = (id) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET IS CARD ADDED TO BLACKLIST
|
||||
const getCardBlacklist = (card_number) => {
|
||||
let result = knex('public.t_m_card_blacklist')
|
||||
.select('c_status')
|
||||
.where('c_card_number', card_number)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET CHECKING CARD PRODUCT FROM GLOBAL PARAMETER
|
||||
const getCheckByCardProductStatusValue = () => {
|
||||
let result = knex('t_m_global_parameter')
|
||||
@@ -1077,6 +1086,7 @@ module.exports = {
|
||||
checkCardNumber,
|
||||
getPartner,
|
||||
getIssuer,
|
||||
getCardBlacklist,
|
||||
getCheckByCardProductStatusValue,
|
||||
getReservationPending,
|
||||
getReservationPendingWithFlagCounter,
|
||||
|
||||
@@ -136,6 +136,58 @@ const paymentRecon = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
console.log(getPartner);
|
||||
|
||||
// check payment recon status is enable
|
||||
if (getPartner.b_payment_recon != true) {
|
||||
result = {
|
||||
code: '444',
|
||||
message: 'Partner unable to receive payment reconciliations',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE PAYMENT-RECON ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// check partner reservation number yang di request sama dengan partner yang di token
|
||||
let checkReservation = await model.checkReservation(reservation_number);
|
||||
|
||||
if (!checkReservation) {
|
||||
result = {
|
||||
code: '400',
|
||||
message: 'Reservation number does not exist.',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE PAYMENT-RECON ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
if (checkReservation.i_partner != partner_id) {
|
||||
result = {
|
||||
code: '443',
|
||||
message:
|
||||
'Partner for payment reconciliation and transaction does not match',
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} [ RESPONSE PAYMENT-RECON ]: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// check reservation number yang di request sudah berhasil di recon atau belum sebelumnnya
|
||||
let checkReservationNumberAndAmountAlreadyRecon =
|
||||
await model.checkReservationNumberAndAmountAlreadyRecon(
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
const knex = require("../../../infrastructure/database/knex");
|
||||
const knex = require('../../../infrastructure/database/knex');
|
||||
|
||||
// GET PARTNER, MERCHANT, TERMINAL FROM TID
|
||||
const getPartner = (mid, tid) => {
|
||||
let result = knex
|
||||
.select(
|
||||
"t_m_partner.i_partner",
|
||||
"t_m_partner.c_code as partner_code",
|
||||
"t_m_partner.c_name as partner_name",
|
||||
"t_m_merchant.i_merchant",
|
||||
"t_m_merchant.c_code as merchant_code",
|
||||
"t_m_merchant.c_name as merchant_name",
|
||||
"t_m_merchant.e_mid as mid",
|
||||
"t_m_terminal.i_terminal",
|
||||
"t_m_terminal.c_code as terminal_code",
|
||||
"t_m_terminal.c_name as terminal_name",
|
||||
"t_m_terminal.e_tid as tid"
|
||||
't_m_partner.i_partner',
|
||||
't_m_partner.c_code as partner_code',
|
||||
't_m_partner.c_name as partner_name',
|
||||
't_m_partner.b_payment_recon',
|
||||
't_m_merchant.i_merchant',
|
||||
't_m_merchant.c_code as merchant_code',
|
||||
't_m_merchant.c_name as merchant_name',
|
||||
't_m_merchant.e_mid as mid',
|
||||
't_m_terminal.i_terminal',
|
||||
't_m_terminal.c_code as terminal_code',
|
||||
't_m_terminal.c_name as terminal_name',
|
||||
't_m_terminal.e_tid as tid'
|
||||
)
|
||||
.from("t_m_terminal")
|
||||
.from('t_m_terminal')
|
||||
.leftJoin(
|
||||
"t_m_merchant",
|
||||
"t_m_terminal.i_merchant",
|
||||
"t_m_merchant.i_merchant"
|
||||
't_m_merchant',
|
||||
't_m_terminal.i_merchant',
|
||||
't_m_merchant.i_merchant'
|
||||
)
|
||||
.leftJoin("t_m_partner", "t_m_merchant.i_partner", "t_m_partner.i_partner")
|
||||
.where("t_m_merchant.e_mid", mid)
|
||||
.where("t_m_terminal.e_tid", tid)
|
||||
.where("t_m_terminal.c_status", "A")
|
||||
.where("t_m_merchant.c_status", "A")
|
||||
.where("t_m_partner.c_status", "A")
|
||||
.leftJoin('t_m_partner', 't_m_merchant.i_partner', 't_m_partner.i_partner')
|
||||
.where('t_m_merchant.e_mid', mid)
|
||||
.where('t_m_terminal.e_tid', tid)
|
||||
.where('t_m_terminal.c_status', 'A')
|
||||
.where('t_m_merchant.c_status', 'A')
|
||||
.where('t_m_partner.c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
@@ -35,57 +36,66 @@ const getPartner = (mid, tid) => {
|
||||
const getPartnerByID = (partner_id) => {
|
||||
let result = knex
|
||||
.select(
|
||||
"t_m_partner.i_partner",
|
||||
"t_m_partner.c_code as partner_code",
|
||||
"t_m_partner.c_name as partner_name"
|
||||
't_m_partner.i_partner',
|
||||
't_m_partner.c_code as partner_code',
|
||||
't_m_partner.c_name as partner_name',
|
||||
't_m_partner.b_payment_recon'
|
||||
)
|
||||
.from("t_m_partner")
|
||||
.where("t_m_partner.i_partner", partner_id)
|
||||
.where("t_m_partner.c_status", "A")
|
||||
.from('t_m_partner')
|
||||
.where('t_m_partner.i_partner', partner_id)
|
||||
.where('t_m_partner.c_status', 'A')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const checkReservationNumberAndAmount = (reservationNumber) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.count("* as total_transaction")
|
||||
.sum("i_reservation_amount as total_amount")
|
||||
.groupBy("c_ref_no")
|
||||
.where("c_reservation_no", reservationNumber)
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.count('* as total_transaction')
|
||||
.sum('i_reservation_amount as total_amount')
|
||||
.groupBy('c_ref_no')
|
||||
.where('c_reservation_no', reservationNumber)
|
||||
// .where("c_status", "A")
|
||||
.whereNull("c_payment_recon_no")
|
||||
.whereNull('c_payment_recon_no')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const checkReservationCanceledStatus = (reservationNumber) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.where("c_reservation_no", reservationNumber)
|
||||
.where("c_status", "X")
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.where('c_reservation_no', reservationNumber)
|
||||
.where('c_status', 'X')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const checkReservation = (reservationNumber) => {
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.where('c_reservation_no', reservationNumber)
|
||||
.where('c_status', '!=', 'X')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const checkReservationNumberAndAmountAlreadyRecon = (reservationNumber) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.select("c_payment_recon_no", "d_payment_recon")
|
||||
.where("c_reservation_no", reservationNumber)
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.select('c_payment_recon_no', 'd_payment_recon')
|
||||
.where('c_reservation_no', reservationNumber)
|
||||
// .where("c_status", "A")
|
||||
.whereNotNull("c_payment_recon_no")
|
||||
.whereNotNull('c_payment_recon_no')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// UPDATE PAYMENT RECON
|
||||
const updatePaymentReconNo = (data) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.update({
|
||||
c_payment_recon_no: data.payment_recon_no,
|
||||
d_payment: data.date,
|
||||
d_payment_recon: data.time,
|
||||
})
|
||||
.whereNull("c_payment_recon_no")
|
||||
.where("c_reservation_no", data.reservation_number);
|
||||
.whereNull('c_payment_recon_no')
|
||||
.where('c_reservation_no', data.reservation_number);
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -104,7 +114,7 @@ const insertPaymentReconTransaction = (
|
||||
responseMessage,
|
||||
responseData
|
||||
) => {
|
||||
let result = knex("payment.t_d_payment_recon").insert({
|
||||
let result = knex('payment.t_d_payment_recon').insert({
|
||||
d_payment: date,
|
||||
d_payment_recon: now,
|
||||
c_partner_code: partnerCode,
|
||||
@@ -123,34 +133,34 @@ const insertPaymentReconTransaction = (
|
||||
|
||||
// INSERT TEMP PAYMENT RECON NUMBER
|
||||
const insertPaymentReconNumber = (paymentReconNumber) => {
|
||||
let result = knex("payment.t_d_payment_recon_no_validate")
|
||||
let result = knex('payment.t_d_payment_recon_no_validate')
|
||||
.insert({
|
||||
c_payment_recon_no: paymentReconNumber,
|
||||
})
|
||||
.onConflict("c_payment_recon_no")
|
||||
.onConflict('c_payment_recon_no')
|
||||
.ignore();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET LAST COUNTER PAYMENT RECON NO
|
||||
const getLastCounterPaymentReconNo = (partnerCode, reconDate) => {
|
||||
let result = knex("payment.t_d_payment_recon")
|
||||
.select("c_payment_recon_no", "d_payment_recon")
|
||||
.whereRaw("??::date = ?", ["d_payment_recon", reconDate])
|
||||
.where("c_partner_code", partnerCode)
|
||||
let result = knex('payment.t_d_payment_recon')
|
||||
.select('c_payment_recon_no', 'd_payment_recon')
|
||||
.whereRaw('??::date = ?', ['d_payment_recon', reconDate])
|
||||
.where('c_partner_code', partnerCode)
|
||||
// .orderBy("d_payment_recon", "desc")
|
||||
.orderBy("c_payment_recon_no", "desc")
|
||||
.orderBy('c_payment_recon_no', 'desc')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
const getReservationToRecon = (date) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.select("c_reservation_no", "i_reservation_amount")
|
||||
.whereNull("d_cancel")
|
||||
.whereNull("c_payment_recon_no")
|
||||
.whereRaw("??::date = ?", ["d_reservation", date])
|
||||
.orderBy("c_reservation_no", "asc");
|
||||
let result = knex('trx.t_d_reservation_balance')
|
||||
.select('c_reservation_no', 'i_reservation_amount')
|
||||
.whereNull('d_cancel')
|
||||
.whereNull('c_payment_recon_no')
|
||||
.whereRaw('??::date = ?', ['d_reservation', date])
|
||||
.orderBy('c_reservation_no', 'asc');
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -159,6 +169,7 @@ module.exports = {
|
||||
getPartnerByID,
|
||||
checkReservationNumberAndAmount,
|
||||
checkReservationCanceledStatus,
|
||||
checkReservation,
|
||||
checkReservationNumberAndAmountAlreadyRecon,
|
||||
updatePaymentReconNo,
|
||||
insertPaymentReconTransaction,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
||||
const knex = require('../../../infrastructure/database/knex');
|
||||
|
||||
// GET IS CARD ADDED TO BLACKLIST
|
||||
const getCardBlacklist = (card_number) => {
|
||||
let result = knex('public.t_m_card_blacklist')
|
||||
.select('c_status')
|
||||
.where('c_card_number', card_number)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET IS CARD ADDED TO BLACKLIST
|
||||
const getCardReplacement = (card_number) => {
|
||||
let result = knex('trx.t_d_card_replacement')
|
||||
.select()
|
||||
.where('c_card_no', card_number)
|
||||
.orderBy('i_card_replacement', 'DESC')
|
||||
.first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET IS CARD ADDED TO BLACKLIST
|
||||
const getCardProduct = (card_number) => {
|
||||
let result = knex('public.t_m_card_product')
|
||||
.select()
|
||||
.where('c_card_number', card_number)
|
||||
.orderBy('i_request_order', 'DESC')
|
||||
.first();
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET CHECKING FROM GLOBAL PARAMETER
|
||||
const getGlobalParameterData = (code) => {
|
||||
let result = knex('t_m_global_parameter')
|
||||
.select('c_value')
|
||||
.where('c_code', code)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET LAST BALANCE FROM CARD HISTORY
|
||||
const getLastBalanceFromCardHistory = (cardNumber) => {
|
||||
let result = knex('log.t_log_card')
|
||||
.select('m_balance_after')
|
||||
.where('c_card_number', cardNumber)
|
||||
.where('c_status', 'S')
|
||||
.where('m_balance_after', '>', 0)
|
||||
.orderBy('d_log', 'desc')
|
||||
.limit(1)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET ACCUMULATION BALANCE IN THIS MONTH FROM CARD HISTORY
|
||||
const getAccumulationBalanceInThisMonthFromCardHistory = (
|
||||
cardNumber,
|
||||
year,
|
||||
month
|
||||
) => {
|
||||
let result = knex('log.t_log_card')
|
||||
.sum('m_amount as accumulation_balance')
|
||||
.where('c_card_number', cardNumber)
|
||||
.where('c_status', 'S')
|
||||
.where('m_balance_after', '>', 0)
|
||||
.whereRaw("DATE_PART('YEAR', ??) = ?", ['d_log', year])
|
||||
.whereRaw("DATE_PART('MONTH', ??) = ?", ['d_log', month])
|
||||
.whereIn('i_log_name', [21])
|
||||
.groupBy('c_card_number')
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// UPDATE CARD REPLACEMENT
|
||||
const updateReplacement = async (i_card_replacement, dataReplacement) => {
|
||||
let result = await knex('trx.t_d_card_replacement')
|
||||
.update(dataReplacement, ['*'])
|
||||
.where({ i_card_replacement: i_card_replacement });
|
||||
return result;
|
||||
};
|
||||
|
||||
const insertReplacementDetail = async (dataReplacement) => {
|
||||
let result = await knex("trx.t_d_card_replacement_detail").insert(dataReplacement);
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getCardBlacklist,
|
||||
getCardReplacement,
|
||||
getCardProduct,
|
||||
getGlobalParameterData,
|
||||
getLastBalanceFromCardHistory,
|
||||
getAccumulationBalanceInThisMonthFromCardHistory,
|
||||
updateReplacement,
|
||||
insertReplacementDetail
|
||||
};
|
||||
@@ -149,6 +149,18 @@ const checkReservation = async (req, res) => {
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION-CHECK ] checking production card number or not...`
|
||||
// );
|
||||
|
||||
let cardBlacklist = await model.getCardBlacklist(card_number);
|
||||
if (cardBlacklist) {
|
||||
if (cardBlacklist.c_status == 'B') {
|
||||
result = {
|
||||
code: '445',
|
||||
message: 'Card is Blacklisted',
|
||||
data: {},
|
||||
};
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
// jika settingan diperuntukan untuk production
|
||||
if (process.env.SERVER_FOR == 'production') {
|
||||
// kartu yang di request bukan kartu production maka akan di tolak
|
||||
@@ -216,9 +228,21 @@ const checkReservation = async (req, res) => {
|
||||
result = {
|
||||
code: '412',
|
||||
message: 'partner is not match',
|
||||
data: {},
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -331,6 +355,18 @@ const reservationValidate = async (req, res) => {
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION-VALIDATE ] checking production card number or not...`
|
||||
// );
|
||||
|
||||
let cardBlacklist = await model.getCardBlacklist(card_number);
|
||||
if (cardBlacklist) {
|
||||
if (cardBlacklist.c_status == 'B') {
|
||||
result = {
|
||||
code: '445',
|
||||
message: 'Card is Blacklisted',
|
||||
data: {},
|
||||
};
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
// jika settingan diperuntukan untuk production
|
||||
if (process.env.SERVER_FOR == 'production') {
|
||||
// kartu yang di request bukan kartu production maka akan di tolak
|
||||
@@ -756,6 +792,18 @@ const reservationValidateV2 = async (req, res) => {
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
let cardBlacklist = await model.getCardBlacklist(card_number);
|
||||
if (cardBlacklist) {
|
||||
if (cardBlacklist.c_status == 'B') {
|
||||
result = {
|
||||
code: '445',
|
||||
message: 'Card is Blacklisted',
|
||||
data: {},
|
||||
};
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
// log debug
|
||||
// pengecekkan nomor kartu yang di request adalah kartu production atau bukan berdasarkan settingan di .ENV dengan constanta SERVER_FOR.
|
||||
// Jika settingan .ENV SERVER_FOR adalah production dan nomor kartu KMT yang di request adalah kartu development maka sistem online topup akan menolaknya. Begitupun sebaliknya
|
||||
@@ -1246,6 +1294,18 @@ const reservation = async (req, res) => {
|
||||
// `${uniqueCode} [ PROCESSING RESERVATION ] checking production card number or not...`
|
||||
// );
|
||||
|
||||
let cardBlacklist = await model.getCardBlacklist(card_number);
|
||||
if (cardBlacklist) {
|
||||
if (cardBlacklist.c_status == 'B') {
|
||||
result = {
|
||||
code: '445',
|
||||
message: 'Card is Blacklisted',
|
||||
data: {},
|
||||
};
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
// jika settingan diperuntukan untuk production
|
||||
if (process.env.SERVER_FOR == 'production') {
|
||||
// kartu yang di request bukan kartu production maka akan di tolak
|
||||
@@ -1970,6 +2030,20 @@ const reservationV2 = async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
let cardBlacklist = await model.getCardBlacklist(
|
||||
reservationData.card_number
|
||||
);
|
||||
if (cardBlacklist) {
|
||||
if (cardBlacklist.c_status == 'B') {
|
||||
result = {
|
||||
code: '445',
|
||||
message: 'Card is Blacklisted',
|
||||
data: {},
|
||||
};
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
}
|
||||
|
||||
if (amount) {
|
||||
if (reservationData.amount != amount) {
|
||||
result = {
|
||||
|
||||
@@ -72,6 +72,15 @@ const getIssuer = (id, time) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET IS CARD ADDED TO BLACKLIST
|
||||
const getCardBlacklist = (card_number) => {
|
||||
let result = knex('public.t_m_card_blacklist')
|
||||
.select('c_status')
|
||||
.where('c_card_number', card_number)
|
||||
.first();
|
||||
return result;
|
||||
};
|
||||
|
||||
// GET RESERVATION EXPIRATION DATE FROM GLOBAL PARAMETER
|
||||
const getReservationExpirationDateValue = () => {
|
||||
let result = knex('t_m_global_parameter')
|
||||
@@ -540,6 +549,7 @@ module.exports = {
|
||||
getReservationNumberSequence,
|
||||
getPartner,
|
||||
getIssuer,
|
||||
getCardBlacklist,
|
||||
getReservationExpirationDateValue,
|
||||
getReservationExpirationDateMeasure,
|
||||
getCheckByCardProductStatusValue,
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const auth = require("../middlewares/jwt.middleware");
|
||||
const controller = require("../modules/pos/pos.controller");
|
||||
|
||||
// API Sample Get Last Balance
|
||||
router.post(
|
||||
"/pos/card-lastbalance",
|
||||
auth.authenticateToken,
|
||||
controller.validate("validateLastBalance"),
|
||||
controller.checkLastBalance
|
||||
);
|
||||
|
||||
// API Validate Sales MT
|
||||
router.post(
|
||||
"/pos/cardsales/validate",
|
||||
auth.authenticateToken,
|
||||
controller.validate("validateCardSales"),
|
||||
controller.validateSales
|
||||
);
|
||||
|
||||
// API Validate Topup MT
|
||||
router.post(
|
||||
"/pos/cardtopup/validate",
|
||||
auth.authenticateToken,
|
||||
controller.validate("validateCardTopup"),
|
||||
controller.validateTopup
|
||||
);
|
||||
|
||||
// API Validate Redeem MT
|
||||
router.post(
|
||||
"/pos/cardredeem/validate",
|
||||
auth.authenticateToken,
|
||||
controller.validate("validateCardRedeem"),
|
||||
controller.validateRedeem
|
||||
);
|
||||
|
||||
// API Check Blacklist
|
||||
router.post(
|
||||
"/pos/checkcardblacklist",
|
||||
auth.authenticateToken,
|
||||
controller.validate("checkBlacklist"),
|
||||
controller.checkBlacklist
|
||||
);
|
||||
|
||||
// API Validate Replacement MT
|
||||
router.post(
|
||||
"/pos/cardreplacement/validate",
|
||||
auth.authenticateToken,
|
||||
controller.validate("validateCardReplacement"),
|
||||
controller.validateReplacement
|
||||
);
|
||||
|
||||
// API Replacement Confirm
|
||||
router.post(
|
||||
"/pos/cardreplacement/confirm",
|
||||
auth.authenticateToken,
|
||||
controller.validate("cardReplacementConfirm"),
|
||||
controller.replacementConfirm
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
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 |
@@ -12,6 +12,7 @@ const historyRoute = require('../application/routes/history.routes');
|
||||
const paymentReconRoute = require('../application/routes/paymentrecon.routes');
|
||||
const invoiceRoute = require('../application/routes/invoiceonline.routes');
|
||||
const cashinRoute = require('../application/routes/cahsin.routes');
|
||||
const posRoute = require('../application/routes/pos.routes');
|
||||
const pooling = require('../application/routes/pooling.routes');
|
||||
const cron = require('node-cron');
|
||||
const moment = require('moment');
|
||||
@@ -51,6 +52,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());
|
||||
|
||||
@@ -79,6 +83,7 @@ app.use('/api/', paymentReconRoute);
|
||||
app.use('/api/', reservationRoute);
|
||||
app.use('/api/', invoiceRoute);
|
||||
app.use('/api/', cashinRoute);
|
||||
app.use('/api/', posRoute);
|
||||
app.use('/api/', pooling);
|
||||
|
||||
// ============================== SAP SCHEDULLER =============================
|
||||
|
||||
Reference in New Issue
Block a user