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
6eaadd66
Commit
6eaadd66
authored
Nov 03, 2020
by
兰国旗
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'center-channel' of gitlab.gongsibao.com:jiangyong/zhichan into center-channel
parents
5a85d25b
62db1d74
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
7 deletions
+147
-7
center-channel/app/base/api/api.base.js
+6
-5
center-channel/app/base/service/impl/utilsSve/utilsOrderSve.js
+61
-2
center-channel/app/base/utils/baiduClient.js
+66
-0
center-channel/app/base/utils/execClient.js
+14
-0
No files found.
center-channel/app/base/api/api.base.js
View file @
6eaadd66
...
@@ -53,17 +53,18 @@ class APIBase {
...
@@ -53,17 +53,18 @@ class APIBase {
await
this
.
redisClient
.
setWithEx
(
shaStr
,
JSON
.
stringify
(
result
),
3600
);
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
};
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
;
return
result
;
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"api调用出现异常,请联系管理员.........."
);
const
stackStr
=
e
.
stack
?
e
.
stack
:
JSON
.
stringify
(
e
);
console
.
log
(
stackStr
,
"api调用出现异常,请联系管理员.........."
);
this
.
logCtl
.
createDb
({
this
.
logCtl
.
createDb
({
appid
:
req
.
app
.
id
,
appid
:
req
.
app
.
id
,
appkey
:
req
.
app
.
uappKey
,
appkey
:
req
.
app
.
uappKey
,
requestId
:
req
.
requestId
,
requestId
:
req
.
requestId
,
op
:
req
.
classname
+
"/"
+
methodname
,
op
:
req
.
classname
+
"/"
+
methodname
,
content
:
JSON
.
stringify
(
pobj
),
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
e
.
stack
)
,
resultInfo
:
stackStr
,
clientIp
:
req
.
clientIp
,
clientIp
:
req
.
clientIp
,
agent
:
req
.
uagent
,
agent
:
req
.
uagent
,
opTitle
:
"api调用出现异常,请联系管理员error,appKey:"
+
settings
.
appKey
,
opTitle
:
"api调用出现异常,请联系管理员error,appKey:"
+
settings
.
appKey
,
...
@@ -78,8 +79,8 @@ class APIBase {
...
@@ -78,8 +79,8 @@ class APIBase {
// agent: req.uagent,
// agent: req.uagent,
// optitle: "api调用出现异常,请联系管理员",
// optitle: "api调用出现异常,请联系管理员",
// });
// });
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"
,
null
,
stackStr
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
stackStr
);
rtnerror
.
requestId
=
req
.
requestId
;
rtnerror
.
requestId
=
req
.
requestId
;
return
rtnerror
;
return
rtnerror
;
}
}
...
...
center-channel/app/base/service/impl/utilsSve/utilsOrderSve.js
View file @
6eaadd66
...
@@ -51,10 +51,14 @@ class UtilsOrderService extends AppServiceBase {
...
@@ -51,10 +51,14 @@ class UtilsOrderService extends AppServiceBase {
// if (buyTotalSum < totalSum) {
// if (buyTotalSum < totalSum) {
// return system.getResult(null, "订单金额有误,100060");
// return system.getResult(null, "订单金额有误,100060");
// }
// }
let
tmpPriceList
=
[];
pobj
.
actionBody
.
product_info
.
price_item
=
price_list
[
productIndex
];
pobj
.
actionBody
.
product_info
.
price_item
=
price_list
[
productIndex
];
tmpPriceList
.
push
(
pobj
.
actionBody
.
product_info
.
price_item
);
if
(
additionsIndex
>=
0
)
{
if
(
additionsIndex
>=
0
)
{
pobj
.
actionBody
.
product_info
.
price_additions_item
=
price_list
[
additionsIndex
];
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
();
return
system
.
getResultSuccess
();
}
}
/**
/**
...
@@ -945,15 +949,19 @@ class UtilsOrderService extends AppServiceBase {
...
@@ -945,15 +949,19 @@ class UtilsOrderService extends AppServiceBase {
opOrderResult
.
data
.
order_info
.
pay_time
=
params
.
payTime
;
//付款时间
opOrderResult
.
data
.
order_info
.
pay_time
=
params
.
payTime
;
//付款时间
opOrderResult
.
data
.
order_info
.
pay_payer_bank_no
=
params
.
buyer_email
||
""
;
//付款账号
opOrderResult
.
data
.
order_info
.
pay_payer_bank_no
=
params
.
buyer_email
||
""
;
//付款账号
opOrderResult
.
data
.
order_contact
=
opOrderResult
.
data
.
delivery_content
.
orderContact
;
opOrderResult
.
data
.
order_contact
=
opOrderResult
.
data
.
delivery_content
.
orderContact
;
var
pobj
=
{
var
pobj
=
{
appInfo
:
opOrderResult
.
data
.
appInfo
,
appInfo
:
opOrderResult
.
data
.
appInfo
,
actionBody
:
opOrderResult
.
data
actionBody
:
opOrderResult
.
data
}
}
// 推送
// 推送
this
.
utilsPushSve
.
pushBusInfo
(
pobj
,
"pushOrder"
,
0
);
this
.
utilsPushSve
.
pushBusInfo
(
pobj
,
"pushOrder"
,
0
);
if
([
'icpsq'
,
'edisq'
].
includes
(
opOrderResult
.
data
.
product_info
.
channel_item_code
))
{
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"
);
this
.
utilsPushSve
.
aliBusiness2Delivery
(
pobj
,
"pushDeliveryOrder"
);
}
}
opOrderResult
.
data
=
null
;
opOrderResult
.
data
=
null
;
...
@@ -970,6 +978,57 @@ class UtilsOrderService extends AppServiceBase {
...
@@ -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
)
{
//渠道订单支付通知
async
channelOrdersPayNotify
(
params
,
client_ip
)
{
//渠道订单支付通知
try
{
try
{
...
...
center-channel/app/base/utils/baiduClient.js
View file @
6eaadd66
const
co
=
require
(
"co"
);
const
co
=
require
(
"co"
);
var
request
=
require
(
"request"
);
var
request
=
require
(
"request"
);
const
crypto
=
require
(
'crypto'
);
const
sha256
=
require
(
'sha256'
);
const
sha256
=
require
(
'sha256'
);
var
urlencode
=
require
(
'urlencode'
);
var
urlencode
=
require
(
'urlencode'
);
const
system
=
require
(
"../system"
);
const
system
=
require
(
"../system"
);
class
baiduClient
{
class
baiduClient
{
constructor
()
{
constructor
()
{
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
}
}
//2020 1027 laolan 调用百度网关
//2020 1027 laolan 调用百度网关
...
@@ -101,5 +103,69 @@ class baiduClient {
...
@@ -101,5 +103,69 @@ class baiduClient {
return
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
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
;
module
.
exports
=
baiduClient
;
center-channel/app/base/utils/execClient.js
View file @
6eaadd66
...
@@ -12,6 +12,8 @@ class ExecClient {
...
@@ -12,6 +12,8 @@ class ExecClient {
this
.
cmdFeishuPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}"
;
this
.
cmdFeishuPostPattern
=
"curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}"
;
//360
//360
this
.
cmd360PostPattern
=
"curl -u gongsibao:qPa4PsVsxbQ847i5pOKSmfPKrzRoNKqx -d '{data}' -X POST {url}"
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
()
{
getUUID
()
{
var
uuid
=
uuidv4
();
var
uuid
=
uuidv4
();
...
@@ -44,6 +46,13 @@ class ExecClient {
...
@@ -44,6 +46,13 @@ class ExecClient {
console
.
log
(
cmd
);
console
.
log
(
cmd
);
return
cmd
;
return
cmd
;
}
}
FetchBaiduPostCmd
(
subData
,
url
)
{
var
data
=
JSON
.
stringify
(
subData
);
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
)
{
FetchPushDataPostCmd
(
subData
,
url
,
token
,
requestId
)
{
var
requestId
=
requestId
||
this
.
getUUID
();
var
requestId
=
requestId
||
this
.
getUUID
();
var
data
=
JSON
.
stringify
(
subData
);
var
data
=
JSON
.
stringify
(
subData
);
...
@@ -62,6 +71,11 @@ class ExecClient {
...
@@ -62,6 +71,11 @@ class ExecClient {
var
result
=
await
this
.
exec
(
cmd
);
var
result
=
await
this
.
exec
(
cmd
);
return
result
;
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
)
{
async
execPushDataPost
(
subData
,
url
,
token
,
requestId
)
{
let
cmd
=
this
.
FetchPushDataPostCmd
(
subData
,
url
,
token
,
requestId
);
let
cmd
=
this
.
FetchPushDataPostCmd
(
subData
,
url
,
token
,
requestId
);
var
options
=
{
var
options
=
{
...
...
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