From 56cbc627a2fbdf7fa4346b515466c05e92c9855d Mon Sep 17 00:00:00 2001 From: Mohamad Ihsan Date: Fri, 3 Mar 2023 16:10:17 +0700 Subject: [PATCH] update --- .../loadbalance/loadbalance.controller.js | 55 ++++++++++++++----- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/application/modules/loadbalance/loadbalance.controller.js b/application/modules/loadbalance/loadbalance.controller.js index 5711cb1..7d56f24 100644 --- a/application/modules/loadbalance/loadbalance.controller.js +++ b/application/modules/loadbalance/loadbalance.controller.js @@ -508,23 +508,48 @@ const loadingBalanceRequest = async (req, res) => { ); // update status to in progress - await model.updateStatusReservation(reservationNumberTemp, now, flag); - - result = { - code: '00', - message: 'reservation exists', - data: { - amount: amountTopup, - total_reservation: totalReservation, - reservation_number: reservationNumber, - }, - }; - - // log info - winston.logger.info( - `${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(result)}` + let updateStatusReservation = await model.updateStatusReservation( + reservationNumberTemp, + now, + flag ); + if (updateStatusReservation) { + result = { + code: '00', + message: 'reservation exists', + data: { + amount: amountTopup, + total_reservation: totalReservation, + reservation_number: reservationNumber, + }, + }; + + // log info + winston.logger.info( + `${uniqueCode} RESPONSE load balance validate: ${JSON.stringify( + result + )}` + ); + } else { + result = { + code: '434', + message: '[434] Failed, please try again later', + data: { + amount: amountTopup, + total_reservation: totalReservation, + reservation_number: reservationNumber, + }, + }; + + // log info + winston.logger.info( + `${uniqueCode} RESPONSE load balance validate: ${JSON.stringify( + result + )}` + ); + } + return res.json(result); } catch (error) { // create log