import request from '@/utils/request'
import { getTenantId } from '../../utils/auth'

// 创建经销商
export function createDealerInfo(data) {
  return request({
    url: '/basic/dealer-info/create',
    method: 'post',
    data: data
  })
}

// 创建经销商(包含经销商销售区域/商品)
export function createDealerAndAreaGoodsInfo(data) {
  return request({
    url:'/basic/dealer-info/createDealerGoods',
    method: 'post',
    data: data
  })
}

// 更新经销商
export function updateDealerInfo(data) {
  return request({
    url: '/basic/dealer-info/update',
    method: 'put',
    data: data
  })
}

export function updateDealerAndAreaGoodsInfo(data) {
  return request({
    url:'/basic/dealer-info/updateDealerGoods',
    method: 'put',
    data: data
  })
}

// 删除经销商
export function deleteDealerInfo(id) {
  return request({
    url: '/basic/dealer-info/delete?id=' + id,
    method: 'delete'
  })
}

// 删除经销商
export function deleteDealerAreaGoods(id) {
  return request({
    url: '/basic/dealer-info/deleteDealerAreaGoods?id=' + id,
    method: 'delete'
  })
}

// 获得经销商
export function getDealerInfo(id) {
  return request({
    url: '/basic/dealer-info/get?id=' + id,
    method: 'get'
  })
}

// 获得经销商分页
export function getDealerInfoPage(query) {
  return request({
    url: '/basic/dealer-info/page',
    method: 'get',
    params: query
  })
}

// 获得所有经销商昵称
export function getPullInfoList(query) {
  return request({
    url: '/basic/dealer-info/pull',
    method: 'get',
    params: query
  })
}

// 根据商品获得经销商列表
export function getDealerInfoByGoodsId(params) {
  return request({
    url: '/basic/dealer-info/getDealerInfoByGoodsId',
    method: 'get',
    params
  })
}

