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

type Result = {
  code: number;
  success: boolean;
  data: any;
  msg: string;
};

/**
 * 获取子账户列表
 * @param data
 */
export const getChildAccountList = data => {
  return http.request<Result>(
    "post",
    baseUrlApi("merchantUserInfo/getChildAccountNotMainPage"),
    {
      data
    }
  );
};

/**
 * 获取当前登录用户的子账户
 */
export const getChildAccount = () => {
  return http.request<Result>(
    "post",
    baseUrlApi("merchantUserInfo/getChildAccountNotMain")
  );
};

/**
 * 新增
 * @param data
 */
export const createChildAccount = data => {
  return http.request<Result>(
    "post",
    baseUrlApi("merchantUserInfo/createChildAccount"),
    {
      data
    }
  );
};

/**
 * 修改
 * @param data
 */
export const updateChildAccount = data => {
  return http.request<Result>("post", baseUrlApi("merchantUserInfo/update"), {
    data
  });
};

/**
 * 详情
 * @param id
 */
export const merchantUserInfoDetail = (id: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi(`merchantUserInfo/detail/${id}`)
  );
};

/**
 * 修改状态
 * @param data
 */
export const merchantUserInfoupdateStatus = data => {
  return http.request<Result>(
    "post",
    baseUrlApi(`merchantUserInfo/updateStatus`),
    {
      data
    }
  );
};

/**
 * 修改接单状态
 * @param data
 */
export const merchantUserInfoupdateAllocationStatus = data => {
  return http.request<Result>(
    "post",
    baseUrlApi(`merchantUserInfo/updateAllocationStatus`),
    {
      data
    }
  );
};
