feat(tenant): 增加双站订单视图与租户统计
This commit is contained in:
@@ -94,6 +94,16 @@ export interface ManualEntryTodayStats {
|
||||
|
||||
export interface AdminDashboard {
|
||||
metrics: DashboardMetrics
|
||||
tenant?: {
|
||||
tenant_id: number
|
||||
user_count: number
|
||||
verified_users: number
|
||||
published_listings: number
|
||||
buyer_order_count: number
|
||||
buyer_gmv_cent: number
|
||||
source_order_count: number
|
||||
source_amount_cent: number
|
||||
}
|
||||
pending: DashboardPending
|
||||
listing_daily: ListingDailyOverview
|
||||
trading_daily: TradingDailyOverview
|
||||
|
||||
@@ -59,6 +59,7 @@ const tradingToday = computed<TradingDayStats>(
|
||||
}
|
||||
)
|
||||
const tradingDays = computed(() => dashboard.value?.trading_daily?.days ?? 7)
|
||||
const tenantStats = computed(() => dashboard.value?.tenant)
|
||||
|
||||
const listingTrend = computed(() => dashboard.value?.listing_daily?.trend ?? [])
|
||||
const listingChannelTrend = computed(() => dashboard.value?.listing_daily?.channel_trend ?? [])
|
||||
@@ -194,7 +195,11 @@ function shortDate(date: string) {
|
||||
<div class="metric-info">
|
||||
<span class="metric-label">订单总数</span>
|
||||
<strong class="metric-val amber-val">{{ dashboard.metrics.total_orders }}</strong>
|
||||
<span class="metric-sub-pill warning"
|
||||
<span v-if="tenantStats" class="metric-sub-pill warning">
|
||||
本站买入 {{ tenantStats.buyer_order_count }} 单 · 出货
|
||||
{{ tenantStats.source_order_count }} 单
|
||||
</span>
|
||||
<span v-else class="metric-sub-pill warning"
|
||||
>使用中 {{ dashboard.metrics.renting_orders }} 个</span
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -352,3 +352,12 @@
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
.page-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.page-title-row h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@@ -173,32 +173,52 @@ const platformCheckoutDisputeAction = computed(
|
||||
const offlineSettlementAction = computed(
|
||||
() => order.value?.admin_actions?.platform_offline_settlement
|
||||
)
|
||||
const hasBuyerRole = computed(
|
||||
() => !order.value?.site_role || ['buyer', 'both'].includes(order.value.site_role)
|
||||
)
|
||||
const hasSourceRole = computed(
|
||||
() => !order.value?.site_role || ['source', 'both'].includes(order.value.site_role)
|
||||
)
|
||||
const resetActionLabel = computed(() => {
|
||||
return resetAction.value?.label || '重置'
|
||||
})
|
||||
const canResetHandoff = computed(() => resetAction.value?.enabled === true)
|
||||
const canPlatformHandoff = computed(() => platformHandoffAction.value?.enabled === true)
|
||||
const canForceHandoff = computed(() => forceHandoffAction.value?.enabled === true)
|
||||
const canResetHandoff = computed(() => hasSourceRole.value && resetAction.value?.enabled === true)
|
||||
const canPlatformHandoff = computed(
|
||||
() => hasSourceRole.value && platformHandoffAction.value?.enabled === true
|
||||
)
|
||||
const canForceHandoff = computed(
|
||||
() => hasSourceRole.value && forceHandoffAction.value?.enabled === true
|
||||
)
|
||||
const forceHandoffNeedsContent = computed(
|
||||
() =>
|
||||
order.value?.handoff_status === 'pending_owner' ||
|
||||
order.value?.handoff_status === 'owner_timeout'
|
||||
)
|
||||
const canPlatformCheckoutConfirm = computed(
|
||||
() => platformCheckoutConfirmAction.value?.enabled === true
|
||||
() => hasBuyerRole.value && platformCheckoutConfirmAction.value?.enabled === true
|
||||
)
|
||||
const canPlatformCheckoutCounter = computed(
|
||||
() => platformCheckoutCounterAction.value?.enabled === true
|
||||
() => hasBuyerRole.value && platformCheckoutCounterAction.value?.enabled === true
|
||||
)
|
||||
const canPlatformCheckoutDispute = computed(
|
||||
() => platformCheckoutDisputeAction.value?.enabled === true
|
||||
() => hasBuyerRole.value && platformCheckoutDisputeAction.value?.enabled === true
|
||||
)
|
||||
const canOfflineSettlement = computed(
|
||||
() => hasSourceRole.value && offlineSettlementAction.value?.enabled === true
|
||||
)
|
||||
const canAdminCreateDispute = computed(
|
||||
() => hasBuyerRole.value && canOperate.value && !order.value?.active_dispute
|
||||
)
|
||||
const canOfflineSettlement = computed(() => offlineSettlementAction.value?.enabled === true)
|
||||
const canAdminCreateDispute = computed(() => canOperate.value && !order.value?.active_dispute)
|
||||
const isPlatformManaged = computed(
|
||||
() =>
|
||||
order.value?.handoff_mode === 'platform' || order.value?.settlement_mode === 'platform_managed'
|
||||
)
|
||||
const siteRoleLabel = computed(() => {
|
||||
if (order.value?.site_role === 'source') return '本站出货'
|
||||
if (order.value?.site_role === 'both') return '本站买卖'
|
||||
if (order.value?.site_role === 'buyer') return '本站买入'
|
||||
return ''
|
||||
})
|
||||
const offlineSettlementStatus = computed(() => order.value?.offline_settlement_status || 'none')
|
||||
// 押金暂扣:仅进行中、有实付押金、且未暂扣过的订单可暂扣。
|
||||
const depositHoldStatus = computed(() => order.value?.deposit_hold_status || 'none')
|
||||
@@ -206,11 +226,14 @@ const depositHoldAmountCent = computed(() => Number(order.value?.deposit_hold_am
|
||||
const isDepositHeld = computed(() => depositHoldStatus.value === 'held')
|
||||
const canHoldDeposit = computed(
|
||||
() =>
|
||||
hasBuyerRole.value &&
|
||||
canOperate.value &&
|
||||
depositHoldStatus.value === 'none' &&
|
||||
Number(order.value?.deposit_amount_cent || 0) > 0
|
||||
)
|
||||
const canReleaseDeposit = computed(() => isDepositHeld.value && depositHoldAmountCent.value > 0)
|
||||
const canReleaseDeposit = computed(
|
||||
() => hasBuyerRole.value && isDepositHeld.value && depositHoldAmountCent.value > 0
|
||||
)
|
||||
const depositHoldStatusLabel = computed(() => {
|
||||
switch (depositHoldStatus.value) {
|
||||
case 'held':
|
||||
@@ -369,6 +392,14 @@ const hasOwnerRentBreakdown = computed(() => ownerCoinBasePriceCent.value !== nu
|
||||
const platformFeeBreakdown = computed(() => orderPlatformFeeBreakdown(order.value))
|
||||
const fundSplitRows = computed(() => {
|
||||
if (!order.value) return []
|
||||
if (!hasBuyerRole.value && hasSourceRole.value) {
|
||||
return [
|
||||
{
|
||||
label: '本站货源结算金额',
|
||||
amountCent: order.value.source_amount_cent,
|
||||
},
|
||||
]
|
||||
}
|
||||
const rows: FundSplitRow[] = []
|
||||
rows.push(
|
||||
{ label: '预收纯币原价', amountCent: order.value.pure_coin_original_amount_cent },
|
||||
@@ -446,14 +477,15 @@ async function loadOrder() {
|
||||
loading.value = true
|
||||
try {
|
||||
order.value = await fetchAdminOrder(String(route.params.id))
|
||||
const [handoffs, events, payments] = await Promise.all([
|
||||
const [handoffs, events] = await Promise.all([
|
||||
fetchAdminHandoffRecords(String(route.params.id)),
|
||||
fetchAdminOrderProcessEvents(String(route.params.id)),
|
||||
fetchAdminPayments({ order_id: String(route.params.id) }),
|
||||
])
|
||||
handoffRecords.value = handoffs
|
||||
processEvents.value = events
|
||||
paymentRecords.value = payments.items
|
||||
paymentRecords.value = hasBuyerRole.value
|
||||
? (await fetchAdminPayments({ order_id: String(route.params.id) })).items
|
||||
: []
|
||||
await loadRefundStatus()
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -461,6 +493,10 @@ async function loadOrder() {
|
||||
}
|
||||
|
||||
async function loadRefundStatus() {
|
||||
if (!hasBuyerRole.value) {
|
||||
refundStatus.value = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
refundStatus.value = await adminRefundStatus(Number(route.params.id))
|
||||
} catch {
|
||||
@@ -1002,7 +1038,10 @@ function formatRatioNumber(value: number) {
|
||||
<div v-if="order" class="page-header-row">
|
||||
<div class="page-header">
|
||||
<p class="eyebrow">{{ order.order_no }}</p>
|
||||
<h1>订单详情</h1>
|
||||
<div class="page-title-row">
|
||||
<h1>订单详情</h1>
|
||||
<el-tag v-if="siteRoleLabel" effect="plain">{{ siteRoleLabel }}</el-tag>
|
||||
</div>
|
||||
<p>
|
||||
商品编号 {{ listingCode }} · {{ order.title }} · {{ order.server_region }} /
|
||||
{{ order.login_platform }}
|
||||
@@ -1074,7 +1113,11 @@ function formatRatioNumber(value: number) {
|
||||
<el-button type="warning" plain @click="confirmHoldDeposit"> 暂扣押金 </el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="isDepositHeld" :content="depositReleaseActionTip" placement="top">
|
||||
<el-tooltip
|
||||
v-if="isDepositHeld && hasBuyerRole"
|
||||
:content="depositReleaseActionTip"
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
<el-button
|
||||
type="success"
|
||||
@@ -1086,7 +1129,7 @@ function formatRatioNumber(value: number) {
|
||||
</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-tooltip :content="refundActionTip" placement="top">
|
||||
<el-tooltip v-if="hasBuyerRole" :content="refundActionTip" placement="top">
|
||||
<span>
|
||||
<el-button
|
||||
type="primary"
|
||||
@@ -1264,7 +1307,7 @@ function formatRatioNumber(value: number) {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="dashboard-panel detail-panel">
|
||||
<section v-if="hasBuyerRole" class="dashboard-panel detail-panel">
|
||||
<div class="panel-heading">
|
||||
<h2>退款概况</h2>
|
||||
<el-tag :type="refundStatusType(refundStatus?.refund_status || '')" effect="light">
|
||||
@@ -1420,7 +1463,7 @@ function formatRatioNumber(value: number) {
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<AdminOrderPaymentRecords :records="paymentRecords" />
|
||||
<AdminOrderPaymentRecords v-if="hasBuyerRole" :records="paymentRecords" />
|
||||
|
||||
<section class="dashboard-panel detail-panel order-wide-panel">
|
||||
<div class="panel-heading">
|
||||
|
||||
@@ -169,6 +169,13 @@ function ownerActualIncome(row: AdminOrderListItem) {
|
||||
const value = row.owner_income_amount_cent
|
||||
return typeof value === 'number' ? value : null
|
||||
}
|
||||
|
||||
function siteRoleLabel(row: AdminOrderListItem) {
|
||||
if (row.site_role === 'source') return '本站出货'
|
||||
if (row.site_role === 'both') return '本站买卖'
|
||||
if (row.site_role === 'buyer') return '本站买入'
|
||||
return ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -177,7 +184,7 @@ function ownerActualIncome(row: AdminOrderListItem) {
|
||||
<div class="page-header">
|
||||
<p class="eyebrow">Orders</p>
|
||||
<h1>订单管理</h1>
|
||||
<p>查看全量订单、交接状态、金额和结算状态。</p>
|
||||
<p>查看本站买入与本站出货订单、交接状态、金额和结算状态。</p>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<el-button v-if="canReturnToWithdrawals" :icon="ArrowLeft" @click="returnToWithdrawals">
|
||||
@@ -297,6 +304,9 @@ function ownerActualIncome(row: AdminOrderListItem) {
|
||||
{{ row.order_no }}
|
||||
</RouterLink>
|
||||
<span>商品编号 {{ formatListingNo(row.listing_no, row.listing_id) }}</span>
|
||||
<el-tag v-if="siteRoleLabel(row)" size="small" effect="plain">
|
||||
{{ siteRoleLabel(row) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -432,6 +442,10 @@ function ownerActualIncome(row: AdminOrderListItem) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.order-main-cell :deep(.el-tag) {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.stacked-cell strong {
|
||||
overflow: hidden;
|
||||
color: #1b2559;
|
||||
|
||||
@@ -7,6 +7,10 @@ import { getTrackCode } from '@/shared/utils/trackCode'
|
||||
|
||||
export interface Order {
|
||||
id: number
|
||||
buyer_tenant_id?: number
|
||||
source_tenant_id?: number
|
||||
payment_tenant_id?: number
|
||||
site_role?: 'buyer' | 'source' | 'both' | ''
|
||||
order_no: string
|
||||
listing_id: number
|
||||
listing_no: string
|
||||
@@ -25,6 +29,7 @@ export interface Order {
|
||||
display_amount_cent: number
|
||||
rent_amount_cent?: number
|
||||
owner_rent_amount_cent?: number
|
||||
source_amount_cent?: number
|
||||
deposit_amount_cent: number
|
||||
deposit_original_amount_cent: number
|
||||
deposit_waived_amount_cent: number
|
||||
@@ -114,6 +119,10 @@ export interface UserOrderListItem {
|
||||
// 后台订单列表返回客服需要的完整用户手机号,其余敏感字段仅在详情接口中按权限返回。
|
||||
export interface AdminOrderListItem {
|
||||
id: number
|
||||
buyer_tenant_id: number
|
||||
source_tenant_id: number
|
||||
payment_tenant_id: number
|
||||
site_role?: 'buyer' | 'source' | 'both' | ''
|
||||
order_no: string
|
||||
listing_id: number
|
||||
listing_no: string
|
||||
|
||||
Reference in New Issue
Block a user