Commit f87a38be by 王勇飞

fix: 2.1~2.4 baidu api

parent 0f46314d
......@@ -9,32 +9,32 @@ class Order extends APIBase {
this.gatewaypushlogSve = system.getObject("service.common.gatewaypushlogSve");
}
//状态变更
async notify(pobj,req) {
if(!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret){
async notify(pobj, req) {
if (!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret) {
return regCfg.getResultFail("未知应用或应用未启用");
}
if(!pobj.isDirectBuy || pobj.isDirectBuy == 0){
pobj.isDirectBuy=0;
if (!pobj.isDirectBuy || pobj.isDirectBuy == 0) {
pobj.isDirectBuy = 0;
}
if (!pobj.mainOrderNo) {
return regCfg.getResultFail("mainOrderNo不能为空");
}
var i= 0;
var i = 0;
var orderLength = pobj.subOrderList.lenght;
for(i=0;i<=orderLength;i++){
for (i = 0; i <= orderLength; i++) {
if (!pobj.subOrderList[i].orderNo) {
return regCfg.getResultFail("orderNo不能为空");
}
if (pobj.isDirectBuy==0 && !pobj.subOrderList[i].bizId) {
if (pobj.isDirectBuy == 0 && !pobj.subOrderList[i].bizId) {
return regCfg.getResultFail("非直接下单bizId不能为空");
}
if (pobj.isDirectBuy==1 && !pobj.subOrderList[i].phone) {
if (pobj.isDirectBuy == 1 && !pobj.subOrderList[i].phone) {
return regCfg.getResultFail("直接下单phone不能为空");
}
if (pobj.isDirectBuy==1 && !pobj.subOrderList[i].consultType) {
if (pobj.isDirectBuy == 1 && !pobj.subOrderList[i].consultType) {
return regCfg.getResultFail("直接下单consultType不能为空");
}
// if (pobj.subOrderList[i].area) {
......@@ -44,10 +44,10 @@ class Order extends APIBase {
return regCfg.getResultFail("area参数错误");
}
}
pobj.status = 1;
pobj.action_type = "regOrderStatus";
var param = {
requestId: req.requestId || regCfg.getUUID(),
requestUrl: "/ic/order/notify",
......@@ -61,8 +61,8 @@ class Order extends APIBase {
return regCfg.getResultSuccess(param.requestId);
}
async close(pobj,req){
if(!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret){
async close(pobj, req) {
if (!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret) {
return regCfg.getResultFail("未知应用或应用未启用");
}
if (!pobj.orderNo) {
......@@ -79,7 +79,7 @@ class Order extends APIBase {
pushtimes: 0,//推送次数
pushStatus: "wts",//推送状态
}
await regCfg.gatewaypushlogSve.create(param);
await this.gatewaypushlogSve.create(param);
return regCfg.getResultSuccess(param.requestId);
}
......
......@@ -204,7 +204,7 @@ module.exports = function (app) {
app.use('/orderNotify/channelPayNotify', async function (req, res) {
try {
var client_ip = system.get_client_ip(req);
let result ={};
let result = {};
result = await utilsOrderSve.channelPayNotify(req.body, client_ip);
logCtl.info({
optitle: (new Date()).Format("yyyy-MM-dd hh:mm:ss") + "渠道支付订单通知 api层",
......@@ -395,6 +395,23 @@ module.exports = function (app) {
//-----------------------新的模式---------api---------开始
//百度手动获取签名sign方法
// app.post("/baidu/creatSign", async function (req, res, next) {
// if (!req.body.key) {
// res.end({ code: -200, message: "缺少加签秘钥key参数" });
// return;
// }
// if (!req.body.obj) {
// res.end({ code: -200, message: "缺少obj参数" });
// return;
// }
// let obj = req.body.obj;
// let key = req.body.key;
// let result = await signSve.createSign(obj, key);
// res.end(JSON.stringify(result));
// return;
// });
app.all("/api/*", async function (req, res, next) {
var result = system.getResult(null, "req method must is post");
if (req.method != "POST") {
......@@ -419,7 +436,7 @@ module.exports = function (app) {
}
//1.通过appkey 获取appInfo
var appRes = await signSve.getAppInfoByAppKey(appkey);
if(!appRes || appRes.status!=0){
if (!appRes || appRes.status != 0) {
result.msg = "获取应用信息失败";
result.data = null;
res.end(JSON.stringify(result));
......@@ -429,20 +446,20 @@ module.exports = function (app) {
//2.通过appsecret 验签
req.body.sign = sign;
var signParams = req.body;
var verifyRes = await signSve.verifySign(req.body,appInfo.uapp_secret);
if(verifyRes && verifyRes.status==0){
var verifyRes = await signSve.verifySign(req.body, appInfo.uapp_secret);
if (verifyRes && verifyRes.status == 0) {
req.body.appInfo = appInfo;
req.appInfo = appInfo;
req.actionProcess = appInfo.app_code;
next();
return;
}else{
} else {
res.end(JSON.stringify(verifyRes));
return;
}
}
if (["getAppTokenByHosts", "getAppTokenByAppKey", "getTmNclFilterSearch","feedback","accountingInfo","booksInfo"].indexOf(req.body.actionType) >= 0) {
if (["getAppTokenByHosts", "getAppTokenByAppKey", "getTmNclFilterSearch", "feedback", "accountingInfo", "booksInfo"].indexOf(req.body.actionType) >= 0) {
req.body.actionBody.appHosts = req.host;
next();
return;
......@@ -653,7 +670,7 @@ module.exports = function (app) {
//icp需求推送
app.post('/icp/consultation/submit', function (req, res) {
var p = null;
var params = ["icpnotify","icpSubmitNeed",req.body,req.query,req];
var params = ["icpnotify", "icpSubmitNeed", req.body, req.query, req];
// gname, methodname, pobj, query, req
var invokeObj = system.getObject("api.action.icpnotify");
if (invokeObj["doexecMethod"]) {
......@@ -667,7 +684,7 @@ module.exports = function (app) {
app.post('/icp/feedback/submit', function (req, res) {
var p = null;
req.body.action_type = "icpFeedbackSubmit";
var params = ["icpnotify","icpFeedbackSubmit",req.body,req.query,req];
var params = ["icpnotify", "icpFeedbackSubmit", req.body, req.query, req];
// gname, methodname, pobj, query, req
var invokeObj = system.getObject("api.action.icpnotify");
if (invokeObj["doexecMethod"]) {
......@@ -681,7 +698,7 @@ module.exports = function (app) {
app.post('/icp/order/notify', function (req, res) {
var p = null;
req.body.action_type = "icpNotify";
var params = ["icpnotify","icpNotify",req.body,req.query,req];
var params = ["icpnotify", "icpNotify", req.body, req.query, req];
// gname, methodname, pobj, query, req
var invokeObj = system.getObject("api.action.icpnotify");
if (invokeObj["doexecMethod"]) {
......
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