import request from '@/utils/request';

/**
 * 获取商家列表信息
 * @returns
 */
export function getSellerList(params) {
  return request({
    url: '/maintain/merchantSort',
    data: params,
    method: 'GET',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

// 获取商品详情信息
export function getSellsDetail(id, data) {
  return request({
    url: `/maintain/merchant/${id}`,
    method: 'GET',
    data: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * 商品详情
 * @returns
 */
export function getGoodsDetailApi(id,param) {
  return request({
    url: `/maintain/goods/${id}`,
    method: 'GET',
    param,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * 分类接口 - 获取分类列表
 * @returns
 */
export function maintainCategories(data) {
  return request({
    url: `/maintain/categories`,
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
    },
    data,
  });
}

/**
 * 预约接口 - 新增预约
 * @param {*} data
 * @returns
 */
export function addReservation(merchantId, data) {
  return request({
    url: `/maintain/merchant/${merchantId}/reservation`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

// 收藏商家接口
export function addFavorite(id) {
  return request({
    url: `/maintain/merchant/${id}/favorite`,
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

// 商品收藏接口
export function addGoodsFavorite(id) {
  return request({
    url: `/maintain/goods/${id}/favorite`,
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

// 商品接口 - 获取商家商品列表

export function changeGoodsType(merchantId, data) {
  return request({
    url: `/maintain/merchant/${merchantId}/goods`,
    method: 'get',
    data: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

// 取消收藏接口
export function cancelFavorite(id) {
  return request({
    url: `/maintain/favorite/${id}`,
    method: 'delete',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * 预约接口 -取消预约
 * @returns
 */

export function cancelReservation(id) {
  return request({
    url: `/maintain/reservation/${id}`,
    method: 'PUT',
    headers: {
      'content-type': 'application/json',
    },
  });
}

/**
 * 购物车接口 - 新增购物车商品
 * @param {*} data
 * @returns
 */
export function addShoppingCart(data) {
  return request({
    url: `/maintain/cartItem`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * 购物车接口 - 获取购物车商品列表
 * @param {*} data
 * @returns
 */
export function getShoppingCart(data) {
  return request({
    url: `/maintain/mineCartList`,
    method: 'get',
    data: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * 购物车接口 - 获取购物车商品列表2
 * @param {*} data
 * @returns
 */
export function getCartList(id) {
  return request({
    url: `/maintain/listCartItem/${id}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * 购物车接口 - 删除购物车
 * @param {*} data
 * @returns
 */
export function deleteCartItem(ids) {
  return request({
    url: `/maintain/cartItem/deleteCartItem/${ids}`,
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * 购物车接口 - 修改购物车商品的数量
 * @param {*} data
 * @returns
 */
export function editGoodsNumb(id, data) {
  return request({
    url: `/maintain/cartItem/${id}`,
    method: 'get',
    data: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * 购物车接口 - 修改购物车商品的数量
 * @param {*} data
 * @returns
 */
export function generateConfirmOrder(data) {
  return request({
    url: `/maintain/generateConfirmOrder`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * 订单接口 - 根据购物车信息生成订单
 * @param {*} data
 * @returns
 */
export function generateOrder(data) {
  return request({
    url: `/maintain/generateOrder`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * 商品评价接口 - 针对订单发布评价
 * @param {*} data
 * @returns
 */
export function accountToOrderGetComment(data) {
  return request({
    url: `/maintain/assess/query`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  });
}

/**
 * 商品评价接口 - 获取商品评价列表
 * @param {*} data
 * @returns
 */
export function getGoodsConcentList(goodsId, data) {
  return request({
    url: `/maintain/goods/${goodsId}/comments`,
    method: 'get',
    data: data,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  });
}

/**
 * 商品评价接口 - 新增商品评价
 * @param {*} data
 * @returns
 */
export function goodsCommentsAdd(data) {
  return request({
    url: `/maintain/assess/add`,
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json',
    },
  });
}
