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
c01e56c0
Commit
c01e56c0
authored
Dec 28, 2019
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
e91b5eaa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
87 deletions
+92
-87
igirl-channel-web/app/base/controller/ctl.base.js
+3
-3
igirl-channel-web/app/base/controller/impl/trademark/tmqueryCtl.js
+70
-21
igirl-channel-web/app/base/utils/execClient.js
+0
-4
igirl-channel-web/app/config/routes/web.js
+19
-59
No files found.
igirl-channel-web/app/base/controller/ctl.base.js
View file @
c01e56c0
...
...
@@ -9,10 +9,10 @@ class CtlBase {
this
.
logUrl
=
settings
.
channelApiUrl
()
+
"/action/opLog"
;
}
async
error
(
param
,
token
)
{
this
.
execClient
.
execPost
TK
(
param
,
this
.
logUrl
+
"/error"
,
token
);
this
.
execClient
.
execPost
(
param
,
this
.
logUrl
+
"/error"
);
}
async
info
(
param
,
token
)
{
this
.
execClient
.
execPost
TK
(
param
,
this
.
logUrl
+
"/info"
,
token
);
async
info
(
param
)
{
this
.
execClient
.
execPost
(
param
,
this
.
logUrl
+
"/info"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
igirl-channel-web/app/base/controller/impl/trademark/tmqueryCtl.js
View file @
c01e56c0
...
...
@@ -11,8 +11,6 @@ class tmqueryCtl extends CtlBase {
1688
:
{
appkey
:
"201911131657"
,
secret
:
"eeb18393aade40149287b024d8ba0850"
},
gsbhome
:
{
appkey
:
"201912141625"
,
secret
:
"8cbb846776874167b5c7e01cd0116c66"
}
};
// this.logClient = system.getObject("util.logClient");
}
async
doPost
(
pobj
,
obj
,
req
)
{
if
([
"subTmOrder"
,
"getTmOrderList"
,
"getTmOrderInfo"
,
"getTmApplyInfo"
,
"getTmNclList"
,
...
...
@@ -266,6 +264,12 @@ class tmqueryCtl extends CtlBase {
if
(
tokenInfo
.
status
!=
0
)
{
return
tokenInfo
;
}
this
.
info
({
optitle
:
"###关联下单的数据参数"
,
op
:
"putPayOrderData"
,
content
:
"pobj参数="
+
JSON
.
stringify
(
pobj
)
+
",orderResult="
+
JSON
.
stringify
(
orderResult
),
clientIp
:
""
});
var
param
=
{
actionProcess
:
pobj
.
actionProcess
,
actionType
:
"updateOrderStatus"
,
...
...
@@ -277,18 +281,20 @@ class tmqueryCtl extends CtlBase {
},
isUser
:
"yes"
};
// console.log(param, "putPayOrderData########################################333333...........................");
this
.
logClient
.
info
(
pobj
.
actionProcess
,
"putPayOrderData###..."
+
JSON
.
stringify
(
param
));
var
reqUrl
=
this
.
channelApiUrl
+
"/action/tmOrder/springBoard"
;
var
tmp
=
await
this
.
execClient
.
execPostTK
(
param
,
reqUrl
,
tokenInfo
.
data
.
token
);
this
.
logClient
.
info
(
pobj
.
actionProcess
,
"putPayOrderData###...Result-->"
+
JSON
.
stringify
(
tmp
));
// console.log(tmp, "putPayOrderData########################################333333..........tmptmptmptmp.................");
this
.
info
({
optitle
:
"###关联下单的数据---结果"
,
op
:
"putPayOrderData"
,
content
:
"结果="
+
JSON
.
stringify
(
tmp
),
clientIp
:
""
});
}
//----------------------------jd------操作------------start
async
getJdUserInfo
(
pobj
,
qobj
,
req
)
{
try
{
// this.logClient.info("jd", "getUserInfo--info--->pobj:" + JSON.stringify(pobj));
req
.
session
.
userPinInfo
=
null
;
if
(
req
.
session
.
userPinInfo
)
{
return
system
.
getResultSuccess
({
encryptChannelUserId
:
req
.
session
.
userPinInfo
.
encryptChannelUserId
||
""
});
...
...
@@ -310,7 +316,7 @@ class tmqueryCtl extends CtlBase {
return
system
.
getResult
(
null
,
"处理用户请求失败,msg:"
+
result
.
error_description
);
}
var
tokenInfo
=
await
this
.
getToken
(
actionProcess
);
this
.
logClient
.
info
(
"jd"
,
"getUserInfo----->tokenInfo:"
+
JSON
.
stringify
(
tokenInfo
));
if
(
tokenInfo
.
status
!=
0
)
{
return
tokenInfo
;
}
...
...
@@ -321,20 +327,37 @@ class tmqueryCtl extends CtlBase {
actionBody
:
{
channelUserId
:
result
.
account
},
isUser
:
"yes"
};
var
reqUrl
=
this
.
channelApiUrl
+
"/action/tmTools/springBoard"
;
var
resultUser
=
await
this
.
execClient
.
execPostTK
(
param
,
reqUrl
,
tokenInfo
.
data
.
token
);
this
.
logClient
.
info
(
"jd"
,
"getUserInfo----->resultUser:"
+
JSON
.
stringify
(
resultUser
));
this
.
info
({
optitle
:
"###获取京东用户结果"
,
op
:
"/jd/getJdUserInfo"
,
content
:
"param参数="
+
JSON
.
stringify
(
param
)
+
",resultUser="
+
JSON
.
stringify
(
resultUser
),
clientIp
:
""
});
if
(
!
resultUser
)
{
return
system
.
getResult
(
null
,
"处理请求失败"
);
}
req
.
session
.
userPinInfo
=
resultUser
.
data
;
return
system
.
getResultSuccess
({
encryptChannelUserId
:
resultUser
.
data
.
encryptChannelUserId
||
""
});
}
catch
(
error
)
{
this
.
logClient
.
error
(
"jd"
,
"req---->getUserInfo---->error:"
+
error
.
stack
);
this
.
error
({
optitle
:
"###获取京东用户异常"
,
op
:
"/jd/getJdUserInfo"
,
content
:
"error="
+
JSON
.
stringify
(
error
.
stack
),
clientIp
:
""
});
return
system
.
getResultFail
(
-
200
,
"操作error"
);
}
}
async
opJdPayPageInfo
(
pobj
,
orderResult
,
req
)
{
//操作下单的数据跟渠道订单关联
this
.
info
({
optitle
:
"###操作下单的数据跟渠道订单关联参数"
,
op
:
"/jd/opJdPayPageInfo"
,
content
:
"pobj参数="
+
JSON
.
stringify
(
pobj
)
+
",orderResult="
+
JSON
.
stringify
(
orderResult
),
clientIp
:
""
});
if
(
!
pobj
.
actionBody
.
itemCode
)
{
return
system
.
getResult
(
null
,
"itemCode param is not empty"
);
}
...
...
@@ -349,7 +372,12 @@ class tmqueryCtl extends CtlBase {
// '{"success":true,"code":null,"msg":null,"data":{"orderNumber":"6058867","erpOrderId":"523198741458590844",
// "returnUrl":"https://buy.jdcloud.com/pay?orderId=523198741458590844","saasCheckUrl":null}}' }
this
.
logClient
.
info
(
"jd"
,
"opJdPayPageInfo--tmpResult-->"
+
JSON
.
stringify
(
tmpResult
));
this
.
info
({
optitle
:
"###操作下单的数据跟渠道订单关联--结果"
,
op
:
"/jd/opJdPayPageInfo"
,
content
:
"tmpResult="
+
JSON
.
stringify
(
tmpResult
),
clientIp
:
""
});
if
(
tmpResult
&&
tmpResult
.
result
&&
tmpResult
.
result
==
true
)
{
var
payDataResult
=
JSON
.
parse
(
tmpResult
.
data
);
...
...
@@ -428,9 +456,12 @@ class tmqueryCtl extends CtlBase {
for
(
let
[
key
,
value
]
of
ctx
.
headers
)
{
options
.
headers
[
key
]
=
value
}
this
.
logClient
.
info
(
"jd"
,
"req---->getJdPayPageAddr---->options:"
+
JSON
.
stringify
(
options
));
this
.
logClient
.
info
(
"jd"
,
"req---->getJdPayPageAddr---->tmpContent:"
+
tmpContent
);
this
.
info
({
optitle
:
"###获取京东下单--参数"
,
op
:
"/jd/getJdPayPageAddr"
,
content
:
"options="
+
JSON
.
stringify
(
options
)
+
",tmpContent="
+
JSON
.
stringify
(
tmpContent
),
clientIp
:
""
});
var
reqResult
=
await
new
Promise
(
function
(
resolve
,
reject
)
{
let
req
=
http
.
request
(
options
,
function
(
res
)
{
// res.setEncoding(encoding);
...
...
@@ -454,11 +485,22 @@ class tmqueryCtl extends CtlBase {
});
return
reqResult
;
}
catch
(
errorMsg
)
{
this
.
logClient
.
error
(
"jd"
,
"req---->getJdPayPageAddr---->error:"
+
error
.
stack
);
this
.
error
({
optitle
:
"###获取京东下单--异常"
,
op
:
"/jd/getJdPayPageAddr"
,
content
:
"error="
+
JSON
.
stringify
(
error
.
stack
),
clientIp
:
""
});
return
{
success
:
false
,
code
:
-
200
,
msg
:
error
.
stack
};
}
}
async
pushJdPayOrder
(
pushData
,
req
)
{
//处理京东推送的订单信息
this
.
info
({
optitle
:
"###处理京东推送的订单信息参数"
,
op
:
"/jd/pushJdPayOrder"
,
content
:
"pushData参数="
+
JSON
.
stringify
(
pushData
),
clientIp
:
""
});
try
{
var
signResult
=
await
this
.
createSign
(
pushData
,
"F6FBD101C7571ADE231670F080653874"
,
true
);
if
(
signResult
.
status
!=
0
)
{
...
...
@@ -486,18 +528,25 @@ class tmqueryCtl extends CtlBase {
isUser
:
"yes"
};
var
reqUrl
=
this
.
channelApiUrl
+
"/action/tmOrder/springBoard"
;
this
.
logClient
.
error
(
"jd"
,
"req---->pushJdPayOrder---->params:"
+
JSON
.
stringify
(
param
)
+
",reqUrl:"
+
reqUrl
);
var
resultUser
=
await
this
.
execClient
.
execPostTK
(
param
,
reqUrl
,
tokenInfo
.
data
.
token
);
this
.
info
({
optitle
:
"###处理京东推送的订单信息结果"
,
op
:
"/jd/pushJdPayOrder"
,
content
:
"result="
+
JSON
.
stringify
(
resultUser
),
clientIp
:
""
});
if
(
!
resultUser
)
{
this
.
logClient
.
error
(
"jd"
,
"req---->pushJdPayOrder---->error:"
+
JSON
.
stringify
(
resultUser
));
return
system
.
getResult
(
null
,
"req error"
);
}
return
resultUser
;
}
catch
(
error
)
{
this
.
logClient
.
error
(
"jd"
,
"req---->pushJdPayOrder---->操作error:"
+
error
.
stack
);
this
.
error
({
optitle
:
"###处理京东推送的订单信息异常"
,
op
:
"/jd/pushJdPayOrder"
,
content
:
"error="
+
JSON
.
stringify
(
error
.
stack
),
clientIp
:
""
});
return
system
.
getResultFail
(
-
200
,
"操作error"
);
}
}
...
...
igirl-channel-web/app/base/utils/execClient.js
View file @
c01e56c0
...
...
@@ -9,8 +9,6 @@ class ExecClient {
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}"
;
// this.logClient = system.getObject("util.logClient");
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -23,7 +21,6 @@ class ExecClient {
maxBuffer
:
1024
*
1024
*
15
});
console
.
log
(
"getUserInfo----->execPostJDTK----FetchPostJDTK----cmd--->result:"
+
result
.
stdout
);
// this.logClient.info("jd", "getUserInfo----->execPostJDTK----FetchPostJDTK----cmd--->result:" + result.stdout);
var
rtn
=
result
.
stdout
;
if
(
rtn
)
{
return
JSON
.
parse
(
rtn
);
...
...
@@ -37,7 +34,6 @@ class ExecClient {
var
cmd
=
this
.
cmdJDPostTK
.
replace
(
/
\{
data
\}
/g
,
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
tk
\}
/g
,
token
);
console
.
log
(
"getUserInfo----->execPostJDTK----FetchPostJDTK----cmd--->"
+
cmd
);
// this.logClient.info("jd", "getUserInfo----->execPostJDTK----FetchPostJDTK----cmd--->" + cmd);
return
cmd
;
}
async
execPostTK
(
subData
,
url
,
token
)
{
...
...
igirl-channel-web/app/config/routes/web.js
View file @
c01e56c0
...
...
@@ -2,7 +2,6 @@
var
system
=
require
(
"../../base/system"
);
var
metaCtl
=
system
.
getObject
(
"web.common.metaCtl"
);
var
tmqueryCtl
=
system
.
getObject
(
"web.trademark.tmqueryCtl"
);
var
logClient
=
system
.
getObject
(
"util.logClient"
);
const
jwt
=
require
(
'jsonwebtoken'
);
const
secret
=
'3rZ3aNfGAyQAB4sE'
;
//自定义
...
...
@@ -14,61 +13,34 @@ module.exports = function (app) {
});
app
.
get
(
"/jdtm/getUser"
,
async
function
(
req
,
res
)
{
try
{
var
params
=
req
.
query
;
if
(
!
params
.
state
)
{
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
var
getUserparams
=
{
actionProcess
:
"jd"
,
authUrl
:
"https://oauth2.jdcloud.com/userinfo"
,
authToken
:
params
.
token_type
+
" "
+
params
.
access_token
};
var
userItemResult
=
await
tmqueryCtl
.
getJdUserInfo
(
getUserparams
,
req
.
query
,
req
);
logClient
.
info
(
"jd"
,
{
optitle
:
"###获取京东用户结果...getJdUserInfo"
,
op
:
"/jdtm/getUser"
,
content
:
"参数="
+
JSON
.
stringify
(
getUserparams
)
+
",result="
+
JSON
.
stringify
(
userItemResult
),
clientIp
:
""
});
var
params
=
req
.
query
;
if
(
!
params
.
state
)
{
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
var
getUserparams
=
{
actionProcess
:
"jd"
,
authUrl
:
"https://oauth2.jdcloud.com/userinfo"
,
authToken
:
params
.
token_type
+
" "
+
params
.
access_token
};
var
userItemResult
=
await
tmqueryCtl
.
getJdUserInfo
(
getUserparams
,
req
.
query
,
req
);
if
(
userItemResult
.
status
!=
0
)
{
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
if
(
!
userItemResult
.
data
.
encryptChannelUserId
||
userItemResult
.
data
.
encryptChannelUserId
==
"undefined"
)
{
userItemResult
=
await
tmqueryCtl
.
getUserIdEncryptStr
(
getUserparams
,
req
.
query
,
req
);
if
(
userItemResult
.
status
!=
0
)
{
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
if
(
!
userItemResult
.
data
.
encryptChannelUserId
||
userItemResult
.
data
.
encryptChannelUserId
==
"undefined"
)
{
userItemResult
=
await
tmqueryCtl
.
getUserIdEncryptStr
(
getUserparams
,
req
.
query
,
req
);
if
(
userItemResult
.
status
!=
0
)
{
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
}
var
skipUrl
=
"/#/jd/"
+
params
.
state
+
"?channelUserId="
+
encodeURIComponent
(
userItemResult
.
data
.
encryptChannelUserId
);
res
.
redirect
(
skipUrl
);
}
catch
(
error
)
{
logClient
.
error
(
"jd"
,
{
optitle
:
"###获取京东用户异常...getJdUserInfo"
,
op
:
"/jdtm/getUser"
,
content
:
error
.
stack
,
clientIp
:
""
});
}
var
skipUrl
=
"/#/jd/"
+
params
.
state
+
"?channelUserId="
+
encodeURIComponent
(
userItemResult
.
data
.
encryptChannelUserId
);
res
.
redirect
(
skipUrl
);
});
app
.
get
(
"/jd/orderNotify"
,
async
function
(
req
,
res
)
{
logClient
.
payLog
(
"jd"
,
{
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
.
pushJdPayOrder
(
req
.
query
,
req
);
logClient
.
payLog
(
"jd"
,
{
optitle
:
"###操作订单结果...orderNotify"
,
op
:
"/jd/orderNotify"
,
content
:
"result="
+
JSON
.
stringify
(
result
),
clientIp
:
""
});
if
(
result
.
status
!=
0
)
{
res
.
end
(
JSON
.
stringify
(
result
));
return
;
...
...
@@ -85,12 +57,6 @@ module.exports = function (app) {
return
;
});
app
.
get
(
"/jd/skipPage"
,
async
function
(
req
,
res
)
{
logClient
.
payLog
(
"jd"
,
{
optitle
:
"###操作订单结果后跳转参数...skipPage"
,
op
:
"/jd/skipPage"
,
content
:
"req.query="
+
JSON
.
stringify
(
req
.
query
)
+
",req.body="
+
JSON
.
stringify
(
req
.
body
),
clientIp
:
""
});
var
channelUserId
=
req
.
query
.
channelUserId
;
if
(
channelUserId
&&
channelUserId
.
indexOf
(
'?'
)
>=
0
)
{
channelUserId
=
channelUserId
.
split
(
"?"
)[
0
];
...
...
@@ -101,12 +67,6 @@ module.exports = function (app) {
};
var
userItemResult
=
await
tmqueryCtl
.
getUserIdEncryptStr
(
getUserparams
,
req
.
query
,
req
);
if
(
userItemResult
.
status
!=
0
)
{
logClient
.
payLog
(
"jd"
,
{
optitle
:
"###操作订单结果...orderNotify...加密用户错误"
,
op
:
"/jd/orderNotify"
,
content
:
"result="
+
JSON
.
stringify
(
userItemResult
),
clientIp
:
""
});
res
.
redirect
(
"/#/jd/jdtrademark"
);
return
;
}
...
...
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