@pisell/pisellos 2.1.158 → 2.1.160

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.
@@ -32,7 +32,7 @@ import { OrderModule } from "../../modules/Order";
32
32
  import { AccountHooks } from "../../modules/Account/types";
33
33
  import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
34
34
  import Decimal from 'decimal.js';
35
- import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
35
+ import { attachItemRuleLimitsToTopLevelProducts, buildProductKey, buildItemRuleBusinessData, collectLinkProductIdsFromReservationRules, computeResourceIsFull, createEmptySummary, findReservationRuleProductByResourceId, getProductIdentityIndex, getSafeProductNum, hasCustomCapacityProduct, pickFirstCustomCapacityDimensionId, pickFirstCustomCapacityPaxBounds, normalizeEnabledItemRuleIds, normalizeOrderProduct, normalizeItemRuleStrategies, pickFirstDurationMinutesFromProducts, toNonNegativeInt, toPriceString, toBoolean, toPositiveString } from "./utils";
36
36
  import { createModule } from "../BookingByStep/types";
37
37
  import { ProductList } from "../../modules/ProductList";
38
38
  import { ScheduleModule } from "../../modules/Schedule";
@@ -852,11 +852,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
852
852
  mode: mode
853
853
  });
854
854
  try {
855
+ var _this$otherParams4;
855
856
  if (!this.store.order) throw new Error('order 模块未初始化');
856
857
  var tempOrder = this.store.order.ensureTempOrder();
857
858
  tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
858
859
  shop_service_data: _objectSpread(_objectSpread({}, (tempOrder.metadata || {}).shop_service_data || {}), {}, {
859
- service_type: 'dine_in',
860
+ service_type: ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) === 'dine_in' ? 'dine_in' : '',
860
861
  pickup_reference_mode: mode
861
862
  })
862
863
  });
@@ -1339,7 +1340,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1339
1340
  key: "prepareRetailAvailability",
1340
1341
  value: function () {
1341
1342
  var _prepareRetailAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1342
- var _this$store$order4, _this$otherParams4;
1343
+ var _this$store$order4, _this$otherParams5;
1343
1344
  var tempOrder, hasOrderId, resourceId, reason, resourceState, availabilityInfo;
1344
1345
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1345
1346
  while (1) switch (_context17.prev = _context17.next) {
@@ -1370,7 +1371,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1370
1371
  case 15:
1371
1372
  _context17.next = 17;
1372
1373
  return this.setItemRuleRuntimeConfig({
1373
- serviceType: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode,
1374
+ serviceType: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
1374
1375
  submissionIndex: hasOrderId ? 1 : 0,
1375
1376
  historicalItems: []
1376
1377
  });
@@ -1411,13 +1412,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1411
1412
  var resourceState = this.store.resource;
1412
1413
  var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
1413
1414
 
1414
- // collect_pax 时的资源占用兜底:single 独占整张桌台,其余模式占 1 个容量位。
1415
- var resolveResourceCapacity = function resolveResourceCapacity() {
1415
+ // ScanOrder booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
1416
+ var resolveBookingCapacityValue = function resolveBookingCapacityValue() {
1416
1417
  if (resourceSelectType === 'single') {
1417
1418
  var _resourceState$table_;
1418
1419
  var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
1419
1420
  var num = Number(raw);
1420
- if (Number.isFinite(num) && num > 0) return num;
1421
+ if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
1421
1422
  return 1;
1422
1423
  }
1423
1424
  return 1;
@@ -1435,8 +1436,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1435
1436
  });
1436
1437
  }
1437
1438
  var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1438
- var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1439
- var resourceCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
1439
+ var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1440
+ var bookingCapacityValue = resolveBookingCapacityValue();
1440
1441
  var pickOriginal = function pickOriginal(value) {
1441
1442
  if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
1442
1443
  var original = value.original;
@@ -1452,21 +1453,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1452
1453
  main_field: mainField,
1453
1454
  form_id: resourceState.tableFormId,
1454
1455
  relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
1455
- capacity: resourceCapacityValue,
1456
+ capacity: bookingCapacityValue,
1456
1457
  metadata: _this5.buildScanOrderResourceMetadata({
1457
1458
  resourceState: resourceState,
1458
1459
  resourceName: mainField
1459
1460
  })
1460
1461
  } : undefined;
1461
1462
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1462
- // 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
1463
- var bookingCapacityValue = resourceCapacityValue;
1464
1463
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1465
1464
  var nextBookings = (payload.bookings || []).map(function (booking, idx) {
1465
+ var metadata = _objectSpread({}, booking.metadata || {});
1466
+ if (hasExplicitCollectPax) {
1467
+ metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
1468
+ } else {
1469
+ delete metadata.collect_pax;
1470
+ }
1466
1471
  return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
1467
1472
  number: bookingCapacityValue,
1468
1473
  appointment_status: 'started',
1469
- metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
1474
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, metadata), resourceSelectType ? {
1470
1475
  resource_select_type: resourceSelectType
1471
1476
  } : {}), resourceSelectType ? {
1472
1477
  capacity: [{
@@ -1516,7 +1521,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1516
1521
  key: "submitScanOrder",
1517
1522
  value: function () {
1518
1523
  var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1519
- var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1524
+ var _this$store$resource, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9, _tempOrder$products, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1520
1525
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1521
1526
  while (1) switch (_context18.prev = _context18.next) {
1522
1527
  case 0:
@@ -1531,12 +1536,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1531
1536
  }
1532
1537
  throw new Error('scanOrder解决方案需要 order 模块支持');
1533
1538
  case 6:
1534
- pax = normalizeSubmitCollectPaxValue(this.store.entryPaxNumber);
1535
- this.store.entryPaxNumber = pax;
1536
1539
  tempOrderForSubmit = this.store.order.ensureTempOrder();
1537
- tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
1538
- collect_pax: pax
1539
- });
1540
1540
  tempOrderForSubmit.delivery_type = 'shop_service';
1541
1541
  resourceTableName = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 || (_this$store$resource = _this$store$resource.table_form_record) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.name;
1542
1542
  if (resourceTableName && _typeof(resourceTableName) === 'object') {
@@ -1546,32 +1546,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1546
1546
  }
1547
1547
  this.store.order.persistTempOrder();
1548
1548
  enhancePayload = this.buildSubmitPayloadEnhancer();
1549
- _context18.next = 17;
1549
+ _context18.next = 14;
1550
1550
  return this.store.order.submitTempOrder({
1551
1551
  cacheId: this.cacheId,
1552
- platform: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform,
1553
- businessCode: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode,
1554
- channel: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.channel,
1555
- type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type,
1552
+ platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
1553
+ businessCode: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode,
1554
+ channel: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel,
1555
+ type: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
1556
1556
  enhancePayload: enhancePayload
1557
1557
  });
1558
- case 17:
1558
+ case 14:
1559
1559
  result = _context18.sent;
1560
1560
  tempOrder = this.store.order.getTempOrder();
1561
1561
  this.logMethodSuccess('submitScanOrder', {
1562
1562
  productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
1563
1563
  });
1564
1564
  return _context18.abrupt("return", result);
1565
- case 23:
1566
- _context18.prev = 23;
1565
+ case 20:
1566
+ _context18.prev = 20;
1567
1567
  _context18.t0 = _context18["catch"](1);
1568
1568
  this.logMethodError('submitScanOrder', _context18.t0);
1569
1569
  throw _context18.t0;
1570
- case 27:
1570
+ case 24:
1571
1571
  case "end":
1572
1572
  return _context18.stop();
1573
1573
  }
1574
- }, _callee18, this, [[1, 23]]);
1574
+ }, _callee18, this, [[1, 20]]);
1575
1575
  }));
