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
f4abece9
Commit
f4abece9
authored
Oct 29, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
baidusign
parent
35a3df97
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
459 additions
and
3 deletions
+459
-3
center-channel/app/base/api/impl/icp/consultation.js
+182
-0
center-channel/app/base/api/impl/icp/feedback.js
+69
-0
center-channel/app/base/api/impl/icp/order.js
+77
-0
center-channel/app/base/service/impl/common/centerorderSve.js
+1
-1
center-channel/app/base/service/impl/common/signSve.js
+100
-0
center-channel/app/config/businessConfig.js
+1
-1
center-channel/app/config/routes/api.js
+29
-1
No files found.
center-channel/app/base/api/impl/icp/consultation.js
0 → 100644
View file @
f4abece9
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
uuidv4
=
require
(
'uuid/v4'
);
/**
* icp通知接口(百度icp接入)
* 庄冰 2020.10.22
*/
class
Consultation
extends
APIBase
{
constructor
()
{
super
();
this
.
gatewaypushlogSve
=
system
.
getObject
(
"service.common.gatewaypushlogSve"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
getResultSuccess
(
requestId
)
{
return
{
"requestId"
:
requestId
,
"success"
:
true
,
"errorMsg"
:
""
,
"errorCode"
:
"ok"
}
}
getResultFail
(
errmsg
)
{
var
self
=
this
;
return
{
"requestId"
:
self
.
getUUID
(),
"success"
:
false
,
"errorMsg"
:
errmsg
,
"errorCode"
:
"ok"
};
}
//icp需求提交
async
submit
(
pobj
,
obj
,
req
)
{
var
self
=
this
;
if
(
!
pobj
.
appInfo
||
!
pobj
.
appInfo
.
uapp_key
||
!
pobj
.
appInfo
.
uapp_secret
){
return
self
.
getResultFail
(
"未知应用或应用未启用"
);
}
if
(
!
pobj
.
intentionBizId
)
{
return
self
.
getResultFail
(
"intentionBizId不能为空"
);
}
if
(
!
pobj
.
phone
)
{
return
self
.
getResultFail
(
"mobile不能为空"
);
}
if
(
!
pobj
.
consultType
)
{
return
self
.
getResultFail
(
"consultType不能为空"
);
}
pobj
.
type
=
pobj
.
consultType
;
pobj
.
mobile
=
pobj
.
phone
;
pobj
.
action_type
=
"submitIcpNeed"
;
if
(
pobj
.
area
)
{
switch
(
pobj
.
area
)
{
case
"1"
:
pobj
.
area
=
"北京"
;
break
;
case
"2"
:
pobj
.
area
=
"上海"
;
break
;
case
"3"
:
pobj
.
area
=
"福建"
;
break
;
case
"4"
:
pobj
.
area
=
"广西"
;
break
;
case
"5"
:
pobj
.
area
=
"广东"
;
break
;
case
"6"
:
pobj
.
area
=
"安徽"
;
break
;
case
"7"
:
pobj
.
area
=
"河南"
;
break
;
case
"8"
:
pobj
.
area
=
"湖北"
;
break
;
case
"9"
:
pobj
.
area
=
"浙江"
;
break
;
case
"10"
:
pobj
.
area
=
"江苏"
;
break
;
case
"11"
:
pobj
.
area
=
"山东"
;
break
;
case
"12"
:
pobj
.
area
=
"陕西"
;
break
;
case
"13"
:
pobj
.
area
=
"宁夏"
;
break
;
case
"14"
:
pobj
.
area
=
"甘肃"
;
break
;
case
"15"
:
pobj
.
area
=
"新疆"
;
break
;
case
"16"
:
pobj
.
area
=
"青海"
;
break
;
case
"17"
:
pobj
.
area
=
"天津"
;
break
;
case
"18"
:
pobj
.
area
=
"重庆"
;
break
;
case
"19"
:
pobj
.
area
=
"河北"
;
break
;
case
"20"
:
pobj
.
area
=
"山西"
;
break
;
case
"21"
:
pobj
.
area
=
"辽宁"
;
break
;
case
"22"
:
pobj
.
area
=
"吉林"
;
break
;
case
"23"
:
pobj
.
area
=
"黑龙江"
;
break
;
case
"24"
:
pobj
.
area
=
"江西"
;
break
;
case
"25"
:
pobj
.
area
=
"湖南"
;
break
;
case
"26"
:
pobj
.
area
=
"四川"
;
break
;
case
"27"
:
pobj
.
area
=
"贵州"
;
break
;
case
"28"
:
pobj
.
area
=
"云南"
;
break
;
case
"29"
:
pobj
.
area
=
"内蒙古"
;
break
;
case
"30"
:
pobj
.
area
=
"西藏"
;
break
;
case
"31"
:
pobj
.
area
=
"含外资"
;
break
;
case
"32"
:
pobj
.
area
=
"全外资"
;
break
;
case
"33"
:
pobj
.
area
=
"香港"
;
break
;
case
"34"
:
pobj
.
area
=
"海南"
;
break
;
default
:
pobj
.
area
=
""
;
break
;
}
}
if
(
!
pobj
.
area
)
{
return
self
.
getResultFail
(
"area参数错误"
);
}
var
param
=
{
requestId
:
req
.
requestId
||
self
.
getUUID
(),
requestUrl
:
"/icp/consultation/submit"
,
requestjson
:
JSON
.
stringify
(
pobj
),
//请求地址
pushUrl
:
"/action/intentionapi/springBoard"
,
//调用地址
pushActionType
:
"submitIcpNeed"
,
//调用参数
pushtimes
:
0
,
//推送次数
pushStatus
:
"wts"
,
//推送状态
}
await
self
.
gatewaypushlogSve
.
create
(
param
);
return
self
.
getResultSuccess
(
param
.
requestId
);
}
}
module
.
exports
=
Consultation
;
\ No newline at end of file
center-channel/app/base/api/impl/icp/feedback.js
0 → 100644
View file @
f4abece9
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
uuidv4
=
require
(
'uuid/v4'
);
/**
* icp通知接口(百度icp接入)
* 庄冰 2020.10.22
*/
class
Feedback
extends
APIBase
{
constructor
()
{
super
();
this
.
gatewaypushlogSve
=
system
.
getObject
(
"service.common.gatewaypushlogSve"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
getResultSuccess
(
requestId
)
{
return
{
"requestId"
:
requestId
,
"success"
:
true
,
"errorMsg"
:
""
,
"errorCode"
:
"ok"
}
}
getResultFail
(
errmsg
)
{
var
self
=
this
;
return
{
"requestId"
:
self
.
getUUID
(),
"success"
:
false
,
"errorMsg"
:
errmsg
,
"errorCode"
:
"ok"
};
}
//icp需求反馈
async
submit
(
pobj
,
obj
,
req
)
{
var
self
=
this
;
if
(
!
pobj
.
appInfo
||
!
pobj
.
appInfo
.
uapp_key
||
!
pobj
.
appInfo
.
uapp_secret
){
return
self
.
getResultFail
(
"未知应用或应用未启用"
);
}
if
(
!
pobj
.
intentionBizId
)
{
return
self
.
getResultFail
(
"intentionBizId不能为空"
);
}
if
(
!
pobj
.
description
)
{
return
self
.
getResultFail
(
"description不能为空"
);
}
if
(
!
pobj
.
intentionStatus
)
{
return
self
.
getResultFail
(
"intentionStatus不能为空"
);
}
var
param
=
{
requestId
:
req
.
requestId
||
self
.
getUUID
(),
requestUrl
:
"/icp/feedback/submit"
,
requestjson
:
JSON
.
stringify
(
pobj
),
//请求地址
pushUrl
:
"/action/intentionapi/springBoard"
,
//调用地址
pushActionType
:
"icpFeedbackSubmit"
,
//调用参数
pushtimes
:
0
,
//推送次数
pushStatus
:
"wts"
,
//推送状态
}
await
self
.
gatewaypushlogSve
.
create
(
param
);
return
self
.
getResultSuccess
(
param
.
requestId
);
}
}
module
.
exports
=
Feedback
;
\ No newline at end of file
center-channel/app/base/api/impl/icp/order.js
0 → 100644
View file @
f4abece9
var
APIBase
=
require
(
"../../api.base"
);
var
system
=
require
(
"../../../system"
);
var
settings
=
require
(
"../../../../config/settings"
);
const
uuidv4
=
require
(
'uuid/v4'
);
/**
* icp通知接口(百度icp接入)
* 庄冰 2020.10.22
*/
class
Order
extends
APIBase
{
constructor
()
{
super
();
this
.
gatewaypushlogSve
=
system
.
getObject
(
"service.common.gatewaypushlogSve"
);
}
getUUID
()
{
var
uuid
=
uuidv4
();
var
u
=
uuid
.
replace
(
/
\-
/g
,
""
);
return
u
;
}
getResultSuccess
(
requestId
)
{
return
{
"requestId"
:
requestId
,
"success"
:
true
,
"errorMsg"
:
""
,
"errorCode"
:
"ok"
}
}
getResultFail
(
errmsg
)
{
var
self
=
this
;
return
{
"requestId"
:
self
.
getUUID
(),
"success"
:
false
,
"errorMsg"
:
errmsg
,
"errorCode"
:
"ok"
};
}
//icp状态变更
async
notify
(
pobj
,
obj
,
req
)
{
var
self
=
this
;
if
(
!
pobj
.
appInfo
||
!
pobj
.
appInfo
.
uapp_key
||
!
pobj
.
appInfo
.
uapp_secret
){
return
self
.
getResultFail
(
"未知应用或应用未启用"
);
}
if
(
!
pobj
.
orderNo
)
{
return
self
.
getResultFail
(
"orderNo不能为空"
);
}
if
(
!
pobj
.
isDirectBuy
||
pobj
.
isDirectBuy
==
"0"
){
pobj
.
isDirectBuy
=
0
;
}
pobj
.
status
=
1
;
if
(
pobj
.
isDirectBuy
==
0
&&
!
pobj
.
bizId
)
{
return
self
.
getResultFail
(
"非直接下单bizId不能为空"
);
}
if
(
pobj
.
isDirectBuy
==
1
&&
!
pobj
.
phone
)
{
return
self
.
getResultFail
(
"直接下单phone不能为空"
);
}
if
(
pobj
.
isDirectBuy
==
1
&&
!
pobj
.
consultType
)
{
return
self
.
getResultFail
(
"直接下单consultType不能为空"
);
}
pobj
.
action_type
=
"icpOrderStatus"
;
var
param
=
{
requestId
:
req
.
requestId
||
self
.
getUUID
(),
requestUrl
:
"/icp/order/notify"
,
requestjson
:
JSON
.
stringify
(
pobj
),
//请求地址
pushUrl
:
"/action/intentionapi/springBoard"
,
//调用地址
pushActionType
:
"icpNotifyNew"
,
//调用参数
pushtimes
:
0
,
//推送次数
pushStatus
:
"wts"
,
//推送状态
}
await
self
.
gatewaypushlogSve
.
create
(
param
);
return
self
.
getResultSuccess
(
param
.
requestId
);
}
}
module
.
exports
=
Order
;
\ No newline at end of file
center-channel/app/base/service/impl/common/centerorderSve.js
View file @
f4abece9
...
@@ -541,7 +541,7 @@ class CenterorderService extends AppServiceBase {
...
@@ -541,7 +541,7 @@ class CenterorderService extends AppServiceBase {
//-----------接入百度ICP------start-------zhuangbing--2020.10.22-------------------------
//-----------接入百度ICP------start-------zhuangbing--2020.10.22-------------------------
async
icppaysuccessNew
(
pobj
)
{
async
icppaysuccessNew
(
pobj
)
{
var
sobj
=
{
var
sobj
=
{
actionType
:
"get
alii
cpProduce"
,
actionType
:
"get
I
cpProduce"
,
// actionBody: { typeCode: itemResult.data.channelTypeCode, province: itemResult.data.province },
// actionBody: { typeCode: itemResult.data.channelTypeCode, province: itemResult.data.province },
actionBody
:
{
typeCode
:
pobj
.
actionBody
.
channelTypeCode
,
province
:
pobj
.
actionBody
.
province
},
actionBody
:
{
typeCode
:
pobj
.
actionBody
.
channelTypeCode
,
province
:
pobj
.
actionBody
.
province
},
appInfo
:
pobj
.
appInfo
,
appInfo
:
pobj
.
appInfo
,
...
...
center-channel/app/base/service/impl/common/signSve.js
0 → 100644
View file @
f4abece9
const
system
=
require
(
"../../../system"
)
const
settings
=
require
(
"../../../../config/settings"
)
const
md5
=
require
(
"MD5"
);
class
SignService
{
constructor
()
{
this
.
centerAppUrl
=
settings
.
centerAppUrl
();
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
}
async
restPostUrl
(
pobj
,
url
)
{
try
{
var
rtn
=
await
this
.
restClient
.
execPost
(
pobj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
catch
(
e
)
{
var
errorMsg
=
"error:"
+
e
.
stack
;
return
system
.
getResult
(
null
,
errorMsg
);
}
}
async
getAppInfoByAppKey
(
appkey
){
let
url
=
this
.
centerAppUrl
+
'payment/paymentApi/getAppInfoByAppKey'
;
let
appInfoRt
=
await
this
.
restPostUrl
({
appKey
:
appkey
},
url
);
return
appInfoRt
;
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_secret 应用的校验key
*/
async
verifySign
(
params
,
app_secret
)
{
if
(
!
params
)
{
return
system
.
getResult
(
null
,
"请求参数为空"
);
}
if
(
!
params
.
sign
)
{
return
system
.
getResult
(
null
,
"请求参数sign为空"
);
}
var
signArr
=
[];
var
keys
=
Object
.
keys
(
params
).
sort
();
if
(
keys
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数信息为空"
);
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
params
[
tKey
])
{
let
tmpKeyValue
=
params
[
tKey
];
if
(
tmpKeyValue
instanceof
Array
||
tmpKeyValue
instanceof
Object
)
{
tmpKeyValue
=
JSON
.
stringify
(
tmpKeyValue
);
}
signArr
.
push
(
tKey
+
"="
+
tmpKeyValue
);
}
}
if
(
signArr
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数组装签名参数信息为空"
);
}
var
resultSignStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
app_secret
;
var
resultTmpSign
=
md5
(
resultSignStr
).
toUpperCase
();
if
(
params
.
sign
!=
resultTmpSign
)
{
return
system
.
getResult
(
null
,
"返回值签名验证失败"
);
}
return
system
.
getResultSuccess
();
}
async
createSign
(
params
,
app_key
)
{
if
(
!
params
)
{
return
system
.
getResultFail
(
-
310
,
"请求参数为空"
);
}
var
signArr
=
[];
var
keys
=
Object
.
keys
(
params
).
sort
();
if
(
keys
.
length
==
0
)
{
return
system
.
getResultFail
(
-
330
,
"请求参数信息为空"
);
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
params
[
tKey
]
&&
!
(
params
[
tKey
]
instanceof
Array
))
{
signArr
.
push
(
tKey
+
"="
+
params
[
tKey
]);
}
}
if
(
signArr
.
length
==
0
)
{
return
system
.
getResultFail
(
-
350
,
"请求参数组装签名参数信息为空"
);
}
var
resultSignStr
=
signArr
.
join
(
"&"
)
+
"&key="
+
app_key
;
var
resultTmpSign
=
md5
(
resultSignStr
).
toUpperCase
();
return
system
.
getResultSuccess
(
resultTmpSign
);
}
}
module
.
exports
=
SignService
;
// var task = new SignService();
// var obj = {
// "intentionBizId": "zhuangbingceshi008",
// "phone": "13075556693",
// "userName": "庄冰",
// "description": "1111111111111222",
// "area": "1",
// "consultType": 5
// };
// task.createSign(obj,"7cbb892450174167b5c7e01we4716t51").then(d=>{
// console.log(d,"!!!!!!!!!!!!!!!!!!!!!!!!!!");
// });
center-channel/app/config/businessConfig.js
View file @
f4abece9
...
@@ -19,6 +19,6 @@ module.exports = {
...
@@ -19,6 +19,6 @@ module.exports = {
"putUserPwdByMobile"
,
"icpNotifyNew"
"putUserPwdByMobile"
,
"icpNotifyNew"
],
],
apiMustUserpinList
:
[
"submitNeed"
,
"paySuccess"
,
"icpNotify"
,
"getLoginInfo"
,
"icpNotifyNew"
],
apiMustUserpinList
:
[
"submitNeed"
,
"paySuccess"
,
"icpNotify"
,
"getLoginInfo"
,
"icpNotifyNew"
],
apiSecretPathList
:
[
"/
baidu/icp
"
]
apiSecretPathList
:
[
"/
api/icp/consultation/submit"
,
"/api/icp/feedback/submit"
,
"/api/icp/order/notify
"
]
}
}
}
}
center-channel/app/config/routes/api.js
View file @
f4abece9
...
@@ -3,6 +3,7 @@ const utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
...
@@ -3,6 +3,7 @@ const utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
logCtl
=
system
.
getObject
(
"service.common.oplogSve"
);
const
utilsOrderSve
=
system
.
getObject
(
"service.utilsSve.utilsOrderSve"
);
const
utilsOrderSve
=
system
.
getObject
(
"service.utilsSve.utilsOrderSve"
);
const
utilsFeishuSve
=
system
.
getObject
(
"service.utilsSve.utilsFeishuSve"
);
const
utilsFeishuSve
=
system
.
getObject
(
"service.utilsSve.utilsFeishuSve"
);
const
signSve
=
system
.
getObject
(
"service.common.signSve"
);
const
xml2js
=
require
(
'xml2js'
);
const
xml2js
=
require
(
'xml2js'
);
const
jwt
=
require
(
'jsonwebtoken'
);
const
jwt
=
require
(
'jsonwebtoken'
);
const
{
PDICT
}
=
require
(
"../../config/businessConfig"
);
const
{
PDICT
}
=
require
(
"../../config/businessConfig"
);
...
@@ -405,9 +406,36 @@ module.exports = function (app) {
...
@@ -405,9 +406,36 @@ module.exports = function (app) {
}
}
if
(
PDICT
.
apiSecretPathList
.
indexOf
(
req
.
originalUrl
)
>=
0
)
{
if
(
PDICT
.
apiSecretPathList
.
indexOf
(
req
.
originalUrl
)
>=
0
)
{
//TODO:验证数据签名
//TODO:验证数据签名
var
appkey
=
req
.
headers
[
"appkey"
]
||
""
;
if
(
!
appkey
)
{
result
.
msg
=
"req headers appkey can not be empty"
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
//1.通过appkey 获取appInfo
var
appRes
=
await
signSve
.
getAppInfoByAppKey
(
appkey
);
if
(
!
appRes
||
appRes
.
status
!=
0
){
result
.
msg
=
"获取应用信息失败"
;
result
.
data
=
null
;
res
.
end
(
JSON
.
stringify
(
result
));
return
;
}
var
appInfo
=
appRes
.
data
;
//2.通过appsecret 验签
var
signParams
=
req
.
body
;
var
verifyRes
=
await
signSve
.
verifySign
(
req
.
body
,
appInfo
.
uapp_secret
);
if
(
verifyRes
&&
verifyRes
.
status
==
0
){
req
.
body
.
appInfo
=
appInfo
;
req
.
appInfo
=
appInfo
;
req
.
actionProcess
=
appInfo
.
app_code
;
next
();
next
();
return
;
return
;
}
else
{
res
.
end
(
JSON
.
stringify
(
verifyRes
));
return
;
}
}
}
if
([
"getAppTokenByHosts"
,
"getAppTokenByAppKey"
,
"getTmNclFilterSearch"
].
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
if
([
"getAppTokenByHosts"
,
"getAppTokenByAppKey"
,
"getTmNclFilterSearch"
].
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
req
.
body
.
actionBody
.
appHosts
=
req
.
host
;
req
.
body
.
actionBody
.
appHosts
=
req
.
host
;
...
...
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