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
70a85181
Commit
70a85181
authored
Nov 17, 2020
by
庄冰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
baiduicpqueue
parent
cf70b33a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
257 additions
and
69 deletions
+257
-69
center-channel/app/base/api/impl/action/qcapi.js
+4
-0
center-channel/app/base/service/impl/common/baseCenterOrderSve.js
+123
-61
center-channel/app/base/service/impl/utilsSve/utilsChannelPartnerSve.js
+82
-0
center-channel/app/base/service/impl/utilsSve/utilsPushSve.js
+22
-0
center-channel/app/base/utils/baiduClient.js
+10
-8
center-channel/app/config/settings.js
+16
-0
No files found.
center-channel/app/base/api/impl/action/qcapi.js
View file @
70a85181
...
...
@@ -90,6 +90,10 @@ class QcAPI extends APIBase {
opResult
=
await
this
.
qcCenterOrderSve
.
rtRecordLogList
(
pobj
);
break
;
// --------- 推送icp信息至渠道和作方 zhuangbing-20201116--------
case
"pushIcpSolution2Channel"
:
//推送ICP方案至渠道(百度)
opResult
=
await
this
.
baseOrderSve
.
pushIcpSolution2Channel
(
pobj
);
break
;
default
:
opResult
=
system
.
getResult
(
null
,
"action_type参数错误"
);
break
;
...
...
center-channel/app/base/service/impl/common/baseCenterOrderSve.js
View file @
70a85181
...
...
@@ -103,86 +103,146 @@ class BaseCenterOrderService extends AppServiceBase {
needsolution
.
solutionContent
=
JSON
.
parse
(
needsolution
.
solutionContent
);
}
var
solution
=
needsolution
.
solutionContent
.
solution
;
var
self
=
this
;
//推送方案
// 2020 0916 lin 修改 增加获取返回值
//var pushIcpSolutionRes = await this.pushIcpSolution(pushObj, needsolution.solutionNo, pobj.appInfo, self);
if
(
ab
.
isTest
&&
ab
.
isTest
==
1
){
var
reqPushParams
=
{
actionBody
:
{
uapp_id
:
needinfo
.
uapp_id
,
channelNeedNo
:
needinfo
.
channelNeedNo
,
CompanyName
:
solution
.
CompanyName
,
IcpType
:
solution
.
IcpType
,
CompanyAddress
:
solution
.
CompanyAddress
,
Area
:
solution
.
Area
,
Note
:
solution
.
Note
,
ActionType
:
solution
.
ActionType
,
channelSolutionNo
:
needsolution
.
channelSolutionNo
,
solutionNo
:
needsolution
.
solutionNo
,
},
appInfo
:
pobj
.
appInfo
};
await
this
.
utilsPushSve
.
business2Channel
(
reqPushParams
,
"pushIcpSolution2Channel"
);
}
else
{
var
self
=
this
;
//2020-10-26 laolan 区分百度与阿里
if
(
needinfo
.
uapp_id
==
uappId
.
ali
){
//推送数据至阿里
// var bizType = needinfo.channelTypeCode;//业务类型里
var
pushObj
=
{
IntentionBizId
:
needinfo
.
channelNeedNo
,
CompanyName
:
solution
.
CompanyName
,
IcpType
:
solution
.
IcpType
,
CompanyAddress
:
solution
.
CompanyAddress
,
Area
:
solution
.
Area
,
Note
:
solution
.
Note
,
ActionType
:
solution
.
ActionType
,
Source
:
"官网"
};
if
(
needsolution
.
channelSolutionNo
)
{
pushObj
[
"BizId"
]
=
needsolution
.
channelSolutionNo
;
}
var
pushIcpSolutionRes
=
await
this
.
pushIcpSolution
(
pushObj
,
needsolution
.
solutionNo
,
pobj
.
appInfo
,
self
);
}
if
(
needinfo
.
uapp_id
==
uappId
.
baidu
){
//推送数据至baidu
// var bizType = needinfo.channelTypeCode;//业务类型里
solution
.
Area
=
cityLetter
[
solution
.
Area
]
console
.
log
(
'solution.Area++'
,
solution
.
Area
)
var
pushObj
=
{
requirementId
:
needinfo
.
channelNeedNo
,
companyName
:
solution
.
CompanyName
,
companyAddress
:
solution
.
CompanyAddress
,
area
:
solution
.
Area
,
type
:
solution
.
IcpType
};
if
(
needsolution
.
channelSolutionNo
)
{
pushObj
[
"bizId"
]
=
needsolution
.
channelSolutionNo
;
}
console
.
log
(
'pushObj++'
,
pushObj
)
var
pushIcpSolutionRes
=
await
this
.
pushBaiduIcpSolution
(
pushObj
,
needsolution
.
solutionNo
,
pobj
.
appInfo
,
self
);
}
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"service/impl/common/qcCenterOrderSve.js/submitIcpProgramme"
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
needinfo
),
optitle
:
"createSolution推送蜂擎获取的接口信息->aliBusiness2Delivery"
,
});
}
var
reqParams
=
{
actionBody
:
{
intentionBizId
:
needinfo
.
channelNeedNo
,
status
:
"createSolution"
},
appInfo
:
pobj
.
appInfo
}
this
.
utilsPushSve
.
aliBusiness2Delivery
(
reqParams
,
"updateChanceStatus"
);
//
// return system.getResultSuccess(pushIcpSolutionRes);
}
return
res
;
}
//推送ICP方案至渠道方
async
pushIcpSolution2Channel
(
pobj
){
var
actionBody
=
pobj
.
actionBody
;
var
appInfo
=
pobj
.
appInfo
;
var
pushRes
=
{
status
:
-
1
,
msg
:
"推送失败"
};
var
self
=
this
;
if
(
actionBody
){
//2020-10-26 laolan 区分百度与阿里
if
(
needinfo
.
uapp_id
==
uappId
.
ali
){
if
(
actionBody
.
uapp_id
==
uappId
.
ali
){
//推送数据至阿里
// var bizType = needinfo.channelTypeCode;//业务类型里
var
pushObj
=
{
IntentionBizId
:
needinfo
.
channelNeedNo
,
CompanyName
:
solution
.
CompanyName
,
IcpType
:
solution
.
IcpType
,
CompanyAddress
:
solution
.
CompanyAddress
,
Area
:
solution
.
Area
,
Note
:
solution
.
Note
,
ActionType
:
solution
.
ActionType
,
IntentionBizId
:
actionBody
.
channelNeedNo
,
CompanyName
:
actionBody
.
CompanyName
,
IcpType
:
actionBody
.
IcpType
,
CompanyAddress
:
actionBody
.
CompanyAddress
,
Area
:
actionBody
.
Area
,
Note
:
actionBody
.
Note
,
ActionType
:
actionBody
.
ActionType
,
Source
:
"官网"
};
if
(
needsolution
.
channelSolutionNo
)
{
pushObj
[
"BizId"
]
=
needsolution
.
channelSolutionNo
;
if
(
actionBody
.
channelSolutionNo
)
{
pushObj
[
"BizId"
]
=
actionBody
.
channelSolutionNo
;
}
var
pushIcpSolutionRes
=
await
this
.
pushIcpSolution
(
pushObj
,
needsolution
.
solutionNo
,
pobj
.
appInfo
,
self
);
pushRes
=
await
this
.
pushIcpSolution
(
pushObj
,
actionBody
.
solutionNo
,
actionBody
.
appInfo
,
self
);
}
if
(
needinfo
.
uapp_id
==
uappId
.
baidu
){
if
(
actionBody
.
uapp_id
==
uappId
.
baidu
){
//推送数据至baidu
// var bizType = needinfo.channelTypeCode;//业务类型里
solution
.
Area
=
cityLetter
[
solution
.
Area
]
console
.
log
(
'solution.Area++'
,
solution
.
Area
)
actionBody
.
Area
=
cityLetter
[
actionBody
.
Area
];
var
pushObj
=
{
requirementId
:
needinfo
.
channelNeedNo
,
companyName
:
solution
.
CompanyName
,
companyAddress
:
solution
.
CompanyAddress
,
area
:
solution
.
Area
,
type
:
solution
.
IcpType
requirementId
:
actionBody
.
channelNeedNo
,
companyName
:
actionBody
.
CompanyName
,
companyAddress
:
actionBody
.
CompanyAddress
,
area
:
actionBody
.
Area
,
type
:
actionBody
.
IcpType
};
if
(
needsolution
.
channelSolutionNo
)
{
pushObj
[
"bizId"
]
=
needsolution
.
channelSolutionNo
;
if
(
actionBody
.
channelSolutionNo
)
{
pushObj
[
"bizId"
]
=
actionBody
.
channelSolutionNo
;
}
console
.
log
(
'pushObj++'
,
pushObj
)
var
pushIcpSolutionRes
=
await
this
.
pushBaiduIcpSolution
(
pushObj
,
needsolution
.
solutionNo
,
pobj
.
appInfo
,
self
);
pushRes
=
await
this
.
pushBaiduIcpSolution
(
pushObj
,
actionBody
.
solutionNo
,
actionBody
.
appInfo
,
self
);
}
// // 2020 0806 lin 新增推送
// var reqParams = {
// actionType: "produceData",// Y 功能名称
// actionBody: {
// pushUrl: pushUrl,// Y 推送地址
// actionType: "updateChanceStatus",// Y 推送地址接收时的功能名称
// notifyUrl: "",// N 推送成功后通知的Url
// identifyCode: "ali.vat",// Y 操作的业务标识
// messageBody: pobj.actionBody, // Y 推送的业务消息,必须有一项对象属性值
// headData: ""//N 请求头信息,Json格式,如:{token:"XXXXXXX"}
// },
// requestId: pobj.requestId || "" // N 请求id
// }
// this.opQueuePushClientPost(pobj, this.opPushQueueUrl, reqParams);
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"
service/impl/common/qcCenterOrderSve.js/submitIcpProgramme
"
,
op
:
"
app/base/service/impl/common/baseCenterOrderSve.js/pushIcpSolution2Channel
"
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
JSON
.
stringify
(
needinfo
),
optitle
:
"
createSolution推送蜂擎获取的接口信息->aliBusiness2Delivery
"
,
resultInfo
:
JSON
.
stringify
(
pushRes
),
optitle
:
"
pushIcpSolution2Channel推送ICP方案至渠道方->pushIcpSolution2Channel
"
,
});
var
reqParams
=
{
actionBody
:
{
intentionBizId
:
needinfo
.
channelNeedNo
,
status
:
"createSolution"
},
appInfo
:
pobj
.
appInfo
}
this
.
utilsPushSve
.
aliBusiness2Delivery
(
reqParams
,
"updateChanceStatus"
);
//
return
system
.
getResultSuccess
(
pushIcpSolutionRes
);
}
return
res
;
if
(
pushRes
.
status
==
0
||
pushRes
.
status
==
1
){
return
system
.
getResultRedisQueueSuccess
();
}
return
pushRes
;
}
//推送ICP方案ali
async
pushIcpSolution
(
pushObj
,
solutionNo
,
appInfo
,
self
)
{
//推送方案信息
...
...
@@ -216,10 +276,11 @@ class BaseCenterOrderService extends AppServiceBase {
var
a
=
await
self
.
reqCenterOrderApi
(
reqObj3
);
//保存用户确认方案url
}
}
return
confirmRes
;
//
return confirmRes;
}
}
}
return
pushRes
;
}
//推送ICP方案baidu 2020-10-26 laolan
...
...
@@ -252,10 +313,11 @@ class BaseCenterOrderService extends AppServiceBase {
};
var
url
=
await
self
.
reqCenterOrderApi
(
reqObj3
);
//保存用户确认方案url
console
.
log
(
'save confirmUrl ++ '
,
url
)
return
pushRes
;
//
return pushRes;
}
}
}
return
pushRes
;
}
//服务商icp方案关闭 2020-10-26 laolan
...
...
center-channel/app/base/service/impl/utilsSve/utilsChannelPartnerSve.js
0 → 100644
View file @
70a85181
var
system
=
require
(
"../../../system"
);
const
AppServiceBase
=
require
(
"../../app.base"
);
var
settings
=
require
(
"../../../../config/settings"
);
//此类用来db中配置来进行调用-主要功能是推送渠道合作方
class
UtilsChannelPartnerService
extends
AppServiceBase
{
constructor
()
{
super
();
this
.
opPushQueueUrl
=
settings
.
opPushQueueUrl
();
}
/**
* 推送业务信息到渠道合作方
* 业务操作的信息不变外加增加组装的一些参数(推送方案、订单交付信息)
* @param {*} pobj
*/
async
pushBusiness2Channel
(
pobj
)
{
//推送业务信息到渠道合作方
console
.
log
(
pobj
,
"pushBusiness2Channel-zhuangbing------------------------------"
);
var
verifyResult
=
await
this
.
verifyParam
(
pobj
);
if
(
verifyResult
.
status
!=
0
)
{
return
await
this
.
disposePushResultFail
(
pobj
,
verifyResult
,
"deliver->pushBusiness2Channel->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
opQueuePushClientPostRes
=
await
this
.
opQueuePushClientPost
(
pobj
,
this
.
opPushQueueUrl
,
reqParams
);
console
.
log
(
opQueuePushClientPostRes
,
"pushBusiness2Channel-zhuangbing----2--------------------------"
);
}
//--------------------------------------------------内部辅助方法-------------------start-----------------
async
opQueuePushClientPost
(
pobj
,
pushQueueUrl
,
reqParams
)
{
try
{
var
rtn
=
await
this
.
restPostUrl
(
reqParams
,
pushQueueUrl
);
if
(
rtn
.
status
!=
1
)
{
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/utilsChannelPartnerSve/opQueuePushClientPost"
,
content
:
"error:"
+
e
.
stack
,
// clientIp: pobj.clientIp,
optitle
:
pobj
.
opType
+
"推送操作异常deliver->opQueuePushClientPost"
,
});
return
system
.
getResult
(
null
,
"推送操作异常deliver->opQueuePushClientPost->error:"
+
e
.
stack
);
}
}
async
verifyParam
(
pobj
)
{
//参数信息验证
var
verify
=
system
.
getResultSuccess
();
if
(
!
pobj
.
interface_params
)
{
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
.
pushUrl
||
!
interface_params_info
.
headData
)
{
verify
=
system
.
getResult
(
null
,
"interface_params(pushUrl、headData) can not be empty,100430"
);
}
verify
.
data
=
interface_params_info
;
return
verify
;
}
//--------------------------------------------------内部辅助方法-------------------end-----------------
}
module
.
exports
=
UtilsChannelPartnerService
;
center-channel/app/base/service/impl/utilsSve/utilsPushSve.js
View file @
70a85181
...
...
@@ -29,6 +29,28 @@ class UtilsPushService extends AppServiceBase {
return
system
.
getResult
(
null
,
"push Fail,interface_info data is empty"
);
}
async
business2Channel
(
pobj
,
opType
)
{
//供业务调用,在代码中调用,不在db中做配置进行调用
pobj
.
actionType
=
"getAppInterface"
;
var
reqUrl
=
settings
.
centerAppUrl
()
+
"action/opProduct/springBoard"
;
var
productItemInterfaceResult
=
await
this
.
restPostUrl
(
pobj
,
reqUrl
);
pobj
.
interface_info
=
productItemInterfaceResult
.
data
;
//日志记录
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
||
""
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
||
""
:
""
,
requestId
:
pobj
.
requestId
||
""
,
op
:
"service/impl/utilsSve/utilsPushSve.js/service/app.base.js/business2Channel"
,
content
:
JSON
.
stringify
(
pobj
),
resultInfo
:
productItemInterfaceResult
.
data
?
JSON
.
stringify
(
productItemInterfaceResult
.
data
)
:
"接口数据为空"
,
optitle
:
opType
+
"推送获取的接口信息->business2Channel"
,
});
if
(
pobj
.
interface_info
)
{
await
this
.
pushBusInfo
(
pobj
,
opType
,
1
);
return
system
.
getResultSuccess
();
}
return
system
.
getResult
(
null
,
"push Fail,interface_info data is empty"
);
}
async
aliBusiness2Fq
(
pobj
,
opType
)
{
//供业务调用,在代码中调用,不在db中做配置进行调用
pobj
.
actionType
=
"getAppInterface"
;
...
...
center-channel/app/base/utils/baiduClient.js
View file @
70a85181
...
...
@@ -4,29 +4,28 @@ const crypto = require('crypto');
const
sha256
=
require
(
'sha256'
);
var
urlencode
=
require
(
'urlencode'
);
const
system
=
require
(
"../system"
);
var
settings
=
require
(
"../../config/settings"
);
class
baiduClient
{
constructor
()
{
this
.
pushlogSve
=
system
.
getObject
(
"service.common.pushlogSve"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
baiduClientParams
=
settings
.
baiduClientParams
();
}
//2020 1027 laolan 调用百度网关
async
baiduPost
(
path
,
actionBody
)
{
console
.
log
(
'actionBody++'
,
actionBody
)
// let domain = "https://gwgp-mwnn9gk4o4e.i.bdcloudapi.com";//开发
let
domain
=
"https://gwgp-nbzljnwusrw.i.bdcloudapi.com"
;
//线上
let
domain
=
this
.
baiduClientParams
.
domain
;
let
url
=
domain
+
path
;
let
version
=
"bce-auth-v1"
;
// let accessKey = "ed0f5c4c7c2d4e87aa335d9b07bf9bd4";
// let secretKey = "f600c4e91f6d43998d637401e6e34ef9";
let
accessKey
=
"0e5abf33ef07457f8dbd779287747c0c"
;
let
secretKey
=
"9d86f04a85db4cdfa95ba8ad28009188"
;
let
accessKey
=
this
.
baiduClientParams
.
accessKey
;
let
secretKey
=
this
.
baiduClientParams
.
secretKey
;
let
timestamp
=
new
Date
().
toISOString
()
let
site
=
timestamp
.
lastIndexOf
(
"."
);
timestamp
=
timestamp
.
substring
(
0
,
site
)
+
"Z"
let
signedHeaders
=
"host"
;
let
extime
=
1800
;
let
canonicalHeaders
=
"host:
gwgp-nbzljnwusrw.i.bdcloudapi.com"
let
canonicalHeaders
=
"host:
"
+
this
.
baiduClientParams
.
host
;
//中间结果1:规范化请求和前缀字符串
let
canonicalRequest
=
"POST"
+
"
\
n"
+
path
+
"
\
n"
+
"
\
n"
+
canonicalHeaders
;
//authStringPrefix(前缀字符串,由除sk字段外的签名信息生成)
...
...
@@ -67,7 +66,7 @@ class baiduClient {
formatParams
:
true
,
// default true, format the parameter name to first letter upper case
method
:
'POST'
,
// set the http method, default is GET
headers
:
{
host
:
"gwgp-nbzljnwusrw.i.bdcloudapi.com"
host
:
this
.
baiduClientParams
.
host
},
// set the http request headers
});
console
.
log
(
'baidu++++res+++'
,
res
)
...
...
@@ -97,3 +96,5 @@ class baiduClient {
}
}
module
.
exports
=
baiduClient
;
// var task = new baiduClient();
// console.log(task.baiduClientParams,"11111111111111111");
\ No newline at end of file
center-channel/app/config/settings.js
View file @
70a85181
...
...
@@ -30,6 +30,22 @@ var settings = {
}
return
"http://43.247.184.94:7200/center_channel_req_log/_doc?pretty"
;
},
baiduClientParams
:
function
()
{
if
(
this
.
env
==
'dev'
)
{
return
{
domain
:
"https://gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
,
//开发
accessKey
:
"ed0f5c4c7c2d4e87aa335d9b07bf9bd4"
,
secretKey
:
"f600c4e91f6d43998d637401e6e34ef9"
,
host
:
"gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
};
}
return
{
domain
:
"https://gwgp-nbzljnwusrw.i.bdcloudapi.com"
,
//线上
accessKey
:
"0e5abf33ef07457f8dbd779287747c0c"
,
secretKey
:
"9d86f04a85db4cdfa95ba8ad28009188"
,
host
:
"gwgp-nbzljnwusrw.i.bdcloudapi.com"
};
},
fbQueryUrl
:
function
()
{
if
(
this
.
env
==
'dev'
||
this
.
env
==
'test'
)
{
return
'http://43.247.184.92:15505'
...
...
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