Sistemazioni...

This commit is contained in:
Paolo Arena
2020-07-02 22:00:58 +02:00
parent c939be279e
commit e2cdee1baa
13 changed files with 454 additions and 171 deletions

View File

@@ -185,6 +185,9 @@ const UserSchema = new mongoose.Schema({
email_paypal: {
type: String
},
revolut: {
type: String
},
link_payment: {
type: String
},
@@ -455,6 +458,7 @@ UserSchema.statics.getUserShortDataByUsername = async function (idapp, username)
'profile.qualified_2invitati': 1,
'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.my_dream': 1,
@@ -505,6 +509,7 @@ UserSchema.statics.getDownlineByUsername = async function (idapp, username, incl
'profile.qualified_2invitati': 1,
'profile.saw_and_accepted': 1,
'profile.email_paypal': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.my_dream': 1,
@@ -583,11 +588,14 @@ UserSchema.statics.getQueryQualified = function () {
'profile.saw_and_accepted': shared_consts.ALL_SAW_AND_ACCEPTED,
'profile.saw_zoom_presentation': true,
'profile.my_dream': { $exists: true },
'profile.email_paypal': { $exists: true },
'profile.paymenttypes': { "$in": ['paypal'] },
$or: [
{ 'profile.email_paypal': { $exists: true } },
{ 'profile.revolut': { $exists: true } },
],
// 'profile.paymenttypes': { "$in": ['paypal'] },
$and: [
{ "$expr": { "$gt": [{ "$strLenCP": "$profile.my_dream" }, 10] } },
{ "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } }
// { "$expr": { "$gt": [{ "$strLenCP": "$profile.email_paypal" }, 6] } }
],
// $where: "this.profile.paymenttypes.length >= 1",
}]
@@ -658,7 +666,7 @@ UserSchema.statics.setUserQualified = async function (idapp, username) {
'username': username,
};
const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified': true } }, { new: false } );
const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified': true } }, { new: false });
return !!myrec;
};
@@ -674,7 +682,7 @@ UserSchema.statics.setUserQualified_2Invitati = async function (idapp, username)
'username': username,
};
const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified_2invitati': true } }, { new: false } );
const myrec = await User.findOneAndUpdate(myquery, { $set: { 'profile.qualified_2invitati': true } }, { new: false });
return !!myrec;
};
@@ -697,10 +705,18 @@ UserSchema.statics.getnumPaymentOk = function (idapp) {
return User.count({
idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
'profile.paymenttypes': { "$in": ['paypal'] },
$where: "this.profile.paymenttypes.length >= 1",
'profile.email_paypal': { $exists: true },
$and: [
{
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
'profile.paymenttypes': { "$in": ['paypal'] },
},
{
$or: [
{ 'profile.email_paypal': { $exists: true } },
{ 'profile.revolut': { $exists: true } },
]
}
]
});
};
@@ -1132,6 +1148,7 @@ UserSchema.statics.getRecByIndOrder = async function (idapp, ind_order) {
surname: 1,
'profile.teleg_id': 1,
'profile.email_paypal': 1,
'profile.revolut': 1,
'profile.link_payment': 1,
'profile.note_payment': 1,
'profile.paymenttypes': 1,
@@ -1285,6 +1302,7 @@ UserSchema.statics.getFieldsForSearch = function () {
{ field: 'email', type: tools.FieldType.string },
{ field: 'profile.cell', type: tools.FieldType.string },
{ field: 'profile.email_paypal', type: tools.FieldType.string },
{ field: 'profile.revolut', type: tools.FieldType.string },
{ field: 'profile.link_payment', type: tools.FieldType.string },
{ field: 'profile.teleg_id', type: tools.FieldType.number },
{ field: 'profile.username_telegram', type: tools.FieldType.string },
@@ -2187,26 +2205,26 @@ UserSchema.statics.DbOp = async function (idapp, mydata) {
return { num };
} else if (mydata.dbop === 'creaLista') {
/*} else if (mydata.dbop === 'creaLista') {
await ListaIngresso.deleteMany({ idapp, added: false });
await ListaIngresso.deleteMany({ idapp, added: false });
arrusers = await User.find({
'idapp': idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
}).sort({ date_added: 1 });
let num = 0;
arrusers = await User.find({
'idapp': idapp,
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }]
}).sort({ date_added: 1 });
let num = 0;
num += await addUtentiInLista(idapp, 1, arrusers);
num += await addUtentiInLista(idapp, 2, arrusers);
num += await addUtentiInLista(idapp, 3, arrusers);
num += await addUtentiInLista(idapp, 4, arrusers);
num += await addUtentiInLista(idapp, 5, arrusers);
// num += await addUtentiInLista(idapp, 3);
// num += await addUtentiInLista(idapp, 4);
return { num };
num += await addUtentiInLista(idapp, 1, arrusers);
num += await addUtentiInLista(idapp, 2, arrusers);
num += await addUtentiInLista(idapp, 3, arrusers);
num += await addUtentiInLista(idapp, 4, arrusers);
num += await addUtentiInLista(idapp, 5, arrusers);
// num += await addUtentiInLista(idapp, 3);
// num += await addUtentiInLista(idapp, 4);
return { num };
*/
}
} catch (e) {
console.error(e.message);