aggiornato prodotti e scontistica
This commit is contained in:
@@ -22,6 +22,12 @@ const CatProdSchema = new Schema({
|
||||
img: {
|
||||
type: String,
|
||||
},
|
||||
icon: {
|
||||
type: String,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
CatProdSchema.statics.getAllCategories = function (callback) {
|
||||
|
||||
@@ -66,6 +66,11 @@ const productSchema = new Schema({
|
||||
default: 1,
|
||||
required: true,
|
||||
},
|
||||
minStepQty: { // step quantità acquistabile
|
||||
type: Number,
|
||||
default: 1,
|
||||
required: true,
|
||||
},
|
||||
maxBookableQty: { // quantità massima Pre-ordinabile (singolarmente)
|
||||
type: Number,
|
||||
default: 0,
|
||||
@@ -113,6 +118,12 @@ const productSchema = new Schema({
|
||||
cat_name: {
|
||||
type: String,
|
||||
},
|
||||
sconto1: {
|
||||
type: String,
|
||||
},
|
||||
sconto2: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
var Product = module.exports = mongoose.model('Product', productSchema);
|
||||
@@ -502,6 +513,7 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
objtoset = {
|
||||
idapp,
|
||||
minBuyQty: 1,
|
||||
minStepQty: 1,
|
||||
maxBookableQty: 0,
|
||||
}
|
||||
}
|
||||
@@ -563,6 +575,46 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
}
|
||||
}
|
||||
|
||||
let arrsconti = []
|
||||
|
||||
if (prod.sconto1) {
|
||||
// Cerca la scontistica
|
||||
let recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto1 }).lean();
|
||||
if (!recscontistica) {
|
||||
recscontistica = new Scontistica({ idapp, code: prod.sconto1 });
|
||||
// Non esiste questa scontistica, quindi lo creo !
|
||||
ris = await recscontistica.save();
|
||||
recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto1 }).lean();
|
||||
}
|
||||
|
||||
if (recscontistica) {
|
||||
arrsconti.push(recscontistica);
|
||||
}
|
||||
}
|
||||
|
||||
if (prod.sconto2) {
|
||||
// Cerca la scontistica
|
||||
let recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto2 }).lean();
|
||||
if (!recscontistica) {
|
||||
recscontistica = new Scontistica({ idapp, code: prod.sconto2 });
|
||||
// Non esiste questa scontistica, quindi lo creo !
|
||||
ris = await recscontistica.save();
|
||||
recscontistica = await Scontistica.findOne({ idapp, code: prod.sconto2 }).lean();
|
||||
}
|
||||
|
||||
if (recscontistica) {
|
||||
arrsconti.push(recscontistica);
|
||||
}
|
||||
}
|
||||
|
||||
if (arrsconti.length > 0) {
|
||||
objtoset = {
|
||||
...objtoset,
|
||||
idScontisticas: arrsconti,
|
||||
}
|
||||
setta = true;
|
||||
}
|
||||
|
||||
// Aggiorna il prezzo ?
|
||||
const aggiornaprezzo = false;
|
||||
if (aggiornaprezzo) {
|
||||
@@ -584,6 +636,8 @@ module.exports.singlerecconvert_AfterImport = async function (idapp, prod, isnuo
|
||||
producer_name: 1,
|
||||
provider_name: 1,
|
||||
magazzino_name: 1,
|
||||
sconto1: 1,
|
||||
sconto2: 1,
|
||||
};
|
||||
|
||||
ris = await Product.updateOne({ _id: ObjectID(prod._id) }, { $unset: objDelete })
|
||||
|
||||
@@ -287,6 +287,9 @@ const UserSchema = new mongoose.Schema({
|
||||
manage_telegram: {
|
||||
type: Boolean,
|
||||
},
|
||||
admin_telegram: {
|
||||
type: Boolean,
|
||||
},
|
||||
resplist: {
|
||||
type: Boolean,
|
||||
},
|
||||
@@ -3606,7 +3609,7 @@ UserSchema.statics.getusersAdmin = async function (idapp) {
|
||||
|
||||
// Int32 mongodb 6.0
|
||||
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true, perm: { $bitsAnySet: 0b001 } },
|
||||
return await User.find({ idapp, 'profile.admin_telegram': true, perm: { $bitsAnySet: 0b001 } },
|
||||
{ username: 1, 'profile.teleg_id': 1, perm: 1 }).then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
@@ -3707,7 +3710,7 @@ UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
|
||||
return await User.findOne({
|
||||
idapp,
|
||||
username: 'paoloar77',
|
||||
'profile.manage_telegram': true,
|
||||
'profile.admin_telegram': true,
|
||||
'profile.teleg_id': idtelegram,
|
||||
}, { 'profile.teleg_id': 1 }).then((rec) => {
|
||||
return (!!rec && rec.profile.teleg_id === idtelegram);
|
||||
@@ -5407,6 +5410,7 @@ UserSchema.statics.addNewSite = async function (idappPass, body) {
|
||||
myuser.profile.special_req = true;
|
||||
myuser.profile.nationality = 'IT';
|
||||
myuser.profile.manage_telegram = true;
|
||||
myuser.profile.admin_telegram = true;
|
||||
myuser.profile.teleg_id = MyTelegramBot.ADMIN_IDTELEGRAM_SERVER;
|
||||
myuser.profile.username_telegram = MyTelegramBot.ADMIN_USERNAME_TELEGRAM;
|
||||
myuser.lasttimeonline = new Date();
|
||||
|
||||
Reference in New Issue
Block a user