fixed withdraw
This commit is contained in:
+30
-8
@@ -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<number, string> = {
|
||||
3: 'ناموفق',
|
||||
}
|
||||
|
||||
const WITHDRAW_STATUS_LABELS: Record<number, string> = {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user