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
6e1cfb4c
Commit
6e1cfb4c
authored
Mar 27, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
ac313f1d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
17 deletions
+108
-17
center-app/app/base/api/impl/auth/channelAccessAuth.js
+9
-0
center-app/app/base/service/impl/utilsSve/utilsAlibankSve.js
+0
-1
center-app/app/base/service/impl/utilsSve/utilsuserSve.js
+99
-16
No files found.
center-app/app/base/api/impl/auth/channelAccessAuth.js
View file @
6e1cfb4c
...
@@ -14,5 +14,13 @@ class ChannelAccessAuthAPI extends APIBase {
...
@@ -14,5 +14,13 @@ class ChannelAccessAuthAPI extends APIBase {
var
opResult
=
await
this
.
utilsuserSve
.
getH5AliDingUserByCode
(
pobj
);
var
opResult
=
await
this
.
utilsuserSve
.
getH5AliDingUserByCode
(
pobj
);
return
opResult
;
return
opResult
;
}
}
/**
* 获取钉钉鉴权信息
* actionBody code授权码
*/
async
getDingJsApiAuthInfo
(
pobj
,
qobj
,
req
)
{
var
opResult
=
await
this
.
utilsuserSve
.
getDingJsApiAuthentication
(
pobj
);
return
opResult
;
}
}
}
module
.
exports
=
ChannelAccessAuthAPI
;
module
.
exports
=
ChannelAccessAuthAPI
;
\ No newline at end of file
center-app/app/base/service/impl/utilsSve/utilsAlibankSve.js
View file @
6e1cfb4c
...
@@ -55,7 +55,6 @@ class utilsTlBankSve extends AppServiceBase {
...
@@ -55,7 +55,6 @@ class utilsTlBankSve extends AppServiceBase {
return
signature
;
return
signature
;
}
}
//-------------------------------------------钉钉h5支付-----------------结束
//-------------------------------------------钉钉h5支付-----------------结束
}
}
...
...
center-app/app/base/service/impl/utilsSve/utilsuserSve.js
View file @
6e1cfb4c
var
system
=
require
(
"../../../system"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
AppServiceBase
=
require
(
"../../app.base"
);
const
AppServiceBase
=
require
(
"../../app.base"
);
const
cryptoJS
=
require
(
"crypto-js"
);
//商标查询操作
//商标查询操作
class
UtilsUserSve
extends
AppServiceBase
{
class
UtilsUserSve
extends
AppServiceBase
{
constructor
()
{
constructor
()
{
super
();
super
();
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
apppaliparamDao
=
system
.
getObject
(
"db.dbapp.apppaliparamDao"
);
this
.
apppaliparamDao
=
system
.
getObject
(
"db.dbapp.apppaliparamDao"
);
this
.
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
this
.
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
}
}
...
@@ -13,25 +15,11 @@ class UtilsUserSve extends AppServiceBase {
...
@@ -13,25 +15,11 @@ class UtilsUserSve extends AppServiceBase {
if
(
!
item
)
{
if
(
!
item
)
{
return
system
.
getResult
(
null
,
"应用对应的配置数据为空!"
);
return
system
.
getResult
(
null
,
"应用对应的配置数据为空!"
);
}
}
var
param
=
{
var
accessTokenResult
=
await
this
.
getDingAccessToken
(
pobj
,
item
);
appkey
:
item
.
appkey
,
appsecret
:
item
.
appsecret
};
var
accessTokenResult
=
await
this
.
execGetUrl
(
param
,
"https://oapi.dingtalk.com/gettoken"
);
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
:
""
,
op
:
"https://oapi.dingtalk.com/gettoken"
,
content
:
"参数:"
+
JSON
.
stringify
(
param
)
+
"返回结果:"
+
JSON
.
stringify
(
accessTokenResult
),
optitle
:
"获取钉钉access_token信息返回"
,
});
if
(
accessTokenResult
.
status
!=
0
)
{
if
(
accessTokenResult
.
status
!=
0
)
{
return
accessTokenResult
;
return
accessTokenResult
;
}
}
if
(
accessTokenResult
.
data
.
errcode
!=
0
)
{
var
param
=
{
return
system
.
getResult
(
null
,
accessTokenResult
.
data
.
errmsg
);
}
param
=
{
access_token
:
accessTokenResult
.
data
.
access_token
,
access_token
:
accessTokenResult
.
data
.
access_token
,
code
:
pobj
.
actionBody
.
code
code
:
pobj
.
actionBody
.
code
};
};
...
@@ -56,5 +44,100 @@ class UtilsUserSve extends AppServiceBase {
...
@@ -56,5 +44,100 @@ class UtilsUserSve extends AppServiceBase {
});
});
}
}
/**
* 获取钉钉jsapi鉴权的参数
* @param {*} pobj
* @param {*} actionBody
*/
async
getDingJsApiAuthentication
(
pobj
)
{
var
item
=
await
this
.
apppaliparamDao
.
getItemByUAppId
(
pobj
.
appInfo
.
uapp_id
);
if
(
!
item
)
{
return
{
status
:
-
310
,
msg
:
"应用没有对应的支付凭证"
}
}
var
accessTokenResult
=
await
this
.
getDingAccessToken
(
pobj
,
item
);
if
(
accessTokenResult
.
status
!=
0
)
{
return
accessTokenResult
;
}
var
ticketResult
=
await
this
.
getDingTicket
(
pobj
,
item
,
accessTokenResult
.
data
.
access_token
);
if
(
ticketResult
.
status
!=
0
)
{
return
ticketResult
;
}
var
timeStamp
=
Date
.
now
();
var
nonceStr
=
await
this
.
getBusUid
(
"sy"
);
var
nowPageUrl
=
pobj
.
actionBody
&&
pobj
.
actionBody
.
nowPageUrl
?
pobj
.
actionBody
.
nowPageUrl
:
"http://alitm.qifu.gongsibao.com"
;
var
parameters
=
{
agentId
:
item
.
agent_id
,
corpId
:
item
.
corp_id
,
timeStamp
:
timeStamp
.
toString
(),
nonceStr
:
nonceStr
};
var
signature
=
await
this
.
getJsApiSingnature
(
ticketResult
.
data
.
ticket
,
parameters
.
nonceStr
,
parameters
.
timeStamp
,
nowPageUrl
);
parameters
.
signature
=
signature
;
return
system
.
getResultSuccess
(
parameters
);
}
async
getDingAccessToken
(
pobj
,
item
)
{
//获取钉钉access_token----本类中调用
var
param
=
{
appkey
:
item
.
appkey
,
appsecret
:
item
.
appsecret
};
var
accessTokenResult
=
await
this
.
execGetUrl
(
param
,
"https://oapi.dingtalk.com/gettoken"
);
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
:
""
,
op
:
"https://oapi.dingtalk.com/gettoken"
,
content
:
"参数:"
+
JSON
.
stringify
(
param
)
+
"返回结果:"
+
JSON
.
stringify
(
accessTokenResult
),
optitle
:
"获取钉钉access_token信息返回"
,
});
if
(
accessTokenResult
.
status
!=
0
)
{
return
accessTokenResult
;
}
if
(
accessTokenResult
.
data
.
errcode
!=
0
)
{
return
system
.
getResult
(
null
,
accessTokenResult
.
data
.
errmsg
);
}
return
accessTokenResult
;
}
async
getDingTicket
(
pobj
,
item
,
access_token
)
{
//获取钉钉jsapi_ticket----本类中调用
var
ticketCachekey
=
settings
.
cacheprefix
+
"_ali-ticket:"
+
item
.
appkey
;
var
cacheValue
=
await
this
.
redisClient
.
get
(
ticketCachekey
);
if
(
cacheValue
&&
cacheValue
!=
"undefined"
&&
cacheValue
!=
"null"
)
{
return
JSON
.
parse
(
cacheValue
)
}
var
param
=
{
access_token
:
access_token
};
var
ticketResult
=
await
this
.
execGetUrl
(
param
,
"https://oapi.dingtalk.com/get_jsapi_ticket"
);
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
:
""
,
op
:
"https://oapi.dingtalk.com/get_jsapi_ticket"
,
content
:
"参数:"
+
JSON
.
stringify
(
param
)
+
"返回结果:"
+
JSON
.
stringify
(
ticketResult
),
optitle
:
"获取钉钉jsapi_ticket信息返回"
,
});
if
(
ticketResult
.
status
!=
0
)
{
return
ticketResult
;
}
if
(
ticketResult
.
data
.
errcode
!=
0
)
{
return
system
.
getResult
(
null
,
ticketResult
.
data
.
errmsg
);
}
var
expireTime
=
ticketResult
.
data
.
expires_in
||
20
;
this
.
redisClient
.
setWithEx
(
ticketCachekey
,
JSON
.
stringify
(
ticketResult
),
expireTime
);
return
ticketResult
;
}
/**
* 获取JsApi鉴权签名信息----本类中调用
* @param {*} ticket
* @param {*} nonce
* @param {*} timeStamp
* @param {*} url
*/
async
getJsApiSingnature
(
ticket
,
nonce
,
timeStamp
,
url
)
{
//获取JsApi鉴权签名信息----本类中调用
let
plainTex
=
"jsapi_ticket="
+
ticket
+
"&noncestr="
+
nonce
+
"×tamp="
+
timeStamp
+
"&url="
+
url
;
let
signature
=
cryptoJS
.
SHA1
(
plainTex
).
toString
();
return
signature
;
}
}
}
module
.
exports
=
UtilsUserSve
;
module
.
exports
=
UtilsUserSve
;
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