Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
c92a2a4d
Commit
c92a2a4d
authored
Aug 17, 2020
by
Sxy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 商机 companyFind
parent
2216c387
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
45 deletions
+48
-45
center-manage/app/base/service/impl/auth/userSve.js
+48
-45
No files found.
center-manage/app/base/service/impl/auth/userSve.js
View file @
c92a2a4d
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment