@pisell/pisellos 2.2.230 → 2.2.232

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.
Files changed (34) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Order/index.js +44 -29
  3. package/dist/modules/Order/types.d.ts +14 -2
  4. package/dist/modules/Order/types.js +8 -1
  5. package/dist/modules/ProductList/index.d.ts +9 -12
  6. package/dist/modules/ProductList/index.js +122 -59
  7. package/dist/modules/ProductList/types.d.ts +14 -0
  8. package/dist/server/index.d.ts +21 -0
  9. package/dist/server/index.js +154 -34
  10. package/dist/server/utils/small-ticket.js +113 -29
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.d.ts +9 -1
  13. package/dist/solution/BookingTicket/index.js +198 -158
  14. package/dist/solution/BookingTicket/types.d.ts +4 -0
  15. package/dist/solution/BookingTicket/utils/cartView.js +20 -6
  16. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +189 -0
  17. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +429 -0
  18. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  19. package/lib/modules/Order/index.js +18 -5
  20. package/lib/modules/Order/types.d.ts +14 -2
  21. package/lib/modules/ProductList/index.d.ts +9 -12
  22. package/lib/modules/ProductList/index.js +32 -4
  23. package/lib/modules/ProductList/types.d.ts +14 -0
  24. package/lib/server/index.d.ts +21 -0
  25. package/lib/server/index.js +107 -9
  26. package/lib/server/utils/small-ticket.js +78 -1
  27. package/lib/solution/BookingByStep/index.d.ts +1 -1
  28. package/lib/solution/BookingTicket/index.d.ts +9 -1
  29. package/lib/solution/BookingTicket/index.js +20 -1
  30. package/lib/solution/BookingTicket/types.d.ts +4 -0
  31. package/lib/solution/BookingTicket/utils/cartView.js +14 -7
  32. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +189 -0
  33. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +241 -0
  34. package/package.json +1 -1
@@ -269,20 +269,21 @@ var Server = /*#__PURE__*/function () {
269
269
  */
270
270
  _defineProperty(this, "handleProductQuery", /*#__PURE__*/function () {
271
271
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
272
- var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, _ref7, callback, subscriberId;
272
+ var url, method, data, config, menu_list_ids, schedule_datetime, schedule_date, customer_id, ids, extension_type, _ref7, callback, subscriberId;
273
273
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
274
274
  while (1) switch (_context3.prev = _context3.next) {
275
275
  case 0:
276
276
  url = _ref5.url, method = _ref5.method, data = _ref5.data, config = _ref5.config;
277
277
  console.log('[Server] handleProductQuery:', url, method, data, config);
278
- menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids;
278
+ menu_list_ids = data.menu_list_ids, schedule_datetime = data.schedule_datetime, schedule_date = data.schedule_date, customer_id = data.customer_id, ids = data.ids, extension_type = data.extension_type;
279
279
  _ref7 = config || {}, callback = _ref7.callback, subscriberId = _ref7.subscriberId;
280
280
  _this.logInfo('handleProductQuery: 开始处理商品查询请求', {
281
281
  menu_list_ids: menu_list_ids,
282
282
  ids: ids,
283
283
  schedule_datetime: schedule_datetime,
284
284
  schedule_date: schedule_date,
285
- customer_id: customer_id
285
+ customer_id: customer_id,
286
+ extension_type: extension_type
286
287
  });
287
288
 
288
289
  // 存储订阅者:后续 pubsub 数据变更时可通过 callback 推送最新结果
@@ -294,7 +295,8 @@ var Server = /*#__PURE__*/function () {
294
295
  ids: ids,
295
296
  schedule_date: schedule_date,
296
297
  schedule_datetime: schedule_datetime,
297
- customer_id: customer_id
298
+ customer_id: customer_id,
299
+ extension_type: extension_type
298
300
  }
299
301
  });
300
302
  _this.logInfo('handleProductQuery: 已注册订阅者', {
@@ -307,7 +309,8 @@ var Server = /*#__PURE__*/function () {
307
309
  ids: ids,
308
310
  schedule_date: schedule_date,
309
311
  schedule_datetime: schedule_datetime,
310
- customer_id: customer_id
312
+ customer_id: customer_id,
313
+ extension_type: extension_type
311
314
  }));
312
315
  case 7:
313
316
  case "end":
@@ -4146,19 +4149,20 @@ var Server = /*#__PURE__*/function () {
4146
4149
  order: printableOrder
4147
4150
  });
4148
4151
  case 7:
4149
- _context44.next = 9;
4152
+ debugger;
4153
+ _context44.next = 10;
4150
4154
  return this.dispatchPrintOtherReceiptTask({
4151
4155
  checkoutData: params.checkoutData,
4152
4156
  syncedOrder: printableOrder,
4153
4157
  response: params.response,
4154
4158
  receiptOnly: true
4155
4159
  });
4156
- case 9:
4160
+ case 10:
4157
4161
  return _context44.abrupt("return", {
4158
4162
  printed: true,
4159
4163
  order: printableOrder
4160
4164
  });
4161
- case 10:
4165
+ case 11:
4162
4166
  case "end":
4163
4167
  return _context44.stop();
4164
4168
  }
