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 getReceivableByOrderId(query) {
  return request({
    url: '/ecw/receivable/getReceivableByOrderId',
    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/getReceivableItemDetail',
    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  getCommissionPayable(params){
  return request({
    url:'/ecw/commission-payable/get',
    method:"get",
    params
  })
}

// 创建付款单
export function createPayment(data) {
  return request({
    url: '/ecw/payment/create',
    method: 'post',
    data: data
  })
}
// 创建佣金订单
export function  commissionPayment(data){
  return request({
    url:'/ecw/commission-payment/create',
    method:'post',
    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 getCommissionPayment(params){
  return request({
    url:'/ecw/commission-payment/get',
    method:'get',
    params
  })
}
// 获得佣金付款单列表
export function getCommissionPayableList(params){
  return request({
    url:'/ecw/commission-payable/list',
    method:'get',
    params
  })
}

// 获得付款单付款明细
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 commissionPaymentUpdate(data){
  return request({
    url:'/ecw/commission-payment/update',
    method:'put',
    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(data) {
  return request({
    url: '/ecw/payment/verification',
    method: 'post',
    data
  })
}

// 反核销付款单
export function paymentVerificationCancel(data) {
  return request({
    url: '/ecw/payment/verificationCancel',
    method: 'post',
    data
  })
}
// 取消付款单反核销
export function paymentCancelFinancePaymentWriteOffNo(data){
  return request({
    url:'ecw/payment/cancelFinancePaymentWriteOffNo',
    method:'post',
    data
  })
}

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

//获取佣金应付款
export function payablePage(params){
  return request({
    url:'/ecw/commission-payable/page',
    method:'get',
    params
  })
}

//获取佣金付款单
export function commissionPaymentPage(params){
  return request({
    url:'/ecw/commission-payment/page',
    method:'get',
    params
  })
}

// 根据流程主键获取付款单流程审核信息
export function getPaymentApprove(id) {
  return request({
    url: '/ecw/payment/getPaymentApprove?id='+id,
    method: 'GET'
  })
}

// 根据流程主键获取收款单流程审核信息
export function getReceiptApprove(id) {
  return request({
    url: '/ecw/receipt/getReceiptApprove?id='+id,
    method: 'GET'
  })
}

// 收款单核销
export function financeReceiptWriteOff(query) {
  return request({
    url: '/ecw/receipt/financeReceiptWriteOff',
    method: 'POST',
     data: query
  })
}

// 收款单银行明细核销
export function financeReceiptItemWriteOff(query) {
  return request({
    url: '/ecw/receipt-item/financeReceiptItemWriteOff',
    method: 'POST',
     data: query
  })
}


// 收款单银行明细核销反审核
export function financeReceiptItemWriteOffNo(query) {
  return request({
    url: '/ecw/receipt-item/financeReceiptItemWriteOffNo',
    method: 'POST',
     data: query
  })
}

// 收款单反审核
export function financeApproveNo(query) {
  return request({
    url: '/ecw/receipt/financeApproveNo',
    method: 'POST',
     data: query
  })
}

// 收款单反核销
export function financeReceiptWriteOffNo(query) {
  return request({
    url: '/ecw/receipt/financeReceiptWriteOffNo',
    method: 'POST',
     data: query
  })
}

// 收款单取消审核
export function cancelFinanceReceiptApproval(query) {
  return request({
    url: '/ecw/receipt/cancelFinanceReceiptApproval',
    method: 'POST',
     data: query
  })
}

// 取消收款单反审核
export function cancelFinanceReceiptApprovalNo(query) {
  return request({
    url: '/ecw/receipt/cancelFinanceReceiptApprovalNo',
    method: 'POST',
     data: query
  })
}
// 取消收款单全部核销审核
export function cancelFinanceReceiptWriteOff(query) {
  return request({
    url: '/ecw/receipt/cancelFinanceReceiptWriteOff',
    method: 'POST',
     data: query
  })
}
// 取消收款单反核销
export function cancelFinanceReceiptWriteOffNo(query) {
  return request({
    url: '/ecw/receipt/cancelFinanceReceiptWriteOffNo',
    method: 'POST',
     data: query
  })
}

// 取消收款明细核销
export function cancelFinanceReceiptItemWriteOff(query) {
  return request({
    url: '/ecw/receipt-item/cancelFinanceReceiptItemWriteOff',
    method: 'POST',
     data: query
  })
}

// 取消收款明细反核销
export function cancelFinanceReceiptItemWriteOffNo(query) {
  return request({
    url: '/ecw/receipt-item/cancelFinanceReceiptItemWriteOffNo',
    method: 'POST',
     data: query
  })
}
// 取消审核
export function cancelFinancePaymentApproval(data){
  return request({
    url:'/ecw/payment/cancelFinancePaymentApproval',
    method:'post',
    data
  })
}
// 取消付款单反审核
export function cancelFinancePaymentApprovalNo(data){
  return request({
    url:'/ecw/payment/cancelFinancePaymentApprovalNo',
    method:'post',
    data
  })
}
// 取消付款单核销
export function cancelFinancePaymentWriteOff(data){
  return request({
    url:'/ecw/payment/cancelFinancePaymentWriteOff',
      method:'post',
    data
  })
}
// 取消付款单反核销
export function cancelFinancePaymentWriteOffNo(data){
 return request({
   url:'/ecw/payment/cancelFinancePaymentWriteOffNo',
   method:'post',
   data
 })
}

//删除佣金付款单
export function commissionPaymentDelete(params){
  return request({
    url:'/ecw/commission-payment/delete',
    method:'delete',
    params
  })
}
//反审核佣金付款单
export function commissionPaymentVerifyCancel(data){
  return request({
    url:'/ecw/commission-payment/verifyCancel',
    method:'post',
    data
  })
}

// 佣金付款单核销
export function commissionPaymentVerification(data){
  return request({
    url:'/ecw/commission-payment/verification',
    method:'post',
    data
  })
}

//付款单反核销申请
 export function commissionPaymentVerificationCancel(data){
  return request({
    url:'/ecw/commission-payment/verificationCancel',
    method:'post',
    data
  })
}
// 取消付款单反审核
export function commissionPaymentCancelFinancePaymentApprovalNo(data){
  return request({
    url:'/ecw/commission-payment/cancelFinancePaymentApprovalNo',
    method:'post',
    data
  })
}
// 取消付款单核销
export function commissionPaymentCancelFinancePaymentWriteOff(data){
  return request({
    url:'/ecw/commission-payment/cancelFinancePaymentWriteOff',
    method:'post',
    data
  })
}

// 取消付款单反核销
export function commissionPaymentCancelFinancePaymentWriteOffNo(data){
  return request({
    url:'/ecw/commission-payment/cancelFinancePaymentWriteOffNo',
    method:'post',
    data,
  })
}

//取消付款单审核
export function commissionPaymentCancelFinancePaymentApproval(data){
  return request({
    url:'/ecw/commission-payment/cancelFinancePaymentApproval',
    method:'post',
    data
  })
}

//根据流程主键获取付款单流程审核信息
export  function commissionPaymentGetPaymentApprove(params){
  return request({
    url:'/ecw/commission-payment/getPaymentApprove',
    method:'get',
    params
  })
}
