Commit e8f105db by 兰国旗

laolan

parent 5f946b9b
...@@ -6,656 +6,698 @@ const logCtl = system.getObject("service.common.oplogSve"); ...@@ -6,656 +6,698 @@ const logCtl = system.getObject("service.common.oplogSve");
const regCfg = require("./regCfg") const regCfg = require("./regCfg")
//gongshang zhuce //gongshang zhuce
class RegCenterOrderService extends AppServiceBase { class RegCenterOrderService extends AppServiceBase {
constructor() { constructor() {
super(); super();
this.execlient = system.getObject("util.execClient"); this.execlient = system.getObject("util.execClient");
this.channelApiUrl = settings.channelApiUrl(); this.channelApiUrl = settings.channelApiUrl();
this.centerChannelUrl = settings.centerChannelUrl(); this.centerChannelUrl = settings.centerChannelUrl();
this.appInfo = { this.appInfo = {
aliyuntmtransfer: { appkey: settings.appKey, secret: settings.secret } aliyuntmtransfer: { appkey: settings.appKey, secret: settings.secret }
}; };
} }
// -------------提交reg需求--------laolan 2020.12.17-------百度reg接入使用--------start------------------ // -------------提交reg需求--------laolan 2020.12.17-------百度reg接入使用--------start------------------
async getCenterTokenByApp(appinfo) { async getCenterTokenByApp(appinfo) {
var reqTokenUrl = this.centerChannelUrl + "/api/opreceive/accessAuth/getAppTokenByAppKey"; var reqTokenUrl = this.centerChannelUrl + "/api/opreceive/accessAuth/getAppTokenByAppKey";
var reqParam = appinfo; var reqParam = appinfo;
if (!reqParam || !reqParam.uapp_key || !reqParam.uapp_secret) { if (!reqParam || !reqParam.uapp_key || !reqParam.uapp_secret) {
return system.getResult(null, "reqType类型有误,请求失败"); return system.getResult(null, "reqType类型有误,请求失败");
} }
var param = { var param = {
"actionType": "getAppTokenByAppKey", "actionType": "getAppTokenByAppKey",
"actionBody": { "actionBody": {
"appkey": reqParam.uapp_key, "appkey": reqParam.uapp_key,
"secret": reqParam.uapp_secret "secret": reqParam.uapp_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;
}
async reqcenterchannel2(pobj) { var rtn = await this.execlient.execPost(param, reqTokenUrl);
console.log('reqcenterchannel2----',pobj) if (!rtn.stdout) {
var sobj = { return system.getResult(null, "获取token失败");
"actionType": pobj.action_type, }
"actionBody": pobj var tokenResult = JSON.parse(rtn.stdout);
} return tokenResult;
if(!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret){ }
return {
"requestId": regCfg.getUUID(), async reqcenterchannel2(pobj) {
"success": false, console.log('reqcenterchannel2----', pobj)
"errorMsg": "无效应用", var sobj = {
"errorCode": "ok" "actionType": pobj.action_type,
}; "actionBody": pobj
} }
var tokenInfo = await this.getCenterTokenByApp(pobj.appInfo); if (!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret) {
if (tokenInfo.status != 0) { return {
return { "requestId": regCfg.getUUID(),
"requestId": regCfg.getUUID(), "success": false,
"success": false, "errorMsg": "无效应用",
"errorMsg": "getTokenInfo fail", "errorCode": "ok"
"errorCode": "ok" };
}; }
} var tokenInfo = await this.getCenterTokenByApp(pobj.appInfo);
var userpin = ""; if (tokenInfo.status != 0) {
//传手机号 return {
if(pobj.phone&&!pobj.mobile){ "requestId": regCfg.getUUID(),
pobj.mobile=pobj.phone; "success": false,
}else{//没传手机号就自己去查渠道唯一码 "errorMsg": "getTokenInfo fail",
var reqData = { "errorCode": "ok"
actionType: "selectNeedInfo", };
actionBody: { }
channelNeedNo:pobj.intentionBizId var userpin = "";
} //传手机号
} if (pobj.phone && !pobj.mobile) {
var needInfoUrl = settings.centerChannelUrl() + "/api/action/regapi/springBoard"; pobj.mobile = pobj.phone;
var needInfoRes = await this.execlient.execPostTK(reqData, needInfoUrl, tokenInfo.data.token); } else {//没传手机号就自己去查渠道唯一码
if(needInfoRes.status == 0){ var reqData = {
pobj.mobile = needInfoRes.data.channelUserId actionType: "selectNeedInfo",
} actionBody: {
} channelNeedNo: pobj.intentionBizId
}
}
var needInfoUrl = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var needInfoRes = await this.execlient.execPostTK(reqData, needInfoUrl, tokenInfo.data.token);
if (needInfoRes.status == 0) {
pobj.mobile = needInfoRes.data.channelUserId
}
}
if (pobj.mobile) {
//有传手机号就直接获取用户userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.mobile,
"mobile": pobj.mobile,
"userName": pobj.mobile
}
};
// pobj.actionBody.channelUserId = pobj.mobile;//渠道用户id,没有则用手机号
// pobj.actionBody.mobile = pobj.mobile;//用户手机号
var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard";
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) {
return system.getResultFail(-99, "获取userpin失败");
}
userpin = userpinResultTmp.data.userpin;
if (!userpin) {
return system.getResultFail(-88, "获取userpin失败!!");
}
if (pobj.mobile) { }
//有传手机号就直接获取用户userpin //带userpin请求
var userparam = { url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
actionType: "getLoginByUserName", var token = tokenInfo.data.token;
actionBody: { var rtn = null;
"channelUserId": pobj.mobile, if (userpin) {
"mobile": pobj.mobile, rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin);
"userName": pobj.mobile } else {
} rtn = await this.execlient.execPostTK(sobj, url, token);
}; if (rtn.status == 0) {
// pobj.actionBody.channelUserId = pobj.mobile;//渠道用户id,没有则用手机号 return {
// pobj.actionBody.mobile = pobj.mobile;//用户手机号 "requestId": rtn.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} else {
return {
"requestId": rtn.requestId,
"success": false,
"errorMsg": rtn.msg,
"errorCode": "ok"
};
}
}
if (!rtn || !rtn.stdout) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status == 0) {
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} else {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
}
//百度reg 2.3 请求
async regOrderStatus(pobj) {
if (!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "无效应用",
"errorCode": "ok"
};
}
// 获取app token
var tokenInfo = await this.getCenterTokenByApp(pobj.appInfo);
if (tokenInfo.status != 0) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "",
"errorCode": "ok"
};
}
var token = tokenInfo.data.token;
// 获取userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {}
};
// 引用属性,channel依赖bizId order依赖intentionBizId
pobj.intentionBizId = pobj.bizId || pobj.orderNo
if (pobj.isDirectBuy == 1) {//直购
userparam.actionBody.channelUserId = pobj.phone
userparam.actionBody.mobile = pobj.phone
userparam.actionBody.userName = pobj.phone
pobj.publishMobile = pobj.phone
pobj.channelTypeCode = pobj.consultType;
if (pobj.area) {
// pobj.area = regCfg.baiduArea[pobj.area]
pobj.area = pobj.area
}
pobj['province'] = pobj.area;
var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard"; var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard";
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token); var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) { if (userpinResultTmp.status != 0) {
return system.getResultFail(-99, "获取userpin失败");
}
userpin = userpinResultTmp.data.userpin;
if (!userpin) {
return system.getResultFail(-88, "获取userpin失败!!");
}
}
//带userpin请求
url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var token = tokenInfo.data.token;
var rtn = null;
if (userpin) {
rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin);
} else {
rtn = await this.execlient.execPostTK(sobj, url, token);
if (rtn.status == 0) {
return { return {
"requestId": rtn.requestId, "requestId": userpinResultTmp.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} else {
return {
"requestId": rtn.requestId,
"success": false, "success": false,
"errorMsg": rtn.msg, "errorMsg": userpinResultTmp.msg,
"errorCode": "ok" "errorCode": "ok"
}; };
} }
}
if (!rtn || !rtn.stdout) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout); // regOrderStatus
if (result.status == 0) { var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
return { var sobj = {
"requestId": result.requestId, "actionType": "regOrderStatus",
"success": true, "actionBody": pobj
"errorMsg": "", }
"errorCode": "ok" var rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpinResultTmp.data.userpin);
}; if (!rtn || !rtn.stdout) {
} else { return {
return { "requestId": self.getUUID(),
"requestId": result.requestId, "success": false,
"success": false, "errorMsg": "网络错误",
"errorMsg": result.msg, "errorCode": "ok"
"errorCode": "ok" };
}; }
} var result = JSON.parse(rtn.stdout);
} if (result.status != 0) {
//百度reg 2.3 请求 return {
async regOrderStatus(pobj) { "requestId": result.requestId,
if(!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret){ "success": false,
return { "errorMsg": result.msg,
"requestId": regCfg.getUUID(), "errorCode": "ok"
"success": false, };
"errorMsg": "无效应用", }
"errorCode": "ok" return {
}; "requestId": result.requestId,
} "success": true,
// 获取app token "errorMsg": "",
var tokenInfo = await this.getCenterTokenByApp(pobj.appInfo); "errorCode": "ok"
if (tokenInfo.status != 0) { };
return { } else {
"requestId": regCfg.getUUID(), var userpin = "";
"success": false, //传手机号
"errorMsg": "", if (pobj.phone && !pobj.mobile) {
"errorCode": "ok" pobj.mobile = pobj.phone;
}; } else {//没传手机号就自己去查渠道唯一码
} var reqData = {
var token = tokenInfo.data.token; actionType: "selectNeedInfo",
// 获取userpin actionBody: {
var userparam = { channelNeedNo: pobj.intentionBizId
actionType: "getLoginByUserName", }
actionBody: {} }
}; var needInfoUrl = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
// 引用属性,channel依赖bizId order依赖intentionBizId var needInfoRes = await this.execlient.execPostTK(reqData, needInfoUrl, tokenInfo.data.token);
pobj.intentionBizId = pobj.bizId if (needInfoRes.status == 0) {
if (pobj.isDirectBuy==1){//直购 pobj.mobile = needInfoRes.data.channelUserId
userparam.actionBody.channelUserId = pobj.phone }
userparam.actionBody.mobile = pobj.phone }
userparam.actionBody.userName = pobj.phone
pobj.publishMobile = pobj.phone
pobj.channelTypeCode = pobj.consultType;
if (pobj.area) {
// pobj.area = regCfg.baiduArea[pobj.area]
pobj.area = pobj.area
}
pobj['province'] = pobj.area;
}else {
var userpin = "";
//传手机号
if(pobj.phone&&!pobj.mobile){
pobj.mobile=pobj.phone;
}else{//没传手机号就自己去查渠道唯一码
var reqData = {
actionType: "selectNeedInfo",
actionBody: {
channelNeedNo:pobj.intentionBizId
}
}
var needInfoUrl = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var needInfoRes = await this.execlient.execPostTK(reqData, needInfoUrl, tokenInfo.data.token);
if(needInfoRes.status == 0){
pobj.mobile = needInfoRes.data.channelUserId
}
}
if (pobj.mobile) {
//有传手机号就直接获取用户userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.mobile,
"mobile": pobj.mobile,
"userName": pobj.mobile
}
};
var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard"; if (pobj.mobile) {
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token); //有传手机号就直接获取用户userpin
if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) { var userparam = {
return system.getResultFail(-99, "获取userpin失败"); actionType: "getLoginByUserName",
} actionBody: {
userpin = userpinResultTmp.data.userpin; "channelUserId": pobj.mobile,
if (!userpin) { "mobile": pobj.mobile,
return system.getResultFail(-88, "获取userpin失败!!"); "userName": pobj.mobile
} }
} };
var sobj = { var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard";
"actionType": "getItemByChannelSolutionNo", var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
"actionBody": pobj if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) {
} return system.getResultFail(-99, "获取userpin失败");
// getItemByChannelSolutionNo }
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard"; userpin = userpinResultTmp.data.userpin;
var result = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin); if (!userpin) {
if(result && result.stdout){ return system.getResultFail(-88, "获取userpin失败!!");
result = result.stdout }
result = JSON.parse(result) }
}
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
console.log('regOrderStatus--start--')
// regOrderStatus
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var sobj = {
"actionType": "regOrderStatus",
"actionBody": pobj
}
var rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpinResultTmp.data.userpin);
if (!rtn || !rtn.stdout) {
return {
"requestId": self.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
}
//百度reg 2.4 请求 关闭reg订单
async regOrderClose(pobj) {
if(!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret){
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "无效应用",
"errorCode": "ok"
};
}
// 获取app token
// var tokenInfo = await this.getCenterToken();
var tokenInfo = await this.getCenterTokenByApp(pobj.appInfo);
if (tokenInfo.status != 0) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "",
"errorCode": "ok"
};
}
var token = tokenInfo.data.token;
var sobj = {
"actionType": "getSolutionByChannelOrderNo",
"actionBody": pobj
}
// getItemByChannelSolutionNo
var userpin = "";
//传手机号
if(pobj.phone&&!pobj.mobile){
pobj.mobile=pobj.phone;
}else{//没传手机号就自己去查渠道唯一码
var reqData = {
actionType: "selectNeedInfo",
actionBody: {
orderNo:pobj.orderNo
}
}
var needInfoUrl = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var needInfoRes = await this.execlient.execPostTK(reqData, needInfoUrl, tokenInfo.data.token);
if(needInfoRes.status == 0){
pobj.mobile = needInfoRes.data.channelUserId
}
}
if (pobj.mobile) {
//有传手机号就直接获取用户userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.mobile,
"mobile": pobj.mobile,
"userName": pobj.mobile
}
};
var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard"; var sobj = {
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token); "actionType": "getItemByChannelSolutionNo",
if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) { "actionBody": pobj
return system.getResultFail(-99, "获取userpin失败"); }
} // getItemByChannelSolutionNo
userpin = userpinResultTmp.data.userpin; var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
if (!userpin) { var result = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin);
return system.getResultFail(-88, "获取userpin失败!!"); if (result && result.stdout) {
} result = result.stdout
} result = JSON.parse(result)
}
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
console.log('regOrderStatus--start--')
// regOrderStatus
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var sobj = {
"actionType": "regOrderStatus",
"actionBody": pobj
}
var rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpinResultTmp.data.userpin);
if (!rtn || !rtn.stdout) {
return {
"requestId": self.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
}
//百度reg 2.4 请求 关闭reg订单
async regOrderClose(pobj) {
if (!pobj.appInfo || !pobj.appInfo.uapp_key || !pobj.appInfo.uapp_secret) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "无效应用",
"errorCode": "ok"
};
}
// 获取app token
// var tokenInfo = await this.getCenterToken();
var tokenInfo = await this.getCenterTokenByApp(pobj.appInfo);
if (tokenInfo.status != 0) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "",
"errorCode": "ok"
};
}
var token = tokenInfo.data.token;
var sobj = {
"actionType": "getSolutionByChannelOrderNo",
"actionBody": pobj
}
// getItemByChannelSolutionNo
var userpin = "";
//传手机号
if (pobj.phone && !pobj.mobile) {
pobj.mobile = pobj.phone;
} else {//没传手机号就自己去查渠道唯一码
var reqData = {
actionType: "selectNeedInfo",
actionBody: {
orderNo: pobj.orderNo
}
}
var needInfoUrl = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var needInfoRes = await this.execlient.execPostTK(reqData, needInfoUrl, tokenInfo.data.token);
if (needInfoRes.status == 0) {
pobj.mobile = needInfoRes.data.channelUserId
}
}
var sobj = { if (pobj.mobile) {
"actionType": "getItemByChannelSolutionNo", //有传手机号就直接获取用户userpin
"actionBody": pobj var userparam = {
} actionType: "getLoginByUserName",
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard"; actionBody: {
var result = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin); "channelUserId": pobj.mobile,
if(result && result.stdout){ "mobile": pobj.mobile,
result = result.stdout "userName": pobj.mobile
result = JSON.parse(result) }
} };
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
if(!result.data.solutionContent || !result.data.solutionContent.customerInfo || !result.data.solutionContent.customerInfo.publishMobile){
return {
"requestId": result.requestId,
"success": false,
"errorMsg": "方案客户信息有误",
"errorCode": "ok"
};
}
// 获取userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
channelUserId:result.data.solutionContent.customerInfo.publishMobile,
mobile:result.data.solutionContent.customerInfo.publishMobile,
userName:result.data.solutionContent.customerInfo.publishMobile
}
};
var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard";
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, token);
if (userpinResultTmp.status != 0) {
return {
"requestId": userpinResultTmp.requestId,
"success": false,
"errorMsg": userpinResultTmp.msg,
"errorCode": "ok"
};
}
var closeobj = {
"actionType": "regOrderClose",
"actionBody": pobj
}
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var rtn = await this.execlient.execDataPostByTokenUserPin(closeobj, url, token,userpinResultTmp.data.userpin);
if (!rtn || !rtn.stdout) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
// -------------提交reg需求--------laolan 2020.12.17-------百度reg接入使用--------end------------------
async paySuccess(pobj) {
var sobj = {
"actionType": pobj.action_type,
"actionBody": pobj
}
var tokenInfo = await this.getCenterToken();
if (tokenInfo.status != 0) {
return {
"requestId": regCfg.getUUID(),
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
// return { "message": "success", "data": {}, "code": 200 }
}
var userpin = "";
if (pobj.phone) {
//获取用户userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.phone,
"mobile": pobj.phone,
"userName": pobj.phone
}
};
// pobj.actionBody.channelUserId = pobj.mobile;//渠道用户id,没有则用手机号
// pobj.actionBody.mobile = pobj.mobile;//用户手机号
var url = settings.centerChannelUrl() + "/api/auth/accessAuth/springBoard";
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) {
// return { "message": "网络错误", "data": {}, "code": -102 }
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
userpin = userpinResultTmp.data.userpin;
if (!userpin) {
// return { "message": "网络错误", "data": {}, "code": -102 }
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
}
//带userpin请求
url = settings.centerChannelUrl() + "/api/opreceive/ic/springBoard";
var token = tokenInfo.data.token;
var rtn = rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin);
if (!rtn || !rtn.stdout) {
// return { "message": "网络错误", "data": {}, "code": -102 }
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status == 0) {
// return { "message": "true", "data": {}, "code": 200 }
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} else {
// return { "message": result.msg, "data": {}, "code": -102 }
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
}
async orderClose(pobj) { var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard";
var sobj = { var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
"actionType": pobj.action_type, if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) {
"actionBody": pobj return system.getResultFail(-99, "获取userpin失败");
} }
var tokenInfo = await this.getCenterToken(); userpin = userpinResultTmp.data.userpin;
if (tokenInfo.status != 0) { if (!userpin) {
return { return system.getResultFail(-88, "获取userpin失败!!");
"requestId": regCfg.getUUID(), }
"success": false, }
"errorMsg": "",
"errorCode": "ok"
};
}
var url = settings.centerChannelUrl() + "/api/opreceive/ic/springBoard"; var sobj = {
var token = tokenInfo.data.token; "actionType": "getItemByChannelSolutionNo",
var rtn = await this.execlient.execPostTK(sobj, url, token); "actionBody": pobj
if (rtn.status == 0) { }
return { var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
"requestId": rtn.requestId, var result = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin);
"success": true, if (result && result.stdout) {
"errorMsg": "", result = result.stdout
"errorCode": "ok" result = JSON.parse(result)
}; }
} else { if (result.status != 0) {
return { return {
"requestId": rtn.requestId, "requestId": result.requestId,
"success": false, "success": false,
"errorMsg": rtn.msg, "errorMsg": result.msg,
"errorCode": "ok" "errorCode": "ok"
}; };
} }
} if (!result.data.solutionContent || !result.data.solutionContent.customerInfo || !result.data.solutionContent.customerInfo.publishMobile) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": "方案客户信息有误",
"errorCode": "ok"
};
}
// 获取userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
channelUserId: result.data.solutionContent.customerInfo.publishMobile,
mobile: result.data.solutionContent.customerInfo.publishMobile,
userName: result.data.solutionContent.customerInfo.publishMobile
}
};
var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard";
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, token);
if (userpinResultTmp.status != 0) {
return {
"requestId": userpinResultTmp.requestId,
"success": false,
"errorMsg": userpinResultTmp.msg,
"errorCode": "ok"
};
}
var closeobj = {
"actionType": "regOrderClose",
"actionBody": pobj
}
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var rtn = await this.execlient.execDataPostByTokenUserPin(closeobj, url, token, userpinResultTmp.data.userpin);
if (!rtn || !rtn.stdout) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
// -------------提交reg需求--------laolan 2020.12.17-------百度reg接入使用--------end------------------
async paySuccess(pobj) {
var sobj = {
"actionType": pobj.action_type,
"actionBody": pobj
}
var tokenInfo = await this.getCenterToken();
if (tokenInfo.status != 0) {
return {
"requestId": regCfg.getUUID(),
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
// return { "message": "success", "data": {}, "code": 200 }
}
var userpin = "";
if (pobj.phone) {
//获取用户userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.phone,
"mobile": pobj.phone,
"userName": pobj.phone
}
};
// pobj.actionBody.channelUserId = pobj.mobile;//渠道用户id,没有则用手机号
// pobj.actionBody.mobile = pobj.mobile;//用户手机号
var url = settings.centerChannelUrl() + "/api/auth/accessAuth/springBoard";
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
if (userpinResultTmp.status != 0 && userpinResultTmp.status != 2060) {
// return { "message": "网络错误", "data": {}, "code": -102 }
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
userpin = userpinResultTmp.data.userpin;
if (!userpin) {
// return { "message": "网络错误", "data": {}, "code": -102 }
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
}
//带userpin请求
url = settings.centerChannelUrl() + "/api/opreceive/ic/springBoard";
var token = tokenInfo.data.token;
var rtn = rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpin);
if (!rtn || !rtn.stdout) {
// return { "message": "网络错误", "data": {}, "code": -102 }
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status == 0) {
// return { "message": "true", "data": {}, "code": 200 }
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
} else {
// return { "message": result.msg, "data": {}, "code": -102 }
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
}
//icp 2.3 请求 async orderClose(pobj) {
async queryOrderState(pobj) { var sobj = {
// 获取app token "actionType": pobj.action_type,
var tokenInfo = await this.getCenterToken(); "actionBody": pobj
if (tokenInfo.status != 0) { }
return { var tokenInfo = await this.getCenterToken();
"requestId": regCfg.getUUID(), if (tokenInfo.status != 0) {
"success": false, return {
"errorMsg": "", "requestId": regCfg.getUUID(),
"errorCode": "ok" "success": false,
}; "errorMsg": "",
} "errorCode": "ok"
var token = tokenInfo.data.token; };
// 引用属性,channel依赖bizId order依赖intentionBizId }
pobj.intentionBizId = pobj.bizId
// 获取userpin var url = settings.centerChannelUrl() + "/api/opreceive/ic/springBoard";
var userparam = { var token = tokenInfo.data.token;
actionType: "getLoginByUserName", var rtn = await this.execlient.execPostTK(sobj, url, token);
actionBody: {} if (rtn.status == 0) {
}; return {
if (pobj.isDirectBuy === "true"){//直购 "requestId": rtn.requestId,
if (!pobj.mobile){ "success": true,
var sobj = { "errorMsg": "",
"actionType": "getSolutionByChannelSolutionNo", "errorCode": "ok"
"actionBody": pobj };
} } else {
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard"; return {
var result = await this.execlient.execPostTK(sobj, url, token); "requestId": rtn.requestId,
if (result.status != 0) { "success": false,
return { "errorMsg": rtn.msg,
"requestId": result.requestId, "errorCode": "ok"
"success": false, };
"errorMsg": result.msg, }
"errorCode": "ok" }
};
} //icp 2.3 请求
pobj.mobile = result.data.solutionContent.customerInfo.publishMobile async queryOrderState(pobj) {
} // 获取app token
userparam.actionBody.channelUserId = pobj.mobile var tokenInfo = await this.getCenterToken();
userparam.actionBody.mobile = pobj.mobile if (tokenInfo.status != 0) {
userparam.actionBody.userName = pobj.mobile return {
pobj.publishMobile = pobj.mobile "requestId": regCfg.getUUID(),
pobj.channelTypeCode = pobj.bizId.startsWith("EDI")?7:5; "success": false,
//pobj.province = pobj.companyLocation+`(${pobj.actionType})` "errorMsg": "",
pobj.province = pobj.area "errorCode": "ok"
}else { };
var sobj = { }
"actionType": "getItemByChannelSolutionNo", var token = tokenInfo.data.token;
"actionBody": pobj // 引用属性,channel依赖bizId order依赖intentionBizId
} pobj.intentionBizId = pobj.bizId
// getItemByChannelSolutionNo // 获取userpin
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard"; var userparam = {
var result = await this.execlient.execPostTK(sobj, url, token); actionType: "getLoginByUserName",
if (result.status != 0) { actionBody: {}
return { };
"requestId": result.requestId, if (pobj.isDirectBuy === "true") {//直购
"success": false, if (!pobj.mobile) {
"errorMsg": result.msg, var sobj = {
"errorCode": "ok" "actionType": "getSolutionByChannelSolutionNo",
}; "actionBody": pobj
} }
userparam.actionBody.channelUserId = result.data.channelUserId var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
userparam.actionBody.mobile = result.data.publishMobile var result = await this.execlient.execPostTK(sobj, url, token);
userparam.actionBody.userName = result.data.publishMobile if (result.status != 0) {
pobj.publishMobile = result.data.publishMobile; return {
pobj.channelNeedNo = result.data.channelNeedNo; "requestId": result.requestId,
pobj.needNo = result.data.needNo; "success": false,
pobj.channelTypeCode = result.data.channelTypeCode; "errorMsg": result.msg,
pobj.province = result.data.solutionProvince;//北京(新购)? "errorCode": "ok"
} };
var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard"; }
var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token); pobj.mobile = result.data.solutionContent.customerInfo.publishMobile
if (userpinResultTmp.status != 0) { }
return { userparam.actionBody.channelUserId = pobj.mobile
"requestId": userpinResultTmp.requestId, userparam.actionBody.mobile = pobj.mobile
"success": false, userparam.actionBody.userName = pobj.mobile
"errorMsg": userpinResultTmp.msg, pobj.publishMobile = pobj.mobile
"errorCode": "ok" pobj.channelTypeCode = pobj.bizId.startsWith("EDI") ? 7 : 5;
}; //pobj.province = pobj.companyLocation+`(${pobj.actionType})`
} pobj.province = pobj.area
// icpNotify } else {
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard"; var sobj = {
var sobj = { "actionType": "getItemByChannelSolutionNo",
"actionType": "icpNotify", "actionBody": pobj
"actionBody": pobj }
} // getItemByChannelSolutionNo
var rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token,userpinResultTmp.data.userpin); var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
if (!rtn || !rtn.stdout) { var result = await this.execlient.execPostTK(sobj, url, token);
return { if (result.status != 0) {
"requestId": regCfg.getUUID(), return {
"success": false, "requestId": result.requestId,
"errorMsg": "网络错误", "success": false,
"errorCode": "ok" "errorMsg": result.msg,
}; "errorCode": "ok"
} };
var result = JSON.parse(rtn.stdout); }
if (result.status != 0) { userparam.actionBody.channelUserId = result.data.channelUserId
return { userparam.actionBody.mobile = result.data.publishMobile
"requestId": result.requestId, userparam.actionBody.userName = result.data.publishMobile
"success": false, pobj.publishMobile = result.data.publishMobile;
"errorMsg": result.msg, pobj.channelNeedNo = result.data.channelNeedNo;
"errorCode": "ok" pobj.needNo = result.data.needNo;
}; pobj.channelTypeCode = result.data.channelTypeCode;
} pobj.province = result.data.solutionProvince;//北京(新购)?
return { }
"requestId": result.requestId, var url = settings.centerChannelUrl() + "/api/opreceive/accessAuth/springBoard";
"success": true, var userpinResultTmp = await this.execlient.execPostTK(userparam, url, tokenInfo.data.token);
"errorMsg": "", if (userpinResultTmp.status != 0) {
"errorCode": "ok" return {
}; "requestId": userpinResultTmp.requestId,
} "success": false,
"errorMsg": userpinResultTmp.msg,
"errorCode": "ok"
};
}
// icpNotify
var url = settings.centerChannelUrl() + "/api/action/regapi/springBoard";
var sobj = {
"actionType": "icpNotify",
"actionBody": pobj
}
var rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, token, userpinResultTmp.data.userpin);
if (!rtn || !rtn.stdout) {
return {
"requestId": regCfg.getUUID(),
"success": false,
"errorMsg": "网络错误",
"errorCode": "ok"
};
}
var result = JSON.parse(rtn.stdout);
if (result.status != 0) {
return {
"requestId": result.requestId,
"success": false,
"errorMsg": result.msg,
"errorCode": "ok"
};
}
return {
"requestId": result.requestId,
"success": true,
"errorMsg": "",
"errorCode": "ok"
};
}
} }
module.exports = RegCenterOrderService; module.exports = RegCenterOrderService;
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