From 1000df59314261ece35efa866cb27fb634294ee5 Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 6 Jul 2026 22:16:17 +0330 Subject: [PATCH] fixed withdraw --- components.d.ts | 3 +++ src/utils/usePrice.ts | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/components.d.ts b/components.d.ts index d00ac37..751269f 100644 --- a/components.d.ts +++ b/components.d.ts @@ -15,12 +15,14 @@ declare module 'vue' { AInputPassword: typeof import('ant-design-vue/es')['InputPassword'] AModal: typeof import('ant-design-vue/es')['Modal'] AppCreditLink: typeof import('./src/components/AppCreditLink.vue')['default'] + ARadio: typeof import('ant-design-vue/es')['Radio'] ARadioButton: typeof import('ant-design-vue/es')['RadioButton'] ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup'] ASelect: typeof import('ant-design-vue/es')['Select'] ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] ASlider: typeof import('ant-design-vue/es')['Slider'] ASpin: typeof import('ant-design-vue/es')['Spin'] + ASwitch: typeof import('ant-design-vue/es')['Switch'] ATag: typeof import('ant-design-vue/es')['Tag'] ATextarea: typeof import('ant-design-vue/es')['Textarea'] ATooltip: typeof import('ant-design-vue/es')['Tooltip'] @@ -68,5 +70,6 @@ declare module 'vue' { TransactionSkeleton: typeof import('./src/components/TransactionSkeleton.vue')['default'] VanActionSheet: typeof import('vant/es')['ActionSheet'] VanDialog: typeof import('vant/es')['Dialog'] + VanField: typeof import('vant/es')['Field'] } } diff --git a/src/utils/usePrice.ts b/src/utils/usePrice.ts index f837da5..2ea2590 100644 --- a/src/utils/usePrice.ts +++ b/src/utils/usePrice.ts @@ -51,6 +51,8 @@ type TransactionPriceSource = { cash?: number | null gold?: number | null type?: number | null + sts?: number | null + sts_str?: string | number | null order?: { price?: number | null total_price?: number | null @@ -72,6 +74,18 @@ const ORDER_STATUS_LABELS: Record = { 3: 'ناموفق', } +const WITHDRAW_STATUS_LABELS: Record = { + 1: 'در انتظار تایید', + 2: 'انجام شد', + 3: 'ناموفق', + 4: 'واریز توسط ادمین', + 5: 'پاداش معرفی', + 9: 'سود زیر مجموعه', + 50: 'در انتظار ارسال', + 51: 'ارسال شده', + 52: 'لغو شده', +} + export function getTransactionTradePrice(item: TransactionPriceSource): number { const orderPrice = Number(item.order?.price) if (Number.isFinite(orderPrice) && orderPrice > 0) { @@ -97,22 +111,30 @@ export function getTransactionTradePrice(item: TransactionPriceSource): number { export function resolveTransactionStatusLabel(item?: TransactionPriceSource | null): string { if (!item) return '' - const raw = item.order?.sts_str ?? item.withdraw?.sts_str + const raw = item.order?.sts_str ?? item.withdraw?.sts_str ?? item.sts_str if (typeof raw === 'string') { const trimmed = raw.trim() - if (trimmed && trimmed !== 'بدون مقدار') { + if (trimmed && trimmed !== 'بدون مقدار' && !/^\d+$/.test(trimmed)) { return trimmed } } - if (typeof raw === 'number' || (typeof raw === 'string' && /^\d+$/.test(String(raw).trim()))) { - const mapped = ORDER_STATUS_LABELS[Number(raw)] - if (mapped) return mapped + const sts = item.order?.sts ?? item.withdraw?.sts ?? item.sts + if (sts != null) { + const withdrawLabel = WITHDRAW_STATUS_LABELS[Number(sts)] + if (withdrawLabel) return withdrawLabel + + const orderLabel = ORDER_STATUS_LABELS[Number(sts)] + if (orderLabel) return orderLabel } - const sts = item.order?.sts ?? item.withdraw?.sts - if (sts != null && ORDER_STATUS_LABELS[Number(sts)]) { - return ORDER_STATUS_LABELS[Number(sts)] + if (typeof raw === 'number' || (typeof raw === 'string' && /^\d+$/.test(String(raw).trim()))) { + const numericSts = Number(raw) + const withdrawLabel = WITHDRAW_STATUS_LABELS[numericSts] + if (withdrawLabel) return withdrawLabel + + const orderLabel = ORDER_STATUS_LABELS[numericSts] + if (orderLabel) return orderLabel } if (item.order_id && Number(item.order?.payment_sts) === 4) {