mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:46:28 +00:00
update
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
# document error code saved on error_code file in docs folder
|
||||||
|
|
||||||
|
# online topup log transaction saved on application/logs folder.
|
||||||
|
## In DEVELOPMENT environment, debugging log, online topup log, and error log will be active.
|
||||||
|
## In PRODUCTION environment, online topup log and error log will be active.
|
||||||
|
# debugging log contains log all validation checks step by step, request data from client, error log, and response data to client
|
||||||
|
# online topup log contains request data from client, error log, and response data to client
|
||||||
|
# error log contains only error system or error service
|
||||||
@@ -57,8 +57,7 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
uniqueCode = await helper.getUniqueCode();
|
uniqueCode = await helper.getUniqueCode();
|
||||||
|
|
||||||
// param
|
// param
|
||||||
let { mid, tid, card_number, uid, balance, balance_before, flag } =
|
let { mid, tid, card_number, uid, balance, flag } = req.body;
|
||||||
req.body;
|
|
||||||
|
|
||||||
// log info
|
// log info
|
||||||
winston.logger.info(
|
winston.logger.info(
|
||||||
@@ -171,11 +170,22 @@ const loadingBalanceRequest = async (req, res) => {
|
|||||||
mid,
|
mid,
|
||||||
tid,
|
tid,
|
||||||
balance,
|
balance,
|
||||||
balance_before,
|
|
||||||
uniqueCode
|
uniqueCode
|
||||||
);
|
);
|
||||||
|
|
||||||
if (insertUpdate) {
|
if (insertUpdate) {
|
||||||
|
// log debug
|
||||||
|
winston.logger.debug(`${uniqueCode} updating flag to server...`);
|
||||||
|
|
||||||
|
// update flag from Server
|
||||||
|
await model.updateFlag(
|
||||||
|
now,
|
||||||
|
card_number,
|
||||||
|
uid.toUpperCase(),
|
||||||
|
balance,
|
||||||
|
flag
|
||||||
|
);
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
code: "01",
|
code: "01",
|
||||||
message: "your card number has been cleared successfully",
|
message: "your card number has been cleared successfully",
|
||||||
@@ -421,7 +431,6 @@ const loadingBalance = async (req, res) => {
|
|||||||
write_status,
|
write_status,
|
||||||
uid,
|
uid,
|
||||||
balance,
|
balance,
|
||||||
balance_before,
|
|
||||||
flag,
|
flag,
|
||||||
unique_code,
|
unique_code,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
@@ -620,6 +629,7 @@ const loadingBalance = async (req, res) => {
|
|||||||
c_tid: getPartner ? getPartner.tid : null,
|
c_tid: getPartner ? getPartner.tid : null,
|
||||||
c_card_number: card_number,
|
c_card_number: card_number,
|
||||||
i_topup_amount: amount,
|
i_topup_amount: amount,
|
||||||
|
m_balance: balance,
|
||||||
c_return_sap: null,
|
c_return_sap: null,
|
||||||
i_load_balance_no_seq: loadBalanceNoSequence,
|
i_load_balance_no_seq: loadBalanceNoSequence,
|
||||||
c_idm: uid,
|
c_idm: uid,
|
||||||
@@ -726,7 +736,7 @@ const loadingBalance = async (req, res) => {
|
|||||||
c_card_number: card_number,
|
c_card_number: card_number,
|
||||||
c_source: "CMS - HSM",
|
c_source: "CMS - HSM",
|
||||||
c_location: null,
|
c_location: null,
|
||||||
m_balance_before: balance_before,
|
m_balance_before: balance - amount > 0 ? balance - amount : 0,
|
||||||
m_amount: amount,
|
m_amount: amount,
|
||||||
m_balance_after: balance,
|
m_balance_after: balance,
|
||||||
j_new_data: { data: data, detail: detail },
|
j_new_data: { data: data, detail: detail },
|
||||||
@@ -859,7 +869,6 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
mid,
|
mid,
|
||||||
tid,
|
tid,
|
||||||
balance,
|
balance,
|
||||||
balance_before,
|
|
||||||
uniqueCode
|
uniqueCode
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
@@ -955,6 +964,7 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
c_tid: getPartner ? getPartner.tid : null,
|
c_tid: getPartner ? getPartner.tid : null,
|
||||||
c_card_number: dataReservation.c_card_number,
|
c_card_number: dataReservation.c_card_number,
|
||||||
i_topup_amount: dataLoadingBalance.i_topup_amount,
|
i_topup_amount: dataLoadingBalance.i_topup_amount,
|
||||||
|
m_balance: dataLoadingBalance.m_balance,
|
||||||
c_return_sap: null,
|
c_return_sap: null,
|
||||||
i_load_balance_no_seq: loadBalanceNoSequence,
|
i_load_balance_no_seq: loadBalanceNoSequence,
|
||||||
c_status: "A",
|
c_status: "A",
|
||||||
@@ -996,7 +1006,7 @@ const updateReservationAndLoadingBalance = async (
|
|||||||
c_card_number: dataReservation.c_card_number,
|
c_card_number: dataReservation.c_card_number,
|
||||||
c_source: "CMS - HSM",
|
c_source: "CMS - HSM",
|
||||||
c_location: null,
|
c_location: null,
|
||||||
m_balance_before: balance_before,
|
m_balance_before: dataLoadingBalance.m_balance,
|
||||||
m_amount: dataLoadingBalance.i_topup_amount,
|
m_amount: dataLoadingBalance.i_topup_amount,
|
||||||
m_balance_after: balance,
|
m_balance_after: balance,
|
||||||
j_new_data: { data: data, detail: dataLoadingBalanceDetail },
|
j_new_data: { data: data, detail: dataLoadingBalanceDetail },
|
||||||
|
|||||||
@@ -179,8 +179,6 @@ const reservation = async (req, res) => {
|
|||||||
getAccumulationBalanceInThisMonthFromCardHistory.accumulation_balance;
|
getAccumulationBalanceInThisMonthFromCardHistory.accumulation_balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("accumulatedBalance: " + accumulatedBalance);
|
|
||||||
|
|
||||||
// validate max topup per month
|
// validate max topup per month
|
||||||
const getMaxTopupPerMonth = await model.getMaxTopupPerMonth();
|
const getMaxTopupPerMonth = await model.getMaxTopupPerMonth();
|
||||||
if (getMaxTopupPerMonth.c_value) {
|
if (getMaxTopupPerMonth.c_value) {
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ const getReservationWithFlag = (cardNumber, time) => {
|
|||||||
let result = knex("trx.t_d_reservation_balance")
|
let result = knex("trx.t_d_reservation_balance")
|
||||||
.count("* as total_reservation")
|
.count("* as total_reservation")
|
||||||
.where("c_card_number", cardNumber)
|
.where("c_card_number", cardNumber)
|
||||||
.where("c_status", "P")
|
.whereIn("c_status", ["P", "I"])
|
||||||
.where("d_expired", ">=", time)
|
.where("d_expired", ">=", time)
|
||||||
.whereNotNull("c_flag")
|
.whereNotNull("c_flag")
|
||||||
.first();
|
.first();
|
||||||
|
|||||||
Reference in New Issue
Block a user