1576
1576
  function submitScanOrder() {
1577
1577
  return _submitScanOrder.apply(this, arguments);
@@ -2482,14 +2482,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2482
2482
  }, {
2483
2483
  key: "normalizeResourceState",
2484
2484
  value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
2485
- var _detail$form_record, _this$otherParams9, _detail$resource_capa, _detail$resource_capa2;
2485
+ var _detail$form_record, _this$otherParams10, _detail$resource_capa, _detail$resource_capa2;
2486
2486
  var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
2487
2487
  var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
2488
2488
  var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
2489
2489
  var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
2490
2490
  var formRecord = (_detail$form_record = detail === null || detail === void 0 ? void 0 : detail.form_record) !== null && _detail$form_record !== void 0 ? _detail$form_record : null;
2491
2491
  // 是否允许加餐
2492
- var allowSnack = ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9 = _this$otherParams9.dineInConfig) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9['sale.allow_add_items']) || false;
2492
+ var allowSnack = ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10 = _this$otherParams10.dineInConfig) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10['sale.allow_add_items']) || false;
2493
2493
  // 开启同桌验证 - 本期没有这个配置,默认关掉
2494
2494
  var deskmateValid = false;
2495
2495
  var isExclusive = resourceSelectType === 'single';
@@ -2569,10 +2569,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2569
2569
  return matched === null || matched === void 0 ? void 0 : matched.type;
2570
2570
  }
