+7
-4
@@ -530,6 +530,9 @@ "use strict"; | ||
| for (const goods of goodsList) { | ||
| const availableNum = Math.max(0, goods.number - (goods.returnNum || 0)); | ||
| // ✅ 强制转数字,彻底解决 NaN | ||
| const availableNum = Number(goods.number || 0) - Number(goods.returnNum || 0); | ||
| const safeNum = Math.max(0, availableNum); | ||
| let basePrice = new bignumber_js_1.BigNumber(0); | ||
| if (goods.is_temporary || goods.isTemporary) { | ||
| basePrice = new bignumber_js_1.BigNumber(goods?.discountSaleAmount ?? 0); | ||
| // ✅ 也强制转数字 | ||
| basePrice = new bignumber_js_1.BigNumber(Number(goods.discountSaleAmount) || 0); | ||
| } | ||
@@ -540,5 +543,5 @@ else if (goods.is_gift || goods.isGift) { | ||
| else { | ||
| basePrice = new bignumber_js_1.BigNumber(goods.skuData?.salePrice ?? goods.salePrice); // SKU原价优先 | ||
| basePrice = new bignumber_js_1.BigNumber(goods.skuData?.salePrice ?? goods.salePrice ?? 0); | ||
| } | ||
| total = total.plus(basePrice.multipliedBy(availableNum)); | ||
| total = total.plus(basePrice.multipliedBy(safeNum)); | ||
| } | ||
@@ -545,0 +548,0 @@ return truncateToTwoDecimals(total.toNumber()); |
+1
-1
| { | ||
| "name": "ysk-utils", | ||
| "version": "1.0.85", | ||
| "version": "1.0.87", | ||
| "main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
273062
0.05%6508
0.05%1
Infinity%