import { request } from '@/utils/request'
import type { PayParams, RefundParams, PayInfo, RefundInfo } from './type'

/** 发起支付 */
export const payAPI = (data: PayParams) => request.post<{ outTradeNo: string }>('/pay/pay', data)

/** 查询支付结果 */
export const queryPayResultAPI = (outTradeNo: string) =>
  request.get<boolean>(`/pay/queryPayResult/${outTradeNo}`)

/** 申请退款 */
export const refundAPI = (data: RefundParams) => request.post('/pay/refund', data)

/** 获取退款详情 */
export const getRefundInfoAPI = () => request.get<RefundInfo[]>('/pay/refundInfo')

/** 撤销退款 */
export const cancelRefundAPI = (id: string) => request.get(`/pay/cancelRefund/${id}`)

/** 获取充值记录 */
export const getPayInfoAPI = () => request.get<PayInfo[]>('/pay/payInfo')
