mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 16:46:28 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 79d4269b70 | |||
| 603a74a5b7 | |||
| c9a08d6832 | |||
| 308fef3ecd | |||
| 31d007dd67 |
@@ -172,6 +172,7 @@ const _generateCashIn = async (uniqueCode) => {
|
|||||||
let reserve = [];
|
let reserve = [];
|
||||||
let code = '';
|
let code = '';
|
||||||
await knex.transaction(async (trx) => {
|
await knex.transaction(async (trx) => {
|
||||||
|
try {
|
||||||
code = await model.generateCode(
|
code = await model.generateCode(
|
||||||
trx,
|
trx,
|
||||||
item.c_partner_code,
|
item.c_partner_code,
|
||||||
@@ -214,6 +215,7 @@ const _generateCashIn = async (uniqueCode) => {
|
|||||||
}
|
}
|
||||||
dataCahsIn.i_amount = cashInAmount;
|
dataCahsIn.i_amount = cashInAmount;
|
||||||
|
|
||||||
|
if(cashInAmount > 0) {
|
||||||
//INSERT CASH-IN
|
//INSERT CASH-IN
|
||||||
const cashIn = await model.insertCashIn(trx, dataCahsIn);
|
const cashIn = await model.insertCashIn(trx, dataCahsIn);
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
@@ -228,6 +230,7 @@ const _generateCashIn = async (uniqueCode) => {
|
|||||||
trx
|
trx
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let m_amount = 0;
|
||||||
for (const detail of reserv) {
|
for (const detail of reserv) {
|
||||||
// data.push({
|
// data.push({
|
||||||
// i_cash_in: cashIn.i_cash_in,
|
// i_cash_in: cashIn.i_cash_in,
|
||||||
@@ -254,22 +257,46 @@ const _generateCashIn = async (uniqueCode) => {
|
|||||||
d_credit: cashIn.d_credit,
|
d_credit: cashIn.d_credit,
|
||||||
c_in_period: cashIn.c_in_period,
|
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);
|
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);
|
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(5000);
|
await wait(10000);
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN TO RESERVE ${code} DATA : ${JSON.stringify(
|
`SCHEDULER-FB70-${uniqueCode} INSERT CASH-IN TO RESERVE ${code} DATA : ${JSON.stringify(
|
||||||
dataCahsIn
|
dataCahsIn
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
// await model.insertCashInDetail(trx, data);
|
}
|
||||||
// await model.insertPostingEt(code, item, trx)
|
await trx.commit();
|
||||||
});
|
|
||||||
|
} catch (error) {
|
||||||
|
sts = "error";
|
||||||
|
await trx.rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
return partnerRecon;
|
return partnerRecon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ const getReserve = async (trx, code, date, invoice) => {
|
|||||||
'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',
|
||||||
|
'tdi.m_amount as invoice_amount'
|
||||||
])
|
])
|
||||||
.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 () {
|
||||||
|
|||||||
@@ -456,6 +456,18 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
return res.status(200).json(result);
|
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
|
// log debug
|
||||||
// winston.logger.debug(
|
// winston.logger.debug(
|
||||||
// `${uniqueCode} [ PROCESSING LOADING-BALANCE-REQUEST ]: checking production card number or not...`
|
// `${uniqueCode} [ PROCESSING LOADING-BALANCE-REQUEST ]: checking production card number or not...`
|
||||||
|
|||||||
@@ -56,6 +56,15 @@ const getIssuer = (id) => {
|
|||||||
return result;
|
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
|
// GET CHECKING CARD PRODUCT FROM GLOBAL PARAMETER
|
||||||
const getCheckByCardProductStatusValue = () => {
|
const getCheckByCardProductStatusValue = () => {
|
||||||
let result = knex('t_m_global_parameter')
|
let result = knex('t_m_global_parameter')
|
||||||
@@ -1077,6 +1086,7 @@ module.exports = {
|
|||||||
checkCardNumber,
|
checkCardNumber,
|
||||||
getPartner,
|
getPartner,
|
||||||
getIssuer,
|
getIssuer,
|
||||||
|
getCardBlacklist,
|
||||||
getCheckByCardProductStatusValue,
|
getCheckByCardProductStatusValue,
|
||||||
getReservationPending,
|
getReservationPending,
|
||||||
getReservationPendingWithFlagCounter,
|
getReservationPendingWithFlagCounter,
|
||||||
|
|||||||
@@ -149,6 +149,18 @@ const checkReservation = async (req, res) => {
|
|||||||
// `${uniqueCode} [ PROCESSING RESERVATION-CHECK ] checking production card number or not...`
|
// `${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
|
// jika settingan diperuntukan untuk production
|
||||||
if (process.env.SERVER_FOR == 'production') {
|
if (process.env.SERVER_FOR == 'production') {
|
||||||
// kartu yang di request bukan kartu production maka akan di tolak
|
// kartu yang di request bukan kartu production maka akan di tolak
|
||||||
@@ -343,6 +355,18 @@ const reservationValidate = async (req, res) => {
|
|||||||
// `${uniqueCode} [ PROCESSING RESERVATION-VALIDATE ] checking production card number or not...`
|
// `${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
|
// jika settingan diperuntukan untuk production
|
||||||
if (process.env.SERVER_FOR == 'production') {
|
if (process.env.SERVER_FOR == 'production') {
|
||||||
// kartu yang di request bukan kartu production maka akan di tolak
|
// kartu yang di request bukan kartu production maka akan di tolak
|
||||||
@@ -768,6 +792,18 @@ const reservationValidateV2 = async (req, res) => {
|
|||||||
return res.status(200).json(result);
|
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
|
// log debug
|
||||||
// pengecekkan nomor kartu yang di request adalah kartu production atau bukan berdasarkan settingan di .ENV dengan constanta SERVER_FOR.
|
// 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
|
// 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
|
||||||
@@ -1258,6 +1294,18 @@ const reservation = async (req, res) => {
|
|||||||
// `${uniqueCode} [ PROCESSING RESERVATION ] checking production card number or not...`
|
// `${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
|
// jika settingan diperuntukan untuk production
|
||||||
if (process.env.SERVER_FOR == 'production') {
|
if (process.env.SERVER_FOR == 'production') {
|
||||||
// kartu yang di request bukan kartu production maka akan di tolak
|
// kartu yang di request bukan kartu production maka akan di tolak
|
||||||
@@ -1982,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 (amount) {
|
||||||
if (reservationData.amount != amount) {
|
if (reservationData.amount != amount) {
|
||||||
result = {
|
result = {
|
||||||
|
|||||||
@@ -72,6 +72,15 @@ const getIssuer = (id, time) => {
|
|||||||
return result;
|
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
|
// GET RESERVATION EXPIRATION DATE FROM GLOBAL PARAMETER
|
||||||
const getReservationExpirationDateValue = () => {
|
const getReservationExpirationDateValue = () => {
|
||||||
let result = knex('t_m_global_parameter')
|
let result = knex('t_m_global_parameter')
|
||||||
@@ -540,6 +549,7 @@ module.exports = {
|
|||||||
getReservationNumberSequence,
|
getReservationNumberSequence,
|
||||||
getPartner,
|
getPartner,
|
||||||
getIssuer,
|
getIssuer,
|
||||||
|
getCardBlacklist,
|
||||||
getReservationExpirationDateValue,
|
getReservationExpirationDateValue,
|
||||||
getReservationExpirationDateMeasure,
|
getReservationExpirationDateMeasure,
|
||||||
getCheckByCardProductStatusValue,
|
getCheckByCardProductStatusValue,
|
||||||
|
|||||||
Reference in New Issue
Block a user