@@ -5489,6 +5493,50 @@ var Server = /*#__PURE__*/function () {
5489
5493
  }
5490
5494
  return computeBookingQueryResult;
5491
5495
  }()
5496
+ /**
5497
+ * 规范商品扩展类型过滤参数。
5498
+ *
5499
+ * @example
5500
+ * const types = this.normalizeProductExtensionTypes(['product_add_time']);
5501
+ */
5502
+ )
5503
+ }, {
5504
+ key: "normalizeProductExtensionTypes",
5505
+ value: function normalizeProductExtensionTypes(extension_type) {
5506
+ if (!Array.isArray(extension_type)) return [];
5507
+ return extension_type.map(function (item) {
5508
+ return String(item || '').trim();
5509
+ }).filter(Boolean);
5510
+ }
5511
+
5512
+ /**
5513
+ * 请求包含 product_add_time 时,按传入 extension_type 数组配置过滤商品。
5514
+ *
5515
+ * @example
5516
+ * const list = this.filterProductsByExtensionTypes(products, ['product_add_time']);
5517
+ */
5518
+ }, {
5519
+ key: "filterProductsByExtensionTypes",
5520
+ value: function filterProductsByExtensionTypes(products, extension_type) {
5521
+ var extensionTypes = this.normalizeProductExtensionTypes(extension_type);
5522
+ if (!extensionTypes.includes('product_add_time')) return products;
5523
+ return products.filter(function (product) {
5524
+ return extensionTypes.includes(String((product === null || product === void 0 ? void 0 : product.extension_type) || ''));
5525
+ });
5526
+ }
5527
+
5528
+ /**
5529
+ * 判断本次查询是否需要跳过餐牌过滤,直接按扩展类型拉商品。
5530
+ *
5531
+ * @example
5532
+ * const skipMenu = this.shouldQueryProductsByExtensionTypes(['product_add_time']);
5533
+ */
5534
+ }, {
5535
+ key: "shouldQueryProductsByExtensionTypes",
5536
+ value: function shouldQueryProductsByExtensionTypes(extension_type) {
5537
+ return this.normalizeProductExtensionTypes(extension_type).includes('product_add_time');
5538
+ }
5539
+
5492
5540
  /**
5493
5541
  * 商品查询的核心计算逻辑(编排 Products、Menu、Schedule 模块)
5494
5542
  * 供 handleProductQuery 首次返回及 pubsub 变更推送复用
@@ -5496,19 +5544,18 @@ var Server = /*#__PURE__*/function () {
5496
5544
  * @param options 可选参数
5497
5545
  * @param options.changedIds 变更的商品 IDs,用于增量更新价格缓存
5498
5546
  */
5499
- )
5500
5547
  }, {
5501
5548
  key: "computeProductQueryResult",
5502
5549
  value: (function () {
5503
5550
  var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(context, options) {
5504
5551
  var _menu_list_ids$length3,
5505
5552
  _this16 = this;
5506
- var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tSort;
5553
+ var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, queryIds, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, menuList, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
5507
5554
  return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5508
5555
  while (1) switch (_context55.prev = _context55.next) {
5509
5556
  case 0:
5510
5557
  tTotal = performance.now();
5511
- menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, product_id = context.product_id;
5558
+ menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id;
5512
5559
  queryIds = Array.isArray(ids) ? ids.map(function (id) {
5513
5560
  return Number(id);
5514
5561
  }).filter(function (id) {
@@ -5520,6 +5567,7 @@ var Server = /*#__PURE__*/function () {
5520
5567
  schedule_datetime: schedule_datetime,
5521
5568
  schedule_date: schedule_date,
5522
5569
  customer_id: customer_id,
5570
+ extension_type: extension_type,
5523
5571
  product_id: product_id,
5524
5572
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5525
5573
  });
@@ -5537,7 +5585,7 @@ var Server = /*#__PURE__*/function () {
5537
5585
  });
5538
5586
  case 7:
5539
5587
  if (!(queryIds.length > 0)) {
5540
- _context55.next = 18;
5588
+ _context55.next = 19;
5541
5589
  break;
5542
5590
  }
5543
5591
  uniqueIds = Array.from(new Set(queryIds));
@@ -5562,46 +5610,47 @@ var Server = /*#__PURE__*/function () {
5562
5610
  }).filter(function (p) {
5563
5611
  return ((p === null || p === void 0 ? void 0 : p.status) || 'published') === 'published';
5564
5612
  });
5613
+ extensionFilteredProducts = this.filterProductsByExtensionTypes(_filteredProducts, extension_type);
5565
5614
  perfMark('computeProductQueryResult', performance.now() - tTotal, {
5566
5615
  mode: 'ids',
5567
5616
  ids: uniqueIds,
5568
- count: _filteredProducts.length
5617
+ count: extensionFilteredProducts.length
5569
5618
  });
5570
5619
  this.logInfo('computeProductQueryResult 完成(ids)', {
5571
5620
  ids: uniqueIds,
5572
- count: _filteredProducts.length
5621
+ count: extensionFilteredProducts.length
5573
5622
  });
5574
5623
  return _context55.abrupt("return", {
5575
5624
  code: 200,
5576
5625
  data: {
5577
- list: _filteredProducts,
5578
- count: _filteredProducts.length
5626
+ list: extensionFilteredProducts,
5627
+ count: extensionFilteredProducts.length
5579
5628
  },
5580
5629
  message: '',
5581
5630
  status: true
5582
5631
  });
5583
- case 18:
5632
+ case 19:
5584
5633
  if (!(product_id != null && Number.isFinite(Number(product_id)))) {
5585
- _context55.next = 30;
5634
+ _context55.next = 31;
5586
5635
  break;
5587
5636
  }
5588
5637
  pid = Number(product_id);
5589
5638
  _tPrice2 = performance.now();
5590
- _context55.next = 23;
5639
+ _context55.next = 24;
5591
5640
  return this.products.getProductsWithPrice(schedule_date, {
5592
5641
  scheduleModule: this.getSchedule()
5593
5642
  }, {
5594
5643
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5595
5644
  });
5596
- case 23:
5645
+ case 24:
5597
5646
  allProductsWithPrice = _context55.sent;
5598
5647
  perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
5599
5648
  count: allProductsWithPrice.length,
5600
5649
  productId: pid
5601
5650
  });
5602
- published = allProductsWithPrice.filter(function (p) {
5651
+ published = this.filterProductsByExtensionTypes(allProductsWithPrice.filter(function (p) {
5603
5652
  return ((p === null || p === void 0 ? void 0 : p.status) || 'published') === 'published';
5604
- });
5653
+ }), extension_type);
5605
5654
  item = (_published$find = published.find(function (p) {
5606
5655
  return Number(p.id) === pid;
5607
5656
  })) !== null && _published$find !== void 0 ? _published$find : null;
@@ -5620,9 +5669,72 @@ var Server = /*#__PURE__*/function () {
5620
5669
  message: item ? '' : '商品不存在或未发布',
5621
5670
  status: true
5622
5671
  });
5623
- case 30:
5672
+ case 31:
5673
+ if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
5674
+ _context55.next = 51;
5675
+ break;
5676
+ }
5677
+ _tPrice3 = performance.now();
5678
+ _context55.next = 35;
5679
+ return this.products.getProductsWithPrice(schedule_date, {
5680
+ scheduleModule: this.getSchedule(),
5681
+ schedule_datetime: schedule_datetime,
5682
+ customer_id: customer_id
5683
+ }, {
5684
+ changedIds: options === null || options === void 0 ? void 0 : options.changedIds
5685
+ });
5686
+ case 35:
5687
+ _filteredProducts2 = _context55.sent;
5688
+ perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
5689
+ count: _filteredProducts2.length,
5690
+ extension_type: extension_type
5691
+ });
5692
+ _tStatus = performance.now();
5693
+ _beforeStatusCount = _filteredProducts2.length;
5694
+ _filteredProducts2 = _filteredProducts2.filter(function (p) {
5695
+ return ((p === null || p === void 0 ? void 0 : p.status) || 'published') === 'published';
5696
+ });
5697
+ perfMark('computeQuery.filterByStatus(extensionType)', performance.now() - _tStatus, {
5698
+ before: _beforeStatusCount,
5699
+ after: _filteredProducts2.length
5700
+ });
5701
+ _tExtensionType = performance.now();
5702
+ _beforeExtensionTypeCount = _filteredProducts2.length;
5703
+ _filteredProducts2 = this.filterProductsByExtensionTypes(_filteredProducts2, extension_type);
5704
+ perfMark('computeQuery.filterByExtensionType(extensionType)', performance.now() - _tExtensionType, {
5705
+ before: _beforeExtensionTypeCount,
5706
+ after: _filteredProducts2.length,
5707
+ extension_type: extension_type
5708
+ });
5709
+ _tSort = performance.now();
5710
+ _filteredProducts2 = _filteredProducts2.sort(function (a, b) {
5711
+ var sortDiff = Number(b.sort) - Number(a.sort);
5712
+ if (sortDiff !== 0) return sortDiff;
5713
+ return (a.title || '').localeCompare(b.title || '');
5714
+ });
5715
+ perfMark('computeQuery.sort(extensionType)', performance.now() - _tSort, {
5716
+ count: _filteredProducts2.length
5717
+ });
5718
+ perfMark('computeProductQueryResult', performance.now() - tTotal, {
5719
+ mode: 'extensionType',
5720
+ filteredCount: _filteredProducts2.length
5721
+ });
5722
+ this.logInfo('computeProductQueryResult 完成(extension_type)', {
5723
+ filteredCount: _filteredProducts2.length,
5724
+ extension_type: extension_type
5725
+ });
5726
+ return _context55.abrupt("return", {
5727
+ code: 200,
5728
+ data: {
5729
+ list: _filteredProducts2,
5730
+ count: _filteredProducts2.length
5731
+ },
5732
+ message: '',
5733
+ status: true
5734
+ });
5735
+ case 51:
5624
5736
  if (this.menu) {
5625
- _context55.next = 33;
5737
+ _context55.next = 54;
5626
5738
  break;
5627
5739
  }
