Commit ec0be88d by 王栋源

wdy

parent 0fa0defa
const system = require("../../../system"); const system = require("../../../system");
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
var moment = require('moment')
class TradetransferAPI extends APIBase { class TradetransferAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.aliclient = system.getObject("util.aliyunClient"); this.aliclient = system.getObject("util.aliyunClient");
this.execlient = system.getObject("util.execClient"); this.execlient = system.getObject("util.execClient");
this.transferurl = settings.reqTransferurl(); this.transferurl = settings.reqTransferurl();
this.corderSve = system.getObject("service.dbcorder.orderinfoSve");
} }
//订单创建 //订单创建
async createtransfer(obj) { async createtransfer(p, obj, req) {
if (!obj.BizId) { if (!obj.actionBody.BizId) {
return { return {
"errorCode": "error", "errorCode": "error",
"errorMsg": "订单号不能为空", "errorMsg": "订单号不能为空",
"module": { "orderNumber": "" }, "module": { "orderNumber": "" },
"requestId": obj.requestid, "requestId": req.requestId,
"success": false "success": false
} }
} }
if (!obj.UserName) { if (!obj.actionBody.UserName) {
return { return {
"errorCode": "error", "errorCode": "error",
"errorMsg": "用户不能为空", "errorMsg": "用户不能为空",
"module": { "orderNumber": "" }, "module": { "orderNumber": "" },
"requestId": obj.requestid, "requestId": req.requestId,
"success": false "success": false
} }
} }
if (!obj.Mobile) { if (!obj.actionBody.Mobile) {
return { return {
"errorCode": "error", "errorCode": "error",
"errorMsg": "用户手机号不能为空", "errorMsg": "用户手机号不能为空",
"module": { "orderNumber": "" }, "module": { "orderNumber": "" },
"requestId": obj.requestid, "requestId": req.requestId,
"success": false "success": false
} }
} }
if (!obj.Price) { if (!obj.actionBody.Price) {
return { return {
"errorCode": "error", "errorCode": "error",
"errorMsg": "价格不能为空", "errorMsg": "价格不能为空",
"module": { "orderNumber": "" }, "module": { "orderNumber": "" },
"requestId": obj.requestid, "requestId": req.requestId,
"success": false "success": false
} }
} }
var a = (new Date()).Format("yyyy-MM-dd hh:mm:ss");
var orderinfo = await this.orderSve.findOne({ ali_bizid: obj.BizId }); var orderc = {
if (orderinfo) { "actionProcess": "ali",
return { "actionType": "addOrder",
"errorCode": "OK", "isUser": "yes",
"errorMsg": "订单已存在", "actionBody":
"module": { "orderId": orderinfo.dataValue.fq_ordernum }, {
"requestId": obj.requestid, "itemCode": "alitmtt",
"success": true "channelParams": obj.actionBody,
"channelUser": {
"channelUserId": obj.actionBody.Mobile,
"channelUserName": obj.actionBody.UserName,
"channelUserMoblie": obj.actionBody.Mobile,
"nickname": "",
"orgName": "",
"orgPath": ""
},
"channelOrder": {
"channelServiceNo": obj.actionBody.BizId,
"channelOrderNo": "",
"needNo": obj.actionBody.BizId,
"quantity": 1,
"totalSum": parseInt(obj.actionBody.Price),
"payTotalSum": parseInt(obj.actionBody.Price) * 0.2,
"payStatus": "yfk",
"payTime": (new Date()).Format("yyyy-MM-dd hh:mm:ss")
}
} }
} else { }
var orderinfo = await this.orderSve.create(obj); var orderinfo = await this.corderSve.createOrder(orderc.actionBody, req);
var url = this.transferurl + "api/transfer/tradeApi/closeOrder"; if (orderinfo) {
var transferinfo = await this.execlient.execPost(obj, url); if (orderinfo.status == "1") {
if (transferinfo) {
return { return {
"errorCode": "OK", "errorCode": "OK",
"errorMsg": "", "errorMsg": "",
"module": { "orderNumber": orderinfo.dataValue.fq_ordernum }, "module": { "orderNumber": orderinfo.dataValue.fq_ordernum },
"requestId": obj.requestid, "requestId": req.requestId,
"success": true "success": true
} }
} else if (orderinfo.status == "2") {
return {
"errorCode": "OK",
"errorMsg": "订单已存在",
"module": { "orderId": orderinfo.dataValue.fq_ordernum },
"requestId": req.requestId,
"success": true
}
}
} else {
return {
"errorCode": "error",
"errorMsg": "",
"module": { "orderNumber": "" },
"requestId": req.requestId,
"success": false
} }
} }
} }
//订单查询 //订单查询
async ordersel(p,obj) { async ordersel(p, obj) {
var url = this.transferurl + "api/transfer/tradeApi/queryOrderState"; var url = this.transferurl + "api/transfer/tradeApi/queryOrderState";
var transferinfo = await this.execlient.execPost(obj.actionBody, url); var transferinfo = await this.execlient.execPost(obj.actionBody, url);
var a=JSON.parse(transferinfo.stdout) var a = JSON.parse(transferinfo.stdout)
return a; return a;
} }
...@@ -85,7 +121,7 @@ class TradetransferAPI extends APIBase { ...@@ -85,7 +121,7 @@ class TradetransferAPI extends APIBase {
async orderclose(obj) { async orderclose(obj) {
var url = this.transferurl + "api/transfer/tradeApi/closeOrder"; var url = this.transferurl + "api/transfer/tradeApi/closeOrder";
var transferinfo = await this.execlient.execPost(obj, url); var transferinfo = await this.execlient.execPost(obj, url);
var a=JSON.parse(transferinfo.stdout) var a = JSON.parse(transferinfo.stdout)
return a; return a;
} }
...@@ -96,7 +132,7 @@ class TradetransferAPI extends APIBase { ...@@ -96,7 +132,7 @@ class TradetransferAPI extends APIBase {
return { return {
"errorCode": "error", "errorCode": "error",
"errorMsg": "订单号不能为空", "errorMsg": "订单号不能为空",
"requestId": obj.requestid, "requestId": obj.requestId,
"success": false "success": false
} }
} }
......
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