Commit 4f72dd0b by linboxuan

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

parents 4067b167 3e7d9833
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class Need2 extends APIBase {
constructor() {
super();
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
this.centerorderSve = system.getObject("service.common.centerorderSve");
this.utilsNeedSve2 = system.getObject("service.utilsSve.utilsNeedSve2");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_process, action_type, action_body, req) {
pobj.requestId = req.requestId;
var self = this;
var opResult = null;
switch (action_type) {
case "submitNeedH5"://提交需求----del
opResult = await this.utilsNeedSve.submitNeedH5(pobj, pobj.actionBody);
break;
//--------------------------------------跟ali合作---------------------------
case "submitNeed"://提交需求
opResult = await this.utilsNeedSve.submitNeed(pobj, pobj.actionBody);
break;
case "needClose"://关闭需求
opResult = await this.utilsNeedSve.needClose(pobj, pobj.actionBody);
break;
case "needCloseIcp"://关闭需求
opResult = await this.utilsNeedSve.needCloseIcp(pobj, pobj.actionBody);
break;
case "needDetailByChannelNo":
opResult = await this.utilsNeedSve.needDetailByChannelNo(pobj, pobj.actionBody);
break;
case "getItemByChannelNeedNo":
opResult = await this.utilsNeedSve.getItemByChannelNeedNo(pobj, pobj.actionBody);
break;
case "getItemByNeedNo":
opResult = await this.utilsNeedSve.getItemByNeedNo(pobj, pobj.actionBody);
break;
case "receiveFeedback"://接收方案反馈信息
opResult = await this.centerorderSve.reqCenterOrderApi(pobj);
break;
case "getItemByChannelSolutionNo":
opResult = await this.utilsNeedSve.getItemByChannelSolutionNo(pobj, pobj.actionBody);
break;
case "icpFeedbackSubmit"://icp接收方案反馈信息
pobj.actionType = "receiveIcpFeedback";
opResult = await this.utilsNeedSve.reqCenterOrderQcApi(pobj);
break;
case "icpNotify"://icp方案更新
opResult = await this.utilsNeedSve.icpNotify(pobj, pobj.actionBody);
if (opResult.status == 0 && pobj.actionBody.status == 1) {
opResult = await self.centerorderSve.icppaysuccess(pobj, pobj.actionBody);
}
break;
case "writeCommunicationLog"://icp接收方案反馈信息2020-11-2 laolan 写入沟通记录
opResult = await this.utilsNeedSve2.writeCommunicationLog(pobj);
break;
case "queryExpertApplyCommunicationLogs"://icp接收方案反馈信息 2020-11-2 laolan 查询沟通记录
opResult = await this.utilsNeedSve2.queryExpertApplyCommunicationLogs(pobj);
break;
case "getaliicpProduce"://方案询价
opResult = await this.centerorderSve.getaliicpProduce(pobj);
break;
case "submitIcpIntention":// 2020 0827 lin 新增 4.1 提交需求
opResult = await this.utilsNeedSve.submitIcpIntention(pobj, pobj.actionBody);
break;
case "queryIntentionList":// 2020 0827 lin 新增 4.2 需求列表查询
opResult = await this.utilsNeedSve.queryIntentionList(pobj, pobj.actionBody);
break;
case "confirmIcpIntention":// 2020 0827 lin 新增 4.3 用户需求确认
opResult = await this.utilsNeedSve.confirmIcpIntention(pobj, pobj.actionBody);
break;
case "needBatchUpload":// 2020 0914 lin 新增 刷单一条龙服务
opResult = await this.utilsNeedSve.needBatchUpload(pobj, pobj.actionBody);
break;
case "testsymq":
opResult = await this.utilsNeedSve.testsymq(pobj);
break;
//-----------接入百度ICP------start----zhuangbing--2020.10.22----------------------------
case "submitIcpNeed"://提交需求
opResult = await this.utilsNeedSve.submitNeed2(pobj, pobj.actionBody);
break;
case "icpFeedbackSubmitNew"://icp接收方案反馈信息
pobj.actionType = "receiveIcpFeedback";
opResult = await this.utilsNeedSve.reqCenterOrderQcApi(pobj);
break;
case "icpNotifyNew"://icp方案更新
opResult = await this.utilsNeedSve.icpNotifyNew(pobj, pobj.actionBody);
if (opResult.status == 0 && pobj.actionBody.status == 1) {
opResult = await self.centerorderSve.icppaysuccessNew(pobj, pobj.actionBody);
}
break;
//-----------接入百度ICP------end----------------------------------
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = Need2;
\ No newline at end of file
......@@ -87,12 +87,11 @@ class BaseCenterOrderService extends AppServiceBase {
//推送数据至baidu
// var bizType = needinfo.channelTypeCode;//业务类型里
var pushObj = {
intentionBizId: needinfo.channelNeedNo,
requirementId: needinfo.channelNeedNo,
companyName: solution.CompanyName,
icpType: solution.IcpType,
companyAddress: solution.CompanyAddress,
area: solution.Area,
actionType:solution.ActionType
type:solution.ActionType
};
if (needsolution.channelSolutionNo) {
pushObj["bizId"] = needsolution.channelSolutionNo;
......@@ -178,7 +177,8 @@ class BaseCenterOrderService extends AppServiceBase {
//推送ICP方案baidu 2020-10-26 laolan
async pushBaiduIcpSolution(pushObj, solutionNo, appInfo, self) {
//推送方案信息
var pushRes = await self.baiduclient.baiduReqbyget({ action: "submitIcpSolution", reqbody: pushObj });
var pushRes = await self.baiduclient.baiduReqbyget({ path: "/api/bla/provider/plan", reqbody: pushObj });
console.log("pushRes++++",pushRes)
if (pushRes && pushRes.status == 0 && pushRes.data) {
var resData = pushRes.data;
if (resData.bizId) {
......@@ -191,51 +191,13 @@ class BaseCenterOrderService extends AppServiceBase {
}
};
var a = await self.reqCenterOrderApi(reqObj2);//保存渠道方案id
//百度不用我们确认方案,所以注释掉
// if (a && a.status == 0) {
// //推送方案确认信息
// var confirmRes = await self.baiduclient.baiduReqbyget({ action: "confirmIntention", reqbody: { bizId: pushObj.intentionBizId } });
// if (confirmRes && confirmRes.status == 0 && confirmRes.data) {
// var confirmResData = confirmRes.data;
// if (confirmResData.ConfirmUrl) {
// var reqObj3 = {
// actionType: "receiveIcpConfirmUrl",
// appInfo: appInfo,
// actionBody: {
// solutionNo: solutionNo,
// confirmUrl: confirmResData.ConfirmUrl
// }
// };
// var a = await self.reqCenterOrderApi(reqObj3);//保存用户确认方案url
// }
// }
// return confirmRes;
// }
return system.getResultSuccess();
return pushRes;
}
}
}
//服务商icp方案关闭
//服务商icp方案关闭 2020-10-26 laolan
async abolishIcpProgramme(pobj) {
// var res = await this.reqCenterOrderApi(pobj, "action/baseapi/springBoard");
// if (res && res.status == 0 && res.data) {
// var needsolution = res.data;//方案信息
// var ab = pobj.actionBody;
// if (typeof (ab.material) == "string") {
// ab.material = JSON.parse(ab.material);
// }
// //推送数据至阿里
// var pushObj = {
// BizId: ab.BizId, Note: ab.Note
// };
// //关闭方案
// this.aliclient.reqbyget({ action: "CloseIcpProduce", reqbody: pushObj, apiVersion: "2019-05-08" });
// return system.getResultSuccess();
// }
// return res;
//2020-10-26 laolan
var res = await this.reqCenterOrderApi(pobj, "action/baseapi/springBoard");
if (res && res.status == 0 && res.data) {
var needsolution = res.data;//方案信息
......@@ -260,7 +222,7 @@ class BaseCenterOrderService extends AppServiceBase {
note: ab.Note
};
//关闭方案
this.baiduuclient.baiduReqbyget({ action: "closeIcpProduce", reqbody: pushObj });
this.baiduclient.baiduReqbyget({ action: "closeIcpProduce", reqbody: pushObj });
}
return system.getResultSuccess();
}
......@@ -322,7 +284,8 @@ class BaseCenterOrderService extends AppServiceBase {
};
var self = this;
//推送方案材料
self.baiduclient.baiduReqbyget({ action: "savePartnerSubmitMaterial", reqbody: pushObj });
var r = self.baiduclient.baiduReqbyget({ action: "savePartnerSubmitMaterial", reqbody: pushObj });
console.log("r++",res)
}
return system.getResultSuccess();
}
......@@ -360,39 +323,15 @@ class BaseCenterOrderService extends AppServiceBase {
//交付单关闭
async closeOrderDelivery(pobj) {
var res = await this.reqCenterOrderApi(pobj, "action/baseapi/springBoard");
// if (res && res.status == 0 && res.data) {
// var needsolution = res.data;//方案信息
// var ab = pobj.actionBody;
// //推送数据至阿里
// var pushObj = {
// BizId: needsolution.channelSolutionNo, Note: ab.note
// };
// //关闭方案
// this.aliclient.reqbyget({ action: "CloseIcpProduce", reqbody: pushObj, apiVersion: "2019-05-08" });
// return system.getResultSuccess();
// }
//2020-10-27 laolan 区分渠道
if (res && res.status == 0 && res.data) {
var needsolution = res.data;//方案信息
var ab = pobj.actionBody;
var uappIds = res.data.uapp_id;
if(uappIds == uappId.ali){
//推送数据至阿里
var pushObj = {
BizId: needsolution.channelSolutionNo, Note: ab.note
};
//关闭方案
this.aliclient.reqbyget({ action: "CloseIcpProduce", reqbody: pushObj, apiVersion: "2019-05-08" });
}
if(uappIds == uappId.baidu){
//推送数据至baidu
var pushObj = {
bizId: needsolution.channelSolutionNo,
note: ab.note
};
//关闭方案
this.baiduclient.baiduReqbyget({ action: "closeOrder", reqbody: pushObj });
}
//推送数据至阿里
var pushObj = {
BizId: needsolution.channelSolutionNo, Note: ab.note
};
//关闭方案
this.aliclient.reqbyget({ action: "CloseIcpProduce", reqbody: pushObj, apiVersion: "2019-05-08" });
return system.getResultSuccess();
}
return res;
......
......@@ -281,8 +281,7 @@ class UtilsNeedService2 extends AppServiceBase {
});
if (result.status == 0) {
if (result.data) {
// pobj.actionBody.orderNo = result.data;
pobj.actionBody.orderNo = result.data.orderNo;//laolan 2020-10-29
pobj.actionBody.orderNo = result.data;
var orderrtn = await self.utilsOrderSve.delOrder(pobj, pobj.actionBody);
if (orderrtn.status < 0) {
return system.getResultFail(-5022, "订单关闭失败");
......@@ -309,16 +308,9 @@ class UtilsNeedService2 extends AppServiceBase {
resultInfo: "",
optitle: "updateChanceStatus推送蜂擎获取的接口信息->aliBusiness2Delivery",
});
if(result.data.uapp_id == uappId.ali ){
// 推送ali
var a = await self.aliclient.reqbyget({ action: "CloseIntention", reqbody: { BizId: actionBody.channelNeedNo, Note: actionBody.note }, apiVersion: "2019-05-08" });
console.log(a);
}
if(result.data.uapp_id == uappId.ali ){
// 推送baidu
var b = await self.baiduclient.baiduReqbyget({ action: "closeIntention", reqbody: { bizId: actionBody.channelNeedNo, note: actionBody.note } });
console.log(b);
}
self.utilsPushSve.aliBusiness2Fq(pobj, "pushCloseICPNeed");
return system.getResultSuccess();
} else {
......@@ -504,7 +496,7 @@ class UtilsNeedService2 extends AppServiceBase {
return system.getResult(null, "actionBody.note can not be empty,100492");
}
var self = this;
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
var reqUrl = this.centerOrderUrl + "action/need2/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
//2020-10-28 laolan start
if(result && result.status == 0 && result.data && result.data.uappIds){
......@@ -661,10 +653,11 @@ class UtilsNeedService2 extends AppServiceBase {
// if (!pobj.actionBody.userFeedBack) {
// return system.getResult(null, "actionBody.userFeedBack can not be empty,100494");
// }
console.log('xxxqqqq+++chaxun+++',pobj)
pobj.actionBody.data = [];
await this.queryByAli(pobj, 1);
pobj.actionType = "getUnCreated";
let reqUrl = this.centerOrderUrl + "action/need/springBoard";
let reqUrl = this.centerOrderUrl + "action/need2/springBoard";
let result = await this.restPostUrl(pobj, reqUrl);
if (result.status == 0) {
pobj.actionBody = {
......
const co = require("co");
var request = require("request");
const sha256 = require('sha256');
var urlencode = require('urlencode');
const system = require("../system");
class baiduClient {
constructor() {
......@@ -5,35 +9,74 @@ class baiduClient {
}
//2020 1027 laolan 调用百度网关
async baiduPost(baidRreqUrl, accessKeyId, accessKeySecret, endpoint, actionBody) {
accessKeyId = "ff2571490b4c4fb5add57385dc5e8f66";
accessKeySecret = "9d86f04a85db4cdfa95ba8ad28009188";
endpoint = "https://iam.bj.baidubce.com";
async baiduPost( path, actionBody) {
console.log('actionBody++',actionBody)
let domain = "https://gwgp-mwnn9gk4o4e.i.bdcloudapi.com";
let authorization ="bce-auth-v1";
let accessKey = "ff2571490b4c4fb5add57385dc5e8f66";
let secretKey = "9d86f04a85db4cdfa95ba8ad28009188";
let timestamp = new Date().toISOString();
let extime = 1800;
var signArr = [];
var keys = Object.keys(actionBody).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && actionBody[tKey] && !(typeof (actionBody[tKey]) === "object")) {
signArr.push(urlencode(tKey) + "=" + urlencode(actionBody[tKey]));
}
}
let resultSignStr = signArr.join("&");
console.log('resultSignStr+++',resultSignStr)
// SigningKey = HMAC-SHA256-HEX(sk, authStringPrefix)
// authStringPrefix代表认证字符串的前缀部分,即:bce-auth-v1/{accessKeyId}/{timestamp}/{expirationPeriodInSeconds}。
// CanonicalRequest = HTTP Method + "\n" + CanonicalURI + "\n" + CanonicalQueryString + "\n" + CanonicalHeaders
// signature = HMAC-SHA256-HEX(SigningKey,CanonicalRequest)
let authStringPrefix = authorization + "/" + accessKey + "/" + timestamp + "/" + extime;
let signingKey = await sha256(secretKey,authStringPrefix);
let newResultSignStr = resultSignStr.replace(/&/g,',')
let canonicalQueryString = path + ','+ newResultSignStr;
console.log('canonicalQueryString+++',canonicalQueryString)
let canonicalHeaders = {
host:urlencode(domain)
}
let canonicalRequest = "POST" + "\n" + path + "\n" + canonicalQueryString + "\n" + canonicalHeaders + "\n" ;
let signature = await sha256(signingKey,canonicalRequest);
path = domain + path;
console.log('path+++',path)
var param = {
data: actionBody,
timeout: 20000,
headers: {
Authorization: authStringPrefix + "/" + "x-bce-date/" + signature,
accept: 'application/json'
}
};
console.log(JSON.stringify(param), "______________峰擎---百度云参数_______");
var result = await this.baiduPost(baidRreqUrl, param);
console.log(JSON.stringify(result), "______________峰擎---百度云返回结果_______");
console.log('param+++',param, "______________峰擎---百度云参数_______");
var result = await request.post(path, param);
console.log('result+++',JSON.stringify(result), "______________峰擎---百度云返回结果_______");
console.log('result-------',result);
return result;
}
//百度接口 2020-10-27 laolan
async baiduReqbyget(obj, cbk) {
var action = obj.action;
console.log('obj+++',obj)
var path = obj.path;
var reqbody = obj.reqbody;
try {
var reqBaiduClient = null;// { ... this.baiduClient };
var res = await reqBaiduClient.request(action, reqbody, {
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: 'GET', // set the http method, default is GET
method: 'POST', // set the http method, default is GET
headers: {}, // set the http request headers
});
console.log('baidu++++res+++',res)
this.pushlogSve.createDb({
op: "new-baiduReqbyget",
content: JSON.stringify(obj),//推送的参数信息
......
......@@ -18,7 +18,7 @@ module.exports = {
"foodCloseNeed", "foodRecordLog", "foodRecordLogList", "getParamsFor360", "addOrderWeb", "getPayRecords", "getLoginInfo", "putUserMobileByVcode",
"putUserPwdByMobile", "icpNotifyNew"
],
apiMustUserpinList: ["submitNeed", "paySuccess", "icpNotify", "getLoginInfo", "icpNotifyNew"],
apiMustUserpinList: ["submitNeed", "paySuccess", "icpNotify", "getLoginInfo", "icpNotifyNew", "submitIcpProgramme","serviceProviderSubmitMaterial","abolishIcpProgramme"],
apiSecretPathList: ["/api/icp/consultation/submit","/api/icp/feedback/submit","/api/icp/order/notify"]
}
}
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