金额使用整数, 不再扣押金, 价格每个人看到自己的-1

This commit is contained in:
yml2213
2026-05-27 00:22:26 +08:00
parent e270ce8bfc
commit 89f4dabfb3
27 changed files with 351 additions and 119 deletions
@@ -72,6 +72,7 @@ const showRejectPopup = ref(false);
const isOwner = computed(() => order.value?.owner_id === session.userId);
const isRenter = computed(() => order.value?.renter_id === session.userId);
const orderAmountLabel = computed(() => (isOwner.value ? "我的租金" : "订单金额"));
const canOpenDispute = computed(() => {
if (!order.value || (!isOwner.value && !isRenter.value)) return false;
return !["completed", "cancelled", "closed", "disputing", "checkout_disputing", "abnormal"].includes(order.value.status);
@@ -94,10 +95,10 @@ const resourceChargeAmount = computed(() => {
});
const snapshotHafCoinM = computed(() => {
const snapshot = readSnapshot();
return roundMoney(readNumber(snapshot?.haf_coin_amount) / 1000000);
return roundQuantity(readNumber(snapshot?.haf_coin_amount) / 1000000);
});
const remainingHafCoinM = computed(() => {
return roundMoney(Math.max(snapshotHafCoinM.value - Number(checkoutForm.value.coin_consumed_m || 0), 0));
return roundQuantity(Math.max(snapshotHafCoinM.value - Number(checkoutForm.value.coin_consumed_m || 0), 0));
});
onMounted(loadOrder);
@@ -450,14 +451,14 @@ function checkoutContentWithSummary() {
.map(
(item) =>
`${item.label} ${readResourceUsage(item.key)}/${item.quantity}${
isChargedResource(item) ? `,扣款¥${resourceLineAmount(item).toFixed(2)}` : ",赠送不扣款"
isChargedResource(item) ? `,金额¥${money(resourceLineAmount(item))}` : ",赠送不扣款"
}`
)
.join(";")}`
);
}
if (Number(checkoutForm.value.coin_consumed_m || 0) > 0) {
lines.push(`哈夫币消耗:${Number(checkoutForm.value.coin_consumed_m).toFixed(2)}M,预计剩余${remainingHafCoinM.value.toFixed(2)}M`);
lines.push(`哈夫币消耗:${quantity(Number(checkoutForm.value.coin_consumed_m))}M,预计剩余${quantity(remainingHafCoinM.value)}M`);
}
if (lines.length === 0) {
lines.push("租客发起结账。");
@@ -480,9 +481,22 @@ function readUnitPrice(priceText: string) {
}
function roundMoney(value: number) {
return Math.round(value);
}
function roundQuantity(value: number) {
return Math.round(value * 100) / 100;
}
function money(value: unknown) {
return `${roundMoney(readNumber(value))}`;
}
function quantity(value: unknown) {
const rounded = roundQuantity(readNumber(value));
return Number.isInteger(rounded) ? `${rounded}` : rounded.toFixed(2);
}
function readNumber(value: unknown) {
const number = Number(value || 0);
return Number.isFinite(number) ? number : 0;
@@ -560,12 +574,12 @@ function getStatusTagType(status: string) {
<h2 class="order-title">{{ order.title }}</h2>
<div class="order-meta-grid">
<div class="meta-item">
<span class="meta-label">订单金额</span>
<strong class="meta-value accent">¥{{ order.rent_amount }}</strong>
<span class="meta-label">{{ orderAmountLabel }}</span>
<strong class="meta-value accent">¥{{ money(order.display_amount) }}</strong>
</div>
<div class="meta-item">
<span class="meta-label">押金</span>
<strong class="meta-value">¥{{ order.deposit_amount }}</strong>
<strong class="meta-value">¥{{ money(order.deposit_amount) }}</strong>
</div>
<div class="meta-item">
<span class="meta-label">交接状态</span>
@@ -711,12 +725,12 @@ function getStatusTagType(status: string) {
min="0"
:max="item.quantity"
/>
<span class="resource-line-amount">¥{{ resourceLineAmount(item).toFixed(2) }}</span>
<span class="resource-line-amount">¥{{ money(resourceLineAmount(item)) }}</span>
</div>
</div>
<div class="resource-panel-footer">
<span>物资费用扣款合计:</span>
<strong>¥{{ resourceChargeAmount.toFixed(2) }}</strong>
<span>物资金额合计:</span>
<strong>¥{{ money(resourceChargeAmount) }}</strong>
</div>
</div>
@@ -735,7 +749,7 @@ function getStatusTagType(status: string) {
</template>
</van-field>
<div class="coin-hint">
订单快照 {{ snapshotHafCoinM.toFixed(2) }}M,预计剩余 {{ remainingHafCoinM.toFixed(2) }}M
订单快照 {{ quantity(snapshotHafCoinM) }}M,预计剩余 {{ quantity(remainingHafCoinM) }}M
</div>
<van-field label="其他费用" label-width="100px">
<template #input>
@@ -778,13 +792,12 @@ function getStatusTagType(status: string) {
<section v-if="order.checkout && ['pending_checkout_confirm', 'pending_checkout_accept'].includes(order.status)" class="card-section">
<h3 class="section-title">结账结算账单</h3>
<van-cell-group inset :border="false">
<van-cell title="买家租金" :value="`¥${order.checkout.rent_amount}`" />
<van-cell title="号主实收租金" :value="`¥${order.checkout.owner_rent_amount}`" />
<van-cell title="平台服务费" :value="`¥${order.checkout.platform_fee}`" />
<van-cell title="押金总额" :value="`¥${order.checkout.deposit_amount}`" />
<van-cell title="扣款总计" :value="`¥${order.checkout.deposit_deduct_amount}`" value-class="red-text" />
<van-cell title="退还租客押金" :value="`¥${order.checkout.renter_refund_amount}`" value-class="green-text" />
<van-cell title="号主最终收益" :value="`¥${order.checkout.owner_income_amount}`" value-class="green-text" />
<van-cell :title="orderAmountLabel" :value="`¥${money(order.checkout.display_amount)}`" />
<van-cell title="押金总额" :value="`¥${money(order.checkout.deposit_amount)}`" />
<van-cell title="额外消耗品金额" :value="`¥${money(order.checkout.consumable_amount)}`" />
<van-cell title="押金扣除" :value="`¥${money(order.checkout.deposit_deduct_amount)}`" value-class="red-text" />
<van-cell v-if="isRenter" title="退还租客押金" :value="`¥${money(order.checkout.renter_refund_amount)}`" value-class="green-text" />
<van-cell v-if="isOwner" title="号主最终收益" :value="`¥${money(order.checkout.owner_income_amount)}`" value-class="green-text" />
<van-cell v-if="order.checkout.content" title="结账备注" :label="order.checkout.content" />
<van-cell v-if="order.checkout.owner_adjustment_reason" title="号主修正原因" :label="order.checkout.owner_adjustment_reason" />
</van-cell-group>