/var/www/greso.tech/server/nsm/services
NameSizeModeActions
auth.service.js9740644editdlrm
company.service.js15340644editdlrm
index.js9350644editdlrm
inventory.service.js21180644editdlrm
lead.service.js15180644editdlrm
mail.service.js99910644editdlrm
order.service.js53520644editdlrm
rateArea.service.js20220644editdlrm
system.service.js8720644editdlrm
webSocket.service.js46110644editdlrm
Edit: /var/www/greso.tech/server/nsm/services/lead.service.js (1518B)
const logger = require('../logger')({ service: 'OrderService' }) const { Op } = require('sequelize') const { isSet, isArray } = require('../utils/validator.util') module.exports = class LeadService { constructor({ db, config }) { this.db = db this.ld = VARS.ld this.next = 0 this.config = config logger.child({ service: 'LeadService', method: 'Constructor' }).info('Success') } async Run() { // load ld this.ld = await this.db.leadDistribution.findAll() var ldCount = this.ld.length; logger.child({ service: 'LeadService', method: 'Run' }).info('Success. Sales representative: ' + ldCount) console.log('LeadService Run Success. Sales representative: ' + ldCount) } async Reload() { this.ld = await this.db.leadDistribution.findAll() var ldCount = this.ld.length; if (this.next > ldCount - 1) { this.next = 0 } logger.child({ service: 'LeadService', method: 'Reload' }).info('Success') console.log('LeadService Reload Success. Sales representative: ' + ldCount) } async Stop() { logger.child({ service: 'LeadService', method: 'Stop' }).info('Success') } //////////////////////////////////////////////////////////////////////////////////////// async GetNextLD(companyId) { // list ld by company var list = [] var res for (let val of this.ld) { if (val.companyId != companyId) continue list.push(val) } if (list.length > 0) { res = list[this.next] this.next++ if (this.next == list.length) { this.next = 0 } } return res } }