Commit c92a2a4d by Sxy

fix: 商机 companyFind

parent 2216c387
......@@ -408,63 +408,66 @@ class UserService extends ServiceBase {
await self.cacheManager["ClientBindBizUserCache"].invalidate(clientMobile)
}
}
if (isGoExec) {
let companyFind = await self.companyDao.model.findOne({
where: { name: spName }, include: [
{
model: self.db.models.user, as: "us", attributes: ['id', 'userName', 'mobile', 'isAllocated', 'opath', 'skilltags', 'regiontags', 'isAllArea', 'isSalesman', 'isDelivery'], raw: true
}
], excludes: ['orgJson'], transaction: t
});
console.log("getBizUserForBizChance获取服务商信息:" + JSON.stringify(companyFind));
let users = companyFind.us
let cansels = users.filter(u => {
if (regionName && regionName != "" && u.regiontags) {
if (u.isAllocated && u.isSalesman && u.skilltags.indexOf(productCatName) >= 0) {
if (u.regiontags.indexOf(regionName) >= 0 || u.isAllArea) {
return true
let companyFind = await self.companyDao.model.findOne({
where: { name: spName }, include: [
{
model: self.db.models.user, as: "us", attributes: ['id', 'userName', 'mobile', 'isAllocated', 'opath', 'skilltags', 'regiontags', 'isAllArea', 'isSalesman', 'isDelivery'], raw: true
}
], excludes: ['orgJson'], transaction: t
});
console.log("getBizUserForBizChance获取服务商信息:" + companyFind);
if (companyFind) {
if (isGoExec) {
let users = companyFind.us
let cansels = users.filter(u => {
if (regionName && regionName != "" && u.regiontags) {
if (u.isAllocated && u.isSalesman && u.skilltags.indexOf(productCatName) >= 0) {
if (u.regiontags.indexOf(regionName) >= 0 || u.isAllArea) {
return true
} else {
return false
}
} else {
return false
}
} 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
} else {
return false
})
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 {
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 {
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 {
if (resultcache) {//不继续,直接返回缓存
return { userInfo: resultcache.tmp, comInfo: { compId: companyFind.id } };
} else {
return { userInfo: null, comInfo: { compId: companyFind.id } };
}
return { userInfo: null, comInfo: null }
}
})
}
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