- edit campi prodotti

- edit ordini
This commit is contained in:
Surya Paolo
2024-01-13 00:28:53 +01:00
parent c63e345285
commit 7bf549569d
6 changed files with 126 additions and 8 deletions

View File

@@ -14,6 +14,9 @@ const ProductInfo = require('../models/productInfo');
const { Circuit } = require('../models/circuit');
const CartClass = require('../modules/Cart')
const Cart = require('../models/cart');
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
@@ -794,6 +797,46 @@ OrdersCartSchema.pre('save', async function (next) {
}
});
module.exports.updateOrdersCartByParams = async function (idOrdersCart, paramstoupdate) {
const ris = await OrdersCart.findOneAndUpdate({ _id: idOrdersCart }, { $set: paramstoupdate });
let myorderscart = await Order.findOne({ _id: idOrder });
return myorderscart;
}
module.exports.updateOrdersCartTotals = async function (idOrdersCart, update) {
try {
let orderscart = await OrdersCart.getOrdersCartById(idOrdersCart);
if (orderscart) {
let newOrdersCart = CartClass.constructByCart(orderscart);
await newOrdersCart.updatetotals();
if (update) {
await OrdersCart.findOneAndUpdate({ _id: idOrdersCart }, {
$set: {
totalPrice: newOrdersCart.totalPrice,
totalQty: newOrdersCart.totalQty,
note: newOrdersCart.note,
modify_at: new Date(),
},
}
)
}
orderscart = await OrdersCart.getOrdersCartById(idOrdersCart);
return orderscart;
}
} catch (e) {
console.error('err', e);
}
};
module.exports.getmsgorderTelegram = async function (ordersCart) {
try {
const statusstr = shared_consts.getStatusStr(ordersCart.status);