Commit f60c99cf by 兰国旗

laolan

parent aac5e3bb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
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 RegCenterOrder extends APIBase { class RegAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.regCenterOrderSve = system.getObject("service.common.regCenterOrderSve"); this.regCenterOrderSve = system.getObject("service.common.regCenterOrderSve");
...@@ -46,8 +46,9 @@ class RegCenterOrder extends APIBase { ...@@ -46,8 +46,9 @@ class RegCenterOrder extends APIBase {
case "getSolutionByChannelOrderNo"://根据渠道订单获取方案信息 case "getSolutionByChannelOrderNo"://根据渠道订单获取方案信息
opResult = await this.regCenterOrderSve.getSolutionByChannelOrderNo(pobj, pobj.actionBody); opResult = await this.regCenterOrderSve.getSolutionByChannelOrderNo(pobj, pobj.actionBody);
break; break;
case "submitBdRegSolution"://方案提交
opResult = await this.regCenterOrderSve.submitBdRegSolution(pobj); case "submitRegSolution"://方案提交
opResult = await this.regCenterOrderSve.submitRegSolution(pobj);
break; break;
case "writeRegCommunicationLog"://新增沟通记录 case "writeRegCommunicationLog"://新增沟通记录
opResult = await this.regCenterOrderSve.writeRegCommunicationLog(pobj); opResult = await this.regCenterOrderSve.writeRegCommunicationLog(pobj);
...@@ -77,4 +78,4 @@ class RegCenterOrder extends APIBase { ...@@ -77,4 +78,4 @@ class RegCenterOrder extends APIBase {
} }
} }
module.exports = RegCenterOrder; module.exports = RegAPI;
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
var regCfg = { var regCfg = {
//工商注册城市对照表 //工商注册城市对照表
baiduArea = { baiduArea : {
"310100":"上海", "310100":"上海",
"441900":"东莞", "441900":"东莞",
"440600":"佛山", "440600":"佛山",
...@@ -46,7 +46,7 @@ var regCfg = { ...@@ -46,7 +46,7 @@ var regCfg = {
"130100":"石家庄" "130100":"石家庄"
}, },
baiduAreaCode = { baiduAreaCode : {
"上海": "310100", "上海": "310100",
"东莞": "441900", "东莞": "441900",
"佛山": "440600", "佛山": "440600",
...@@ -89,7 +89,7 @@ var regCfg = { ...@@ -89,7 +89,7 @@ var regCfg = {
"哈尔滨":"230100", "哈尔滨":"230100",
"石家庄":"130100" "石家庄":"130100"
}, },
channel_type_code = { channelTypeCode : {
"gszc" : "baidu.gszc", "gszc" : "baidu.gszc",
"kzfw" : "baidu.kzfw", "kzfw" : "baidu.kzfw",
"gsbg" : "baidu.gsbg", "gsbg" : "baidu.gsbg",
...@@ -98,7 +98,7 @@ var regCfg = { ...@@ -98,7 +98,7 @@ var regCfg = {
"swbd" : "baidu.swbd" "swbd" : "baidu.swbd"
}, },
//区分渠道的uappid //区分渠道的uappid
uappId = { uappId : {
'ali':18, 'ali':18,
'baidu':44 'baidu':44
}, },
......
...@@ -13,6 +13,7 @@ class RegCenterOrderService extends AppServiceBase { ...@@ -13,6 +13,7 @@ class RegCenterOrderService extends AppServiceBase {
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve"); this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
this.opPushQueueUrl = settings.opPushQueueUrl(); this.opPushQueueUrl = settings.opPushQueueUrl();
this.baiduclient = system.getObject("util.baiduClient"); this.baiduclient = system.getObject("util.baiduClient");
this.baiduRegclient = system.getObject("util.baiduRegclient");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve"); this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
}; };
//调用center-order //调用center-order
...@@ -107,7 +108,7 @@ async regPaySuccess(pobj) { ...@@ -107,7 +108,7 @@ async regPaySuccess(pobj) {
pobj.actionBody.needId = solutiondata.data.channelNeedNo; pobj.actionBody.needId = solutiondata.data.channelNeedNo;
} }
if (pobj.actionBody.channelItemCode) { if (pobj.actionBody.channelItemCode) {
pobj.actionBody.channelItemCode = regCfg.channel_type_code[pobj.actionBody.channelItemCode]; pobj.actionBody.channelItemCode = regCfg.channelTypeCode[pobj.actionBody.channelItemCode];
} }
var fqobj = { var fqobj = {
actionBody: { actionBody: {
...@@ -220,7 +221,7 @@ async regPaySuccess(pobj) { ...@@ -220,7 +221,7 @@ async regPaySuccess(pobj) {
pobj.actionBody.channel_type_name = data.data.channel_type_name; pobj.actionBody.channel_type_name = data.data.channel_type_name;
pobj.actionBody.type = pobj.actionBody.channel_type_code; pobj.actionBody.type = pobj.actionBody.channel_type_code;
if (pobj.actionBody.channel_type_code) { if (pobj.actionBody.channel_type_code) {
pobj.actionBody.channel_type_code = regCfg.channel_type_code[pobj.actionBody.channel_type_code] pobj.actionBody.channel_type_code = regCfg.channelTypeCode[pobj.actionBody.channel_type_code]
} }
if (pobj.actionBody.description && pobj.actionBody.description.indexOf("备#") < 0) { if (pobj.actionBody.description && pobj.actionBody.description.indexOf("备#") < 0) {
pobj.actionBody.level = "A"; pobj.actionBody.level = "A";
...@@ -353,37 +354,63 @@ async regOrderClose(pobj) { ...@@ -353,37 +354,63 @@ async regOrderClose(pobj) {
return rtn; return rtn;
} }
//提交reg注册方案 //提交reg注册方案
async submitSolution(pobj) { async submitRegSolution(pobj) {
var res = await this.reqCenterOrderApi(pobj, "action/regCenterOrder/springBoard"); console.log('reg --- pobj -----',pobj)
if (res && res.status == 0 && res.data && res.data.needinfo && res.data.needsolution) { var res = await this.reqCenterOrderApi(pobj, "action/regapi/springBoard");
if (res && res.status == 0 && res.data && res.data.needinfo && res.data.needsolutions) {
console.log('reg --- res -----',res)
var needinfo = res.data.needinfo;//需求信息 var needinfo = res.data.needinfo;//需求信息
var needsolution = res.data.needsolution;//方案信息 var needsolutions = res.data.needsolutions;//方案信息
var ab = pobj.actionBody; // var ab = pobj.actionBody;
if (typeof (ab.solutionContent) == "string") { // if (typeof (ab.solutionContent) == "string") {
ab.solutionContent = JSON.parse(ab.solutionContent); // ab.solutionContent = JSON.parse(ab.solutionContent);
} // }
if (typeof (needsolution.solutionContent) == "string") { // if (typeof (needsolutions.solutionContent) == "string") {
needsolution.solutionContent = JSON.parse(needsolution.solutionContent); // needsolutions.solutionContent = JSON.parse(needsolutions.solutionContent);
} // }
var solution = needsolution.solutionContent.solution; // var solution = needsolutions.solutionContent.solution;
var self = this; var self = this;
if(needinfo.uapp_id == regCfg.uappId.baidu){ if(needinfo.uapp_id == regCfg.uappId.baidu){
//推送数据至baidu //推送数据至baidu
solution.Area = regCfg.baiduAreaCode[solution.Area] // solution.Area = regCfg.baiduAreaCode[solution.Area]
console.log('solution.Area++',solution.Area) // console.log('solution.Area++',solution.Area)
// var pushObj = {
// intentionBizId: needinfo.channelNeedNo,
// solutionList:{
// gsbBizId:"",
// bizType:"",
// solutionContent:""
// },
// };
var i=0;
var needsolutionsLength = needsolutions.length;
var bizTypes;
var solutionList = [];
for(i=0;i<needsolutionsLength;i++){
bizTypes = needsolutions[i].solutionContent;
console.log('bizTypes-----',bizTypes)
bizTypes = JSON.parse(bizTypes)
console.log('bizTypes++++',bizTypes)
bizTypes.solution.serviceArea = regCfg.baiduAreaCode[bizTypes.solution.serviceArea]
var list = {
gsbBizId:needsolutions[i].solutionNo,
bizType:bizTypes.bizType,
solutionContent:bizTypes.solution
}
solutionList.push(list)
}
var pushObj = { var pushObj = {
requirementId: needinfo.channelNeedNo, intentionBizId: needinfo.channelNeedNo,
companyName: solution.CompanyName, solutionList:solutionList
companyAddress: solution.CompanyAddress,
area: solution.Area,
type:solution.IcpType
}; };
if (needsolution.channelSolutionNo) { console.log('pushObj---pushObj---',pushObj)
pushObj["bizId"] = needsolution.channelSolutionNo; // if (needsolutions.channelSolutionNo) {
} // pushObj["bizId"] = needsolutions.channelSolutionNo;
console.log('pushObj++',pushObj) // }
var pushBaiduRegSolution = await this.pushBaiduRegSolution(pushObj, needsolution.solutionNo, pobj.appInfo, self); var pushBaiduRegSolution = await this.pushBaiduRegSolution(pushObj, needsolutions.solutionNo, pobj.appInfo, self);
console.log('pushBaiduRegSolution+++',pushBaiduRegSolution) console.log('pushBaiduRegSolution+++',pushBaiduRegSolution)
} }
this.logCtl.info({ this.logCtl.info({
...@@ -414,7 +441,7 @@ async regOrderClose(pobj) { ...@@ -414,7 +441,7 @@ async regOrderClose(pobj) {
async pushBaiduRegSolution(pushObj, solutionNo, appInfo, self) { async pushBaiduRegSolution(pushObj, solutionNo, appInfo, self) {
console.log('pushObj++baidu+++',pushObj) console.log('pushObj++baidu+++',pushObj)
//推送方案信息 //推送方案信息
var pushRes = await self.baiduclient.baiduReqbyget({ path: "/api/bla/provider/plan", reqbody: pushObj }); var pushRes = await self.baiduRegclient.baiduReqbyget({ path: "/v1/provider/demand?submitSolutions=", reqbody: pushObj });
console.log("pushRes++++",pushRes) console.log("pushRes++++",pushRes)
if (pushRes && pushRes.status == 0 && pushRes.data) { if (pushRes && pushRes.status == 0 && pushRes.data) {
var resData = pushRes.data; var resData = pushRes.data;
......
const crypto = require('crypto');
const sha256 = require('sha256');
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.baiduRegClientParams = settings.baiduRegClientParams();
}
//2020 1027 laolan 调用百度网关
async baiduPost( path, actionBody) {
console.log('actionBody++',actionBody)
let domain = this.baiduRegClientParams.domain;
let url = domain+path;
let version ="bce-auth-v1";
let accessKey = this.baiduRegClientParams.accessKey;
let secretKey = this.baiduRegClientParams.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:"+this.baiduRegClientParams.host;
//中间结果1:规范化请求和前缀字符串
var canonicalRequest = null
var pathParams = path.split("?");
if(pathParams && pathParams.length > 1){
canonicalRequest = "POST" + "\n" + pathParams[0] + "\n" + pathParams[1] + "\n" + canonicalHeaders;
}else{
canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders;
}
// let canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders;
console.log('canonicalRequest+++++++',canonicalRequest)
//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);
console.log("baiduObj+++++",baiduObj)
console.log("url+++++",url)
console.log("rtn+++++",rtn)
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
//百度接口 2020-10-27 laolan
async baiduReqbyget(obj, cbk) {
var path = obj.path;
var reqbody = obj.reqbody;
try {
var res = await this.baiduPost( path, reqbody, {
timeout: 10000, // default 3000 ms 修改3000为10000,原因ConfirmIcpIntention BizIds 超过5条会超时
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'POST', // set the http method, default is GET
headers: {
host:this.baiduRegClientParams.host
}, // set the http request headers
});
console.log('baidu++++res+++',res)
this.pushlogSve.createDb({
op: "new-baiduRegReqbyget",
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-baiduRegReqbyget推送百度信息返回异常",
pushNumber: obj.pushNumber || 1
});
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
}
}
module.exports = baiduClient;
// var task = new baiduClient();
// console.log(task.baiduRegClientParams,"11111111111111111");
\ No newline at end of file
...@@ -17,7 +17,9 @@ module.exports = { ...@@ -17,7 +17,9 @@ module.exports = {
"ncSubmitMaterial","ncNotification","ncSubmitSolution","ncCloseNeed","ncClosePlan", "ncSubmitMaterial","ncNotification","ncSubmitSolution","ncCloseNeed","ncClosePlan",
"rtSubmitMaterial","rtNotification","rtSubmitSolution","rtCloseNeed","rtClosePlan", "rtSubmitMaterial","rtNotification","rtSubmitSolution","rtCloseNeed","rtClosePlan",
"getParamsFor360", "addOrderWeb", "getPayRecords", "getLoginInfo", "putUserMobileByVcode", "getParamsFor360", "addOrderWeb", "getPayRecords", "getLoginInfo", "putUserMobileByVcode",
"putUserPwdByMobile", "icpNotifyNew" "putUserPwdByMobile", "icpNotifyNew",
//百度工商注册
"submitRegSolution","writeRegCommunicationLog","queryExpertRegCommunicationLogs","updateOrdertatus","closeBdRegNeed"
], ],
apiMustUserpinList: [ apiMustUserpinList: [
"icpOrderClose", "icpOrderClose",
...@@ -25,6 +27,8 @@ module.exports = { ...@@ -25,6 +27,8 @@ module.exports = {
"submitService","serviceProviderNotification", "submitService","serviceProviderNotification",
"ncSubmitMaterial","ncNotification","ncSubmitSolution","ncCloseNeed","ncClosePlan", "ncSubmitMaterial","ncNotification","ncSubmitSolution","ncCloseNeed","ncClosePlan",
"rtSubmitMaterial","rtNotification","rtSubmitSolution","rtCloseNeed","rtClosePlan", "rtSubmitMaterial","rtNotification","rtSubmitSolution","rtCloseNeed","rtClosePlan",
//百度工商注册
"submitRegSolution","writeRegCommunicationLog","queryExpertRegCommunicationLogs","updateOrdertatus","closeBdRegNeed"
], ],
apiSecretPathList: ["/api/icp/consultation/submit","/api/icp/feedback/submit","/api/icp/order/notify","/api/opreceive/service/create","/api/icp/order/close","/api/opreceive/service/notify","/api/icp/queueNotify/springBoard",] apiSecretPathList: ["/api/icp/consultation/submit","/api/icp/feedback/submit","/api/icp/order/notify","/api/opreceive/service/create","/api/icp/order/close","/api/opreceive/service/notify","/api/icp/queueNotify/springBoard",]
} }
......
...@@ -30,6 +30,7 @@ var settings = { ...@@ -30,6 +30,7 @@ var settings = {
} }
return "http://43.247.184.94:7200/center_channel_req_log/_doc?pretty"; return "http://43.247.184.94:7200/center_channel_req_log/_doc?pretty";
}, },
//百度icp、edi、nc、rt
baiduClientParams: function () { baiduClientParams: function () {
if (this.env == 'dev') { if (this.env == 'dev') {
return { return {
...@@ -46,6 +47,23 @@ var settings = { ...@@ -46,6 +47,23 @@ var settings = {
host:"gwgp-nbzljnwusrw.i.bdcloudapi.com" host:"gwgp-nbzljnwusrw.i.bdcloudapi.com"
}; };
}, },
//百度工商注册
baiduRegClientParams: 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"
};
},
//工商核名请求接口配置 //工商核名请求接口配置
checkIcNameUrl() { checkIcNameUrl() {
if (this.env === 'localhost') { if (this.env === 'localhost') {
......
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