Commit 60392743 by zhaoxiqing

gsb

parent c64cdc36
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
class ActionAPI extends APIBase { class ActionAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.accountSve = system.getObject("service.account.accountSve"); this.accountSve = system.getObject("service.account.accountSve");
this.merchantSve = system.getObject("service.merchant.merchantSve");
this.merchanttradeSve = system.getObject("service.merchant.merchanttradeSve");
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
} }
/** /**
* 接口跳转 * 接口跳转
* action_process 执行的流程 * action_process 执行的流程
...@@ -21,11 +26,11 @@ class ActionAPI extends APIBase { ...@@ -21,11 +26,11 @@ class ActionAPI extends APIBase {
return system.getResult(null, "action_type参数不能为空"); return system.getResult(null, "action_type参数不能为空");
} }
try { try {
result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body); result = await this.handleRequest(pobj.action_process, pobj.action_type, pobj.action_body);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
return result; return result;
} }
...@@ -62,15 +67,52 @@ class ActionAPI extends APIBase { ...@@ -62,15 +67,52 @@ class ActionAPI extends APIBase {
case "test4": case "test4":
opResult = await this.accountSve.test(action_body); opResult = await this.accountSve.test(action_body);
break; break;
//商户管理
// 增加或修改商户
case "addModifyMerchants":
opResult = await this.merchantSve.addModifyMerchants(action_body);
break;
//商户列表
case "merchantOfList":
opResult = await this.merchantSve.merchantOfList(action_body);
break;
//商户审核
case "auditMerchant":
opResult = await this.merchantSve.auditMerchant(action_body);
break;
//商户名称
case "merchantSuggest":
opResult = await this.merchantSve.merchantSuggest(action_body);
break;
//资金调账
// 新增充值
case "addMerchanttrades":
opResult = await this.merchanttradeSve.addMerchanttrades(action_body);
break;
//资金调账列表
case "merchanttradesOfList":
opResult = await this.merchanttradeSve.merchanttradesOfList(action_body);
break;
//审核
case "auditMerchanttrade":
opResult = await this.merchanttradeSve.auditMerchanttrade(action_body);
break;
//资金流水
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
} }
return opResult; return opResult;
} }
exam() { exam() {
return `<pre><pre/>`; return `<pre><pre/>`;
} }
classDesc() { classDesc() {
return { return {
groupName: "op", groupName: "op",
...@@ -80,6 +122,7 @@ class ActionAPI extends APIBase { ...@@ -80,6 +122,7 @@ class ActionAPI extends APIBase {
exam: "", exam: "",
}; };
} }
methodDescs() { methodDescs() {
return [ return [
{ {
...@@ -111,4 +154,5 @@ class ActionAPI extends APIBase { ...@@ -111,4 +154,5 @@ class ActionAPI extends APIBase {
]; ];
} }
} }
module.exports = ActionAPI;
\ No newline at end of file module.exports = ActionAPI;
const Dao = require("../../dao.base");
class MerchantDao extends Dao {
constructor() {
super(Dao.getModelName(MerchantDao));
}
async suggest(name) {
if (!name) {
return [];
}
var sql = "SELECT id, name FROM `e_merchant` WHERE name LIKE :queryLike AND deleted_at IS NULL ";
sql = sql + " ORDER BY id ASC LIMIT 10";
var list = await this.customQuery(sql, {queryLike: "%" + name + "%"});
return list || [];
}
}
module.exports = MerchantDao;
const Dao=require("../../dao.base");
class MerchantaccountDao extends Dao{
constructor(){
super(Dao.getModelName(MerchantaccountDao));
}
}
module.exports=MerchantaccountDao;
const Dao=require("../../dao.base");
class merchanttradeDao extends Dao{
constructor(){
super(Dao.getModelName(merchanttradeDao));
}
}
module.exports=merchanttradeDao;
module.exports = (db, DataTypes) => {
return db.define("merchant", {
name: DataTypes.STRING,
short_name: DataTypes.STRING,
credit_code: DataTypes.STRING,
tax_type: DataTypes.STRING,
business_lincense_img: DataTypes.STRING,
account_name: DataTypes.STRING,
account_bank_name: DataTypes.STRING,
account_bank_no: DataTypes.STRING,
account_mobile: DataTypes.STRING,
contact_man: DataTypes.STRING,
contact_mobile: DataTypes.STRING,
contact_email: DataTypes.STRING,
contact_addr: DataTypes.STRING,
bd_id: DataTypes.STRING,
bd_mobile: DataTypes.STRING,
bd_email: DataTypes.STRING,
audit_status: DataTypes.TINYINT,
audit_remark: DataTypes.STRING,
audit_user_id: DataTypes.STRING,
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
tableName: 'e_merchant',
validate: {},
indexes: []
});
}
module.exports = (db, DataTypes) => {
return db.define("merchantaccount", {
merchant_id: DataTypes.STRING,
balance_amount: DataTypes.BIGINT,
available_amount: DataTypes.BIGINT,
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
tableName: 'e_merchant_account',
validate: {},
indexes: []
});
}
module.exports = (db, DataTypes) => {
return db.define("merchanttrade", {
merchant_id: DataTypes.STRING,
trade_type: DataTypes.TINYINT,
trade_data_id: DataTypes.STRING,
pay_type: DataTypes.TINYINT,
amount_type: DataTypes.TINYINT,
amount: DataTypes.BIGINT,
trade_time: DataTypes.DATE,
trade_voucher: DataTypes.STRING,
audit_status: DataTypes.TINYINT,
audit_remark: DataTypes.STRING,
audit_user_id: DataTypes.STRING,
balance_amount: DataTypes.BIGINT,
available_amount: DataTypes.BIGINT,
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
tableName: 'e_merchant_trade',
validate: {},
indexes: []
});
}
const ServiceBase = require("../../sve.base");
class MerchantService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchantService));
}
async addModifyMerchants(params) {
try {
if (!params.name) {
return system.getResultFail(-1, "请提供商户名称");
}
if (!params.short_name) {
return system.getResultFail(-1, "请提供商户简称");
}
if (!params.credit_code) {
return system.getResultFail(-1, "请提供统一社会信用代码");
}
if (!params.tax_type) {
return system.getResultFail(-1, "请选择纳税人类型");
}
if (!params.business_lincense_img) {
return system.getResultFail(-1, "请上传营业执照");
}
if (!params.account_name) {
return system.getResultFail(-1, "请提供开户名称");
}
if (!params.account_bank_no) {
return system.getResultFail(-1, "请提供对公账号");
}
if (!params.account_bank_name) {
return system.getResultFail(-1, "请提供开户行");
}
if (!params.contact_man) {
return system.getResultFail(-1, "请提供联系人姓名");
}
if (!params.contact_mobile) {
return system.getResultFail(-1, "请提供联系人电话");
}
if (!params.contact_email) {
return system.getResultFail(-1, "请提供联系人Email");
}
if (!params.contact_addr) {
return system.getResultFail(-1, "请提供联系人地址");
}
if (!params.bd_id) {
return system.getResultFail(-1, "请选择客户经理");
}
if (!params.bd_mobile) {
return system.getResultFail(-1, "请提供客户经理电话");
}
if (!params.bd_email) {
return system.getResultFail(-1, "请提供客户经理Email");
}
var merchant = null;
if (params.id) {
merchant = await this.service.findById(params.id);
}
var rtn = null;
if (merchant) {
rtn = await this.service.update(params)
} else {
rtn = await this.service.create(params);
}
return system.getResultSuccess(rtn);
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
async merchantOfList(params) {
try {
var currentPage = Number(params.currentPage || 0);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.name) {
where.name = {
[this.db.Op.like]: params.name
};
}
this.addWhereTime(where, 'completed_at', params.beginTime, params.entTime, true);
var orderby = [["id", 'desc']];
var attributes = [`id`, `name`, `credit_code`, `contact_man`, `contact_mobile`, `contact_email`, `account_name`, `audit_status`];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
// if (page && page.rows) {
// for (var row of page.rows) {
// this.handleDate(row, ["created_at"], null);
// }
// }
return system.getResultSuccess(page);
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
async auditMerchant(params) {
try {
if (!params.id) {
return system.getResultFail(-1, "请提供商户ID");
}
if (params.audit_status == 0) {
return system.getResultFail(-1, "请选择审核状态");
}
if (params.audit_status == 2 && !params.audit_remark) {
return system.getResultFail(-1, "请输入失败原因");
}
var rtn = await this.service.update(params);
return system.getResultSuccess(rtn);
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
async merchantSuggest(params) {
try {
return await this.dao.suggest(name);
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
}
module.exports = MerchantService;
const ServiceBase = require("../../sve.base");
class MerchantaccountService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchantaccountService));
}
}
module.exports = MerchantaccountService;
const ServiceBase = require("../../sve.base");
class MerchanttradeService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchanttradeService));
}
async addMerchanttrades(params) {
try {
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
async merchanttradesOfList(params) {
try {
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
async auditMerchanttrade(params) {
try {
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
}
module.exports = MerchanttradeService;
...@@ -6,7 +6,7 @@ var settings={ ...@@ -6,7 +6,7 @@ var settings={
db:10, db:10,
}, },
database:{ database:{
dbname : "engine-product", dbname : "esign-sve-merchant",
user: "write", user: "write",
password: "write", password: "write",
config: { config: {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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