import apis from '../utils/request';
import { replaceSpecialIcon } from '../utils/index'
const { GET, POST, PUT, DELETE } = apis

// 获取园区id模糊搜索商户列表
export const getTenementList = async function({ park, keyword }) {
  return await GET(`/wx/getTenementList?park=${park}&keyword=${replaceSpecialIcon(keyword)}`);
}

// 后台用户获取园区id模糊搜索商户列表
export const getWxTenementList = async function({ park, keyword }) {
  return await GET(`/vx/getTenementList?park=${park}&keyword=${replaceSpecialIcon(keyword)}`);
}

// 获取名下所有的商户
export const getOwnTenementList = async function() {
  return await GET(`/wx/getOwnTenements`);
}

// 获取商户详情(简易)
export const getTenementDetail = async function(id) {
  return await GET(`/wx/getTenementDetail/${id}`);
}

// 获取商户是否限电
export const getTenementExceptionalCase = async function(pid, tid) {
  return await GET(`/wx/exceptionalCase/${pid}/${tid}`);
}

// 获取商户详情（b端）
export const getTenementInfoDetail = async function(id) {
  return await GET(`/wx/getTenementDetail/${id}`);
}
// 创建商户
export const createTenement = async function(pid, data) {
  return await POST(`/vx/tenement/${pid}`, data)
}
// 修改商户
export const updateTenement = async function(pid, data) {
  return await POST(`/vx/tenement/${pid}`, data)
}
// 解绑电表
export const unbindMeter = async function(pid, tid, code, data) {
  return await PUT(`/vx/${pid}/${tid}/binding/${code}/unbind`,data)
}

// 获取b端用户
export const getTenementUsers = async function({ park, keyword }) {
  return await GET(`/records/getWxUserList?park=${park}&keyword=${keyword}`);
}

// c端获取指定商户的详细信息
export const getTenementBackInfo = async (pid, tid) => {
  return await GET(`/vx/${pid}/${tid}`);
}

// 新增用户
export const createTenementWxUser = async function(data) {
  return await POST(`/wx/createUser`, data)
}

// 创建商户
export const createBackTenement = async function(pid, data) {
  return await POST(`/vx/tenement/${pid}`, data)
}
// 修改商户信息
export const updateTenementBackInfo = async function(pid, tid, data) {
  return await PUT(`/vx/${pid}/${tid}`, data)
}

// c端给商户绑定一个表计
export const bindMeter = async function(pid, tid, data) {
  return await POST(`/vx/${pid}/${tid}/binding`,data)
}

// 修改管理员手机号
export const updateAdminPhone = async function(data) {
  return await PUT(`/wx/updatePhone`, data)
}

// 工作台移交管理权限
export const updateUserApp = async function(data) {
  return await PUT(`/wx/updateUserApp`, data)
}