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
07ffb29e
Commit
07ffb29e
authored
Dec 03, 2019
by
王栋源
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wdy
parent
4c1fd1c4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
7 deletions
+111
-7
igirl-channel-gateway/app/base/api/api.base.js
+1
-6
igirl-channel-gateway/app/base/api/impl/action/tradetransfer.js
+75
-0
igirl-channel-gateway/app/base/utils/execClient.js
+27
-1
igirl-channel-gateway/app/config/settings.js
+8
-0
igirl-channel-gateway/package-lock.json
+0
-0
No files found.
igirl-channel-gateway/app/base/api/api.base.js
View file @
07ffb29e
...
...
@@ -118,12 +118,7 @@ class APIBase {
req
.
headers
[
"request-id"
]
=
requestid
;
}
try
{
//验证accesskey或验签
var
isPassResult
=
await
this
.
checkAcck
(
gname
,
methodname
,
pobj
,
query
,
req
);
if
(
isPassResult
.
status
!=
0
)
{
isPassResult
.
requestId
=
""
;
return
isPassResult
;
}
req
.
requestId
=
requestid
;
var
rtn
=
await
this
[
methodname
](
pobj
,
query
,
req
);
if
(
rtn
&&
!
rtn
.
requestId
)
{
...
...
igirl-channel-gateway/app/base/api/impl/action/tradetransfer.js
0 → 100644
View file @
07ffb29e
const
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
var
APIBase
=
require
(
"../../api.base"
);
class
TradetransferAPI
extends
APIBase
{
constructor
()
{
super
();
this
.
execlient
=
system
.
getObject
(
"util.execClient"
);
this
.
channelApiUrl
=
settings
.
channelApiUrl
();
}
async
getToken
()
{
var
self
=
this
;
var
reqTokenUrl
=
this
.
channelApiUrl
+
"/auth/accessAuth/getToken"
;
var
reqParam
=
self
.
appInfo
[
"aliyuntmtransfer"
];
if
(
!
reqParam
.
appkey
||
!
reqParam
.
secret
)
{
return
system
.
getResult
(
null
,
"reqType类型有误,请求失败"
);
}
var
rtn
=
await
this
.
execlient
.
execPost
(
reqParam
,
reqTokenUrl
);
if
(
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"获取token失败"
);
}
var
tokenResult
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
tokenResult
.
status
==
0
)
{
tokenResult
.
data
.
secret
=
reqParam
.
secret
;
}
return
tokenResult
;
}
//订单创建
async
createtransfer
(
obj
)
{
var
sobj
=
{
"actionProcess"
:
"aliyuntmtransfer"
,
"actionType"
:
"aliclient"
,
"sign"
:
"2FviZ9PGws8Pt1fBhq0t90mjUvI"
,
"actionBody"
:
obj
}
// var tokenInfo = await this.getToken();
var
url
=
this
.
channelApiUrl
+
"/api/transfer/tradeApi/createtransfer"
;
// var rtn = await this.execlient.execPostTK(sobj, reqUrl, tokenInfo.data.token);
var
rtn
=
await
this
.
execlient
.
execPostTK
(
sobj
,
url
,
"token"
);
return
rtn
;
}
//订单查询
async
ordersel
(
obj
)
{
var
sobj
=
{
"actionProcess"
:
"aliyuntmtransfer"
,
"actionType"
:
"aliclient"
,
"sign"
:
"2FviZ9PGws8Pt1fBhq0t90mjUvI"
,
"actionBody"
:
obj
}
// var tokenInfo = await this.getToken();
var
url
=
this
.
channelApiUrl
+
"/api/transfer/tradeApi/ordersel"
;
// var rtn = await this.execlient.execPostTK(sobj, reqUrl, tokenInfo.data.token);
var
rtn
=
await
this
.
execlient
.
execPostTK
(
sobj
,
url
,
"token"
);
return
rtn
;
}
//订单关闭
async
orderclose
(
obj
)
{
var
sobj
=
{
"actionProcess"
:
"aliyuntmtransfer"
,
"actionType"
:
"aliclient"
,
"sign"
:
"2FviZ9PGws8Pt1fBhq0t90mjUvI"
,
"actionBody"
:
obj
}
// var tokenInfo = await this.getToken();
var
url
=
this
.
channelApiUrl
+
"/api/transfer/tradeApi/orderclose"
;
// var rtn = await this.execlient.execPostTK(sobj, reqUrl, tokenInfo.data.token);
var
rtn
=
await
this
.
execlient
.
execPostTK
(
sobj
,
url
,
"token"
);
return
rtn
;
}
}
module
.
exports
=
TradetransferAPI
;
igirl-channel-gateway/app/base/utils/execClient.js
View file @
07ffb29e
var
childproc
=
require
(
'child_process'
);
const
util
=
require
(
'util'
);
const
exec
=
util
.
promisify
(
require
(
'child_process'
).
exec
);
const
uuidv4
=
require
(
'uuid/v4'
);
class
ExecClient
{
constructor
()
{
this
.
cmdPostPattern
=
"curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}"
;
this
.
cmdGetPattern
=
"curl -G -X GET '{url}'"
;
this
.
cmdPostTK
=
"curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}"
;
}
async
exec
(
cmd
)
{
...
...
@@ -15,6 +16,31 @@ class ExecClient {
return
{
stdout
,
stderr
};
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
async
execPostTK
(
subData
,
url
,
token
)
{
let
cmd
=
this
.
FetchPostTK
(
subData
,
url
,
token
);
var
result
=
await
this
.
exec
(
cmd
,
{
maxBuffer
:
1024
*
1024
*
15
});
var
rtn
=
result
.
stdout
;
if
(
rtn
)
{
return
JSON
.
parse
(
rtn
);
}
else
{
return
null
;
}
}
FetchPostTK
(
subData
,
url
,
token
)
{
var
data
=
JSON
.
stringify
(
subData
);
var
requestId
=
this
.
getUUID
();
var
cmd
=
this
.
cmdPostTK
.
replace
(
/
\{
data
\}
/g
,
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
tk
\}
/g
,
token
).
replace
(
/
\{
requestId
\}
/g
,
requestId
);
return
cmd
;
}
async
exec2
(
cmd
)
{
return
exec
(
cmd
,
{
encoding
:
"base64"
});
...
...
igirl-channel-gateway/app/config/settings.js
View file @
07ffb29e
...
...
@@ -38,6 +38,14 @@ var settings = {
return
"http://43.247.184.94:7200/"
;
}
},
channelApiUrl
:
function
()
{
if
(
this
.
env
==
"dev"
)
{
return
"http://192.168.18.61:4003"
;
}
else
{
return
"http://zc-channel-service"
;
}
},
apiconfig
:
{
opLogUrl
:
function
()
{
return
settings
.
reqEsAddr
()
+
"bigdata_zc_op_log/_doc?pretty"
;
...
...
igirl-channel-gateway/package-lock.json
View file @
07ffb29e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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