@pisell/pisellos 0.0.559 → 0.0.560

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -91,7 +91,8 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
91
91
  key: "loadProducts",
92
92
  value: function () {
93
93
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref, options) {
94
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, _ref$with_extra, with_extra, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
94
+ var _this$otherParams, _this$otherParams2;
95
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, _ref$with_extra, with_extra, userPlugin, customer_id, _userPlugin$get, channelMap, saleChannel, productsData, sortedList;
95
96
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
96
97
  while (1) switch (_context3.prev = _context3.next) {
97
98
  case 0:
@@ -115,8 +116,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
115
116
  } catch (error) {
116
117
  console.error(error);
117
118
  }
118
- _context3.prev = 4;
119
- _context3.next = 7;
119
+ channelMap = {
120
+ 'online_store': 'online-store',
121
+ 'scan_to_order': 'online-store',
122
+ 'scan_to_order_2': 'online-store',
123
+ 'scan_to_order_3': 'online-store'
124
+ };
125
+ saleChannel = channelMap[(_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel] || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel);
126
+ _context3.prev = 6;
127
+ _context3.next = 9;
120
128
  return this.request.post("/product/query", {
121
129
  open_quotation: 1,
122
130
  open_bundle: 0,
@@ -136,7 +144,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
136
144
  schedule_date: schedule_date,
137
145
  schedule_datetime: schedule_datetime,
138
146
  // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
139
- application_code: 'online-store',
147
+ application_code: saleChannel,
140
148
  with_schedule: with_schedule,
141
149
  is_eject: 1,
142
150
  open_deposit: 1
@@ -147,7 +155,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
147
155
  useCache: true,
148
156
  customToast: function customToast() {}
149
157
  });
150
- case 7:
158
+ case 9:
151
159
  productsData = _context3.sent;
152
160
  sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
153
161
  return Number(b.sort) - Number(a.sort);
@@ -160,15 +168,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
160
168
  // }
161
169
  this.addProduct(sortedList);
162
170
  return _context3.abrupt("return", sortedList);
163
- case 13:
164
- _context3.prev = 13;
165
- _context3.t0 = _context3["catch"](4);
171
+ case 15:
172
+ _context3.prev = 15;
173
+ _context3.t0 = _context3["catch"](6);
166
174
  return _context3.abrupt("return", _context3.t0);
167
- case 16:
175
+ case 18:
168
176
  case "end":
169
177
  return _context3.stop();
170
178
  }
171
- }, _callee3, this, [[4, 13]]);
179
+ }, _callee3, this, [[6, 15]]);
172
180
  }));
173
181
  function loadProducts(_x5, _x6) {
174
182
  return _loadProducts.apply(this, arguments);
@@ -605,6 +605,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
605
605
  }
606
606
  });
607
607
  }
608
+ // 检查商品是否被排除(全品类)
609
+ var isProductIncludedByLimitedData = function isProductIncludedByLimitedData(limitedData, productId) {
610
+ var excludedIds = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.exclude_product_ids) || [];
611
+ var isExcluded = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.filter) === 1 && excludedIds.some(function (id) {
612
+ return String(id) === String(productId);
613
+ });
614
+ return !isExcluded;
615
+ };
608
616
 
609
617
  /**
610
618
  // 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
@@ -1101,9 +1109,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1101
1109
 
1102
1110
  // 判断优惠券是否适用于该商品
1103
1111
  if (limitedData.type === 'product_all') {
1104
- if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
1112
+ if (!isProductIncludedByLimitedData(limitedData, product.id)) {
1105
1113
  return false;
1106
1114
  }
1115
+
1107
1116
  // 检查 package_sub_item_usage_rules
1108
1117
  if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
1109
1118
  return false;
@@ -616,6 +616,27 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
616
616
  }, new Decimal(0));
617
617
  return totalTaxFee;
618
618
  };
619
+ var getCartItemDepositData = function getCartItemDepositData(item) {
620
+ var _target$_productOrigi, _target$_origin, _target$_origin2;
621
+ var target = item;
622
+ return (target === null || target === void 0 || (_target$_productOrigi = target._productOrigin) === null || _target$_productOrigi === void 0 ? void 0 : _target$_productOrigi.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin = target._origin) === null || _target$_origin === void 0 ? void 0 : _target$_origin.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin2 = target._origin) === null || _target$_origin2 === void 0 || (_target$_origin2 = _target$_origin2.product) === null || _target$_origin2 === void 0 ? void 0 : _target$_origin2.custom_deposit_data);
623
+ };
624
+ var getCartItemQuantity = function getCartItemQuantity(item) {
625
+ return new Decimal((item === null || item === void 0 ? void 0 : item.num) || 1);
626
+ };
627
+ var calculateCartItemDepositTotal = function calculateCartItemDepositTotal(item) {
628
+ var _item$deposit;
629
+ var depositData = getCartItemDepositData(item);
630
+ if ((depositData === null || depositData === void 0 ? void 0 : depositData.has_deposit) == 1 && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_fixed) === 'string' && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_percentage) === 'string') {
631
+ var _ref7, _summaryTotal;
632
+ var lineTotal = new Decimal((_ref7 = (_summaryTotal = item.summaryTotal) !== null && _summaryTotal !== void 0 ? _summaryTotal : item.total) !== null && _ref7 !== void 0 ? _ref7 : 0);
633
+ var quantity = getCartItemQuantity(item);
634
+ var fixedTotal = new Decimal(depositData.deposit_fixed || 0).times(quantity);
635
+ var percentageTotal = new Decimal(depositData.deposit_percentage || 0).times(lineTotal);
636
+ return fixedTotal.plus(percentageTotal);
637
+ }
638
+ return new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
639
+ };
619
640
 
620
641
  /**
621
642
  * @title: 计算定金
@@ -630,9 +651,9 @@ export var calculateDeposit = function calculateDeposit(items) {
630
651
  var hasDeposit = false;
631
652
  var total = items.reduce(function (sum, item) {
632
653
  if (item !== null && item !== void 0 && item.deposit) {
633
- var _item$deposit, _item$deposit2;
654
+ var _item$deposit2;
634
655
  hasDeposit = true;
635
- var cartItemTotalPrice = new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
656
+ var cartItemTotalPrice = calculateCartItemDepositTotal(item);
636
657
  // 将协议数据去重合并
637
658
  item === null || item === void 0 || (_item$deposit2 = item.deposit) === null || _item$deposit2 === void 0 || (_item$deposit2 = _item$deposit2.protocols) === null || _item$deposit2 === void 0 || _item$deposit2.forEach(function (protocol) {
638
659
  if (protocols.findIndex(function (p) {
@@ -669,9 +690,9 @@ export var calculateDeposit = function calculateDeposit(items) {
669
690
  * @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
670
691
  * @returns 订单附加费金额(number,金额单位与商品价格一致)
671
692
  */
672
- export var getSurchargeAmount = function getSurchargeAmount(_ref7, surcharge, options) {
673
- var bookingDetail = _ref7.bookingDetail,
674
- bookingId = _ref7.bookingId;
693
+ export var getSurchargeAmount = function getSurchargeAmount(_ref8, surcharge, options) {
694
+ var bookingDetail = _ref8.bookingDetail,
695
+ bookingId = _ref8.bookingId;
675
696
  var isEdit = options.isEdit;
676
697
  // 订单未变更过
677
698
  if (!isEdit) {
@@ -716,17 +737,17 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
716
737
  * 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
717
738
  */
718
739
  var getMainProductTotal = function getMainProductTotal(item) {
719
- var _ref8, _ref9, _item$main_product_se, _item$metadata, _item$metadata2, _item$metadata3, _item$metadata4;
740
+ var _ref9, _ref10, _item$main_product_se, _item$metadata, _item$metadata2, _item$metadata3, _item$metadata4;
720
741
  // 新语义 v2 下 `main_product_selling_price` / `metadata.main_product_selling_price`
721
742
  // 已经是"含 option、含主商品折扣"的主价,直接作为主商品基准,无需再减折扣或加 option。
722
743
  // 仅需叠加 markup / markdown 类 bundle(原价 bundle 的税费单独处理)。
723
- var total = new Decimal((_ref8 = (_ref9 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref9 !== void 0 ? _ref9 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref8 !== void 0 ? _ref8 : 0);
744
+ var total = new Decimal((_ref9 = (_ref10 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref10 !== void 0 ? _ref10 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
724
745
 
725
746
  // 做个兜底 如果新语义价格字段都没有,则切换回老逻辑
726
747
  var hasMainProductPrice = (item === null || item === void 0 ? void 0 : item.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.main_product_original_price) != null;
727
748
  if (!hasMainProductPrice) {
728
- var _ref10, _ref11, _item$main_product_se2, _item$metadata5, _item$_origin3, _item$_originData;
729
- total = new Decimal((_ref10 = (_ref11 = (_item$main_product_se2 = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se2 !== void 0 ? _item$main_product_se2 : item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.main_product_selling_price) !== null && _ref11 !== void 0 ? _ref11 : item.price) !== null && _ref10 !== void 0 ? _ref10 : 0);
749
+ var _ref11, _ref12, _item$main_product_se2, _item$metadata5, _item$_origin3, _item$_originData;
750
+ total = new Decimal((_ref11 = (_ref12 = (_item$main_product_se2 = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se2 !== void 0 ? _item$main_product_se2 : item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.main_product_selling_price) !== null && _ref12 !== void 0 ? _ref12 : item.price) !== null && _ref11 !== void 0 ? _ref11 : 0);
730
751
  var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
731
752
  var _item$metadata6;
732
753
  return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
@@ -747,9 +768,9 @@ var getMainProductTotal = function getMainProductTotal(item) {
747
768
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
748
769
  var bundleItem = _step4.value;
749
770
  if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
750
- var _ref12, _bundleItem$bundle_se2;
771
+ var _ref13, _bundleItem$bundle_se2;
751
772
  // IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price 和 price 其实都已经是折后价格了,不需要单独再减一次
752
- var bundleItemTotal = new Decimal((_ref12 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref12 !== void 0 ? _ref12 : 0);
773
+ var bundleItemTotal = new Decimal((_ref13 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref13 !== void 0 ? _ref13 : 0);
753
774
  total = total.add(bundleItemTotal);
754
775
  }
755
776
  }
@@ -869,12 +890,12 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
869
890
  * @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
870
891
  * @returns 附加费列表(仅返回金额 > 0 的项)
871
892
  */
872
- export var getSurcharge = function getSurcharge(_ref13, options) {
893
+ export var getSurcharge = function getSurcharge(_ref14, options) {
873
894
  var _service$filter;
874
- var service = _ref13.service,
875
- addons = _ref13.addons,
876
- bookingDetail = _ref13.bookingDetail,
877
- bookingId = _ref13.bookingId;
895
+ var service = _ref14.service,
896
+ addons = _ref14.addons,
897
+ bookingDetail = _ref14.bookingDetail,
898
+ bookingId = _ref14.bookingId;
878
899
  var isEdit = options.isEdit,
879
900
  isInScheduleByDate = options.isInScheduleByDate,
880
901
  surcharge_list = options.surcharge_list,
@@ -996,11 +1017,11 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
996
1017
  scheduleById: scheduleById || {},
997
1018
  isInScheduleByDate: isInScheduleByDate
998
1019
  })) {
999
- var _ref14, _bundleItem$bundle_se3;
1020
+ var _ref15, _bundleItem$bundle_se3;
1000
1021
  var _mainQuantity = item.num || 1;
1001
1022
  matchedItems.push({
1002
1023
  isMain: false,
1003
- total: Number((_ref14 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref14 !== void 0 ? _ref14 : 0),
1024
+ total: Number((_ref15 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref15 !== void 0 ? _ref15 : 0),
1004
1025
  quantity: bundleItem.num || bundleItem.quantity || 1,
1005
1026
  item: bundleItem,
1006
1027
  mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
@@ -1216,9 +1237,9 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
1216
1237
  }
1217
1238
  return surchargeWithAmount;
1218
1239
  };
1219
- function resetItemsSurchargeSideEffects(_ref15) {
1220
- var service = _ref15.service,
1221
- addons = _ref15.addons;
1240
+ function resetItemsSurchargeSideEffects(_ref16) {
1241
+ var service = _ref16.service,
1242
+ addons = _ref16.addons;
1222
1243
  var resetItem = function resetItem(item) {
1223
1244
  if (!item) return;
1224
1245
  item.surcharge_fee = 0;
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -0,0 +1,49 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
34
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
+ default: () => import_adapter2.default
37
+ });
38
+ module.exports = __toCommonJS(promotion_exports);
39
+ var import_evaluator = require("./evaluator");
40
+ var import_adapter = require("./adapter");
41
+ var import_adapter2 = __toESM(require("./adapter"));
42
+ var import_examples = require("./examples");
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ BUY_X_GET_Y_FREE_STRATEGY,
46
+ PromotionAdapter,
47
+ PromotionEvaluator,
48
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
49
+ });
@@ -62,7 +62,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
62
62
  with_schedule,
63
63
  with_extra = []
64
64
  }, options) {
65
- var _a;
65
+ var _a, _b, _c;
66
66
  let userPlugin = this.core.getPlugin("user");
67
67
  let customer_id = void 0;
68
68
  try {
@@ -70,6 +70,13 @@ var ProductList = class extends import_BaseModule.BaseModule {
70
70
  } catch (error) {
71
71
  console.error(error);
72
72
  }
73
+ const channelMap = {
74
+ "online_store": "online-store",
75
+ "scan_to_order": "online-store",
76
+ "scan_to_order_2": "online-store",
77
+ "scan_to_order_3": "online-store"
78
+ };
79
+ const saleChannel = channelMap[(_b = this.otherParams) == null ? void 0 : _b.channel] || ((_c = this.otherParams) == null ? void 0 : _c.channel);
73
80
  try {
74
81
  const productsData = await this.request.post(
75
82
  `/product/query`,
@@ -99,7 +106,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
99
106
  schedule_date,
100
107
  schedule_datetime,
101
108
  // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
102
- application_code: "online-store",
109
+ application_code: saleChannel,
103
110
  with_schedule,
104
111
  is_eject: 1,
105
112
  open_deposit: 1
@@ -418,6 +418,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
418
418
  }
419
419
  });
420
420
  }
421
+ const isProductIncludedByLimitedData = (limitedData, productId) => {
422
+ const excludedIds = (limitedData == null ? void 0 : limitedData.exclude_product_ids) || [];
423
+ const isExcluded = (limitedData == null ? void 0 : limitedData.filter) === 1 && excludedIds.some((id) => String(id) === String(productId));
424
+ return !isExcluded;
425
+ };
421
426
  const usedDiscounts = /* @__PURE__ */ new Map();
422
427
  const usedProductIdCounts = /* @__PURE__ */ new Map();
423
428
  const usedDiscountCardLimitCounts = /* @__PURE__ */ new Map();
@@ -776,7 +781,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
776
781
  return false;
777
782
  }
778
783
  if (limitedData.type === "product_all") {
779
- if (limitedData.filter === 1 && limitedData.exclude_product_ids.includes(product.id)) {
784
+ if (!isProductIncludedByLimitedData(limitedData, product.id)) {
780
785
  return false;
781
786
  }
782
787
  if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
@@ -387,6 +387,26 @@ var calculateTaxFee = (shopInfo, items) => {
387
387
  }, new import_decimal.default(0));
388
388
  return totalTaxFee;
389
389
  };
390
+ var getCartItemDepositData = (item) => {
391
+ var _a, _b, _c, _d;
392
+ const target = item;
393
+ return ((_a = target == null ? void 0 : target._productOrigin) == null ? void 0 : _a.custom_deposit_data) || ((_b = target == null ? void 0 : target._origin) == null ? void 0 : _b.custom_deposit_data) || ((_d = (_c = target == null ? void 0 : target._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.custom_deposit_data);
394
+ };
395
+ var getCartItemQuantity = (item) => {
396
+ return new import_decimal.default((item == null ? void 0 : item.num) || 1);
397
+ };
398
+ var calculateCartItemDepositTotal = (item) => {
399
+ var _a;
400
+ const depositData = getCartItemDepositData(item);
401
+ if ((depositData == null ? void 0 : depositData.has_deposit) == 1 && typeof (depositData == null ? void 0 : depositData.deposit_fixed) === "string" && typeof (depositData == null ? void 0 : depositData.deposit_percentage) === "string") {
402
+ const lineTotal = new import_decimal.default(item.summaryTotal ?? item.total ?? 0);
403
+ const quantity = getCartItemQuantity(item);
404
+ const fixedTotal = new import_decimal.default(depositData.deposit_fixed || 0).times(quantity);
405
+ const percentageTotal = new import_decimal.default(depositData.deposit_percentage || 0).times(lineTotal);
406
+ return fixedTotal.plus(percentageTotal);
407
+ }
408
+ return new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
409
+ };
390
410
  var calculateDeposit = (items) => {
391
411
  if (!(items == null ? void 0 : items.length)) {
392
412
  return void 0;
@@ -394,11 +414,11 @@ var calculateDeposit = (items) => {
394
414
  const protocols = [];
395
415
  let hasDeposit = false;
396
416
  const total = items.reduce((sum, item) => {
397
- var _a, _b, _c;
417
+ var _a, _b;
398
418
  if (item == null ? void 0 : item.deposit) {
399
419
  hasDeposit = true;
400
- const cartItemTotalPrice = new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
401
- (_c = (_b = item == null ? void 0 : item.deposit) == null ? void 0 : _b.protocols) == null ? void 0 : _c.forEach((protocol) => {
420
+ const cartItemTotalPrice = calculateCartItemDepositTotal(item);
421
+ (_b = (_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.protocols) == null ? void 0 : _b.forEach((protocol) => {
402
422
  if (protocols.findIndex((p) => p.id === protocol.id) === -1) {
403
423
  protocols.push(protocol);
404
424
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.559",
4
+ "version": "0.0.560",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",