import {http2} from "@/utils/request.js";

/**用户余额管理 */
/**修改用户余额  */
export const editUserBalance = (data) => {
  return http2.post('/api/v1/admin/user/balance/update', data,{
    headers:{
        'Content-Type':'multipart/form-data'
    }
  })
}
/**添加用户消费记录 */
export const addUserConsumption = (data) => {
  return http2.post('/api/v1/admin/user/balance/add_history', data,{
    headers:{
        'Content-Type':'multipart/form-data'
    }
  })
}


/**获取用户余额记录 */
export const getUserBalanceRecord = (data) => {
  return http2.get('/api/v1/admin/user/balance/history?user_id='+data.user_id + '&balance_type=' + data.balance_type + '&page=' + data.page + '&count=' + data.count)
}

/**获取用户余额 */
export const getUserBalanceCount = (data) => {
  return http2.get('/api/v1/admin/user/balance/get?user_id='+data.user_id)
}
/**获取用户信息 */
export const getUserInfo = (data) => {
  return http2.get('/api/v1/admin/user/user/detail?user_id='+data.user_id)
}

/**获取用户列表 */
export const getUserList = (params) => {
  return http2.get('/api/v1/admin/user/user/list', { params })
}

/**更新用户信息 */
export const updateUserInfo = (data) => {
  return http2.post('/api/v1/admin/user/user/update', data,{
    headers:{
        'Content-Type':'multipart/form-data'
    }
  })
}

/**删除用户 */
export const deleteUser = (data) => { 
    return http2.delete('/api/v1/admin/user/user/delete?user_id='+data.user_id)
} 
/**修改用户头像 */ 
export const updateUserAvatar = (data) => {
    return http2.post('/api/v1/admin/user/user/update_cover', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}
/**修改用户密码 */
export const updateUserPassword = (data) => {
    return http2.post('/api/v1/admin/user/user/update_password', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}

/**修改用户组 */
export const updateUserGroup = (data) => {
    return http2.post('/api/v1/admin/user/user/update_group', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}
/**修改用户管理员权限*/
export const updateUserAdmin = (data) => {
    return http2.post('/api/v1/admin/user/user/user2admin', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}
/**修改用户实名信息*/
export const updateUserRealName = (data) => {
    return http2.post('/api/v1/admin/user/user/update_real_name', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}
/**获取用户登录记录*/
export const getUserLoginRecord = (data) => {
    return http2.get('/api/v1/admin/user/user/login_history?user_id='+data.user_id + '&page=' + data.page + '&count=' + data.count)
}

/**获取用户操作记录 */
export const getUserOperationRecord = (data) => {
    return http2.get('/api/v1/admin/user/user/manage_history?user_id='+data.user_id + '&page=' + data.page + '&count=' + data.count)
}
/**模拟用户登录 */
export const mockUserLogin = (data) => {
    return http2.get('/api/v1/admin/user/user/simulation_login?user_id='+data.user_id)
}

/**通过IDC代理商uid获取用户信息 */
export const getUserByIdcAgentUid = (params) => {
    return http2.get('/api/v1/admin/user/idc_agent/user', { params })
}

/**新建任务 */
export const createTask = (data) => {
    return http2.post('/api/v1/admin/user/user/create', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}

/**用户组管理 */
/**获取用户组列表 */
export const getUserGroupList = (data) => {
    return http2.get('/api/v1/admin/user_group/list?page=' + data.page + '&count=' + data.count)
}
/**获取用户组成员列表 */
export const getUserGroupMemberList = (data) => {
    return http2.get('/api/v1/admin/user_group/member_list?group_id=' + data.group_id + '&page=' + data.page + '&count=' + data.count)
}
/**获取用户组详情信息 */
export const getUserGroupDetail = (data) => {
    return http2.get('/api/v1/admin/user_group/detail?group_id=' + data.group_id)
}
/**新建用户组 */
export const createUserGroup = (data) => {
    return http2.post('/api/v1/admin/user_group/create', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}
/**更新用户组信息 */
export const updateUserGroupInfo = (data) => {
    return http2.post('/api/v1/admin/user_group/update', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}
/**删除用户组 */
export const deleteUserGroup = (data) => {
    return http2.delete(`/api/v1/admin/user_group/delete?group_id=`+data.group_id,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}
/**添加用户组成员 */
export const addUserGroupMember = (data) => {
    return http2.post('/api/v1/admin/user_group/add_member', data,{
        headers:{
            'Content-Type':'multipart/form-data'
        }
    })
}

/**退款对应账单 */
export const refundBalance = (data) => {
    return http2.get('/api/v1/admin/user/balance/refund', {
        params:data,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}