- corretto cancellazione ordine
This commit is contained in:
@@ -19,7 +19,7 @@ const Order = require('../models/order');
|
||||
const Variant = require('../models/variant');
|
||||
const { User } = require('../models/user');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
/*const Department = require('../models/Department')
|
||||
const Category = require('../models/Category')
|
||||
@@ -489,20 +489,6 @@ router.post('/:userId/gestord', authenticate, async function (req, res, next) {
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{
|
||||
'gasordine.active': true,
|
||||
},
|
||||
{
|
||||
gasordine: {
|
||||
$exists: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
@@ -519,6 +505,21 @@ router.post('/:userId/gestord', authenticate, async function (req, res, next) {
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: "orderscarts",
|
||||
localField: "_id",
|
||||
foreignField: "items.order",
|
||||
as: "matchingOrders",
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
"matchingOrders": {
|
||||
$ne: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: '$product._id',
|
||||
|
||||
@@ -31,7 +31,7 @@ const Cart = require('../models/cart');
|
||||
router.post('/', auth_default, async function (req, res, next) {
|
||||
const idapp = req.body.idapp;
|
||||
const userId = req.body.userId;
|
||||
|
||||
|
||||
let ismanager = await tools.isManagerByReq(req);
|
||||
|
||||
let products = await Product.findAllIdApp(idapp, "", undefined, ismanager);
|
||||
@@ -43,11 +43,30 @@ router.post('/', auth_default, async function (req, res, next) {
|
||||
orders = await OrdersCart.getOrdersCartByUserId(userId, idapp, 0, false);
|
||||
}
|
||||
|
||||
let ind = 0;
|
||||
for (const ord of orders) {
|
||||
let newitems = []
|
||||
for (myord of ord.items) {
|
||||
if (!myord.order) {
|
||||
console.log('NO ORDINE ', myord, 'Ind=', ind);
|
||||
} else {
|
||||
if (myord.order && !myord.order.hasOwnProperty('idGasordine')) {
|
||||
console.log('NO idGasordine', myord);
|
||||
} else {
|
||||
newitems.push(myord)
|
||||
}
|
||||
}
|
||||
}
|
||||
ind++;
|
||||
|
||||
ord.items = newitems
|
||||
}
|
||||
|
||||
if (products)
|
||||
return res.send({ code: server_constants.RIS_CODE_OK, products, orders });
|
||||
else
|
||||
return res.status(400).send({ code: server_constants.RIS_CODE_OK, products, orders });
|
||||
|
||||
|
||||
});
|
||||
|
||||
router.post('/:code', auth_default, async function (req, res, next) {
|
||||
|
||||
@@ -1247,6 +1247,8 @@ async function eseguiDbOp(idapp, mydata, locale, req, res) {
|
||||
await Reaction.updateReactionsCounts();
|
||||
} else if (mydata.dbop === 'GeneraCSVOrdineProdotti') {
|
||||
await Order.GeneraCSVOrdineProdotti();
|
||||
} else if (mydata.dbop === 'RemoveDeletedOrdersInOrderscart') {
|
||||
await Order.RemoveDeletedOrdersInOrderscart();
|
||||
} else if (mydata.dbop === 'AbilitaNewsletterALL') {
|
||||
await User.updateMany({
|
||||
$or: [
|
||||
|
||||
Reference in New Issue
Block a user