fix: non riuscivi ad acquistare i RIS al gruppo
- lista linkREG
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
DATABASE=test_PiuCheBuono
|
||||
DATABASE=test_FreePlanet
|
||||
UDB=paofreeplanet
|
||||
PDB=mypassword@1A
|
||||
SEND_EMAIL=0
|
||||
SEND_EMAIL_ORDERS=1
|
||||
PORT=3000
|
||||
appTelegram_TEST=["1","17"]
|
||||
appTelegram=["1","17"]
|
||||
appTelegram_DEVELOP=["17"]
|
||||
appTelegram_TEST=["1","13"]
|
||||
appTelegram=["1","13"]
|
||||
appTelegram_DEVELOP=["13"]
|
||||
DOMAIN=mongodb://localhost:27017/
|
||||
AUTH_MONGODB=0
|
||||
ENABLE_PUSHNOTIFICATION=1
|
||||
@@ -29,7 +29,7 @@ GCM_API_KEY=""
|
||||
PROD=0
|
||||
PROJECT_DESCR_MAIN='__PROJECTS'
|
||||
SECRK=Askb38v23jjDFaoskBOWj92axXCQ
|
||||
TOKEN_LIFE=2h
|
||||
TOKEN_LIFE=1m
|
||||
REFRESH_TOKEN_LIFE=14d
|
||||
FTPSERVER_HOST=139.162.166.31
|
||||
FTPSERVER_PORT=21
|
||||
@@ -38,9 +38,4 @@ FTPSERVER_PWD=ftpmypwd@1A_
|
||||
AUTH_NEW_SITES=123123123
|
||||
SCRIPTS_DIR=admin_scripts
|
||||
CLOUDFLARE_TOKENS=[{"label":"Paolo.arena77@gmail.com","value":"M9EM309v8WFquJKpYgZCw-TViM2wX6vB3wlK6GD0"},{"label":"gruppomacro.com","value":"bqmzGShoX7WqOBzkXocoECyBkPq3GfqcM5t6VFd8"}]
|
||||
MIAB_HOST=box.lamiaposta.org
|
||||
MIAB_ADMIN_EMAIL=admin@lamiaposta.org
|
||||
MIAB_ADMIN_PASSWORD=passpao1pabox@1A
|
||||
DS_API_KEY="sk-222e3addb3d8455d8b0516d93906eec7"
|
||||
API_KEY_MSSQL="m68yADSr123MIVIDA@154$DSAGVOK"
|
||||
SERVER_A_URL="http://51.77.156.69:3000"
|
||||
@@ -478,4 +478,9 @@ Gio 13/03 ORE 18:57: [<b>Circuito RIS Italia</b>]: Inviate Monete da surya1977 a
|
||||
|
||||
Saldi:
|
||||
surya1977: 11.00 RIS]
|
||||
GruppoYurta: 17.00 RIS]
|
||||
GruppoYurta: 17.00 RIS]
|
||||
Dom 23/03 ORE 22:24: [<b>Circuito RIS Italia</b>]: Inviate Monete da surya1977 a GruppoYurta 1 RIS [causale: ]
|
||||
|
||||
Saldi:
|
||||
surya1977: 88.20 RIS]
|
||||
GruppoYurta: 6.00 RIS]
|
||||
@@ -55,6 +55,7 @@ const StatSchema = new Schema({
|
||||
diffusorilist: [],
|
||||
receiveRislist: [],
|
||||
receiveRislistgroup: [],
|
||||
listlinksreg: [],
|
||||
strettelist: [],
|
||||
num_transaz_tot: Number,
|
||||
tot_RIS_transati: Number,
|
||||
@@ -95,6 +96,7 @@ StatSchema.statics.calculateStats = async function (idapp) {
|
||||
lastsonline: await User.getLastOnlineUsers(idapp),
|
||||
lastssharedlink: await User.getLastSharedLink(idapp),
|
||||
diffusorilist: await User.getDiffusoriUsers(idapp),
|
||||
listlinksreg: await User.getListLinkReg(idapp),
|
||||
receiveRislist: await User.getReceiveRISUsers(idapp),
|
||||
receiveRislistgroup: await MyGroup.getReceiveRISGroups(idapp),
|
||||
strettelist: await User.getLastStretteDiManoUsers(idapp),
|
||||
|
||||
@@ -435,6 +435,9 @@ const UserSchema = new mongoose.Schema({
|
||||
lastdate_reqRis: {
|
||||
type: Date,
|
||||
},
|
||||
lastdate_LinkReg: {
|
||||
type: Date,
|
||||
},
|
||||
notifs: [
|
||||
{
|
||||
_id: false,
|
||||
@@ -4878,6 +4881,15 @@ UserSchema.statics.getReceiveRISUsers = async function (idapp) {
|
||||
return ris;
|
||||
});
|
||||
|
||||
};
|
||||
UserSchema.statics.getListLinkReg = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.aggregate(User.getQueryListLinkReg(idapp, 8)).then(ris => {
|
||||
// console.table(ris);
|
||||
return ris;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.checkUser = async function (idapp, username) {
|
||||
@@ -5423,6 +5435,93 @@ UserSchema.statics.getQueryReceiveRISUsers = function (idapp, hours) {
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSchema.statics.getQueryListLinkReg = function (idapp, hours) {
|
||||
|
||||
const query = [
|
||||
{
|
||||
$match: {
|
||||
idapp,
|
||||
'profile.lastdate_LinkReg': { $gte: tools.IncDateNow(-(1000 * 60 * 60 * hours)) },
|
||||
$or: [
|
||||
{ deleted: { $exists: false } },
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
},
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
_id: "$username",
|
||||
count: {
|
||||
$sum: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
{ $sort: { 'profile.lastdate_linkReg': -1 } },
|
||||
{ $limit: 30 },
|
||||
{
|
||||
$lookup: {
|
||||
from: "users",
|
||||
let: {
|
||||
username: "$_id",
|
||||
idapp,
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
$match: {
|
||||
$expr: {
|
||||
$and: [
|
||||
{
|
||||
$eq: [
|
||||
"$$username",
|
||||
"$username",
|
||||
],
|
||||
},
|
||||
{
|
||||
$eq: [
|
||||
"$$idapp",
|
||||
"$idapp",
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
as: "user",
|
||||
},
|
||||
},
|
||||
{ $unwind: "$user" },
|
||||
{
|
||||
$replaceRoot: {
|
||||
newRoot: {
|
||||
$mergeObjects: ["$user", "$$ROOT"],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
count: 1,
|
||||
aportador_solidario: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
'profile.lastdate_linkReg': 1,
|
||||
'profile.mycircuits': 1,
|
||||
date_reg: 1,
|
||||
idapp: 1,
|
||||
"profile.img": 1,
|
||||
'profile.handshake': 1,
|
||||
'profile.note': 1,
|
||||
'profile.da_contattare': 1,
|
||||
perm: 1,
|
||||
},
|
||||
},
|
||||
];
|
||||
return query;
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersRegWeekly = function (idapp, nrec) {
|
||||
|
||||
const query = [
|
||||
@@ -6220,6 +6319,17 @@ UserSchema.statics.setReceiveRis = async function (idapp, username) {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
UserSchema.statics.setLinkReg = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
idapp, username,
|
||||
},
|
||||
{ $set: { 'profile.lastdate_LinkReg': new Date() } }, { new: false }).lean().then((record) => {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.addNewSite = async function (idappPass, body) {
|
||||
|
||||
@@ -393,7 +393,7 @@ router.post('/', async (req, res) => {
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
router.get('/:idapp/:username', async (req, res) => {
|
||||
@@ -496,6 +496,28 @@ router.post('/receiveris', authenticate, (req, res) => {
|
||||
};
|
||||
});
|
||||
|
||||
router.post('/listlinkreg', authenticate, (req, res) => {
|
||||
const username = req.user ? req.user.username : '';
|
||||
const groupname = req.body.groupname;
|
||||
const idapp = req.body.idapp;
|
||||
|
||||
try {
|
||||
if (!username)
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR });
|
||||
|
||||
return User.setLinkReg(idapp, username)
|
||||
.then(risult => {
|
||||
res.send({ code: server_constants.RIS_CODE_OK });
|
||||
}).catch((err) => {
|
||||
tools.mylog('ERRORE IN listlinkreg: ' + err.message);
|
||||
res.status(400).send();
|
||||
});
|
||||
} catch (e) {
|
||||
res.status(400).send();
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
router.post('/profile', authenticate, (req, res) => {
|
||||
const usernameOrig = req.user ? req.user.username : '';
|
||||
const perm = req.user ? req.user.perm : tools.Perm.PERM_NONE;
|
||||
@@ -1047,7 +1069,7 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
// ++ Replace All Circuitname with 'Circuito RIS %s'
|
||||
await Circuit.replaceAllCircuitNames(idapp);
|
||||
} else if (mydata.dbop === 'eliminaCatProds') {
|
||||
|
||||
|
||||
await CatProd.deleteMany({ idapp });
|
||||
await SubCatProd.deleteMany({ idapp });
|
||||
} else if (mydata.dbop === 'creaUtentiTest') {
|
||||
@@ -1561,7 +1583,7 @@ async function ConvertiDaIntAStr(mytable) {
|
||||
const doc = await myrec.save();
|
||||
ind++;
|
||||
console.log('++Add (', ind, ')', doc._id);
|
||||
} catch (err) {
|
||||
} catch (err) {
|
||||
const myid = parseInt(err.keyValue._id, 10) + 0;
|
||||
const canc = await mytable.findOneAndDelete({ _id: myid });
|
||||
if (canc)
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.2.28
|
||||
1.2.29
|
||||
Reference in New Issue
Block a user