@pisell/pisellos 2.2.275 → 2.2.276

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.
@@ -253,6 +253,11 @@ declare class Server {
253
253
  * 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
254
254
  */
255
255
  private recomputeAndNotifySubscriber;
256
+ /**
257
+ * 根据餐牌 ID 获取其绑定日程中的全部时间点。
258
+ * 商品查询定时器与 schedule-time-points 路由共用此逻辑。
259
+ */
260
+ private getMenuScheduleTimePoints;
256
261
  /**
257
262
  * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
258
263
  */
@@ -33,6 +33,7 @@ import { FloorPlanModule } from "./modules/floor-plan";
33
33
  import { FloorPlanHooks } from "./modules/floor-plan/types";
34
34
  import { PaymentServerModule } from "./modules/payment";
35
35
  import { extractScheduleIdsFromMenus, extractTimePointsFromSchedules } from "./utils/schedule";
36
+ import { sortTimePoints } from "./utils/time";
36
37
  import { ProductsHooks } from "./modules/products/types";
37
38
  import { perfMark } from "./utils/product";
38
39
  import { OrderModule } from "./modules/order";
@@ -329,7 +330,11 @@ var Server = /*#__PURE__*/function () {
329
330
  case 8:
330
331
  result = _context3.sent;
331
332
  if (subscriberId && typeof callback === 'function') {
332
- _this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
333
+ _this.syncProductQueryScheduleTimers({
334
+ subscriberId: subscriberId,
335
+ menu_list_ids: menu_list_ids,
336
+ strategy_context: strategy_context
337
+ });
333
338
  }
334
339
  return _context3.abrupt("return", result);
335
340
  case 11:
@@ -1672,7 +1677,7 @@ var Server = /*#__PURE__*/function () {
1672
1677
  _defineProperty(this, "handleGetScheduleTimePoints", /*#__PURE__*/function () {
1673
1678
  var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref58) {
1674
1679
  var _menu_list_ids$length;
1675
- var url, method, data, config, menu_list_ids, _menu_list_ids$length2, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1680
+ var url, method, data, config, menu_list_ids, _menu_list_ids$length2, _this$getMenuSchedule, menuList, scheduleIds, scheduleList, timePoints, errorMessage;
1676
1681
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1677
1682
  while (1) switch (_context24.prev = _context24.next) {
1678
1683
  case 0:
@@ -1728,8 +1733,7 @@ var Server = /*#__PURE__*/function () {
1728
1733
  });
1729
1734
  case 16:
1730
1735
  _context24.prev = 16;
1731
- // 1. 获取餐牌列表
1732
- menuList = _this.menu.getMenuByIds(menu_list_ids);
1736
+ _this$getMenuSchedule = _this.getMenuScheduleTimePoints(menu_list_ids), menuList = _this$getMenuSchedule.menuList, scheduleIds = _this$getMenuSchedule.scheduleIds, scheduleList = _this$getMenuSchedule.scheduleList, timePoints = _this$getMenuSchedule.timePoints;
1733
1737
  console.log("[Server] \u627E\u5230 ".concat(menuList.length, " \u4E2A\u9910\u724C"));
1734
1738
  _this.logInfo('handleGetScheduleTimePoints: 获取到餐牌列表', {
1735
1739
  requestedCount: menu_list_ids.length,
@@ -1737,15 +1741,12 @@ var Server = /*#__PURE__*/function () {
1737
1741
  menu_list_ids: menu_list_ids,
1738
1742
  menuList: menuList
1739
1743
  });
1740
-
1741
- // 2. 提取所有的 schedule IDs
1742
- scheduleIds = extractScheduleIdsFromMenus(menuList);
1743
1744
  console.log("[Server] \u63D0\u53D6\u5230 ".concat(scheduleIds.length, " \u4E2A\u65E5\u7A0BID:"), scheduleIds);
1744
1745
  _this.logInfo('handleGetScheduleTimePoints: 提取到日程 IDs', {
1745
1746
  scheduleCount: scheduleIds.length
1746
1747
  });
1747
1748
  if (!(scheduleIds.length === 0)) {
1748
- _context24.next = 26;
1749
+ _context24.next = 25;
1749
1750
  break;
1750
1751
  }
1751
1752
  _this.logInfo('handleGetScheduleTimePoints: 没有找到相关日程', {
@@ -1757,17 +1758,12 @@ var Server = /*#__PURE__*/function () {
1757
1758
  data: [],
1758
1759
  status: true
1759
1760
  });
1760
- case 26:
1761
- // 3. 获取日程详情
1762
- scheduleList = _this.schedule.getScheduleByIds(scheduleIds);
1761
+ case 25:
1763
1762
  console.log("[Server] \u627E\u5230 ".concat(scheduleList.length, " \u4E2A\u65E5\u7A0B"));
1764
1763
  _this.logInfo('handleGetScheduleTimePoints: 获取到日程详情', {
1765
1764
  requestedCount: scheduleIds.length,
1766
1765
  foundCount: scheduleList.length
1767
1766
  });
1768
-
1769
- // 4. 提取时间点
1770
- timePoints = extractTimePointsFromSchedules(scheduleList);
1771
1767
  console.log("[Server] \u63D0\u53D6\u5230 ".concat(timePoints.length, " \u4E2A\u65F6\u95F4\u70B9:"), timePoints);
1772
1768
  _this.logInfo('handleGetScheduleTimePoints 处理完成', {
1773
1769
  menuListIdsCount: menu_list_ids.length,
@@ -1781,8 +1777,8 @@ var Server = /*#__PURE__*/function () {
1781
1777
  data: timePoints,
1782
1778
  status: true
1783
1779
  });
1784
- case 35:
1785
- _context24.prev = 35;
1780
+ case 32:
1781
+ _context24.prev = 32;
1786
1782
  _context24.t0 = _context24["catch"](16);
1787
1783
  errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : '未知错误';
1788
1784
  console.error('[Server] 获取日程时间点失败:', _context24.t0);
@@ -1796,11 +1792,11 @@ var Server = /*#__PURE__*/function () {
1796
1792
  data: [],
1797
1793
  status: false
1798
1794
  });
1799
- case 41:
1795
+ case 38:
1800
1796
  case "end":
1801
1797
  return _context24.stop();
1802
1798
  }
1803
- }, _callee24, null, [[16, 35]]);
1799
+ }, _callee24, null, [[16, 32]]);
1804
1800
  }));
