Commit 571eea34 by 王栋源

wdy

parent 89bc05d9
const system = require("../../../system");
var APIBase = require("../../api.base");
var settings = require("../../../../config/settings");
class TradetransferAPI extends APIBase {
constructor() {
super();
this.aliclient = system.getObject("util.aliyunClient");
this.execlient = system.getObject("util.execClient");
this.transferurl = settings.reqTransferurl();
}
//订单创建
async createtransfer(obj) {
if (!obj.BizId) {
return {
"errorCode": "error",
"errorMsg": "订单号不能为空",
"module": { "orderNumber": "" },
"requestId": obj.requestid,
"success": false
}
}
if (!obj.UserName) {
return {
"errorCode": "error",
"errorMsg": "用户不能为空",
"module": { "orderNumber": "" },
"requestId": obj.requestid,
"success": false
}
}
if (!obj.Mobile) {
return {
"errorCode": "error",
"errorMsg": "用户手机号不能为空",
"module": { "orderNumber": "" },
"requestId": obj.requestid,
"success": false
}
}
if (!obj.Price) {
return {
"errorCode": "error",
"errorMsg": "价格不能为空",
"module": { "orderNumber": "" },
"requestId": obj.requestid,
"success": false
}
}
var orderinfo = await this.orderSve.findOne({ ali_bizid: obj.BizId });
if (orderinfo) {
return {
"errorCode": "OK",
"errorMsg": "订单已存在",
"module": { "orderId": orderinfo.dataValue.fq_ordernum },
"requestId": obj.requestid,
"success": true
}
} else {
var orderinfo = await this.orderSve.create(obj);
var url = this.transferurl + "api/transfer/tradeApi/closeOrder";
var transferinfo = await this.execlient.execPost(obj, url);
if (transferinfo) {
return {
"errorCode": "OK",
"errorMsg": "",
"module": { "orderNumber": orderinfo.dataValue.fq_ordernum },
"requestId": obj.requestid,
"success": true
}
}
}
}
//订单查询
async ordersel(p,obj) {
var url = this.transferurl + "api/transfer/tradeApi/queryOrderState";
var transferinfo = await this.execlient.execPost(obj.actionBody, url);
var a=JSON.parse(transferinfo.stdout)
return a;
}
//订单关闭
async orderclose(obj) {
var url = this.transferurl + "api/transfer/tradeApi/closeOrder";
var transferinfo = await this.execlient.execPost(obj, url);
return transferinfo;
}
//业务员分配
async fenpeiowner(obj) {
if (!obj.BizId) {
return {
"errorCode": "error",
"errorMsg": "订单号不能为空",
"requestId": obj.requestid,
"success": false
}
}
var transferinfo = await this.findOne({ ali_bizid: obj.BizId });
}
//阿里网关
async aliclienttransfer(obj) {
if (obj.actionBody) {
var rtn = await this.aliclient.reqbyget(obj.actionBody)
return rtn;
}
}
}
module.exports = TradetransferAPI;
const Client = require('aliyun-api-gateway').Client;
var RPCClient = require('@alicloud/pop-core').RPCClient;
// const client = new Client('203727307', 'b6za34qem6k9a3s3jguvh24nc3ridlnh');
const client = new Client('203756805', 'crkyej0xlmqa6bmvqijun6ltxparllyn');
class aliyunClient {
constructor() {
// this.aliReqUrl = "https://aliapi.gongsibao.com/tm/springboard";
this.aliclient = new RPCClient({
accessKeyId: 'LTAI4FvNyYTUtvfUsuoMzy7D',
accessKeySecret: '1B4YqlWxNUtMpifbtmExQwY7m3Caj4',
endpoint: 'https://trademark.aliyuncs.com',
apiVersion: '2018-07-24'
});
}
async post(aliReqUrl, actionBody) {
// var reqParam = {};
......@@ -25,6 +32,20 @@ class aliyunClient {
console.log(JSON.stringify(result), "______________峰擎---阿里云返回结果_______");
return result;
}
//阿里接口
async reqbyget(obj, cbk) {
var self = this;
var action = obj.action;
var reqbody = obj.reqbody;
return self.aliclient.request(action, reqbody, {
timeout: 3000, // default 3000 ms
formatAction: true, // default true, format the action to Action
formatParams: true, // default true, format the parameter name to first letter upper case
method: 'GET', // set the http method, default is GET
headers: {}, // set the http request headers
});
}
// async getCreateOrderNum() {
// var createOrderNum = await this.getUidStr(5, 36);//====================订单号生成
......
......@@ -27,6 +27,13 @@ var settings = {
return "http://open.gongsibao.com/";
}
},
reqTransferurl: function () {
if (this.env == "dev") {
return "http://192.168.18.61:3003/";
} else {
return "http://jxy-service/";
}
},
reqEsAddr: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,6 +9,7 @@
"author": "jy",
"license": "ISC",
"dependencies": {
"@alicloud/pop-core": "^1.7.7",
"MD5": "^1.3.0",
"after": "^0.8.2",
"ali-oss": "^4.12.2",
......
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