@pisell/pisellos 0.0.500 → 0.0.501

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 (57) hide show
  1. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
  2. package/dist/model/strategy/adapter/itemRule/adapter.js +52 -8
  3. package/dist/model/strategy/adapter/itemRule/examples.d.ts +15 -0
  4. package/dist/model/strategy/adapter/itemRule/examples.js +68 -1
  5. package/dist/model/strategy/adapter/itemRule/index.d.ts +1 -1
  6. package/dist/model/strategy/adapter/itemRule/index.js +1 -1
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +20 -1
  8. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  9. package/dist/modules/Order/index.d.ts +6 -0
  10. package/dist/modules/Order/index.js +42 -38
  11. package/dist/modules/Order/types.d.ts +4 -0
  12. package/dist/modules/Order/utils.d.ts +28 -0
  13. package/dist/modules/Order/utils.js +93 -13
  14. package/dist/modules/ProductList/index.js +2 -2
  15. package/dist/modules/Quotation/index.js +6 -3
  16. package/dist/modules/SalesSummary/types.d.ts +2 -1
  17. package/dist/modules/SalesSummary/utils.js +10 -10
  18. package/dist/modules/Schedule/utils.d.ts +1 -1
  19. package/dist/solution/BookingByStep/index.d.ts +2 -2
  20. package/dist/solution/ScanOrder/index.d.ts +7 -0
  21. package/dist/solution/ScanOrder/index.js +284 -67
  22. package/dist/solution/ScanOrder/types.d.ts +22 -5
  23. package/dist/solution/ScanOrder/utils.d.ts +26 -0
  24. package/dist/solution/ScanOrder/utils.js +191 -44
  25. package/dist/solution/VenueBooking/index.d.ts +14 -0
  26. package/dist/solution/VenueBooking/index.js +318 -144
  27. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  28. package/dist/solution/VenueBooking/utils/dateSummary.js +6 -4
  29. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
  30. package/lib/model/strategy/adapter/itemRule/adapter.js +41 -2
  31. package/lib/model/strategy/adapter/itemRule/examples.d.ts +15 -0
  32. package/lib/model/strategy/adapter/itemRule/examples.js +47 -0
  33. package/lib/model/strategy/adapter/itemRule/index.d.ts +1 -1
  34. package/lib/model/strategy/adapter/itemRule/index.js +2 -0
  35. package/lib/model/strategy/adapter/itemRule/type.d.ts +20 -1
  36. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  37. package/lib/modules/Order/index.d.ts +6 -0
  38. package/lib/modules/Order/index.js +20 -36
  39. package/lib/modules/Order/types.d.ts +4 -0
  40. package/lib/modules/Order/utils.d.ts +28 -0
  41. package/lib/modules/Order/utils.js +78 -9
  42. package/lib/modules/ProductList/index.js +3 -2
  43. package/lib/modules/Quotation/index.js +3 -0
  44. package/lib/modules/SalesSummary/types.d.ts +2 -1
  45. package/lib/modules/SalesSummary/utils.js +2 -2
  46. package/lib/modules/Schedule/utils.d.ts +1 -1
  47. package/lib/solution/BookingByStep/index.d.ts +2 -2
  48. package/lib/solution/ScanOrder/index.d.ts +7 -0
  49. package/lib/solution/ScanOrder/index.js +162 -18
  50. package/lib/solution/ScanOrder/types.d.ts +22 -5
  51. package/lib/solution/ScanOrder/utils.d.ts +26 -0
  52. package/lib/solution/ScanOrder/utils.js +128 -19
  53. package/lib/solution/VenueBooking/index.d.ts +14 -0
  54. package/lib/solution/VenueBooking/index.js +156 -30
  55. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  56. package/lib/solution/VenueBooking/utils/dateSummary.js +13 -4
  57. package/package.json +1 -1
@@ -22,8 +22,10 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
22
22
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
23
  import { BaseModule } from "../../modules/BaseModule";
