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
c2c8d06e
Commit
c2c8d06e
authored
Dec 09, 2019
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
74cdc99f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
17 deletions
+103
-17
igirl-channel-jdweb/app/base/controller/impl/trademark/tmqueryCtl.js
+73
-11
igirl-channel-jdweb/app/config/environment.js
+3
-3
igirl-channel-jdweb/app/config/routes/web.js
+27
-3
No files found.
igirl-channel-jdweb/app/base/controller/impl/trademark/tmqueryCtl.js
View file @
c2c8d06e
...
...
@@ -12,6 +12,7 @@ class tmqueryCtl extends CtlBase {
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
}
async
doPost
(
pobj
,
obj
,
req
)
{
console
.
log
(
req
.
session
.
userPinInfo
,
"req.session.userPinInfo.......................######################################################"
);
var
rc
=
system
.
getObject
(
"util.execClient"
);
try
{
if
(
!
pobj
.
requrl
)
{
...
...
@@ -130,14 +131,12 @@ class tmqueryCtl extends CtlBase {
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
* @param {*} isEmptySign params key 对应值为空是否参与签名
*/
async
createSign
(
params
,
app_key
)
{
async
createSign
(
params
,
app_key
,
isEmptySign
)
{
if
(
!
params
)
{
return
system
.
getResult
(
null
,
"请求参数为空"
);
}
if
(
!
params
.
timeStamp
)
{
return
system
.
getResult
(
null
,
"请求参数timeStamp为空"
);
}
var
signArr
=
[];
var
keys
=
Object
.
keys
(
params
).
sort
();
if
(
keys
.
length
==
0
)
{
...
...
@@ -145,8 +144,18 @@ class tmqueryCtl extends CtlBase {
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
params
[
tKey
])
{
signArr
.
push
(
tKey
+
"="
+
params
[
tKey
]);
if
(
tKey
!=
"sign"
)
{
if
(
tKey
!=
"token"
)
{
if
(
tKey
!=
"actionProcess"
)
{
if
(
isEmptySign
)
{
signArr
.
push
(
tKey
+
"="
+
params
[
tKey
]);
}
else
{
if
(
params
[
tKey
])
{
signArr
.
push
(
tKey
+
"="
+
params
[
tKey
]);
}
}
}
}
}
}
if
(
signArr
.
length
==
0
)
{
...
...
@@ -172,12 +181,10 @@ class tmqueryCtl extends CtlBase {
return
system
.
getResult
(
null
,
"actionProcess不能为空"
);
}
var
result
=
await
this
.
execClient
.
execPostJDTK
(
""
,
authUrl
,
authToken
);
console
.
log
(
result
,
"execPostJDTK............"
);
if
(
!
result
||
!
result
.
account
)
{
return
system
.
getResult
(
null
,
"处理用户请求失败,msg:"
+
result
.
error_description
);
}
var
tokenInfo
=
await
this
.
getToken
(
actionProcess
);
console
.
log
(
tokenInfo
,
"getUserInfo..................getToken............"
);
if
(
tokenInfo
.
status
!=
0
)
{
return
tokenInfo
;
}
...
...
@@ -190,10 +197,10 @@ class tmqueryCtl extends CtlBase {
};
var
reqUrl
=
this
.
channelApiUrl
+
"/action/tmTools/springBoard"
;
var
resultUser
=
await
this
.
execClient
.
execPostTK
(
param
,
reqUrl
,
tokenInfo
.
data
.
token
);
console
.
log
(
resultUser
,
"getUserInfo..................resultUser............"
);
if
(
!
resultUser
)
{
return
system
.
getResult
(
null
,
"处理请求失败"
);
}
req
.
session
.
userPinInfo
=
resultUser
.
data
;
return
resultUser
;
}
catch
(
error
)
{
console
.
log
(
error
.
stack
,
"操作error..................."
);
...
...
@@ -202,7 +209,12 @@ class tmqueryCtl extends CtlBase {
}
async
opPayPageInfo
(
pobj
)
{
if
(
pobj
.
actionProcess
==
"jd"
)
{
var
tmpResult
=
this
.
opJdOrder
();
if
(
!
tmpResult
.
success
&&
tmpResult
.
success
!=
true
)
{
//记录下来
}
return
system
.
getResultSuccess
({
payUrl
:
tmpResult
.
data
.
returnUrl
});
}
return
system
.
getResultSuccess
()
}
...
...
@@ -230,8 +242,6 @@ class tmqueryCtl extends CtlBase {
ctx
.
method
=
'POST'
var
signer
=
new
Signer
(
ctx
,
credentials
);
ctx
.
headers
.
set
(
'Content-Length'
,
tmpContentLength
)
ctx
.
buildNonce
()
var
dd
=
new
Date
();
...
...
@@ -279,6 +289,58 @@ class tmqueryCtl extends CtlBase {
console
.
log
(
errorMsg
,
"--jd>>>>>>>errorMsg..............................>>>>>>"
);
}
}
async
pushJdOrder
(
pushData
,
req
)
{
try
{
var
signResult
=
await
this
.
createSign
(
pushData
,
"6B876EB84731E166D76E1F73AD5764BA"
,
true
);
if
(
signResult
.
status
!=
0
)
{
return
signResult
;
}
if
(
signResult
.
data
!=
pushData
.
token
.
toUpperCase
())
{
return
system
.
getResult
(
null
,
"签名错误"
);
}
var
tokenInfo
=
await
this
.
getToken
(
pushData
.
actionProcess
);
if
(
tokenInfo
.
status
!=
0
)
{
return
tokenInfo
;
}
var
param
=
{};
if
(
pushData
.
serviceCode
==
"FW_GOODS-581976"
)
{
param
=
{
actionProcess
:
pushData
.
actionProcess
,
actionType
:
"updateOrderPayStatus"
,
actionBody
:
{
channelUserId
:
pushData
.
jdPin
,
channelItemCode
:
pushData
.
serviceCode
,
needNoOrderNo
:
pushData
.
orderId
,
buyerMoblie
:
pushData
.
mobile
},
isUser
:
"yes"
};
}
//自助注册产品
else
{
//有返回用户信息进行用户ID加密
param
=
{
actionProcess
:
pushData
.
actionProcess
,
actionType
:
"addOrderAndDelivery"
,
actionBody
:
{
channelUserId
:
pushData
.
jdPin
,
needNoOrderNo
:
pushData
.
orderId
,
buyerMoblie
:
pushData
.
mobile
},
isUser
:
"yes"
};
}
//商标注册【专家辅助申请】、商标注册【担保申请】和 除商标之外的产品
var
reqUrl
=
this
.
channelApiUrl
+
"/action/tmOrder/springBoard"
;
var
resultUser
=
await
this
.
execClient
.
execPostTK
(
param
,
reqUrl
,
tokenInfo
.
data
.
token
);
if
(
!
resultUser
)
{
return
system
.
getResult
(
null
,
"req error"
);
}
return
resultUser
;
}
catch
(
error
)
{
console
.
log
(
error
.
stack
,
"操作error..................."
);
return
system
.
getResultFail
(
-
200
,
"操作error"
);
}
}
}
module
.
exports
=
tmqueryCtl
;
igirl-channel-jdweb/app/config/environment.js
View file @
c2c8d06e
...
...
@@ -31,7 +31,7 @@ module.exports = function (app) {
res
.
header
(
'Access-Control-Allow-Methods'
,
'PUT, POST, GET, DELETE, OPTIONS'
);
// res.header('Access-Control-Allow-Credentials', 'true');
if
(
req
.
method
==
'OPTIONS'
)
{
res
.
send
(
200
);
/让options请求快速返回/
res
.
send
(
200
);
/
/
让options请求快速返回/
}
else
{
next
();
...
...
@@ -40,7 +40,7 @@ module.exports = function (app) {
if
(
settings
.
env
==
"dev"
){
app
.
use
(
session
(
{
name
:
'
devdemosid
'
,
name
:
'
userpin
'
,
cookie
:
{
maxAge
:
3600000
},
rolling
:
true
,
resave
:
false
,
...
...
@@ -53,7 +53,7 @@ module.exports = function (app) {
}
else
{
app
.
use
(
session
(
{
name
:
'
demosid
'
,
name
:
'
userpin
'
,
cookie
:
{
maxAge
:
3600000
},
rolling
:
true
,
resave
:
false
,
...
...
igirl-channel-jdweb/app/config/routes/web.js
View file @
c2c8d06e
...
...
@@ -24,9 +24,33 @@ module.exports = function (app) {
res
.
redirect
(
skipUrl
);
});
app
.
get
(
"/jd/orderNotify"
,
async
function
(
req
,
res
)
{
console
.
log
(
req
.
query
,
"req.query.....########################################################.................orderNotify"
);
console
.
log
(
req
.
body
,
"req.body......########################################################................orderNotify"
);
//TODO:处理新购
// oplogCtl.info({
// optitle: "########################################################.................orderNotify",
// op: "/jd/orderNotify",
// content: "req.query=" + JSON.stringify(req.query) + ",req.body=" + JSON.stringify(req.body),
// clientIp: ""
// });
req
.
query
.
actionProcess
=
"jd"
;
var
result
=
await
tmqueryCtl
.
pushJdOrder
(
req
.
query
,
req
);
// oplogCtl.info({
// optitle: "############################################操作订单结果.................orderNotify",
// op: "/jd/orderNotify",
// content: "req.query=" + JSON.stringify(req.query) + ",req.body=" + JSON.stringify(req.body),
// clientIp: ""
// });
if
(
result
.
status
!=
0
)
{
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
var
params
=
{
instanceId
:
req
.
query
.
orderBizId
,
appInfo
:
{
authUrl
:
"http://oauth2.jdcloud.com/authorize?response_type=token&redirect_uri=http://tm.plus.jdcloud.com/jdtm/getUser&state=jdindentlist&client_id=9841572588670903"
}
};
res
.
end
(
JSON
.
stringify
(
params
));
return
;
});
app
.
get
(
"/"
,
async
function
(
req
,
res
)
{
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