Commit 4e201ed1 by 宋毅

tj

parent 331a0d8a
...@@ -16,6 +16,9 @@ class AccessAuthAPI extends APIBase { ...@@ -16,6 +16,9 @@ class AccessAuthAPI extends APIBase {
} }
async taskAgainFqPushInfo(pobj, qobj, req) {//再次推送蜂擎业务数据 async taskAgainFqPushInfo(pobj, qobj, req) {//再次推送蜂擎业务数据
var rtn = await this.utilsPushSve.aliBusiness2Fq(pobj, pobj.opType); var rtn = await this.utilsPushSve.aliBusiness2Fq(pobj, pobj.opType);
if (rtn.status == 0) {
this.pushlogSve.delDbPushfaillogById(Number(pobj.id || 0));
}
return rtn; return rtn;
} }
async taskAgainPushOneNewBusInfo(pobj, qobj, req) {//再次推送新rpc业务数据 async taskAgainPushOneNewBusInfo(pobj, qobj, req) {//再次推送新rpc业务数据
...@@ -27,6 +30,9 @@ class AccessAuthAPI extends APIBase { ...@@ -27,6 +30,9 @@ class AccessAuthAPI extends APIBase {
} }
async taskAgainPushOneOldBusInfo(pobj, qobj, req) {//再次推送老rpc业务数据 async taskAgainPushOneOldBusInfo(pobj, qobj, req) {//再次推送老rpc业务数据
var rtn = await this.aliclient.reqbyget(pobj) var rtn = await this.aliclient.reqbyget(pobj)
if (rtn.status == 0) {
this.pushlogSve.delDbPushfaillogById(Number(pobj.id || 0));
}
return rtn; return rtn;
} }
async taskAliTmUpdate(pobj, qobj, req) {//操作阿里商标更新 async taskAliTmUpdate(pobj, qobj, req) {//操作阿里商标更新
...@@ -35,7 +41,26 @@ class AccessAuthAPI extends APIBase { ...@@ -35,7 +41,26 @@ class AccessAuthAPI extends APIBase {
} }
async taskAliRpcAgainPush(pobj, qobj, req) { async taskAliRpcAgainPush(pobj, qobj, req) {
var result = await this.pushlogSve.getFailLogList();
if (result.status != 0 || !result.data || result.data.length == 0) {
return system.getResult(null, "push data is empty");
}
for (let index = 0; index < result.data.length; index++) {
const element = result.data[index];
if (element) {
var contentData = JSON.parse(element.content);
contentData.id = element.id;
contentData.pushNumber = element.pushNumber + 1;
if (element.failType == 1) {
this.taskAgainPushOneOldBusInfo(contentData);
}
else if (element.failType == 2) {
this.taskAgainPushOneNewBusInfo(contentData);
} else if (element.failType == 4) {
this.taskAgainFqPushInfo(contentData);
}//FQ
}
}
return system.getResultSuccess(); return system.getResultSuccess();
} }
......
...@@ -8,6 +8,7 @@ class AppServiceBase { ...@@ -8,6 +8,7 @@ class AppServiceBase {
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.pushlogSve = system.getObject("service.common.pushlogSve"); this.pushlogSve = system.getObject("service.common.pushlogSve");
this.pushlogFailType = { OLDRPC: 1, NEWRPC: 2, FAILLOG: 3, FQ: 4 };
this.logCtl = system.getObject("service.common.oplogSve"); this.logCtl = system.getObject("service.common.oplogSve");
} }
/** /**
...@@ -157,7 +158,14 @@ class AppServiceBase { ...@@ -157,7 +158,14 @@ class AppServiceBase {
return system.getResult(null, errorMsg); return system.getResult(null, errorMsg);
} }
} }
async disposePushResult(pobj, result, opTitleDesc) {//处理结果信息--内部使用 /**
* 处理成功后的信息
* @param {*} pobj
* @param {*} result
* @param {*} opTitleDesc
* @param {*} failType this.pushlogFailType
*/
async disposePushResult(pobj, result, opTitleDesc, failType) {//处理结果信息--内部使用
var opType = pobj.opType || ""; var opType = pobj.opType || "";
if (result.status != 0) { if (result.status != 0) {
this.pushlogSve.createFailLogDb({ this.pushlogSve.createFailLogDb({
...@@ -167,7 +175,7 @@ class AppServiceBase { ...@@ -167,7 +175,7 @@ class AppServiceBase {
content: JSON.stringify(pobj),//推送的参数信息 content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(result), resultInfo: JSON.stringify(result),
clientIp: pobj.clientIp || "", clientIp: pobj.clientIp || "",
failType: 2, failType: failType || 3,
opTitle: opType + "推送操作失败->" + opTitleDesc, opTitle: opType + "推送操作失败->" + opTitleDesc,
pushNumber: pobj.pushNumber || 1 pushNumber: pobj.pushNumber || 1
}); });
...@@ -192,7 +200,7 @@ class AppServiceBase { ...@@ -192,7 +200,7 @@ class AppServiceBase {
* @param {*} pobj * @param {*} pobj
* @param {*} result * @param {*} result
* @param {*} opTitleDesc * @param {*} opTitleDesc
* @param {*} failType 错误类型,1为old-rpc推送失败日志,2为new-rpc推送失败日志,业务处理失败日志,3为失败日志记录 * @param {*} failType this.pushlogFailType
*/ */
async disposePushResultFail(pobj, result, opTitleDesc, failType) {//处理失败的结果信息--内部使用 async disposePushResultFail(pobj, result, opTitleDesc, failType) {//处理失败的结果信息--内部使用
var opType = pobj.opType || ""; var opType = pobj.opType || "";
...@@ -203,7 +211,7 @@ class AppServiceBase { ...@@ -203,7 +211,7 @@ class AppServiceBase {
content: JSON.stringify(pobj),//推送的参数信息 content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(result), resultInfo: JSON.stringify(result),
clientIp: pobj.clientIp || "", clientIp: pobj.clientIp || "",
failType: failType || 2, failType: failType || 3,
opTitle: opType + "推送操作失败->" + opTitleDesc, opTitle: opType + "推送操作失败->" + opTitleDesc,
pushNumber: pobj.pushNumber || 1 pushNumber: pobj.pushNumber || 1
}); });
......
...@@ -44,5 +44,11 @@ class PushlogService extends ServiceBase { ...@@ -44,5 +44,11 @@ class PushlogService extends ServiceBase {
async delDbPushfaillogById(id) { async delDbPushfaillogById(id) {
this.pushfaillogDao.bulkDeleteByWhere({ where: { id: id } }); this.pushfaillogDao.bulkDeleteByWhere({ where: { id: id } });
} }
async getFailLogList() {
var sql = "SELECT id,`content`,failType,pushNumber,opTitle FROM `center_channel_pushfaillog` WHERE failType IN(1,2,4) AND pushNumber<10 LIMIT 200";
var list = await this.pushfaillogDao.customQuery(sql);
var result = system.getResultSuccess(list);
return result;
}
} }
module.exports = PushlogService; module.exports = PushlogService;
...@@ -27,7 +27,7 @@ class UtilsFqAliyunService extends AppServiceBase { ...@@ -27,7 +27,7 @@ class UtilsFqAliyunService extends AppServiceBase {
verifyResult = system.getResult(null, "orderInfo.productInfo.price_item.service_code can not be empty,100430"); verifyResult = system.getResult(null, "orderInfo.productInfo.price_item.service_code can not be empty,100430");
} }
if (verifyResult.status != 0) { if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "fq->pushOrderBusinessByProductCode2Fq->verifyResult"); return await this.disposePushResultFail(pobj, verifyResult, "fq->pushOrderBusinessByProductCode2Fq->verifyResult", this.pushlogFailType.FQ);
} }
var interface_params_info = verifyResult.data; var interface_params_info = verifyResult.data;
...@@ -44,7 +44,7 @@ class UtilsFqAliyunService extends AppServiceBase { ...@@ -44,7 +44,7 @@ class UtilsFqAliyunService extends AppServiceBase {
productQuantity: orderInfo.quantity,// 是 产品数量 productQuantity: orderInfo.quantity,// 是 产品数量
}; };
var result = await this.opAliyunClientPost(pobj, "pushOrderBusiness", interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, params); var result = await this.opAliyunClientPost(pobj, "pushOrderBusiness", interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, params);
return await this.disposePushResult(pobj, result, "fq->pushOrderBusinessByProductCode2Fq->result"); return await this.disposePushResult(pobj, result, "fq->pushOrderBusinessByProductCode2Fq->result", this.pushlogFailType.FQ);
} }
/** /**
...@@ -55,11 +55,11 @@ class UtilsFqAliyunService extends AppServiceBase { ...@@ -55,11 +55,11 @@ class UtilsFqAliyunService extends AppServiceBase {
async pushAliBusiness2Fq(pobj) {//推送阿里信息操作到峰擎 async pushAliBusiness2Fq(pobj) {//推送阿里信息操作到峰擎
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, "fq->pushAliBusiness2Fq->verifyResult"); return await this.disposePushResultFail(pobj, verifyResult, "fq->pushAliBusiness2Fq->verifyResult", this.pushlogFailType.FQ);
} }
var interface_params_info = verifyResult.data; var interface_params_info = verifyResult.data;
var result = await this.opAliyunClientPost(pobj, interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody); var result = await this.opAliyunClientPost(pobj, interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody);
return await this.disposePushResult(pobj, result, "fq->pushAliBusiness2Fq->result"); return await this.disposePushResult(pobj, result, "fq->pushAliBusiness2Fq->result", this.pushlogFailType.FQ);
} }
//--------------------------------------------------内部辅助方法-------------------start----------------- //--------------------------------------------------内部辅助方法-------------------start-----------------
......
...@@ -89,12 +89,12 @@ class UtilsPushService extends AppServiceBase { ...@@ -89,12 +89,12 @@ class UtilsPushService extends AppServiceBase {
delete actionBody["product_info"]; delete actionBody["product_info"];
}//是否删除产品信息进行推送 }//是否删除产品信息进行推送
refResult = await this.restPostUrl(pobj.actionBody, interface_info.interface_url); refResult = await this.restPostUrl(pobj.actionBody, interface_info.interface_url);
this.disposePushResult(pobj, refResult, "ycUrlPush->reflexAction->refResult"); this.disposePushResult(pobj, refResult, "ycUrlPush->reflexAction->refResult", this.pushlogFailType.NEWRPC);
} }
return system.getResultSuccess(); return system.getResultSuccess();
} catch (e) { } catch (e) {
var errorResult = system.getResult(null, "送异常-->reflexAction->" + e.stack) var errorResult = system.getResult(null, "送异常-->reflexAction->" + e.stack)
return await this.disposePushResultFail(pobj, errorResult, "数据推送异常-->reflexAction-->errorResult"); return await this.disposePushResultFail(pobj, errorResult, "数据推送异常-->reflexAction-->errorResult", this.pushlogFailType.FAILLOG);
} }
} }
} }
......
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