mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 10:26:27 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90aaf3f6f6 |
@@ -73,6 +73,11 @@ const validate = (method) => {
|
|||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage('Reservation Number is required'),
|
.withMessage('Reservation Number is required'),
|
||||||
];
|
];
|
||||||
|
case 'cancelReservationValidateV2':
|
||||||
|
return [
|
||||||
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||||
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||||
|
];
|
||||||
case 'cancelReservationV2':
|
case 'cancelReservationV2':
|
||||||
return [
|
return [
|
||||||
body('cancel_reservation_data')
|
body('cancel_reservation_data')
|
||||||
@@ -3130,11 +3135,11 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
// param
|
// param
|
||||||
let { mid, tid, reservation_number } = req.body;
|
let { mid, tid, reservation_number, ref_no } = req.body;
|
||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} [ REQUEST CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ REQUEST CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
req.body
|
req.body
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3150,7 +3155,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3161,7 +3166,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
// log debug
|
// log debug
|
||||||
// proses pengecekkan data partner berdasarkan mid dan tid yang di request, apakah terdaftar di sistem CMS atau tidak
|
// proses pengecekkan data partner berdasarkan mid dan tid yang di request, apakah terdaftar di sistem CMS atau tidak
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE ]: checking partner...`
|
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE-V2 ]: checking partner...`
|
||||||
);
|
);
|
||||||
|
|
||||||
// get partner, merchant, terminal from tid
|
// get partner, merchant, terminal from tid
|
||||||
@@ -3175,21 +3180,85 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let getReservationCanBeCanceled;
|
||||||
|
|
||||||
|
// jika cancelation reservation dilakukan dengan menggunakan ref no
|
||||||
|
if (ref_no) {
|
||||||
|
if (!ref_no) {
|
||||||
|
result = {
|
||||||
|
code: '400',
|
||||||
|
message: 'Ref no is required',
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
|
}
|
||||||
|
|
||||||
// log debug
|
// log debug
|
||||||
// proses pengecekkan status reservation number yang di request
|
// proses pengecekkan status reservation number yang di request
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE ]: getting reservation by reservation number...`
|
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE-V2 ]: getting reservation by ref no...`
|
||||||
|
);
|
||||||
|
|
||||||
|
// get reservation berdasarkan ref_no yang di request
|
||||||
|
getReservationCanBeCanceled =
|
||||||
|
await model.getReservationCanBeCanceledByRefno(ref_no);
|
||||||
|
|
||||||
|
if (!getReservationCanBeCanceled) {
|
||||||
|
result = {
|
||||||
|
code: '440',
|
||||||
|
message: "Ref no doesn't exist.",
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
return res.status(200).json(result);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!reservation_number) {
|
||||||
|
result = {
|
||||||
|
code: '400',
|
||||||
|
message: 'Reservation number is required',
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
// log warn
|
||||||
|
winston.logger.warn(
|
||||||
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
|
result
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.status(200).json(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// log debug
|
||||||
|
// proses pengecekkan status reservation number yang di request
|
||||||
|
winston.logger.debug(
|
||||||
|
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE-V2 ]: getting reservation by reservation number...`
|
||||||
);
|
);
|
||||||
|
|
||||||
// get reservation berdasarkan reservation number yang di request
|
// get reservation berdasarkan reservation number yang di request
|
||||||
let getReservationCanBeCanceled = await model.getReservationCanBeCanceled(
|
getReservationCanBeCanceled = await model.getReservationCanBeCanceled(
|
||||||
reservation_number
|
reservation_number
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -3202,12 +3271,17 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
return res.status(200).json(result);
|
return res.status(200).json(result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let reservationNumber = getReservationCanBeCanceled?.c_reservation_no;
|
||||||
|
let cardNumber = getReservationCanBeCanceled?.c_card_number;
|
||||||
|
let amount = getReservationCanBeCanceled?.i_reservation_amount;
|
||||||
|
|
||||||
// get value global parameter
|
// get value global parameter
|
||||||
let getGlobalParameter = await model.getGlobalParameter();
|
let getGlobalParameter = await model.getGlobalParameter();
|
||||||
@@ -3221,7 +3295,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3238,7 +3312,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3255,7 +3329,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3272,7 +3346,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3296,7 +3370,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3317,7 +3391,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} RESPONSE cancel reservation validate: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3333,7 +3407,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3350,7 +3424,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
|
|
||||||
// log warn
|
// log warn
|
||||||
winston.logger.warn(
|
winston.logger.warn(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3377,7 +3451,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
// log debug
|
// log debug
|
||||||
// process enkripsi data reservasi dengan AES yang nanti nya akan di kirim ke end point reservation api untuk menyimpan data reservasi
|
// process enkripsi data reservasi dengan AES yang nanti nya akan di kirim ke end point reservation api untuk menyimpan data reservasi
|
||||||
winston.logger.debug(
|
winston.logger.debug(
|
||||||
`${uniqueCode} [ PROCESSING RESERVATION-VALIDATE-V2 ] encrypting data reservation: ${JSON.stringify(
|
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE-V2 ] encrypting data reservation: ${JSON.stringify(
|
||||||
reservationData
|
reservationData
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3390,12 +3464,17 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
message: 'reservation can be canceled.',
|
message: 'reservation can be canceled.',
|
||||||
data: {
|
data: {
|
||||||
cancel_reservation_data: hash,
|
cancel_reservation_data: hash,
|
||||||
|
cancel_reservation_detail: {
|
||||||
|
reservation_number: reservationNumber,
|
||||||
|
card_number: cardNumber,
|
||||||
|
amount: amount,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
||||||
result
|
result
|
||||||
)}`
|
)}`
|
||||||
);
|
);
|
||||||
@@ -3404,7 +3483,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// create log
|
// create log
|
||||||
winston.logger.error(
|
winston.logger.error(
|
||||||
`[ RESPONSE CANCEL-RESERVATION-VALIDATE ]: 500 internal server error - backend server | ${error.message}`
|
`[ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: 500 internal server error - backend server | ${error.message}`
|
||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
|
|||||||
@@ -378,6 +378,14 @@ const getReservationCanBeCanceled = (reservation_number) => {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// GET RESERVATION PENDING AND NOT YET PAYMENT RECON
|
||||||
|
const getReservationCanBeCanceledByRefno = (ref_no) => {
|
||||||
|
let result = knex('trx.t_d_reservation_balance')
|
||||||
|
.where('c_ref_no', ref_no)
|
||||||
|
.first();
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
const insertReservationNumber = (reservationNumber) => {
|
const insertReservationNumber = (reservationNumber) => {
|
||||||
let result = knex('trx.t_d_reservation_no_validate')
|
let result = knex('trx.t_d_reservation_no_validate')
|
||||||
.insert({
|
.insert({
|
||||||
@@ -545,6 +553,7 @@ module.exports = {
|
|||||||
createReserveBalanceLog,
|
createReserveBalanceLog,
|
||||||
getReservationWithPendingAndInProgressStatus,
|
getReservationWithPendingAndInProgressStatus,
|
||||||
getReservationCanBeCanceled,
|
getReservationCanBeCanceled,
|
||||||
|
getReservationCanBeCanceledByRefno,
|
||||||
insertReservationNumber,
|
insertReservationNumber,
|
||||||
cancelReservation,
|
cancelReservation,
|
||||||
deleteReservationNumberValidate,
|
deleteReservationNumberValidate,
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ router.post(
|
|||||||
router.post(
|
router.post(
|
||||||
'/reservation/cancel/validate/v2',
|
'/reservation/cancel/validate/v2',
|
||||||
auth.authenticateToken,
|
auth.authenticateToken,
|
||||||
controller.validate('cancelReservation'),
|
controller.validate('cancelReservationValidateV2'),
|
||||||
controller.cancelReservationValidateV2
|
controller.cancelReservationValidateV2
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -99,11 +99,11 @@ router.post(
|
|||||||
controller.cancelReservationV2
|
controller.cancelReservationV2
|
||||||
);
|
);
|
||||||
|
|
||||||
router.post(
|
// router.post(
|
||||||
'/reservation/cancel/v2.1',
|
// '/reservation/cancel/v2.1',
|
||||||
auth.authenticateToken,
|
// auth.authenticateToken,
|
||||||
controller.validate('cancelReservation'),
|
// controller.validate('cancelReservation'),
|
||||||
controller.cancelReservationV2_1
|
// controller.cancelReservationV2_1
|
||||||
);
|
// );
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
Reference in New Issue
Block a user