Commit 8ad7e8fa by 任晓松

update 优化

parent 5f04641f
...@@ -183,7 +183,7 @@ class Order extends APIBase { ...@@ -183,7 +183,7 @@ class Order extends APIBase {
requestUrl: "/icp/order/notify", requestUrl: "/icp/order/notify",
requestjson: JSON.stringify(pobj),//请求地址 requestjson: JSON.stringify(pobj),//请求地址
pushUrl: "/action/intentionapi/springBoard",//调用地址 pushUrl: "/action/intentionapi/springBoard",//调用地址
pushActionType: "icpNotifyNew",//调用参数 pushActionType: "icpOrderStatus",//调用参数
pushtimes: 0,//推送次数 pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态 pushStatus: "wts",//推送状态
} }
......
...@@ -77,37 +77,13 @@ class utils360Sve extends AppServiceBase { ...@@ -77,37 +77,13 @@ class utils360Sve extends AppServiceBase {
} }
let result = await this.restPostUrl(pushObj, url); let result = await this.restPostUrl(pushObj, url);
if (result.code == 200) { if (result.code == 200) {
this.pushlogSve.createDb({ this.disposePushResult(pobj, result, "utils360Sve---pushOrderStatus--推送成功", 4);
op: "360-pushOrderStatus",
content: JSON.stringify(pushObj),//推送的参数信息
resultInfo: JSON.stringify(result),
returnType: '1',
logLevel: 1,
opTitle: "推送360信息返回成功"
});
} else { } else {
this.logCtl.error({ this.disposePushResultFail(pobj, result, "utils360Sve---pushOrderStatus--推送失败", 4);
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushOrderStatus",
content: "error:" + result.msg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
} }
console.log(result, '-------------push360-----------------')
return result; return result;
} catch (e) { } catch (e) {
this.logCtl.error({ this.disposePushResultFail(pobj, e.stack, "utils360Sve---pushOrderStatus", 4);
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushOrderStatus",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
} }
} }
...@@ -132,63 +108,40 @@ class utils360Sve extends AppServiceBase { ...@@ -132,63 +108,40 @@ class utils360Sve extends AppServiceBase {
} }
let params = actionBody.itemCode.join(','); let params = actionBody.itemCode.join(',');
let url = settings.requestUrl360() + `api/v1/eshop/GetGoodsLowestPrice?sku_ids=${params}`; let url = settings.requestUrl360() + `api/v1/eshop/GetGoodsLowestPrice?sku_ids=${params}`;
let rtn = await this.restClient.execGet("",url); let rtn = await this.restClient.execGet("", url);
if (!rtn || !rtn.stdout) { if (!rtn || !rtn.stdout) {
return system.getResult(null, "restGet data is empty"); return system.getResult(null, "restGet data is empty");
} }
let result = JSON.parse(rtn.stdout); let result = JSON.parse(rtn.stdout);
if(result.code != 200){ if (result.code != 200) {
return system.getResultFail(-1,result.msg) return system.getResultFail(-1, result.msg)
} }
return system.getResultSuccess(result.data); return system.getResultSuccess(result.data);
} }
async pushTmOrderStatus(pobj){ async pushTmOrderStatus(pobj) {
let token = await this.utilsAuthSve.get360Token(); try {
let url = settings.pushUrl360() + 'api/v1/eshop/GsbOrderUpdate?token=' + token.access_token; let token = await this.utilsAuthSve.get360Token();
let order_id = pobj.orderNo; let url = settings.pushUrl360() + 'api/v1/eshop/GsbOrderUpdate?token=' + token.access_token;
let sub_status = pobj.sub_status; let order_id = pobj.orderNo;
let status = pobj.status; let sub_status = pobj.sub_status;
let pushObj = { let status = pobj.status;
order_id, let pushObj = {
status, order_id,
sub_status: sub_status status,
} sub_status: sub_status
let result = await this.restPostUrl(pushObj, url); }
if (result.code == 200) { let result = await this.restPostUrl(pushObj, url);
this.pushlogSve.createDb({ if (result.code == 200) {
op: "360-pushTMOrderStatus", this.disposePushResult(pobj, result, "utils360Sve---pushTmOrderStatus--推送成功", 4)
content: JSON.stringify(pushObj),//推送的参数信息 } else {
resultInfo: JSON.stringify(result), this.disposePushResultFail(pobj, result, "utils360Sve---pushTmOrderStatus--推送失败", 4);
returnType: '1', }
logLevel: 1, return result;
opTitle: "推送360信息返回成功" } catch (e) {
}); this.disposePushResultFail(pobj, e.stack, "utils360Sve---pushTmOrderStatus--推送失败", 4);
} else {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushTMOrderStatus",
content: "error:" + result.msg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushTMOrderStatus",
});
} }
console.log(result, '-------------push360-----------------')
return result;
} catch (e) {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "utilsSve/utils360Sve/pushTMOrderStatus",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常status->pushOrderStatus",
});
}
}
} }
module.exports = utils360Sve; module.exports = utils360Sve;
...@@ -11,34 +11,33 @@ class UtilsDeliverSystemService extends AppServiceBase { ...@@ -11,34 +11,33 @@ class UtilsDeliverSystemService extends AppServiceBase {
/** /**
* 推送业务信息到交付系统 * 推送业务信息到交付系统
* 业务操作的信息不变外加增加组装的一些参数(推送需求商机、关闭需求、订单商机、关闭订单) * 业务操作的信息不变外加增加组装的一些参数(推送需求商机、关闭需求、订单商机、关闭订单)
* @param {*} pobj * @param {*} pobj
*/ */
async pushBusiness2DeliverSystem(pobj) {//推送业务信息到交付系统 async pushBusiness2DeliverSystem(pobj) {//推送业务信息到交付系统
console.log(pobj,"pushBusiness2DeliverSystem-zhuangbing------------------------------");
var verifyResult = await this.verifyParam(pobj); var verifyResult = await this.verifyParam(pobj);
if (verifyResult.status != 0) { if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "deliver->pushBusiness2DeliverSystem->verifyResult", this.pushlogFailType.FQ); return await this.disposePushResultFail(pobj, verifyResult, "deliver->pushBusiness2DeliverSystem->verifyResult", this.pushlogFailType.FQ);
} }
var interface_params_info = verifyResult.data; var interface_params_info = verifyResult.data;
if(interface_params_info.headData){ // var reqParams = {
if(pobj && pobj.appInfo && pobj.appInfo.app_code){ // actionType: "produceData",// Y 功能名称
interface_params_info.headData.appcode = pobj.appInfo.app_code; // actionBody: {
} // pushUrl: interface_params_info.pushUrl,// Y 推送地址
} // actionType: interface_params_info.actionType,// Y 推送地址接收时的功能名称
var reqParams = { // notifyUrl: interface_params_info.notifyUrl || "",// N 推送成功后通知的Url
actionType: "produceData",// Y 功能名称 // identifyCode: interface_params_info.identifyCode,// Y 操作的业务标识
actionBody: { // messageBody: pobj.actionBody, // Y 推送的业务消息,必须有一项对象属性值
pushUrl: interface_params_info.pushUrl,// Y 推送地址 // headData: interface_params_info.headData //N 请求头信息,Json格式,如:{token:"XXXXXXX"}
actionType: interface_params_info.actionType,// Y 推送地址接收时的功能名称 // },
notifyUrl: interface_params_info.notifyUrl || "",// N 推送成功后通知的Url // requestId: pobj.requestId || "" // N 请求id
identifyCode: interface_params_info.identifyCode,// Y 操作的业务标识 // }
messageBody: pobj.actionBody, // Y 推送的业务消息,必须有一项对象属性值 let parms = {
headData: interface_params_info.headData //N 请求头信息,Json格式,如:{token:"XXXXXXX"} actionType:interface_params_info.actionType,
}, actionBody: pobj.actionBody
requestId: pobj.requestId || "" // N 请求id
} }
var opQueuePushClientPostRes = await this.opQueuePushClientPost(pobj, this.opPushQueueUrl, reqParams); let url = interface_params_info.opUrl;
console.log(opQueuePushClientPostRes,"pushBusiness2DeliverSystem-zhuangbing----2--------------------------"); var opQueuePushClientPostRes = await this.opQueuePushClientPost(pobj, url, parms);
return await this.disposePushResult(pobj, opQueuePushClientPostRes, "delivery->pushBusiness2DeliverSystem->result", this.pushlogFailType.FQ);
} }
//--------------------------------------------------内部辅助方法-------------------start----------------- //--------------------------------------------------内部辅助方法-------------------start-----------------
...@@ -47,21 +46,22 @@ class UtilsDeliverSystemService extends AppServiceBase { ...@@ -47,21 +46,22 @@ class UtilsDeliverSystemService extends AppServiceBase {
try { try {
var rtn = await this.restPostUrl(reqParams, pushQueueUrl); var rtn = await this.restPostUrl(reqParams, pushQueueUrl);
if (rtn.status != 1) { if (rtn.status != 1) {
this.execClientNew.execLogs(`推送队列接收数据失败->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", rtn, JSON.stringify(rtn)); this.execClientNew.execLogs(`推送资质宝失败->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", rtn, JSON.stringify(rtn));
return system.getResult(null, "推送队列接收数据失败,失败原因:" + JSON.stringify(rtn)); return system.getResult(null, "推送资质宝失败,失败原因:" + JSON.stringify(rtn));
} }
return system.getResultSuccess(null, "推送成功"); return system.getResultSuccess(null, "推送成功");
} catch (e) { } catch (e) {
//日志记录 //日志记录
this.logCtl.error({ // this.logCtl.error({
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: "utilsSve/utilsDeliverSystemSve/opQueuePushClientPost", // op: "utilsSve/utilsDeliverSystemSve/opQueuePushClientPost",
content: "error:" + e.stack, // content: "error:" + e.stack,
// clientIp: pobj.clientIp, // // clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常deliver->opQueuePushClientPost", // optitle: pobj.opType + "推送操作异常deliver->opQueuePushClientPost",
}); // });
this.execClientNew.execLogs(`推送资质宝失败->opQueuePushClientPost`, pobj, "center-channel-utilsDeliverSystemSve-opQueuePushClientPost", null, JSON.stringify(e.stack));
return system.getResult(null, "推送操作异常deliver->opQueuePushClientPost->error:" + e.stack); return system.getResult(null, "推送操作异常deliver->opQueuePushClientPost->error:" + e.stack);
} }
} }
...@@ -71,8 +71,8 @@ class UtilsDeliverSystemService extends AppServiceBase { ...@@ -71,8 +71,8 @@ class UtilsDeliverSystemService extends AppServiceBase {
verify = system.getResult(null, "interface_params can not be empty,100400"); verify = system.getResult(null, "interface_params can not be empty,100400");
} }
var interface_params_info = JSON.parse(pobj.interface_params); var interface_params_info = JSON.parse(pobj.interface_params);
if (!interface_params_info || !interface_params_info.pushUrl || !interface_params_info.headData) { if (!interface_params_info || !interface_params_info.opUrl || !interface_params_info.headData) {
verify = system.getResult(null, "interface_params(pushUrl、headData) can not be empty,100430"); verify = system.getResult(null, "interface_params(opUrl、headData) can not be empty,100430");
} }
verify.data = interface_params_info; verify.data = interface_params_info;
return verify; return verify;
......
...@@ -2,8 +2,10 @@ const crypto = require('crypto'); ...@@ -2,8 +2,10 @@ const crypto = require('crypto');
const sha256 = require('sha256'); const sha256 = require('sha256');
const system = require("../system"); const system = require("../system");
var settings = require("../../config/settings"); var settings = require("../../config/settings");
class baiduClient { const AppServiceBase = require("../service/app.base");
class baiduClient extends AppServiceBase{
constructor() { constructor() {
super();
this.pushlogSve = system.getObject("service.common.pushlogSve"); this.pushlogSve = system.getObject("service.common.pushlogSve");
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
this.baiduClientParams = settings.baiduClientParams(); this.baiduClientParams = settings.baiduClientParams();
...@@ -50,11 +52,9 @@ class baiduClient { ...@@ -50,11 +52,9 @@ class baiduClient {
data:actionBody data:actionBody
} }
var rtn = await this.execClient.execBaiduPost(baiduObj, url); var rtn = await this.execClient.execBaiduPost(baiduObj, url);
console.log("baiduObj+++++",baiduObj)
console.log("url+++++",url)
console.log("rtn+++++",rtn)
if (!rtn || !rtn.stdout) { if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty"); this.execClientNew.execLogs(`baiduClient-opBaiduClientPost-result:url=${url}`, actionBody, "center-channel-opBaiduClientPost", null, rtn);
return system.getResult(null, rtn);
} }
var result = JSON.parse(rtn.stdout); var result = JSON.parse(rtn.stdout);
return result; return result;
...@@ -74,28 +74,33 @@ class baiduClient { ...@@ -74,28 +74,33 @@ class baiduClient {
host:this.baiduClientParams.host host:this.baiduClientParams.host
}, // set the http request headers }, // set the http request headers
}); });
console.log('baidu++++res+++',res) if(res.status == 0){
this.pushlogSve.createDb({ await this.disposePushResult(obj, res, "baidu->pushBusiness2Baidu->result", "");
op: "new-baiduReqbyget", }else{
content: JSON.stringify(obj),//推送的参数信息 await this.disposePushResultFail(obj, res, "badiu->pushBusiness2Baidu->catchError", this.pushlogFailType.FAILLOG);
resultInfo: JSON.stringify(res), }
returnType: '1', // this.pushlogSve.createDb({
logLevel: '1', // op: "new-baiduReqbyget",
opTitle: "new-baiduReqbyget推送百度信息返回成功" // content: JSON.stringify(obj),//推送的参数信息
}); // resultInfo: JSON.stringify(res),
// returnType: '1',
// logLevel: '1',
// opTitle: "new-baiduReqbyget推送百度信息返回成功"
// });
return system.getResultSuccess(res); return system.getResultSuccess(res);
} catch (e) { } catch (e) {
this.pushlogSve.createFailLogDb({ await this.disposePushResultFail(obj, e, "badiu->pushBusiness2Baidu->catchError", this.pushlogFailType.FAILLOG);
appid: obj.appInfo ? obj.appInfo.uapp_id || "" : "", // this.pushlogSve.createFailLogDb({
appkey: obj.appInfo ? obj.appInfo.uapp_key || "" : "", // appid: obj.appInfo ? obj.appInfo.uapp_id || "" : "",
requestId: obj.requestId || "", // appkey: obj.appInfo ? obj.appInfo.uapp_key || "" : "",
content: JSON.stringify(obj),//推送的参数信息 // requestId: obj.requestId || "",
resultInfo: "error:" + JSON.stringify(e), // content: JSON.stringify(obj),//推送的参数信息
clientIp: obj.clientIp || "", // resultInfo: "error:" + JSON.stringify(e),
failType: 1, // clientIp: obj.clientIp || "",
opTitle: "new-baiduReqbyget推送百度信息返回异常", // failType: 1,
pushNumber: obj.pushNumber || 1 // opTitle: "new-baiduReqbyget推送百度信息返回异常",
}); // pushNumber: obj.pushNumber || 1
// });
return system.getResultFail(-200, "出现异常,error:" + e.stack); return system.getResultFail(-200, "出现异常,error:" + e.stack);
} }
} }
......
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