Commit b173fe85 by 王悦

阿里下订单走igirl_channel->老加西亚

parent 49418136
const system = require("../../../system");
var settings = require("../../../../config/settings");
var APIBase = require("../../api.base");
class TradetransferAPI extends APIBase {
constructor() {
super();
this.execlient = system.getObject("util.execClient");
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
this.channelApiUrl = settings.channelApiUrl();
this.centerChannelUrl = settings.centerChannelUrl();
this.appInfo = {
aliyuntmtransfer: { appkey: settings.appKey, secret: settings.secret }
};
}
async getToken() {
var self = this;
var reqTokenUrl = this.channelApiUrl + "/web/auth/accessAuth/getAppTokenByHosts";
// var reqParam = self.appInfo["aliyuntmtransfer"];
var reqParam = {
"actionType": "getAppTokenByHosts",
"actionBody": {}
}
// if (!reqParam.appkey || !reqParam.secret) {
// return system.getResult(null, "reqType类型有误,请求失败");
// }
var rtn = await this.execlient.execPost(reqParam, reqTokenUrl);
if (!rtn.stdout) {
return system.getResult(null, "获取token失败");
}
var tokenResult = JSON.parse(rtn.stdout);
if (tokenResult.status == 0) {
tokenResult.data.secret = reqParam.secret;
}
return tokenResult;
}
//订单创建
// 2020 0828 lin 修改 匹配商标交易
async acceptOrder(pobj,qobj,req) {
if (!pobj&&!qobj){
console.log("请求参数为空",req)
}
if (!pobj.BizId) {
return {
"errorCode": "error",
"errorMsg": "订单号不能为空",
"module": { "orderNumber": "" },
"eequestId": req.requestId,
"success": false
}
}
if (!pobj.UserName) {
return {
"errorCode": "error",
"errorMsg": "用户不能为空",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
}
}
if (!pobj.Mobile) {
return {
"errorCode": "error",
"errorMsg": "用户手机号不能为空",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
}
}
if (!pobj.Price) {
return {
"errorCode": "error",
"errorMsg": "价格不能为空",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
}
}
if (!pobj.RegisterNumber) {
return {
"errorCode": "error",
"errorMsg": "商标注册号不能为空",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
}
}
if (!pobj.Classification) {
return {
"errorCode": "error",
"errorMsg": "商标国际一级分类不能为空",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
}
}
var sobj = {
"actionProcess": "aliyuntmtransfer",
"actionType": "tmAccept",
"actionBody": {
"bizId": pobj.BizId,
"userName": pobj.UserName,
"mobile": pobj.Mobile,
"registerNumber": pobj.RegisterNumber,
"classification": pobj.Classification,
"price": pobj.Price,
"channelItemCode":"tmjy",
"payCode": "tmjy-1",
"quantity":1,
"totalSum": pobj.Price,
"payTotalSum": pobj.Price,
"channelOrder":{
"channelServiceNo": pobj.BizId,
"channelOrderNo": pobj.BizId
}
}
}
// 获取token
var tokenInfo = await this.getToken();
if (tokenInfo.status != 0) {
return {
"errorCode": "error",
"errorMsg": "渠道验证失败",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
};
}
// 获取userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.Mobile,
"mobile": pobj.Mobile,
"userName": pobj.UserName
}
};
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 {
"errorCode": "error",
"errorMsg": "用户验证失败",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
};
}
// 调取channel 开始业务
var url = this.channelApiUrl + "/web/opaction/tmOrder/springBoard";
// var rtn = await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
var rtn = rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, tokenInfo.data.token, userpinResultTmp.data.userpin);
if (!rtn.stdout) {
return {
"errorCode": "error",
"errorMsg": "建立订单失败",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
};
}
return JSON.parse(rtn.stdout);
}
//订单查询
async queryOrderState(p,obj) {
var sobj = {
"actionProcess": "aliyuntmtransfer",
"actionType": "aliclient",
"sign": "2FviZ9PGws8Pt1fBhq0t90mjUvI",
"actionBody": p
}
var tokenInfo = await this.getToken();
console.log(tokenInfo);
var url = this.channelApiUrl + "/action/tradetransfer/ordersel";
var rtn = await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
console.log(rtn);
// var rtn = await this.execlient.execPostTK(sobj, url,"token");
return rtn;
}
//订单关闭
async tmRefuse(p,obj,req) {
var sobj = {
"actionProcess": "aliyuntmtransfer",
"actionType": "tmRefuse",
"actionBody": {
bizId: obj.BizId
}
}
var tokenInfo = await this.getToken();
var url = this.channelApiUrl + "/web/opaction/tmOrder/springBoard";
var rtn = await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
// var rtn = await this.execlient.execPostTK(sobj, url,"token");
return rtn;
}
//查询咨询客户列表
async queryTradeIntentionUserList(p,obj) {
let sobj = {
"actionType": "QueryTradeIntentionUserList",
};
let tokenInfo = await this.utilsNeedSve.getCenterToken();
let url = this.centerChannelUrl + "/web/trade/brand/springBoard";
return await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
}
}
module.exports = TradetransferAPI;
......@@ -16,15 +16,11 @@ class TradetransferAPI extends APIBase {
async getToken() {
var self = this;
var reqTokenUrl = this.channelApiUrl + "/web/auth/accessAuth/getAppTokenByHosts";
// var reqParam = self.appInfo["aliyuntmtransfer"];
var reqParam = {
"actionType": "getAppTokenByHosts",
"actionBody": {}
}
// if (!reqParam.appkey || !reqParam.secret) {
// return system.getResult(null, "reqType类型有误,请求失败");
// }
var reqTokenUrl = this.channelApiUrl + "/auth/accessAuth/getToken";
var reqParam = self.appInfo["aliyuntmtransfer"];
if (!reqParam.appkey || !reqParam.secret) {
return system.getResult(null, "reqType类型有误,请求失败");
}
var rtn = await this.execlient.execPost(reqParam, reqTokenUrl);
if (!rtn.stdout) {
return system.getResult(null, "获取token失败");
......@@ -37,17 +33,13 @@ class TradetransferAPI extends APIBase {
}
//订单创建
// 2020 0828 lin 修改 匹配商标交易
async acceptOrder(pobj,qobj,req) {
if (!pobj&&!qobj){
console.log("请求参数为空",req)
}
if (!pobj.BizId) {
return {
"errorCode": "error",
"errorMsg": "订单号不能为空",
"module": { "orderNumber": "" },
"eequestId": req.requestId,
"requestId": req.requestId,
"success": false
}
}
......@@ -78,90 +70,39 @@ class TradetransferAPI extends APIBase {
"success": false
}
}
if (!pobj.RegisterNumber) {
return {
"errorCode": "error",
"errorMsg": "商标注册号不能为空",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
}
}
if (!pobj.Classification) {
return {
"errorCode": "error",
"errorMsg": "商标国际一级分类不能为空",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
}
}
var sobj = {
"actionProcess": "aliyuntmtransfer",
"actionType": "tmAccept",
"actionType": "aliclient",
"sign": "2FviZ9PGws8Pt1fBhq0t90mjUvI",
"isUser": "yes",
"actionBody": {
"bizId": pobj.BizId,
"userName": pobj.UserName,
"mobile": pobj.Mobile,
"registerNumber": pobj.RegisterNumber,
"classification": pobj.Classification,
"price": pobj.Price,
"channelItemCode":"tmjy",
"payCode": "tmjy-1",
"quantity":1,
"totalSum": pobj.Price,
"payTotalSum": pobj.Price,
"channelOrder":{
"itemCode": "alitmtt",
"channelParams": pobj,
"channelUser": {
"channelUserId": pobj.Mobile,
"channelUserName": pobj.UserName,
"channelUserMoblie": pobj.Mobile,
"nickname": "",
"orgName": "",
"orgPath": ""
},
"channelOrder": {
"channelServiceNo": pobj.BizId,
"channelOrderNo": pobj.BizId
"channelOrderNo": "",
"needNo": pobj.BizId,
"quantity": 1,
"totalSum": parseInt(pobj.Price),
"payTotalSum": parseInt(pobj.Price) * 0.2,
"payStatus": "bfyfk",
"payTime": (new Date()).Format("yyyy-MM-dd hh:mm:ss")
}
}
}
// 获取token
var tokenInfo = await this.getToken();
if (tokenInfo.status != 0) {
return {
"errorCode": "error",
"errorMsg": "渠道验证失败",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
};
}
// 获取userpin
var userparam = {
actionType: "getLoginByUserName",
actionBody: {
"channelUserId": pobj.Mobile,
"mobile": pobj.Mobile,
"userName": pobj.UserName
}
};
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 {
"errorCode": "error",
"errorMsg": "用户验证失败",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
};
}
// 调取channel 开始业务
var url = this.channelApiUrl + "/web/opaction/tmOrder/springBoard";
// var rtn = await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
var rtn = rtn = await this.execlient.execDataPostByTokenUserPin(sobj, url, tokenInfo.data.token, userpinResultTmp.data.userpin);
if (!rtn.stdout) {
return {
"errorCode": "error",
"errorMsg": "建立订单失败",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
};
}
return JSON.parse(rtn.stdout);
var url = this.channelApiUrl + "/action/tradetransfer/createtransfer";
var rtn = await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
//var rtn = await this.execlient.execPostTK(sobj, url,"token");
return rtn;
}
//订单查询
async queryOrderState(p,obj) {
......@@ -181,16 +122,15 @@ class TradetransferAPI extends APIBase {
}
//订单关闭
async tmRefuse(p,obj,req) {
async closeOrder(p,obj) {
var sobj = {
"actionProcess": "aliyuntmtransfer",
"actionType": "tmRefuse",
"actionBody": {
bizId: obj.BizId
}
"actionType": "aliclient",
"sign": "2FviZ9PGws8Pt1fBhq0t90mjUvI",
"actionBody": p
}
var tokenInfo = await this.getToken();
var url = this.channelApiUrl + "/web/opaction/tmOrder/springBoard";
var url = this.channelApiUrl + "/action/tradetransfer/orderclose";
var rtn = await this.execlient.execPostTK(sobj, url, tokenInfo.data.token);
// var rtn = await this.execlient.execPostTK(sobj, url,"token");
return rtn;
......
......@@ -38,8 +38,8 @@ var settings = {
// return "http://192.168.210.192:4003";
return "http://ali.qifu.gongsibao.com:4012";
} else {
// return "http://zc-channel-service";
return "http://ali.qifu.gongsibao.com";
return "http://zc-channel-service";
//return "http://ali.qifu.gongsibao.com";
}
},
centerChannelUrl: function () {//---------center-channel
......
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