- edit campi prodotti
- edit ordini
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user