Quando accedi al Circuito RIS Nazionale, ti imposta il Fido e QtaMax DOPPIA rispetto al tuo Circuito Locale
This commit is contained in:
BIN
emails/.DS_Store
vendored
Normal file
BIN
emails/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -22,4 +22,6 @@ Dom 25/06 ORE 16:11: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
Ven 29/09 ORE 23:18: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Mar 03/10 ORE 22:49: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
Sab 04/11 ORE 15:17: 🤖: Da Sùrya (Paolo) undefined (paoloar77):
|
||||
✅ SuryaArena è stato Abilitato correttamente (da paoloar77)!
|
||||
@@ -621,6 +621,20 @@ AccountSchema.statics.updateFido = async function (idapp, username, groupname, c
|
||||
return risult;
|
||||
};
|
||||
|
||||
AccountSchema.statics.updateQtaMax = async function (idapp, username, groupname, circuitId, qtamax) {
|
||||
|
||||
let paramstoupdate = {
|
||||
qta_maxConcessa: qtamax,
|
||||
};
|
||||
let risult = null;
|
||||
if (groupname)
|
||||
risult = await Account.updateOne({ idapp, circuitId, groupname }, { $set: paramstoupdate });
|
||||
else
|
||||
risult = await Account.updateOne({ idapp, username, circuitId }, { $set: paramstoupdate });
|
||||
|
||||
return risult;
|
||||
};
|
||||
|
||||
AccountSchema.statics.canEditAccountAdmins = async function (username, id) {
|
||||
const account = await Account.findOne({ _id: id }).lean();
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ const CircuitSchema = new Schema({
|
||||
totCircolante: {
|
||||
type: Number,
|
||||
},
|
||||
showAlways: {
|
||||
type: Boolean,
|
||||
},
|
||||
totTransato: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -212,6 +215,10 @@ const CircuitSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
showAlways: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
status: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -276,6 +283,7 @@ CircuitSchema.statics.getWhatToShow = function (idapp, username) {
|
||||
fido_scoperto_default_grp: 1,
|
||||
qta_max_default_grp: 1,
|
||||
deperimento: 1,
|
||||
showAlways: 1,
|
||||
transactionsEnabled: 1,
|
||||
status: 1,
|
||||
valuta_per_euro: 1,
|
||||
@@ -331,6 +339,7 @@ CircuitSchema.statics.getWhatToShow_Unknown = function (idapp, username) {
|
||||
longdescr: 1,
|
||||
regulation: 1,
|
||||
numMembers: 1,
|
||||
showAlways: 1,
|
||||
systemUserId: 1,
|
||||
founderUserId: 1,
|
||||
nome_valuta: 1,
|
||||
@@ -936,6 +945,7 @@ CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, prov
|
||||
photos: [],
|
||||
color: '#ff5500',
|
||||
deperimento: false,
|
||||
showAlways: false,
|
||||
transactionsEnabled: true, // Abilita cmq il circuito dall'inizio
|
||||
status: shared_consts.CIRCUIT_STATUS.FASE1_CREAZIONE_GRUPPO,
|
||||
symbol: 'RIS',
|
||||
@@ -1031,7 +1041,7 @@ CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, usernam
|
||||
const useraccounts = await Account.getUserAccounts(idapp, username);
|
||||
const groupsaccounts = await Account.getGroupAccounts(idapp, groupname);
|
||||
|
||||
|
||||
|
||||
|
||||
for (let account of useraccounts) {
|
||||
if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) {
|
||||
@@ -1092,16 +1102,56 @@ CircuitSchema.statics.setFido = async function (idapp, username, circuitName, gr
|
||||
mycircuit = await Circuit.findOne({ idapp, name: circuitName });
|
||||
if (mycircuit) {
|
||||
const circuitId = mycircuit._id;
|
||||
let account = null;
|
||||
let fido = 0;
|
||||
let qtamax = 0;
|
||||
|
||||
const account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
|
||||
if (account) {
|
||||
let fido = 0;
|
||||
if (mycircuit.showAlways) {
|
||||
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const myuser = await User.getUserByUsername(idapp, username);
|
||||
|
||||
// Se è il circuito Nazionale, allora prende i valori dal proprio Circuito Locale:
|
||||
const accountsuser = await Account.getUserAccounts(idapp, username);
|
||||
if (accountsuser) {
|
||||
// Se lo trovo della mia provincia, prendo quello
|
||||
account = accountsuser.find((account) => account.circuit.strProv === myuser.profile.resid_province)
|
||||
if (!account && accountsuser.length > 0) {
|
||||
// Se non lo trovo, prendo il primo in cui sono entrato !
|
||||
account = accountsuser[0];
|
||||
}
|
||||
if (account && account.circuit) {
|
||||
if (groupname) {
|
||||
qtamax = account.circuit.qta_max_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||
fido = account.circuit.fido_scoperto_default_grp * shared_consts.CIRCUIT_CFG.MULT_FIDO_GROUP;
|
||||
} else {
|
||||
qtamax = account.circuit.qta_max_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||
fido = account.circuit.fido_scoperto_default * shared_consts.CIRCUIT_CFG.MULT_FIDO_USER;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Se non ho Circuiti locali, non applico il Fido !
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
account = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, true, true, groupname, '');
|
||||
if (groupname)
|
||||
fido = mycircuit.fido_scoperto_default_grp;
|
||||
else
|
||||
fido = mycircuit.fido_scoperto_default;
|
||||
}
|
||||
|
||||
return await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
||||
if (account) {
|
||||
if (qtamax > 0) {
|
||||
await Account.updateQtaMax(idapp, username, groupname, circuitId, qtamax);
|
||||
}
|
||||
|
||||
const ris = await Account.updateFido(idapp, username, groupname, circuitId, fido);
|
||||
if (ris) {
|
||||
return { qta_maxConcessa: qtamax, fidoConcesso: fido };
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -381,16 +381,16 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_SETFIDO) {
|
||||
if (recnotif.paramsObj.isAdmin) {
|
||||
if (recnotif.extrarec.groupname) {
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fido_scoperto_default_grp, recnotif.paramsObj.circuitnameDest,
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP', recnotif.extrarec.groupname, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
|
||||
username_action);
|
||||
} else {
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fido_scoperto_default, recnotif.paramsObj.circuitnameDest,
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO_ADMINS_CIRCUIT', sender, -recnotif.paramsObj.extrarec.fidoConcesso, recnotif.paramsObj.circuitnameDest,
|
||||
username_action);
|
||||
}
|
||||
|
||||
recnotif.openUrl = '/my/' + sender;
|
||||
} else {
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO', -recnotif.paramsObj.extrarec.fido_scoperto_default, username_action, recnotif.paramsObj.circuitnameDest);
|
||||
newdescr = i18n.__('FIDO_IMPOSTATO', -recnotif.paramsObj.extrarec.fidoConcesso, username_action, recnotif.paramsObj.circuitnameDest);
|
||||
}
|
||||
tag = 'setfido';
|
||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_CIRCUIT_ACCEPTED) {
|
||||
|
||||
@@ -2615,16 +2615,23 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SETFIDO) {
|
||||
|
||||
ris = await Circuit.setFido(idapp, usernameOrig, circuitname, groupname);
|
||||
|
||||
// Elimina la richiesta:
|
||||
update = { $pull: { req_users: { username: { $in: [usernameOrig] } } } };
|
||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
|
||||
await Circuit.updateData(idapp, circuitname)
|
||||
if (ris) {
|
||||
// Invia una notifica alla persona e agli Admin
|
||||
tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, value, true, username_action, extrarec);
|
||||
outres.result = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
||||
|
||||
extrarec.fidoConcesso = ris.fidoConcesso;
|
||||
extrarec.qta_maxConcessa = ris.qta_maxConcessa;
|
||||
|
||||
// Elimina la richiesta:
|
||||
update = { $pull: { req_users: { username: { $in: [usernameOrig] } } } };
|
||||
await Circuit.updateOne({ idapp, name: circuitname }, update);
|
||||
|
||||
await Circuit.updateData(idapp, circuitname)
|
||||
if (ris) {
|
||||
// Invia una notifica alla persona e agli Admin
|
||||
tools.sendNotificationByCircuit(idapp, usernameOrig, circuitname, cmd, value, true, username_action, extrarec);
|
||||
outres.result = await Circuit.getInfoCircuitByName(idapp, circuitname);
|
||||
}
|
||||
} else {
|
||||
// errore !?
|
||||
}
|
||||
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
@@ -2797,7 +2804,7 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
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: '',
|
||||
@@ -5230,7 +5237,7 @@ const FuncUsers = {
|
||||
return user.save().then(async () => {
|
||||
return User.findByUsername(user.idapp, user.username, false).
|
||||
then(async (usertrovato) => {
|
||||
|
||||
|
||||
const numutenti = await User.getNumUsers(user.idapp);
|
||||
|
||||
let msg = '++ Nuovo Entrato: [' + numutenti + '] ' + user.username + ' ' + user.name + ' ' + user.surname;
|
||||
@@ -5240,7 +5247,7 @@ const FuncUsers = {
|
||||
return telegrambot.askConfirmationUser(user.idapp, shared_consts.CallFunz.REGISTRATION, user, '', '', '', '');
|
||||
});
|
||||
}).catch((e) => {
|
||||
console.error(e.message);
|
||||
console.error(e.message);
|
||||
});
|
||||
|
||||
} catch (e) {
|
||||
|
||||
@@ -248,6 +248,12 @@ module.exports = {
|
||||
VISIB_ONLY_MANAGER: 2,
|
||||
VISIB_ONLY_ADMIN: 4,
|
||||
|
||||
CIRCUIT_CFG: {
|
||||
MULT_FIDO_USER: 2.0,
|
||||
MULT_FIDO_GROUP: 2.0,
|
||||
},
|
||||
|
||||
|
||||
Visibility_Group: {
|
||||
PRIVATE: 1,
|
||||
HIDDEN: 2,
|
||||
@@ -643,6 +649,7 @@ module.exports = {
|
||||
nome_valuta: 1,
|
||||
fido_scoperto_default: 1,
|
||||
deperimento: 1,
|
||||
showAlways: 1,
|
||||
status: 1,
|
||||
transactionsEnabled: 1,
|
||||
qta_max_default: 1,
|
||||
|
||||
Reference in New Issue
Block a user