import { request } from "@umijs/max";
import { TradeOrderPageRespVO, TradeReq, TradeSummaryRespVO } from "./list";
import {
  TradeOrderDetailRespVO,
  TradeOrderFastPhotoRespVo,
  TradeOrderSubLogDO,
} from "./detail";

export const getTradeOrderPage = async (params: TradeReq) => {
  return request<PageResult<TradeOrderPageRespVO[]>>("/trade/order/page", {
    method: "GET",
    params,
  });
};

export const getTradeOrderDetail = async (id: number) => {
  return request<TradeOrderDetailRespVO>("/trade/order/get-detail", {
    method: "GET",
    params: { id },
  });
};

//获得交易订单统计
export const getTradeSummary = async () => {
  return request<TradeSummaryRespVO>("/trade/order/summary", {
    method: "GET",
  });
};

//交易快照

export const getfastPhoto = async (params: {
  itemId: number;
  spuId: number;
}) => {
  return request<TradeOrderFastPhotoRespVo>("/trade/order/fastPhoto", {
    method: "GET",
    params,
  });
};

//服务信息修改记录

export const getSubTimeLog = async (id: number) => {
  return request<TradeOrderSubLogDO[]>(`/trade/order/subTimeLog/${id}`, {
    method: "GET",
  });
};

//取消订单
export const cancelOrder = async (data: {
  id: number;
  cancelReason: string;
  cancelRemark: string;
}) => {
  return request<boolean>(`/trade/order/cancel`, {
    method: "PUT",
    data,
  });
};
//接单确认
export const acceptConfirm = async (id: number) => {
  return request<boolean>(`/trade/order/acceptConfirm`, {
    method: "PUT",
    params: { id },
  });
};

//服务上报
export const reportServe = async (id: number) => {
  return request<boolean>(`/trade/order/reportServe`, {
    method: "PUT",
    params: { id },
  });
};

//商家备注
export const updateOrderRemark = async (params: {
  id?: number;
  remark?: string;
}) => {
  return request<boolean>(`/trade/order/update-remark`, {
    method: "PUT",
    data: params,
  });
};

export {
  TradeOrderPageRespVO,
  TradeOrderDetailRespVO,
  TradeReq,
  TradeSummaryRespVO,
  TradeOrderFastPhotoRespVo,
  TradeOrderSubLogDO,
};
