feat(withdrawal): 增加提现审核对账与历史记录

This commit is contained in:
yml2213
2026-11-02 19:02:30 +08:00
parent 5334c2b218
commit 1b23b9b14b
12 changed files with 1595 additions and 250 deletions
@@ -2,27 +2,32 @@ import { apiClient } from '@/shared/api/client'
import type { ApiResponse, PaginatedResult } from '@/shared/types/types'
// 管理员端提现详情接口
export interface WithdrawalDetail {
// 管理员端提现列表使用的轻量数据,不包含完整收款凭证和审核详情。
export interface WithdrawalListItem {
id: number
withdraw_no: string
user_id: number
distribution_site_id?: number
distribution_site_name?: string
distribution_site_code?: string
user_nickname: string
user_phone: string
amount_cent: number
fee_cent: number
actual_amount_cent: number
payment_account_id: number | null
account_type: string
account_name: string
account_no: string // 管理员可见完整账号
account_no: string
bank_name: string
status: string
created_at: string
}
// 管理员端提现完整详情接口
export interface WithdrawalDetail extends WithdrawalListItem {
distribution_site_code?: string
payment_account_id: number | null
bank_branch: string
certificate_urls: string[] // 收款二维码图片
status: string
reviewed_by: number | null
reviewed_by_name: string
reviewed_at: string | null
@@ -32,10 +37,79 @@ export interface WithdrawalDetail {
paid_at: string | null
payment_proof_url: string
payment_remark: string
created_at: string
updated_at: string
}
export interface WithdrawalReviewSummary {
owner_order_count: number
owner_pickup_count?: number
finalized_order_count: number
wallet_actual_income_cent: number
pickup_income_cent?: number
wallet_pickup_income_cent?: number
platform_managed_pickup_income_cent?: number
platform_managed_income_cent: number
withdrawal_count: number
withdrawn_amount_cent: number
pending_withdrawal_amount_cent: number
rejected_withdrawal_count: number
reconcile_difference_amount_cent: number
}
export interface WithdrawalReviewPickup {
id: number
pickup_no: string
listing_no: string
title: string
status: string
settlement_mode: string
offline_settlement_status: string
settle_amount_cent: number
settle_adjustment_cent: number
effective_settle_amount_cent: number
completed_at?: string
created_at: string
}
export interface WithdrawalReviewOrder {
id: number
order_no: string
listing_no: string
title: string
status: string
settlement_status: string
settlement_mode: string
rent_amount_cent: number
owner_actual_income_cent?: number
created_at: string
settled_at?: string
}
export interface WithdrawalReviewHistory {
id: number
withdraw_no: string
amount_cent: number
fee_cent: number
actual_amount_cent: number
status: string
created_at: string
reviewed_at?: string
paid_at?: string
}
export interface WithdrawalReviewContext {
summary: WithdrawalReviewSummary
orders: WithdrawalReviewOrder[]
order_page: number
order_page_size: number
pickups: WithdrawalReviewPickup[]
pickup_page: number
pickup_page_size: number
withdrawals: WithdrawalReviewHistory[]
withdrawal_page: number
withdrawal_page_size: number
}
// 审核请求
export interface ReviewWithdrawalRequest {
approved: boolean
@@ -56,7 +130,7 @@ export async function fetchAdminWithdrawals(params: {
page?: number
page_size?: number
}) {
const { data } = await apiClient.get<ApiResponse<PaginatedResult<WithdrawalDetail>>>(
const { data } = await apiClient.get<ApiResponse<PaginatedResult<WithdrawalListItem>>>(
'/admin/withdrawals',
{
params,
@@ -70,6 +144,22 @@ export async function fetchAdminWithdrawal(id: number) {
return data.data
}
export async function fetchAdminWithdrawalReviewContext(
id: number,
params: {
order_page?: number
pickup_page?: number
withdrawal_page?: number
page_size?: number
} = {}
) {
const { data } = await apiClient.get<ApiResponse<WithdrawalReviewContext>>(
`/admin/withdrawals/${id}/review-context`,
{ params }
)
return data.data
}
export async function reviewWithdrawal(id: number, req: ReviewWithdrawalRequest) {
const { data } = await apiClient.post<ApiResponse<WithdrawalDetail>>(
`/admin/withdrawals/${id}/review`,
@@ -11,7 +11,10 @@ import {
} from '@/features/admin/api/adminInvitations'
import { fetchAdminPayments, type AdminPayment } from '@/features/admin/api/adminPayments'
import { fetchAdminWalletLedger, type AdminWalletLedger } from '@/features/admin/api/adminWallet'
import { fetchAdminWithdrawals, type WithdrawalDetail } from '@/features/admin/api/adminWithdrawal'
import {
fetchAdminWithdrawals,
type WithdrawalListItem,
} from '@/features/admin/api/adminWithdrawal'
import type { AdminUserItem } from '@/features/admin/api/adminUsers'
import { fetchAdminOrders, type AdminOrderListItem } from '@/features/orders'
import { adminPath } from '@/shared/utils/adminPath'
@@ -87,7 +90,7 @@ const orderPage = ref(1)
const orderPageSize = ref(20)
const withdrawalLoading = ref(false)
const withdrawalRows = ref<WithdrawalDetail[]>([])
const withdrawalRows = ref<WithdrawalListItem[]>([])
const withdrawalTotal = ref(0)
const withdrawalPage = ref(1)
const withdrawalPageSize = ref(20)
@@ -1,20 +1,22 @@
<script setup lang="ts">
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { computed, ref, watch } from 'vue'
import type { WithdrawalDetail } from '@/features/admin/api/adminWithdrawal'
import { reviewWithdrawal, confirmPayment } from '@/features/admin/api/adminWithdrawal'
import { formatCent } from '@/shared/utils/money'
import { adminPath } from '@/shared/utils/adminPath'
import {
confirmPayment,
fetchAdminWithdrawalReviewContext,
reviewWithdrawal,
type WithdrawalDetail,
type WithdrawalReviewContext,
} from '@/features/admin/api/adminWithdrawal'
import AuthImage from '@/shared/components/business/AuthImage.vue'
const router = useRouter()
import { formatCent, formatCentWithSymbol } from '@/shared/utils/money'
import { orderStatusLabel, settlementStatusLabel } from '@/shared/utils/statusLabels'
import { formatDateTime } from '@/shared/utils/time'
const props = defineProps<{
modelValue: boolean
withdrawal: WithdrawalDetail | null
returnQuery?: Record<string, string>
}>()
const emit = defineEmits<{
@@ -23,18 +25,80 @@ const emit = defineEmits<{
}>()
const submitting = ref(false)
const contextLoading = ref(false)
const reviewContext = ref<WithdrawalReviewContext | null>(null)
const historyTab = ref<'orders' | 'pickups' | 'withdrawals'>('orders')
const orderPage = ref(1)
const pickupPage = ref(1)
const withdrawalPage = ref(1)
const contextPageSize = 5
/** 跳转订单管理页并预填号主搜索,快速查看该号主相关订单 */
function goToOwnerOrders() {
const pickupCount = computed(() => Number(reviewContext.value?.summary.owner_pickup_count ?? 0))
const historyBusinessCount = computed(
() => Number(reviewContext.value?.summary.owner_order_count ?? 0) + pickupCount.value
)
const platformPickupIncome = computed(() =>
Number(reviewContext.value?.summary.platform_managed_pickup_income_cent ?? 0)
)
const reconcileType = computed<'success' | 'error' | 'info'>(() => {
const difference = reviewContext.value?.summary.reconcile_difference_amount_cent ?? 0
if (difference === 0) return 'success'
if (difference < 0) return 'error'
return 'info'
})
const reconcileTitle = computed(() => {
const difference = reviewContext.value?.summary.reconcile_difference_amount_cent ?? 0
if (difference === 0) return '钱包收入与提现记录已对平'
if (difference < 0)
return `提现金额超过钱包实际收入 ${formatCentWithSymbol(Math.abs(difference))}`
return `仍有 ${formatCentWithSymbol(difference)} 钱包收入未提现或待处理`
})
watch(
() => [props.modelValue, props.withdrawal?.id] as const,
([visible]) => {
if (!visible || !props.withdrawal?.id) return
orderPage.value = 1
pickupPage.value = 1
withdrawalPage.value = 1
historyTab.value = 'orders'
void loadReviewContext()
}
)
async function loadReviewContext() {
if (!props.withdrawal) return
const keyword = props.withdrawal.user_phone?.trim() || String(props.withdrawal.user_id || '')
void router.push({
path: adminPath('orders'),
query: {
...props.returnQuery,
...(keyword ? { keyword } : {}),
},
})
contextLoading.value = true
try {
reviewContext.value = await fetchAdminWithdrawalReviewContext(props.withdrawal.id, {
order_page: orderPage.value,
pickup_page: pickupPage.value,
withdrawal_page: withdrawalPage.value,
page_size: contextPageSize,
})
} catch (error: any) {
reviewContext.value = null
ElMessage.error(error.response?.data?.message || '审核汇总加载失败')
} finally {
contextLoading.value = false
}
}
function changeOrderPage(page: number) {
orderPage.value = page
void loadReviewContext()
}
function changePickupPage(page: number) {
pickupPage.value = page
void loadReviewContext()
}
function changeWithdrawalPage(page: number) {
withdrawalPage.value = page
void loadReviewContext()
}
async function handleReview(approved: boolean) {
@@ -61,6 +125,7 @@ async function handleReview(approved: boolean) {
ElMessage.success(`审核${action}`)
emit('saved')
await loadReviewContext()
} catch (error: any) {
if (error !== 'cancel') {
ElMessage.error(error.response?.data?.message || '操作失败')
@@ -96,6 +161,7 @@ async function handleConfirmPayment() {
ElMessage.success('打款完成')
emit('saved')
await loadReviewContext()
} catch (error: any) {
if (error !== 'cancel') {
ElMessage.error(error.response?.data?.message || '操作失败')
@@ -136,204 +202,407 @@ function accountTypeLabel(type: string) {
}
return labels[type] || type
}
function settlementModeLabel(mode: string) {
return mode === 'platform_managed' ? '平台代管' : '钱包结算'
}
function pickupSettlementLabel(pickup: {
settlement_mode: string
offline_settlement_status: string
}) {
if (pickup.settlement_mode !== 'platform_managed') return '已入钱包'
return pickup.offline_settlement_status === 'settled' ? '已线下结算' : '待线下结算'
}
function incomeText(income?: number) {
return typeof income === 'number' ? formatCentWithSymbol(income) : '-'
}
</script>
<template>
<el-dialog
:model-value="modelValue"
title="提现详情"
width="700px"
title="提现详情与审核对账"
width="min(1320px, 96vw)"
top="4vh"
class="withdrawal-review-dialog"
@update:model-value="emit('update:modelValue', $event)"
>
<div v-if="withdrawal" class="withdrawal-detail">
<!-- 基本信息 -->
<el-descriptions :column="2" border>
<el-descriptions-item label="提现单号">
{{ withdrawal.withdraw_no }}
</el-descriptions-item>
<el-descriptions-item label="所属站点">
<el-tag v-if="withdrawal.distribution_site_id" type="warning" size="small">
{{
withdrawal.distribution_site_name || `分销站点 #${withdrawal.distribution_site_id}`
}}
<template v-if="withdrawal.distribution_site_code">
({{ withdrawal.distribution_site_code }})</template
>
</el-tag>
<el-tag v-else type="info" size="small">主站</el-tag>
</el-descriptions-item>
<el-descriptions-item label="状态">
<el-tag :type="statusType(withdrawal.status)">
{{ statusLabel(withdrawal.status) }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="申请时间">
{{ new Date(withdrawal.created_at).toLocaleString('zh-CN') }}
</el-descriptions-item>
</el-descriptions>
<!-- 用户信息 -->
<h3 style="margin-top: 20px">
用户信息
<el-button
size="small"
type="primary"
plain
style="margin-left: 12px"
@click="goToOwnerOrders"
>
查看该号主订单
</el-button>
</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="用户ID">
{{ withdrawal.user_id }}
</el-descriptions-item>
<el-descriptions-item label="昵称">
{{ withdrawal.user_nickname }}
</el-descriptions-item>
<el-descriptions-item label="手机号" :span="2">
{{ withdrawal.user_phone }}
</el-descriptions-item>
</el-descriptions>
<!-- 金额信息 -->
<h3 style="margin-top: 20px">金额信息</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="提现金额">
<span style="color: #f56c6c; font-weight: 600; font-size: 16px">
¥{{ formatCent(withdrawal.amount_cent) }}
</span>
</el-descriptions-item>
<el-descriptions-item label="手续费">
¥{{ formatCent(withdrawal.fee_cent) }}
</el-descriptions-item>
<el-descriptions-item label="实际到账" :span="2">
<span style="color: #67c23a; font-weight: 600; font-size: 16px">
¥{{ formatCent(withdrawal.actual_amount_cent) }}
</span>
</el-descriptions-item>
</el-descriptions>
<!-- 收款账号信息 -->
<h3 style="margin-top: 20px">收款账号信息</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="账号类型">
<el-tag>{{ accountTypeLabel(withdrawal.account_type) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="账户名">
{{ withdrawal.account_name }}
</el-descriptions-item>
<el-descriptions-item label="账号" :span="2">
<span style="font-family: monospace; font-weight: 600">
{{ withdrawal.account_no }}
</span>
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.bank_name" label="银行名称">
{{ withdrawal.bank_name }}
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.bank_branch" label="开户支行">
{{ withdrawal.bank_branch }}
</el-descriptions-item>
<el-descriptions-item
v-if="withdrawal.certificate_urls && withdrawal.certificate_urls.length > 0"
label="收款二维码"
:span="2"
>
<div style="display: flex; gap: 8px; flex-wrap: wrap">
<AuthImage
v-for="(url, idx) in withdrawal.certificate_urls"
:key="idx"
:source="url"
:admin="true"
:preview-src-list="withdrawal.certificate_urls"
fit="cover"
:image-style="{
width: '100px',
height: '100px',
borderRadius: '4px',
cursor: 'pointer',
}"
/>
</div>
</el-descriptions-item>
</el-descriptions>
<!-- 审核信息 -->
<div v-if="withdrawal.reviewed_at">
<h3 style="margin-top: 20px">审核信息</h3>
<div v-if="withdrawal" class="withdrawal-layout">
<main class="withdrawal-detail">
<el-descriptions :column="2" border>
<el-descriptions-item label="审核人">
{{ withdrawal.reviewed_by_name }}
<el-descriptions-item label="提现单号">
{{ withdrawal.withdraw_no }}
</el-descriptions-item>
<el-descriptions-item label="审核时间">
{{ new Date(withdrawal.reviewed_at).toLocaleString('zh-CN') }}
<el-descriptions-item label="所属站点">
<el-tag v-if="withdrawal.distribution_site_id" type="warning" size="small">
{{
withdrawal.distribution_site_name || `分销站点 #${withdrawal.distribution_site_id}`
}}
</el-tag>
<el-tag v-else type="info" size="small">主站</el-tag>
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.review_remark" label="审核备注" :span="2">
{{ withdrawal.review_remark }}
<el-descriptions-item label="状态">
<el-tag :type="statusType(withdrawal.status)">
{{ statusLabel(withdrawal.status) }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="申请时间">
{{ formatDateTime(withdrawal.created_at) }}
</el-descriptions-item>
</el-descriptions>
</div>
<!-- 打款信息 -->
<div v-if="withdrawal.paid_at">
<h3 style="margin-top: 20px">打款信息</h3>
<h3>用户信息</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="打款人">
{{ withdrawal.paid_by_name }}
<el-descriptions-item label="用户ID">
{{ withdrawal.user_id }}
</el-descriptions-item>
<el-descriptions-item label="打款时间">
{{ new Date(withdrawal.paid_at).toLocaleString('zh-CN') }}
<el-descriptions-item label="昵称">
{{ withdrawal.user_nickname || '-' }}
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.payment_remark" label="打款备注" :span="2">
{{ withdrawal.payment_remark }}
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.payment_proof_url" label="打款凭证" :span="2">
<AuthImage
:source="withdrawal.payment_proof_url"
admin
alt="打款凭证"
class="certificate-image"
:preview-src-list="[withdrawal.payment_proof_url]"
/>
<el-descriptions-item label="手机号" :span="2">
{{ withdrawal.user_phone || '-' }}
</el-descriptions-item>
</el-descriptions>
</div>
<!-- 操作提示 -->
<el-alert
v-if="withdrawal.status === 'pending'"
type="warning"
:closable="false"
show-icon
style="margin-top: 20px"
>
<template #title>
<div style="font-size: 13px">
请仔细核对账号信息后进行审核。审核通过后,需要手动转账到用户账号,并确认打款完成。
</div>
</template>
</el-alert>
<h3>金额信息</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="提现金额">
<span class="amount-danger">¥{{ formatCent(withdrawal.amount_cent) }}</span>
</el-descriptions-item>
<el-descriptions-item label="手续费">
¥{{ formatCent(withdrawal.fee_cent) }}
</el-descriptions-item>
<el-descriptions-item label="实际到账" :span="2">
<span class="amount-success">¥{{ formatCent(withdrawal.actual_amount_cent) }}</span>
</el-descriptions-item>
</el-descriptions>
<el-alert
v-if="withdrawal.status === 'processing'"
type="info"
:closable="false"
show-icon
style="margin-top: 20px"
>
<template #title>
<div style="font-size: 13px">
请手动转账
<strong>¥{{ formatCent(withdrawal.actual_amount_cent) }}</strong> 到用户收款账号,
完成后点击"确认打款"按钮。
</div>
<h3>收款账号信息</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="账号类型">
<el-tag>{{ accountTypeLabel(withdrawal.account_type) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="账户名">
{{ withdrawal.account_name || '-' }}
</el-descriptions-item>
<el-descriptions-item label="账号" :span="2">
<span class="mono-account">{{ withdrawal.account_no || '-' }}</span>
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.bank_name" label="银行名称">
{{ withdrawal.bank_name }}
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.bank_branch" label="开户支行">
{{ withdrawal.bank_branch }}
</el-descriptions-item>
<el-descriptions-item
v-if="withdrawal.certificate_urls && withdrawal.certificate_urls.length > 0"
label="收款二维码"
:span="2"
>
<div class="certificate-list">
<AuthImage
v-for="(url, idx) in withdrawal.certificate_urls"
:key="idx"
:source="url"
:admin="true"
:preview-src-list="withdrawal.certificate_urls"
fit="cover"
:image-style="{
width: '100px',
height: '100px',
borderRadius: '4px',
cursor: 'pointer',
}"
/>
</div>
</el-descriptions-item>
</el-descriptions>
<template v-if="withdrawal.reviewed_at">
<h3>审核信息</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="审核人">
{{ withdrawal.reviewed_by_name || '-' }}
</el-descriptions-item>
<el-descriptions-item label="审核时间">
{{ formatDateTime(withdrawal.reviewed_at) }}
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.review_remark" label="审核备注" :span="2">
{{ withdrawal.review_remark }}
</el-descriptions-item>
</el-descriptions>
</template>
</el-alert>
<template v-if="withdrawal.paid_at">
<h3>打款信息</h3>
<el-descriptions :column="2" border>
<el-descriptions-item label="打款人">
{{ withdrawal.paid_by_name || '-' }}
</el-descriptions-item>
<el-descriptions-item label="打款时间">
{{ formatDateTime(withdrawal.paid_at) }}
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.payment_remark" label="打款备注" :span="2">
{{ withdrawal.payment_remark }}
</el-descriptions-item>
<el-descriptions-item v-if="withdrawal.payment_proof_url" label="打款凭证" :span="2">
<AuthImage
:source="withdrawal.payment_proof_url"
admin
alt="打款凭证"
class="certificate-image"
:preview-src-list="[withdrawal.payment_proof_url]"
/>
</el-descriptions-item>
</el-descriptions>
</template>
<el-alert
v-if="withdrawal.status === 'pending'"
type="warning"
:closable="false"
show-icon
class="review-alert"
>
请核对右侧历史订单、最终实际收入和历史提现后再审核。审核通过后,需要手动转账并确认打款。
</el-alert>
<el-alert
v-if="withdrawal.status === 'processing'"
type="info"
:closable="false"
show-icon
class="review-alert"
>
请手动转账
<strong>¥{{ formatCent(withdrawal.actual_amount_cent) }}</strong>
到用户收款账号,完成后点击“确认打款”。
</el-alert>
</main>
<aside v-loading="contextLoading" class="review-panel">
<div class="review-panel__header">
<div>
<strong>用户审核对账</strong>
<span>最终结算收入与历史提现</span>
</div>
<el-tag type="info" effect="plain">UID {{ withdrawal.user_id }}</el-tag>
</div>
<template v-if="reviewContext">
<div class="review-metrics">
<div class="review-metric">
<span>历史订单 / 提号</span>
<strong>{{ historyBusinessCount }}</strong>
<small>
订单 {{ reviewContext.summary.owner_order_count }} · 提号
{{ pickupCount }}
</small>
</div>
<div class="review-metric">
<span>钱包实际收入</span>
<strong class="income">{{
formatCentWithSymbol(reviewContext.summary.wallet_actual_income_cent)
}}</strong>
<small>可用于提现核对</small>
</div>
<div class="review-metric">
<span>历史已打款</span>
<strong>{{
formatCentWithSymbol(reviewContext.summary.withdrawn_amount_cent)
}}</strong>
<small>共 {{ reviewContext.summary.withdrawal_count }} 笔提现</small>
</div>
<div class="review-metric">
<span>待审核 / 待打款</span>
<strong>{{
formatCentWithSymbol(reviewContext.summary.pending_withdrawal_amount_cent)
}}</strong>
<small>拒绝 {{ reviewContext.summary.rejected_withdrawal_count }} 笔</small>
</div>
</div>
<div class="offline-income">
<div>
<span>平台代管线下结算</span>
<small>
订单
{{
formatCentWithSymbol(
reviewContext.summary.platform_managed_income_cent - platformPickupIncome
)
}}
· 提号
{{ formatCentWithSymbol(platformPickupIncome) }}
</small>
</div>
<strong>{{
formatCentWithSymbol(reviewContext.summary.platform_managed_income_cent)
}}</strong>
</div>
<el-alert :type="reconcileType" :closable="false" show-icon class="reconcile-alert">
<template #title>
<div class="reconcile-title">
<span>{{ reconcileTitle }}</span>
<strong>
{{ formatCentWithSymbol(reviewContext.summary.reconcile_difference_amount_cent) }}
</strong>
</div>
</template>
</el-alert>
<el-tabs v-model="historyTab" class="review-tabs">
<el-tab-pane label="历史订单" name="orders">
<el-table size="small" :data="reviewContext.orders" empty-text="暂无号主订单">
<el-table-column label="上架编号 / 订单号" min-width="190">
<template #default="{ row }">
<div class="listing-cell">
<strong class="mono-code">{{ row.listing_no }}</strong>
<small>{{ row.order_no }}</small>
<span>{{ row.title }} · {{ settlementModeLabel(row.settlement_mode) }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="最终收入" width="92" align="right">
<template #default="{ row }">
<strong v-if="typeof row.owner_actual_income_cent === 'number'" class="income">
{{ incomeText(row.owner_actual_income_cent) }}
</strong>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="状态" width="92">
<template #default="{ row }">
<span>{{ orderStatusLabel(row.status) }}</span>
<small class="status-sub">{{
settlementStatusLabel(row.settlement_status)
}}</small>
</template>
</el-table-column>
<el-table-column label="结算时间" width="126">
<template #default="{ row }">
{{ formatDateTime(row.settled_at || row.created_at) }}
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="reviewContext.summary.owner_order_count > contextPageSize"
small
background
layout="prev, pager, next"
:page-size="contextPageSize"
:current-page="orderPage"
:total="reviewContext.summary.owner_order_count"
class="review-pagination"
@current-change="changeOrderPage"
/>
</el-tab-pane>
<el-tab-pane label="线下提号" name="pickups">
<el-table size="small" :data="reviewContext.pickups" empty-text="暂无线下提号记录">
<el-table-column label="上架编号 / 提号编号" min-width="190">
<template #default="{ row }">
<div class="listing-cell">
<strong class="mono-code">{{ row.listing_no }}</strong>
<small>{{ row.pickup_no }}</small>
<span>{{ row.title }} · {{ settlementModeLabel(row.settlement_mode) }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="最终结算" width="96" align="right">
<template #default="{ row }">
<strong class="income">
{{ formatCentWithSymbol(row.effective_settle_amount_cent) }}
</strong>
<small v-if="row.settle_adjustment_cent" class="adjustment-sub">
调整 {{ formatCentWithSymbol(row.settle_adjustment_cent) }}
</small>
</template>
</el-table-column>
<el-table-column label="状态" width="94">
<template #default="{ row }">
<span>已完成</span>
<small class="status-sub">{{ pickupSettlementLabel(row) }}</small>
</template>
</el-table-column>
<el-table-column label="完成时间" width="126">
<template #default="{ row }">
{{ formatDateTime(row.completed_at || row.created_at) }}
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="pickupCount > contextPageSize"
small
background
layout="prev, pager, next"
:page-size="contextPageSize"
:current-page="pickupPage"
:total="pickupCount"
class="review-pagination"
@current-change="changePickupPage"
/>
</el-tab-pane>
<el-tab-pane label="历史提现" name="withdrawals">
<el-table size="small" :data="reviewContext.withdrawals" empty-text="暂无提现记录">
<el-table-column label="提现单号" min-width="190">
<template #default="{ row }">
<div class="listing-cell">
<strong class="mono-code">{{ row.withdraw_no }}</strong>
<small v-if="row.id === withdrawal.id">
<el-tag size="small" type="warning" effect="plain">本单</el-tag>
</small>
</div>
</template>
</el-table-column>
<el-table-column label="申请 / 到账" width="105" align="right">
<template #default="{ row }">
<div class="amount-stack">
<span>{{ formatCentWithSymbol(row.amount_cent) }}</span>
<small>到账 {{ formatCentWithSymbol(row.actual_amount_cent) }}</small>
</div>
</template>
</el-table-column>
<el-table-column label="状态" width="95">
<template #default="{ row }">
<el-tag size="small" :type="statusType(row.status)">
{{ statusLabel(row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="申请 / 打款时间" width="145">
<template #default="{ row }">
<div class="time-stack">
<span>{{ formatDateTime(row.created_at) }}</span>
<small v-if="row.paid_at">{{ formatDateTime(row.paid_at) }}</small>
</div>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="reviewContext.summary.withdrawal_count > contextPageSize"
small
background
layout="prev, pager, next"
:page-size="contextPageSize"
:current-page="withdrawalPage"
:total="reviewContext.summary.withdrawal_count"
class="review-pagination"
@current-change="changeWithdrawalPage"
/>
</el-tab-pane>
</el-tabs>
</template>
<el-empty v-else-if="!contextLoading" description="暂无审核汇总数据" :image-size="80" />
</aside>
</div>
<template #footer>
<div style="display: flex; justify-content: space-between; width: 100%">
<div class="dialog-footer">
<div>
<el-button
v-if="withdrawal?.status === 'pending'"
@@ -360,13 +629,20 @@ function accountTypeLabel(type: string) {
确认打款
</el-button>
</div>
<el-button @click="emit('update:modelValue', false)"> 关闭 </el-button>
<el-button @click="emit('update:modelValue', false)">关闭</el-button>
</div>
</template>
</el-dialog>
</template>
<style scoped>
.withdrawal-layout {
display: grid;
grid-template-columns: minmax(0, 1fr) 560px;
gap: 20px;
align-items: start;
}
.withdrawal-detail h3 {
margin: 20px 0 12px;
font-size: 15px;
@@ -374,7 +650,223 @@ function accountTypeLabel(type: string) {
color: #303133;
}
.amount-danger,
.amount-success {
font-size: 16px;
font-weight: 600;
}
.amount-danger {
color: #f56c6c;
}
.amount-success,
.income {
color: #16a34a;
}
.mono-account,
.mono-code {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.certificate-list {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.review-alert {
margin-top: 20px;
}
.review-panel {
position: sticky;
top: 0;
min-height: 420px;
padding: 16px;
border: 1px solid #e2e8f0;
border-radius: 12px;
background: linear-gradient(180deg, #f8fafc 0%, #ffffff 45%);
}
.review-panel__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
margin-bottom: 14px;
}
.review-panel__header > div {
display: flex;
flex-direction: column;
gap: 3px;
}
.review-panel__header strong {
font-size: 16px;
color: #0f172a;
}
.review-panel__header span {
font-size: 12px;
color: #64748b;
}
.review-metrics {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.review-metric {
display: flex;
min-height: 82px;
padding: 12px;
flex-direction: column;
justify-content: center;
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #fff;
}
.review-metric span,
.review-metric small,
.offline-income span {
color: #64748b;
font-size: 12px;
}
.review-metric strong {
margin: 4px 0 2px;
color: #0f172a;
font-size: 19px;
}
.offline-income {
display: flex;
margin-top: 10px;
padding: 9px 12px;
align-items: center;
justify-content: space-between;
border-radius: 8px;
background: #fffbeb;
}
.offline-income strong {
color: #b45309;
}
.offline-income > div {
display: flex;
flex-direction: column;
gap: 2px;
}
.offline-income small {
color: #b45309;
font-size: 11px;
}
.reconcile-alert {
margin: 12px 0;
}
.reconcile-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.review-tabs :deep(.el-tabs__header) {
margin-bottom: 8px;
}
.review-tabs :deep(.el-scrollbar__bar) {
display: none;
}
.listing-cell {
display: flex;
min-width: 0;
flex-direction: column;
gap: 2px;
}
.listing-cell strong {
color: #2563eb;
font-size: 13px;
}
.listing-cell small,
.listing-cell span,
.status-sub {
overflow: hidden;
color: #64748b;
font-size: 11px;
text-overflow: ellipsis;
white-space: nowrap;
}
.status-sub {
display: block;
margin-top: 2px;
}
.time-stack {
display: flex;
flex-direction: column;
gap: 2px;
}
.amount-stack {
display: flex;
flex-direction: column;
gap: 2px;
}
.time-stack small,
.adjustment-sub,
.amount-stack small {
color: #94a3b8;
}
.adjustment-sub {
display: block;
margin-top: 2px;
font-size: 10px;
}
.review-pagination {
margin-top: 10px;
justify-content: flex-end;
}
.dialog-footer {
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
}
:deep(.el-descriptions__label) {
width: 120px;
}
:global(.withdrawal-review-dialog .el-dialog__body) {
max-height: none;
overflow: visible;
}
@media (max-width: 980px) {
.withdrawal-layout {
grid-template-columns: 1fr;
}
.review-panel {
position: static;
}
}
</style>
@@ -12,26 +12,26 @@ import {
Wallet,
} from '@element-plus/icons-vue'
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import {
fetchAdminWithdrawals,
fetchAdminWithdrawal,
reviewWithdrawal,
confirmPayment,
type WithdrawalDetail,
type WithdrawalListItem,
} from '@/features/admin/api/adminWithdrawal'
import { formatCentWithSymbol } from '@/shared/utils/money'
import { formatDateTime } from '@/shared/utils/time'
import { adminPath } from '@/shared/utils/adminPath'
import AdminTablePagination from '../components/AdminTablePagination.vue'
import WithdrawalDetailDialog from '../components/WithdrawalDetailDialog.vue'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const withdrawals = ref<WithdrawalDetail[]>([])
const withdrawals = ref<WithdrawalListItem[]>([])
const total = ref(0)
const currentPage = ref(1)
const pageSize = ref(20)
@@ -43,6 +43,7 @@ const filters = ref({
const showDetailDialog = ref(false)
const selectedWithdrawal = ref<WithdrawalDetail | null>(null)
const detailLoading = ref(false)
const statusOptions = [
{ label: '全部状态', value: '' },
@@ -53,17 +54,6 @@ const statusOptions = [
{ label: '已取消', value: 'cancelled' },
]
const withdrawalReturnQuery = computed<Record<string, string>>(() => {
const query: Record<string, string> = {
from: 'withdrawals',
withdrawal_page: String(currentPage.value),
withdrawal_page_size: String(pageSize.value),
}
if (filters.value.status) query.withdrawal_status = filters.value.status
if (filters.value.user_id) query.withdrawal_user_id = String(filters.value.user_id)
return query
})
const pendingCount = computed(() => withdrawals.value.filter(w => w.status === 'pending').length)
const processingCount = computed(
() => withdrawals.value.filter(w => w.status === 'processing').length
@@ -135,23 +125,20 @@ function resetFilters() {
void loadWithdrawals()
}
function openDetail(withdrawal: WithdrawalDetail) {
selectedWithdrawal.value = withdrawal
showDetailDialog.value = true
async function openDetail(withdrawal: WithdrawalListItem) {
if (detailLoading.value) return
detailLoading.value = true
try {
selectedWithdrawal.value = await fetchAdminWithdrawal(withdrawal.id)
showDetailDialog.value = true
} catch (error: any) {
ElMessage.error(error.response?.data?.message || '提现详情加载失败')
} finally {
detailLoading.value = false
}
}
function goToOwnerOrders(withdrawal: WithdrawalDetail) {
const keyword = withdrawal.user_phone?.trim() || String(withdrawal.user_id || '')
void router.push({
path: adminPath('orders'),
query: {
...withdrawalReturnQuery.value,
...(keyword ? { keyword } : {}),
},
})
}
async function handleReview(withdrawal: WithdrawalDetail, approved: boolean) {
async function handleReview(withdrawal: WithdrawalListItem, approved: boolean) {
const action = approved ? '通过' : '拒绝'
try {
const { value: remark } = await ElMessageBox.prompt(
@@ -179,7 +166,7 @@ async function handleReview(withdrawal: WithdrawalDetail, approved: boolean) {
}
}
async function handleConfirmPayment(withdrawal: WithdrawalDetail) {
async function handleConfirmPayment(withdrawal: WithdrawalListItem) {
try {
const { value: remark } = await ElMessageBox.prompt(
'请输入打款备注(如:已通过支付宝/微信转账)',
@@ -438,13 +425,18 @@ function money(cent: number | undefined | null) {
</template>
</el-table-column>
<el-table-column label="操作" width="240" fixed="right" align="center">
<el-table-column label="操作" width="190" fixed="right" align="center">
<template #default="{ row }">
<div class="action-cell">
<el-button link type="primary" :icon="View" @click="openDetail(row)">
<el-button
link
type="primary"
:icon="View"
:loading="detailLoading"
@click="openDetail(row)"
>
详情
</el-button>
<el-button link type="primary" @click="goToOwnerOrders(row)"> 号主订单 </el-button>
<el-button
v-if="row.status === 'pending'"
link
@@ -488,7 +480,6 @@ function money(cent: number | undefined | null) {
<WithdrawalDetailDialog
v-model="showDetailDialog"
:withdrawal="selectedWithdrawal"
:return-query="withdrawalReturnQuery"
@saved="onDetailDialogSaved"
/>
</div>