var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class ChannelCtl extends CtlBase {
  constructor() {
    super();
    this.channelSve = system.getObject("service.saas.channelSve");
  }

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

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

  /**
   * fn:获取渠道交付信息
   * @param params
   * @param pobj2
   * @param req
   * @returns {Promise<{msg: string, data: (*|null), bizmsg: string, status: number}|*>}
   */
  async delvierInfo(params, pobj2, req) {
    try {
      if(!params.channel_id){
        system.getResult(null, `登录失效，请重新登录`);
      }
      let user = req.loginUser;
      let rs = {
        contact_man:user.contact_man,
        contact_mobile : user.contact_mobile,
        contact_email : user.contact_email,
        contact_addr : user.contact_addr,
      };
      return system.getResult(rs);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

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


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


}
module.exports = ChannelCtl;