Compare commits
11 Commits
beforeRisI
...
1.0.20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e42baf79e | ||
|
|
e3ed2934ee | ||
|
|
e895e7dae2 | ||
|
|
4a408b4ebd | ||
|
|
0e3ba5ff87 | ||
|
|
a66cd610dd | ||
|
|
5aa6accfc5 | ||
|
|
35178684af | ||
|
|
bba0df4302 | ||
|
|
f1954d98d6 | ||
|
|
34b00bdf98 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -28,3 +28,5 @@ src/server/.DS_Store
|
|||||||
emails/.DS_Store
|
emails/.DS_Store
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.DS_Store
|
||||||
|
logtrans.txt
|
||||||
|
|||||||
20
logtrans.txt
20
logtrans.txt
@@ -97,3 +97,23 @@ Gio 12/10 ORE 08:06: [<b>Circuito RIS Rimini</b>]: Inviate Monete da paoloar77 a
|
|||||||
Saldi:
|
Saldi:
|
||||||
paoloar77: -18 RIS]
|
paoloar77: -18 RIS]
|
||||||
SuryaArena2: 7 RIS]
|
SuryaArena2: 7 RIS]
|
||||||
|
Mer 29/11 ORE 16:35: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 5 RIS [causale: Seconda]
|
||||||
|
Saldi:
|
||||||
|
SuryaArena: -5 RIS]
|
||||||
|
paoloar77: 5 RIS]
|
||||||
|
Mer 29/11 ORE 16:44: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Eccolo]
|
||||||
|
Saldi:
|
||||||
|
SuryaArena: -8 RIS]
|
||||||
|
paoloar77: 8 RIS]
|
||||||
|
Mer 29/11 ORE 16:50: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 3 RIS [causale: Ricevuto un bel massaggio]
|
||||||
|
Saldi:
|
||||||
|
SuryaArena: -11 RIS]
|
||||||
|
paoloar77: 11 RIS]
|
||||||
|
Mer 29/11 ORE 16:52: [<b>Circuito RIS Bologna</b>]: Inviate Monete da SuryaArena a paoloar77 4 RIS [causale: Un bel massaggio con olio caldo]
|
||||||
|
Saldi:
|
||||||
|
SuryaArena: -4 RIS]
|
||||||
|
paoloar77: 14 RIS]
|
||||||
|
Mer 29/11 ORE 17:14: [<b>Circuito RIS Italia</b>]: Inviate Monete da SuryaArena a paoloar77 2 RIS [causale: Massaggio !]
|
||||||
|
Saldi:
|
||||||
|
SuryaArena: -13 RIS]
|
||||||
|
paoloar77: 13 RIS]
|
||||||
@@ -5,6 +5,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "../../../newfreeplanet"
|
"path": "../../../newfreeplanet"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "../../../cnm"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"settings": {
|
"settings": {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal '%s'",
|
"CIRCUIT_EXIT_USER": "❌ l'utente %s è uscito dal '%s'",
|
||||||
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal '%s'",
|
"CIRCUIT_EXIT_USER_TO_ME": "❌ Sei uscito dal '%s'",
|
||||||
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal '%s' (da parte di %s)",
|
"CIRCUIT_REMOVED_TO_ME": "❌ Sei stato rimosso dal '%s' (da parte di %s)",
|
||||||
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong> sul '%s'.",
|
"CIRCUIT_SENDCOINSREQ": "%s ti sta inviando <strong>%s %s</strong> sul <strong>'%s'</strong>",
|
||||||
"COMUNITARIO": "Comunitario",
|
"COMUNITARIO": "Comunitario",
|
||||||
"COLLETTIVO": "Gruppo",
|
"COLLETTIVO": "Gruppo",
|
||||||
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'.",
|
"CIRCUIT_SENDCOINSREQ_GROUP": "%s sta inviando <strong>%s %s</strong> al Conto %s '%s' sul '%s'.",
|
||||||
@@ -107,5 +107,11 @@
|
|||||||
"DATEDAYONLY": "%s dalle %s alle %s",
|
"DATEDAYONLY": "%s dalle %s alle %s",
|
||||||
"DATE_2DAYS": "%s dalle %s fino a %s alle %s",
|
"DATE_2DAYS": "%s dalle %s fino a %s alle %s",
|
||||||
"SENDMSG_ENTRA_IN_RISO_ITALIA": "Ciao %s!<br>%s che appartiene al <em>%s</em> vuole inviarti dei RIS. Per poterli ricevere dovete entrambi utilizzare il <strong>Circuito RIS Italia</strong>.",
|
"SENDMSG_ENTRA_IN_RISO_ITALIA": "Ciao %s!<br>%s che appartiene al <em>%s</em> vuole inviarti dei RIS. Per poterli ricevere dovete entrambi utilizzare il <strong>Circuito RIS Italia</strong>.",
|
||||||
"CLICCA_QUI": "CLICCA QUI"
|
"CLICCA_QUI": "CLICCA QUI",
|
||||||
|
"✅ %s è stato Abilitato correttamente (da %s)!": "✅ %s è stato Abilitato correttamente (da %s)!",
|
||||||
|
"✅ Sei stato Abilitato correttamente da %s!": "✅ Sei stato Abilitato correttamente da %s!",
|
||||||
|
"🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!",
|
||||||
|
"🚫 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 Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !"
|
||||||
}
|
}
|
||||||
@@ -9,16 +9,16 @@ const CartSchema = new Schema({
|
|||||||
idapp: {
|
idapp: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
userId: {type: Schema.Types.ObjectId, ref: 'User'},
|
userId: { type: Schema.Types.ObjectId, ref: 'User' },
|
||||||
totalQty: {type: Number, default: 0},
|
totalQty: { type: Number, default: 0 },
|
||||||
totalPrice: {type: Number, default: 0},
|
totalPrice: { type: Number, default: 0 },
|
||||||
department: {
|
department: {
|
||||||
type: String, ref: 'Department',
|
type: String, ref: 'Department',
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
order:
|
order:
|
||||||
{type: Schema.Types.ObjectId, ref: 'Order'},
|
{ type: Schema.Types.ObjectId, ref: 'Order' },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
note: {
|
note: {
|
||||||
@@ -31,57 +31,61 @@ const CartSchema = new Schema({
|
|||||||
|
|
||||||
var Cart = module.exports = mongoose.model('Cart', CartSchema);
|
var Cart = module.exports = mongoose.model('Cart', CartSchema);
|
||||||
|
|
||||||
module.exports.findAllIdApp = async function(idapp, userId) {
|
module.exports.findAllIdApp = async function (idapp, userId) {
|
||||||
const myfind = {idapp, userId};
|
const myfind = { idapp, userId };
|
||||||
|
|
||||||
return await Cart.findOne(myfind).lean();
|
return await Cart.findOne(myfind).lean();
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getCartByUserId = async function(uid, idapp) {
|
module.exports.getCartByUserId = async function (uid, idapp) {
|
||||||
let query = {userId: uid, idapp};
|
try {
|
||||||
const mycart = await Cart.findOne(query).lean();
|
let query = { userId: uid, idapp };
|
||||||
|
const mycart = await Cart.findOne(query).lean();
|
||||||
|
|
||||||
if (!!mycart) {
|
if (!!mycart) {
|
||||||
for (const idkey in mycart.items) {
|
for (const idkey in mycart.items) {
|
||||||
try {
|
try {
|
||||||
idorder = mycart.items[idkey]._id.toString();
|
idorder = mycart.items[idkey]._id.toString();
|
||||||
const myorder = mycart.items[idkey].order;
|
const myorder = mycart.items[idkey].order;
|
||||||
if (!!myorder) {
|
if (!!myorder) {
|
||||||
idorder = mycart.items[idkey].order._id.toString();
|
idorder = mycart.items[idkey].order._id.toString();
|
||||||
|
}
|
||||||
|
const myord = await Order.getTotalOrderById(idorder);
|
||||||
|
if (myord.length > 0) {
|
||||||
|
mycart.items[idkey].order = myord[0];
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('err', e);
|
||||||
}
|
}
|
||||||
const myord = await Order.getTotalOrderById(idorder);
|
|
||||||
if (myord.length > 0) {
|
|
||||||
mycart.items[idkey].order = myord[0];
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('err', e);
|
|
||||||
}
|
}
|
||||||
|
return mycart;
|
||||||
}
|
}
|
||||||
return mycart;
|
return null;
|
||||||
|
} catch (e) {
|
||||||
|
console.log('getCartByUserId err', e);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.updateCartByUserId = function(userId, newCart, callback) {
|
module.exports.updateCartByUserId = function (userId, newCart, callback) {
|
||||||
let query = {userId: userId};
|
let query = { userId: userId };
|
||||||
Cart.find(query, function(err, c) {
|
Cart.find(query, function (err, c) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
||||||
//exist cart in databse
|
//exist cart in databse
|
||||||
if (c.length > 0) {
|
if (c.length > 0) {
|
||||||
Cart.findOneAndUpdate(
|
Cart.findOneAndUpdate(
|
||||||
{userId: userId},
|
{ userId: userId },
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
items: newCart.items,
|
items: newCart.items,
|
||||||
totalQty: newCart.totalQty,
|
totalQty: newCart.totalQty,
|
||||||
totalPrice: newCart.totalPrice,
|
totalPrice: newCart.totalPrice,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{new: true},
|
},
|
||||||
callback,
|
{ new: true },
|
||||||
|
callback,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
//no cart in database
|
//no cart in database
|
||||||
@@ -90,7 +94,7 @@ module.exports.updateCartByUserId = function(userId, newCart, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.updateCartByCartId = async function(cartId, newCart) {
|
module.exports.updateCartByCartId = async function (cartId, newCart) {
|
||||||
// delete newCart._doc._id;
|
// delete newCart._doc._id;
|
||||||
const items = newCart.items;
|
const items = newCart.items;
|
||||||
const totalQty = newCart.totalQty;
|
const totalQty = newCart.totalQty;
|
||||||
@@ -98,14 +102,14 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
|
|||||||
|
|
||||||
const modify_at = new Date();
|
const modify_at = new Date();
|
||||||
|
|
||||||
return await Cart.findOneAndUpdate({_id: cartId}, {
|
return await Cart.findOneAndUpdate({ _id: cartId }, {
|
||||||
$set: {
|
$set: {
|
||||||
items,
|
items,
|
||||||
totalPrice,
|
totalPrice,
|
||||||
totalQty,
|
totalQty,
|
||||||
modify_at,
|
modify_at,
|
||||||
},
|
},
|
||||||
}, {new: false}).lean().then((ris) => {
|
}, { new: false }).lean().then((ris) => {
|
||||||
return ris;
|
return ris;
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log('err', err);
|
console.log('err', err);
|
||||||
@@ -114,11 +118,11 @@ module.exports.updateCartByCartId = async function(cartId, newCart) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.deleteCartByCartId = async function(cartId) {
|
module.exports.deleteCartByCartId = async function (cartId) {
|
||||||
return await Cart.remove({_id: cartId});
|
return await Cart.remove({ _id: cartId });
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.createCart = async function(newCart) {
|
module.exports.createCart = async function (newCart) {
|
||||||
return await newCart.save();
|
return await newCart.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
|
||||||
const mongoose = require('mongoose').set('debug', false)
|
const mongoose = require('mongoose').set('debug', false)
|
||||||
const Schema = mongoose.Schema;
|
const Schema = mongoose.Schema;
|
||||||
|
|
||||||
mongoose.Promise = global.Promise;
|
mongoose.Promise = global.Promise;
|
||||||
mongoose.level = "F";
|
mongoose.level = "F";
|
||||||
|
|
||||||
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
// Resolving error Unknown modifier: $pushAll
|
// Resolving error Unknown modifier: $pushAll
|
||||||
mongoose.plugin(schema => {
|
mongoose.plugin(schema => {
|
||||||
@@ -11,20 +13,41 @@ mongoose.plugin(schema => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const CategorySchema = new Schema({
|
const CategorySchema = new Schema({
|
||||||
|
idapp: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
unique: true,
|
||||||
index: true,
|
index: true,
|
||||||
lowercase: true
|
},
|
||||||
}
|
img: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports.getAllCategories = function (callback) {
|
CategorySchema.statics.getAllCategories = function (callback) {
|
||||||
Category.find(callback)
|
Category.find(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getCategoryById = function (id, callback) {
|
CategorySchema.statics.getCategoryById = function (id, callback) {
|
||||||
Category.findById(id, callback);
|
Category.findById(id, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = mongoose.model('Category', CategorySchema);
|
CategorySchema.statics.getFieldsForSearch = function () {
|
||||||
|
return [{ field: 'name', type: tools.FieldType.string }]
|
||||||
|
};
|
||||||
|
|
||||||
|
CategorySchema.statics.executeQueryTable = function (idapp, params) {
|
||||||
|
return tools.executeQueryTable(this, idapp, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
CategorySchema.statics.findAllIdApp = async function (idapp) {
|
||||||
|
const myfind = { idapp };
|
||||||
|
|
||||||
|
return await Category.find(myfind);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Category = mongoose.model('Category', CategorySchema);
|
||||||
|
|
||||||
|
module.exports = { Category };
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ const orderSchema = new Schema({
|
|||||||
weight: {
|
weight: {
|
||||||
type: Number
|
type: Number
|
||||||
},
|
},
|
||||||
|
unit: {
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
stars: {
|
stars: {
|
||||||
type: Number
|
type: Number
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ const productSchema = new Schema({
|
|||||||
],
|
],
|
||||||
code: {
|
code: {
|
||||||
type: String,
|
type: String,
|
||||||
lowercase: true
|
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -39,8 +38,13 @@ const productSchema = new Schema({
|
|||||||
type: String, ref: 'Department'
|
type: String, ref: 'Department'
|
||||||
},
|
},
|
||||||
category: {
|
category: {
|
||||||
type: String, ref: 'Category'
|
type: Array,
|
||||||
// type: String
|
},
|
||||||
|
prezzo_ivato: { // Con IVA
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
|
perc_iva: { // 4, 10, 22 &
|
||||||
|
type: Number
|
||||||
},
|
},
|
||||||
price: {
|
price: {
|
||||||
type: Number
|
type: Number
|
||||||
@@ -57,6 +61,9 @@ const productSchema = new Schema({
|
|||||||
weight: {
|
weight: {
|
||||||
type: Number
|
type: Number
|
||||||
},
|
},
|
||||||
|
unit: {
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
quantityAvailable: {
|
quantityAvailable: {
|
||||||
type: Number
|
type: Number
|
||||||
},
|
},
|
||||||
@@ -183,6 +190,9 @@ module.exports.getProductByID = function (id, callback) {
|
|||||||
Product.findById(id, callback);
|
Product.findById(id, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// const Product = mongoose.model('Product', ProductSchema);
|
// const Product = mongoose.model('Product', ProductSchema);
|
||||||
|
|
||||||
// module.exports = { Product };
|
// module.exports = { Product };
|
||||||
|
// PROVA
|
||||||
|
|||||||
@@ -1011,7 +1011,6 @@ sendNotifSchema.statics.sendToTheDestinations = async function (myrecnotifpass,
|
|||||||
arrcircuits.push(await City.getCircuitNameBystrProv(prov));
|
arrcircuits.push(await City.getCircuitNameBystrProv(prov));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
if (myrecnotifpass.tablerec === shared_consts.TABLES_MYGOODS) {
|
||||||
idSector = myrectableorig.idSectorGood;
|
idSector = myrectableorig.idSectorGood;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const validator = require('validator');
|
|||||||
const jwt = require('jsonwebtoken');
|
const jwt = require('jsonwebtoken');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
const printf = require('util').format;
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
|
|
||||||
const { Settings } = require('../models/settings');
|
const { Settings } = require('../models/settings');
|
||||||
@@ -2057,22 +2058,56 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
|||||||
req = tools.getReqByPar(idapp, usernameOrig);
|
req = tools.getReqByPar(idapp, usernameOrig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let userDest = null;
|
||||||
|
if (usernameDest)
|
||||||
|
userDest = await User.getUserShortDataByUsername(idapp, usernameDest);
|
||||||
|
|
||||||
const username_action = req.user.username;
|
const username_action = req.user.username;
|
||||||
let username_worked = usernameDest;
|
let username_worked = usernameDest;
|
||||||
|
|
||||||
let ris = null;
|
let ris = null;
|
||||||
|
let lang = '';
|
||||||
|
let user = null;
|
||||||
|
if (usernameOrig) {
|
||||||
|
user = await User.getUserShortDataByUsername(idapp, usernameOrig);
|
||||||
|
}
|
||||||
|
lang = user ? user.lang : '';
|
||||||
let update = {};
|
let update = {};
|
||||||
try {
|
try {
|
||||||
if (cmd === shared_consts.FRIENDSCMD.SETTRUST) {
|
if (cmd === shared_consts.FRIENDSCMD.SETTRUST) {
|
||||||
|
|
||||||
// Aggiungi alle amicizie
|
let msgOrig = '';
|
||||||
await this.setFriendsCmd(req, idapp, usernameOrig, usernameDest,
|
let msgDest = '';
|
||||||
shared_consts.FRIENDSCMD.SETFRIEND, value);
|
// Aggiorna true se lo accetti e false se non lo accetti
|
||||||
|
const ris = await User.updateOne({ idapp, username: usernameDest },
|
||||||
return await User.updateOne({ idapp, username: usernameDest },
|
|
||||||
{ $set: { verified_by_aportador: value, trust_modified: new Date() } },
|
{ $set: { verified_by_aportador: value, trust_modified: new Date() } },
|
||||||
{ new: false });
|
{ new: false });
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
// Aggiungi alle amicizie
|
||||||
|
await this.setFriendsCmd(req, idapp, usernameOrig, usernameDest,
|
||||||
|
shared_consts.FRIENDSCMD.SETFRIEND, value);
|
||||||
|
|
||||||
|
msgOrig = i18n.__({ phrase: '✅ Hai Abilitato l\'accesso alla App a %s !', locale: userDest.lang }, userDest.username);
|
||||||
|
msgDest = i18n.__({ phrase: '✅ Sei stato Abilitato correttamente da %s!', locale: lang }, usernameOrig);
|
||||||
|
msgAdmin = i18n.__({ phrase: '✅ %s è stato Abilitato correttamente (da %s)!', locale: userDest.lang }, userDest.username, usernameOrig);
|
||||||
|
} else {
|
||||||
|
msgOrig = i18n.__({ phrase: '🚫 Hai rifiutato l\'accesso alla App di RISO da parte di %s!', locale: userDest.lang }, userDest.username);
|
||||||
|
msgDest = i18n.__({ phrase: '🚫 Ti è stato rifiutato l\'accesso. Probabilmente l\'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l\'Assistenza Tecnica.', locale: lang }, usernameOrig);
|
||||||
|
msgAdmin = i18n.__({ phrase: '🚫 %s ha rifiutato l\'accesso alla App a %s !', locale: userDest.lang }, usernameOrig, userDest.username);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
await telegrambot.sendMsgTelegram(idapp, usernameOrig, msgOrig);
|
||||||
|
await telegrambot.sendMsgTelegram(idapp, userDest.username, msgDest);
|
||||||
|
|
||||||
|
// Invia questo msg anche all'Admin
|
||||||
|
await telegrambot.sendMsgTelegramToTheAdmin(idapp, msgAdmin, true);
|
||||||
|
|
||||||
|
// telegrambot.askConfirmationUser(user.idapp, shared_consts.CallFunz.REGISTRATION, user, '', '', '', '');
|
||||||
|
|
||||||
|
return ris;
|
||||||
|
|
||||||
} else if (cmd === shared_consts.FRIENDSCMD.SETFRIEND) {
|
} else if (cmd === shared_consts.FRIENDSCMD.SETFRIEND) {
|
||||||
// Aggiungo l'Amicizia a me
|
// Aggiungo l'Amicizia a me
|
||||||
const foundIfAlreadyFriend = await User.findOne({
|
const foundIfAlreadyFriend = await User.findOne({
|
||||||
@@ -3125,6 +3160,20 @@ UserSchema.statics.getAskedFriendsByUsername = async function (idapp, username)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UserSchema.statics.getUsersToVerify = async function (idapp, username) {
|
||||||
|
|
||||||
|
const whatToShow_Unknown = getWhatToShow(idapp, username);
|
||||||
|
let usersToVerify = await User.find({
|
||||||
|
idapp, aportador_solidario: username,
|
||||||
|
verified_by_aportador: { $exists: false },
|
||||||
|
$or: [
|
||||||
|
{ deleted: { $exists: false } },
|
||||||
|
{ deleted: { $exists: true, $eq: false } }],
|
||||||
|
}, whatToShow_Unknown).lean();
|
||||||
|
|
||||||
|
return usersToVerify;
|
||||||
|
};
|
||||||
|
|
||||||
UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
UserSchema.statics.getFriendsByUsername = async function (idapp, username) {
|
||||||
|
|
||||||
if (!username) {
|
if (!username) {
|
||||||
@@ -4076,7 +4125,7 @@ UserSchema.statics.getUsersDreams = async function (idapp) {
|
|||||||
UserSchema.statics.getLastUsers = async function (idapp) {
|
UserSchema.statics.getLastUsers = async function (idapp) {
|
||||||
const User = this;
|
const User = this;
|
||||||
|
|
||||||
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 10);
|
const lastn = await Settings.getValDbSettings(idapp, 'SHOW_LAST_N_USERS', 20);
|
||||||
|
|
||||||
return await User.find(
|
return await User.find(
|
||||||
{
|
{
|
||||||
@@ -4090,6 +4139,7 @@ UserSchema.statics.getLastUsers = async function (idapp) {
|
|||||||
name: 1,
|
name: 1,
|
||||||
surname: 1,
|
surname: 1,
|
||||||
lasttimeonline: 1,
|
lasttimeonline: 1,
|
||||||
|
verified_by_aportador: 1,
|
||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
date_reg: 1,
|
date_reg: 1,
|
||||||
index: 1,
|
index: 1,
|
||||||
@@ -5024,6 +5074,8 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, v
|
|||||||
|
|
||||||
recUser.profile.reaction = await Reaction.find({ idapp, username: recUser.username }).lean();
|
recUser.profile.reaction = await Reaction.find({ idapp, username: recUser.username }).lean();
|
||||||
|
|
||||||
|
recUser.profile.userstoverify = await User.getUsersToVerify(idapp, recUser.username);
|
||||||
|
|
||||||
recUser.profile.manage_mygroups = listManageGroups
|
recUser.profile.manage_mygroups = listManageGroups
|
||||||
? listManageGroups
|
? listManageGroups
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -30,17 +30,20 @@ const Cart = require('../models/cart');
|
|||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
|
|
||||||
//GET cart
|
//GET cart
|
||||||
router.get('/:userId', authenticate, function (req, res, next) {
|
router.get('/:userId', authenticate, async function (req, res, next) {
|
||||||
let userId = req.body.userId
|
let userId = req.params.userId
|
||||||
let idapp = req.body.idapp
|
let idapp = req.user.idapp
|
||||||
Cart.getCartByUserId(userId, idapp, function (err, cart) {
|
return await Cart.getCartByUserId(userId, idapp)
|
||||||
if (err) return next(err)
|
.then((cart) => {
|
||||||
|
if (cart)
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_OK, cart });
|
||||||
|
else
|
||||||
|
return res.status(400).send(e);
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error('Err', err);
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null });
|
||||||
|
});
|
||||||
|
|
||||||
if (cart)
|
|
||||||
res.send({ code: server_constants.RIS_CODE_OK, cart });
|
|
||||||
else
|
|
||||||
res.status(400).send(e);
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//POST cart
|
//POST cart
|
||||||
@@ -51,46 +54,54 @@ router.post('/:userId', authenticate, async function (req, res, next) {
|
|||||||
let subqty = req.body.subqty;
|
let subqty = req.body.subqty;
|
||||||
let order = req.body.order;
|
let order = req.body.order;
|
||||||
|
|
||||||
const mycart = await Cart.getCartByUserId(userId, idapp);
|
try {
|
||||||
|
|
||||||
// const myorder = Order.getOrderByID(order._id);
|
const mycart = await Cart.getCartByUserId(userId, idapp);
|
||||||
if (!addqty && !subqty)
|
|
||||||
order._id = await Order.createOrder(order);
|
|
||||||
|
|
||||||
let cart = null;
|
// const myorder = Order.getOrderByID(order._id);
|
||||||
// no cart save empty cart to database then return response
|
if (!addqty && !subqty)
|
||||||
let myqty = 0;
|
order._id = await Order.createOrder(order);
|
||||||
if (!mycart) {
|
|
||||||
let oldCart = new CartClass(order)
|
let cart = null;
|
||||||
cart = await Cart.createCart(oldCart.generateModel());
|
// no cart save empty cart to database then return response
|
||||||
} else {
|
let myqty = 0;
|
||||||
let newCart = CartClass.constructByCart(mycart);
|
if (!mycart) {
|
||||||
if (addqty) {
|
let oldCart = new CartClass(order)
|
||||||
myqty = await newCart.addqty(order);
|
cart = await Cart.createCart(oldCart.generateModel());
|
||||||
} else if (subqty) {
|
|
||||||
myqty = await newCart.subqty(order);
|
|
||||||
} else {
|
} else {
|
||||||
const ind = newCart.addItem(order);
|
let newCart = CartClass.constructByCart(mycart);
|
||||||
|
if (addqty) {
|
||||||
|
myqty = await newCart.addqty(order);
|
||||||
|
} else if (subqty) {
|
||||||
|
myqty = await newCart.subqty(order);
|
||||||
|
} else {
|
||||||
|
const ind = newCart.addItem(order);
|
||||||
|
}
|
||||||
|
cart = await Cart.updateCartByCartId(mycart._id, newCart.generateModel());
|
||||||
}
|
}
|
||||||
cart = await Cart.updateCartByCartId(mycart._id, newCart.generateModel());
|
if (cart) {
|
||||||
}
|
const carttot = await Cart.getCartByUserId(userId, idapp);
|
||||||
if (cart) {
|
return res.send({ code: server_constants.RIS_CODE_OK, cart: carttot, qty: myqty });
|
||||||
const carttot = await Cart.getCartByUserId(userId, idapp);
|
} else {
|
||||||
return res.send({ code: server_constants.RIS_CODE_OK, cart: carttot, qty: myqty });
|
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null });
|
||||||
} else {
|
}
|
||||||
return res.send({ code: server_constants.RIS_CODE_ERR, cart: null });
|
|
||||||
|
/*
|
||||||
|
Cart.updateCartByUserId(
|
||||||
|
userId,
|
||||||
|
newCart,
|
||||||
|
function (err, result) {
|
||||||
|
if (err) return next(err)
|
||||||
|
return res.status(200).json({ cart: result })
|
||||||
|
})
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR, cart: 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Cart.updateCartByUserId(
|
|
||||||
userId,
|
|
||||||
newCart,
|
|
||||||
function (err, result) {
|
|
||||||
if (err) return next(err)
|
|
||||||
return res.status(200).json({ cart: result })
|
|
||||||
})
|
|
||||||
|
|
||||||
*/
|
|
||||||
})
|
})
|
||||||
|
|
||||||
router.delete('/:userId', authenticate, async function (req, res) {
|
router.delete('/:userId', authenticate, async function (req, res) {
|
||||||
@@ -122,47 +133,56 @@ router.delete('/:userId', authenticate, async function (req, res) {
|
|||||||
|
|
||||||
|
|
||||||
//PUT cart
|
//PUT cart
|
||||||
router.put('/:userId', authenticate, function (req, res, next) {
|
router.put('/:userId', authenticate, async function (req, res, next) {
|
||||||
let userId = req.params.userId
|
let userId = req.params.userId
|
||||||
let requestProduct = req.body
|
let requestProduct = req.body
|
||||||
let { productId, color, size } = requestProduct.product
|
let { productId, color, size } = requestProduct.product
|
||||||
|
|
||||||
Cart.getCartByUserId(userId, function (err, c) {
|
try {
|
||||||
if (err) return next(err)
|
|
||||||
let oldCart = new CartClass(c[0] || {})
|
|
||||||
Product.getProductByID(productId, function (err, p) {
|
|
||||||
if (err) return next(err)
|
|
||||||
let newCart = oldCart.add(p, productId, { color, size })
|
|
||||||
|
|
||||||
//exist cart in databse
|
await Cart.getCartByUserId(userId, function (err, c) {
|
||||||
if (c.length > 0) {
|
if (err) return next(err)
|
||||||
Cart.updateCartByUserId(
|
let oldCart = new CartClass(c[0] || {})
|
||||||
userId,
|
|
||||||
{
|
Product.getProductByID(productId, function (err, p) {
|
||||||
|
if (err) return next(err)
|
||||||
|
let newCart = oldCart.add(p, productId, { color, size })
|
||||||
|
|
||||||
|
//exist cart in databse
|
||||||
|
if (c.length > 0) {
|
||||||
|
Cart.updateCartByUserId(
|
||||||
|
userId,
|
||||||
|
{
|
||||||
|
items: newCart.items,
|
||||||
|
totalQty: newCart.totalQty,
|
||||||
|
totalPrice: newCart.totalPrice,
|
||||||
|
userId: userId
|
||||||
|
},
|
||||||
|
function (err, result) {
|
||||||
|
if (err) return next(err)
|
||||||
|
res.json(result)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
//no cart in database
|
||||||
|
newCart = new Cart({
|
||||||
items: newCart.items,
|
items: newCart.items,
|
||||||
totalQty: newCart.totalQty,
|
totalQty: newCart.totalQty,
|
||||||
totalPrice: newCart.totalPrice,
|
totalPrice: newCart.totalPrice,
|
||||||
userId: userId
|
userId: userId
|
||||||
},
|
|
||||||
function (err, result) {
|
|
||||||
if (err) return next(err)
|
|
||||||
res.json(result)
|
|
||||||
})
|
})
|
||||||
} else {
|
Cart.createCart(newCart, function (err, resultCart) {
|
||||||
//no cart in database
|
if (err) return next(err)
|
||||||
newCart = new Cart({
|
res.status(201).json(resultCart)
|
||||||
items: newCart.items,
|
})
|
||||||
totalQty: newCart.totalQty,
|
}
|
||||||
totalPrice: newCart.totalPrice,
|
})
|
||||||
userId: userId
|
|
||||||
})
|
|
||||||
Cart.createCart(newCart, function (err, resultCart) {
|
|
||||||
if (err) return next(err)
|
|
||||||
res.status(201).json(resultCart)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_OK });
|
||||||
|
} catch (e) {
|
||||||
|
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//POST cart
|
//POST cart
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ const Cart = require('../models/cart');
|
|||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Department = require('../models/department');
|
const Department = require('../models/department');
|
||||||
|
const { Category } = require('../models/category');
|
||||||
const Group = require('../models/group');
|
const Group = require('../models/group');
|
||||||
|
|
||||||
const tools = require('../tools/general');
|
const tools = require('../tools/general');
|
||||||
@@ -373,6 +374,7 @@ router.post('/settable', authenticate, async (req, res) => {
|
|||||||
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined || mytablerec._id === '0')) {
|
if ((mydata['_id'] === undefined || mydata['_id'] === '' || (mytablerec.isNew && mydata['_id'] === 0)) && (mytablerec._id === undefined || mytablerec._id === '0')) {
|
||||||
mytablerec._id = new ObjectID();
|
mytablerec._id = new ObjectID();
|
||||||
mydata._id = new ObjectID();
|
mydata._id = new ObjectID();
|
||||||
|
mytablerec.isNew = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1403,6 +1405,7 @@ function load(req, res, version) {
|
|||||||
let workers = User.getusersWorkersList(idapp);
|
let workers = User.getusersWorkersList(idapp);
|
||||||
let storehouses = Storehouse.findAllIdApp(idapp);
|
let storehouses = Storehouse.findAllIdApp(idapp);
|
||||||
let departments = Department.findAllIdApp(idapp);
|
let departments = Department.findAllIdApp(idapp);
|
||||||
|
let categories = Category.findAllIdApp(idapp);
|
||||||
|
|
||||||
// SKILLS:
|
// SKILLS:
|
||||||
let levels = Level.findAllIdApp(idapp);
|
let levels = Level.findAllIdApp(idapp);
|
||||||
@@ -1486,6 +1489,7 @@ function load(req, res, version) {
|
|||||||
mygroups,
|
mygroups,
|
||||||
listcircuits, // 37
|
listcircuits, // 37
|
||||||
myelems, // 38
|
myelems, // 38
|
||||||
|
categories, // 39
|
||||||
]).then((arrdata) => {
|
]).then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
let myuser = req.user;
|
let myuser = req.user;
|
||||||
@@ -1567,7 +1571,10 @@ function load(req, res, version) {
|
|||||||
mygroups: arrdata[36],
|
mygroups: arrdata[36],
|
||||||
listcircuits: arrdata[37],
|
listcircuits: arrdata[37],
|
||||||
myelems: arrdata[38],
|
myelems: arrdata[38],
|
||||||
|
categories: arrdata[39],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const prova = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ const shared_consts = require('./tools/shared_nodejs');
|
|||||||
|
|
||||||
const {User} = require('./models/user');
|
const {User} = require('./models/user');
|
||||||
|
|
||||||
|
const { MsgTemplate } = require('./models/msg_template');
|
||||||
|
|
||||||
const transport_preview = nodemailer.createTransport({
|
const transport_preview = nodemailer.createTransport({
|
||||||
jsonTransport: true,
|
jsonTransport: true,
|
||||||
});
|
});
|
||||||
@@ -168,6 +170,9 @@ module.exports = {
|
|||||||
|
|
||||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||||
|
|
||||||
|
// ++ estrai l'html da mettere sulla email:
|
||||||
|
// const msghtml = await MsgTemplate.getMsgByLang(idapp, user, shared_consts.TypeMsgTemplate.MSG_BENV_REGISTRATO, user.lang);
|
||||||
|
|
||||||
let mylocalsconf = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
|
|||||||
@@ -893,6 +893,8 @@ const MyTelegramBot = {
|
|||||||
}, */
|
}, */
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
send_notif = true;
|
||||||
|
|
||||||
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_GRUPPO) {
|
} else if (myfunc === shared_consts.CallFunz.RICHIESTA_GRUPPO) {
|
||||||
|
|
||||||
domanda = printf(getstr(langdest, 'MSG_ACCEPT_NEWENTRY_INGROUP'), name) + '<br>' + struserinfomsg;
|
domanda = printf(getstr(langdest, 'MSG_ACCEPT_NEWENTRY_INGROUP'), name) + '<br>' + struserinfomsg;
|
||||||
@@ -924,6 +926,8 @@ const MyTelegramBot = {
|
|||||||
groupid + tools.SEP + groupname,
|
groupid + tools.SEP + groupname,
|
||||||
},*/
|
},*/
|
||||||
]);
|
]);
|
||||||
|
send_notif = true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest }, myuser.username, name) + '<br>' + struserinfomsg;
|
domanda = i18n.__({ phrase: 'CIRCUIT_ACCEPT_NEWENTRY', locale: langdest }, myuser.username, name) + '<br>' + struserinfomsg;
|
||||||
|
|
||||||
@@ -939,6 +943,7 @@ const MyTelegramBot = {
|
|||||||
groupid,
|
groupid,
|
||||||
}, */
|
}, */
|
||||||
]);
|
]);
|
||||||
|
send_notif = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ const Cart = require('../models/cart');
|
|||||||
const OrdersCart = require('../models/orderscart');
|
const OrdersCart = require('../models/orderscart');
|
||||||
const Storehouse = require('../models/storehouse');
|
const Storehouse = require('../models/storehouse');
|
||||||
const Department = require('../models/department');
|
const Department = require('../models/department');
|
||||||
|
const { Category } = require('../models/category');
|
||||||
const ShareWithUs = require('../models/sharewithus');
|
const ShareWithUs = require('../models/sharewithus');
|
||||||
const Site = require('../models/site');
|
const Site = require('../models/site');
|
||||||
const IscrittiConacreis = require('../models/iscrittiConacreis');
|
const IscrittiConacreis = require('../models/iscrittiConacreis');
|
||||||
@@ -105,6 +106,8 @@ module.exports = {
|
|||||||
mytable = Storehouse;
|
mytable = Storehouse;
|
||||||
else if (tablename === 'departments')
|
else if (tablename === 'departments')
|
||||||
mytable = Department;
|
mytable = Department;
|
||||||
|
else if (tablename === 'categorys')
|
||||||
|
mytable = Category;
|
||||||
else if (tablename === 'sharewithus')
|
else if (tablename === 'sharewithus')
|
||||||
mytable = ShareWithUs;
|
mytable = ShareWithUs;
|
||||||
else if (tablename === 'sites')
|
else if (tablename === 'sites')
|
||||||
|
|||||||
@@ -326,6 +326,38 @@ module.exports = {
|
|||||||
OPZ1_2: 2,
|
OPZ1_2: 2,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
UNITS_OF_MEASURE: {
|
||||||
|
NESSUNO: 0,
|
||||||
|
GRAMMI: 1,
|
||||||
|
CHILI: 2,
|
||||||
|
LITRI: 3,
|
||||||
|
PEZZI: 4,
|
||||||
|
},
|
||||||
|
|
||||||
|
Units_Of_Measure_ListBox: [
|
||||||
|
{
|
||||||
|
label: '[Nessuno]',
|
||||||
|
value: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Grammi (g)',
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Chili (kg)',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Litri (l)',
|
||||||
|
value: 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Pezzi (p)',
|
||||||
|
value: 4,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
|
||||||
CallFunz: {
|
CallFunz: {
|
||||||
SOSTITUISCI: 345,
|
SOSTITUISCI: 345,
|
||||||
AGGIUNGI_NUOVO_IMBARCO: 380,
|
AGGIUNGI_NUOVO_IMBARCO: 380,
|
||||||
@@ -379,6 +411,7 @@ module.exports = {
|
|||||||
TypeMsgTemplate: {
|
TypeMsgTemplate: {
|
||||||
MSG_BENVENUTO: 2010,
|
MSG_BENVENUTO: 2010,
|
||||||
MS_SHARE_LINK: 2000,
|
MS_SHARE_LINK: 2000,
|
||||||
|
MSG_BENV_REGISTRATO: 2020,
|
||||||
},
|
},
|
||||||
|
|
||||||
TypeSend: {
|
TypeSend: {
|
||||||
@@ -757,6 +790,7 @@ module.exports = {
|
|||||||
myreact: 1,
|
myreact: 1,
|
||||||
mycities: 1,
|
mycities: 1,
|
||||||
lang: 1,
|
lang: 1,
|
||||||
|
verified_by_aportador: 1,
|
||||||
'profile.img': 1,
|
'profile.img': 1,
|
||||||
'profile.mygroups': 1,
|
'profile.mygroups': 1,
|
||||||
'profile.mycircuits': 1,
|
'profile.mycircuits': 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user