import ajax from "../utils/request.js";
import requestOrther from "../utils/requestOrther.js";

/**
 * 商品列表
 * @returns {AjaxPromise}
 */
export function goodsList(data) {
  return ajax({
    url: "/goods/list",
    method: "get",
    data,
  });
}

/**
 * 排队列表
 * @returns {AjaxPromise}
 */
export function orderList(data) {
  return ajax({
    url: "/orders/queue",
    method: "get",
    data,
  });
}

/**
 * 预约
 * @returns {AjaxPromise}
 */
export function apply(data) {
  return ajax({
    url: "/orders/add-app",
    method: "post",
    data,
  });
}
export function applyreal(data) {
  return ajax({
    url: "/orders/add-house",
    method: "post",
    data,
  });
}

/**
 * 取消预约
 * @returns {AjaxPromise}
 */
export function cancel(data) {
  return ajax({
    url: "/orders/cancel",
    method: "get",
    data,
  });
}

/**
 * 取消预约
 * @returns {AjaxPromise}
 */
export function advance(data) {
  return ajax({
    url: "/orders/to-house",
    method: "get",
    data,
  });
}

/**
 * 跳过
 * @returns {AjaxPromise}
 */
export function skip(data) {
  return ajax({
    url: "/orders/skip",
    method: "GET",
    data,
  });
}

/**
 * 下一个
 * @returns {AjaxPromise}
 */
export function nextone(data) {
  return ajax({
    url: "/orders/finish",
    method: "GET",
    data,
  });
}

/**
 * 预约时段
 * @returns {AjaxPromise}
 */
export function applyrang(data) {
  return ajax({
    url: "/time-segment/list",
    method: "GET",
    data,
  });
}

/**
 * 获取app用户名
 * @returns {AjaxPromise}
 */
export function getAPPUser(data, header) {
  return requestOrther({
    url: "/seeyon/thirdpartyController.do",
    method: "GET",
    header,
    data,
  });
}
/**
 * 获取apptoken
 * @returns {AjaxPromise}
 */
export function getAPPToken(urldata) {
  return requestOrther({
    url: "/seeyon/rest/token/" + urldata,
    method: "GET",
  });
}
/**
 * 获取app登录人员信息
 * @returns {AjaxPromise}
 */
export function getAPPUserDetail(data) {
  return requestOrther({
    url: "/seeyon/rest/orgMember",
    method: "GET",
    data,
  });
}

/**
 * 获取当前打烊规则
 * @returns {AjaxPromise}
 */
export function getRule(data) {
  return ajax({
    url: "/stop-rule/list",
    method: "POST",
    data,
  });
}

/**
 * 更新当前打烊规则
 * @returns {AjaxPromise}
 */
export function upRule(data) {
  return ajax({
    url: "/stop-rule/edit",
    method: "POST",
    data,
  });
}

/**
 * 菜单列表
 * @returns {AjaxPromise}
 */
export function menulist(data) {
  return ajax({
    urlType: "menuURL",
    url: "/menu/recently",
    method: "GET",
    data,
  });
}

/**
 * 菜单周列表
 * @returns {AjaxPromise}
 */
export function menuWeekList(data) {
  return ajax({
    urlType: "topic",
    url: "/menu/now-week",
    method: "GET",
    data,
  });
}

export function jsonDataRanking(data) {
  return ajax({
    urlType: "dataJSON",
    url: `/data/oa-rank/${data.url}.json`,
    method: "GET",
    data: data.data || undefined,
  });
}

export function infoDate() {
  return ajax({
    urlType: "dataJSON",
    url: `/data/oa-rank/info.json`,
    method: "GET",
  });
}

export function getCoffeeGoods(data) {
  return ajax({
    urlType: "coffee",
    url: `/getGoods?${data || ""}`,
    method: "GET",
  });
}

export function getCoffeeTypes() {
  return ajax({
    urlType: "coffee",
    url: `/getTypes`,
    method: "GET",
  });
}

export function getAddrees(data) {
  return ajax({
    urlType: "coffee",
    url: `/addressList?phone=${data.phone}`,
    method: "GET",
  });
}

export function getAddreesOne() {
  return ajax({
    urlType: "coffee",
    url: `/addressOne`,
    method: "GET",
  });
}

export function pushOrder(data) {
  return ajax({
    urlType: "coffee",
    url: `/pushOrder`,
    method: "POST",
    data,
  });
}

export function pushAddress(data) {
  return ajax({
    urlType: "coffee",
    url: `/addressPush`,
    method: "POST",
    data,
  });
}

export function editAddress(data) {
  return ajax({
    urlType: "coffee",
    url: `/addressEdit`,
    method: "POST",
    data,
  });
}

export function deleteAddress(data) {
  return ajax({
    urlType: "coffee",
    url: `/addressDetele`,
    method: "DELETE",
    data,
  });
}

export function listOrder(data) {
  const { page, size } = data;
  return ajax({
    urlType: "coffee",
    url: `/listOrder?page=${page}&size=${size}`,
    method: "GET",
  });
}

export function jsonZhou(data) {
  return ajax({
    urlType: "cxzx",
    url: `/zhoubao/data/${data.start}-${data.end}ctmt.json?${data.time}`,
    method: "GET",
  });
}

export function jsonZhouMobile(data) {
  return ajax({
    urlType: "cxzx",
    url: `/zhoubao/data/new-media-${data.date}.json?${data.time}`,
    method: "GET",
  });
}

export function jsonAdvertisement(data) {
  return ajax({
    urlType: "cxzx",
    url: `/zhoubao/data/ad-${data.date}.json?${data.time}`,
    method: "GET",
  });
}

export function jsonCalendarOne(data) {
  return ajax({
    urlType: "cxzx",
    url: `/zhoubao/data/${data.date}-calendar.json?${data.time}`,
    method: "GET",
  });
}

export default {};
