Compare commits

..

88 Commits

Author SHA1 Message Date
ihsan c8f01db5e9 update 2023-03-03 17:33:01 +07:00
ihsan 1be5cc8d0c update 2023-03-03 17:31:43 +07:00
ihsan 352ec2822f update 2023-03-03 17:31:02 +07:00
ihsan 9910d4d834 update 2023-03-03 17:28:29 +07:00
ihsan a2eb984658 update 2023-03-03 17:25:24 +07:00
ihsan eac57a3821 update 2023-03-03 17:21:07 +07:00
ihsan f4451aaea2 update 2023-03-03 17:11:50 +07:00
ihsan 837d1c5d77 update 2023-03-03 16:33:20 +07:00
ihsan 74825d277b update 2023-03-03 16:26:01 +07:00
ihsan 8c231e9901 update 2023-03-03 16:16:14 +07:00
ihsan f7c5cf33f6 update 2023-03-03 16:03:34 +07:00
ihsan 870d8aea46 skip check amount topup 2023-02-27 12:40:48 +07:00
ihsan b46d3a5b25 update 2023-02-24 16:53:38 +07:00
ihsan 5408639d80 update reservation amount total 2023-02-24 15:56:52 +07:00
ihsan 9b2ab48e99 update 2023-02-22 10:24:24 +07:00
ihsan a35492c124 update 2023-02-22 08:20:55 +07:00
ihsan e1f0c60b37 update 2023-02-22 01:24:46 +07:00
ihsan 16afd42876 update 2023-02-22 00:59:36 +07:00
ihsan 3722be6eeb update 2023-02-22 00:44:59 +07:00
ihsan 493f131779 update 2023-02-22 00:36:24 +07:00
ihsan f10ff80284 update 2023-02-22 00:32:01 +07:00
ihsan f30ee86552 update 2023-02-22 00:26:49 +07:00
ihsan e8de33b663 update 2023-02-22 00:13:41 +07:00
ihsan 68ebfb0ac2 update 2023-02-21 20:02:33 +07:00
ihsan 96c46ad49c update 2023-02-21 19:56:53 +07:00
ihsan 10e38babcd update 2023-02-21 19:54:06 +07:00
ihsan 8bc68493cf update 2023-02-21 19:49:42 +07:00
ihsan 2b1b14548a update 2023-02-21 19:46:28 +07:00
ihsan 240bb5fa17 update 2023-02-21 19:44:37 +07:00
ihsan 7676ec54ef update 2023-02-21 19:42:22 +07:00
ihsan de0a8847b5 update 2023-02-21 19:39:57 +07:00
ihsan 4df41a426c update 2023-02-21 19:36:51 +07:00
ihsan 3401e425b4 updaye 2023-02-21 19:33:43 +07:00
ihsan 0d29175942 update 2023-02-21 19:19:07 +07:00
ihsan 4f03433bb2 update 2023-02-21 19:17:07 +07:00
ihsan 1df5f97543 update 2023-02-21 19:08:11 +07:00
ihsan a222714bcb update 2023-02-21 19:07:02 +07:00
ihsan 2249bbbbaf update 2023-02-21 19:01:02 +07:00
ihsan 16fbfdcae1 update 2023-02-21 18:02:58 +07:00
ihsan 6b5f92e597 update 2023-02-21 14:52:28 +07:00
ihsan baf99a975d update bugs 2023-02-21 14:40:05 +07:00
ihsan 70b9ef78cb update 2023-02-20 23:54:54 +07:00
ihsan 4169b40e97 update 2023-02-20 23:52:36 +07:00
ihsan 3566f63bea update 2023-02-20 23:50:21 +07:00
ihsan 066fd49173 update 2023-02-20 23:49:00 +07:00
ihsan 2c0ffbd9d6 update 2023-02-20 23:47:30 +07:00
ihsan ee46232c7a update 2023-02-20 23:46:38 +07:00
ihsan 15131cebb1 update 2023-02-20 23:31:42 +07:00
ihsan 6ff785de5a Merge branch 'nuranggi' into feature_fraud 2023-02-20 23:26:52 +07:00
Nuranggi Hermawan 8e997346d2 UPdate 2023-02-20 23:25:33 +07:00
Nuranggi Hermawan 80dda817fb Update 2023-02-20 23:24:55 +07:00
Nuranggi Hermawan 410ef5ac53 Update 2023-02-20 23:24:07 +07:00
ihsan d9d5be8921 update 2023-02-20 23:24:01 +07:00
ihsan 574092e015 update 2023-02-20 23:18:09 +07:00
ihsan 5ece7912f4 update 2023-02-20 23:15:38 +07:00
ihsan 2540b1c6c0 update 2023-02-20 23:12:29 +07:00
ihsan 4feb7a7724 update 2023-02-20 23:10:14 +07:00
ihsan 4994278078 UPDATE 2023-02-20 23:09:31 +07:00
ihsan c6488f7f69 update 2023-02-20 23:06:20 +07:00
ihsan f0bbf54afc update 2023-02-20 22:53:16 +07:00
ihsan 7c6ab450be update 2023-02-20 22:51:09 +07:00
ihsan 1524d643c6 update 2023-02-20 22:49:18 +07:00
ihsan 36b61697dd update 2023-02-20 22:46:25 +07:00
ihsan 8366d9b38b update 2023-02-20 22:42:35 +07:00
ihsan ed7e0ce127 update 2023-02-20 22:39:46 +07:00
ihsan 8d1e2075c3 update 2023-02-20 22:38:24 +07:00
ihsan 5df52be111 update 2023-02-20 22:37:15 +07:00
ihsan 6e0627fb86 update 2023-02-20 22:34:40 +07:00
ihsan 0235cdb7c0 update 2023-02-20 22:31:14 +07:00
ihsan a64c38b928 update 2023-02-20 22:27:40 +07:00
ihsan 99f004adf2 update 2023-02-20 22:22:55 +07:00
Nuranggi Hermawan 3e5d73dd56 Merge branch 'feature_fraud' of https://github.com/mohamadihsan/topuponline into nuranggi 2023-02-20 22:18:19 +07:00
Nuranggi Hermawan 4481079289 Update 2023-02-20 22:18:02 +07:00
ihsan 9bc1260bc0 update 2023-02-20 22:13:50 +07:00
ihsan df8ad92eba update 2023-02-20 22:10:55 +07:00
ihsan 3b8d9d20ff update merge 2023-02-20 22:08:03 +07:00
Nuranggi Hermawan 5197966807 Udpate 2023-02-20 22:06:22 +07:00
ihsan 966c7b1f60 update 2023-02-20 21:49:33 +07:00
ihsan 002f1375e4 merge 2023-02-20 21:39:20 +07:00
ihsan ada8358c07 merge 2023-02-20 21:37:17 +07:00
Nuranggi Hermawan b587640684 Update 2023-02-20 21:35:43 +07:00
Nuranggi Hermawan 7d56ebbe77 Update 2023-02-20 21:32:12 +07:00
Nuranggi Hermawan 015832c683 Update 2023-02-20 21:23:47 +07:00
Nuranggi Hermawan 79a5c5951b Update 2023-02-20 21:19:59 +07:00
ihsan c54a030519 update fraud 2023-02-20 21:16:12 +07:00
Nuranggi Hermawan 775b36cfd2 Update 2023-02-20 21:03:02 +07:00
ihsan b796bfdd5c update 2023-02-20 17:15:09 +07:00
ihsan 25f66afa7b change update status to in progress to last statement 2023-02-14 06:26:04 +07:00
4 changed files with 1195 additions and 629 deletions
File diff suppressed because it is too large Load Diff
@@ -72,8 +72,33 @@ const getReservationPending = (cardNumber, time, flag) => {
// .where("d_expired", ">=", time) // .where("d_expired", ">=", time)
.where(function () { .where(function () {
this.orWhere('c_flag', flag).orWhere('c_flag', '-1'); this.orWhere('c_flag', flag).orWhere('c_flag', '-1');
}) });
.orderBy('i_reservation_amount', 'asc');
return result;
};
const getReservationPendingV2 = (cardNumber, time, flag) => {
let result = knex('trx.t_d_reservation_balance')
// .sum("i_reservation_amount as total_reservation_amount")
// .count("* as total_reservation")
.select(
'i_reservation_amount',
'c_reservation_no',
'c_flag',
'd_reservation',
'c_ref_no',
'c_card_number',
'c_status'
)
.where('c_card_number', cardNumber)
.whereIn('c_status', ['P', 'I'])
// .where("d_expired", ">=", time)
.whereRaw(
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
)
.where(function () {
this.orWhere('c_flag', flag).orWhere('c_flag', '-1');
});
return result; return result;
}; };
@@ -96,6 +121,28 @@ const getReservationPendingWithFlagCounter = (cardNumber, time, flag) => {
return result; return result;
}; };
// GET RESERVATION PENDING WITH COMPARE FLAG COUNTER
const getReservationPendingWithFlagCounterV2 = (cardNumber, time, flag) => {
let result = knex('trx.t_d_reservation_balance')
// .sum("i_reservation_amount as total_reservation_amount")
// .count("* as total_reservation")
.select(
'i_reservation_amount',
'c_reservation_no',
'c_flag',
'c_load_balance_no'
)
.where('c_card_number', cardNumber)
.whereIn('c_status', ['P', 'I'])
.whereRaw('??::INT < ??', ['c_flag', parseInt(flag)])
.whereRaw(
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
)
// .where("d_expired", ">=", time)
.where('c_flag', '!=', '-1');
return result;
};
// GET RESERVATION PENDING WITH FLAG // GET RESERVATION PENDING WITH FLAG
const getReservationPendingWithFlag = (cardNumber, time) => { const getReservationPendingWithFlag = (cardNumber, time) => {
let result = knex('trx.t_d_reservation_balance') let result = knex('trx.t_d_reservation_balance')
@@ -108,6 +155,21 @@ const getReservationPendingWithFlag = (cardNumber, time) => {
return result; return result;
}; };
// GET RESERVATION PENDING WITH FLAG
const getReservationPendingWithFlagV2 = (cardNumber, time) => {
let result = knex('trx.t_d_reservation_balance')
// .sum("i_reservation_amount as total_reservation_amount")
// .count("* as total_reservation")
.select('i_reservation_amount', 'c_reservation_no', 'c_flag')
.where('c_card_number', cardNumber)
.whereIn('c_status', ['P', 'I'])
.whereRaw(
`c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud tdf WHERE tdf.c_status = 'A' AND tdf.c_card_number = '${cardNumber}')`
)
.whereNotNull('c_flag_code');
return result;
};
// GET BI REGULATION STATUS FROM GLOBAL PARAMETER // GET BI REGULATION STATUS FROM GLOBAL PARAMETER
const getBIRegulationStatus = () => { const getBIRegulationStatus = () => {
let result = knex('t_m_global_parameter') let result = knex('t_m_global_parameter')
@@ -217,7 +279,7 @@ const insertLoadingBalance = async (
balance, balance,
flag flag
) => { ) => {
await knex return await knex
.transaction((trx) => { .transaction((trx) => {
knex('trx.t_d_load_balance') knex('trx.t_d_load_balance')
.transacting(trx) .transacting(trx)
@@ -321,7 +383,7 @@ const insertLoadingBalance = async (
}) })
.then((result) => { .then((result) => {
// console.log(result); // console.log(result);
return result; return result.rowCount;
}) })
.catch((error) => { .catch((error) => {
console.log(error.message); console.log(error.message);
@@ -539,7 +601,7 @@ const updateReservationAndLoadingBalance = async (
now, now,
flag flag
) => { ) => {
await knex return await knex
.transaction((trx) => { .transaction((trx) => {
knex('trx.t_d_load_balance') knex('trx.t_d_load_balance')
.transacting(trx) .transacting(trx)
@@ -600,7 +662,7 @@ const updateReservationAndLoadingBalance = async (
}) })
.then((result) => { .then((result) => {
// console.log(result); // console.log(result);
return result; return result.rowCount;
}) })
.catch((error) => { .catch((error) => {
console.log(error.message); console.log(error.message);
@@ -641,11 +703,12 @@ const getLastLoadingBalanceDetailFlag = (loadBalanceId) => {
}; };
// update // update
const updateStatusReservation = (reservationNumber, now) => { const updateStatusReservation = (reservationNumber, now, flag) => {
let result = knex('trx.t_d_reservation_balance') let result = knex('trx.t_d_reservation_balance')
.update({ .update({
c_status: 'I', c_status: 'I',
c_status_name: 'IN PROGRESS', c_status_name: 'IN PROGRESS',
c_flag: flag,
d_modify: now, d_modify: now,
i_modify: null, i_modify: null,
c_modify_username: null, c_modify_username: null,
@@ -723,16 +786,248 @@ const insertLoadBalanceNumber = (loadBalanceNumber) => {
return result; return result;
}; };
// GET TOPUP PARTIAL STATUS FROM GLOBAL PARAMETER // GET RESERVATION PENDING WITHOUT FRAUD
const getTopupPartialStatus = () => { const getReservationPendingWithoutFraud = (
let result = knex('t_m_global_parameter') cardNumber,
.select('c_value') flag,
.where('c_code', 'HSM_TOPUP_PARTIAL_STAT') reservationNumber = []
.where('c_status', 'A') ) => {
if (reservationNumber.length > 0) {
let rsv = ``;
if (reservationNumber.length > 0) {
for (let index = 0; index < reservationNumber.length; index++) {
if (index > 0) {
rsv = rsv + `,`;
}
rsv = `'` + rsv + reservationNumber[index] + `'`;
}
}
let result = knex('trx.t_d_reservation_balance')
.select(
'trx.t_d_reservation_balance.i_reservation_amount',
'trx.t_d_reservation_balance.c_reservation_no',
'trx.t_d_reservation_balance.c_flag'
)
.where('trx.t_d_reservation_balance.c_card_number', cardNumber)
.whereIn('trx.t_d_reservation_balance.c_status', ['P', 'I'])
.whereRaw(
`trx.t_d_reservation_balance.c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud WHERE trx.t_d_fraud.c_status = 'A' AND trx.t_d_fraud.c_reservation_no IN (${rsv}))`
)
// .where("d_expired", ">=", time)
.where(function () {
this.orWhere('trx.t_d_reservation_balance.c_flag', flag).orWhere(
'trx.t_d_reservation_balance.c_flag',
'-1'
);
});
return result;
} else {
let result = knex('trx.t_d_reservation_balance')
// .sum("i_reservation_amount as total_reservation_amount")
// .count("* as total_reservation")
.select('i_reservation_amount', 'c_reservation_no', 'c_flag')
.where('c_card_number', cardNumber)
.whereIn('c_status', ['P', 'I'])
// .where("d_expired", ">=", time)
.where(function () {
this.orWhere('c_flag', flag).orWhere('c_flag', '-1');
});
return result;
}
};
// GET FRAUD TRANSACTION
const getFraudTransaction = (cardNumber) => {
let result = knex('trx.t_d_fraud')
.where('c_card_number', cardNumber)
.where('c_status', '!=', 'X');
return result;
};
// GET FRAUD TRANSACTION
const getLastHistory = (cardNumber) => {
let result = knex('log.t_log_card')
.where('c_card_number', cardNumber)
.whereIn('i_log_name', [21, 90])
.where('c_source', 'CMS')
.where('c_status', 'S')
.orderBy('d_log', 'desc')
.first(); .first();
return result; return result;
}; };
// INSERT FRAUD TRANSACTION
const insertFraudTransaction = (reservationNumber) => {
let rsv = ``;
if (reservationNumber.length > 0) {
for (let index = 0; index < reservationNumber.length; index++) {
if (index > 0) {
rsv = rsv + `,`;
}
rsv = `'` + rsv + reservationNumber[index] + `'`;
}
}
let result = knex
.into(
knex.raw('?? (??, ??, ??, ??, ??, ??)', [
'trx.t_d_fraud',
'c_card_number',
'c_reservation_no',
'i_reservation_amount',
'c_reservation_status',
'c_reservation_flag',
'c_reservation_ref_no',
])
)
.insert(function () {
this.select(
'c_card_number',
'c_reservation_no',
'i_reservation_amount',
'c_status',
'c_flag',
'c_ref_no'
)
.from('trx.t_d_reservation_balance')
.whereIn(
'trx.t_d_reservation_balance.c_reservation_no',
reservationNumber
)
.whereRaw(
`trx.t_d_reservation_balance.c_reservation_no NOT IN (SELECT c_reservation_no FROM trx.t_d_fraud WHERE trx.t_d_fraud.c_status = 'A' AND trx.t_d_fraud.c_reservation_no IN (${rsv}))`
);
});
return result;
};
// SUSPEND RESERVATION
const suspendReservation = (reservationNumber, datetime) => {
let result = knex('trx.t_d_reservation_balance')
.update({
c_status: 'S',
c_status_name: 'SUSPEND',
d_modify: datetime,
})
.whereIn('c_reservation_no', reservationNumber);
return result;
};
// CHECK HISTORY CARD
const checkCardHistory = (c_card_number) => {
let result = knex('log.t_log_card')
// .select(['i_log_name', 'c_source'])
.where('c_card_number', c_card_number)
.where('c_source', 'CMS')
.whereIn('i_log_name', ['21', '90'])
.orderBy('d_log', 'DESC')
.first();
return result;
};
// INSERT FRAUD
const insertFraud = (data) => {
let result = knex('trx.t_d_fraud').insert(data, ['c_reservation_no']);
return result;
};
// UPDATE RESERVE BALANCE
const updateFraudToReserve = (reserve_no) => {
let result = knex('trx.t_d_reservation_balance')
.update({
c_status: 'S',
c_status_name: 'SUSPEND',
})
.whereIn('c_reservation_no', reserve_no);
return result;
};
// CREATE DETAIL LOAD BALANCE FROM RESERVATION
const createDetailLoadBalanceFromReservation = (reservationNumber) => {
let result = knex('trx.t_d_reservation_balance')
.whereIn('c_reservation_no', reservationNumber)
.where('c_status', '!=', 'X');
return result;
};
// UPDATE RESERVATION AND LOADING BALANCE CASE FAILED WRITE BEFORE
const updateReservationAndInsertLoadingBalance = async (
reservationNumber,
dataLoadBalance,
detailLoadBalance,
now,
flag
) => {
return await knex
.transaction((trx) => {
knex('trx.t_d_load_balance')
.transacting(trx)
.insert(dataLoadBalance)
.returning('i_load_balance')
.then((detail) => {
let id = detail[0];
let loadDetail = [];
detailLoadBalance.forEach((element) => {
loadDetail.push({
i_load_balance: id,
i_reservation_balance: element.i_reservation_balance,
c_reservation_no: element.c_reservation_no,
i_amount: element.i_reservation_amount,
i_issuer: element.i_issuer,
i_issuer_code: element.i_issuer_code,
i_issuer_name: element.i_issuer_name,
i_issuer_fee: element.i_issuer_fee,
i_channel: element.i_channel,
i_channel_code: element.i_channel_code,
i_channel_name: element.i_channel_name,
i_channel_fee: element.i_channel_fee,
});
});
// insert detail load balance
return knex('trx.t_d_load_balance_detail')
.transacting(trx)
.insert(loadDetail);
})
.then(() => {
// update reservation
return knex('trx.t_d_reservation_balance')
.transacting(trx)
.update({
d_load_balance: dataLoadBalance.d_load_balance,
c_load_balance_no: dataLoadBalance.c_load_balance_no,
c_flag: flag,
c_flag_code: null,
c_status: 'A',
c_status_name: 'LOADED',
d_modify: now,
i_modify: null,
c_modify_username: null,
c_modify_fullname: null,
})
.whereIn('c_reservation_no', reservationNumber);
})
.then(trx.commit)
.catch(trx.rollback);
})
.then((result) => {
console.log(result);
return result.rowCount;
})
.catch((error) => {
console.log(error.message);
return error.message;
});
};
module.exports = { module.exports = {
checkCardNumber, checkCardNumber,
getPartner, getPartner,
@@ -764,5 +1059,17 @@ module.exports = {
getAccumulationBalanceInThisMonthFromCardHistory, getAccumulationBalanceInThisMonthFromCardHistory,
createLoadBalanceLog, createLoadBalanceLog,
insertLoadBalanceNumber, insertLoadBalanceNumber,
getTopupPartialStatus, getReservationPendingWithoutFraud,
getFraudTransaction,
getLastHistory,
insertFraudTransaction,
suspendReservation,
checkCardHistory,
insertFraud,
updateFraudToReserve,
getReservationPendingV2,
getReservationPendingWithFlagCounterV2,
getReservationPendingWithFlagV2,
createDetailLoadBalanceFromReservation,
updateReservationAndInsertLoadingBalance,
}; };
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -8,7 +8,7 @@ let password;
if (process.env.SERVER_FOR == 'local') { if (process.env.SERVER_FOR == 'local') {
host = 'localhost'; host = 'localhost';
database = 'CMS_DEV'; database = 'postgres';
port = 5432; port = 5432;
user = 'postgres'; user = 'postgres';
password = 'postgres'; password = 'postgres';
@@ -16,8 +16,8 @@ if (process.env.SERVER_FOR == 'local') {
host = '10.20.14.14'; host = '10.20.14.14';
database = 'postgres'; database = 'postgres';
port = 5432; port = 5432;
user = 'cms'; user = 'postgres';
password = 'Cm5kc1#2021'; password = 'inhc0mmute_cms';
} else if (process.env.SERVER_FOR == 'production') { } else if (process.env.SERVER_FOR == 'production') {
host = '10.1.201.75'; host = '10.1.201.75';
database = 'postgres'; database = 'postgres';