Commit 9a3dd283 by 刘泽奇

Merge branch 'igirl-channel-jdweb' of gitlab.gongsibao.com:jiangyong/zhichan…

Merge branch 'igirl-channel-jdweb' of gitlab.gongsibao.com:jiangyong/zhichan into igirl-channel-jdweb
parents 538168e7 7e74ab17
...@@ -12,6 +12,20 @@ class tmqueryCtl extends CtlBase { ...@@ -12,6 +12,20 @@ class tmqueryCtl extends CtlBase {
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
} }
async doPost(pobj, obj, req) { async doPost(pobj, obj, req) {
if (["subTmOrder", "getTmOrderList", "getTmOrderInfo", "getTmApplyInfo", "getTmNclList",
"getNeedInfo", "tmConfirm", "updateTmInfo", "updateNclInfo",
"updateContacts", "updateCustomerInfo"].indexOf(actionType) >= 0) {
if (!pobj.actionBody.channelUserId) {
return system.getResult(null, "verify channelUserId is not empty");
}
if (!req.session.userPinInfo) {
return system.getResult(null, "ueser is not login");
}
if (req.session.userPinInfo.encryptChannelUserId != pobj.actionBody.channelUserId) {
return system.getResult(null, "ueser login is error");
}
}
var rc = system.getObject("util.execClient"); var rc = system.getObject("util.execClient");
try { try {
if (!pobj.requrl) { if (!pobj.requrl) {
...@@ -130,14 +144,12 @@ class tmqueryCtl extends CtlBase { ...@@ -130,14 +144,12 @@ class tmqueryCtl extends CtlBase {
* 验证签名 * 验证签名
* @param {*} params 要验证的参数 * @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key * @param {*} app_key 应用的校验key
* @param {*} isEmptySign params key 对应值为空是否参与签名
*/ */
async createSign(params, app_key) { async createSign(params, app_key, isEmptySign) {
if (!params) { if (!params) {
return system.getResult(null, "请求参数为空"); return system.getResult(null, "请求参数为空");
} }
if (!params.timeStamp) {
return system.getResult(null, "请求参数timeStamp为空");
}
var signArr = []; var signArr = [];
var keys = Object.keys(params).sort(); var keys = Object.keys(params).sort();
if (keys.length == 0) { if (keys.length == 0) {
...@@ -145,8 +157,18 @@ class tmqueryCtl extends CtlBase { ...@@ -145,8 +157,18 @@ class tmqueryCtl extends CtlBase {
} }
for (let k = 0; k < keys.length; k++) { for (let k = 0; k < keys.length; k++) {
const tKey = keys[k]; const tKey = keys[k];
if (tKey != "sign" && params[tKey]) { if (tKey != "sign") {
signArr.push(tKey + "=" + params[tKey]); if (tKey != "token") {
if (tKey != "actionProcess") {
if (isEmptySign) {
signArr.push(tKey + "=" + params[tKey]);
} else {
if (params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
}
}
}
} }
} }
if (signArr.length == 0) { if (signArr.length == 0) {
...@@ -172,12 +194,10 @@ class tmqueryCtl extends CtlBase { ...@@ -172,12 +194,10 @@ class tmqueryCtl extends CtlBase {
return system.getResult(null, "actionProcess不能为空"); return system.getResult(null, "actionProcess不能为空");
} }
var result = await this.execClient.execPostJDTK("", authUrl, authToken); var result = await this.execClient.execPostJDTK("", authUrl, authToken);
console.log(result, "execPostJDTK............");
if (!result || !result.account) { if (!result || !result.account) {
return system.getResult(null, "处理用户请求失败,msg:" + result.error_description); return system.getResult(null, "处理用户请求失败,msg:" + result.error_description);
} }
var tokenInfo = await this.getToken(actionProcess); var tokenInfo = await this.getToken(actionProcess);
console.log(tokenInfo, "getUserInfo..................getToken............");
if (tokenInfo.status != 0) { if (tokenInfo.status != 0) {
return tokenInfo; return tokenInfo;
} }
...@@ -190,10 +210,10 @@ class tmqueryCtl extends CtlBase { ...@@ -190,10 +210,10 @@ class tmqueryCtl extends CtlBase {
}; };
var reqUrl = this.channelApiUrl + "/action/tmTools/springBoard"; var reqUrl = this.channelApiUrl + "/action/tmTools/springBoard";
var resultUser = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token); var resultUser = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token);
console.log(resultUser, "getUserInfo..................resultUser............");
if (!resultUser) { if (!resultUser) {
return system.getResult(null, "处理请求失败"); return system.getResult(null, "处理请求失败");
} }
req.session.userPinInfo = resultUser.data;
return resultUser; return resultUser;
} catch (error) { } catch (error) {
console.log(error.stack, "操作error..................."); console.log(error.stack, "操作error...................");
...@@ -202,7 +222,12 @@ class tmqueryCtl extends CtlBase { ...@@ -202,7 +222,12 @@ class tmqueryCtl extends CtlBase {
} }
async opPayPageInfo(pobj) { async opPayPageInfo(pobj) {
if (pobj.actionProcess == "jd") { if (pobj.actionProcess == "jd") {
var tmpResult = this.opJdOrder();
if (!tmpResult.success && tmpResult.success != true) {
//记录下来
}
return system.getResultSuccess({ payUrl: tmpResult.data.returnUrl });
} }
return system.getResultSuccess() return system.getResultSuccess()
} }
...@@ -230,8 +255,6 @@ class tmqueryCtl extends CtlBase { ...@@ -230,8 +255,6 @@ class tmqueryCtl extends CtlBase {
ctx.method = 'POST' ctx.method = 'POST'
var signer = new Signer(ctx, credentials); var signer = new Signer(ctx, credentials);
ctx.headers.set('Content-Length', tmpContentLength) ctx.headers.set('Content-Length', tmpContentLength)
ctx.buildNonce() ctx.buildNonce()
var dd = new Date(); var dd = new Date();
...@@ -279,6 +302,58 @@ class tmqueryCtl extends CtlBase { ...@@ -279,6 +302,58 @@ class tmqueryCtl extends CtlBase {
console.log(errorMsg, "--jd>>>>>>>errorMsg..............................>>>>>>"); console.log(errorMsg, "--jd>>>>>>>errorMsg..............................>>>>>>");
} }
} }
async pushJdOrder(pushData, req) {
try {
var signResult = await this.createSign(pushData, "6B876EB84731E166D76E1F73AD5764BA", true);
if (signResult.status != 0) {
return signResult;
}
if (signResult.data != pushData.token.toUpperCase()) {
return system.getResult(null, "签名错误");
}
var tokenInfo = await this.getToken(pushData.actionProcess);
if (tokenInfo.status != 0) {
return tokenInfo;
}
var param = {};
if (pushData.serviceCode == "FW_GOODS-581976") {
param = {
actionProcess: pushData.actionProcess,
actionType: "updateOrderPayStatus",
actionBody: {
channelUserId: pushData.jdPin,
channelItemCode: pushData.serviceCode,
needNoOrderNo: pushData.orderId,
buyerMoblie: pushData.mobile
},
isUser: "yes"
};
}//自助注册产品
else {
//有返回用户信息进行用户ID加密
param = {
actionProcess: pushData.actionProcess,
actionType: "addOrderAndDelivery",
actionBody: {
channelUserId: pushData.jdPin,
needNoOrderNo: pushData.orderId,
buyerMoblie: pushData.mobile
},
isUser: "yes"
};
}//商标注册【专家辅助申请】、商标注册【担保申请】和 除商标之外的产品
var reqUrl = this.channelApiUrl + "/action/tmOrder/springBoard";
var resultUser = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token);
if (!resultUser) {
return system.getResult(null, "req error");
}
return resultUser;
} catch (error) {
console.log(error.stack, "操作error...................");
return system.getResultFail(-200, "操作error");
}
}
} }
module.exports = tmqueryCtl; module.exports = tmqueryCtl;
...@@ -31,7 +31,7 @@ module.exports = function (app) { ...@@ -31,7 +31,7 @@ module.exports = function (app) {
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS'); res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// res.header('Access-Control-Allow-Credentials', 'true'); // res.header('Access-Control-Allow-Credentials', 'true');
if (req.method == 'OPTIONS') { if (req.method == 'OPTIONS') {
res.send(200); /让options请求快速返回/ res.send(200); //让options请求快速返回/
} }
else { else {
next(); next();
...@@ -40,7 +40,7 @@ module.exports = function (app) { ...@@ -40,7 +40,7 @@ module.exports = function (app) {
if(settings.env=="dev"){ if(settings.env=="dev"){
app.use(session( app.use(session(
{ {
name:'devdemosid', name:'userPinInfo',
cookie: {maxAge: 3600000}, cookie: {maxAge: 3600000},
rolling:true, rolling:true,
resave: false, resave: false,
...@@ -53,7 +53,7 @@ module.exports = function (app) { ...@@ -53,7 +53,7 @@ module.exports = function (app) {
}else{ }else{
app.use(session( app.use(session(
{ {
name:'demosid', name:'userPinInfo',
cookie: {maxAge: 3600000}, cookie: {maxAge: 3600000},
rolling:true, rolling:true,
resave: false, resave: false,
......
...@@ -24,9 +24,33 @@ module.exports = function (app) { ...@@ -24,9 +24,33 @@ module.exports = function (app) {
res.redirect(skipUrl); res.redirect(skipUrl);
}); });
app.get("/jd/orderNotify", async function (req, res) { app.get("/jd/orderNotify", async function (req, res) {
console.log(req.query, "req.query.....########################################################.................orderNotify"); // oplogCtl.info({
console.log(req.body, "req.body......########################################################................orderNotify"); // optitle: "########################################################.................orderNotify",
//TODO:处理新购 // op: "/jd/orderNotify",
// content: "req.query=" + JSON.stringify(req.query) + ",req.body=" + JSON.stringify(req.body),
// clientIp: ""
// });
req.query.actionProcess="jd";
var result = await tmqueryCtl.pushJdOrder(req.query, req);
// oplogCtl.info({
// optitle: "############################################操作订单结果.................orderNotify",
// op: "/jd/orderNotify",
// content: "req.query=" + JSON.stringify(req.query) + ",req.body=" + JSON.stringify(req.body),
// clientIp: ""
// });
if (result.status != 0) {
res.end(JSON.stringify(result));
return;
}
var params =
{
instanceId: req.query.orderBizId,
appInfo: {
authUrl: "http://oauth2.jdcloud.com/authorize?response_type=token&redirect_uri=http://tm.plus.jdcloud.com/jdtm/getUser&state=jdindentlist&client_id=9841572588670903"
}
};
res.end(JSON.stringify(params));
return;
}); });
app.get("/", async function (req, res) { app.get("/", async function (req, res) {
try { try {
...@@ -49,29 +73,6 @@ module.exports = function (app) { ...@@ -49,29 +73,6 @@ module.exports = function (app) {
} }
}); });
app.get('/jdtm/:gname/:qname/:method', function (req, res) {
try {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
classPath = gname + "." + classPath;
var params = [];
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = System.getObject("web." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
} catch (error) {
console.log(error.stack, "get/web/:gname/:qname/:method,error.............");
}
});
app.get('/web/:gname/:qname/:method', function (req, res) { app.get('/web/:gname/:qname/:method', function (req, res) {
try { try {
var classPath = req.params["qname"]; var classPath = req.params["qname"];
......
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