- ordinamento per Data
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
DATABASE=test_FreePlanet
|
DATABASE=test_PiuCheBuono
|
||||||
UDB=paofreeplanet
|
UDB=paofreeplanet
|
||||||
PDB=mypassword@1A
|
PDB=mypassword@1A
|
||||||
SEND_EMAIL=0
|
SEND_EMAIL=0
|
||||||
SEND_EMAIL_ORDERS=1
|
SEND_EMAIL_ORDERS=1
|
||||||
PORT=3000
|
PORT=3000
|
||||||
appTelegram_TEST=["1","13"]
|
appTelegram_TEST=["1","17","18"]
|
||||||
appTelegram=["1","13"]
|
appTelegram=["1","17","18"]
|
||||||
DOMAIN=mongodb://localhost:27017/
|
DOMAIN=mongodb://localhost:27017/
|
||||||
AUTH_MONGODB=1
|
AUTH_MONGODB=1
|
||||||
MONGODB_USER=admin
|
MONGODB_USER=admin
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ const catalogo = new Schema(
|
|||||||
//++AddCATALOGO_FIELDS
|
//++AddCATALOGO_FIELDS
|
||||||
productTypes: [{ type: Number }],
|
productTypes: [{ type: Number }],
|
||||||
excludeproductTypes: [{ type: Number }],
|
excludeproductTypes: [{ type: Number }],
|
||||||
|
Editore: [{ type: String }],
|
||||||
// formato: [{ type: String, default: '' }],
|
// formato: [{ type: String, default: '' }],
|
||||||
// categoria: [{ type: String, default: '' }],
|
// categoria: [{ type: String, default: '' }],
|
||||||
// Editore: [{ type: String, default: '' }],
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ const productSchema = new Schema({
|
|||||||
active: {
|
active: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
arrversioni: [{
|
versione: {
|
||||||
type: Number,
|
type: Number,
|
||||||
}],
|
},
|
||||||
status: { //publish
|
status: { //publish
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
@@ -500,6 +500,20 @@ module.exports.findAllIdApp = async function (idapp, code, id, all) {
|
|||||||
as: 'productInfo.authors'
|
as: 'productInfo.authors'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'publishers',
|
||||||
|
localField: 'productInfo.idPublisher',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'productInfo.publisher'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: '$productInfo.publisher',
|
||||||
|
preserveNullAndEmptyArrays: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: 'catprods',
|
from: 'catprods',
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ const productInfoSchema = new Schema({
|
|||||||
date_publishing: {
|
date_publishing: {
|
||||||
type: Date,
|
type: Date,
|
||||||
},
|
},
|
||||||
|
date_publishing_ts: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
productTypes: [{
|
productTypes: [{
|
||||||
type: Number,
|
type: Number,
|
||||||
}],
|
}],
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let versione = 0;
|
let versione = 0;
|
||||||
let arrversioni = [];
|
|
||||||
|
|
||||||
productInfo.productTypes = [];
|
productInfo.productTypes = [];
|
||||||
// console.log('indprod', indprod, 'arrversGM', arrversGM, 'versione', product.Versione);
|
// console.log('indprod', indprod, 'arrversGM', arrversGM, 'versione', product.Versione);
|
||||||
@@ -374,48 +374,36 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
for (let i = 0; i < arrversGM.length; i++) {
|
for (let i = 0; i < arrversGM.length; i++) {
|
||||||
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
||||||
if (arrversGM[i] === 'Nuovo')
|
if (arrversGM[i] === 'Nuovo')
|
||||||
versione = shared_consts.VERSIONE.NUOVO
|
vers = shared_consts.PRODUCTTYPE.NUOVO
|
||||||
else if (arrversGM[i] === 'Usato')
|
else if (arrversGM[i] === 'Usato')
|
||||||
versione = shared_consts.VERSIONE.USATO;
|
vers = shared_consts.PRODUCTTYPE.USATO;
|
||||||
else if (arrversGM[i] === 'Download')
|
else if (arrversGM[i] === 'Download')
|
||||||
versione = shared_consts.VERSIONE.DOWNLOAD;
|
vers = shared_consts.PRODUCTTYPE.DOWNLOAD;
|
||||||
else if (arrversGM[i] === 'DVD')
|
else if (arrversGM[i] === 'DVD')
|
||||||
versione = shared_consts.VERSIONE.DVD;
|
vers = shared_consts.PRODUCTTYPE.DVD;
|
||||||
else if (arrversGM[i] === 'Epub')
|
else if (arrversGM[i] === 'Epub')
|
||||||
versione = shared_consts.VERSIONE.EPUB;
|
vers = shared_consts.PRODUCTTYPE.EPUB;
|
||||||
else if (arrversGM[i] === 'Mobi')
|
else if (arrversGM[i] === 'Mobi')
|
||||||
versione = shared_consts.VERSIONE.MOBI;
|
vers = shared_consts.PRODUCTTYPE.MOBI;
|
||||||
else if (arrversGM[i] === 'PDF')
|
else if (arrversGM[i] === 'PDF')
|
||||||
versione = shared_consts.VERSIONE.PDF;
|
vers = shared_consts.PRODUCTTYPE.PDF;
|
||||||
else if (arrversGM[i] === 'Streaming')
|
else if (arrversGM[i] === 'Streaming')
|
||||||
versione = shared_consts.VERSIONE.STREAMING;
|
vers = shared_consts.PRODUCTTYPE.STREAMING;
|
||||||
|
|
||||||
arrversioni.push(versione);
|
if (i === 0) {
|
||||||
|
// salvati il primo, // nel 99,9% dei casi c'è solo 1 elemento (perchè queste sono tutte le variazioni)
|
||||||
if (versione === shared_consts.VERSIONE.DOWNLOAD)
|
versione = vers;
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.DOWNLOAD);
|
|
||||||
else if (versione === shared_consts.VERSIONE.DVD)
|
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.DVD);
|
|
||||||
else if (versione === shared_consts.VERSIONE.EPUB)
|
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.EPUB);
|
|
||||||
else if (versione === shared_consts.VERSIONE.MOBI)
|
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.MOBI);
|
|
||||||
else if (versione === shared_consts.VERSIONE.PDF)
|
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.PDF);
|
|
||||||
else if (versione === shared_consts.VERSIONE.STREAMING)
|
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.STREAMING);
|
|
||||||
else if (versione === shared_consts.VERSIONE.USATO)
|
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.USATO);
|
|
||||||
else if (versione === shared_consts.VERSIONE.NUOVO)
|
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.NUOVO);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (productInfo.productTypes.length === 0) {
|
productInfo.productTypes.push(vers);
|
||||||
productInfo.productTypes.push(shared_consts.PRODUCTTYPE.LIBRO);
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
if (product.Data)
|
|
||||||
|
if (product.Data) {
|
||||||
productInfo.date_publishing = new Date(product.Data * 1000);
|
productInfo.date_publishing = new Date(product.Data * 1000);
|
||||||
|
// convert data to timestamp
|
||||||
|
productInfo.date_publishing_ts = productInfo.date_publishing.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
productInfo.name = productInfo.name.replace(/ - Usato$| - Nuovo$| - Epub$| - Ebook$| - Mobi$| - DVD$| - Streaming$| - Download$/, "");
|
productInfo.name = productInfo.name.replace(/ - Usato$| - Nuovo$| - Epub$| - Ebook$| - Mobi$| - DVD$| - Streaming$| - Download$/, "");
|
||||||
|
|
||||||
@@ -621,7 +609,9 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cerca l'indice della versione in arrvariazioni
|
// cerca l'indice della versione in arrvariazioni
|
||||||
let ind = arrvariazioni.findIndex(x => arrversioni.includes(x.versione));
|
let ind = arrvariazioni.findIndex(x =>
|
||||||
|
x.versione === versione)
|
||||||
|
|
||||||
let nuovaVariazione = ind < 0;
|
let nuovaVariazione = ind < 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -632,7 +622,7 @@ router.post('/import', authenticate, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
variazione.active = true; // ++ ??
|
variazione.active = true; // ++ ??
|
||||||
variazione.arrversioni = arrversioni;
|
variazione.versione = versione;
|
||||||
variazione.status = product.Stato ? product.Stato : null;
|
variazione.status = product.Stato ? product.Stato : null;
|
||||||
variazione.price = product.price ? parseFloat(tools.convertPriceEurToValue(product.price)) : null;
|
variazione.price = product.price ? parseFloat(tools.convertPriceEurToValue(product.price)) : null;
|
||||||
variazione.sale_price = product.sale_price ? parseFloat(tools.convertPriceEurToValue(product.sale_price)) : null;
|
variazione.sale_price = product.sale_price ? parseFloat(tools.convertPriceEurToValue(product.sale_price)) : null;
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ const SubCatProd = require('../models/subcatprod');
|
|||||||
const Gasordine = require('../models/gasordine');
|
const Gasordine = require('../models/gasordine');
|
||||||
const Product = require('../models/product');
|
const Product = require('../models/product');
|
||||||
const Author = require('../models/author');
|
const Author = require('../models/author');
|
||||||
|
const Publisher = require('../models/publisher');
|
||||||
const ProductInfo = require('../models/productInfo');
|
const ProductInfo = require('../models/productInfo');
|
||||||
const Scontistica = require('../models/scontistica');
|
const Scontistica = require('../models/scontistica');
|
||||||
const Department = require('../models/department');
|
const Department = require('../models/department');
|
||||||
@@ -1366,6 +1367,7 @@ router.post('/duprec/:table/:id', authenticate, async (req, res) => {
|
|||||||
|
|
||||||
tools.mylog('DUPLICATED ', rec);
|
tools.mylog('DUPLICATED ', rec);
|
||||||
|
|
||||||
|
|
||||||
// Do extra things after deleted
|
// Do extra things after deleted
|
||||||
return await actions.doOtherThingsAfterDuplicated(tablename, rec).
|
return await actions.doOtherThingsAfterDuplicated(tablename, rec).
|
||||||
then(({ myrec }) => {
|
then(({ myrec }) => {
|
||||||
@@ -1425,6 +1427,7 @@ function load(req, res, version) {
|
|||||||
|
|
||||||
// tools.mylog('loadsite : ', req.params);
|
// tools.mylog('loadsite : ', req.params);
|
||||||
|
|
||||||
|
|
||||||
let bookedevent = [];
|
let bookedevent = [];
|
||||||
// let msgs = [];
|
// let msgs = [];
|
||||||
|
|
||||||
@@ -1490,6 +1493,7 @@ function load(req, res, version) {
|
|||||||
}
|
}
|
||||||
let products = Product.findAllIdApp(idapp, undefined, undefined, ismanager);
|
let products = Product.findAllIdApp(idapp, undefined, undefined, ismanager);
|
||||||
let authors = Author.findAllIdApp(idapp);
|
let authors = Author.findAllIdApp(idapp);
|
||||||
|
let publishers = Publisher.findAllIdApp(idapp);
|
||||||
let productInfos = ProductInfo.findAllIdApp(idapp);
|
let productInfos = ProductInfo.findAllIdApp(idapp);
|
||||||
let scontisticas = Scontistica.findAllIdApp(idapp);
|
let scontisticas = Scontistica.findAllIdApp(idapp);
|
||||||
let departments = Department.findAllIdApp(idapp);
|
let departments = Department.findAllIdApp(idapp);
|
||||||
@@ -1587,6 +1591,7 @@ function load(req, res, version) {
|
|||||||
catprods_gas,
|
catprods_gas,
|
||||||
catAI,
|
catAI,
|
||||||
authors,
|
authors,
|
||||||
|
publishers,
|
||||||
]).then((arrdata) => {
|
]).then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
let myuser = req.user;
|
let myuser = req.user;
|
||||||
@@ -1680,6 +1685,7 @@ function load(req, res, version) {
|
|||||||
catAI: arrdata[48],
|
catAI: arrdata[48],
|
||||||
code: req.code,
|
code: req.code,
|
||||||
authors: arrdata[49],
|
authors: arrdata[49],
|
||||||
|
publishers: arrdata[50],
|
||||||
});
|
});
|
||||||
|
|
||||||
const prova = 1;
|
const prova = 1;
|
||||||
|
|||||||
@@ -1104,15 +1104,5 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
// Download, DVD, Epub, Mobi, Nuovo, PDF, Streaming, Usato
|
||||||
VERSIONE: {
|
|
||||||
NUOVO: 1,
|
|
||||||
USATO: 2,
|
|
||||||
DOWNLOAD: 3,
|
|
||||||
DVD: 4,
|
|
||||||
EPUB: 5,
|
|
||||||
MOBI: 6,
|
|
||||||
PDF: 7,
|
|
||||||
STREAMING: 8,
|
|
||||||
},
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user