Commit 90560737 by 王昆

gsb

parent 7029e472
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class TradeCtl extends CtlBase {
constructor() {
super();
this.tradeSve = system.getObject("service.trade.tradeSve");
this.redisClient = system.getObject("util.redisClient");
}
async orderPage(params, pobj2, req) {
try {
this.doTimeCondition(params, ["createBegin", "createEnd"]);
return await this.tradeSve.orderPage(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async orderInfo(params, pobj2, req) {
try {
return await this.tradeSve.orderInfo(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async itemPage(params, pobj2, req) {
try {
this.doTimeCondition(params, ["createBegin", "createEnd"]);
return await this.tradeSve.itemPage(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async audit1(params, pobj2, req) {
try {
return await this.tradeSve.audit1(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async audit2(params, pobj2, req) {
try {
return await this.tradeSve.audit2(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async trade(params, pobj2, req) {
try {
return await this.tradeSve.trade(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async tradeFeedBack(params, pobj2, req) {
try {
return await this.tradeSve.tradeFeedBack(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = TradeCtl;
\ No newline at end of file
......@@ -8,6 +8,11 @@ class MerchantService extends ServiceBase {
this.mainSve = system.getObject("service.saas.mainSve");
}
async idsLikeName(params) {
var rs = await this.callms("merchant", "mchtIdsLikeName", params || {});
return rs;
}
async mapByIds(params) {
var rs = await this.callms("merchant", "mchtMapByIds", params || {});
return rs;
......
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
const settings = require("../../../../config/settings");
class TradeService extends ServiceBase {
constructor() {
super();
this.businessmenSve = system.getObject("service.business.businessmenSve");
this.merchantSve = system.getObject("service.saas.merchantSve");
this.redisClient = system.getObject("util.redisClient");
}
async orderPage(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
let res = await this.setMerchantIdsByName(params);
if (res.status !== 0) {
return system.getResultSuccess({count: 0, rows: []});
}
let rs = await this.callms("trade", "orderPage", params) || {};
if (rs.data && rs.data.rows) {
this.transFields(rs.data.rows);
}
return rs;
}
async orderInfo(params) {
let rs = await this.callms("trade", "orderInfo", params) || {};
let order = rs.data;
if (order) {
this.transFields([order]);
let merchant = await this.merchantSve.info({id: order.saas_merchant_id}) || {};
merchant = merchant.data || {};
order.merchant_name = merchant.name;
}
return rs;
}
async setMerchantIdsByName(params) {
let merchantName = this.trim(params.merchant_name);
if (merchantName) {
let merchantIds = await this.merchantSve.idsLikeName({
name: merchantName,
saas_id: this.trim(params.saas_id),
saas_merchant_id: this.trim(params.saas_merchant_id),
}) || {};
if (!merchantIds || !merchantIds.data || merchantIds.data.length == 0) {
return system.getResult(null);
}
params.saas_merchant_ids = merchantIds.data;
}
return system.getResultSuccess();
}
async itemPage(params) {
params = params || {};
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
let res = await this.setMerchantIdsByName(params);
if (res.status !== 0) {
return system.getResultSuccess({count: 0, rows: []});
}
let rs = await this.callms("trade", "itemPage", params) || {};
if (rs.data && rs.data.rows) {
this.transFields(rs.data.rows);
}
return rs;
}
async audit1(params) {
let rs = await this.callms("trade", "orderAudit1", params) || {};
return rs;
}
async audit2(params) {
let rs = await this.callms("trade", "orderAudit2", params) || {};
return rs;
}
async trade(params) {
let rs = await this.callms("trade", "orderTrade", params) || {};
return rs;
}
async tradeFeedBack(params) {
let rs = await this.callms("trade", "itemTradeOfflineCB", params) || {};
return rs;
}
transFields(rows) {
if (!rows || rows.length == 0) {
return;
}
for (let row of rows) {
row.amt = system.f2y(row.amt);
row.actual_amt = system.f2y(row.actual_amt);
row.deduct_amt = system.f2y(row.deduct_amt);
row.service_tax = system.f2y(row.service_tax);
row.service_rate = system.f2y(row.service_rate);
}
}
}
module.exports = TradeService;
\ No newline at end of file
var fs = require("fs");
var objsettings = require("../config/objsettings");
var settings = require("../config/settings");
class System {
static declare(ns) {
var ar = ns.split('.');
......@@ -15,6 +16,7 @@ class System {
}
}
}
static register(key, ClassObj) {
if (System.objTable[key] != null) {
throw new Error("相同key的对象已经存在");
......@@ -25,6 +27,7 @@ class System {
return System.objTable[key];
}
static getResult(data, opmsg = "操作成功", req) {
return {
status: !data ? -1 : 0,
......@@ -33,6 +36,7 @@ class System {
bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : "empty"
};
}
/**
* 请求返回成功
* @param {*} data 操作成功返回的数据
......@@ -45,6 +49,7 @@ class System {
data: data || null,
};
}
/**
* 请求返回失败
* @param {*} status 操作失败状态,默认为-1
......@@ -58,6 +63,7 @@ class System {
data: data,
};
}
static getObject(objpath) {
var pathArray = objpath.split(".");
var packageName = pathArray[0];
......@@ -81,6 +87,7 @@ class System {
return System.register(objabspath, ClassObj);
}
}
static getUiConfig(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/" + appid + "/index.js";
if (settings.env == "dev") {
......@@ -89,6 +96,7 @@ class System {
var configValue = require(configPath);
return configValue;
}
static getUiConfig2(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/index.js";
// if(settings.env=="dev"){
......@@ -99,6 +107,7 @@ class System {
var configValue = require(configPath);
return configValue[appid];
}
static get_client_ip(req) {
var ip = req.headers['x-forwarded-for'] ||
req.ip ||
......@@ -144,6 +153,7 @@ class System {
}
}
}
static getUid(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var uuid = [],
......@@ -169,42 +179,40 @@ class System {
console.log(settings.env, "-------------- microsetting env ------------------");
var path = "/api/op/action/springboard";
if (settings.env == "dev") {
// var domain = "http://192.168.18.237";
let local = "http://127.0.0.1";
let dev = "http://39.107.234.14";
return {
// 公共服务
common: dev + ":3102" + path,
// common: "http://127.0.0.1:3102" + path,
// 商户服务
merchant: dev + ":3101" + path,
// merchant: "http://127.0.0.1:3101" + path,
// 订单服务
order: dev + ":3103" + path,
// order: "http://127.0.0.1:3103" + path,
// 发票服务
invoice: dev + ":3105" + path,
// invoice: "http://127.0.0.1:3105" + path,
// 用户服务
uc: dev + ":3106" + path,
// uc: "http://127.0.0.1:3106" + path,
// 交易
trade: local + ":3107" + path,
}
} else {
var odomain = "http://123.57.217.203"
return {
common: "xggsvecommon-service" + path,
merchant: "xggsvemerchant-service" + path,
order: "xggsveorder-service" + path,
invoice: "xggsveinvoice-service" + path,
uc: "xggsveuc-service" + path,
trade: "xggsvetrade-service" + path,
}
}
}
}
Date.prototype.Format = function (fmt) { //author: meizz
var o = {
"M+": this.getMonth() + 1, //月份
......
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