import request from '@/config/axios'

// 客户信息 VO
export interface CustomerInfoVO {
  id: number // 编号
  customerName: string // 客户姓名
  contact: string // 联系方式
  companyName: string // 公司名称
  customerType: number // 性质等级
  provinceName: string // 省名称
  cityName: string // 市名称
  areaName: string // 区名称
  regionFullName: string // 所在地区
  locationText: string // 详细地址
  longitude: number // 经度
  latitude: number // 纬度
  locationImage: string // 定位静态图 URL
  productIds: string // 产品信息
  department: string // 客户部门
}

// 客户信息 API
export const CustomerInfoApi = {
  // 查询客户信息分页
  getCustomerInfoPage: async (params: any) => {
    return await request.get({ url: `/visit/customer-info/page`, params })
  },

  // 查询客户信息详情
  getCustomerInfo: async (id: number) => {
    return await request.get({ url: `/visit/customer-info/get?id=` + id })
  },

  // 查询客户信息详情根据客户公司名称
  getCustomerInfoByCompanyName: async (param: string) => {
    return await request.get({ url: `/visit/customer-info/getByCompanyName?companyName=` + param })
  },

  // 查询客户信息详情根据手机号
  getCustomerInfoByPhone: async (param: string) => {
    return await request.get({ url: `/visit/customer-info/getByPhone?contact=` + param })
  },
  // 查询所有客户信息详情
  getAll: async () => {
    return await request.get({ url: `/visit/customer-info/getAll`})
  },

  // 查询客户信息中拜访品种详情
  getProductSimpleList: async (id: number) => {
    return await request.get({ url: `/visit/customer-info/getProductSimpleList?id=` + id })
  },

  // 新增客户信息
  createCustomerInfo: async (data: CustomerInfoVO) => {
    return await request.post({ url: `/visit/customer-info/create`, data })
  },

  // 修改客户信息
  updateCustomerInfo: async (data: CustomerInfoVO) => {
    return await request.put({ url: `/visit/customer-info/update`, data })
  },

  // 删除客户信息
  deleteCustomerInfo: async (id: number) => {
    return await request.delete({ url: `/visit/customer-info/delete?id=` + id })
  },

  // 批量删除客户信息
  deleteCustomerInfoByIds: async (ids: String) => {
    return await request.delete({ url: `/visit/customer-info/deleteByIds?ids=` + ids })
  },

  // 导出客户信息 Excel
  exportCustomerInfo: async (params) => {
    return await request.download({ url: `/visit/customer-info/export-excel`, params })
  },


  // 下载客户信息导入模板
  importProductTemplate: async () => {
    return await request.download({ url: '/visit/customer-info/get-import-template' })
  }
}
