Commit 8d07b5f0 by 宋毅

Mestrge branch 'center-channel' of gitlab.gongsibao.com:jiangyong/zhichan into center-channel

parents 383263e3 8be567a5
...@@ -112,9 +112,12 @@ class AccessAuthAPI extends WEBBase { ...@@ -112,9 +112,12 @@ class AccessAuthAPI extends WEBBase {
case "logout"://用户退出--已经废弃,前端自己进行移除userpin信息 case "logout"://用户退出--已经废弃,前端自己进行移除userpin信息
opResult = await this.utilsAuthSve.userLogout(pobj, pobj.actionBody); opResult = await this.utilsAuthSve.userLogout(pobj, pobj.actionBody);
break; break;
case "getAllChannels": case "getAllChannels"://获取所有渠道(去重appid、app名字)
opResult = await this.utilsAuthSve.getAllChannels(pobj); opResult = await this.utilsAuthSve.getAllChannels(pobj);
break; break;
case "getAllService"://获取所有渠道(信息更全一些)
opResult = await this.utilsAuthSve.getAllService(pobj);
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
...@@ -206,16 +206,7 @@ class NcService extends AppServiceBase { ...@@ -206,16 +206,7 @@ class NcService extends AppServiceBase {
var reqUrl = this.centerOrderUrl + "action/qcapi/springBoard"; var reqUrl = this.centerOrderUrl + "action/qcapi/springBoard";
var result = await this.restPostUrl(pobj, reqUrl); var result = await this.restPostUrl(pobj, reqUrl);
console.log('nc 关闭需求result-----',result) console.log('nc 关闭需求result-----',result)
if (result.status == 0) { if (result && result.status == 0) {
if (result.data && result.data.orderNo) {
pobj.actionBody.orderNo = result.data.orderNo;
var orderrtn = await this.utilsOrderSve.delOrder(pobj, pobj.actionBody);
console.log("orderrtn +++ +++ ++",orderrtn)
if (orderrtn.status < 0) {
return system.getResultFail(-5022, "订单关闭失败");
}
}
//推送交付系统 //推送交付系统
var reqParams = { var reqParams = {
actionBody: { actionBody: {
......
...@@ -352,18 +352,18 @@ class RegCenterOrderService extends AppServiceBase { ...@@ -352,18 +352,18 @@ class RegCenterOrderService extends AppServiceBase {
//关闭reg订单 //关闭reg订单
async regOrderClose(pobj) { async regOrderClose(pobj) {
var actionBody = pobj.actionBody; // var actionBody = pobj.actionBody;
var self = this; var self = this;
var url = settings.centerOrderUrl() + "action/regapi/springBoard"; var url = settings.centerOrderUrl() + "action/regapi/springBoard";
var rtn = await this.restPostUrl(pobj, url); var rtn = await this.restPostUrl(pobj, url);
if (rtn.status == 0 && rtn.data) { if (rtn.status == 0 && rtn.data) {
var channelOrderNo = pobj.actionBody.orderNo; var channelOrderNo = pobj.actionBody.orderNo;
pobj.actionBody.orderNo = rtn.data.orderNo; // pobj.actionBody.orderNo = rtn.data.orderNo;
pobj.actionType="delOrder"; // pobj.actionType="delOrder";
var orderrtn = await self.utilsOrderSve.delOrder(pobj, actionBody); // var orderrtn = await self.utilsOrderSve.delOrder(pobj, actionBody);
if (orderrtn.status < 0) { // if (orderrtn.status < 0) {
return system.getResultFail(-5022, "订单关闭失败"); // return system.getResultFail(-5022, "订单关闭失败");
} // }
var tmpObj = { var tmpObj = {
actionBody: { actionBody: {
orderNo: rtn.data.orderNo, orderNo: rtn.data.orderNo,
...@@ -506,23 +506,8 @@ class RegCenterOrderService extends AppServiceBase { ...@@ -506,23 +506,8 @@ class RegCenterOrderService extends AppServiceBase {
var reqUrl = this.centerOrderUrl + "action/regapi/springBoard"; var reqUrl = this.centerOrderUrl + "action/regapi/springBoard";
var result = await this.restPostUrl(pobj, reqUrl); var result = await this.restPostUrl(pobj, reqUrl);
console.log('regNeedClose+++result', result) console.log('regNeedClose+++result', result)
var i;
var len; if (result && result.status == 0) {
if(result && result.data ){
len = result.data.length
}
var orders = []
if (result.status == 0) {
for(i=0;i<len;i++){
if (result.data && result.data[i].orderNo) {
orders.push(result.data[i].orderNo)
pobj.actionBody.orderNo = orders;
var orderrtn = await this.utilsOrderSve.delOrders(pobj, pobj.actionBody);
if (orderrtn.status < 0) {
return system.getResultFail(-5022, "订单关闭失败");
}
}
}
//推送交付系统 //推送交付系统
var reqParams = { var reqParams = {
actionBody: { actionBody: {
......
...@@ -209,16 +209,7 @@ class RtService extends AppServiceBase { ...@@ -209,16 +209,7 @@ class RtService extends AppServiceBase {
var reqUrl = this.centerOrderUrl + "action/qcapi/springBoard"; var reqUrl = this.centerOrderUrl + "action/qcapi/springBoard";
var result = await this.restPostUrl(pobj, reqUrl); var result = await this.restPostUrl(pobj, reqUrl);
console.log('rt 关闭需求result-----',result) console.log('rt 关闭需求result-----',result)
if (result.status == 0) { if (result && result.status == 0) {
if (result.data && result.data.orderNo) {
pobj.actionBody.orderNo = result.data.orderNo;
var orderrtn = await this.utilsOrderSve.delOrder(pobj, pobj.actionBody);
console.log("orderrtn +++ +++ ++",orderrtn)
if (orderrtn.status < 0) {
return system.getResultFail(-5022, "订单关闭失败");
}
}
//推送交付系统 //推送交付系统
var reqParams = { var reqParams = {
actionBody: { actionBody: {
......
...@@ -5,303 +5,313 @@ const jwt = require('jsonwebtoken'); ...@@ -5,303 +5,313 @@ const jwt = require('jsonwebtoken');
const { PDICT } = require("../../../../config/businessConfig"); const { PDICT } = require("../../../../config/businessConfig");
//用户权限操作 //用户权限操作
class UtilsAuthService extends AppServiceBase { class UtilsAuthService extends AppServiceBase {
constructor() { constructor() {
super(); super();
this.centerAppUrl = settings.centerAppUrl(); this.centerAppUrl = settings.centerAppUrl();
}
//---------------登录-----------------------------------------------------
/**
* 解密信息
* @param {*} encryptStr 加密字符串
*/
async decryptInfo(encryptStr) {
var result = await this.decryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, encryptStr);
return result;
}
async getReqTokenByHosts(actionBody, req) { //获取token----改成jwt方式--sy-2020-10-21
if (["hosts", "appkey"].indexOf(actionBody.reqType) < 0) {
return system.getResult(null, "actionBody.reqType is error");
}
if (actionBody.reqType == "hosts") {
if (!actionBody.appHosts) {
return system.getResult(null, "actionBody.appHosts can not be empty");
}
}
if (actionBody.reqType == "appkey") {
if (!actionBody.appkey) {
return system.getResult(null, "actionBody.appkey can not be empty");
}
if (!actionBody.secret) {
return system.getResult(null, "actionBody.secret can not be empty");
}
}
var tmpResult = await this.execPostByTimeOut(req, actionBody, settings.centerAppUrl() + "auth/accessAuth/getTokenByHosts");
if (!tmpResult || tmpResult.status != 0) {
return system.getResult(null, "data is empty");
} }
if (!tmpResult.data || tmpResult.data.status != 0) { //---------------登录-----------------------------------------------------
return system.getResult(null, "data is empty!");
}
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data));
let bodyInfo = {
env: settings.env,
id: tmpResult.data.data.id,
uapp_id: tmpResult.data.data.uapp_id,
token_secret: encrypt_info
};
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
//生成tokenid
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
expiresIn: 60 * 60 * 4 //单位秒,4小时
}); /**
return system.getResultSuccess({ token: tokenid }); * 解密信息
} * @param {*} encryptStr 加密字符串
/** */
* 渠道通过账户进行登录,有则返回用户信息,没有则创建用户 async decryptInfo(encryptStr) {
* @param {*} pobj var result = await this.decryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, encryptStr);
* @param {*} actionBody {channelUserId:XX} return result;
*/ }
async getLoginByUserName(req, pobj, actionBody) {//渠道通过账户进行登录,有则返回用户信息,没有则创建用户---actionBody.channelUserId async getReqTokenByHosts(actionBody, req) { //获取token----改成jwt方式--sy-2020-10-21
if (!actionBody.channelUserId) { if (["hosts", "appkey"].indexOf(actionBody.reqType) < 0) {
return system.getResult(null, "actionBody.channelUserId can not be empty"); return system.getResult(null, "actionBody.reqType is error");
} }
var tmpResult = await this.execPostByTimeOut(req, pobj, settings.centerAppUrl() + "auth/accessAuth/getLoginByUserName"); if (actionBody.reqType == "hosts") {
if (!tmpResult || tmpResult.status != 0) { if (!actionBody.appHosts) {
return system.getResult(null, "data is empty"); return system.getResult(null, "actionBody.appHosts can not be empty");
} }
if (!tmpResult.data || tmpResult.data.status != 0) { }
return system.getResult(null, "data is empty!"); if (actionBody.reqType == "appkey") {
} if (!actionBody.appkey) {
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data)); return system.getResult(null, "actionBody.appkey can not be empty");
let bodyInfo = { }
env: settings.env, if (!actionBody.secret) {
user_id: tmpResult.data.data.id, return system.getResult(null, "actionBody.secret can not be empty");
uapp_id: tmpResult.data.data.uapp_id, }
userpin_secret: encrypt_info }
}; var tmpResult = await this.execPostByTimeOut(req, actionBody, settings.centerAppUrl() + "auth/accessAuth/getTokenByHosts");
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod; if (!tmpResult || tmpResult.status != 0) {
//生成tokenid return system.getResult(null, "data is empty");
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒 }
expiresIn: 60 * 60 * 4 //单位秒,4小时 if (!tmpResult.data || tmpResult.data.status != 0) {
return system.getResult(null, "data is empty!");
}
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data));
let bodyInfo = {
env: settings.env,
id: tmpResult.data.data.id,
uapp_id: tmpResult.data.data.uapp_id,
token_secret: encrypt_info
};
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
//生成tokenid
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
expiresIn: 60 * 60 * 4 //单位秒,4小时
}); });
return system.getResultSuccess({ userpin: tokenid }); return system.getResultSuccess({ token: tokenid });
} }
/**
* 渠道通过账户进行登录,有则返回用户信息,没有则创建用户
* @param {*} pobj
* @param {*} actionBody {channelUserId:XX}
*/
async getLoginByUserName(req, pobj, actionBody) {//渠道通过账户进行登录,有则返回用户信息,没有则创建用户---actionBody.channelUserId
if (!actionBody.channelUserId) {
return system.getResult(null, "actionBody.channelUserId can not be empty");
}
var tmpResult = await this.execPostByTimeOut(req, pobj, settings.centerAppUrl() + "auth/accessAuth/getLoginByUserName");
if (!tmpResult || tmpResult.status != 0) {
return system.getResult(null, "data is empty");
}
if (!tmpResult.data || tmpResult.data.status != 0) {
return system.getResult(null, "data is empty!");
}
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data));
let bodyInfo = {
env: settings.env,
user_id: tmpResult.data.data.id,
uapp_id: tmpResult.data.data.uapp_id,
userpin_secret: encrypt_info
};
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
//生成tokenid
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
expiresIn: 60 * 60 * 4 //单位秒,4小时
/** });
* 通过账户和密码登录 return system.getResultSuccess({ userpin: tokenid });
* @param {*} req
* @param {*} pobj
* @param {*} actionBody {userName:XX,password:XXX}
*/
async getReqUserPinByLgoin(req, pobj, actionBody) {
if (!actionBody.userName) {
return system.getResult(null, "用户名不能为空");
}
if (!actionBody.password) {
return system.getResult(null, "密码不能为空");
}
var tmpResult = await this.execPostByTimeOut(req, pobj, settings.centerAppUrl() + "auth/accessAuth/login");
if (!tmpResult || tmpResult.status != 0) {
return system.getResult(null, "用户名或密码错误");
}
if (!tmpResult.data || tmpResult.data.status != 0) {
return system.getResult(null, "用户名或密码错误!");
} }
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data));
let bodyInfo = {
env: settings.env,
user_id: tmpResult.data.data.id,
uapp_id: tmpResult.data.data.uapp_id,
userpin_secret: encrypt_info
};
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
//生成tokenid
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
expiresIn: 60 * 60 * 4 //单位秒,4小时
}); /**
return system.getResultSuccess({ userpin: tokenid }); * 通过账户和密码登录
} * @param {*} req
/** * @param {*} pobj
* 通过短信登录或注册信息 * @param {*} actionBody {userName:XX,password:XXX}
* @param {*} req */
* @param {*} pobj async getReqUserPinByLgoin(req, pobj, actionBody) {
* @param {*} actionBody {mobile:XXX,vcode:XXX,reqType:"reg",password:XXX-reqType为reg时有此值} if (!actionBody.userName) {
*/ return system.getResult(null, "用户名不能为空");
async getReqUserPinByLgoinVcode(req, pobj, actionBody) { }
if (!actionBody.mobile) { if (!actionBody.password) {
return system.getResult(null, "电话号码不能为空"); return system.getResult(null, "密码不能为空");
} }
if (!actionBody.vcode) { var tmpResult = await this.execPostByTimeOut(req, pobj, settings.centerAppUrl() + "auth/accessAuth/login");
return system.getResult(null, "验证码不能为空"); if (!tmpResult || tmpResult.status != 0) {
} return system.getResult(null, "用户名或密码错误");
if (actionBody.reqType == "reg") { }
if (!actionBody.password) { if (!tmpResult.data || tmpResult.data.status != 0) {
return system.getResult(null, "actionBody.password can not be empty"); return system.getResult(null, "用户名或密码错误!");
} }
} let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data));
const tmpResult = await this.execPostByTimeOut(req, pobj, this.centerAppUrl + "auth/accessAuth/loginByVerifyCode", null, null); let bodyInfo = {
if (!tmpResult || tmpResult.status != 0) { env: settings.env,
return system.getResult(null, tmpResult.msg); user_id: tmpResult.data.data.id,
} uapp_id: tmpResult.data.data.uapp_id,
if (!tmpResult.data || tmpResult.data.status != 0) { userpin_secret: encrypt_info
return system.getResult(null, tmpResult.data.msg); };
} const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data)); //生成tokenid
let bodyInfo = { const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
env: settings.env, expiresIn: 60 * 60 * 4 //单位秒,4小时
user_id: tmpResult.data.data.id || 0,//新建立的用户时user_id为0
uapp_id: tmpResult.data.data.uapp_id,
userpin_secret: encrypt_info
};
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
//生成tokenid
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
expiresIn: 60 * 60 * 4 //单位秒,4小时
}); });
return system.getResultSuccess({ userpin: tokenid }); return system.getResultSuccess({ userpin: tokenid });
} }
/**
* 通过短信登录或注册信息
* @param {*} req
* @param {*} pobj
* @param {*} actionBody {mobile:XXX,vcode:XXX,reqType:"reg",password:XXX-reqType为reg时有此值}
*/
async getReqUserPinByLgoinVcode(req, pobj, actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "电话号码不能为空");
}
if (!actionBody.vcode) {
return system.getResult(null, "验证码不能为空");
}
if (actionBody.reqType == "reg") {
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
}
const tmpResult = await this.execPostByTimeOut(req, pobj, this.centerAppUrl + "auth/accessAuth/loginByVerifyCode", null, null);
if (!tmpResult || tmpResult.status != 0) {
return system.getResult(null, tmpResult.msg);
}
if (!tmpResult.data || tmpResult.data.status != 0) {
return system.getResult(null, tmpResult.data.msg);
}
let encrypt_info = await this.encryptStr(PDICT.encrypt_key, PDICT.encrypt_secret, JSON.stringify(tmpResult.data.data));
let bodyInfo = {
env: settings.env,
user_id: tmpResult.data.data.id || 0,//新建立的用户时user_id为0
uapp_id: tmpResult.data.data.uapp_id,
userpin_secret: encrypt_info
};
const tokenSecret = settings.env == "localhost" || settings.env == "dev" ? PDICT.token_secret_dev : PDICT.token_secret_prod;
//生成tokenid
const tokenid = jwt.sign(bodyInfo, tokenSecret, { // expiresIn:过期时间单位是秒
expiresIn: 60 * 60 * 4 //单位秒,4小时
/** });
* 获取默认模板的手机验证码 return system.getResultSuccess({ userpin: tokenid });
* @param {*} req
* @param {*} pobj
* @param {*} actionBody {mobile:XXX}
*/
async getVerifyCodeByMoblie(req, pobj, actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty !");
} }
const result = await this.execPostByTimeOut(req, pobj, this.centerAppUrl + "auth/accessAuth/getVerifyCodeByMoblie", null, null);
if (result.status === 0 && result.data.status != 0) {
return result.data;
}
return system.getResultSuccess();
}
/** /**
* 通过手机验证码修改用户密码 * 获取默认模板的手机验证码
* @param {*} pobj * @param {*} req
* @param {*} actionBody {mobile:XX,vcode:XXX,newPwd:XXX,userpin:XXXXX} * @param {*} pobj
*/ * @param {*} actionBody {mobile:XXX}
async putUserPwdByMobile(pobj, actionBody) { */
if (!actionBody.mobile) { async getVerifyCodeByMoblie(req, pobj, actionBody) {
return system.getResult(null, "pobj.mobile can not be empty !"); if (!actionBody.mobile) {
} return system.getResult(null, "actionBody.mobile can not be empty !");
if (!actionBody.vcode) { }
return system.getResult(null, "pobj.vcode can not be empty !"); const result = await this.execPostByTimeOut(req, pobj, this.centerAppUrl + "auth/accessAuth/getVerifyCodeByMoblie", null, null);
} if (result.status === 0 && result.data.status != 0) {
if (!actionBody.newPwd) { return result.data;
return system.getResult(null, "pobj.newPwd can not be empty !"); }
} return system.getResultSuccess();
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !");
}
var result = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/modiPasswordByMobile");
if (result.status == 0) {
this.userLogout(pobj, actionBody);
} }
return result;
}
/** /**
* 通过手机验证码修改用户手机号,邮箱 * 通过手机验证码修改用户密码
* @param {*} pobj * @param {*} pobj
* @param {*} actionBody {mobile:XX,vcode:XXX,newPwd:XXX,userpin:XXXXX} * @param {*} actionBody {mobile:XX,vcode:XXX,newPwd:XXX,userpin:XXXXX}
*/ */
async putUserMobileByVcode(pobj, actionBody) { async putUserPwdByMobile(pobj, actionBody) {
if (!actionBody.vcode) { if (!actionBody.mobile) {
return system.getResult(null, "pobj.vcode can not be empty !"); return system.getResult(null, "pobj.mobile can not be empty !");
}
if (!actionBody.vcode) {
return system.getResult(null, "pobj.vcode can not be empty !");
}
if (!actionBody.newPwd) {
return system.getResult(null, "pobj.newPwd can not be empty !");
}
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !");
}
var result = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/modiPasswordByMobile");
if (result.status == 0) {
this.userLogout(pobj, actionBody);
}
return result;
} }
if (!pobj.appInfo) {
return system.getResult(null, "pobj.appInfo can not be empty !"); /**
} * 通过手机验证码修改用户手机号,邮箱
var result = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/putUserMobileByVcode"); * @param {*} pobj
if (result.status == 0) { * @param {*} actionBody {mobile:XX,vcode:XXX,newPwd:XXX,userpin:XXXXX}
this.userLogout(pobj, actionBody); */
} async putUserMobileByVcode(pobj, actionBody) {
return result; if (!actionBody.vcode) {
} return system.getResult(null, "pobj.vcode can not be empty !");
/** }
* 通过userpin获取用户登录信息 if (!pobj.appInfo) {
* @param {*} pobj return system.getResult(null, "pobj.appInfo can not be empty !");
* @param {*} actionBody {userpin:XXXXX} }
*/ var result = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/putUserMobileByVcode");
async getLoginInfo(pobj, actionBody) { if (result.status == 0) {
if (!actionBody.userpin) { this.userLogout(pobj, actionBody);
return system.getResult(null, "pobj.userpin can not be empty !"); }
} return result;
if (!pobj.appInfo) { }
return system.getResult(null, "pobj.appInfo can not be empty !"); /**
} * 通过userpin获取用户登录信息
var result = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/getLoginInfo"); * @param {*} pobj
return result; * @param {*} actionBody {userpin:XXXXX}
} */
/** async getLoginInfo(pobj, actionBody) {
* 用户退出 if (!actionBody.userpin) {
* @param {*} pobj return system.getResult(null, "pobj.userpin can not be empty !");
* @param {*} actionBody {userpin:XXXX} }
*/ if (!pobj.appInfo) {
async userLogout(pobj, actionBody) { return system.getResult(null, "pobj.appInfo can not be empty !");
console.log(actionBody.userpin); }
if (!actionBody.userpin) { var result = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/getLoginInfo");
return system.getResult(null, "actionBody.userpin can not be empty !"); return result;
}
/**
* 用户退出
* @param {*} pobj
* @param {*} actionBody {userpin:XXXX}
*/
async userLogout(pobj, actionBody) {
console.log(actionBody.userpin);
if (!actionBody.userpin) {
return system.getResult(null, "actionBody.userpin can not be empty !");
}
var applogout = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/logout");
return applogout;
} }
var applogout = await this.restPostUrl(pobj, this.centerAppUrl + "auth/accessAuth/logout");
return applogout;
}
/** /**
* 解析用户,获取认证token * 解析用户,获取认证token
* @param pobj * @param pobj
* @param actionBody * @param actionBody
* @param req * @param req
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async channelUserLogin(pobj, actionBody, req) { async channelUserLogin(pobj, actionBody, req) {
let opResult = system.getResultSuccess() let opResult = system.getResultSuccess()
let pin = actionBody.pin; let pin = actionBody.pin;
let result = await this.get360Token(); let result = await this.get360Token();
let token = result.access_token; let token = result.access_token;
//360验证接口 //360验证接口
let subData = "pin=" + pin + "&token=" + token; let subData = "pin=" + pin + "&token=" + token;
let url = settings.requestUrl360() + 'api/v1/VerifyPin'; let url = settings.requestUrl360() + 'api/v1/VerifyPin';
let rtn = await this.restClient.execGet(subData,url); let rtn = await this.restClient.execGet(subData, url);
if (!rtn || !rtn.stdout) { if (!rtn || !rtn.stdout) {
return system.getResult(null, "restGet data is empty"); return system.getResult(null, "restGet data is empty");
}
let checkRet = JSON.parse(rtn.stdout);
if (checkRet.code != 200) {
return system.getResultFail(-1, checkRet.msg)
}
//---渠道用户登录,有则返回userpin ,没有则注册用户并返回userpin
actionBody.channelUserId = pin;
opResult = await this.getLoginByUserName(req, pobj, actionBody);
return opResult;
} }
let checkRet = JSON.parse(rtn.stdout);
if(checkRet.code != 200){ async get360Token() {
return system.getResultFail(-1,checkRet.msg) let rtn = await this.execClient.exec360GetToken(settings.tokenUrl360())
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty");
}
let result = JSON.parse(rtn.stdout);
return result;
} }
//---渠道用户登录,有则返回userpin ,没有则注册用户并返回userpin
actionBody.channelUserId = pin;
opResult = await this.getLoginByUserName(req,pobj, actionBody);
return opResult;
}
async get360Token() { /**
let rtn = await this.execClient.exec360GetToken(settings.tokenUrl360()) * 获取所有渠道(去重appid、app名字)
if (!rtn || !rtn.stdout) { * @returns {Promise<void>}
return system.getResult(null, "restPost data is empty"); */
async getAllChannels(pobj) {
let url = this.centerAppUrl + 'auth/accessAuth/getAllChannels';
let result = await this.restPostUrl(pobj, url);
return result
} }
let result = JSON.parse(rtn.stdout);
return result;
}
/** /**
* 获取所有渠道 * 获取所有渠道(信息更全一些)
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
async getAllChannels(pobj){ async getAllService(pobj) {
let url= this.centerAppUrl + 'auth/accessAuth/getAllChannels'; let url = this.centerAppUrl + 'auth/accessAuth/getAllService';
let result = await this.restPostUrl(pobj,url); let result = await this.restPostUrl(pobj, url);
return result return result
} }
} }
module.exports = UtilsAuthService; module.exports = UtilsAuthService;
...@@ -413,14 +413,6 @@ class UtilsNeedService extends AppServiceBase { ...@@ -413,14 +413,6 @@ class UtilsNeedService extends AppServiceBase {
// 明天找栋源确认 如果需要增加 在这个文件搜索updateChanceStatus // 明天找栋源确认 如果需要增加 在这个文件搜索updateChanceStatus
// 2020 1016 lin 新增 需求关闭时判断 方案状态 订单状态,打个比方如果已经生成订单了 那么肯定不能直接关闭需求 // 2020 1016 lin 新增 需求关闭时判断 方案状态 订单状态,打个比方如果已经生成订单了 那么肯定不能直接关闭需求
if (result.status == 0) { if (result.status == 0) {
if (result.data) {
pobj.actionBody.orderNo = result.data;
var orderrtn = await self.utilsOrderSve.delOrder(pobj, pobj.actionBody);
if (orderrtn.status < 0) {
return system.getResultFail(-5022, "订单关闭失败");
}
}
//推送交付系统 //推送交付系统
var reqParams = { var reqParams = {
actionBody: { actionBody: {
......
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