24
24
  import { ScanOrderHooks } from "./types";
25
- import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, createEmptySummary, getProductIdentityIndex, getSafeProductNum, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, toNonNegativeInt, toNonNegativeNumber, toPriceString, toBoolean, toPositiveString } from "./utils";
25
+ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toNonNegativeNumber, toPriceString, toBoolean, toPositiveString } from "./utils";
26
26
  import { createModule } from "../BookingByStep/types";
27
+ import { ProductList } from "../../modules/ProductList";
28
+ import { normalizeSubmitCollectPaxValue } from "../../modules/Order/utils";
27
29
  import dayjs from 'dayjs';
28
30
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
29
31
  export * from "./types";
@@ -50,7 +52,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
50
52
  cartValidation: {
51
53
  passed: null,
52
54
  failures: []
53
- }
55
+ },
56
+ entryPaxNumber: 1
54
57
  });
55
58
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
56
59
  _defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
@@ -61,6 +64,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
61
64
  _defineProperty(_assertThisInitialized(_this), "itemRuleConfigsPromise", null);
62
65
  _defineProperty(_assertThisInitialized(_this), "itemRulePrefillApplied", false);
63
66
  _defineProperty(_assertThisInitialized(_this), "itemRuleRuntimeConfig", {});
67
+ /** 最近一次 checkResourceAvailable 从预约规则 link 拉取的商品快照 */
68
+ _defineProperty(_assertThisInitialized(_this), "enabledReservationRuleProducts", []);
64
69
  return _this;
65
70
  }
66
71
  _createClass(ScanOrderImpl, [{
@@ -632,7 +637,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
632
637
  key: "submitScanOrder",
633
638
  value: function () {
634
639
  var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
635
- var _tempOrder$products, result, tempOrder;
640
+ var _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, result, tempOrder;
636
641
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
637
642
  while (1) switch (_context9.prev = _context9.next) {
638
643
  case 0:
@@ -647,27 +652,38 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
647
652
  }
648
653
  throw new Error('scanOrder解决方案需要 order 模块支持');
649
654
  case 6:
650
- _context9.next = 8;
655
+ pax = normalizeSubmitCollectPaxValue(this.store.entryPaxNumber);
656
+ this.store.entryPaxNumber = pax;
657
+ tempOrderForSubmit = this.store.order.ensureTempOrder();
658
+ tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
659
+ collect_pax: pax
660
+ });
661
+ this.store.order.persistTempOrder();
662
+ _context9.next = 13;
651
663
  return this.store.order.submitTempOrder({
652
- cacheId: this.cacheId
664
+ cacheId: this.cacheId,
665
+ platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
666
+ businessCode: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
667
+ channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel,
668
+ type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type
653
669
  });
654
- case 8:
670
+ case 13:
655
671
  result = _context9.sent;
656
672
  tempOrder = this.store.order.getTempOrder();
657
673
  this.logMethodSuccess('submitScanOrder', {
658
674
  productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
659
675
  });
660
676
  return _context9.abrupt("return", result);
661
- case 14:
662
- _context9.prev = 14;
677
+ case 19:
678
+ _context9.prev = 19;
663
679
  _context9.t0 = _context9["catch"](1);
664
680
  this.logMethodError('submitScanOrder', _context9.t0);
665
681
  throw _context9.t0;
666
- case 18:
682
+ case 23:
667
683
  case "end":
668
684
  return _context9.stop();
669
685
  }
670
- }, _callee9, this, [[1, 14]]);
686
+ }, _callee9, this, [[1, 19]]);
671
687
  }));
