// 代理相关API
import request from '@/utils/request'

/**
 * 获取代理信息
 */
export const getAgentInfo = () => {
  return request({
    url: '/agent/info',
    method: 'GET'
  })
}

/**
 * 获取代理佣金列表
 * @param {Object} params 查询参数 {page, page_size}
 */
export const getAgentCommission = (params) => {
  return request({
    url: '/agent/commission',
    method: 'GET',
    params
  })
}

/**
 * 获取代理奖励列表
 * @param {Object} params 查询参数 {page, page_size}
 */
export const getAgentRewards = (params) => {
  return request({
    url: '/agent/rewards',
    method: 'GET',
    params
  })
}

/**
 * 获取代理状态
 */
export const getAgentStatus = () => {
  return request({
    url: '/agent/status',
    method: 'GET'
  })
}

/**
 * 代理申请
 * @param {Object} data 申请数据 {region, mobile, wechat_id, code, ancestor?}
 */
export const applyAgent = (data) => {
  return request({
    url: '/agent/apply',
    method: 'POST',
    data
  })
}

/**
 * 获取代理会员用户配置
 * @param {Object} params 查询参数 {product_id}
 */
export const getAgentMembershipUserConfig = (params) => {
  return request({
    url: '/agent/membership/user_config',
    method: 'GET',
    params
  })
}

/**
 * 保存代理会员用户配置
 * @param {Object} data 配置数据
 */
export const saveAgentMembershipUserConfig = (data) => {
  return request({
    url: '/agent/membership/save_user_config',
    method: 'POST',
    data
  })
}

/**
 * 获取产品配置
 */
export const getProductConfig = () => {
  return request({
    url: '/agent/product_config',
    method: 'GET'
  })
}

/**
 * 生成推广链接
 * @param {Object} data 推广数据 {product, price}
 */
export const generatePromotionLink = (data) => {
  return request({
    url: '/agent/generating_link',
    method: 'POST',
    data
  })
}

/**
 * 获取代理收益
 */
export const getAgentRevenue = () => {
  return request({
    url: '/agent/revenue',
    method: 'GET'
  })
}

/**
 * 代理提现
 * @param {Object} data 提现数据 {payee_account, amount, payee_name}
 */
export const agentWithdrawal = (data) => {
  return request({
    url: '/agent/withdrawal',
    method: 'POST',
    data
  })
}

/**
 * 获取提现记录
 * @param {Object} params 查询参数 {page, page_size}
 */
export const getWithdrawalRecords = (params) => {
  return request({
    url: '/agent/withdrawal',
    method: 'GET',
    params
  })
}
