|
|
|
@@ -73,6 +73,11 @@ const validate = (method) => {
|
|
|
|
|
.isEmpty()
|
|
|
|
|
.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':
|
|
|
|
|
return [
|
|
|
|
|
body('cancel_reservation_data')
|
|
|
|
@@ -3130,11 +3135,11 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
let result = {};
|
|
|
|
|
|
|
|
|
|
// param
|
|
|
|
|
let { mid, tid, reservation_number } = req.body;
|
|
|
|
|
let { mid, tid, reservation_number, ref_no } = req.body;
|
|
|
|
|
|
|
|
|
|
// log info
|
|
|
|
|
winston.logger.info(
|
|
|
|
|
`${uniqueCode} [ REQUEST CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ REQUEST CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
req.body
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3150,7 +3155,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3161,7 +3166,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
// log debug
|
|
|
|
|
// proses pengecekkan data partner berdasarkan mid dan tid yang di request, apakah terdaftar di sistem CMS atau tidak
|
|
|
|
|
winston.logger.debug(
|
|
|
|
|
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE ]: checking partner...`
|
|
|
|
|
`${uniqueCode} [ PROCESSING CANCEL-RESERVATION-VALIDATE-V2 ]: checking partner...`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// get partner, merchant, terminal from tid
|
|
|
|
@@ -3175,40 +3180,109 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${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 ]: getting reservation by reservation number...`
|
|
|
|
|
);
|
|
|
|
|
let getReservationCanBeCanceled;
|
|
|
|
|
|
|
|
|
|
// get reservation berdasarkan reservation number yang di request
|
|
|
|
|
let getReservationCanBeCanceled = await model.getReservationCanBeCanceled(
|
|
|
|
|
reservation_number
|
|
|
|
|
);
|
|
|
|
|
// jika cancelation reservation dilakukan dengan menggunakan ref no
|
|
|
|
|
if (ref_no) {
|
|
|
|
|
if (!ref_no) {
|
|
|
|
|
result = {
|
|
|
|
|
code: '400',
|
|
|
|
|
message: 'Ref no is required',
|
|
|
|
|
data: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!getReservationCanBeCanceled) {
|
|
|
|
|
result = {
|
|
|
|
|
code: '414',
|
|
|
|
|
message: "Reservation doesn't exist.",
|
|
|
|
|
data: {},
|
|
|
|
|
};
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${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 ref no...`
|
|
|
|
|
);
|
|
|
|
|
return res.status(200).json(result);
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
getReservationCanBeCanceled = await model.getReservationCanBeCanceled(
|
|
|
|
|
reservation_number
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!getReservationCanBeCanceled) {
|
|
|
|
|
result = {
|
|
|
|
|
code: '414',
|
|
|
|
|
message: "Reservation doesn't exist.",
|
|
|
|
|
data: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
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
|
|
|
|
|
let getGlobalParameter = await model.getGlobalParameter();
|
|
|
|
|
// check value global parameter
|
|
|
|
@@ -3221,7 +3295,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3238,7 +3312,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3255,7 +3329,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3272,7 +3346,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3296,7 +3370,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3317,7 +3391,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} RESPONSE cancel reservation validate: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3333,7 +3407,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3350,7 +3424,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
|
|
|
|
|
// log warn
|
|
|
|
|
winston.logger.warn(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3377,7 +3451,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
// log debug
|
|
|
|
|
// process enkripsi data reservasi dengan AES yang nanti nya akan di kirim ke end point reservation api untuk menyimpan data reservasi
|
|
|
|
|
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
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3390,12 +3464,17 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
message: 'reservation can be canceled.',
|
|
|
|
|
data: {
|
|
|
|
|
cancel_reservation_data: hash,
|
|
|
|
|
cancel_reservation_detail: {
|
|
|
|
|
reservation_number: reservationNumber,
|
|
|
|
|
card_number: cardNumber,
|
|
|
|
|
amount: amount,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// log info
|
|
|
|
|
winston.logger.info(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE ]: ${JSON.stringify(
|
|
|
|
|
`${uniqueCode} [ RESPONSE CANCEL-RESERVATION-VALIDATE-V2 ]: ${JSON.stringify(
|
|
|
|
|
result
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
@@ -3404,7 +3483,7 @@ const cancelReservationValidateV2 = async (req, res) => {
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// create log
|
|
|
|
|
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({
|
|
|
|
|