线下提号 优化价格拆分
This commit is contained in:
@@ -41,6 +41,9 @@ export interface AvailableListing {
|
||||
owner_phone: string
|
||||
listing_price_cent: number
|
||||
owner_price_cent: number
|
||||
owner_pure_price_cent: number
|
||||
owner_extra_item_price_cent: number
|
||||
owner_total_price_cent: number
|
||||
website_profit_cent: number
|
||||
seller_ratio: number
|
||||
buyer_ratio: number
|
||||
|
||||
@@ -38,6 +38,21 @@ const listingLoading = ref(false)
|
||||
const selectedListing = computed(
|
||||
() => listingOptions.value.find(item => item.id === createForm.listing_id) || null
|
||||
)
|
||||
const selectedPriceSnapshot = computed(() => {
|
||||
const item = selectedListing.value
|
||||
if (!item) return null
|
||||
const totalCent = normalizeCent(item.owner_total_price_cent || item.owner_price_cent)
|
||||
let pureCent = normalizeCent(item.owner_pure_price_cent)
|
||||
let extraCent = normalizeCent(item.owner_extra_item_price_cent)
|
||||
if (pureCent <= 0 && extraCent <= 0) {
|
||||
pureCent = totalCent
|
||||
} else if (pureCent <= 0) {
|
||||
pureCent = Math.max(totalCent - extraCent, 0)
|
||||
} else if (extraCent <= 0) {
|
||||
extraCent = Math.max(totalCent - pureCent, 0)
|
||||
}
|
||||
return { pureCent, extraCent, totalCent }
|
||||
})
|
||||
|
||||
onMounted(loadList)
|
||||
|
||||
@@ -193,6 +208,16 @@ function ratioText(value: number) {
|
||||
const rounded = Math.round(ratio * 100) / 100
|
||||
return `1:${Number.isInteger(rounded) ? rounded : rounded.toFixed(2)}`
|
||||
}
|
||||
|
||||
function normalizeCent(value: number | undefined | null) {
|
||||
const cent = Number(value || 0)
|
||||
if (!Number.isFinite(cent)) return 0
|
||||
return Math.max(Math.round(cent), 0)
|
||||
}
|
||||
|
||||
function listingOwnerTotalCent(item: AvailableListing) {
|
||||
return normalizeCent(item.owner_total_price_cent || item.owner_price_cent)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -317,15 +342,17 @@ function ratioText(value: number) {
|
||||
<el-option
|
||||
v-for="item in listingOptions"
|
||||
:key="item.id"
|
||||
:label="`${item.listing_no} · ${item.account_title} · ${formatCentWithSymbol(item.owner_price_cent)} / ${formatCentWithSymbol(item.listing_price_cent)}`"
|
||||
:label="`${item.listing_no} · ${item.account_title} · ${formatCentWithSymbol(listingOwnerTotalCent(item))} / ${formatCentWithSymbol(item.listing_price_cent)}`"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<div class="form-hint">仅显示已发布、已审核、未在交易中的账号</div>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="selectedListing" label="价格快照">
|
||||
<el-form-item v-if="selectedListing && selectedPriceSnapshot" label="价格快照">
|
||||
<div class="price-snapshot">
|
||||
<span>号主价 {{ formatCentWithSymbol(selectedListing.owner_price_cent) }}</span>
|
||||
<span>纯比价格 {{ formatCentWithSymbol(selectedPriceSnapshot.pureCent) }}</span>
|
||||
<span>额外物品价格 {{ formatCentWithSymbol(selectedPriceSnapshot.extraCent) }}</span>
|
||||
<span>号主总价 {{ formatCentWithSymbol(selectedPriceSnapshot.totalCent) }}</span>
|
||||
<span>网站售价 {{ formatCentWithSymbol(selectedListing.listing_price_cent) }}</span>
|
||||
<span>网站加价 {{ formatCentWithSymbol(selectedListing.website_profit_cent) }}</span>
|
||||
<span>回收 {{ ratioText(selectedListing.seller_ratio) }}</span>
|
||||
|
||||
Reference in New Issue
Block a user