统一金额分制重构
This commit is contained in:
@@ -8,7 +8,7 @@ import QRCode from 'qrcode'
|
||||
import { fetchOrderChat } from '@/features/chats/api/chats'
|
||||
import { createDispute } from '@/features/disputes'
|
||||
import { uploadFile } from '@/shared/api/files'
|
||||
import { centToYuan, formatMoney } from '@/shared/utils/money'
|
||||
import { centToYuan, formatCent, formatMoney } from '@/shared/utils/money'
|
||||
import {
|
||||
acceptCheckout,
|
||||
cancelOrder,
|
||||
@@ -606,26 +606,24 @@ function money(value: unknown) {
|
||||
return formatMoney(readNumber(value))
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -645,16 +643,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) {
|
||||
@@ -789,13 +781,13 @@ async function copyListingCode() {
|
||||
<div class="metric-card">
|
||||
<span class="metric-label">押金</span>
|
||||
<strong class="metric-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="metric-note"
|
||||
>已免押 ¥{{
|
||||
money(amountYuan(order.deposit_waived_amount_cent, order.deposit_waived_amount))
|
||||
money(amountYuan(order.deposit_waived_amount_cent))
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
@@ -979,81 +971,40 @@ async function copyListingCode() {
|
||||
<div class="summary-row">
|
||||
<span>实际结算租金</span>
|
||||
<strong
|
||||
>¥{{
|
||||
money(
|
||||
amountYuan(order.checkout.display_amount_cent, order.checkout.display_amount)
|
||||
)
|
||||
}}</strong
|
||||
>¥{{ money(amountYuan(order.checkout.display_amount_cent)) }}</strong
|
||||
>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span>预收押金</span>
|
||||
<strong>
|
||||
¥{{
|
||||
money(
|
||||
amountYuan(order.checkout.deposit_amount_cent, order.checkout.deposit_amount)
|
||||
)
|
||||
}}
|
||||
<em
|
||||
v-if="
|
||||
amountYuan(order.deposit_waived_amount_cent, order.deposit_waived_amount) > 0
|
||||
"
|
||||
>已免押 ¥{{
|
||||
money(amountYuan(order.deposit_waived_amount_cent, order.deposit_waived_amount))
|
||||
}}</em
|
||||
¥{{ money(amountYuan(order.checkout.deposit_amount_cent)) }}
|
||||
<em v-if="amountYuan(order.deposit_waived_amount_cent) > 0"
|
||||
>已免押 ¥{{ money(amountYuan(order.deposit_waived_amount_cent)) }}</em
|
||||
>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span>额外消耗品已用</span>
|
||||
<strong class="warning"
|
||||
>¥{{
|
||||
money(
|
||||
amountYuan(
|
||||
order.checkout.consumable_amount_cent,
|
||||
order.checkout.consumable_amount
|
||||
)
|
||||
)
|
||||
}}</strong
|
||||
>¥{{ money(amountYuan(order.checkout.consumable_amount_cent)) }}</strong
|
||||
>
|
||||
</div>
|
||||
<div class="summary-row">
|
||||
<span>押金赔付扣除</span>
|
||||
<strong class="warning"
|
||||
>¥{{
|
||||
money(
|
||||
amountYuan(
|
||||
order.checkout.deposit_deduct_amount_cent,
|
||||
order.checkout.deposit_deduct_amount
|
||||
)
|
||||
)
|
||||
}}</strong
|
||||
>¥{{ money(amountYuan(order.checkout.deposit_deduct_amount_cent)) }}</strong
|
||||
>
|
||||
</div>
|
||||
<div v-if="isRenter" class="summary-row highlight">
|
||||
<span>退还租客(未使用租金 + 剩余押金)</span>
|
||||
<strong class="amount"
|
||||
>¥{{
|
||||
money(
|
||||
amountYuan(
|
||||
order.checkout.renter_refund_amount_cent,
|
||||
order.checkout.renter_refund_amount
|
||||
)
|
||||
)
|
||||
}}</strong
|
||||
>¥{{ money(amountYuan(order.checkout.renter_refund_amount_cent)) }}</strong
|
||||
>
|
||||
</div>
|
||||
<div v-if="isOwner" class="summary-row highlight">
|
||||
<span>号主最终收入(租金 + 押金赔付)</span>
|
||||
<strong class="amount"
|
||||
>¥{{
|
||||
money(
|
||||
amountYuan(
|
||||
order.checkout.owner_income_amount_cent,
|
||||
order.checkout.owner_income_amount
|
||||
)
|
||||
)
|
||||
}}</strong
|
||||
>¥{{ money(amountYuan(order.checkout.owner_income_amount_cent)) }}</strong
|
||||
>
|
||||
</div>
|
||||
<div v-if="order.checkout.content" class="summary-note">
|
||||
@@ -1109,7 +1060,7 @@ async function copyListingCode() {
|
||||
v-model="counterForm.deposit_deduct_amount"
|
||||
class="full-control"
|
||||
:min="0"
|
||||
:max="amountYuan(order.deposit_amount_cent, order.deposit_amount)"
|
||||
:max="amountYuan(order.deposit_amount_cent)"
|
||||
:precision="0"
|
||||
controls-position="right"
|
||||
/>
|
||||
@@ -1331,7 +1282,7 @@ async function copyListingCode() {
|
||||
<div class="pay-summary">
|
||||
<div class="pay-summary-row">
|
||||
<span>支付金额</span>
|
||||
<strong>¥{{ formatMoney(activePayment.amount_cent / 100) }}</strong>
|
||||
<strong>¥{{ formatCent(activePayment.amount_cent) }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="paymentPayURL()" class="pay-qr-section">
|
||||
|
||||
Reference in New Issue
Block a user