Commit 46489b6c by 庄冰

push2ali

parents 4316d10c e618b979
...@@ -41,8 +41,8 @@ class AccessAuthAPI extends WEBBase { ...@@ -41,8 +41,8 @@ class AccessAuthAPI extends WEBBase {
opResult.data.userpin = tmpOpResult.data.userpin; opResult.data.userpin = tmpOpResult.data.userpin;
} }
//获取需求信息 //获取需求信息
pobj.actionType = "getItemByNeedNo"; pobj.actionType = "getItemByChannelNeedNo";
var needResult = await this.utilsNeedSve.getItemByNeedNo(pobj, pobj.actionBody); var needResult = await this.utilsNeedSve.getItemByChannelNeedNo(pobj, pobj.actionBody);
if (needResult.status != 0) { if (needResult.status != 0) {
return needResult; return needResult;
} }
...@@ -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"://创建订单
......
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = system.getResult(null, "req Failure");
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
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 (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break;
case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess()
}
break;
case "userPinByLgoin"://通过账户和密码登录
opResult = await this.utilsAuthSve.getReqUserPinByLgoin(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByLgoinVcode"://通过短信登录信息
pobj.actionBody.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByRegister"://通过短信注册信息
pobj.actionBody.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "putUserPwdByMobile"://通过手机验证码修改用户密码
opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody);
break;
case "getLoginInfo"://通过userpin获取用户登录信息
opResult = await this.utilsAuthSve.getLoginInfo(pobj, pobj.actionBody);
break;
case "logout"://用户退出
opResult = await this.utilsAuthSve.userLogout(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByHosts(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "hosts";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByAppKey(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "appkey";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
...@@ -32,7 +32,9 @@ class Ic extends APIBase { ...@@ -32,7 +32,9 @@ class Ic extends APIBase {
break; break;
case "reqCenterOrderApi"://办理公司状态 case "reqCenterOrderApi"://办理公司状态
break; break;
case "paySuccess"://支付回调
opResult = await this.centerorderSve.paySuccess(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -5,6 +5,7 @@ class Need extends APIBase { ...@@ -5,6 +5,7 @@ class Need extends APIBase {
constructor() { constructor() {
super(); super();
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve"); this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
this.centerorderSve = system.getObject("service.common.centerorderSve");
} }
/** /**
...@@ -24,6 +25,7 @@ class Need extends APIBase { ...@@ -24,6 +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"://提交需求
...@@ -32,6 +34,9 @@ class Need extends APIBase { ...@@ -32,6 +34,9 @@ class Need extends APIBase {
case "needClose"://关闭需求 case "needClose"://关闭需求
opResult = await this.utilsNeedSve.needClose(pobj, pobj.actionBody); opResult = await this.utilsNeedSve.needClose(pobj, pobj.actionBody);
break; break;
case "receiveFeedback"://接收方案反馈信息
opResult = await this.centerorderSve.reqCenterOrderApi(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -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: {
......
const system = require("../../../system"); const system = require("../../../system");
const crypto = require('crypto'); const crypto = require('crypto');
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
class CenterorderService{ class CenterorderService {
constructor() { constructor() {
this.centerOrderUrl = settings.centerOrderUrl(); this.centerOrderUrl = settings.centerOrderUrl();
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
this.aliclient = system.getObject("util.aliyunClient"); this.aliclient = system.getObject("util.aliyunClient");
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
}; };
//调用center-order //调用center-order
async reqCenterOrderApi(pobj,reqUrl){ async reqCenterOrderApi(pobj, reqUrl) {
var url = this.centerOrderUrl + "action/icapi/springBoard"; var url = this.centerOrderUrl + "action/icapi/springBoard";
if(reqUrl){ if (reqUrl) {
var url = this.centerOrderUrl + reqUrl; var url = this.centerOrderUrl + reqUrl;
} }
var rtn = await this.execClient.execPost(pobj, url); var rtn = await this.execClient.execPost(pobj, url);
...@@ -19,7 +21,7 @@ class CenterorderService{ ...@@ -19,7 +21,7 @@ class CenterorderService{
return data; return data;
} }
//提交公司注册方案 //提交公司注册方案
async submitProgramme(pobj){ async submitProgramme(pobj) {
var res = await this.reqCenterOrderApi(pobj); var res = await this.reqCenterOrderApi(pobj);
if(res && res.status==0 && res.data && res.data.needinfo && res.data.needsolution){ if(res && res.status==0 && res.data && res.data.needinfo && res.data.needsolution){
var needinfo = res.data.needinfo;//需求信息 var needinfo = res.data.needinfo;//需求信息
...@@ -59,9 +61,9 @@ class CenterorderService{ ...@@ -59,9 +61,9 @@ class CenterorderService{
return system.getResultSuccess(); return system.getResultSuccess();
} }
//服务商方案作废 //服务商方案作废
async abolishProgramme(pobj){ async abolishProgramme(pobj) {
var res = await this.reqCenterOrderApi(pobj); var res = await this.reqCenterOrderApi(pobj);
if(res && res.status==0 && res.data && res.data.channelSolutionNo){ if (res && res.status == 0 && res.data && res.data.channelSolutionNo) {
//推送数据至阿里 //推送数据至阿里
var pushObj = { var pushObj = {
solutionBizId:res.data.channelSolutionNo,note:pobj.actionBody.note || "" solutionBizId:res.data.channelSolutionNo,note:pobj.actionBody.note || ""
...@@ -70,6 +72,105 @@ class CenterorderService{ ...@@ -70,6 +72,105 @@ class CenterorderService{
} }
return res; return res;
} }
//支付回调
async paySuccess(pobj) {
var actionBody = pobj.actionBody;
if (!pobj.actionBody.orderNo) {
return system.getResult(null, "orderNo不能为空");
}
if (!actionBody.orderPrice) {
return system.getResult(null, "orderPrice不能为空");
}
if (!actionBody.phone) {
return system.getResult(null, "phone不能为空");
}
if (pobj.actionBody.companyName) {
if (!actionBody.city) {
return system.getResult(null, "city不能为空");
}
if (!actionBody.companyCategory) {
return system.getResult(null, "companyCategory不能为空");
}
if (!actionBody.orgType) {
return system.getResult(null, "orgType不能为空");
}
if (!actionBody.industryType) {
return system.getResult(null, "industryType不能为空");
}
if (!actionBody.scope) {
return system.getResult(null, "scope不能为空");
}
pobj.actionBody.regType = "ali.companyreg"
} else if (pobj.actionBody.park) {
if (!actionBody.productType) {
return system.getResult(null, "productType不能为空");
}
pobj.actionBody.regType = "ali.companyreg_cloud"
} else {
return system.getResult(null, "参数异常");
}
var sobj = {
actionType: "getaliicProduce",
actionBody: pobj.actionBody,
appInfo: pobj.appInfo,
actionProcess: pobj.actionProcess
}
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
var rtn = await this.execClient.execPost(sobj, url);
if (!rtn || !rtn.stdout) {
return system.getResultFail(-5010, "产品查询失败");
}
var data = JSON.parse(rtn.stdout);
if (data.status != 0) {
return system.getResultFail(-5010, "产品查询失败");
}
pobj.actionBody = data.data;
// var needNo="";
// if(solutiondata.data){
// needNo=solutiondata.data.channelNeedNo;
// }
pobj.actionBody.totalSum = pobj.actionBody.orderPrice;
pobj.actionBody.payTotalSum = pobj.actionBody.orderPrice;
pobj.actionBody.quantity = 1;
pobj.actionBody.channelOrder = {
channelServiceNo: pobj.actionBody.orderNo,
channelOrderNo: pobj.actionBody.orderNo,
orderStatus: 2
}
var orderrtn = await this.utilsOrderSve.addOrder(pobj, pobj.actionBody);
if (orderrtn.status != 0) {
return system.getResultFail(-5012, "订单创建失败");
}
if (orderrtn.data) {
pobj.actionBody.orderNo = orderrtn.data.orderNo
}
if (pobj.actionBody.solutionBizId) {
pobj.actionBody.channelSolutionNo=pobj.actionBody.solutionBizId;
pobj.actionType = "receiveSolutionPayInfo";
} else {
pobj.actionType = "createSolutionByOrder";
}
var url = settings.centerOrderUrl() + "action/icapi/springBoard";
var solutionrtn = await this.execClient.execPost(pobj, url);
if (!solutionrtn || !solutionrtn.stdout) {
return system.getResultFail(-5011, "方案查询失败");
}
var solutiondata = JSON.parse(solutionrtn.stdout);
if (solutiondata.status != 0) {
return system.getResultFail(-5011, "方案查询失败");
}
if (solutiondata.data && solutiondata.data.channelNeedNo) {
pobj.actionBody.needId = solutiondata.data.channelNeedNo;
}
if (solutiondata.status == 0) {
this.utilsPushSve.aliBusiness2Fq(pobj, "pushOrderBusiness");
}
return system.getResultSuccess();
}
} }
module.exports = CenterorderService; module.exports = CenterorderService;
// var task = new CenterorderService(); // var task = new CenterorderService();
......
...@@ -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 pushAliBusiness2Fq(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,11 @@ class UtilsNeedSve extends AppServiceBase { ...@@ -18,7 +19,11 @@ 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) {
this.utilsPushSve.aliBusiness2Fq(pobj, "pushNeedBusiness");
}
return result;
} }
/** /**
* 获取需求详情 * 获取需求详情
...@@ -34,6 +39,19 @@ class UtilsNeedSve extends AppServiceBase { ...@@ -34,6 +39,19 @@ class UtilsNeedSve extends AppServiceBase {
return itemResult; return itemResult;
} }
/** /**
* 获取需求详情
* @param {*} pobj
* @param {*} actionBody needNo 需求号
*/
async getItemByChannelNeedNo(pobj, actionBody) {
if (!actionBody.needNo) {
return system.getResult(null, "actionBody.needNo can not be empty,100380");
}
var reqUrl = this.centerOrderUrl + "action/need/springBoard";
var itemResult = await this.restPostUrl(pobj, reqUrl);
return itemResult;
}
/**
* 关闭需求 * 关闭需求
* @param {*} pobj * @param {*} pobj
* @param {*} actionBody * @param {*} actionBody
...@@ -43,7 +61,14 @@ class UtilsNeedSve extends AppServiceBase { ...@@ -43,7 +61,14 @@ 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) {
this.utilsPushSve.aliBusiness2Fq(pobj, "pushCloseNeed");
return system.getResultSuccess();
} else {
return system.getResult(null, "推送失敗 100388");
}
} }
} }
module.exports = UtilsNeedSve; module.exports = UtilsNeedSve;
......
...@@ -14,7 +14,7 @@ class UtilsOpOrderService extends AppServiceBase { ...@@ -14,7 +14,7 @@ class UtilsOpOrderService extends AppServiceBase {
} }
var reqUrl = this.centerOrderUrl + "opaction/opOrder/springBoard"; var reqUrl = this.centerOrderUrl + "opaction/opOrder/springBoard";
var result = await this.restPostUrl(pobj, reqUrl); var result = await this.restPostUrl(pobj, reqUrl);
this.opUpdatePushInfo(result, pobj, actionBody, "pushUpdateContacts"); this.opUpdatePushInfo(result, pobj, actionBody, "pushUpdateOrderContacts");
result.data = null; result.data = null;
return result; 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.pushInfo(result.data, opType, 1); this.utilsPushSve.pushBusInfo(tmpPobj, opType, 1);
} }
} }
} }
......
...@@ -79,16 +79,13 @@ class UtilsOrderService extends AppServiceBase { ...@@ -79,16 +79,13 @@ class UtilsOrderService extends AppServiceBase {
return verifyResult; return verifyResult;
} }
pobj.actionType = "getProductInterface"; pobj.actionType = "getProductInterface";
pobj.actionBody.productPriceId = pobj.actionBody.product_info.price_item.id; pobj.actionBody.product_id = pobj.actionBody.product_info.id;
var productItemInterfaceResult = await this.restPostUrl(pobj, url); var productItemInterfaceResult = await this.restPostUrl(pobj, url);
// if (productItemInterfaceResult.status != 0) {
// return productItemInterfaceResult;
// }
pobj.actionBody.product_info.interface_info = productItemInterfaceResult.data; pobj.actionBody.product_info.interface_info = productItemInterfaceResult.data;
pobj.actionType = "addOrder"; pobj.actionType = "addOrder";
var reqUrl = this.centerOrderUrl + "action/order/springBoard"; var reqUrl = this.centerOrderUrl + "action/order/springBoard";
console.log(pobj); // console.log(pobj);
var result = await this.restPostUrl(pobj, reqUrl); var result = await this.restPostUrl(pobj, reqUrl);
result.totalSum = actionBody.totalSum; result.totalSum = actionBody.totalSum;
return result; return result;
...@@ -438,14 +435,18 @@ class UtilsOrderService extends AppServiceBase { ...@@ -438,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.pushInfo(opResult.data, "pushBusiness",0); var pobj = {
this.utilsPushSve.pushInfo(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,33 @@ class UtilsPushService extends AppServiceBase { ...@@ -7,23 +7,33 @@ class UtilsPushService extends AppServiceBase {
super(); super();
this.pushlogSve = system.getObject("service.common.pushlogSve"); this.pushlogSve = system.getObject("service.common.pushlogSve");
}; };
async pushInfo(actionBody, opType, isDelProductInfo) {
var interface_list = actionBody.product_info.interface_info; async aliBusiness2Fq(pobj, opType) {
pobj.actionType = "getAppInterface";
var reqUrl = settings.centerAppUrl() + "action/opProduct/springBoard";
var productItemInterfaceResult = await this.restPostUrl(pobj, reqUrl);
pobj.interface_info = productItemInterfaceResult.data;
this.pushBusInfo(pobj, opType, 1);
}
async pushBusInfo(pobj, opType, isDelProductInfo) {//推送业务信息
var interface_list = pobj.interface_info ? pobj.interface_info : pobj.actionBody.product_info.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 +42,10 @@ class UtilsPushService extends AppServiceBase { ...@@ -32,9 +42,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 +56,28 @@ class UtilsPushService extends AppServiceBase { ...@@ -45,27 +56,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({ 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: refResult ? JSON.stringify(refResult) : "", resultInfo: JSON.stringify(rtn),
returnType: '1', returnType: refResult.status == 0 ? '1' : '0',
opTitle: "数据推送成功" opTitle: opType + (refResult.status == 0 ? "数据推送成功->reflexAction" : "数据推送出错->reflexAction")
}); });
return refResult; }
return system.getResultSuccess();
} 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"
}); });
} }
} }
......
...@@ -183,6 +183,11 @@ module.exports = function (app) { ...@@ -183,6 +183,11 @@ module.exports = function (app) {
res.end(JSON.stringify(result)); res.end(JSON.stringify(result));
return; return;
} }
if (["getAppTokenByHosts", "getAppTokenByAppKey"].indexOf(req.body.actionType) >= 0) {
req.body.actionBody.appHosts = req.host;
next();
return;
}
if (!req.body.actionType) { if (!req.body.actionType) {
result.msg = "actionType can not be empty"; result.msg = "actionType can not be empty";
res.end(JSON.stringify(result)); res.end(JSON.stringify(result));
...@@ -204,7 +209,7 @@ module.exports = function (app) { ...@@ -204,7 +209,7 @@ module.exports = function (app) {
req.body.appInfo = result.data; req.body.appInfo = result.data;
req.body.actionProcess = result.data.app_code; req.body.actionProcess = result.data.app_code;
var lst = [ var lst = [
"submitNeed" "submitNeed","paySuccess"
]; ];
if (lst.indexOf(req.body.actionType) >= 0) { if (lst.indexOf(req.body.actionType) >= 0) {
var userpin = req.headers["userpin"] || ""; var userpin = req.headers["userpin"] || "";
......
1.获取请求token 1.获取请求token
1.获取请求token 1.获取请求token
[/web/auth/accessAuth/getAppTokenByAppKey] [/api/opreceive/accessAuth/getAppTokenByAppKey]
请求方式:POST 请求方式:POST
参数格式 JSON 参数格式 JSON
HTTP请求方式 POST HTTP请求方式 POST
...@@ -20,35 +20,8 @@ HTTP请求方式 POST ...@@ -20,35 +20,8 @@ HTTP请求方式 POST
"requestId": "2016c54abe7249a2a1195d236b333f79" "requestId": "2016c54abe7249a2a1195d236b333f79"
} }
2.渠道通过账户进行登录,有则返回用户信息,没有则创建用户 3.渠道通过账户进行登录,有则返回用户信息,没有则创建用户------>供后端调用
地址:[/web/auth/accessAuth/springBoard] 地址:[/api/opreceive/accessAuth/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
{
"actionType": "getNeedUserPinByChannelUserId",
"actionBody": {
"needNo":"N2020021413152wiWI2e",// Y 需求号
"channelUserId":"15010929366",// Y 渠道用户ID
"channelUserName":"",// N 渠道用户名
"mobile":"15010929366", // N 渠道用户手机号
"nickName":"", // N 用户昵称
"orgName":"" // N 公司名称
}
}
返回结果
{
"status": 0,//0成功,否则失败
"msg": "success",
"data": {
"userpin":"c54abe7249a2a1195d236b333f79",
"channelTypeCode":"",//阿里公司注册编码:普通公司注册:esp.companyreg、云上公司注册:esp.companyreg_cloud
"typeCode":"gszc"//gszc公司注册,ysgszc云上公司注册
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
3.渠道通过账户进行登录,有则返回用户信息,没有则创建用户
地址:[/web/auth/accessAuth/springBoard]
请求方式:POST 请求方式:POST
请求头中需要有token(token值从接口1中获取) 请求头中需要有token(token值从接口1中获取)
{ {
...@@ -83,7 +56,6 @@ HTTP请求方式 POST ...@@ -83,7 +56,6 @@ HTTP请求方式 POST
orgName//公司名称 orgName//公司名称
token//token值 token//token值
4.推送公司表单材料 4.推送公司表单材料
地址:[/api/opreceive/ic/springBoard] 地址:[/api/opreceive/ic/springBoard]
请求方式:POST 请求方式:POST
...@@ -131,7 +103,7 @@ HTTP请求方式 POST ...@@ -131,7 +103,7 @@ HTTP请求方式 POST
请求方式:POST 请求方式:POST
请求头中需要有token(token值从接口1中获取) 请求头中需要有token(token值从接口1中获取)
{ {
"actionType": "close", // 关闭需求 "actionType": "needClose", // 关闭需求
"actionBody": { "actionBody": {
"needNo":"xxxxxxxxx"//需求号 "needNo":"xxxxxxxxx"//需求号
} }
...@@ -143,3 +115,32 @@ HTTP请求方式 POST ...@@ -143,3 +115,32 @@ HTTP请求方式 POST
"data": null, "data": null,
"requestId": "2016c54abe7249a2a1195d236b333f79" "requestId": "2016c54abe7249a2a1195d236b333f79"
} }
2.渠道通过账户进行登录,有则返回用户信息,没有则创建用户---->供前端调用
地址:[/web/auth/accessAuth/springBoard]
请求方式:POST
请求头中需要有token(token值从接口1中获取)
{
"actionType": "getNeedUserPinByChannelUserId",
"actionBody": {
"needNo":"N2020021413152wiWI2e",// Y 需求号
"channelUserId":"15010929366",// Y 渠道用户ID
"channelUserName":"",// N 渠道用户名
"mobile":"15010929366", // N 渠道用户手机号
"nickName":"", // N 用户昵称
"orgName":"" // N 公司名称
}
}
返回结果
{
"status": 0,//0成功,否则失败
"msg": "success",
"data": {
"userpin":"c54abe7249a2a1195d236b333f79",
"channelTypeCode":"",//阿里公司注册编码:普通公司注册:esp.companyreg、云上公司注册:esp.companyreg_cloud
"typeCode":"gszc"//gszc公司注册,ysgszc云上公司注册
},
"requestId": "2016c54abe7249a2a1195d236b333f79"
}
\ 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