import request from '@/utils/request'
import Qs from 'qs'

export function listShop(query) {
  return request({
    url: '/shop/list',
    method: 'get',
    params: query
  })
}

export function createShop(data) {
  return request({
    url: '/shop/create',
    method: 'post',
    data
  })
}

export function readShop(data) {
  return request({
    url: '/shop/read',
    method: 'get',
    data
  })
}

export function updateShop(data) {
  return request({
    url: '/shop/update',
    method: 'post',
    data
  })
}

export function deleteShop(data) {
  return request({
    url: '/shop/delete',
    method: 'post',
    data
  })
}

export function getStoreBySourceNo(data) {
  return request({
    url: '/shop/getStoreBySourceNo',
    method: 'get',
    params: data
  })
}

export function syncShop(data) {
  return request({
    url: '/dyshop/syncShop',
    method: 'get',
    params: data,
    paramsSerializer: function (pparam) {
      return pparam.shopIds.map(_ => `shopIds=${_}`).join('&')
    }
  })
}


export function selectAllPosition(data) {
  return request({
    url: '/shop/selectAllPosition',
    method: 'get',
    params: data
  })
}


export function shopGoods(data) {
  return request({
    url: '/dyshop/shopGoods',
    method: 'get',
    params: data
  })
}

export function goodsApply(data) {
  return request({
    url: '/dyshop/goodsApply',
    method: 'get',
    params: data,
    paramsSerializer: function (params) {
      return Qs.stringify(params, { arrayFormat: 'repeat' })
    }
  })
}



export function selectAll() {
  return request({
    url: '/shop/selectAll',
    method: 'get'
  })
}

export function syncMeiTuanShop() {
  return request({
    url: '/shop/syncMeiTuanShop',
    method: 'get'
  })
}

export function selectByChannel(data) {
  return request({
    url: '/shop/selectByChannel',
    method: 'get',
    params: data
  })
}