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
9a557a21
Commit
9a557a21
authored
Jul 29, 2020
by
王勇飞
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gsb-center-manage' of gitlab.gongsibao.com:jiangyong/zhichan into gsb-center-manage
parents
bdbe32bf
4e733e98
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
873 additions
and
97 deletions
+873
-97
center-manage/app/base/db/models/auth/user.js
+21
-1
center-manage/app/base/service/impl/auth/userSve.js
+108
-7
center-manage/app/base/service/impl/common/channelhandlers/ali.js
+528
-0
center-manage/app/base/service/impl/common/companySve.js
+23
-23
center-manage/app/base/system.js
+17
-1
center-manage/app/config/environment.js
+35
-21
center-manage/app/config/routes/api.js
+103
-26
center-manage/app/config/routes/web.js
+15
-15
center-manage/app/config/settings.js
+22
-3
center-manage/package.json
+1
-0
No files found.
center-manage/app/base/db/models/auth/user.js
View file @
9a557a21
...
...
@@ -55,7 +55,27 @@ module.exports = (db, DataTypes) => {
regiontags
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
}
// 区域标签
},
// 区域标签
openid
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
unid
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
,
},
isDelivery
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
isSalesman
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
},
isAllArea
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
}
},
{
paranoid
:
true
,
//假的删除
underscored
:
true
,
...
...
center-manage/app/base/service/impl/auth/userSve.js
View file @
9a557a21
...
...
@@ -115,7 +115,6 @@ class UserService extends ServiceBase {
//创建统一账号 to add extra fields
let
cred
=
await
self
.
cregister
(
u
.
userName
,
p
.
company_id
,
p
.
password
,
u
.
id
+
""
)
console
.
log
(
"......................................"
);
console
.
log
(
cred
.
consumer
.
id
);
if
(
cred
)
{
u
.
center_id
=
cred
.
consumer
.
id
;
u
.
jwtkey
=
cred
.
key
;
...
...
@@ -392,7 +391,7 @@ class UserService extends ServiceBase {
*/
async
getBizUserForBizChance
(
clientMobile
,
spName
,
productCatName
,
regionName
)
{
var
self
=
this
clientMobile
=
clientMobile
+
"_"
+
spName
+
"_"
+
regionName
clientMobile
=
clientMobile
+
"_"
+
spName
+
"_"
+
regionName
+
"_"
+
productCatName
//按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称
return
this
.
db
.
transaction
(
async
function
(
t
)
{
//先检查缓存是否存在bizuser
...
...
@@ -420,13 +419,13 @@ class UserService extends ServiceBase {
let
users
=
companyFind
.
us
let
cansels
=
users
.
filter
(
u
=>
{
if
(
regionName
&&
regionName
!=
""
&&
u
.
regiontags
)
{
if
(
u
.
isAllocated
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
&&
u
.
regiontags
.
indexOf
(
regionName
)
>=
0
)
{
if
(
u
.
isAllocated
&&
u
.
isSalesman
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
&&
u
.
regiontags
.
indexOf
(
regionName
)
>=
0
)
{
return
true
}
else
{
return
false
}
}
else
{
if
(
u
.
isAllocated
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
)
{
if
(
u
.
isAllocated
&&
u
.
isSalesman
&&
u
.
isAllArea
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
)
{
return
true
}
else
{
return
false
...
...
@@ -471,7 +470,7 @@ class UserService extends ServiceBase {
* @param {*} regionName 区域
*/
async
getBizUserForDelivery
(
xclientMobile
,
spName
,
productCatName
,
skucode
,
regionName
)
{
let
clientMobile
=
'fordeliver'
+
xclientMobile
+
"_"
+
spName
+
"_"
+
regionName
let
clientMobile
=
'fordeliver'
+
xclientMobile
+
"_"
+
spName
+
"_"
+
regionName
+
"_"
+
productCatName
var
self
=
this
//按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称
return
this
.
db
.
transaction
(
async
function
(
t
)
{
...
...
@@ -519,13 +518,13 @@ class UserService extends ServiceBase {
let
users
=
companyFind
.
us
let
cansels
=
users
.
filter
(
u
=>
{
if
(
regionName
&&
regionName
!=
""
&&
u
.
regiontags
)
{
if
(
u
.
isAllocated
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
&&
u
.
regiontags
.
indexOf
(
regionName
)
>=
0
)
{
if
(
u
.
isAllocated
&&
u
.
isDelivery
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
&&
u
.
regiontags
.
indexOf
(
regionName
)
>=
0
)
{
return
true
}
else
{
return
false
}
}
else
{
if
(
u
.
isAllocated
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
)
{
if
(
u
.
isAllocated
&&
u
.
isDelivery
&&
u
.
isAllArea
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
)
{
return
true
}
else
{
return
false
...
...
@@ -561,6 +560,108 @@ class UserService extends ServiceBase {
}
})
}
/**
* 阿里交付单分配规则(交付单处理业务员和交付员不是一个同一人)
* @param {*} xclientMobile 客户电话
* @param {*} spName 服务商名称
* @param {*} productCatName 产品类型名称
* @param {*} skucode 最小销售货品编码,来自渠道上架的码
* @param {*} regionName 区域
*/
async
getBizUserForAliDelivery
(
xclientMobile
,
spName
,
productCatName
,
skucode
,
regionName
)
{
let
clientMobile
=
'fordeliver'
+
xclientMobile
+
"_"
+
spName
+
"_"
+
regionName
let
self
=
this
//按照服务商名字查询到公司,按照公司查询出users,条件是可以接受派单任务,并且技能标签含有,产品类别名称
return
this
.
db
.
transaction
(
async
function
(
t
)
{
//按照产品简码,查询服务成本
let
productpricetmp
=
await
self
.
db
.
models
.
productprice
.
findOne
({
where
:
{
skucode
:
skucode
},
include
:
[
{
model
:
self
.
db
.
models
.
productcost
,
as
:
"costs"
,
attributes
:
[
'id'
,
'expensetype'
,
'costamount'
]
}
],
transaction
:
t
}
)
let
serviceCost
=
productpricetmp
.
costs
.
filter
(
c
=>
{
if
(
c
.
expensetype
==
"service"
)
{
return
true
}
})
let
costAmount
=
0
//获取服务费成本
if
(
serviceCost
.
length
>
0
)
{
costAmount
=
serviceCost
[
0
].
costamount
}
//先检查缓存是否存在bizuser
let
resultcache
=
await
self
.
cacheManager
[
"DeliveryBizUserCache"
].
getCache
(
clientMobile
)
let
isGoExec
=
false
if
(
!
resultcache
)
{
isGoExec
=
true
}
else
{
let
uname
=
resultcache
.
userName
let
ucache
=
await
self
.
cacheManager
[
"UserCache"
].
cache
(
uname
)
if
(
!
ucache
.
isAllocated
)
{
//解决修改为不接单
isGoExec
=
true
await
self
.
cacheManager
[
"DeliveryBizUserCache"
].
invalidate
(
clientMobile
)
}
}
//TODO 查询数据库user表来获取交付员信息 需要根据是否是"交付员"字段筛选(派单规则是将交付单派给交付员)
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'
],
raw
:
true
}
],
excludes
:
[
'orgJson'
],
transaction
:
t
});
let
users
=
companyFind
.
us
let
cansels
=
users
.
filter
(
u
=>
{
if
(
regionName
&&
regionName
!=
""
&&
u
.
regiontags
)
{
if
(
u
.
isAllocated
&&
u
.
isDelivery
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
&&
u
.
regiontags
.
indexOf
(
regionName
)
>=
0
)
{
return
true
}
else
{
return
false
}
}
else
{
if
(
u
.
isAllocated
&&
u
.
isDelivery
&&
u
.
isAllArea
&&
u
.
skilltags
.
indexOf
(
productCatName
)
>=
0
)
{
return
true
}
else
{
return
false
}
}
})
let
lngth
=
cansels
.
length
//TODO 分配规则,需要改成循环分配
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
,
cost
:
costAmount
,
compId
:
companyFind
.
id
}
await
self
.
cacheManager
[
"DeliveryBizUserCache"
].
cache
(
clientMobile
,
tmp
)
return
tmp
}
else
{
return
null
}
}
else
{
if
(
resultcache
)
{
//不继续,直接返回缓存
resultcache
[
"cost"
]
=
costAmount
return
resultcache
}
else
{
return
null
}
}
})
}
}
module
.
exports
=
UserService
;
...
...
center-manage/app/base/service/impl/common/channelhandlers/ali.js
0 → 100644
View file @
9a557a21
var
system
=
require
(
"../../../../system"
);
const
sha235
=
require
(
"sha256"
);
var
settings
=
require
(
"../../../../../config/settings"
);
class
AliHandler
{
constructor
()
{
this
.
icUrl
=
settings
.
icUrl
()
+
"/web/bizchance"
;
this
.
userService
=
system
.
getObject
(
"service.auth.userSve"
);
this
.
msgService
=
system
.
getObject
(
"service.msg.msgSve"
)
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
}
/**
* 需要调用生成者接口,把数据丢入队列
* 组装生产者需要的数据结构
* @param {*} datajson
*/
//新商机处理
async
addChance
(
datajson
)
{
console
.
log
(
"put in queue"
,
datajson
);
try
{
var
cachestr
=
sha235
(
JSON
.
stringify
(
datajson
));
var
cacheInfo
=
await
this
.
cacheManager
[
"AliCache"
].
getCache
(
cachestr
);
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
"已处理成功!"
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
//获取分配的业务员信息
var
ConsultTypeName
=
datajson
.
actionBody
.
ConsultTypeName
.
split
(
"/"
)[
2
];
var
salesmanInfo
=
await
this
.
userService
.
getBizUserForBizChance
(
datajson
.
actionBody
.
ContactsMobile
,
datajson
.
actionBody
.
ServicerName
,
ConsultTypeName
,
datajson
.
actionBody
.
RegionName
);
console
.
log
(
"salesman "
+
salesmanInfo
);
var
rc
=
system
.
getObject
(
"util.execClient"
);
var
requrl
=
this
.
icUrl
+
"/bizoptCtl/insertInfo"
;
var
params
=
{
"businessMode"
:
datajson
.
actionBody
.
NeedNum
,
"servicerName"
:
datajson
.
actionBody
.
ServicerName
,
"serviceCode"
:
datajson
.
actionBody
.
RegionId
,
"serviceName"
:
datajson
.
actionBody
.
RegionName
,
"contactsName"
:
datajson
.
actionBody
.
ContactsName
,
"contactsPhone"
:
datajson
.
actionBody
.
ContactsMobile
,
"businessType"
:
datajson
.
actionBody
.
ConsultType
,
"businessName"
:
datajson
.
actionBody
.
ConsultTypeName
}
if
(
datajson
.
actionBody
.
Notes
&&
datajson
.
actionBody
.
Notes
!=
'undefined'
)
{
params
.
memoInfo
=
datajson
.
actionBody
.
Notes
;
}
if
(
datajson
.
actionBody
.
CompanyName
&&
datajson
.
actionBody
.
CompanyName
!=
'undefined'
)
{
params
.
companyName
=
datajson
.
actionBody
.
CompanyName
;
}
if
(
datajson
.
actionBody
.
UserName
&&
datajson
.
actionBody
.
UserName
!=
'undefined'
)
{
params
.
UserName
=
datajson
.
actionBody
.
UserName
;
}
if
(
salesmanInfo
&&
salesmanInfo
!=
'undefined'
)
{
params
.
salesmanOpcode
=
salesmanInfo
.
opath
;
params
.
salesmanId
=
salesmanInfo
.
userId
;
params
.
clerkName
=
salesmanInfo
.
userName
;
params
.
clerkPhone
=
salesmanInfo
.
mobile
;
params
.
servicerCode
=
salesmanInfo
.
compId
}
var
rtn
=
await
rc
.
execPost3
({
"d"
:
params
},
requrl
);
var
j
=
JSON
.
parse
(
rtn
.
stdout
);
console
.
log
(
JSON
.
stringify
(
j
),
"RRRRRRRRRRRRRRR"
);
if
(
j
.
status
==
1
)
{
await
this
.
cacheManager
[
"AliCache"
].
cache
(
cachestr
,
null
,
1200000
);
//插入redis缓存
//给业务员发信息
var
msg
=
{
"title"
:
"你有新的商机,请尽快处理"
,
"content"
:
"商机编号"
+
params
.
businessMode
+
",商机类型是"
+
params
.
businessName
+
",服务地区是"
+
params
.
serviceName
,
"sender"
:
"管理员"
,
"sender_id"
:
0
,
"msgType"
:
"single"
,
"target"
:
{
"id"
:
params
.
salesmanId
,
"name"
:
params
.
clerkName
},
}
if
(
params
.
businessType
==
"/qcfw/icp/"
||
params
.
businessType
==
"/qcfw/edi/"
||
params
.
businessType
==
"/qcfw/icpannals/"
||
params
.
businessType
==
"/qcfw/ediannals/"
)
{
msg
.
app_key
=
"5ae2da88-0ced-4b7a-98ea-60d5e1ff7e2e"
;
msg
.
jump_address
=
"allDispose"
}
else
{
msg
.
app_key
=
"42d814c1-4daa-4643-88b2-f5dd3ec853f3"
;
msg
.
jump_address
=
"myChance"
}
await
this
.
msgService
.
create
(
msg
);
}
return
j
;
}
}
catch
(
error
)
{
console
.
log
(
"TTTTTTTTTTTTTT"
);
console
.
log
(
error
);
return
system
.
getResultError
(
error
);
}
}
//退回商机处理
async
needClose
(
datajson
)
{
console
.
log
(
"put in queue"
+
JSON
.
stringify
(
datajson
)
+
"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
);
try
{
var
cachestr
=
sha235
(
JSON
.
stringify
(
datajson
));
var
cacheInfo
=
await
this
.
cacheManager
[
"AliCache"
].
getCache
(
cachestr
);
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
"已处理成功!"
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
var
rc
=
system
.
getObject
(
"util.execClient"
);
var
requrl
=
this
.
icUrl
+
"/schemeCtl/updateStatusByDemandCode"
;
var
params
=
{
"d"
:
{
"businessMode"
:
datajson
.
actionBody
.
NeedNum
,
"schemeNumber"
:
datajson
.
actionBody
.
SolutionNum
,
"currentStatus"
:
"isReject"
,
"statusReason"
:
datajson
.
actionBody
.
RefusalContent
}
}
var
rtn
=
await
rc
.
execPost3
(
params
,
requrl
);
var
j
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
j
.
status
==
0
)
{
await
this
.
cacheManager
[
"AliCache"
].
cache
(
cachestr
,
null
,
1200000
);
//插入缓存
//给业务员发信息
var
selUrl
=
this
.
icUrl
+
"/schemeCtl/findInfoByDemandCode"
;
var
selpar
=
{
"d"
:
{
"businessMode"
:
datajson
.
actionBody
.
NeedNum
}
}
rtn
=
await
rc
.
execPost3
(
selpar
,
selUrl
);
var
jj
=
JSON
.
parse
(
rtn
.
stdout
);
console
.
log
(
"jj------------------------------"
+
rtn
.
stdout
);
if
(
jj
.
status
==
0
&&
jj
.
data
){
var
msg
=
{
"title"
:
"你有退回的商机,请尽快处理"
,
"content"
:
"商机编号"
+
jj
.
data
.
businessMode
+
",商机类型是"
+
jj
.
data
.
businessName
,
"sender"
:
"管理员"
,
"sender_id"
:
0
,
"msgType"
:
"single"
,
"target"
:
{
"id"
:
jj
.
data
.
clerkId
,
"name"
:
jj
.
data
.
clerkName
},
}
if
(
jj
.
data
.
businessType
==
"ICP"
||
jj
.
data
.
businessType
==
"EDI"
||
jj
.
data
.
businessType
==
"ICPANNUALREPORT"
||
jj
.
data
.
businessType
==
"EDIANNUALREPORT"
)
{
msg
.
app_key
=
"5ae2da88-0ced-4b7a-98ea-60d5e1ff7e2e"
;
msg
.
jump_address
=
"allDispose"
}
else
{
msg
.
app_key
=
"42d814c1-4daa-4643-88b2-f5dd3ec853f3"
;
msg
.
jump_address
=
"myChance"
}
var
msgInfo
=
await
this
.
msgService
.
create
(
msg
);
console
.
log
(
"msgInfo -----------------------------"
+
msgInfo
);
}
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
"成功"
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
return
j
;
}
}
}
catch
(
error
)
{
return
system
.
getResultError
(
error
);
}
}
//交付单处理
async
orderSubmit
(
datajson
)
{
console
.
log
(
"put in queue-----------------------------------------------------------------------------------------------------"
,
datajson
);
try
{
var
cachestr
=
sha235
(
JSON
.
stringify
(
datajson
));
var
cacheInfo
=
await
this
.
cacheManager
[
"AliCache"
].
getCache
(
cachestr
);
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
"已处理成功!"
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
var
rc
=
system
.
getObject
(
"util.execClient"
);
var
requrl
=
this
.
icUrl
+
"/deliverybillCtl/findInfoByDeliverCode"
;
var
delInfo
=
await
rc
.
execPost3
({
"d"
:
{
"deliverNumber"
:
datajson
.
actionBody
.
orderNum
}
},
requrl
);
console
.
log
(
"jdelInfo---------------------------------------------"
+
delInfo
.
stdout
);
var
jdelInfo
=
JSON
.
parse
(
delInfo
.
stdout
);
if
(
jdelInfo
.
status
==
0
)
{
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
"数据已存在"
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
//获取分配的业务员信息
var
ConsultTypeName
=
""
;
console
.
log
(
"productTypeName-----------------------------"
+
datajson
.
actionBody
.
productTypeName
);
if
(
datajson
.
actionBody
.
productTypeName
&&
datajson
.
actionBody
.
productTypeName
!=
'undefined'
)
{
ConsultTypeName
=
datajson
.
actionBody
.
productTypeName
.
split
(
"/"
)[
2
];
}
console
.
log
(
"ConsultTypeName-----------------------------"
+
ConsultTypeName
);
var
salesmanInfo
=
await
this
.
userService
.
getBizUserForDelivery
(
datajson
.
actionBody
.
orderSnapshot
.
contactsPhone
,
datajson
.
actionBody
.
servicerName
,
ConsultTypeName
,
datajson
.
actionBody
.
aliPriceCode
,
datajson
.
actionBody
.
regionName
);
requrl
=
this
.
icUrl
+
"/deliverybillCtl/insertInfo"
;
var
bizurl
=
this
.
icUrl
+
"/bizoptCtl/updateStatusByDemandCode"
;
var
params
=
{
"deliverNumber"
:
datajson
.
actionBody
.
orderNum
,
"servicerName"
:
datajson
.
actionBody
.
servicerName
,
"serviceCode"
:
datajson
.
actionBody
.
regionId
,
"serviceName"
:
datajson
.
actionBody
.
regionName
,
"businessType"
:
datajson
.
actionBody
.
productType
,
"businessName"
:
ConsultTypeName
,
"skuCode"
:
datajson
.
actionBody
.
aliPriceCode
,
"aliOrderNum"
:
datajson
.
actionBody
.
aliOrderNum
,
"baseInfo"
:
{
"aliOrderNum"
:
datajson
.
actionBody
.
aliOrderNum
,
"isAdviser"
:
"已分配"
,
//是否分配顾问
"contactsName"
:
datajson
.
actionBody
.
orderSnapshot
.
contactsName
,
"contactsPhone"
:
datajson
.
actionBody
.
orderSnapshot
.
contactsPhone
,
"payStatus"
:
"待交付"
},
"companyInfo"
:
{},
"registeredInfo"
:
{},
"positionInfo"
:
{},
"regInfo"
:
{},
"express_info"
:
{}
}
if
(
salesmanInfo
&&
salesmanInfo
!=
'undefined'
)
{
params
.
clerkOpcode
=
salesmanInfo
.
opath
;
params
.
clerkId
=
salesmanInfo
.
userId
;
params
.
clerkName
=
salesmanInfo
.
userName
;
params
.
clerkPhone
=
salesmanInfo
.
mobile
;
params
.
costPrice
=
salesmanInfo
.
cost
;
params
.
servicerCode
=
salesmanInfo
.
compId
;
params
.
baseInfo
.
clerkName
=
salesmanInfo
.
userName
;
params
.
baseInfo
.
clerkPhone
=
salesmanInfo
.
mobile
}
if
(
!
params
.
serviceCode
||
params
.
serviceCode
==
'undefined'
)
{
if
(
datajson
.
actionBody
.
orderSnapshot
.
servicerCode
&&
datajson
.
actionBody
.
orderSnapshot
.
servicerCode
!=
'undefined'
)
{
params
.
serviceCode
=
datajson
.
actionBody
.
orderSnapshot
.
servicerCode
;
//fuwushang id
}
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
needNum
&&
datajson
.
actionBody
.
orderSnapshot
.
needNum
!=
'undefined'
)
{
params
.
businessMode
=
datajson
.
actionBody
.
orderSnapshot
.
needNum
;
//商机编号
}
if
(
datajson
.
actionBody
.
realTotalCost
&&
datajson
.
actionBody
.
realTotalCost
!=
'undefined'
)
{
params
.
sellingPrice
=
datajson
.
actionBody
.
realTotalCost
;
//价格
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
channelSource
&&
datajson
.
actionBody
.
orderSnapshot
.
channelSource
!=
'undefined'
)
{
params
.
channelSource
=
datajson
.
actionBody
.
orderSnapshot
.
channelSource
;
//渠道名称
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
channelNumber
&&
datajson
.
actionBody
.
orderSnapshot
.
channelNumber
!=
'undefined'
)
{
params
.
channelNumber
=
datajson
.
actionBody
.
orderSnapshot
.
channelNumber
;
//渠道编码
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
hasOwnProperty
(
"isWhether"
))
{
if
(
datajson
.
actionBody
.
orderSnapshot
.
isWhether
===
true
||
datajson
.
actionBody
.
orderSnapshot
.
isWhether
===
"yes"
)
{
params
.
baseInfo
.
isWhether
=
"yes"
;
//是否刻章
}
else
{
params
.
baseInfo
.
isWhether
=
"no"
;
//是否刻章
}
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
hasOwnProperty
(
"financial"
))
{
if
(
datajson
.
actionBody
.
orderSnapshot
.
financial
===
true
||
datajson
.
actionBody
.
orderSnapshot
.
financial
===
"yes"
)
{
params
.
baseInfo
.
financial
=
"yes"
;
}
else
{
params
.
baseInfo
.
financial
=
"no"
;
}
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
officialSeal
&&
datajson
.
actionBody
.
orderSnapshot
.
officialSeal
!=
'undefined'
)
{
params
.
baseInfo
.
officialSeal
=
datajson
.
actionBody
.
orderSnapshot
.
officialSeal
;
//公章扫描件
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
businessLicense
&&
datajson
.
actionBody
.
orderSnapshot
.
businessLicense
!=
'undefined'
)
{
params
.
baseInfo
.
businessLicense
=
datajson
.
actionBody
.
orderSnapshot
.
businessLicense
;
//营业执照扫描件
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
taxpayerName
&&
datajson
.
actionBody
.
orderSnapshot
.
taxpayerName
!=
'undefined'
)
{
params
.
baseInfo
.
taxpayerName
=
datajson
.
actionBody
.
orderSnapshot
.
taxpayerName
;
//纳税人类型名称
}
else
if
(
datajson
.
actionBody
.
orderSnapshot
.
taxpayerType
&&
datajson
.
actionBody
.
orderSnapshot
.
taxpayerType
!=
'undefined'
)
{
params
.
baseInfo
.
taxpayerName
=
datajson
.
actionBody
.
orderSnapshot
.
taxpayerType
;
//纳税人类型名称
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
buyDuration
&&
datajson
.
actionBody
.
orderSnapshot
.
buyDuration
!=
'undefined'
)
{
params
.
baseInfo
.
buyDuration
=
datajson
.
actionBody
.
orderSnapshot
.
buyDuration
;
//购买时长
}
else
if
(
datajson
.
actionBody
.
orderSnapshot
.
timeSpan
&&
datajson
.
actionBody
.
orderSnapshot
.
timeSpan
!=
'undefined'
)
{
params
.
baseInfo
.
buyDuration
=
datajson
.
actionBody
.
orderSnapshot
.
timeSpan
+
"年"
;
//购买时长
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
buyTime
&&
datajson
.
actionBody
.
orderSnapshot
.
buyTime
!=
'undefined'
)
{
params
.
baseInfo
.
buyTime
=
datajson
.
actionBody
.
orderSnapshot
.
buyTime
;
//购买时间
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
isRenew
&&
datajson
.
actionBody
.
orderSnapshot
.
isRenew
!=
'undefined'
)
{
params
.
baseInfo
.
isRenew
=
datajson
.
actionBody
.
orderSnapshot
.
isRenew
;
//是否自动续费
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
memoInfo
&&
datajson
.
actionBody
.
orderSnapshot
.
memoInfo
!=
'undefined'
)
{
params
.
baseInfo
.
memoInfo
=
datajson
.
actionBody
.
orderSnapshot
.
memoInfo
;
}
else
if
(
datajson
.
actionBody
.
orderSnapshot
.
businessContent
&&
datajson
.
actionBody
.
orderSnapshot
.
businessContent
!=
'undefined'
)
{
params
.
baseInfo
.
memoInfo
=
datajson
.
actionBody
.
orderSnapshot
.
businessContent
;
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
whetherType
&&
datajson
.
actionBody
.
orderSnapshot
.
whetherType
!=
'undefined'
)
{
params
.
baseInfo
.
whetherType
=
datajson
.
actionBody
.
orderSnapshot
.
whetherType
;
//刻章类型
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
hasOwnProperty
(
"annualReport"
))
{
//年报信息
params
.
baseInfo
.
annualReport
=
datajson
.
actionBody
.
orderSnapshot
.
annualReport
;
}
else
{
if
(
datajson
.
actionBody
.
orderSnapshot
.
annual_report
&&
datajson
.
actionBody
.
orderSnapshot
.
annual_report
!=
'undefined'
)
{
params
.
baseInfo
.
annualReport
=
true
;
//shifouxuyaonianbao
}
else
{
params
.
baseInfo
.
annualReport
=
false
;
}
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
hasOwnProperty
(
"addressType"
))
{
//注册地址类型
if
(
datajson
.
actionBody
.
orderSnapshot
.
addressType
===
true
||
datajson
.
actionBody
.
orderSnapshot
.
addressType
===
"practical"
)
{
params
.
baseInfo
.
addressType
=
"practical"
;
}
else
{
params
.
baseInfo
.
addressType
=
"virtual"
;
}
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
subjectType
&&
datajson
.
actionBody
.
orderSnapshot
.
subjectType
!=
'undefined'
)
{
params
.
baseInfo
.
subjectType
=
datajson
.
actionBody
.
orderSnapshot
.
subjectType
;
//代理记账主体类型
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
companyName
&&
datajson
.
actionBody
.
orderSnapshot
.
companyName
!=
'undefined'
)
{
params
.
baseInfo
.
companyName
=
datajson
.
actionBody
.
orderSnapshot
.
companyName
;
//公司名称
params
.
companyInfo
.
companyName
=
datajson
.
actionBody
.
orderSnapshot
.
companyName
;
}
else
if
(
datajson
.
actionBody
.
orderSnapshot
.
company
&&
datajson
.
actionBody
.
orderSnapshot
.
company
!=
'undefined'
)
{
params
.
baseInfo
.
companyName
=
datajson
.
actionBody
.
orderSnapshot
.
company
;
//公司名称
params
.
companyInfo
.
companyName
=
datajson
.
actionBody
.
orderSnapshot
.
company
;
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
companyProperties
&&
datajson
.
actionBody
.
orderSnapshot
.
companyProperties
!=
'undefined'
)
{
params
.
companyInfo
.
companyPropertiesName
=
datajson
.
actionBody
.
orderSnapshot
.
companyProperties
;
//公司性质名称
}
else
if
(
datajson
.
actionBody
.
orderSnapshot
.
companyType
&&
datajson
.
actionBody
.
orderSnapshot
.
companyType
!=
'undefined'
)
{
params
.
companyInfo
.
companyPropertiesName
=
datajson
.
actionBody
.
orderSnapshot
.
companyType
;
//公司性质名称
}
else
if
(
datajson
.
actionBody
.
orderSnapshot
.
registeredName
&&
datajson
.
actionBody
.
orderSnapshot
.
registeredName
!=
'undefined'
)
{
params
.
companyInfo
.
companyPropertiesName
=
datajson
.
actionBody
.
orderSnapshot
.
registeredName
;
//公司性质名称
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
fullAddress
&&
datajson
.
actionBody
.
orderSnapshot
.
fullAddress
!=
'undefined'
)
{
params
.
companyInfo
.
fullAddress
=
datajson
.
actionBody
.
orderSnapshot
.
fullAddress
;
//详细地址
}
else
if
(
datajson
.
actionBody
.
orderSnapshot
.
residenceAddress
&&
datajson
.
actionBody
.
orderSnapshot
.
residenceAddress
!=
'undefined'
)
{
params
.
companyInfo
.
fullAddress
=
datajson
.
actionBody
.
orderSnapshot
.
residenceAddress
;
//详细地址
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
virtualPrice
&&
datajson
.
actionBody
.
orderSnapshot
.
virtualPrice
!=
'undefined'
)
{
params
.
companyInfo
.
virtualPrice
=
datajson
.
actionBody
.
orderSnapshot
.
virtualPrice
;
//虚拟地址价格
params
.
baseInfo
.
virtualPrice
=
datajson
.
actionBody
.
orderSnapshot
.
virtualPrice
;
//虚拟地址价格
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
residenceAddress
&&
datajson
.
actionBody
.
orderSnapshot
.
residenceAddress
!=
'undefined'
)
{
params
.
companyInfo
.
residenceAddress
=
datajson
.
actionBody
.
orderSnapshot
.
residenceAddress
;
//zhusuo
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
engagedIndustry
&&
datajson
.
actionBody
.
orderSnapshot
.
engagedIndustry
!=
'undefined'
)
{
params
.
companyInfo
.
engagedIndName
=
datajson
.
actionBody
.
orderSnapshot
.
engagedIndustry
;
//从事行业名称
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
businessScope
&&
datajson
.
actionBody
.
orderSnapshot
.
businessScope
!=
'undefined'
)
{
params
.
companyInfo
.
businessScope
=
datajson
.
actionBody
.
orderSnapshot
.
businessScope
;
//经营范围
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
operatingPeriod
&&
datajson
.
actionBody
.
orderSnapshot
.
operatingPeriod
!=
'undefined'
)
{
params
.
companyInfo
.
operatingPeriod
=
datajson
.
actionBody
.
orderSnapshot
.
operatingPeriod
;
//经营期限
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
businessTerm
&&
datajson
.
actionBody
.
orderSnapshot
.
businessTerm
!=
'undefined'
)
{
params
.
companyInfo
.
businessTerm
=
datajson
.
actionBody
.
orderSnapshot
.
businessTerm
;
//经营期限
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
registeredCapital
&&
datajson
.
actionBody
.
orderSnapshot
.
registeredCapital
!=
'undefined'
)
{
params
.
companyInfo
.
registeredCapital
=
datajson
.
actionBody
.
orderSnapshot
.
registeredCapital
;
//注册资本
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
creditCode
&&
datajson
.
actionBody
.
orderSnapshot
.
creditCode
!=
'undefined'
)
{
params
.
companyInfo
.
creditCode
=
datajson
.
actionBody
.
orderSnapshot
.
creditCode
;
//统一社会信用代码
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
establishedTime
&&
datajson
.
actionBody
.
orderSnapshot
.
establishedTime
!=
'undefined'
)
{
params
.
companyInfo
.
establishedTime
=
datajson
.
actionBody
.
orderSnapshot
.
establishedTime
;
//成立时间
}
if
(
datajson
.
actionBody
.
orderSnapshot
.
shareholderName
&&
datajson
.
actionBody
.
orderSnapshot
.
shareholderName
!=
'undefined'
)
{
params
.
companyInfo
.
shareholderName
=
datajson
.
actionBody
.
orderSnapshot
.
shareholderName
;
//法人代表
}
var
rtn
=
await
rc
.
execPost3
({
"d"
:
params
},
requrl
);
var
j
=
JSON
.
parse
(
rtn
.
stdout
);
console
.
log
(
"j---------------------------------"
+
rtn
.
stdout
);
var
stau
=
{
"businessMode"
:
params
.
businessMode
,
"currentStatus"
:
"isFinished"
,
"statusReason"
:
""
}
rtn
=
await
rc
.
execPost3
({
"d"
:
stau
},
bizurl
);
//更新商机状态为已完成
var
j1
=
JSON
.
parse
(
rtn
.
stdout
);
console
.
log
(
"j1---------------------------------"
+
rtn
.
stdout
);
if
(
j
.
status
==
0
&&
j1
.
status
==
0
)
{
await
this
.
cacheManager
[
"AliCache"
].
cache
(
cachestr
,
null
,
1200000
);
//给业务员发信息
var
msg
=
{
"title"
:
"你有新的交付单,请尽快处理"
,
"content"
:
"交付单编号"
+
params
.
deliverNumber
+
",产品类型是"
+
params
.
businessName
+
",服务地区是"
+
params
.
serviceName
,
"sender"
:
"管理员"
,
"sender_id"
:
0
,
"msgType"
:
"single"
,
"target"
:
{
"id"
:
params
.
clerkId
,
"name"
:
params
.
clerkName
},
}
if
(
params
.
businessType
==
"/qcfw/icp/"
||
params
.
businessType
==
"/qcfw/edi/"
||
params
.
businessType
==
"/qcfw/icpannals/"
||
params
.
businessType
==
"/qcfw/ediannals/"
)
{
msg
.
app_key
=
"5ae2da88-0ced-4b7a-98ea-60d5e1ff7e2e"
;
msg
.
jump_address
=
"deliveryAll"
}
else
{
msg
.
app_key
=
"42d814c1-4daa-4643-88b2-f5dd3ec853f3"
;
msg
.
jump_address
=
"myDeliver"
}
await
this
.
msgService
.
create
(
msg
);
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
""
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
return
j
;
}
}
}
}
catch
(
error
)
{
console
.
log
(
"error-------------------------------------"
+
error
);
return
system
.
getResultError
(
error
);
}
}
//关闭交付单处理
async
orderClose
(
datajson
)
{
console
.
log
(
"put in queue"
,
datajson
);
try
{
var
cachestr
=
sha235
(
JSON
.
stringify
(
datajson
));
var
cacheInfo
=
await
this
.
cacheManager
[
"AliCache"
].
getCache
(
cachestr
);
if
(
cacheInfo
&&
cacheInfo
!=
'undefined'
)
{
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
"已处理成功!"
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
var
rc
=
system
.
getObject
(
"util.execClient"
);
var
requrl
=
this
.
icUrl
+
"/deliverybillCtl/updateStatusByDeliverCode"
;
var
params
=
{
"d"
:
{
"deliverNumber"
:
datajson
.
actionBody
.
orderNum
,
"deliverStatus"
:
"closed"
,
"statusReason"
:
datajson
.
actionBody
.
refusalContent
}
}
var
rtn
=
await
rc
.
execPost3
(
params
,
requrl
);
var
j
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
j
.
status
==
0
)
{
await
this
.
cacheManager
[
"AliCache"
].
cache
(
cachestr
,
null
,
1200000
);
//插入缓存
//给业务员发信息
var
selUrl
=
this
.
icUrl
+
"/deliverybillCtl/findInfoByDeliverCode"
;
var
selpar
=
{
"d"
:{
"deliverNumber"
:
datajson
.
actionBody
.
orderNum
}
}
rtn
=
await
rc
.
execPost3
(
selpar
,
selUrl
);
var
jj
=
JSON
.
parse
(
rtn
.
stdout
);
console
.
log
(
"jj-------------------------"
+
rtn
.
stdout
);
if
(
jj
.
status
==
0
&&
jj
.
data
){
var
msg
=
{
"title"
:
"你有关闭的交付单,请尽快处理"
,
"content"
:
"交付单编号"
+
jj
.
data
.
delivery_code
+
",产品类型是"
+
jj
.
data
.
product_name
,
"sender"
:
"管理员"
,
"sender_id"
:
0
,
"msgType"
:
"single"
,
"target"
:
{
"id"
:
jj
.
data
.
salesman_id
,
"name"
:
jj
.
data
.
salesman_name
},
}
if
(
jj
.
data
.
product_code
==
"ICP"
||
jj
.
data
.
product_code
==
"EDI"
||
jj
.
data
.
product_code
==
"ICPANNUALREPORT"
||
jj
.
data
.
product_code
==
"EDIANNUALREPORT"
)
{
msg
.
app_key
=
"5ae2da88-0ced-4b7a-98ea-60d5e1ff7e2e"
;
msg
.
jump_address
=
"deliveryAll"
}
else
{
msg
.
app_key
=
"42d814c1-4daa-4643-88b2-f5dd3ec853f3"
;
msg
.
jump_address
=
"myDeliver"
}
await
this
.
msgService
.
create
(
msg
);
}
return
{
"status"
:
1
,
//1代表成功,否则失败
"msg"
:
""
,
"data"
:
""
,
"requestId"
:
""
}
}
else
{
return
j
;
}
}
}
catch
(
error
)
{
return
system
.
getResultError
(
error
);
}
}
}
module
.
exports
=
new
AliHandler
();
// (async ()=>{
// var task = new AliHandler();
// var d = await task.userService.getBizUserForDelivery("16512345678","公司宝","公司注册","sv_business_registration_category_limited1","北京");
// console.log("ddddddddddddd");
// console.log(JSON.stringify(d));
// console.log("dddddddddddddd");
// })()
center-manage/app/base/service/impl/common/companySve.js
View file @
9a557a21
...
...
@@ -5,7 +5,7 @@ class CompanyService extends ServiceBase {
constructor
()
{
super
(
"common"
,
ServiceBase
.
getDaoName
(
CompanyService
));
}
async
getMyApps
(
appids
,
isSuper
)
{
async
getMyApps
(
appids
,
isSuper
)
{
let
appsrtn
=
null
if
(
isSuper
)
{
appsrtn
=
this
.
db
.
models
.
app
.
findAll
({
...
...
@@ -24,14 +24,14 @@ class CompanyService extends ServiceBase {
}
return
appsrtn
}
async
bindApps
(
appids
,
companyid
)
{
async
bindApps
(
appids
,
companyid
)
{
var
self
=
this
return
this
.
db
.
transaction
(
async
function
(
t
)
{
let
u
=
await
self
.
dao
.
update
({
appids
:
appids
,
id
:
companyid
},
t
)
return
appids
})
}
async
setOrgs
(
p
,
cmk
)
{
async
setOrgs
(
p
,
cmk
)
{
var
self
=
this
let
curNodeData
=
p
.
curdata
let
opathstr
=
curNodeData
.
orgpath
...
...
@@ -39,20 +39,20 @@ class CompanyService extends ServiceBase {
let
strjson
=
JSON
.
stringify
(
p
.
orgJson
)
p
.
id
=
p
.
company_id
p
.
orgJson
=
strjson
let
oldopath
=
''
if
(
!
oldNodeData
)
{
//如果不传老对象,表示当前操作是删除节点操作,检查是否存在用户,如果已经存在
let
oldopath
=
''
if
(
!
oldNodeData
)
{
//如果不传老对象,表示当前操作是删除节点操作,检查是否存在用户,如果已经存在
//那么就提示不能删除
let
us
=
await
self
.
db
.
models
.
user
.
findOne
({
where
:
{
opath
:
{
[
self
.
db
.
Op
.
like
]:
`%
${
opathstr
}
%`
}
}})
if
(
us
)
{
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}});
let
us
=
await
self
.
db
.
models
.
user
.
findOne
({
where
:
{
opath
:
{
[
self
.
db
.
Op
.
like
]:
`%
${
opathstr
}
%`
}
}
})
if
(
us
)
{
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}
});
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
}
else
{
}
else
{
let
u
=
await
this
.
dao
.
update
(
p
)
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}});
let
companytmp
=
await
this
.
dao
.
model
.
findOne
({
where
:
{
id
:
p
.
company_id
}
});
return
{
orgJson
:
JSON
.
parse
(
companytmp
.
orgJson
)
}
}
}
else
{
oldopath
=
oldNodeData
.
orgpath
}
else
{
oldopath
=
oldNodeData
.
orgpath
==
''
?
'123456'
:
oldNodeData
.
orgpath
}
return
this
.
db
.
transaction
(
async
function
(
t
)
{
...
...
@@ -60,7 +60,7 @@ class CompanyService extends ServiceBase {
let
u
=
await
self
.
dao
.
update
(
p
,
t
)
//更新,还得传输当前节点,查询出当前节点的角色
//按照当前节点的opath查询出所有的用户,更新这些用户的角色信息
if
(
curNodeData
)
{
if
(
curNodeData
.
isPosition
)
{
let
us
=
await
self
.
db
.
models
.
user
.
findAll
({
where
:
{
opath
:
{
[
self
.
db
.
Op
.
like
]:
`%
${
oldopath
}
%`
}
},
transaction
:
t
})
...
...
@@ -77,22 +77,22 @@ class CompanyService extends ServiceBase {
let
rs
=
await
self
.
db
.
models
.
role
.
findAll
({
where
:
{
id
:
{
[
self
.
db
.
Op
.
in
]:
roleids
}
},
transaction
:
t
})
for
(
let
u
of
us
)
{
await
u
.
setRoles
(
rs
,
{
transaction
:
t
})
if
(
opathstr
!=
oldopath
)
{
u
.
opath
=
opathstr
+
"/"
+
u
.
userName
u
.
ptags
=
curNodeData
.
ptags
u
.
save
({
transaction
:
t
})
}
//
if (opathstr != oldopath) {
u
.
opath
=
opathstr
+
"/"
+
u
.
userName
u
.
ptags
=
curNodeData
.
ptags
u
.
save
({
transaction
:
t
})
//
}
//令用户缓存失效
await
self
.
cacheManager
[
"UserCache"
].
invalidate
(
u
.
userName
)
}
}
else
{
//不是岗位节点,检查修改后的路径是否和原始一致,如果不一致,那么需要查出原始的用户数据
}
else
{
//不是岗位节点,检查修改后的路径是否和原始一致,如果不一致,那么需要查出原始的用户数据
//把原来的路径替换当前新的code
if
(
opathstr
!=
oldopath
)
{
if
(
opathstr
!=
oldopath
)
{
let
us2
=
await
self
.
db
.
models
.
user
.
findAll
({
where
:
{
opath
:
{
[
self
.
db
.
Op
.
like
]:
`%
${
oldopath
}
%`
}
},
transaction
:
t
})
for
(
let
u
of
us2
)
{
let
curpath
=
u
.
opath
let
newpath
=
curpath
.
replace
(
oldNodeData
.
code
,
curNodeData
.
code
)
u
.
opath
=
newpath
let
curpath
=
u
.
opath
let
newpath
=
curpath
.
replace
(
oldNodeData
.
code
,
curNodeData
.
code
)
u
.
opath
=
newpath
u
.
save
({
transaction
:
t
})
//令用户缓存失效
await
self
.
cacheManager
[
"UserCache"
].
invalidate
(
u
.
userName
)
...
...
center-manage/app/base/system.js
View file @
9a557a21
...
...
@@ -2,6 +2,8 @@ var fs = require("fs");
var
objsettings
=
require
(
"../config/objsettings"
);
var
settings
=
require
(
"../config/settings"
);
const
request
=
require
(
'request'
);
const
jwk2pem
=
require
(
'pem-jwk'
).
jwk2pem
const
jwt
=
require
(
'jsonwebtoken'
)
class
System
{
static
declare
(
ns
)
{
var
ar
=
ns
.
split
(
'.'
);
...
...
@@ -16,6 +18,14 @@ class System {
}
}
}
/**
* 验证token
* @param {String} token jwt token
* @param {Object} publicKey 公钥
*/
static
verify
(
token
,
publicKey
)
{
return
jwt
.
verify
(
token
,
jwk2pem
(
publicKey
));
}
static
async
delReq
(
url
,
qdata
)
{
let
rtn
=
{}
let
promise
=
new
Promise
(
function
(
resv
,
rej
)
{
...
...
@@ -98,12 +108,14 @@ class System {
url
:
url
,
form
:
data
},
function
(
error
,
response
,
body
)
{
rtn
.
statusCode
=
response
.
statusCode
if
(
!
error
)
{
rtn
.
statusCode
=
response
.
statusCode
let
data
=
JSON
.
parse
(
body
)
rtn
.
data
=
data
resv
(
rtn
);
}
else
{
console
.
log
(
error
)
rej
(
error
)
}
});
...
...
@@ -365,4 +377,8 @@ module.exports = System;
//System.execLogs("hello",{"opcode":"xxxxx"},"ddfdf",{requestId:'ddds'},null)
// let str = "Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImRjMmM1MzMwMjNhMTExZTlhOTU3NjliODBiNDI4Y2QxIn0.eyJpZCI6IjViZDk2MWJkZWQxN2E5MmI1MDFjZWQ0ZCIsIm5hbWUiOiLpnZLph4kxMSIsImVtcGxveWVlIjoiNWQ5ZWNlODc1Zjk3ZGQzMzEwNzI4ZjY4IiwicGhvbmUiOiI3TFlYZ29ySkdGM2hBbHdqQTZGelFnPT0iLCJvcmdpZCI6IjViY2ZlOTVjYjBhMDFmMDAwOTI4NGJjMyIsInBsYXRmb3JtIjoiZDVmYTU4Yjk3NGExMjBlZTYxMTMzM2MwMDNjOWZlYzAiLCJ1bmlvbmlkIjoib2RuWjR0OERoV1V0N0lXT09maEF0UTdqM1docyIsImp0aSI6Imo3R0hLRGFzNDEzQTQ2OGkiLCJleHAiOjE1OTYwODEzMTEsImlhdCI6MTU5NTQ3NjUxMX0.I196XbcCR3k7r1O8uwoI2HUhow0UhGHKzii5wOR39vLmuNOUatNY7ccQTCHijqysbSCePP43Iuglrl2gLQASf5uAr9uqTzhTc3O4Z5iF3oR2qR1vlBxrzTDF8xuhKHQ4tO6Hbsib0FdOYVeU8fe0g_GZiIcuYIv-f8VsiAGMF9TEES129CDwZacJfVViw4EXVnXSivAzQG4JgGSwUACvPT140bCZ1XPeHi0GXmgtEN77NjWfOGI5RYGC0Gq3CGevlSWERjb3mUscAIjoXsOxlWNwy7dc1u1A7uX1a6bUhLU1wtiQ6md4TnyeR5OdYeVqGlIe3hZGcH_E3QrQMq988Q"
// console.log(str)
// let s = System.verify(str.split(' ')[1], settings.publickey())
// console.log(s)
center-manage/app/config/environment.js
View file @
9a557a21
...
...
@@ -11,28 +11,42 @@ var system = require('../base/system');
var
routes
=
require
(
'./routes'
);
var
history
=
require
(
'connect-history-api-fallback'
);
module
.
exports
=
function
(
app
)
{
app
.
set
(
'port'
,
settings
.
port
);
app
.
set
(
'views'
,
settings
.
basepath
+
'/app/front/entry'
);
app
.
set
(
'view engine'
,
'ejs'
);
app
.
use
(
history
());
app
.
set
(
'port'
,
settings
.
port
);
app
.
set
(
'views'
,
settings
.
basepath
+
'/app/front/entry'
);
app
.
set
(
'view engine'
,
'ejs'
);
app
.
use
(
methodOverride
());
app
.
use
(
cookierParser
());
app
.
use
(
bodyParser
.
json
({
limit
:
'50mb'
}));
app
.
use
(
bodyParser
.
urlencoded
({
limit
:
'50mb'
,
extended
:
true
}));
routes
(
app
);
//初始化路由
app
.
use
(
history
(
{
rewrites
:
[
{
from
:
/.*/
,
to
:
function
(
context
)
{
if
(
context
.
parsedUrl
.
pathname
.
indexOf
(
"autologin"
)
>=
0
)
{
return
context
.
parsedUrl
.
pathname
}
else
{
return
'/index.html'
;
}
app
.
use
(
methodOverride
());
app
.
use
(
cookierParser
());
app
.
use
(
bodyParser
.
json
({
limit
:
'50mb'
}));
app
.
use
(
bodyParser
.
urlencoded
({
limit
:
'50mb'
,
extended
:
true
}));
routes
(
app
);
//初始化路由
app
.
use
(
express
.
static
(
path
.
join
(
settings
.
basepath
,
'/app/front/entry/public'
)));
// development only
if
(
'development'
==
app
.
get
(
'env'
))
{
app
.
use
(
errorHandler
());
}
else
{
app
.
use
(
function
(
err
,
req
,
res
){
console
.
log
(
"prod error handler................................>>>>>>>>>>>>>>>>>"
);
console
.
log
(
err
);
//logerApp.error("prod error handler",err);
res
.
send
(
"link admin"
);
});
}
}
]
}
));
app
.
use
(
express
.
static
(
path
.
join
(
settings
.
basepath
,
'/app/front/entry/public'
)));
// development only
if
(
'development'
==
app
.
get
(
'env'
))
{
app
.
use
(
errorHandler
());
}
else
{
app
.
use
(
function
(
err
,
req
,
res
)
{
console
.
log
(
"prod error handler................................>>>>>>>>>>>>>>>>>"
);
console
.
log
(
err
);
//logerApp.error("prod error handler",err);
res
.
send
(
"link admin"
);
});
}
};
center-manage/app/config/routes/api.js
View file @
9a557a21
var
url
=
require
(
"url"
);
var
System
=
require
(
"../../base/system"
);
const
chnelapi
=
System
.
getObject
(
"api.common.channels"
)
const
chnelapi
=
System
.
getObject
(
"api.common.channels"
)
const
userS
=
System
.
getObject
(
"service.auth.userSve"
)
const
roleS
=
System
.
getObject
(
"service.auth.roleSve"
)
const
companyS
=
System
.
getObject
(
"service.common.companySve"
)
const
settings
=
require
(
"../settings.js"
)
let
channelCache
=
{};
module
.
exports
=
function
(
app
)
{
app
.
all
(
"*"
,
async
function
(
req
,
res
,
next
){
try
{
let
channel
=
await
chnelapi
.
getChannels
(
req
.
headers
[
"x-forwarded-host"
])
if
(
!
channel
){
app
.
get
(
"/autologin"
,
async
function
(
req
,
res
,
next
)
{
let
appkey
=
req
.
query
.
appkey
.
trim
()
if
(
!
appkey
)
{
res
.
end
(
"没有资质宝appkey,请联系资质宝服务提供方"
)
return
}
let
companykey
=
req
.
query
.
companykey
.
trim
()
if
(
!
companykey
)
{
res
.
end
(
"没有公司宝的租户companykey,请联系资质宝服务提供方"
)
return
}
let
cooktoken
=
req
.
cookies
[
"token"
]
let
tv
=
cooktoken
.
split
(
' '
)[
1
]
let
sourceUser
=
System
.
verify
(
tv
,
settings
.
publickey
())
let
openid
=
sourceUser
.
employee
let
userName
=
openid
let
nickName
=
sourceUser
.
name
let
unid
=
sourceUser
.
unionid
let
fixedcodes
=
[
"资质宝交付员"
,
'资质宝业务员'
]
let
rolecodes
=
sourceUser
.
roles
?
sourceUser
.
roles
:
[]
let
rcs
=
rolecodes
.
filter
(
rc
=>
{
if
(
fixedcodes
.
indexOf
(
rc
)
>=
0
)
{
return
true
}
else
{
return
false
}
})
if
(
rcs
.
length
==
0
)
{
res
.
end
(
"当前登录人没有资质宝访问权限"
)
return
}
//先按照openid去查看是否已经存在
let
uf
=
await
userS
.
dao
.
model
.
findOne
({
where
:
{
openid
:
openid
}
})
if
(
!
uf
)
{
//按照公司companykey查询出要注册公司的所在公司,取公司id
let
company
=
await
companyS
.
dao
.
model
.
findOne
({
where
:
{
companykey
:
companykey
}
})
//构造注册用户对象,需要设置默认角色,默认角色需要按照rolecode查询出角色
let
rolesfind
=
await
roleS
.
dao
.
model
.
findAll
({
where
:
{
code
:
{
[
self
.
db
.
Op
.
in
]:
rcs
},
company_id
:
company
.
id
}
})
//根据rolecode--,设置组织路径
let
opath
=
''
let
isSalesman
=
false
let
isDelivery
=
false
if
(
rcs
[
0
]
==
"资质宝业务员"
)
{
opath
=
"root10/bizgroup01/g1members/"
+
userName
isSalesman
=
true
}
else
{
opath
=
"root10/dlivergroup/dgroupmembers/"
+
userName
isDelivery
=
true
}
//调用pmregister
let
reguser
=
{
company_id
:
company
.
id
,
userName
:
userName
,
nickName
:
nickName
,
roles
:
rolesfind
.
map
(
r
=>
r
.
id
),
opath
:
opath
,
openid
:
openid
,
isSalesman
:
isSalesman
,
isDelivery
:
isDelivery
}
uf
=
await
userS
.
registerByTantent
(
reguser
)
}
let
rtnobj
=
await
userS
.
loginApp
(
appkey
,
userName
)
res
.
redirect
(
rtnobj
.
homePage
+
"?code="
+
rtnobj
.
code
)
})
app
.
post
(
"*"
,
async
function
(
req
,
res
,
next
)
{
try
{
let
channel
;
let
sourceHost
=
req
.
headers
[
"x-forwarded-host"
];
if
(
sourceHost
in
channelCache
)
{
channel
=
channelCache
[
sourceHost
];
}
else
{
channel
=
await
chnelapi
.
getChannels
(
sourceHost
);
channelCache
[
sourceHost
]
=
channel
;
}
if
(
!
channel
)
{
next
()
}
else
{
let
rtn
=
await
chnelapi
.
channelHandle
(
channel
,
req
.
path
+
"/"
+
req
.
body
.
actionType
,
req
.
body
)
if
(
rtn
!=
null
)
{
}
else
{
let
rtn
=
await
chnelapi
.
channelHandle
(
channel
,
req
.
path
+
"/"
+
req
.
body
.
actionType
,
req
.
body
)
if
(
rtn
!=
null
)
{
res
.
end
(
JSON
.
stringify
(
rtn
));
}
else
{
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
"fail"
}));
}
else
{
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
"fail"
}));
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
e
}));
res
.
end
(
JSON
.
stringify
({
status
:
-
1
,
message
:
e
}));
}
})
app
.
get
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
// var classPath = req.params["qname"];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
System
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
uagent
=
req
.
headers
[
"user-agent"
];
// req.classname=classPath;
var
params
=
[];
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
System
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
...
...
@@ -47,22 +124,22 @@ module.exports = function (app) {
});
app
.
post
(
'/api/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
console
.
log
(
"===================="
);
console
.
log
(
classPath
);
var
tClientIp
=
System
.
get_client_ip
(
req
);
req
.
clientIp
=
tClientIp
;
req
.
uagent
=
req
.
headers
[
"user-agent"
];
req
.
uagent
=
req
.
headers
[
"user-agent"
];
// req.classname=classPath;
params
.
push
(
gname
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
System
.
getObject
(
"api."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
...
...
center-manage/app/config/routes/web.js
View file @
9a557a21
var
url
=
require
(
"url"
);
var
system
=
require
(
"../../base/system"
);
var
metaCtl
=
system
.
getObject
(
"web.common.metaCtl"
);
var
metaCtl
=
system
.
getObject
(
"web.common.metaCtl"
);
module
.
exports
=
function
(
app
)
{
app
.
get
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
classPath
=
gname
+
"."
+
classPath
;
var
params
=
[];
params
.
push
(
methodName
);
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
...
...
@@ -24,18 +24,18 @@ module.exports = function (app) {
app
.
post
(
'/web/:gname/:qname/:method'
,
function
(
req
,
res
)
{
req
.
codepath
=
req
.
headers
[
"codepath"
];
var
classPath
=
req
.
params
[
"qname"
];
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
methodName
=
req
.
params
[
"method"
];
var
gname
=
req
.
params
[
"gname"
];
var
params
=
[];
classPath
=
gname
+
"."
+
classPath
;
var
tClientIp
=
system
.
get_client_ip
(
req
);
req
.
body
.
clientIp
=
tClientIp
;
req
.
body
.
agent
=
req
.
headers
[
"user-agent"
];
req
.
body
.
classname
=
classPath
;
req
.
body
.
agent
=
req
.
headers
[
"user-agent"
];
req
.
body
.
classname
=
classPath
;
params
.
push
(
methodName
);
params
.
push
(
req
.
body
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
params
.
push
(
req
.
query
);
params
.
push
(
req
);
var
p
=
null
;
var
invokeObj
=
system
.
getObject
(
"web."
+
classPath
);
if
(
invokeObj
[
"doexec"
])
{
...
...
center-manage/app/config/settings.js
View file @
9a557a21
...
...
@@ -18,8 +18,27 @@ var settings = {
defaultpwd
:
"gsb2020"
,
basepath
:
path
.
normalize
(
path
.
join
(
__dirname
,
'../..'
)),
port
:
process
.
env
.
NODE_PORT
||
80
,
logindex
:
"center_manage"
,
appname
:
"center_manage"
,
logindex
:
"center_manage"
,
appname
:
"center_manage"
,
publickey
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
{
"kty"
:
"RSA"
,
"n"
:
"qrie8Rrptw5hGJ9fdI8f6QJuLLbTulWkSmFYDQDPu2aXP65wbRhtPMxn6DA9Qh_o29LqtlNd1L5dhY5ma_hXSwNv-FfiQoUkkdFFZ2H_mODnKaLtV5evho9r3_wGa92dxV_UZQVUurhZ7V6gQk0BzrpUuMqZ1JDOcD4iG_bEEZjuRXWpXtKKj7MoXJyTUrOlCyN1yFo7gxM3ee6rImxfDP4nEhKPnL7HqwTcXCQApLJORRluoThEciVXRs8SYk08MtemZUhCq8QjXTvS52S5u5o_osFqs1DnPYHpiAfydOfEweFCgomt7imD5vIjOlUDEBSGE0mRUFCBnM3Qg_idZQ"
,
"e"
:
"AQAB"
,
"kid"
:
"dc2c533023a111e9a95769b80b428cd1"
,
"alg"
:
"ES256"
}
}
else
{
return
{
"kty"
:
"RSA"
,
"n"
:
"vkjTlSBYiknVYOJZXAGOyckL3aIdxxcR7iBtGtScfmB5xPop3-ZyYIuBnvCDlqx4r33Hut0bBnEbyOCOWPjsL0szsNZO4Ojbzju3INhiXxqJUPsfuPs82zDEuq-MOF2FnxeGeihPY8Va_YPSjZj9ZeN7eUtRP-nct2N4XftOxQrUPwbMAWnfZskMrjiYD-NRsIcwYaKvkvO9sfjzD9Hkp3OVTnz-doVN7FqWTLGAX8veN2bTWOD5vTqfHwhgxFR0jgZgDHMD262zFBj4ULlLlGr2J9zhWPxEOvod58ll_tHA4Q9HLzmol3u8yGuD7heyRmqnF74qEbbal-Xk67uAyw"
,
"e"
:
"AQAB"
,
"kid"
:
"e1703c2001dd11e9b50fd525bc2a7e1d"
,
"alg"
:
"ES256"
};
}
},
kongurl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
var
localsettings
=
require
(
"./localsettings"
);
...
...
@@ -35,7 +54,7 @@ var settings = {
return
"http://icdeliver-service"
;
}
},
logUrl
:
function
()
{
logUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
"http://192.168.1.128:4019/api/queueAction/producer/springBoard"
;
}
else
{
...
...
center-manage/package.json
View file @
9a557a21
...
...
@@ -45,6 +45,7 @@
"
node-cron
"
:
"^2.0.1"
,
"
node-uuid
"
:
"^1.4.8"
,
"
pdfcrowd
"
:
"^4.2.0"
,
"
pem-jwk
"
:
"^2.0.0"
,
"
pinyin
"
:
"^2.8.3"
,
"
qr-image
"
:
"^3.2.0"
,
"
request
"
:
"^2.88.2"
,
...
...
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