优化发布确认与订单资金拆分

This commit is contained in:
yml2213
2026-06-24 01:57:03 +08:00
parent 86a136e663
commit c30914b538
4 changed files with 83 additions and 27 deletions
@@ -42,6 +42,12 @@ const paymentRecords = ref<AdminPayment[]>([])
const actionType = ref<'close' | 'abnormal' | 'reset' | ''>('')
const reason = ref('')
const refundStatus = ref<RefundStatus | null>(null)
type FundSplitRow = {
label: string
amountCent: number | null | undefined
}
const listingCode = computed(() =>
order.value ? formatListingNo(order.value.listing_no, order.value.listing_id) : '-'
)
@@ -109,10 +115,14 @@ const assetSummary = computed(() => {
if (typeof summary !== 'object' || summary === null) return null
return summary as Record<string, unknown>
})
const snapshotRatio = computed(() => {
const snapshotPriceBreakdown = computed(() => {
const breakdown = assetSummary.value?.price_breakdown
if (typeof breakdown !== 'object' || breakdown === null) return null
const row = breakdown as Record<string, unknown>
return breakdown as Record<string, unknown>
})
const snapshotRatio = computed(() => {
const row = snapshotPriceBreakdown.value
if (!row) return null
const sellerRatio = Number(row.seller_ratio || 0)
const buyerRatio = Number(row.buyer_ratio || 0)
const publishRatio = Number(assetSummary.value?.publish_ratio || 0)
@@ -121,6 +131,36 @@ const snapshotRatio = computed(() => {
sellRatio: buyerRatio > 0 ? buyerRatio : 0,
}
})
const ownerCoinBasePriceCent = computed(() => readPriceBreakdownCent('seller_coin_base_price'))
const ownerLossPriceCent = computed(() => {
const consumableCent = readPriceBreakdownCent('consumable_price')
if (consumableCent !== null) return consumableCent
if (ownerCoinBasePriceCent.value === null || !order.value?.owner_rent_amount_cent) return null
return Math.max(Number(order.value.owner_rent_amount_cent) - ownerCoinBasePriceCent.value, 0)
})
const hasOwnerRentBreakdown = computed(() => ownerCoinBasePriceCent.value !== null)
const fundSplitRows = computed(() => {
if (!order.value) return []
const rows: FundSplitRow[] = [
{ label: '租客租金', amountCent: order.value.rent_amount_cent },
]
if (hasOwnerRentBreakdown.value) {
rows.push(
{ label: '号主纯币价格', amountCent: ownerCoinBasePriceCent.value },
{ label: '号主损耗', amountCent: ownerLossPriceCent.value ?? 0 },
{ label: '号主租金合计', amountCent: order.value.owner_rent_amount_cent }
)
} else {
rows.push({ label: '号主租金', amountCent: order.value.owner_rent_amount_cent })
}
rows.push(
{ label: '平台费用', amountCent: order.value.platform_fee_cent },
{ label: '实付押金', amountCent: order.value.deposit_amount_cent },
{ label: '原始押金', amountCent: order.value.deposit_original_amount_cent },
{ label: '免押额度', amountCent: order.value.deposit_waived_amount_cent }
)
return rows
})
const snapshotSeasonTags = computed(() => {
const tags = currentSnapshot.value?.season_tags
return Array.isArray(tags) ? tags.map(item => String(item)).filter(Boolean) : []
@@ -298,6 +338,14 @@ function moneyCent(value: number | undefined | null) {
return formatCentWithSymbol(Number(value || 0))
}
function readPriceBreakdownCent(key: string) {
const raw = snapshotPriceBreakdown.value?.[key]
if (raw === undefined || raw === null || raw === '') return null
const value = Number(raw)
if (!Number.isFinite(value)) return null
return Math.round(value * 100)
}
function firstQueryValue(value: unknown) {
if (Array.isArray(value)) return typeof value[0] === 'string' ? value[0] : ''
return typeof value === 'string' ? value : ''
@@ -564,29 +612,9 @@ function paymentPaidAt(record: AdminPayment) {
<span class="panel-subtitle">{{ priceRoleLabel(order.price_role) }}</span>
</div>
<div class="money-list">
<div class="money-row">
<span>租客租金</span>
<strong>{{ moneyCent(order.rent_amount_cent) }}</strong>
</div>
<div class="money-row">
<span>号主租金</span>
<strong>{{ moneyCent(order.owner_rent_amount_cent) }}</strong>
</div>
<div class="money-row">
<span>平台费用</span>
<strong>{{ moneyCent(order.platform_fee_cent) }}</strong>
</div>
<div class="money-row">
<span>实付押金</span>
<strong>{{ moneyCent(order.deposit_amount_cent) }}</strong>
</div>
<div class="money-row">
<span>原始押金</span>
<strong>{{ moneyCent(order.deposit_original_amount_cent) }}</strong>
</div>
<div class="money-row">
<span>免押额度</span>
<strong>{{ moneyCent(order.deposit_waived_amount_cent) }}</strong>
<div v-for="row in fundSplitRows" :key="row.label" class="money-row">
<span>{{ row.label }}</span>
<strong>{{ moneyCent(row.amountCent) }}</strong>
</div>
<div class="money-row total">
<span>订单实付合计</span>