import {
    MemberQueryParam,
    MemberPageResult,
    MemberIdParam,
    MemberForceCloseParam,
    MemberStatusParam,
    MemberSuperPartnerParam,
    InviteRelationParam,
} from "@/types/api/member/list";
import request from "@/utils/request";
import { AxiosPromise } from "axios";

/**
 * "会员管理" => "会员列表"
 * @param data
 */
export function memberManage(
    data: MemberQueryParam
): AxiosPromise<MemberPageResult> {
    return request({
        url: "admin/member/page-with-amount",
        method: "post",
        params: data,
    });
}

/**
 * "会员管理" => "锁定"
 */
export function memberLock(data: MemberIdParam): any {
    return request({
        url: "admin/member/lock",
        method: "post",
        params: data,
    });
}

/**
 * "会员管理" => "解锁"
 */
export function memberUnlock(data: MemberIdParam): any {
    return request({
        url: "admin/member/unlock",
        method: "post",
        params: data,
    });
}

/**
 * 会员管理" => "开始返佣"
 */
export function memberEnableReward(data: MemberIdParam): any {
    return request({
        url: "admin/member/enableReward",
        method: "post",
        params: data,
    });
}

/**
 * "会员管理" => "停止返佣"
 */
export function memberDisableReward(data: MemberIdParam): any {
    return request({
        url: "admin/member/disableReward",
        method: "post",
        params: data,
    });
}

/**
 * "会员管理" => "平仓"
 */
export function memberForceClose(data: MemberForceCloseParam): any {
    return request({
        url: "admin/swap/position/force-close-member",
        method: "post",
        params: data,
    });
}

/**
 * "法币管理"=>"认证商家"=>"禁用/解禁会员"
 */
export function forbiddenMember(data: MemberStatusParam): any {
    return request({
        url: "admin/member/alter-status",
        method: "post",
        params: data,
    });
}

/**
 * "法币管理"=>"认证商家"=>"禁用/解禁会员交易"
 */
export function forbiddenMemberTrans(data: MemberStatusParam): any {
    return request({
        url: "admin/member/alter-transaction-status",
        method: "post",
        params: data,
    });
}

/**
 * "法币管理"=>"认证商家"=>"授权代理商"
 */
export function setSuperPartner(data: MemberSuperPartnerParam): any {
    return request({
        url: "admin/member/alter-member-superpartner",
        method: "post",
        params: data,
    });
}

/**
 * 添加邀请关系
 */
export function setInviter(data: InviteRelationParam): any {
    return request({
        url: "admin/member/setInviter",
        method: "post",
        params: data,
    });
}

// "会员管理"=>"会员列表"=>"刷新缓存"

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

export function setMoneyLock(data: any) {
    return request({
        url: "admin/member/set-money-lock",
        method: "post",
        params: data,
    });
}
// 强制下线
export function forceOffline(data: any) {
    return request({
        url: "admin/member/force-offline",
        method: "post",
        params: data,
    });
}

// 增加新用户

export function addUser(data: any) {
    return request({
        url: "admin/member/add",
        method: "post",
        params: data,
    });
}

// 增加新用户

export function updatePhone(data: any) {
    return request({
        url: "admin/member/update-phone",
        method: "post",
        params: data,
    });
}

// CT转账

export function ctTransfer(data: any) {
    return request({
        url: "admin/finance/transfer/ct",
        method: "post",
        params: data,
    });
}

// 取消谷歌绑定

export function unbindGoogle(data: any) {
    return request({
        url: "admin/member/unbind-google?memberId=" + data.id,
        method: "post",
    });
}

// 设置/取消内部账户
export function setInternal(data: any) {
    return request({
        url: "admin/member/set-internal",
        method: "post",
        params: data,
    });
}

// 生成钱包

export function generateWallet(data: any) {
    return request({
        url: "admin/member/generateWallet?memberId=" + data,
        method: "get",
    });
}