2571
2571
  }, {
2572
- key: "fetchResourceOccupyDetailByResourceId",
2572
+ key: "fetchResourceOccupyDetailsByResourceId",
2573
2573
  value: function () {
2574
- var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
2575
- var _this$otherParams10, _this$otherParams10$g, _response$data$occupy, _response$data;
2574
+ var _fetchResourceOccupyDetailsByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
2575
+ var _this$otherParams11, _this$otherParams11$g, _response$data$occupy, _response$data;
2576
2576
  var formRecordId, shopId, response;
2577
2577
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2578
2578
  while (1) switch (_context36.prev = _context36.next) {
@@ -2584,7 +2584,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2584
2584
  }
2585
2585
  throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
2586
2586
  case 3:
2587
- shopId = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 || (_this$otherParams10$g = _this$otherParams10.getStateData) === null || _this$otherParams10$g === void 0 ? void 0 : _this$otherParams10$g.call(_this$otherParams10, 'shop_id');
2587
+ shopId = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 || (_this$otherParams11$g = _this$otherParams11.getStateData) === null || _this$otherParams11$g === void 0 ? void 0 : _this$otherParams11$g.call(_this$otherParams11, 'shop_id');
2588
2588
  if (shopId) {
2589
2589
  _context36.next = 6;
2590
2590
  break;
@@ -2607,18 +2607,68 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2607
2607
  }
2608
2608
  throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
2609
2609
  case 11:
2610
- return _context36.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.occupy_details) === null || _response$data === void 0 ? void 0 : _response$data[0]) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : null);
2610
+ return _context36.abrupt("return", (_response$data$occupy = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.occupy_details) !== null && _response$data$occupy !== void 0 ? _response$data$occupy : []);
2611
2611
  case 12:
2612
2612
  case "end":
2613
2613
  return _context36.stop();
2614
2614
  }
2615
2615
  }, _callee36, this);
2616
2616
  }));
2617
- function fetchResourceOccupyDetailByResourceId(_x18) {
2618
- return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
2617
+ function fetchResourceOccupyDetailsByResourceId(_x18) {
2618
+ return _fetchResourceOccupyDetailsByResourceId.apply(this, arguments);
2619
+ }
2620
+ return fetchResourceOccupyDetailsByResourceId;
2621
+ }()
2622
+ }, {
2623
+ key: "resolveAdditionalOrderFromOccupyDetail",
2624
+ value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
2625
+ var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
2626
+ if (currentOrderId) {
2627
+ return {
2628
+ matched: true,
2629
+ order_id: currentOrderId
2630
+ };
2631
+ }
2632
+ var orderListIds = (Array.isArray(detail === null || detail === void 0 ? void 0 : detail.order_list) ? (detail === null || detail === void 0 ? void 0 : detail.order_list) || [] : []).map(function (order) {
2633
+ return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
2634
+ }).filter(Boolean);
2635
+ if (resourceSelectType !== 'single') {
2636
+ return {
2637
+ matched: false,
2638
+ reason: 'no_order'
2639
+ };
2640
+ }
2641
+ if (!orderListIds.length) {
2642
+ return {
2643
+ matched: false,
2644
+ reason: 'no_order'
2645
+ };
2646
+ }
2647
+ if (!allowAddItems) {
2648
+ return {
2649
+ matched: false,
2650
+ reason: 'add_items_disabled'
2651
+ };
2619
2652
  }
2620
- return fetchResourceOccupyDetailByResourceId;
2621
- }() // 检测当前链接是否可用
2653
+ if (orderListIds.length === 1) {
2654
+ return {
2655
+ matched: true,
2656
+ order_id: orderListIds[0]
2657
+ };
2658
+ }
2659
+ if (orderListIds.length > 1) {
2660
+ return {
2661
+ matched: false,
2662
+ reason: 'multiple_orders'
2663
+ };
2664
+ }
2665
+ return {
2666
+ matched: false,
2667
+ reason: 'no_order'
2668
+ };
2669
+ }
2670
+
2671
+ // 检测当前链接是否可用
2622
2672
  // 通过 resource_id + 店铺配置
2623
2673
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
2624
2674
  }, {
@@ -2628,18 +2678,19 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2628
2678
  var hasOrderId,
2629
2679
  normalizedResourceId,
2630
2680
  _this$otherParams$bus,
2631
- _this$otherParams11,
2632
- _this$otherParams$cha,
2633
2681
  _this$otherParams12,
2682
+ _this$otherParams$cha,
2634
2683
  _this$otherParams13,
2635
- _this$otherParams13$g,
2684
+ _this$otherParams14,
2685
+ _this$otherParams14$g,
2686
+ _occupyDetails$,
2636
2687
  _occupyDetail$form_re,
2637
2688
  _occupyDetail$form_re2,
2638
- _this$otherParams14,
2639
- _this$store$order6,
2640
- _this$store$order8,
2641
- _this$store$order8$ge,
2642
2689
  _this$otherParams15,
2690
+ _this$store$order6,
2691
+ _this$store$order7,
2692
+ _this$store$order7$ge,
2693
+ _this$otherParams16,
2643
2694
  businessCode,
2644
2695
  channel,
2645
2696
  openDataTarget,
@@ -2663,17 +2714,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2663
2714
  scheduleDate,
2664
2715
  scheduleDatetime,
2665
2716
  loaded,
2717
+ matchedRuleProduct,
2718
+ ruleProductsForResource,
2666
2719
  occupancyMinutes,
2667
2720
  paxBounds,
2668
2721
  error,
2722
+ occupyDetails,
2669
2723
  occupyDetail,
2670
2724
  resourceSelectType,
2725
+ allowAddItems,
2726
+ additionalOrderResult,
2727
+ _occupyDetail$order_l,
2728
+ multipleOrdersState,
2729
+ _availabilityInfo,
2671
2730
  resourceState,
2731
+ additionalOrderId,
2672
2732
  availabilityInfo,
2673
- _this$store$order7,
2674
- _res$data,
2675
- res,
2676
- entryPaxNumber,
2733
+ isAdditionalOrderMode,
2677
2734
  lastOrderInfo,
2678
2735
  historicalItems,
2679
2736
  _args37 = arguments;
@@ -2686,11 +2743,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2686
2743
  resourceId: normalizedResourceId
2687
2744
  });
