import request from '@/utils/request'

// 查询批量缴费列表
export function listFee(params) {
  return new Promise((resolve, reject) => {
    request({
      url: '/fee.listFee',
      method: 'get',
      params
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 查询费用对象
export function listFeeObj(params) {
  return new Promise((resolve, reject) => {
    request({
      url: '/feeApi/listFeeObj',
      method: 'get',
      params
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 查询业主账户
export function queryCommunityOwnerAccount(params) {
  return new Promise((resolve, reject) => {
    request({
      url: '/account.queryCommunityOwnerAccount',
      method: 'get',
      params
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 查询押金信息
export function queryFeeDeposit(params) {
  return new Promise((resolve, reject) => {
    request({
      url: '/fee.queryFeeDeposit',
      method: 'get',
      params
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 退押金
export function refundFeeDeposit(data) {
  return new Promise((resolve, reject) => {
    request({
      url: '/fee.refundFeeDeposit',
      method: 'post',
      data
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 批量缴费
export function payBatchFee(data) {
  return new Promise((resolve, reject) => {
    request({
      url: '/fee.payBatchFee',
      method: 'post',
      data
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 扫码支付
export function qrCodePayment(data) {
  return new Promise((resolve, reject) => {
    request({
      url: '/payment.qrCodePayment',
      method: 'post',
      data
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 检查支付状态
export function checkPayFinish(data) {
  return new Promise((resolve, reject) => {
    request({
      url: '/payment.checkPayFinish',
      method: 'post',
      data
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}

// 查询打印页面
export function listFeePrintPage(params) {
  return new Promise((resolve, reject) => {
    request({
      url: '/feePrintPage.listFeePrintPage',
      method: 'get',
      params
    }).then(response => {
      const res = response.data
      resolve(res)
    }).catch(error => {
      reject(error)
    })
  })
}