Commit 15796978 by 王昆

gsb

parent 7704bd18
......@@ -101,7 +101,10 @@ class ActionAPI extends APIBase {
case "mchtSign":
opResult = await this.saasmerchantSve.sign(action_body);
break;
case "mchtSettings":
opResult = await this.saasmerchantSve.getSettings(action_body);
break;
// ------------------------------以下api为历史将要弃用的---------------------------------------
// 商户api
// case "infoList":
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SaasmerchantSettingsDao extends Dao {
constructor() {
super(Dao.getModelName(SaasmerchantSettingsDao));
}
async listByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE id IN (:ids) `;
return await this.customQuery(sql, {
ids: ids
});
}
async mapByIds(ids, attrs) {
let result = {};
let list = await this.listByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
async bySaasId(saasId, attrs) {
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE saas_id = :saasId `;
return await this.customQuery(sql, {
saasId: saasId
});
}
async byChannelId(channelId, attrs) {
attrs = attrs || "*";
let sql = `SELECT ${attrs} FROM ${this.model.tableName} WHERE channel_id = :channelId `;
return await this.customQuery(sql, {
channelId: channelId
});
}
async countByCondition(params) {
var sql = [];
sql.push("SELECT");
sql.push("count(1) as num");
sql.push("FROM saas_merchant t1");
sql.push("INNER JOIN saas_merchant_sign t2 ON t1.id = t2.id");
sql.push("WHERE 1 = 1 ");
this.setCondition(sql, params);
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return 0;
}
return list[0].num;
}
async listByCondition(params) {
params.startRow = Number(params.startRow || 0);
params.pageSize = Number(params.pageSize || 10);
var sql = [];
sql.push("SELECT");
sql.push("t1.*,");
sql.push("t2.main_id, t2.begin_date, t2.end_date, t2.bm_reg_price, t2.invoice_service_rate, t2.trans_service_rate ");
sql.push("FROM saas_merchant t1");
sql.push("INNER JOIN saas_merchant_sign t2 ON t1.id = t2.id");
sql.push("WHERE 1 = 1 ");
this.setCondition(sql, params);
sql.push("ORDER BY t1.id DESC");
sql.push("LIMIT :startRow, :pageSize");
return await this.customQuery(sql.join(" "), params);
}
setCondition(sql, params) {
if (!params || !sql) {
return;
}
if (params.saas_id) {
sql.push("AND t1.saas_id = :saas_id");
}
if (params.channel_id) {
sql.push("AND t1.channel_id = :channel_id");
}
if (params.name) {
params.nameLike = `%${params.name}%`;
sql.push("AND t1.name LIKE :nameLike");
}
if (params.credit_code) {
sql.push("AND t1.credit_code LIKE :credit_code");
}
if(typeof params.is_sign != "undefined" && (params.is_sign === 1 || params.is_sign === 0)) {
sql.push("AND t1.is_sign LIKE :is_sign");
}
if (params.createBegin) {
sql.push("AND t1.created_at >= :createBegin");
}
if (params.createEnd) {
sql.push("AND t1.created_at <= :createEnd");
}
}
}
module.exports = SaasmerchantSettingsDao;
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("saasmerchantsettings", {
appid: DataTypes.STRING,
secret: DataTypes.STRING,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'saas_merchant_settings',
validate: {
},
indexes:[
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
......@@ -6,6 +6,7 @@ class SaasMerchantService extends ServiceBase {
super("merchant", ServiceBase.getDaoName(SaasMerchantService));
this.saasmerchantsignDao = system.getObject("db.merchant.saasmerchantsignDao");
this.saasmerchantsettingsDao = system.getObject("db.merchant.saasmerchantsettingsDao");
}
// -----------------------以此间隔,上面为API,下面为service---------------------------------
......@@ -240,6 +241,14 @@ class SaasMerchantService extends ServiceBase {
await merchant.save();
return system.getResultSuccess();
}
async getSettings(params) {
let rs = await this.saasmerchantsettingsDao.getById(params.id);
return system.getResultSuccess({
appid: rs.appid,
secret: rs.secret,
});
}
}
module.exports = SaasMerchantService;
// var task=new UserService();
......
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