import request from '@/utils/request'

// 计费方案
export function createFeePlan(data) {
  return request({
    url: '/api/fee/plan/create',
    method: 'post',
    data: data
  })
}

export function saveFeePlanItems(data) {
  return request({
    url: '/api/fee/plan/item/save',
    method: 'post',
    data: data
  })
}

export function saveFlowTiers(data) {
  return request({
    url: '/api/fee/plan/flow-tier/save',
    method: 'post',
    data: data
  })
}

export function publishFeePlan(planCode, version) {
  return request({
    url: '/api/fee/plan/publish',
    method: 'post',
    params: { planCode, version }
  })
}

// 租户计费
export function bindTenantPlan(data) {
  return request({
    url: '/api/fee/tenant/bind-plan',
    method: 'post',
    data: data
  })
}

export function changeTenantBillingMode(data) {
  return request({
    url: '/api/fee/tenant/change-billing-mode',
    method: 'post',
    data: data
  })
}

export function changeTenantType(data) {
  return request({
    url: '/api/fee/tenant/change-type',
    method: 'post',
    data: data
  })
}

// 钱包
export function getTenantWallet(tenantId) {
  return request({
    url: '/api/fee/wallet/detail/' + tenantId,
    method: 'get'
  })
}

export function rechargeTenantWallet(data) {
  return request({
    url: '/api/fee/wallet/recharge',
    method: 'post',
    data: data
  })
}

// 用量事件
export function reportUsageEvent(data) {
  return request({
    url: '/api/fee/usage/report',
    method: 'post',
    data: data
  })
}

// 账单与明细
export function listBillingDetailsAdmin(params) {
  return request({
    url: '/api/fee/billing/detail/list',
    method: 'get',
    params: params
  })
}

export function listBillingDetailsMy() {
  return request({
    url: '/api/fee/billing/detail/my',
    method: 'get'
  })
}

// 兼容历史页面调用
export function listBillingDetails(params) {
  return listBillingDetailsAdmin(params)
}

export function generateStatement(params) {
  return request({
    url: '/api/fee/statement/generate',
    method: 'post',
    params: params
  })
}