5628
5740
  this.logError('computeProductQueryResult: Menu 模块未注册');
@@ -5633,9 +5745,9 @@ var Server = /*#__PURE__*/function () {
5633
5745
  count: 0
5634
5746
  }
5635
5747
  });
5636
- case 33:
5748
+ case 54:
5637
5749
  if (this.schedule) {
5638
- _context55.next = 36;
5750
+ _context55.next = 57;
5639
5751
  break;
5640
5752
  }
5641
5753
  this.logError('computeProductQueryResult: Schedule 模块未注册');
@@ -5646,7 +5758,7 @@ var Server = /*#__PURE__*/function () {
5646
5758
  count: 0
5647
5759
  }
5648
5760
  });
5649
- case 36:
5761
+ case 57:
5650
5762
  activeMenuList = [];
5651
5763
  if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
5652
5764
  tMenu = performance.now();
@@ -5670,10 +5782,10 @@ var Server = /*#__PURE__*/function () {
5670
5782
  });
5671
5783
  tPrice = performance.now();
5672
5784
  if (!(scopedProductIds.length > 0)) {
5673
- _context55.next = 49;
5785
+ _context55.next = 70;
5674
5786
  break;
5675
5787
  }
5676
- _context55.next = 46;
5788
+ _context55.next = 67;
5677
5789
  return this.products.getProductsWithPrice(schedule_date, {
5678
5790
  scheduleModule: this.getSchedule(),
5679
5791
  schedule_datetime: schedule_datetime,
@@ -5682,13 +5794,13 @@ var Server = /*#__PURE__*/function () {
5682
5794
  changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
5683
5795
  productIds: productScope.isAllProducts ? undefined : scopedProductIds
5684
5796
  });
5685
- case 46:
5797
+ case 67:
5686
5798
  _context55.t0 = _context55.sent;
5687
- _context55.next = 50;
5799
+ _context55.next = 71;
5688
5800
  break;
5689
- case 49:
5801
+ case 70:
5690
5802
  _context55.t0 = [];
5691
- case 50:
5803
+ case 71:
5692
5804
  filteredProducts = _context55.t0;
5693
5805
  perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
5694
5806
  count: filteredProducts.length,
@@ -5703,6 +5815,14 @@ var Server = /*#__PURE__*/function () {
5703
5815
  before: beforeStatusCount,
5704
5816
  after: filteredProducts.length
5705
5817
  });
