@pisell/pisellos 2.1.154 → 2.1.156

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 (54) hide show
  1. package/dist/modules/Holder/index.d.ts +48 -0
  2. package/dist/modules/Holder/index.js +639 -0
  3. package/dist/modules/Holder/types.d.ts +123 -0
  4. package/dist/modules/Holder/types.js +1 -0
  5. package/dist/modules/Holder/utils.d.ts +13 -0
  6. package/dist/modules/Holder/utils.js +34 -0
  7. package/dist/modules/Order/index.d.ts +2 -1
  8. package/dist/modules/Order/index.js +18 -1
  9. package/dist/modules/Order/types.d.ts +2 -0
  10. package/dist/modules/Order/utils.d.ts +10 -0
  11. package/dist/modules/Order/utils.js +35 -3
  12. package/dist/modules/Product/types.d.ts +7 -0
  13. package/dist/modules/index.d.ts +1 -0
  14. package/dist/modules/index.js +2 -1
  15. package/dist/plugins/window.d.ts +1 -0
  16. package/dist/solution/BookingByStep/index.d.ts +16 -1
  17. package/dist/solution/BookingByStep/index.js +276 -204
  18. package/dist/solution/BookingByStep/types.d.ts +2 -1
  19. package/dist/solution/BookingByStep/types.js +3 -1
  20. package/dist/solution/ScanOrder/index.d.ts +2 -6
  21. package/dist/solution/ScanOrder/index.js +57 -250
  22. package/dist/solution/ScanOrder/types.d.ts +2 -20
  23. package/dist/solution/VenueBooking/index.d.ts +19 -0
  24. package/dist/solution/VenueBooking/index.js +963 -733
  25. package/dist/solution/VenueBooking/types.d.ts +2 -0
  26. package/dist/types/index.d.ts +1 -0
  27. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  28. package/lib/modules/Holder/index.d.ts +48 -0
  29. package/lib/modules/Holder/index.js +401 -0
  30. package/lib/modules/Holder/types.d.ts +123 -0
  31. package/lib/modules/Holder/types.js +17 -0
  32. package/lib/modules/Holder/utils.d.ts +13 -0
  33. package/lib/modules/Holder/utils.js +71 -0
  34. package/lib/modules/Order/index.d.ts +2 -1
  35. package/lib/modules/Order/index.js +14 -0
  36. package/lib/modules/Order/types.d.ts +2 -0
  37. package/lib/modules/Order/utils.d.ts +10 -0
  38. package/lib/modules/Order/utils.js +36 -5
  39. package/lib/modules/Product/types.d.ts +7 -0
  40. package/lib/modules/index.d.ts +1 -0
  41. package/lib/modules/index.js +3 -1
  42. package/lib/plugins/window.d.ts +1 -0
  43. package/lib/solution/BookingByStep/index.d.ts +16 -1
  44. package/lib/solution/BookingByStep/index.js +39 -0
  45. package/lib/solution/BookingByStep/types.d.ts +2 -1
  46. package/lib/solution/BookingByStep/types.js +5 -0
  47. package/lib/solution/ScanOrder/index.d.ts +2 -6
  48. package/lib/solution/ScanOrder/index.js +47 -212
  49. package/lib/solution/ScanOrder/types.d.ts +2 -20
  50. package/lib/solution/VenueBooking/index.d.ts +19 -0
  51. package/lib/solution/VenueBooking/index.js +134 -16
  52. package/lib/solution/VenueBooking/types.d.ts +2 -0
  53. package/lib/types/index.d.ts +1 -0
  54. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, SalesSummaryModule, ScheduleModule, ScanOrderLoggerModule } from '../../modules';
