import { get, post } from '../utils/http.js'

// 获取我的邀请码
export const getMyInviteCode = async () => {
  try {
    const response = await get(`/activity/invite/user/my/invite/code`)
    return response
  } catch (error) {
    console.error('Failed to fetch get my invite code:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取我的邀请人信息
export const getMyInviter = async () => {
  try {
    const response = await get(`/activity/invite/user/my-inviter-info`)
    return response
  } catch (error) {
    console.error('Failed to fetch get my inviter:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 绑定邀请码
export const bindInviteCode = async (data) => {
  try {
    const response = await post(`/activity/invite/user/bind/invite/code`, data)
    return response
  } catch (error) {
    console.error('Failed to fetch bind invite code:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取收益统计
export const getMyInviteIncome = async () => {
  try {
    const response = await get(`/activity/invite/user/income/statistics`)
    return response
  } catch (error) {
    console.error('Failed to fetch get my invite income:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 有效邀请用户列表
export const getMyInviteUsers = async () => {
  try {
    const response = await get(`/activity/invite/user/valid/invite/users`)
    return response
  } catch (error) {
    console.error('Failed to fetch get my invite users:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取绑定用户奖励
export const apiGetBindingUserRewards = async (data) => {
  try {
    const response = await post(`/props-activity/reward/client/map/config-info`, data)
    return response
  } catch (error) {
    console.error('Failed to fetch get binding user rewards:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 邀请用户领取奖励
export const getInviteReceiveAward = async (awardId) => {
  try {
    const response = await get(`/activity/invite/user/receive/award?id=${awardId}`)
    return response
  } catch (error) {
    console.error('Failed to fetch get receive invite award:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}
