- Uscita PRIMA VERSIONE PiuCheBuono.app
This commit is contained in:
@@ -74,13 +74,15 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
if (product.cat_name) {
|
||||
arrcat = product.cat_name.trim().split(',');
|
||||
for (const mycat of arrcat) {
|
||||
let mycatstr = mycat.trim();
|
||||
|
||||
// Cerca la Categoria
|
||||
let reccateg = await CatProd.findOne({ idapp, name: mycat }).lean();
|
||||
let reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
if (!reccateg) {
|
||||
// Non esiste questo produttore, quindi lo creo !
|
||||
reccateg = new CatProd({ idapp, name: mycat });
|
||||
reccateg = new CatProd({ idapp, name: mycatstr });
|
||||
ris = await reccateg.save();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycat }).lean();
|
||||
reccateg = await CatProd.findOne({ idapp, name: mycatstr }).lean();
|
||||
}
|
||||
|
||||
if (reccateg) {
|
||||
@@ -125,9 +127,10 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
|
||||
if (!options.aggiornaStockQty && esisteindb) {
|
||||
delete product.stockQty;
|
||||
delete product.bookableQty;
|
||||
delete product.maxbookableGASQty;
|
||||
}
|
||||
|
||||
// AGGIORNA PRODUCT
|
||||
let risrec = await Product.findOneAndUpdate({ idProductInfo: product.idProductInfo }, { $set: product }, { new: true, upsert: true });
|
||||
|
||||
let recnew = await Product.findOne({ idProductInfo: product.idProductInfo }).lean();
|
||||
@@ -150,7 +153,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
errors++;
|
||||
}
|
||||
|
||||
await Product.singlerecconvert_AfterImport(idapp, recnew, isnuovo);
|
||||
await Product.singlerecconvert_AfterImport_AndSave(idapp, recnew, isnuovo);
|
||||
} else {
|
||||
console.error('Error ProductInfo: ', product.code);
|
||||
errors++;
|
||||
@@ -162,7 +165,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
/*return await Product.insertMany(dataObjects, { ordered: false })
|
||||
.then((ris) => {
|
||||
|
||||
Product.convertAfterImport(idapp, dataObjects).then((ris) => {
|
||||
Product.convertAfterImportALLPROD(idapp, dataObjects).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
|
||||
@@ -170,7 +173,7 @@ router.post('/import', authenticate, async (req, res) => {
|
||||
})
|
||||
.catch((errors) => {
|
||||
console.error(errors);
|
||||
Product.convertAfterImport(idapp).then((ris) => {
|
||||
Product.convertAfterImportALLPROD(idapp).then((ris) => {
|
||||
return res.status(200).send(true);
|
||||
});
|
||||
});*/
|
||||
|
||||
@@ -290,7 +290,7 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||
else {
|
||||
|
||||
await Order.updateStatusOrders(mycart.items, status);
|
||||
await Order.updateStatusOrders(mycart.items, status);
|
||||
|
||||
const myris = ris;
|
||||
// Cancella il Cart appena salvato in OrdersCart
|
||||
@@ -302,6 +302,8 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
|
||||
.then((orders) => {
|
||||
if (!!orders) {
|
||||
|
||||
OrdersCart.updateCmd(orders[0], status, true);
|
||||
|
||||
// Invia la email dell'Ordine
|
||||
sendemail.sendEmail_OrderProduct(user.lang, idapp, orders[0], user)
|
||||
.then(async (ris) => {
|
||||
@@ -384,7 +386,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
}
|
||||
|
||||
if (ordertype !== '') {
|
||||
sendemail.sendEmail_Order(user.lang, idapp, orderCart, user, ordertype)
|
||||
sendemail.sendEmail_Order(user.lang, idapp, orderCart, user, ordertype, status)
|
||||
.then((ris) => {
|
||||
|
||||
})
|
||||
|
||||
@@ -36,6 +36,7 @@ const { authenticate, authenticate_noerror } = require('../middleware/authentica
|
||||
const Cart = require('../models/cart');
|
||||
const CartClass = require('../modules/Cart');
|
||||
const Product = require('../models/product');
|
||||
const CatProd = require('../models/catprod');
|
||||
const ProductInfo = require('../models/productInfo');
|
||||
const Order = require('../models/order');
|
||||
const OrdersCart = require('../models/orderscart');
|
||||
@@ -1311,6 +1312,10 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
await Product.collection.drop();
|
||||
ris = await ProductInfo.collection.drop();
|
||||
|
||||
} else if (mydata.dbop === 'dropCatProd') {
|
||||
|
||||
await CatProd.collection.drop();
|
||||
|
||||
} else if (mydata.dbop === 'dropAllOrders') {
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user