Commit 1b8c58bd by 王昆

gsb

parent 7343bdf7
......@@ -11,13 +11,14 @@ class ActionAPI extends APIBase {
this.saasmerchantSve = system.getObject("service.merchant.saasmerchantSve");
this.saasmerchanttitleSve = system.getObject("service.merchant.saasmerchanttitleSve");
this.saasmerchantaddrSve = system.getObject("service.merchant.saasmerchantaddrSve");
this.saasmerchantconsumeSve = system.getObject("service.merchant.saasmerchantconsumeSve");
// -------------------------------将要弃用------------------------------------------
this.merchantSve = system.getObject("service.merchant.merchantSve");
this.merchantsignedSve = system.getObject("service.merchant.merchantsignedSve");
this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve");
this.merchanttitleSve = system.getObject("service.merchant.merchanttitleSve");
this.merchantaddressSve = system.getObject("service.merchant.merchantaddressSve");
// this.merchantSve = system.getObject("service.merchant.merchantSve");
// this.merchantsignedSve = system.getObject("service.merchant.merchantsignedSve");
// this.merchantaccountSve = system.getObject("service.merchant.merchantaccountSve");
// this.merchantrechargeSve = system.getObject("service.merchant.merchantrechargeSve");
// this.merchanttitleSve = system.getObject("service.merchant.merchanttitleSve");
// this.merchantaddressSve = system.getObject("service.merchant.merchantaddressSve");
}
/**
* 接口跳转
......@@ -126,8 +127,8 @@ class ActionAPI extends APIBase {
case "mchtAddrs":
opResult = await this.saasmerchantaddrSve.byMerchantId(action_body);
break;
case "mchtAddrSave":
opResult = await this.saasmerchantaddrSve.saveByMerchantId(action_body);
case "addConsumeLog":
opResult = await this.saasmerchantconsumeSve.addLog(action_body);
break;
// ------------------------------以下api为历史将要弃用的---------------------------------------
// 商户api
......
......@@ -10,7 +10,7 @@ class Dao {
}
async preCreate(u) {
if (!u.id) {
if (!u.id && !u.autoIncrement) {
u.id = await this.redisClient.genrateId(this.modelName);
}
return u;
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SaasmerchantConsumeDao extends Dao {
constructor() {
super(Dao.getModelName(SaasmerchantConsumeDao));
}
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) {
this.setCondition();
return 0;
}
async listByCondition(params) {
params.startRow = Number(params.startRow || 0);
params.pageSize = Number(params.pageSize || 10);
this.setCondition();
return [];
}
setCondition(sql, params) {
if (!params || !sql) {
return;
}
if (params.saas_id) {
sql.push("AND saas_id = :saas_id");
}
if (params.saas_merchant_id) {
sql.push("AND saas_merchant_id = :saas_merchant_id");
}
if (params.createBegin) {
sql.push("AND created_at >= :createBegin");
}
if (params.createEnd) {
sql.push("AND created_at <= :createEnd");
}
}
}
module.exports = SaasmerchantConsumeDao;
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("saasmerchantconsume", {
saas_id: DataTypes.STRING,
saas_merchant_id: DataTypes.STRING,
consume_type: DataTypes.STRING,
consume_id: DataTypes.STRING,
result: DataTypes.STRING,
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'saas_merchant_consume',
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}]
// }
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class SaasmerchantConsumeService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(SaasmerchantConsumeService));
}
async addLog(params) {
let log = params.log;
if (!log) {
console.log(`商户日志插入错误,[${JSON.stringify(params.log)}]`);
return system.getResult(null, "log为空");
}
log.autoIncrement = true;
let rs = await this.dao.create(log);
return system.getResultSuccess(rs);
}
}
module.exports = SaasmerchantConsumeService;
\ No newline at end of file
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