彻底优化数据库字段
This commit is contained in:
@@ -17,9 +17,6 @@ export interface Listing {
|
||||
screenshot_urls: string[]
|
||||
cover_url: string
|
||||
price: number
|
||||
price_hourly: number
|
||||
price_daily: number
|
||||
price_weekly: number
|
||||
deposit_amount: number
|
||||
is_accelerated_sale?: boolean
|
||||
in_transaction: boolean
|
||||
@@ -41,9 +38,6 @@ export interface ListingPayload {
|
||||
asset_summary?: Record<string, unknown>
|
||||
screenshot_urls: string[]
|
||||
price: number
|
||||
price_hourly: number
|
||||
price_daily: number
|
||||
price_weekly: number
|
||||
deposit_amount: number
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,8 @@ export interface Order {
|
||||
login_platform: string
|
||||
rented_at?: string
|
||||
estimated_duration_hours: number
|
||||
rent_start_at?: string
|
||||
rent_end_at?: string
|
||||
rent_amount: number
|
||||
owner_rent_amount: number
|
||||
deposit_amount: number
|
||||
platform_fee: number
|
||||
account_snapshot?: Record<string, unknown>
|
||||
@@ -34,6 +33,8 @@ export interface Checkout {
|
||||
initiated_by: number
|
||||
status: string
|
||||
rent_amount: number
|
||||
owner_rent_amount: number
|
||||
platform_fee: number
|
||||
deposit_amount: number
|
||||
consumable_amount: number
|
||||
coin_consumed_m: number
|
||||
|
||||
@@ -308,12 +308,11 @@ function readError(error: unknown, fallback: string) {
|
||||
}
|
||||
|
||||
function orderRentedAt() {
|
||||
return order.value?.rented_at || order.value?.rent_start_at
|
||||
return order.value?.rented_at
|
||||
}
|
||||
|
||||
function orderEstimatedEndAt() {
|
||||
if (!order.value) return undefined
|
||||
if (order.value.rent_end_at) return order.value.rent_end_at
|
||||
const rentedAt = orderRentedAt()
|
||||
const durationHours = Number(order.value.estimated_duration_hours || 0)
|
||||
if (!rentedAt || durationHours <= 0) return undefined
|
||||
@@ -466,6 +465,10 @@ function linesToList(value: string) {
|
||||
<span>订单金额</span>
|
||||
<strong>¥{{ order.rent_amount }}</strong>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<span>平台费用</span>
|
||||
<strong>¥{{ order.platform_fee }}</strong>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<span>押金</span>
|
||||
<strong>¥{{ order.deposit_amount }}</strong>
|
||||
@@ -554,7 +557,8 @@ function linesToList(value: string) {
|
||||
|
||||
<div v-if="order && order.checkout && ['pending_checkout_confirm', 'pending_checkout_accept'].includes(order.status)" class="order-panel">
|
||||
<h2>结账明细</h2>
|
||||
<p>租金:¥{{ order.checkout.rent_amount }},押金:¥{{ order.checkout.deposit_amount }}</p>
|
||||
<p>买家租金:¥{{ order.checkout.rent_amount }},号主租金:¥{{ order.checkout.owner_rent_amount }},平台费用:¥{{ order.checkout.platform_fee }}</p>
|
||||
<p>押金:¥{{ order.checkout.deposit_amount }}</p>
|
||||
<p>扣除:¥{{ order.checkout.deposit_deduct_amount }},退还租客:¥{{ order.checkout.renter_refund_amount }},号主收入:¥{{ order.checkout.owner_income_amount }}</p>
|
||||
<p v-if="order.checkout.content">说明:{{ order.checkout.content }}</p>
|
||||
<p v-if="order.checkout.owner_adjustment_reason">修正原因:{{ order.checkout.owner_adjustment_reason }}</p>
|
||||
|
||||
@@ -58,7 +58,7 @@ function money(value: number) {
|
||||
}
|
||||
|
||||
function listingPrice(row: Listing) {
|
||||
return money(row.price || row.price_daily || row.price_hourly)
|
||||
return money(row.price)
|
||||
}
|
||||
|
||||
function extractObjectKey(url: string) {
|
||||
|
||||
@@ -63,7 +63,7 @@ function openEvidence(row: Listing) {
|
||||
}
|
||||
|
||||
function listingPrice(row: Listing) {
|
||||
return `¥${Number(row.price || row.price_daily || row.price_hourly || 0).toFixed(2)}`
|
||||
return `¥${Number(row.price || 0).toFixed(2)}`
|
||||
}
|
||||
|
||||
function extractObjectKey(url: string) {
|
||||
|
||||
@@ -43,7 +43,7 @@ function money(value: number) {
|
||||
}
|
||||
|
||||
function listingPrice(row: Listing) {
|
||||
return money(row.price || row.price_daily || row.price_hourly)
|
||||
return money(row.price)
|
||||
}
|
||||
|
||||
function ownerName(row: Listing) {
|
||||
|
||||
@@ -65,12 +65,11 @@ function readError(error: unknown, fallback: string) {
|
||||
}
|
||||
|
||||
function orderRentedAt() {
|
||||
return order.value?.rented_at || order.value?.rent_start_at
|
||||
return order.value?.rented_at
|
||||
}
|
||||
|
||||
function orderEstimatedEndAt() {
|
||||
if (!order.value) return undefined
|
||||
if (order.value.rent_end_at) return order.value.rent_end_at
|
||||
const rentedAt = orderRentedAt()
|
||||
const durationHours = Number(order.value.estimated_duration_hours || 0)
|
||||
if (!rentedAt || durationHours <= 0) return undefined
|
||||
@@ -108,6 +107,10 @@ function orderEstimatedEndAt() {
|
||||
<span>订单金额</span>
|
||||
<strong>¥{{ order.rent_amount }}</strong>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<span>平台费用</span>
|
||||
<strong>¥{{ order.platform_fee }}</strong>
|
||||
</div>
|
||||
<div class="metric-card">
|
||||
<span>押金</span>
|
||||
<strong>¥{{ order.deposit_amount }}</strong>
|
||||
|
||||
@@ -428,7 +428,6 @@ async function handleSubmit() {
|
||||
try {
|
||||
const title = `${form.server_region} ${form.rank_level} ${form.haf_coin_amount}M哈夫币`;
|
||||
const dailyPrice = calculatedFinalPrice.value;
|
||||
const hourlyPrice = Math.max(roundMoney(dailyPrice / 24), 0.01);
|
||||
|
||||
const listing = await createListing({
|
||||
title,
|
||||
@@ -440,9 +439,6 @@ async function handleSubmit() {
|
||||
asset_summary: buildAssetSummary(),
|
||||
screenshot_urls: screenshotUrls.value,
|
||||
price: dailyPrice,
|
||||
price_hourly: hourlyPrice,
|
||||
price_daily: dailyPrice,
|
||||
price_weekly: roundMoney(dailyPrice * 7),
|
||||
deposit_amount: Number(form.deposit_amount),
|
||||
});
|
||||
localStorage.removeItem(draftKey);
|
||||
@@ -493,6 +489,9 @@ function validateForm() {
|
||||
if (!Number.isFinite(Number(form.deposit_amount))) {
|
||||
return "押金格式不正确";
|
||||
}
|
||||
if (calculatedConsumablePrice.value > 0 && Number(form.deposit_amount) <= calculatedConsumablePrice.value) {
|
||||
return `押金必须大于额外消耗品总价值 ¥${calculatedConsumablePrice.value}`;
|
||||
}
|
||||
if (!calculatedFinalPrice.value) {
|
||||
return "请完善币数、保险、体力和负重后再发布";
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export function formatHafCoinM(amountWan: number) {
|
||||
}
|
||||
|
||||
export function getListingDisplayPrice(item: Listing) {
|
||||
return Number(item.price_daily || item.price_hourly || 0);
|
||||
return Number(item.price || 0);
|
||||
}
|
||||
|
||||
export function getRatioValue(item: Listing) {
|
||||
|
||||
@@ -45,7 +45,7 @@ function readError(error: unknown, fallback: string) {
|
||||
}
|
||||
|
||||
function listingPrice(item: Listing) {
|
||||
return Number(item.price || item.price_daily || item.price_hourly || 0).toFixed(2);
|
||||
return Number(item.price || 0).toFixed(2);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -28,9 +28,6 @@ async function handleSubmit() {
|
||||
const listing = await createListing({
|
||||
...form,
|
||||
price,
|
||||
price_hourly: Math.max(Math.round((price / 24) * 100) / 100, 0.01),
|
||||
price_daily: price,
|
||||
price_weekly: Math.round(price * 7 * 100) / 100,
|
||||
screenshot_urls: screenshotUrls.value,
|
||||
})
|
||||
ElMessage.success(
|
||||
|
||||
@@ -45,7 +45,7 @@ function readSellerPrice(row: Listing) {
|
||||
const price = Number((breakdown as Record<string, unknown>).seller_total_price)
|
||||
if (Number.isFinite(price) && price > 0) return price
|
||||
}
|
||||
return Number(row.price || row.price_daily || row.price_hourly || 0)
|
||||
return Number(row.price || 0)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user