672
688
  function submitScanOrder() {
673
689
  return _submitScanOrder.apply(this, arguments);
@@ -1153,7 +1169,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1153
1169
  key: "applyPrefillByItemRule",
1154
1170
  value: function () {
1155
1171
  var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1156
- var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator2, _step2, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, _ref3, _sourceItem$original_, _ref4, _sourceItem$payment_p, sellingPrice, originalPrice, paymentPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
1172
+ var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator2, _step2, _prefillItem$product_, _targetProduct$_origi, _targetProduct$_origi2, _targetProduct$_origi3, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
1157
1173
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1158
1174
  while (1) switch (_context20.prev = _context20.next) {
1159
1175
  case 0:
@@ -1203,7 +1219,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1203
1219
  _iterator2.s();
1204
1220
  case 22:
1205
1221
  if ((_step2 = _iterator2.n()).done) {
1206
- _context20.next = 49;
1222
+ _context20.next = 47;
1207
1223
  break;
1208
1224
  }
1209
1225
  prefillItem = _step2.value;
@@ -1214,13 +1230,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1214
1230
  _context20.next = 29;
1215
1231
  break;
1216
1232
  }
1217
- return _context20.abrupt("continue", 47);
1233
+ return _context20.abrupt("continue", 45);
1218
1234
  case 29:
1219
1235
  if (!Number.isNaN(productVariantId)) {
1220
1236
  _context20.next = 31;
1221
1237
  break;
1222
1238
  }
1223
- return _context20.abrupt("continue", 47);
1239
+ return _context20.abrupt("continue", 45);
1224
1240
  case 31:
1225
1241
  sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
1226
1242
  productIndex = getProductIdentityIndex(tempOrder.products, {
@@ -1228,19 +1244,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1228
1244
  product_variant_id: productVariantId
1229
1245
  });
1230
1246
  if (!(productIndex === -1)) {
1231
- _context20.next = 40;
1247
+ _context20.next = 38;
1232
1248
  break;
1233
1249
  }
1234
1250
  sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
1235
- originalPrice = toPriceString((_ref3 = (_sourceItem$original_ = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.original_price) !== null && _sourceItem$original_ !== void 0 ? _sourceItem$original_ : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref3 !== void 0 ? _ref3 : sellingPrice, sellingPrice);
1236
- paymentPrice = toPriceString((_ref4 = (_sourceItem$payment_p = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.payment_price) !== null && _sourceItem$payment_p !== void 0 ? _sourceItem$payment_p : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref4 !== void 0 ? _ref4 : sellingPrice, sellingPrice);
1237
1251
  tempOrder.products.push(normalizeOrderProduct({
1238
1252
  product_id: productId,
1239
1253
  product_variant_id: productVariantId,
1240
1254
  num: targetQuantity,
1241
1255
  selling_price: sellingPrice,
1242
- original_price: originalPrice,
1243
- payment_price: paymentPrice,
1256
+ original_price: sellingPrice,
1244
1257
  metadata: {
1245
1258
  item_rule_prefill: true,
1246
1259
  item_rule_id: prefillItem.ruleId
@@ -1251,8 +1264,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1251
1264
  })
1252
1265
  }));
1253
1266
  hasChanges = true;
1254
- return _context20.abrupt("continue", 47);
1255
- case 40:
1267
+ return _context20.abrupt("continue", 45);
1268
+ case 38:
1256
1269
  targetProduct = tempOrder.products[productIndex];
1257
1270
  existedQuantity = toNonNegativeInt(targetProduct.num);
1258
1271
  delta = targetQuantity - existedQuantity;
@@ -1271,45 +1284,45 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1271
1284
  tempOrder.products[productIndex] = nextProduct;
1272
1285
  hasChanges = true;
1273
1286
  }
1274
- case 47:
1287
+ case 45:
1275
1288
  _context20.next = 22;
1276
1289
  break;
1277
- case 49:
1278
- _context20.next = 54;
1290
+ case 47:
1291
+ _context20.next = 52;
1279
1292
  break;
1280
- case 51:
1281
- _context20.prev = 51;
1293
+ case 49:
1294
+ _context20.prev = 49;
1282
1295
  _context20.t0 = _context20["catch"](20);
1283
1296
  _iterator2.e(_context20.t0);
1284
- case 54:
1285
- _context20.prev = 54;
1297
+ case 52:
1298
+ _context20.prev = 52;
1286
1299
  _iterator2.f();
1287
- return _context20.finish(54);
1288
- case 57:
1300
+ return _context20.finish(52);
1301
+ case 55:
1289
1302
  if (!hasChanges) {
1290
- _context20.next = 61;
1303
+ _context20.next = 59;
1291
1304
  break;
1292
1305
  }
1293
- _context20.next = 60;
1306
+ _context20.next = 58;
1294
1307
  return this.store.order.recalculateSummary({
1295
1308
  createIfMissing: true
1296
1309
  });
1297
- case 60:
1310
+ case 58:
1298
1311
  this.store.order.persistTempOrder();
1299
- case 61:
1300
- _context20.next = 63;
1312
+ case 59:
1313
+ _context20.next = 61;
1301
1314
  return this.refreshItemRuleQuantityLimits();
1302
- case 63:
1315
+ case 61:
1303
1316
  this.itemRulePrefillApplied = true;
1304
1317
  this.logMethodSuccess('applyPrefillByItemRule', {
1305
1318
  prefillCount: prefillItems.length,
1306
1319
  hasChanges: hasChanges
1307
1320
  });
1308
- case 65:
1321
+ case 63:
1309
1322
  case "end":
1310
1323
  return _context20.stop();
1311
1324
  }
1312
- }, _callee20, this, [[20, 51, 54, 57]]);
1325
+ }, _callee20, this, [[20, 49, 52, 55]]);
1313
1326
  }));
