import request from '@/utils/request'

// 查询缴费单
export function getBillInvoiceList(data) {
  return request({
    url: '/bill/invoice/list',
    method: 'post',
    data: {
      billId: data.billId, // 缴费项目id
      phase: data.phase,
      building: data.building,
      unit: data.unit,
      roomNo: data.roomNo,
      ownerName: data.ownerName,
      billStatus: data.billStatus,
      payName: data.payName,
      pageSize: data.pageSize,
      pageNum: data.pageNum
    }
  })
}

// 修改缴费项 收费项名称,缴费项说明,截止时间
export function updateBillNameAndBillExplainAndEndDate(data) {
  return request({
    url: '/bill/invoice/updateBill',
    method: 'put',
    data: {
      id: data.id, // 收费项ID
      billName: data.billName, // 收费项名称
      billExplain: data.billExplain, // 缴费项说明
      endDate: data.endDate // 截止时间
    }
  })
}

// 根据ID 查询缴费项信息
export function getBillByIdInfo(id) {
  return request({
    url: '/bill/' + id,
    method: 'get'
  })
}

//  根据 id 批量删除 缴费单
export function deleteBillInvoiceById(data) {
  return request({
    url: '/bill/invoice/delete',
    method: 'post',
    data
  })
}

// 设置线下缴费
export function billInvoiceOfflinePayment(data) {
  return request({
    url: '/bill/invoice/offlinePayment',
    method: 'post',
    data
  })
}

// 由前台批量添加收费单, 默认定为 作废
export function addTempBillInvoice(data) {
  return request({
    url: '/bill/invoice/addTempBillInvoice',
    method: 'post',
    data: {
      billId: data.billId, //  收费项id
      phase: data.phaseId, // 期/区
      building: data.buildingId, // 栋
      unit: data.unitId, // 单元
      level: data.levelId, // 楼层
      roomNo: data.roomNoId, // 户号
      worthOf: data.worthOf, // 催缴日期
      billInvoiceExplain: data.billInvoiceExplain, // 收费单说明
      payPrice: data.payPrice // 收费金额
    }
  })
}

// 由前台批量添加收费单, 进行统一的提交, 修改为有效
export function updateBillInvoiceStatus(data) {
  return request({
    url: '/bill/invoice/updateBillInvoiceStatus',
    method: 'post',
    data
  })
}

// 查询前台批量添加的收费单, 状态是作废
export function getTempBillInvoice(billId) {
  return request({
    url: '/bill/invoice/getTempBillInvoice/' + billId,
    method: 'get'
  })
}

// 根据id删除收费单, 只能删除作废的
export function deleteTempBillInvoice(billId) {
  return request({
    url: '/bill/invoice/deleteTempBillInvoice/' + billId,
    method: 'delete'
  })
}

// 根据缴费单id, 修改金额
export function updateBillInvoiceIdPayPrice(data) {
  return request({
    url: '/bill/invoice/updateBillInvoiceIdPayPrice/' + data.id,
    method: 'post',
    data: {
      payPrice: data.payPrice
    }
  })
}

// 下载excel
export function exportExcel(billId) {
  return request({
    url: '/bill/invoice/exportExcel/' + billId,
    method: 'get',
    responseType: 'blob'
  })
}

// 根据缴费项id, 查询草稿
export function billInvoiceGetInvoiceInvalid(data) {
  return request({
    url: '/bill/invoice/getInvoiceInvalid',
    method: 'post',
    data: {
      billId: data.billId,
      pageNum: data.pageNum,
      pageSize: data.pageSize
    }
  })
}

// 根据收费单id, 修改收费说明
export function updateBillInvoiceIdBillInvoiceExplain(data) {
  return request({
    url: '/bill/invoice/updateBillInvoiceIdBillInvoiceExplain/' + data.id,
    method: 'post',
    data: {
      billInvoiceExplain: data.billInvoiceExplain
    }
  })
}