1
+ import { ProductList, CartModule, ProductData, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule, SalesSummaryModule, ScheduleModule, ScanOrderLoggerModule, HolderModule } from '../../modules';
2
2
  export interface BookingByStepState {
3
3
  cart: CartModule;
4
4
  summary: SummaryModule;
@@ -16,6 +16,7 @@ export interface BookingByStepState {
16
16
  schedule: ScheduleModule;
17
17
  salesSummary?: SalesSummaryModule;
18
18
  scanOrderLogger?: ScanOrderLoggerModule;
19
+ holder: HolderModule;
19
20
  }
20
21
  export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
21
22
  export declare enum BookingByStepHooks {
@@ -1,4 +1,4 @@
1
- import { ProductList, CartModule, AccountListModule, DateModule, OrderModule, PaymentModule, StepModule, SummaryModule, SalesSummaryModule, ScheduleModule, ScanOrderLoggerModule } from "../../modules";
1
+ import { ProductList, CartModule, AccountListModule, DateModule, OrderModule, PaymentModule, StepModule, SummaryModule, SalesSummaryModule, ScheduleModule, ScanOrderLoggerModule, HolderModule } from "../../modules";
2
2
  export function createModule(moduleName, solutionName, name, version) {
3
3
  switch (moduleName) {
4
4
  case 'cart':
@@ -23,6 +23,8 @@ export function createModule(moduleName, solutionName, name, version) {
23
23
  return new ScheduleModule("".concat(solutionName, "_").concat(name || moduleName), version);
24
24
  case 'scanOrderLogger':
25
25
  return new ScanOrderLoggerModule("".concat(solutionName, "_").concat(name || moduleName), version);
26
+ case 'holder':
27
+ return new HolderModule("".concat(solutionName, "_").concat(name || moduleName), version);
26
28
  default:
27
29
  throw new Error("Unknown module type: ".concat(moduleName));
28
30
  }
@@ -1,6 +1,6 @@
1
1
  import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
- import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderAllowAddItemsInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderReservationResourceSelectInfo, ScanOrderScanCodeResult, ScanOrderSyncAdditionalOrderResult, ScanOrderTempOrder } from './types';
3
+ import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderScanCodeResult, ScanOrderTempOrder } from './types';
4
4
  import type { UpdateProductInOrderParams } from '../../modules/Order/types';
5
5
  import type { Discount } from '../../modules/Discount/types';
6
6
  import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
@@ -118,8 +118,7 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
118
118
  setItemRuleRuntimeConfig(config?: ScanOrderItemRuleRuntimeConfig): Promise<void>;
119
119
  private normalizeResourceState;
120
120
  private resolveResourceSelectType;
121
- private fetchResourceOccupyDetailsByResourceId;
122
- private resolveAdditionalOrderFromOccupyDetail;
121
+ private fetchResourceOccupyDetailByResourceId;
123
122
  checkResourceAvailable(resourceId?: string | null, hasOrderId?: boolean): Promise<ScanOrderAvailabilityInfo>;
124
123
  getAdditionalOrderInfo(): Promise<{
125
124
  orderId: string;
@@ -143,9 +142,6 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
143
142
  clearUIState(): void;
144
143
  setEntryPaxNumber(number: number): Promise<void>;
145
144
  getEntryPaxNumber(): number | null;
146
- syncAdditionalOrderFromResource(resourceId?: string | null): Promise<ScanOrderSyncAdditionalOrderResult>;
147
- getReservationResourceSelectType(): ScanOrderReservationResourceSelectInfo;
148
- checkAllowAddItems(): ScanOrderAllowAddItemsInfo;
149
145
  getFulfillmentModes(): {
150
146
  enablePickup: boolean;
151
147
  enableTableService: boolean;
@@ -1411,13 +1411,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1411
1411
  var resourceState = this.store.resource;
1412
1412
  var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
1413
1413
 
1414
- // ScanOrder booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
1415
- var resolveBookingCapacityValue = function resolveBookingCapacityValue() {
1414
+ // collect_pax 时的资源占用兜底:single 独占整张桌台,其余模式占 1 个容量位。
1415
+ var resolveResourceCapacity = function resolveResourceCapacity() {
1416
1416
  if (resourceSelectType === 'single') {
1417
1417
  var _resourceState$table_;
1418
1418
  var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
1419
1419
  var num = Number(raw);
1420
- if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
1420
+ if (Number.isFinite(num) && num > 0) return num;
1421
1421
  return 1;
1422
1422
  }
1423
1423
  return 1;
@@ -1435,8 +1435,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1435
1435
  });
1436
1436
  }
1437
1437
  var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1438
- var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1439
- var bookingCapacityValue = resolveBookingCapacityValue();
1438
+ var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1439
+ var resourceCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
1440
1440
  var pickOriginal = function pickOriginal(value) {
1441
1441
  if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
1442
1442
  var original = value.original;
@@ -1452,25 +1452,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1452
1452
  main_field: mainField,
1453
1453
  form_id: resourceState.tableFormId,
1454
1454
  relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
1455
- capacity: bookingCapacityValue,
1455
+ capacity: resourceCapacityValue,
1456
1456
  metadata: _this5.buildScanOrderResourceMetadata({
1457
1457
  resourceState: resourceState,
1458
1458
  resourceName: mainField
1459
1459
  })
1460
1460
  } : undefined;
1461
1461
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1462
+ // 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
1463
+ var bookingCapacityValue = resourceCapacityValue;
1462
1464
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1463
1465
  var nextBookings = (payload.bookings || []).map(function (booking, idx) {
1464
- var metadata = _objectSpread({}, booking.metadata || {});
1465
- if (hasExplicitCollectPax) {
1466
- metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
1467
- } else {
1468
- delete metadata.collect_pax;
1469
- }
1470
1466
  return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
1471
1467
  number: bookingCapacityValue,
1472
1468
  appointment_status: 'started',
1473
- metadata: _objectSpread(_objectSpread(_objectSpread({}, metadata), resourceSelectType ? {
1469
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
1474
1470
  resource_select_type: resourceSelectType
1475
1471
  } : {}), resourceSelectType ? {
1476
1472
  capacity: [{
@@ -1520,7 +1516,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1520
1516
  key: "submitScanOrder",
1521
1517
  value: function () {
1522
1518
  var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1523
- var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1519
+ var _this$store$resource, _this$otherParams5, _this$otherParams6, _this$otherParams7, _this$otherParams8, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1524
1520
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1525
1521
  while (1) switch (_context18.prev = _context18.next) {
1526
1522
  case 0:
@@ -1535,7 +1531,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1535
1531
  }
1536
1532
  throw new Error('scanOrder解决方案需要 order 模块支持');
1537
1533
  case 6:
1534
+ pax = normalizeSubmitCollectPaxValue(this.store.entryPaxNumber);
1535
+ this.store.entryPaxNumber = pax;
1538
1536
  tempOrderForSubmit = this.store.order.ensureTempOrder();
1537
+ tempOrderForSubmit.metadata = _objectSpread(_objectSpread({}, tempOrderForSubmit.metadata), {}, {
1538
+ collect_pax: pax
1539
+ });
1539
1540
  tempOrderForSubmit.delivery_type = 'shop_service';
1540
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;
1541
1542
  if (resourceTableName && _typeof(resourceTableName) === 'object') {
@@ -1545,7 +1546,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1545
1546
  }
1546
1547
  this.store.order.persistTempOrder();
1547
1548
  enhancePayload = this.buildSubmitPayloadEnhancer();
1548
- _context18.next = 14;
1549
+ _context18.next = 17;
1549
1550
  return this.store.order.submitTempOrder({
1550
1551
  cacheId: this.cacheId,
1551
1552
  platform: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform,
@@ -1554,23 +1555,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1554
1555
  type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type,
1555
1556
  enhancePayload: enhancePayload
1556
1557
  });
1557
- case 14:
1558
+ case 17:
1558
1559
  result = _context18.sent;
1559
1560
  tempOrder = this.store.order.getTempOrder();
1560
1561
  this.logMethodSuccess('submitScanOrder', {
1561
1562
  productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
1562
1563
  });
1563
1564
  return _context18.abrupt("return", result);
1564
- case 20:
1565
- _context18.prev = 20;
1565
+ case 23:
1566
+ _context18.prev = 23;
1566
1567
  _context18.t0 = _context18["catch"](1);
1567
1568
  this.logMethodError('submitScanOrder', _context18.t0);
1568
1569
  throw _context18.t0;
1569
- case 24:
1570
+ case 27:
1570
1571
  case "end":
1571
1572
  return _context18.stop();
1572
1573
  }
1573
- }, _callee18, this, [[1, 20]]);
1574
+ }, _callee18, this, [[1, 23]]);
1574
1575
  }));
1575
1576
  function submitScanOrder() {
1576
1577
  return _submitScanOrder.apply(this, arguments);
@@ -2568,9 +2569,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2568
2569
  return matched === null || matched === void 0 ? void 0 : matched.type;
2569
2570
  }
2570
2571
  }, {
2571
- key: "fetchResourceOccupyDetailsByResourceId",
2572
+ key: "fetchResourceOccupyDetailByResourceId",
2572
2573
  value: function () {
2573
- var _fetchResourceOccupyDetailsByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
2574
+ var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
2574
2575
  var _this$otherParams10, _this$otherParams10$g, _response$data$occupy, _response$data;
2575
2576
  var formRecordId, shopId, response;
2576
2577
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
@@ -2606,68 +2607,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2606
2607
  }
2607
2608
  throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
2608
2609
  case 11:
2609
- 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 : []);
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
2611
  case 12:
2611
2612
  case "end":
2612
2613
  return _context36.stop();
2613
2614
  }
