- fixed: Se tenti d'inviare dei RIS a chi ha raggiunto il limite, deve comparirti un msg ed inviare un msg al destinatario !

This commit is contained in:
Surya Paolo
2025-03-12 22:42:43 +01:00
parent 7827e49760
commit 65b29a6eee
5 changed files with 89 additions and 59 deletions

View File

@@ -438,4 +438,9 @@ Lun 03/03 ORE 01:06: [<b>Circuito RIS Arezzo</b>]: Inviate Monete da surya1977 a
Saldi:
surya1977: -1.10 RIS]
Andro: 1.00 RIS]
Andro: 1.00 RIS]
Mer 12/03 ORE 21:30: [<b>Circuito RIS Italia</b>]: Inviate Monete da surya1977 a Giovannifruttadisicilia 60 RIS [causale: prova]
Saldi:
surya1977: 34.20 RIS]
Giovannifruttadisicilia: 458.50 RIS]

View File

@@ -104,8 +104,8 @@
"ID_CIRCUIT_COINS_ACCEPTED_TO_ME": "🔄 Hai inviato <strong>%s %s</strong> a %s sul '%s'.",
"ID_CIRCUIT_COINS_REFUSED": "%s %s rifiutati da %s sul '%s'.",
"ID_CIRCUIT_COINS_REFUSED_TO_ME": "%s %s rifiutati da %s sul '%s'.",
"CIRCUIT_AMOUNT_EXCEED_FIDO": "L'importo supera la quantità massima concessa per %s",
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "L'importo supera la quantità massima che il destinatario (%s) può accumulare",
"CIRCUIT_AMOUNT_EXCEED_FIDO": "⚠️ L'importo supera la quantità massima concessa per %s",
"CIRCUIT_AMOUNT_EXCEED_QTAMAX": "⚠️ L'importo supera la quantità massima che il destinatario (%s) può accumulare",
"CIRCUIT_COINS_ALREADY_PROCESSED": "La richiesta è stata già processata. Stato %s",
"STATUS_SENT": "Inviato",
"STATUS_REFUSED": "Rifiutato",
@@ -127,6 +127,9 @@
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
"🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !",
"✅ Hai Ammesso l'accesso alla App a %s !": "✅ Hai Ammesso l'accesso alla App a %s !",
"EXCEED_FIDO": "⚠️ L'importo supera la Fiducia concessa per %s",
"EXCEED_QTAMAX": "⚠️ Attenzione! %s sta tentando di inviarti %s RIS, ma il tuo conto ha raggiunto il limite massimo di accumulo sul %s. \nPer poter ricevere il pagamento, devi prima spendere alcuni RIS cercando quello che ti serve, in modo da liberare spazio nel tuo conto. 🙏🏻",
"EXCEED_QTAMAX_MITTENTE": "⚠️ Attenzione! %s ha raggiunto la quota massima accumulabile in RIS, pertanto non puoi inviarglieli. Dovrebbe prima cercare di spendere i RIS cercando quello che gli serve, in modo da liberare spazio nel suo conto. 🙏🏻",
"Good: %": "Good: %",
"Service: %": "Service: %"
}

View File

