import request from '@/utils/request'

// 创建扫码记录
export function createScanRecord(data) {
  return request({
    url: '/identity/scan-record/create',
    method: 'post',
    data: data
  })
}

export function createScanRecordBatch(data) {
  return request({
    url: '/identity/scan-record/createBatch',
    method: 'post',
    data: data
  })
}

// 更新扫码记录
export function updateScanRecord(data) {
  return request({
    url: '/identity/scan-record/update',
    method: 'put',
    data: data
  })
}

// 删除扫码记录
export function deleteScanRecord(id) {
  return request({
    url: '/identity/scan-record/delete?id=' + id,
    method: 'delete'
  })
}

// 获得扫码记录
export function getScanRecord(id) {
  return request({
    url: '/identity/scan-record/get?id=' + id,
    method: 'get'
  })
}

// 获得扫码记录分页
export function getScanRecordPage(query) {
  return request({
    url: '/identity/scan-record/page',
    method: 'get',
    params: query
  })
}

// 导出扫码记录 Excel
export function exportScanRecordExcel(query) {
  return request({
    url: '/identity/scan-record/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 获得扫码记录列表
export function getScanRecordTimeList(query) {
  return request({
    url: '/identity/scan-record/timeList',
    method: 'get',
    params: query
  })
}

// 获得扫码次数
export function getScanCountToday(query) {
  return request({
    url: '/identity/scan-record/count',
    method: 'get',
    params: query
  })
}

// 根据采收批次ID 获取首次的扫码时间与首次扫码地点和扫码次数
export function getFirstScanInfoByBatchId(params) {
  return request({
    url: '/identity/scan-record/getFirstScanInfoByBatchId',
    method: 'get',
    params
  })
}