2688
2745
  _context37.prev = 3;
2689
- businessCode = String((_this$otherParams$bus = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
2690
- channel = String((_this$otherParams$cha = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
2746
+ businessCode = String((_this$otherParams$bus = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
2747
+ channel = String((_this$otherParams$cha = (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
2691
2748
  openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
2692
2749
  _context37.next = 9;
2693
- return (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13$g = _this$otherParams13.getOpenData) === null || _this$otherParams13$g === void 0 ? void 0 : _this$otherParams13$g.call(_this$otherParams13, {
2750
+ return (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 || (_this$otherParams14$g = _this$otherParams14.getOpenData) === null || _this$otherParams14$g === void 0 ? void 0 : _this$otherParams14$g.call(_this$otherParams14, {
2694
2751
  scope: 'board',
2695
2752
  target: openDataTarget,
2696
2753
  section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
@@ -2805,14 +2862,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2805
2862
  case 46:
2806
2863
  loaded = _context37.sent;
2807
2864
  if (Array.isArray(loaded)) {
2808
- this.enabledReservationRuleProducts = loaded;
2809
- occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
2865
+ matchedRuleProduct = findReservationRuleProductByResourceId(loaded, normalizedResourceId);
2866
+ ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
2867
+ this.enabledReservationRuleProducts = ruleProductsForResource;
2868
+ occupancyMinutes = pickFirstDurationMinutesFromProducts(ruleProductsForResource);
2810
2869
  if (occupancyMinutes !== undefined) {
2811
2870
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
2812
2871
  }
2813
- if (hasCustomCapacityProduct(loaded)) {
2872
+ if (hasCustomCapacityProduct(ruleProductsForResource)) {
2814
2873
  pendingRequestEntryPax = 1;
2815
- paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
2874
+ paxBounds = pickFirstCustomCapacityPaxBounds(ruleProductsForResource);
2816
2875
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) pendingRequestPaxMin = paxBounds.min;
2817
2876
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) pendingRequestPaxMax = paxBounds.max;
2818
2877
  }
@@ -2828,15 +2887,52 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2828
2887
  });
2829
2888
  }
2830
2889
 
2831
- // Step2: 请求新的资源占用详情接口
2890
+ // Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
2832
2891
  _context37.next = 50;
2833
- return this.fetchResourceOccupyDetailByResourceId(normalizedResourceId);
2892
+ return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
2834
2893
  case 50:
2835
- occupyDetail = _context37.sent;
2836
- // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2894
+ occupyDetails = _context37.sent;
2895
+ occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2837
2896
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
2838
- resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2897
+ resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
2898
+ allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
2899
+ additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
2900
+ if (!(additionalOrderResult.reason === 'multiple_orders')) {
2901
+ _context37.next = 61;
2902
+ break;
2903
+ }
2904
+ multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
2905
+ mode: 'multiple_orders'
2906
+ });
2907
+ this.store.resource = multipleOrdersState;
2908
+ _availabilityInfo = {
2909
+ mode: 'multiple_orders',
2910
+ deskmate_valid: multipleOrdersState.deskmate_valid,
2911
+ relation_id: multipleOrdersState.relationId,
2912
+ table_form_id: multipleOrdersState.tableFormId,
2913
+ table_form_record: multipleOrdersState.table_form_record
2914
+ };
2915
+ this.logMethodSuccess('checkResourceAvailable', {
2916
+ resourceId: normalizedResourceId,
2917
+ mode: _availabilityInfo.mode,
2918
+ orderListCount: (occupyDetail === null || occupyDetail === void 0 || (_occupyDetail$order_l = occupyDetail.order_list) === null || _occupyDetail$order_l === void 0 ? void 0 : _occupyDetail$order_l.length) || 0,
2919
+ resourceSelectType: resourceSelectType
2920
+ });
2921
+ return _context37.abrupt("return", _availabilityInfo);
2922
+ case 61:
2923
+ // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2839
2924
  resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
2925
+ additionalOrderId = additionalOrderResult.order_id;
2926
+ if (additionalOrderId) {
2927
+ resourceState.mode = 'additional_order';
2928
+ resourceState.order_id = additionalOrderId;
2929
+ } else if (additionalOrderResult.reason === 'add_items_disabled') {
2930
+ resourceState.mode = 'resource_busy';
2931
+ resourceState.order_id = '0';
2932
+ } else if (resourceSelectType === 'multiple' && resourceState.isFull) {
2933
+ resourceState.mode = 'resource_busy';
2934
+ resourceState.order_id = '0';
2935
+ }
2840
2936
  this.store.resource = resourceState;
2841
2937
 
2842
2938
  // Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
@@ -2865,45 +2961,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2865
2961
  } : {}), this.store.resource.requestPaxMax !== undefined ? {
2866
2962
  requestPaxMax: this.store.resource.requestPaxMax
2867
2963
  } : {});
2868
- tempOrder.relation_id = normalizedResourceId || ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.relation_id);
2964
+ tempOrder.relation_id = normalizedResourceId || ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.relation_id);
2869
2965
  tempOrder.table_form_id = resourceState.tableFormId;
2870
2966
  tempOrder.resource_id = normalizedResourceId;
2871
2967
  (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || _this$store$order6.persistTempOrder();
2872
2968
 
2873
2969
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2874
2970
  if (!(availabilityInfo.mode === 'idle')) {
2875
- _context37.next = 65;
2971
+ _context37.next = 76;
2876
2972
  break;
2877
2973
  }
2878
- _context37.next = 65;
2974
+ _context37.next = 76;
2879
2975
  return this.addNewOrder();
2880
- case 65:
2881
- // 如果是加单模式,tempOrder 需要记录 lastOrderId,提交的时候走加单接口
2882
- if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
2883
- tempOrder.order_id = resourceState.lastOrderId;
2884
- }
2885
- if (!tempOrder.order_id) {
2886
- _context37.next = 74;
2887
- break;
2976
+ case 76:
2977
+ isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
2978
+ if (isAdditionalOrderMode) {
2979
+ tempOrder.order_id = additionalOrderId;
2888
2980
  }
2889
- _context37.next = 69;
2890
- return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
2891
- case 69:
2892
- res = _context37.sent;
2893
- // 找到下单的时候输入的 entryPaxNumber
2894
- 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) {
2895
- var _p$metadata;
2896
- return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2897
- })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2898
- if (!entryPaxNumber) {
2899
- _context37.next = 74;
2900
- break;
2901
- }
2902
- _context37.next = 74;
2903
- return this.setEntryPaxNumber(entryPaxNumber);
2904
- case 74:
2905
- lastOrderInfo = (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || (_this$store$order8$ge = _this$store$order8.getLastOrderInfo) === null || _this$store$order8$ge === void 0 ? void 0 : _this$store$order8$ge.call(_this$store$order8);
2906
- historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2981
+ 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);
2982
+ historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2907
2983
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
2908
2984
  acc.push(_objectSpread({
2909
2985
  product_id: p.product_id,
@@ -2913,13 +2989,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2913
2989
  } : {}));
2914
2990
  return acc;
2915
2991
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2916
- _context37.next = 78;
2992
+ _context37.next = 82;
2917
2993
  return this.setItemRuleRuntimeConfig({
2918
- serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
2919
- submissionIndex: hasOrderId ? 1 : 0,
2994
+ serviceType: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode,
2995
+ submissionIndex: isAdditionalOrderMode ? 1 : 0,
2920
2996
  historicalItems: historicalItems
2921
2997
  });
2922
- case 78:
2998
+ case 82:
2923
2999
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
2924
3000
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
2925
3001
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -2941,31 +3017,70 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2941
3017
  isFull: resourceState.isFull
2942
3018
  });
2943
3019
  return _context37.abrupt("return", availabilityInfo);
2944
- case 83:
2945
- _context37.prev = 83;
3020
+ case 87:
3021
+ _context37.prev = 87;
2946
3022
  _context37.t0 = _context37["catch"](3);
2947
3023
  this.logMethodError('checkResourceAvailable', _context37.t0.message, {
2948
3024
  resourceId: normalizedResourceId
2949
3025
  });
2950
3026
  throw _context37.t0;
2951
- case 87:
3027
+ case 91:
2952
3028
  case "end":
2953
3029
  return _context37.stop();
2954
3030
  }
