const system = require("../../../system");
const ServiceBase = require("../../svems.base")

class AuthService extends ServiceBase {
  constructor() {
    super();
  }
  async nameTwo(params) {
    try {
      // 通过应用id查询商户订单信息，确定产品认证接口
      return this.doAuth(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }
  async bankThree(params) {
    try {
      return this.doAuth(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }
  async bankFour(params) {
    try {
      return this.doAuth(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  async doAuth(params) {
    // 1. 扣费
    // 2. 调用认证引擎
    // 3. 异步调用订单逻辑
    // 4. 返回认证结果
  }

  /**
   * @param params
   * {
   *     "currentPage": 1,
   *     "pageSize": 10,
   *     "account_id": "1",
   *     "trade_type": "1",
   *     "trade_no": "123313",
   *     "tradeTimeBegin": "2020-06-26 04:21:31",
   *     "tradeTimeEnd": "2020-06-26 05:11:31"
   * }
   * @returns
   */
  async accountTradePage(params) {
    try {
      return await this.callms("engine_fee", "accountTrade", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   * account_id
   * @param params
   * {
   *     "account_id": "1",
   *     "trade_type": "1",
   *     "trade_nos": ['1','2'],
   * }
   * @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}|{msg: string, data, bizmsg: *|string, status: number}|any|undefined>}
   */
  async tradeMapByIds(params) {
    try {
      return await this.callms("engine_fee", "tradeMapByIds", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

}

module.exports = AuthService;