Commit dfea7fbf by 宋毅

tj

parent e39384f2
...@@ -76,7 +76,7 @@ class UtilsOrderService extends AppServiceBase { ...@@ -76,7 +76,7 @@ class UtilsOrderService extends AppServiceBase {
fqobj.actionBody.sku = opResult.data.product_info.price_item.service_code; fqobj.actionBody.sku = opResult.data.product_info.price_item.service_code;
fqobj.actionBody.price_desc = opResult.data.product_info.price_item.price_desc; fqobj.actionBody.price_desc = opResult.data.product_info.price_item.price_desc;
} }
this.execClientNew.execLogs("pushNewFq-3", tmpPobj, "center-channel-utilsOrderSve-pushNewFqByChannelOrderNo-pushBusInfo", "pushOrder", null); this.execClientNew.execLogs("pushNewFq-3", fqobj, "center-channel-utilsOrderSve-pushNewFqByChannelOrderNo-pushBusInfo", "pushOrder", null);
this.utilsPushSve.aliBusiness2Fq(fqobj, "pushOrderBusiness"); this.utilsPushSve.aliBusiness2Fq(fqobj, "pushOrderBusiness");
} }
} }
......
...@@ -2,238 +2,233 @@ const system = require("../../../system"); ...@@ -2,238 +2,233 @@ const system = require("../../../system");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
const querystring = require('querystring'); const querystring = require('querystring');
const AppServiceBase = require("../../app.base"); const AppServiceBase = require("../../app.base");
class UtilsPushService extends AppServiceBase { class UtilsPushService extends AppServiceBase {
constructor() { constructor() {
super(); super();
}; };
async aliBusiness2Delivery(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用 async aliBusiness2Delivery(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
pobj.actionType = "getAppInterface"; pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard"; var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl); var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
pobj.interface_info = productItemInterfaceResult.data; pobj.interface_info = productItemInterfaceResult.data;
//日志记录 //日志记录
this.logCtl.info({ this.logCtl.info({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "", appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "", appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "", requestId: pobj.requestId || "",
op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/aliBusiness2Delivery", op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/aliBusiness2Delivery",
content: JSON.stringify(pobj), content: JSON.stringify(pobj),
resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空", resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空",
optitle: opType + "推送蜂擎获取的接口信息->aliBusiness2Delivery", optitle: opType + "推送蜂擎获取的接口信息->aliBusiness2Delivery",
}); });
if (pobj.interface_info) { if (pobj.interface_info) {
await this.pushBusInfo(pobj, opType, 1); await this.pushBusInfo(pobj, opType, 1);
return system.getResultSuccess(); return system.getResultSuccess();
}
return system.getResult(null, "push Fail,interface_info data is empty");
} }
return system.getResult(null, "push Fail,interface_info data is empty");
}
async business2Channel(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用 async business2Channel(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
console.log("business2Channel++++++++start++++++++++"); console.log("business2Channel++++++++start++++++++++");
console.log(pobj,"business2Channel++++++++++++++++++"); console.log(pobj, "business2Channel++++++++++++++++++");
pobj.actionType = "getAppInterface"; pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard"; var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl); var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
pobj.interface_info = productItemInterfaceResult.data; pobj.interface_info = productItemInterfaceResult.data;
//日志记录 //日志记录
this.logCtl.info({ this.logCtl.info({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "", appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "", appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "", requestId: pobj.requestId || "",
op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/business2Channel", op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/business2Channel",
content: JSON.stringify(pobj), content: JSON.stringify(pobj),
resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空", resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空",
optitle: opType + "推送获取的接口信息->business2Channel", optitle: opType + "推送获取的接口信息->business2Channel",
}); });
if (pobj.interface_info) { if (pobj.interface_info) {
await this.pushBusInfo(pobj, opType, 1); await this.pushBusInfo(pobj, opType, 1);
return system.getResultSuccess(); return system.getResultSuccess();
}
return system.getResult(null, "push Fail,interface_info data is empty");
} }
return system.getResult(null, "push Fail,interface_info data is empty");
}
async aliBusiness2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用 async aliBusiness2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
pobj.actionType = "getAppInterface"; pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard"; var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl); var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
pobj.interface_info = productItemInterfaceResult.data; pobj.interface_info = productItemInterfaceResult.data;
//日志记录 this.execClientNew.execLogs(`${pobj.opType}推送蜂擎获取的接口信息->aliBusiness2Fq->app(getAppInterface)`, pobj, "center-channel-utilsPushSve-aliBusiness2Fq", productItemInterfaceResult.data, null);
this.logCtl.info({ if (pobj.interface_info) {
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "", await this.pushBusInfo(pobj, opType, 1);
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "", return system.getResultSuccess();
requestId: pobj.requestId || "", }
op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/aliBusiness2Fq", return system.getResult(null, "push Fail,interface_info data is empty");
content: JSON.stringify(pobj),
resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空",
optitle: pobj.opType + "推送蜂擎获取的接口信息->aliBusiness2Fq",
});
if (pobj.interface_info) {
await this.pushBusInfo(pobj, opType, 1);
return system.getResultSuccess();
}
return system.getResult(null, "push Fail,interface_info data is empty");
}
async business2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
pobj.interface_info = productItemInterfaceResult.data;
//日志记录
this.logCtl.info({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/business2Fq",
content: JSON.stringify(pobj),
resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空",
optitle: pobj.opType + "推送蜂擎获取的接口信息->business2Fq",
});
if (pobj.interface_info) {
await this.pushBusInfo(pobj, opType, 1);
return system.getResultSuccess();
} }
return system.getResult(null, "push Fail,interface_info data is empty");
}
async pushBusInfo(pobj, opType, isDelProductInfo) {//推送业务总入口,不在db中做配置进行调用 async business2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
console.log(JSON.stringify(pobj), ".......pushBusInfo........................."+opType); pobj.actionType = "getAppInterface";
var interface_list = pobj.interface_info ? pobj.interface_info : pobj.actionBody.product_info.interface_info; var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
if (!interface_list) { var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
return system.getResult(null, "暂无推送配置"); pobj.interface_info = productItemInterfaceResult.data;
} //日志记录
var interface_list_temp = interface_list.filter(f => f.op_type == opType); this.logCtl.info({
console.log(interface_list_temp,"interface_list_temp+++++++++++++++"); appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
if (!interface_list_temp || interface_list_temp.length == 0) { appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
return system.getResult(null, "暂无【" + opType + "】的推送配置"); requestId: pobj.requestId || "",
} op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/business2Fq",
var self = this; content: JSON.stringify(pobj),
let result; resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空",
if (interface_list_temp && interface_list_temp.length == 1) { optitle: pobj.opType + "推送蜂擎获取的接口信息->business2Fq",
const element = interface_list_temp[0]; });
let reflexActionRes = await self.reflexAction(element, opType, pobj, isDelProductInfo); if (pobj.interface_info) {
self.execClientNew.execLogs("pushBusInfo-reflexAction-result:", pobj, "center-channel-reflexAction", reflexActionRes, null); await this.pushBusInfo(pobj, opType, 1);
return reflexActionRes; return system.getResultSuccess();
} else { }
for (let index = 0; index < interface_list_temp.length; index++) { return system.getResult(null, "push Fail,interface_info data is empty");
const element = interface_list_temp[index];
result = await self.reflexAction(element, opType, pobj, isDelProductInfo);
self.execClientNew.execLogs("pushBusInfo-for---reflexAction-result:", pobj, "center-channel-reflexAction", result, null);
}
return result;
} }
} async pushBusInfo(pobj, opType, isDelProductInfo) {//推送业务总入口,不在db中做配置进行调用
console.log(JSON.stringify(pobj), ".......pushBusInfo........................." + opType);
var interface_list = pobj.interface_info ? pobj.interface_info : pobj.actionBody.product_info.interface_info;
if (!interface_list) {
return system.getResult(null, "暂无推送配置");
}
var interface_list_temp = interface_list.filter(f => f.op_type == opType);
console.log(interface_list_temp, "interface_list_temp+++++++++++++++");
if (!interface_list_temp || interface_list_temp.length == 0) {
return system.getResult(null, "暂无【" + opType + "】的推送配置");
}
var self = this;
let result;
if (interface_list_temp && interface_list_temp.length == 1) {
const element = interface_list_temp[0];
let reflexActionRes = await self.reflexAction(element, opType, pobj, isDelProductInfo);
self.execClientNew.execLogs("pushBusInfo-reflexAction-result:", pobj, "center-channel-reflexAction", reflexActionRes, null);
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);
self.execClientNew.execLogs("pushBusInfo-for---reflexAction-result:", pobj, "center-channel-reflexAction", result, null);
}
return result;
}
async againPushBusInfo(pobj) {//再次推送业务总入口-重试
var interface_info = pobj.interface_info ? pobj.interface_info : pobj.actionBody.product_info.interface_info;
if (!interface_info) {
return system.getResult(null, "暂无推送配置");
} }
var result = await this.reflexAction(interface_info, pobj.opType, pobj, pobj.isDelProductInfo || 1);
this.execClientNew.execLogs("againPushBusInfo-reflexAction-result:", pobj, "center-channel-reflexAction", result, null);
if (result.status != 0) {
return result;
}
return system.getResultSuccess();
}
async reflexAction(interface_info, opType, pobj, isDelProductInfo) { async againPushBusInfo(pobj) {//再次推送业务总入口-重试
console.log(interface_info,"reflexAction+++++++++++++++"+opType); var interface_info = pobj.interface_info ? pobj.interface_info : pobj.actionBody.product_info.interface_info;
console.log(pobj,"reflexAction++++++2+++++++++"+opType); if (!interface_info) {
var refResult = null; return system.getResult(null, "暂无推送配置");
pobj.interface_info = interface_info;
pobj.opType = opType;
pobj.isDelProductInfo = isDelProductInfo;
try {
if (interface_info.interface_type == "bd") {
if (!interface_info.method_name) {
return system.getResult(null, "产品接口参数信息有误,100350");
}//操作的方法名称
var invokeObj = system.getObject(interface_info.interface_url);
if (!invokeObj[interface_info.method_name]) {
return system.getResult(null, "产品接口参数方法信息有误,100360");
}
pobj.interface_params = interface_info.params;
var params = [pobj];
var doRes = await invokeObj[interface_info.method_name].apply(invokeObj, params);
return doRes;
}
else if (interface_info.interface_type == "yc") {
var actionBody = pobj.actionBody;
if (!interface_info.interface_url) {
return system.getResult(null, "产品接口interface_url参数不能为空,100370");
}
if (actionBody.product_info && actionBody.product_info.price_list) {
delete actionBody.product_info["price_list"];
} }
if (actionBody.product_info && actionBody.product_info.interface_info) { var result = await this.reflexAction(interface_info, pobj.opType, pobj, pobj.isDelProductInfo || 1);
delete actionBody.product_info["interface_info"]; this.execClientNew.execLogs("againPushBusInfo-reflexAction-result:", pobj, "center-channel-reflexAction", result, null);
if (result.status != 0) {
return result;
} }
if (isDelProductInfo && isDelProductInfo == 1 && actionBody.product_info) { return system.getResultSuccess();
delete actionBody["product_info"]; }
}//是否删除产品信息进行推送
refResult = await this.restPostUrl(pobj.actionBody, interface_info.interface_url); async reflexAction(interface_info, opType, pobj, isDelProductInfo) {
if (refResult.code == 1) { console.log(interface_info, "reflexAction+++++++++++++++" + opType);
refResult.status = 0 console.log(pobj, "reflexAction++++++2+++++++++" + opType);
var refResult = null;
pobj.interface_info = interface_info;
pobj.opType = opType;
pobj.isDelProductInfo = isDelProductInfo;
try {
if (interface_info.interface_type == "bd") {
if (!interface_info.method_name) {
return system.getResult(null, "产品接口参数信息有误,100350");
}//操作的方法名称
var invokeObj = system.getObject(interface_info.interface_url);
if (!invokeObj[interface_info.method_name]) {
return system.getResult(null, "产品接口参数方法信息有误,100360");
}
pobj.interface_params = interface_info.params;
var params = [pobj];
var doRes = await invokeObj[interface_info.method_name].apply(invokeObj, params);
return doRes;
} else if (interface_info.interface_type == "yc") {
var actionBody = pobj.actionBody;
if (!interface_info.interface_url) {
return system.getResult(null, "产品接口interface_url参数不能为空,100370");
}
if (actionBody.product_info && actionBody.product_info.price_list) {
delete actionBody.product_info["price_list"];
}
if (actionBody.product_info && actionBody.product_info.interface_info) {
delete actionBody.product_info["interface_info"];
}
if (isDelProductInfo && isDelProductInfo == 1 && actionBody.product_info) {
delete actionBody["product_info"];
}//是否删除产品信息进行推送
refResult = await this.restPostUrl(pobj.actionBody, interface_info.interface_url);
if (refResult.code == 1) {
refResult.status = 0
}
this.disposePushResult(pobj, refResult, "ycUrlPush->reflexAction->refResult", this.pushlogFailType.NEWRPC);
}
return system.getResultSuccess();
} catch (e) {
var errorResult = system.getResult(null, "送异常-->reflexAction->" + e.stack)
return await this.disposePushResultFail(pobj, errorResult, "数据推送异常-->reflexAction-->errorResult", this.pushlogFailType.FAILLOG);
} }
this.disposePushResult(pobj, refResult, "ycUrlPush->reflexAction->refResult", this.pushlogFailType.NEWRPC);
}
return system.getResultSuccess();
} catch (e) {
var errorResult = system.getResult(null, "送异常-->reflexAction->" + e.stack)
return await this.disposePushResultFail(pobj, errorResult, "数据推送异常-->reflexAction-->errorResult", this.pushlogFailType.FAILLOG);
} }
}
//---------百度---zhuangbing--2020.10.28------start-------------------------------------------- //---------百度---zhuangbing--2020.10.28------start--------------------------------------------
async baiduBusiness2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用 async baiduBusiness2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
pobj.actionType = "getAppInterface"; pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard"; var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl); var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
pobj.interface_info = productItemInterfaceResult.data; pobj.interface_info = productItemInterfaceResult.data;
//日志记录 //日志记录
this.logCtl.info({ this.logCtl.info({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "", appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "", appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "", requestId: pobj.requestId || "",
op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/baiduBusiness2Fq", op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/baiduBusiness2Fq",
content: JSON.stringify(pobj), content: JSON.stringify(pobj),
resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空", resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空",
optitle: pobj.opType + "推送蜂擎获取的接口信息->baiduBusiness2Fq", optitle: pobj.opType + "推送蜂擎获取的接口信息->baiduBusiness2Fq",
pobj:pobj pobj: pobj
}); });
if (pobj.interface_info) { if (pobj.interface_info) {
var pushBusInfo = await this.pushBusInfo(pobj, opType, 1); var pushBusInfo = await this.pushBusInfo(pobj, opType, 1);
return system.getResultSuccess(pushBusInfo); return system.getResultSuccess(pushBusInfo);
}
return system.getResult(null, "push Fail,interface_info data is empty");
} }
return system.getResult(null, "push Fail,interface_info data is empty");
} async baiduBusiness2Delivery(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
async baiduBusiness2Delivery(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用 pobj.actionType = "getAppInterface";
pobj.actionType = "getAppInterface"; var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard"; var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl); pobj.interface_info = productItemInterfaceResult.data;
pobj.interface_info = productItemInterfaceResult.data; console.log(pobj, "baiduBusiness2Delivery-zhuangbing------------------------------" + opType);
console.log(pobj,"baiduBusiness2Delivery-zhuangbing------------------------------"+opType); console.log(productItemInterfaceResult);
console.log(productItemInterfaceResult); //日志记录
//日志记录 this.logCtl.info({
this.logCtl.info({ appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "", appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "", requestId: pobj.requestId || "",
requestId: pobj.requestId || "", op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/baiduBusiness2Delivery",
op: "service/impl/utilsSve/utilsPushSve.js/service/app.base.js/baiduBusiness2Delivery", content: JSON.stringify(pobj),
content: JSON.stringify(pobj), resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空",
resultInfo: productItemInterfaceResult.data ? JSON.stringify(productItemInterfaceResult.data) : "接口数据为空", optitle: opType + "推送蜂擎获取的接口信息->baiduBusiness2Delivery",
optitle: opType + "推送蜂擎获取的接口信息->baiduBusiness2Delivery", pobj: pobj
pobj:pobj });
}); if (pobj.interface_info) {
if (pobj.interface_info) { await this.pushBusInfo(pobj, opType, 1);
await this.pushBusInfo(pobj, opType, 1); return system.getResultSuccess();
return system.getResultSuccess(); }
return system.getResult(null, "push Fail,interface_info data is empty");
} }
return system.getResult(null, "push Fail,interface_info data is empty");
} //---------百度---zhuangbing--2020.10.28------end--------------------------------------------
//---------百度---zhuangbing--2020.10.28------end--------------------------------------------
} }
module.exports = UtilsPushService; module.exports = UtilsPushService;
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