Commit 27989a27 by 宋毅

tj

parent 267d85e0
...@@ -183,6 +183,9 @@ class tmqueryCtl extends CtlBase { ...@@ -183,6 +183,9 @@ class tmqueryCtl extends CtlBase {
} }
async getUserIdEncryptStr(pobj, qobj, req) { async getUserIdEncryptStr(pobj, qobj, req) {
try { try {
if (!req.session.userPinInfo) {
return system.getResult(null, "user is not login...");
}
var tokenInfo = await this.getToken(pobj.actionProcess); var tokenInfo = await this.getToken(pobj.actionProcess);
if (tokenInfo.status != 0) { if (tokenInfo.status != 0) {
return tokenInfo; return tokenInfo;
...@@ -191,7 +194,7 @@ class tmqueryCtl extends CtlBase { ...@@ -191,7 +194,7 @@ class tmqueryCtl extends CtlBase {
var param = { var param = {
actionProcess: pobj.actionProcess, actionProcess: pobj.actionProcess,
actionType: "encryptStr", actionType: "encryptStr",
actionBody: { channelUserId: pobj.channelUserId, opStr: pobj.channelUserId }, actionBody: { channelUserId: req.session.userPinInfo.channelUserId, opStr: req.session.userPinInfo.channelUserId },
isUser: "yes" isUser: "yes"
}; };
var reqUrl = this.channelApiUrl + "/action/tmTools/springBoard"; var reqUrl = this.channelApiUrl + "/action/tmTools/springBoard";
...@@ -202,7 +205,8 @@ class tmqueryCtl extends CtlBase { ...@@ -202,7 +205,8 @@ class tmqueryCtl extends CtlBase {
if (resultUser.status != 0) { if (resultUser.status != 0) {
return system.getResult(null, "encrypt userId is error"); return system.getResult(null, "encrypt userId is error");
} }
return resultUser; req.session.userPinInfo.encryptChannelUserId = resultUser.data || "";
return system.getResultSuccess({ encryptChannelUserId: resultUser.data || "" });
} catch (error) { } catch (error) {
console.log(error.stack, "操作error..................."); console.log(error.stack, "操作error...................");
return system.getResultFail(-200, "操作error"); return system.getResultFail(-200, "操作error");
...@@ -235,24 +239,9 @@ class tmqueryCtl extends CtlBase { ...@@ -235,24 +239,9 @@ class tmqueryCtl extends CtlBase {
} }
async getUserInfo(pobj, qobj, req) { async getUserInfo(pobj, qobj, req) {
try { try {
this.logClient.info("jd", "getUserInfo----->req参数:" + JSON.stringify(pobj));
if (req.session.userPinInfo) { if (req.session.userPinInfo) {
this.logClient.info("jd", "req.session.userPinInfo true 参数:" + JSON.stringify(req.session.userPinInfo)); return system.getResultSuccess({ encryptChannelUserId: req.session.userPinInfo.encryptChannelUserId || "" });
if (!req.session.userPinInfo.encryptChannelUserId) {
pobj.channelUserId = req.session.userPinInfo.channelUserId;
var userIdEncryptStrResult = await this.getUserIdEncryptStr(pobj);
this.logClient.info("jd", "req.session.userPinInfo userIdEncryptStrResult 结果1111111:" + JSON.stringify(userIdEncryptStrResult));
if (userIdEncryptStrResult && userIdEncryptStrResult.status == 0) {
req.session.userPinInfo.encryptChannelUserId = userIdEncryptStrResult.data;
}//重新加密成功
else {
return userIdEncryptStrResult;
}
}
return system.getResultSuccess({ encryptChannelUserId: req.session.userPinInfo.encryptChannelUserId });
} }
// console.log();
var authUrl = pobj.authUrl; var authUrl = pobj.authUrl;
var authToken = pobj.authToken; var authToken = pobj.authToken;
var actionProcess = pobj.actionProcess; var actionProcess = pobj.actionProcess;
...@@ -266,7 +255,6 @@ class tmqueryCtl extends CtlBase { ...@@ -266,7 +255,6 @@ 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);
this.logClient.info("jd", "getUserInfo----->execPostJDTK----authUrl--->result:" + JSON.stringify(result));
if (!result || !result.account) { if (!result || !result.account) {
return system.getResult(null, "处理用户请求失败,msg:" + result.error_description); return system.getResult(null, "处理用户请求失败,msg:" + result.error_description);
} }
...@@ -289,18 +277,7 @@ class tmqueryCtl extends CtlBase { ...@@ -289,18 +277,7 @@ class tmqueryCtl extends CtlBase {
return system.getResult(null, "处理请求失败"); return system.getResult(null, "处理请求失败");
} }
req.session.userPinInfo = resultUser.data; req.session.userPinInfo = resultUser.data;
if (!req.session.userPinInfo.encryptChannelUserId) { return system.getResultSuccess({ encryptChannelUserId: resultUser.data.encryptChannelUserId || "" });
pobj.channelUserId = req.session.userPinInfo.channelUserId;
var userIdEncryptStrResult = await this.getUserIdEncryptStr(pobj);
this.logClient.info("jd", "req.session.userPinInfo userIdEncryptStrResult 结果222222:" + JSON.stringify(userIdEncryptStrResult));
if (userIdEncryptStrResult && userIdEncryptStrResult.status == 0) {
req.session.userPinInfo.encryptChannelUserId = userIdEncryptStrResult.data;
}//重新加密成功
else {
return userIdEncryptStrResult;
}
}
return resultUser;
} catch (error) { } catch (error) {
this.logClient.error("jd", "req---->getUserInfo---->error:" + error.stack); this.logClient.error("jd", "req---->getUserInfo---->error:" + error.stack);
return system.getResultFail(-200, "操作error"); return system.getResultFail(-200, "操作error");
......
...@@ -14,8 +14,7 @@ module.exports = function (app) { ...@@ -14,8 +14,7 @@ module.exports = function (app) {
var getUserparams = { var getUserparams = {
actionProcess: "jd", actionProcess: "jd",
authUrl: "https://oauth2.jdcloud.com/userinfo", authUrl: "https://oauth2.jdcloud.com/userinfo",
authToken: params.token_type + " " + params.access_token, authToken: params.token_type + " " + params.access_token
tmpchannelUserId: params.tmpchannelUserId
}; };
var userItemResult = await tmqueryCtl.getUserInfo(getUserparams, req.query, req); var userItemResult = await tmqueryCtl.getUserInfo(getUserparams, req.query, req);
if (userItemResult.status != 0) { if (userItemResult.status != 0) {
...@@ -23,7 +22,7 @@ module.exports = function (app) { ...@@ -23,7 +22,7 @@ module.exports = function (app) {
return; return;
} }
if (!userItemResult.data.encryptChannelUserId || userItemResult.data.encryptChannelUserId == "undefined") { if (!userItemResult.data.encryptChannelUserId || userItemResult.data.encryptChannelUserId == "undefined") {
userItemResult = await tmqueryCtl.getUserInfo(getUserparams, req.query, req); userItemResult = await tmqueryCtl.getUserIdEncryptStr(getUserparams, req.query, req);
if (userItemResult.status != 0) { if (userItemResult.status != 0) {
res.redirect("/#/jd/jdtrademark"); res.redirect("/#/jd/jdtrademark");
return; return;
......
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