52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import type { AdminPayment } from '@/features/admin/api/adminPayments'
|
|
|
|
export function estimateOrderEndAt(
|
|
estimatedEndAt?: string,
|
|
rentedAt?: string,
|
|
durationHours?: number
|
|
) {
|
|
if (estimatedEndAt) return estimatedEndAt
|
|
const hours = Number(durationHours || 0)
|
|
if (!rentedAt || hours <= 0) return undefined
|
|
const startedAt = new Date(rentedAt).getTime()
|
|
if (!Number.isFinite(startedAt)) return undefined
|
|
return new Date(startedAt + hours * 60 * 60 * 1000).toISOString()
|
|
}
|
|
|
|
export function paymentStatusLabel(status: string) {
|
|
const labels: Record<string, string> = {
|
|
created: '已创建',
|
|
paying: '支付中',
|
|
paid: '已支付',
|
|
refunding: '退款中',
|
|
refunded: '已退款',
|
|
failed: '失败',
|
|
}
|
|
return labels[status] || status
|
|
}
|
|
|
|
export function paymentStatusType(status: string) {
|
|
if (['paid', 'refunded'].includes(status)) return 'success' as const
|
|
if (status === 'failed') return 'danger' as const
|
|
if (['paying', 'refunding'].includes(status)) return 'warning' as const
|
|
return 'info' as const
|
|
}
|
|
|
|
export function paymentBizTypeLabel(type: string) {
|
|
const labels: Record<string, string> = {
|
|
order_pay: '订单支付',
|
|
checkout_refund: '结账退款',
|
|
arbitration_refund: '仲裁退款',
|
|
admin_refund: '人工退款',
|
|
cancel_refund: '取消退款',
|
|
admin_close_refund: '客服关闭退款',
|
|
admin_seal_refund: '封存退款',
|
|
deposit_refund: '暂扣押金归还',
|
|
}
|
|
return labels[type] || type
|
|
}
|
|
|
|
export function paymentPaidAt(record: Pick<AdminPayment, 'paid_at' | 'updated_at' | 'created_at'>) {
|
|
return record.paid_at || record.updated_at || record.created_at
|
|
}
|