2955
- }, _callee37, this, [[3, 83]]);
3031
+ }, _callee37, this, [[3, 87]]);
2956
3032
  }));
2957
3033
  function checkResourceAvailable(_x19) {
2958
3034
  return _checkResourceAvailable.apply(this, arguments);
2959
3035
  }
2960
3036
  return checkResourceAvailable;
3037
+ }() // 恢复之前订单的数据,读取 entrypax
3038
+ }, {
3039
+ key: "restorePreviousOrderData",
3040
+ value: function () {
3041
+ var _restorePreviousOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3042
+ var tempOrder, _this$store$order8, _res$data, res, entryPaxNumber;
3043
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3044
+ while (1) switch (_context38.prev = _context38.next) {
3045
+ case 0:
3046
+ tempOrder = this.ensureTempOrder();
3047
+ if (!tempOrder.order_id) {
3048
+ _context38.next = 9;
3049
+ break;
3050
+ }
3051
+ _context38.next = 4;
3052
+ return (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getOrderInfoByRemote(tempOrder.order_id);
3053
+ case 4:
3054
+ res = _context38.sent;
3055
+ // 找到下单的时候输入的 entryPaxNumber
3056
+ 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) {
3057
+ var _p$metadata;
3058
+ return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
3059
+ })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
3060
+ if (!entryPaxNumber) {
3061
+ _context38.next = 9;
3062
+ break;
3063
+ }
3064
+ _context38.next = 9;
3065
+ return this.setEntryPaxNumber(entryPaxNumber);
3066
+ case 9:
3067
+ case "end":
3068
+ return _context38.stop();
3069
+ }
3070
+ }, _callee38, this);
3071
+ }));
3072
+ function restorePreviousOrderData() {
3073
+ return _restorePreviousOrderData.apply(this, arguments);
3074
+ }
3075
+ return restorePreviousOrderData;
2961
3076
  }() // 如果是加单的情况,提供返回当前订单相关信息的能力
