/var/www/greso.tech/server/nsm/services
Edit: /var/www/greso.tech/server/nsm/services/inventory.service.js (2118B)
const logger = require('../logger')({ service: 'OrderService' })
const { Op } = require('sequelize')
module.exports = class InventoryService {
constructor({ db, config }) {
this.db = db
this.interval = null
this.config = config
logger.child({ service: 'InventoryService', method: 'Constructor' }).info('Success')
}
async Run() {
logger.child({ service: 'InventoryService', method: 'Run' }).info('Success')
}
async Stop() {
this.interval = null
logger.child({ service: 'InventoryService', method: 'Stop' }).info('Success')
}
////////////////////////////////////////////////////////////////////////////////////////
async UpdateInventory(order) {
const inventory = await db.orderInventory.findOne({
// include: [{ model: db.role }],
where: { id: id }
})
if (!inventory) {
throw new NotFound({ lang: req.user?.languageCode })
}
inventory.rate = order.rate
inventory.items_weight = order.items_weight
inventory.items_volume = order.items_volume
inventory.items_count = items_count
inventory.items_total = items_total
inventory.bulky_count = bulky_count
inventory.bulky_total = bulky_total
inventory.extras_count = extras_count
inventory.extras_total = extras_total
inventory.packages_count = packages_count
inventory.packages_total = packages_total
inventory.fuel_percent = fuel_percent
inventory.fuel_total = fuel_total
inventory.discount_cash = discount_cash
inventory.total = total
inventory.paid = paid
inventory.due = due
await inventory.save()
// // отправить клинету
// await SERVICES.WebSocketService.SendToClient(order.userId, status, headerClients)
// // отправить company
// if(order.companyId != null && order.companyId != ''){
// await SERVICES.WebSocketService.SendToCrmByCompany(
// order.companyId,
// status,
// headerOperators
// )
// }
// // отправить branch
// if(order.branchId != null && order.branchId != ''){
// await SERVICES.WebSocketService.SendToCrmByBranch(
// order.branchId,
// status,
// headerOperators
// )
// }
}
}