import request from '@/utils/request'

export function listAbnormalRecord(pripid) {
  return request({
    url: `/abnList/listAbnormalRecord?pripid=${pripid}`,
    method: 'get'
  })
}

export function queryEntLockDetails(pripid) {
  return request({
    url: `/entlock/queryEntlockOne?pripid=${pripid}`,
    method: 'get'
  })
}

export function queryTSAbnListDetails(pripid) {
  return request({
    url: `/abnList/queryAbnListOne?pripid=${pripid}`,
    method: 'get'
  })
}

export function queryEOtCaseDetails(pripid) {
  return request({
    url: `/eOtCase/queryEOtCaseOne?pripid=${pripid}`,
    method: 'get'
  })
}

export function queryCphStatistics(data) {
  return request({
    url: '/eBaseinfo/queryCphStatistics',
    method: 'post',
    data: data
  })
}

export function businessQuery(page) {
  return request({
    url: '/task/businessQuery',
    method: 'post',
    data: page
  })
}

export function tFraudEntStatistics() {
  return request({
    url: '/fraudReg/tBizFraud/statistics',
    method: 'get'
  })
}

export function entBlacklistStatistics(params) {
  return request({
    url: '/entBlacklist/statistics',
    method: 'get',
    params
  })
}

export function queryStatistics(params) {
  return request({
    url: '/abnStatistics/StatisticsForAbn',
    method: 'post',
    data: params
  })
}

export function getEntListByStatistics(data) {
  return request({
    url: '/abnStatistics/getEntListByStatistics',
    method: 'post',
    data
  })
}

/**
 * 经营异常主体信息列表导出
 * @param data
 */
export function exportEntListByStatistics(data) {
  return request({
    url: '/abnStatistics/exportEntListByStatistics',
    method: 'post',
    responseType: 'blob',
    data
  })
}

export function queryAllOrg() {
  return request({
    url: '/task/queryAllOrg',
    method: 'get'
  })
}

export function queryOldeBusness(page) {
  return request({
    url: '/task/queryOldeBusness',
    method: 'post',
    data: page
  })
}

export function queryAbnList(page) {
  return request({
    url: '/task/queryAbnList',
    method: 'post',
    data: page
  })
}

export function exportAbnListFile(data) {
  return request({
    url: '/task/exportAbnList',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

export function queryEAlterByPripid(pripid) {
  const form = new FormData()
  form.append('pripid', pripid)
  return request({
    url: '/eBaseinfo/queryEAlterByPripid',
    method: 'post',
    data: form
  })
}

/**
 * 信用修复预警待办分析
 * @param data
 * @returns {AxiosPromise}
 */
export function repairTaskQuery(data) {
  return request({
    url: '/task/repairTaskQuery',
    method: 'post',
    data
  })
}

export function queryEAlterByEntNo(pripid) {
  const form = new FormData()
  form.append('pripid', pripid)
  return request({
    url: '/eBaseinfo/queryEAlterByEntNo',
    method: 'post',
    data: form
  })
}

export function queryContactByEntNo(pripid) {
  const form = new FormData()
  form.append('pripid', pripid)
  return request({
    url: '/eBaseinfo/queryContactByEntNo',
    method: 'post',
    data: form
  })
}

export function addContactLogByEntNo(pripid) {
  const form = new FormData()
  form.append('pripid', pripid)
  return request({
    url: '/eBaseinfo/addContactLogByEntNo',
    method: 'post',
    data: form
  })
}

export function queryEAlterTempByBizseq(bizseq) {
  const form = new FormData()
  form.append('bizseq', bizseq)
  return request({
    url: '/eBaseinfo/queryEAlterTempByBizseq',
    method: 'post',
    data: form
  })
}

export function queryxyxfCqList(page) {
  return request({
    url: '/task/queryxyxfCqList',
    method: 'post',
    data: page
  })
}

export function exportxyxfCqList(data) {
  return request({
    url: '/task/exportxyxfCqList',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

export function queryqzzxEntList(data) {
  return request({
    url: '/eBaseinfo/queryForcedLogoutEntList',
    method: 'post',
    data
  })
}

export function exportqzzxList(data) {
  return request({
    url: '/eBaseinfo/exportqzzxList',
    method: 'post',
    data,
    responseType: 'blob'
  })
}

/**
 * 获取主体信用档案图谱数据
 * @param {Object} params
 * @param {string} params.pripid 主体身份代码
 * @param {number} [params.reportYear] 年报年度（可选，不传则取最近一年，影响"对外投资"分支）
 */
export function getCreditArchive(params) {
  return request({
    url: '/eBaseinfo/getCreditArchive',
    method: 'get',
    params
  })
}

/**
 * 根据人员姓名/证件号查询其担任的相关企业（信用档案图谱三级节点扩展）
 * @param {Object} params
 * @param {string} params.name 姓名（必填）
 * @param {string} [params.cerno] 证件号（可选，精确匹配）
 * @param {string} [params.excludePripid] 排除的主体pripid（可选）
 */
export function getPersonRelatedEnts(params) {
  return request({
    url: '/eBaseinfo/getPersonRelatedEnts',
    method: 'get',
    params
  })
}

/**
 * 信用修复预警统计
 * @param data
 * @returns {AxiosPromise}
 */
export function repairTaskStatistic(data) {
  return request({
    url: '/task/repairTaskStatistic',
    method: 'post',
    data
  })
}
