feat(admin): 订单与商品详情页补齐明细与操作
This commit is contained in:
@@ -156,3 +156,74 @@ export function listingAccountLevel(row: AdminListing) {
|
||||
if (fireLevel !== '—') return fireLevel
|
||||
return row.rank_level || '—'
|
||||
}
|
||||
|
||||
function breakdownCent(row: AdminListing, key: string) {
|
||||
const breakdown = recordOf(row.asset_summary?.price_breakdown)
|
||||
const cent = numberOf(breakdown[`${key}_cent`])
|
||||
if (cent > 0) return Math.round(cent)
|
||||
const yuan = numberOf(breakdown[key])
|
||||
return yuan > 0 ? Math.round(yuan * 100) : 0
|
||||
}
|
||||
|
||||
export function listingConsumablePriceCent(row: AdminListing) {
|
||||
return breakdownCent(row, 'consumable_price')
|
||||
}
|
||||
|
||||
export function listingSellerCoinBasePriceCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'seller_coin_base_price')
|
||||
if (stored > 0) return stored
|
||||
const fallback = row.price_cent - listingConsumablePriceCent(row)
|
||||
return Math.max(0, Math.round(fallback))
|
||||
}
|
||||
|
||||
export function listingSellerTotalPriceCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'seller_total_price')
|
||||
if (stored > 0) return stored
|
||||
return listingSellerCoinBasePriceCent(row) + listingConsumablePriceCent(row)
|
||||
}
|
||||
|
||||
export function listingBuyerCoinBasePriceCent(row: AdminListing) {
|
||||
return listingPureCoinPrice(row)
|
||||
}
|
||||
|
||||
export function listingBuyerTotalPriceCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'buyer_total_price')
|
||||
if (stored > 0) return stored
|
||||
return listingBuyerCoinBasePriceCent(row) + listingConsumablePriceCent(row)
|
||||
}
|
||||
|
||||
export function listingPlatformMarkupCent(row: AdminListing) {
|
||||
const stored = breakdownCent(row, 'platform_markup_amount')
|
||||
if (stored > 0) return stored
|
||||
return Math.max(0, listingBuyerCoinBasePriceCent(row) - listingSellerCoinBasePriceCent(row))
|
||||
}
|
||||
|
||||
export function listingSellerRatio(row: AdminListing) {
|
||||
const breakdown = recordOf(row.asset_summary?.price_breakdown)
|
||||
const stored = numberOf(breakdown.seller_ratio) || numberOf(breakdown.seller_reference_ratio)
|
||||
if (stored > 0) return stored
|
||||
const baseYuan = listingSellerCoinBasePriceCent(row) / 100
|
||||
const coinWan = numberOf(row.haf_coin_amount) / 10000
|
||||
return baseYuan > 0 ? coinWan / baseYuan : 0
|
||||
}
|
||||
|
||||
export function listingBuyerRatio(row: AdminListing) {
|
||||
const breakdown = recordOf(row.asset_summary?.price_breakdown)
|
||||
const stored = numberOf(breakdown.buyer_ratio)
|
||||
if (stored > 0) return stored
|
||||
const baseYuan = listingBuyerCoinBasePriceCent(row) / 100
|
||||
const coinWan = numberOf(row.haf_coin_amount) / 10000
|
||||
return baseYuan > 0 ? coinWan / baseYuan : 0
|
||||
}
|
||||
|
||||
export function listingSkinNames(row: AdminListing): string[] {
|
||||
const groups = recordOf(row.asset_summary?.skin_groups)
|
||||
const names: string[] = []
|
||||
Object.values(groups).forEach(value => {
|
||||
if (!Array.isArray(value)) return
|
||||
value.forEach(name => {
|
||||
if (typeof name === 'string' && name.trim()) names.push(name.trim())
|
||||
})
|
||||
})
|
||||
return Array.from(new Set(names))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user