mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 10:46:27 +00:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 676553409b | |||
| 72a94891ed | |||
| 84be7587a8 | |||
| 8080b89c46 | |||
| 6dbd9b6246 | |||
| 5bafb81d8d | |||
| 1dd7860c0b | |||
| 1cf06d1fdd | |||
| be2cedc869 | |||
| f5f75381ca | |||
| 5cbdccca11 |
@@ -334,7 +334,12 @@ const getSalesKMT = async (trx, code, date, invoice) => {
|
|||||||
.where('tdpr.c_status', '=', 'S')
|
.where('tdpr.c_status', '=', 'S')
|
||||||
.whereNotNull('tdsi.c_return_sap')
|
.whereNotNull('tdsi.c_return_sap')
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`tdskm.c_sales_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM payment.t_d_cash_in_detail cid
|
||||||
|
WHERE cid.c_reservation_no = tdskm.c_sales_no
|
||||||
|
AND cid.b_reversal IS NOT TRUE
|
||||||
|
)`
|
||||||
);
|
);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -364,7 +369,11 @@ const getSalesInternal = async (trx, code, date, invoice) => {
|
|||||||
.where('tdpr.c_status', '=', 'S')
|
.where('tdpr.c_status', '=', 'S')
|
||||||
.whereNotNull('tdsi.c_return_sap_fi')
|
.whereNotNull('tdsi.c_return_sap_fi')
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`tdskm.c_sales_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM payment.t_d_cash_in_detail cid
|
||||||
|
WHERE cid.c_reservation_no = tdskm.c_sales_no
|
||||||
|
AND cid.b_reversal IS NOT TRUE)`
|
||||||
);
|
);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -394,7 +403,12 @@ const getTopUpCashlessInternal = async (trx, code, date, invoice) => {
|
|||||||
.where('tdpr.c_status', '=', 'S')
|
.where('tdpr.c_status', '=', 'S')
|
||||||
.whereNotNull('tdsi.c_return_sap')
|
.whereNotNull('tdsi.c_return_sap')
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`tdskm.c_topup_no NOT IN (SELECT c_reservation_no FROM payment.t_d_cash_in_detail WHERE b_reversal IS NOT TRUE)`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM payment.t_d_cash_in_detail cid
|
||||||
|
WHERE cid.c_reservation_no = tdskm.c_topup_no
|
||||||
|
AND cid.b_reversal IS NOT TRUE
|
||||||
|
)`
|
||||||
);
|
);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@@ -583,7 +597,7 @@ const getPartnerReconSalesInternal = async (trx) => {
|
|||||||
'tmp.c_account_sales_revenue',
|
'tmp.c_account_sales_revenue',
|
||||||
'tmp.c_account_code_sales_ar',
|
'tmp.c_account_code_sales_ar',
|
||||||
trx.raw(`CASE WHEN to_char(tdpr.d_payment, 'YYYYMM') >= to_char(tdsi.d_invoice_date, 'YYYYMM')
|
trx.raw(`CASE WHEN to_char(tdpr.d_payment, 'YYYYMM') >= to_char(tdsi.d_invoice_date, 'YYYYMM')
|
||||||
THEN 'IP' ELSE 'OP'
|
THEN 'IP' ELSE 'IP'
|
||||||
END c_in_period`),
|
END c_in_period`),
|
||||||
])
|
])
|
||||||
.from('trx.t_d_sales_internal AS tdskm')
|
.from('trx.t_d_sales_internal AS tdskm')
|
||||||
@@ -627,7 +641,7 @@ const getPartnerReconTopUpCashlessInternal = async (trx) => {
|
|||||||
'tmp.c_account_topup',
|
'tmp.c_account_topup',
|
||||||
'tmp.c_account_code_topup',
|
'tmp.c_account_code_topup',
|
||||||
trx.raw(`CASE WHEN to_char(tdpr.d_payment, 'YYYYMM') >= to_char(tdsi.d_invoice_date, 'YYYYMM')
|
trx.raw(`CASE WHEN to_char(tdpr.d_payment, 'YYYYMM') >= to_char(tdsi.d_invoice_date, 'YYYYMM')
|
||||||
THEN 'IP' ELSE 'OP'
|
THEN 'IP' ELSE 'IP'
|
||||||
END c_in_period`),
|
END c_in_period`),
|
||||||
])
|
])
|
||||||
.from('trx.t_d_topup_cashless_internal AS tdskm')
|
.from('trx.t_d_topup_cashless_internal AS tdskm')
|
||||||
|
|||||||
@@ -108,7 +108,14 @@ const getReservationPendingV2 = (cardNumber, time, flag) => {
|
|||||||
.whereIn('c_status', ['P', 'I'])
|
.whereIn('c_status', ['P', 'I'])
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM trx.t_d_fraud tdf
|
||||||
|
WHERE tdf.c_reservation_no = trx.t_d_reservation_balance.c_reservation_no
|
||||||
|
AND tdf.c_status = 'A'
|
||||||
|
AND tdf.c_card_number = ?
|
||||||
|
)`,
|
||||||
|
[cardNumber]
|
||||||
)
|
)
|
||||||
.where(function () {
|
.where(function () {
|
||||||
this.orWhere('c_flag', flag).orWhere('c_flag', '-1');
|
this.orWhere('c_flag', flag).orWhere('c_flag', '-1');
|
||||||
@@ -170,7 +177,14 @@ const getReservationPendingWithFlagCounterV2 = (cardNumber, time, flag) => {
|
|||||||
.whereIn('c_status', ['P', 'I'])
|
.whereIn('c_status', ['P', 'I'])
|
||||||
.whereRaw('??::INT < ??', ['c_flag', parseInt(flag)])
|
.whereRaw('??::INT < ??', ['c_flag', parseInt(flag)])
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM trx.t_d_fraud tdf
|
||||||
|
WHERE tdf.c_reservation_no = trx.t_d_reservation_balance.c_reservation_no
|
||||||
|
AND tdf.c_status = 'A'
|
||||||
|
AND tdf.c_card_number = ?
|
||||||
|
)`,
|
||||||
|
[cardNumber]
|
||||||
)
|
)
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.where('c_flag', '!=', '-1');
|
.where('c_flag', '!=', '-1');
|
||||||
@@ -198,7 +212,14 @@ const getReservationPendingWithFlagV2 = (cardNumber, time) => {
|
|||||||
.where('c_card_number', cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.whereIn('c_status', ['P', 'I'])
|
.whereIn('c_status', ['P', 'I'])
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM trx.t_d_fraud tdf
|
||||||
|
WHERE tdf.c_reservation_no = trx.t_d_reservation_balance.c_reservation_no
|
||||||
|
AND tdf.c_status = 'A'
|
||||||
|
AND tdf.c_card_number = ?
|
||||||
|
)`,
|
||||||
|
[cardNumber]
|
||||||
)
|
)
|
||||||
.whereNotNull('c_flag_code');
|
.whereNotNull('c_flag_code');
|
||||||
return result;
|
return result;
|
||||||
@@ -727,7 +748,7 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// winston.logger.debug(`${reservationNumber} commit transaction`);
|
// winston.logger.debug(`${reservationNumber} commit transaction`);
|
||||||
trx.commit();
|
return trx.commit();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
@@ -876,17 +897,6 @@ const getReservationPendingWithoutFraud = (
|
|||||||
reservationNumber = []
|
reservationNumber = []
|
||||||
) => {
|
) => {
|
||||||
if (reservationNumber.length > 0) {
|
if (reservationNumber.length > 0) {
|
||||||
let rsv = '';
|
|
||||||
if (reservationNumber.length > 0) {
|
|
||||||
for (let index = 0; index < reservationNumber.length; index++) {
|
|
||||||
if (index > 0) {
|
|
||||||
rsv = rsv + ',';
|
|
||||||
}
|
|
||||||
|
|
||||||
rsv = rsv + "'" + reservationNumber[index] + "'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = knex('trx.t_d_reservation_balance')
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.select(
|
.select(
|
||||||
'trx.t_d_reservation_balance.i_reservation_amount',
|
'trx.t_d_reservation_balance.i_reservation_amount',
|
||||||
@@ -896,7 +906,14 @@ const getReservationPendingWithoutFraud = (
|
|||||||
.where('trx.t_d_reservation_balance.c_card_number', cardNumber)
|
.where('trx.t_d_reservation_balance.c_card_number', cardNumber)
|
||||||
.whereIn('trx.t_d_reservation_balance.c_status', ['P', 'I'])
|
.whereIn('trx.t_d_reservation_balance.c_status', ['P', 'I'])
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`trx.t_d_reservation_balance.c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud WHERE trx.t_d_fraud.c_status = 'A' AND trx.t_d_fraud.c_reservation_no IN (${rsv}))`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM trx.t_d_fraud f
|
||||||
|
WHERE f.c_reservation_no = trx.t_d_reservation_balance.c_reservation_no
|
||||||
|
AND f.c_status = 'A'
|
||||||
|
AND f.c_reservation_no = ANY(ARRAY[?])
|
||||||
|
)`,
|
||||||
|
[reservationNumber]
|
||||||
)
|
)
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.where(function () {
|
.where(function () {
|
||||||
@@ -946,17 +963,6 @@ const getLastHistory = (cardNumber) => {
|
|||||||
|
|
||||||
// INSERT FRAUD TRANSACTION
|
// INSERT FRAUD TRANSACTION
|
||||||
const insertFraudTransaction = (reservationNumber) => {
|
const insertFraudTransaction = (reservationNumber) => {
|
||||||
let rsv = '';
|
|
||||||
if (reservationNumber.length > 0) {
|
|
||||||
for (let index = 0; index < reservationNumber.length; index++) {
|
|
||||||
if (index > 0) {
|
|
||||||
rsv = rsv + ',';
|
|
||||||
}
|
|
||||||
|
|
||||||
rsv = rsv + "'" + reservationNumber[index] + "'";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = knex
|
let result = knex
|
||||||
.into(
|
.into(
|
||||||
knex.raw(
|
knex.raw(
|
||||||
@@ -1013,7 +1019,14 @@ const insertFraudTransaction = (reservationNumber) => {
|
|||||||
reservationNumber
|
reservationNumber
|
||||||
)
|
)
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`trx.t_d_reservation_balance.c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud WHERE trx.t_d_fraud.c_status = 'A' AND trx.t_d_fraud.c_reservation_no IN (${rsv}))`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM trx.t_d_fraud f
|
||||||
|
WHERE f.c_reservation_no = trx.t_d_reservation_balance.c_reservation_no
|
||||||
|
AND f.c_status = 'A'
|
||||||
|
AND f.c_reservation_no = ANY(ARRAY[?])
|
||||||
|
)`,
|
||||||
|
[reservationNumber]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
@@ -1128,7 +1141,7 @@ const updateReservationAndInsertLoadingBalance = async (
|
|||||||
})
|
})
|
||||||
.whereIn('c_reservation_no', reservationNumber);
|
.whereIn('c_reservation_no', reservationNumber);
|
||||||
})
|
})
|
||||||
.then(trx.commit)
|
.then(() => trx.commit())
|
||||||
.catch(trx.rollback);
|
.catch(trx.rollback);
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ const completingDataSalesInternal = async (ppn) => {
|
|||||||
trx.t_d_sales_internal.is_complete is not true
|
trx.t_d_sales_internal.is_complete is not true
|
||||||
AND trx.t_d_sales_internal.i_card_price > 0
|
AND trx.t_d_sales_internal.i_card_price > 0
|
||||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||||
|
AND t_m_card_theme.c_status = 'A'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
trx.t_d_sales_internal.c_card_number,
|
trx.t_d_sales_internal.c_card_number,
|
||||||
t_m_card_theme.c_card_type_code,
|
t_m_card_theme.c_card_type_code,
|
||||||
@@ -214,6 +215,7 @@ const completingDataSalesInternal = async (ppn) => {
|
|||||||
AND trx.t_d_sales_internal.i_old_card_price > 0
|
AND trx.t_d_sales_internal.i_old_card_price > 0
|
||||||
AND trx.t_d_sales_internal.c_category IN ('N', 'W')
|
AND trx.t_d_sales_internal.c_category IN ('N', 'W')
|
||||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||||
|
AND t_m_card_theme.c_status = 'A'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
trx.t_d_sales_internal.c_old_card_number,
|
trx.t_d_sales_internal.c_old_card_number,
|
||||||
t_m_card_theme.c_card_type_code,
|
t_m_card_theme.c_card_type_code,
|
||||||
@@ -275,6 +277,7 @@ const completingDataSalesNewCard = async (ppn) => {
|
|||||||
trx.t_d_sales_internal.is_complete is not true
|
trx.t_d_sales_internal.is_complete is not true
|
||||||
AND trx.t_d_sales_internal.i_card_price > 0
|
AND trx.t_d_sales_internal.i_card_price > 0
|
||||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||||
|
AND t_m_card_theme.c_status = 'A'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
trx.t_d_sales_internal.c_card_number,
|
trx.t_d_sales_internal.c_card_number,
|
||||||
t_m_card_theme.c_card_type_code,
|
t_m_card_theme.c_card_type_code,
|
||||||
@@ -320,6 +323,7 @@ const completingDataSalesOldCard = async (ppn) => {
|
|||||||
AND trx.t_d_sales_internal.i_old_card_price > 0
|
AND trx.t_d_sales_internal.i_old_card_price > 0
|
||||||
AND trx.t_d_sales_internal.c_category IN ('N', 'W')
|
AND trx.t_d_sales_internal.c_category IN ('N', 'W')
|
||||||
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
AND trx.t_d_sales_internal.i_sales_invoice_internal is null
|
||||||
|
AND t_m_card_theme.c_status = 'A'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
trx.t_d_sales_internal.c_old_card_number,
|
trx.t_d_sales_internal.c_old_card_number,
|
||||||
t_m_card_theme.c_card_type_code,
|
t_m_card_theme.c_card_type_code,
|
||||||
|
|||||||
@@ -1254,7 +1254,7 @@ const reservation = async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
// generate unique code
|
// generate unique code
|
||||||
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
// param
|
// param
|
||||||
@@ -1712,11 +1712,11 @@ const reservation = async (req, res) => {
|
|||||||
// create log
|
// create log
|
||||||
winston.logger.error(`server is busy. please try again.`);
|
winston.logger.error(`server is busy. please try again.`);
|
||||||
|
|
||||||
return {
|
return res.status(200).json({
|
||||||
code: '500',
|
code: '500',
|
||||||
message: 'server is busy. please try again.',
|
message: 'server is busy. please try again.',
|
||||||
data: {},
|
data: {},
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
maxLoop++;
|
maxLoop++;
|
||||||
@@ -1841,8 +1841,7 @@ const reservation = async (req, res) => {
|
|||||||
m_balance_after: balance > 0 ? balance : 0,
|
m_balance_after: balance > 0 ? balance : 0,
|
||||||
j_new_data: data,
|
j_new_data: data,
|
||||||
j_old_data: null,
|
j_old_data: null,
|
||||||
c_note: `RESERVED BALANCE ${amount} FROM ${
|
c_note: `RESERVED BALANCE ${amount} FROM ${getPartner ? getPartner.partner_name : null
|
||||||
getPartner ? getPartner.partner_name : null
|
|
||||||
} SUCCESSFULLY`,
|
} SUCCESSFULLY`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
@@ -1923,7 +1922,7 @@ const reservationV2 = async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
// generate unique code
|
// generate unique code
|
||||||
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
// unique code ini digunakan untuk keperluan log agar mudah untuk dibaca
|
||||||
let uniqueCode = helper.getUniqueCode();
|
let uniqueCode = await helper.getUniqueCode();
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
// param
|
// param
|
||||||
@@ -2547,11 +2546,11 @@ const reservationV2 = async (req, res) => {
|
|||||||
// create log
|
// create log
|
||||||
winston.logger.error(`server is busy. please try again.`);
|
winston.logger.error(`server is busy. please try again.`);
|
||||||
|
|
||||||
return {
|
return res.status(200).json({
|
||||||
code: '500',
|
code: '500',
|
||||||
message: 'server is busy. please try again.',
|
message: 'server is busy. please try again.',
|
||||||
data: {},
|
data: {},
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
maxLoop++;
|
maxLoop++;
|
||||||
@@ -2678,8 +2677,7 @@ const reservationV2 = async (req, res) => {
|
|||||||
m_balance_after: balance > 0 ? balance : 0,
|
m_balance_after: balance > 0 ? balance : 0,
|
||||||
j_new_data: data,
|
j_new_data: data,
|
||||||
j_old_data: null,
|
j_old_data: null,
|
||||||
c_note: `RESERVED BALANCE ${amount} FROM ${
|
c_note: `RESERVED BALANCE ${amount} FROM ${getPartner ? getPartner.partner_name : null
|
||||||
getPartner ? getPartner.partner_name : null
|
|
||||||
} SUCCESSFULLY`,
|
} SUCCESSFULLY`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
@@ -3176,8 +3174,7 @@ const cancelReservation = async (req, res) => {
|
|||||||
m_balance_after: balance > 0 ? balance : 0,
|
m_balance_after: balance > 0 ? balance : 0,
|
||||||
j_new_data: data,
|
j_new_data: data,
|
||||||
j_old_data: getReservationCanBeCanceled,
|
j_old_data: getReservationCanBeCanceled,
|
||||||
c_note: `CANCEL RESERVE BALANCE ${
|
c_note: `CANCEL RESERVE BALANCE ${getReservationCanBeCanceled.i_reservation_amount
|
||||||
getReservationCanBeCanceled.i_reservation_amount
|
|
||||||
} FROM ${getPartner ? getPartner.partner_name : null}`,
|
} FROM ${getPartner ? getPartner.partner_name : null}`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
@@ -3329,6 +3326,14 @@ const inquiryReservationByReservation = async (req, res) => {
|
|||||||
|
|
||||||
// check reservation
|
// check reservation
|
||||||
result = await model.inquiryListByRefNumber(ref_no, show_complete_data);
|
result = await model.inquiryListByRefNumber(ref_no, show_complete_data);
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
return res.status(200).json({
|
||||||
|
code: '414',
|
||||||
|
message: "reservation doesn't exist",
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (req.query.search === 'load-balance-number') {
|
} else if (req.query.search === 'load-balance-number') {
|
||||||
// validation parameter inquiry
|
// validation parameter inquiry
|
||||||
if (!load_balance_number) {
|
if (!load_balance_number) {
|
||||||
@@ -3344,6 +3349,14 @@ const inquiryReservationByReservation = async (req, res) => {
|
|||||||
load_balance_number,
|
load_balance_number,
|
||||||
show_complete_data
|
show_complete_data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (result.length < 1) {
|
||||||
|
return res.status(200).json({
|
||||||
|
code: '414',
|
||||||
|
message: "reservation doesn't exist",
|
||||||
|
data: {},
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// validation parameter inquiry
|
// validation parameter inquiry
|
||||||
if (!reservation_number) {
|
if (!reservation_number) {
|
||||||
@@ -3359,7 +3372,6 @@ const inquiryReservationByReservation = async (req, res) => {
|
|||||||
reservation_number,
|
reservation_number,
|
||||||
show_complete_data
|
show_complete_data
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
@@ -3368,6 +3380,7 @@ const inquiryReservationByReservation = async (req, res) => {
|
|||||||
data: {},
|
data: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
code: '00',
|
code: '00',
|
||||||
@@ -4093,8 +4106,7 @@ const cancelReservationV2 = async (req, res) => {
|
|||||||
m_balance_after: balance > 0 ? balance : 0,
|
m_balance_after: balance > 0 ? balance : 0,
|
||||||
j_new_data: data,
|
j_new_data: data,
|
||||||
j_old_data: getReservationCanBeCanceled,
|
j_old_data: getReservationCanBeCanceled,
|
||||||
c_note: `CANCEL RESERVE BALANCE ${
|
c_note: `CANCEL RESERVE BALANCE ${getReservationCanBeCanceled.i_reservation_amount
|
||||||
getReservationCanBeCanceled.i_reservation_amount
|
|
||||||
} FROM ${getPartner ? getPartner.partner_name : null}`,
|
} FROM ${getPartner ? getPartner.partner_name : null}`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
@@ -4376,8 +4388,7 @@ const cancelReservationV2_1 = async (req, res) => {
|
|||||||
m_balance_after: balance > 0 ? balance : 0,
|
m_balance_after: balance > 0 ? balance : 0,
|
||||||
j_new_data: data,
|
j_new_data: data,
|
||||||
j_old_data: getReservationCanBeCanceled,
|
j_old_data: getReservationCanBeCanceled,
|
||||||
c_note: `CANCEL RESERVE BALANCE ${
|
c_note: `CANCEL RESERVE BALANCE ${getReservationCanBeCanceled.i_reservation_amount
|
||||||
getReservationCanBeCanceled.i_reservation_amount
|
|
||||||
} FROM ${getPartner ? getPartner.partner_name : null}`,
|
} FROM ${getPartner ? getPartner.partner_name : null}`,
|
||||||
c_status: 'S',
|
c_status: 'S',
|
||||||
d_created: now,
|
d_created: now,
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ const getMaxReservation = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// INQUIRY BY RESERVATION NUMBER
|
// INQUIRY BY RESERVATION NUMBER
|
||||||
let inquiryByReservationNumber = (reservationNumber, show_complete_data) => {
|
const inquiryByReservationNumber = (reservationNumber, show_complete_data) => {
|
||||||
let result = knex('trx.t_d_reservation_balance');
|
let result = knex('trx.t_d_reservation_balance');
|
||||||
if (show_complete_data === true) {
|
if (show_complete_data === true) {
|
||||||
result.select(
|
result.select(
|
||||||
@@ -198,14 +198,14 @@ let inquiryByReservationNumber = (reservationNumber, show_complete_data) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
result
|
result = result
|
||||||
.where('trx.t_d_reservation_balance.c_reservation_no', reservationNumber)
|
.where('trx.t_d_reservation_balance.c_reservation_no', reservationNumber)
|
||||||
.first();
|
.first();
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// INQUIRY LIST RESERVATION
|
// INQUIRY LIST RESERVATION
|
||||||
let inquiryListReservation = (partnerID, startDate, endDate) => {
|
const inquiryListReservation = (partnerID, startDate, endDate) => {
|
||||||
let result = knex('trx.t_d_reservation_balance');
|
let result = knex('trx.t_d_reservation_balance');
|
||||||
result.select(
|
result.select(
|
||||||
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
'trx.t_d_reservation_balance.c_reservation_no as reservation_number',
|
||||||
@@ -253,7 +253,7 @@ let inquiryListReservation = (partnerID, startDate, endDate) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// INQUIRY BY CARD NUMBER
|
// INQUIRY BY CARD NUMBER
|
||||||
let inquiryByCardNumber = (cardNumber, startDate, endDate) => {
|
const inquiryByCardNumber = (cardNumber, startDate, endDate) => {
|
||||||
let result = knex('trx.t_d_reservation_balance')
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
.select(
|
.select(
|
||||||
'c_reservation_no as reservation_number',
|
'c_reservation_no as reservation_number',
|
||||||
@@ -286,7 +286,14 @@ const getReservationPending = (cardNumber, time) => {
|
|||||||
.where('c_card_number', cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.where('c_status', 'P')
|
.where('c_status', 'P')
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM trx.t_d_fraud f
|
||||||
|
WHERE f.c_reservation_no = trx.t_d_reservation_balance.c_reservation_no
|
||||||
|
AND f.c_status = 'A'
|
||||||
|
AND f.c_card_number = ?
|
||||||
|
)`,
|
||||||
|
[cardNumber]
|
||||||
)
|
)
|
||||||
// .where("d_expired", ">=", time)
|
// .where("d_expired", ">=", time)
|
||||||
.first();
|
.first();
|
||||||
@@ -310,7 +317,14 @@ const getReservationPendingV2 = (cardNumber, time) => {
|
|||||||
.where('c_card_number', cardNumber)
|
.where('c_card_number', cardNumber)
|
||||||
.where('c_status', 'P')
|
.where('c_status', 'P')
|
||||||
.whereRaw(
|
.whereRaw(
|
||||||
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
|
`NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM trx.t_d_fraud f
|
||||||
|
WHERE f.c_reservation_no = trx.t_d_reservation_balance.c_reservation_no
|
||||||
|
AND f.c_status = 'A'
|
||||||
|
AND f.c_card_number = ?
|
||||||
|
)`,
|
||||||
|
[cardNumber]
|
||||||
);
|
);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -425,7 +439,7 @@ const deleteReservationNumberValidate = (reservationNumber) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// INQUIRY BY REF NUMBER
|
// INQUIRY BY REF NUMBER
|
||||||
let inquiryListByRefNumber = (refNumber, show_complete_data) => {
|
const inquiryListByRefNumber = (refNumber, show_complete_data) => {
|
||||||
let result = knex('trx.t_d_reservation_balance');
|
let result = knex('trx.t_d_reservation_balance');
|
||||||
if (show_complete_data === true) {
|
if (show_complete_data === true) {
|
||||||
result.select(
|
result.select(
|
||||||
@@ -469,7 +483,7 @@ let inquiryListByRefNumber = (refNumber, show_complete_data) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
result.where('trx.t_d_reservation_balance.c_ref_no', refNumber).first();
|
result = result.where('trx.t_d_reservation_balance.c_ref_no', refNumber).first();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|||||||
Generated
+2605
-8411
File diff suppressed because it is too large
Load Diff
+8
-6
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "topuponline",
|
"name": "onlinetopup-v1",
|
||||||
"version": "1.6.2",
|
"version": "1.6.5",
|
||||||
"description": "pos cms integration",
|
"description": "optimize query and coding enhancement",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "nodemon index",
|
"start": "nodemon index",
|
||||||
@@ -37,11 +37,13 @@
|
|||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
"node-cron": "^3.0.1",
|
"node-cron": "^3.0.1",
|
||||||
"pg": "^8.6.0",
|
"pg": "^8.6.0",
|
||||||
"pm2": "^5.2.0",
|
"pm2": "^6.0.13",
|
||||||
"prom-client": "^14.2.0",
|
"prom-client": "^14.2.0",
|
||||||
"redis": "^4.6.5",
|
"redis": "^4.6.5",
|
||||||
"response-time": "^2.3.2",
|
"response-time": "^2.3.2",
|
||||||
|
"simple-update-notifier": "^2.0.0",
|
||||||
"sticky-session": "^0.1.0",
|
"sticky-session": "^0.1.0",
|
||||||
|
"superagent": "^10.2.3",
|
||||||
"winston": "^3.7.2",
|
"winston": "^3.7.2",
|
||||||
"winston-daily-rotate-file": "^4.7.1",
|
"winston-daily-rotate-file": "^4.7.1",
|
||||||
"winston-loki": "^6.0.6",
|
"winston-loki": "^6.0.6",
|
||||||
@@ -50,8 +52,8 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^29.0.2",
|
"jest": "^29.0.2",
|
||||||
"nodemon": "^2.0.7",
|
"nodemon": "^3.1.10",
|
||||||
"supertest": "^6.2.4"
|
"supertest": "^7.1.3"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"testEnvironment": "node",
|
"testEnvironment": "node",
|
||||||
|
|||||||
Reference in New Issue
Block a user