Commit 3ceaf19c by 陈思聪

feat:百度工商注册新流程

parent ab84846f
......@@ -80,6 +80,18 @@ class RegAPI extends APIBase {
case "againPushYf"://单独重新推送数据到云服
opResult = await this.utilsPushSve.business2Channel(pobj, pobj.opType);
break;
case "submitGongshangLicense"://百度工商注册新流程接口:公司注册完成后,供应商将营业执照回传百度云
onResult = await this.regCenterOrderSve.submitGongshangLicense(pobj);
break;
case "submitGongshangEngraving"://百度工商注册新流程接口:刻章环节,供应商使用此接口同步刻章信息
onResult = await this.regCenterOrderSve.submitGongshangEngraving(pobj);
break;
case "updateGongshangRegStatus"://百度工商注册新流程接口:将工商注册流程状态更新给百度
onResult = await this.regCenterOrderSve.updateGongshangRegStatus(pobj);
break;
case "submitGongshangMaterial"://百度工商注册新流程接口:供应商变更用户申请材料
onResult = await this.regCenterOrderSve.submitGongshangMaterial(pobj);
break;
//-----------接入百度reg------end----------------------------
default:
opResult = system.getResult(null, "action_type参数错误");
......
......@@ -7,8 +7,30 @@ class Order extends APIBase {
constructor() {
super();
this.gatewaypushlogSve = system.getObject("service.common.gatewaypushlogSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
}
// 20220423 baidu 工商注册新流程 提交公司注册申请材料 baidu->公司宝
async submitMaterial(pobj,req){
console.log(">>> 提交工商注册申请材料 start...",pobj)
this.execClientNew.execLogs(`>>> 提交工商注册申请材料 start...`, pobj, "center-channel-order-submitMaterial", null, null);
if(!pobj){
return regCfg.getResultFail("orderNo不能为空");
}
// 将数据推送到资质宝
var deliveryObj = {
actionBody: {
...pobj,
servicer: {
code: 'gsb',
name: '公司宝'
}
},
appInfo: pobj.appInfo
};
await this.utilsPushSve.business2Channel(deliveryObj, "pushOrderDeliveryMaterial");
return regCfg.getResultSuccess(param.requestId);
}
//状态变更
async notify(pobj, req) {
......
......@@ -591,6 +591,120 @@ class RegCenterOrderService extends AppServiceBase {
}
/**
* 百度工商注册新流程接口:刻章环节,供应商使用此接口同步刻章信息
*
* @param {*} pobj
*/
async submitGongshangEngraving(pobj) {
const deliveryId = pobj.actionBody.deliveryId
this.execClientNew.execLogs("submitGongshangEngraving-开始:", pobj, "center-channel-submitGongshangEngraving", null, null);
console.log(`>>>>【百度工商注册新流程接口:刻章环节,供应商使用此接口同步刻章信息 ${deliveryId}】submitGongshangEngraving方法开始`, pobj)
// 组装请求参数
let pushObj = {
who :{
accountId: pobj.actionBody.who.accountId,
serviceId: pobj.actionBody.who.serviceId,
},
content: pobj.actionBody.content? pobj.actionBody.content: "公章、财务章、合同章",
status: pobj.actionBody.status,
expressNum: pobj.actionBody.expressNum
};
let baiduParams = {path: "/v1/com/engraving", reqbody: pushObj}
console.log(`>>>>【百度工商注册新流程接口:刻章环节,供应商使用此接口同步刻章信息 交付单id:${deliveryId}】submitGongshangEngraving方法,接口请求参数:`, pushObj)
// 同步刻章信息给百度
let baiduRes = await self.baiduRegClient.baiduReqbyget(baiduParams);
console.log(`>>>>【百度工商注册新流程接口:刻章环节,供应商使用此接口同步刻章信息 交付单id:${deliveryId}】submitGongshangEngraving方法,接口响应:`, baiduRes)
this.execClientNew.execLogs("submitGongshangEngraving-baiduReqbyget:", pobj, "center-channel-submitGongshangEngraving", baiduParams, baiduRes);
return baiduRes;
}
/**
* 百度工商注册新流程接口:公司注册完成后,供应商将营业执照回传百度云
*
* @param {*} pobj
*/
async submitGongshangLicense(pobj) {
const deliveryId = pobj.actionBody.deliveryId
console.log(`>>>>【百度工商注册新流程接口:公司注册完成后,供应商将营业执照回传百度云 ${deliveryId}】submitGongshangLicense方法开始`, pobj)
this.execClientNew.execLogs("submitGongshangLicense-开始:", pobj, "center-channel-submitGongshangLicense", null, null);
// 组装请求参数
let pushObj = {
who :{
accountId: pobj.actionBody.who.accountId,
serviceId: pobj.actionBody.who.serviceId,
},
licenseUrl: pobj.actionBody.licenseUrl
};
let baiduParams = {path: "/v1/com/license", reqbody: pushObj}
console.log(`>>>>【百度工商注册新流程接口:公司注册完成后,供应商将营业执照回传百度云 交付单id:${deliveryId}】submitGongshangLicense方法,接口请求参数:`, pushObj)
// 回传营业执照给百度
let baiduRes = await self.baiduRegClient.baiduReqbyget(baiduParams);
console.log(`>>>>【百度工商注册新流程接口:公司注册完成后,供应商将营业执照回传百度云 交付单id:${deliveryId}】submitGongshangLicense方法,接口响应:`, baiduRes)
this.execClientNew.execLogs("submitGongshangLicense-baiduReqbyget:", pobj, "center-channel-submitGongshangLicense", baiduParams, baiduRes);
return baiduRes;
}
/**
* 百度工商注册新流程接口:将工商注册流程状态更新给百度
*
* @param {*} pobj
*/
async updateGongshangRegStatus(pobj) {
const deliveryId = pobj.actionBody.deliveryId
console.log(`>>>>【百度工商注册新流程接口:将工商注册流程状态更新给百度 ${deliveryId}】updateGongshangRegStatus方法开始`, pobj)
this.execClientNew.execLogs("updateGongshangRegStatus-开始:", pobj, "center-channel-updateGongshangRegStatus", null, null);
// 组装请求参数
let pushObj = {
who :{
accountId: pobj.actionBody.who.accountId,
serviceId: pobj.actionBody.who.serviceId,
},
status: pobj.actionBody.status,
msg: null,
detail: null
};
let baiduParams = {path: "/v1/com/status", reqbody: pushObj}
console.log(`>>>>【百度工商注册新流程接口:将工商注册流程状态更新给百度 交付单id:${deliveryId}】updateGongshangRegStatus方法,接口请求参数:`, pushObj)
// 同步工商注册流程最新状态给百度
let baiduRes = await self.baiduRegClient.baiduReqbyput(baiduParams);
console.log(`>>>>【百度工商注册新流程接口:将工商注册流程状态更新给百度 交付单id:${deliveryId}】updateGongshangRegStatus方法,接口响应:`, baiduRes)
this.execClientNew.execLogs("updateGongshangRegStatus-baiduReqbyput:", pobj, "center-channel-updateGongshangRegStatus", baiduParams, baiduRes);
return baiduRes;
}
/**
* 供应商变更用户申请材料
* @param {*} pobj
*/
async submitGongshangMaterial(pobj){
const deliveryId = pobj.actionBody.deliveryId
console.log(`>>>>【百度工商注册新流程接口:供应商变更用户申请材料 ${deliveryId}】submitGongshangMaterial`, pobj)
this.execClientNew.execLogs("submitGongshangMaterial-开始:", pobj, "center-channel-submitGongshangMaterial", null, null);
// 组装请求参数
let pushObj = {
who: pobj.actionBody.deliverContent.companyInfo.channelMaterials.who, // 目标
com: pobj.actionBody.deliverContent.companyInfo.channelMaterials.com, // 公司基本信息
receiver: pobj.actionBody.deliverContent.companyInfo.channelMaterials.receiver, // 邮寄地址
shareholders: pobj.actionBody.deliverContent.companyInfo.channelMaterials.shareholders, // 股东信息
members:pobj.actionBody.deliverContent.companyInfo.channelMaterials.members // 主要人员信息
};
let baiduParams = {path: "/v1/com/application-material", reqbody: pushObj}
console.log(`>>>>【百度工商注册新流程接口:供应商变更用户申请材料 交付单id:${deliveryId}】submitGongshangLicense方法,接口请求参数:`, pushObj)
// 推送交付信息
let baiduRes = await self.baiduRegClient.baiduReqbyput(baiduParams);
console.log(`>>>>【百度工商注册新流程接口:供应商变更用户申请材料 交付单id:${deliveryId}】submitGongshangLicense方法,接口响应:`, baiduRes)
this.execClientNew.execLogs("submitGongshangMaterial-baiduReqbyput:", pobj, "center-channel-submitGongshangMaterial", baiduParams, baiduRes);
return baiduRes;
}
//提交交付信息/修改订单状态
async regUpdateOrderStatus(pobj) {
let self = this;
......@@ -613,6 +727,24 @@ class RegCenterOrderService extends AppServiceBase {
if (res.data.uapp_id == regCfg.uappId.baidu) {
//2021-5-18新增套餐公司注册与正常公司注册区分
if (pobj.actionBody.consultType && pobj.actionBody.consultType == "GSREG") {
// if(pobj.actionBody.deliverContent.comapnyInfo && pobj.actionBody.deliverContent.comapnyInfo.channelMaterials && pobj.actionBody.deliverContent.comapnyInfo.channelMaterials.who){
// // 20220425 如果传过来的交付内容中包含who,说明是要调百度新工商注册流程接口
// console.log('调用百度新工商注册流程接口更新材料信息')
// pushObj = {
// who: pobj.actionBody.deliverContent.companyInfo.channelMaterials.who, // 目标
// com: pobj.actionBody.deliverContent.companyInfo.channelMaterials.com, // 公司基本信息
// receiver: pobj.actionBody.deliverContent.companyInfo.channelMaterials.receiver, // 邮寄地址
// shareholders: pobj.actionBody.deliverContent.companyInfo.channelMaterials.shareholders, // 股东信息
// members:pobj.actionBody.deliverContent.companyInfo.channelMaterials.members // 主要人员信息
// }
// let baiduParams = {path: "/v1/com/application-material", reqbody: pushObj}
// //推送交付信息/修改订单状态
// let baidu = await self.baiduRegClient.baiduReqbyput(baiduParams);
// this.execClientNew.execLogs("regUpdateOrderStatus-baiduReqbyput:", baiduParams, "center-channel-regUpdateOrderStatus-application-material", baidu, null);
// return baidu
// }
//推送正常公司注册数据至百度
pushObj = {
orderNo: res.data.bizId,
......
......@@ -62,6 +62,58 @@ class baiduRegClient {
return result;
}
//2022 chensc put调用百度网关
async baiduPut( 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 = "PUT" + "\n" + pathParams[0] + "\n" + pathParams[1] + "\n" + canonicalHeaders;
}else{
canonicalRequest = "PUT" + "\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);
this.execClientNew.execLogs("api-center-channel-baiduPut:"+url, baiduObj, "center-channel-baiduPut", rtn, null);
// console.log("baiduObj+++++",baiduObj)
// console.log("url+++++",url)
// console.log("rtn+++++",rtn)
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPut data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
//百度接口 2020-10-27 laolan
async baiduReqbyget(obj, cbk) {
var path = obj.path;
......@@ -101,6 +153,46 @@ class baiduRegClient {
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
}
//百度接口 2022-04-23
async baiduReqbyput(obj, cbk) {
var path = obj.path;
var reqbody = obj.reqbody;
try {
var res = await this.baiduPut( 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: 'PUT', // set the http method, default is GET
headers: {
host:this.baiduRegClientParams.host
}, // set the http request headers
});
console.log('baiduReqbyput++++res+++',res)
this.pushlogSve.createDb({
op: "new-baiduRegReqbyput",
content: JSON.stringify(obj),//推送的参数信息
resultInfo: JSON.stringify(res),
returnType: '1',
logLevel: '1',
opTitle: "new-baiduReqbyput推送百度信息返回成功"
});
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-baiduRegReqbyput推送百度信息返回异常",
pushNumber: obj.pushNumber || 1
});
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
}
}
module.exports = baiduRegClient;
// var task = new baiduRegClient();
......
......@@ -17,6 +17,9 @@ class ExecClient {
this.cmdBaiduPostPattern = "curl -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}";
this.cmdBaiduPutPattern = "curl -X PUT -k -H 'Content-type: application/json' -H 'Authorization: {Authorization}' -d '{data}' {url}";
this.cmdGetpatternToken = "curl -G -k -H 'authorization:{token}' -d '{data}' {url}";
//易名
......@@ -64,6 +67,15 @@ class ExecClient {
console.log(cmd);
return cmd;
}
FetchBaiduPutCmd(subData, url) {
var data = JSON.stringify(subData.data);
var cmd = this.cmdBaiduPutPattern.replace(/\{data\}/g,
data).replace(/\{url\}/g, url).replace(/\{Authorization\}/g, subData.authorization);
console.log(cmd);
return cmd;
}
FetchEnamePostCmd(subData, url) {
var data = JSON.stringify(subData);
var cmd = this.cmdEnamePostPattern.replace(/\{data\}/g,
......
......@@ -22,7 +22,7 @@ module.exports = {
//百度工商注册
"regGetInfoByChannelNeedNo", "submitRegNeed", "regFeedbackSubmit", "regOrderStatus", "regOrderClose",
"getSolutionByChannelOrderNo", "regSubmitSolution", "regNeedClose",
"regWriteCommunicationLog", "regQueryExpertCommunicationLogs", "regUpdateOrderStatus", "regPaySuccess",
"regWriteCommunicationLog", "regQueryExpertCommunicationLogs", "regUpdateOrderStatus", "regPaySuccess","submitGongshangLicense","submitGongshangEngraving","updateGongshangRegStatus","submitGongshangMaterial",
//yiming/ename
"eNameCloseOrder",
],
......@@ -36,7 +36,7 @@ module.exports = {
"regGetInfoByChannelNeedNo", "submitRegNeed", "regFeedbackSubmit", "regOrderStatus", "regOrderClose",
// "getSolutionByChannelOrderNo",
"regSubmitSolution", "regNeedClose",
"regWriteCommunicationLog", "regQueryExpertCommunicationLogs", "regUpdateOrderStatus", "regPaySuccess",
"regWriteCommunicationLog", "regQueryExpertCommunicationLogs", "regUpdateOrderStatus", "regPaySuccess","submitGongshangLicense","submitGongshangEngraving","updateGongshangRegStatus",,"submitGongshangMaterial",
//yiming/ename
"eNameCloseOrder",
],
......
......@@ -462,6 +462,13 @@ var settings = {
// 2020 1119 lin 正式环境已经给出,鲁班发的ip
return "http://139.196.159.202:8980/"
}
}
},
icpUrl: function () {
if (this.env == "dev") {
return "http://127.0.0.1:8002" || "http://icp.com:8000";
} else {
return "http://icpdeliver-service";
}
},
};
module.exports = settings;
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