Commit e6790735 by 宋毅

tj

parent 3c2f9db9
......@@ -31,7 +31,7 @@ class AccessAuthAPI extends WEBBase {
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getNeedUserPinByChannelUserId"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
......@@ -50,14 +50,14 @@ class AccessAuthAPI extends WEBBase {
opResult.data.typeCode = needResult.data.typeCode
break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
opResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (opResult.status != 0 && opResult.status != 2060) {
return opResult;
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (opResult.status == 2060) {
opResult.msg = opResult.msg;
opResult.data.userpin = opResult.data.userpin;
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break;
case "getVerifyCode"://获取默认模板的手机验证码
......
......@@ -23,6 +23,7 @@ class IcbcOrderNotify extends WEBBase {
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
this.logCtl.info({
appid: pobj.appInfo.uapp_id,
......
......@@ -23,6 +23,7 @@ class ProductAPI extends WEBBase {
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "updateContacts"://修改订单联系人
......
......@@ -23,6 +23,7 @@ class ProductAPI extends WEBBase {
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "addOrder"://创建订单
......
......@@ -31,8 +31,8 @@ class AccessAuthAPI extends APIBase {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getNeedUserPinByChannelUserId"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
......@@ -41,25 +41,6 @@ class AccessAuthAPI extends APIBase {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
//获取需求信息
pobj.actionType = "getItemByNeedNo";
var needResult = await this.utilsNeedSve.getItemByNeedNo(pobj, pobj.actionBody);
if (needResult.status != 0) {
return needResult;
}
opResult.data.channelTypeCode = needResult.data.channelTypeCode;
opResult.data.typeCode = needResult.data.typeCode
break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
opResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (opResult.status != 0 && opResult.status != 2060) {
return opResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (opResult.status == 2060) {
opResult.msg = opResult.msg;
opResult.data.userpin = opResult.data.userpin;
}
break;
case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
......
......@@ -25,7 +25,7 @@ class Need extends APIBase {
return result;
}
async opActionProcess(pobj, action_process, action_type, action_body, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "submitNeed"://提交需求
......
......@@ -13,7 +13,7 @@ module.exports = (db, DataTypes) => {
defaultValue: "info",
},
op: DataTypes.STRING(4000),
content: DataTypes.TEXT,
content: DataTypes.TEXT('long'),
resultInfo: DataTypes.TEXT('long'),
returnTypeName: DataTypes.STRING,
returnType: {
......
......@@ -55,10 +55,6 @@ class PushlogService extends ServiceBase {
}
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
//解决日志大于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-----------------------*****************");
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const logCtl = system.getObject("service.common.oplogSve");
const aliyunClient = system.getObject("util.aliyunClient");
class UtilsFqAliyunSve extends AppServiceBase {
constructor() {
super();
this.logCtl = system.getObject("service.common.oplogSve");
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
async pushOldNeedBusiness(actionBody) {//推送旧的需求商机
async pushOldNeedBusiness(pobj) {//推送旧的需求商机
return system.getResultSuccess();
}
async pushOrderBusiness(actionBody) {//推送订单商机
var orderInfo = actionBody.order_info;
async pushOrderBusiness(pobj) {//推送订单商机
var orderInfo = pobj.actionBody.order_info;
if (!orderInfo) {
return "";
}
if (orderInfo.orderStatus < 2) {
return "";
}
var orderContact = actionBody.order_contact;
var productInfo = actionBody.product_info;
if (!actionBody.interface_params) {
var orderContact = pobj.actionBody.order_contact;
var productInfo = pobj.actionBody.product_info;
if (!pobj.interface_params) {
return "";
}
var interface_params_info = JSON.parse(actionBody.interface_params);
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 "";
}
......@@ -40,37 +42,76 @@ class UtilsFqAliyunSve extends AppServiceBase {
productId: productInfo.price_item.service_code,// 是 产品 ID
productQuantity: orderInfo.quantity,// 是 产品数量
};
var result = this.opAliyunClientPost("pushOrderBusiness", interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, params);
var result = this.opAliyunClientPost(pobj, "pushOrderBusiness", interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, params);
}
async pushAliIcNeedBusiness(pobj) {//推送阿里工商需求商机
if (!pobj.interface_params) {
return "";
}
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 "";
}
var result = this.opAliyunClientPost(pobj, "pushAliIcNeedBusiness", interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody);
}
async opAliyunClientPost(methodName, url, key, secret, params) {
async opAliyunClientPost(pobj, methodName, url, key, secret, params) {
try {
var rc = system.getObject("util.aliyunClient");
var rtn = = await rc.post(url, key, secret, params);
var rtn = await rc.post(url, key, secret, params);
this.logCtl.info({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uappKey,
requestId: req.requestId || "",
op: "center-channel/app/base/service/impl/utilsSve/utilsFqAliyunSve.js/" + methodName,
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),
clientIp: pobj.clientIp,
optitle: "推送订单商机到FQ信息--again",
optitle: "推送商机->opAliyunClientPost",
});
if (rtn.code != 200 && rtn.success != true) {
return system.getResult(null, "推送失败,失败原因:" + rtn.errorMsg + ",selfrequestId=" + req.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: '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,
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.uapp_id,
appkey: pobj.appInfo.uappKey,
requestId: req.requestId || "",
op: "center-channel/app/base/service/impl/utilsSve/utilsFqAliyunSve.js/" + methodName,
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: "推送操作出错->opAliyunClientPost",
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->opAliyunClientPost",
});
return system.getResult(null, "推送error");
}
}
}
......
......@@ -6,6 +6,7 @@ class UtilsNeedSve extends AppServiceBase {
constructor() {
super();
this.centerOrderUrl = settings.centerOrderUrl();
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
}
/**
......@@ -18,7 +19,15 @@ class UtilsNeedSve extends AppServiceBase {
return system.getResult(null, "actionBody.intentionBizId can not be empty,100380");
}
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
return await this.restPostUrl(pobj, reqUrl);
var result = await this.restPostUrl(pobj, reqUrl);
if (result.status == 0) {
pobj.actionType = "getAppInterface";
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, url);
pobj.interface_info = productItemInterfaceResult.data;
this.utilsPushSve.pushBusInfo(pobj, "pushNeedBusiness", 1);
}
return result;
}
/**
* 获取需求详情
......
......@@ -41,8 +41,12 @@ class UtilsOpOrderService extends AppServiceBase {
channel_username: pobj.userInfo.channel_username,
channel_nickname: pobj.userInfo.channel_nickname
};
var tmpPobj = {
appInfo: opResult.data.appInfo,
actionBody: opResult.data
}
delete result.data["orderStatus"];
this.utilsPushSve.pushOrderInfo(result.data, opType, 1);
this.utilsPushSve.pushBusInfo(tmpPobj, opType, 1);
}
}
}
......
......@@ -435,14 +435,18 @@ class UtilsOrderService extends AppServiceBase {
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
};
// this.utilsPushSve.pushOrderInfo(opResult.data, "pushOrderBusiness",0);
this.utilsPushSve.pushOrderInfo(opResult.data, "pushOrder", 0);
var pobj = {
appInfo: opResult.data.appInfo,
actionBody: opResult.data
}
// this.utilsPushSve.pushBusInfo(opResult.data, "pushOrderBusiness",0);
this.utilsPushSve.pushBusInfo(pobj, "pushOrder", 0);
}
opResult.data = null;
return opResult;
......
......@@ -7,23 +7,24 @@ class UtilsPushService extends AppServiceBase {
super();
this.pushlogSve = system.getObject("service.common.pushlogSve");
};
async pushOrderInfo(actionBody, opType, isDelProductInfo) {
var interface_list = actionBody.product_info.interface_info;
async pushBusInfo(pobj, opType, isDelProductInfo) {//推送业务信息
var interface_list = pobj.actionBody.product_info ? pobj.actionBody.product_info.interface_info : pobj.interface_info;
if (!interface_list) {
return "";
return system.getResult(null, "暂无推送配置");
}
var interface_list_temp = interface_list.filter(f => f.op_type == opType)
if (!interface_list_temp || interface_list_temp.length == 0) {
return "";
return system.getResult(null, "暂无【" + opType + "】的推送配置");
}
for (let index = 0; index < interface_list_temp.length; index++) {
const element = interface_list_temp[index];
var refOpResult = this.reflexAction(element, actionBody, isDelProductInfo);
var refOpResult = this.reflexAction(element, opType, pobj, isDelProductInfo);
}
}
async reflexAction(interface_info, actionBody, isDelProductInfo) {
async reflexAction(interface_info, opType, pobj, isDelProductInfo) {
var refResult = null;
try {
pobj.opType = opType;
if (interface_info.interface_type == "bd") {
if (!interface_info.method_name) {
return system.getResult(null, "产品接口参数信息有误,100350");
......@@ -32,9 +33,10 @@ class UtilsPushService extends AppServiceBase {
if (!invokeObj[interface_info.method_name]) {
return system.getResult(null, "产品接口参数方法信息有误,100360");
}
actionBody.interface_params = interface_info.params;
var params = [actionBody];
refResult = await invokeObj[interface_info.method_name].apply(invokeObj, params);
pobj.interface_info = interface_info;
pobj.interface_params = interface_info.params;
var params = [pobj];
invokeObj[interface_info.method_name].apply(invokeObj, params);
}
else if (interface_info.interface_type == "yc") {
if (!interface_info.interface_url) {
......@@ -45,27 +47,28 @@ class UtilsPushService extends AppServiceBase {
if (isDelProductInfo && isDelProductInfo == 1) {
delete actionBody["product_info"];
}//是否删除产品信息进行推送
refResult = await this.restPostUrl(actionBody, interface_info.interface_url);
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.pushlogSve.createDb({
appid: actionBody.appInfo.uapp_id,
appkey: actionBody.appInfo.uapp_key,
op: "推送的接口信息:" + JSON.stringify(interface_info),
content: JSON.stringify(actionBody),
resultInfo: refResult ? JSON.stringify(refResult) : "",
returnType: '1',
opTitle: "数据推送成功"
});
return refResult;
return system.getResultSuccess();
} catch (e) {
this.pushlogSve.createDb({
appid: actionBody.appInfo.uapp_id,
appkey: actionBody.appInfo.uapp_key,
op: "推送的接口信息:" + JSON.stringify(interface_info),
content: JSON.stringify(actionBody),
resultInfo: JSON.stringify(e.stack),
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
op: "推送的接口信息:" + JSON.stringify(pobj.interface_info),
content: "推送的参数信息:" + JSON.stringify(pobj),
resultInfo: "",
returnType: '0',
opTitle: "数据推送异常"
opTitle: opType + "数据推送异常-->reflexAction"
});
}
}
......
1.获取请求token
1.获取请求token
1.获取请求token
[/api/auth/accessAuth/getAppTokenByAppKey]
[/api/opreceive/accessAuth/getAppTokenByAppKey]
请求方式:POST
参数格式 JSON
HTTP请求方式 POST
......
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