import {http2} from "@/utils/request.js";
/**---------------------------------- */
/**商品组管理 */

/**获取商品分组列表 */
export const getProductGroupList = (params) => {
  return http2.get('/api/v1/admin/good/group/list', {params: params})
}
/**创建商品分组 */
export const createProductGroup = (data) => {
  return http2.post('/api/v1/admin/good/group/create', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**更新商品分组 */
export const updateProductGroup = (data) => {
  return http2.post('/api/v1/admin/good/group/update', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**隐藏商品组 */
export const hideProductGroup = (data) => {
  return http2.post('/api/v1/admin/good/group/disable', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**启动商品组 */
export const startProductGroup = (data) => {
  return http2.post('/api/v1/admin/good/group/enable', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**删除商品分组 */
export const deleteProductGroup = (data) => {
  return http2.delete('/api/v1/admin/good/group/delete',{
    data: data,
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}



/**---------------------------------- */
/**商品管理 */

/**获取商品列表 */
export const getProductList = (params) => {
  return http2.get('/api/v1/admin/good/goods/list', {params: params})
}
/**获取商品详情（含商品参数列表） */
export const getProductDetail = (params) => {
  return http2.get('/api/v1/admin/good/goods/detail', {params: params})
}
/**获取商品标签列表 */
export const getProductTagList = () => {
  return http2.get('/api/v1/admin/good/goods/tag_list')
}
/**创建商品 */
export const createProduct = (data) => {
  return http2.post('/api/v1/admin/good/goods/create', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**更新商品 */
export const updateProduct = (data) => {
  return http2.post('/api/v1/admin/good/goods/update', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**删除商品 */
export const deleteProduct = (data) => {
  return http2.delete('/api/v1/admin/good/goods/delete',{
    data:data,
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}



/**---------------------------------- */
/**商品参数管理 */

/**获取商品参数列表 */
export const getProductParameterList = (params) => {
  return http2.get('/api/v1/admin/good/spec/list', {params: params})
}
/**创建商品参数 */
export const createProductParameter = (data) => {
  const {good_id, ...payload} = data
  return http2.post('/api/v1/admin/good/spec/create', payload,{
    params: {good_id},
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**获取商品参数详情 */
export const getProductParameterDetail = (params) => {
  return http2.get('/api/v1/admin/good/spec/detail', {params: params})
}
/**更新商品参数 */
export const updateProductParameter = (data) => {
  const {good_id, ...payload} = data
  return http2.post('/api/v1/admin/good/spec/update', payload, {
    params: {good_id},
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**删除商品参数 */
export const deleteProductParameter = (data) => {
  return http2.delete('/api/v1/admin/good/spec/delete', {
    params: data
  })
}
/**增加商品参数值 */
export const addProductParameterValue = (data) => {
  const {good_id, ...payload} = data
  return http2.post('/api/v1/admin/good/spec/add_value', payload,{
    params: {good_id},
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**删除商品参数值 */
export const deleteProductParameterValue = (data) => {
  return http2.delete('/api/v1/admin/good/spec/delete_value', {
    params: data
  })
}
/**更新商品参数值 */
export const updateProductParameterValue = (data) => {
  const {good_id, ...payload} = data
  return http2.post('/api/v1/admin/good/spec/update_value', payload,{
    params: {good_id},
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}


/**---------------------------------- */
/**商品套餐管理 */

/**获取商品套餐列表 */
export const getProductPlanList = (params) => {
  return http2.get('/api/v1/admin/good/plan/list', {params: params})
}
/**获取商品套餐详情 */
export const getProductPlanDetail = (params) => {
  return http2.get('/api/v1/admin/good/plan/detail', {params: params})
}
/**创建商品套餐 */
export const createProductPlan = (data) => {
  return http2.post('/api/v1/admin/good/plan/create', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**更新商品套餐 */
export const updateProductPlan = (data) => {
  return http2.post('/api/v1/admin/good/plan/update', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**删除商品套餐 */
export const deleteProductPlan = (params) => {
  return http2.delete('/api/v1/admin/good/plan/delete', {params: params})
}
/**禁用商品套餐 */
export const disableProductPlan = (data) => {
  return http2.post('/api/v1/admin/good/plan/disable', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**启用商品套餐 */
export const enableProductPlan = (data) => {
  return http2.post('/api/v1/admin/good/plan/enable', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}

/**禁用套餐固定价格 */
export const disablePlanFixedPrice = (data) => {
  return http2.post('/api/v1/admin/good/plan/disable_fixed_price', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}

/**启用套餐固定价格 */
export const enablePlanFixedPrice = (data) => {
  return http2.post('/api/v1/admin/good/plan/enable_fixed_price', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}


/**---------------------------------- */
/**商品分组标签管理 */

/**获取商品分组标签列表 */
export const getProductGroupTagList = (params) => {
  return http2.get('/api/v1/admin/good/group_tag/list', {params: params})
}
/**获取商品分组标签详情 */
export const getProductGroupTagDetail = (params) => {
  return http2.get('/api/v1/admin/good/group_tag/detail', {params: params})
}
/**创建商品分组标签 */
export const createProductGroupTag = (data) => {
  return http2.post('/api/v1/admin/good/group_tag/create', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**更新商品分组标签 */
export const updateProductGroupTag = (data) => {
  return http2.post('/api/v1/admin/good/group_tag/update', data,{
    headers:{
      'Content-Type':'multipart/form-data'
    }
  })
}
/**删除商品分组标签 */
export const deleteProductGroupTag = (params) => {
  return http2.delete('/api/v1/admin/good/group_tag/delete', {params: params})
}


/**---------------------------------- */
/**已购商品管理 */

/**获取用户已购商品列表 */
export const getUserGoodsList = (params) => {
  return http2.get('/api/v1/admin/good/user_goods/list', {params: params})
}
