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
c860800c
Commit
c860800c
authored
Dec 05, 2019
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
cd959b15
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
28 deletions
+46
-28
igirl-channel-jdweb/app/base/controller/impl/trademark/tmqueryCtl.js
+15
-0
igirl-channel-jdweb/app/base/utils/execClient.js
+20
-0
igirl-channel-jdweb/app/config/routes/web.js
+11
-28
No files found.
igirl-channel-jdweb/app/base/controller/impl/trademark/tmqueryCtl.js
View file @
c860800c
...
...
@@ -10,6 +10,7 @@ class tmqueryCtl extends CtlBase {
jd
:
{
appkey
:
"201911251551"
,
secret
:
"56006077354d48858026c80c0e10bef6"
}
};
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
jdOauthUrl
=
"https://oauth2.jdcloud.com/userinfo"
;
}
async
doPost
(
pobj
,
obj
,
req
)
{
var
rc
=
system
.
getObject
(
"util.execClient"
);
...
...
@@ -157,6 +158,20 @@ class tmqueryCtl extends CtlBase {
return
system
.
getResultSuccess
(
resultTmpSign
);
}
async
getUserInfo
(
pobj
,
qobj
,
req
)
{
try
{
var
result
=
await
this
.
execClient
.
execPostJDTK
(
""
,
this
.
jdOauthUrl
,
qobj
.
access_token
);
console
.
log
(
result
,
"getUserInfo.....result......."
);
if
(
!
result
||
!
result
.
account
)
{
return
system
.
getResult
(
null
,
"处理用户请求失败,msg:"
+
result
.
error_description
);
}
return
system
.
getResultSuccess
(
result
);
}
catch
(
error
)
{
console
.
log
(
e
.
stack
,
"操作error..................."
);
return
system
.
getResult
(
null
,
"操作失败"
);
}
}
}
module
.
exports
=
tmqueryCtl
;
// var task = new tmqueryCtl();
...
...
igirl-channel-jdweb/app/base/utils/execClient.js
View file @
c860800c
...
...
@@ -7,12 +7,32 @@ class ExecClient {
this
.
cmdPostPattern
=
"curl -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}"
;
this
.
cmdJDPostTK
=
"curl -k -H 'Content-type:text/plain;charset=UTF-8' -H 'metadata:true' -H 'Authorization:{tk}' -d '{data}' {url}"
;
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
async
execPostJDTK
(
subData
,
url
,
token
)
{
let
cmd
=
this
.
FetchPostJDTK
(
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
;
}
}
FetchPostJDTK
(
subData
,
url
,
token
)
{
var
data
=
JSON
.
stringify
(
subData
);
var
requestId
=
this
.
getUUID
();
var
cmd
=
this
.
cmdJDPostTK
.
replace
(
/
\{
data
\}
/g
,
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
tk
\}
/g
,
token
);
return
cmd
;
}
async
execPostTK
(
subData
,
url
,
token
)
{
let
cmd
=
this
.
FetchPostTK
(
subData
,
url
,
token
);
var
result
=
await
this
.
exec
(
cmd
,
{
...
...
igirl-channel-jdweb/app/config/routes/web.js
View file @
c860800c
...
...
@@ -3,40 +3,23 @@ var System = require("../../base/system");
var
metaCtl
=
System
.
getObject
(
"web.common.metaCtl"
);
var
tmqueryCtl
=
System
.
getObject
(
"web.trademark.tmqueryCtl"
);
module
.
exports
=
function
(
app
)
{
app
.
get
(
"/1688/selfRegister"
,
async
function
(
req
,
res
)
{
var
params
=
{
actionProcess
:
"1688"
,
requrl
:
"/action/tmOrder/springBoard"
,
actionType
:
"op1688ChannelPushOrder"
,
actionBody
:
req
.
query
};
params
.
actionBody
.
channelItemCode
=
"1406046"
;
var
result
=
await
tmqueryCtl
.
doPost
(
params
,
null
,
req
);
if
(
result
.
status
!=
0
)
{
console
.
log
(
result
,
"result........."
);
res
.
end
(
JSON
.
stringify
(
result
));
app
.
get
(
"/jdtm/getUser"
,
async
function
(
req
,
res
)
{
var
params
=
req
.
query
;
if
(
!
params
.
state
)
{
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
var
skipUrl
=
"/#/1688/jdindentlist?channelUserId="
+
encodeURIComponent
(
result
.
data
);
res
.
redirect
(
skipUrl
);
});
app
.
get
(
"/1688/auxRegister"
,
async
function
(
req
,
res
)
{
var
params
=
{
actionProcess
:
"1688"
,
requrl
:
"/action/tmOrder/springBoard"
,
actionType
:
"op1688ChannelPushOrder"
,
actionBody
:
req
.
query
};
params
.
actionBody
.
channelItemCode
=
"3492659"
;
var
result
=
await
tmqueryCtl
.
doPost
(
params
,
null
,
req
);
if
(
result
.
status
!=
0
)
{
console
.
log
(
result
,
"result........."
);
res
.
end
(
JSON
.
stringify
(
result
));
var
userItemResult
=
await
this
.
tmqueryCtl
.
getUserInfo
(
req
.
body
,
req
.
query
,
req
);
if
(
userItemResult
.
status
!=
0
)
{
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
var
skipUrl
=
"/#/
1688/jdindentlist?channelUserId="
+
encodeURIComponent
(
result
.
data
);
var
skipUrl
=
"/#/
jd/"
+
params
.
state
+
"?channelUserId="
+
encodeURIComponent
(
userItemResult
.
data
.
account
);
res
.
redirect
(
skipUrl
);
});
app
.
get
(
"/jdtm/orderNotify"
,
async
function
(
req
,
res
)
{
//TODO:处理新购
});
app
.
get
(
"/"
,
async
function
(
req
,
res
)
{
console
.
log
(
req
.
hostname
,
"hostname............."
);
try
{
...
...
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