Commit f677b718 by 宋毅

tj

parent 23f848bd
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
const getRawBody = require('raw-body');
class OplogService extends ServiceBase { class OplogService extends ServiceBase {
constructor() { constructor() {
super("common", ServiceBase.getDaoName(OplogService)); super("common", ServiceBase.getDaoName(OplogService));
...@@ -76,5 +77,26 @@ class OplogService extends ServiceBase { ...@@ -76,5 +77,26 @@ class OplogService extends ServiceBase {
this.dao.create(qobj); this.dao.create(qobj);
} }
} }
async applicationOctetStream2Json(req) {
var promiseT = await new Promise((resv, rej) => {
getRawBody(req, {
length: req.headers['content-length'],
encoding: req.charset
}, function (err, string) {
if (err) {
rej(err);
} else {
resv(string);
}
});
});
if (promiseT.length > 0) {
var step1 = JSON.stringify(promiseT);
var step2 = JSON.parse(step1);
var step3 = new Buffer(step2);
var step4 = step3.toString();
req.body = JSON.parse(step4);
}
}
} }
module.exports = OplogService; module.exports = OplogService;
...@@ -5,24 +5,14 @@ const logCtl = system.getObject("service.common.oplogSve"); ...@@ -5,24 +5,14 @@ const logCtl = system.getObject("service.common.oplogSve");
const utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve"); const utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
module.exports = function (app) { module.exports = function (app) {
// app.get("/auth", async function (req, res) {
// if (!req.query.opencode) {
// return system.getResult(null, "opencode参数不能为空");
// }
// return await userSve.authByCode(opencode);
// });
// case "submitSolution"://提交需求
// opResult = await this.needinfoSve.createicneedinfo(pobj);
// break;
// case "paySuccess"://支付成功回调
// opResult = await this.orderinfoSve.createsolutionOrder(pobj);
// break;
// case "solutionClose"://需求关闭
// opResult = await this.needinfoSve.solutionClose(pobj);
app.use('/api/ali/esp/intention/submit', async function (req, res) { app.use('/api/ali/esp/intention/submit', async function (req, res) {
try { try {
if (req.headers['content-type'] === 'application/octet-stream') {
await logCtl.applicationOctetStream2Json(req);
}
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 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,
...@@ -44,8 +34,11 @@ module.exports = function (app) { ...@@ -44,8 +34,11 @@ module.exports = function (app) {
}); });
app.use('/api/ali/esp/intention/solution/feedback', async function (req, res) { app.use('/api/ali/esp/intention/solution/feedback', async function (req, res) {
try { try {
if (req.headers['content-type'] === 'application/octet-stream') {
await logCtl.applicationOctetStream2Json(req);
}
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 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,
...@@ -66,8 +59,11 @@ module.exports = function (app) { ...@@ -66,8 +59,11 @@ module.exports = function (app) {
}); });
app.use('/api/ali/ic/paySuccess', async function (req, res) { app.use('/api/ali/ic/paySuccess', async function (req, res) {
try { try {
if (req.headers['content-type'] === 'application/octet-stream') {
await logCtl.applicationOctetStream2Json(req);
}
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 utilsNeedSve.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,
...@@ -88,8 +84,11 @@ module.exports = function (app) { ...@@ -88,8 +84,11 @@ module.exports = function (app) {
}); });
app.use('/api/ali/esp/intention/close', async function (req, res) { app.use('/api/ali/esp/intention/close', async function (req, res) {
try { try {
if (req.headers['content-type'] === 'application/octet-stream') {
await logCtl.applicationOctetStream2Json(req);
}
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 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,
......
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