Commit d8ca5d89 by 宋毅

tj

parent a374b20e
...@@ -118,6 +118,10 @@ class tmqueryCtl extends CtlBase { ...@@ -118,6 +118,10 @@ class tmqueryCtl extends CtlBase {
var opJdPayPageInfoResult = await this.opJdPayPageInfo(pobj, result, req); var opJdPayPageInfoResult = await this.opJdPayPageInfo(pobj, result, req);
return opJdPayPageInfoResult; return opJdPayPageInfoResult;
} }
else if (["gsb"].indexOf(pobj.actionProcess) >= 0 && pobj.actionType == "subTmOrder") {
var opGsbPayPageInfoResult = await this.opGsbPayPageInfo(pobj, result, req);
return opGsbPayPageInfoResult;
}
return result; return result;
} catch (e) { } catch (e) {
console.log(e.stack, "操作error..................."); console.log(e.stack, "操作error...................");
...@@ -501,7 +505,7 @@ class tmqueryCtl extends CtlBase { ...@@ -501,7 +505,7 @@ class tmqueryCtl extends CtlBase {
var reqUrl = this.channelApiUrl + "/action/tmOrder/springBoard"; var reqUrl = this.channelApiUrl + "/action/tmOrder/springBoard";
this.logClient.error("jd", "req---->pushJdPayOrder---->params:" + JSON.stringify(param) + ",reqUrl:" + reqUrl); this.logClient.error("jd", "req---->pushJdPayOrder---->params:" + JSON.stringify(param) + ",reqUrl:" + reqUrl);
var resultUser = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token); var resultUser = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token);
if (!resultUser) { if (!resultUser) {
this.logClient.error("jd", "req---->pushJdPayOrder---->error:" + JSON.stringify(resultUser)); this.logClient.error("jd", "req---->pushJdPayOrder---->error:" + JSON.stringify(resultUser));
...@@ -522,95 +526,46 @@ class tmqueryCtl extends CtlBase { ...@@ -522,95 +526,46 @@ class tmqueryCtl extends CtlBase {
if (!pobj.actionBody.itemCode) { if (!pobj.actionBody.itemCode) {
return system.getResult(null, "itemCode param is not empty"); return system.getResult(null, "itemCode param is not empty");
} }
return system.getResultSuccess();
}
async getGsbPayPageAddr(itemCode, itemCodeList, req) {//获取京东下单
try { try {
const { Signer, Context } = require('../jd-gateway-sdk'); var tokenInfo = await this.getToken(pobj.actionProcess);
let ctx = new Context('x3k0s704lfun.cn-north-1.jdcloud-api.net', '/market/order/api/submit', 'POST', null, 'empty'); if (tokenInfo.status != 0) {
ctx.regionId = 'cn-north-1' return tokenInfo;
ctx.headers.set('content-type', 'application/json');
let credentials = {
accessKeyId: 'C6D680733C19362B5DF478207D6A90A4', //替换自己的AK
secretAccessKey: 'EB9AFEE49CE41700CADD5F2EE3B2122C' //替换自己的SK--jd>>>>>>>
} }
//测试报文: var param = {
//ctx.body = "pin=jcloud_pRiHQTd&serviceId=580010&itemCode=FW_GOODS-580010-1&platform=6" actionProcess: pobj.actionProcess,
//POST actionType: "subGsbOrderInfo",
var qs = require('querystring'); actionBody: {
// var post_data = { pin: "syaify", serviceId: 580010, itemCode: "FW_GOODS-580010-1", platform: 6, orderNum: 1, articleType: 1 };//这是需要提交的数据 channelUserId: req.session.userPinInfo.channelUserId,
channelItemCode: pobj.actionBody.itemCode,
var post_data = { order_param: {
pin: req.session.userPinInfo.channelUserId, mobile_phone: pobj.actionBody.apply.mobile || "18888888888",//必填
serviceId: itemCodeList[1], goods_list: [{//必填
itemCode: itemCode, goods_name: pobj.actionBody.itemCode,
platform: 6, goods_quantity: 1,
orderNum: 1, }],
articleType: 1, order_price: 300,//必填
additions: '{ \"246\": 0 }' province_name: "",//省
};//这是需要提交的数据 city_name: "",//市
district_name: ""//区
// var tmpContent = '{"pin":"syaify","serviceId":"581976","itemCode":"FW_GOODS-581976","platform":6,"orderNum":1,"articleType":1,"additions":{"246":0}}'; }
var tmpContent = JSON.stringify(post_data); },
var tmpContentLength = Buffer.byteLength(tmpContent); isUser: "yes"
ctx.body = tmpContent;
ctx.method = 'POST'
var signer = new Signer(ctx, credentials);
ctx.headers.set('Content-Length', tmpContentLength)
ctx.buildNonce()
var dd = new Date();
var auth = signer.sign(dd)
console.log("POST签名为:", auth)
ctx.headers.set('Authorization', auth)
////////////////////////////////////////////////////////////////////////////////////////////////////////////
var http = require('https');
var options = {
host: 'x3k0s704lfun.cn-north-1.jdcloud-api.net',
port: 443,
path: '/market/order/api/submit',
method: 'POST',
headers: {
}
}; };
var reqUrl = this.channelApiUrl + "/action/tmOrder/springBoard";
for (let [key, value] of ctx.headers) { console.log("req---->opGsbPayPageInfo---->params:" + JSON.stringify(param) + ",reqUrl:" + reqUrl);
options.headers[key] = value var result = await this.execClient.execPostTK(param, reqUrl, tokenInfo.data.token);
if (!result) {
console.log("req---->opGsbPayPageInfo---->error:" + JSON.stringify(result));
return system.getResult(null, "req error");
} }
return result;
this.logClient.info("jd", "req---->getJdPayPageAddr---->options:" + JSON.stringify(options)); } catch (error) {
this.logClient.info("jd", "req---->getJdPayPageAddr---->tmpContent:" + tmpContent); console.log("req---->opGsbPayPageInfo---->操作error:" + error.stack);
var reqResult = await new Promise(function (resolve, reject) { return system.getResultFail(-200, "操作error");
let req = http.request(options, function (res) {
// res.setEncoding(encoding);
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
var _data = '';
res.on('data', function (chunk) {
_data += chunk;
});
res.on('end', function () {
console.log("\n--req---成功->>\nresult:", _data)
resolve({ result: true, data: _data });
});
});
req.on('error', (e) => {
console.error(`请求遇到问题-------------: ${e.message}`);
resolve({ result: false, errmsg: e.message });
});
req.write(tmpContent);
req.end();
});
return reqResult;
} catch (errorMsg) {
this.logClient.error("jd", "req---->getJdPayPageAddr---->error:" + error.stack);
return { success: false, code: -200, msg: error.stack };
} }
return system.getResultSuccess();
} }
async pushGsbPayOrder(pushData, req) {//处理京东推送的订单信息 async pushGsbPayOrder(pushData, req) {//处理京东推送的订单信息
try { try {
......
...@@ -7,6 +7,11 @@ var logClient = system.getObject("util.logClient"); ...@@ -7,6 +7,11 @@ var logClient = system.getObject("util.logClient");
const jwt = require('jsonwebtoken'); const jwt = require('jsonwebtoken');
const secret = '3rZ3aNfGAyQAB4sE'; //自定义 const secret = '3rZ3aNfGAyQAB4sE'; //自定义
module.exports = function (app) { module.exports = function (app) {
app.get("/admin", async function (req, res) {
res.redirect("http://oauth2.jdcloud.com/authorize?response_type=token&redirect_uri=http://tm.plus.jdcloud.com/jdtm/getUser&state=OAjdlist&client_id=9841572588670903");
return;
});
app.get("/jdtm/getUser", async function (req, res) { app.get("/jdtm/getUser", async function (req, res) {
try { try {
var params = req.query; var params = req.query;
...@@ -48,47 +53,6 @@ module.exports = function (app) { ...@@ -48,47 +53,6 @@ module.exports = function (app) {
}); });
} }
}); });
// app.get("/login", async function (req, res) {
// try {
// var params = req.query;
// if (!params.state || !params.token_type || !params.access_token) {
// res.redirect("http://oauth2.jdcloud.com/authorize?response_type=token&redirect_uri=http://tm.plus.jdcloud.com/jdtm/getUser&state=jdindentlist&client_id=9841572588670903");
// return;
// }
// var getUserparams = {
// actionProcess: "jd",
// authUrl: "https://oauth2.jdcloud.com/userinfo",
// authToken: params.token_type + " " + params.access_token
// };
// var userItemResult = await tmqueryCtl.getJdUserInfo(getUserparams, req.query, req);
// logClient.info("jd", {
// optitle: "###获取京东用户结果...getJdUserInfo",
// op: "/jdtm/loginUser",
// content: "参数=" + JSON.stringify(getUserparams) + ",result=" + JSON.stringify(userItemResult),
// clientIp: ""
// });
// if (userItemResult.status != 0) {
// res.redirect("/#/jd/jdindentlist");
// return;
// }
// if (!userItemResult.data.encryptChannelUserId || userItemResult.data.encryptChannelUserId == "undefined") {
// userItemResult = await tmqueryCtl.getUserIdEncryptStr(getUserparams, req.query, req);
// if (userItemResult.status != 0) {
// res.redirect("/#/jd/jdindentlist");
// return;
// }
// }
// var skipUrl = "/#/jd/" + params.state + "?channelUserId=" + encodeURIComponent(userItemResult.data.encryptChannelUserId);
// res.redirect(skipUrl);
// } catch (error) {
// logClient.error("jd", {
// optitle: "###获取京东用户异常...getJdUserInfo",
// op: "/jdtm/loginUser",
// content: error.stack,
// clientIp: ""
// });
// }
// });
app.get("/jd/orderNotify", async function (req, res) { app.get("/jd/orderNotify", async function (req, res) {
logClient.payLog("jd", { logClient.payLog("jd", {
optitle: "###操作订单结果参数...orderNotify", optitle: "###操作订单结果参数...orderNotify",
...@@ -202,8 +166,13 @@ module.exports = function (app) { ...@@ -202,8 +166,13 @@ module.exports = function (app) {
res.redirect(skipUrl); res.redirect(skipUrl);
}); });
app.get("/gsb/selfRegister", async function (req, res) { app.get("/gsb", async function (req, res) {
var skipUrl = "/#/gsb/selftmreg?channelUserId="; var skipUrl = "/#/gsb/selftmreg?channelUserId=";
var params = req.query;
if (!params.state) {
res.redirect(skipUrl);
return;
}
var token = req.cookies.ic_token; var token = req.cookies.ic_token;
if (!token) { if (!token) {
res.redirect(skipUrl); res.redirect(skipUrl);
...@@ -230,9 +199,39 @@ module.exports = function (app) { ...@@ -230,9 +199,39 @@ module.exports = function (app) {
res.redirect(skipUrl); res.redirect(skipUrl);
return; return;
} }
skipUrl = skipUrl + encodeURIComponent(userItemResult.data.encryptChannelUserId); skipUrl = "/#/gsb/" + params.state + "?channelUserId=" + encodeURIComponent(userItemResult.data.encryptChannelUserId);
res.redirect(skipUrl); res.redirect(skipUrl);
}); });
app.get("/gsb/orderNotify", async function (req, res) {
logClient.payLog("jd", {
optitle: "###操作订单结果参数...orderNotify",
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.pushJdPayOrder(req.query, req);
logClient.payLog("jd", {
optitle: "###操作订单结果...orderNotify",
op: "/jd/orderNotify",
content: "result=" + JSON.stringify(result),
clientIp: ""
});
if (result.status != 0) {
res.end(JSON.stringify(result));
return;
}
var params =
{
instanceId: req.query.orderBizId,
appInfo: {
authUrl: "https://tm.plus.jdcloud.com/jd/skipPage?channelUserId=" + req.query.jdPin,
adminUrl: "https://tm.plus.jdcloud.com"
}
};
res.end(JSON.stringify(params));
return;
});
app.get("/", async function (req, res) { app.get("/", async function (req, res) {
try { try {
var appinfo = await metaCtl.getAppInfo(req); var appinfo = await metaCtl.getAppInfo(req);
......
...@@ -106,12 +106,6 @@ basecomp.forEach(function (comp) { ...@@ -106,12 +106,6 @@ basecomp.forEach(function (comp) {
}else{ }else{
this.logins.push({"icon":"el-icon-arrow-right","title":"退出","type":"text",key:"exit","isOnGrid":true}); this.logins.push({"icon":"el-icon-arrow-right","title":"退出","type":"text",key:"exit","isOnGrid":true});
} }
this.checkLogin(()=>{
if(location.hash=="#/"){
this.$router.push("/index");
}
});
}, },
methods:{ methods:{
initWindowShow(){ initWindowShow(){
......
...@@ -209,7 +209,6 @@ axios.get("/web/common/metaCtl/getRouteConfig").then(d => { ...@@ -209,7 +209,6 @@ axios.get("/web/common/metaCtl/getRouteConfig").then(d => {
} else { } else {
this.logins.push({ "icon": "el-icon-arrow-right", "title": "退出", "type": "text", key: "exit", "isOnGrid": true }); this.logins.push({ "icon": "el-icon-arrow-right", "title": "退出", "type": "text", key: "exit", "isOnGrid": true });
} }
this.checkLogin();
}, },
methods: { methods: {
// 返回当前接入渠道标识 // 返回当前接入渠道标识
......
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