import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

type Result = {
  code: number;
  success: boolean;
  data: {
    list: object[];
    total: number;
  };
  msg: string;
};

// 获取订单列表（分页）
export const getMerchantOrderInfoAllList = (data: object) => {
  return http.request<Result>("post", baseUrlApi("merchantOrderInfo/allList"), {
    data
  });
};

// 添加订单
export const updateStartLevel = (data: object) => {
  return http.request<Result>("post", baseUrlApi("merchantFollowInfo/add"), {
    data
  });
};

// 获取订单列表
export const merchantFollowInfoList = (data: object) => {
  return http.request<Result>("post", baseUrlApi("merchantFollowInfo/list"), {
    data
  });
};

// 解除分配
export const merchantFollowInfoReliveOrder = (data: object) => {
  return http.request<Result>(
    "post",
    baseUrlApi("merchantFollowInfo/reliveOrder"),
    {
      data
    }
  );
};

// 分配订单
export const merchantFollowInfoAllocationAccount = (data: object) => {
  return http.request<Result>(
    "post",
    baseUrlApi("merchantOrderInfo/allocationAccount"),
    {
      data
    }
  );
};

// 获取我的订单列表（分页）
export const getMyOrderInfoAllList = (data: object) => {
  return http.request<Result>(
    "post",
    baseUrlApi("merchantOrderInfo/allocationMyList"),
    {
      data
    }
  );
};

type DetailResult = {
  code: number;
  success: boolean;
  data: {
    custAssertInfoVO: object;
    orderInfoVO: object;
  };
};

// 详情
export const merchantFollowInfoDetail = (data: object) => {
  return http.request<DetailResult>(
    "post",
    baseUrlApi("merchantOrderInfo/detail"),
    {
      data
    }
  );
};

// 能否查看详情
export const merchantFollowInfoOrderVisible = (data: object) => {
  return http.request<Result>(
    "post",
    baseUrlApi("merchantOrderInfo/order/visible"),
    {
      data
    }
  );
};
