var system = require("../../../system")
const CtlBase = require("../../ctlms.base");

class ChannelCtl extends CtlBase {
  constructor() {
    super();
    this.orderSve = system.getObject("service.saas.orderSve");
  }

  // async microAdd(params, pobj2, req) {
  //   try {
  //     return await this.orderSve.microAdd(params);
  //   } catch (error) {
  //     return system.getResult(null, `系统错误 错误信息 ${error}`);
  //   }
  // }

  async platformInfo(params, pobj2, req) {
    try {
      return await this.orderSve.platformInfo(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  async info(params, pobj2, req) {
    try {
      return await this.orderSve.info(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  async page(params, pobj2, req) {
    try {
      return await this.orderSve.page(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  async audit(params, pobj2, req) {
    if (params.audit_status != "20" && params.audit_status != "30") {
      return system.getResult(null, "审核状态错误");
    }
    try {
      return await this.orderSve.audit(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  async deliver(params, pobj2, req) {
    try {
      return await this.orderSve.deliver(params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }



  /**
   * fn：查询产品
   * @param pobj
   * @param pobj2
   * @param req
   * @returns {Promise<{msg: *, data: *, status: *}|{msg: *, data, bizmsg: *|string, status: number}>}
   */
  async orderChooseProducts(pobj, pobj2, req) {
    //TODO: 绑定渠道商品信息
    try {
      // return system.getResult([{"id":"10020300","name":"刻章办理"},{"id":"10020400","name":"银行开户"},{"id":"10020500","name":"税务报道"},{"id":"10020600","name":"代理记账"}]);
      return system.getResult([{"id":"10020300","name":"刻章办理"},{"id":"10020400","name":"银行开户"},{"id":"10020500","name":"税务报道"}]);
    } catch (e) {
      console.log(e);
      return system.getResultFail(500, "接口错误");
    }
  }
}

module.exports = ChannelCtl;