Carrello con scontistica aggiornata

This commit is contained in:
Surya Paolo
2023-12-18 12:11:12 +01:00
parent 56b5bac5f0
commit 7628fb97fc
7 changed files with 154 additions and 66 deletions

View File

@@ -58,8 +58,12 @@ router.post('/:userId', authenticate, async function (req, res, next) {
let mycart = await Cart.getCartByUserId(userId, idapp);
// const myorder = Order.getOrderByID(order._id);
if (!addqty && !subqty)
if (!addqty && !subqty) {
order._id = await Order.createOrder(order);
if (!order._id) {
return res.send({ code: server_constants.RIS_CODE_ERR, cart: 0 });
}
}
let cart = null;
let product = null;
@@ -222,7 +226,7 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
let note = req.body.note;
try {
const mycart = await Cart.findOne({ _id: cart_id });
let mycart = await Cart.findOne({ _id: cart_id });
let numorder = await OrdersCart.getLastNumOrder(idapp);
let numord_pers = await OrdersCart.getLastNumOrdPers(userId, idapp);
@@ -301,6 +305,7 @@ router.post('/:userId/createorderscart', authenticate, async function (req, res,
recOrderCart: myorderCart
});
} catch (e) {
console.error('Err', e);
return res.send({ code: server_constants.RIS_CODE_ERR, status: 0, recOrderCart: null });
}