2614
2615
  }, _callee36, this);
2615
2616
  }));
2616
- function fetchResourceOccupyDetailsByResourceId(_x18) {
2617
- return _fetchResourceOccupyDetailsByResourceId.apply(this, arguments);
2618
- }
2619
- return fetchResourceOccupyDetailsByResourceId;
2620
- }()
2621
- }, {
2622
- key: "resolveAdditionalOrderFromOccupyDetail",
2623
- value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
2624
- var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
2625
- if (currentOrderId) {
2626
- return {
2627
- matched: true,
2628
- order_id: currentOrderId
2629
- };
2630
- }
2631
- 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) {
2632
- return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
2633
- }).filter(Boolean);
2634
- if (resourceSelectType !== 'single') {
2635
- return {
2636
- matched: false,
2637
- reason: 'no_order'
2638
- };
2639
- }
2640
- if (!orderListIds.length) {
2641
- return {
2642
- matched: false,
2643
- reason: 'no_order'
2644
- };
2617
+ function fetchResourceOccupyDetailByResourceId(_x18) {
2618
+ return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
2645
2619
  }
2646
- if (!allowAddItems) {
2647
- return {
2648
- matched: false,
2649
- reason: 'add_items_disabled'
2650
- };
2651
- }
2652
- if (orderListIds.length === 1) {
2653
- return {
2654
- matched: true,
2655
- order_id: orderListIds[0]
2656
- };
2657
- }
2658
- if (orderListIds.length > 1) {
2659
- return {
2660
- matched: false,
2661
- reason: 'multiple_orders'
2662
- };
2663
- }
2664
- return {
2665
- matched: false,
2666
- reason: 'no_order'
2667
- };
2668
- }
2669
-
2670
- // 检测当前链接是否可用
2620
+ return fetchResourceOccupyDetailByResourceId;
2621
+ }() // 检测当前链接是否可用
2671
2622
  // 通过 resource_id + 店铺配置
