import request from '@/utils/request'

// 创建收款单
export function createReceipt(data) {
  return request({
    url: '/ecw/receipt/create',
    method: 'post',
    data: data
  })
}

// 更新收款单
export function updateReceipt(data) {
  return request({
    url: '/ecw/receipt/update',
    method: 'put',
    data: data
  })
}

// 获取收款单列表
export function getReceiptList(query) {
  return request({
    url: '/ecw/receipt/page',
    method: 'get',
    params: query
  })
}

// 获取应收款列表
export function getReceivableList(query) {
  return request({
    url: '/ecw/receivable/page',
    method: 'get',
    params: query
  })
}

// 获取应收款详情
export function getReceivableInfoByIds(query) {
  return request({
    url: '/ecw/receivable/get',
    method: 'get',
    params: query
  })
}

// 修改优惠信息
export function updateReceivableDiscountById(query) {
  return request({
    url: '/ecw/receivable/updateReceivableDiscountById',
    method: 'post',
    data: query
  })
}

// 得到应收优惠的最后操作人
export function getReceivableDiscountLogById(query) {
  return request({
    url: '/ecw/receivable/getReceivableDiscountLogById',
    method: 'get',
    params: query
  })
}

// 根据订单ID获得需要预付应收款列表
export function getFirstReceivableListByOrderId(query) {
  return request({
    url: '/ecw/receivable/getFirstReceivableListByOrderId',
    method: 'get',
    params: query
  })
}

// 核销收款单
// export function receiptVerification(id) {
//   return request({
//     url: '/ecw/receipt/verification/' + id,
//     method: 'GET'
//   })
// }

// 反核销收款单
// export function receiptVerificationCancel(id) {
//   return request({
//     url: '/ecw/receipt/verificationCancel/' + id,
//     method: 'GET'
//   })
// }

// 获取收款单详情
export function getReceiptInfoByIds(query) {
  return request({
    url: '/ecw/receipt/get',
    method: 'get',
    params: query
  })
}

// 获取收款单明细列表
export function getReceivableItemDetail(query) {
  return request({
    url: '/ecw/receipt/getReceivableItemDetail',
    method: 'get',
    params: query
  })
}

// 获取收款单明细
export function getInvoicingItem(query) {
  return request({
    url: '/ecw/receipt/getInvoicingItem',
    method: 'get',
    params: query
  })
}

// 创建收款明细
export function receiptItemCreate(data) {
  return request({
    url: '/ecw/receipt-item/create',
    method: 'post',
    data: data
  })
}

// 根据收款单ID获得收款明细列表
export function getReceivableItem(query) {
  return request({
    url: '/ecw/receipt-item/getReceivableItem',
    method: 'get',
    params: query
  })
}

// 根据收款单ID获得收款账户细列表
export function getReceiptAccountList(query) {
  return request({
    url: '/ecw/receipt/getReceiptAccountList',
    method: 'get',
    params: query
  })
}

// 删除收款明细
export function deleteReceiptItem(id) {
  return request({
    url: '/ecw/receipt-item/delete?id=' + id,
    method: 'delete'
  })
}

// 更新收款明细
export function updateReceiptItem(data) {
  return request({
    url: '/ecw/receipt-item/update',
    method: 'put',
    data: data
  })
}

// 收款明细核销
export function receiptItemVerification(id) {
  return request({
    url: '/ecw/receipt-item/verification/' + id,
    method: 'GET'
  })
}

// 反核销收款单
export function receiptItemVerificationCancel(id) {
  return request({
    url: '/ecw/receipt-item/verificationCancel/' + id,
    method: 'GET'
  })
}

// 收款明细批量核销
export function receiptItemBatchVerification(query) {
  return request({
    url: '/ecw/receipt-item/batchVerification',
    method: 'GET',
    params: query
  })
}

// 收款单全部核销
export function receiptItemAllVerification(id) {
  return request({
    url: '/ecw/receipt-item/allVerification/' + id,
    method: 'GET'
  })
}

// 根据获取应收款列表
// export function getReceivableListByIds(query) {
//   return request({
//     url: '/ecw/receivable/list',
//     method: 'get',
//     params: query
//   })
// }

// 导出收款单 Excel
export function receiptExportExcel(query) {
  return request({
    url: '/ecw/receipt/export-excel',
    method: 'get',
    responseType: 'blob',
    params: query
  })
}

// 删除收款单
export function deleteReceipt(id) {
  return request({
    url: '/ecw/receipt/delete?id=' + id,
    method: 'delete'
  })
}

// 获得收款单开票信息
export function getReceiptInvoicing(id) {
  return request({
    url: '/ecw/receipt/invoicing/info/' + id,
    method: 'get'
  })
}

// 更新收款单开票信息
export function updateReceiptInvoicing(data) {
  return request({
    url: '/ecw/receipt/invoicing/info',
    method: 'put',
    data: data
  })
}


// 更新应付款
export function updatePayable(data) {
  return request({
    url: '/ecw/payable/update',
    method: 'put',
    data: data
  })
}

// 删除应付款
export function deletePayable(id) {
  return request({
    url: '/ecw/payable/delete?id=' + id,
    method: 'delete'
  })
}



// 获取应付款列表
export function getPayableList(query) {
  return request({
    url: '/ecw/payable/page',
    method: 'get',
    params: query
  })
}

// 获取应付款详情
export function getPayableInfoByIds(query) {
  return request({
    url: '/ecw/payable/get',
    method: 'get',
    params: query
  })
}

// 创建付款单
export function createPayment(data) {
  return request({
    url: '/ecw/payment/create',
    method: 'post',
    data: data
  })
}

// 获取付款单列表
export function getPaymentList(query) {
  return request({
    url: '/ecw/payment/page',
    method: 'get',
    params: query
  })
}

// 获取付款单详情
export function getPaymentInfoByIds(query) {
  return request({
    url: '/ecw/payment/get',
    method: 'get',
    params: query
  })
}

// 获得付款单付款明细
export function getPaymentItem(query) {
  return request({
    url: '/ecw/payment/getPaymentItem',
    method: 'get',
    params: query
  })
}

// 更新付款单
export function updatePayment(data) {
  return request({
    url: '/ecw/payment/update',
    method: 'put',
    data: data
  })
}

// 删除付款单
export function deletePayment(id) {
  return request({
    url: '/ecw/payment/delete?id=' + id,
    method: 'delete'
  })
}

// 审核付款单
export function paymentVerify(query) {
  return request({
    url: '/ecw/payment/verify',
    method: 'post',
    data: query
  })
}

// 核销付款单
export function paymentVerification(id) {
  return request({
    url: '/ecw/payment/verification/' + id,
    method: 'GET'
  })
}

// 反核销付款单
export function paymentVerificationCancel(id) {
  return request({
    url: '/ecw/payment/verificationCancel/' + id,
    method: 'GET'
  })
}

// 反审核付款单
export function paymentVerifyCancel(id) {
  return request({
    url: '/ecw/payment/verifyCancel/' + id,
    method: 'GET'
  })
}
