import request from '@/router/axios';
import { getToken } from '@/util/auth'
import Qs from 'qs'

export const getWaiting =
  (current, size, params) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/list',
      method: 'get',
      params: {
        ...params,
        current,
        size,
      }
    })
  }

export const create =
  (ids, taxPayrollTitle) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/saveBatch',
      method: 'post',
      params: { ids, taxPayrollTitle }
    })
  }

export const rename =
  (id, taxPayrollTitle) => {
    return request({
      url: '/api/jobslink-api/payment/taxpayroll/updateName',
      method: 'post',
      data: { id, taxPayrollTitle }
    })
  }

export const detail =
  (id) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/detail',
      method: 'get',
      params: { id }
    })
  }

export const exportUserGather =
  (taxPayrollNo) => {
    return `/api/jobslink-api/payment/personalTax/exportUserGather?taxPayrollNo=${
      taxPayrollNo}&Jobslink-Auth=${getToken()}`
  }

export const exportUserSixItems =
  (taxPayrollNo) => {
    return `/api/jobslink-api/payment/jobslink-api/payment/personalTax/exportUserSixItems?taxPayrollNo=${
      taxPayrollNo}&Jobslink-Auth=${getToken()}`
  }

export const exportUserTrailTax =
  (taxPayrollNo) => {
    return `/api/jobslink-api/payment/jobslink-api/payment/personalTax/exportUserTrailTax?taxPayrollNo=${
      taxPayrollNo}&Jobslink-Auth=${getToken()}`
  }

export const saveUserTaxList =
  (taxPayrollId, wageRealTotal) => {
    return request({
      url: '/api/jobslink-api/payment/personalTax/saveUserTaxList',
      method: 'post',
      params: { taxPayrollId, wageRealTotal },
    })
  }

export const taxPayroll =
  (current, size, params) => {
    return request({
      url: '/api/jobslink-api/payment/taxpayroll/list',
      method: 'get',
      params: {
        ...params,
        current,
        size,
      }
    })
  }

export const taxPayrollDetail =
  (current, size, payrollId, params) => {
    return request({
      url: '/api/jobslink-api/payment/taxpayroll/list',
      method: 'get',
      params: {
        ...params,
        current,
        size,
      }
    })
  }

export const saveUserTaxOne =
  (data) => {
    return request({
      url: '/api/jobslink-api/payment/personalTax/saveUserTaxOne',
      method: 'post',
      data: data
    })
  }

export const historyWageList =
    (current, size, params) => {
      return request({
        url: '/api/jobslink-api/payment/userOrder/hisList',
        method: 'get',
        paramsSerializer(params) {
          return Qs.stringify(params, {arrayFormat: 'indices'})
        },
        params: {
          ...params,
          current,
          size,
        }
      })
    }


export const waitList =
  (current, size, params) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/waitList',
      method: 'get',
      params: {
        ...params,
        current,
        size,
      }
    })
  }

export const historyDetail =
  (id) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/historyDetail',
      method: 'get',
      params: { id }
    })
  }

export const exportCCB =
  (ids) => {
    return `/api/jobslink-api/payment/userOrder/exportCCB?ids=${
      ids}&Jobslink-Auth=${getToken()}`
  }

export const uploadRelease =
  (isCovered) => {
    return `/api/jobslink-api/payment/userOrder/uploadRelease?isCovered=${
      isCovered}`
  }

export const importUserTax =
  (taxPayrollNo, isCovered) => {
    return `/api/jobslink-api/payment/personalTax/importUserTax?isCovered=${
      isCovered}&taxPayrollNo=${taxPayrollNo}`
  }

export const removeTax =
  (id) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/removeTax',
      method: 'post',
      params: { id }
    })
  }

export const payrollDetail =
  (id) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/user/payroll/detail',
      method: 'get',
      params: { id }
    })
  }

export const orderError =
  (ids) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/error',
      method: 'post',
      params: { ids }
    })
  }

export const onlinePay =
  (ids) => {
    return request({
      url: '/api/jobslink-api/payment/userOrder/onlinePay',
      method: 'post',
      params: { ids }
    })
  }

export const getUserDetail = (orderId) => {
  return request({
    url: '/api/jobslink-api/payment/bankorder/manage/user/detail',
    method: 'get',
    params: { orderId }
  })
}

export const downloadWigeHistory=(month,auth)=>{
  return  `/api/jobslink-api/payment/userOrder/exportHistory?month=${month}&Jobslink-Auth=${auth}`
}

