corretto
This commit is contained in:
@@ -353,7 +353,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
const { User } = require('../models/user');
|
||||
|
||||
|
||||
let orderscart = await OrdersCart.findOne({ idapp, _id: order_id }).lean();
|
||||
let myOrdersCart = await OrdersCart.findOne({ idapp, _id: order_id }).lean();
|
||||
|
||||
if ((userId !== String(req.user._id)) && !User.isManager(req.user.perm)) {
|
||||
// I'm trying to write something not mine!
|
||||
@@ -361,19 +361,19 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
}
|
||||
|
||||
try {
|
||||
if (!!orderscart) {
|
||||
if (!!myOrdersCart) {
|
||||
|
||||
let fields_to_update = { status };
|
||||
|
||||
await OrdersCart.findOneAndUpdate({ _id: order_id }, { $set: fields_to_update }
|
||||
, { new: false })
|
||||
.then(async (ris) => {
|
||||
const userDest = await User.findById(ordersCart.userId).lean();
|
||||
const userDest = await User.findById(myOrdersCart.userId).lean();
|
||||
|
||||
if (ris) {
|
||||
|
||||
// Aggiorna gli Stati Interni !
|
||||
ordersCart = await OrdersCart.updateCmd(ordersCart, status, true, options);
|
||||
myOrdersCart = await OrdersCart.updateCmd(myOrdersCart, status, true, options);
|
||||
|
||||
let ordertype = '';
|
||||
|
||||
@@ -386,7 +386,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
}
|
||||
|
||||
if (ordertype !== '') {
|
||||
sendemail.sendEmail_Order(userDest.lang, idapp, ordersCart, userDest, ordertype, status)
|
||||
sendemail.sendEmail_Order(userDest.lang, idapp, myOrdersCart, userDest, ordertype, status)
|
||||
.then((ris) => {
|
||||
|
||||
})
|
||||
@@ -394,6 +394,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
let orderscart = null;
|
||||
|
||||
if (User.isManager(user.perm)) {
|
||||
@@ -407,6 +408,7 @@ router.post('/:userId/ordercartstatus', authenticate, async function (req, res,
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('err', e);
|
||||
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user