import request from '@/utils/request'
import type { ApiResult, PageResult } from '@/api'
import type { UserBalanceLog, UserBalanceLogParam } from './model'

/**
 * 分页查询用户余额日志
 */
export async function pageUserBalanceLog(params?: UserBalanceLogParam): Promise<PageResult<UserBalanceLog>> {
  const res = await request.get<ApiResult<PageResult<UserBalanceLog>>>(
    '/shop/shop-user-balance-log/page',
      params
  )
  if (res.code === 0 && res.data) {
    return res.data
  }
  return Promise.reject(new Error(res.message))
}

/**
 * 查询全部用户余额日志
 */
export async function listUserBalanceLog(params?: UserBalanceLogParam): Promise<UserBalanceLog[]> {
  const res = await request.get<ApiResult<UserBalanceLog[]>>(
    '/shop/shop-user-balance-log',
    params
  )
  if (res.code === 0 && res.data) {
    return res.data
  }
  return Promise.reject(new Error(res.message))
}