1314
1327
  function applyPrefillByItemRule() {
1315
1328
  return _applyPrefillByItemRule.apply(this, arguments);
@@ -1320,19 +1333,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1320
1333
  key: "applyItemRulePrefill",
1321
1334
  value: function () {
1322
1335
  var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1336
+ var _this$store$order4, _this$store$order4$ge;
1323
1337
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1324
1338
  while (1) switch (_context21.prev = _context21.next) {
1325
1339
  case 0:
1340
+ if (!((_this$store$order4 = this.store.order) !== null && _this$store$order4 !== void 0 && (_this$store$order4$ge = _this$store$order4.getLastOrderInfo) !== null && _this$store$order4$ge !== void 0 && _this$store$order4$ge.call(_this$store$order4))) {
1341
+ _context21.next = 2;
1342
+ break;
1343
+ }
1344
+ return _context21.abrupt("return");
1345
+ case 2:
1326
1346
  this.logMethodStart('applyItemRulePrefill');
1327
- _context21.next = 3;
1328
- return this.applyPrefillByItemRule();
1329
- case 3:
1330
1347
  _context21.next = 5;
1331
- return this.refreshItemRuleQuantityLimits();
1348
+ return this.applyPrefillByItemRule();
1332
1349
  case 5:
1333
1350
  _context21.next = 7;
1334
- return this.refreshCartValidationPassed();
1351
+ return this.refreshItemRuleQuantityLimits();
1335
1352
  case 7:
1353
+ _context21.next = 9;
1354
+ return this.refreshCartValidationPassed();
1355
+ case 9:
1336
1356
  case "end":
1337
1357
  return _context21.stop();
1338
1358
  }
@@ -1519,7 +1539,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1519
1539
  }, {
1520
1540
  key: "normalizeResourceState",
1521
1541
  value: function normalizeResourceState(config, hasOrderId) {
1522
- var _this$otherParams4;
1542
+ var _this$otherParams8, _config$table_form_re;
1523
1543
  var orderNumberPrefix = Array.isArray(config === null || config === void 0 ? void 0 : config.order_number_prefix) ? (config === null || config === void 0 ? void 0 : config.order_number_prefix) || [] : [];
1524
1544
  var tableMaxNumber = Number((config === null || config === void 0 ? void 0 : config.table_max_number) || 1);
1525
1545
  var orderCount = toNonNegativeNumber(config === null || config === void 0 ? void 0 : config.order_count);
@@ -1528,7 +1548,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1528
1548
  var relationId = toPositiveString(config === null || config === void 0 ? void 0 : config.relation_id);
1529
1549
  var tableFormId = toPositiveString(config === null || config === void 0 ? void 0 : config.table_form_id);
1530
1550
  // 是否允许加餐
1531
- var allowSnack = ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 || (_this$otherParams4 = _this$otherParams4.dineInConfig) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4['workflow.allow_add_items']) || false;
1551
+ var allowSnack = ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.dineInConfig) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8['workflow.allow_add_items']) || false;
1532
1552
  // 开启同桌验证 - 本期没有这个配置,默认关掉
