- Profile
- Bot Telegram - fixed Chip multiselect
This commit is contained in:
@@ -136,9 +136,16 @@ var UserSchema = new mongoose.Schema({
|
||||
email_paypal: {
|
||||
type: String
|
||||
},
|
||||
paymenttypes: [],
|
||||
username_telegram: {
|
||||
type: String
|
||||
},
|
||||
teleg_id: {
|
||||
type: Number
|
||||
},
|
||||
teleg_checkcode: {
|
||||
type: Number
|
||||
},
|
||||
dateofbirth: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -404,6 +411,50 @@ UserSchema.statics.getEmailByUsername = async function (idapp, username) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.UserByIdTelegram = async function (idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, 'profile.teleg_id': teleg_id })
|
||||
.then((rec) => {
|
||||
return (!!rec) ? rec._doc : null;
|
||||
}).catch((e) => {
|
||||
console.error('UserExistByIdTelegram', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.SetTelegramCheckCode = async function (idapp, username, teleg_checkcode) {
|
||||
const User = this;
|
||||
|
||||
const fields_to_update = {
|
||||
'profile.teleg_checkcode': teleg_checkcode
|
||||
};
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
idapp,
|
||||
username
|
||||
}, { $set: fields_to_update }, { new: false }).then((record) => {
|
||||
return !!record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.SetTelegramIdSuccess = async function (idapp, username, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
const fields_to_update = {
|
||||
'profile.teleg_id': teleg_id,
|
||||
'profile.teleg_checkcode': 0
|
||||
};
|
||||
|
||||
return await User.findOneAndUpdate({
|
||||
idapp,
|
||||
username
|
||||
}, { $set: fields_to_update }, { new: false }).then((record) => {
|
||||
return record;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.getUsersList = function (idapp) {
|
||||
const User = this;
|
||||
@@ -463,6 +514,32 @@ UserSchema.statics.executeQueryTable = function (idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
UserSchema.statics.getDashboard = async function (idapp, aportador_solidario, username) {
|
||||
try {
|
||||
|
||||
// DATA: username, name, surname, email, intcode_cell, cell
|
||||
const dashboard = {
|
||||
aportador: {},
|
||||
downline: []
|
||||
};
|
||||
|
||||
// Data of my Aportador
|
||||
dashboard.aportador = await User.getUserShortDataByUsername(idapp, aportador_solidario);
|
||||
|
||||
// Data of my Downline
|
||||
dashboard.downline = await User.getDownlineByUsername(idapp, username);
|
||||
|
||||
for (let index = 0; index < dashboard.downline.length; ++index) {
|
||||
dashboard.downline[index].downline = await User.getDownlineByUsername(idapp, dashboard.downline[index].username);
|
||||
}
|
||||
return dashboard;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (tools.INITDB_FIRSTIME) {
|
||||
console.log(' createIndex User Index...');
|
||||
// UserSchema.index({ username: 'text', name: 'text', surname: 'text', email: 'text' });
|
||||
|
||||
Reference in New Issue
Block a user