import request from "@/utils/request";

/**
 * 汇总数据
 * @returns
 */
export function summaryGet() {
  return request({
    url: "/api/summary",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId")
    }
  });
}

/**
 * 今日数据
 * @returns
 */
export function summaryTodayGet() {
  return request({
    url: "/api/summary/today",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId")
    }
  });
}

/**
 * 今日数据
 * @returns
 */
export function summaryDateGet(day) {
  return request({
    url: "/api/summary/date",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      day: day
    }
  });
}

/**
 * 销售额柱状图
 * @returns
 */
export function dateAmount(day) {
  return request({
    url: "/api/summary/dateAmount",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      day: day
    }
  });
}

/**
 * 商品销售排行
 * @returns
 */
export function dateProduct(day, page, size) {
  return request({
    // url: "/api/summary/dateProduct",
    url: "/api/summary/productSaleDate",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      day: day,
      page: page,
      size: size
    }
  });
}

/**
 * 支付类型占比
 * @returns
 */
export function datePayType(day) {
  return request({
    url: "/api/summary/datePayType",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      day: day
    }
  });
}

/**
 * 导出数据
 * @returns
 */
export function daydownload(data) {
  return request({
    url: "/api/summary/day/download",
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    },
    responseType: "blob"
  });
}

/**
 * 总数统计
 * @returns
 */
export function daycount(params) {
  return request({
    url: "/api/summary/day/count",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}

/**
 * 获取数据
 * @returns
 */
export function summaryday(params) {
  return request({
    url: "/api/summary/day",
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}

/**
 * 营业板块
 * @returns
 */
export function summarytrade(data) {
  return request({
    url: "/api/summary/trade",
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}
