优化订单支付
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
type Order,
|
||||
type RefundStatus,
|
||||
} from '@/features/orders'
|
||||
import { fetchAdminPayments, type AdminPayment } from '@/features/admin/api/adminPayments'
|
||||
import { handoffStatusLabel, orderStatusLabel } from '@/utils/statusLabels'
|
||||
import { formatDateTime } from '@/utils/time'
|
||||
import { formatListingNo } from '@/utils/listingDisplay'
|
||||
@@ -23,6 +24,7 @@ const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
const order = ref<Order | null>(null)
|
||||
const handoffRecords = ref<HandoffRecord[]>([])
|
||||
const paymentRecords = ref<AdminPayment[]>([])
|
||||
const actionType = ref<'close' | 'abnormal' | ''>('')
|
||||
const reason = ref('')
|
||||
const refundStatus = ref<RefundStatus | null>(null)
|
||||
@@ -44,6 +46,7 @@ async function loadOrder() {
|
||||
try {
|
||||
order.value = await fetchAdminOrder(String(route.params.id))
|
||||
handoffRecords.value = await fetchAdminHandoffRecords(String(route.params.id))
|
||||
paymentRecords.value = (await fetchAdminPayments({ order_id: String(route.params.id) })).items
|
||||
await loadRefundStatus()
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -124,12 +127,49 @@ async function handleRefund() {
|
||||
function refundStatusLabel(status: string) {
|
||||
const map: Record<string, string> = {
|
||||
pending: '待退款',
|
||||
refunding: '退款中',
|
||||
refunded: '已退款',
|
||||
failed: '退款失败',
|
||||
}
|
||||
return map[status] || status || '未退款'
|
||||
}
|
||||
|
||||
function paymentStatusLabel(status: string) {
|
||||
const map: Record<string, string> = {
|
||||
created: '已创建',
|
||||
paying: '支付中',
|
||||
paid: '已支付',
|
||||
refunding: '退款中',
|
||||
refunded: '已退款',
|
||||
failed: '失败',
|
||||
}
|
||||
return map[status] || status
|
||||
}
|
||||
|
||||
function paymentStatusType(status: string) {
|
||||
if (['paid', 'refunded'].includes(status)) return 'success'
|
||||
if (status === 'failed') return 'danger'
|
||||
if (['paying', 'refunding'].includes(status)) return 'warning'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
function paymentBizTypeLabel(type: string) {
|
||||
const map: Record<string, string> = {
|
||||
order_pay: '订单支付',
|
||||
checkout_refund: '结账退款',
|
||||
arbitration_refund: '仲裁退款',
|
||||
admin_refund: '人工退款',
|
||||
cancel_refund: '取消退款',
|
||||
admin_close_refund: '客服关闭退款',
|
||||
wallet_recharge: '钱包充值',
|
||||
}
|
||||
return map[type] || type
|
||||
}
|
||||
|
||||
function moneyCent(value: number) {
|
||||
return `¥${(Number(value || 0) / 100).toFixed(2)}`
|
||||
}
|
||||
|
||||
function formatHandoffRecordType(type: string) {
|
||||
const typeMap: Record<string, string> = {
|
||||
owner_handoff: '卖家交接',
|
||||
@@ -137,6 +177,7 @@ function formatHandoffRecordType(type: string) {
|
||||
owner_counter_checkout: '卖家反驳结账',
|
||||
renter_confirm_checkout: '买家确认结账',
|
||||
owner_accept_checkout: '卖家接受结账',
|
||||
admin_arbitration: '客服仲裁',
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
@@ -214,6 +255,27 @@ function formatHandoffRecordType(type: string) {
|
||||
<p>预计截止:{{ formatDateTime(orderEstimatedEndAt(), '未设置') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="order-panel dashboard-panel">
|
||||
<h2>支付与退款</h2>
|
||||
<el-empty v-if="paymentRecords.length === 0" description="暂无支付流水" />
|
||||
<div v-for="record in paymentRecords" :key="record.id" class="timeline-item">
|
||||
<strong>
|
||||
{{ paymentBizTypeLabel(record.biz_type) }} · {{ moneyCent(record.amount_cent) }}
|
||||
</strong>
|
||||
<p>
|
||||
{{ record.provider || '-' }} · {{ record.third_order_id }}
|
||||
<span v-if="record.provider_order_id"> / {{ record.provider_order_id }}</span>
|
||||
</p>
|
||||
<p v-if="record.error_message" class="danger-text">
|
||||
{{ record.error_code }} {{ record.error_message }}
|
||||
</p>
|
||||
<el-tag :type="paymentStatusType(record.status)">
|
||||
{{ paymentStatusLabel(record.status) }}
|
||||
</el-tag>
|
||||
<span>{{ formatDateTime(record.created_at) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="order-panel dashboard-panel">
|
||||
<h2>交接记录</h2>
|
||||
<el-empty v-if="handoffRecords.length === 0" description="暂无交接记录" />
|
||||
|
||||
Reference in New Issue
Block a user