import request from "@/utils/request";

/**
 * 查询订单
 * @param {*} data
 * @returns
 */
export function tbOrderInfoData(data) {
  return request({
    url: "/api/tbOrderInfo/date",
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}

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

/**
 * 通过Id查询订单
 * @param {*} id
 * @returns
 */
export function tbOrderInfoDetail(id) {
  return request({
    url: `/api/tbOrderInfo/${id}`,
    method: "get"
  });
}

/**
 * 通过Id查询订单
 * @param {*} createdAt
 * @returns
 */
export function payCount(createdAt) {
  console.log(createdAt);
  return request({
    url: `/api/tbOrderInfo/payCount`,
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      createdAt: createdAt
    }
  });
}

/**
 * 订单列表
 * @param {*} createdAt
 * @returns
 */
export function tbGroupOrderInfo(params) {
  return request({
    url: `/api/tbGroupOrderInfo`,
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}

/**
 * 退单
 * @param {*} data
 * @returns
 */
export function returnGpOrder(data) {
  return request({
    url: `/api/tbGroupOrderInfo/returnGpOrder`,
    method: "post",
    data
  });
}
