import request from '@/utils/request';

// 邀请数据总览
export const getInviteStats = () =>
  request.get('/api/admin/activity/invite/stats');

// 邀请记录列表
export const getInviteRecords = (params?: { page?: number; pageSize?: number }) =>
  request.get('/api/admin/activity/invite/records', { params });

// 返现记录列表
export const getCashbackRecords = (params?: { page?: number; pageSize?: number }) =>
  request.get('/api/admin/activity/invite/cashbacks', { params });

// 邀请提现列表
export const getInviteWithdrawals = (params?: { page?: number; pageSize?: number; status?: string }) =>
  request.get('/api/admin/activity/invite/withdrawals', { params });

// 审核通过提现
export const approveInviteWithdrawal = (id: number) =>
  request.put(`/api/admin/activity/invite/withdrawals/${id}/approve`);

// 审核拒绝提现
export const rejectInviteWithdrawal = (id: number, reason: string) =>
  request.put(`/api/admin/activity/invite/withdrawals/${id}/reject`, { reason });

// 确认打款
export const payInviteWithdrawal = (id: number) =>
  request.put(`/api/admin/activity/invite/withdrawals/${id}/pay`);

// 获取邀请活动配置
export const getInviteConfig = () =>
  request.get('/api/admin/activity/invite/config');

// 更新邀请活动配置
export const updateInviteConfig = (data: {
  config?: {
    firstOrderRate?: number;
    secondOrderRate?: number;
    minCashback?: number;
    maxCashback?: number;
    withdrawThreshold?: number;
  };
  enabled?: boolean;
}) =>
  request.put('/api/admin/activity/invite/config', data);