import request from '@/utils/request'
import { download } from '@/utils/request'

// 查询划款管理列表
export function listPayment(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/list',
    method: 'get',
    params: query
  })
}

// 查询划款管理列表
export function listContract(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/listContract',
    method: 'get',
    params: query
  })
}

export function exportPayment(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  download(
    "business/payment/export",
    {
      ...query,
    },
    `支出管理导出_${new Date().getTime()}.xlsx`
  )
}


export function listContractDetail(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/listContractDetail',
    method: 'get',
    params: query
  })
}

export function getPaymentByContract(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/list',
    method: 'get',
    params: query
  })
}
export function listCompany(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/listCompany',
    method: 'get',
    params: query
  })
}

export function listTypes() {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/listTypes',
    method: 'get'
  })
}

export function getCreditTermByCompId(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/getCreditTermByCompId',
    method: 'get',
    params: query
  })
}

// 查询划款管理详细
export function getPayment(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/' + id,
    method: 'get'
  })
}

// 新增划款管理
export function addPayment(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment',
    method: 'post',
    data: data
  })
}

// 修改划款管理
export function updatePayment(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment',
    method: 'put',
    data: data
  })
}

// 删除划款管理
export function delPayment(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/' + id,
    method: 'delete'
  })
}

export function exportDeposition(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  download(
    "business/payment/export",
    {
      ...query,
    },
    `划款导出_${new Date().getTime()}.xlsx`
  )
}

// 修改划款管理
export function savePayment(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/save',
    method: 'post',
    data: data
  })
}
export function verifyPayment(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/verified',
    method: 'post',
    data: data
  })
}

export function setPaymentZero(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/payment/setPaymentZero/'+ id,
    method: 'get',
  })
}

