Commit 24d5c9a5 by 宋毅

tj

parent cb4c349c
......@@ -7,6 +7,8 @@ class AppServiceBase {
this.restClient = system.getObject("util.restClient");
this.execClient = system.getObject("util.execClient");
this.cacheManager = system.getObject("db.common.cacheManager");
this.pushlogSve = system.getObject("service.common.pushlogSve");
this.logCtl = system.getObject("service.common.oplogSve");
}
/**
* 验证签名
......@@ -57,6 +59,78 @@ class AppServiceBase {
var result = JSON.parse(rtn.stdout);
return result;
}
async opAliyunRpcVerifyParam(pobj) {//参数信息验证
var verify = system.getResultSuccess();
if (!pobj.interface_params) {
verify = system.getResult(null, "interface_params can not be empty,100440");
}
var interface_params_info = JSON.parse(pobj.interface_params);
if (!interface_params_info || !interface_params_info.action) {
verify = system.getResult(null, "interface_params.action can not be empty,100443");
}
verify.data = interface_params_info;
return verify;
}
/**
* 阿里RPC调用
* @param {*} pobj {action: rpcParam.action,reqbody: pobj.actionBody,rpcParam: rpcParam}
* @param {*} params {为阿里的接口参数}
*/
async opAliyunRpcReq(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.reqCustomByGet(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 + ",requestId=" + rtn.requestId);
}
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: '1',
opTitle: pobj.opType + "数据推送成功->opAliyunClientPost"
});
return system.getResultSuccess(null, "推送成功");
} 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: "error:" + e.stack,
returnType: '0',
opTitle: pobj.opType + "推送操作异常->opAliyunClientPost"
});
//日志记录
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/" + methodName,
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->opAliyunClientPost",
});
return system.getResult(null, "推送error");
}
}
/*
返回20位业务订单号
prefix:业务前缀
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const aliyunClient = system.getObject("util.aliyunClient");
//此类用来db中配置来进行调用
class UtilsFqAliyunService extends AppServiceBase {
constructor() {
super();
this.logCtl = system.getObject("service.common.oplogSve");
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
async pushOldNeedBusiness(pobj) {//推送旧的需求商机
return system.getResultSuccess();
}
async pushOrderBusiness(pobj) {//推送订单商机
async pushOrderBusinessByProductCode2Fq(pobj) {//推送自定义产品码的订单商机到峰擎(订单已经支付成功才推送)
var verify = await this.verifyParam(pobj);
var orderInfo = pobj.actionBody.order_info;
var orderContact = pobj.actionBody.order_contact;
var productInfo = pobj.actionBody.product_info;
if (!orderInfo) {
return "";
verify = system.getResult(null, "orderInfo can not be empty,100420");
}
if (orderInfo.orderStatus < 2) {
return "";
if (!orderInfo.orderStatus || orderInfo.orderStatus < 2) {
verify = system.getResult(null, "orderInfo status must be paid,100423");
}
var orderContact = pobj.actionBody.order_contact;
var productInfo = pobj.actionBody.product_info;
if (!pobj.interface_params) {
return "";
if (!orderContact || !orderContact.mobile) {
verify = system.getResult(null, "orderInfo.orderContact.mobile can not be empty,100425");
}
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) {
return "";
if (!productInfo || !productInfo.service_business_code) {
verify = 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");
}
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 interface_params_info = verify.data;
var params = {
idempotentId: orderInfo.orderNo,// 是 业务 ID
idempotentSource: productInfo.service_business_code,// 是 业务来源(ic_jdyun、ic_ali)
idempotentSourceName: productInfo.service_business_code,// 是 京东云应用、阿里云应用
idempotentSourceName: productInfo.service_business_name || productInfo.service_business_code,// 是 京东云应用、阿里云应用
city: "",// 否 所属城市
phone: orderContact.mobile,// 是 手机号
userId: orderInfo.channelUserId,// 否 用户 ID
......@@ -45,36 +56,53 @@ class UtilsFqAliyunService extends AppServiceBase {
var result = this.opAliyunClientPost(pobj, "pushOrderBusiness", interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, params);
}
async pushAliBusiness2Fq(pobj) {//推送阿里工商需求商机
/**
* 推送阿里信息操作到峰擎
* 阿里操作的信息不变外加增加组装的一些参数(推送工商需求商机、推送工商订单商机、推送关闭工商需求)
* @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 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) {
return "";
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) {
return "";
verify = system.getResult(null, "interface_params(opUrl、key、secret) can not be empty,100410");
}
var result = this.opAliyunClientPost(pobj, "pushAliIcNeedBusiness", interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody);
verify.data = interface_params_info;
return verify;
}
async opAliyunClientPost(pobj, methodName, url, key, secret, params) {
async opAliyunClientPost(pobj, url, key, secret, params) {
try {
var rc = system.getObject("util.aliyunClient");
var rtn = await rc.post(url, key, secret, params);
this.logCtl.info({
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/" + methodName,
content: "请求地址:" + url + ",参数:" + JSON.stringify(params) + ",返回结果:" + JSON.stringify(rtn),
optitle: "推送商机->opAliyunClientPost",
});
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),
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(rtn),
returnType: '0',
opTitle: pobj.opType + "推送操作出错->opAliyunClientPost"
......@@ -84,8 +112,9 @@ class UtilsFqAliyunService extends AppServiceBase {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
op: "推送的接口信息:" + JSON.stringify(pobj.interface_info),
content: "推送的参数信息:" + JSON.stringify(pobj),
requestId: pobj.requestId || "",
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(rtn),
returnType: '1',
opTitle: pobj.opType + "数据推送成功->opAliyunClientPost"
......@@ -95,8 +124,9 @@ class UtilsFqAliyunService extends AppServiceBase {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
op: "推送的接口信息:" + JSON.stringify(pobj.interface_info),
content: "推送的参数信息:" + JSON.stringify(pobj),
requestId: pobj.requestId || "",
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "error:" + e.stack,
returnType: '0',
opTitle: pobj.opType + "推送操作异常->opAliyunClientPost"
......@@ -106,7 +136,7 @@ class UtilsFqAliyunService extends AppServiceBase {
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/" + methodName,
op: "center-channel/app/base/service/impl/utilsSve/opAliyunClientPost.js/opAliyunClientPost",
content: "error:" + e.stack,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->opAliyunClientPost",
......
......@@ -48,7 +48,7 @@ class UtilsNeedService extends AppServiceBase {
*/
async getItemByNeedNo(pobj, actionBody) {
if (!actionBody.needNo) {
return system.getResult(null, "actionBody.needNo can not be empty,100380");
return system.getResult(null, "actionBody.needNo can not be empty,100385");
}
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
var itemResult = await this.restPostUrl(pobj, reqUrl);
......@@ -61,7 +61,7 @@ class UtilsNeedService extends AppServiceBase {
*/
async getItemByChannelNeedNo(pobj, actionBody) {
if (!actionBody.needNo) {
return system.getResult(null, "actionBody.needNo can not be empty,100380");
return system.getResult(null, "actionBody.needNo can not be empty,100390");
}
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
var itemResult = await this.restPostUrl(pobj, reqUrl);
......@@ -74,7 +74,7 @@ class UtilsNeedService extends AppServiceBase {
*/
async needClose(pobj, actionBody) {
if (!actionBody.intentionBizId) {
return system.getResult(null, "actionBody.intentionBizId can not be empty,100380");
return system.getResult(null, "actionBody.intentionBizId can not be empty,100395");
}
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
......
......@@ -8,7 +8,7 @@ class UtilsPushService extends AppServiceBase {
this.pushlogSve = system.getObject("service.common.pushlogSve");
};
async aliBusiness2Fq(pobj, opType) {
async aliBusiness2Fq(pobj, opType) {//供业务调用,在代码中调用,不在db中做配置进行调用
pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
......@@ -16,7 +16,7 @@ class UtilsPushService extends AppServiceBase {
this.pushBusInfo(pobj, opType, 1);
}
async pushBusInfo(pobj, opType, isDelProductInfo) {//推送业务信息
async pushBusInfo(pobj, opType, isDelProductInfo) {//推送业务总入口-包括重试
var interface_list = pobj.interface_info ? pobj.interface_info : pobj.actionBody.product_info.interface_info;
if (!interface_list) {
return system.getResult(null, "暂无推送配置");
......@@ -27,13 +27,14 @@ class UtilsPushService extends AppServiceBase {
}
for (let index = 0; index < interface_list_temp.length; index++) {
const element = interface_list_temp[index];
var refOpResult = this.reflexAction(element, opType, pobj, isDelProductInfo);
this.reflexAction(element, opType, pobj, isDelProductInfo);
}
}
async reflexAction(interface_info, opType, pobj, isDelProductInfo) {
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) {
......@@ -66,8 +67,8 @@ class UtilsPushService extends AppServiceBase {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
op: "推送的接口信息:" + JSON.stringify(pobj.interface_info),
content: "推送的参数信息:" + JSON.stringify(pobj),
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")
......@@ -78,8 +79,8 @@ class UtilsPushService extends AppServiceBase {
this.pushlogSve.createDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
op: "推送的接口信息:" + JSON.stringify(pobj.interface_info),
content: "推送的参数信息:" + JSON.stringify(pobj),
op: JSON.stringify(pobj.interface_info),//推送的接口信息
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: "",
returnType: '0',
opTitle: opType + "数据推送异常-->reflexAction"
......
const AppServiceBase = require("../../app.base");
//此类用来db中配置来进行调用-主要功能是商标业务
class UtilsTmAliyunService extends AppServiceBase {
constructor() {
super();
}
async tmCreateApplicant(pobj) {//创建商标申请人信息
var verify = await this.opAliyunRpcVerifyParam(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 + "推送操作失败->tmCreateApplicant"
});
return verify;
}
var rpcParam = verify.data;
var params = {
action: rpcParam.action,
reqbody: pobj.actionBody,
rpcParam: rpcParam
}
this.opAliyunRpcReq(pobj, params);
}
async tmCreateTrademarkApplication(pobj) {//创建商标申请信息
var verify = await this.opAliyunRpcVerifyParam(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 + "推送操作失败->tmCreateTrademarkApplication"
});
return verify;
}
var rpcParam = verify.data;
var params = {
action: rpcParam.action,
reqbody: pobj.actionBody,
rpcParam: rpcParam
}
this.opAliyunRpcReq(pobj, params);
}
}
module.exports = UtilsTmAliyunService;
......@@ -42,8 +42,8 @@ class aliyunClient {
content: JSON.stringify(obj),
resultInfo: JSON.stringify(res),
returnType: '1',
logLevel:'1',
opTitle: "推送阿里信息返回成功"
logLevel: '1',
opTitle: "old-reqbyget推送阿里信息返回成功"
});
return system.getResultSuccess(res);
} catch (e) {
......@@ -52,12 +52,42 @@ class aliyunClient {
content: JSON.stringify(obj),
resultInfo: JSON.stringify(e.stack),
returnType: '0',
logLevel:'3',
opTitle: "推送阿里信息返回异常"
logLevel: '3',
opTitle: "old-reqbyget推送阿里信息返回异常"
});
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
}
async reqCustomByGet(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;
}
try {
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: 'GET', // set the http method, default is GET
headers: {}, // set the http request headers
});
return system.getResultSuccess(res);
} catch (e) {
return system.getResultFail(-200, "出现异常,error:" + e.stack);
}
}
}
......
已经使用的编码汇总:
已经使用的编码汇总:
......@@ -36,4 +36,10 @@
100350
100360
100370
100380
\ No newline at end of file
100380
100390
100400
100410
100420
100430
100440
\ 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