Commit 617bfaeb by 宋毅

tj

parent 3def24ac
......@@ -6,15 +6,27 @@ class AccessAuthAPI extends WEBBase {
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.gatewaypushlogSve = system.getObject("service.common.gatewaypushlogSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
this.aliclient = system.getObject("util.aliyunClient");
}
async taskAliIcapi() {
var rtn = await this.gatewaypushlogSve.taskAliIcapi();
return rtn;
}
async taskAgainPushBusInfo(pobj, qobj, req) {//再次推送业务数据
async taskAgainPushOneNewBusInfo(pobj, qobj, req) {//再次推送新rpc业务数据
var rtn = await this.utilsPushSve.againPushBusInfo(pobj);
return rtn;
}
async taskAgainPushOneOldBusInfo(pobj, qobj, req) {//再次推送老rpc业务数据
var rtn = await this.aliclient.reqbyget(pobj)
return rtn;
}
// async taskAgainPushNewBusInfo(pobj, qobj, req) {//再次推送新rpc业务数据
// var rtn = await this.utilsPushSve.againPushBusInfo(pobj);
// return rtn;
// }
// async taskAgainPushOldBusInfo(pobj, qobj, req) {//再次推送老rpc业务数据
// var rtn = await this.aliclient.reqbyget(pobj)
// return rtn;
// }
}
module.exports = AccessAuthAPI;
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class PushFailLogDao extends Dao{
constructor(){
super(Dao.getModelName(PushFailLogDao));
}
}
module.exports=PushFailLogDao;
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("pushfaillog", {
appid: DataTypes.STRING,
appkey: DataTypes.STRING,
requestId: DataTypes.STRING,
content: DataTypes.TEXT('long'),
resultInfo: DataTypes.TEXT('long'),
clientIp: DataTypes.STRING,
opTitle: DataTypes.STRING(500),
failType: DataTypes.INTEGER,//错误类型,1为old-rpc推送失败日志,2为new-rpc推送失败日志
pushNumber: DataTypes.INTEGER,//推送次数
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'center_channel_pushfaillog',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
......@@ -85,30 +85,92 @@ class AppServiceBase {
var rtn = await aliyunClient.reqCustomByGet(params);
return rtn;
} catch (e) {
this.pushlogSve.createDb({
var errorMsg = "error:" + e.stack;
//日志记录
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
op: pobj.interface_info ? JSON.stringify(pobj.interface_info) : "",//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "error:" + e.stack,
returnType: '0',
opTitle: pobj.opType + "推送操作异常->opAliyunRpcReq"
requestId: pobj.requestId || "",
op: "center-channel/app/base/service/impl/utilsSve/opAliyunClientPost.js/opAliyunRpcReq",
content: errorMsg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->opAliyunRpcReq",
});
return system.getResult(null, errorMsg);
}
}
/**
* 阿里RPC调用-post请求
* @param {*} pobj {action: rpcParam.action,reqbody: pobj.actionBody,rpcParam: rpcParam}
* @param {*} params {为阿里的接口参数}
*/
async opAliyunRpcReqByPost(pobj, params) {
try {
// var action = obj.action;
// var reqbody = obj.reqbody;
// var rpcParam = obj.rpcParam;
var aliyunClient = system.getObject("util.aliyunClient");
var rtn = await aliyunClient.reqCustomByPost(params);
return rtn;
} catch (e) {
var errorMsg = "error:" + e.stack;
//日志记录
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "center-channel/app/base/service/impl/utilsSve/opAliyunClientPost.js/opAliyunRpcReq",
content: "error:" + e.stack,
op: "center-channel/app/base/service/impl/utilsSve/opAliyunClientPost.js/opAliyunRpcReqByPost",
content: errorMsg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->opAliyunRpcReq",
optitle: pobj.opType + "推送操作异常->opAliyunRpcReqByPost",
});
return system.getResult(null, "推送error");
return system.getResult(null, errorMsg);
}
}
async disposePushResult(pobj, result, opTitleDesc) {//处理结果信息--内部使用
if (result.status != 0) {
this.pushlogSve.createFailLogDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(result),
clientIp: pobj.clientIp || "",
failType: 2,
opTitle: pobj.opType + "推送操作失败->" + opTitleDesc,
pushNumber: pobj.pushNumber || 1
});
result.data = null;
return result;
}
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(result),
returnType: '1',
opTitle: pobj.opType + "数据推送成功->" + opTitleDesc
});
result.data = null;
return result;
}
async disposePushResultFail(pobj, result, opTitleDesc) {//处理失败的结果信息--内部使用
this.pushlogSve.createFailLogDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(result),
clientIp: pobj.clientIp || "",
failType: 2,
opTitle: pobj.opType + "推送操作失败->" + opTitleDesc,
pushNumber: pobj.pushNumber || 1
});
result.data = null;
return result;
}
/*
返回20位业务订单号
prefix:业务前缀
......
......@@ -4,72 +4,47 @@ var settings = require("../../../../config/settings");
class PushlogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(PushlogService));
//this.appDao=system.getObject("db.appDao");
this.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
this.logCtl = system.getObject("service.common.oplogSve");
this.pushfaillogDao = system.getObject("db.common.pushfaillogDao");
}
async create(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
var rc = system.getObject("util.execClient");
var rtn = null;
async createDb(qobj) {
try {
// var myDate = new Date();
// var tmpTitle=myDate.toLocaleString()+":"+qobj.optitle;
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
if (this.opLogEsIsAdd == 1) {
qobj.content = qobj.content.replace("field list", "字段列表")
qobj.created_at = (new Date()).getTime();
//往Es中写入日志
var addEsData = JSON.stringify(qobj);
rc.execPost(qobj, this.opLogUrl);
} else {
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
} catch (e) {
//日志记录
this.logCtl.error({
appid: qobj.appid || "",
appkey: qobj.appkey || "",
requestId: qobj.requestId || "",
op: qobj.op || "",
content: qobj.content + "-->error:" + e.stack,
clientIp: qobj.clientIp || "",
optitle: qobj.optitle || "" + "-->添加日志失败center_channel_pushlog->createDb",
});
}
}
async createDb(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
async createFailLogDb(qobj) {
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
this.dao.create(qobj);
this.pushfaillogDao.create(qobj);
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
//日志记录
this.logCtl.error({
appid: qobj.appid || "",
appkey: qobj.appkey || "",
requestId: qobj.requestId || "",
op: qobj.op || "",
content: qobj.content + "-->error:" + e.stack,
clientIp: qobj.clientIp || "",
optitle: qobj.optitle || "" + "-->添加日志失败center_channel_pushfaillog->createFailLogDb",
});
}
}
async delDbById(id) {
var sql = "DELETE FROM `center_channel_pushlog` WHERE id=:id";
var paramWhere = { id: id };
this.customQuery(sql, paramWhere);
var sql = "DELETE FROM `c?enter_channel_pushlog` WHERE id=:id";
// var paramWhere = { id: id ??};
this.bulkDeleteByWhere({ where: { id: id } });//customQuery(sql, paramWhere);
}
}
module.exports = PushlogService;
......@@ -2,7 +2,7 @@ var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const logCtl = system.getObject("service.common.oplogSve");
//阿里支付类
class utilsTlBankSve extends AppServiceBase {
constructor() {
super();
......
......@@ -2,7 +2,7 @@ var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const logCtl = system.getObject("service.common.oplogSve");
//商标查询操作
//用户权限操作
class UtilsAuthService extends AppServiceBase {
constructor() {
super();
......
......@@ -2,7 +2,7 @@ var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const logCtl = system.getObject("service.common.oplogSve");
//商标查询操作
//渠道用户权限操作
class UtilsChannelAuthService extends AppServiceBase {
constructor() {
super();
......
var system = require("../../../system");
const AppServiceBase = require("../../app.base");
//此类用来db中配置来进行调用
//此类用来db中配置来进行调用-主要功能是推送蜂擎业务
class UtilsFqAliyunService extends AppServiceBase {
constructor() {
super();
}
async pushOrderBusinessByProductCode2Fq(pobj) {//推送自定义产品码的订单商机到峰擎(订单已经支付成功才推送)
var verify = await this.verifyParam(pobj);
var verifyResult = await this.verifyParam(pobj);
var orderInfo = pobj.actionBody.order_info;
var orderContact = pobj.actionBody.order_contact;
var productInfo = pobj.actionBody.product_info;
if (!orderInfo) {
verify = system.getResult(null, "orderInfo can not be empty,100420");
verifyResult = system.getResult(null, "orderInfo can not be empty,100420");
}
if (!orderInfo.orderStatus || orderInfo.orderStatus < 2) {
verify = system.getResult(null, "orderInfo status must be paid,100423");
verifyResult = system.getResult(null, "orderInfo status must be paid,100423");
}
if (!orderContact || !orderContact.mobile) {
verify = system.getResult(null, "orderInfo.orderContact.mobile can not be empty,100425");
verifyResult = system.getResult(null, "orderInfo.orderContact.mobile can not be empty,100425");
}
if (!productInfo || !productInfo.service_business_code) {
verify = system.getResult(null, "orderInfo.productInfo.service_business_code can not be empty,100427");
verifyResult = system.getResult(null, "orderInfo.productInfo.service_business_code can not be empty,100427");
}
if (!productInfo || !productInfo.price_item || !productInfo.price_item.service_code) {
verify = 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 (verify.status != 0) {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: "暂无推送的接口信息" + ",verify-msg:" + verify.msg,//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "",
returnType: '0',
opTitle: pobj.opType + "推送操作失败->opAliyunClientPost"
});
return verify;
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "fq->pushOrderBusinessByProductCode2Fq->verifyResult");
}
var interface_params_info = verify.data;
var interface_params_info = verifyResult.data;
var params = {
idempotentId: orderInfo.orderNo,// 是 业务 ID
idempotentSource: productInfo.service_business_code,// 是 业务来源(ic_jdyun、ic_ali)
......@@ -53,7 +43,8 @@ class UtilsFqAliyunService extends AppServiceBase {
productId: productInfo.price_item.service_code,// 是 产品 ID
productQuantity: orderInfo.quantity,// 是 产品数量
};
var result = 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");
}
/**
......@@ -62,75 +53,26 @@ class UtilsFqAliyunService extends AppServiceBase {
* @param {*} pobj
*/
async pushAliBusiness2Fq(pobj) {//推送阿里信息操作到峰擎
var verify = await this.verifyParam(pobj);
if (verify.status != 0) {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: "暂无推送的接口信息" + ",verify-msg:" + verify.msg,//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "",
returnType: '0',
opTitle: pobj.opType + "推送操作失败->opAliyunClientPost"
});
return verify;
var verifyResult = await this.verifyParam(pobj);
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "fq->pushAliBusiness2Fq->verifyResult");
}
var interface_params_info = verify.data;
this.opAliyunClientPost(pobj, interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody);
}
async verifyParam(pobj) {//参数信息验证
var verify = system.getResultSuccess();
if (!pobj.interface_params) {
verify = system.getResult(null, "interface_params can not be empty,100400");
}
var interface_params_info = JSON.parse(pobj.interface_params);
if (!interface_params_info || !interface_params_info.opUrl || !interface_params_info.key || !interface_params_info.secret) {
verify = system.getResult(null, "interface_params(opUrl、key、secret) can not be empty,100410");
}
verify.data = interface_params_info;
return verify;
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");
}
//--------------------------------------------------内部辅助方法-------------------start-----------------
async opAliyunClientPost(pobj, url, key, secret, params) {
try {
var rc = system.getObject("util.aliyunClient");
var rtn = await rc.post(url, key, secret, params);
if (rtn.code != 200 && rtn.success != true) {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(rtn),
returnType: '0',
opTitle: pobj.opType + "推送操作出错->opAliyunClientPost"
});
return system.getResult(null, "推送失败,失败原因:" + rtn.errorMsg + ",selfrequestId=" + pobj.requestId + ",requestId=" + rtn.requestId);
}
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(rtn),
returnType: '1',
opTitle: pobj.opType + "数据推送成功->opAliyunClientPost"
});
return system.getResultSuccess(null, "推送成功");
} catch (e) {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "error:" + e.stack,
returnType: '0',
opTitle: pobj.opType + "推送操作异常->opAliyunClientPost"
});
//日志记录
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
......@@ -141,8 +83,22 @@ class UtilsFqAliyunService extends AppServiceBase {
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->opAliyunClientPost",
});
return system.getResult(null, "推送error");
return system.getResult(null, "推送操作异常->opAliyunClientPost->error:" + e.stack);
}
}
async verifyParam(pobj) {//参数信息验证
var verify = system.getResultSuccess();
if (!pobj.interface_params) {
verify = system.getResult(null, "interface_params can not be empty,100400");
}
var interface_params_info = JSON.parse(pobj.interface_params);
if (!interface_params_info || !interface_params_info.opUrl || !interface_params_info.key || !interface_params_info.secret) {
verify = system.getResult(null, "interface_params(opUrl、key、secret) can not be empty,100410");
}
verify.data = interface_params_info;
return verify;
}
//--------------------------------------------------内部辅助方法-------------------end-----------------
}
module.exports = UtilsFqAliyunService;
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
//商标查询操作
//需求操作类
class UtilsNeedService extends AppServiceBase {
constructor() {
super();
......
......@@ -2,6 +2,7 @@ const system = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
const AppServiceBase = require("../../app.base");
//订单操作类
class UtilsOpOrderService extends AppServiceBase {
constructor() {
super();
......@@ -51,28 +52,28 @@ class UtilsOpOrderService extends AppServiceBase {
}
async tmConfirm(pobj,actionBody){//商标方案确认
async tmConfirm(pobj, actionBody) {//商标方案确认
if (!actionBody.orderNo) {
return system.getResult(null, "actionBody.orderNo can not be empty,100025");
}
var reqUrl = this.centerOrderUrl + "action/order/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
if(result && result.status==0 && result.data){
this.pushTmConfirm(result,pobj,actionBody);//推送方案确认信息
if (result && result.status == 0 && result.data) {
this.pushTmConfirm(result, pobj, actionBody);//推送方案确认信息
return system.getResultSuccess();
}
return result;
}
//推送方案确认信息
async pushTmConfirm(result,pobj,actionBody){
async pushTmConfirm(result, pobj, actionBody) {
var orderdelivery = result.data;
var deliveryContent = orderdelivery.deliveryContent;
if(deliveryContent){
if (deliveryContent) {
var pushObj = {//推送参数
serviceNo:deliveryContent.serviceNo,
isConfirm:actionBody.isConfirm,
channelCode:deliveryContent.channelCode,
notes:actionBody.notes || "",
serviceNo: deliveryContent.serviceNo,
isConfirm: actionBody.isConfirm,
channelCode: deliveryContent.channelCode,
notes: actionBody.notes || "",
appInfo: pobj.appInfo
};
var tmpPobj = {
......@@ -82,9 +83,9 @@ class UtilsOpOrderService extends AppServiceBase {
//获取产品详情
var getProductDetailUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var getProductDetailObj = {
"actionType":"getProductDetail",
"appInfo":pobj.appInfo,
"actionBody":{"channelItemCode":deliveryContent.itemCode}
"actionType": "getProductDetail",
"appInfo": pobj.appInfo,
"actionBody": { "channelItemCode": deliveryContent.itemCode }
};
var productItemResult = await this.restPostUrl(getProductDetailObj, getProductDetailUrl);
if (productItemResult.status != 0) {
......@@ -95,9 +96,9 @@ class UtilsOpOrderService extends AppServiceBase {
//获取推送接口信息
var getProductInterfaceUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var getProductInterfaceObj = {
"actionType":"getProductInterface",
"appInfo":pobj.appInfo,
"actionBody":{"product_id":tmpPobj.actionBody.product_id}
"actionType": "getProductInterface",
"appInfo": pobj.appInfo,
"actionBody": { "product_id": tmpPobj.actionBody.product_id }
};
var productItemInterfaceResult = await this.restPostUrl(getProductInterfaceObj, getProductInterfaceUrl);
tmpPobj.actionBody.product_info.interface_info = productItemInterfaceResult.data;
......
......@@ -471,66 +471,67 @@ class UtilsOrderService extends AppServiceBase {
content: JSON.stringify(parmas),
clientIp: client_ip || ""
});
if (!parmas.app_id) {
return system.getResult(null, "app_id参数不能为空,100470");
if (!parmas.trade_status) {
return system.getResult(null, "trade_status参数不能为空,100470");
}
var url = this.centerAppUrl + "payment/paymentApi/getAppInfo";
var opResult = await this.restPostUrl({ uappId: parmas.uappid }, url);
if (parmas.trade_status != "TRADE_FINISHED" && parmas.trade_status != "TRADE_SUCCESS") {
return system.getResult(null, "trade_status状态有误,100473");
}
var url = this.centerAppUrl + "payment/aliPayment/verifyAliPayReturnSign";
var opResult = await this.restPostUrl(parmas, url);
if (opResult.status != 0) {
opResult.msg = opResult.msg + ",100270";
opResult.msg = opResult.msg + ",100480";
return opResult;
}
var appInfo = opResult.data;
var resultSign = await this.verifySign(parmas, appInfo.uapp_secret);
if (!resultSign || resultSign.status != 0) {
return resultSign;
}
// data:{
// orderNo: outTradeInfo[0],
// uappId: outTradeInfo[1],
// productId: outTradeInfo.length == 3 ? outTradeInfo[2] : 0
// }
opResult.data = {
orderNo: "TM36202004111014WcFs",
uappId: 36,
productId: 42
};
//获取充值业务锁
// await this.cacheManager["TlPayLocker"].init(parmas.out_trade_no);//---测试时放开
var locker = await this.cacheManager["TlPayLocker"].enter(parmas.out_trade_no);
await this.cacheManager["TlPayLocker"].init(opResult.data.orderNo);//---测试时放开
var locker = await this.cacheManager["TlPayLocker"].enter(opResult.data.orderNo);
if (!locker || locker != "1") {
this.logCtl.info({
appid: appInfo.uapp_id,
appkey: appInfo.uapp_key,
op: "center-channel/app/base/service/impl/utilsSve/utilsOrderSve.js/opBackNotify",
appid: opResult.data.uappId,
appkey: "",
op: "center-channel/app/base/service/impl/utilsSve/utilsOrderSve.js/opH5AliDingPayBackNotify",
content: "参数=" + JSON.stringify(parmas),
clientIp: parmas.client_ip || "",
optitle: "通联回调操作频繁---太频繁了,太频繁了"
optitle: "阿里回调操作频繁---太频繁了,太频繁了"
});
return system.getResultFail(-200, "回调操作频繁---太频繁了,太频繁了");
return system.getResultFail(-200, "阿里回调操作频繁---太频繁了,太频繁了");
}
if (parmas.trxcode == "VSP501") {
parmas.pay_type = "wx";
} else {
parmas.pay_type = "alipay";
}
parmas.appInfo = appInfo;
parmas.orderNo = parmas.out_trade_no;
parmas.appInfo = { appInfo: { uapp_id: opResult.data.uappId } };
parmas.orderNo = opResult.data.orderNo;
parmas.pay_type = "alipay";
//修改并返回订单支付状态,创建收款单
var url = this.centerOrderUrl + "opaction/opPayOrder/receivePayCallBackNotify";
var opResult = await this.restPostUrl(parmas, url);
if (opResult.status == 0) {
opResult.data.appInfo = {
uapp_id: appInfo.uapp_id,
uapp_key: appInfo.uapp_key,
app_code: appInfo.app_code,
app_name: appInfo.app_name
}; interface_info
opResult.data.userInfo = {
channel_userid: opResult.data.order_info.channelUserId,
channel_username: opResult.data.order_info.channelUserId,
channel_nickname: opResult.data.order_info.channelUserId
};
var pobj = {
appInfo: opResult.data.appInfo,
actionBody: opResult.data
}
// this.utilsPushSve.pushBusInfo(opResult.data, "pushOrderBusiness",0);
this.utilsPushSve.pushBusInfo(pobj, "pushOrder", 0);
var url = this.centerOrderUrl + "opaction/opPayOrder/receivePayCallBackNotifyByAliDing";
var opOrderResult = await this.restPostUrl(parmas, url);
if (opOrderResult.status != 0) {
opOrderResult.data = null;
return opOrderResult;
}
opResult.data = null;
return opResult;
opOrderResult.data.appInfo = {
uapp_id: opResult.data.uappId
};
opOrderResult.data.userInfo = {
channel_userid: opOrderResult.data.order_info.channelUserId,
channel_username: opOrderResult.data.order_info.channelUserId,
channel_nickname: opOrderResult.data.order_info.channelUserId
};
var pobj = {
appInfo: opOrderResult.data.appInfo,
actionBody: opOrderResult.data
}
this.utilsPushSve.pushBusInfo(pobj, "createAliTmApply", 1);
opOrderResult.data = null;
return opOrderResult;
} catch (e) {
await this.cacheManager["TlPayLocker"].release(parmas.out_trade_no);
this.logCtl.error({
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
//商标查询操作
//产品操作类
class UtilsProductService extends AppServiceBase {
constructor() {
super();
......
......@@ -5,7 +5,6 @@ const AppServiceBase = require("../../app.base");
class UtilsPushService extends AppServiceBase {
constructor() {
super();
this.pushlogSve = system.getObject("service.common.pushlogSve");
};
async aliBusiness2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
......@@ -37,7 +36,7 @@ class UtilsPushService extends AppServiceBase {
return system.getResult(null, "暂无推送配置");
}
var result = await this.reflexAction(interface_info, pobj.opType, pobj, pobj.isDelProductInfo || 1);
if (result.data != 0) {
if (result.status != 0) {
return result;
}
await this.pushlogSve.delDbById(Number(pobj.id || 0));
......@@ -78,28 +77,12 @@ class UtilsPushService extends AppServiceBase {
delete actionBody["product_info"];
}//是否删除产品信息进行推送
refResult = await this.restPostUrl(pobj.actionBody, interface_info.interface_url);
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(rtn),
returnType: refResult.status == 0 ? '1' : '0',
opTitle: opType + (refResult.status == 0 ? "数据推送成功->reflexAction" : "数据推送出错->reflexAction")
});
this.disposePushResult(pobj, refResult, "ycUrlPush->reflexAction->refResult");
}
return system.getResultSuccess();
} catch (e) {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "",
returnType: '0',
opTitle: opType + "数据推送异常-->reflexAction"
});
var errorResult = system.getResult(null, "送异常-->reflexAction->" + e.stack)
return await this.disposePushResultFail(pobj, errorResult, "数据推送异常-->reflexAction-->errorResult");
}
}
}
......
......@@ -2,7 +2,7 @@ const AppServiceBase = require("../../app.base");
var settings = require("../../../../config/settings");
const system = require("../../../system");
//此类用来db中配置来进行调用-主要功能是商标业务
//此类用来db中配置来进行调用-主要功能是推送阿里商标业务
class UtilsTmAliyunService extends AppServiceBase {
constructor() {
super();
......@@ -10,52 +10,68 @@ class UtilsTmAliyunService extends AppServiceBase {
this.aliOssFileType = { ICON: "ICON", CARD: "CARD", ATTORNEY: "ATTORNEY", PASSPORT: "PASSPORT", BUSINESS_LICENSE: "BUSINESS_LICENSE", LEGAL_NOTICE: "LEGAL_NOTICE", SUPPLEMENT: "SUPPLEMENT" };
}
async tmCreateApplicant(pobj) {//创建商标申请人信息
var verify = await this.opAliyunRpcVerifyParam(pobj);
var verifyResult = await this.opAliyunRpcVerifyParam(pobj);
var apply = pobj.actionBody.delivery_content.apply;
var orderContact = pobj.actionBody.delivery_content.orderContact;
var orderInfo = pobj.actionBody.order_info;
var tmInfo = pobj.actionBody.delivery_content.tm;
if (!orderInfo) {
verify = system.getResult(null, "orderInfo data is empty,100450");
verifyResult = system.getResult(null, "orderInfo data is empty,100450");
}
if (Number(orderInfo.orderStatus) != 2) {
verify = system.getResult(null, "orderInfo status is error,100453");
verifyResult = system.getResult(null, "orderInfo status is error,100453");
}
if (!apply) {
verify = system.getResult(null, "apply data is empty,100455");
verifyResult = system.getResult(null, "apply data is empty,100455");
}
if (verify.status != 0) {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: "暂无推送的接口信息" + ",verify-msg:" + verify.msg,//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "",
returnType: '0',
opTitle: pobj.opType + "推送操作失败->tmCreateApplicant"
});
return verify;
var rpcParam = verifyResult.data;
if (!tmInfo) {
return system.getResult(null, "tmInfo data is empty,100460");
}
var rpcParam = verify.data;
var idCardOssKey = "";
var businessLicenceOssKey = "";
var legalNoticeOssKey = "";
if (apply.customerType != "ent" && apply.identityCardPic) {
idCardOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.CARD, apply.identityCardPic, rpcParam);
if (!idCardOssKey) {
verifyResult = system.getResult(null, "identityCardPic ali oss upload is error,100462");
}
}
if (apply.customerType == "ent" && apply.businessLicensePic) {
businessLicenceOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.BUSINESS_LICENSE, apply.businessLicensePic, rpcParam);
if (!businessLicenceOssKey) {
verifyResult = system.getResult(null, "businessLicensePic ali oss upload is error,100464");
}
}
if (apply.smwjUrl) {
legalNoticeOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.LEGAL_NOTICE, apply.smwjUrl, rpcParam);
if (!legalNoticeOssKey) {
verifyResult = system.getResult(null, "smwjUrl ali oss upload is error,100466");
}
}
var picUrl = "";
var authorizationOssKey = "";
if (tmInfo.picUrl) {
picUrl = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.ICON, tmInfo.picUrl, rpcParam);
if (!picUrl) {
verifyResult = system.getResult(null, "picUrl ali oss upload is error,100467");
}
}
if (apply.gzwtsUrl) {
authorizationOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.ATTORNEY, apply.gzwtsUrl, rpcParam);
if (!authorizationOssKey) {
verifyResult = system.getResult(null, "gzwtsUrl ali oss upload is error,100468");
}
}
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "ali->tmCreateApplicant->verifyResult");
}
var actionBody = {
ContactName: orderContact.contactName || "",//String 否 张三 联系人姓名
ContactNumber: orderContact.mobile || "",//String 否 18611112222 联系人电话
ContactEmail: orderContact.email || "",//String 否 test@alibaba.com 联系人邮箱
ContactZipcode: apply.zipCode || "",//String 否 100000 联系人邮编
// ContactAddress :orderContact.,//String 否 北京市朝阳区绿地中心A座 联系人地址
ContactAddress: apply.applyAddr,//String 否 北京市朝阳区绿地中心A座 联系人地址
ApplicantType: apply.customerType && apply.customerType == "ent" ? 2 : 1,//Integer 否 1 申请人类型 1, "个人";2, "企业"
ApplicantRegion: 1,//Integer 否 1 阿拉伯数字 1, "中国大陆";2, "中国香港";3, "中国澳门";4, "中国台湾";5, "国外"
......@@ -78,24 +94,129 @@ class UtilsTmAliyunService extends AppServiceBase {
reqbody: actionBody,
rpcParam: rpcParam
}
var applicantResult = await this.opAliyunRpcReq(pobj, params);
var classifications = await this.getClassifications(pobj, pobj.actionBody.delivery_content.nclones, rpcParam);
var tmCreateResult = await this.tmCreate(pobj, rpcParam, apply.gzwtsUrl, classifications, 1);
var tmp = 0;
// var applicantResult = await this.opAliyunRpcReq(pobj, params);
// if (applicantResult.status != 0) {
// return await this.disposePushResultFail(pobj, applicantResult, "ali->tmCreateApplicant->applicantResult");
// }//++++++++++++++++++++++323661
var classificationsResult = await this.getClassifications(pobj, pobj.actionBody.delivery_content.nclones, rpcParam);
if (Object.keys(classificationsResult).length == 0) {
classificationsResult = system.getResult(null, "获取阿里尼斯数据为空,100469");
return await this.disposePushResultFail(pobj, classificationsResult, "ali->tmCreateApplicant->classificationsResult");
}
var tmCreateResult = await this.tmCreate(pobj, tmInfo, rpcParam, picUrl, authorizationOssKey, classificationsResult, 323661);//applicantResult.data.ApplicantId);
return await this.disposePushResult(pobj, tmCreateResult, "ali->tmCreateApplicant->tmCreateResult");
}
async tmCreate(pobj, rpcParam, gzwtsUrl, classifications, applicantId) {//创建商标申请信息
var tmInfo = pobj.actionBody.delivery_content.tm;
if (!tmInfo) {
return system.getResult(null, "tmInfo data is empty,100460");
async bindAliTmApplicantGzwtsUrl(pobj) {//绑定商标申请人信息-(绑定授权书Oss文件)
var verifyResult = await this.opAliyunRpcVerifyParam(pobj);
if (!pobj.actionBody.applicantId) {
verifyResult = system.getResult(null, "applicantId param is empty,100500");
}
if (!pobj.actionBody.gzwtsUrl) {
verifyResult = system.getResult(null, "gzwtsUrl param is empty,100503");
}
var picUrl = "";
var authorizationOssKey = "";
if (tmInfo.picUrl) {
picUrl = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.ICON, tmInfo.picUrl, rpcParam);
if (pobj.actionBody.gzwtsUrl) {
authorizationOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.ATTORNEY, pobj.actionBody.gzwtsUrl, rpcParam);
if (!authorizationOssKey) {
verifyResult = system.getResult(null, "gzwtsUrl ali oss upload is error,100505");
}
}
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "ali->bindAliTmApplicantGzwtsUrl->verifyResult");
}
var params = {
action: rpcParam.action,
reqbody: { ApplicantId: pobj.actionBody.applicantId, AuthorizationOssKey: authorizationOssKey },
rpcParam: rpcParam
}
var result = await this.opAliyunRpcReq(pobj, params);
return await this.disposePushResult(pobj, result, "ali->bindAliTmApplicantGzwtsUrl->result");
}
async updateAliTmApplicant(pobj) {//更新商标申请人信息
var verifyResult = await this.opAliyunRpcVerifyParam(pobj);
var apply = pobj.actionBody.delivery_content.apply;
var orderContact = pobj.actionBody.delivery_content.orderContact;
if (!apply) {
verifyResult = system.getResult(null, "apply data is empty,100510");
}
var idCardOssKey = "";
var businessLicenceOssKey = "";
var legalNoticeOssKey = "";
if (apply.customerType != "ent" && apply.identityCardPic) {
idCardOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.CARD, apply.identityCardPic, rpcParam);
if (!idCardOssKey) {
verifyResult = system.getResult(null, "identityCardPic ali oss upload is error,100512");
}
}
if (apply.customerType == "ent" && apply.businessLicensePic) {
businessLicenceOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.BUSINESS_LICENSE, apply.businessLicensePic, rpcParam);
if (!businessLicenceOssKey) {
verifyResult = system.getResult(null, "businessLicensePic ali oss upload is error,100514");
}
}
if (apply.smwjUrl) {
legalNoticeOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.LEGAL_NOTICE, apply.smwjUrl, rpcParam);
if (!legalNoticeOssKey) {
verifyResult = system.getResult(null, "smwjUrl ali oss upload is error,100516");
}
}
if (gzwtsUrl) {
authorizationOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.ATTORNEY, gzwtsUrl, rpcParam);
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "ali->updateAliTmApplicant->verifyResult");
}
var rpcParam = verify.data;
var actionBody = {
ApplicantId: pobj.actionBody.applicantId,//Long 是 123456 申请人ID
ContactName: orderContact.contactName || "",//String 否 张三 联系人姓名
ContactNumber: orderContact.mobile || "",//String 否 18611112222 联系人电话
ContactEmail: orderContact.email || "",//String 否 test@alibaba.com 联系人邮箱
ContactZipcode: apply.zipCode || "",//String 否 100000 联系人邮编
ContactAddress: apply.applyAddr,//String 否 北京市朝阳区绿地中心A座 联系人地址
ApplicantType: apply.customerType && apply.customerType == "ent" ? 2 : 1,//Integer 否 1 申请人类型 1, "个人";2, "企业"
ApplicantRegion: 1,//Integer 否 1 阿拉伯数字 1, "中国大陆";2, "中国香港";3, "中国澳门";4, "中国台湾";5, "国外"
ApplicantName: apply.name,//String 否 张三 申请人名称
CardNumber: apply.customerType && apply.customerType == "ent" ? apply.code : apply.identityCardNo,//String 否 123456 证件号码
Address: apply.applyAddr,//String 否 北京市朝阳区绿地中心A座 申请人地址
IdCardOssKey: idCardOssKey,//String 否 1219541161213057/card/ujd8hthwfdk.png 身份证ossKey
BusinessLicenceOssKey: businessLicenceOssKey,//String 否 1219541161213057/business_license/gmzl6cvbk48.png 营业执照ossKey
LegalNoticeOssKey: legalNoticeOssKey//String 否 1219541161213057/legal_notice/mlnpsjmaed.jpg 法律声明ossKey
// Province: apply.,//String 否 安徽省 省份
// EName: apply.,//String 否 zhang san 英文名称
// EAddress: apply.,//String 否 bei jing shi 英文地址
// Country: apply.,//String 否 2096 国家
// PassportOssKey: apply.,//String 否 1219541161213057/pass_port/gmzl16cvbk48.png 护照ossKey
// AuthorizationOssKey: apply.,//String 否 1219541161213057/attorney/gy378w6btam.jpg 授权书ossKey--联系了开发,创建申请人时不用填写,在创建商标时填写
};
var params = {
action: rpcParam.action,
reqbody: actionBody,
rpcParam: rpcParam
}
var result = await this.opAliyunRpcReq(pobj, params);
return await this.disposePushResult(pobj, result, "ali->updateAliTmApplicant->result");
}
async closeAliTrademarkApplication(pobj) {//主动关闭商标申请
var verifyResult = await this.opAliyunRpcVerifyParam(pobj);
if (!pobj.actionBody.parentCode) {
verifyResult = system.getResult(null, "parentCode param is empty,100490");
}
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "ali->closeAliTrademarkApplication->verifyResult");
}
var rpcParam = verifyResult.data;
var params = {
action: rpcParam.action,
reqbody: { ParentCode: pobj.actionBody.parentCode },
rpcParam: rpcParam
}
var result = await this.opAliyunRpcReq(pobj, params);
return await this.disposePushResult(pobj, result, "ali->closeAliTrademarkApplication->result");
}
//--------------------------------------------------内部辅助方法-------------------start-----------------
async tmCreate(pobj, tmInfo, rpcParam, picUrl, authorizationOssKey, classifications, applicantId) {//创建商标申请信息-内部使用-配合tmCreateApplicant方法使用
// 商标类型形式: 3: 字, 4: 图, 5: 字图
var trademarkNameType = 1;
if (tmInfo.tmFormType == "4") {
......@@ -106,6 +227,7 @@ class UtilsTmAliyunService extends AppServiceBase {
tmInfo.tmName = tmInfo.tmName + "及图";
}
var actionBody = {
AutoPay: true,
TrademarkNameType: trademarkNameType,//String 否 1 商标申请类型 1-文字 2-图形 3-文字及图形
TrademarkName: tmInfo.tmName,//String 是 pop-test 商标名称
TrademarkComment: tmInfo.tmName,//String 否 测试 商标说明
......@@ -113,28 +235,20 @@ class UtilsTmAliyunService extends AppServiceBase {
BlackAndWhiteIcon: picUrl,//String 否 1219541161213057/icon/gii9s4oyg8.jpg
ApplicationType: 1,//Integer 否 1 固定值1
ApplicantId: applicantId,//String 否 111 申请人ID,通过申请人API创建申请人获得,或者通过申请人列表查询接口获得
Classifications: classifications,//String 是 {"38":"380005,380024,380050,380040,38020148,380004,38010007,38020149,38020141,380053"} 商标分类
Classifications: JSON.stringify(classifications),//String 是 {"38":"380005,380024,380050,380040,38020148,380004,38010007,38020149,38020141,380053"} 商标分类
AuthorizationOssKey: authorizationOssKey,//String 否 1219541161213057/attorney/9cgvhk2yd1l.JPG 授权书ossKey
Channel: "aliTmH5"//String 否 pop接口测试 通道,调用方填写,独立标志,用于区分来源-自己随便定义
};
var params = {
action: "tmCreateTrademarkApplication",
action: "CreateTrademarkApplication",
reqbody: actionBody,
rpcParam: rpcParam
}
this.opAliyunRpcReq(pobj, params);
// var tmCreateReslut = await this.opAliyunRpcReqByPost(pobj, params);
var tmCreateReslut = await this.opAliyunRpcReq(pobj, params);
return tmCreateReslut;
}
// async closeTrademarkApplication(){
// var params = {
// action: "CloseTrademarkApplication",
// reqbody: { ParentCode: parentCode },
// rpcParam: rpcParam
// }
// }
async getAliOssFileUrl(bucketName, pobj, fileType, selfFileUrl, rpcParam) {
var fileUrl = "";
var resultInfo = await this.getAliOssInfo(pobj, fileType, rpcParam);
......@@ -153,8 +267,23 @@ class UtilsTmAliyunService extends AppServiceBase {
"encodePolicy": resultInfo.data.EncodedPolicy,
"signature": resultInfo.data.Signature
}
var aliOssFileInfo = await this.execPostUrl(params, settings.aliossjavaUrl());
return aliOssFileInfo;
try {
var aliOssFileInfo = await this.execPostUrl(params, settings.aliossjavaUrl());
if (aliOssFileInfo) {
fileUrl = params.filedir + "/" + params.objectName;
}
} catch (e) {
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "center-channel/app/base/service/impl/utilsSve/utilsTmAliyunSve.js/aliossjavaUrl",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "aliossjava-upload阿里上传文件操作异常->getAliOssFileUrl->aliossjavaUrl",
});
}
return fileUrl;
}
async getAliOssInfo(pobj, fileType, rpcParam) {
var params = {
......@@ -162,7 +291,7 @@ class UtilsTmAliyunService extends AppServiceBase {
reqbody: { FileType: fileType },
rpcParam: rpcParam
}
var resultInfo = this.opAliyunRpcReq(pobj, params);
var resultInfo = await this.opAliyunRpcReq(pobj, params);
return resultInfo;
}
async getClassifications(pobj, nclones, rpcParam) {
......@@ -201,7 +330,8 @@ class UtilsTmAliyunService extends AppServiceBase {
}
}
}//一个大类下小项组装完毕
aliNclThreesList["\"" + nclOneItem.code + "\""] = "\"" + getAliThreeList.join(',') + "\"";
aliNclThreesList[nclOneItem.code] = getAliThreeList.join(',');
// aliNclThreesList["\"" + nclOneItem.code + "\""] = "\"" + getAliThreeList.join(',') + "\"";
}
return aliNclThreesList;
}
......@@ -218,5 +348,6 @@ class UtilsTmAliyunService extends AppServiceBase {
return system.getResultSuccess(nclInfoResult.data.Classifications.Classification);
}
//--------------------------------------------------内部辅助方法-------------------end-----------------
}
module.exports = UtilsTmAliyunService;
......@@ -30,6 +30,9 @@ class aliyunClient {
var action = obj.action;
var reqbody = obj.reqbody;
try {
if (rpcParam.apiVersion) {
this.aliclient.apiVersion = obj.apiVersion;
}
var res = await this.aliclient.request(action, reqbody, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
......@@ -38,8 +41,8 @@ class aliyunClient {
headers: {}, // set the http request headers
});
this.pushlogSve.createDb({
op: "推送阿里信息返回:" + action,
content: JSON.stringify(obj),
op: "old-reqbyget",
content: JSON.stringify(obj),//推送的参数信息
resultInfo: JSON.stringify(res),
returnType: '1',
logLevel: '1',
......@@ -47,13 +50,16 @@ class aliyunClient {
});
return system.getResultSuccess(res);
} catch (e) {
this.pushlogSve.createDb({
op: "推送阿里信息返回:" + action,
content: JSON.stringify(obj),
resultInfo: JSON.stringify(e.stack),
returnType: '0',
logLevel: '3',
opTitle: "old-reqbyget推送阿里信息返回异常"
this.pushlogSve.createFailLogDb({
appid: obj.appInfo ? obj.appInfo.uapp_id || "" : "",
appkey: obj.appInfo ? obj.appInfo.uapp_key || "" : "",
requestId: obj.requestId || "",
content: JSON.stringify(obj),//推送的参数信息
resultInfo: "error:" + JSON.stringify(e.stack),
clientIp: obj.clientIp || "",
failType: 1,
opTitle: "old-reqbyget推送阿里信息返回异常",
pushNumber: obj.pushNumber || 1
});
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
......@@ -84,6 +90,30 @@ class aliyunClient {
});
return system.getResultSuccess(res);
}
async reqCustomByPost(obj, cbk) {
var action = obj.action;
var reqbody = obj.reqbody;
var rpcParam = obj.rpcParam;
if (rpcParam.accessKeyId) {
this.aliclient.accessKeyId = rpcParam.accessKeyId;
}
if (rpcParam.accessKeySecret) {
this.aliclient.accessKeySecret = rpcParam.accessKeySecret;
}
if (rpcParam.endpoint) {
this.aliclient.endpoint = rpcParam.endpoint;
}
if (rpcParam.apiVersion) {
this.aliclient.apiVersion = rpcParam.apiVersion;
}
var res = await this.aliclient.request(action, reqbody, {
timeout: 3000, // default 3000 ms
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
});
return system.getResultSuccess(res);
}
}
module.exports = aliyunClient;
......@@ -5,9 +5,7 @@ const md5 = require("MD5");
class PushUtils {
constructor() {
this.logCtl = system.getObject("service.common.oplogSve");
this.merchantpushlogSve = system.getObject("service.merchant.merchantpushlogSve");
this.execClient = system.getObject("util.execClient");
this.merchantpushSve = system.getObject("service.merchant.merchantpushSve");
}
getUUID() {
var uuid = uuidv4();
......@@ -19,53 +17,7 @@ class PushUtils {
var cacheManager = system.getObject("db.common.cacheManager");
return await cacheManager["MerchantPushUrlCache"].cache(merchant_id, null, 3600);
}
/**
* 推送到第三方数据
* @param {*} reqUrl 请求推送的url
* @param {*} params 推送的参数
*/
async push(merchantId, field, params) {
try {
var pushConfig = await this.getCachePushItemUrl(merchantId) || {};
var reqUrl = pushConfig[field];
if(!reqUrl) {
this.logCtl.error({
optitle: "推送到第三方数据异常error",
op: "merchantId = " + merchantId + "; reqUrl is empty, field = " + field,
content: "reqUrl is empty",
clientIp: "pushUtils中没有ip"
});
return;
}
// 签名
params.sign = await this.createSign(params, merchantId);
params.requestid = this.getUUID();
var rtn = await this.execClient.execPost(params, reqUrl);
var returnValue = 0;
if (rtn.stdout) {
var result = JSON.parse(rtn.stdout);
if (result.code == "success") {
returnValue = 1;
}
}
//记录推送结果
this.merchantpushlogSve.create({
merchant_id: merchantId,//商户id
api: reqUrl,//接口地址
params: JSON.stringify(params),//推送数据信息
rs: rtn.stdout,//推送返回结果
success: returnValue//是否推送成功
});
} catch (e) {
console.log(e.stack);
this.logCtl.error({
optitle: "推送到第三方数据异常error",
op: reqUrl + ";params=" + JSON.stringify(params) + ";reqid=" + params.requestid,
content: e.stack,
clientIp: "pushUtils中没有ip"
});
}
}
/**
* 多次推送到第三方数据
* @param {*} reqUrl 请求推送的url
......@@ -102,10 +54,10 @@ class PushUtils {
var keys = Object.keys(params).sort();
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
}
var resultSignStr = signArr.join("&") + "&key=" + appInfo.appSecret;
return md5(resultSignStr).toUpperCase();
......
......@@ -22,7 +22,7 @@ var settings = {
port: process.env.NODE_PORT || 4012,
aliossjavaUrl: function () {
if (this.env == "dev") {
return "http://192.168.0.102:8080/uploadfile";
return "http://192.168.0.104:8080/uploadfile";
} else {
return "http://aliossjava-service/uploadfile";
}
......
已经使用的编码汇总:
已经使用的编码汇总:
......@@ -45,4 +45,8 @@
100440
100450
100460
100470
\ No newline at end of file
100470
100480
100490
100500
100510
\ No newline at end of file
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