@pisell/pisellos 1.0.21 → 1.0.22

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.
@@ -507,7 +507,15 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
507
507
  return Number(product === null || product === void 0 ? void 0 : product.price) === 0;
508
508
  };
509
509
  var isAllProductUsedOrFree = (_item$applicableProdu = item.applicableProductIds) === null || _item$applicableProdu === void 0 ? void 0 : _item$applicableProdu.every(function (id) {
510
- return (allUsedProductIds === null || allUsedProductIds === void 0 ? void 0 : allUsedProductIds.includes(id)) || isProductFree(id);
510
+ var _item$applicableProdu2;
511
+ // 检查当前 id是否在 item.applicableProductIds 里出现了几次,且要求次数和 item.applicableProductIds 里出现的次数一致
512
+ var sameIdTimes = ((_item$applicableProdu2 = item.applicableProductIds) === null || _item$applicableProdu2 === void 0 ? void 0 : _item$applicableProdu2.filter(function (n) {
513
+ return n === id;
514
+ }).length) || 1;
515
+ var targetIdTimes = (allUsedProductIds === null || allUsedProductIds === void 0 ? void 0 : allUsedProductIds.filter(function (n) {
516
+ return n === id;
517
+ }).length) || 1;
518
+ return targetIdTimes >= sameIdTimes && (allUsedProductIds === null || allUsedProductIds === void 0 ? void 0 : allUsedProductIds.includes(id)) || isProductFree(id);
511
519
  });
512
520
  if (!item.isSelected && isAllProductUsedOrFree) {
513
521
  item.isDisabledForProductUsed = true;
@@ -349,7 +349,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
349
349
  return Number(product == null ? void 0 : product.price) === 0;
350
350
  };
351
351
  const isAllProductUsedOrFree = (_a2 = item.applicableProductIds) == null ? void 0 : _a2.every((id) => {
352
- return (allUsedProductIds == null ? void 0 : allUsedProductIds.includes(id)) || isProductFree(id);
352
+ var _a3;
353
+ const sameIdTimes = ((_a3 = item.applicableProductIds) == null ? void 0 : _a3.filter((n) => n === id).length) || 1;
354
+ const targetIdTimes = (allUsedProductIds == null ? void 0 : allUsedProductIds.filter((n) => n === id).length) || 1;
355
+ return targetIdTimes >= sameIdTimes && (allUsedProductIds == null ? void 0 : allUsedProductIds.includes(id)) || isProductFree(id);
353
356
  });
354
357
  if (!item.isSelected && isAllProductUsedOrFree) {
355
358
  item.isDisabledForProductUsed = true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.21",
4
+ "version": "1.0.22",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",