Commit 6e04aa48 by 宋毅

tj

parent 16167a82
......@@ -181,6 +181,33 @@ class tmqueryCtl extends CtlBase {
var resultTmpSign = md5(resultSignStr).toUpperCase();
return system.getResultSuccess(resultTmpSign);
}
async getUserIdEncryptStr(pobj, qobj, req) {
try {
var tokenInfo = await this.getToken(pobj.actionProcess);
if (tokenInfo.status != 0) {
return tokenInfo;
}
//有返回用户信息进行用户ID加密
var param = {
actionProcess: pobj.actionProcess,
actionType: "encryptStr",
actionBody: { channelUserId: pobj.channelUserId, opStr: pobj.channelUserId },
isUser: "yes"
};
var reqUrl = this.channelApiUrl + "/action/tmTools/springBoard";
var resultUser = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token);
if (!resultUser) {
return system.getResult(null, "req encrypt userId is error");
}
if (resultUser.status != 0) {
return system.getResult(null, "encrypt userId is error");
}
return resultUser;
} catch (error) {
console.log(error.stack, "操作error...................");
return system.getResultFail(-200, "操作error");
}
}
async getUserInfoTest(pobj, qobj, req) {
try {
var tokenInfo = await this.getToken(pobj.actionProcess);
......@@ -211,6 +238,17 @@ class tmqueryCtl extends CtlBase {
this.logClient.info("jd", "getUserInfo----->req参数:" + JSON.stringify(pobj));
if (req.session.userPinInfo) {
this.logClient.info("jd", "req.session.userPinInfo true 参数:" + JSON.stringify(req.session.userPinInfo));
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 });
}
......@@ -251,13 +289,33 @@ class tmqueryCtl extends CtlBase {
return system.getResult(null, "处理请求失败");
}
req.session.userPinInfo = resultUser.data;
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 结果222222:" + JSON.stringify(userIdEncryptStrResult));
if (userIdEncryptStrResult && userIdEncryptStrResult.status == 0) {
req.session.userPinInfo.encryptChannelUserId = userIdEncryptStrResult.data;
}//重新加密成功
else {
return userIdEncryptStrResult;
}
}
return resultUser;
} catch (error) {
this.logClient.error("jd", "req---->getUserInfo---->error:" + error.stack);
return system.getResultFail(-200, "操作error");
}
}
async opPayPageInfo(pobj, orderResult, req) {
var reqobj = {
"actionProcess": pobj.actionProcess || "",
"actionType": pobj.actionType || "",
"sign": pobj.sign || "",
"isUser": pobj.isUser || "yes",//是否需要验证用户,no否,yes是
"isDecryptUser": pobj.isDecryptUser || "no",//是否解密用户Id,no否,yes是
"actionBody": pobj.actionBody || null
};
async opPayPageInfo(pobj, orderResult, req) {
if (!pobj.actionBody.itemCode) {
return system.getResult(null, "itemCode param is not empty");
}
......@@ -285,8 +343,8 @@ class tmqueryCtl extends CtlBase {
return system.getResult(null, "pay page is error");
}
return system.getResultSuccess();
}
async putPayOrderData(pobj, orderResult, payDataResult, req) {
}
async putPayOrderData(pobj, orderResult, payDataResult, req) {
var tokenInfo = await this.getToken(pobj.actionProcess);
if (tokenInfo.status != 0) {
return tokenInfo;
......@@ -307,8 +365,8 @@ class tmqueryCtl extends CtlBase {
var reqUrl = this.channelApiUrl + "/action/tmOrder/springBoard";
var tmp = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token);
console.log(tmp, "putPayOrderData########################################333333..........tmptmptmptmp.................");
}
async getPayPageAddr(itemCode, itemCodeList, req) {
}
async getPayPageAddr(itemCode, itemCodeList, req) {
try {
const { Signer, Context } = require('../jd-gateway-sdk');
......@@ -417,8 +475,8 @@ class tmqueryCtl extends CtlBase {
console.log(errorMsg, "--jd>>>>>>>errorMsg..............................>>>>>>");
return { success: false, code: -200, msg: errorMsg.stack };
}
}
async pushPayOrder(pushData, req) {//处理京东推送的订单信息
}
async pushPayOrder(pushData, req) {//处理京东推送的订单信息
try {
var signResult = await this.createSign(pushData, "6B876EB84731E166D76E1F73AD5764BA", true);
if (signResult.status != 0) {
......@@ -471,7 +529,7 @@ class tmqueryCtl extends CtlBase {
console.log(error.stack, "操作error...................");
return system.getResultFail(-200, "操作error");
}
}
}
}
module.exports = tmqueryCtl;
......@@ -2,7 +2,7 @@
var system = require("../../base/system");
var metaCtl = system.getObject("web.common.metaCtl");
var tmqueryCtl = system.getObject("web.trademark.tmqueryCtl");
// var logClient = system.getObject("util.logClient");
var logClient = system.getObject("util.logClient");
module.exports = function (app) {
app.get("/jdtm/getUser", async function (req, res) {
try {
......@@ -32,8 +32,7 @@ module.exports = function (app) {
var skipUrl = "/#/jd/" + params.state + "?channelUserId=" + encodeURIComponent(userItemResult.data.encryptChannelUserId);
res.redirect(skipUrl);
} catch (error) {
console.log("req---->/jdtm/getUser---->error:" + error.stack);
// logClient.error("jd", "req---->/jdtm/getUser---->error:" + error.stack);
logClient.error("jd", "req---->/jdtm/getUser---->error:" + error.stack);
}
});
app.get("/jdtm/getUserTest", async 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