726 lines
19 KiB
Vue
726 lines
19 KiB
Vue
<script setup lang="ts">
|
|
import { Document, DocumentChecked, Refresh, Search, View } from '@element-plus/icons-vue'
|
|
import { onMounted, reactive, ref } from 'vue'
|
|
|
|
import {
|
|
fetchFinanceDetails,
|
|
SETTLEMENT_DIFF_THRESHOLD_CENT,
|
|
type FinanceDetail,
|
|
} from '@/features/admin/api/adminFinance'
|
|
import { adminPath } from '@/shared/utils/adminPath'
|
|
import { formatCentWithSymbol } from '@/shared/utils/money'
|
|
import { orderStatusLabel } from '@/shared/utils/statusLabels'
|
|
import { formatDateTime, formatInputDate } from '@/shared/utils/time'
|
|
import AdminTablePagination from '../components/AdminTablePagination.vue'
|
|
|
|
const loading = ref(false)
|
|
const details = ref<FinanceDetail[]>([])
|
|
const currentPage = ref(1)
|
|
const currentPageSize = ref(20)
|
|
const total = ref(0)
|
|
|
|
const filters = reactive({
|
|
start_date: defaultStartDate(),
|
|
end_date: defaultEndDate(),
|
|
date_type: 'settled',
|
|
order_no: '',
|
|
user_id: '',
|
|
order_status: '',
|
|
settlement_status: '',
|
|
settlement_mode: '',
|
|
offline_settlement_status: '',
|
|
})
|
|
|
|
onMounted(loadDetails)
|
|
|
|
async function loadDetails() {
|
|
loading.value = true
|
|
try {
|
|
const result = await fetchFinanceDetails({
|
|
...filters,
|
|
page: currentPage.value,
|
|
page_size: currentPageSize.value,
|
|
})
|
|
details.value = result.items
|
|
total.value = result.total
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
|
|
function resetFilters() {
|
|
filters.start_date = defaultStartDate()
|
|
filters.end_date = defaultEndDate()
|
|
filters.date_type = 'settled'
|
|
filters.order_no = ''
|
|
filters.user_id = ''
|
|
filters.order_status = ''
|
|
filters.settlement_status = ''
|
|
filters.settlement_mode = ''
|
|
filters.offline_settlement_status = ''
|
|
currentPage.value = 1
|
|
void loadDetails()
|
|
}
|
|
|
|
async function handlePageChange() {
|
|
await loadDetails()
|
|
}
|
|
|
|
function moneyCent(value: number | undefined | null) {
|
|
return formatCentWithSymbol(value || 0)
|
|
}
|
|
|
|
function financeStatusLabel(status: string) {
|
|
const map: Record<string, string> = {
|
|
normal: '正常',
|
|
refund_pending: '退款中',
|
|
refund_failed: '退款失败',
|
|
settlement_diff: '结算差异',
|
|
offline_settlement_pending: '待线下结算',
|
|
}
|
|
return map[status] || status
|
|
}
|
|
|
|
function financeStatusType(status: string): 'success' | 'danger' | 'warning' | 'info' {
|
|
if (status === 'normal') return 'success'
|
|
if (status === 'settlement_diff' || status === 'refund_failed') return 'danger'
|
|
if (status === 'refund_pending' || status === 'offline_settlement_pending') return 'warning'
|
|
return 'info'
|
|
}
|
|
|
|
function settlementStatusLabel(status: string) {
|
|
const map: Record<string, string> = {
|
|
unsettled: '未结算',
|
|
settling: '结算中',
|
|
settled: '已结算',
|
|
}
|
|
return map[status] || status || '-'
|
|
}
|
|
|
|
function isPlatformManaged(row: FinanceDetail) {
|
|
return row.handoff_mode === 'platform' || row.settlement_mode === 'platform_managed'
|
|
}
|
|
|
|
function settlementModeLabel(row: FinanceDetail) {
|
|
return isPlatformManaged(row) ? '平台代管' : '号主钱包'
|
|
}
|
|
|
|
function offlineSettlementStatusLabel(status: string) {
|
|
const map: Record<string, string> = {
|
|
none: '无需线下结算',
|
|
pending: '待线下结算',
|
|
settled: '已线下结算',
|
|
}
|
|
return map[status] || status || '-'
|
|
}
|
|
|
|
function defaultStartDate() {
|
|
const date = new Date()
|
|
date.setDate(date.getDate() - 29)
|
|
return formatInputDate(date)
|
|
}
|
|
|
|
function defaultEndDate() {
|
|
return formatInputDate(new Date())
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="finance-page-container">
|
|
<!-- 页面头部卡片 -->
|
|
<header class="page-header-card">
|
|
<div class="header-main">
|
|
<div class="title-group">
|
|
<div class="eyebrow-tag">
|
|
<el-icon><Document /></el-icon>
|
|
<span>FINANCE DETAILS</span>
|
|
</div>
|
|
<h1 class="page-title">财务明细</h1>
|
|
<p class="page-subtitle">
|
|
按订单维度精细核对收款、退款、平台利润扣费、号主应得与实际入账差异。
|
|
</p>
|
|
</div>
|
|
|
|
<div class="toolbar-actions">
|
|
<el-button :icon="Refresh" @click="resetFilters">重置</el-button>
|
|
<el-button type="primary" :icon="Search" :loading="loading" @click="loadDetails">
|
|
查询
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- 筛选面板卡片 -->
|
|
<section class="section-card filter-card">
|
|
<el-form class="filter-grid" label-position="top" @keyup.enter="loadDetails">
|
|
<el-form-item label="日期类型">
|
|
<el-select v-model="filters.date_type" class="full-control">
|
|
<el-option label="结算日期" value="settled" />
|
|
<el-option label="线下打款日期" value="offline_settled" />
|
|
<el-option label="下单日期" value="created" />
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="开始日期">
|
|
<el-date-picker
|
|
v-model="filters.start_date"
|
|
class="full-control"
|
|
type="date"
|
|
value-format="YYYY-MM-DD"
|
|
:clearable="false"
|
|
/>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="结束日期">
|
|
<el-date-picker
|
|
v-model="filters.end_date"
|
|
class="full-control"
|
|
type="date"
|
|
value-format="YYYY-MM-DD"
|
|
:clearable="false"
|
|
/>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="订单号">
|
|
<el-input v-model="filters.order_no" clearable placeholder="按订单号检索" />
|
|
</el-form-item>
|
|
|
|
<el-form-item label="用户 ID">
|
|
<el-input v-model="filters.user_id" clearable placeholder="租客或号主 ID" />
|
|
</el-form-item>
|
|
|
|
<el-form-item label="订单状态">
|
|
<el-select
|
|
v-model="filters.order_status"
|
|
clearable
|
|
placeholder="全部状态"
|
|
class="full-control"
|
|
>
|
|
<el-option label="待支付" value="pending_payment" />
|
|
<el-option label="使用中" value="renting" />
|
|
<el-option label="待结账" value="pending_checkout_confirm" />
|
|
<el-option label="已完成" value="completed" />
|
|
<el-option label="已关闭" value="closed" />
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="结算状态">
|
|
<el-select
|
|
v-model="filters.settlement_status"
|
|
clearable
|
|
placeholder="全部结算"
|
|
class="full-control"
|
|
>
|
|
<el-option label="未结算" value="unsettled" />
|
|
<el-option label="已结算" value="settled" />
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="结算模式">
|
|
<el-select
|
|
v-model="filters.settlement_mode"
|
|
clearable
|
|
placeholder="全部模式"
|
|
class="full-control"
|
|
>
|
|
<el-option label="号主钱包" value="owner_wallet" />
|
|
<el-option label="平台代管" value="platform_managed" />
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="线下状态">
|
|
<el-select
|
|
v-model="filters.offline_settlement_status"
|
|
clearable
|
|
placeholder="全部状态"
|
|
class="full-control"
|
|
>
|
|
<el-option label="待线下结算" value="pending" />
|
|
<el-option label="已线下结算" value="settled" />
|
|
<el-option label="无需线下结算" value="none" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-form>
|
|
</section>
|
|
|
|
<!-- 财务明细数据表格 -->
|
|
<section class="section-card table-section-card">
|
|
<div class="table-card-header">
|
|
<div class="table-header-title">
|
|
<el-icon class="header-icon"><DocumentChecked /></el-icon>
|
|
<span>订单财务流水台账</span>
|
|
</div>
|
|
<span class="count-badge">共 {{ total }} 条订单明细</span>
|
|
</div>
|
|
|
|
<div class="table-container">
|
|
<el-table
|
|
v-loading="loading"
|
|
class="custom-enterprise-table"
|
|
:data="details"
|
|
stripe
|
|
empty-text="暂无财务明细记录"
|
|
>
|
|
<!-- 订单标识 -->
|
|
<el-table-column label="订单信息" min-width="190" fixed="left">
|
|
<template #default="{ row }">
|
|
<div class="order-cell">
|
|
<RouterLink class="order-no-link" :to="adminPath(`orders/${row.order_id}`)">
|
|
{{ row.order_no }}
|
|
</RouterLink>
|
|
<small class="time-sub">结算 {{ formatDateTime(row.settled_at) || '-' }}</small>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 状态复合列 -->
|
|
<el-table-column label="订单与结算状态" min-width="170">
|
|
<template #default="{ row }">
|
|
<div class="status-stack">
|
|
<div class="status-row">
|
|
<span class="order-status-badge">{{ orderStatusLabel(row.order_status) }}</span>
|
|
<el-tag size="small" :type="financeStatusType(row.finance_status)" effect="plain">
|
|
{{ financeStatusLabel(row.finance_status) }}
|
|
</el-tag>
|
|
</div>
|
|
<small class="settle-desc">
|
|
{{ settlementStatusLabel(row.settlement_status) }} ·
|
|
{{ settlementModeLabel(row) }}
|
|
</small>
|
|
<small v-if="isPlatformManaged(row)" class="offline-desc">
|
|
{{ offlineSettlementStatusLabel(row.offline_settlement_status) }}
|
|
</small>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 交易双方 -->
|
|
<el-table-column label="交易双方" min-width="160">
|
|
<template #default="{ row }">
|
|
<div class="parties-cell">
|
|
<div class="party-line">
|
|
<span class="role-badge renter">租</span>
|
|
<span class="party-info">{{
|
|
row.renter_phone || row.renter_nickname || `UID ${row.renter_id}`
|
|
}}</span>
|
|
</div>
|
|
<div class="party-line">
|
|
<span class="role-badge owner">主</span>
|
|
<span class="party-info">{{
|
|
row.owner_phone || row.owner_nickname || `UID ${row.owner_id}`
|
|
}}</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 收款 -->
|
|
<el-table-column label="收款金额" min-width="120" align="right">
|
|
<template #default="{ row }">
|
|
<span class="amount-val flow-amount">{{ moneyCent(row.paid_amount_cent) }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 退款情况 -->
|
|
<el-table-column label="已退 / 退中" min-width="130" align="right">
|
|
<template #default="{ row }">
|
|
<div class="refund-stack">
|
|
<span v-if="row.refunded_amount_cent > 0" class="refund-text">
|
|
退 {{ moneyCent(row.refunded_amount_cent) }}
|
|
</span>
|
|
<span v-else class="zero-text">0.0</span>
|
|
|
|
<span v-if="row.refunding_amount_cent > 0" class="refunding-text">
|
|
中 {{ moneyCent(row.refunding_amount_cent) }}
|
|
</span>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 渠道净流入 -->
|
|
<el-table-column label="渠道净流入" min-width="125" align="right">
|
|
<template #default="{ row }">
|
|
<span class="amount-val net-amount">{{
|
|
moneyCent(row.channel_net_amount_cent)
|
|
}}</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 平台利润 -->
|
|
<el-table-column label="平台收益" min-width="125" align="right">
|
|
<template #default="{ row }">
|
|
<strong class="amount-val profit-amount">
|
|
{{ moneyCent(row.checkout_platform_fee_cent) }}
|
|
</strong>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 号主应得 -->
|
|
<el-table-column label="号主应得" min-width="125" align="right">
|
|
<template #default="{ row }">
|
|
<span class="amount-val">{{ moneyCent(row.checkout_owner_income_cent) }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 实际入账 / 线下 -->
|
|
<el-table-column label="实际结算" min-width="130" align="right">
|
|
<template #default="{ row }">
|
|
<span class="amount-val success-val">
|
|
{{ moneyCent(row.owner_effective_settlement_amount_cent) }}
|
|
</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 结算差异 -->
|
|
<el-table-column label="结算差异" min-width="120" align="right">
|
|
<template #default="{ row }">
|
|
<el-tag
|
|
v-if="Math.abs(row.settlement_diff_amount_cent) >= SETTLEMENT_DIFF_THRESHOLD_CENT"
|
|
type="danger"
|
|
size="small"
|
|
class="diff-tag"
|
|
>
|
|
{{ moneyCent(row.settlement_diff_amount_cent) }}
|
|
</el-tag>
|
|
<span v-else class="amount-val zero-diff">
|
|
{{ moneyCent(row.settlement_diff_amount_cent) }}
|
|
</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<!-- 操作 -->
|
|
<el-table-column label="操作" width="90" fixed="right" align="center">
|
|
<template #default="{ row }">
|
|
<RouterLink :to="adminPath(`orders/${row.order_id}`)" class="action-link">
|
|
<el-icon><View /></el-icon>
|
|
<span>查看</span>
|
|
</RouterLink>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
|
|
<AdminTablePagination
|
|
v-model:current-page="currentPage"
|
|
v-model:page-size="currentPageSize"
|
|
:total="total"
|
|
@page-change="handlePageChange"
|
|
/>
|
|
</section>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.finance-page-container {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
padding: 0 4px 32px;
|
|
}
|
|
|
|
/* ================= 头部卡片 ================= */
|
|
.page-header-card {
|
|
background: #ffffff;
|
|
border-radius: 16px;
|
|
padding: 24px 28px;
|
|
box-shadow:
|
|
0 1px 3px rgba(15, 23, 42, 0.04),
|
|
0 4px 12px rgba(15, 23, 42, 0.02);
|
|
border: 1px solid rgba(226, 232, 240, 0.8);
|
|
}
|
|
|
|
.header-main {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
justify-content: space-between;
|
|
gap: 16px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.title-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
}
|
|
|
|
.eyebrow-tag {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
letter-spacing: 0.8px;
|
|
color: #4f46e5;
|
|
background: #eef2ff;
|
|
padding: 3px 10px;
|
|
border-radius: 20px;
|
|
width: fit-content;
|
|
}
|
|
|
|
.page-title {
|
|
margin: 0;
|
|
font-size: 26px;
|
|
font-weight: 800;
|
|
color: #0f172a;
|
|
letter-spacing: -0.5px;
|
|
}
|
|
|
|
.page-subtitle {
|
|
margin: 0;
|
|
font-size: 13.5px;
|
|
color: #64748b;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.toolbar-actions {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
/* ================= 筛选面板 ================= */
|
|
.section-card {
|
|
background: #ffffff;
|
|
border-radius: 16px;
|
|
padding: 22px 24px;
|
|
border: 1px solid rgba(226, 232, 240, 0.8);
|
|
box-shadow:
|
|
0 1px 3px rgba(15, 23, 42, 0.04),
|
|
0 4px 12px rgba(15, 23, 42, 0.02);
|
|
}
|
|
|
|
.filter-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
gap: 14px 16px;
|
|
}
|
|
|
|
.filter-grid :deep(.el-form-item) {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.filter-grid :deep(.el-form-item__label) {
|
|
padding-bottom: 4px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: #64748b;
|
|
}
|
|
|
|
.full-control {
|
|
width: 100%;
|
|
}
|
|
|
|
/* ================= 表格卡片 ================= */
|
|
.table-section-card {
|
|
padding-bottom: 16px;
|
|
}
|
|
|
|
.table-card-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.table-header-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: #1e293b;
|
|
}
|
|
|
|
.header-icon {
|
|
color: #4f46e5;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.count-badge {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: #4f46e5;
|
|
background: #eef2ff;
|
|
padding: 3px 10px;
|
|
border-radius: 20px;
|
|
}
|
|
|
|
.table-container {
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
border: 1px solid #e2e8f0;
|
|
}
|
|
|
|
.custom-enterprise-table :deep(.el-table__header-wrapper th) {
|
|
background-color: #f8fafc !important;
|
|
color: #475569;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
padding: 12px 0;
|
|
border-bottom: 1px solid #e2e8f0;
|
|
}
|
|
|
|
.custom-enterprise-table :deep(.el-table__body-wrapper td) {
|
|
padding: 12px 0;
|
|
font-size: 13px;
|
|
color: #334155;
|
|
}
|
|
|
|
.order-cell {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 3px;
|
|
}
|
|
|
|
.order-no-link {
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
font-size: 12.5px;
|
|
font-weight: 700;
|
|
color: #3b82f6;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.order-no-link:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.time-sub {
|
|
font-size: 11px;
|
|
color: #94a3b8;
|
|
}
|
|
|
|
.status-stack {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 3px;
|
|
}
|
|
|
|
.status-row {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.order-status-badge {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: #1e293b;
|
|
}
|
|
|
|
.settle-desc {
|
|
font-size: 11.5px;
|
|
color: #64748b;
|
|
}
|
|
|
|
.offline-desc {
|
|
font-size: 11px;
|
|
color: #d97706;
|
|
}
|
|
|
|
.parties-cell {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
}
|
|
|
|
.party-line {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.role-badge {
|
|
font-size: 10px;
|
|
font-weight: 700;
|
|
padding: 1px 4px;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.role-badge.renter {
|
|
background: #eff6ff;
|
|
color: #3b82f6;
|
|
}
|
|
|
|
.role-badge.owner {
|
|
background: #f5f3ff;
|
|
color: #7c3aed;
|
|
}
|
|
|
|
.party-info {
|
|
font-size: 12px;
|
|
color: #334155;
|
|
}
|
|
|
|
.amount-val {
|
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
.flow-amount {
|
|
color: #1e293b;
|
|
}
|
|
|
|
.net-amount {
|
|
color: #0891b2;
|
|
}
|
|
|
|
.profit-amount {
|
|
color: #059669;
|
|
font-size: 13.5px;
|
|
}
|
|
|
|
.success-val {
|
|
color: #10b981;
|
|
}
|
|
|
|
.refund-stack {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
gap: 2px;
|
|
}
|
|
|
|
.refund-text {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: #ef4444;
|
|
}
|
|
|
|
.refunding-text {
|
|
font-size: 11px;
|
|
color: #f59e0b;
|
|
}
|
|
|
|
.zero-text {
|
|
font-size: 12px;
|
|
color: #cbd5e1;
|
|
}
|
|
|
|
.diff-tag {
|
|
font-weight: 700;
|
|
}
|
|
|
|
.zero-diff {
|
|
color: #94a3b8;
|
|
}
|
|
|
|
.action-link {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
font-size: 12.5px;
|
|
color: #3b82f6;
|
|
text-decoration: none;
|
|
font-weight: 500;
|
|
padding: 4px 8px;
|
|
border-radius: 6px;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.action-link:hover {
|
|
background: #eff6ff;
|
|
}
|
|
</style>
|