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
97d6a397
Commit
97d6a397
authored
Nov 06, 2020
by
任晓松
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
3375ccf7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
68 deletions
+58
-68
center-order/app/base/service/app.base.js
+14
-0
center-order/app/base/service/impl/common/push360Sve.js
+44
-68
No files found.
center-order/app/base/service/app.base.js
View file @
97d6a397
...
@@ -4,6 +4,7 @@ const settings = require("../../config/settings");
...
@@ -4,6 +4,7 @@ const settings = require("../../config/settings");
const
md5
=
require
(
"MD5"
);
const
md5
=
require
(
"MD5"
);
class
AppServiceBase
{
class
AppServiceBase
{
constructor
()
{
constructor
()
{
this
.
execClientNew
=
system
.
getObject
(
"util.execClientNew"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
restClient
=
system
.
getObject
(
"util.restClient"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
this
.
cacheManager
=
system
.
getObject
(
"db.common.cacheManager"
);
...
@@ -57,5 +58,18 @@ class AppServiceBase {
...
@@ -57,5 +58,18 @@ class AppServiceBase {
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
var
result
=
JSON
.
parse
(
rtn
.
stdout
);
return
result
;
return
result
;
}
}
/**
* 带超时时间的post请求
* @param {*} req 请求信息
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间
*/
async
execPostByTimeOut
(
req
,
params
,
url
,
ContentType
,
headData
,
timeOut
=
60
)
{
const
result
=
await
this
.
execClientNew
.
execPostTimeOutByBusiness
(
'sve.base'
,
params
,
url
,
ContentType
,
headData
,
timeOut
,
req
);
return
result
;
}
}
}
module
.
exports
=
AppServiceBase
;
module
.
exports
=
AppServiceBase
;
center-order/app/base/service/impl/common/push360Sve.js
View file @
97d6a397
const
system
=
require
(
"../../../system"
);
const
system
=
require
(
"../../../system"
);
const
ServiceBase
=
require
(
"../../sve
.base"
);
const
AppBase
=
require
(
"../../app
.base"
);
var
settings
=
require
(
"../../../../config/settings"
);
var
settings
=
require
(
"../../../../config/settings"
);
class
Push360Service
{
class
Push360Service
extends
AppBase
{
constructor
()
{
constructor
()
{
this
.
pushlogDao
=
system
.
getObject
(
"db.common.pushlogDao"
);
super
()
this
.
ordercontactsDao
=
system
.
getObject
(
"db.dbcorder.ordercontactsDao"
);
this
.
ordercontactsDao
=
system
.
getObject
(
"db.dbcorder.ordercontactsDao"
);
this
.
orderinfoDao
=
system
.
getObject
(
"db.dbcorder.orderinfoDao"
);
this
.
orderinfoDao
=
system
.
getObject
(
"db.dbcorder.orderinfoDao"
);
this
.
push360Url
=
settings
.
push360Url
();
this
.
push360Url
=
settings
.
push360Url
();
...
@@ -18,50 +18,35 @@ class Push360Service {
...
@@ -18,50 +18,35 @@ class Push360Service {
status
=
40
;
status
=
40
;
}
}
let
order_id
=
actionBody
.
orderNo
;
let
order_id
=
actionBody
.
orderNo
;
var
result
,
pushObj
,
url
;
try
{
try
{
var
rc
=
system
.
getObject
(
"util.execClient"
);
let
rtn
=
await
this
.
execClient
.
exec360GetToken
(
this
.
auth360Url
)
let
rtn
=
await
rc
.
exec360GetToken
(
this
.
auth360Url
)
if
(
!
rtn
||
!
rtn
.
stdout
)
{
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPost data is empty"
);
return
system
.
getResult
(
null
,
"restPost data is empty"
);
}
}
let
tokenResult
=
JSON
.
parse
(
rtn
.
stdout
);
let
tokenResult
=
JSON
.
parse
(
rtn
.
stdout
);
let
token
=
tokenResult
.
access_token
;
let
token
=
tokenResult
.
access_token
;
let
url
=
this
.
push360Url
+
'/api/v1/eshop/GsbOrderUpdate?token='
+
token
;
url
=
this
.
push360Url
+
'/api/v1/eshop/GsbOrderUpdate?token='
+
token
;
let
pushObj
=
{
pushObj
=
{
order_id
:
order_id
,
order_id
:
order_id
,
status
:
status
status
:
status
}
}
let
result
=
await
rc
.
execPost
(
pushObj
,
url
);
result
=
await
this
.
execPostByTimeOut
(
pushObj
,
url
);
var
logObj
=
{
if
(
result
.
status
!=
0
)
{
appid
:
""
,
return
result
;
appkey
:
""
,
op
:
url
,
content
:
JSON
.
stringify
(
actionBody
),
resultInfo
:
result
?
JSON
.
stringify
(
result
)
:
""
};
if
(
!
result
||
!
result
.
stdout
)
{
logObj
[
"returnType"
]
=
"0"
;
logObj
[
"opTitle"
]
=
"数据推送360返回失败"
;
this
.
pushlogDao
.
create
(
logObj
);
return
system
.
getResultFail
(
-
502
,
"execPost data is empty"
);
}
else
{
logObj
[
"returnType"
]
=
"1"
;
logObj
[
"opTitle"
]
=
"数据推送360返回成功"
;
this
.
pushlogDao
.
create
(
logObj
);
let
stdout
=
JSON
.
parse
(
result
.
stdout
);
return
system
.
getResultSuccess
(
stdout
);
}
}
if
(
result
.
data
.
status
!=
0
)
{
return
result
.
data
;
}
return
system
.
getResultSuccess
(
result
.
data
.
data
);
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
pushlogDao
.
create
({
this
.
execClientNew
.
execLogs
({
appid
:
""
,
opTitle
:
"360订单状态推送"
,
appkey
:
""
,
params
:
actionBody
.
orderNo
,
logLevel
:
"3"
,
identifyCode
:
"360TmStatus"
,
op
:
this
.
push360Url
,
resultInfo
:
""
,
content
:
JSON
.
stringify
(
actionBody
),
errorInfo
:
e
.
stack
resultInfo
:
JSON
.
stringify
(
e
.
stack
),
})
returnType
:
"0"
,
opTitle
:
"数据推送360---异常"
});
return
system
.
getResultFail
(
-
500
,
JSON
.
stringify
(
e
.
stack
));
return
system
.
getResultFail
(
-
500
,
JSON
.
stringify
(
e
.
stack
));
}
}
}
}
...
@@ -70,6 +55,12 @@ class Push360Service {
...
@@ -70,6 +55,12 @@ class Push360Service {
async
sendMessage
(
actionBody
)
{
async
sendMessage
(
actionBody
)
{
try
{
try
{
let
orderNo
=
actionBody
.
orderNo
;
let
orderNo
=
actionBody
.
orderNo
;
if
(
!
actionBody
.
registNumInfo
){
return
system
.
getResultFail
(
-
1
,
''
)
}
if
(
!
actionBody
.
officialInfo
){
return
system
.
getResultFail
(
-
1
,
''
)
}
//获取联系人信息
//获取联系人信息
let
item
=
await
this
.
ordercontactsDao
.
getItemByOrderNo
(
actionBody
.
orderNo
);
let
item
=
await
this
.
ordercontactsDao
.
getItemByOrderNo
(
actionBody
.
orderNo
);
let
deliveryInfo
=
actionBody
.
deliveryInfo
;
let
deliveryInfo
=
actionBody
.
deliveryInfo
;
...
@@ -95,8 +86,7 @@ class Push360Service {
...
@@ -95,8 +86,7 @@ class Push360Service {
// templateId = 2;
// templateId = 2;
// }
// }
var
rc
=
system
.
getObject
(
"util.execClient"
);
let
rtn
=
await
this
.
execClient
.
exec360GetToken
(
this
.
auth360Url
)
let
rtn
=
await
rc
.
exec360GetToken
(
this
.
auth360Url
)
if
(
!
rtn
||
!
rtn
.
stdout
)
{
if
(
!
rtn
||
!
rtn
.
stdout
)
{
return
system
.
getResult
(
null
,
"restPost data is empty"
);
return
system
.
getResult
(
null
,
"restPost data is empty"
);
}
}
...
@@ -105,37 +95,23 @@ class Push360Service {
...
@@ -105,37 +95,23 @@ class Push360Service {
let
url
=
this
.
push360Url
+
'/api/v1/GsbSendsms'
;
let
url
=
this
.
push360Url
+
'/api/v1/GsbSendsms'
;
let
params
=
tmName
+
"|"
+
oneNcl
+
"|"
+
tmRegistNum
+
"|"
+
uploadFileName
;
let
params
=
tmName
+
"|"
+
oneNcl
+
"|"
+
tmRegistNum
+
"|"
+
uploadFileName
;
let
subData
=
"token="
+
token
+
"&mobile="
+
mobile
+
"&templated="
+
templateId
+
"&replaceContent="
+
params
;
let
subData
=
"token="
+
token
+
"&mobile="
+
mobile
+
"&templated="
+
templateId
+
"&replaceContent="
+
params
;
let
result
=
await
rc
.
execGet
(
subData
,
url
);
let
result
=
await
this
.
execClient
.
execGet
(
subData
,
url
);
var
logObj
=
{
this
.
execClientNew
.
execLogs
({
appid
:
""
,
opTitle
:
"360短信推送"
,
appkey
:
""
,
params
:
params
,
op
:
url
,
identifyCode
:
"360Message"
,
content
:
JSON
.
stringify
(
actionBody
),
resultInfo
:
result
.
data
,
resultInfo
:
result
?
JSON
.
stringify
(
result
)
:
""
errorInfo
:
""
};
})
if
(
!
result
||
!
result
.
stdout
)
{
return
system
.
getResultSuccess
()
logObj
[
"returnType"
]
=
"0"
;
logObj
[
"opTitle"
]
=
"数据推送360返回失败"
;
this
.
pushlogDao
.
create
(
logObj
);
return
system
.
getResultFail
(
-
502
,
"execPost data is empty"
);
}
else
{
logObj
[
"returnType"
]
=
"1"
;
logObj
[
"opTitle"
]
=
"数据推送360返回成功"
;
this
.
pushlogDao
.
create
(
logObj
);
let
stdout
=
JSON
.
parse
(
result
.
stdout
);
return
system
.
getResultSuccess
(
stdout
);
}
}
catch
(
e
)
{
}
catch
(
e
)
{
this
.
pushlogDao
.
create
({
this
.
execClientNew
.
execLogs
({
appid
:
""
,
opTitle
:
"360短信推送"
,
appkey
:
""
,
params
:
actionBody
.
orderNo
,
logLevel
:
"3"
,
identifyCode
:
"360Message"
,
op
:
this
.
push360Url
,
resultInfo
:
""
,
content
:
JSON
.
stringify
(
actionBody
),
errorInfo
:
e
.
stack
resultInfo
:
JSON
.
stringify
(
e
.
stack
),
})
returnType
:
"0"
,
opTitle
:
"数据推送360短信---异常"
});
return
system
.
getResultFail
(
-
500
,
JSON
.
stringify
(
e
.
stack
));
return
system
.
getResultFail
(
-
500
,
JSON
.
stringify
(
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