Răsfoiți Sursa

Add withdrawal data type and localization support

- Introduced a new type for withdrawal data in WalletRecordCard.vue to handle withdrawal requests.
- Implemented a function to validate withdrawal data structure.
- Updated localization files (English, Indonesian, Chinese) to include new translations for withdrawal-related messages, enhancing user experience across multiple languages.
0es 1 lună în urmă
părinte
comite
fb42e6ac89

+ 26 - 0
app/components/wallet/WalletRecordCard.vue

@@ -25,6 +25,12 @@ type WalletRecordRechargeData = {
   provider?: string
 }
 
+type WalletRecordWithdrawData = {
+  amount?: number | string
+  actualAmount?: number | string
+  currency?: string
+}
+
 const props = defineProps<{
   records: WalletRecordVo[]
   walletType: WalletType
@@ -98,6 +104,16 @@ const isWalletRecordRechargeData = (data: WalletRecordData): data is WalletRecor
   return typeof data.provider === 'string'
 }
 
+const isWalletRecordWithdrawData = (data: WalletRecordData): data is WalletRecordWithdrawData => {
+  return (
+    typeof data.amount === 'number'
+    || typeof data.amount === 'string'
+    || typeof data.actualAmount === 'number'
+    || typeof data.actualAmount === 'string'
+    || typeof data.currency === 'string'
+  )
+}
+
 // Backend walletType (int) mapping: best-effort.
 // Common patterns: 1=goldCoin, 2=diamond, 3=bean
 const currencyNameByBackendWalletType = (walletType: unknown) => {
@@ -227,6 +243,16 @@ const buildTitleAndDescription = (type: WalletType, record: WalletRecordVo) => {
     }
   }
 
+  // 3.5) Bean: withdraw apply
+  if (type === 'bean' && bizType === 30013) {
+    const wd = isWalletRecordWithdrawData(data) ? data : {}
+    const amountText = formatPlainNumber(wd.actualAmount ?? wd.amount ?? record.amount)
+    return {
+      title: t('wallet.record.title.withdrawApply'),
+      description: t('wallet.record.desc.withdrawApply', { amount: amountText }),
+    }
+  }
+
   // 4) Fallback (no rule matched)
   return {
     title: t(`wallet.record.bizTypeFallback.${bizType}`),

+ 5 - 2
i18n/locales/en.json

@@ -249,6 +249,7 @@
         "orderRefund": "Order refund",
         "orderIncome": "Order income",
         "refundClawback": "Refund clawback",
+        "withdrawApply": "Withdrawal request",
         "operationGrant": "Operations grant",
         "operationDeduct": "Operations deduction"
       },
@@ -258,7 +259,8 @@
         "playmateOrder": "Place [{category}] order to [{seller}]",
         "orderRefund": "Refund for order [{orderNo}]",
         "orderIncome": "Completed [{category}] order",
-        "refundClawback": "[{user}] order refund"
+        "refundClawback": "[{user}] order refund",
+        "withdrawApply": "Apply to withdraw {amount} IDR"
       },
       "bizTypeFallback": {
         "30000": "Order settlement",
@@ -266,7 +268,8 @@
         "30002": "Recharge",
         "30003": "Order refund",
         "30004": "Order refund",
-        "30008": "Exchange"
+        "30008": "Exchange",
+        "30013": "Withdrawal request"
       }
     },
     "dateSelect": {

+ 5 - 2
i18n/locales/id.json

@@ -250,6 +250,7 @@
         "orderRefund": "Refund pesanan",
         "orderIncome": "Pendapatan pesanan",
         "refundClawback": "Penarikan kembali refund",
+        "withdrawApply": "Pengajuan penarikan",
         "operationGrant": "Pemberian operasi",
         "operationDeduct": "Pengurangan operasi"
       },
@@ -259,7 +260,8 @@
         "playmateOrder": "Buat pesanan [{category}] ke [{seller}]",
         "orderRefund": "Refund untuk pesanan [{orderNo}]",
         "orderIncome": "Menyelesaikan pesanan [{category}]",
-        "refundClawback": "Refund pesanan [{user}]"
+        "refundClawback": "Refund pesanan [{user}]",
+        "withdrawApply": "Ajukan penarikan {amount} IDR"
       },
       "bizTypeFallback": {
         "30000": "Penyelesaian pesanan",
@@ -267,7 +269,8 @@
         "30002": "Isi ulang",
         "30003": "Refund pesanan",
         "30004": "Refund pesanan",
-        "30008": "Tukar"
+        "30008": "Tukar",
+        "30013": "Pengajuan penarikan"
       }
     },
     "dateSelect": {

+ 5 - 2
i18n/locales/zh.json

@@ -250,6 +250,7 @@
         "orderRefund": "订单退款",
         "orderIncome": "订单收入",
         "refundClawback": "退款追回",
+        "withdrawApply": "提现申请",
         "operationGrant": "运营发放",
         "operationDeduct": "运营扣减"
       },
@@ -259,7 +260,8 @@
         "playmateOrder": "下单[{category}]给[{seller}]",
         "orderRefund": "订单[{orderNo}]退款",
         "orderIncome": "完成[{category}]订单",
-        "refundClawback": "[{user}]订单退款"
+        "refundClawback": "[{user}]订单退款",
+        "withdrawApply": "申请提现 {amount} IDR"
       },
       "bizTypeFallback": {
         "30000": "订单结算",
@@ -267,7 +269,8 @@
         "30002": "充值",
         "30003": "订单退款",
         "30004": "订单退款",
-        "30008": "兑换"
+        "30008": "兑换",
+        "30013": "提现申请"
       }
     },
     "dateSelect": {