统一金额分制重构

This commit is contained in:
yml
2026-06-09 19:04:11 +08:00
parent 87673288ef
commit 5cd3ead4bd
69 changed files with 886 additions and 1277 deletions
@@ -557,26 +557,24 @@ function formatHandoffRecordType(type: string) {
return typeMap[type] || type
}
function amountYuan(cent: unknown, legacyYuan?: unknown) {
function amountYuan(cent: unknown) {
if (cent !== undefined && cent !== null) return centToYuan(readNumber(cent))
return readNumber(legacyYuan)
return 0
}
function orderRentAmount(item: Order) {
if (item.owner_id === session.userId)
return amountYuan(item.owner_rent_amount_cent, item.owner_rent_amount ?? item.display_amount)
return amountYuan(item.owner_rent_amount_cent)
if (item.renter_id === session.userId)
return amountYuan(item.rent_amount_cent, item.rent_amount ?? item.display_amount)
return amountYuan(item.display_amount_cent, item.display_amount)
return amountYuan(item.rent_amount_cent)
return amountYuan(item.display_amount_cent)
}
function ownerActualIncome(item: Order) {
if (item.owner_id !== session.userId) return null
const value = item.checkout?.owner_income_amount_cent
if (typeof value === 'number') return centToYuan(value)
return typeof item.checkout?.owner_income_amount === 'number'
? item.checkout.owner_income_amount
: null
return null
}
function quantity(value: unknown) {
@@ -596,16 +594,10 @@ function isRecord(value: unknown): value is Record<string, unknown> {
function hydrateCounterForm() {
if (!order.value?.checkout) return
const checkout = order.value.checkout
counterForm.value.consumable_amount = amountYuan(
checkout.consumable_amount_cent,
checkout.consumable_amount
)
counterForm.value.consumable_amount = amountYuan(checkout.consumable_amount_cent)
counterForm.value.coin_consumed_m = checkout.coin_consumed_m
counterForm.value.other_amount = amountYuan(checkout.other_amount_cent, checkout.other_amount)
counterForm.value.deposit_deduct_amount = amountYuan(
checkout.deposit_deduct_amount_cent,
checkout.deposit_deduct_amount
)
counterForm.value.other_amount = amountYuan(checkout.other_amount_cent)
counterForm.value.deposit_deduct_amount = amountYuan(checkout.deposit_deduct_amount_cent)
}
function linesToList(value: string) {
@@ -696,14 +688,12 @@ async function copyListingCode() {
<div class="meta-item">
<span class="meta-label">押金</span>
<strong class="meta-value"
>¥{{ money(amountYuan(order.deposit_amount_cent, order.deposit_amount)) }}</strong
>¥{{ money(amountYuan(order.deposit_amount_cent)) }}</strong
>
<span
v-if="amountYuan(order.deposit_waived_amount_cent, order.deposit_waived_amount) > 0"
v-if="amountYuan(order.deposit_waived_amount_cent) > 0"
class="meta-note"
>已免押 ¥{{
money(amountYuan(order.deposit_waived_amount_cent, order.deposit_waived_amount))
}}</span
>已免押 ¥{{ money(amountYuan(order.deposit_waived_amount_cent)) }}</span
>
</div>
<div class="meta-item">
@@ -956,59 +946,36 @@ async function copyListingCode() {
<van-cell-group inset :border="false">
<van-cell
title="实际结算租金"
:value="`¥${money(
amountYuan(order.checkout.display_amount_cent, order.checkout.display_amount)
)}`"
:value="`¥${money(amountYuan(order.checkout.display_amount_cent))}`"
/>
<van-cell
title="押金总额"
:label="
amountYuan(order.deposit_waived_amount_cent, order.deposit_waived_amount) > 0
? `已免押 ¥${money(
amountYuan(order.deposit_waived_amount_cent, order.deposit_waived_amount)
)}`
amountYuan(order.deposit_waived_amount_cent) > 0
? `已免押 ¥${money(amountYuan(order.deposit_waived_amount_cent))}`
: ''
"
:value="`¥${money(
amountYuan(order.checkout.deposit_amount_cent, order.checkout.deposit_amount)
)}`"
:value="`¥${money(amountYuan(order.checkout.deposit_amount_cent))}`"
/>
<van-cell
title="额外消耗品已用"
:value="`¥${money(
amountYuan(order.checkout.consumable_amount_cent, order.checkout.consumable_amount)
)}`"
:value="`¥${money(amountYuan(order.checkout.consumable_amount_cent))}`"
/>
<van-cell
title="押金赔付扣除"
:value="`¥${money(
amountYuan(
order.checkout.deposit_deduct_amount_cent,
order.checkout.deposit_deduct_amount
)
)}`"
:value="`¥${money(amountYuan(order.checkout.deposit_deduct_amount_cent))}`"
value-class="red-text"
/>
<van-cell
v-if="isRenter"
title="退还租客"
:value="`¥${money(
amountYuan(
order.checkout.renter_refund_amount_cent,
order.checkout.renter_refund_amount
)
)}`"
:value="`¥${money(amountYuan(order.checkout.renter_refund_amount_cent))}`"
value-class="green-text"
/>
<van-cell
v-if="isOwner"
title="号主最终收入"
:value="`¥${money(
amountYuan(
order.checkout.owner_income_amount_cent,
order.checkout.owner_income_amount
)
)}`"
:value="`¥${money(amountYuan(order.checkout.owner_income_amount_cent))}`"
value-class="green-text"
/>
<van-cell