Commit 15298dac by zhaoxiqing

gsb

parent 383d07fb
......@@ -92,6 +92,10 @@ class ActionAPI extends APIBase {
case "addordelavailable" :
opResult = await this.merchantaccountSve.addordelavailable(action_body);
break;
//商户账户
case "merchantAccountList" :
opResult = await this.merchantaccountSve.addordelavailable(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
......
......@@ -4,6 +4,7 @@ const system = require("../../../system");
class MerchantaccountService extends ServiceBase {
constructor() {
super("merchant", ServiceBase.getDaoName(MerchantaccountService));
this.merchantDao = system.getObject("db.merchant.merchantDao")
}
async addtomerchantrmb(merchant_id, amount) {
......@@ -72,6 +73,43 @@ class MerchantaccountService extends ServiceBase {
}
}
async merchantAccountList(params) {
try {
var currentPage = Number(params.currentPage || 0);
var pageSize = Number(params.pageSize || 10);
var where = {};
if (params.merchant_id) {
where.name = {
[this.db.Op.eq]: params.merchant_id
};
}
var orderby = [["id", 'desc']];
var attributes = [];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
await this.setMerchantName(page.rows);
return system.getResultSuccess(page);
} catch (e) {
console.log(e);
return system.getResultFail();
}
}
async setMerchantName(list) {
if (!list || list.length == 0) {
return;
}
var merchantIds = [];
for (var item of list) {
merchantIds.push(item.merchant_id || 0);
}
var merchantMap = await this.merchantDao.findMapByIds(merchantIds, " id, name ");
for (var item of list) {
item.merchant = merchantMap[item.merchant_id] || {};
}
}
}
module.exports = MerchantaccountService;
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