2672
2623
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
2673
2624
  }, {
@@ -2682,7 +2633,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2682
2633
  _this$otherParams12,
2683
2634
  _this$otherParams13,
2684
2635
  _this$otherParams13$g,
2685
- _occupyDetails$,
2686
2636
  _occupyDetail$form_re,
2687
2637
  _occupyDetail$form_re2,
2688
2638
  _this$otherParams14,
@@ -2716,18 +2666,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2716
2666
  occupancyMinutes,
2717
2667
  paxBounds,
2718
2668
  error,
2719
- occupyDetails,
2720
2669
  occupyDetail,
2721
2670
  resourceSelectType,
2722
- allowAddItems,
2723
- additionalOrderResult,
2724
- _occupyDetail$order_l,
2725
- multipleOrdersState,
2726
- _availabilityInfo,
2727
2671
  resourceState,
2728
- additionalOrderId,
2729
2672
  availabilityInfo,
2730
- isAdditionalOrderMode,
2731
2673
  _this$store$order7,
2732
2674
  _res$data,
2733
2675
  res,
@@ -2886,52 +2828,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2886
2828
  });
2887
2829
  }
2888
2830
 
2889
- // Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
2831
+ // Step2: 请求新的资源占用详情接口
2890
2832
  _context37.next = 50;
2891
- return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
2833
+ return this.fetchResourceOccupyDetailByResourceId(normalizedResourceId);
2892
2834
  case 50:
2893
- occupyDetails = _context37.sent;
2894
- occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2835
+ occupyDetail = _context37.sent;
2836
+ // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2895
2837
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
2896
- resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
2897
- allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
2898
- additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
2899
- if (!(additionalOrderResult.reason === 'multiple_orders')) {
2900
- _context37.next = 61;
2901
- break;
2902
- }
2903
- multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
2904
- mode: 'multiple_orders'
2905
- });
2906
- this.store.resource = multipleOrdersState;
2907
- _availabilityInfo = {
2908
- mode: 'multiple_orders',
2909
- deskmate_valid: multipleOrdersState.deskmate_valid,
2910
- relation_id: multipleOrdersState.relationId,
2911
- table_form_id: multipleOrdersState.tableFormId,
2912
- table_form_record: multipleOrdersState.table_form_record
2913
- };
2914
- this.logMethodSuccess('checkResourceAvailable', {
2915
- resourceId: normalizedResourceId,
2916
- mode: _availabilityInfo.mode,
2917
- 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,
2918
- resourceSelectType: resourceSelectType
2919
- });
2920
- return _context37.abrupt("return", _availabilityInfo);
2921
- case 61:
2922
- // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2838
+ resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2923
2839
  resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
2924
- additionalOrderId = additionalOrderResult.order_id;
2925
- if (additionalOrderId) {
2926
- resourceState.mode = 'additional_order';
2927
- resourceState.order_id = additionalOrderId;
2928
- } else if (additionalOrderResult.reason === 'add_items_disabled') {
2929
- resourceState.mode = 'resource_busy';
2930
- resourceState.order_id = '0';
2931
- } else if (resourceSelectType === 'multiple' && resourceState.isFull) {
2932
- resourceState.mode = 'resource_busy';
2933
- resourceState.order_id = '0';
2934
- }
2935
2840
  this.store.resource = resourceState;
2936
2841
 
2937
2842
  // Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
@@ -2967,23 +2872,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2967
2872
 
2968
2873
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2969
2874
  if (!(availabilityInfo.mode === 'idle')) {
2970
- _context37.next = 76;
2875
+ _context37.next = 65;
2971
2876
  break;
2972
2877
  }
2973
- _context37.next = 76;
2878
+ _context37.next = 65;
2974
2879
  return this.addNewOrder();
2975
- case 76:
2976
- isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
2977
- if (isAdditionalOrderMode) {
2978
- tempOrder.order_id = additionalOrderId;
2880
+ case 65:
2881
+ // 如果是加单模式,tempOrder 需要记录 lastOrderId,提交的时候走加单接口
2882
+ if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
2883
+ tempOrder.order_id = resourceState.lastOrderId;
2979
2884
  }
2980
2885
  if (!tempOrder.order_id) {
2981
- _context37.next = 86;
2886
+ _context37.next = 74;
2982
2887
  break;
2983
2888
  }
2984
- _context37.next = 81;
2889
+ _context37.next = 69;
2985
2890
  return (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getOrderInfoByRemote(tempOrder.order_id);
2986
- case 81:
2891
+ case 69:
2987
2892
  res = _context37.sent;
2988
2893
  // 找到下单的时候输入的 entryPaxNumber
2989
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) {
@@ -2991,14 +2896,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2991
2896
  return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2992
2897
  })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2993
2898
  if (!entryPaxNumber) {
2994
- _context37.next = 86;
2899
+ _context37.next = 74;
2995
2900
  break;
2996
2901
  }
2997
- _context37.next = 86;
2902
+ _context37.next = 74;
2998
2903
  return this.setEntryPaxNumber(entryPaxNumber);
2999
- case 86:
2904
+ case 74:
3000
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);
3001
- historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2906
+ historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
3002
2907
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
3003
2908
  acc.push(_objectSpread({
3004
2909
  product_id: p.product_id,
@@ -3008,13 +2913,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3008
2913
  } : {}));
3009
2914
  return acc;
3010
2915
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
3011
- _context37.next = 90;
2916
+ _context37.next = 78;
3012
2917
  return this.setItemRuleRuntimeConfig({
3013
2918
  serviceType: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode,
3014
- submissionIndex: isAdditionalOrderMode ? 1 : 0,
2919
+ submissionIndex: hasOrderId ? 1 : 0,
3015
2920
  historicalItems: historicalItems
3016
2921
  });
3017
- case 90:
2922
+ case 78:
3018
2923
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
3019
2924
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
3020
2925
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -3036,18 +2941,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3036
2941
  isFull: resourceState.isFull
3037
2942
  });
3038
2943
  return _context37.abrupt("return", availabilityInfo);