1805
1801
  return function (_x24) {
1806
1802
  return _ref59.apply(this, arguments);
@@ -3622,18 +3618,48 @@ var Server = /*#__PURE__*/function () {
3622
3618
  return recomputeAndNotifySubscriber;
3623
3619
  }()
3624
3620
  /**
3625
- * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3621
+ * 根据餐牌 ID 获取其绑定日程中的全部时间点。
3622
+ * 商品查询定时器与 schedule-time-points 路由共用此逻辑。
3626
3623
  */
3627
3624
  )
3625
+ }, {
3626
+ key: "getMenuScheduleTimePoints",
3627
+ value: function getMenuScheduleTimePoints(menuListIds) {
3628
+ var _this$menu$getMenuByI, _this$menu, _this$schedule$getSch, _this$schedule;
3629
+ var menuList = (_this$menu$getMenuByI = (_this$menu = this.menu) === null || _this$menu === void 0 ? void 0 : _this$menu.getMenuByIds(menuListIds)) !== null && _this$menu$getMenuByI !== void 0 ? _this$menu$getMenuByI : [];
3630
+ var scheduleIds = extractScheduleIdsFromMenus(menuList);
3631
+ var scheduleList = scheduleIds.length > 0 ? (_this$schedule$getSch = (_this$schedule = this.schedule) === null || _this$schedule === void 0 ? void 0 : _this$schedule.getScheduleByIds(scheduleIds)) !== null && _this$schedule$getSch !== void 0 ? _this$schedule$getSch : [] : [];
3632
+ var timePoints = extractTimePointsFromSchedules(scheduleList);
3633
+ return {
3634
+ menuList: menuList,
3635
+ scheduleIds: scheduleIds,
3636
+ scheduleList: scheduleList,
3637
+ timePoints: timePoints
3638
+ };
3639
+ }
3640
+
3641
+ /**
3642
+ * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
3643
+ */
3628
3644
  }, {
3629
3645
  key: "syncProductQueryScheduleTimers",
3630
- value: function syncProductQueryScheduleTimers(subscriberId, strategy_context) {
3646
+ value: function syncProductQueryScheduleTimers(_ref61) {
3631
3647
  var _this$products$getLas3, _this$products2, _this$products2$getLa;
3648
+ var subscriberId = _ref61.subscriberId,
3649
+ menu_list_ids = _ref61.menu_list_ids,
3650
+ strategy_context = _ref61.strategy_context;
3632
3651
  this.clearSubscriberScheduleTimers(subscriberId);
3633
3652
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
3634
3653
  return;
3635
3654
  }
3636
- var timePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3655
+ var productTimePoints = (_this$products$getLas3 = (_this$products2 = this.products) === null || _this$products2 === void 0 || (_this$products2$getLa = _this$products2.getLastScheduleTimePoints) === null || _this$products2$getLa === void 0 ? void 0 : _this$products2$getLa.call(_this$products2)) !== null && _this$products$getLas3 !== void 0 ? _this$products$getLas3 : [];
3656
+ var menuListIds = Array.isArray(menu_list_ids) ? Array.from(new Set(menu_list_ids.map(function (id) {
3657
+ return Number(id);
3658
+ }).filter(function (id) {
3659
+ return Number.isFinite(id);
3660
+ }))) : [];
3661
+ var menuTimePoints = this.getMenuScheduleTimePoints(menuListIds).timePoints;
3662
+ var timePoints = sortTimePoints(Array.from(new Set([].concat(_toConsumableArray(productTimePoints), _toConsumableArray(menuTimePoints)))));
3637
3663
  if (timePoints.length > 0) {
3638
3664
  this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
3639
3665
  }
@@ -3650,7 +3676,7 @@ var Server = /*#__PURE__*/function () {
3650
3676
  */
3651
3677
  function () {
3652
3678
  var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(kind, backendPath, data, config) {
3653
- var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
3679
+ var queryPayload, result, _ref62, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator6, _step6, orderId;
3654
3680
  return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3655
3681
  while (1) switch (_context43.prev = _context43.next) {
3656
3682
  case 0:
@@ -3659,7 +3685,7 @@ var Server = /*#__PURE__*/function () {
3659
3685
  return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
3660
3686
  case 3:
3661
3687
  result = _context43.sent;
3662
- _ref61 = config || {}, callback = _ref61.callback, subscriberId = _ref61.subscriberId, resetVisibleOrderIds = _ref61.resetVisibleOrderIds;
3688
+ _ref62 = config || {}, callback = _ref62.callback, subscriberId = _ref62.subscriberId, resetVisibleOrderIds = _ref62.resetVisibleOrderIds;
3663
3689
  if (subscriberId && typeof callback === 'function') {
3664
3690
  contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
3665
3691
  existing = this.salesSearchSubscribers.get(subscriberId);
@@ -6123,10 +6149,10 @@ var Server = /*#__PURE__*/function () {
6123
6149
  }, {
6124
6150
  key: "shouldBuildSmallTicketData",
6125
6151
  value: function shouldBuildSmallTicketData(order) {
6126
- var _ref63, _order$small_ticket_d;
6152
+ var _ref64, _order$small_ticket_d;
6127
6153
  if (!order || _typeof(order) !== 'object') return false;
6128
6154
  // if (hasSmallTicketData(order.payment_info?.small_ticket_data)) return false;
6129
- return Number((_ref63 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref63 !== void 0 ? _ref63 : 0) === 1;
6155
+ return Number((_ref64 = (_order$small_ticket_d = order.small_ticket_data_flag) !== null && _order$small_ticket_d !== void 0 ? _order$small_ticket_d : order.smallTicketDataFlag) !== null && _ref64 !== void 0 ? _ref64 : 0) === 1;
6130
6156
  }
6131
6157
  }, {
6132
6158
  key: "shouldPrintSyncedOrder",
@@ -6144,7 +6170,7 @@ var Server = /*#__PURE__*/function () {
6144
6170
  }, {
6145
6171
  key: "isSalesOrderFullyPaid",
6146
6172
  value: function isSalesOrderFullyPaid(order) {
6147
- var _order$summary$amount, _order$summary, _ref64, _ref65, _order$summary$expect, _order$summary2, _order$summary3;
6173
+ var _order$summary$amount, _order$summary, _ref65, _ref66, _order$summary$expect, _order$summary2, _order$summary3;
6148
6174
  if (!order || _typeof(order) !== 'object') return false;
6149
6175
  var paymentStatus = String(order.payment_status || '').toLowerCase();
6150
6176
  if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
@@ -6156,7 +6182,7 @@ var Server = /*#__PURE__*/function () {
6156
6182
  return this.toAmountNumber(amountGap) <= 0;
6157
6183
  }
6158
6184
  var paidAmount = this.sumPaidOrderPayments(order.payments);
6159
- var targetAmount = this.toAmountNumber((_ref64 = (_ref65 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref65 !== void 0 ? _ref65 : order.expect_amount) !== null && _ref64 !== void 0 ? _ref64 : order.total_amount);
6185
+ var targetAmount = this.toAmountNumber((_ref65 = (_ref66 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref66 !== void 0 ? _ref66 : order.expect_amount) !== null && _ref65 !== void 0 ? _ref65 : order.total_amount);
6160
6186
  if (targetAmount <= 0) return paidAmount > 0;
6161
6187
  return paidAmount >= targetAmount;
6162
6188
  }
@@ -6200,8 +6226,8 @@ var Server = /*#__PURE__*/function () {
6200
6226
  }
6201
6227
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6202
6228
  product.product_bundle.forEach(function (bundle) {
6203
- var _ref66, _bundle$bundle_produc;
6204
- var bundleProductId = (_ref66 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref66 !== void 0 ? _ref66 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6229
+ var _ref67, _bundle$bundle_produc;
6230
+ var bundleProductId = (_ref67 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref67 !== void 0 ? _ref67 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6205
6231
  if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
6206
6232
  productIdSet.add(bundleProductId);
6207
6233
  }
@@ -6217,7 +6243,7 @@ var Server = /*#__PURE__*/function () {
6217
6243
  case 6:
6218
6244
  _context64.next = 8;
6219
6245
  return Promise.all(productIds.map( /*#__PURE__*/function () {
6220
- var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(id) {
6246
+ var _ref68 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(id) {
6221
6247
  var _this14$products, _this14$products$getP, product;
6222
6248
  return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6223
6249
  while (1) switch (_context63.prev = _context63.next) {
@@ -6243,7 +6269,7 @@ var Server = /*#__PURE__*/function () {
6243
6269
  }, _callee63, null, [[0, 7]]);
6244
6270
  }));
6245
6271
  return function (_x72) {
6246
- return _ref67.apply(this, arguments);
6272
+ return _ref68.apply(this, arguments);
6247
6273
  };
6248
6274
  }()));
6249
6275
  case 8:
@@ -6282,8 +6308,8 @@ var Server = /*#__PURE__*/function () {
6282
6308
  addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
6283
6309
  if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
6284
6310
  product.product_bundle.forEach(function (bundle) {
6285
- var _ref68, _bundle$bundle_produc2;
6286
- addProductId((_ref68 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref68 !== void 0 ? _ref68 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6311
+ var _ref69, _bundle$bundle_produc2;
6312
+ addProductId((_ref69 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
6287
6313
  });
6288
6314
  }
6289
6315
  });
@@ -6359,9 +6385,9 @@ var Server = /*#__PURE__*/function () {
6359
6385
  if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
6360
6386
  var hasChanged = false;
6361
6387
  var productBundle = product.product_bundle.map(function (bundle) {
6362
- var _ref69, _bundle$bundle_produc3;
6388
+ var _ref70, _bundle$bundle_produc3;
6363
6389
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
6364
- var rawProductId = (_ref69 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref69 !== void 0 ? _ref69 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6390
+ var rawProductId = (_ref70 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref70 !== void 0 ? _ref70 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
6365
6391
  if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
6366
6392
  var productId = Number(rawProductId);
6367
6393
  if (!Number.isFinite(productId)) return bundle;
@@ -6485,7 +6511,7 @@ var Server = /*#__PURE__*/function () {
6485
6511
  }, {
6486
6512
  key: "resolveProductTitleValue",
6487
6513
  value: function resolveProductTitleValue(value, key, currentLocale) {
6488
- var _ref70, _ref71, _value$key;
6514
+ var _ref71, _ref72, _value$key;
6489
6515
  if (value === undefined || value === null || value === '') return null;
6490
6516
  if (_typeof(value) !== 'object') {
6491
6517
  var title = String(value);
@@ -6495,7 +6521,7 @@ var Server = /*#__PURE__*/function () {
6495
6521
  }
6496
6522
  var normalizedKey = key.replace('-', '_');
6497
6523
  var dashedKey = key.replace('_', '-');
6498
- var rawValue = (_ref70 = (_ref71 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref71 !== void 0 ? _ref71 : value[dashedKey]) !== null && _ref70 !== void 0 ? _ref70 : key === 'auto' ? value.default : undefined;
6524
+ var rawValue = (_ref71 = (_ref72 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref72 !== void 0 ? _ref72 : value[dashedKey]) !== null && _ref71 !== void 0 ? _ref71 : key === 'auto' ? value.default : undefined;
6499
6525
  if (rawValue === undefined || rawValue === null || rawValue === '') return null;
6500
6526
  if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
6501
6527
  return String(rawValue);
@@ -7844,14 +7870,14 @@ var Server = /*#__PURE__*/function () {
7844
7870
  }, {
7845
7871
  key: "buildProductFormatterContext",
7846
7872
  value: function buildProductFormatterContext(context) {
7847
- var _this$menu, _this$menu$getMenuLis, _scheduleModule$getSc, _this$core$context5;
7873
+ var _this$menu2, _this$menu2$getMenuLi, _scheduleModule$getSc, _this$core$context5;
7848
7874
  var scheduleModule = this.getSchedule();
7849
7875
  return {
7850
7876
  scheduleModule: scheduleModule,
7851
7877
  schedule_datetime: context.schedule_datetime,
7852
7878
  customer_id: context.customer_id,
7853
7879
  strategy_context: context.strategy_context,
7854
- menuList: ((_this$menu = this.menu) === null || _this$menu === void 0 || (_this$menu$getMenuLis = _this$menu.getMenuList) === null || _this$menu$getMenuLis === void 0 ? void 0 : _this$menu$getMenuLis.call(_this$menu)) || [],
7880
+ menuList: ((_this$menu2 = this.menu) === null || _this$menu2 === void 0 || (_this$menu2$getMenuLi = _this$menu2.getMenuList) === null || _this$menu2$getMenuLi === void 0 ? void 0 : _this$menu2$getMenuLi.call(_this$menu2)) || [],
7855
7881
  scheduleList: (scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule)) || [],
7856
7882
  dataVariantEvaluator: (_this$core$context5 = this.core.context) === null || _this$core$context5 === void 0 ? void 0 : _this$core$context5.dataVariantEvaluator
7857
7883
  };
@@ -193,7 +193,7 @@ export function transformBaseProductToOrderProduct(params) {
193
193
  }
194
194
  // 从源头补充商品多语言标题
195
195
  var productTitle = _objectSpread(_objectSpread({}, (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title_i18n) || {}), {}, {
196
- original: (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || ''
196
+ original: (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.original_title) || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || ''
197
197
  });
198
198
  return {
199
199
  product_id: productId,
@@ -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 | 5 | 4 | 3 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 6 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -326,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
326
326
  * 获取当前的客户搜索条件
327
327
  * @returns 当前搜索条件
328
328
  */
329
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
329
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
330
330
  /**
331
331
  * 获取客户列表状态(包含滚动加载相关状态)
332
332
  * @returns 客户状态
@@ -2620,10 +2620,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2620
2620
  _context30.next = 11;
2621
2621
  break;
2622
2622
  }
2623
- return _context30.abrupt("return", this.store.order.addProductsToOrder(orderLines, {
2624
- skipEditDiscountConfigRefresh: true,
2625
- skipDiscountRecalculation: true
2626
- }));
2623
+ return _context30.abrupt("return", this.store.order.addProductsToOrder(orderLines));
2627
2624
  case 11:
2628
2625
  result = [];
2629
2626
  _iterator2 = _createForOfIteratorHelper(orderLines);
@@ -0,0 +1,51 @@
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
+ ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
34
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
35
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
36
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
37
+ default: () => import_adapter2.default
38
+ });
39
+ module.exports = __toCommonJS(promotion_exports);
40
+ var import_evaluator = require("./evaluator");
41
+ var import_adapter = require("./adapter");
42
+ var import_adapter2 = __toESM(require("./adapter"));
43
+ var import_examples = require("./examples");
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ BUY_X_GET_Y_FREE_STRATEGY,
47
+ ITEM_REWARD_STRATEGY,
48
+ PromotionAdapter,
49
+ PromotionEvaluator,
50
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
51
+ });
@@ -133,7 +133,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
133
133
  this.draftPersistEnabled = true;
134
134
  }
135
135
  collectHydratedEditDiscounts(products) {
136
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
136
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
137
137
  const discountMap = /* @__PURE__ */ new Map();
138
138
  for (const product of (0, import_bundleDiscountHydration.expandHydratedProductsForDiscountCollection)(products)) {
139
139
  for (const item of (product == null ? void 0 : product.discount_list) || []) {
@@ -148,16 +148,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
148
148
  const key = Number.isFinite(id) ? id : String(resourceId);
149
149
  const title = ((_b = item == null ? void 0 : item.discount) == null ? void 0 : _b.title) ?? {};
150
150
  const amount = Number((item == null ? void 0 : item.amount) || 0);
151
+ const discountCardType = (_c = item == null ? void 0 : item.discount) == null ? void 0 : _c.discount_card_type;
152
+ const parValue = isDiscountCard ? discountCardType === "fixed_amount" ? ((_d = item == null ? void 0 : item.discount) == null ? void 0 : _d.fixed_amount) ?? (item == null ? void 0 : item.amount) : (_e = item == null ? void 0 : item.discount) == null ? void 0 : _e.percent : "0";
151
153
  const detail = {
152
154
  amount: String((item == null ? void 0 : item.amount) ?? "0"),
153
155
  type,
154
156
  resource_id: key,
155
157
  title,
156
- original_amount: String(((_c = item == null ? void 0 : item.discount) == null ? void 0 : _c.original_amount) ?? (item == null ? void 0 : item.amount) ?? "0"),
157
- num: Number(((_d = item == null ? void 0 : item.metadata) == null ? void 0 : _d.num) ?? (product == null ? void 0 : product.num) ?? (product == null ? void 0 : product.product_quantity) ?? 1) || 1,
158
+ original_amount: String(((_f = item == null ? void 0 : item.discount) == null ? void 0 : _f.original_amount) ?? (item == null ? void 0 : item.amount) ?? "0"),
159
+ num: Number(((_g = item == null ? void 0 : item.metadata) == null ? void 0 : _g.num) ?? (product == null ? void 0 : product.num) ?? (product == null ? void 0 : product.product_quantity) ?? 1) || 1,
158
160
  metadata: item == null ? void 0 : item.metadata,
159
161
  discount: item == null ? void 0 : item.discount,
160
- _num: Number(((_e = item == null ? void 0 : item.metadata) == null ? void 0 : _e.num) ?? (product == null ? void 0 : product.num) ?? (product == null ? void 0 : product.product_quantity) ?? 1) || 1
162
+ _num: Number(((_h = item == null ? void 0 : item.metadata) == null ? void 0 : _h.num) ?? (product == null ? void 0 : product.num) ?? (product == null ? void 0 : product.product_quantity) ?? 1) || 1
161
163
  };
162
164
  const existed = discountMap.get(key);
163
165
  if (existed) {
@@ -166,7 +168,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
166
168
  if (!isDiscountCard) {
167
169
  existed.balance = String(Number(existed.balance || 0) + amount);
168
170
  }
169
- const productIds = Array.isArray((_f = existed.limited_relation_product_data) == null ? void 0 : _f.product_ids) ? existed.limited_relation_product_data.product_ids : [];
171
+ const productIds = Array.isArray((_i = existed.limited_relation_product_data) == null ? void 0 : _i.product_ids) ? existed.limited_relation_product_data.product_ids : [];
170
172
  if ((product == null ? void 0 : product.product_id) !== void 0 && (product == null ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
171
173
  existed.limited_relation_product_data = {
172
174
  ...existed.limited_relation_product_data || {},
@@ -189,9 +191,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
189
191
  encoded: "",
190
192
  code: "",
191
193
  tag: type,
192
- product_id: ((_g = item == null ? void 0 : item.discount) == null ? void 0 : _g.discount_product_id) ?? (product == null ? void 0 : product.product_id) ?? 0,
194
+ product_id: ((_j = item == null ? void 0 : item.discount) == null ? void 0 : _j.discount_product_id) ?? (product == null ? void 0 : product.product_id) ?? 0,
193
195
  relation_type: "",
194
- par_value: String(((_h = item == null ? void 0 : item.discount) == null ? void 0 : _h.original_amount) ?? (item == null ? void 0 : item.amount) ?? "0"),
196
+ par_value: String(parValue ?? "0"),
195
197
  used_par_value: String((item == null ? void 0 : item.amount) ?? "0"),
196
198
  limit_status: "enable",
197
199
  limited_relation_product_data: {
@@ -221,8 +223,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
221
223
  discount: {
222
224
  ...(item == null ? void 0 : item.discount) || {},
223
225
  resource_id: key,
224
- discount_product_id: ((_i = item == null ? void 0 : item.discount) == null ? void 0 : _i.discount_product_id) ?? (product == null ? void 0 : product.product_id) ?? 0,
225
- discount_calculation_mode: ((_j = item == null ? void 0 : item.discount) == null ? void 0 : _j.discount_calculation_mode) ?? "item_level"
226
+ discount_product_id: ((_k = item == null ? void 0 : item.discount) == null ? void 0 : _k.discount_product_id) ?? (product == null ? void 0 : product.product_id) ?? 0,
227
+ discount_calculation_mode: ((_l = item == null ? void 0 : item.discount) == null ? void 0 : _l.discount_calculation_mode) ?? "item_level"
226
228
  },
227
229
  applicableProductDetails: [detail],
228
230
  appliedProductDetails: [detail]
@@ -274,7 +276,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
274
276
  const isPersistedBundleProduct = isPersistedProduct || Boolean(
275
277
  (bundle == null ? void 0 : bundle.order_detail_id) || (bundle == null ? void 0 : bundle.orderDetailId) || (bundle == null ? void 0 : bundle.booking_id)
276
278
  );
277
- const bundleQty = new import_decimal.default(Number(qty) || 1).times(Number((bundle == null ? void 0 : bundle.num) ?? (bundle == null ? void 0 : bundle.quantity) ?? 1) || 1).toNumber();
279
+ const bundleQty = Number(qty) || 1;
278
280
  for (const pd of (bundle == null ? void 0 : bundle.discount_list) || []) {
279
281
  addProductDiscountAmount(pd, bundleQty, isPersistedBundleProduct);
280
282
  }
@@ -253,6 +253,11 @@ declare class Server {
253
253
  * 对单个商品 query 订阅者重算并推送(定时路径;不新建 schedule timer)。
254
254
  */
255
255
  private recomputeAndNotifySubscriber;
256
+ /**
257
+ * 根据餐牌 ID 获取其绑定日程中的全部时间点。
258
+ * 商品查询定时器与 schedule-time-points 路由共用此逻辑。
259
+ */
260
+ private getMenuScheduleTimePoints;
256
261
  /**
257
262
  * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
258
263
  */
@@ -45,6 +45,7 @@ var import_floor_plan = require("./modules/floor-plan");
45
45
  var import_types = require("./modules/floor-plan/types");
46
46
  var import_payment = require("./modules/payment");
47
47
  var import_schedule2 = require("./utils/schedule");
48
+ var import_time = require("./utils/time");
48
49
  var import_types2 = require("./modules/products/types");
49
50
  var import_product = require("./utils/product");
50
51
  var import_order = require("./modules/order");
@@ -247,7 +248,11 @@ var Server = class {
247
248
  strategy_context
248
249
  });
249
250
  if (subscriberId && typeof callback === "function") {
250
- this.syncProductQueryScheduleTimers(subscriberId, strategy_context);
251
+ this.syncProductQueryScheduleTimers({
252
+ subscriberId,
253
+ menu_list_ids,
254
+ strategy_context
255
+ });
251
256
  }
252
257
  return result;
253
258
  };
@@ -1074,7 +1079,12 @@ var Server = class {
1074
1079
  };
1075
1080
  }
1076
1081
  try {
1077
- const menuList = this.menu.getMenuByIds(menu_list_ids);
1082
+ const {
1083
+ menuList,
1084
+ scheduleIds,
1085
+ scheduleList,
1086
+ timePoints
1087
+ } = this.getMenuScheduleTimePoints(menu_list_ids);
1078
1088
  console.log(`[Server] 找到 ${menuList.length} 个餐牌`);
1079
1089
  this.logInfo("handleGetScheduleTimePoints: 获取到餐牌列表", {
1080
1090
  requestedCount: menu_list_ids.length,
@@ -1082,7 +1092,6 @@ var Server = class {
1082
1092
  menu_list_ids,
1083
1093
  menuList
1084
1094
  });
1085
- const scheduleIds = (0, import_schedule2.extractScheduleIdsFromMenus)(menuList);
1086
1095
  console.log(`[Server] 提取到 ${scheduleIds.length} 个日程ID:`, scheduleIds);
1087
1096
  this.logInfo("handleGetScheduleTimePoints: 提取到日程 IDs", {
1088
1097
  scheduleCount: scheduleIds.length
@@ -1096,13 +1105,11 @@ var Server = class {
1096
1105
  status: true
1097
1106
  };
1098
1107
  }
1099
- const scheduleList = this.schedule.getScheduleByIds(scheduleIds);
1100
1108
  console.log(`[Server] 找到 ${scheduleList.length} 个日程`);
1101
1109
  this.logInfo("handleGetScheduleTimePoints: 获取到日程详情", {
1102
1110
  requestedCount: scheduleIds.length,
1103
1111
  foundCount: scheduleList.length
1104
1112
  });
1105
- const timePoints = (0, import_schedule2.extractTimePointsFromSchedules)(scheduleList);
1106
1113
  console.log(`[Server] 提取到 ${timePoints.length} 个时间点:`, timePoints);
1107
1114
  this.logInfo("handleGetScheduleTimePoints 处理完成", {
1108
1115
  menuListIdsCount: menu_list_ids.length,
@@ -2264,16 +2271,44 @@ var Server = class {
2264
2271
  });
2265
2272
  }
2266
2273
  }
2274
+ /**
2275
+ * 根据餐牌 ID 获取其绑定日程中的全部时间点。
2276
+ * 商品查询定时器与 schedule-time-points 路由共用此逻辑。
2277
+ */
2278
+ getMenuScheduleTimePoints(menuListIds) {
2279
+ var _a, _b;
2280
+ const menuList = ((_a = this.menu) == null ? void 0 : _a.getMenuByIds(menuListIds)) ?? [];
2281
+ const scheduleIds = (0, import_schedule2.extractScheduleIdsFromMenus)(menuList);
2282
+ const scheduleList = scheduleIds.length > 0 ? ((_b = this.schedule) == null ? void 0 : _b.getScheduleByIds(scheduleIds)) ?? [] : [];
2283
+ const timePoints = (0, import_schedule2.extractTimePointsFromSchedules)(scheduleList);
2284
+ return {
2285
+ menuList,
2286
+ scheduleIds,
2287
+ scheduleList,
2288
+ timePoints
2289
+ };
2290
+ }
2267
2291
  /**
2268
2292
  * query 完成后为 subscriber 同步 schedule 定时器(先 clear 再 schedule)。
2269
2293
  */
2270
- syncProductQueryScheduleTimers(subscriberId, strategy_context) {
2294
+ syncProductQueryScheduleTimers({
2295
+ subscriberId,
2296
+ menu_list_ids,
2297
+ strategy_context
2298
+ }) {
2271
2299
  var _a, _b;
2272
2300
  this.clearSubscriberScheduleTimers(subscriberId);
2273
2301
  if (!this.shouldScheduleProductQueryReload(strategy_context)) {
2274
2302
  return;
2275
2303
  }
2276
- const timePoints = ((_b = (_a = this.products) == null ? void 0 : _a.getLastScheduleTimePoints) == null ? void 0 : _b.call(_a)) ?? [];
2304
+ const productTimePoints = ((_b = (_a = this.products) == null ? void 0 : _a.getLastScheduleTimePoints) == null ? void 0 : _b.call(_a)) ?? [];
2305
+ const menuListIds = Array.isArray(menu_list_ids) ? Array.from(new Set(
2306
+ menu_list_ids.map((id) => Number(id)).filter((id) => Number.isFinite(id))
2307
+ )) : [];
2308
+ const menuTimePoints = this.getMenuScheduleTimePoints(menuListIds).timePoints;
2309
+ const timePoints = (0, import_time.sortTimePoints)(
2310
+ Array.from(/* @__PURE__ */ new Set([...productTimePoints, ...menuTimePoints]))
2311
+ );
2277
2312
  if (timePoints.length > 0) {
2278
2313
  this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
2279
2314
  }
@@ -217,7 +217,7 @@ function transformBaseProductToOrderProduct(params) {
217
217
  }
218
218
  const productTitle = {
219
219
  ...(sourceProduct == null ? void 0 : sourceProduct.title_i18n) || {},
220
- original: (sourceProduct == null ? void 0 : sourceProduct.title) || ""
220
+ original: (sourceProduct == null ? void 0 : sourceProduct.original_title) || (sourceProduct == null ? void 0 : sourceProduct.title) || ""
221
221
  };
222
222
  return {
223
223
  product_id: productId,
@@ -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 | 5 | 4 | 3 | 6;
314
+ weekNum: 0 | 1 | 2 | 3 | 6 | 4 | 5;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -326,7 +326,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
326
326
  * 获取当前的客户搜索条件
327
327
  * @returns 当前搜索条件
328
328
  */
329
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
329
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
330
330
  /**
331
331
  * 获取客户列表状态(包含滚动加载相关状态)
332
332
  * @returns 客户状态
@@ -1568,10 +1568,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
1568
1568
  });
1569
1569
  }
1570
1570
  if (typeof this.store.order.addProductsToOrder === "function") {
1571
- return this.store.order.addProductsToOrder(orderLines, {
1572
- skipEditDiscountConfigRefresh: true,
1573
- skipDiscountRecalculation: true
1574
- });
1571
+ return this.store.order.addProductsToOrder(orderLines);
1575
1572
  }
1576
1573
  const result = [];
1577
1574
  for (const line of orderLines) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.275",
4
+ "version": "2.2.276",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",