import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/common";

// 查询企微用户列表
export function qwList(query) {
  return request({
    url: '/company/CompanyUserAll/qwList',
    method: 'get',
    params: query
  })
}
export function getList(query) {
  return request({
    url: '/company/CompanyUserAll/getList',
    method: 'get',
    params: query
  })
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: '/company/CompanyUserAll/' + praseStrEmpty(userId),
    method: 'get'
  })
}

// 查询用户详细
export function addInfo(companyId) {
  return request({
    url: '/company/CompanyUserAll/addInfo/' +companyId,
    method: 'get'
  })
}


// 新增用户
export function addUser(data) {
  return request({
    url: '/company/CompanyUserAll',
    method: 'post',
    data: data
  })
}

//创建二维码
export function addCodeUrl(data) {
  return request({
    url: '/company/CompanyUserAll/addCodeUrl',
    method: 'post',
    data: data
  })
}


// 修改用户
export function updateUser(data) {
  return request({
    url: '/company/CompanyUserAll',
    method: 'put',
    data: data
  })
}

// 删除用户
export function delUser(userIds) {
  return request({
    url: '/company/CompanyUserAll/' + userIds,
    method: 'delete'
  })
}

// 导出用户
export function exportUser(query) {
  return request({
    url: '/company/CompanyUserAll/export',
    method: 'get',
    params: query
  })
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/company/CompanyUserAll/resetPwd',
    method: 'put',
    data: data
  })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/company/CompanyUserAll/changeStatus',
    method: 'put',
    data: data
  })
}

// 下载用户导入模板
export function importTemplate() {
  return request({
    url: '/company/CompanyUserAll/importTemplate',
    method: 'get'
  })
}

/**
 * 获取地区
 */
export function getCitysAreaList(query) {
  return request({
    url: '/company/CompanyUserAll/getCitysAreaList',
    method: 'get',
    params: query
  })
}

/**
 * 批量修改 销售的所属区域(临时的)
 */
export function updateCompanyUserAreaList(data) {
  return request({
    url: '/company/CompanyUserAll/updateCompanyUserAreaList',
    method: 'post',
    data: data
  })
}


//生成域名
export function generateSubDomain(query){
  return request({
    url: '/company/CompanyUserAll/generateSubDomain',
    method: 'get',
    params: query
  })
}

// 设置是否需要单独注册会员
export function setIsRegisterMember(status, data) {
  return request({
    url: '/company/CompanyUserAll/setRegister',
    method: 'put',
    params: status,
    data: data
  })
}

// 开关是否允许所有方式注册会员
export function isAllowedAllRegister(status, data) {
  return request({
    url: '/company/CompanyUserAll/allowedAllRegister',
    method: 'put',
    params: status,
    data: data
  })
}

// 绑定医生
export function bindDoctorId(data) {
  return request({
    url: '/company/CompanyUserAll/bindDoctorId',
    method: 'post',
    data: data
  })
}

//解绑医生
export function unBindDoctorId(userId) {
  return request({
    url: '/company/CompanyUserAll/unBindDoctorId/'+userId,
    method: 'get'
  })
}

//批量修改用户的角色
export function updateBatchUserRoles(data) {
  return request({
    url: '/company/CompanyUserAll/updateBatchUserRoles',
    method: 'post',
    data: data
  })
}

export function getAllNotVoiceList(data) {
  return request({
    url: '/company/CompanyUserAll/getAllNotVoiceList',
    method: 'post',
    data: data
  })
}

export function getAllVoiceList(data) {
  return request({
    url: '/company/CompanyUserAll/getAllVoiceList' ,
    method: 'post',
    data: data
  })
}

export function transferVoiceCompanyUserId(data) {
  return request({
    url: '/company/CompanyUserAll/transferVoiceCompanyUserId',
    method: 'post',
    data: data
  })
}

export function unBind(userId) {
  return request({
    url: '/company/CompanyUserAll/unBind',
    method: 'post',
    data: { userId: userId }
  })
}
