Commit a0f8192b by linboxuan

ali wangwen 2.1-2.4

parent 749506cc
......@@ -54,6 +54,12 @@ class TradetransferAPI extends APIBase {
case "needCloseAliEsp":// 2020 0926 lin 新增 阿里文网文 服务商侧提供接口2.2 关闭需求通知服务商
opResult = await this.utilsNeedSve.needCloseAliEsp(pobj);
break;
case "produceNoticeAliEsp":// 2020 0927 lin 新增 阿里文网文 服务商侧提供接口2.3 服务单通知服务商
opResult = await this.utilsNeedSve.produceNoticeAliEsp(pobj);
break;
case "needCloseAliEsp":// 2020 0926 lin 新增 阿里文网文 服务商侧提供接口2.2 关闭需求通知服务商
opResult = await this.utilsNeedSve.needCloseAliEsp(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -385,7 +385,7 @@ class GatewaypushlogService extends ServiceBase {
return self.getResultFail("intentionBizId is empty");
}
if (!pobj.note) {
return self.getResultFail("mobile is empty");
return self.getResultFail("note is empty");
}
pobj.action_type = "needCloseAliEsp";
var param = {
......@@ -401,5 +401,37 @@ class GatewaypushlogService extends ServiceBase {
return self.getResultSuccess(param.requestId);
}
// 2020 0927 lin 新增 阿里文网文 服务商侧提供接口2.3 服务单通知服务商
async produceNoticeAliEsp(pobj) {
var self = this;
if (!pobj.bizId) {
return self.getResultFail("bizId is empty");
}
if (!pobj.status) {
return self.getResultFail("status is empty");
}
if (!pobj.intentionBizId) {
return self.getResultFail("intentionBizId is empty");
}
if (!pobj.isDirectBuy) {
return self.getResultFail("isDirectBuy is empty");
}
if (!pobj.operationType) {
return self.getResultFail("operationType is empty");
}
pobj.action_type = "produceNoticeAliEsp";
var param = {
requestId: self.getUUID(),
requestUrl: "/ali/esp/intention/submit",
requestjson: JSON.stringify(pobj),//请求地址
pushUrl: "/action/intentionapi/springBoard",//调用地址
pushActionType: "produceNoticeAliEsp",//调用参数
pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态
}
await self.create(param);
return self.getResultSuccess(param.requestId);
}
}
module.exports = GatewaypushlogService;
\ No newline at end of file
......@@ -363,7 +363,8 @@ class UtilsNeedSve extends AppServiceBase {
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.userId,
// 为什么2.1 有userId 但是不用 还要用mobile。因为模式不支持
"channelUserId": pobj.mobile,
"mobile": pobj.mobile,
"userName": pobj.userName ? pobj.userName : pobj.mobile
}
......@@ -392,6 +393,10 @@ class UtilsNeedSve extends AppServiceBase {
}
//带userpin请求
url = settings.centerChannelUrl() + "/api/opreceive/edi/springBoard";
// 2020 0927 lin 新增 type 由 esp.wangwen 转换为 wangwen
if(pobj.type == "esp.wangwen") {
pobj.type == "wangwen"
}
var sobj = {
"actionType": pobj.action_type,
"actionBody": pobj
......@@ -441,7 +446,7 @@ class UtilsNeedSve extends AppServiceBase {
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.userId,
"channelUserId": pobj.mobile,
"mobile": pobj.mobile,
"userName": pobj.userName ? pobj.userName : pobj.mobile
}
......@@ -500,5 +505,83 @@ class UtilsNeedSve extends AppServiceBase {
};
}
}
// 2020 0926 lin 新增 阿里文网文 服务商侧提供接口2.2 关闭需求通知服务商
async produceNoticeAliEsp(pobj) {
var tokenInfo = await this.getCenterToken();
if (tokenInfo.status != 0) {
return {
"requestId": self.getUUID(),
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
var token = tokenInfo.data.token;
var userpin = "";
if (pobj.mobile) {
//获取用户userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.userId,
"mobile": pobj.mobile,
"userName": pobj.userName ? pobj.userName : pobj.mobile
}
};
var self = this;
var url = settings.centerChannelUrl() + "/api/auth/accessAuth/springBoard";
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) {
return {
"requestId": self.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
userpin = userpinResultTmp.data.userpin;
if (!userpin) {
// return { "message": "网络错误", "data": {}, "code": -102 }
return {
"requestId": self.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
}
//带userpin请求
url = settings.centerChannelUrl() + "/api/opreceive/edi/springBoard";
var sobj = {
"actionType": pobj.action_type,
"actionBody": pobj
}
var rtn = rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin);
if (!rtn || !rtn.stdout) {
return {
"requestId": self.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status == 0) {
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} else {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
}
}
module.exports = UtilsNeedSve;
......@@ -276,6 +276,62 @@ module.exports = function (app) {
return JSON.stringify(result);
}
});
// 2020 0927 lin 新增 阿里文网文 服务商侧提供接口2.3 服务单通知服务商
app.use('/ali/esp/produce/notice', 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);
var result = await gatewaypushlogSve.produceNoticeAliEsp(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/ali/esp/produce/notice",
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: "/ali/esp/produce/notice",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
return JSON.stringify(result);
}
});
// 2020 0928 lin 新增 阿里文网文 服务商侧提供接口2.4 ⽤户⽅案反馈通知服务商
app.use('/ali/esp/intention/solution/feedback', 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);
var result = await gatewaypushlogSve.produceNoticeAliEsp(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "回调处理订单结果:,method=" + req.body.trxcode,
op: "/ali/esp/produce/notice",
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: "/ali/esp/produce/notice",
content: "回调参数:" + JSON.stringify(req.body) + "error:" + error.stack,
clientIp: client_ip || ""
});
return JSON.stringify(result);
}
});
app.get('/api/:gname/:qname/:method', function (req, res) {
......
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