mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 23:16:28 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8f01db5e9 | |||
| 1be5cc8d0c | |||
| 352ec2822f | |||
| 9910d4d834 | |||
| a2eb984658 | |||
| eac57a3821 | |||
| f4451aaea2 | |||
| 837d1c5d77 | |||
| 74825d277b | |||
| 8c231e9901 |
@@ -86,38 +86,38 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
`${uniqueCode} checking production card number or not...`
|
`${uniqueCode} checking production card number or not...`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (process.env.SERVER_FOR == 'production') {
|
// if (process.env.SERVER_FOR == 'production') {
|
||||||
if (card_number.substring(0, 1) != '1') {
|
// if (card_number.substring(0, 1) != '1') {
|
||||||
result = {
|
// result = {
|
||||||
code: '400',
|
// code: '400',
|
||||||
message: "It's not production card number.",
|
// message: "It's not production card number.",
|
||||||
data: {},
|
// data: {},
|
||||||
};
|
// };
|
||||||
|
|
||||||
// log warn
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (card_number.substring(0, 1) == '1') {
|
// if (card_number.substring(0, 1) == '1') {
|
||||||
result = {
|
// result = {
|
||||||
code: '400',
|
// code: '400',
|
||||||
message:
|
// message:
|
||||||
"It's production card number. Please use the development card number.",
|
// "It's production card number. Please use the development card number.",
|
||||||
data: {},
|
// data: {},
|
||||||
};
|
// };
|
||||||
|
|
||||||
// log warn
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// time
|
// time
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
@@ -412,50 +412,6 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
`${uniqueCode} checking the card number in list fraud transaction or not...`
|
`${uniqueCode} checking the card number in list fraud transaction or not...`
|
||||||
);
|
);
|
||||||
|
|
||||||
// check fraud transaction by card number and how much fraud amount
|
|
||||||
let fraudTransaction = await model.getFraudTopupAndDeductTransaction(
|
|
||||||
card_number
|
|
||||||
);
|
|
||||||
|
|
||||||
let fraudReservationNumber = [];
|
|
||||||
let amountFraudTopup = 0;
|
|
||||||
let amountFraudDeduct = 0;
|
|
||||||
let restAmountFraud = 0;
|
|
||||||
let totalFraudReservation = 0;
|
|
||||||
|
|
||||||
// if card number has fraud transaction
|
|
||||||
if (fraudTransaction.length > 0) {
|
|
||||||
let i = 0;
|
|
||||||
|
|
||||||
if (fraudTransaction.length > 0) {
|
|
||||||
fraudTransaction.forEach((rsv) => {
|
|
||||||
fraudReservationNumber.push(rsv.c_reservation_no);
|
|
||||||
amountFraudTopup += parseInt(rsv.i_reservation_amount);
|
|
||||||
i++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
totalFraudReservation = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate rest amount fraud
|
|
||||||
restAmountFraud = parseInt(amountFraudTopup) - parseInt(amountFraudDeduct);
|
|
||||||
|
|
||||||
// if card number has fraud transaction and amount greater than 0
|
|
||||||
if (parseInt(restAmountFraud) > 0) {
|
|
||||||
// fraud reservation found, and tell the lib to deduct transaction
|
|
||||||
|
|
||||||
result = {
|
|
||||||
code: '00',
|
|
||||||
message: 'reservation exists',
|
|
||||||
data: {
|
|
||||||
amount: parseInt(amountFraudTopup) * -1,
|
|
||||||
total_reservation: totalFraudReservation,
|
|
||||||
reservation_number: fraudReservationNumber,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// card number does't have fraud transaction
|
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(`${uniqueCode} checking total topup amount...`);
|
winston.logger.debug(`${uniqueCode} checking total topup amount...`);
|
||||||
|
|
||||||
@@ -484,9 +440,7 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
const getBIRegulationStatus = await model.getBIRegulationStatus();
|
const getBIRegulationStatus = await model.getBIRegulationStatus();
|
||||||
if (getBIRegulationStatus.c_value == 'A') {
|
if (getBIRegulationStatus.c_value == 'A') {
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(
|
winston.logger.debug(`${uniqueCode} checking max balance on the card...`);
|
||||||
`${uniqueCode} checking max balance on the card...`
|
|
||||||
);
|
|
||||||
|
|
||||||
// get max saldo on the card
|
// get max saldo on the card
|
||||||
const getMaxAmountOnTheCard = await model.getMaxAmountOnTheCard();
|
const getMaxAmountOnTheCard = await model.getMaxAmountOnTheCard();
|
||||||
@@ -555,7 +509,7 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
`${uniqueCode} updating status reservation to in progress...`
|
`${uniqueCode} updating status reservation to in progress...${reservationNumberTemp}, ${now}, ${flag}`
|
||||||
);
|
);
|
||||||
|
|
||||||
// update status to in progress
|
// update status to in progress
|
||||||
@@ -565,6 +519,9 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
flag
|
flag
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(`${uniqueCode} XXXXX ${updateStatusReservation}`);
|
||||||
|
|
||||||
if (updateStatusReservation) {
|
if (updateStatusReservation) {
|
||||||
result = {
|
result = {
|
||||||
code: '00',
|
code: '00',
|
||||||
@@ -600,7 +557,6 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return res.json(result);
|
return res.json(result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -668,38 +624,38 @@ const loadingBalance = async (req, res) => {
|
|||||||
`${uniqueCode} checking production card number or not...`
|
`${uniqueCode} checking production card number or not...`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (process.env.SERVER_FOR == 'production') {
|
// if (process.env.SERVER_FOR == 'production') {
|
||||||
if (card_number.substring(0, 1) != '1') {
|
// if (card_number.substring(0, 1) != '1') {
|
||||||
result = {
|
// result = {
|
||||||
code: '400',
|
// code: '400',
|
||||||
message: "It's not production card number.",
|
// message: "It's not production card number.",
|
||||||
data: {},
|
// data: {},
|
||||||
};
|
// };
|
||||||
|
|
||||||
// log warn
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (card_number.substring(0, 1) == '1') {
|
// if (card_number.substring(0, 1) == '1') {
|
||||||
result = {
|
// result = {
|
||||||
code: '400',
|
// code: '400',
|
||||||
message:
|
// message:
|
||||||
"It's production card number. Please use the development card number.",
|
// "It's production card number. Please use the development card number.",
|
||||||
data: {},
|
// data: {},
|
||||||
};
|
// };
|
||||||
|
|
||||||
// log warn
|
// // log warn
|
||||||
winston.logger.warn(
|
// winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
// `${uniqueCode} RESPONSE check reservation: ${JSON.stringify(result)}`
|
||||||
);
|
// );
|
||||||
|
|
||||||
return res.status(200).json(result);
|
// return res.status(200).json(result);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// time
|
// time
|
||||||
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
let now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
|||||||
@@ -715,7 +715,7 @@ const updateStatusReservation = (reservationNumber, now, flag) => {
|
|||||||
c_modify_fullname: null,
|
c_modify_fullname: null,
|
||||||
})
|
})
|
||||||
.whereIn('c_reservation_no', reservationNumber);
|
.whereIn('c_reservation_no', reservationNumber);
|
||||||
return result.rowCount;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// update flag
|
// update flag
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user