Commit 06997acc by 王栋源

wdy

parent 4c12fed5
...@@ -7,30 +7,8 @@ class TradetransferAPI extends APIBase { ...@@ -7,30 +7,8 @@ class TradetransferAPI extends APIBase {
super(); super();
this.execlient = system.getObject("util.execClient"); this.execlient = system.getObject("util.execClient");
this.channelApiUrl = settings.channelApiUrl(); this.channelApiUrl = settings.channelApiUrl();
this.appInfo = {
aliyuntmtransfer: { appkey: settings.appKey, secret: settings.secret }
};
} }
async getToken() {
var self = this;
var reqTokenUrl = this.channelApiUrl + "/auth/accessAuth/getToken";
var reqParam = self.appInfo["aliyuntmtransfer"];
if (!reqParam.appkey || !reqParam.secret) {
return system.getResult(null, "reqType类型有误,请求失败");
}
var rtn = await this.execlient.execPost(reqParam, reqTokenUrl);
if (!rtn.stdout) {
return system.getResult(null, "获取token失败");
}
var tokenResult = JSON.parse(rtn.stdout);
if (tokenResult.status == 0) {
tokenResult.data.secret = reqParam.secret;
}
return tokenResult;
}
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
* actionProcess 执行的流程 * actionProcess 执行的流程
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class GatewaypushlogDao extends Dao{
constructor(){
super(Dao.getModelName(GatewaypushlogDao));
}
}
module.exports=GatewaypushlogDao;
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("gatewaypushlog", {
requestId: DataTypes.STRING,
requestUrl: DataTypes.STRING, //请求地址
requestjson: DataTypes.STRING,//请求地址
pushUrl: DataTypes.STRING,//调用地址
pushActionType: DataTypes.STRING,//调用参数
pushtimes:DataTypes.INTEGER,//推送次数
pushStatus:DataTypes.STRING,//推送状态
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'gateway_pushlog',
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}]
// }
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
const uuidv4 = require('uuid/v4');
const getRawBody = require('raw-body');
class GatewaypushlogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(GatewaypushlogService));
//this.appDao=system.getObject("db.appDao");
this.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
getResultSuccess(requestId) {
return {
"requestId": requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
}
}
getResultFail(errmsg) {
var self = this;
return {
"requestId": self.getUUID(),
"success": false,
"errorMsg": errmsg,
"errorCode": "ok"
};
}
//需求提交
async submitNeed(pobj) {
var self = this;
if (!pobj.intentionBizId) {
return self.getResultFail("intentionBizId不能为空");
}
if (!pobj.mobile) {
return self.getResultFail("mobile不能为空");
}
if (!pobj.type) {
return self.getResultFail("type不能为空");
}
var param = {
requestId: self.getUUID(),
requestUrl: "/api/ali/esp/intention/submit",
requestjson: JSON.stringify(pobj),//请求地址
pushUrl: "/action/intentionapi/queryOrderState",//调用地址
pushActionType: "submitNeed",//调用参数
pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态
}
await self.create(param);
return self.getResultSuccess(param.requestId);
}
//需求关闭
async needClose(pobj) {
var self = this;
if (!pobj.intentionBizId) {
return self.getResultFail("intentionBizId不能为空");
}
var param = {
requestId: self.getUUID(),
requestUrl: "/api/ali/esp/intention/close",
requestjson: JSON.stringify(pobj),//请求地址
pushUrl: "/action/intentionapi/queryOrderState",//调用地址
pushActionType: "needClose",//调用参数
pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态
}
await self.create(param);
return self.getResultSuccess(param.requestId);
}
//需求反馈
async receiveFeedback(pobj) {
var self = this;
if (!pobj.solutionBizId) {
return self.getResultFail("solutionBizId不能为空");
}
if (!pobj.operateType) {
return self.getResultFail("operateType不能为空");
}
var param = {
requestId: self.getUUID(),
requestUrl: "/api/ali/esp/intention/solution/feedback",
requestjson: JSON.stringify(pobj),//请求地址
pushUrl: "/action/intentionapi/queryOrderState",//调用地址
pushActionType: "receiveFeedback",//调用参数
pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态
}
await self.create(param);
return self.getResultSuccess(param.requestId);
}
//支付回调
async paySuccess(pobj) {
var self = this;
if (!pobj.orderNo) {
return self.getResultFail("orderNo不能为空");
}
if (!pobj.orderPrice) {
return self.getResultFail("orderPrice不能为空");
}
if (!pobj.phone) {
return self.getResultFail("phone不能为空");
}
if (pobj.companyName) {
if (!pobj.city) {
return self.getResultFail("city不能为空");
}
if (!pobj.companyCategory) {
return self.getResultFail("companyCategory不能为空");
}
if (!pobj.orgType) {
return self.getResultFail("orgType不能为空");
}
if (!pobj.industryType) {
return self.getResultFail("industryType不能为空");
}
if (!pobj.scope) {
return self.getResultFail("scope不能为空");
}
} else if (pobj.park) {
if (!pobj.productType) {
return self.getResultFail("productType不能为空");
}
} else {
return self.getResultFail("参数异常");
}
var param = {
requestId: self.getUUID(),
requestUrl: "/api/ali/ic/paySuccess",
requestjson: JSON.stringify(pobj),//请求地址
pushUrl: "/action/intentionapi/queryOrderState",//调用地址
pushActionType: "paySuccess",//调用参数
pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态
}
await this.create(param);
return self.getResultSuccess(param.requestId);
}
}
module.exports = GatewaypushlogService;
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
var system = require("../../base/system"); var system = require("../../base/system");
// var userSve = system.getObject("service.auth.userSve"); // var userSve = system.getObject("service.auth.userSve");
const logCtl = system.getObject("service.common.oplogSve"); const logCtl = system.getObject("service.common.oplogSve");
const gatewaypushlogSve = system.getObject("service.common.gatewaypushlogSve");
const utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve"); const utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
module.exports = function (app) { module.exports = function (app) {
...@@ -14,7 +15,7 @@ module.exports = function (app) { ...@@ -14,7 +15,7 @@ module.exports = function (app) {
} }
var client_ip = system.get_client_ip(req); var client_ip = system.get_client_ip(req);
req.body.action_type = "submitNeed"; req.body.action_type = "submitNeed";
var result = await utilsNeedSve.reqcenterchannel(req.body, client_ip); var result = await gatewaypushlogSve.submitNeed(req.body, client_ip);
logCtl.info({ logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode, optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "api/ali/esp/intention/submit", op: "api/ali/esp/intention/submit",
...@@ -40,7 +41,7 @@ module.exports = function (app) { ...@@ -40,7 +41,7 @@ module.exports = function (app) {
} }
var client_ip = system.get_client_ip(req); var client_ip = system.get_client_ip(req);
req.body.action_type = "receiveFeedback"; req.body.action_type = "receiveFeedback";
var result = await utilsNeedSve.reqcenterchannel(req.body, client_ip); var result = await gatewaypushlogSve.receiveFeedback(req.body, client_ip);
logCtl.info({ logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode, optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/api/ali/esp/intention/solution/feedback", op: "/api/ali/esp/intention/solution/feedback",
...@@ -65,7 +66,7 @@ module.exports = function (app) { ...@@ -65,7 +66,7 @@ module.exports = function (app) {
} }
var client_ip = system.get_client_ip(req); var client_ip = system.get_client_ip(req);
req.body.action_type = "paySuccess"; req.body.action_type = "paySuccess";
var result = await utilsNeedSve.paySuccess(req.body, client_ip); var result = await gatewaypushlogSve.paySuccess(req.body, client_ip);
logCtl.info({ logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode, optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/api/ali/ic/paySuccess", op: "/api/ali/ic/paySuccess",
...@@ -115,6 +116,136 @@ module.exports = function (app) { ...@@ -115,6 +116,136 @@ module.exports = function (app) {
} }
var client_ip = system.get_client_ip(req); var client_ip = system.get_client_ip(req);
req.body.action_type = "needClose"; req.body.action_type = "needClose";
var result = await gatewaypushlogSve.needClose(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/api/ali/esp/intention/close",
content: "回调参数:" + JSON.stringify(req.body) + "回调处理订单结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
res.end(JSON.stringify(result));
return JSON.stringify(result);
} catch (error) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录回调处理结果异常:,method=" + req.body.trxcode,
op: "/api/ali/esp/intention/close",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
}
});
//test
app.use('/api/alitest/esp/intention/submit', async function (req, res) {
try {
console.log(req.headers['content-type'])
if (req.headers['content-type'].indexOf('application/octet-stream')>-1 ) {
await logCtl.applicationOctetStream2Json(req);
}
var client_ip = system.get_client_ip(req);
req.body.action_type = "submitNeed";
var result = await utilsNeedSve.reqcenterchannel(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "api/ali/esp/intention/submit",
content: "回调参数:" + JSON.stringify(req.body) + "回调处理订单结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
res.end(JSON.stringify(result));
return JSON.stringify(result);
} catch (error) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录回调处理结果异常:,method=" + req.body.trxcode,
op: "/api/ali/esp/intention/submit",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
return JSON.stringify(result);
}
});
app.use('/api/alitest/esp/intention/solution/feedback', async function (req, res) {
try {
if (req.headers['content-type'].indexOf('application/octet-stream')>-1 ) {
await logCtl.applicationOctetStream2Json(req);
}
var client_ip = system.get_client_ip(req);
req.body.action_type = "receiveFeedback";
var result = await utilsNeedSve.reqcenterchannel(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/api/ali/esp/intention/solution/feedback",
content: "回调参数:" + JSON.stringify(req.body) + "回调处理订单结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
res.end(JSON.stringify(result));
return JSON.stringify(result);
} catch (error) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录回调处理结果异常:,method=" + req.body.trxcode,
op: "/api/ali/esp/intention/solution/feedback",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
}
});
app.use('/api/alitest/ic/paySuccess', async function (req, res) {
try {
if (req.headers['content-type'].indexOf('application/octet-stream')>-1 ) {
await logCtl.applicationOctetStream2Json(req);
}
var client_ip = system.get_client_ip(req);
req.body.action_type = "paySuccess";
var result = await utilsNeedSve.paySuccess(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/api/ali/ic/paySuccess",
content: "回调参数:" + JSON.stringify(req.body) + "回调处理订单结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
res.end(JSON.stringify(result));
return JSON.stringify(result);
} catch (error) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录回调处理结果异常:,method=" + req.body.trxcode,
op: "/api/ali/ic/paySuccess",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
}
});
app.use('/api/alitest/ic/close', async function (req, res) {
try {
if (req.headers['content-type'].indexOf('application/octet-stream')>-1 ) {
await logCtl.applicationOctetStream2Json(req);
}
var client_ip = system.get_client_ip(req);
req.body.action_type = "orderClose";
var result = await utilsNeedSve.orderClose(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/api/ali/ic/close",
content: "回调参数:" + JSON.stringify(req.body) + "回调处理订单结果:" + JSON.stringify(result),
clientIp: client_ip || ""
});
res.end(JSON.stringify(result));
return JSON.stringify(result);
} catch (error) {
logCtl.error({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "记录回调处理结果异常:,method=" + req.body.trxcode,
op: "/api/ali/ic/close",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
}
});
app.use('/api/alitest/esp/intention/close', async function (req, res) {
try {
if (req.headers['content-type'].indexOf('application/octet-stream')>-1 ) {
await logCtl.applicationOctetStream2Json(req);
}
var client_ip = system.get_client_ip(req);
req.body.action_type = "needClose";
var result = await utilsNeedSve.reqcenterchannel(req.body, client_ip); var result = await utilsNeedSve.reqcenterchannel(req.body, client_ip);
logCtl.info({ logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode, optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
...@@ -133,6 +264,8 @@ module.exports = function (app) { ...@@ -133,6 +264,8 @@ module.exports = function (app) {
}); });
} }
}); });
app.get('/api/:gname/:qname/:method', function (req, res) { app.get('/api/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"]; var classPath = req.params["qname"];
var methodName = req.params["method"]; var methodName = req.params["method"];
......
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