fix recharge yumi local currency amount
This commit is contained in:
parent
219b1744ef
commit
13f8d1446f
@ -830,6 +830,10 @@ var default_api = 'https://api.global-interaction.com/';
|
|||||||
var amountUsd = normalizeAmountUsd(
|
var amountUsd = normalizeAmountUsd(
|
||||||
item.amountUsd || item.amount_usd
|
item.amountUsd || item.amount_usd
|
||||||
);
|
);
|
||||||
|
var localAmount = normalizeAmountUsd(
|
||||||
|
item.amount || item.amountLocal || item.amount_local
|
||||||
|
);
|
||||||
|
var currencyCode = item.currency || item.currency_code || '';
|
||||||
return {
|
return {
|
||||||
product_id: item.id,
|
product_id: item.id,
|
||||||
productId: item.id,
|
productId: item.id,
|
||||||
@ -849,7 +853,11 @@ var default_api = 'https://api.global-interaction.com/';
|
|||||||
amount_usdt: amountUsd,
|
amount_usdt: amountUsd,
|
||||||
amount_usdt_micro: Math.round(amountUsd * 1000000),
|
amount_usdt_micro: Math.round(amountUsd * 1000000),
|
||||||
amount_minor: decimalToMinor(amountUsd),
|
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,
|
raw: item,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2538,11 +2538,22 @@
|
|||||||
return Math.random().toString(36).slice(2, 14);
|
return Math.random().toString(36).slice(2, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 本地三方支付按后台 USD->本币汇率展示;无有效汇率时回退 USD 展示但后端仍会拒绝不可用配置。
|
// Yumi 商品接口会直接返回本币 amount;优先用它,避免把 1 USD 误显示成 1 EGP。
|
||||||
|
// 其他应用没有本币商品金额时,继续按后台 USD->本币汇率展示。
|
||||||
function convertedAmount(product, method) {
|
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 usd = productUSD(product);
|
||||||
var rate = Number(method.usd_to_currency_rate || 0);
|
var rate = Number(method.usd_to_currency_rate || 0);
|
||||||
var currency = method.currency_code || 'USD';
|
|
||||||
var amount =
|
var amount =
|
||||||
Number.isFinite(rate) && rate > 0 ? usd * rate : usd;
|
Number.isFinite(rate) && rate > 0 ? usd * rate : usd;
|
||||||
return (
|
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) {
|
function productUSD(product) {
|
||||||
var directUSDT = Number(
|
var directUSDT = Number(
|
||||||
product.amount_usdt || product.amountUsdt || 0
|
product.amount_usdt || product.amountUsdt || 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user