Commit 21839639 by linboxuan

ucommune api update

parent 3f5e64af
...@@ -3,73 +3,99 @@ var settings = require("../../../../config/settings"); ...@@ -3,73 +3,99 @@ var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base"); const AppServiceBase = require("../../app.base");
//产品操作类 //产品操作类
class UtilsUcommuneService extends AppServiceBase { class UtilsUcommuneService extends AppServiceBase {
constructor() { constructor() {
super(); super();
this.centerOrderUrl = settings.centerOrderUrl(); this.centerOrderUrl = settings.centerOrderUrl();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve"); this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
} }
//--------------------------------优客工厂相关接口-start----------------------------------------------------- //--------------------------------优客工厂相关接口-start-----------------------------------------------------
/** /**
* 根据优客token获取用户信息,生成userPin返回前端 * 根据优客token获取用户信息,生成userPin返回前端
* @param {*} pobj * @param {*} pobj
* @param {*} actionBody userToken 为优客工厂的userToken * @param {*} actionBody userToken 为优客工厂的userToken
*/ */
async getUserInfo(pobj, actionBody) { async getUserInfo(pobj, actionBody) {
if (!actionBody.userToken) { if (!actionBody.userToken) {
return system.getResult(null, "actionBody.token can not be empty,100410"); return system.getResult(null, "actionBody.token can not be empty,100410");
}
var url = settings.ucommuneUrl() + "third/getUserInfo"; // 调用优客工场接口 获取用户信息
// 拼接规则curl -k -H 'Content-type: application/json' -H 'authorization:{token}' -X POST {url} pobj作为发生错误时记录日志用
let result = await this.restPostWithHAuthorizationUrl(pobj, actionBody.userToken, url);
if(result.retCode == 0) { // 0成功 1失败
pobj.actionType = "getLoginByUserName";
pobj.actionBody.channelUserId = result.data.mobile;
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
} }
return system.getResultSuccess({ userpin: tmpOpResult.data.userpin }) var url = settings.ucommuneUrl() + "third/getUserInfo"; // 调用优客工场接口 获取用户信息
} else { // 拼接规则curl -k -H 'Content-type: application/json' -H 'authorization:{token}' -X POST {url} pobj作为发生错误时记录日志用
// 获取用户信息失败 let result = await this.restPostWithHAuthorizationUrl(pobj, actionBody.userToken, url);
return system.getResult(null, "Failed to get user information, 100420"); if(result.retCode == 0) { // 0成功 1失败
pobj.actionType = "getLoginByUserName";
pobj.actionBody.channelUserId = result.data.mobile;
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
return system.getResultSuccess({ userpin: tmpOpResult.data.userpin })
} else {
// 获取用户信息失败
return system.getResult(null, "Failed to get user information, 100420");
}
}
/**
* 优客调取订单列表用
* @param {*} pobj
* @param {*} actionBody
*/
async UcommuneGetOrderList(pobj, actionBody) {
var reqUrl = this.centerOrderUrl + "action/order/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
return result;
} }
}
/**
* 优客调取订单列表用
* @param {*} pobj
* @param {*} actionBody
*/
async UcommuneGetOrderList(pobj, actionBody) {
var reqUrl = this.centerOrderUrl + "action/order/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
return result;
}
/** /**
* addOrder后进入支付页面获取支付金额 * addOrder后进入支付页面获取支付金额
* @param {*} pobj * @param {*} pobj
* @param {*} actionBody orderNo orderIndo订单号 * @param {*} actionBody orderNo orderIndo订单号
*/ */
async orderTotalSum(pobj, actionBody) { async orderTotalSum(pobj, actionBody) {
pobj.actionType = "getOrderDetails" // 获取订单详细信息 用来拼接字符串 totalsum为总金额,返回给前端 pobj.actionType = "getOrderDetails" // 获取订单详细信息 用来拼接字符串 totalsum为总金额,返回给前端
var reqUrl = this.centerOrderUrl + "action/order/springBoard"; var reqUrl = this.centerOrderUrl + "action/order/springBoard";
var result = await this.restPostUrl(pobj, reqUrl); var result = await this.restPostUrl(pobj, reqUrl);
} return result;
}
/**
* 点击确认支付后返回拼接字符串
* @param {*} pobj
* @param {*} actionBody orderNo orderIndo订单号
*/
async orderConfirm(pobj, actionBody) {
await this.orderConfirmValidate(pobj, actionBody);
pobj.actionType = "getOrderDetails" // 获取订单详细信息 用来拼接字符串 totalsum为总金额,返回给前端
var reqUrl = this.centerOrderUrl + "action/order/springBoard";
var orderResult = await this.restPostUrl(pobj, reqUrl);
if(actionBody.payWay == 1) { // 支付宝
}
if(actionBody.payWay == 3) { // 微信
}
return system.getResult(null, "actionBody.payWay is eoor values,100450");
}
/** /**
* 点击确认支付后返回拼接字符串 * 点击确认支付后返回拼接字符串 orderConfirm 的验证数据方法
* @param {*} pobj * @param {*} pobj
* @param {*} actionBody orderNo orderIndo订单号 * @param {*} actionBody orderNo orderIndo订单号
*/ */
async orderConfirm(pobj, actionBody) { async orderConfirmValidate(pobj, actionBody) {
pobj.actionType = "getOrderDetails" // 获取订单详细信息 用来拼接字符串 totalsum为总金额,返回给前端 if(!actionBody.orderNo) { // 订单号
var reqUrl = this.centerOrderUrl + "action/order/springBoard"; return system.getResult(null, "actionBody.orderNo can not be empty,100430");
var result = await this.restPostUrl(pobj, reqUrl); }
} if(!actionBody.payWay) { // 支付方式 1 支付宝 3微信
return system.getResult(null, "actionBody.payWay can not be empty,100440");
}
if(actionBody.payWay != 1 || actionBody.payWay != 3) { // payway 非1非3
return system.getResult(null, "actionBody.payWay is eoor values,100450");
}
}
//--------------------------------优客工厂相关接口--end---------------------------------------------------- //--------------------------------优客工厂相关接口--end----------------------------------------------------
......
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