2962
3077
  }, {
2963
3078
  key: "getAdditionalOrderInfo",
2964
3079
  value: function () {
2965
- var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3080
+ var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
2966
3081
  var result;
2967
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2968
- while (1) switch (_context38.prev = _context38.next) {
3082
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3083
+ while (1) switch (_context39.prev = _context39.next) {
2969
3084
  case 0:
2970
3085
  this.logMethodStart('getAdditionalOrderInfo');
2971
3086
  result = {
@@ -2979,12 +3094,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2979
3094
  orderId: result.orderId,
2980
3095
  orderStatus: result.orderStatus
2981
3096
  });
2982
- return _context38.abrupt("return", result);
3097
+ return _context39.abrupt("return", result);
2983
3098
  case 4:
2984
3099
  case "end":
2985
- return _context38.stop();
3100
+ return _context39.stop();
2986
3101
  }
2987
- }, _callee38, this);
3102
+ }, _callee39, this);
2988
3103
  }));
2989
3104
  function getAdditionalOrderInfo() {
2990
3105
  return _getAdditionalOrderInfo.apply(this, arguments);
@@ -2994,25 +3109,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2994
3109
  }, {
2995
3110
  key: "getProductList",
2996
3111
  value: function () {
2997
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
2998
- var _this$otherParams16;
3112
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3113
+ var _this$otherParams17;
2999
3114
  var menu_list_ids, res, productList, formattedRes;
3000
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3001
- while (1) switch (_context39.prev = _context39.next) {
3115
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3116
+ while (1) switch (_context40.prev = _context40.next) {
3002
3117
  case 0:
3003
3118
  this.logMethodStart('getProductList');
3004
3119
  // 可以直接通过配置里的 menu 读取
3005
- menu_list_ids = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 || (_this$otherParams16 = _this$otherParams16.dineInConfig) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16['menu.associated_menus'].map(function (n) {
3120
+ menu_list_ids = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.dineInConfig) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['menu.associated_menus'].map(function (n) {
3006
3121
  return Number(n.value);
3007
3122
  })) || [];
3008
- _context39.prev = 2;
3123
+ _context40.prev = 2;
3009
3124
  if (this.store.products) {
3010
- _context39.next = 5;
3125
+ _context40.next = 5;
3011
3126
  break;
3012
3127
  }
3013
3128
  throw new Error('products 模块未初始化');
3014
3129
  case 5:
3015
- _context39.next = 7;
3130
+ _context40.next = 7;
3016
3131
  return this.store.products.loadProducts({
3017
3132
  menu_list_ids: menu_list_ids,
3018
3133
  cacheId: this.cacheId,
@@ -3020,7 +3135,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3020
3135
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
3021
3136
  });
3022
3137
  case 7:
3023
- res = _context39.sent;
3138
+ res = _context40.sent;
3024
3139
  productList = this.assertProductListLoaded('getProductList', res, {
3025
3140
  menu_list_ids: menu_list_ids,
3026
3141
  cacheId: this.cacheId
@@ -3029,22 +3144,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3029
3144
  this.logMethodSuccess('getProductList', {
3030
3145
  menuCount: menu_list_ids.length
3031
3146
  });
3032
- return _context39.abrupt("return", formattedRes);
3147
+ return _context40.abrupt("return", formattedRes);
3033
3148
  case 14:
3034
- _context39.prev = 14;
3035
- _context39.t0 = _context39["catch"](2);
3036
- if (!(_context39.t0 !== null && _context39.t0 !== void 0 && _context39.t0.__scanOrderLogged)) {
3037
- this.logMethodError('getProductList', _context39.t0, {
3149
+ _context40.prev = 14;
3150
+ _context40.t0 = _context40["catch"](2);
3151
+ if (!(_context40.t0 !== null && _context40.t0 !== void 0 && _context40.t0.__scanOrderLogged)) {
3152
+ this.logMethodError('getProductList', _context40.t0, {
3038
3153
  menu_list_ids: menu_list_ids,
3039
3154
  cacheId: this.cacheId
3040
3155
  });
3041
3156
  }
3042
- throw _context39.t0;
3157
+ throw _context40.t0;
3043
3158
  case 18:
3044
3159
  case "end":
3045
- return _context39.stop();
3160
+ return _context40.stop();
3046
3161
  }
3047
- }, _callee39, this, [[2, 14]]);
3162
+ }, _callee40, this, [[2, 14]]);
3048
3163
  }));
3049
3164
  function getProductList() {
3050
3165
  return _getProductList.apply(this, arguments);
@@ -3059,15 +3174,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3059
3174
  }, {
3060
3175
  key: "setOtherParams",
3061
3176
  value: function () {
3062
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
3177
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3063
3178
  var _ref9,
3064
3179
  _ref9$cover,
3065
3180
  cover,
3066
- _args40 = arguments;
3067
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3068
- while (1) switch (_context40.prev = _context40.next) {
3181
+ _args41 = arguments;
3182
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3183
+ while (1) switch (_context41.prev = _context41.next) {
3069
3184
  case 0:
3070
- _ref9 = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3185
+ _ref9 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref9$cover = _ref9.cover, cover = _ref9$cover === void 0 ? false : _ref9$cover;
3071
3186
  if (cover) {
3072
3187
  this.otherParams = params;
3073
3188
  } else {
@@ -3075,9 +3190,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3075
3190
  }
3076
3191
  case 2:
3077
3192
  case "end":
3078
- return _context40.stop();
3193
+ return _context41.stop();
3079
3194
  }
3080
- }, _callee40, this);
3195
+ }, _callee41, this);
3081
3196
  }));
3082
3197
  function setOtherParams(_x20) {
3083
3198
  return _setOtherParams.apply(this, arguments);
@@ -3169,10 +3284,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3169
3284
  }, {
3170
3285
  key: "setEntryPaxNumber",
3171
3286
  value: function () {
3172
- var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(number) {
3287
+ var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(number) {
3173
3288
  var pax, t;
3174
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3175
- while (1) switch (_context41.prev = _context41.next) {
3289
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3290
+ while (1) switch (_context42.prev = _context42.next) {
3176
3291
  case 0:
3177
3292
  pax = normalizeSubmitCollectPaxValue(number);
3178
3293
  this.store.entryPaxNumber = pax;
@@ -3193,16 +3308,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3193
3308
  }
3194
3309
  });
3195
3310
  this.itemRulePrefillApplied = false;
3196
- _context41.next = 7;
3311
+ _context42.next = 7;
3197
3312
  return this.refreshItemRuleQuantityLimits();
3198
3313
  case 7:
3199
- _context41.next = 9;
3314
+ _context42.next = 9;
3200
3315
  return this.refreshCartValidationPassed();
3201
3316
  case 9:
3202
3317
  case "end":
3203
- return _context41.stop();
3318
+ return _context42.stop();
3204
3319
  }
3205
- }, _callee41, this);
3320
+ }, _callee42, this);
3206
3321
  }));
