mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:46:28 +00:00
update
This commit is contained in:
@@ -9,6 +9,11 @@
|
||||
"date": 1657267492554,
|
||||
"name": "2022-07-08-onlinetopup.log",
|
||||
"hash": "eb050e1a7fc373dd45fbb3ee982333f4e68d3a957348426026df54964e032f3f"
|
||||
},
|
||||
{
|
||||
"date": 1657318223033,
|
||||
"name": "2022-07-09-onlinetopup.log",
|
||||
"hash": "0b91d47db406a098e198aa5e145df01f47f203c04a28b151f50a3bbb7deff454"
|
||||
}
|
||||
],
|
||||
"hashType": "sha256"
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
const { param, body, validationResult } = require("express-validator");
|
||||
const helper = require("../../helpers/helper");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const model = require("./dongleorder.model");
|
||||
const moment = require("moment");
|
||||
moment.locale("id");
|
||||
|
||||
var result = {};
|
||||
var uniqueCode;
|
||||
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case "dongleOrderUpdate":
|
||||
return [
|
||||
body("dongle_id").not().isEmpty().withMessage("Dongle ID is required"),
|
||||
];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
// GET DONGLE ORDER
|
||||
const getDongleOrder = async (req, res) => {
|
||||
try {
|
||||
|
||||
uniqueCode = await helper.getUniqueCode();
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} get RO...`);
|
||||
|
||||
// get RO
|
||||
let getRO = await model.getRO();
|
||||
if (!getRO) {
|
||||
result = {
|
||||
code: "422",
|
||||
message: "data doesn't exists'",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE get RO and dongle order: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "success",
|
||||
data: getRO,
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} RESPONSE get RO and dongle order: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// UPDATE DONGLE ORDER
|
||||
const updateDongleOrder = async (req, res) => {
|
||||
try {
|
||||
// param
|
||||
let {
|
||||
dongle_id, status
|
||||
} = req.body;
|
||||
|
||||
uniqueCode = await helper.getUniqueCode();
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} REQUEST update dongle order: ${JSON.stringify(req.body)}`
|
||||
);
|
||||
|
||||
// check validator
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: "400",
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE update dongle order: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
// time
|
||||
let now = moment().format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
// log debug
|
||||
winston.logger.debug(`${uniqueCode} updating dongle order...`);
|
||||
|
||||
let data = {
|
||||
c_status: status == "G" ? "G" : "C",
|
||||
c_status_name: status == "G" ? "GENERATED" : "CREATED",
|
||||
d_modify: now,
|
||||
}
|
||||
|
||||
// get partner, merchant, terminal from tid
|
||||
let updateDongleOrderStatus = await model.updateDongleOrderStatus(data, dongle_id);
|
||||
if (!updateDongleOrderStatus) {
|
||||
result = {
|
||||
code: "423",
|
||||
message: "update failed",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE update dongle order: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
}
|
||||
|
||||
result = {
|
||||
code: "00",
|
||||
message: "updated successfully",
|
||||
data: {},
|
||||
};
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} RESPONSE update dongle order: ${JSON.stringify(result)}`
|
||||
);
|
||||
|
||||
return res.status(200).json(result);
|
||||
} catch (error) {
|
||||
// create log
|
||||
winston.logger.error(
|
||||
`500 internal server error - backend server | ${error.message}`
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
code: "500",
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validate,
|
||||
getDongleOrder,
|
||||
updateDongleOrder,
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
const knex = require("../../../infrastructure/database/knex");
|
||||
|
||||
// GET RO
|
||||
const getRO = () => {
|
||||
let result = knex("trx.t_d_dongle_order")
|
||||
.select("trx.t_d_dongle_order.*")
|
||||
.leftJoin(
|
||||
"trx.t_d_request_order",
|
||||
"trx.t_d_dongle_order.i_request_order",
|
||||
"trx.t_d_request_order.i_request_order"
|
||||
)
|
||||
.where("trx.t_d_request_order.c_status", "!=", "X");
|
||||
return result;
|
||||
};
|
||||
|
||||
// UPDATE DONGLE ORDER STATUS
|
||||
const updateDongleOrderStatus = (data, dongleID) => {
|
||||
let result = knex("trx.t_d_dongle_order")
|
||||
.update(data)
|
||||
.where("c_dongle_id", dongleID);
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getRO,
|
||||
updateDongleOrderStatus,
|
||||
};
|
||||
@@ -490,7 +490,7 @@ const loadingBalance = async (req, res) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -516,7 +516,7 @@ const loadingBalance = async (req, res) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -542,7 +542,7 @@ const loadingBalance = async (req, res) => {
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -570,7 +570,7 @@ const loadingBalance = async (req, res) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -596,7 +596,7 @@ const loadingBalance = async (req, res) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -703,7 +703,7 @@ const loadingBalance = async (req, res) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -885,7 +885,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -911,7 +911,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -937,7 +937,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log info
|
||||
winston.logger.info(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -965,7 +965,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -991,7 +991,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -1098,7 +1098,7 @@ const loadingBalanceInsert = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance insert: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
@@ -1239,7 +1239,7 @@ const loadingBalanceUpdate = async (param) => {
|
||||
|
||||
// log warn
|
||||
winston.logger.warn(
|
||||
`${uniqueCode} RESPONSE load balance validate: ${JSON.stringify(
|
||||
`${uniqueCode} RESPONSE load balance update: ${JSON.stringify(
|
||||
result
|
||||
)}`
|
||||
);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const express = require("express");
|
||||
const router = express.Router();
|
||||
const auth = require("../middlewares/jwt.middleware");
|
||||
const controller = require("../modules/dongleorder/dongleorder.controller");
|
||||
|
||||
router.get(
|
||||
"/dongleorder/ro",
|
||||
auth.authenticateToken,
|
||||
controller.getDongleOrder
|
||||
);
|
||||
|
||||
router.put(
|
||||
"/dongleorder/update",
|
||||
auth.authenticateToken,
|
||||
controller.validate("dongleOrderUpdate"),
|
||||
controller.updateDongleOrder
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
+5
-5
@@ -3,7 +3,7 @@
|
||||
01 Success Without Write to the card
|
||||
02 Success without reservation pending or in progress status
|
||||
03 Success with reservation pending or in progress status
|
||||
04 Success. Transaction has been recon
|
||||
04 Success. Transaction has been recon previously
|
||||
|
||||
# ERROR MESSAGE CODE TOPUP ONLINE SERVICE
|
||||
400 Bad Request Parameter or Validation Parameter Error
|
||||
@@ -22,11 +22,11 @@
|
||||
419 load balance doesn't exist
|
||||
420 your card number has incomplete transaction. Please unload your balance!
|
||||
421 your card number has some pending transaction. Please finished it!
|
||||
422 history doesn't exist
|
||||
422 data doesn't exist
|
||||
423 update/insert failed
|
||||
424 Duplicate Ref No
|
||||
425 Total amount is different
|
||||
426 Partner doesn't exists
|
||||
424 duplicate Ref No
|
||||
425 total amount is different
|
||||
426 partner doesn't exists
|
||||
427 transaction doesn't exists
|
||||
428 failed recon. The other transaction with same data is running
|
||||
500 Error Catch
|
||||
|
||||
@@ -4,6 +4,7 @@ const cors = require("cors");
|
||||
const helper = require("./application/helpers/helper");
|
||||
const winston = require("./application/helpers/winston.logger");
|
||||
const authRoute = require("./application/routes/auth.routes");
|
||||
const dongleOrderRoute = require("./application/routes/dongleorder.routes");
|
||||
const reservationRoute = require("./application/routes/reservebalance.routes");
|
||||
const loadBalanceRoute = require("./application/routes/loadbalance.routes");
|
||||
const hsmRoute = require("./application/routes/hsm.routes");
|
||||
@@ -38,6 +39,7 @@ app.get("/", (req, res) => {
|
||||
});
|
||||
|
||||
app.use("/api/", authRoute);
|
||||
app.use("/api/", dongleOrderRoute);
|
||||
app.use("/api/", historyRoute);
|
||||
app.use("/api/", hsmRoute);
|
||||
app.use("/api/", loadBalanceRoute);
|
||||
|
||||
Reference in New Issue
Block a user