@pisell/pisellos 0.0.558 → 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";
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "appointment_booking" | "virtual";
87
+ type: "virtual" | "appointment_booking";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -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;
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
373
373
  };
374
374
  setOtherData(key: string, value: any): void;
375
375
  getOtherData(key: string): any;
376
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
376
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
377
377
  /**
378
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
379
379
  *
@@ -1074,7 +1074,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1074
1074
  key: "_doLoadAllProducts",
1075
1075
  value: function () {
1076
1076
  var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1077
- var _this$otherParams16, _this$store$venueProd, associatedMenus, menuListIds, allProducts, list, venueList, addonList, venueStore, _this$store$order3, _this$store$order3$ge, products;
1077
+ var _this$otherParams16, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, venueList, addonList, venueStore, _this$store$order3, _this$store$order3$ge, products;
1078
1078
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1079
1079
  while (1) switch (_context12.prev = _context12.next) {
1080
1080
  case 0:
@@ -1116,9 +1116,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1116
1116
  });
1117
1117
  case 15:
1118
1118
  allProducts = _context12.sent;
1119
- list = Array.isArray(allProducts) ? allProducts : [];
1119
+ rawList = Array.isArray(allProducts) ? allProducts : [];
1120
+ list = rawList;
1121
+ this.smartPricingProductCatalog = rawList.slice();
1120
1122
  list = formatProductsWithDataVariant(list, this.buildSmartPricingContext(), dayjs().format('YYYY-MM-DD HH:mm:ss'));
1121
- this.smartPricingProductCatalog = list.slice();
1122
1123
  this.clearSlotPriceMapCache();
1123
1124
  venueList = list.filter(function (p) {
1124
1125
  return p.duration != null;
@@ -1137,13 +1138,13 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1137
1138
 
1138
1139
  // 加载 holder 表单
1139
1140
  if (!this.store.order) {
1140
- _context12.next = 30;
1141
+ _context12.next = 31;
1141
1142
  break;
1142
1143
  }
1143
1144
  products = ((_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getOrderProducts) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3)) || [];
1144
- _context12.next = 30;
1145
+ _context12.next = 31;
1145
1146
  return this.preloadHolderForms(products);
1146
- case 30:
1147
+ case 31:
1147
1148
  this.productsLoaded = true;
1148
1149
  this.logMethodSuccess('loadAllProducts', {
1149
1150
  total: list.length,
@@ -1155,16 +1156,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1155
1156
  venueProducts: venueList,
1156
1157
  addonProducts: addonList
1157
1158
  });
1158
- case 35:
1159
- _context12.prev = 35;
1159
+ case 36:
1160
+ _context12.prev = 36;
1160
1161
  _context12.t0 = _context12["catch"](1);
1161
1162
  this.logMethodError('loadAllProducts', _context12.t0);
1162
1163
  throw _context12.t0;
1163
- case 39:
1164
+ case 40:
1164
1165
  case "end":
1165
1166
  return _context12.stop();
1166
1167
  }
1167
- }, _callee12, this, [[1, 35]]);
1168
+ }, _callee12, this, [[1, 36]]);
1168
1169
  }));
1169
1170
  function _doLoadAllProducts() {
1170
1171
  return _doLoadAllProducts2.apply(this, arguments);
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "appointment_booking" | "virtual";
87
+ type: "virtual" | "appointment_booking";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -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
  }
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
373
373
  };
374
374
  setOtherData(key: string, value: any): void;
375
375
  getOtherData(key: string): any;
376
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
376
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
377
377
  /**
378
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
379
379
  *
@@ -715,13 +715,14 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
715
715
  schedule_datetime: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
716
716
  with_extra: ["dataVariants"]
717
717
  });
718
- let list = Array.isArray(allProducts) ? allProducts : [];
718
+ const rawList = Array.isArray(allProducts) ? allProducts : [];
719
+ let list = rawList;
720
+ this.smartPricingProductCatalog = rawList.slice();
719
721
  list = (0, import_smartPricing.formatProductsWithDataVariant)(
720
722
  list,
721
723
  this.buildSmartPricingContext(),
722
724
  (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss")
723
725
  );
724
- this.smartPricingProductCatalog = list.slice();
725
726
  this.clearSlotPriceMapCache();
726
727
  const venueList = list.filter((p) => p.duration != null);
727
728
  const addonList = list.filter((p) => p.duration == null);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.558",
4
+ "version": "0.0.560",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",