Commit bd2b7795 by 蒋勇

Merge branch 'center-channel' of gitlab.gongsibao.com:jiangyong/zhichan into center-channel

parents c97e2e81 3de5a10d
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
class QcAPI extends APIBase { class QcAPI extends APIBase {
constructor() { constructor() {
super(); super();
...@@ -9,6 +10,7 @@ class QcAPI extends APIBase { ...@@ -9,6 +10,7 @@ class QcAPI extends APIBase {
this.ncSve = system.getObject("service.common.ncSve"); this.ncSve = system.getObject("service.common.ncSve");
this.rtSve = system.getObject("service.common.rtSve"); this.rtSve = system.getObject("service.common.rtSve");
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
* action_process 执行的流程 * action_process 执行的流程
...@@ -22,6 +24,7 @@ class QcAPI extends APIBase { ...@@ -22,6 +24,7 @@ class QcAPI extends APIBase {
var result = await this.opActionProcess(pobj, pobj.actionType, req); var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result; return result;
} }
async opActionProcess(pobj, action_type, req) { async opActionProcess(pobj, action_type, req) {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
...@@ -97,4 +100,5 @@ class QcAPI extends APIBase { ...@@ -97,4 +100,5 @@ class QcAPI extends APIBase {
} }
} }
module.exports = QcAPI; module.exports = QcAPI;
\ No newline at end of file
...@@ -21,39 +21,16 @@ class Order extends APIBase { ...@@ -21,39 +21,16 @@ class Order extends APIBase {
if (!pobj.orderNo) { if (!pobj.orderNo) {
return regCfg.getResultFail("orderNo不能为空"); return regCfg.getResultFail("orderNo不能为空");
} }
// var i = 0;
// var orderLength = pobj.subOrderList.lenght;
// for (i = 0; i <= orderLength; i++) {
// if (!pobj.subOrderList[i].orderNo) {
// return regCfg.getResultFail("orderNo不能为空");
// }
// if (pobj.isDirectBuy == 0 && !pobj.subOrderList[i].bizId) {
// return regCfg.getResultFail("非直接下单bizId不能为空");
// }
// if (pobj.isDirectBuy == 1 && !pobj.subOrderList[i].phone) {
// return regCfg.getResultFail("直接下单phone不能为空");
// }
// if (pobj.isDirectBuy == 1 && !pobj.subOrderList[i].consultType) {
// return regCfg.getResultFail("直接下单consultType不能为空");
// }
// // if (pobj.subOrderList[i].area) {
// // pobj.subOrderList[i].area = regCfg.baiduArea[pobj.subOrderList[i].area]
// // }
// if (!pobj.subOrderList[i].area) {
// return regCfg.getResultFail("area参数错误");
// }
// }
if (!pobj.orderNo) { if (!pobj.orderNo) {
return regCfg.getResultFail("orderNo不能为空"); return regCfg.getResultFail("orderNo不能为空");
} }
if (pobj.isDirectBuy==0 && !pobj.bizId) { if (pobj.isDirectBuy == 0 && !pobj.bizId) {
return regCfg.getResultFail("非直接下单bizId不能为空"); return regCfg.getResultFail("非直接下单bizId不能为空");
} }
if (pobj.isDirectBuy==1 && !pobj.phone) { if (pobj.isDirectBuy == 1 && !pobj.phone) {
return regCfg.getResultFail("直接下单phone不能为空"); return regCfg.getResultFail("直接下单phone不能为空");
} }
if (pobj.isDirectBuy==1 && !pobj.consultType) { if (pobj.isDirectBuy == 1 && !pobj.consultType) {
return regCfg.getResultFail("直接下单consultType不能为空"); return regCfg.getResultFail("直接下单consultType不能为空");
} }
if (pobj.area) { if (pobj.area) {
...@@ -98,4 +75,5 @@ class Order extends APIBase { ...@@ -98,4 +75,5 @@ class Order extends APIBase {
} }
} }
module.exports = Order; module.exports = Order;
\ No newline at end of file
...@@ -2,77 +2,94 @@ ...@@ -2,77 +2,94 @@
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
var regCfg = { var regCfg = {
//工商注册城市对照表 //工商注册城市对照表
baiduArea : { baiduArea: {
"310100":"上海", "310100": "上海",
"441900":"东莞", "441900": "东莞",
"440600":"佛山", "440600": "佛山",
"110100":"北京", "110100": "北京",
"320100":"南京", "320100": "南京",
"360100":"南昌", "360100": "南昌",
"320600":"南通", "320600": "南通",
"331000":"台州", "331000": "台州",
"340100":"合肥", "340100": "合肥",
"330400":"嘉兴", "330400": "嘉兴",
"210200":"大连", "210200": "大连",
"120100":"天津", "120100": "天津",
"140100":"太原", "140100": "太原",
"330200":"宁波", "330200": "宁波",
"320400":"常州", "320400": "常州",
"440100":"广州", "440100": "广州",
"320300":"徐州", "320300": "徐州",
"510100":"成都", "510100": "成都",
"321000":"扬州", "321000": "扬州",
"320200":"无锡", "320200": "无锡",
"530100":"昆明", "530100": "昆明",
"330100":"杭州", "330100": "杭州",
"420100":"武汉", "420100": "武汉",
"210100":"沈阳", "210100": "沈阳",
"370100":"济南", "370100": "济南",
"440300":"深圳", "440300": "深圳",
"330300":"温州", "330300": "温州",
"370600":"烟台", "370600": "烟台",
"350100":"福州", "350100": "福州",
"330600":"绍兴", "330600": "绍兴",
"320500":"苏州", "320500": "苏州",
"610100":"西安", "610100": "西安",
"520100":"贵阳", "520100": "贵阳",
"410100":"郑州", "410100": "郑州",
"500100":"重庆", "500100": "重庆",
"330700":"金华", "330700": "金华",
"220100":"长春", "220100": "长春",
"430100":"长沙", "430100": "长沙",
"370200":"青岛", "370200": "青岛",
"410200":"开封", "410200": "开封",
"230100":"哈尔滨", "230100": "哈尔滨",
"130100":"石家庄", "130100": "石家庄",
"350200":"厦门", "350200": "厦门",
"360400":"九江", "360400": "九江",
"410300":"洛阳", "410300": "洛阳",
"411000":"许昌", "411000": "许昌",
"411600":"周口", "411600": "周口",
"411300":"南阳", "411300": "南阳",
"420500":"宜昌", "420500": "宜昌",
"420600":"襄阳", "420600": "襄阳",
"430600":"岳阳", "430600": "岳阳",
"430700":"常德", "430700": "常德",
"440700":"江门", "440700": "江门",
"440400":"珠海", "440400": "珠海",
"440900":"茂名", "440900": "茂名",
"441300":"惠州", "441300": "惠州",
"442000":"中山", "442000": "中山",
"450100":"南宁", "450100": "南宁",
"460100":"海口", "460100": "海口",
"460200":"三亚", "460200": "三亚",
"510700":"绵阳", "510700": "绵阳",
"540100":"拉萨", "540100": "拉萨",
"130600":"保定", "130600": "保定",
"130200":"唐山", "130200": "唐山",
"140200":"大同", "140200": "大同",
"1501":"呼和浩特", "1501": "呼和浩特",
"341200":"阜阳" "341200": "阜阳",
"CPF009": "北京朝阳区",
"CPF010": "北京海淀区",
"CPF011": "北京丰台区",
"CPF012": "北京东城区",
"CPF013": "北京西城区",
"CPF014": "北京昌平区",
"CPF015": "北京通州区",
"CPF016": "北京怀柔区",
"CPF017": "北京石景山区",
"CPF018": "北京平谷区",
"CPF019": "北京顺义区",
"CPF020": "北京房山区",
"CPF021": "北京门头沟区",
"CPF022": "北京密云区",
"CPF023": "北京大兴区",
"CP0024": "北京顺义园区",
"CP0025": "北京房山园区"
}, },
baiduAreaCode : { baiduAreaCode: {
"上海": "310100", "上海": "310100",
"东莞": "441900", "东莞": "441900",
"佛山": "440600", "佛山": "440600",
...@@ -113,49 +130,69 @@ var regCfg = { ...@@ -113,49 +130,69 @@ var regCfg = {
"长沙": "430100", "长沙": "430100",
"青岛": "370200", "青岛": "370200",
"开封": "410200", "开封": "410200",
"哈尔滨":"230100", "哈尔滨": "230100",
"石家庄":"130100", "石家庄": "130100",
"厦门":"350200", "厦门": "350200",
"九江":"360400", "九江": "360400",
"洛阳":"410300", "洛阳": "410300",
"许昌":"411000", "许昌": "411000",
"周口":"411600", "周口": "411600",
"南阳":"411300", "南阳": "411300",
"宜昌":"420500", "宜昌": "420500",
"襄阳":"420600", "襄阳": "420600",
"岳阳":"430600", "岳阳": "430600",
"常德":"430700", "常德": "430700",
"江门":"440700", "江门": "440700",
"珠海":"440400", "珠海": "440400",
"茂名":"440900", "茂名": "440900",
"惠州":"441300", "惠州": "441300",
"中山":"442000", "中山": "442000",
"南宁":"450100", "南宁": "450100",
"海口":"460100", "海口": "460100",
"三亚":"460200", "三亚": "460200",
"绵阳":"510700", "绵阳": "510700",
"拉萨":"540100", "拉萨": "540100",
"保定":"130600", "保定": "130600",
"唐山":"130200", "唐山": "130200",
"大同":"140200", "大同": "140200",
"呼和浩特":"150100", "呼和浩特": "150100",
"阜阳":"341200" "阜阳": "341200",
"北京朝阳区": "CPF009",
"北京海淀区": "CPF010",
"北京丰台区": "CPF011",
"北京东城区": "CPF012",
"北京西城区": "CPF013",
"北京昌平区": "CPF014",
"北京通州区": "CPF015",
"北京怀柔区": "CPF016",
"北京石景山区": "CPF017",
"北京平谷区": "CPF018",
"北京顺义区": "CPF019",
"北京房山区": "CPF020",
"北京门头沟区": "CPF021",
"北京密云区": "CPF022",
"北京大兴区": "CPF023",
"北京顺义园区": "CP0024",
"北京房山园区": "CP0025"
}, },
channelTypeCode : { channelTypeCode: {
"GSREG" : "baidu.gsreg", "GSREG": "baidu.gsreg",
"KZFW" : "baidu.kzfw", "KZFW": "baidu.kzfw",
"GSCHANGS" : "baidu.gsbg", "GSCHANGS": "baidu.gsbg",
"GSNB" : "baidu.gsnb", "GSNB": "baidu.gsnb",
"SKSQ" : "baidu.sksq", "SKSQ": "baidu.sksq",
"SWBD" : "baidu.swbd" "SWBD": "baidu.swbd",
"QYJYTC3":"baidu_qyjytc3",
"QYJYTC4":"baidu_qyjytc4",
"QYJYTC5":"baidu_qyjytc5"
}, },
//区分渠道的uappid //区分渠道的uappid
uappId : { uappId: {
'baidu':44, 'baidu': 44,
'zhogxiaowei': 38 'zhogxiaowei': 38
}, },
//交付状态 //交付状态
deliverRegStatus:{ deliverRegStatus: {
'RECEIVED': 'RECEIVED',//已接单 'RECEIVED': 'RECEIVED',//已接单
'COLLECTING': 'COLLECTING',//材料收集环节 'COLLECTING': 'COLLECTING',//材料收集环节
'AUDITING': 'AUDITING',//工商审核环节 'AUDITING': 'AUDITING',//工商审核环节
...@@ -164,7 +201,7 @@ var regCfg = { ...@@ -164,7 +201,7 @@ var regCfg = {
'ACTIVE': 'ACTIVE' //服务中 'ACTIVE': 'ACTIVE' //服务中
}, },
//交付状态 //交付状态
deliverStatus:{ deliverStatus: {
'RECEIVED': '已接单',// 'RECEIVED': '已接单',//
'COLLECTING': '材料收集环节',// 'COLLECTING': '材料收集环节',//
'AUDITING': '工商审核环节',// 'AUDITING': '工商审核环节',//
...@@ -182,17 +219,17 @@ var regCfg = { ...@@ -182,17 +219,17 @@ var regCfg = {
return { return {
"status": 0, "status": 0,
"msg": "success", "msg": "success",
"data":null, "data": null,
"requestId": requestId "requestId": requestId
}; };
}, },
getResultFail(errmsg) { getResultFail(errmsg) {
return { return {
"status":-1, "status": -1,
"msg": errmsg, "msg": errmsg,
"requestId": this.getUUID(), "requestId": this.getUUID(),
"data":null, "data": null,
"bizmsg":"empty" "bizmsg": "empty"
}; };
} }
} }
......
...@@ -8,47 +8,36 @@ class UtilsDeliverSystemService extends AppServiceBase { ...@@ -8,47 +8,36 @@ class UtilsDeliverSystemService extends AppServiceBase {
super(); super();
this.opPushQueueUrl = settings.opPushQueueUrl(); this.opPushQueueUrl = settings.opPushQueueUrl();
} }
/** /**
* 推送业务信息到交付系统 * 推送业务信息到交付系统
* 业务操作的信息不变外加增加组装的一些参数(推送需求商机、关闭需求、订单商机、关闭订单) * 业务操作的信息不变外加增加组装的一些参数(推送需求商机、关闭需求、订单商机、关闭订单)
* @param {*} pobj * @param {*} pobj
*/ */
async pushBusiness2DeliverSystem(pobj) {//推送业务信息到交付系统 async pushBusiness2DeliverSystem(pobj) {//推送业务信息到交付系统
this.execClientNew.execLogs(`推送资质宝结果->pushBusiness2DeliverSystem`, pobj, "center-channel-utilsDeliverSystemSve-pushBusiness2DeliverSystem", null, null);
var verifyResult = await this.verifyParam(pobj); var verifyResult = await this.verifyParam(pobj);
if (verifyResult.status != 0) { if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "deliver->pushBusiness2DeliverSystem->verifyResult", this.pushlogFailType.FQ); return await this.disposePushResultFail(pobj, verifyResult, "deliver->pushBusiness2DeliverSystem->verifyResult", this.pushlogFailType.FQ);
} }
var interface_params_info = verifyResult.data; var interface_params_info = verifyResult.data;
// var reqParams = { let params = null
// actionType: "produceData",// Y 功能名称 let headInfo = {}
// actionBody: { if (pobj.appInfo) {
// pushUrl: interface_params_info.pushUrl,// Y 推送地址 headInfo["appcode"] = pobj.appInfo.app_code
// actionType: interface_params_info.actionType,// Y 推送地址接收时的功能名称 params = {
// notifyUrl: interface_params_info.notifyUrl || "",// N 推送成功后通知的Url actionType: interface_params_info.actionType,
// 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 params=null
let headInfo={}
if(req.appInfo){
headInfo["appcode"]=req.appInfo.app_code
parms = {
actionType:interface_params_info.actionType,
actionBody: pobj.actionBody, actionBody: pobj.actionBody,
headData:headInfo headData: headInfo
} }
}else{ } else {
parms = { params = {
actionType:interface_params_info.actionType, actionType: interface_params_info.actionType,
actionBody: pobj.actionBody actionBody: pobj.actionBody
} }
} }
let url = interface_params_info.opUrl; let url = interface_params_info.opUrl;
var opQueuePushClientPostRes = await this.opQueuePushClientPost(pobj, url, parms); var opQueuePushClientPostRes = await this.opQueuePushClientPost(pobj, url, params);
return await this.disposePushResult(pobj, opQueuePushClientPostRes, "delivery->pushBusiness2DeliverSystem->result", this.pushlogFailType.FQ); return await this.disposePushResult(pobj, opQueuePushClientPostRes, "delivery->pushBusiness2DeliverSystem->result", this.pushlogFailType.FQ);
} }
...@@ -57,26 +46,18 @@ class UtilsDeliverSystemService extends AppServiceBase { ...@@ -57,26 +46,18 @@ class UtilsDeliverSystemService extends AppServiceBase {
async opQueuePushClientPost(pobj, pushQueueUrl, reqParams) { async opQueuePushClientPost(pobj, pushQueueUrl, reqParams) {
try { try {
var rtn = await this.restPostUrl(reqParams, pushQueueUrl); var rtn = await this.restPostUrl(reqParams, pushQueueUrl);
this.execClientNew.execLogs(`推送资质宝结果->opQueuePushClientPost->url:` + pushQueueUrl, reqParams, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", rtn, null);
if (rtn.status != 1) { if (rtn.status != 1) {
this.execClientNew.execLogs(`推送资质宝失败->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", rtn, JSON.stringify(rtn));
return system.getResult(null, "推送资质宝失败,失败原因:" + JSON.stringify(rtn)); return system.getResult(null, "推送资质宝失败,失败原因:" + JSON.stringify(rtn));
} }
return system.getResultSuccess(null, "推送成功"); return system.getResultSuccess(null, "推送成功");
} catch (e) { } catch (e) {
//日志记录 const stackStr = e.stack ? e.stack : JSON.stringify(e);
// this.logCtl.error({ this.execClientNew.execLogs(`推送操作异常deliver->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", null, stackStr);
// appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "", return system.getResult(null, "推送操作异常deliver->opQueuePushClientPost->error:" + stackStr);
// 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);
} }
} }
async verifyParam(pobj) {//参数信息验证 async verifyParam(pobj) {//参数信息验证
var verify = system.getResultSuccess(); var verify = system.getResultSuccess();
if (!pobj.interface_params) { if (!pobj.interface_params) {
...@@ -92,4 +73,5 @@ class UtilsDeliverSystemService extends AppServiceBase { ...@@ -92,4 +73,5 @@ class UtilsDeliverSystemService extends AppServiceBase {
//--------------------------------------------------内部辅助方法-------------------end----------------- //--------------------------------------------------内部辅助方法-------------------end-----------------
} }
module.exports = UtilsDeliverSystemService; module.exports = UtilsDeliverSystemService;
...@@ -164,7 +164,6 @@ class UtilsOrderService extends AppServiceBase { ...@@ -164,7 +164,6 @@ class UtilsOrderService extends AppServiceBase {
pobj.actionType = "addOrder"; pobj.actionType = "addOrder";
var reqUrl = this.centerOrderUrl + "action/order/springBoard"; var reqUrl = this.centerOrderUrl + "action/order/springBoard";
// console.log(pobj);
var result = await this.execPostByTimeOut(null, pobj, reqUrl); var result = await this.execPostByTimeOut(null, pobj, reqUrl);
if (result.status != 0) { if (result.status != 0) {
return result; return result;
......
...@@ -3,7 +3,8 @@ const sha256 = require('sha256'); ...@@ -3,7 +3,8 @@ const sha256 = require('sha256');
const system = require("../system"); const system = require("../system");
var settings = require("../../config/settings"); var settings = require("../../config/settings");
const AppServiceBase = require("../service/app.base"); const AppServiceBase = require("../service/app.base");
class baiduClient extends AppServiceBase{
class baiduClient extends AppServiceBase {
constructor() { constructor() {
super(); super();
this.pushlogSve = system.getObject("service.common.pushlogSve"); this.pushlogSve = system.getObject("service.common.pushlogSve");
...@@ -12,31 +13,31 @@ class baiduClient extends AppServiceBase{ ...@@ -12,31 +13,31 @@ class baiduClient extends AppServiceBase{
} }
//2020 1027 laolan 调用百度网关 //2020 1027 laolan 调用百度网关
async baiduPost( path, actionBody) { async baiduPost(path, actionBody) {
console.log('actionBody++',actionBody) console.log('baiduPost-actionBody++', actionBody)
let domain = this.baiduClientParams.domain; let domain = this.baiduClientParams.domain;
let url = domain+path; let url = domain + path;
let version ="bce-auth-v1"; let version = "bce-auth-v1";
let accessKey = this.baiduClientParams.accessKey; let accessKey = this.baiduClientParams.accessKey;
let secretKey = this.baiduClientParams.secretKey; let secretKey = this.baiduClientParams.secretKey;
let timestamp = new Date().toISOString() let timestamp = new Date().toISOString()
let site = timestamp.lastIndexOf("."); let site = timestamp.lastIndexOf(".");
timestamp = timestamp.substring(0,site)+"Z" timestamp = timestamp.substring(0, site) + "Z"
let signedHeaders = "host"; let signedHeaders = "host";
let extime = 1800; let extime = 1800;
let canonicalHeaders = "host:"+this.baiduClientParams.host; let canonicalHeaders = "host:" + this.baiduClientParams.host;
//中间结果1:规范化请求和前缀字符串 //中间结果1:规范化请求和前缀字符串
var canonicalRequest = null let canonicalRequest = null
var pathParams = path.split("?"); let pathParams = path.split("?");
if(pathParams && pathParams.length > 1){ if (pathParams && pathParams.length > 1) {
canonicalRequest = "POST" + "\n" + pathParams[0] + "\n" + pathParams[1] + "\n" + canonicalHeaders; canonicalRequest = "POST" + "\n" + pathParams[0] + "\n" + pathParams[1] + "\n" + canonicalHeaders;
}else{ } else {
canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders; canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders;
} }
// let canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders; // let canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders;
console.log('canonicalRequest+++++++',canonicalRequest) console.log('canonicalRequest+++++++', canonicalRequest)
//authStringPrefix(前缀字符串,由除sk字段外的签名信息生成) //authStringPrefix(前缀字符串,由除sk字段外的签名信息生成)
let authStringPrefix = version+"/"+accessKey+"/"+timestamp+"/"+extime; let authStringPrefix = version + "/" + accessKey + "/" + timestamp + "/" + extime;
//中间结果2:派生签名密钥 signingKey //中间结果2:派生签名密钥 signingKey
let signingKey = crypto.createHmac('sha256', secretKey) let signingKey = crypto.createHmac('sha256', secretKey)
.update(authStringPrefix) .update(authStringPrefix)
...@@ -46,17 +47,18 @@ class baiduClient extends AppServiceBase{ ...@@ -46,17 +47,18 @@ class baiduClient extends AppServiceBase{
.update(canonicalRequest) .update(canonicalRequest)
.digest('hex'); .digest('hex');
//最终结果:认证字符串 authorization //最终结果:认证字符串 authorization
let authorization = authStringPrefix+"/"+signedHeaders+"/"+signature; let authorization = authStringPrefix + "/" + signedHeaders + "/" + signature;
var baiduObj={ let baiduObj = {
authorization:authorization, authorization: authorization,
data:actionBody data: actionBody
} }
var rtn = await this.execClient.execBaiduPost(baiduObj, url); let rtn = await this.execClient.execBaiduPost(baiduObj, url);
this.execClientNew.execLogs(`baiduClient-baiduPost-result:url=${url}`, baiduObj, "center-channel-opBaiduClientPost", rtn, null);
if (!rtn || !rtn.stdout) { if (!rtn || !rtn.stdout) {
this.execClientNew.execLogs(`baiduClient-opBaiduClientPost-result:url=${url}`, actionBody, "center-channel-opBaiduClientPost", null, rtn); this.execClientNew.execLogs(`baiduClient-opBaiduClientPost-result:url=${url}`, actionBody, "center-channel-opBaiduClientPost", null, rtn);
return system.getResult(null, rtn); return system.getResult(null, rtn);
} }
var result = JSON.parse(rtn.stdout); let result = JSON.parse(rtn.stdout);
return result; return result;
} }
...@@ -65,46 +67,23 @@ class baiduClient extends AppServiceBase{ ...@@ -65,46 +67,23 @@ class baiduClient extends AppServiceBase{
var path = obj.path; var path = obj.path;
var reqbody = obj.reqbody; var reqbody = obj.reqbody;
try { try {
var res = await this.baiduPost( path, reqbody, { var res = await this.baiduPost(path, reqbody, {
timeout: 10000, // default 3000 ms 修改3000为10000,原因ConfirmIcpIntention BizIds 超过5条会超时 timeout: 10000, // default 3000 ms 修改3000为10000,原因ConfirmIcpIntention BizIds 超过5条会超时
formatAction: true, // default true, format the action to Action formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case formatParams: true, // default true, format the parameter name to first letter upper case
method: 'POST', // set the http method, default is GET method: 'POST', // set the http method, default is GET
headers: { headers: {
host:this.baiduClientParams.host host: this.baiduClientParams.host
}, // set the http request headers }, // set the http request headers
}); });
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); return system.getResultSuccess(res);
} catch (e) { } catch (e) {
await this.disposePushResultFail(obj, e, "badiu->pushBusiness2Baidu->catchError", this.pushlogFailType.FAILLOG); await this.disposePushResultFail(obj, e, "badiu->baiduReqbyget->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); return system.getResultFail(-200, "出现异常,error:" + e.stack);
} }
} }
} }
module.exports = baiduClient; module.exports = baiduClient;
// var task = new baiduClient(); // var task = new baiduClient();
// console.log(task.baiduClientParams,"11111111111111111"); // console.log(task.baiduClientParams,"11111111111111111");
\ No newline at end of file
...@@ -6,12 +6,13 @@ class baiduRegClient { ...@@ -6,12 +6,13 @@ class baiduRegClient {
constructor() { constructor() {
this.pushlogSve = system.getObject("service.common.pushlogSve"); this.pushlogSve = system.getObject("service.common.pushlogSve");
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
this.execClientNew = system.getObject("util.execClientNew");
this.baiduRegClientParams = settings.baiduRegClientParams(); this.baiduRegClientParams = settings.baiduRegClientParams();
} }
//2020 1027 laolan 调用百度网关 //2020 1027 laolan 调用百度网关
async baiduPost( path, actionBody) { async baiduPost( path, actionBody) {
console.log('actionBody++',actionBody) // console.log('actionBody++',actionBody)
let domain = this.baiduRegClientParams.domain; let domain = this.baiduRegClientParams.domain;
let url = domain+path; let url = domain+path;
let version ="bce-auth-v1"; let version ="bce-auth-v1";
...@@ -32,7 +33,7 @@ class baiduRegClient { ...@@ -32,7 +33,7 @@ class baiduRegClient {
canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders; canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders;
} }
// let canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders; // let canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders;
console.log('canonicalRequest+++++++',canonicalRequest) // console.log('canonicalRequest+++++++',canonicalRequest)
//authStringPrefix(前缀字符串,由除sk字段外的签名信息生成) //authStringPrefix(前缀字符串,由除sk字段外的签名信息生成)
let authStringPrefix = version+"/"+accessKey+"/"+timestamp+"/"+extime; let authStringPrefix = version+"/"+accessKey+"/"+timestamp+"/"+extime;
//中间结果2:派生签名密钥 signingKey //中间结果2:派生签名密钥 signingKey
...@@ -50,9 +51,10 @@ class baiduRegClient { ...@@ -50,9 +51,10 @@ class baiduRegClient {
data:actionBody data:actionBody
} }
var rtn = await this.execClient.execBaiduPost(baiduObj, url); var rtn = await this.execClient.execBaiduPost(baiduObj, url);
console.log("baiduObj+++++",baiduObj) this.execClientNew.execLogs("api-center-channel-baiduPost:"+url, baiduObj, "center-channel-baiduPost", rtn, null);
console.log("url+++++",url) // console.log("baiduObj+++++",baiduObj)
console.log("rtn+++++",rtn) // console.log("url+++++",url)
// console.log("rtn+++++",rtn)
if (!rtn || !rtn.stdout) { if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty"); return system.getResult(null, "execPost data is empty");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment