Commit c92a2a4d by Sxy

fix: 商机 companyFind

parent 2216c387
...@@ -408,63 +408,66 @@ class UserService extends ServiceBase { ...@@ -408,63 +408,66 @@ class UserService extends ServiceBase {
await self.cacheManager["ClientBindBizUserCache"].invalidate(clientMobile) await self.cacheManager["ClientBindBizUserCache"].invalidate(clientMobile)
} }
} }
if (isGoExec) { let companyFind = await self.companyDao.model.findOne({
let companyFind = await self.companyDao.model.findOne({ where: { name: spName }, include: [
where: { name: spName }, include: [ {
{ model: self.db.models.user, as: "us", attributes: ['id', 'userName', 'mobile', 'isAllocated', 'opath', 'skilltags', 'regiontags', 'isAllArea', 'isSalesman', 'isDelivery'], raw: true
model: self.db.models.user, as: "us", attributes: ['id', 'userName', 'mobile', 'isAllocated', 'opath', 'skilltags', 'regiontags', 'isAllArea', 'isSalesman', 'isDelivery'], raw: true }
} ], excludes: ['orgJson'], transaction: t
], excludes: ['orgJson'], transaction: t });
}); console.log("getBizUserForBizChance获取服务商信息:" + companyFind);
console.log("getBizUserForBizChance获取服务商信息:" + JSON.stringify(companyFind)); if (companyFind) {
let users = companyFind.us if (isGoExec) {
let cansels = users.filter(u => { let users = companyFind.us
if (regionName && regionName != "" && u.regiontags) { let cansels = users.filter(u => {
if (u.isAllocated && u.isSalesman && u.skilltags.indexOf(productCatName) >= 0) { if (regionName && regionName != "" && u.regiontags) {
if (u.regiontags.indexOf(regionName) >= 0 || u.isAllArea) { if (u.isAllocated && u.isSalesman && u.skilltags.indexOf(productCatName) >= 0) {
return true if (u.regiontags.indexOf(regionName) >= 0 || u.isAllArea) {
return true
} else {
return false
}
} else { } else {
return false return false
} }
} else { } else {
return false if (u.isAllocated && u.isSalesman && u.isAllArea && u.skilltags.indexOf(productCatName) >= 0) {
return true
} else {
return false
}
} }
} else {
if (u.isAllocated && u.isSalesman && u.isAllArea && u.skilltags.indexOf(productCatName) >= 0) { })
return true console.log("getBizUserForBizChance可以接单的业务员:" + JSON.stringify(cansels) + "服务商id:" + companyFind.id);
} else { let lngth = cansels.length
return false if (lngth > 0) {
let randindex = Math.floor(Math.random() * lngth)
let selresult = cansels[randindex]
//添加到缓存,按照客户电话key--缓存到业务员的对象
let tmp = {
userId: selresult.id,
userName: selresult.userName,
mobile: selresult.mobile,
opath: selresult.opath,
compId: companyFind.id
} }
await self.cacheManager["ClientBindBizUserCache"].cache(clientMobile, tmp)
return { userInfo: tmp, comInfo: { compId: tmp.compId } };
} else {
return { userInfo: null, comInfo: { compId: tmp.compId } };
} }
})
console.log("getBizUserForBizChance可以接单的业务员:" + JSON.stringify(cansels) + "服务商id:" + companyFind.id);
let lngth = cansels.length
if (lngth > 0) {
let randindex = Math.floor(Math.random() * lngth)
let selresult = cansels[randindex]
//添加到缓存,按照客户电话key--缓存到业务员的对象
let tmp = {
userId: selresult.id,
userName: selresult.userName,
mobile: selresult.mobile,
opath: selresult.opath,
compId: companyFind.id
}
await self.cacheManager["ClientBindBizUserCache"].cache(clientMobile, tmp)
return { userInfo: tmp, comInfo: { compId: tmp.compId } };
} else { } else {
return { userInfo: null, comInfo: { compId: tmp.compId } }; if (resultcache) {//不继续,直接返回缓存
return { userInfo: resultcache.tmp, comInfo: { compId: companyFind.id } };
} else {
return { userInfo: null, comInfo: { compId: companyFind.id } };
}
} }
} else { } else {
if (resultcache) {//不继续,直接返回缓存 return { userInfo: null, comInfo: null }
return { userInfo: resultcache.tmp, comInfo: { compId: companyFind.id } };
} else {
return { userInfo: null, comInfo: { compId: companyFind.id } };
}
} }
}) })
} }
async findCostBySkuCode(skucode) { async findCostBySkuCode(skucode) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment