fix: parse formatted Yumi recharge amounts

This commit is contained in:
zhx 2026-07-14 17:59:04 +08:00
parent ee32247f4a
commit 1edc2e8d17

View File

@ -939,11 +939,19 @@ var default_api = 'https://api.global-interaction.com/';
]);
}
function normalizeAmountUsd(value) {
var amount = Number(value || 0);
function normalizeFormattedNumber(value) {
// Yumi legacy commodity responses can serialize large numeric values with
// thousands separators (for example, "27,600,000"). Normalizing at the
// adapter boundary preserves the server's numeric value before display
// and order payload fields independently fall back to zero.
var amount = Number(String(value || 0).replace(/,/g, ''));
return Number.isFinite(amount) && amount > 0 ? amount : 0;
}
function normalizeAmountUsd(value) {
return normalizeFormattedNumber(value);
}
function decimalToMinor(value) {
return Math.round(normalizeAmountUsd(value) * 100);
}
@ -1042,8 +1050,10 @@ var default_api = 'https://api.global-interaction.com/';
options = options || {};
var products = (options.commodity || options.products || []).map(
function (item) {
var content = Number(item.content || 0);
var awardContent = Number(
// Coin quantities use the same formatter because Yumi returns
// content as a comma-formatted string while the UI expects a number.
var content = normalizeFormattedNumber(item.content);
var awardContent = normalizeFormattedNumber(
item.awardContent || item.award_content || 0
);
var amountUsd = normalizeAmountUsd(