3207
3322
  function setEntryPaxNumber(_x21) {
3208
3323
  return _setEntryPaxNumber.apply(this, arguments);
@@ -3214,15 +3329,113 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3214
3329
  value: function getEntryPaxNumber() {
3215
3330
  return this.store.entryPaxNumber;
3216
3331
  }
3332
+ }, {
3333
+ key: "syncAdditionalOrderFromResource",
3334
+ value: function () {
3335
+ var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
3336
+ var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams18, _this$store$order9;
3337
+ var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
3338
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3339
+ while (1) switch (_context43.prev = _context43.next) {
3340
+ case 0:
3341
+ tempOrder = this.ensureTempOrder();
3342
+ normalizedResourceId = String((_ref10 = (_ref11 = (_ref12 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref12 !== void 0 ? _ref12 : (_this$store$resource2 = this.store.resource) === null || _this$store$resource2 === void 0 ? void 0 : _this$store$resource2.relationId) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource3 = this.store.resource) === null || _this$store$resource3 === void 0 ? void 0 : _this$store$resource3.relation_id) !== null && _ref10 !== void 0 ? _ref10 : '').trim();
3343
+ this.logMethodStart('syncAdditionalOrderFromResource', {
3344
+ resourceId: normalizedResourceId
3345
+ });
3346
+ if (normalizedResourceId) {
3347
+ _context43.next = 7;
3348
+ break;
3349
+ }
3350
+ _result = {
3351
+ matched: false,
3352
+ reason: 'missing_resource_id'
3353
+ };
3354
+ this.logMethodSuccess('syncAdditionalOrderFromResource', _result);
3355
+ return _context43.abrupt("return", _result);
3356
+ case 7:
3357
+ _context43.next = 9;
3358
+ return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
3359
+ case 9:
3360
+ occupyDetails = _context43.sent;
3361
+ occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
3362
+ resourceSelectType = ((_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
3363
+ allowAddItems = toBoolean((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 || (_this$otherParams18 = _this$otherParams18.dineInConfig) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18['sale.allow_add_items']);
3364
+ result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
3365
+ if (!(!result.matched || !result.order_id)) {
3366
+ _context43.next = 17;
3367
+ break;
3368
+ }
3369
+ this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3370
+ resourceId: normalizedResourceId,
3371
+ resourceSelectType: resourceSelectType,
3372
+ allowAddItems: allowAddItems
3373
+ }));
3374
+ return _context43.abrupt("return", result);
3375
+ case 17:
3376
+ tempOrder.order_id = result.order_id;
3377
+ tempOrder.resource_id = normalizedResourceId;
3378
+ tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
3379
+ tempOrder.table_form_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
3380
+ (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || _this$store$order9.persistTempOrder();
3381
+ this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3382
+ resourceId: normalizedResourceId,
3383
+ resourceSelectType: resourceSelectType,
3384
+ allowAddItems: allowAddItems
3385
+ }));
3386
+ return _context43.abrupt("return", result);
3387
+ case 24:
3388
+ case "end":
3389
+ return _context43.stop();
3390
+ }
3391
+ }, _callee43, this);
3392
+ }));
3393
+ function syncAdditionalOrderFromResource(_x22) {
3394
+ return _syncAdditionalOrderFromResource.apply(this, arguments);
3395
+ }
3396
+ return syncAdditionalOrderFromResource;
3397
+ }() // 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
3398
+ // 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
3399
+ }, {
3400
+ key: "getReservationResourceSelectType",
3401
+ value: function getReservationResourceSelectType() {
3402
+ var _this$store$resource5;
3403
+ this.logMethodStart('getReservationResourceSelectType');
3404
+ var resourceSelectType = (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.resourceSelectType;
3405
+ var result = _objectSpread(_objectSpread({}, resourceSelectType ? {
3406
+ resourceSelectType: resourceSelectType
3407
+ } : {}), {}, {
3408
+ isSingleReservation: resourceSelectType === 'single',
3409
+ isMultipleReservation: resourceSelectType === 'multiple',
3410
+ isCapacityReservation: resourceSelectType === 'capacity'
3411
+ });
3412
+ this.logMethodSuccess('getReservationResourceSelectType', result);
3413
+ return result;
3414
+ }
3415
+
3416
+ // 判定后台是否开启允许加餐
3417
+ // 依赖 checkResourceAvailable 已缓存的 dineInConfig
3418
+ }, {
3419
+ key: "checkAllowAddItems",
3420
+ value: function checkAllowAddItems() {
3421
+ var _this$otherParams19;
3422
+ this.logMethodStart('checkAllowAddItems');
3423
+ var dineInConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.dineInConfig) || {};
3424
+ var result = {
3425
+ enabled: toBoolean(dineInConfig['sale.allow_add_items'])
3426
+ };
3427
+ this.logMethodSuccess('checkAllowAddItems', result);
3428
+ return result;
3429
+ }
3217
3430
 
3218
3431
  // 读取取餐/送餐开关
3219
3432
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
3220
3433
  }, {
3221
3434
  key: "getFulfillmentModes",
3222
3435
  value: function getFulfillmentModes() {
3223
- var _this$otherParams17;
3436
+ var _this$otherParams20;
3224
3437
  this.logMethodStart('getFulfillmentModes');
3225
- var dineInConfig = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.dineInConfig) || {};
3438
+ var dineInConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.dineInConfig) || {};
3226
3439
  var result = {
3227
3440
  enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
3228
3441
  enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
@@ -3236,9 +3449,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3236
3449
  }, {
3237
3450
  key: "checkManualPickupRef",
3238
3451
  value: function checkManualPickupRef() {
3239
- var _this$otherParams18;
3452
+ var _this$otherParams21;
3240
3453
  this.logMethodStart('checkManualPickupRef');
3241
- var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
3454
+ var dineInConfig = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.dineInConfig) || {};
3242
3455
  var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
3243
3456
  var manualInputType = dineInConfig['fulfillment.manual_input_type'];
3244
3457
  var enabled = refMode === 'manual_input';