@@ -720,6 +720,7 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
let ris = {
result: false,
cansend: true,
errorcode: 0,
errormsg: '',
rec: null,
useraccounts: [],
@@ -768,11 +769,13 @@ CircuitSchema.statics.sendCoins = async function (onlycheck, idapp, usernameOrig
if (accountorigTable.saldo - myqty < -accountorigTable.fidoConcesso) {
ris.cansend = false;
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_FIDO', usernameOrig);
ris.errorcode = shared_consts.SENDRIS_CODES.EXCEED_FIDO;
}
if (accountdestTable.saldo + myqty > accountdestTable.qta_maxConcessa) {
ris.cansend = false;
ris.errormsg = i18n.__('CIRCUIT_AMOUNT_EXCEED_QTAMAX', extrarec.dest);
ris.errorcode = shared_consts.SENDRIS_CODES.EXCEED_QTAMAX;
}
}

View File

@@ -3023,6 +3023,7 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
// console.log('setCircuitCmd', cmd);
const { SendNotif } = require('../models/sendnotif');
const telegrambot = require('../telegram/telegrambot');
let ris = null;
let outres = {
@@ -3261,73 +3262,86 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
outres = await Circuit.sendCoins(onlycheck, idapp, usernameOrig, extrarec);
if (outres.cansend) {
// Invia una notifica di moneta alla persona
//const out = await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action,
// extrarec);
//if (out)
// outres.result = out.ris;
} else {
outres.cansend = false;
}
ris = true;
// } else if ((cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) || (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE)) {
// Before to accept, I see if it's already set !
ris = true;
// } else if ((cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) || (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE)) {
// Before to accept, I see if it's already set !
/*outres = {
cansend: false,
errormsg: '',
}; */
/*outres = {
cansend: false,
errormsg: '',
}; */
let outcheck = outres;
let outcheck = outres;
let risStatus = '';
const status = await SendNotif.getStatus(extrarec.notifId);
if (status === shared_consts.CircuitsNotif.STATUS_ACCEPTED) {
risStatus = i18n.__('STATUS_SENT');
} else if (status === shared_consts.CircuitsNotif.STATUS_REFUSED) {
risStatus = i18n.__('STATUS_REFUSED');
}
// if (!await SendNotif.checkIfCoinsAlreadySent(extrarec.notifId)) {
//if (!await Movement.checkIfCoinsAlreadySent(extrarec.notifId)) {
if (true) {
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
//outcheck = await Circuit.sendCoins(true, idapp, usernameOrig, extrarec);
outcheck.cansend = true;
outres.cansend = true;
} else {
outcheck.cansend = true;
outres.cansend = true;
let risStatus = '';
const status = await SendNotif.getStatus(extrarec.notifId);
if (status === shared_consts.CircuitsNotif.STATUS_ACCEPTED) {
risStatus = i18n.__('STATUS_SENT');
} else if (status === shared_consts.CircuitsNotif.STATUS_REFUSED) {
risStatus = i18n.__('STATUS_REFUSED');
}
cmd = shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT;
/*if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT && outcheck.cansend) {
if (!await Movement.checkIfCoinsAlreadySent(extrarec.notifId)) {
outres = await Circuit.sendCoins(false, idapp, usernameOrig, extrarec);
// if (!await SendNotif.checkIfCoinsAlreadySent(extrarec.notifId)) {
//if (!await Movement.checkIfCoinsAlreadySent(extrarec.notifId)) {
if (true) {
if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) {
//outcheck = await Circuit.sendCoins(true, idapp, usernameOrig, extrarec);
outcheck.cansend = true;
outres.cansend = true;
} else {
outcheck.cansend = false; //GIA INVIATO
outcheck.cansend = true;
outres.cansend = true;
}
} */
if (outcheck.cansend) {
// Invia una notifica di moneta (accettata o rifiutata) alla persona
const out = await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
cmd = shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT;
if (outres && extrarec.groupname) {
// Setta agli altri admin,
/*if (cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT && outcheck.cansend) {
if (!await Movement.checkIfCoinsAlreadySent(extrarec.notifId)) {
outres = await Circuit.sendCoins(false, idapp, usernameOrig, extrarec);
} else {
outcheck.cansend = false; //GIA INVIATO
}
} */
if (outcheck.cansend) {
// Invia una notifica di moneta (accettata o rifiutata) alla persona
const out = await tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, false, true, username_action, extrarec);
if (outres && extrarec.groupname) {
// Setta agli altri admin,
}
}
}
outres.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.OTHERS);
if (await User.isAdminByUsername(idapp, username_action)) {
outres.arrrecnotifcoins = await SendNotif.findAllNotifCoinsAllIdAndIdApp(idapp);
} else {
outres.arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIFCOINS_FOR_USER, shared_consts.QualiNotifs.CIRCUITS);
}
outres.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER, shared_consts.QualiNotifs.OTHERS);
if (await User.isAdminByUsername(idapp, username_action)) {
outres.arrrecnotifcoins = await SendNotif.findAllNotifCoinsAllIdAndIdApp(idapp);
} else {
outres.arrrecnotifcoins = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIFCOINS_FOR_USER, shared_consts.QualiNotifs.CIRCUITS);
}
}
}
if (outres.errormsg) {
let msgerr = '';
let username_dest = extrarec.dest;
if (outres.errorcode === shared_consts.SENDRIS_CODES.EXCEED_FIDO) {
} else if (outres.errorcode === shared_consts.SENDRIS_CODES.EXCEED_QTAMAX) {
// invia un messaggio al destinatario
const msgDest = i18n.__('EXCEED_QTAMAX', usernameOrig, extrarec.qty.toString(), extrarec.circuitname);
await telegrambot.sendMsgTelegram(idapp, username_dest, msgDest);
msgerr = i18n.__('EXCEED_QTAMAX_MITTENTE', username_dest);
await telegrambot.sendMsgTelegram(idapp, usernameOrig, msgDest);
}
console.warn('🔴 ATTENZIONE! ', outres.errormsg + '\n(Mittente: ' + usernameOrig + ')');
// await telegrambot.sendMsgTelegram(idapp, usernameOrig, msgOrig);
// Invia questo msg anche all'Admin
await telegrambot.sendMsgTelegramToTheAdmin(idapp, outres.errormsg + '\n(Mittente: ' + usernameOrig + ')', true);
}
} else if ((cmd === shared_consts.CIRCUITCMD.SENDCOINS_ACCEPT) || (cmd === shared_consts.CIRCUITCMD.SENDCOINS_REFUSE)) {

View File

@@ -1187,6 +1187,11 @@ module.exports = {
SET: 1,
},
SENDRIS_CODES: {
EXCEED_FIDO: 10,
EXCEED_QTAMAX: 20,
},
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
};