//线上代发工资列表
export const getHisList = (current, size, leibie,params) => {
    return request({
      url: '/api/jobslink-api/payment/withhold/hisList',
      method: 'get',
      params: {
        leibie,
        ...params,
        current,
        size,
      }
    })
  }
  //线上代发工资列表--详情
  export const getHisListDetails = (id) => {
    return request({
      url: '/api/jobslink-api/payment/withhold/details/one',
      method: 'get',
      params: {
        id,
      }
    })
  }
  //线上代发工资暂不发放
  export const pauseOrder = (ids,remarks) => {
    return request({
      url: '/api/jobslink-api/payment/withhold/pauseOrder',
      method: 'post',
      params: { ids, remarks }
    })
  }
  //线上代发工资确定发放
  export const submitOrder = (ids,wageRealTotal) => {
    return request({
      url: '/api/jobslink-api/payment/withhold/submitOrder',
      method: 'post',
      params: { ids, wageRealTotal }
    })
  }
  //线上代发工资重新发放
  export const reSubmitOrder = (ids,wageRealTotal) => {
    return request({
      url: '/api/jobslink-api/payment/withhold/submitOrder/re',
      method: 'post',
      params: { ids, wageRealTotal }
    })
  }
  //线上工资发放成功后，下载人员工资信息
  export const downloadExportUserGather=(month)=>{
    return  `/api/jobslink-api/payment/withhold/exportUserGather?month=${month}&Jobslink-Auth=${getToken()}`
  }
  //线上发放历史里，导出查询信息
  export const exportHisList=(query)=>{
    return  `/api/jobslink-api/payment/withhold/exportHisList?${query}&Jobslink-Auth=${getToken()}`
  }
//线下代发工资列表
export const getUnderLineList = (current, size, leibie, params) => {
  return request({
    url: '/api/jobslink-api/payment/withhold/underLineList',
    method: 'get',
    params: {
      ...params,
      leibie,
      current,
      size,
    }
  })
}
//个税校准补发 -- 待校准
export const getDrawbackOrderList = (current, size, params) => {
  return request({
    url: '/api/jobslink-api/payment/drawbackOrder/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
//个税校准补发 -- 待校准 详情页
export const getDrawbackOrderDetail = (id) => {
  return request({
    url: '/api/jobslink-api/payment/drawbackOrder/detail',
    method: 'get',
    params: {
      id,
    }
  })
}

//获取个税校准关联任务
export const getDrawbackOrderAbout = (id) => {
  return request({
    url: '/api/jobslink-api/payment/drawbackOrder/aboutMission',
    method: 'get',
    params: {
      id,
    }
  })
}

//个税校准管理 单条校准
export const drawback = (data) => {
  return request({
    url: '/api/jobslink-api/payment/drawbackOrder/drawback',
    method: 'post',
    data:data
  })
}

//个税校准管理 单条校准
export const drawbackConfirm = (data) => {
  return request({
    url: '/api/jobslink-api/payment/drawbackOrder/confirm',
    method: 'post',
    data:data
  })
}
//个税校准管理 批量校准导入
export const excelImport = (file) => {
  return request({
    url: '/api/jobslink-api/payment/drawbackOrder/excelImport',
    method: 'post',
    data:file
  })
}

export const exportCCBOrder =
  (ids) => {
    return `/api/jobslink-api/payment/drawbackOrder/exportCCB?ids=${
      ids}&Jobslink-Auth=${getToken()}`
  }
  //个税校准银联代发
  export const onlinePayOrder =
  (data) => {
    return request({
      url: '/api/jobslink-api/payment/drawbackOrder/onlinePay',
      method: 'post',
      data:data
    })
  }
  //上传建行发放结果
  export const uploadReleaseOrder =
  (file) => {
    return `/api/jobslink-api/payment/drawbackOrder/uploadRelease?file=${
      file}`
  }
  //校准批量导入
  export const excelImportOrder =
  (file) => {
    return `/api/jobslink-api/payment/drawbackOrder/excelImport?file=${
      file}`
  }
  //设置工资自动发放状态
  export const setAutoSalary=(id)=>request({
    url:'/api/jobslink-api/payment/withhold/config/set',
    method:'post',
    params:{id}
  })
  //获取工资自动发放状态
  export const getAutoSalary=()=>request({
    url:'/api/jobslink-api/payment/withhold/config',
    method:'get'
  })

  //超三倍工资数据列表
  export const getThreeList=(current,size,params)=>request({
    url:'/api/jobslink-api/payment/withhold/three/list',
    method:'get',
    params:{
      ...params,
        current,
        size,
    }
  })
  //重新发放
  export const rePay=(orderIds)=>request({
    url:'/api/jobslink-api/payment/withhold/three/topay',
    method:'post',
    params:{orderIds}
  })
  //暂不发放
  export const noPay=(orderIds,remarks,ids)=>request({
    url:'/api/jobslink-api/payment/withhold/three/nopay',
    method:'post',
    params:{orderIds,remarks,ids}
  })
