Commit 5531a501 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 8562237f c860800c
......@@ -10,6 +10,7 @@ class tmqueryCtl extends CtlBase {
jd: { appkey: "201911251551", secret: "56006077354d48858026c80c0e10bef6" }
};
this.execClient = system.getObject("util.execClient");
this.jdOauthUrl = "https://oauth2.jdcloud.com/userinfo";
}
async doPost(pobj, obj, req) {
var rc = system.getObject("util.execClient");
......@@ -157,6 +158,20 @@ class tmqueryCtl extends CtlBase {
return system.getResultSuccess(resultTmpSign);
}
async getUserInfo(pobj, qobj, req) {
try {
var result = await this.execClient.execPostJDTK("", this.jdOauthUrl, qobj.access_token);
console.log(result, "getUserInfo.....result.......");
if (!result || !result.account) {
return system.getResult(null, "处理用户请求失败,msg:" + result.error_description);
}
return system.getResultSuccess(result);
} catch (error) {
console.log(e.stack, "操作error...................");
return system.getResult(null, "操作失败");
}
}
}
module.exports = tmqueryCtl;
// var task = new tmqueryCtl();
......
......@@ -7,12 +7,32 @@ class ExecClient {
this.cmdPostPattern = "curl -k -H 'Content-type: application/json' -d '{data}' {url}";
this.cmdGetPattern = "curl -G -X GET '{url}'";
this.cmdPostTK = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}";
this.cmdJDPostTK = "curl -k -H 'Content-type:text/plain;charset=UTF-8' -H 'metadata:true' -H 'Authorization:{tk}' -d '{data}' {url}";
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
async execPostJDTK(subData, url, token) {
let cmd = this.FetchPostJDTK(subData, url, token);
var result = await this.exec(cmd, {
maxBuffer: 1024 * 1024 * 15
});
var rtn = result.stdout;
if (rtn) {
return JSON.parse(rtn);
} else {
return null;
}
}
FetchPostJDTK(subData, url, token) {
var data = JSON.stringify(subData);
var requestId = this.getUUID();
var cmd = this.cmdJDPostTK.replace(/\{data\}/g,
data).replace(/\{url\}/g, url).replace(/\{tk\}/g, token);
return cmd;
}
async execPostTK(subData, url, token) {
let cmd = this.FetchPostTK(subData, url, token);
var result = await this.exec(cmd, {
......
......@@ -3,40 +3,23 @@ var System = require("../../base/system");
var metaCtl = System.getObject("web.common.metaCtl");
var tmqueryCtl = System.getObject("web.trademark.tmqueryCtl");
module.exports = function (app) {
app.get("/1688/selfRegister", async function (req, res) {
var params = {
actionProcess: "1688",
requrl: "/action/tmOrder/springBoard",
actionType: "op1688ChannelPushOrder",
actionBody: req.query
};
params.actionBody.channelItemCode = "1406046";
var result = await tmqueryCtl.doPost(params, null, req);
if (result.status != 0) {
console.log(result, "result.........");
res.end(JSON.stringify(result));
app.get("/jdtm/getUser", async function (req, res) {
var params = req.query;
if (!params.state) {
res.redirect("/#/jd/jdtrademark");
return;
}
var skipUrl = "/#/1688/jdindentlist?channelUserId=" + encodeURIComponent(result.data);
res.redirect(skipUrl);
});
app.get("/1688/auxRegister", async function (req, res) {
var params = {
actionProcess: "1688",
requrl: "/action/tmOrder/springBoard",
actionType: "op1688ChannelPushOrder",
actionBody: req.query
};
params.actionBody.channelItemCode = "3492659";
var result = await tmqueryCtl.doPost(params, null, req);
if (result.status != 0) {
console.log(result, "result.........");
res.end(JSON.stringify(result));
var userItemResult = await this.tmqueryCtl.getUserInfo(req.body, req.query, req);
if (userItemResult.status != 0) {
res.redirect("/#/jd/jdtrademark");
return;
}
var skipUrl = "/#/1688/jdindentlist?channelUserId=" + encodeURIComponent(result.data);
var skipUrl = "/#/jd/" + params.state + "?channelUserId=" + encodeURIComponent(userItemResult.data.account);
res.redirect(skipUrl);
});
app.get("/jdtm/orderNotify", async function (req, res) {
//TODO:处理新购
});
app.get("/", async function (req, res) {
console.log(req.hostname, "hostname.............");
try {
......
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