Commit e6790735 by 宋毅

tj

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