var system = require("../../system")
const md5 = require("MD5");
const logCtl = system.getObject("web.oplogCtl");
const moment = require("moment");
class EcompanyApi {
  constructor() {
    this.ecompanySve = system.getObject("service.ecompanySve");
    this.esettleSve = system.getObject("service.esettleSve");
    this.offlinecompanySve = system.getObject("service.offlinecompanySve")
  }

  async merchantNameSuggest(queryobj, qobj, req) {
    var name = this.trim(queryobj.name);
    if(!name) {
      return system.getResult2([])
    }
    var list = await this.ecompanySve.suggest(name);
    return system.getResult2(list);
  }

  async offlinemerchantNameSuggest(queryobj, qobj, req) {
    var name = this.trim(queryobj.name);
    if(!name) {
      return system.getResult2([])
    }
    var list = await this.offlinecompanySve.suggest(name);
    return system.getResult2(list);
  }

  async settleMerchantNameSuggest(queryobj, qobj, req) {
    var name = this.trim(queryobj.name);
    if(!name) {
      return system.getResult2([])
    }
    var list = await this.esettleSve.suggest2(name);
    return system.getResult2(list);
  }


  trim(o) {
    if (!o) {
      return "";
    }
    return o.toString().trim();
  }
}
module.exports = EcompanyApi;
