import request from '@/utils/request'
import { getCommunityId } from '@/api/community/communityApi'

// 查询账户明细列表
export function queryOwnerAccountDetail(params) {
  return new Promise((resolve, reject) => {
    const communityId = getCommunityId()
    request({
      url: '/account/queryOwnerAccountDetail',
      method: 'get',
      params: {
        ...params,
        communityId
      }
    }).then(response => {
      const res = response.data
      if (res.code === 0) {
        resolve(res)
      } else {
        reject(new Error(res.msg || '查询账户明细失败'))
      }
    }).catch(error => {
      reject(error)
    })
  })
}

// 撤销账户明细
export function cancelAccountDetail(data) {
  return new Promise((resolve, reject) => {
    const communityId = getCommunityId()
    request({
      url: '/account.cancelAccountDetail',
      method: 'post',
      data: {
        ...data,
        communityId
      }
    }).then(response => {
      const res = response.data
      if (res.code === 0) {
        resolve(res)
      } else {
        reject(new Error(res.msg || '撤销操作失败'))
      }
    }).catch(error => {
      reject(error)
    })
  })
}