3039
- case 95:
3040
- _context37.prev = 95;
2944
+ case 83:
2945
+ _context37.prev = 83;
3041
2946
  _context37.t0 = _context37["catch"](3);
3042
2947
  this.logMethodError('checkResourceAvailable', _context37.t0.message, {
3043
2948
  resourceId: normalizedResourceId
3044
2949
  });
3045
2950
  throw _context37.t0;
3046
- case 99:
2951
+ case 87:
3047
2952
  case "end":
3048
2953
  return _context37.stop();
3049
2954
  }
3050
- }, _callee37, this, [[3, 95]]);
2955
+ }, _callee37, this, [[3, 83]]);
3051
2956
  }));
3052
2957
  function checkResourceAvailable(_x19) {
3053
2958
  return _checkResourceAvailable.apply(this, arguments);
@@ -3309,113 +3214,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3309
3214
  value: function getEntryPaxNumber() {
3310
3215
  return this.store.entryPaxNumber;
3311
3216
  }
3312
- }, {
3313
- key: "syncAdditionalOrderFromResource",
3314
- value: function () {
3315
- var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(resourceId) {
3316
- var _ref10, _ref11, _ref12, _this$store$resource2, _this$store$resource3, _occupyDetails$2, _this$store$resource4, _this$otherParams17, _this$store$order9;
3317
- var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
3318
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3319
- while (1) switch (_context42.prev = _context42.next) {
3320
- case 0:
3321
- tempOrder = this.ensureTempOrder();
3322
- 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();
3323
- this.logMethodStart('syncAdditionalOrderFromResource', {
3324
- resourceId: normalizedResourceId
3325
- });
3326
- if (normalizedResourceId) {
3327
- _context42.next = 7;
3328
- break;
3329
- }
3330
- _result = {
3331
- matched: false,
3332
- reason: 'missing_resource_id'
3333
- };
3334
- this.logMethodSuccess('syncAdditionalOrderFromResource', _result);
3335
- return _context42.abrupt("return", _result);
3336
- case 7:
3337
- _context42.next = 9;
3338
- return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
3339
- case 9:
3340
- occupyDetails = _context42.sent;
3341
- occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
3342
- 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));
3343
- allowAddItems = toBoolean((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.dineInConfig) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['sale.allow_add_items']);
3344
- result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
3345
- if (!(!result.matched || !result.order_id)) {
3346
- _context42.next = 17;
3347
- break;
3348
- }
3349
- this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3350
- resourceId: normalizedResourceId,
3351
- resourceSelectType: resourceSelectType,
3352
- allowAddItems: allowAddItems
3353
- }));
3354
- return _context42.abrupt("return", result);
3355
- case 17:
3356
- tempOrder.order_id = result.order_id;
3357
- tempOrder.resource_id = normalizedResourceId;
3358
- tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
3359
- tempOrder.table_form_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
3360
- (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || _this$store$order9.persistTempOrder();
3361
- this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3362
- resourceId: normalizedResourceId,
3363
- resourceSelectType: resourceSelectType,
3364
- allowAddItems: allowAddItems
3365
- }));
3366
- return _context42.abrupt("return", result);
3367
- case 24:
3368
- case "end":
3369
- return _context42.stop();
3370
- }
3371
- }, _callee42, this);
3372
- }));
3373
- function syncAdditionalOrderFromResource(_x22) {
3374
- return _syncAdditionalOrderFromResource.apply(this, arguments);
3375
- }
3376
- return syncAdditionalOrderFromResource;
3377
- }() // 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
3378
- // 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
3379
- }, {
3380
- key: "getReservationResourceSelectType",
3381
- value: function getReservationResourceSelectType() {
3382
- var _this$store$resource5;
3383
- this.logMethodStart('getReservationResourceSelectType');
3384
- var resourceSelectType = (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.resourceSelectType;
3385
- var result = _objectSpread(_objectSpread({}, resourceSelectType ? {
3386
- resourceSelectType: resourceSelectType
3387
- } : {}), {}, {
3388
- isSingleReservation: resourceSelectType === 'single',
3389
- isMultipleReservation: resourceSelectType === 'multiple',
3390
- isCapacityReservation: resourceSelectType === 'capacity'
3391
- });
3392
- this.logMethodSuccess('getReservationResourceSelectType', result);
3393
- return result;
3394
- }
3395
-
3396
- // 判定后台是否开启允许加餐
3397
- // 依赖 checkResourceAvailable 已缓存的 dineInConfig
3398
- }, {
3399
- key: "checkAllowAddItems",
3400
- value: function checkAllowAddItems() {
3401
- var _this$otherParams18;
3402
- this.logMethodStart('checkAllowAddItems');
3403
- var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
3404
- var result = {
3405
- enabled: toBoolean(dineInConfig['sale.allow_add_items'])
3406
- };
3407
- this.logMethodSuccess('checkAllowAddItems', result);
3408
- return result;
3409
- }
3410
3217
 
3411
3218
  // 读取取餐/送餐开关
3412
3219
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
3413
3220
  }, {
3414
3221
  key: "getFulfillmentModes",
3415
3222
  value: function getFulfillmentModes() {
3416
- var _this$otherParams19;
3223
+ var _this$otherParams17;
3417
3224
  this.logMethodStart('getFulfillmentModes');
3418
- var dineInConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.dineInConfig) || {};
3225
+ var dineInConfig = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.dineInConfig) || {};
3419
3226
  var result = {
3420
3227
  enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
3421
3228
  enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
@@ -3429,9 +3236,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3429
3236
  }, {
3430
3237
  key: "checkManualPickupRef",
3431
3238
  value: function checkManualPickupRef() {
3432
- var _this$otherParams20;
3239
+ var _this$otherParams18;
3433
3240
  this.logMethodStart('checkManualPickupRef');
3434
- var dineInConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.dineInConfig) || {};
3241
+ var dineInConfig = ((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.dineInConfig) || {};
3435
3242
  var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
3436
3243
  var manualInputType = dineInConfig['fulfillment.manual_input_type'];
3437
3244
  var enabled = refMode === 'manual_input';
@@ -34,6 +34,7 @@ export interface ScanOrderOrderProductIdentity {
34
34
  /** 参与合并/匹配;与 remove 通配语义见 isSkuOnlyDeleteIdentity */
35
35
  product_option_item?: any[];
36
36
  product_bundle?: any[];
37
+ shop_id?: number | string;
37
38
  }
38
39
  export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
39
40
  order_detail_id: number | null;
@@ -185,7 +186,7 @@ export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platfo
185
186
  }>;
186
187
  products: ScanOrderSubmitProduct[];
187
188
  }
188
- export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'multiple_orders' | 'additional_order_with_code' | 'additional_order';
189
+ export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'submit_disabled' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
189
190
  export interface ScanOrderTableFormRecord {
190
191
  policy?: string | null;
191
192
  partyroom_booking?: string | null;
@@ -228,10 +229,6 @@ export interface ScanOrderResourceOccupyDetail {
228
229
  form_id?: number | string | null;
229
230
  order_id?: number | string | null;
230
231
  last_order_id?: number | string | null;
231
- order_list?: Array<{
232
- id?: number | string | null;
233
- [key: string]: any;
234
- }> | null;
235
232
  resource_capacity?: ScanOrderResourceCapacity[] | null;
236
233
  form_record?: ScanOrderTableFormRecord | null;
237
234
  [key: string]: any;
@@ -245,21 +242,6 @@ export interface ScanOrderResourceOccupyDetailApiResponse {
245
242
  } | null;
246
243
  }
247
244
  export type ScanOrderResourceSelectType = 'single' | 'multiple' | 'capacity';
248
- export interface ScanOrderReservationResourceSelectInfo {
249
- resourceSelectType?: ScanOrderResourceSelectType;
250
- isSingleReservation: boolean;
251
- isMultipleReservation: boolean;
252
- isCapacityReservation: boolean;
253
- }
254
- export interface ScanOrderAllowAddItemsInfo {
255
- enabled: boolean;
256
- }
257
- export type ScanOrderSyncAdditionalOrderReason = 'missing_resource_id' | 'no_order' | 'multiple_orders' | 'add_items_disabled' | 'invalid_order_id';
258
- export interface ScanOrderSyncAdditionalOrderResult {
259
- matched: boolean;
260
- order_id?: string;
261
- reason?: ScanOrderSyncAdditionalOrderReason;
262
- }
263
245
  export interface ScanOrderResourceState extends ScanOrderAvailabilityInfo {
264
246
  relationId?: string;
265
247
  tableFormId?: string;