5818
+ tExtensionType = performance.now();
5819
+ beforeExtensionTypeCount = filteredProducts.length;
5820
+ filteredProducts = this.filterProductsByExtensionTypes(filteredProducts, extension_type);
5821
+ perfMark('computeQuery.filterByExtensionType', performance.now() - tExtensionType, {
5822
+ before: beforeExtensionTypeCount,
5823
+ after: filteredProducts.length,
5824
+ extension_type: extension_type
5825
+ });
5706
5826
  tSort = performance.now();
5707
5827
  filteredProducts = filteredProducts.sort(function (a, b) {
5708
5828
  var sortDiff = Number(b.sort) - Number(a.sort);
@@ -5731,7 +5851,7 @@ var Server = /*#__PURE__*/function () {
5731
5851
  message: '',
5732
5852
  status: true
5733
5853
  });
5734
- case 62:
5854
+ case 87:
5735
5855
  case "end":
5736
5856
  return _context55.stop();
5737
5857
  }
@@ -1,9 +1,13 @@
1
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
3
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
4
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
11
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
12
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
13
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -188,6 +192,11 @@ function buildProducts(order, locale, productMap) {
188
192
  currencySymbol: currencySymbol,
189
193
  parentProduct: parentProduct
190
194
  });
195
+ var resolvedVariant = resolveProductVariantText({
196
+ product: product,
197
+ parentProduct: parentProduct,
198
+ locale: locale
199
+ });
191
200
  return _objectSpread(_objectSpread(_objectSpread({
192
201
  product_title: productTitle,
193
202
  product_quantity: quantity,
@@ -197,8 +206,8 @@ function buildProducts(order, locale, productMap) {
197
206
  extension_list: Array.isArray(product.extension_list) ? product.extension_list : []
198
207
  }, options.length ? {
199
208
  options: options
200
- } : {}), product.variant ? {
201
- variant: getLocalizedValue(product.variant, locale)
209
+ } : {}), resolvedVariant ? {
210
+ variant: resolvedVariant
202
211
  } : {}), Array.isArray(product.combinations) ? {
203
212
  combinations: product.combinations
204
213
  } : combinations.length ? {
@@ -300,17 +309,92 @@ function resolveProductFromMap(productId, productMap) {
300
309
  if (productId === undefined || productId === null || productId === '') return null;
301
310
  return productMap[productId] || productMap[String(productId)] || null;
302
311
  }
312
+ function resolveProductVariantText(params) {
313
+ var _product$product_vari;
314
+ var product = params.product,
315
+ parentProduct = params.parentProduct,
316
+ locale = params.locale;
317
+ if (product.variant) return getLocalizedValue(product.variant, locale);
318
+ if (!parentProduct) return '';
319
+ var productVariantId = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id;
320
+ if (!isNonZeroId(productVariantId)) return '';
321
+ var matchedVariant = normalizeArray(parentProduct.variant).find(function (variant) {
322
+ return isSameId(variant.id, productVariantId);
323
+ });
324
+ if (!matchedVariant) return '';
325
+ var resolvedFromSkuKey = resolveVariantTextFromSkuKey({
326
+ skuKey: matchedVariant.sku_key,
327
+ parentProduct: parentProduct,
328
+ locale: locale
329
+ });
330
+ if (resolvedFromSkuKey) return resolvedFromSkuKey;
331
+ return resolveVariantTextFromNameMap({
332
+ nameMap: matchedVariant.name || matchedVariant.title,
333
+ parentProduct: parentProduct,
334
+ locale: locale
335
+ });
336
+ }
337
+ function resolveVariantTextFromSkuKey(params) {
338
+ var skuKey = stringify(params.skuKey);
339
+ if (!skuKey) return '';
340
+ return skuKey.split('_').map(function (item) {
341
+ var _item$split = item.split(':'),
342
+ _item$split2 = _slicedToArray(_item$split, 2),
343
+ groupPositionId = _item$split2[0],
344
+ itemPositionId = _item$split2[1];
345
+ return resolveVariantTextItem({
346
+ parentProduct: params.parentProduct,
347
+ groupPositionId: groupPositionId,
348
+ itemPositionId: itemPositionId,
349
+ locale: params.locale
350
+ });
351
+ }).filter(Boolean).join(',');
352
+ }
353
+ function resolveVariantTextFromNameMap(params) {
354
+ if (!params.nameMap || _typeof(params.nameMap) !== 'object') return '';
355
+ return Object.entries(params.nameMap).map(function (_ref13) {
356
+ var _ref14 = _slicedToArray(_ref13, 2),
357
+ groupPositionId = _ref14[0],
358
+ value = _ref14[1];
359
+ var group = resolveVariantGroup(params.parentProduct, groupPositionId);
360
+ if (!group) return '';
361
+ var groupName = getLocalizedValue(group.name, params.locale);
362
+ var itemName = getLocalizedValue(value, params.locale);
363
+ if (!groupName || !itemName) return '';
364
+ return "".concat(groupName, ":").concat(itemName);
365
+ }).filter(Boolean).join(',');
366
+ }
367
+ function resolveVariantTextItem(params) {
368
+ var group = resolveVariantGroup(params.parentProduct, params.groupPositionId);
369
+ var item = resolveVariantItem(group, params.itemPositionId);
370
+ if (!group || !item) return '';
371
+ var groupName = getLocalizedValue(group.name, params.locale);
372
+ var itemName = getLocalizedValue(item.name, params.locale);
373
+ if (!groupName || !itemName) return '';
374
+ return "".concat(groupName, ":").concat(itemName);
375
+ }
376
+ function resolveVariantGroup(parentProduct, groupPositionId) {
377
+ return normalizeArray(parentProduct.variant_group).find(function (group) {
378
+ return isSameId(group.position_id, groupPositionId) || isSameId(group.id, groupPositionId);
379
+ }) || null;
380
+ }
381
+ function resolveVariantItem(group, itemPositionId) {
382
+ if (!group) return null;
383
+ return normalizeArray(group.variant_item).find(function (item) {
384
+ return isSameId(item.position_id, itemPositionId) || isSameId(item.id, itemPositionId);
385
+ }) || null;
386
+ }
303
387
  function getProductTitleSource(source, locale) {
304
388
  if (!source || _typeof(source) !== 'object') return '';
305
389
  return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
306
390
  }
307
391
  function resolveTitleValue(value, locale) {
308
- var _ref13, _ref14, _value$locale;
392
+ var _ref15, _ref16, _value$locale;
309
393
  if (value === undefined || value === null) return '';
310
394
  if (_typeof(value) !== 'object') return stringify(value);
311
395
  var dashedLocale = locale.replace('_', '-');
312
396
  var underscoredLocale = locale.replace('-', '_');
313
- return stringify((_ref13 = (_ref14 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref14 !== void 0 ? _ref14 : value[underscoredLocale]) !== null && _ref13 !== void 0 ? _ref13 : '');
397
+ return stringify((_ref15 = (_ref16 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref16 !== void 0 ? _ref16 : value[underscoredLocale]) !== null && _ref15 !== void 0 ? _ref15 : '');
314
398
  }
315
399
  function resolveOptionTitleFromParentProduct(params) {
316
400
  var option = params.option,
@@ -328,17 +412,17 @@ function flattenOptionItems(parentProduct) {
328
412
  return optionGroups.flatMap(function (group) {
329
413
  var items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
330
414
  return items.map(function (item) {
331
- var _ref15, _item$option_group_id;
415
+ var _ref17, _item$option_group_id;
332
416
  return _objectSpread(_objectSpread({}, item), {}, {
333
- option_group_id: (_ref15 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref15 !== void 0 ? _ref15 : group.option_group_id
417
+ option_group_id: (_ref17 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref17 !== void 0 ? _ref17 : group.option_group_id
334
418
  });
335
419
  });
336
420
  });
337
421
  }
338
422
  function isOptionItemMatch(option, item) {
339
- var _ref16, _option$option_group_, _ref17, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
340
- var optionItemId = (_ref16 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref16 !== void 0 ? _ref16 : option.id;
341
- var itemId = (_ref17 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref17 !== void 0 ? _ref17 : item.id;
423
+ var _ref18, _option$option_group_, _ref19, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
424
+ var optionItemId = (_ref18 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref18 !== void 0 ? _ref18 : option.id;
425
+ var itemId = (_ref19 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref19 !== void 0 ? _ref19 : item.id;
342
426
  if (!isSameId(optionItemId, itemId)) return false;
343
427
  var optionGroupId = (_option$option_group_2 = option.option_group_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_id;
344
428
  var itemGroupId = (_item$option_group_id2 = item.option_group_id) !== null && _item$option_group_id2 !== void 0 ? _item$option_group_id2 : item.group_id;
@@ -348,16 +432,16 @@ function isOptionItemMatch(option, item) {
348
432
  return true;
349
433
  }
350
434
  function resolveBundleItemFromParentProduct(params) {
351
- var _ref18, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref20, _bundle$bundle_produc2;
435
+ var _ref20, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref22, _bundle$bundle_produc2;
352
436
  var bundle = params.bundle,
353
437
  parentProduct = params.parentProduct;
354
438
  if (!parentProduct) return null;
355
439
  var bundleItems = flattenBundleItems(parentProduct);
356
- var bundleVariantId = (_ref18 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref18 !== void 0 ? _ref18 : bundle.product_variant_id;
440
+ var bundleVariantId = (_ref20 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref20 !== void 0 ? _ref20 : bundle.product_variant_id;
357
441
  if (isNonZeroId(bundleVariantId)) {
358
442
  var matchedByVariant = bundleItems.find(function (item) {
359
- var _ref19, _item$bundle_variant_;
360
- return isSameId((_ref19 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref19 !== void 0 ? _ref19 : item.product_variant_id, bundleVariantId);
443
+ var _ref21, _item$bundle_variant_;
444
+ return isSameId((_ref21 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref21 !== void 0 ? _ref21 : item.product_variant_id, bundleVariantId);
361
445
  });
362
446
  if (matchedByVariant) return matchedByVariant;
363
447
  }
@@ -370,18 +454,18 @@ function resolveBundleItemFromParentProduct(params) {
370
454
  if (matchedByBundleId) return matchedByBundleId;
371
455
  }
372
456
  var bundleGroupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
373
- var bundleProductId = (_ref20 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref20 !== void 0 ? _ref20 : bundle.product_id;
457
+ var bundleProductId = (_ref22 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref22 !== void 0 ? _ref22 : bundle.product_id;
374
458
  if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
375
459
  var matchedByGroupAndProduct = bundleItems.find(function (item) {
376
- var _item$group_id, _ref21, _item$bundle_product_;
377
- return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref21 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref21 !== void 0 ? _ref21 : item.product_id, bundleProductId);
460
+ var _item$group_id, _ref23, _item$bundle_product_;
461
+ return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref23 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : item.product_id, bundleProductId);
378
462
  });
379
463
  if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
380
464
  }
381
465
  if (isPresentId(bundleProductId)) {
382
466
  return bundleItems.find(function (item) {
383
- var _ref22, _item$bundle_product_2;
384
- return isSameId((_ref22 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref22 !== void 0 ? _ref22 : item.product_id, bundleProductId);
467
+ var _ref24, _item$bundle_product_2;
468
+ return isSameId((_ref24 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref24 !== void 0 ? _ref24 : item.product_id, bundleProductId);
385
469
  }) || null;
386
470
  }
387
471
  return null;
@@ -391,9 +475,9 @@ function flattenBundleItems(parentProduct) {
391
475
  return bundleGroups.flatMap(function (group) {
392
476
  var items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
393
477
  return items.map(function (item) {
394
- var _ref23, _item$group_id2;
478
+ var _ref25, _item$group_id2;
395
479
  return _objectSpread(_objectSpread({}, item), {}, {
396
- group_id: (_ref23 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref23 !== void 0 ? _ref23 : group.group_id
480
+ group_id: (_ref25 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref25 !== void 0 ? _ref25 : group.group_id
397
481
  });
398
482
  });
399
483
  });
@@ -419,8 +503,8 @@ function buildOptionTitleSuffix(options) {
419
503
  return text ? "(".concat(text, ")") : '';
420
504
  }
421
505
  function formatBundlePrice(bundle, currencySymbol) {
422
- var _ref24, _ref25, _bundle$bundle_sellin;
423
- var value = (_ref24 = (_ref25 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref25 !== void 0 ? _ref25 : bundle.price) !== null && _ref24 !== void 0 ? _ref24 : 0;
506
+ var _ref26, _ref27, _bundle$bundle_sellin;
507
+ var value = (_ref26 = (_ref27 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref27 !== void 0 ? _ref27 : bundle.price) !== null && _ref26 !== void 0 ? _ref26 : 0;
424
508
  var amount = new Decimal(toMoneyNumber(value));
425
509
  var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
426
510
  if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
@@ -435,9 +519,9 @@ function buildFees(params) {
435
519
  currencySymbol = params.currencySymbol;
436
520
  var fees = [];
437
521
  for (var _i = 0, _normalizeArray = normalizeArray(order.surcharges || summary.surcharges); _i < _normalizeArray.length; _i++) {
438
- var _ref26, _surcharge$amount;
522
+ var _ref28, _surcharge$amount;
439
523
  var surcharge = _normalizeArray[_i];
440
- var value = (_ref26 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref26 !== void 0 ? _ref26 : surcharge.total_amount;
524
+ var value = (_ref28 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref28 !== void 0 ? _ref28 : surcharge.total_amount;
441
525
  if (!isNonZero(value)) continue;
442
526
  fees.push({
443
527
  item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
@@ -572,8 +656,8 @@ function buildPaymentData(params) {
572
656
  currencySymbol: params.currencySymbol
573
657
  })));
574
658
  } else {
575
- var _ref27, _payment$remaining_am, _payment$metadata;
576
- var remainingAmount = (_ref27 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref27 !== void 0 ? _ref27 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
659
+ var _ref29, _payment$remaining_am, _payment$metadata;
660
+ var remainingAmount = (_ref29 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref29 !== void 0 ? _ref29 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
577
661
  if (remainingAmount !== undefined && remainingAmount !== null) {
578
662
  items.push({
579
663
  item: label(params.locale, 'remainingAmount'),
@@ -681,11 +765,11 @@ function label(locale, key) {
681
765
  return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
682
766
  }
683
767
  function getLocalizedValue(value, locale) {
684
- var _ref28, _ref29, _ref30, _value$locale2;
768
+ var _ref30, _ref31, _ref32, _value$locale2;
685
769
  if (value === undefined || value === null) return '';
686
770
  if (_typeof(value) !== 'object') return stringify(value);
687
771
  var dashedLocale = locale.replace('_', '-');
688
- return stringify((_ref28 = (_ref29 = (_ref30 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref30 !== void 0 ? _ref30 : value.default) !== null && _ref29 !== void 0 ? _ref29 : value.en) !== null && _ref28 !== void 0 ? _ref28 : '');
772
+ return stringify((_ref30 = (_ref31 = (_ref32 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref32 !== void 0 ? _ref32 : value.default) !== null && _ref31 !== void 0 ? _ref31 : value.en) !== null && _ref30 !== void 0 ? _ref30 : '');
689
773
  }
690
774
  function serviceTypeToLabelKey(serviceType) {
691
775
  var normalized = serviceType.toLowerCase();
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 6 | 3 | 4 | 5;
314
+ weekNum: 0 | 1 | 5 | 4 | 2 | 3 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;