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

// 获取充值记录
export const getRechargeList = async function(year = "", codeId = "", pay = "") {
  const tenement = wx.getStorageSync('tenement')?.id
  return await GET(`/wx/getRechargeList?year=${year}&tenement=${tenement}&codeId=${codeId}&pay=${pay}`);
}

// 预备充值请求
export const requestRecharge = async function(data) {
  return await POST(`/wx/requestRecharge`, data);
}

// 获取充值记录详情
export const getRechargeDetail = async function(rid) {
  return await GET(`/wx/getRechargeDetail/${rid}`);
}

// 退费
export const returnFee = async function(data) {
  return await POST(`/wx/return`, data);
}

// 创建对公
export const createPublicTopUp = async function(data) {
  return await POST(`/wx/createPublicTopUp`, data);
}

// 后台充值
export const handleRecharge = async function(park, data) {
  return await POST(`/wechatTopup/${park}`, data)
}

// 获取后台审核列表
export const getRechargeApproveList = async function({park = "", page, keyword, status}) {
  return await GET(`/wx/getTopExamineList?park=${park}&page=${page}&keyword=${replaceSpecialIcon(keyword)}&status=${status}`)
}

// 对公审核
export const rechargeApprove = async function({ id, status, reason }) {
  return await PUT(`/wx/updateTopExamineList/`, { id, status, reason })
}