diff --git a/common/api.js b/common/api.js index 2859e27..77864ce 100644 --- a/common/api.js +++ b/common/api.js @@ -830,6 +830,10 @@ var default_api = 'https://api.global-interaction.com/'; var amountUsd = normalizeAmountUsd( item.amountUsd || item.amount_usd ); + var localAmount = normalizeAmountUsd( + item.amount || item.amountLocal || item.amount_local + ); + var currencyCode = item.currency || item.currency_code || ''; return { product_id: item.id, productId: item.id, @@ -849,7 +853,11 @@ var default_api = 'https://api.global-interaction.com/'; amount_usdt: amountUsd, amount_usdt_micro: Math.round(amountUsd * 1000000), amount_minor: decimalToMinor(amountUsd), - currency_code: item.currency || item.currency_code || '', + // Yumi commodity returns both USD amount and local-currency amount; keep both so H5 display does not treat USD as EGP. + local_amount: localAmount, + localAmount: localAmount, + currency_code: currencyCode, + currencyCode: currencyCode, raw: item, }; } diff --git a/recharge/index.html b/recharge/index.html index 16c7caa..c06be85 100644 --- a/recharge/index.html +++ b/recharge/index.html @@ -2538,11 +2538,22 @@ return Math.random().toString(36).slice(2, 14); } - // 本地三方支付按后台 USD->本币汇率展示;无有效汇率时回退 USD 展示但后端仍会拒绝不可用配置。 + // Yumi 商品接口会直接返回本币 amount;优先用它,避免把 1 USD 误显示成 1 EGP。 + // 其他应用没有本币商品金额时,继续按后台 USD->本币汇率展示。 function convertedAmount(product, method) { + var currency = method.currency_code || 'USD'; + var localAmount = productLocalAmount(product, currency); + if (localAmount > 0) { + return ( + localAmount.toFixed( + currencyFractionDigits(currency) + ) + + ' ' + + currency + ); + } var usd = productUSD(product); var rate = Number(method.usd_to_currency_rate || 0); - var currency = method.currency_code || 'USD'; var amount = Number.isFinite(rate) && rate > 0 ? usd * rate : usd; return ( @@ -2552,6 +2563,29 @@ ); } + function productLocalAmount(product, currency) { + var productCurrency = String( + product.currency_code || product.currencyCode || '' + ).toUpperCase(); + var methodCurrency = String(currency || '').toUpperCase(); + if ( + productCurrency && + methodCurrency && + productCurrency !== methodCurrency + ) { + return 0; + } + var amount = Number( + product.local_amount || + product.localAmount || + product.amount || + product.amountLocal || + product.amount_local || + 0 + ); + return Number.isFinite(amount) && amount > 0 ? amount : 0; + } + function productUSD(product) { var directUSDT = Number( product.amount_usdt || product.amountUsdt || 0