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
1a708ae3
Commit
1a708ae3
authored
Nov 05, 2020
by
linboxuan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'center-channel' of
http://gitlab.gongsibao.com/jiangyong/zhichan
into center-channel
parents
9f4a44e2
91fd7d14
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
325 additions
and
110 deletions
+325
-110
center-channel/app/base/api/api.base.js
+6
-5
center-channel/app/base/api/impl/opreceive/need2.js
+1
-1
center-channel/app/base/service/impl/common/baseCenterOrderSve.js
+47
-22
center-channel/app/base/service/impl/common/centerorderSve.js
+29
-2
center-channel/app/base/service/impl/common/qcCenterOrderSve.js
+3
-1
center-channel/app/base/service/impl/utilsSve/utilsFqAliyunSve.js
+1
-1
center-channel/app/base/service/impl/utilsSve/utilsNeedSve2.js
+10
-5
center-channel/app/base/service/impl/utilsSve/utilsOrderSve.js
+61
-2
center-channel/app/base/service/impl/utilsSve/utilsPushSve.js
+14
-6
center-channel/app/base/utils/baiduClient.js
+120
-46
center-channel/app/base/utils/execClient.js
+14
-0
center-channel/app/base/utils/execClientNew.js
+19
-19
No files found.
center-channel/app/base/api/api.base.js
View file @
1a708ae3
...
...
@@ -53,17 +53,18 @@ class APIBase {
await
this
.
redisClient
.
setWithEx
(
shaStr
,
JSON
.
stringify
(
result
),
3600
);
}
var
tmpResult
=
pobj
.
actionType
&&
pobj
.
actionType
.
indexOf
(
"List"
)
<
0
?
result
:
{
status
:
result
.
status
,
message
:
result
.
message
,
requestId
:
result
.
requestId
};
this
.
execClientNew
.
execLogs
(
"reqPath:"
+
req
.
path
,
pobj
,
"center-channel-doexecMethod"
,
tmpResult
,
null
);
this
.
execClientNew
.
execLogs
(
"
center-channel-doexecMethod-
reqPath:"
+
req
.
path
,
pobj
,
"center-channel-doexecMethod"
,
tmpResult
,
null
);
return
result
;
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"api调用出现异常,请联系管理员.........."
);
const
stackStr
=
e
.
stack
?
e
.
stack
:
JSON
.
stringify
(
e
);
console
.
log
(
stackStr
,
"api调用出现异常,请联系管理员.........."
);
this
.
logCtl
.
createDb
({
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
req
.
requestId
,
op
:
req
.
classname
+
"/"
+
methodname
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
e
.
stack
)
,
resultInfo
:
stackStr
,
clientIp
:
req
.
clientIp
,
agent
:
req
.
uagent
,
opTitle
:
"api调用出现异常,请联系管理员error,appKey:"
+
settings
.
appKey
,
...
...
@@ -78,8 +79,8 @@ class APIBase {
// agent: req.uagent,
// optitle: "api调用出现异常,请联系管理员",
// });
this
.
execClientNew
.
execLogs
(
"
reqPath异常:"
+
req
.
path
,
pobj
,
"center-channel-doexecMethod"
,
tmpResult
,
null
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
this
.
execClientNew
.
execLogs
(
"
center-channel-doexecMethod-reqPath异常:"
+
req
.
path
,
pobj
,
"center-channel-doexecMethod"
,
null
,
stackStr
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
stackStr
);
rtnerror
.
requestId
=
req
.
requestId
;
return
rtnerror
;
}
...
...
center-channel/app/base/api/impl/opreceive/need2.js
View file @
1a708ae3
...
...
@@ -81,7 +81,7 @@ class Need2 extends APIBase {
opResult
=
await
this
.
utilsNeedSve
.
submitIcpIntention
(
pobj
,
pobj
.
actionBody
);
break
;
case
"queryIntentionList"
:
// 2020 0827 lin 新增 4.2 需求列表查询
opResult
=
await
this
.
utilsNeedSve
.
queryIntentionList
(
pobj
,
pobj
.
actionBody
);
opResult
=
await
this
.
utilsNeedSve
2
.
queryIntentionList
(
pobj
,
pobj
.
actionBody
);
break
;
case
"confirmIcpIntention"
:
// 2020 0827 lin 新增 4.3 用户需求确认
opResult
=
await
this
.
utilsNeedSve
.
confirmIcpIntention
(
pobj
,
pobj
.
actionBody
);
...
...
center-channel/app/base/service/impl/common/baseCenterOrderSve.js
View file @
1a708ae3
...
...
@@ -17,6 +17,42 @@ const uappId = {
'ali'
:
"18"
,
//(阿里icp、edi)
'baidu'
:
"44"
//(百度icp、edi)
}
const
city
=
{
"1"
:
"北京"
,
"2"
:
"上海"
,
"3"
:
"福建"
,
"4"
:
"广西"
,
"5"
:
"广东"
,
"6"
:
"安徽"
,
"7"
:
"河南"
,
"8"
:
"湖北"
,
"9"
:
"浙江"
,
"10"
:
"江苏"
,
"11"
:
"山东"
,
"12"
:
"陕西"
,
"13"
:
"宁夏"
,
"14"
:
"甘肃"
,
"15"
:
"新疆"
,
"16"
:
"青海"
,
"17"
:
"天津"
,
"18"
:
"重庆"
,
"19"
:
"河北"
,
"20"
:
"山西"
,
"21"
:
"辽宁"
,
"22"
:
"吉林"
,
"23"
:
"黑龙江"
,
"24"
:
"江西"
,
"25"
:
"湖南"
,
"26"
:
"四川"
,
"27"
:
"贵州"
,
"28"
:
"云南"
,
"29"
:
"内蒙古"
,
"30"
:
"西藏"
,
"31"
:
"含外资"
,
"32"
:
"全外资"
,
"33"
:
"香港"
,
"34"
:
"海南"
}
/**
* 资质信息提报相关接口(ICP\EDI)
*/
...
...
@@ -96,6 +132,7 @@ class BaseCenterOrderService extends AppServiceBase {
if
(
needsolution
.
channelSolutionNo
)
{
pushObj
[
"bizId"
]
=
needsolution
.
channelSolutionNo
;
}
console
.
log
(
'pushObj++'
,
pushObj
)
var
pushIcpSolutionRes
=
await
this
.
pushBaiduIcpSolution
(
pushObj
,
needsolution
.
solutionNo
,
pobj
.
appInfo
,
self
);
}
...
...
@@ -176,6 +213,7 @@ class BaseCenterOrderService extends AppServiceBase {
//推送ICP方案baidu 2020-10-26 laolan
async
pushBaiduIcpSolution
(
pushObj
,
solutionNo
,
appInfo
,
self
)
{
console
.
log
(
'pushObj++baidu+++'
,
pushObj
)
//推送方案信息
var
pushRes
=
await
self
.
baiduclient
.
baiduReqbyget
({
path
:
"/api/bla/provider/plan"
,
reqbody
:
pushObj
});
console
.
log
(
"pushRes++++"
,
pushRes
)
...
...
@@ -191,7 +229,7 @@ class BaseCenterOrderService extends AppServiceBase {
}
};
var
a
=
await
self
.
reqCenterOrderApi
(
reqObj2
);
//保存渠道方案id
return
pushRes
;
return
system
.
getResultSuccess
()
;
}
}
}
...
...
@@ -205,25 +243,12 @@ class BaseCenterOrderService extends AppServiceBase {
if
(
typeof
(
ab
.
material
)
==
"string"
)
{
ab
.
material
=
JSON
.
parse
(
ab
.
material
);
}
var
uappIds
=
res
.
data
.
uapp_id
;
if
(
uappIds
==
uappId
.
ali
){
//推送数据至阿里
var
pushObj
=
{
BizId
:
ab
.
BizId
,
Note
:
ab
.
Note
};
//关闭方案
this
.
aliclient
.
reqbyget
({
action
:
"CloseIcpProduce"
,
reqbody
:
pushObj
,
apiVersion
:
"2019-05-08"
});
}
if
(
uappIds
==
uappId
.
baidu
){
//推送数据至baidu
var
pushObj
=
{
bizId
:
ab
.
BizId
,
note
:
ab
.
Note
};
//关闭方案
this
.
baiduclient
.
baiduReqbyget
({
action
:
"closeIcpProduce"
,
reqbody
:
pushObj
});
}
//推送数据至阿里
var
pushObj
=
{
BizId
:
ab
.
BizId
,
Note
:
ab
.
Note
};
//关闭方案
this
.
aliclient
.
reqbyget
({
action
:
"CloseIcpProduce"
,
reqbody
:
pushObj
,
apiVersion
:
"2019-05-08"
});
return
system
.
getResultSuccess
();
}
return
res
;
...
...
@@ -284,7 +309,7 @@ class BaseCenterOrderService extends AppServiceBase {
};
var
self
=
this
;
//推送方案材料
var
r
=
self
.
baiduclient
.
baiduReqbyget
({
action
:
"savePartnerSubmitM
aterial"
,
reqbody
:
pushObj
});
var
r
=
self
.
baiduclient
.
baiduReqbyget
({
path
:
"/api/bla/provider/license/m
aterial"
,
reqbody
:
pushObj
});
console
.
log
(
"r++"
,
res
)
}
return
system
.
getResultSuccess
();
...
...
@@ -314,7 +339,7 @@ class BaseCenterOrderService extends AppServiceBase {
applicationStatus
:
res
.
data
.
ApplicationStatus
};
//推送状态变更
this
.
baiduclient
.
baiduReqbyget
({
action
:
"acceptPartnerNotification
"
,
reqbody
:
pushObj
});
this
.
baiduclient
.
baiduReqbyget
({
path
:
"/api/bla/provider/requirement/update
"
,
reqbody
:
pushObj
});
}
return
system
.
getResultSuccess
();
}
...
...
center-channel/app/base/service/impl/common/centerorderSve.js
View file @
1a708ae3
...
...
@@ -614,6 +614,7 @@ class CenterorderService extends AppServiceBase {
},
appInfo
:
pobj
.
appInfo
}
var
baiduPushRes
=
await
this
.
utilsPushSve
.
baiduBusiness2Fq
(
fqobj
,
"pushOrderICPBusinessNew"
);
var
deliveryObj
=
{
actionBody
:
{
orderNo
:
orderrtn
.
data
.
orderNo
,
//pobj.actionBody.channelOrder.channelOrderNo,
...
...
@@ -627,9 +628,35 @@ class CenterorderService extends AppServiceBase {
}
},
appInfo
:
pobj
.
appInfo
};
if
(
pobj
.
actionBody
.
isDirectBuy
&&
pobj
.
actionBody
.
isDirectBuy
==
1
){
//直接下单需执行添加订单业务员操作
if
(
baiduPushRes
&&
baiduPushRes
.
status
==
0
){
if
(
baiduPushRes
.
data
&&
baiduPushRes
.
data
.
data
){
var
resData
=
baiduPushRes
.
data
.
data
;
var
salesmanInfo
=
{
salesmanName
:
resData
.
orderList
&&
resData
.
orderList
.
length
>
0
?
resData
.
orderList
[
0
].
operatorName
:
""
,
salesmanChannelId
:
resData
.
orderList
&&
resData
.
orderList
.
length
>
0
?
resData
.
orderList
[
0
].
operator
:
""
,
};
var
salesmanObj
=
{
appInfo
:
pobj
.
appInfo
,
actionType
:
"addIcpSalesmanInfo"
,
//添加业务员信息
actionBody
:{
salesmanInfo
:
salesmanInfo
,
orderNo
:
orderrtn
.
data
.
orderNo
}
};
var
url
=
settings
.
centerOrderUrl
()
+
"action/qcapi/springBoard"
;
var
addRes
=
await
this
.
execClient
.
execPost
(
salesmanObj
,
url
);
if
(
addRes
&&
addRes
.
stdout
)
{
var
salesmanRes
=
JSON
.
parse
(
addRes
.
stdout
);
if
(
salesmanRes
.
status
==
0
)
{
deliveryObj
.
needsolution
=
salesmanRes
.
data
;
await
this
.
utilsPushSve
.
baiduBusiness2Delivery
(
deliveryObj
,
"pushDeliveryOrder"
);
}
}
}
}
}
else
{
this
.
utilsPushSve
.
baiduBusiness2Delivery
(
deliveryObj
,
"pushDeliveryOrder"
);
}
this
.
utilsPushSve
.
baiduBusiness2Fq
(
fqobj
,
"pushOrderICPBusinessNew"
);
this
.
utilsPushSve
.
baiduBusiness2Delivery
(
deliveryObj
,
"pushDeliveryOrder"
);
return
system
.
getResultSuccess
();
}
}
...
...
center-channel/app/base/service/impl/common/qcCenterOrderSve.js
View file @
1a708ae3
...
...
@@ -196,7 +196,9 @@ class QcCenterOrderService extends AppServiceBase {
};
var
self
=
this
;
//推送方案材料
self
.
aliclient
.
reqbyget
({
action
:
"SavePartnerSubmitMaterial"
,
reqbody
:
pushObj
,
apiVersion
:
"2019-05-08"
});
if
(
pobj
.
appInfo
.
uapp_id
==
18
){
self
.
aliclient
.
reqbyget
({
action
:
"SavePartnerSubmitMaterial"
,
reqbody
:
pushObj
,
apiVersion
:
"2019-05-08"
});
}
return
system
.
getResultSuccess
();
}
return
res
;
...
...
center-channel/app/base/service/impl/utilsSve/utilsFqAliyunSve.js
View file @
1a708ae3
...
...
@@ -87,7 +87,7 @@ class UtilsFqAliyunService extends AppServiceBase {
if
(
rtn
.
code
!=
200
&&
rtn
.
success
!=
true
)
{
return
system
.
getResult
(
null
,
"推送失败,失败原因:"
+
rtn
.
errorMsg
+
",selfrequestId="
+
pobj
.
requestId
+
",requestId="
+
rtn
.
requestId
);
}
return
system
.
getResultSuccess
(
null
,
"推送成功"
);
return
system
.
getResultSuccess
(
rtn
.
data
,
"推送成功"
);
}
catch
(
e
)
{
//日志记录
this
.
logCtl
.
error
({
...
...
center-channel/app/base/service/impl/utilsSve/utilsNeedSve2.js
View file @
1a708ae3
...
...
@@ -501,11 +501,11 @@ class UtilsNeedService2 extends AppServiceBase {
//2020-10-28 laolan start
if
(
result
&&
result
.
status
==
0
&&
result
.
data
&&
result
.
data
.
uappIds
){
if
(
result
.
data
.
uappIds
==
uappId
.
ali
){
var
res
=
await
self
.
aliclient
.
reqbyget
({
action
:
"
W
riteCommunicationLog"
,
reqbody
:
{
BizId
:
pobj
.
actionBody
.
intentionBizId
,
Note
:
pobj
.
actionBody
.
note
},
apiVersion
:
"2019-05-08"
});
var
res
=
await
self
.
aliclient
.
reqbyget
({
action
:
"
w
riteCommunicationLog"
,
reqbody
:
{
BizId
:
pobj
.
actionBody
.
intentionBizId
,
Note
:
pobj
.
actionBody
.
note
},
apiVersion
:
"2019-05-08"
});
console
.
log
(
"ali+res"
,
res
)
}
if
(
result
.
data
.
uappIds
==
uappId
.
baidu
){
var
ress
=
await
self
.
baiduclient
.
baiduReqbyget
({
action
:
"writeCommunicationLog
"
,
reqbody
:
{
bizId
:
pobj
.
actionBody
.
intentionBizId
,
note
:
pobj
.
actionBody
.
note
}
});
var
ress
=
await
self
.
baiduclient
.
baiduReqbyget
({
path
:
"/api/bla/provider/communication
"
,
reqbody
:
{
bizId
:
pobj
.
actionBody
.
intentionBizId
,
note
:
pobj
.
actionBody
.
note
}
});
console
.
log
(
"baidu+res"
,
ress
)
}
}
...
...
@@ -559,7 +559,7 @@ class UtilsNeedService2 extends AppServiceBase {
if
(
result
.
data
.
uapp_id
==
uappId
.
baidu
){
var
res
=
await
this
.
baiduclient
.
baiduReqbyget
({
action
:
"queryExpertApplyCommunicationLogs
"
,
reqbody
:
{
path
:
"/api/bla/providerommunication/list
"
,
reqbody
:
{
beginTime
:
pobj
.
actionBody
.
BeginTime
?
pobj
.
actionBody
.
BeginTime
:
""
,
endTime
:
pobj
.
actionBody
.
EndTime
?
pobj
.
actionBody
.
EndTime
:
""
,
bizId
:
pobj
.
actionBody
.
intentionBizId
,
...
...
@@ -620,8 +620,13 @@ class UtilsNeedService2 extends AppServiceBase {
* @param {*} actionBody
*/
async
queryIntentionList
(
pobj
,
actionBody
)
{
var
aliResult
=
await
self
.
aliclient
.
reqbyget
({
action
:
"QueryIntentionList"
,
reqbody
:
actionBody
,
apiVersion
:
"2019-05-08"
});
if
(
aliResult
.
code
==
200
)
{
if
(
pobj
.
appInfo
.
uapp_id
=
uappId
.
ali
){
var
result
=
await
self
.
aliclient
.
reqbyget
({
action
:
"QueryIntentionList"
,
reqbody
:
actionBody
,
apiVersion
:
"2019-05-08"
});
}
if
(
pobj
.
appInfo
.
uapp_id
=
uappId
.
baidu
){
var
result
=
await
self
.
baiduclient
.
baiduReqbyget
({
path
:
"api/bla/provider/requirement/list"
,
reqbody
:
actionBody
});
}
if
(
result
.
code
==
200
)
{
return
system
.
getResultSuccess
();
}
else
{
return
system
.
getResult
(
null
,
"查询失败 10420"
);
...
...
center-channel/app/base/service/impl/utilsSve/utilsOrderSve.js
View file @
1a708ae3
...
...
@@ -51,10 +51,14 @@ class UtilsOrderService extends AppServiceBase {
// if (buyTotalSum < totalSum) {
// return system.getResult(null, "订单金额有误,100060");
// }
let
tmpPriceList
=
[];
pobj
.
actionBody
.
product_info
.
price_item
=
price_list
[
productIndex
];
tmpPriceList
.
push
(
pobj
.
actionBody
.
product_info
.
price_item
);
if
(
additionsIndex
>=
0
)
{
pobj
.
actionBody
.
product_info
.
price_additions_item
=
price_list
[
additionsIndex
];
tmpPriceList
.
push
(
pobj
.
actionBody
.
product_info
.
price_additions_item
);
}
pobj
.
actionBody
.
product_info
.
price_list
=
tmpPriceList
;
return
system
.
getResultSuccess
();
}
/**
...
...
@@ -945,15 +949,19 @@ class UtilsOrderService extends AppServiceBase {
opOrderResult
.
data
.
order_info
.
pay_time
=
params
.
payTime
;
//付款时间
opOrderResult
.
data
.
order_info
.
pay_payer_bank_no
=
params
.
buyer_email
||
""
;
//付款账号
opOrderResult
.
data
.
order_contact
=
opOrderResult
.
data
.
delivery_content
.
orderContact
;
var
pobj
=
{
appInfo
:
opOrderResult
.
data
.
appInfo
,
actionBody
:
opOrderResult
.
data
}
// 推送
this
.
utilsPushSve
.
pushBusInfo
(
pobj
,
"pushOrder"
,
0
);
if
([
'icpsq'
,
'edisq'
].
includes
(
opOrderResult
.
data
.
product_info
.
channel_item_code
))
{
//创建方案
let
pushRet
=
await
this
.
packagingPushData
(
pobj
);
if
(
pushRet
.
status
!=
0
)
{
throw
new
Error
(
'推送失败'
)
}
pobj
.
actionBody
=
pushRet
.
data
;
this
.
utilsPushSve
.
aliBusiness2Delivery
(
pobj
,
"pushDeliveryOrder"
);
}
opOrderResult
.
data
=
null
;
...
...
@@ -970,6 +978,57 @@ class UtilsOrderService extends AppServiceBase {
}
}
//组装推送交付系统数据
async
packagingPushData
(
pobj
)
{
let
ab
=
pobj
.
actionBody
;
pobj
.
actionType
=
'createSolution'
;
ab
.
bizId
=
ab
.
orderNo
;
let
channelSolutionNo
=
await
this
.
getBusUid
(
"NS"
);
ab
.
channelSolutionNo
=
channelSolutionNo
;
let
url
=
this
.
centerOrderUrl
+
"action/need/springBoard"
let
solutionRet
=
await
this
.
restPostUrl
(
pobj
,
url
);
if
(
solutionRet
.
status
!=
0
)
{
return
system
.
getResultFail
(
-
1
,
'创建方案失败'
)
}
let
solution
=
{
"source"
:
ab
.
appInfo
.
app_name
,
"IcpType"
:
ab
.
product_info
.
channel_item_code
,
"actionType"
:
"新办"
,
"CompanyName"
:
""
,
"licenseType"
:
""
,
"solutionCity"
:
ab
.
product_info
.
price_item
.
price_desc
,
"solutionPrice"
:
ab
.
order_info
.
totalSum
,
"channelTypeCode"
:
ab
.
product_info
.
service_business_code
,
"companyLocation"
:
ab
.
product_info
.
price_item
.
price_desc
}
let
needSolution
=
{
"status"
:
"USER_PAY_PRODUCE"
,
"bizType"
:
ab
.
product_info
.
channel_item_code
,
"solution"
:
solution
,
"totalSum"
:
ab
.
order_info
.
totalSum
,
"typeCode"
:
ab
.
product_info
.
channel_item_code
,
"typeName"
:
ab
.
product_info
.
channel_item_name
,
"statusName"
:
"⽤户⽀付"
,
"customerInfo"
:
{
"publishName"
:
""
,
"publishMobile"
:
""
}
}
//推送数据
let
pushObj
=
{
"orderNo"
:
ab
.
orderNo
,
"needsolution"
:
needSolution
,
"channelNeedNo"
:
""
,
"channelSolutionNo"
:
channelSolutionNo
,
"skuCode"
:
ab
.
product_info
.
price_item
.
payCode
,
"servicer"
:
{
"code"
:
"gsb"
,
"name"
:
"公司宝"
}
};
return
system
.
getResultSuccess
(
pushObj
);
}
async
channelOrdersPayNotify
(
params
,
client_ip
)
{
//渠道订单支付通知
try
{
...
...
center-channel/app/base/service/impl/utilsSve/utilsPushSve.js
View file @
1a708ae3
...
...
@@ -63,10 +63,17 @@ class UtilsPushService extends AppServiceBase {
return
system
.
getResult
(
null
,
"暂无【"
+
opType
+
"】的推送配置"
);
}
var
self
=
this
;
for
(
let
index
=
0
;
index
<
interface_list_temp
.
length
;
index
++
)
{
const
element
=
interface_list_temp
[
index
];
await
self
.
reflexAction
(
element
,
opType
,
pobj
,
isDelProductInfo
);
if
(
interface_list_temp
&&
interface_list_temp
.
length
==
1
){
const
element
=
interface_list_temp
[
0
];
var
reflexActionRes
=
await
self
.
reflexAction
(
element
,
opType
,
pobj
,
isDelProductInfo
);
return
reflexActionRes
;
}
else
{
for
(
let
index
=
0
;
index
<
interface_list_temp
.
length
;
index
++
)
{
const
element
=
interface_list_temp
[
index
];
await
self
.
reflexAction
(
element
,
opType
,
pobj
,
isDelProductInfo
);
}
}
}
async
againPushBusInfo
(
pobj
)
{
//再次推送业务总入口-重试
...
...
@@ -97,7 +104,8 @@ class UtilsPushService extends AppServiceBase {
}
pobj
.
interface_params
=
interface_info
.
params
;
var
params
=
[
pobj
];
invokeObj
[
interface_info
.
method_name
].
apply
(
invokeObj
,
params
);
var
doRes
=
await
invokeObj
[
interface_info
.
method_name
].
apply
(
invokeObj
,
params
);
return
doRes
;
}
else
if
(
interface_info
.
interface_type
==
"yc"
)
{
var
actionBody
=
pobj
.
actionBody
;
...
...
@@ -142,8 +150,8 @@ class UtilsPushService extends AppServiceBase {
optitle
:
pobj
.
opType
+
"推送蜂擎获取的接口信息->baiduBusiness2Fq"
,
});
if
(
pobj
.
interface_info
)
{
await
this
.
pushBusInfo
(
pobj
,
opType
,
1
);
return
system
.
getResultSuccess
();
var
pushBusInfo
=
await
this
.
pushBusInfo
(
pobj
,
opType
,
1
);
return
system
.
getResultSuccess
(
pushBusInfo
);
}
return
system
.
getResult
(
null
,
"push Fail,interface_info data is empty"
);
}
...
...
center-channel/app/base/utils/baiduClient.js
View file @
1a708ae3
const
co
=
require
(
"co"
);
var
request
=
require
(
"request"
);
const
crypto
=
require
(
'crypto'
);
const
sha256
=
require
(
'sha256'
);
var
urlencode
=
require
(
'urlencode'
);
const
system
=
require
(
"../system"
);
class
baiduClient
{
constructor
()
{
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
}
//2020 1027 laolan 调用百度网关
async
baiduPost
(
path
,
actionBody
)
{
console
.
log
(
'actionBody++'
,
actionBody
)
let
domain
=
"https://gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
;
let
authorization
=
"bce-auth-v1"
;
let
accessKey
=
"ff2571490b4c4fb5add57385dc5e8f66"
;
let
secretKey
=
"9d86f04a85db4cdfa95ba8ad28009188"
;
let
timestamp
=
new
Date
().
toISOString
();
let
url
=
domain
+
path
;
let
version
=
"bce-auth-v1"
;
let
accessKey
=
"ed0f5c4c7c2d4e87aa335d9b07bf9bd4"
;
let
secretKey
=
"f600c4e91f6d43998d637401e6e34ef9"
;
let
timestamp
=
new
Date
().
toISOString
()
let
site
=
timestamp
.
lastIndexOf
(
"."
);
timestamp
=
timestamp
.
substring
(
0
,
site
)
+
"Z"
// let timestamp = "2020-11-05T04:00:00Z"
console
.
log
(
'timestamp++'
,
timestamp
)
let
signedHeaders
=
"host"
;
let
extime
=
1800
;
var
signArr
=
[];
var
keys
=
Object
.
keys
(
actionBody
).
sort
();
if
(
keys
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数信息为空"
);
// 因为是post,所以CanonicalQueryString为空
// var signArr = [];
// var keys = Object.keys(actionBody).sort();
// if (keys.length == 0) {
// return system.getResult(null, "请求参数信息为空");
// }
// for (let k = 0; k < keys.length; k++) {
// const tKey = keys[k];
// if (tKey != "sign" && actionBody[tKey] && !(typeof (actionBody[tKey]) === "object")) {
// signArr.push(urlencode(tKey) + "=" + urlencode(actionBody[tKey]));
// }
// }
// let resultSignStr = signArr.join("&");
// console.log('resultSignStr+++',resultSignStr)
let
canonicalHeaders
=
"host:gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
//中间结果1:规范化请求和前缀字符串
let
canonicalRequest
=
"POST"
+
"
\
n"
+
path
+
"
\
n"
+
"
\
n"
+
canonicalHeaders
;
console
.
log
(
'canonicalRequest+++'
,
canonicalRequest
)
//authStringPrefix(前缀字符串,由除sk字段外的签名信息生成)
let
authStringPrefix
=
version
+
"/"
+
accessKey
+
"/"
+
timestamp
+
"/"
+
extime
;
console
.
log
(
'authStringPrefix+++'
,
authStringPrefix
)
//中间结果2:派生签名密钥 signingKey
let
signingKey
=
crypto
.
createHmac
(
'sha256'
,
secretKey
)
.
update
(
authStringPrefix
)
.
digest
(
'hex'
);
console
.
log
(
'signingKey+++'
,
signingKey
)
//中间结果3:签名摘要 signature
let
signature
=
crypto
.
createHmac
(
'sha256'
,
signingKey
)
.
update
(
canonicalRequest
)
.
digest
(
'hex'
);
console
.
log
(
'signature+++'
,
signature
)
//最终结果:认证字符串 authorization
let
authorization
=
authStringPrefix
+
"/"
+
signedHeaders
+
"/"
+
signature
;
console
.
log
(
'authorization+++'
,
authorization
)
var
baiduObj
=
{
authorization
:
authorization
,
data
:
actionBody
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
actionBody
[
tKey
]
&&
!
(
typeof
(
actionBody
[
tKey
])
===
"object"
))
{
signArr
.
push
(
urlencode
(
tKey
)
+
"="
+
urlencode
(
actionBody
[
tKey
]));
}
var
rtn
=
await
this
.
execClient
.
execBaiduPost
(
baiduObj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
let
resultSignStr
=
signArr
.
join
(
"&"
);
console
.
log
(
'resultSignStr+++'
,
resultSignStr
)
// SigningKey = HMAC-SHA256-HEX(sk, authStringPrefix)
// authStringPrefix代表认证字符串的前缀部分,即:bce-auth-v1/{accessKeyId}/{timestamp}/{expirationPeriodInSeconds}。
// CanonicalRequest = HTTP Method + "\n" + CanonicalURI + "\n" + CanonicalQueryString + "\n" + CanonicalHeaders
// signature = HMAC-SHA256-HEX(SigningKey,CanonicalRequest)
let
authStringPrefix
=
authorization
+
"/"
+
accessKey
+
"/"
+
timestamp
+
"/"
+
extime
;
let
signingKey
=
await
sha256
(
secretKey
,
authStringPrefix
);
let
newResultSignStr
=
resultSignStr
.
replace
(
/&/g
,
','
)
let
canonicalQueryString
=
path
+
','
+
newResultSignStr
;
console
.
log
(
'canonicalQueryString+++'
,
canonicalQueryString
)
let
canonicalHeaders
=
{
host
:
urlencode
(
domain
)
}
let
canonicalRequest
=
"POST"
+
"
\
n"
+
path
+
"
\
n"
+
canonicalQueryString
+
"
\
n"
+
canonicalHeaders
+
"
\
n"
;
let
signature
=
await
sha256
(
signingKey
,
canonicalRequest
);
path
=
domain
+
path
;
console
.
log
(
'path+++'
,
path
)
var
param
=
{
data
:
actionBody
,
timeout
:
20000
,
headers
:
{
Authorization
:
authStringPrefix
+
"/"
+
"x-bce-date/"
+
signature
,
accept
:
'application/json'
}
};
console
.
log
(
'param+++'
,
param
,
"______________峰擎---百度云参数_______"
);
var
result
=
await
request
.
post
(
path
,
param
);
console
.
log
(
'result+++'
,
JSON
.
stringify
(
result
),
"______________峰擎---百度云返回结果_______"
);
console
.
log
(
'result-------'
,
result
);
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
}
...
...
@@ -74,7 +82,9 @@ class baiduClient {
formatAction
:
true
,
// default true, format the action to Action
formatParams
:
true
,
// default true, format the parameter name to first letter upper case
method
:
'POST'
,
// set the http method, default is GET
headers
:
{},
// set the http request headers
headers
:
{
host
:
"gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
},
// set the http request headers
});
console
.
log
(
'baidu++++res+++'
,
res
)
this
.
pushlogSve
.
createDb
({
...
...
@@ -101,5 +111,69 @@ class baiduClient {
return
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
}
}
async
test
(){
var
obj
=
{
path
:
"/api/bla/provider/plan"
,
reqbody
:{
"area"
:
"北京"
,
"companyName"
:
"demoData"
,
"companyAddress"
:
"demoData"
,
"requirementId"
:
"TRE-nmnHtEoTjeE"
,
"type"
:
"ICP"
}
};
var
actionBody
=
obj
.
reqbody
;
var
path
=
obj
.
path
;
let
domain
=
"https://gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
;
let
url
=
domain
+
path
;
let
version
=
"bce-auth-v1"
;
let
accessKey
=
"ed0f5c4c7c2d4e87aa335d9b07bf9bd4"
;
let
secretKey
=
"f600c4e91f6d43998d637401e6e34ef9"
;
let
timestamp
=
new
Date
().
toISOString
();
let
signedHeaders
=
"host"
;
let
extime
=
1800
;
var
signArr
=
[];
var
keys
=
Object
.
keys
(
actionBody
).
sort
();
if
(
keys
.
length
==
0
)
{
return
system
.
getResult
(
null
,
"请求参数信息为空"
);
}
for
(
let
k
=
0
;
k
<
keys
.
length
;
k
++
)
{
const
tKey
=
keys
[
k
];
if
(
tKey
!=
"sign"
&&
actionBody
[
tKey
]
&&
!
(
typeof
(
actionBody
[
tKey
])
===
"object"
))
{
signArr
.
push
(
urlencode
(
tKey
)
+
"="
+
urlencode
(
actionBody
[
tKey
]));
}
}
let
resultSignStr
=
signArr
.
join
(
"&"
);
console
.
log
(
'resultSignStr+++'
,
resultSignStr
)
let
canonicalHeaders
=
"host:gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
//中间结果1:规范化请求和前缀字符串
let
canonicalRequest
=
"POST"
+
"
\
n"
+
path
+
"
\
n"
+
resultSignStr
+
"
\
n"
+
canonicalHeaders
;
//authStringPrefix(前缀字符串,由除sk字段外的签名信息生成)
let
authStringPrefix
=
version
+
"/"
+
accessKey
+
"/"
+
timestamp
+
"/"
+
extime
;
//中间结果2:派生签名密钥 signingKey
let
signingKey
=
crypto
.
createHmac
(
'sha256'
,
secretKey
)
.
update
(
authStringPrefix
)
.
digest
(
'hex'
);
//中间结果3:签名摘要 signature
let
signature
=
crypto
.
createHmac
(
'sha256'
,
signingKey
)
.
update
(
canonicalRequest
)
.
digest
(
'hex'
);
//最终结果:认证字符串 authorization
let
authorization
=
authStringPrefix
+
"/"
+
signedHeaders
+
"/"
+
signature
;
var
baiduObj
=
{
authorization
:
authorization
,
data
:
actionBody
}
var
rtn
=
await
this
.
execClient
.
execBaiduPost
(
baiduObj
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
!
result
||
!
result
.
result
){
return
system
.
getResultFail
(
"推送失败"
);
}
return
system
.
getResultSuccess
();
}
}
module
.
exports
=
baiduClient
;
center-channel/app/base/utils/execClient.js
View file @
1a708ae3
...
...
@@ -12,6 +12,8 @@ class ExecClient {
this
.
cmdFeishuPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}"
;
//360
this
.
cmd360PostPattern
=
"curl -u gongsibao:qPa4PsVsxbQ847i5pOKSmfPKrzRoNKqx -d '{data}' -X POST {url}"
this
.
cmdBaiduPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}"
;
}
getUUID
()
{
var
uuid
=
uuidv4
();
...
...
@@ -44,6 +46,13 @@ class ExecClient {
console
.
log
(
cmd
);
return
cmd
;
}
FetchBaiduPostCmd
(
subData
,
url
)
{
var
data
=
JSON
.
stringify
(
subData
.
data
);
var
cmd
=
this
.
cmdBaiduPostPattern
.
replace
(
/
\{
data
\}
/g
,
data
).
replace
(
/
\{
url
\}
/g
,
url
).
replace
(
/
\{
Authorization
\}
/g
,
subData
.
authorization
);
console
.
log
(
cmd
);
return
cmd
;
}
FetchPushDataPostCmd
(
subData
,
url
,
token
,
requestId
)
{
var
requestId
=
requestId
||
this
.
getUUID
();
var
data
=
JSON
.
stringify
(
subData
);
...
...
@@ -62,6 +71,11 @@ class ExecClient {
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
async
execBaiduPost
(
subData
,
url
)
{
let
cmd
=
this
.
FetchBaiduPostCmd
(
subData
,
url
);
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
}
async
execPushDataPost
(
subData
,
url
,
token
,
requestId
)
{
let
cmd
=
this
.
FetchPushDataPostCmd
(
subData
,
url
,
token
,
requestId
);
var
options
=
{
...
...
center-channel/app/base/utils/execClientNew.js
View file @
1a708ae3
...
...
@@ -207,25 +207,25 @@ class ExecClientNew {
if
(
!
ContentType
)
{
ContentType
=
"application/json"
;
}
var
data
=
null
;
if
(
typeof
params
===
'object'
)
{
// 声明cache变量,便于匹配是否有循环引用的情况
var
cache
=
[];
data
=
JSON
.
stringify
(
params
,
function
(
key
,
value
)
{
if
(
typeof
value
===
'object'
&&
value
!==
null
)
{
if
(
cache
.
indexOf
(
value
)
!==
-
1
)
{
// 移除
return
;
}
// 收集所有的值
cache
.
push
(
value
);
}
return
value
;
});
cache
=
null
;
// 清空变量,便于垃圾回收机制回收
}
else
{
data
=
params
;
}
var
data
=
JSON
.
stringify
(
params
)
;
//
if (typeof params === 'object') {
//
// 声明cache变量,便于匹配是否有循环引用的情况
//
var cache = [];
//
data = JSON.stringify(params, function (key, value) {
//
if (typeof value === 'object' && value !== null) {
//
if (cache.indexOf(value) !== -1) {
//
// 移除
//
return;
//
}
//
// 收集所有的值
//
cache.push(value);
//
}
//
return value;
//
});
//
cache = null; // 清空变量,便于垃圾回收机制回收
//
} else {
//
data = params;
//
}
var
cmdStr
=
"curl --user admines:adminGSBes. -k -H 'Content-type:"
+
ContentType
+
"'"
;
if
(
headData
)
{
var
headDataKeys
=
Object
.
keys
(
headData
);
...
...
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