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 { ...@@ -8,6 +8,11 @@ class MerchantService extends ServiceBase {
this.mainSve = system.getObject("service.saas.mainSve"); this.mainSve = system.getObject("service.saas.mainSve");
} }
async idsLikeName(params) {
var rs = await this.callms("merchant", "mchtIdsLikeName", params || {});
return rs;
}
async mapByIds(params) { async mapByIds(params) {
var rs = await this.callms("merchant", "mchtMapByIds", params || {}); var rs = await this.callms("merchant", "mchtMapByIds", params || {});
return rs; 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 fs = require("fs");
var objsettings = require("../config/objsettings"); var objsettings = require("../config/objsettings");
var settings = require("../config/settings"); var settings = require("../config/settings");
class System { class System {
static declare(ns) { static declare(ns) {
var ar = ns.split('.'); var ar = ns.split('.');
...@@ -15,6 +16,7 @@ class System { ...@@ -15,6 +16,7 @@ class System {
} }
} }
} }
static register(key, ClassObj) { static register(key, ClassObj) {
if (System.objTable[key] != null) { if (System.objTable[key] != null) {
throw new Error("相同key的对象已经存在"); throw new Error("相同key的对象已经存在");
...@@ -25,6 +27,7 @@ class System { ...@@ -25,6 +27,7 @@ class System {
return System.objTable[key]; return System.objTable[key];
} }
static getResult(data, opmsg = "操作成功", req) { static getResult(data, opmsg = "操作成功", req) {
return { return {
status: !data ? -1 : 0, status: !data ? -1 : 0,
...@@ -33,6 +36,7 @@ class System { ...@@ -33,6 +36,7 @@ class System {
bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : "empty" bizmsg: req && req.session && req.session.bizmsg ? req.session.bizmsg : "empty"
}; };
} }
/** /**
* 请求返回成功 * 请求返回成功
* @param {*} data 操作成功返回的数据 * @param {*} data 操作成功返回的数据
...@@ -45,6 +49,7 @@ class System { ...@@ -45,6 +49,7 @@ class System {
data: data || null, data: data || null,
}; };
} }
/** /**
* 请求返回失败 * 请求返回失败
* @param {*} status 操作失败状态,默认为-1 * @param {*} status 操作失败状态,默认为-1
...@@ -58,6 +63,7 @@ class System { ...@@ -58,6 +63,7 @@ class System {
data: data, data: data,
}; };
} }
static getObject(objpath) { static getObject(objpath) {
var pathArray = objpath.split("."); var pathArray = objpath.split(".");
var packageName = pathArray[0]; var packageName = pathArray[0];
...@@ -81,6 +87,7 @@ class System { ...@@ -81,6 +87,7 @@ class System {
return System.register(objabspath, ClassObj); return System.register(objabspath, ClassObj);
} }
} }
static getUiConfig(appid) { static getUiConfig(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/" + appid + "/index.js"; var configPath = settings.basepath + "/app/base/db/metadata/" + appid + "/index.js";
if (settings.env == "dev") { if (settings.env == "dev") {
...@@ -89,6 +96,7 @@ class System { ...@@ -89,6 +96,7 @@ class System {
var configValue = require(configPath); var configValue = require(configPath);
return configValue; return configValue;
} }
static getUiConfig2(appid) { static getUiConfig2(appid) {
var configPath = settings.basepath + "/app/base/db/metadata/index.js"; var configPath = settings.basepath + "/app/base/db/metadata/index.js";
// if(settings.env=="dev"){ // if(settings.env=="dev"){
...@@ -99,6 +107,7 @@ class System { ...@@ -99,6 +107,7 @@ class System {
var configValue = require(configPath); var configValue = require(configPath);
return configValue[appid]; return configValue[appid];
} }
static get_client_ip(req) { static get_client_ip(req) {
var ip = req.headers['x-forwarded-for'] || var ip = req.headers['x-forwarded-for'] ||
req.ip || req.ip ||
...@@ -144,6 +153,7 @@ class System { ...@@ -144,6 +153,7 @@ class System {
} }
} }
} }
static getUid(len, radix) { static getUid(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var uuid = [], var uuid = [],
...@@ -169,42 +179,40 @@ class System { ...@@ -169,42 +179,40 @@ class System {
console.log(settings.env, "-------------- microsetting env ------------------"); console.log(settings.env, "-------------- microsetting env ------------------");
var path = "/api/op/action/springboard"; var path = "/api/op/action/springboard";
if (settings.env == "dev") { if (settings.env == "dev") {
// var domain = "http://192.168.18.237";
let local = "http://127.0.0.1"; let local = "http://127.0.0.1";
let dev = "http://39.107.234.14"; let dev = "http://39.107.234.14";
return { return {
// 公共服务 // 公共服务
common: dev + ":3102" + path, common: dev + ":3102" + path,
// common: "http://127.0.0.1:3102" + path,
// 商户服务 // 商户服务
merchant: dev + ":3101" + path, merchant: dev + ":3101" + path,
// merchant: "http://127.0.0.1:3101" + path,
// 订单服务 // 订单服务
order: dev + ":3103" + path, order: dev + ":3103" + path,
// order: "http://127.0.0.1:3103" + path,
// 发票服务 // 发票服务
invoice: dev + ":3105" + path, invoice: dev + ":3105" + path,
// invoice: "http://127.0.0.1:3105" + path,
// 用户服务 // 用户服务
uc: dev + ":3106" + path, uc: dev + ":3106" + path,
// uc: "http://127.0.0.1:3106" + path,
// 交易
trade: local + ":3107" + path,
} }
} else { } else {
var odomain = "http://123.57.217.203"
return { return {
common: "xggsvecommon-service" + path, common: "xggsvecommon-service" + path,
merchant: "xggsvemerchant-service" + path, merchant: "xggsvemerchant-service" + path,
order: "xggsveorder-service" + path, order: "xggsveorder-service" + path,
invoice: "xggsveinvoice-service" + path, invoice: "xggsveinvoice-service" + path,
uc: "xggsveuc-service" + path, uc: "xggsveuc-service" + path,
trade: "xggsvetrade-service" + path,
} }
} }
} }
} }
Date.prototype.Format = function (fmt) { //author: meizz Date.prototype.Format = function (fmt) { //author: meizz
var o = { var o = {
"M+": this.getMonth() + 1, //月份 "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