const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class SaasmerchanttitleService extends ServiceBase {
  constructor() {
    super("merchant", ServiceBase.getDaoName(SaasmerchanttitleService));
    this.saasMerchantAddrDao = system.getObject("db.merchant.saasmerchantaddrDao");


  }

  /**
   * 发票信息管理列表
   * @param {*} params 
   */
  async invoiceInfoPage(params){
    try {
      var currentPage = Number(params.currentPage || 1);
      var pageSize = Number(params.pageSize || 10);
      let where={};
      if(params.merchant_name){
        where = {
          merchant_name:this.trim(params.merchant_name)
        };
      }
      var orderby = [
        ["id", 'desc']
      ];
      var page = await this.getPageList(currentPage, pageSize, where, orderby);
      if (page && page.rows) {
        for (var row of page.rows) {
          this.handleDate(row, ["created_at"], null, -8);
        }
      }
      return system.getResultSuccess(page);
    } catch (error) {
      console.log(error);
      return system.getResult(null,`系统错误`);
    }
  }
  
  /**
   * 发票信息管理修改
   * @param {*} params 
   */
  async updateinvoiceInfo(params){
    if(!params.id){
      return system.getResult(null,`参数错误 ID不能为空`);
    }
    let _saasInvoice = this.dao.getById(this.trim(params.id));
    if(!_saasInvoice){
      return system.getResult(null, `信息不存在，请核对信息ID`);
    }

    // merchant_name: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '商户名称' },
    // merchant_credit_code: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '商户纳税人识别号' },
    // merchant_tax_type: { type: DataTypes.STRING(4), allowNull: false, COMMENT: '纳税人类型 00一般纳税人 10小规模纳税人' },
    // merchant_addr: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '商户地址' },
    // merchant_mobile: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '商户电话' },
    // merchant_bank: { type: DataTypes.STRING(4), allowNull: true, defaultValue: "", COMMENT: '商户开户行' },
    // merchant_account: { type: DataTypes.STRING(32), allowNull: false, COMMENT: '商户银行账号' },
    let _invoiceInfoPorperty={};
    if(params.merchant_name){
      _invoiceInfoPorperty.merchant_name = this.trim(params._invoiceInfoPorperty);
    }
    if(params.merchant_credit_code){
      _invoiceInfoPorperty.merchant_credit_code = this.trim(params.merchant_credit_code);
    }
    if(params.merchant_tax_type){
      _invoiceInfoPorperty.merchant_tax_type = this.trim(params.merchant_tax_type);
    }
    if(params.merchant_addr){
      _invoiceInfoPorperty.merchant_addr = this.trim(params.merchant_addr);
    }
    if(params.merchant_mobile){
      _invoiceInfoPorperty.merchant_mobile = this.trim(params.merchant_mobile);
    }
    if(params.merchant_bank){
      _invoiceInfoPorperty.merchant_bank = this.trim(params.merchant_bank);
    }
    if(params.merchant_account){
      _invoiceInfoPorperty.merchant_account = this.trim(params.merchant_account);
    }
    



  }
  





}
module.exports = SaasmerchanttitleService;