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

export const searchUser = async (userId) => {
  try {
    const response = await get(`/user/user-profile/open-search?account=${userId}`)
    return response
  } catch (error) {
    console.error('Failed to fetch search user:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 用户支付充值用户搜索
export const searchPayRechargeUser = async (params) => {
  try {
    const response = await get(
      `/order/web/pay/user-profile?sysOrigin=${params.sysOrigin}&account=${params.account}&type=${params.type}`
    )
    return response
  } catch (error) {
    console.error('Failed to fetch search pay recharge user:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取BD列表
export const getBDList = async (data) => {
  try {
    const response = await get(
      `/team/bd/page2?sysOrigin=LIKEI&userId=${data.userId}&cursor=${data.cursor}&limit=${data.limit}`
    )
    return response
  } catch (error) {
    console.error('Failed to fetch get BD list:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取金币代理列表
export const getAgencyList = async (data) => {
  try {
    const response = await get(`/app/h5/recharge-page?cursor=${data.cursor}&limit=${data.limit}`)
    return response
  } catch (error) {
    console.error('Failed to fetch get agency list:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 获取货运代理充值月度汇总（当月，上月）
export const getAgencyTotalRecharge = async (data) => {
  try {
    const response = await get(`/app/h5/recharge-summary`)
    return response
  } catch (error) {
    console.error('Failed to fetch get agency total recharge:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 分页查询货运
export const getFreightAgencys = async () => {
  try {
    const response = await get(`/user/freight-balance/page`)
    return response
  } catch (error) {
    console.error('Failed to fetch get Freight Agencys:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}

// 搜索团队成员
export const getTeamMember = async (account) => {
  try {
    const response = await get(`/team/search-members?account=${account}`)
    return response
  } catch (error) {
    console.error('Failed to fetch get team member:', error)
    console.error('error:' + error.response.errorMsg)
    throw error
  }
}
