Commit ca5784f2 by 宋毅

tj

parent e82034fa
...@@ -10,7 +10,6 @@ class tmqueryCtl extends CtlBase { ...@@ -10,7 +10,6 @@ class tmqueryCtl extends CtlBase {
jd: { appkey: "201911251551", secret: "56006077354d48858026c80c0e10bef6" } jd: { appkey: "201911251551", secret: "56006077354d48858026c80c0e10bef6" }
}; };
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
this.jdOauthUrl = "https://oauth2.jdcloud.com/userinfo";
} }
async doPost(pobj, obj, req) { async doPost(pobj, obj, req) {
var rc = system.getObject("util.execClient"); var rc = system.getObject("util.execClient");
...@@ -92,8 +91,9 @@ class tmqueryCtl extends CtlBase { ...@@ -92,8 +91,9 @@ class tmqueryCtl extends CtlBase {
if (!result) { if (!result) {
return system.getResult(null, "处理请求失败"); return system.getResult(null, "处理请求失败");
} }
if (result.status && result.status != 0) { if (["jd"].indexOf(pobj.actionProcess).length >= 0 && pobj.actionType == "subTmOrder") {
return result; var opPayPageInfoResult = await opPayPageInfo(pobj);
return opPayPageInfoResult;
} }
return result; return result;
} catch (e) { } catch (e) {
...@@ -101,7 +101,6 @@ class tmqueryCtl extends CtlBase { ...@@ -101,7 +101,6 @@ class tmqueryCtl extends CtlBase {
return system.getResult(null, "操作失败"); return system.getResult(null, "操作失败");
} }
} }
async getToken(reqType) { async getToken(reqType) {
var self = this; var self = this;
var token = ""; var token = "";
...@@ -160,19 +159,45 @@ class tmqueryCtl extends CtlBase { ...@@ -160,19 +159,45 @@ class tmqueryCtl extends CtlBase {
async getUserInfo(pobj, qobj, req) { async getUserInfo(pobj, qobj, req) {
try { try {
console.log(qobj, "getUserInfo..######################.qobj...."); var authUrl = pobj.authUrl;
var result = await this.execClient.execPostJDTK("", this.jdOauthUrl, qobj.token_type + " " + qobj.access_token); var authToken = pobj.authToken;
console.log(result, "getUserInfo.....result......."); if (!authUrl) {
return system.getResult(null, "authUrl不能为空");
}
if (!authToken) {
return system.getResult(null, "authToken不能为空");
}
var result = await this.execClient.execPostJDTK("", authUrl, authToken);
if (!result || !result.account) { if (!result || !result.account) {
return system.getResult(null, "处理用户请求失败,msg:" + result.error_description); return system.getResult(null, "处理用户请求失败,msg:" + result.error_description);
} }
return system.getResultSuccess(result); var tokenInfo = await this.getToken(pobj.actionProcess);
if (tokenInfo.status != 0) {
return tokenInfo;
}
//有返回用户信息进行用户ID加密
var param = {
channelUserId: result.data.account,
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, "处理请求失败");
}
return resultUser;
} catch (error) { } catch (error) {
console.log(e.stack, "操作error..................."); console.log(e.stack, "操作error...................");
return system.getResult(null, "操作失败"); return system.getResultFail(-200, "操作error");
}
}
async opPayPageInfo(pobj) {
if (pobj.actionProcess == "jd") {
} }
return system.getResultSuccess()
} }
async getJdSign(pobj, qobj, req) { async opJdOrder(pobj, qobj, req) {
try { try {
const { Signer, Context } = require('../jd-gateway-sdk'); const { Signer, Context } = require('../jd-gateway-sdk');
let ctx = new Context('x3k0s704lfun-test.cn-north-1.jdcloud-api.net', '/market/order/api/submit', 'POST', null, 'empty'); let ctx = new Context('x3k0s704lfun-test.cn-north-1.jdcloud-api.net', '/market/order/api/submit', 'POST', null, 'empty');
...@@ -248,20 +273,3 @@ class tmqueryCtl extends CtlBase { ...@@ -248,20 +273,3 @@ class tmqueryCtl extends CtlBase {
} }
module.exports = tmqueryCtl; module.exports = tmqueryCtl;
// var task = new tmqueryCtl();
// var obj={
// "currentpage": 1,
// "keyword": "萌",
// "max": "",
// "min": "",
// "order": "",
// "pagesize": 36,
// "sort": "",
// "tm_nclcode": [],
// "tm_structure": "",
// "tm_word": ""
// };
// task.test(obj).then(d=>{
// console.log("dddddddddddddddddddddddddddddd");
// console.log(d);
// })
...@@ -4,18 +4,22 @@ var metaCtl = System.getObject("web.common.metaCtl"); ...@@ -4,18 +4,22 @@ var metaCtl = System.getObject("web.common.metaCtl");
var tmqueryCtl = System.getObject("web.trademark.tmqueryCtl"); var tmqueryCtl = System.getObject("web.trademark.tmqueryCtl");
module.exports = function (app) { module.exports = function (app) {
app.get("/jdtm/getUser", async function (req, res) { app.get("/jdtm/getUser", async function (req, res) {
console.log(req.query,"/jdtm/getUser...................."); console.log(req.query, "/jdtm/getUser....................");
var params = req.query; var params = req.query;
if (!params.state) { if (!params.state) {
res.redirect("/#/jd/jdtrademark"); res.redirect("/#/jd/jdtrademark");
return; return;
} }
var userItemResult = await tmqueryCtl.getUserInfo(req.body, req.query, req); var getUserparams = {
authUrl: "https://oauth2.jdcloud.com/userinfo",
authToken: params.token_type + " " + params.access_token
};
var userItemResult = await tmqueryCtl.getUserInfo(getUserparams, req.query, req);
if (userItemResult.status != 0) { if (userItemResult.status != 0) {
res.redirect("/#/jd/jdtrademark"); res.redirect("/#/jd/jdtrademark");
return; return;
} }
var skipUrl = "/#/jd/" + params.state + "?channelUserId=" + encodeURIComponent(userItemResult.data.account); var skipUrl = "/#/jd/" + params.state + "?channelUserId=" + encodeURIComponent(userItemResult.data.encryptChannelUserId);
res.redirect(skipUrl); res.redirect(skipUrl);
}); });
app.get("/jdtm/orderNotify", async function (req, res) { app.get("/jdtm/orderNotify", 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