This commit is contained in:
2022-07-08 16:39:33 +07:00
parent 1f48a2b5c8
commit 6e17edae8e
3 changed files with 70 additions and 17 deletions
@@ -6,14 +6,9 @@
"auditLog": ".71c131f2ce727b13210eef32232709400762e5fb-audit.json",
"files": [
{
"date": 1657083816934,
"name": "2022-07-06-onlinetopup.log",
"hash": "30b451f63da1f932d353c9dc6ee56ed27010fa8b9793e4660cbac42238d8940e"
},
{
"date": 1657159692809,
"name": "2022-07-07-onlinetopup.log",
"hash": "09c139d9a50d9f13fb6a0f7df53ec39ec0d128a6cf604f0b8b3d54c83649a707"
"date": 1657267492554,
"name": "2022-07-08-onlinetopup.log",
"hash": "eb050e1a7fc373dd45fbb3ee982333f4e68d3a957348426026df54964e032f3f"
}
],
"hashType": "sha256"
@@ -12,7 +12,14 @@ var uniqueCode;
const validate = (method) => {
switch (method) {
case "cardHistory":
return [body("data").not().isEmpty().withMessage("Data is required")];
return [
body("data")
.not()
.isEmpty()
.withMessage("Data is required")
.isArray()
.withMessage("Data is invalid request format"),
];
case "history":
return [
body("mid").not().isEmpty().withMessage("MID is required"),
@@ -60,20 +67,38 @@ const cardHistory = async (req, res) => {
}
// parsing data from card
// PARSING DISINI ZEN
let date = new Date((parseInt(data.slice(0,8),16) + 946684800) * 1000)
let nominal = parseInt(data.slice(8, 16), 16)
let mid = data.slice(16, 20)
let tid = data.slice(20,24)
let istopup = parseInt(data.slice(24, 26), 16) == 0 ? 'Topup' : 'Deduct'
let element;
let date;
let nominal;
let mid;
let tid;
let istopup;
let terminalName;
let history = [];
for (let index = 0; index < data.length; index++) {
element = data[index];
date = new Date((parseInt(element.slice(0, 8), 16) + 946684800) * 1000);
nominal = parseInt(element.slice(8, 16), 16);
mid = element.slice(16, 20);
tid = element.slice(20, 24);
istopup = parseInt(element.slice(24, 26), 16) == 0 ? "Topup" : "Deduct";
//Parsing ini di foreach sebanyak list Data req API
// get terminal name
terminalName = await model.getPartnerPartialMIDTID(mid, tid);
terminalName = terminalName ? terminalName.merchant_name : "";
history[index] = {
date: date,
nominal: nominal,
terminal_name: terminalName,
transaction_type: istopup,
};
}
result = {
code: "00",
message: "success",
data: {},
data: history,
};
// log info
@@ -32,6 +32,38 @@ const getPartner = (mid, tid) => {
return result;
};
// GET PARTNER, MERCHANT, TERMINAL FROM TID
const getPartnerPartialMIDTID = (mid, tid) => {
let result = knex
.select(
"t_m_partner.i_partner",
"t_m_partner.c_code as partner_code",
"t_m_partner.c_name as partner_name",
"t_m_merchant.i_merchant",
"t_m_merchant.c_code as merchant_code",
"t_m_merchant.c_name as merchant_name",
"t_m_merchant.e_mid as mid",
"t_m_terminal.i_terminal",
"t_m_terminal.c_code as terminal_code",
"t_m_terminal.c_name as terminal_name",
"t_m_terminal.e_tid as tid"
)
.from("t_m_terminal")
.leftJoin(
"t_m_merchant",
"t_m_terminal.i_merchant",
"t_m_merchant.i_merchant"
)
.leftJoin("t_m_partner", "t_m_merchant.i_partner", "t_m_partner.i_partner")
.whereRaw("SUBSTRING(t_m_merchant.e_mid, 9, 4) = ?", mid)
.whereRaw("SUBSTRING(t_m_terminal.e_tid, 1, 4) = ?", tid)
.where("t_m_terminal.c_status", "A")
.where("t_m_merchant.c_status", "A")
.where("t_m_partner.c_status", "A")
.first();
return result;
};
// HISTORY BY CARD NUMBER
let historyByCardNumber = (mid, tid, cardNumber, startDate, endDate) => {
// let result = knex("trx.t_d_reservation_balance")
@@ -77,5 +109,6 @@ let historyByCardNumber = (mid, tid, cardNumber, startDate, endDate) => {
module.exports = {
getPartner,
getPartnerPartialMIDTID,
historyByCardNumber,
};