import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
    recordItme,
    traderApplicationParam,
    traderApplicationResult,
    traderHierarchyResult,
    approvalOfTransactionParam,
    labelManagementResult,
    addlabelParam,
    addTraderLevelsParam,
    updateParam,
    updatalabelParam,
} from "@/types/api/documentary/index";
//跟单管理=> 跟单记录
export function recordform(data: any): AxiosPromise<recordItme> {
    return request({
        url: "/copy-trade-admin/copied-trade/list",
        method: "post",
        data: data,
    });
}
//跟单管理=> 交易员申请列表
export function traderApplication(
    data: traderApplicationParam
): AxiosPromise<traderApplicationResult> {
    return request({
        url: "/copy-trade-admin/customer/applying-list",
        method: "post",
        data: data,
    });
}

//跟单管理=> 交易员等级列表

export function traderHierarchy(): AxiosPromise<traderHierarchyResult> {
    return request({
        url: "/copy-trade-admin/trader-level/",
        method: "get",
    });
}

//跟单管理=>交易员申请列表=> 批准交易员申请
export function approvalOfTransaction(
    data: approvalOfTransactionParam
): AxiosPromise<traderApplicationResult> {
    return request({
        url: `/copy-trade-admin/customer/approval-trader/${data.traderId}/${data.levelId}`,
        method: "put",
    });
}
//跟单管理=>交易员申请列表=>  拒绝交易员申请
export function rejectTrade(
    data: number
): AxiosPromise<traderApplicationResult> {
    return request({
        url: `/copy-trade-admin/customer/reject-trader/${data}`,
        method: "put",
    });
}

//跟单管理=> 获取标签列表

export function labelManagement(): AxiosPromise<labelManagementResult> {
    return request({
        url: `/copy-trade-admin//tag/`,
        method: "get",
    });
}

// 跟单管理=> 获取标签列表=>添加标签

export function addlabel(data: any) {
    return request({
        url: `/copy-trade-admin/tag/add`,
        method: "post",
        data: data,
    });
}

//跟单管理=> 获取标签列表=>修改标签内容
export function updatalabel(data: updatalabelParam) {
    return request({
        url: `/copy-trade-admin/tag/update`,
        method: "post",
        data: data,
    });
}
//删除标签
export function removelabel(data: number) {
    return request({
        url: `/copy-trade-admin/tag/delete/${data}`,
        method: "put",
    });
}

//跟单管理=> 获取跟单配置

export function tagList(): AxiosPromise<labelManagementResult> {
    return request({
        url: `/copy-trade-admin/tag/list`,
        method: "post",
    });
}

//跟单管理=> 修改跟单配置

export function tagEdit(data: any): AxiosPromise<labelManagementResult> {
    return request({
        url: `/copy-trade-admin/tag/edit/`,
        method: "post",
        data: data,
    });
}

// 添加交易员等级

export function addTraderLevels(data: addTraderLevelsParam) {
    return request({
        url: `/copy-trade-admin/trader-level/add`,
        method: "post",
        data: data,
    });
}

// 修改交易员等级详细
export function modifyTraderDetails(data: updateParam) {
    return request({
        url: `/copy-trade-admin/trader-level/update`,
        method: "post",
        data: data,
    });
}
// 删除交易员等级

export function removeTraderRanks(data: number) {
    return request({
        url: `/copy-trade-admin/trader-level/delete/${data}`,
        method: "put",
    });
}

// 获取交易员列表

export function listOfTraders(data: traderApplicationParam) {
    return request({
        url: `/copy-trade-admin/customer/trader-list`,
        method: "post",
        data: data,
    });
}

// 修改交易员等级

export function changeTraderLevels(data: approvalOfTransactionParam) {
    return request({
        url: `/copy-trade-admin/customer/update-trader-level/${data.traderId}/${data.levelId}`,
        method: "put",
    });
}

// 设置顶级交易员

export function updateTraderTop(traderId: number, isTop: number) {
    return request({
        url: `/copy-trade-admin/customer/update-trader-top/${traderId}/${isTop}`,
        method: "put",
    });
}

// 取消交易员

export function cancelTraders(data: number) {
    return request({
        url: `/copy-trade-admin/customer/cancel-trader/${data}`,
        method: "put",
    });
}

// 跟单管理=>仓位管理

export function positionManagement(data: any) {
    return request({
        url: `admin/follow/account/page-query`,
        method: "post",
        params: data,
    });
}
// 跟单管理=>交易员持仓

export function followTrader(data: any) {
    return request({
        url: `admin/swap/account/trader-page-query`,
        method: "post",
        params: data,
    });
}