1533
1553
  var deskmateValid = false;
1534
1554
  var isExclusive = tableMaxNumber > 0 ? tableMaxNumber <= 1 : false;
@@ -1598,7 +1618,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1598
1618
  isExclusive: isExclusive,
1599
1619
  isFull: isFull,
1600
1620
  orderNumberPrefix: orderNumberPrefix,
1601
- raw: config
1621
+ raw: config,
1622
+ table_form_record: (_config$table_form_re = config === null || config === void 0 ? void 0 : config.table_form_record) !== null && _config$table_form_re !== void 0 ? _config$table_form_re : null
1602
1623
  });
1603
1624
  }
1604
1625
  }, {
@@ -1647,7 +1668,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1647
1668
  key: "checkResourceAvailable",
1648
1669
  value: function () {
1649
1670
  var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(resourceId, hasOrderId) {
1650
- var _this$otherParams5, _this$otherParams5$ge, _config$table_form_re, _config$table_form_re2, _this$otherParams6, _this$store$order4, openData, dineInConfig, shopClosedInfo, config, resourceState, availabilityInfo, tempOrder;
1671
+ var _this$otherParams9, _this$otherParams9$ge, _config$table_form_re2, _config$table_form_re3, _this$otherParams10, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams11, openData, dineInConfig, shopClosedInfo, config, resourceState, availabilityInfo, tempOrder, reservationLinkIds, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
1651
1672
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1652
1673
  while (1) switch (_context27.prev = _context27.next) {
1653
1674
  case 0:
@@ -1656,7 +1677,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1656
1677
  });
1657
1678
  _context27.prev = 1;
1658
1679
  _context27.next = 4;
1659
- return (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 || (_this$otherParams5$ge = _this$otherParams5.getOpenData) === null || _this$otherParams5$ge === void 0 ? void 0 : _this$otherParams5$ge.call(_this$otherParams5, {
1680
+ return (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getOpenData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, {
1660
1681
  scope: 'board',
1661
1682
  target: 'dine_in+scan_to_order',
1662
1683
  section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
@@ -1706,33 +1727,153 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1706
1727
  relation_id: resourceState.relationId,
1707
1728
  table_form_id: resourceState.tableFormId,
1708
1729
  deskmate_valid: resourceState.deskmate_valid,
1709
- policy: config === null || config === void 0 || (_config$table_form_re = config.table_form_record) === null || _config$table_form_re === void 0 ? void 0 : _config$table_form_re.policy,
1710
- partyroom_booking: config === null || config === void 0 || (_config$table_form_re2 = config.table_form_record) === null || _config$table_form_re2 === void 0 ? void 0 : _config$table_form_re2.partyroom_booking
1730
+ table_form_record: resourceState.table_form_record,
1731
+ policy: config === null || config === void 0 || (_config$table_form_re2 = config.table_form_record) === null || _config$table_form_re2 === void 0 ? void 0 : _config$table_form_re2.policy,
1732
+ partyroom_booking: config === null || config === void 0 || (_config$table_form_re3 = config.table_form_record) === null || _config$table_form_re3 === void 0 ? void 0 : _config$table_form_re3.partyroom_booking
1711
1733
  };
1712
1734
  tempOrder = this.ensureTempOrder();
1713
- tempOrder.relation_id = resourceId || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.relation_id);
1735
+ tempOrder.relation_id = resourceId || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.relation_id);
1714
1736
  tempOrder.table_form_id = resourceState.tableFormId;
1715
1737
  tempOrder.resource_id = resourceId;
1716
- (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
1738
+ reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['reservation.enabled_reservation_rules']);
1739
+ if (!(reservationLinkIds.length === 0)) {
1740
+ _context27.next = 31;
1741
+ break;
1742
+ }
1743
+ this.enabledReservationRuleProducts = [];
1744
+ if (this.store.resource) {
1745
+ delete this.store.resource.requestEntryPax;
1746
+ delete this.store.resource.requestPaxMin;
1747
+ delete this.store.resource.requestPaxMax;
1748
+ }
1749
+ _context27.next = 42;
1750
+ break;
1751
+ case 31:
1752
+ tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
1753
+ delete tempOrder.metadata.table_occupancy_duration;
1754
+ reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
1755
+ _context27.next = 36;
1756
+ return reservationProductList.initialize(this.core, {
1757
+ store: {
1758
+ list: [],
1759
+ selectProducts: []
1760
+ },
1761
+ otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
1762
+ fatherModule: this.name,
1763
+ openCache: Boolean(this.cacheId),
1764
+ cacheId: this.cacheId
1765
+ })
1766
+ });
1767
+ case 36:
1768
+ scheduleDate = dayjs().format('YYYY-MM-DD');
1769
+ scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
1770
+ _context27.next = 40;
1771
+ return reservationProductList.loadProducts({
1772
+ product_ids: reservationLinkIds,
1773
+ schedule_date: scheduleDate,
1774
+ schedule_datetime: scheduleDatetime,
1775
+ cacheId: this.cacheId
1776
+ });
1777
+ case 40:
1778
+ loaded = _context27.sent;
1779
+ if (Array.isArray(loaded)) {
1780
+ this.enabledReservationRuleProducts = loaded;
1781
+ occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
1782
+ if (occupancyMinutes !== undefined) {
1783
+ tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
1784
+ }
1785
+ if (hasCustomCapacityProduct(loaded)) {
1786
+ availabilityInfo.requestEntryPax = 1;
1787
+ if (this.store.resource) this.store.resource.requestEntryPax = 1;
1788
+ delete availabilityInfo.requestPaxMin;
1789
+ delete availabilityInfo.requestPaxMax;
1790
+ if (this.store.resource) {
1791
+ delete this.store.resource.requestPaxMin;
1792
+ delete this.store.resource.requestPaxMax;
1793
+ }
1794
+ paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
1795
+ if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) {
1796
+ availabilityInfo.requestPaxMin = paxBounds.min;
1797
+ if (this.store.resource) this.store.resource.requestPaxMin = paxBounds.min;
1798
+ }
1799
+ if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) {
1800
+ availabilityInfo.requestPaxMax = paxBounds.max;
1801
+ if (this.store.resource) this.store.resource.requestPaxMax = paxBounds.max;
1802
+ }
1803
+ } else if (this.store.resource) {
1804
+ delete this.store.resource.requestEntryPax;
1805
+ delete this.store.resource.requestPaxMin;
1806
+ delete this.store.resource.requestPaxMax;
1807
+ }
1808
+ } else {
1809
+ this.enabledReservationRuleProducts = [];
1810
+ if (this.store.resource) {
1811
+ delete this.store.resource.requestEntryPax;
1812
+ delete this.store.resource.requestPaxMin;
1813
+ delete this.store.resource.requestPaxMax;
1814
+ }
1815
+ void this.addScanOrderLog({
1816
+ level: 'error',
1817
+ title: '[ScanOrder] enabled_reservation_rules product query failed',
1818
+ payload: {
1819
+ linkIds: reservationLinkIds,
1820
+ error: this.serializeError(loaded)
1821
+ }
1822
+ });
1823
+ }
1824
+ case 42:
1825
+ (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
1717
1826
 
1718
1827
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
1719
1828
  if (!(availabilityInfo.mode === 'idle')) {
1720
- _context27.next = 29;
1829
+ _context27.next = 46;
1721
1830
  break;
1722
1831
  }
1723
- _context27.next = 29;
1832
+ _context27.next = 46;
1724
1833
  return this.addNewOrder();
1725
- case 29:
1834
+ case 46:
1726
1835
  // 如果是加单模式,tempOrder 里 需要记录 lastOrderId,提交的时候走加单接口
1727
1836
  if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
1728
1837
  tempOrder.order_id = resourceState.lastOrderId;
1729
1838
  }
