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
8ad7e8fa
Commit
8ad7e8fa
authored
Nov 17, 2021
by
任晓松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 优化
parent
5f04641f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
134 deletions
+92
-134
center-channel/app/base/api/impl/icp/order.js
+1
-1
center-channel/app/base/service/impl/utilsSve/utils360Sve.js
+28
-75
center-channel/app/base/service/impl/utilsSve/utilsDeliverSystemSve.js
+33
-33
center-channel/app/base/utils/baiduClient.js
+30
-25
No files found.
center-channel/app/base/api/impl/icp/order.js
View file @
8ad7e8fa
...
...
@@ -183,7 +183,7 @@ class Order extends APIBase {
requestUrl
:
"/icp/order/notify"
,
requestjson
:
JSON
.
stringify
(
pobj
),
//请求地址
pushUrl
:
"/action/intentionapi/springBoard"
,
//调用地址
pushActionType
:
"icp
NotifyNew
"
,
//调用参数
pushActionType
:
"icp
OrderStatus
"
,
//调用参数
pushtimes
:
0
,
//推送次数
pushStatus
:
"wts"
,
//推送状态
}
...
...
center-channel/app/base/service/impl/utilsSve/utils360Sve.js
View file @
8ad7e8fa
...
...
@@ -77,37 +77,13 @@ class utils360Sve extends AppServiceBase {
}
let
result
=
await
this
.
restPostUrl
(
pushObj
,
url
);
if
(
result
.
code
==
200
)
{
this
.
pushlogSve
.
createDb
({
op
:
"360-pushOrderStatus"
,
content
:
JSON
.
stringify
(
pushObj
),
//推送的参数信息
resultInfo
:
JSON
.
stringify
(
result
),
returnType
:
'1'
,
logLevel
:
1
,
opTitle
:
"推送360信息返回成功"
});
this
.
disposePushResult
(
pobj
,
result
,
"utils360Sve---pushOrderStatus--推送成功"
,
4
);
}
else
{
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"utilsSve/utils360Sve/pushOrderStatus"
,
content
:
"error:"
+
result
.
msg
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常status->pushOrderStatus"
,
});
this
.
disposePushResultFail
(
pobj
,
result
,
"utils360Sve---pushOrderStatus--推送失败"
,
4
);
}
console
.
log
(
result
,
'-------------push360-----------------'
)
return
result
;
}
catch
(
e
)
{
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"utilsSve/utils360Sve/pushOrderStatus"
,
content
:
"error:"
+
e
.
stack
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常status->pushOrderStatus"
,
});
this
.
disposePushResultFail
(
pobj
,
e
.
stack
,
"utils360Sve---pushOrderStatus"
,
4
);
}
}
...
...
@@ -132,63 +108,40 @@ class utils360Sve extends AppServiceBase {
}
let
params
=
actionBody
.
itemCode
.
join
(
','
);
let
url
=
settings
.
requestUrl360
()
+
`api/v1/eshop/GetGoodsLowestPrice?sku_ids=
${
params
}
`
;
let
rtn
=
await
this
.
restClient
.
execGet
(
""
,
url
);
let
rtn
=
await
this
.
restClient
.
execGet
(
""
,
url
);
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restGet data is empty"
);
}
let
result
=
JSON
.
parse
(
rtn
.
stdout
);
if
(
result
.
code
!=
200
)
{
return
system
.
getResultFail
(
-
1
,
result
.
msg
)
if
(
result
.
code
!=
200
)
{
return
system
.
getResultFail
(
-
1
,
result
.
msg
)
}
return
system
.
getResultSuccess
(
result
.
data
);
}
async
pushTmOrderStatus
(
pobj
){
let
token
=
await
this
.
utilsAuthSve
.
get360Token
();
let
url
=
settings
.
pushUrl360
()
+
'api/v1/eshop/GsbOrderUpdate?token='
+
token
.
access_token
;
let
order_id
=
pobj
.
orderNo
;
let
sub_status
=
pobj
.
sub_status
;
let
status
=
pobj
.
status
;
let
pushObj
=
{
order_id
,
status
,
sub_status
:
sub_status
}
let
result
=
await
this
.
restPostUrl
(
pushObj
,
url
);
if
(
result
.
code
==
200
)
{
this
.
pushlogSve
.
createDb
({
op
:
"360-pushTMOrderStatus"
,
content
:
JSON
.
stringify
(
pushObj
),
//推送的参数信息
resultInfo
:
JSON
.
stringify
(
result
),
returnType
:
'1'
,
logLevel
:
1
,
opTitle
:
"推送360信息返回成功"
});
}
else
{
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"utilsSve/utils360Sve/pushTMOrderStatus"
,
content
:
"error:"
+
result
.
msg
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常status->pushTMOrderStatus"
,
});
async
pushTmOrderStatus
(
pobj
)
{
try
{
let
token
=
await
this
.
utilsAuthSve
.
get360Token
();
let
url
=
settings
.
pushUrl360
()
+
'api/v1/eshop/GsbOrderUpdate?token='
+
token
.
access_token
;
let
order_id
=
pobj
.
orderNo
;
let
sub_status
=
pobj
.
sub_status
;
let
status
=
pobj
.
status
;
let
pushObj
=
{
order_id
,
status
,
sub_status
:
sub_status
}
let
result
=
await
this
.
restPostUrl
(
pushObj
,
url
);
if
(
result
.
code
==
200
)
{
this
.
disposePushResult
(
pobj
,
result
,
"utils360Sve---pushTmOrderStatus--推送成功"
,
4
)
}
else
{
this
.
disposePushResultFail
(
pobj
,
result
,
"utils360Sve---pushTmOrderStatus--推送失败"
,
4
);
}
return
result
;
}
catch
(
e
)
{
this
.
disposePushResultFail
(
pobj
,
e
.
stack
,
"utils360Sve---pushTmOrderStatus--推送失败"
,
4
);
}
console
.
log
(
result
,
'-------------push360-----------------'
)
return
result
;
}
catch
(
e
)
{
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"utilsSve/utils360Sve/pushTMOrderStatus"
,
content
:
"error:"
+
e
.
stack
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常status->pushOrderStatus"
,
});
}
}
}
module
.
exports
=
utils360Sve
;
center-channel/app/base/service/impl/utilsSve/utilsDeliverSystemSve.js
View file @
8ad7e8fa
...
...
@@ -11,34 +11,33 @@ class UtilsDeliverSystemService extends AppServiceBase {
/**
* 推送业务信息到交付系统
* 业务操作的信息不变外加增加组装的一些参数(推送需求商机、关闭需求、订单商机、关闭订单)
* @param {*} pobj
* @param {*} pobj
*/
async
pushBusiness2DeliverSystem
(
pobj
)
{
//推送业务信息到交付系统
console
.
log
(
pobj
,
"pushBusiness2DeliverSystem-zhuangbing------------------------------"
);
var
verifyResult
=
await
this
.
verifyParam
(
pobj
);
if
(
verifyResult
.
status
!=
0
)
{
return
await
this
.
disposePushResultFail
(
pobj
,
verifyResult
,
"deliver->pushBusiness2DeliverSystem->verifyResult"
,
this
.
pushlogFailType
.
FQ
);
}
var
interface_params_info
=
verifyResult
.
data
;
if
(
interface_params_info
.
headData
){
if
(
pobj
&&
pobj
.
appInfo
&&
pobj
.
appInfo
.
app_code
){
interface_params_info
.
headData
.
appcode
=
pobj
.
appInfo
.
app_code
;
}
}
var
reqParams
=
{
actionType
:
"produceData"
,
// Y 功能名称
actionBody
:
{
pushUrl
:
interface_params_info
.
pushUrl
,
// Y 推送地址
actionType
:
interface_params_info
.
actionType
,
// Y 推送地址接收时的功能名称
notifyUrl
:
interface_params_info
.
notifyUrl
||
""
,
// N 推送成功后通知的Url
identifyCode
:
interface_params_info
.
identifyCode
,
// Y 操作的业务标识
messageBody
:
pobj
.
actionBody
,
// Y 推送的业务消息,必须有一项对象属性值
headData
:
interface_params_info
.
headData
//N 请求头信息,Json格式,如:{token:"XXXXXXX"}
},
requestId
:
pobj
.
requestId
||
""
// N 请求id
// var reqParams = {
// actionType: "produceData",// Y 功能名称
// actionBody: {
// pushUrl: interface_params_info.pushUrl,// Y 推送地址
// actionType: interface_params_info.actionType,// Y 推送地址接收时的功能名称
// notifyUrl: interface_params_info.notifyUrl || "",// N 推送成功后通知的Url
// identifyCode: interface_params_info.identifyCode,// Y 操作的业务标识
// messageBody: pobj.actionBody, // Y 推送的业务消息,必须有一项对象属性值
// headData: interface_params_info.headData //N 请求头信息,Json格式,如:{token:"XXXXXXX"}
// },
// requestId: pobj.requestId || "" // N 请求id
// }
let
parms
=
{
actionType
:
interface_params_info
.
actionType
,
actionBody
:
pobj
.
actionBody
}
var
opQueuePushClientPostRes
=
await
this
.
opQueuePushClientPost
(
pobj
,
this
.
opPushQueueUrl
,
reqParams
);
console
.
log
(
opQueuePushClientPostRes
,
"pushBusiness2DeliverSystem-zhuangbing----2--------------------------"
);
let
url
=
interface_params_info
.
opUrl
;
var
opQueuePushClientPostRes
=
await
this
.
opQueuePushClientPost
(
pobj
,
url
,
parms
);
return
await
this
.
disposePushResult
(
pobj
,
opQueuePushClientPostRes
,
"delivery->pushBusiness2DeliverSystem->result"
,
this
.
pushlogFailType
.
FQ
);
}
//--------------------------------------------------内部辅助方法-------------------start-----------------
...
...
@@ -47,21 +46,22 @@ class UtilsDeliverSystemService extends AppServiceBase {
try
{
var
rtn
=
await
this
.
restPostUrl
(
reqParams
,
pushQueueUrl
);
if
(
rtn
.
status
!=
1
)
{
this
.
execClientNew
.
execLogs
(
`推送
队列接收数据
失败->opQueuePushClientPost`
,
pobj
,
"center-channel-utilsDeliverSystemSve-opQueuePushClientPost"
,
rtn
,
JSON
.
stringify
(
rtn
));
return
system
.
getResult
(
null
,
"推送
队列接收数据
失败,失败原因:"
+
JSON
.
stringify
(
rtn
));
this
.
execClientNew
.
execLogs
(
`推送
资质宝
失败->opQueuePushClientPost`
,
pobj
,
"center-channel-utilsDeliverSystemSve-opQueuePushClientPost"
,
rtn
,
JSON
.
stringify
(
rtn
));
return
system
.
getResult
(
null
,
"推送
资质宝
失败,失败原因:"
+
JSON
.
stringify
(
rtn
));
}
return
system
.
getResultSuccess
(
null
,
"推送成功"
);
}
catch
(
e
)
{
//日志记录
this
.
logCtl
.
error
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"utilsSve/utilsDeliverSystemSve/opQueuePushClientPost"
,
content
:
"error:"
+
e
.
stack
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常deliver->opQueuePushClientPost"
,
});
// this.logCtl.error({
// appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
// appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
// requestId: pobj.requestId || "",
// op: "utilsSve/utilsDeliverSystemSve/opQueuePushClientPost",
// content: "error:" + e.stack,
// // clientIp: pobj.clientIp,
// optitle: pobj.opType + "推送操作异常deliver->opQueuePushClientPost",
// });
this
.
execClientNew
.
execLogs
(
`推送资质宝失败->opQueuePushClientPost`
,
pobj
,
"center-channel-utilsDeliverSystemSve-opQueuePushClientPost"
,
null
,
JSON
.
stringify
(
e
.
stack
));
return
system
.
getResult
(
null
,
"推送操作异常deliver->opQueuePushClientPost->error:"
+
e
.
stack
);
}
}
...
...
@@ -71,8 +71,8 @@ class UtilsDeliverSystemService extends AppServiceBase {
verify
=
system
.
getResult
(
null
,
"interface_params can not be empty,100400"
);
}
var
interface_params_info
=
JSON
.
parse
(
pobj
.
interface_params
);
if
(
!
interface_params_info
||
!
interface_params_info
.
push
Url
||
!
interface_params_info
.
headData
)
{
verify
=
system
.
getResult
(
null
,
"interface_params(
push
Url、headData) can not be empty,100430"
);
if
(
!
interface_params_info
||
!
interface_params_info
.
op
Url
||
!
interface_params_info
.
headData
)
{
verify
=
system
.
getResult
(
null
,
"interface_params(
op
Url、headData) can not be empty,100430"
);
}
verify
.
data
=
interface_params_info
;
return
verify
;
...
...
center-channel/app/base/utils/baiduClient.js
View file @
8ad7e8fa
...
...
@@ -2,8 +2,10 @@ const crypto = require('crypto');
const
sha256
=
require
(
'sha256'
);
const
system
=
require
(
"../system"
);
var
settings
=
require
(
"../../config/settings"
);
class
baiduClient
{
const
AppServiceBase
=
require
(
"../service/app.base"
);
class
baiduClient
extends
AppServiceBase
{
constructor
()
{
super
();
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
baiduClientParams
=
settings
.
baiduClientParams
();
...
...
@@ -50,11 +52,9 @@ class baiduClient {
data
:
actionBody
}
var
rtn
=
await
this
.
execClient
.
execBaiduPost
(
baiduObj
,
url
);
console
.
log
(
"baiduObj+++++"
,
baiduObj
)
console
.
log
(
"url+++++"
,
url
)
console
.
log
(
"rtn+++++"
,
rtn
)
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"execPost data is empty"
);
this
.
execClientNew
.
execLogs
(
`baiduClient-opBaiduClientPost-result:url=
${
url
}
`
,
actionBody
,
"center-channel-opBaiduClientPost"
,
null
,
rtn
);
return
system
.
getResult
(
null
,
rtn
);
}
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
...
...
@@ -74,28 +74,33 @@ class baiduClient {
host
:
this
.
baiduClientParams
.
host
},
// set the http request headers
});
console
.
log
(
'baidu++++res+++'
,
res
)
this
.
pushlogSve
.
createDb
({
op
:
"new-baiduReqbyget"
,
content
:
JSON
.
stringify
(
obj
),
//推送的参数信息
resultInfo
:
JSON
.
stringify
(
res
),
returnType
:
'1'
,
logLevel
:
'1'
,
opTitle
:
"new-baiduReqbyget推送百度信息返回成功"
});
if
(
res
.
status
==
0
){
await
this
.
disposePushResult
(
obj
,
res
,
"baidu->pushBusiness2Baidu->result"
,
""
);
}
else
{
await
this
.
disposePushResultFail
(
obj
,
res
,
"badiu->pushBusiness2Baidu->catchError"
,
this
.
pushlogFailType
.
FAILLOG
);
}
// this.pushlogSve.createDb({
// op: "new-baiduReqbyget",
// content: JSON.stringify(obj),//推送的参数信息
// resultInfo: JSON.stringify(res),
// returnType: '1',
// logLevel: '1',
// opTitle: "new-baiduReqbyget推送百度信息返回成功"
// });
return
system
.
getResultSuccess
(
res
);
}
catch
(
e
)
{
this
.
pushlogSve
.
createFailLogDb
({
appid
:
obj
.
appInfo
?
obj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
obj
.
appInfo
?
obj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
obj
.
requestId
||
""
,
content
:
JSON
.
stringify
(
obj
),
//推送的参数信息
resultInfo
:
"error:"
+
JSON
.
stringify
(
e
),
clientIp
:
obj
.
clientIp
||
""
,
failType
:
1
,
opTitle
:
"new-baiduReqbyget推送百度信息返回异常"
,
pushNumber
:
obj
.
pushNumber
||
1
});
await
this
.
disposePushResultFail
(
obj
,
e
,
"badiu->pushBusiness2Baidu->catchError"
,
this
.
pushlogFailType
.
FAILLOG
);
// this.pushlogSve.createFailLogDb({
// appid: obj.appInfo ? obj.appInfo.uapp_id || "" : "",
// appkey: obj.appInfo ? obj.appInfo.uapp_key || "" : "",
// requestId: obj.requestId || "",
// content: JSON.stringify(obj),//推送的参数信息
// resultInfo: "error:" + JSON.stringify(e),
// clientIp: obj.clientIp || "",
// failType: 1,
// opTitle: "new-baiduReqbyget推送百度信息返回异常",
// pushNumber: obj.pushNumber || 1
// });
return
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
}
}
...
...
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