@pisell/pisellos 2.2.55 → 2.2.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -332,7 +332,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
332
332
|
// 1. 筛选 status === 1 && disable === 0的数据
|
|
333
333
|
// 2. 检查列表里是否有 code=WALLET_PASS的数据,如果没有,则列表里如果有 PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 则删除他们
|
|
334
334
|
// 如果有 code = WALLET_PASS的数据,则列表里PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 的channel_application 指向 WALLET_PASS 的 channel_application
|
|
335
|
-
payMethods.filter(function (method) {
|
|
335
|
+
payMethods = payMethods.filter(function (method) {
|
|
336
336
|
return method.status === 1 && method.disable === 0;
|
|
337
337
|
});
|
|
338
338
|
walletPassMethod = payMethods.find(function (method) {
|
|
@@ -442,8 +442,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
442
442
|
return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
|
|
443
443
|
case 46:
|
|
444
444
|
this.logInfo('getPayMethodListAsync completed successfully', {
|
|
445
|
-
|
|
446
|
-
hasCache: cachedMethods.length > 0
|
|
445
|
+
payMethods: payMethods
|
|
447
446
|
});
|
|
448
447
|
return _context4.abrupt("return", payMethods);
|
|
449
448
|
case 50:
|
|
@@ -2014,10 +2013,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2014
2013
|
// 计算有效支付金额:支付金额 + 抹零金额的绝对值
|
|
2015
2014
|
// 当 rounding_amount 为负数时,表示抹掉的金额,按绝对值计算有效支付
|
|
2016
2015
|
// 例如:amount=15, rounding_amount=-0.2,有效支付=15.2(抹掉0.2元零头)
|
|
2016
|
+
// 例2:amount=15,rounding_amount=0.2,有效支付 14.8
|
|
2017
2017
|
var paymentAmount = new Decimal(payment.amount || 0);
|
|
2018
2018
|
var roundingAmount = new Decimal(payment.rounding_amount || 0);
|
|
2019
|
-
|
|
2020
|
-
var effectiveAmount = paymentAmount.plus(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
|
|
2019
|
+
var effectiveAmount = paymentAmount.minus(roundingAmount);
|
|
2021
2020
|
return sum.plus(effectiveAmount);
|
|
2022
2021
|
} catch (error) {
|
|
2023
2022
|
console.warn("[PaymentModule] \u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: amount=".concat(payment.amount, ", rounding_amount=").concat(payment.rounding_amount, "\uFF0C\u8DF3\u8FC7\u8BA1\u7B97"));
|
|
@@ -2045,7 +2044,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2045
2044
|
code: p.code,
|
|
2046
2045
|
amount: p.amount,
|
|
2047
2046
|
rounding_amount: p.rounding_amount || '0.00',
|
|
2048
|
-
effective_amount: new Decimal(p.amount || 0).
|
|
2047
|
+
effective_amount: new Decimal(p.amount || 0).minus(new Decimal(p.rounding_amount || 0)).toFixed(2)
|
|
2049
2048
|
};
|
|
2050
2049
|
}),
|
|
2051
2050
|
说明: '有效支付金额包含抹零计算(amount + |rounding_amount|)'
|
|
@@ -1567,8 +1567,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1567
1567
|
quantity: 1,
|
|
1568
1568
|
discount_list: updatedMainDiscountList,
|
|
1569
1569
|
bundle: newBundleWithDiscount,
|
|
1570
|
-
total: newTotalWithDiscount,
|
|
1571
|
-
origin_total: newOriginTotalWithDiscount
|
|
1570
|
+
total: new Decimal(newTotalWithDiscount).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber(),
|
|
1571
|
+
origin_total: new Decimal(newOriginTotalWithDiscount).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber()
|
|
1572
1572
|
})));
|
|
1573
1573
|
|
|
1574
1574
|
// 第二个:包含原始bundle (qty=原quantity-1)
|
|
@@ -1630,6 +1630,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1630
1630
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1631
1631
|
}, new Decimal(newTotalOriginal)).toNumber();
|
|
1632
1632
|
}
|
|
1633
|
+
newTotalOriginal = new Decimal(newTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1634
|
+
newOriginTotalOriginal = new Decimal(newOriginTotalOriginal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1633
1635
|
|
|
1634
1636
|
// 添加第二个主商品:qty=原quantity-1,包含原始bundle
|
|
1635
1637
|
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
@@ -1734,6 +1736,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1734
1736
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1735
1737
|
}, new Decimal(newTotal)).toNumber();
|
|
1736
1738
|
}
|
|
1739
|
+
newTotal = new Decimal(newTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1740
|
+
newOriginTotal = new Decimal(newOriginTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
|
|
1737
1741
|
|
|
1738
1742
|
// 生成最终的主商品
|
|
1739
1743
|
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
@@ -204,7 +204,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
async filterPayMethods(payMethods) {
|
|
207
|
-
payMethods.filter((method) => method.status === 1 && method.disable === 0);
|
|
207
|
+
payMethods = payMethods.filter((method) => method.status === 1 && method.disable === 0);
|
|
208
208
|
const walletPassMethod = payMethods.find((method) => method.code === "WALLET_PASS");
|
|
209
209
|
if (walletPassMethod) {
|
|
210
210
|
payMethods.forEach((method) => {
|
|
@@ -249,8 +249,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
249
249
|
payMethods
|
|
250
250
|
);
|
|
251
251
|
this.logInfo("getPayMethodListAsync completed successfully", {
|
|
252
|
-
|
|
253
|
-
hasCache: cachedMethods.length > 0
|
|
252
|
+
payMethods
|
|
254
253
|
});
|
|
255
254
|
return payMethods;
|
|
256
255
|
} catch (error) {
|
|
@@ -1030,7 +1029,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
1030
1029
|
}
|
|
1031
1030
|
const paymentAmount = new import_decimal.Decimal(payment.amount || 0);
|
|
1032
1031
|
const roundingAmount = new import_decimal.Decimal(payment.rounding_amount || 0);
|
|
1033
|
-
const effectiveAmount = paymentAmount.
|
|
1032
|
+
const effectiveAmount = paymentAmount.minus(roundingAmount);
|
|
1034
1033
|
return sum.plus(effectiveAmount);
|
|
1035
1034
|
} catch (error) {
|
|
1036
1035
|
console.warn(`[PaymentModule] 无效的支付金额: amount=${payment.amount}, rounding_amount=${payment.rounding_amount},跳过计算`);
|
|
@@ -1052,7 +1051,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
1052
1051
|
code: p.code,
|
|
1053
1052
|
amount: p.amount,
|
|
1054
1053
|
rounding_amount: p.rounding_amount || "0.00",
|
|
1055
|
-
effective_amount: new import_decimal.Decimal(p.amount || 0).
|
|
1054
|
+
effective_amount: new import_decimal.Decimal(p.amount || 0).minus(new import_decimal.Decimal(p.rounding_amount || 0)).toFixed(2)
|
|
1056
1055
|
})),
|
|
1057
1056
|
说明: "有效支付金额包含抹零计算(amount + |rounding_amount|)"
|
|
1058
1057
|
});
|
|
@@ -1270,8 +1270,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1270
1270
|
quantity: 1,
|
|
1271
1271
|
discount_list: updatedMainDiscountList,
|
|
1272
1272
|
bundle: newBundleWithDiscount,
|
|
1273
|
-
total: newTotalWithDiscount,
|
|
1274
|
-
origin_total: newOriginTotalWithDiscount
|
|
1273
|
+
total: new import_decimal.default(newTotalWithDiscount).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber(),
|
|
1274
|
+
origin_total: new import_decimal.default(newOriginTotalWithDiscount).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber()
|
|
1275
1275
|
})
|
|
1276
1276
|
);
|
|
1277
1277
|
if (mainProductQuantity > 1) {
|
|
@@ -1329,6 +1329,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1329
1329
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1330
1330
|
}, new import_decimal.default(newTotalOriginal)).toNumber();
|
|
1331
1331
|
}
|
|
1332
|
+
newTotalOriginal = new import_decimal.default(newTotalOriginal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1333
|
+
newOriginTotalOriginal = new import_decimal.default(newOriginTotalOriginal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1332
1334
|
result.push(
|
|
1333
1335
|
this.hooks.setProduct(mainProduct, {
|
|
1334
1336
|
...mainProductData,
|
|
@@ -1412,6 +1414,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
1412
1414
|
return accumulator.add(currentPrice.mul(currentNum));
|
|
1413
1415
|
}, new import_decimal.default(newTotal)).toNumber();
|
|
1414
1416
|
}
|
|
1417
|
+
newTotal = new import_decimal.default(newTotal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1418
|
+
newOriginTotal = new import_decimal.default(newOriginTotal).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP).toNumber();
|
|
1415
1419
|
result.push(
|
|
1416
1420
|
this.hooks.setProduct(mainProduct, {
|
|
1417
1421
|
...mainProductData,
|