/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许，不可做商业用途！
*
* 版权所有，侵权必究！
*/
import request from '@/utils/request'
import excelRequest from '@/utils/excelRequest'

export function page (pageParam) {
  return request({
    url: '/mall4cloud_search/s/search/page',
    method: 'get',
    params: pageParam
  })
}

export function get (spuId) {
  return request({
    url: '/mall4cloud_product/s/spu',
    method: 'get',
    params: {
      spuId
    }
  })
}

export function save (data) {
  return request({
    url: '/mall4cloud_product/s/spu',
    method: 'post',
    data
  })
}

export function update (data) {
  return request({
    url: '/mall4cloud_product/s/spu',
    method: 'put',
    data
  })
}

export function deleteById (spuIds) {
  return request({
    url: '/mall4cloud_product/s/spu/batch?spuIds=' + spuIds,
    method: 'delete'
    // params: {
    //   spuId
    // }
  })
}

// 获取可以参与秒杀活动的商品分页列表
export function pageCanSeckillProd (pageParam) {
  return request({
    url: '/mall4cloud_product/s/spu/page_can_seckill_prod',
    method: 'get',
    params: pageParam
  })
}

// 商品上下架
export function updateProdStatus (data) {
  return request({
    url: '/mall4cloud_product/s/spu/prod_status',
    method: 'put',
    data
  })
}

// 修改spu（名称、价格、库存、序号）信息
export function updatePartProdStatus (data) {
  return request({
    url: '/mall4cloud_product/s/spu/update_spu_data',
    method: 'put',
    data
  })
}

// 获取最新下线活动详情
export function getOfflineHandleEvent (spuId) {
  return request({
    url: `/mall4cloud_product/s/spu/get_offline_handle_event/${spuId}`,
    method: 'GET'
  })
}

// 申请上线
export function auditApply (data) {
  return request({
    url: '/mall4cloud_product/s/spu/audit_apply',
    method: 'POST',
    data
  })
}

// 下载商品excel
export function soldExcel (pageParam) {
  return excelRequest({
    url: '/mall4cloud_product/s/spu/sold_excel',
    method: 'GET',
    params: pageParam
  })
}

// 下载商品excel模板
export function downModel () {
  return excelRequest({
    url: '/mall4cloud_product/s/spu/down_model',
    method: 'GET'
  })
}
