Commit 2b8fa150 by 宋毅

tj

parent 91e33a4e
......@@ -9,6 +9,7 @@ class UtilsNeedSve extends AppServiceBase {
super();
this.execlient = system.getObject("util.execClient");
this.channelApiUrl = settings.channelApiUrl();
this.centerChannelUrl = settings.centerChannelUrl();
this.appInfo = {
aliyuntmtransfer: { appkey: settings.appKey, secret: settings.secret }
};
......@@ -33,6 +34,28 @@ class UtilsNeedSve extends AppServiceBase {
return tokenResult;
}
async getCenterToken() {
var self = this;
var reqTokenUrl = this.centerChannelUrl + "/web/auth/accessAuth/getAppTokenByAppKey";
var reqParam = self.appInfo["aliyuntmtransfer"];
if (!reqParam.appkey || !reqParam.secret) {
return system.getResult(null, "reqType类型有误,请求失败");
}
var param = {
"actionType": "getAppTokenByAppKey",
"actionBody": {
"appkey": reqParam.appkey,
"secret": reqParam.secret
}
};
var rtn = await this.execlient.execPost(param, reqTokenUrl);
if (!rtn.stdout) {
return system.getResult(null, "获取token失败");
}
var tokenResult = JSON.parse(rtn.stdout);
return tokenResult;
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
......@@ -41,15 +64,52 @@ class UtilsNeedSve extends AppServiceBase {
async reqcenterchannel(pobj) {
var sobj = {
"actionProcess": "ali",
"actionType": pobj.action_type,
"isUser": "yes",
"actionBody": pobj
}
var tokenInfo = await this.getToken();
var url = settings.centerChannelUrl() + "web/opreceive/need/springBoard";
var tokenInfo = await this.getCenterToken();
if (tokenInfo.status != 0) {
return {
"requestId": self.getUUID(),
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
// //获取用户userpin
// var userpin = "";
// pobj.actionType = "getLoginByUserName";
// pobj.actionBody.channelUserId = actionBody.channelUserId;//渠道用户id,没有则用手机号
// pobj.actionBody.mobile = userMoblie;//用户手机号
// var url = settings.centerChannelUrl() + "/web/auth/accessAuth/springBoard";
// var userpinResult = await this.execlient.execPostTK(pobj, url, token);
// if (!userpinResult || !userpinResult.stdout) {
// return system.getResult(null, userpinResult.msg);
// }
// var userpinResultTmp = JSON.parse(userpinResult.stdout);
// if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) {
// return system.getResultFail(-99, "获取userpin失败");
// }
// userpin = userpinResultTmp.data.userpin;
// if (!userpin) {
// return system.getResultFail(-88, "获取userpin失败!!");
// }
//带userpin请求
// url = settings.centerChannelUrl() + "web/opaction/order/springBoard";
// pobj.actionType = "getOrderDeliveryFlowInfo";
// var rtn = await this.execlient.execDataPostByTokenUserPin(pobj, url, token, userpin);
// if (!rtn || !rtn.stdout) {
// return system.getResult(null, "execPost is empty");
// }
// var result = JSON.parse(rtn.stdout);
var url = settings.centerChannelUrl() + "/web/opreceive/need/springBoard";
var rtn = await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
var self=this;
var self = this;
return {
"requestId": self.getUUID(),
"success": true,
......
......@@ -7,6 +7,7 @@ class ExecClient {
this.cmdPostPattern = "curl --user admines:adminGSBes. -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.cmdDataPostByTokenUserPinPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'userpin:{UPIN}' -d '{data}' {url}";
}
async exec(cmd) {
......@@ -44,6 +45,19 @@ class ExecClient {
return cmd;
}
async execDataPostByTokenUserPin(subData, url, token, userPin) {
let cmd = this.execDataPostByTokenUserPinCmd(subData, url, token, userPin);
var result = await this.exec(cmd);
return result;
}
execDataPostByTokenUserPinCmd(subData, url, token, userPin) {
var data = JSON.stringify(subData);
var cmd = this.cmdDataPostByTokenUserPinPattern.replace(/\{data\}/g,
data).replace(/\{url\}/g, url).replace(/\{tk\}/g, token).replace(/\{UPIN\}/g, userPin);
console.log(cmd);
return cmd;
}
async exec2(cmd) {
return exec(cmd, {encoding: "base64"});
}
......
......@@ -40,9 +40,9 @@ var settings = {
},
centerChannelUrl: function () {
if (this.env == "dev") {
return "http://gsb.qifu.gongsibao.com:4012/";//localsettings.reqEsDevUrl;
return "http://gsb.qifu.gongsibao.com:4012";//localsettings.reqEsDevUrl;
} else {
return "http://gsb.qifu.gongsibao.com:4012/";
return "http://gsb.qifu.gongsibao.com:4012";
}
},
......
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