// 跟单管理=>仓位管理=>强平

export function forceCloseOut(data: any): any {
    return request({
        url: "admin/swap/position-new/force-close-wallet",
        method: "post",
        params: data,
    });
}

// 所有用户一键强平
export function forceCloseAll(data: any) {
    return request({
        url: "admin/swap/position-new/force-close-all-follow",
        method: "post",
        params: data,
    });
}

// 特级跟单管理

export function specialMerchandisingManagement(data: any) {
    return request({
        url: "admin/swap/account/traderClose",
        method: "post",
        params: data,
    });
}

// 获取合约行情

export function detailsOfTheContract() {
    return request({
        url: "admin/swap/account/swapPrice",
        method: "post",
    });
}

// 获取特级交易员下单数量

export function orderQuantity(data: any) {
    return request({
        url: "admin/swap/account/traderAmount",
        method: "post",
        params: data,
    });
}

// 平仓获取交易员id

export function gettingTheId() {
    return request({
        url: "admin/swap/account/traderList",
        method: "post",
    });
}

//  获取可以修改的交易员统计数据列表

export function statisticsCanBeModified(data: any) {
    return request({
        url: `/copy-trade-admin/traderdata/list`,
        method: "post",
        data: data,
    });
}

// 获取每日统计数据列表

export function dailyStats(data: number) {
    return request({
        url: `/copy-trade-admin/statistics-data/list/${data}`,
        method: "post",
    });
}

// 修改交易员每日统计数据

export function modifyingDailyData(data: any) {
    return request({
        url: `/copy-trade-admin/statistics-data/edit`,
        method: "post",
        data: data,
    });
}

// 修改交易员统计数据

export function modifyingTrader(data: any) {
    return request({
        url: `/copy-trade-admin/traderdata/edit`,
        method: "post",
        data: data,
    });
}

// 修改交易配置参数

export function modifyingTraderConfiguration(data: any) {
    return request({
        url: `/copy-trade-admin/customer/update-trader-params/${data.traderId}`,
        method: "put",
        data: data.traderForm,
    });
}

// 获取K线数据

export function kLineData(data: any) {
    return request({
        url: `${
            import.meta.env.VITE_APP_APP_API
        }/market/swap/history`,
        method: "post",
        params: data,
    });
}

// 跟单业务汇总

export const summaryDocumentaryIndustry = (data: any) => {
    return request({
        url: "/copy-trade-admin/customer/trader-total-list",
        method: "post",
        data: data,
    });
};

// 跟单历史仓位

export const positionHistory = (data: any) => {
    return request({
        url: "/copy-trade-admin/position/list",
        method: "post",
        data: data,
    });
};

// 重置交易员状态

export const resetState = (data: any) => {
    return request({
        url: "admin/swap/account/traderReset",
        method: "post",
        params: data,
    });
};

// 获取平仓记录

export function liquidationRecord(data: any): AxiosPromise<recordItme> {
    return request({
        url: "/copy-trade-admin/close-position/list",
        method: "post",
        data: data,
    });
}

// 获取跟随学生列表

export function studentFollowingList(
    data: any,
    traderMemberId: Number
): AxiosPromise<recordItme> {
    return request({
        url: `/copy-trade-admin/follow/followers`,
        method: "post",
        data: data,
    });
}

// 移除跟随

export function removeFollow(data: any): AxiosPromise<recordItme> {
    return request({
        url: `/copy-trade-admin/follow/remove-follow`,
        method: "put",
        params: data,
    });
}

// 跟单持仓统计
export function copyTradePositionList(params: {
    pageNo: number; pageSize: number;
    traderMemberId?: number; symbol?: string;
    direction?: 0 | 1; profitStatus?: "positive" | "negative";
}) {
    return request({ url: "admin/copy-trade-position/page-query", method: "post", params });
}

export function copyTradePositionRefresh() {
    return request({ url: "admin/copy-trade-position/refresh", method: "post" });
}

export function copyTradePositionForceClose(params: {
    traderMemberId: number; symbol: string; username: string; password: string;
}) {
    return request({ url: "admin/copy-trade-position/force-close", method: "post", params });
}

export function copyTradePositionDetail(params: {
    traderMemberId: number; symbol: string;
    memberKeyword?: string; pageNo: number; pageSize: number;
}) {
    return request({ url: "admin/copy-trade-position/detail", method: "post", params });
}

export function copyTradePositionForceCloseOne(params: {
    positionId: number; username: string; password: string;
}) {
    return request({ url: "admin/copy-trade-position/force-close-one", method: "post", params });
}
