Commit dd41fcfd by 宋毅

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

parents af610a79 0b0b22af
......@@ -17,6 +17,42 @@ const uappId = {
'ali':"18", //(阿里icp、edi)
'baidu':"44" //(百度icp、edi)
}
const city = {
"1":"北京",
"2":"上海",
"3":"福建",
"4":"广西",
"5":"广东",
"6":"安徽",
"7":"河南",
"8":"湖北",
"9":"浙江",
"10":"江苏",
"11":"山东",
"12":"陕西",
"13":"宁夏",
"14":"甘肃",
"15":"新疆",
"16":"青海",
"17":"天津",
"18":"重庆",
"19":"河北",
"20":"山西",
"21":"辽宁",
"22":"吉林",
"23":"黑龙江",
"24":"江西",
"25":"湖南",
"26":"四川",
"27":"贵州",
"28":"云南",
"29":"内蒙古",
"30":"西藏",
"31":"含外资",
"32":"全外资",
"33":"香港",
"34":"海南"
}
/**
* 资质信息提报相关接口(ICP\EDI)
*/
......@@ -96,6 +132,7 @@ class BaseCenterOrderService extends AppServiceBase {
if (needsolution.channelSolutionNo) {
pushObj["bizId"] = needsolution.channelSolutionNo;
}
console.log('pushObj++',pushObj)
var pushIcpSolutionRes = await this.pushBaiduIcpSolution(pushObj, needsolution.solutionNo, pobj.appInfo, self);
}
......@@ -176,6 +213,7 @@ class BaseCenterOrderService extends AppServiceBase {
//推送ICP方案baidu 2020-10-26 laolan
async pushBaiduIcpSolution(pushObj, solutionNo, appInfo, self) {
console.log('pushObj++baidu+++',pushObj)
//推送方案信息
var pushRes = await self.baiduclient.baiduReqbyget({ path: "/api/bla/provider/plan", reqbody: pushObj });
console.log("pushRes++++",pushRes)
......@@ -191,7 +229,7 @@ class BaseCenterOrderService extends AppServiceBase {
}
};
var a = await self.reqCenterOrderApi(reqObj2);//保存渠道方案id
return pushRes;
return system.getResultSuccess();
}
}
}
......
......@@ -614,6 +614,7 @@ class CenterorderService extends AppServiceBase {
},
appInfo: pobj.appInfo
}
var baiduPushRes = await this.utilsPushSve.baiduBusiness2Fq(fqobj, "pushOrderICPBusinessNew");
var deliveryObj = {
actionBody: {
orderNo: orderrtn.data.orderNo,//pobj.actionBody.channelOrder.channelOrderNo,
......@@ -627,9 +628,35 @@ class CenterorderService extends AppServiceBase {
}
},
appInfo: pobj.appInfo
};
if(pobj.actionBody.isDirectBuy && pobj.actionBody.isDirectBuy==1){//直接下单需执行添加订单业务员操作
if(baiduPushRes && baiduPushRes.status==0){
if(baiduPushRes.data && baiduPushRes.data.data){
var resData = baiduPushRes.data.data;
var salesmanInfo = {
salesmanName:resData.orderList && resData.orderList.length>0?resData.orderList[0].operatorName:"",
salesmanChannelId:resData.orderList && resData.orderList.length>0?resData.orderList[0].operator:"",
};
var salesmanObj={
appInfo:pobj.appInfo,
actionType:"addIcpSalesmanInfo",//添加业务员信息
actionBody:{salesmanInfo:salesmanInfo,orderNo:orderrtn.data.orderNo}
};
var url = settings.centerOrderUrl() + "action/qcapi/springBoard";
var addRes = await this.execClient.execPost(salesmanObj, url);
if (addRes && addRes.stdout) {
var salesmanRes = JSON.parse(addRes.stdout);
if (salesmanRes.status == 0) {
deliveryObj.needsolution = salesmanRes.data;
await this.utilsPushSve.baiduBusiness2Delivery(deliveryObj, "pushDeliveryOrder");
}
}
}
}
}else{
this.utilsPushSve.baiduBusiness2Delivery(deliveryObj, "pushDeliveryOrder");
}
this.utilsPushSve.baiduBusiness2Fq(fqobj, "pushOrderICPBusinessNew");
this.utilsPushSve.baiduBusiness2Delivery(deliveryObj, "pushDeliveryOrder");
return system.getResultSuccess();
}
}
......
......@@ -87,8 +87,12 @@ class SignService{
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey] && !(params[tKey] instanceof Array)) {
signArr.push(tKey + "=" + params[tKey]);
if (tKey != "sign" && params[tKey]) {
let tmpKeyValue = params[tKey];
if (tmpKeyValue instanceof Array || tmpKeyValue instanceof Object) {
tmpKeyValue = JSON.stringify(tmpKeyValue);
}
signArr.push(tKey + "=" + tmpKeyValue);
}
}
if (signArr.length == 0) {
......@@ -98,10 +102,10 @@ class SignService{
var resultTmpSign = md5(resultSignStr).toUpperCase();
return system.getResultSuccess(resultTmpSign);
}
}
module.exports = SignService;
// var task = new SignService();
var task = new SignService();
// var obj = {
// "intentionBizId": "TRE-nmnHtEoTjeEtest",
// "phone": "13126673246",
......@@ -113,3 +117,23 @@ module.exports = SignService;
// task.createSign(obj,"7cbb892450174167b5c7e01we4716t51").then(d=>{
// console.log(d,"!!!!!!!!!!!!!!!!!!!!!!!!!!");
// });
// var obj = {
// "bizId":"202011031421",
// "contactName":"lin",
// "contactMobile":"13911391996",
// "timeUnit":"year",
// "quantity":1,
// "companyInfo":{
// "companyName":"公司宝",
// "taxpayerType":"NORMAL_TAXPAYER",
// "acctgSystemId":"10001",
// "companyForm":"1",
// "industry":"1",
// "taxpayerNumber":"123456789",
// "companyArea":"北京"
// }
// }
// task.createSign(obj,"7cbb892450174167b5c7e01we4717z51").then(d=>{
// console.log(d,"!!!!!!!!!!!!!!!!!!!!!!!!!!");
// });
\ No newline at end of file
......@@ -87,7 +87,7 @@ class UtilsFqAliyunService extends AppServiceBase {
if (rtn.code != 200 && rtn.success != true) {
return system.getResult(null, "推送失败,失败原因:" + rtn.errorMsg + ",selfrequestId=" + pobj.requestId + ",requestId=" + rtn.requestId);
}
return system.getResultSuccess(null, "推送成功");
return system.getResultSuccess(rtn.data, "推送成功");
} catch (e) {
//日志记录
this.logCtl.error({
......
......@@ -620,8 +620,13 @@ class UtilsNeedService2 extends AppServiceBase {
* @param {*} actionBody
*/
async queryIntentionList(pobj, actionBody) {
var aliResult = await self.aliclient.reqbyget({ action: "QueryIntentionList", reqbody: actionBody, apiVersion: "2019-05-08" });
if (aliResult.code == 200) {
if(pobj.appInfo.uapp_id = uappId.ali){
var result = await self.aliclient.reqbyget({ action: "QueryIntentionList", reqbody: actionBody, apiVersion: "2019-05-08" });
}
if(pobj.appInfo.uapp_id = uappId.baidu){
var result = await self.baiduclient.baiduReqbyget({ path: "api/bla/provider/requirement/list", reqbody: actionBody });
}
if (result.code == 200) {
return system.getResultSuccess();
} else {
return system.getResult(null, "查询失败 10420");
......
......@@ -936,7 +936,8 @@ class UtilsOrderService extends AppServiceBase {
uapp_id: appInfo.uapp_id,
uapp_key: appInfo.uapp_key,
app_code: appInfo.app_code,
app_name: appInfo.app_name
app_name: appInfo.app_name,
contact_mobile:appInfo.contact_mobile
};
opOrderResult.data.userInfo = {
channel_userid: opOrderResult.data.order_info.channelUserId,
......@@ -954,9 +955,18 @@ class UtilsOrderService extends AppServiceBase {
actionBody: opOrderResult.data
}
// 推送
this.utilsPushSve.pushBusInfo(pobj, "pushOrder", 0);
let yfRet = await this.utilsPushSve.pushBusInfo(pobj, "pushOrder", 0);
if(yfRet.status !=0){
return yfRet;
}
if (['icpsq', 'edisq'].includes(opOrderResult.data.product_info.channel_item_code)) {
//创建方案
pobj.salesmanInfo ={
"salesmanId":yfRet.data.orderList[0].operator || "",
"salesmanName":yfRet.data.orderList[0].operatorName || "",
"salesmanMobile":yfRet.data.orderList[0].phone ||"",
"salesmanChannelId":yfRet.data.orderList[0].channelUserId || ""
}
let pushRet = await this.packagingPushData(pobj);
if (pushRet.status != 0) {
throw new Error('推送失败')
......@@ -997,7 +1007,7 @@ class UtilsOrderService extends AppServiceBase {
"CompanyName": "",
"licenseType": "",
"solutionCity": ab.product_info.price_item.price_desc,
"solutionPrice": ab.order_info.totalSum,
"solutionPrice": Number(ab.order_info.totalSum)*100,
"channelTypeCode": ab.product_info.service_business_code,
"companyLocation": ab.product_info.price_item.price_desc
}
......@@ -1005,14 +1015,15 @@ class UtilsOrderService extends AppServiceBase {
"status": "USER_PAY_PRODUCE",
"bizType": ab.product_info.channel_item_code,
"solution": solution,
"totalSum": ab.order_info.totalSum,
"totalSum": Number(ab.order_info.totalSum)*100,
"typeCode": ab.product_info.channel_item_code,
"typeName": ab.product_info.channel_item_name,
"statusName": "⽤户⽀付",
"customerInfo": {
"publishName": "",
"publishMobile": ""
}
"publishName": ab.order_contact.contactName || "",
"publishMobile": ab.order_contact.mobile || ""
},
"salesmanInfo":pobj.salesmanInfo
}
//推送数据
let pushObj = {
......
......@@ -63,10 +63,19 @@ class UtilsPushService extends AppServiceBase {
return system.getResult(null, "暂无【" + opType + "】的推送配置");
}
var self = this;
for (let index = 0; index < interface_list_temp.length; index++) {
const element = interface_list_temp[index];
await self.reflexAction(element, opType, pobj, isDelProductInfo);
let result;
if(interface_list_temp && interface_list_temp.length==1){
const element = interface_list_temp[0];
var reflexActionRes = await self.reflexAction(element, opType, pobj, isDelProductInfo);
return reflexActionRes;
}else{
for (let index = 0; index < interface_list_temp.length; index++) {
const element = interface_list_temp[index];
result = await self.reflexAction(element, opType, pobj, isDelProductInfo);
}
return result;
}
}
async againPushBusInfo(pobj) {//再次推送业务总入口-重试
......@@ -97,7 +106,8 @@ class UtilsPushService extends AppServiceBase {
}
pobj.interface_params = interface_info.params;
var params = [pobj];
invokeObj[interface_info.method_name].apply(invokeObj, params);
var doRes = await invokeObj[interface_info.method_name].apply(invokeObj, params);
return doRes;
}
else if (interface_info.interface_type == "yc") {
var actionBody = pobj.actionBody;
......@@ -142,8 +152,8 @@ class UtilsPushService extends AppServiceBase {
optitle: pobj.opType + "推送蜂擎获取的接口信息->baiduBusiness2Fq",
});
if (pobj.interface_info) {
await this.pushBusInfo(pobj, opType, 1);
return system.getResultSuccess();
var pushBusInfo = await this.pushBusInfo(pobj, opType, 1);
return system.getResultSuccess(pushBusInfo);
}
return system.getResult(null, "push Fail,interface_info data is empty");
}
......
......@@ -14,54 +14,60 @@ class baiduClient {
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 url = domain+path;
let version ="bce-auth-v1";
let accessKey = "ed0f5c4c7c2d4e87aa335d9b07bf9bd4";
let secretKey = "f600c4e91f6d43998d637401e6e34ef9";
let timestamp = new Date().toISOString()
let site = timestamp.lastIndexOf(".");
timestamp = timestamp.substring(0,site)+"Z"
// let timestamp = "2020-11-05T04:00:00Z"
console.log('timestamp++',timestamp)
let signedHeaders = "host";
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]));
}
// 因为是post,所以CanonicalQueryString为空
// 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)
let canonicalHeaders = "host:gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
//中间结果1:规范化请求和前缀字符串
let canonicalRequest = "POST" + "\n" + path + "\n" + "\n" + canonicalHeaders;
console.log('canonicalRequest+++',canonicalRequest)
//authStringPrefix(前缀字符串,由除sk字段外的签名信息生成)
let authStringPrefix = version+"/"+accessKey+"/"+timestamp+"/"+extime;
console.log('authStringPrefix+++',authStringPrefix)
//中间结果2:派生签名密钥 signingKey
let signingKey = crypto.createHmac('sha256', secretKey)
.update(authStringPrefix)
.digest('hex');
console.log('signingKey+++',signingKey)
//中间结果3:签名摘要 signature
let signature = crypto.createHmac('sha256', signingKey)
.update(canonicalRequest)
.digest('hex');
console.log('signature+++',signature)
//最终结果:认证字符串 authorization
let authorization = authStringPrefix+"/"+signedHeaders+"/"+signature;
console.log('authorization+++',authorization)
var baiduObj={
authorization:authorization,
data:actionBody
}
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)
var rtn = await this.execClient.execBaiduPost(baiduObj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty");
}
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('param+++',param, "______________峰擎---百度云参数_______");
var result = await request.post(path, param);
console.log('result+++',JSON.stringify(result), "______________峰擎---百度云返回结果_______");
console.log('result-------',result);
var result = JSON.parse(rtn.stdout);
return result;
}
......@@ -76,7 +82,9 @@ class baiduClient {
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: {}, // set the http request headers
headers: {
host:"gwgp-mwnn9gk4o4e.i.bdcloudapi.com"
}, // set the http request headers
});
console.log('baidu++++res+++',res)
this.pushlogSve.createDb({
......
......@@ -47,7 +47,7 @@ class ExecClient {
return cmd;
}
FetchBaiduPostCmd(subData, url) {
var data = JSON.stringify(subData);
var data = JSON.stringify(subData.data);
var cmd = this.cmdBaiduPostPattern.replace(/\{data\}/g,
data).replace(/\{url\}/g, url).replace(/\{Authorization\}/g, subData.authorization);
console.log(cmd);
......
......@@ -246,7 +246,7 @@ var settings = {
if (this.env == "dev") {
return "http://180.163.239.98:38085/"// 360测试环境
} else {
return "http://180.163.239.98:38085/"//
return "https://console.e.360.cn/"//
}
},
aliUappId: function () {
......
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