feat(finance): 添加财务记录状态显示功能

- 在 API 类型定义中添加订单状态字段及其枚举值
- 更新桌面端财务记录表格界面,增加状态列并调整列宽布局
- 实现移动端财务记录表格的状态列显示和样式适配
- 添加财务记录状态的颜色标识和标签显示逻辑
- 在多语言文件中添加状态相关的翻译内容
- 修复充值组件中的金额字段引用错误
- 重构提现功能中的汇率计算逻辑,提高准确性
This commit is contained in:
JiaJun
2026-07-07 16:29:05 +08:00
parent 8519a36ab7
commit 8721a47a61
12 changed files with 135 additions and 23 deletions

View File

@@ -16,7 +16,7 @@ function formatNumber(locale: string, value: number) {
}
function getInitialWithdrawAmount(
selectedRate: number,
selectedExchangeRate: number,
maxWithdrawAmount: number,
) {
if (maxWithdrawAmount <= 0) {
@@ -25,10 +25,22 @@ function getInitialWithdrawAmount(
return Math.min(
maxWithdrawAmount,
Math.max(1, Math.round(selectedRate * QUICK_FIAT_AMOUNTS[0])),
Math.max(1, Math.round(QUICK_FIAT_AMOUNTS[0] / selectedExchangeRate)),
)
}
function getCurrencyExchangeRate(
config: DepositWithdrawConfig,
currencyCode: string,
fallbackRate: number,
) {
const configuredRate = config.rates.find(
(rate) => rate.currency === currencyCode,
)?.diamondsPerFiatUnitValue
return configuredRate && configuredRate > 0 ? configuredRate : fallbackRate
}
function getActiveCurrencyCode(
currencies: DepositWithdrawConfig['currencies'],
selectedCurrencyCode: string,
@@ -108,9 +120,11 @@ export function useWithdrawVm() {
currencyCode,
)
const selectedRate = selectedCurrency.withdrawCoinsPerFiatValue || 1
const selectedExchangeRate =
config.rates.find((rate) => rate.currency === selectedCurrency.code)
?.diamondsPerFiatUnitValue || selectedRate
const selectedExchangeRate = getCurrencyExchangeRate(
config,
selectedCurrency.code,
selectedRate,
)
const sortedPayChannels = useMemo(
() =>
[
@@ -200,11 +214,13 @@ export function useWithdrawVm() {
}, [bankCode, sortedBanks])
useEffect(() => {
if (!hasInitializedAmount && selectedRate > 0) {
setAmount(getInitialWithdrawAmount(selectedRate, maxWithdrawAmount))
if (!hasInitializedAmount && selectedExchangeRate > 0) {
setAmount(
getInitialWithdrawAmount(selectedExchangeRate, maxWithdrawAmount),
)
setHasInitializedAmount(true)
}
}, [hasInitializedAmount, maxWithdrawAmount, selectedRate, setAmount])
}, [hasInitializedAmount, maxWithdrawAmount, selectedExchangeRate, setAmount])
useEffect(() => {
if (amount > maxWithdrawAmount) {
@@ -216,12 +232,12 @@ export function useWithdrawVm() {
return QUICK_FIAT_AMOUNTS.map((fiatAmount) => ({
diamonds: Math.min(
maxWithdrawAmount,
Math.max(1, Math.round(selectedRate * fiatAmount)),
Math.max(1, Math.round(fiatAmount / selectedExchangeRate)),
),
id: `quick-${selectedCurrency.code}-${fiatAmount}`,
preview: `${selectedCurrency.code} ${formatNumber(locale, fiatAmount)}`,
}))
}, [locale, maxWithdrawAmount, selectedCurrency.code, selectedRate])
}, [locale, maxWithdrawAmount, selectedCurrency.code, selectedExchangeRate])
const resetForm = useCallback(() => {
const nextCurrencyCode = config.currencies[0]?.code ?? DEFAULT_CURRENCY_CODE
@@ -229,9 +245,15 @@ export function useWithdrawVm() {
config.currencies,
nextCurrencyCode,
)
const nextRate = nextCurrency.withdrawCoinsPerFiatValue || 1
const nextExchangeRate = getCurrencyExchangeRate(
config,
nextCurrency.code,
nextCurrency.withdrawCoinsPerFiatValue || 1,
)
setAmountState(getInitialWithdrawAmount(nextRate, maxWithdrawAmount))
setAmountState(
getInitialWithdrawAmount(nextExchangeRate, maxWithdrawAmount),
)
setHasInitializedAmount(true)
setCurrencyCode(nextCurrencyCode)
setPaymentChannelCode(sortedPayChannels[0]?.code ?? '')
@@ -240,7 +262,7 @@ export function useWithdrawVm() {
setBankAccount('')
setReceiverEmail('')
setReceiverPhone('')
}, [config.currencies, maxWithdrawAmount, sortedPayChannels])
}, [config, maxWithdrawAmount, sortedPayChannels])
const selectedCurrencyPreview = useMemo(
() => ({
@@ -255,7 +277,7 @@ export function useWithdrawVm() {
}),
convertibleValue: `${formatNumber(
locale,
selectedRate > 0 ? amount / selectedRate : 0,
selectedExchangeRate > 0 ? amount * selectedExchangeRate : 0,
)} ${selectedCurrency.code}`,
}),
[
@@ -264,7 +286,6 @@ export function useWithdrawVm() {
selectedCurrency.code,
selectedCurrency.label,
selectedExchangeRate,
selectedRate,
t,
],
)