1730
- _context27.next = 32;
1731
- return this.refreshItemRuleQuantityLimits();
1732
- case 32:
1733
- _context27.next = 34;
1734
- return this.refreshCartValidationPassed();
1735
- case 34:
1839
+ if (!tempOrder.order_id) {
1840
+ _context27.next = 55;
1841
+ break;
1842
+ }
1843
+ _context27.next = 50;
1844
+ return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getOrderInfoByRemote(tempOrder.order_id);
1845
+ case 50:
1846
+ res = _context27.sent;
1847
+ // 找到下单的时候输入的 entryPaxNumber
1848
+ entryPaxNumber = res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.bookings) === null || _res$data === void 0 || (_res$data = _res$data.find(function (p) {
1849
+ var _p$metadata;
1850
+ return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
1851
+ })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
1852
+ if (!entryPaxNumber) {
1853
+ _context27.next = 55;
1854
+ break;
1855
+ }
1856
+ _context27.next = 55;
1857
+ return this.setEntryPaxNumber(entryPaxNumber);
1858
+ case 55:
1859
+ lastOrderInfo = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 || (_this$store$order7$ge = _this$store$order7.getLastOrderInfo) === null || _this$store$order7$ge === void 0 ? void 0 : _this$store$order7$ge.call(_this$store$order7);
1860
+ historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
1861
+ if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
1862
+ acc.push(_objectSpread({
1863
+ product_id: p.product_id,
1864
+ quantity: Number(p.product_quantity) || 0
1865
+ }, typeof p.product_variant_id === 'number' ? {
1866
+ product_variant_id: p.product_variant_id
1867
+ } : {}));
1868
+ return acc;
1869
+ }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
1870
+ _context27.next = 59;
1871
+ return this.setItemRuleRuntimeConfig({
1872
+ serviceType: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode,
1873
+ submissionIndex: hasOrderId ? 1 : 0,
1874
+ historicalItems: historicalItems
1875
+ });
1876
+ case 59:
1736
1877
  this.logMethodSuccess('checkResourceAvailable', {
1737
1878
  resourceId: resourceId,
1738
1879
  mode: availabilityInfo.mode,
@@ -1748,18 +1889,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1748
1889
  isFull: resourceState.isFull
1749
1890
  });
