mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 22:56:26 +00:00
change logic masximum reservation with pending status
This commit is contained in:
@@ -337,7 +337,7 @@ const reservationValidate = async (req, res) => {
|
||||
let getMaxReservation = await model.getMaxReservation();
|
||||
let maxReservation = getMaxReservation.c_value
|
||||
? parseInt(getMaxReservation.c_value)
|
||||
: 1;
|
||||
: 0;
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} checking total reservation pending...`);
|
||||
@@ -348,9 +348,10 @@ const reservationValidate = async (req, res) => {
|
||||
now
|
||||
);
|
||||
let totalReservationPending =
|
||||
getReservationPending.total_reservation > 0
|
||||
? getReservationPending.total_reservation
|
||||
: 0;
|
||||
getReservationPending.total_nominal_reservation > 0
|
||||
? parseInt(getReservationPending.total_nominal_reservation) +
|
||||
parseInt(amount)
|
||||
: parseInt(amount);
|
||||
|
||||
if (totalReservationPending >= maxReservation) {
|
||||
result = {
|
||||
@@ -603,7 +604,7 @@ const reservation = async (req, res) => {
|
||||
let getMaxReservation = await model.getMaxReservation();
|
||||
let maxReservation = getMaxReservation.c_value
|
||||
? parseInt(getMaxReservation.c_value)
|
||||
: 1;
|
||||
: 0;
|
||||
|
||||
// // log debug
|
||||
// winston.logger.debug(`${uniqueCode} checking reservation with flag...`);
|
||||
@@ -642,9 +643,10 @@ const reservation = async (req, res) => {
|
||||
now
|
||||
);
|
||||
let totalReservationPending =
|
||||
getReservationPending.total_reservation > 0
|
||||
? getReservationPending.total_reservation
|
||||
: 0;
|
||||
getReservationPending.total_nominal_reservation > 0
|
||||
? parseInt(getReservationPending.total_nominal_reservation) +
|
||||
parseInt(amount)
|
||||
: parseInt(amount);
|
||||
|
||||
if (totalReservationPending >= maxReservation) {
|
||||
result = {
|
||||
|
||||
@@ -180,6 +180,7 @@ let inquiryByCardNumber = (cardNumber, startDate, endDate) => {
|
||||
const getReservationPending = (cardNumber, time) => {
|
||||
let result = knex("trx.t_d_reservation_balance")
|
||||
.count("* as total_reservation")
|
||||
.sum("* as total_nominal_reservation")
|
||||
.where("c_card_number", cardNumber)
|
||||
.where("c_status", "P")
|
||||
// .where("d_expired", ">=", time)
|
||||
|
||||
Reference in New Issue
Block a user