1750
1891
  return _context27.abrupt("return", availabilityInfo);
1751
- case 38:
1752
- _context27.prev = 38;
1892
+ case 63:
1893
+ _context27.prev = 63;
1753
1894
  _context27.t0 = _context27["catch"](1);
1754
1895
  this.logMethodError('checkResourceAvailable', _context27.t0, {
1755
1896
  resourceId: resourceId
1756
1897
  });
1757
1898
  throw _context27.t0;
1758
- case 42:
1899
+ case 67:
1759
1900
  case "end":
1760
1901
  return _context27.stop();
1761
1902
  }
1762
- }, _callee27, this, [[1, 38]]);
1903
+ }, _callee27, this, [[1, 63]]);
1763
1904
  }));
1764
1905
  function checkResourceAvailable(_x10, _x11) {
1765
1906
  return _checkResourceAvailable.apply(this, arguments);
@@ -1802,14 +1943,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1802
1943
  key: "getProductList",
1803
1944
  value: function () {
1804
1945
  var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
1805
- var _this$otherParams7;
1946
+ var _this$otherParams12;
1806
1947
  var menu_list_ids, _this$store$products, res, formattedRes;
1807
1948
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1808
1949
  while (1) switch (_context29.prev = _context29.next) {
1809
1950
  case 0:
1810
1951
  this.logMethodStart('getProductList');
1811
1952
  // 可以直接通过配置里的 menu 读取
1812
- menu_list_ids = ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 || (_this$otherParams7 = _this$otherParams7.dineInConfig) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7['menu.associated_menus'].map(function (n) {
1953
+ menu_list_ids = ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 || (_this$otherParams12 = _this$otherParams12.dineInConfig) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12['menu.associated_menus'].map(function (n) {
1813
1954
  return Number(n.value);
1814
1955
  })) || [];
1815
1956
  _context29.prev = 2;
@@ -1848,6 +1989,82 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1848
1989
  value: function getOtherParams() {
1849
1990
  return this.otherParams;
1850
1991
  }
1992
+ }, {
1993
+ key: "setOtherParams",
1994
+ value: function () {
1995
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
1996
+ var _ref3,
1997
+ _ref3$cover,
1998
+ cover,
1999
+ _args30 = arguments;
2000
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2001
+ while (1) switch (_context30.prev = _context30.next) {
2002
+ case 0:
2003
+ _ref3 = _args30.length > 1 && _args30[1] !== undefined ? _args30[1] : {}, _ref3$cover = _ref3.cover, cover = _ref3$cover === void 0 ? false : _ref3$cover;
2004
+ if (cover) {
2005
+ this.otherParams = params;
2006
+ } else {
2007
+ this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
2008
+ }
2009
+ case 2:
2010
+ case "end":
2011
+ return _context30.stop();
2012
+ }
2013
+ }, _callee30, this);
2014
+ }));
2015
+ function setOtherParams(_x12) {
2016
+ return _setOtherParams.apply(this, arguments);
2017
+ }
2018
+ return setOtherParams;
2019
+ }()
2020
+ }, {
2021
+ key: "setEntryPaxNumber",
2022
+ value: function () {
2023
+ var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(number) {
2024
+ var pax, t;
2025
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2026
+ while (1) switch (_context31.prev = _context31.next) {
2027
+ case 0:
2028
+ pax = normalizeSubmitCollectPaxValue(number);
2029
+ this.store.entryPaxNumber = pax;
2030
+ if (this.store.order) {
2031
+ t = this.store.order.ensureTempOrder();
2032
+ t.metadata = _objectSpread(_objectSpread({}, t.metadata), {}, {
2033
+ collect_pax: pax
2034
+ });
2035
+ this.store.order.persistTempOrder();
2036
+ }
2037
+
2038
+ // pax 变化后同步到 itemRuleRuntimeConfig,并刷新限购 / 校验
2039
+ this.itemRuleRuntimeConfig = _objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), {}, {
2040
+ pax: {
2041
+ total: pax,
2042
+ adult: 0,
2043
+ child: 0
2044
+ }
2045
+ });
2046
+ this.itemRulePrefillApplied = false;
2047
+ _context31.next = 7;
2048
+ return this.refreshItemRuleQuantityLimits();
2049
+ case 7:
2050
+ _context31.next = 9;
2051
+ return this.refreshCartValidationPassed();
2052
+ case 9:
2053
+ case "end":
2054
+ return _context31.stop();
2055
+ }
2056
+ }, _callee31, this);
2057
+ }));
2058
+ function setEntryPaxNumber(_x13) {
2059
+ return _setEntryPaxNumber.apply(this, arguments);
2060
+ }
2061
+ return setEntryPaxNumber;
2062
+ }()
2063
+ }, {
2064
+ key: "getEntryPaxNumber",
2065
+ value: function getEntryPaxNumber() {
2066
+ return this.store.entryPaxNumber;
2067
+ }
1851
2068
  }]);
1852
2069
  return ScanOrderImpl;
1853
2070
  }(BaseModule);