@pisell/pisellos 2.3.49 → 2.3.50

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 (162) hide show
  1. package/dist/modules/Discount/index.d.ts +1 -0
  2. package/dist/modules/Discount/index.js +40 -11
  3. package/dist/modules/Discount/types.d.ts +1 -0
  4. package/dist/modules/Holder/index.d.ts +48 -0
  5. package/dist/modules/Holder/index.js +640 -0
  6. package/dist/modules/Holder/types.d.ts +123 -0
  7. package/dist/modules/Holder/types.js +1 -0
  8. package/dist/modules/Holder/utils.d.ts +13 -0
  9. package/dist/modules/Holder/utils.js +34 -0
  10. package/dist/modules/OpenData/index.js +2 -2
  11. package/dist/modules/Order/index.d.ts +3 -1
  12. package/dist/modules/Order/index.js +54 -25
  13. package/dist/modules/Order/types.d.ts +9 -0
  14. package/dist/modules/Order/utils.d.ts +10 -0
  15. package/dist/modules/Order/utils.js +35 -3
  16. package/dist/modules/Payment/types.d.ts +0 -8
  17. package/dist/modules/Payment/walletpass.d.ts +1 -7
  18. package/dist/modules/Payment/walletpass.js +45 -155
  19. package/dist/modules/Product/types.d.ts +1 -0
  20. package/dist/modules/ProductList/index.js +33 -14
  21. package/dist/modules/Quotation/index.d.ts +1 -1
  22. package/dist/modules/Quotation/index.js +2 -2
  23. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  24. package/dist/modules/ResourcePlanner/index.js +181 -0
  25. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  26. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  27. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  28. package/dist/modules/ResourcePlanner/types.js +1 -0
  29. package/dist/modules/Rules/index.js +47 -13
  30. package/dist/modules/SalesSummary/index.js +12 -13
  31. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  32. package/dist/modules/ScanOrderLogger/index.js +15 -2
  33. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  34. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  35. package/dist/modules/Schedule/index.d.ts +3 -1
  36. package/dist/modules/Schedule/index.js +21 -16
  37. package/dist/modules/Summary/utils.js +38 -13
  38. package/dist/modules/index.d.ts +2 -0
  39. package/dist/modules/index.js +3 -1
  40. package/dist/plugins/window.d.ts +1 -0
  41. package/dist/server/index.d.ts +14 -0
  42. package/dist/server/index.js +907 -793
  43. package/dist/server/modules/index.d.ts +1 -1
  44. package/dist/server/modules/order/index.d.ts +0 -16
  45. package/dist/server/modules/order/index.js +776 -964
  46. package/dist/server/modules/order/types.d.ts +0 -14
  47. package/dist/server/modules/order/types.js +0 -6
  48. package/dist/solution/BaseSales/index.d.ts +8 -3
  49. package/dist/solution/BaseSales/index.js +64 -50
  50. package/dist/solution/BookingByStep/index.d.ts +17 -2
  51. package/dist/solution/BookingByStep/index.js +294 -215
  52. package/dist/solution/BookingByStep/types.d.ts +2 -1
  53. package/dist/solution/BookingByStep/types.js +3 -1
  54. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  55. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  56. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  57. package/dist/solution/BookingTicket/index.d.ts +1 -1
  58. package/dist/solution/BookingTicket/index.js +2 -2
  59. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  60. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  61. package/dist/solution/ScanOrder/index.d.ts +26 -14
  62. package/dist/solution/ScanOrder/index.js +1142 -739
  63. package/dist/solution/ScanOrder/types.d.ts +21 -1
  64. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  65. package/dist/solution/ScanOrder/utils.js +66 -25
  66. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  67. package/dist/solution/ShopDiscount/index.js +125 -87
  68. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  69. package/dist/solution/UnifiedBookingSales/index.js +1891 -0
  70. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  71. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  72. package/dist/solution/VenueBooking/index.d.ts +39 -11
  73. package/dist/solution/VenueBooking/index.js +1167 -841
  74. package/dist/solution/VenueBooking/types.d.ts +3 -0
  75. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  76. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  77. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  78. package/dist/solution/index.d.ts +1 -0
  79. package/dist/solution/index.js +2 -1
  80. package/dist/types/index.d.ts +1 -0
  81. package/lib/model/strategy/adapter/promotion/index.js +51 -0
  82. package/lib/modules/Discount/index.d.ts +1 -0
  83. package/lib/modules/Discount/index.js +9 -0
  84. package/lib/modules/Discount/types.d.ts +1 -0
  85. package/lib/modules/Holder/index.d.ts +48 -0
  86. package/lib/modules/Holder/index.js +402 -0
  87. package/lib/modules/Holder/types.d.ts +123 -0
  88. package/lib/modules/Holder/types.js +17 -0
  89. package/lib/modules/Holder/utils.d.ts +13 -0
  90. package/lib/modules/Holder/utils.js +71 -0
  91. package/lib/modules/OpenData/index.js +1 -1
  92. package/lib/modules/Order/index.d.ts +3 -1
  93. package/lib/modules/Order/index.js +26 -10
  94. package/lib/modules/Order/types.d.ts +9 -0
  95. package/lib/modules/Order/utils.d.ts +10 -0
  96. package/lib/modules/Order/utils.js +36 -5
  97. package/lib/modules/Payment/types.d.ts +0 -8
  98. package/lib/modules/Payment/walletpass.d.ts +1 -7
  99. package/lib/modules/Payment/walletpass.js +9 -107
  100. package/lib/modules/Product/types.d.ts +1 -0
  101. package/lib/modules/ProductList/index.js +40 -31
  102. package/lib/modules/Quotation/index.d.ts +1 -1
  103. package/lib/modules/Quotation/index.js +2 -2
  104. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  105. package/lib/modules/ResourcePlanner/index.js +148 -0
  106. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  107. package/lib/modules/ResourcePlanner/planner.js +933 -0
  108. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  109. package/lib/modules/ResourcePlanner/types.js +17 -0
  110. package/lib/modules/Rules/index.js +33 -16
  111. package/lib/modules/SalesSummary/index.js +6 -7
  112. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  113. package/lib/modules/ScanOrderLogger/index.js +13 -1
  114. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  115. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  116. package/lib/modules/Schedule/index.d.ts +3 -1
  117. package/lib/modules/Schedule/index.js +10 -8
  118. package/lib/modules/Summary/utils.js +21 -1
  119. package/lib/modules/index.d.ts +2 -0
  120. package/lib/modules/index.js +5 -1
  121. package/lib/plugins/window.d.ts +1 -0
  122. package/lib/server/index.d.ts +14 -0
  123. package/lib/server/index.js +72 -15
  124. package/lib/server/modules/index.d.ts +1 -1
  125. package/lib/server/modules/order/index.d.ts +0 -16
  126. package/lib/server/modules/order/index.js +4 -140
  127. package/lib/server/modules/order/types.d.ts +0 -14
  128. package/lib/server/modules/order/types.js +0 -1
  129. package/lib/solution/BaseSales/index.d.ts +8 -3
  130. package/lib/solution/BaseSales/index.js +24 -14
  131. package/lib/solution/BookingByStep/index.d.ts +17 -2
  132. package/lib/solution/BookingByStep/index.js +60 -18
  133. package/lib/solution/BookingByStep/types.d.ts +2 -1
  134. package/lib/solution/BookingByStep/types.js +5 -0
  135. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  136. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  137. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  138. package/lib/solution/BookingTicket/index.d.ts +1 -1
  139. package/lib/solution/BookingTicket/index.js +10 -2
  140. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  141. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  142. package/lib/solution/ScanOrder/index.d.ts +26 -14
  143. package/lib/solution/ScanOrder/index.js +449 -182
  144. package/lib/solution/ScanOrder/types.d.ts +21 -1
  145. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  146. package/lib/solution/ScanOrder/utils.js +31 -0
  147. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  148. package/lib/solution/ShopDiscount/index.js +14 -0
  149. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  150. package/lib/solution/UnifiedBookingSales/index.js +1084 -0
  151. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  152. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  153. package/lib/solution/VenueBooking/index.d.ts +39 -11
  154. package/lib/solution/VenueBooking/index.js +322 -110
  155. package/lib/solution/VenueBooking/types.d.ts +3 -0
  156. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  157. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  158. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  159. package/lib/solution/index.d.ts +1 -0
  160. package/lib/solution/index.js +3 -1
  161. package/lib/types/index.d.ts +1 -0
  162. package/package.json +1 -1
@@ -26,18 +26,17 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
26
26
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
27
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
28
28
  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); }
29
- import { BaseModule } from "../../modules/BaseModule";
29
+ import { BaseSalesImpl } from "../BaseSales";
30
30
  import { ScanOrderHooks } from "./types";
31
31
  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, filterProductsForScanOrderMore, 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
- import { ScheduleModule } from "../../modules/Schedule";
39
38
  import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
40
- import { composeLinePrice, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
39
+ import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitCollectPaxValue, sumOptionUnitPrice } from "../../modules/Order/utils";
41
40
  import dayjs from 'dayjs';
42
41
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
43
42
  export * from "./types";
@@ -45,8 +44,8 @@ function isItemRewardProductDiscount(discount) {
45
44
  var _discount$metadata, _discount$metadata2;
46
45
  return (discount === null || discount === void 0 ? void 0 : discount.type) === 'product' && (discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.source) === 'promotion' && (discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.actionType) === 'ITEM_REWARD';
47
46
  }
48
- export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
49
- _inherits(ScanOrderImpl, _BaseModule);
47
+ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
48
+ _inherits(ScanOrderImpl, _BaseSalesImpl);
50
49
  var _super = _createSuper(ScanOrderImpl);
51
50
  function ScanOrderImpl(name, version) {
52
51
  var _this;
@@ -87,8 +86,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
87
86
  _defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
88
87
  return _this;
89
88
  }
90
-
91
- /** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
92
89
  _createClass(ScanOrderImpl, [{
93
90
  key: "getScanOrderLoggerContext",
94
91
  value: function getScanOrderLoggerContext() {
@@ -439,70 +436,42 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
439
436
  }
440
437
  return refreshOrderMarketingAfterLogin;
441
438
  }()
439
+ }, {
440
+ key: "getRegisteredModuleNames",
441
+ value: function getRegisteredModuleNames() {
442
+ return ['scanOrderLogger', 'products', 'order', 'salesSummary', 'schedule'];
443
+ }
444
+ }, {
445
+ key: "createSubModule",
446
+ value: function createSubModule(moduleName) {
447
+ if (moduleName === 'scanOrderLogger') {
448
+ return createModule('scanOrderLogger', this.name);
449
+ }
450
+ return _get(_getPrototypeOf(ScanOrderImpl.prototype), "createSubModule", this).call(this, moduleName);
451
+ }
452
+
453
+ /** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
442
454
  }, {
443
455
  key: "getCacheId",
444
456
  value: function getCacheId() {
445
457
  return this.cacheId;
446
458
  }
447
- }, {
448
- key: "destroyRegisteredChildModules",
449
- value: function () {
450
- var _destroyRegisteredChildModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
451
- var modules, _i3, _modules, mod;
452
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
453
- while (1) switch (_context6.prev = _context6.next) {
454
- case 0:
455
- modules = [this.store.schedule, this.store.salesSummary, this.store.order, this.store.products, this.store.scanOrderLogger];
456
- _i3 = 0, _modules = modules;
457
- case 2:
458
- if (!(_i3 < _modules.length)) {
459
- _context6.next = 10;
460
- break;
461
- }
462
- mod = _modules[_i3];
463
- if (!(mod && typeof mod.destroy === 'function')) {
464
- _context6.next = 7;
465
- break;
466
- }
467
- _context6.next = 7;
468
- return Promise.resolve(mod.destroy());
469
- case 7:
470
- _i3++;
471
- _context6.next = 2;
472
- break;
473
- case 10:
474
- case "end":
475
- return _context6.stop();
476
- }
477
- }, _callee6, this);
478
- }));
479
- function destroyRegisteredChildModules() {
480
- return _destroyRegisteredChildModules.apply(this, arguments);
481
- }
482
- return destroyRegisteredChildModules;
483
- }()
484
459
  }, {
485
460
  key: "initialize",
486
461
  value: function () {
487
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(core) {
488
- var _options$otherParams,
489
- _this$otherParams,
490
- _this$otherParams2,
491
- _this$otherParams3,
492
- _this4 = this;
462
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(core) {
463
+ var _options$otherParams, _this$otherParams, _this$otherParams2, _this$otherParams3;
493
464
  var options,
494
- moduleArr,
495
- scheduleModule,
465
+ _this$otherParams4,
466
+ _this$otherParams5,
496
467
  _this$store$order,
497
468
  _this$store$order2,
498
- _args7 = arguments;
499
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
500
- while (1) switch (_context7.prev = _context7.next) {
469
+ _args6 = arguments;
470
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
471
+ while (1) switch (_context6.prev = _context6.next) {
501
472
  case 0:
502
- options = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
473
+ options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
503
474
  this.logMethodStart('initialize');
504
- this.core = core;
505
- this.initializeOptions = options || {};
506
475
  this.store = _objectSpread(_objectSpread({}, this.store), options.store);
507
476
  this.store.entryContext = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.entryContext) || this.store.entryContext;
508
477
  this.store.status = 'initializing';
@@ -518,122 +487,76 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
518
487
  passed: null,
519
488
  failures: []
520
489
  };
521
- this.window = core.getPlugin('window');
522
- this.request = core.getPlugin('request');
523
- if (this.window) {
524
- _context7.next = 21;
525
- break;
526
- }
527
- this.logMethodError('initialize', 'window plugin missing');
528
- throw new Error('scanOrder解决方案需要 window 插件支持');
529
- case 21:
530
- if (this.request) {
531
- _context7.next = 24;
532
- break;
533
- }
534
- this.logMethodError('initialize', 'request plugin missing');
535
- throw new Error('scanOrder解决方案需要 request 插件支持');
536
- case 24:
537
- moduleArr = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
538
- moduleArr.forEach(function (step) {
539
- var targetModule = createModule(step, _this4.name);
540
- if (targetModule) {
541
- var _this4$store$order, _this4$otherParams, _this4$otherParams2, _this4$otherParams3, _this4$otherParams4;
542
- _this4.store[step] = targetModule;
543
- var initialState = step === 'salesSummary' ? {
544
- summary: ((_this4$store$order = _this4.store.order) === null || _this4$store$order === void 0 || (_this4$store$order = _this4$store$order.getTempOrder()) === null || _this4$store$order === void 0 ? void 0 : _this4$store$order.summary) || createEmptySummary()
545
- } : {};
546
- var loggerProvider = ((_this4$otherParams = _this4.otherParams) === null || _this4$otherParams === void 0 ? void 0 : _this4$otherParams.scanOrderLoggerProvider) || 'feishu';
547
- var loggerConfig = ((_this4$otherParams2 = _this4.otherParams) === null || _this4$otherParams2 === void 0 ? void 0 : _this4$otherParams2.scanOrderLoggerConfig) || {
548
- feishu: {
549
- webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
550
- errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
551
- }
552
- };
553
- _this4.core.registerModule(targetModule, {
554
- initialState: initialState,
555
- otherParams: _objectSpread(_objectSpread({}, _this4.otherParams), {}, {
556
- fatherModule: _this4.name,
557
- openCache: (_this4$otherParams3 = _this4.otherParams) !== null && _this4$otherParams3 !== void 0 && _this4$otherParams3.cacheId ? true : false,
558
- cacheId: (_this4$otherParams4 = _this4.otherParams) === null || _this4$otherParams4 === void 0 ? void 0 : _this4$otherParams4.cacheId,
559
- salesSummaryModuleName: "".concat(_this4.name, "_salesSummary"),
560
- provider: loggerProvider,
561
- providerConfig: loggerConfig,
562
- context: _this4.getScanOrderLoggerContext()
563
- })
564
- });
565
- } else {
566
- _this4.logMethodError('initialize', "module ".concat(step, " missing"));
567
- throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
568
- }
569
- });
490
+ _context6.next = 16;
491
+ return _get(_getPrototypeOf(ScanOrderImpl.prototype), "initialize", this).call(this, core, options);
492
+ case 16:
570
493
  if (this.store.scanOrderLogger) {
494
+ this.store.scanOrderLogger.setProvider(((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.scanOrderLoggerProvider) || 'feishu');
495
+ this.store.scanOrderLogger.setProviderConfig(((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.scanOrderLoggerConfig) || {
496
+ feishu: {
497
+ webhook: 'https://open.feishu.cn/open-apis/bot/v2/hook/216b3fe6-af98-424e-8706-f0471241a7ed',
498
+ errorHook: 'https://open.feishu.cn/open-apis/bot/v2/hook/015b7c2a-dd3c-4c30-9898-ef0f5253111f'
499
+ }
500
+ });
571
501
  this.store.scanOrderLogger.setContext(this.getScanOrderLoggerContext());
572
502
  }
573
- scheduleModule = new ScheduleModule("".concat(this.name, "_schedule"));
574
- this.store.schedule = scheduleModule;
575
- this.core.registerModule(scheduleModule, {
576
- otherParams: _objectSpread(_objectSpread({}, this.otherParams), {}, {
577
- fatherModule: this.name
578
- })
579
- });
580
503
  this.registerCustomerLoginListeners();
581
504
  console.log('[ScanOrder] 初始化开始');
582
- _context7.prev = 32;
583
- _context7.next = 35;
505
+ _context6.prev = 19;
506
+ _context6.next = 22;
584
507
  return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
585
508
  createIfMissing: false
586
509
  });
587
- case 35:
510
+ case 22:
588
511
  (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
589
- _context7.next = 38;
512
+ _context6.next = 25;
590
513
  return this.loadRuntimeConfigs();
591
- case 38:
514
+ case 25:
592
515
  if (!this.store.schedule) {
593
- _context7.next = 47;
516
+ _context6.next = 34;
594
517
  break;
595
518
  }
596
- _context7.prev = 39;
597
- _context7.next = 42;
519
+ _context6.prev = 26;
520
+ _context6.next = 29;
598
521
  return this.store.schedule.loadAllSchedule();
599
- case 42:
600
- _context7.next = 47;
522
+ case 29:
523
+ _context6.next = 34;
601
524
  break;
602
- case 44:
603
- _context7.prev = 44;
604
- _context7.t0 = _context7["catch"](39);
605
- console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context7.t0);
606
- case 47:
607
- _context7.next = 49;
525
+ case 31:
526
+ _context6.prev = 31;
527
+ _context6.t0 = _context6["catch"](26);
528
+ console.warn('[ScanOrder] loadAllSchedule 失败,operating_hours 判定将跳过', _context6.t0);
529
+ case 34:
530
+ _context6.next = 36;
608
531
  return this.refreshItemRuleQuantityLimits();
609
- case 49:
532
+ case 36:
610
533
  this.store.status = 'ready';
611
534
  console.log('[ScanOrder] 初始化完成');
612
- _context7.next = 53;
535
+ _context6.next = 40;
613
536
  return this.core.effects.emit(ScanOrderHooks.onInited, {
614
537
  status: this.store.status
615
538
  });
616
- case 53:
539
+ case 40:
617
540
  this.logMethodSuccess('initialize', {
618
541
  status: this.store.status
619
542
  });
620
- _context7.next = 63;
543
+ _context6.next = 50;
621
544
  break;
622
- case 56:
623
- _context7.prev = 56;
624
- _context7.t1 = _context7["catch"](32);
545
+ case 43:
546
+ _context6.prev = 43;
547
+ _context6.t1 = _context6["catch"](19);
625
548
  this.store.status = 'error';
626
- this.store.error = _context7.t1 instanceof Error ? _context7.t1.message : '初始化失败';
627
- console.error('[ScanOrder] 初始化失败', _context7.t1);
628
- this.logMethodError('initialize', _context7.t1, {
549
+ this.store.error = _context6.t1 instanceof Error ? _context6.t1.message : '初始化失败';
550
+ console.error('[ScanOrder] 初始化失败', _context6.t1);
551
+ this.logMethodError('initialize', _context6.t1, {
629
552
  status: this.store.status
630
553
  });
631
- throw _context7.t1;
632
- case 63:
554
+ throw _context6.t1;
555
+ case 50:
633
556
  case "end":
634
- return _context7.stop();
557
+ return _context6.stop();
635
558
  }
636
- }, _callee7, this, [[32, 56], [39, 44]]);
559
+ }, _callee6, this, [[19, 43], [26, 31]]);
637
560
  }));
638
561
  function initialize(_x5) {
639
562
  return _initialize.apply(this, arguments);
@@ -643,26 +566,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
643
566
  }, {
644
567
  key: "destroy",
645
568
  value: function () {
646
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
647
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
648
- while (1) switch (_context8.prev = _context8.next) {
569
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
570
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
571
+ while (1) switch (_context7.prev = _context7.next) {
649
572
  case 0:
650
573
  this.logMethodStart('destroy');
651
574
  this.clearLoginEffectListeners();
652
- _context8.next = 4;
575
+ _context7.next = 4;
653
576
  return this.core.effects.emit(ScanOrderHooks.onDestroy, {});
654
577
  case 4:
655
- _context8.next = 6;
656
- return this.destroyRegisteredChildModules();
657
- case 6:
658
578
  _get(_getPrototypeOf(ScanOrderImpl.prototype), "destroy", this).call(this);
659
579
  console.log('[ScanOrder] 已销毁');
660
580
  this.logMethodSuccess('destroy');
661
- case 9:
581
+ case 7:
662
582
  case "end":
663
- return _context8.stop();
583
+ return _context7.stop();
664
584
  }
665
- }, _callee8, this);
585
+ }, _callee7, this);
666
586
  }));
667
587
  function destroy() {
668
588
  return _destroy.apply(this, arguments);
@@ -672,33 +592,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
672
592
  }, {
673
593
  key: "retryInit",
674
594
  value: function () {
675
- var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
676
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
677
- while (1) switch (_context9.prev = _context9.next) {
595
+ var _retryInit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
596
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
597
+ while (1) switch (_context8.prev = _context8.next) {
678
598
  case 0:
679
599
  this.logMethodStart('retryInit');
680
600
  // TODO: 细化重试策略(指数退避、最大重试次数)后替换当前实现
681
601
  console.log('[ScanOrder] retryInit 调用');
682
- _context9.next = 4;
602
+ _context8.next = 4;
683
603
  return this.core.effects.emit(ScanOrderHooks.onRetryInit, {});
684
604
  case 4:
685
- _context9.prev = 4;
686
- _context9.next = 7;
605
+ _context8.prev = 4;
606
+ _context8.next = 7;
687
607
  return this.initialize(this.core, this.initializeOptions);
688
608
  case 7:
689
609
  this.logMethodSuccess('retryInit');
690
- _context9.next = 14;
610
+ _context8.next = 14;
691
611
  break;
692
612
  case 10:
693
- _context9.prev = 10;
694
- _context9.t0 = _context9["catch"](4);
695
- this.logMethodError('retryInit', _context9.t0);
696
- throw _context9.t0;
613
+ _context8.prev = 10;
614
+ _context8.t0 = _context8["catch"](4);
615
+ this.logMethodError('retryInit', _context8.t0);
616
+ throw _context8.t0;
697
617
  case 14:
698
618
  case "end":
699
- return _context9.stop();
619
+ return _context8.stop();
700
620
  }
701
- }, _callee9, this, [[4, 10]]);
621
+ }, _callee8, this, [[4, 10]]);
702
622
  }));
703
623
  function retryInit() {
704
624
  return _retryInit.apply(this, arguments);
@@ -708,23 +628,23 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
708
628
  }, {
709
629
  key: "refresh",
710
630
  value: function () {
711
- var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
712
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
713
- while (1) switch (_context10.prev = _context10.next) {
631
+ var _refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
632
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
633
+ while (1) switch (_context9.prev = _context9.next) {
714
634
  case 0:
715
635
  this.logMethodStart('refresh');
716
636
  // TODO: 接入真实刷新逻辑(资源重拉取、流程重建)后替换当前实现
717
637
  console.log('[ScanOrder] refresh 调用');
718
- _context10.prev = 2;
638
+ _context9.prev = 2;
719
639
  this.store.status = 'initializing';
720
- _context10.next = 6;
640
+ _context9.next = 6;
721
641
  return this.loadRuntimeConfigs();
722
642
  case 6:
723
- _context10.next = 8;
643
+ _context9.next = 8;
724
644
  return this.refreshItemRuleQuantityLimits();
725
645
  case 8:
726
646
  this.store.status = 'ready';
727
- _context10.next = 11;
647
+ _context9.next = 11;
728
648
  return this.core.effects.emit(ScanOrderHooks.onRefresh, {
729
649
  status: this.store.status
730
650
  });
@@ -732,18 +652,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
732
652
  this.logMethodSuccess('refresh', {
733
653
  status: this.store.status
734
654
  });
735
- _context10.next = 18;
655
+ _context9.next = 18;
736
656
  break;
737
657
  case 14:
738
- _context10.prev = 14;
739
- _context10.t0 = _context10["catch"](2);
740
- this.logMethodError('refresh', _context10.t0);
741
- throw _context10.t0;
658
+ _context9.prev = 14;
659
+ _context9.t0 = _context9["catch"](2);
660
+ this.logMethodError('refresh', _context9.t0);
661
+ throw _context9.t0;
742
662
  case 18:
743
663
  case "end":
744
- return _context10.stop();
664
+ return _context9.stop();
745
665
  }
746
- }, _callee10, this, [[2, 14]]);
666
+ }, _callee9, this, [[2, 14]]);
747
667
  }));
748
668
  function refresh() {
749
669
  return _refresh.apply(this, arguments);
@@ -831,16 +751,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
831
751
  }, {
832
752
  key: "updateTempOrderNote",
833
753
  value: function updateTempOrderNote(note) {
754
+ var _this4 = this;
755
+ var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
834
756
  this.logMethodStart('updateTempOrderNote', {
835
757
  noteLength: String(note || '').length
836
758
  });
837
759
  try {
838
760
  if (!this.store.order) throw new Error('order 模块未初始化');
839
- var result = this.store.order.updateTempOrderNote(note);
761
+ var result = this.store.order.updateTempOrderNote(note, sync);
762
+ if (result && typeof result.then === 'function') {
763
+ return result.then(function (nextNote) {
764
+ _this4.logMethodSuccess('updateTempOrderNote', {
765
+ noteLength: nextNote.length
766
+ });
767
+ return nextNote;
768
+ });
769
+ }
770
+ var nextNote = result;
840
771
  this.logMethodSuccess('updateTempOrderNote', {
841
- noteLength: result.length
772
+ noteLength: nextNote.length
842
773
  });
843
- return result;
774
+ return nextNote;
844
775
  } catch (error) {
845
776
  this.logMethodError('updateTempOrderNote', error);
846
777
  throw error;
@@ -856,11 +787,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
856
787
  mode: mode
857
788
  });
858
789
  try {
790
+ var _this$otherParams6;
859
791
  if (!this.store.order) throw new Error('order 模块未初始化');
860
792
  var tempOrder = this.store.order.ensureTempOrder();
861
793
  tempOrder.metadata = _objectSpread(_objectSpread({}, tempOrder.metadata || {}), {}, {
862
794
  shop_service_data: _objectSpread(_objectSpread({}, (tempOrder.metadata || {}).shop_service_data || {}), {}, {
863
- service_type: 'dine_in',
795
+ service_type: ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) === 'dine_in' ? 'dine_in' : '',
864
796
  pickup_reference_mode: mode
865
797
  })
866
798
  });
@@ -897,8 +829,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
897
829
  }
898
830
  }
899
831
  }, {
900
- key: "ensureTempOrder",
901
- value: function ensureTempOrder() {
832
+ key: "ensureScanOrderTempOrder",
833
+ value: function ensureScanOrderTempOrder() {
902
834
  if (!this.store.order) throw new Error('order 模块未初始化');
903
835
  return this.store.order.ensureTempOrder();
904
836
  }
@@ -907,37 +839,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
907
839
  }, {
908
840
  key: "addNewOrder",
909
841
  value: function () {
910
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
842
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
911
843
  var tempOrder;
912
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
913
- while (1) switch (_context11.prev = _context11.next) {
844
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
845
+ while (1) switch (_context10.prev = _context10.next) {
914
846
  case 0:
915
847
  this.logMethodStart('addNewOrder');
916
- _context11.prev = 1;
848
+ _context10.prev = 1;
917
849
  if (this.store.order) {
918
- _context11.next = 4;
850
+ _context10.next = 4;
919
851
  break;
920
852
  }
921
853
  throw new Error('order 模块未初始化');
922
854
  case 4:
923
- _context11.next = 6;
855
+ _context10.next = 6;
924
856
  return this.store.order.addNewOrder();
925
857
  case 6:
926
- tempOrder = _context11.sent;
858
+ tempOrder = _context10.sent;
927
859
  this.logMethodSuccess('addNewOrder', {
928
860
  productCount: tempOrder.products.length
929
861
  });
930
- return _context11.abrupt("return", tempOrder);
862
+ return _context10.abrupt("return", tempOrder);
931
863
  case 11:
932
- _context11.prev = 11;
933
- _context11.t0 = _context11["catch"](1);
934
- this.logMethodError('addNewOrder', _context11.t0);
935
- throw _context11.t0;
864
+ _context10.prev = 11;
865
+ _context10.t0 = _context10["catch"](1);
866
+ this.logMethodError('addNewOrder', _context10.t0);
867
+ throw _context10.t0;
936
868
  case 15:
937
869
  case "end":
938
- return _context11.stop();
870
+ return _context10.stop();
939
871
  }
940
- }, _callee11, this, [[1, 11]]);
872
+ }, _callee10, this, [[1, 11]]);
941
873
  }));
942
874
  function addNewOrder() {
943
875
  return _addNewOrder.apply(this, arguments);
@@ -948,15 +880,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
948
880
  }, {
949
881
  key: "restoreOrder",
950
882
  value: function () {
951
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
883
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
952
884
  var tempOrder;
953
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
954
- while (1) switch (_context12.prev = _context12.next) {
885
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
886
+ while (1) switch (_context11.prev = _context11.next) {
955
887
  case 0:
956
888
  this.logMethodStart('restoreOrder');
957
- _context12.prev = 1;
889
+ _context11.prev = 1;
958
890
  if (this.store.order) {
959
- _context12.next = 4;
891
+ _context11.next = 4;
960
892
  break;
961
893
  }
962
894
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -966,17 +898,17 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
966
898
  this.enabledReservationRuleProducts = [];
967
899
  tempOrder = this.store.order.restoreOrder();
968
900
  this.logMethodSuccess('restoreOrder');
969
- return _context12.abrupt("return", tempOrder);
901
+ return _context11.abrupt("return", tempOrder);
970
902
  case 12:
971
- _context12.prev = 12;
972
- _context12.t0 = _context12["catch"](1);
973
- this.logMethodError('restoreOrder', _context12.t0);
974
- throw _context12.t0;
903
+ _context11.prev = 12;
904
+ _context11.t0 = _context11["catch"](1);
905
+ this.logMethodError('restoreOrder', _context11.t0);
906
+ throw _context11.t0;
975
907
  case 16:
976
908
  case "end":
977
- return _context12.stop();
909
+ return _context11.stop();
978
910
  }
979
- }, _callee12, this, [[1, 12]]);
911
+ }, _callee11, this, [[1, 12]]);
980
912
  }));
981
913
  function restoreOrder() {
982
914
  return _restoreOrder.apply(this, arguments);
@@ -997,37 +929,37 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
997
929
  }, {
998
930
  key: "getSummary",
999
931
  value: function () {
1000
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
932
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1001
933
  var summary;
1002
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1003
- while (1) switch (_context13.prev = _context13.next) {
934
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
935
+ while (1) switch (_context12.prev = _context12.next) {
1004
936
  case 0:
1005
937
  this.logMethodStart('getSummary');
1006
- _context13.prev = 1;
938
+ _context12.prev = 1;
1007
939
  if (this.store.order) {
1008
- _context13.next = 4;
940
+ _context12.next = 4;
1009
941
  break;
1010
942
  }
1011
943
  throw new Error('order 模块未初始化');
1012
944
  case 4:
1013
- _context13.next = 6;
945
+ _context12.next = 6;
1014
946
  return this.store.order.getOrderSummary();
1015
947
  case 6:
1016
- summary = _context13.sent;
948
+ summary = _context12.sent;
1017
949
  this.logMethodSuccess('getSummary', {
1018
950
  totalAmount: summary.total_amount
1019
951
  });
1020
- return _context13.abrupt("return", summary);
952
+ return _context12.abrupt("return", summary);
1021
953
  case 11:
1022
- _context13.prev = 11;
1023
- _context13.t0 = _context13["catch"](1);
1024
- this.logMethodError('getSummary', _context13.t0);
1025
- throw _context13.t0;
954
+ _context12.prev = 11;
955
+ _context12.t0 = _context12["catch"](1);
956
+ this.logMethodError('getSummary', _context12.t0);
957
+ throw _context12.t0;
1026
958
  case 15:
1027
959
  case "end":
1028
- return _context13.stop();
960
+ return _context12.stop();
1029
961
  }
1030
- }, _callee13, this, [[1, 11]]);
962
+ }, _callee12, this, [[1, 11]]);
1031
963
  }));
1032
964
  function getSummary() {
1033
965
  return _getSummary.apply(this, arguments);
@@ -1043,30 +975,30 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1043
975
  }, {
1044
976
  key: "scanCode",
1045
977
  value: function () {
1046
- var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(code, customerId) {
978
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(code, customerId) {
1047
979
  var raw;
1048
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1049
- while (1) switch (_context14.prev = _context14.next) {
980
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
981
+ while (1) switch (_context13.prev = _context13.next) {
1050
982
  case 0:
1051
983
  this.logMethodStart('scanCode', {
1052
984
  code: code
1053
985
  });
1054
- _context14.prev = 1;
986
+ _context13.prev = 1;
1055
987
  if (this.store.order) {
1056
- _context14.next = 4;
988
+ _context13.next = 4;
1057
989
  break;
1058
990
  }
1059
991
  throw new Error('order 模块未初始化');
1060
992
  case 4:
1061
- _context14.next = 6;
993
+ _context13.next = 6;
1062
994
  return this.store.order.scanCode(code, customerId);
1063
995
  case 6:
1064
- raw = _context14.sent;
996
+ raw = _context13.sent;
1065
997
  if (!raw.isAvailable) {
1066
- _context14.next = 11;
998
+ _context13.next = 11;
1067
999
  break;
1068
1000
  }
1069
- _context14.next = 10;
1001
+ _context13.next = 10;
1070
1002
  return this.store.order.recalculateSummary({
1071
1003
  createIfMissing: true
1072
1004
  });
@@ -1076,21 +1008,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1076
1008
  this.logMethodSuccess('scanCode', {
1077
1009
  isAvailable: raw.isAvailable
1078
1010
  });
1079
- return _context14.abrupt("return", {
1011
+ return _context13.abrupt("return", {
1080
1012
  isAvailable: raw.isAvailable,
1081
1013
  type: raw.type,
1082
1014
  unavailableReason: raw.unavailableReason
1083
1015
  });
1084
1016
  case 15:
1085
- _context14.prev = 15;
1086
- _context14.t0 = _context14["catch"](1);
1087
- this.logMethodError('scanCode', _context14.t0);
1088
- throw _context14.t0;
1017
+ _context13.prev = 15;
1018
+ _context13.t0 = _context13["catch"](1);
1019
+ this.logMethodError('scanCode', _context13.t0);
1020
+ throw _context13.t0;
1089
1021
  case 19:
1090
1022
  case "end":
1091
- return _context14.stop();
1023
+ return _context13.stop();
1092
1024
  }
1093
- }, _callee14, this, [[1, 15]]);
1025
+ }, _callee13, this, [[1, 15]]);
1094
1026
  }));
1095
1027
  function scanCode(_x6, _x7) {
1096
1028
  return _scanCode.apply(this, arguments);
@@ -1100,15 +1032,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1100
1032
  }, {
1101
1033
  key: "setDiscountSelected",
1102
1034
  value: function () {
1103
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1035
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
1104
1036
  var _tempOrder$holder, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _origin, _product$metadata$sou, _product$metadata, _product$metadata2, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
1105
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1106
- while (1) switch (_context15.prev = _context15.next) {
1037
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1038
+ while (1) switch (_context14.prev = _context14.next) {
1107
1039
  case 0:
1108
1040
  this.logMethodStart('setDiscountSelected', params);
1109
- _context15.prev = 1;
1041
+ _context14.prev = 1;
1110
1042
  if (this.store.order) {
1111
- _context15.next = 4;
1043
+ _context14.next = 4;
1112
1044
  break;
1113
1045
  }
1114
1046
  throw new Error('order 模块未初始化');
@@ -1128,7 +1060,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1128
1060
  form_record_id: tempOrder.holder.form_record_id
1129
1061
  }] : [];
1130
1062
  nextDiscountList = updated;
1131
- _context15.next = 14;
1063
+ _context14.next = 14;
1132
1064
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
1133
1065
  case 14:
1134
1066
  if (rulesModule) {
@@ -1177,26 +1109,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1177
1109
  return d.id;
1178
1110
  }));
1179
1111
  _iterator3 = _createForOfIteratorHelper(tempOrder.products);
1180
- _context15.prev = 17;
1112
+ _context14.prev = 17;
1181
1113
  _iterator3.s();
1182
1114
  case 19:
1183
1115
  if ((_step3 = _iterator3.n()).done) {
1184
- _context15.next = 36;
1116
+ _context14.next = 36;
1185
1117
  break;
1186
1118
  }
1187
1119
  product = _step3.value;
1188
1120
  if (!((_origin = product._origin) !== null && _origin !== void 0 && _origin.isManualDiscount)) {
1189
- _context15.next = 23;
1121
+ _context14.next = 23;
1190
1122
  break;
1191
1123
  }
1192
- return _context15.abrupt("continue", 34);
1124
+ return _context14.abrupt("continue", 34);
1193
1125
  case 23:
1194
1126
  if (!(product.discount_list || []).some(isItemRewardProductDiscount)) {
1195
- _context15.next = 26;
1127
+ _context14.next = 26;
1196
1128
  break;
1197
1129
  }
1198
1130
  product.discount_list = (product.discount_list || []).filter(isItemRewardProductDiscount);
1199
- return _context15.abrupt("continue", 34);
1131
+ return _context14.abrupt("continue", 34);
1200
1132
  case 26:
1201
1133
  product.discount_list = (product.discount_list || []).filter(function (pd) {
1202
1134
  var _pd$discount$resource, _pd$discount;
@@ -1222,46 +1154,46 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1222
1154
  bundle: product.product_bundle
1223
1155
  });
1224
1156
  case 34:
1225
- _context15.next = 19;
1157
+ _context14.next = 19;
1226
1158
  break;
1227
1159
  case 36:
1228
- _context15.next = 41;
1160
+ _context14.next = 41;
1229
1161
  break;
1230
1162
  case 38:
1231
- _context15.prev = 38;
1232
- _context15.t0 = _context15["catch"](17);
1233
- _iterator3.e(_context15.t0);
1163
+ _context14.prev = 38;
1164
+ _context14.t0 = _context14["catch"](17);
1165
+ _iterator3.e(_context14.t0);
1234
1166
  case 41:
1235
- _context15.prev = 41;
1167
+ _context14.prev = 41;
1236
1168
  _iterator3.f();
1237
- return _context15.finish(41);
1169
+ return _context14.finish(41);
1238
1170
  case 44:
1239
1171
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
1240
- _context15.next = 47;
1172
+ _context14.next = 47;
1241
1173
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
1242
1174
  case 47:
1243
1175
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
1244
1176
  return d.isSelected;
1245
1177
  });
1246
- _context15.next = 50;
1178
+ _context14.next = 50;
1247
1179
  return this.store.order.recalculateSummary({
1248
1180
  createIfMissing: true
1249
1181
  });
1250
1182
  case 50:
1251
1183
  this.store.order.persistTempOrder();
1252
1184
  this.logMethodSuccess('setDiscountSelected', params);
1253
- _context15.next = 58;
1185
+ _context14.next = 58;
1254
1186
  break;
1255
1187
  case 54:
1256
- _context15.prev = 54;
1257
- _context15.t1 = _context15["catch"](1);
1258
- this.logMethodError('setDiscountSelected', _context15.t1);
1259
- throw _context15.t1;
1188
+ _context14.prev = 54;
1189
+ _context14.t1 = _context14["catch"](1);
1190
+ this.logMethodError('setDiscountSelected', _context14.t1);
1191
+ throw _context14.t1;
1260
1192
  case 58:
1261
1193
  case "end":
1262
- return _context15.stop();
1194
+ return _context14.stop();
1263
1195
  }
1264
- }, _callee15, this, [[1, 54], [17, 38, 41, 44]]);
1196
+ }, _callee14, this, [[1, 54], [17, 38, 41, 44]]);
1265
1197
  }));
1266
1198
  function setDiscountSelected(_x8) {
1267
1199
  return _setDiscountSelected.apply(this, arguments);
@@ -1271,15 +1203,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1271
1203
  }, {
1272
1204
  key: "onCustomerLogin",
1273
1205
  value: function () {
1274
- var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1275
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1276
- while (1) switch (_context16.prev = _context16.next) {
1206
+ var _onCustomerLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1207
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1208
+ while (1) switch (_context15.prev = _context15.next) {
1277
1209
  case 0:
1278
1210
  this.logMethodStart('onCustomerLogin', {
1279
1211
  customerId: params.customerId
1280
1212
  });
1281
- _context16.prev = 1;
1282
- _context16.next = 4;
1213
+ _context15.prev = 1;
1214
+ _context15.next = 4;
1283
1215
  return this.refreshOrderMarketingAfterLogin({
1284
1216
  customerId: params.customerId
1285
1217
  });
@@ -1287,18 +1219,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1287
1219
  this.logMethodSuccess('onCustomerLogin', {
1288
1220
  customerId: params.customerId
1289
1221
  });
1290
- _context16.next = 11;
1222
+ _context15.next = 11;
1291
1223
  break;
1292
1224
  case 7:
1293
- _context16.prev = 7;
1294
- _context16.t0 = _context16["catch"](1);
1295
- this.logMethodError('onCustomerLogin', _context16.t0);
1296
- throw _context16.t0;
1225
+ _context15.prev = 7;
1226
+ _context15.t0 = _context15["catch"](1);
1227
+ this.logMethodError('onCustomerLogin', _context15.t0);
1228
+ throw _context15.t0;
1297
1229
  case 11:
1298
1230
  case "end":
1299
- return _context16.stop();
1231
+ return _context15.stop();
1300
1232
  }
1301
- }, _callee16, this, [[1, 7]]);
1233
+ }, _callee15, this, [[1, 7]]);
1302
1234
  }));
1303
1235
  function onCustomerLogin(_x9) {
1304
1236
  return _onCustomerLogin.apply(this, arguments);
@@ -1346,8 +1278,70 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1346
1278
  combined_resource: isCombined ? combined : null
1347
1279
  };
1348
1280
  }
1349
-
1350
- // ScanOrder 提交 payload enhancer:
1281
+ }, {
1282
+ key: "prepareRetailAvailability",
1283
+ value: function () {
1284
+ var _prepareRetailAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1285
+ var _this$store$order4, _this$otherParams7;
1286
+ var tempOrder, hasOrderId, resourceId, reason, resourceState, availabilityInfo;
1287
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1288
+ while (1) switch (_context16.prev = _context16.next) {
1289
+ case 0:
1290
+ tempOrder = params.tempOrder, hasOrderId = params.hasOrderId, resourceId = params.resourceId, reason = params.reason;
1291
+ this.enabledReservationRuleProducts = [];
1292
+ tempOrder.bookings = [];
1293
+ tempOrder.order_id = null;
1294
+ delete tempOrder.relation_id;
1295
+ delete tempOrder.table_form_id;
1296
+ delete tempOrder.resource_id;
1297
+ delete tempOrder.table_number;
1298
+ tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
1299
+ delete tempOrder.metadata.table_occupancy_duration;
1300
+ resourceState = {
1301
+ mode: 'idle',
1302
+ deskmate_valid: false,
1303
+ allowSnack: false,
1304
+ deskmateValid: false,
1305
+ isExclusive: false,
1306
+ isFull: false,
1307
+ raw: null
1308
+ };
1309
+ this.store.resource = resourceState;
1310
+ (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
1311
+ _context16.next = 15;
1312
+ return this.addNewOrder();
1313
+ case 15:
1314
+ _context16.next = 17;
1315
+ return this.setItemRuleRuntimeConfig({
1316
+ serviceType: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode,
1317
+ submissionIndex: hasOrderId ? 1 : 0,
1318
+ historicalItems: []
1319
+ });
1320
+ case 17:
1321
+ availabilityInfo = {
1322
+ mode: 'idle',
1323
+ deskmate_valid: false
1324
+ };
1325
+ this.logMethodSuccess('checkResourceAvailable', {
1326
+ resourceId: resourceId,
1327
+ mode: availabilityInfo.mode,
1328
+ retailMode: true,
1329
+ retailReason: reason,
1330
+ relationId: resourceState.relationId,
1331
+ persistedResourceId: resourceState.relationId
1332
+ });
1333
+ return _context16.abrupt("return", availabilityInfo);
1334
+ case 20:
1335
+ case "end":
1336
+ return _context16.stop();
1337
+ }
1338
+ }, _callee16, this);
1339
+ }));
1340
+ function prepareRetailAvailability(_x10) {
1341
+ return _prepareRetailAvailability.apply(this, arguments);
1342
+ }
1343
+ return prepareRetailAvailability;
1344
+ }() // ScanOrder 提交 payload enhancer:
1351
1345
  // - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
1352
1346
  // - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
1353
1347
  // - 给第一条 booking 补 resources 与 product_uid(仅当存在 resource / rule product)
@@ -1360,25 +1354,32 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1360
1354
  var resourceState = this.store.resource;
1361
1355
  var resourceSelectType = resourceState === null || resourceState === void 0 ? void 0 : resourceState.resourceSelectType;
1362
1356
 
1363
- // collect_pax 时的资源占用兜底:single 独占整张桌台,其余模式占 1 个容量位。
1364
- var resolveResourceCapacity = function resolveResourceCapacity() {
1357
+ // ScanOrder booking 容量只由预约规则决定:single 占用整张桌台,multiple 占用 1 个容量位。
1358
+ var resolveBookingCapacityValue = function resolveBookingCapacityValue() {
1365
1359
  if (resourceSelectType === 'single') {
1366
1360
  var _resourceState$table_;
1367
1361
  var raw = resourceState === null || resourceState === void 0 || (_resourceState$table_ = resourceState.table_form_record) === null || _resourceState$table_ === void 0 ? void 0 : _resourceState$table_.capacity;
1368
1362
  var num = Number(raw);
1369
- if (Number.isFinite(num) && num > 0) return num;
1363
+ if (Number.isFinite(num) && num > 0) return Math.max(1, Math.floor(num));
1370
1364
  return 1;
1371
1365
  }
1372
1366
  return 1;
1373
1367
  };
1374
1368
  return function (payload, _ref3) {
1375
- var _resource_id, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati, _pickFirstCustomCapac;
1369
+ var _resourceState$relati, _tempOrder$metadata, _ref4, _pickOriginal, _resourceState$table_2, _resourceState$relati2, _pickFirstCustomCapac;
1376
1370
  var bookingUuid = _ref3.bookingUuid,
1377
1371
  tempOrder = _ref3.tempOrder;
1378
- var resourceId = (_resource_id = tempOrder.resource_id) !== null && _resource_id !== void 0 ? _resource_id : resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId;
1372
+ var resourceId = String((_resourceState$relati = resourceState === null || resourceState === void 0 ? void 0 : resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : '').trim();
1373
+ var hasReservationBookingContext = Boolean(ruleProduct && resourceState && resourceId && resourceState.relationId && resourceState.tableFormId);
1374
+ if (!hasReservationBookingContext) {
1375
+ return _objectSpread(_objectSpread({}, payload), {}, {
1376
+ bookings: [],
1377
+ products: _toConsumableArray(payload.products || [])
1378
+ });
1379
+ }
1379
1380
  var rawCollectPax = (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.collect_pax;
1380
- var hasCollectPaxForCapacity = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1381
- var resourceCapacityValue = hasCollectPaxForCapacity ? normalizeSubmitCollectPaxValue(rawCollectPax) : resolveResourceCapacity();
1381
+ var hasExplicitCollectPax = rawCollectPax !== null && rawCollectPax !== undefined && rawCollectPax !== '';
1382
+ var bookingCapacityValue = resolveBookingCapacityValue();
1382
1383
  var pickOriginal = function pickOriginal(value) {
1383
1384
  if (value && _typeof(value) === 'object' && !Array.isArray(value)) {
1384
1385
  var original = value.original;
@@ -1393,22 +1394,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1393
1394
  id: Number(resourceId),
1394
1395
  main_field: mainField,
1395
1396
  form_id: resourceState.tableFormId,
1396
- relation_id: (_resourceState$relati = resourceState.relationId) !== null && _resourceState$relati !== void 0 ? _resourceState$relati : resourceId,
1397
- capacity: resourceCapacityValue,
1397
+ relation_id: (_resourceState$relati2 = resourceState.relationId) !== null && _resourceState$relati2 !== void 0 ? _resourceState$relati2 : resourceId,
1398
+ capacity: bookingCapacityValue,
1398
1399
  metadata: _this5.buildScanOrderResourceMetadata({
1399
1400
  resourceState: resourceState,
1400
1401
  resourceName: mainField
1401
1402
  })
1402
1403
  } : undefined;
1403
1404
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1404
- // 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
1405
- var bookingCapacityValue = resourceCapacityValue;
1406
1405
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1407
1406
  var nextBookings = (payload.bookings || []).map(function (booking, idx) {
1407
+ var metadata = _objectSpread({}, booking.metadata || {});
1408
+ if (hasExplicitCollectPax) {
1409
+ metadata.collect_pax = normalizeSubmitCollectPaxValue(rawCollectPax);
1410
+ } else {
1411
+ delete metadata.collect_pax;
1412
+ }
1408
1413
  return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
1409
1414
  number: bookingCapacityValue,
1410
1415
  appointment_status: 'started',
1411
- metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
1416
+ metadata: _objectSpread(_objectSpread(_objectSpread({}, metadata), resourceSelectType ? {
1412
1417
  resource_select_type: resourceSelectType
1413
1418
  } : {}), resourceSelectType ? {
1414
1419
  capacity: [{
@@ -1457,20 +1462,98 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1457
1462
  };
1458
1463
  }
1459
1464
  }, {
1460
- key: "submitScanOrder",
1465
+ key: "isScanOrderMoreMode",
1466
+ value: function isScanOrderMoreMode(tempOrder) {
1467
+ var _this$store$resource, _this$store$entryCont;
1468
+ var mode = (_this$store$resource = this.store.resource) === null || _this$store$resource === void 0 ? void 0 : _this$store$resource.mode;
1469
+ return Boolean(tempOrder.order_id && (mode === 'additional_order' || mode === 'additional_order_with_code' || ((_this$store$entryCont = this.store.entryContext) === null || _this$store$entryCont === void 0 ? void 0 : _this$store$entryCont.mode) === 'append'));
1470
+ }
1471
+ }, {
1472
+ key: "submitScanOrderMore",
1461
1473
  value: function () {
1462
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1463
- var _this$store$resource, _this$otherParams4, _this$otherParams5, _this$otherParams6, _this$otherParams7, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1474
+ var _submitScanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1475
+ var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _this$otherParams12;
1476
+ var tempOrder, enhancePayload, latestSummary, payload, products, orderId, result;
1464
1477
  return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1465
1478
  while (1) switch (_context17.prev = _context17.next) {
1479
+ case 0:
1480
+ if (this.request) {
1481
+ _context17.next = 2;
1482
+ break;
1483
+ }
1484
+ throw new Error('scanOrder解决方案需要 request 插件支持');
1485
+ case 2:
1486
+ if (this.store.order) {
1487
+ _context17.next = 4;
1488
+ break;
1489
+ }
1490
+ throw new Error('scanOrder解决方案需要 order 模块支持');
1491
+ case 4:
1492
+ tempOrder = params.tempOrder, enhancePayload = params.enhancePayload;
1493
+ _context17.next = 7;
1494
+ return this.store.order.recalculateSummary({
1495
+ createIfMissing: true
1496
+ });
1497
+ case 7:
1498
+ latestSummary = _context17.sent;
1499
+ payload = buildSubmitPayload({
1500
+ tempOrder: tempOrder,
1501
+ cacheId: this.cacheId,
1502
+ platform: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform,
1503
+ businessCode: ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.business_code),
1504
+ channel: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.channel,
1505
+ type: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.type,
1506
+ summary: latestSummary,
1507
+ enhance: enhancePayload
1508
+ });
1509
+ products = filterProductsForScanOrderMore(payload.products);
1510
+ orderId = tempOrder.order_id;
1511
+ _context17.next = 13;
1512
+ return this.request.put("/order/order/product/".concat(orderId), {
1513
+ products: products,
1514
+ request_unique_idempotency_token: payload.request_unique_idempotency_token
1515
+ }, {
1516
+ customToast: function customToast() {}
1517
+ });
1518
+ case 13:
1519
+ result = _context17.sent;
1520
+ if (!((result === null || result === void 0 ? void 0 : result.code) === 200 && !(result !== null && result !== void 0 && result.data))) {
1521
+ _context17.next = 16;
1522
+ break;
1523
+ }
1524
+ return _context17.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
1525
+ data: {
1526
+ order_id: orderId
1527
+ }
1528
+ }));
1529
+ case 16:
1530
+ return _context17.abrupt("return", result);
1531
+ case 17:
1532
+ case "end":
1533
+ return _context17.stop();
1534
+ }
1535
+ }, _callee17, this);
1536
+ }));
1537
+ function submitScanOrderMore(_x11) {
1538
+ return _submitScanOrderMore.apply(this, arguments);
1539
+ }
1540
+ return submitScanOrderMore;
1541
+ }()
1542
+ }, {
1543
+ key: "submitScanOrder",
1544
+ value: function () {
1545
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1546
+ var _this$store$resource2, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, enhancePayload, result, tempOrder;
1547
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1548
+ while (1) switch (_context18.prev = _context18.next) {
1466
1549
  case 0:
1467
1550
  this.logMethodStart('submitScanOrder');
1468
- _context17.prev = 1;
1469
- _context17.next = 4;
1551
+ _context18.prev = 1;
1552
+ _context18.next = 4;
1470
1553
  return this.validateBeforeSubmitByItemRule();
1471
1554
  case 4:
1472
1555
  if (this.store.order) {
1473
- _context17.next = 6;
1556
+ _context18.next = 6;
1474
1557
  break;
1475
1558
  }
1476
1559
  throw new Error('scanOrder解决方案需要 order 模块支持');
@@ -1482,7 +1565,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1482
1565
  collect_pax: pax
1483
1566
  });
1484
1567
  tempOrderForSubmit.delivery_type = 'shop_service';
1485
- 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;
1568
+ resourceTableName = (_this$store$resource2 = this.store.resource) === null || _this$store$resource2 === void 0 || (_this$store$resource2 = _this$store$resource2.table_form_record) === null || _this$store$resource2 === void 0 ? void 0 : _this$store$resource2.name;
1486
1569
  if (resourceTableName && _typeof(resourceTableName) === 'object') {
1487
1570
  tempOrderForSubmit.table_number = resourceTableName;
1488
1571
  } else {
@@ -1490,32 +1573,43 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1490
1573
  }
1491
1574
  this.store.order.persistTempOrder();
1492
1575
  enhancePayload = this.buildSubmitPayloadEnhancer();
1493
- _context17.next = 17;
1494
- return this.store.order.submitTempOrder({
1495
- cacheId: this.cacheId,
1496
- platform: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform,
1497
- businessCode: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode,
1498
- channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel,
1499
- type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type,
1576
+ if (!this.isScanOrderMoreMode(tempOrderForSubmit)) {
1577
+ _context18.next = 21;
1578
+ break;
1579
+ }
1580
+ _context18.next = 18;
1581
+ return this.submitScanOrderMore({
1582
+ tempOrder: tempOrderForSubmit,
1500
1583
  enhancePayload: enhancePayload
1501
1584
  });
1502
- case 17:
1503
- result = _context17.sent;
1585
+ case 18:
1586
+ _context18.t0 = _context18.sent;
1587
+ _context18.next = 24;
1588
+ break;
1589
+ case 21:
1590
+ _context18.next = 23;
1591
+ return this.submitSalesOrder({
1592
+ enhancePayload: enhancePayload
1593
+ });
1594
+ case 23:
1595
+ _context18.t0 = _context18.sent;
1596
+ case 24:
1597
+ result = _context18.t0;
1504
1598
  tempOrder = this.store.order.getTempOrder();
1505
1599
  this.logMethodSuccess('submitScanOrder', {
1506
1600
  productCount: (tempOrder === null || tempOrder === void 0 || (_tempOrder$products = tempOrder.products) === null || _tempOrder$products === void 0 ? void 0 : _tempOrder$products.length) || 0
1507
1601
  });
1508
- return _context17.abrupt("return", result);
1509
- case 23:
1510
- _context17.prev = 23;
1511
- _context17.t0 = _context17["catch"](1);
1512
- this.logMethodError('submitScanOrder', _context17.t0);
1513
- throw _context17.t0;
1514
- case 27:
1602
+ return _context18.abrupt("return", result);
1603
+ case 30:
1604
+ _context18.prev = 30;
1605
+ _context18.t1 = _context18["catch"](1);
1606
+ this.logMethodError('submitScanOrder', _context18.t1);
1607
+ throw _context18.t1;
1608
+ case 34:
1515
1609
  case "end":
1516
- return _context17.stop();
1610
+ return _context18.stop();
1517
1611
  }
1518
- }, _callee17, this, [[1, 23]]);
1612
+ }, _callee18, this, [[1, 30]]);
1519
1613
  }));
1520
1614
  function submitScanOrder() {
1521
1615
  return _submitScanOrder.apply(this, arguments);
@@ -1525,48 +1619,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1525
1619
  }, {
1526
1620
  key: "addProductToOrder",
1527
1621
  value: function () {
1528
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product) {
1622
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product) {
1529
1623
  var products;
1530
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1531
- while (1) switch (_context18.prev = _context18.next) {
1624
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1625
+ while (1) switch (_context19.prev = _context19.next) {
1532
1626
  case 0:
1533
1627
  this.logMethodStart('addProductToOrder', {
1534
1628
  product_id: product.product_id,
1535
1629
  product_variant_id: product.product_variant_id
1536
1630
  });
1537
- _context18.prev = 1;
1631
+ _context19.prev = 1;
1538
1632
  if (this.store.order) {
1539
- _context18.next = 4;
1633
+ _context19.next = 4;
1540
1634
  break;
1541
1635
  }
1542
1636
  throw new Error('order 模块未初始化');
1543
1637
  case 4:
1544
- _context18.next = 6;
1638
+ _context19.next = 6;
1545
1639
  return this.store.order.addProductToOrder(product);
1546
1640
  case 6:
1547
- products = _context18.sent;
1548
- _context18.next = 9;
1641
+ products = _context19.sent;
1642
+ _context19.next = 9;
1549
1643
  return this.refreshItemRuleQuantityLimits();
1550
1644
  case 9:
1551
- _context18.next = 11;
1645
+ _context19.next = 11;
1552
1646
  return this.refreshCartValidationPassed();
1553
1647
  case 11:
1554
1648
  this.logMethodSuccess('addProductToOrder', {
1555
1649
  productCount: products.length
1556
1650
  });
1557
- return _context18.abrupt("return", products);
1651
+ return _context19.abrupt("return", products);
1558
1652
  case 15:
1559
- _context18.prev = 15;
1560
- _context18.t0 = _context18["catch"](1);
1561
- this.logMethodError('addProductToOrder', _context18.t0);
1562
- throw _context18.t0;
1653
+ _context19.prev = 15;
1654
+ _context19.t0 = _context19["catch"](1);
1655
+ this.logMethodError('addProductToOrder', _context19.t0);
1656
+ throw _context19.t0;
1563
1657
  case 19:
1564
1658
  case "end":
1565
- return _context18.stop();
1659
+ return _context19.stop();
1566
1660
  }
1567
- }, _callee18, this, [[1, 15]]);
1661
+ }, _callee19, this, [[1, 15]]);
1568
1662
  }));
1569
- function addProductToOrder(_x10) {
1663
+ function addProductToOrder(_x12) {
1570
1664
  return _addProductToOrder.apply(this, arguments);
1571
1665
  }
1572
1666
  return addProductToOrder;
@@ -1574,48 +1668,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1574
1668
  }, {
1575
1669
  key: "updateOrderProduct",
1576
1670
  value: function () {
1577
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1671
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
1578
1672
  var products;
1579
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1580
- while (1) switch (_context19.prev = _context19.next) {
1673
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1674
+ while (1) switch (_context20.prev = _context20.next) {
1581
1675
  case 0:
1582
1676
  this.logMethodStart('updateOrderProduct', {
1583
1677
  product_id: params.product_id,
1584
1678
  product_variant_id: params.product_variant_id
1585
1679
  });
1586
- _context19.prev = 1;
1680
+ _context20.prev = 1;
1587
1681
  if (this.store.order) {
1588
- _context19.next = 4;
1682
+ _context20.next = 4;
1589
1683
  break;
1590
1684
  }
1591
1685
  throw new Error('order 模块未初始化');
1592
1686
  case 4:
1593
- _context19.next = 6;
1687
+ _context20.next = 6;
1594
1688
  return this.store.order.updateOrderProduct(params);
1595
1689
  case 6:
1596
- products = _context19.sent;
1597
- _context19.next = 9;
1690
+ products = _context20.sent;
1691
+ _context20.next = 9;
1598
1692
  return this.refreshItemRuleQuantityLimits();
1599
1693
  case 9:
1600
- _context19.next = 11;
1694
+ _context20.next = 11;
1601
1695
  return this.refreshCartValidationPassed();
1602
1696
  case 11:
1603
1697
  this.logMethodSuccess('updateOrderProduct', {
1604
1698
  productCount: products.length
1605
1699
  });
1606
- return _context19.abrupt("return", products);
1700
+ return _context20.abrupt("return", products);
1607
1701
  case 15:
1608
- _context19.prev = 15;
1609
- _context19.t0 = _context19["catch"](1);
1610
- this.logMethodError('updateOrderProduct', _context19.t0);
1611
- throw _context19.t0;
1702
+ _context20.prev = 15;
1703
+ _context20.t0 = _context20["catch"](1);
1704
+ this.logMethodError('updateOrderProduct', _context20.t0);
1705
+ throw _context20.t0;
1612
1706
  case 19:
1613
1707
  case "end":
1614
- return _context19.stop();
1708
+ return _context20.stop();
1615
1709
  }
1616
- }, _callee19, this, [[1, 15]]);
1710
+ }, _callee20, this, [[1, 15]]);
1617
1711
  }));
1618
- function updateOrderProduct(_x11) {
1712
+ function updateOrderProduct(_x13) {
1619
1713
  return _updateOrderProduct.apply(this, arguments);
1620
1714
  }
1621
1715
  return updateOrderProduct;
@@ -1627,16 +1721,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1627
1721
  }, {
1628
1722
  key: "setOrderProductLineNote",
1629
1723
  value: (function () {
1630
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(identity, note) {
1724
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity, note) {
1631
1725
  var params, products;
1632
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1633
- while (1) switch (_context20.prev = _context20.next) {
1726
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1727
+ while (1) switch (_context21.prev = _context21.next) {
1634
1728
  case 0:
1635
1729
  this.logMethodStart('setOrderProductLineNote', {
1636
1730
  product_id: identity.product_id,
1637
1731
  product_variant_id: identity.product_variant_id
1638
1732
  });
1639
- _context20.prev = 1;
1733
+ _context21.prev = 1;
1640
1734
  params = {
1641
1735
  product_id: identity.product_id,
1642
1736
  product_variant_id: identity.product_variant_id,
@@ -1649,26 +1743,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1649
1743
  params.product_sku = identity.product_sku;
1650
1744
  }
1651
1745
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
1652
- _context20.next = 8;
1746
+ _context21.next = 8;
1653
1747
  return this.updateOrderProduct(params);
1654
1748
  case 8:
1655
- products = _context20.sent;
1749
+ products = _context21.sent;
1656
1750
  this.logMethodSuccess('setOrderProductLineNote', {
1657
1751
  productCount: products.length
1658
1752
  });
1659
- return _context20.abrupt("return", products);
1753
+ return _context21.abrupt("return", products);
1660
1754
  case 13:
1661
- _context20.prev = 13;
1662
- _context20.t0 = _context20["catch"](1);
1663
- this.logMethodError('setOrderProductLineNote', _context20.t0);
1664
- throw _context20.t0;
1755
+ _context21.prev = 13;
1756
+ _context21.t0 = _context21["catch"](1);
1757
+ this.logMethodError('setOrderProductLineNote', _context21.t0);
1758
+ throw _context21.t0;
1665
1759
  case 17:
1666
1760
  case "end":
1667
- return _context20.stop();
1761
+ return _context21.stop();
1668
1762
  }
1669
- }, _callee20, this, [[1, 13]]);
1763
+ }, _callee21, this, [[1, 13]]);
1670
1764
  }));
1671
- function setOrderProductLineNote(_x12, _x13) {
1765
+ function setOrderProductLineNote(_x14, _x15) {
1672
1766
  return _setOrderProductLineNote.apply(this, arguments);
1673
1767
  }
1674
1768
  return setOrderProductLineNote;
@@ -1676,48 +1770,48 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1676
1770
  }, {
1677
1771
  key: "removeProductFromOrder",
1678
1772
  value: function () {
1679
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(identity) {
1773
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(identity) {
1680
1774
  var products;
1681
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1682
- while (1) switch (_context21.prev = _context21.next) {
1775
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1776
+ while (1) switch (_context22.prev = _context22.next) {
1683
1777
  case 0:
1684
1778
  this.logMethodStart('removeProductFromOrder', {
1685
1779
  product_id: identity.product_id,
1686
1780
  product_variant_id: identity.product_variant_id
1687
1781
  });
1688
- _context21.prev = 1;
1782
+ _context22.prev = 1;
1689
1783
  if (this.store.order) {
1690
- _context21.next = 4;
1784
+ _context22.next = 4;
1691
1785
  break;
1692
1786
  }
1693
1787
  throw new Error('order 模块未初始化');
1694
1788
  case 4:
1695
- _context21.next = 6;
1789
+ _context22.next = 6;
1696
1790
  return this.store.order.removeProductFromOrder(identity);
1697
1791
  case 6:
1698
- products = _context21.sent;
1699
- _context21.next = 9;
1792
+ products = _context22.sent;
1793
+ _context22.next = 9;
1700
1794
  return this.refreshItemRuleQuantityLimits();
1701
1795
  case 9:
1702
- _context21.next = 11;
1796
+ _context22.next = 11;
1703
1797
  return this.refreshCartValidationPassed();
1704
1798
  case 11:
1705
1799
  this.logMethodSuccess('removeProductFromOrder', {
1706
1800
  productCount: products.length
1707
1801
  });
1708
- return _context21.abrupt("return", products);
1802
+ return _context22.abrupt("return", products);
1709
1803
  case 15:
1710
- _context21.prev = 15;
1711
- _context21.t0 = _context21["catch"](1);
1712
- this.logMethodError('removeProductFromOrder', _context21.t0);
1713
- throw _context21.t0;
1804
+ _context22.prev = 15;
1805
+ _context22.t0 = _context22["catch"](1);
1806
+ this.logMethodError('removeProductFromOrder', _context22.t0);
1807
+ throw _context22.t0;
1714
1808
  case 19:
1715
1809
  case "end":
1716
- return _context21.stop();
1810
+ return _context22.stop();
1717
1811
  }
1718
- }, _callee21, this, [[1, 15]]);
1812
+ }, _callee22, this, [[1, 15]]);
1719
1813
  }));
1720
- function removeProductFromOrder(_x14) {
1814
+ function removeProductFromOrder(_x16) {
1721
1815
  return _removeProductFromOrder.apply(this, arguments);
1722
1816
  }
1723
1817
  return removeProductFromOrder;
@@ -1725,26 +1819,26 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1725
1819
  }, {
1726
1820
  key: "loadRuntimeConfigs",
1727
1821
  value: function () {
1728
- var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1822
+ var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1729
1823
  var itemRuleConfigs;
1730
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1731
- while (1) switch (_context22.prev = _context22.next) {
1824
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1825
+ while (1) switch (_context23.prev = _context23.next) {
1732
1826
  case 0:
1733
- _context22.next = 2;
1827
+ _context23.next = 2;
1734
1828
  return this.ensureItemRuleConfigsLoaded();
1735
1829
  case 2:
1736
- itemRuleConfigs = _context22.sent;
1830
+ itemRuleConfigs = _context23.sent;
1737
1831
  this.logMethodSuccess('loadRuntimeConfigs', {
1738
1832
  itemRuleCount: itemRuleConfigs.length
1739
1833
  });
1740
- return _context22.abrupt("return", {
1834
+ return _context23.abrupt("return", {
1741
1835
  itemRuleConfigs: itemRuleConfigs
1742
1836
  });
1743
1837
  case 5:
1744
1838
  case "end":
1745
- return _context22.stop();
1839
+ return _context23.stop();
1746
1840
  }
1747
- }, _callee22, this);
1841
+ }, _callee23, this);
1748
1842
  }));
1749
1843
  function loadRuntimeConfigs() {
1750
1844
  return _loadRuntimeConfigs.apply(this, arguments);
@@ -1754,15 +1848,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1754
1848
  }, {
1755
1849
  key: "syncItemRuleConfigsFromDineInConfig",
1756
1850
  value: function () {
1757
- var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(dineInConfig) {
1851
+ var _syncItemRuleConfigsFromDineInConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(dineInConfig) {
1758
1852
  var enableItemRules, strategyModelIds, itemRuleConfigs;
1759
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1760
- while (1) switch (_context23.prev = _context23.next) {
1853
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1854
+ while (1) switch (_context24.prev = _context24.next) {
1761
1855
  case 0:
1762
1856
  enableItemRules = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enable_item_rules']);
1763
1857
  strategyModelIds = normalizeEnabledItemRuleIds(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.enabled_item_rules']);
1764
1858
  if (!(!enableItemRules || !strategyModelIds.length)) {
1765
- _context23.next = 8;
1859
+ _context24.next = 8;
1766
1860
  break;
1767
1861
  }
1768
1862
  this.itemRuleConfigs = [];
@@ -1773,12 +1867,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1773
1867
  strategyModelIds: [],
1774
1868
  itemRuleCount: 0
1775
1869
  });
1776
- return _context23.abrupt("return", []);
1870
+ return _context24.abrupt("return", []);
1777
1871
  case 8:
1778
- _context23.next = 10;
1872
+ _context24.next = 10;
1779
1873
  return this.fetchItemRuleConfigsByModelIds(strategyModelIds);
1780
1874
  case 10:
1781
- itemRuleConfigs = _context23.sent;
1875
+ itemRuleConfigs = _context24.sent;
1782
1876
  this.itemRuleConfigs = itemRuleConfigs;
1783
1877
  this.itemRuleConfigsPromise = Promise.resolve(itemRuleConfigs);
1784
1878
  this.itemRuleEvaluator.setStrategyConfigs(itemRuleConfigs);
@@ -1787,14 +1881,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1787
1881
  strategyModelIds: strategyModelIds,
1788
1882
  itemRuleCount: itemRuleConfigs.length
1789
1883
  });
1790
- return _context23.abrupt("return", itemRuleConfigs);
1884
+ return _context24.abrupt("return", itemRuleConfigs);
1791
1885
  case 16:
1792
1886
  case "end":
1793
- return _context23.stop();
1887
+ return _context24.stop();
1794
1888
  }
1795
- }, _callee23, this);
1889
+ }, _callee24, this);
1796
1890
  }));
1797
- function syncItemRuleConfigsFromDineInConfig(_x15) {
1891
+ function syncItemRuleConfigsFromDineInConfig(_x17) {
1798
1892
  return _syncItemRuleConfigsFromDineInConfig.apply(this, arguments);
1799
1893
  }
1800
1894
  return syncItemRuleConfigsFromDineInConfig;
@@ -1802,22 +1896,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1802
1896
  }, {
1803
1897
  key: "fetchItemRuleConfigsByModelIds",
1804
1898
  value: function () {
1805
- var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(strategyModelIds) {
1899
+ var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(strategyModelIds) {
1806
1900
  var result, configs;
1807
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1808
- while (1) switch (_context24.prev = _context24.next) {
1901
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1902
+ while (1) switch (_context25.prev = _context25.next) {
1809
1903
  case 0:
1810
1904
  this.logMethodStart('fetchItemRuleConfigsByModelIds', {
1811
1905
  strategyModelIds: strategyModelIds
1812
1906
  });
1813
1907
  if (strategyModelIds.length) {
1814
- _context24.next = 3;
1908
+ _context25.next = 3;
1815
1909
  break;
1816
1910
  }
1817
- return _context24.abrupt("return", []);
1911
+ return _context25.abrupt("return", []);
1818
1912
  case 3:
1819
- _context24.prev = 3;
1820
- _context24.next = 6;
1913
+ _context25.prev = 3;
1914
+ _context25.next = 6;
1821
1915
  return this.request.get('/promotion', {
1822
1916
  skip: 1,
1823
1917
  num: 99,
@@ -1825,7 +1919,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1825
1919
  ids: strategyModelIds
1826
1920
  });
1827
1921
  case 6:
1828
- result = _context24.sent;
1922
+ result = _context25.sent;
1829
1923
  configs = [];
1830
1924
  if (result.code === 200) {
1831
1925
  configs = result.data.list.map(function (item) {
@@ -1836,22 +1930,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1836
1930
  strategyModelIds: strategyModelIds,
1837
1931
  strategyCount: configs.length
1838
1932
  });
1839
- return _context24.abrupt("return", configs);
1933
+ return _context25.abrupt("return", configs);
1840
1934
  case 13:
1841
- _context24.prev = 13;
1842
- _context24.t0 = _context24["catch"](3);
1843
- this.logMethodError('fetchItemRuleConfigsByModelIds', _context24.t0, {
1935
+ _context25.prev = 13;
1936
+ _context25.t0 = _context25["catch"](3);
1937
+ this.logMethodError('fetchItemRuleConfigsByModelIds', _context25.t0, {
1844
1938
  strategyModelIds: strategyModelIds
1845
1939
  });
1846
1940
  // A:策略加载失败时不阻塞下单
1847
- return _context24.abrupt("return", []);
1941
+ return _context25.abrupt("return", []);
1848
1942
  case 17:
1849
1943
  case "end":
1850
- return _context24.stop();
1944
+ return _context25.stop();
1851
1945
  }
1852
- }, _callee24, this, [[3, 13]]);
1946
+ }, _callee25, this, [[3, 13]]);
1853
1947
  }));
1854
- function fetchItemRuleConfigsByModelIds(_x16) {
1948
+ function fetchItemRuleConfigsByModelIds(_x18) {
1855
1949
  return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
1856
1950
  }
1857
1951
  return fetchItemRuleConfigsByModelIds;
@@ -1859,22 +1953,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1859
1953
  }, {
1860
1954
  key: "buildPrefillProductSourceMap",
1861
1955
  value: function () {
1862
- var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1956
+ var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1863
1957
  var sourceMap, productList, visited, collectFromValue;
1864
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1865
- while (1) switch (_context25.prev = _context25.next) {
1958
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1959
+ while (1) switch (_context26.prev = _context26.next) {
1866
1960
  case 0:
1867
1961
  sourceMap = new Map();
1868
- _context25.prev = 1;
1869
- _context25.next = 4;
1962
+ _context26.prev = 1;
1963
+ _context26.next = 4;
1870
1964
  return this.getProductList();
1871
1965
  case 4:
1872
- productList = _context25.sent;
1966
+ productList = _context26.sent;
1873
1967
  if (Array.isArray(productList)) {
1874
- _context25.next = 7;
1968
+ _context26.next = 7;
1875
1969
  break;
1876
1970
  }
1877
- return _context25.abrupt("return", sourceMap);
1971
+ return _context26.abrupt("return", sourceMap);
1878
1972
  case 7:
1879
1973
  visited = new Set();
1880
1974
  collectFromValue = function collectFromValue(value) {
@@ -1909,27 +2003,27 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1909
2003
  sourceMap.set(key, node);
1910
2004
  }
1911
2005
  }
1912
- for (var _i4 = 0, _Object$values = Object.values(node); _i4 < _Object$values.length; _i4++) {
1913
- var childValue = _Object$values[_i4];
2006
+ for (var _i3 = 0, _Object$values = Object.values(node); _i3 < _Object$values.length; _i3++) {
2007
+ var childValue = _Object$values[_i3];
1914
2008
  if (childValue && _typeof(childValue) === 'object') {
1915
2009
  collectFromValue(childValue);
1916
2010
  }
1917
2011
  }
1918
2012
  };
1919
2013
  collectFromValue(productList);
1920
- _context25.next = 15;
2014
+ _context26.next = 15;
1921
2015
  break;
1922
2016
  case 12:
1923
- _context25.prev = 12;
1924
- _context25.t0 = _context25["catch"](1);
1925
- this.logMethodError('buildPrefillProductSourceMap', _context25.t0);
2017
+ _context26.prev = 12;
2018
+ _context26.t0 = _context26["catch"](1);
2019
+ this.logMethodError('buildPrefillProductSourceMap', _context26.t0);
1926
2020
  case 15:
1927
- return _context25.abrupt("return", sourceMap);
2021
+ return _context26.abrupt("return", sourceMap);
1928
2022
  case 16:
1929
2023
  case "end":
1930
- return _context25.stop();
2024
+ return _context26.stop();
1931
2025
  }
1932
- }, _callee25, this, [[1, 12]]);
2026
+ }, _callee26, this, [[1, 12]]);
1933
2027
  }));
1934
2028
  function buildPrefillProductSourceMap() {
1935
2029
  return _buildPrefillProductSourceMap.apply(this, arguments);
@@ -1944,58 +2038,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1944
2038
  }, {
1945
2039
  key: "ensureItemRuleConfigsLoaded",
1946
2040
  value: function () {
1947
- var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2041
+ var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
1948
2042
  var _this6 = this;
1949
2043
  var loadedConfigs;
1950
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1951
- while (1) switch (_context27.prev = _context27.next) {
2044
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2045
+ while (1) switch (_context28.prev = _context28.next) {
1952
2046
  case 0:
1953
2047
  if (!(this.itemRuleConfigs.length > 0)) {
1954
- _context27.next = 2;
2048
+ _context28.next = 2;
1955
2049
  break;
1956
2050
  }
1957
- return _context27.abrupt("return", this.itemRuleConfigs);
2051
+ return _context28.abrupt("return", this.itemRuleConfigs);
1958
2052
  case 2:
1959
2053
  if (!this.itemRuleConfigsPromise) {
1960
- _context27.next = 4;
2054
+ _context28.next = 4;
1961
2055
  break;
1962
2056
  }
1963
- return _context27.abrupt("return", this.itemRuleConfigsPromise);
2057
+ return _context28.abrupt("return", this.itemRuleConfigsPromise);
1964
2058
  case 4:
1965
- this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2059
+ this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1966
2060
  var runtimeConfig, staticConfigs;
1967
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1968
- while (1) switch (_context26.prev = _context26.next) {
2061
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2062
+ while (1) switch (_context27.prev = _context27.next) {
1969
2063
  case 0:
1970
2064
  runtimeConfig = _this6.getItemRuleRuntimeConfig();
1971
2065
  staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
1972
2066
  if (!(staticConfigs.length > 0)) {
1973
- _context26.next = 6;
2067
+ _context27.next = 6;
1974
2068
  break;
1975
2069
  }
1976
2070
  _this6.itemRuleConfigs = staticConfigs;
1977
2071
  _this6.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
1978
- return _context26.abrupt("return", _this6.itemRuleConfigs);
2072
+ return _context27.abrupt("return", _this6.itemRuleConfigs);
1979
2073
  case 6:
1980
2074
  _this6.itemRuleConfigs = [];
1981
2075
  _this6.itemRuleEvaluator.setStrategyConfigs([]);
1982
- return _context26.abrupt("return", _this6.itemRuleConfigs);
2076
+ return _context27.abrupt("return", _this6.itemRuleConfigs);
1983
2077
  case 9:
1984
2078
  case "end":
1985
- return _context26.stop();
2079
+ return _context27.stop();
1986
2080
  }
1987
- }, _callee26);
2081
+ }, _callee27);
1988
2082
  }))();
1989
- _context27.next = 7;
2083
+ _context28.next = 7;
1990
2084
  return this.itemRuleConfigsPromise;
1991
2085
  case 7:
1992
- loadedConfigs = _context27.sent;
1993
- return _context27.abrupt("return", loadedConfigs);
2086
+ loadedConfigs = _context28.sent;
2087
+ return _context28.abrupt("return", loadedConfigs);
1994
2088
  case 9:
1995
2089
  case "end":
1996
- return _context27.stop();
2090
+ return _context28.stop();
1997
2091
  }
1998
- }, _callee27, this);
2092
+ }, _callee28, this);
1999
2093
  }));
2000
2094
  function ensureItemRuleConfigsLoaded() {
2001
2095
  return _ensureItemRuleConfigsLoaded.apply(this, arguments);
@@ -2005,25 +2099,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2005
2099
  }, {
2006
2100
  key: "refreshItemRuleQuantityLimits",
2007
2101
  value: function () {
2008
- var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2102
+ var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2009
2103
  var strategyConfigs, businessData, limits;
2010
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2011
- while (1) switch (_context28.prev = _context28.next) {
2104
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2105
+ while (1) switch (_context29.prev = _context29.next) {
2012
2106
  case 0:
2013
- _context28.prev = 0;
2014
- _context28.next = 3;
2107
+ _context29.prev = 0;
2108
+ _context29.next = 3;
2015
2109
  return this.ensureItemRuleConfigsLoaded();
2016
2110
  case 3:
2017
- strategyConfigs = _context28.sent;
2111
+ strategyConfigs = _context29.sent;
2018
2112
  if (strategyConfigs.length) {
2019
- _context28.next = 7;
2113
+ _context29.next = 7;
2020
2114
  break;
2021
2115
  }
2022
2116
  this.store.itemRuleQuantityLimits = [];
2023
- return _context28.abrupt("return", []);
2117
+ return _context29.abrupt("return", []);
2024
2118
  case 7:
2025
2119
  businessData = buildItemRuleBusinessData({
2026
- tempOrder: this.ensureTempOrder(),
2120
+ tempOrder: this.ensureScanOrderTempOrder(),
2027
2121
  runtimeConfig: this.getItemRuleRuntimeConfig(),
2028
2122
  itemRuleConfigs: this.itemRuleConfigs
2029
2123
  });
@@ -2032,18 +2126,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2032
2126
  this.logMethodSuccess('refreshItemRuleQuantityLimits', {
2033
2127
  limitCount: limits.length
2034
2128
  });
2035
- return _context28.abrupt("return", limits);
2129
+ return _context29.abrupt("return", limits);
2036
2130
  case 14:
2037
- _context28.prev = 14;
2038
- _context28.t0 = _context28["catch"](0);
2131
+ _context29.prev = 14;
2132
+ _context29.t0 = _context29["catch"](0);
2039
2133
  this.store.itemRuleQuantityLimits = [];
2040
- this.logMethodError('refreshItemRuleQuantityLimits', _context28.t0);
2041
- return _context28.abrupt("return", []);
2134
+ this.logMethodError('refreshItemRuleQuantityLimits', _context29.t0);
2135
+ return _context29.abrupt("return", []);
2042
2136
  case 19:
2043
2137
  case "end":
2044
- return _context28.stop();
2138
+ return _context29.stop();
2045
2139
  }
2046
- }, _callee28, this, [[0, 14]]);
2140
+ }, _callee29, this, [[0, 14]]);
2047
2141
  }));
2048
2142
  function refreshItemRuleQuantityLimits() {
2049
2143
  return _refreshItemRuleQuantityLimits.apply(this, arguments);
@@ -2053,58 +2147,58 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2053
2147
  }, {
2054
2148
  key: "applyPrefillByItemRule",
2055
2149
  value: function () {
2056
- var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2150
+ var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2057
2151
  var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator6, _step6, _prefillItem$product_, _origin2, _origin3, _origin4, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct, hasQuantityChanged, hasOriginChanged;
2058
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2059
- while (1) switch (_context29.prev = _context29.next) {
2152
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2153
+ while (1) switch (_context30.prev = _context30.next) {
2060
2154
  case 0:
2061
2155
  if (!this.itemRulePrefillApplied) {
2062
- _context29.next = 2;
2156
+ _context30.next = 2;
2063
2157
  break;
2064
2158
  }
2065
- return _context29.abrupt("return");
2159
+ return _context30.abrupt("return");
2066
2160
  case 2:
2067
2161
  if (this.store.order) {
2068
- _context29.next = 4;
2162
+ _context30.next = 4;
2069
2163
  break;
2070
2164
  }
2071
- return _context29.abrupt("return");
2165
+ return _context30.abrupt("return");
2072
2166
  case 4:
2073
- _context29.next = 6;
2167
+ _context30.next = 6;
2074
2168
  return this.ensureItemRuleConfigsLoaded();
2075
2169
  case 6:
2076
- strategyConfigs = _context29.sent;
2170
+ strategyConfigs = _context30.sent;
2077
2171
  if (strategyConfigs.length) {
2078
- _context29.next = 9;
2172
+ _context30.next = 9;
2079
2173
  break;
2080
2174
  }
2081
- return _context29.abrupt("return");
2175
+ return _context30.abrupt("return");
2082
2176
  case 9:
2083
2177
  businessData = buildItemRuleBusinessData({
2084
- tempOrder: this.ensureTempOrder(),
2178
+ tempOrder: this.ensureScanOrderTempOrder(),
2085
2179
  runtimeConfig: this.getItemRuleRuntimeConfig(),
2086
2180
  itemRuleConfigs: this.itemRuleConfigs
2087
2181
  });
2088
2182
  prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
2089
2183
  if (prefillItems.length) {
2090
- _context29.next = 14;
2184
+ _context30.next = 14;
2091
2185
  break;
2092
2186
  }
2093
2187
  this.itemRulePrefillApplied = true;
2094
- return _context29.abrupt("return");
2188
+ return _context30.abrupt("return");
2095
2189
  case 14:
2096
- _context29.next = 16;
2190
+ _context30.next = 16;
2097
2191
  return this.buildPrefillProductSourceMap();
2098
2192
  case 16:
2099
- productSourceMap = _context29.sent;
2100
- tempOrder = this.ensureTempOrder();
2193
+ productSourceMap = _context30.sent;
2194
+ tempOrder = this.ensureScanOrderTempOrder();
2101
2195
  hasChanges = false;
2102
2196
  _iterator6 = _createForOfIteratorHelper(prefillItems);
2103
- _context29.prev = 20;
2197
+ _context30.prev = 20;
2104
2198
  _iterator6.s();
2105
2199
  case 22:
2106
2200
  if ((_step6 = _iterator6.n()).done) {
2107
- _context29.next = 47;
2201
+ _context30.next = 47;
2108
2202
  break;
2109
2203
  }
2110
2204
  prefillItem = _step6.value;
@@ -2112,16 +2206,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2112
2206
  productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
2113
2207
  targetQuantity = toNonNegativeInt(prefillItem.quantity);
2114
2208
  if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
2115
- _context29.next = 29;
2209
+ _context30.next = 29;
2116
2210
  break;
2117
2211
  }
2118
- return _context29.abrupt("continue", 45);
2212
+ return _context30.abrupt("continue", 45);
2119
2213
  case 29:
2120
2214
  if (!Number.isNaN(productVariantId)) {
2121
- _context29.next = 31;
2215
+ _context30.next = 31;
2122
2216
  break;
2123
2217
  }
2124
- return _context29.abrupt("continue", 45);
2218
+ return _context30.abrupt("continue", 45);
2125
2219
  case 31:
2126
2220
  sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
2127
2221
  productIndex = getProductIdentityIndex(tempOrder.products, {
@@ -2129,7 +2223,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2129
2223
  product_variant_id: productVariantId
2130
2224
  });
2131
2225
  if (!(productIndex === -1)) {
2132
- _context29.next = 38;
2226
+ _context30.next = 38;
2133
2227
  break;
2134
2228
  }
2135
2229
  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');
@@ -2149,7 +2243,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2149
2243
  })
2150
2244
  })));
2151
2245
  hasChanges = true;
2152
- return _context29.abrupt("continue", 45);
2246
+ return _context30.abrupt("continue", 45);
2153
2247
  case 38:
2154
2248
  targetProduct = tempOrder.products[productIndex];
2155
2249
  existedQuantity = toNonNegativeInt(targetProduct.num);
@@ -2170,34 +2264,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2170
2264
  hasChanges = true;
2171
2265
  }
2172
2266
  case 45:
2173
- _context29.next = 22;
2267
+ _context30.next = 22;
2174
2268
  break;
2175
2269
  case 47:
2176
- _context29.next = 52;
2270
+ _context30.next = 52;
2177
2271
  break;
2178
2272
  case 49:
2179
- _context29.prev = 49;
2180
- _context29.t0 = _context29["catch"](20);
2181
- _iterator6.e(_context29.t0);
2273
+ _context30.prev = 49;
2274
+ _context30.t0 = _context30["catch"](20);
2275
+ _iterator6.e(_context30.t0);
2182
2276
  case 52:
2183
- _context29.prev = 52;
2277
+ _context30.prev = 52;
2184
2278
  _iterator6.f();
2185
- return _context29.finish(52);
2279
+ return _context30.finish(52);
2186
2280
  case 55:
2187
2281
  if (!hasChanges) {
2188
- _context29.next = 60;
2282
+ _context30.next = 60;
2189
2283
  break;
2190
2284
  }
2191
2285
  // Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
2192
2286
  this.store.order.applyDiscount();
2193
- _context29.next = 59;
2287
+ _context30.next = 59;
2194
2288
  return this.store.order.recalculateSummary({
2195
2289
  createIfMissing: true
2196
2290
  });
2197
2291
  case 59:
2198
2292
  this.store.order.persistTempOrder();
2199
2293
  case 60:
2200
- _context29.next = 62;
2294
+ _context30.next = 62;
2201
2295
  return this.refreshItemRuleQuantityLimits();
2202
2296
  case 62:
2203
2297
  this.itemRulePrefillApplied = true;
@@ -2207,9 +2301,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2207
2301
  });
2208
2302
  case 64:
2209
2303
  case "end":
2210
- return _context29.stop();
2304
+ return _context30.stop();
2211
2305
  }
2212
- }, _callee29, this, [[20, 49, 52, 55]]);
2306
+ }, _callee30, this, [[20, 49, 52, 55]]);
2213
2307
  }));
2214
2308
  function applyPrefillByItemRule() {
2215
2309
  return _applyPrefillByItemRule.apply(this, arguments);
@@ -2219,31 +2313,31 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2219
2313
  }, {
2220
2314
  key: "applyItemRulePrefill",
2221
2315
  value: function () {
2222
- var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2223
- var _this$store$order4, _this$store$order4$ge;
2224
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2225
- while (1) switch (_context30.prev = _context30.next) {
2316
+ var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2317
+ var _this$store$order5, _this$store$order5$ge;
2318
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2319
+ while (1) switch (_context31.prev = _context31.next) {
2226
2320
  case 0:
2227
- 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))) {
2228
- _context30.next = 2;
2321
+ if (!((_this$store$order5 = this.store.order) !== null && _this$store$order5 !== void 0 && (_this$store$order5$ge = _this$store$order5.getLastOrderInfo) !== null && _this$store$order5$ge !== void 0 && _this$store$order5$ge.call(_this$store$order5))) {
2322
+ _context31.next = 2;
2229
2323
  break;
2230
2324
  }
2231
- return _context30.abrupt("return");
2325
+ return _context31.abrupt("return");
2232
2326
  case 2:
2233
2327
  this.logMethodStart('applyItemRulePrefill');
2234
- _context30.next = 5;
2328
+ _context31.next = 5;
2235
2329
  return this.applyPrefillByItemRule();
2236
2330
  case 5:
2237
- _context30.next = 7;
2331
+ _context31.next = 7;
2238
2332
  return this.refreshItemRuleQuantityLimits();
2239
2333
  case 7:
2240
- _context30.next = 9;
2334
+ _context31.next = 9;
2241
2335
  return this.refreshCartValidationPassed();
2242
2336
  case 9:
2243
2337
  case "end":
2244
- return _context30.stop();
2338
+ return _context31.stop();
2245
2339
  }
2246
- }, _callee30, this);
2340
+ }, _callee31, this);
2247
2341
  }));
2248
2342
  function applyItemRulePrefill() {
2249
2343
  return _applyItemRulePrefill.apply(this, arguments);
@@ -2253,35 +2347,35 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2253
2347
  }, {
2254
2348
  key: "evaluateCartValidationByItemRule",
2255
2349
  value: function () {
2256
- var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2350
+ var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2257
2351
  var strategyConfigs, businessData;
2258
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2259
- while (1) switch (_context31.prev = _context31.next) {
2352
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2353
+ while (1) switch (_context32.prev = _context32.next) {
2260
2354
  case 0:
2261
- _context31.next = 2;
2355
+ _context32.next = 2;
2262
2356
  return this.ensureItemRuleConfigsLoaded();
2263
2357
  case 2:
2264
- strategyConfigs = _context31.sent;
2358
+ strategyConfigs = _context32.sent;
2265
2359
  if (strategyConfigs.length) {
2266
- _context31.next = 5;
2360
+ _context32.next = 5;
2267
2361
  break;
2268
2362
  }
2269
- return _context31.abrupt("return", {
2363
+ return _context32.abrupt("return", {
2270
2364
  passed: true,
2271
2365
  failures: []
2272
2366
  });
2273
2367
  case 5:
2274
2368
  businessData = buildItemRuleBusinessData({
2275
- tempOrder: this.ensureTempOrder(),
2369
+ tempOrder: this.ensureScanOrderTempOrder(),
2276
2370
  runtimeConfig: this.getItemRuleRuntimeConfig(),
2277
2371
  itemRuleConfigs: this.itemRuleConfigs
2278
2372
  });
2279
- return _context31.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
2373
+ return _context32.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
2280
2374
  case 7:
2281
2375
  case "end":
2282
- return _context31.stop();
2376
+ return _context32.stop();
2283
2377
  }
2284
- }, _callee31, this);
2378
+ }, _callee32, this);
2285
2379
  }));
2286
2380
  function evaluateCartValidationByItemRule() {
2287
2381
  return _evaluateCartValidationByItemRule.apply(this, arguments);
@@ -2291,20 +2385,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2291
2385
  }, {
2292
2386
  key: "validateBeforeSubmitByItemRule",
2293
2387
  value: function () {
2294
- var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2388
+ var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2295
2389
  var validationResult, firstFailure, errorMessage, error;
2296
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2297
- while (1) switch (_context32.prev = _context32.next) {
2390
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2391
+ while (1) switch (_context33.prev = _context33.next) {
2298
2392
  case 0:
2299
- _context32.next = 2;
2393
+ _context33.next = 2;
2300
2394
  return this.evaluateCartValidationByItemRule();
2301
2395
  case 2:
2302
- validationResult = _context32.sent;
2396
+ validationResult = _context33.sent;
2303
2397
  if (!validationResult.passed) {
2304
- _context32.next = 5;
2398
+ _context33.next = 5;
2305
2399
  break;
2306
2400
  }
2307
- return _context32.abrupt("return");
2401
+ return _context33.abrupt("return");
2308
2402
  case 5:
2309
2403
  firstFailure = validationResult.failures[0];
2310
2404
  errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
@@ -2313,9 +2407,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2313
2407
  throw error;
2314
2408
  case 10:
2315
2409
  case "end":
2316
- return _context32.stop();
2410
+ return _context33.stop();
2317
2411
  }
2318
- }, _callee32, this);
2412
+ }, _callee33, this);
2319
2413
  }));
2320
2414
  function validateBeforeSubmitByItemRule() {
2321
2415
  return _validateBeforeSubmitByItemRule.apply(this, arguments);
@@ -2325,10 +2419,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2325
2419
  }, {
2326
2420
  key: "refreshCartValidationPassed",
2327
2421
  value: function () {
2328
- var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2422
+ var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2329
2423
  var previous, nextState, validationResult, changed;
2330
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2331
- while (1) switch (_context33.prev = _context33.next) {
2424
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2425
+ while (1) switch (_context34.prev = _context34.next) {
2332
2426
  case 0:
2333
2427
  previous = this.store.cartValidation || {
2334
2428
  passed: null,
@@ -2338,20 +2432,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2338
2432
  passed: null,
2339
2433
  failures: []
2340
2434
  };
2341
- _context33.prev = 2;
2342
- _context33.next = 5;
2435
+ _context34.prev = 2;
2436
+ _context34.next = 5;
2343
2437
  return this.evaluateCartValidationByItemRule();
2344
2438
  case 5:
2345
- validationResult = _context33.sent;
2439
+ validationResult = _context34.sent;
2346
2440
  nextState = {
2347
2441
  passed: validationResult.passed,
2348
2442
  failures: validationResult.failures || []
2349
2443
  };
2350
- _context33.next = 12;
2444
+ _context34.next = 12;
2351
2445
  break;
2352
2446
  case 9:
2353
- _context33.prev = 9;
2354
- _context33.t0 = _context33["catch"](2);
2447
+ _context34.prev = 9;
2448
+ _context34.t0 = _context34["catch"](2);
2355
2449
  nextState = {
2356
2450
  passed: false,
2357
2451
  failures: []
@@ -2360,21 +2454,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2360
2454
  this.store.cartValidation = nextState;
2361
2455
  changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
2362
2456
  if (!changed) {
2363
- _context33.next = 17;
2457
+ _context34.next = 17;
2364
2458
  break;
2365
2459
  }
2366
- _context33.next = 17;
2460
+ _context34.next = 17;
2367
2461
  return this.core.effects.emit(ScanOrderHooks.onCartValidationChanged, {
2368
2462
  cartValidation: nextState,
2369
2463
  cartValidationPassed: nextState.passed
2370
2464
  });
2371
2465
  case 17:
2372
- return _context33.abrupt("return", nextState.passed);
2466
+ return _context34.abrupt("return", nextState.passed);
2373
2467
  case 18:
2374
2468
  case "end":
2375
- return _context33.stop();
2469
+ return _context34.stop();
2376
2470
  }
2377
- }, _callee33, this, [[2, 9]]);
2471
+ }, _callee34, this, [[2, 9]]);
2378
2472
  }));
2379
2473
  function refreshCartValidationPassed() {
2380
2474
  return _refreshCartValidationPassed.apply(this, arguments);
@@ -2384,14 +2478,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2384
2478
  }, {
2385
2479
  key: "setItemRuleRuntimeConfig",
2386
2480
  value: function () {
2387
- var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2481
+ var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2388
2482
  var _this$itemRuleRuntime, _this$itemRuleRuntime2;
2389
2483
  var config,
2390
- _args34 = arguments;
2391
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2392
- while (1) switch (_context34.prev = _context34.next) {
2484
+ _args35 = arguments;
2485
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2486
+ while (1) switch (_context35.prev = _context35.next) {
2393
2487
  case 0:
2394
- config = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
2488
+ config = _args35.length > 0 && _args35[0] !== undefined ? _args35[0] : {};
2395
2489
  this.logMethodStart('setItemRuleRuntimeConfig');
2396
2490
  this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
2397
2491
  pax: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime === void 0 ? void 0 : _this$itemRuleRuntime.pax) || {}), (config === null || config === void 0 ? void 0 : config.pax) || {}),
@@ -2403,10 +2497,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2403
2497
  this.itemRuleEvaluator.setStrategyConfigs([]);
2404
2498
  }
2405
2499
  this.itemRulePrefillApplied = false;
2406
- _context34.next = 7;
2500
+ _context35.next = 7;
2407
2501
  return this.refreshItemRuleQuantityLimits();
2408
2502
  case 7:
2409
- _context34.next = 9;
2503
+ _context35.next = 9;
2410
2504
  return this.refreshCartValidationPassed();
2411
2505
  case 9:
2412
2506
  this.logMethodSuccess('setItemRuleRuntimeConfig', {
@@ -2414,9 +2508,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2414
2508
  });
2415
2509
  case 10:
2416
2510
  case "end":
2417
- return _context34.stop();
2511
+ return _context35.stop();
2418
2512
  }
2419
- }, _callee34, this);
2513
+ }, _callee35, this);
2420
2514
  }));
2421
2515
  function setItemRuleRuntimeConfig() {
2422
2516
  return _setItemRuleRuntimeConfig.apply(this, arguments);
@@ -2426,14 +2520,14 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2426
2520
  }, {
2427
2521
  key: "normalizeResourceState",
2428
2522
  value: function normalizeResourceState(detail, resourceSelectType, hasOrderId) {
2429
- var _detail$form_record, _this$otherParams8, _detail$resource_capa, _detail$resource_capa2;
2523
+ var _detail$form_record, _this$otherParams13, _detail$resource_capa, _detail$resource_capa2;
2430
2524
  var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
2431
2525
  var lastOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.last_order_id);
2432
2526
  var relationId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_record_id);
2433
2527
  var tableFormId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.form_id);
2434
2528
  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;
2435
2529
  // 是否允许加餐
2436
- 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['sale.allow_add_items']) || false;
2530
+ var allowSnack = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['sale.allow_add_items']) || false;
2437
2531
  // 开启同桌验证 - 本期没有这个配置,默认关掉
2438
2532
  var deskmateValid = false;
2439
2533
  var isExclusive = resourceSelectType === 'single';
@@ -2513,29 +2607,29 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2513
2607
  return matched === null || matched === void 0 ? void 0 : matched.type;
2514
2608
  }
2515
2609
  }, {
2516
- key: "fetchResourceOccupyDetailByResourceId",
2610
+ key: "fetchResourceOccupyDetailsByResourceId",
2517
2611
  value: function () {
2518
- var _fetchResourceOccupyDetailByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(resourceId) {
2519
- var _this$otherParams9, _this$otherParams9$ge, _response$data$occupy, _response$data;
2612
+ var _fetchResourceOccupyDetailsByResourceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId) {
2613
+ var _this$otherParams14, _this$otherParams14$g, _response$data$occupy, _response$data;
2520
2614
  var formRecordId, shopId, response;
2521
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2522
- while (1) switch (_context35.prev = _context35.next) {
2615
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2616
+ while (1) switch (_context36.prev = _context36.next) {
2523
2617
  case 0:
2524
2618
  formRecordId = Number(resourceId);
2525
2619
  if (!(!Number.isFinite(formRecordId) || formRecordId <= 0)) {
2526
- _context35.next = 3;
2620
+ _context36.next = 3;
2527
2621
  break;
2528
2622
  }
2529
2623
  throw new Error("[ScanOrder] \u975E\u6CD5\u684C\u53F0 resourceId: ".concat(resourceId));
2530
2624
  case 3:
2531
- shopId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9$ge = _this$otherParams9.getStateData) === null || _this$otherParams9$ge === void 0 ? void 0 : _this$otherParams9$ge.call(_this$otherParams9, 'shop_id');
2625
+ shopId = (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 || (_this$otherParams14$g = _this$otherParams14.getStateData) === null || _this$otherParams14$g === void 0 ? void 0 : _this$otherParams14$g.call(_this$otherParams14, 'shop_id');
2532
2626
  if (shopId) {
2533
- _context35.next = 6;
2627
+ _context36.next = 6;
2534
2628
  break;
2535
2629
  }
2536
2630
  throw new Error('[ScanOrder] 无法获取 shop_id');
2537
2631
  case 6:
2538
- _context35.next = 8;
2632
+ _context36.next = 8;
2539
2633
  return this.request.get('/order/resource/occupy-detail', {
2540
2634
  shop_id: shopId,
2541
2635
  'form_record_ids[]': formRecordId,
@@ -2544,61 +2638,175 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2544
2638
  with_resource_form_info: 1
2545
2639
  });
2546
2640
  case 8:
2547
- response = _context35.sent;
2641
+ response = _context36.sent;
2548
2642
  if (response !== null && response !== void 0 && response.status) {
2549
- _context35.next = 11;
2643
+ _context36.next = 11;
2550
2644
  break;
2551
2645
  }
2552
2646
  throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取资源占用详情失败');
2553
2647
  case 11:
2554
- return _context35.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);
2648
+ 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 : []);
2555
2649
  case 12:
2556
2650
  case "end":
2557
- return _context35.stop();
2651
+ return _context36.stop();
2558
2652
  }
2559
- }, _callee35, this);
2653
+ }, _callee36, this);
2560
2654
  }));
2561
- function fetchResourceOccupyDetailByResourceId(_x17) {
2562
- return _fetchResourceOccupyDetailByResourceId.apply(this, arguments);
2655
+ function fetchResourceOccupyDetailsByResourceId(_x19) {
2656
+ return _fetchResourceOccupyDetailsByResourceId.apply(this, arguments);
2657
+ }
2658
+ return fetchResourceOccupyDetailsByResourceId;
2659
+ }()
2660
+ }, {
2661
+ key: "resolveAdditionalOrderFromOccupyDetail",
2662
+ value: function resolveAdditionalOrderFromOccupyDetail(detail, resourceSelectType, allowAddItems) {
2663
+ var currentOrderId = toPositiveString(detail === null || detail === void 0 ? void 0 : detail.order_id);
2664
+ if (currentOrderId) {
2665
+ return {
2666
+ matched: true,
2667
+ order_id: currentOrderId
2668
+ };
2669
+ }
2670
+ 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) {
2671
+ return toPositiveString(order === null || order === void 0 ? void 0 : order.id);
2672
+ }).filter(Boolean);
2673
+ if (resourceSelectType !== 'single') {
2674
+ return {
2675
+ matched: false,
2676
+ reason: 'no_order'
2677
+ };
2678
+ }
2679
+ if (!orderListIds.length) {
2680
+ return {
2681
+ matched: false,
2682
+ reason: 'no_order'
2683
+ };
2684
+ }
2685
+ if (!allowAddItems) {
2686
+ return {
2687
+ matched: false,
2688
+ reason: 'add_items_disabled'
2689
+ };
2563
2690
  }
2564
- return fetchResourceOccupyDetailByResourceId;
2565
- }() // 检测当前链接是否可用
2691
+ if (orderListIds.length === 1) {
2692
+ return {
2693
+ matched: true,
2694
+ order_id: orderListIds[0]
2695
+ };
2696
+ }
2697
+ if (orderListIds.length > 1) {
2698
+ return {
2699
+ matched: false,
2700
+ reason: 'multiple_orders'
2701
+ };
2702
+ }
2703
+ return {
2704
+ matched: false,
2705
+ reason: 'no_order'
2706
+ };
2707
+ }
2708
+
2709
+ // 检测当前链接是否可用
2566
2710
  // 通过 resource_id + 店铺配置
2567
2711
  // hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
2568
2712
  }, {
2569
2713
  key: "checkResourceAvailable",
2570
2714
  value: function () {
2571
- var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(resourceId, hasOrderId) {
2572
- var _this$otherParams$bus, _this$otherParams10, _this$otherParams$cha, _this$otherParams11, _this$otherParams12, _this$otherParams12$g, _occupyDetail$form_re, _occupyDetail$form_re2, _this$otherParams13, _this$store$order5, _this$store$order7, _this$store$order7$ge, _this$otherParams14, businessCode, channel, openDataTarget, openData, dineInConfig, closedBehaviorValue, closedMessage, basicUnavailableMessage, pauseMessage, makeShopClosed, operatingHourIds, outsideOperatingHours, scheduleList, now, tempOrder, reservationLinkIds, pendingRequestEntryPax, pendingRequestPaxMin, pendingRequestPaxMax, reservationProductList, scheduleDate, scheduleDatetime, loaded, occupancyMinutes, paxBounds, error, occupyDetail, resourceSelectType, resourceState, availabilityInfo, _this$store$order6, _res$data, res, entryPaxNumber, lastOrderInfo, historicalItems;
2573
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2574
- while (1) switch (_context36.prev = _context36.next) {
2715
+ var _checkResourceAvailable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(resourceId) {
2716
+ var hasOrderId,
2717
+ normalizedResourceId,
2718
+ _this$otherParams$bus,
2719
+ _this$otherParams15,
2720
+ _this$otherParams$cha,
2721
+ _this$otherParams16,
2722
+ _this$otherParams17,
2723
+ _this$otherParams17$g,
2724
+ _occupyDetails$,
2725
+ _occupyDetail$form_re,
2726
+ _occupyDetail$form_re2,
2727
+ _this$store$order6,
2728
+ _this$store$order7,
2729
+ _this$store$order7$ge,
2730
+ _this$otherParams18,
2731
+ _this$store$resource3,
2732
+ _this$store$resource4,
2733
+ businessCode,
2734
+ channel,
2735
+ openDataTarget,
2736
+ openData,
2737
+ dineInConfig,
2738
+ closedBehaviorValue,
2739
+ closedMessage,
2740
+ basicUnavailableMessage,
2741
+ pauseMessage,
2742
+ makeShopClosed,
2743
+ operatingHourIds,
2744
+ outsideOperatingHours,
2745
+ scheduleList,
2746
+ now,
2747
+ tempOrder,
2748
+ reservationLinkIds,
2749
+ pendingRequestEntryPax,
2750
+ pendingRequestPaxMin,
2751
+ pendingRequestPaxMax,
2752
+ reservationProductList,
2753
+ scheduleDate,
2754
+ scheduleDatetime,
2755
+ loaded,
2756
+ matchedRuleProduct,
2757
+ ruleProductsForResource,
2758
+ occupancyMinutes,
2759
+ paxBounds,
2760
+ error,
2761
+ _occupancyMinutes,
2762
+ _paxBounds,
2763
+ _error,
2764
+ occupyDetails,
2765
+ occupyDetail,
2766
+ resourceSelectType,
2767
+ allowAddItems,
2768
+ additionalOrderResult,
2769
+ _occupyDetail$order_l,
2770
+ multipleOrdersState,
2771
+ _availabilityInfo,
2772
+ resourceState,
2773
+ additionalOrderId,
2774
+ availabilityInfo,
2775
+ isAdditionalOrderMode,
2776
+ lastOrderInfo,
2777
+ historicalItems,
2778
+ _args37 = arguments;
2779
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2780
+ while (1) switch (_context37.prev = _context37.next) {
2575
2781
  case 0:
2782
+ hasOrderId = _args37.length > 1 && _args37[1] !== undefined ? _args37[1] : false;
2783
+ normalizedResourceId = String(resourceId !== null && resourceId !== void 0 ? resourceId : '').trim();
2576
2784
  this.logMethodStart('checkResourceAvailable', {
2577
- resourceId: resourceId
2785
+ resourceId: normalizedResourceId
2578
2786
  });
2579
- _context36.prev = 1;
2580
- businessCode = String((_this$otherParams$bus = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
2581
- channel = String((_this$otherParams$cha = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
2787
+ _context37.prev = 3;
2788
+ businessCode = String((_this$otherParams$bus = (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : '').trim();
2789
+ channel = String((_this$otherParams$cha = (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
2582
2790
  openDataTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : 'dine_in+scan_to_order';
2583
- _context36.next = 7;
2584
- return (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 || (_this$otherParams12$g = _this$otherParams12.getOpenData) === null || _this$otherParams12$g === void 0 ? void 0 : _this$otherParams12$g.call(_this$otherParams12, {
2791
+ _context37.next = 9;
2792
+ return (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17$g = _this$otherParams17.getOpenData) === null || _this$otherParams17$g === void 0 ? void 0 : _this$otherParams17$g.call(_this$otherParams17, {
2585
2793
  scope: 'board',
2586
2794
  target: openDataTarget,
2587
2795
  section_code: ['basic', 'fulfillment', 'reservation', 'sale', 'menu', 'availability', 'workflow']
2588
2796
  });
2589
- case 7:
2590
- openData = _context36.sent;
2797
+ case 9:
2798
+ openData = _context37.sent;
2591
2799
  if (!((openData === null || openData === void 0 ? void 0 : openData.status) === false)) {
2592
- _context36.next = 10;
2800
+ _context37.next = 12;
2593
2801
  break;
2594
2802
  }
2595
2803
  throw new Error((openData === null || openData === void 0 ? void 0 : openData.message) || '获取店铺配置失败');
2596
- case 10:
2804
+ case 12:
2597
2805
  dineInConfig = (openData === null || openData === void 0 ? void 0 : openData.data) || {};
2598
2806
  this.otherParams.dineInConfig = dineInConfig;
2599
- _context36.next = 14;
2807
+ _context37.next = 16;
2600
2808
  return this.syncItemRuleConfigsFromDineInConfig(dineInConfig);
2601
- case 14:
2809
+ case 16:
2602
2810
  closedBehaviorValue = dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_behavior'];
2603
2811
  closedMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.closed_message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.message']) || (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.closed_message']);
2604
2812
  basicUnavailableMessage = (dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.unavailable_message']) || closedMessage;
@@ -2615,21 +2823,21 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2615
2823
  };
2616
2824
  }; // 1. 基础开关 basic.enable 关闭
2617
2825
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['basic.enable']) === false)) {
2618
- _context36.next = 21;
2826
+ _context37.next = 23;
2619
2827
  break;
2620
2828
  }
2621
- return _context36.abrupt("return", makeShopClosed(basicUnavailableMessage));
2622
- case 21:
2829
+ return _context37.abrupt("return", makeShopClosed(basicUnavailableMessage));
2830
+ case 23:
2623
2831
  if (!toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.paused'])) {
2624
- _context36.next = 24;
2832
+ _context37.next = 26;
2625
2833
  break;
2626
2834
  }
2627
2835
  if (!((dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.pause_behavior']) === 'hide_all')) {
2628
- _context36.next = 24;
2836
+ _context37.next = 26;
2629
2837
  break;
2630
2838
  }
2631
- return _context36.abrupt("return", makeShopClosed(pauseMessage));
2632
- case 24:
2839
+ return _context37.abrupt("return", makeShopClosed(pauseMessage));
2840
+ case 26:
2633
2841
  // 3. 营业时间 operating_hours 闸门
2634
2842
  operatingHourIds = Array.isArray(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['availability.operating_hours']) ? dineInConfig['availability.operating_hours'].map(function (id) {
2635
2843
  return Number(id);
@@ -2645,27 +2853,33 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2645
2853
  }
2646
2854
  }
2647
2855
  if (!(outsideOperatingHours && closedBehaviorValue !== 'show_menu_disabled')) {
2648
- _context36.next = 29;
2856
+ _context37.next = 31;
2649
2857
  break;
2650
2858
  }
2651
- return _context36.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
2652
- case 29:
2859
+ return _context37.abrupt("return", makeShopClosed(closedMessage, closedBehaviorValue));
2860
+ case 31:
2653
2861
  // Step1: 先加载预约规则商品,拿到 enabledReservationRuleProducts 与容量附加信息
2654
2862
  // (resourceSelectType 需要基于这些商品 + 占用接口的 form_id 计算,故必须前置)
2655
- tempOrder = this.ensureTempOrder();
2863
+ tempOrder = this.ensureScanOrderTempOrder();
2656
2864
  reservationLinkIds = collectLinkProductIdsFromReservationRules(dineInConfig['fulfillment.enabled_resource_rules']);
2657
- if (!(reservationLinkIds.length === 0)) {
2658
- _context36.next = 35;
2865
+ if (!(!normalizedResourceId || reservationLinkIds.length === 0)) {
2866
+ _context37.next = 37;
2659
2867
  break;
2660
2868
  }
2661
- this.enabledReservationRuleProducts = [];
2662
- _context36.next = 46;
2663
- break;
2664
- case 35:
2869
+ _context37.next = 36;
2870
+ return this.prepareRetailAvailability({
2871
+ tempOrder: tempOrder,
2872
+ hasOrderId: hasOrderId,
2873
+ resourceId: normalizedResourceId,
2874
+ reason: !normalizedResourceId ? 'missing_resource_id' : 'missing_enabled_resource_rules'
2875
+ });
2876
+ case 36:
2877
+ return _context37.abrupt("return", _context37.sent);
2878
+ case 37:
2665
2879
  tempOrder.metadata = _objectSpread({}, tempOrder.metadata || {});
2666
2880
  delete tempOrder.metadata.table_occupancy_duration;
2667
2881
  reservationProductList = new ProductList("".concat(this.name, "_reservationEnabledRules"), this.defaultVersion);
2668
- _context36.next = 40;
2882
+ _context37.next = 42;
2669
2883
  return reservationProductList.initialize(this.core, {
2670
2884
  store: {
2671
2885
  list: [],
@@ -2677,27 +2891,29 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2677
2891
  cacheId: this.cacheId
2678
2892
  })
2679
2893
  });
2680
- case 40:
2894
+ case 42:
2681
2895
  scheduleDate = dayjs().format('YYYY-MM-DD');
2682
2896
  scheduleDatetime = dayjs().format('YYYY-MM-DD HH:mm:ss');
2683
- _context36.next = 44;
2897
+ _context37.next = 46;
2684
2898
  return reservationProductList.loadProducts({
2685
2899
  product_ids: reservationLinkIds,
2686
2900
  schedule_date: scheduleDate,
2687
2901
  schedule_datetime: scheduleDatetime,
2688
2902
  cacheId: this.cacheId
2689
2903
  });
2690
- case 44:
2691
- loaded = _context36.sent;
2904
+ case 46:
2905
+ loaded = _context37.sent;
2692
2906
  if (Array.isArray(loaded)) {
2693
- this.enabledReservationRuleProducts = loaded;
2694
- occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
2907
+ matchedRuleProduct = findReservationRuleProductByResourceId(loaded, normalizedResourceId);
2908
+ ruleProductsForResource = matchedRuleProduct ? [matchedRuleProduct] : [];
2909
+ this.enabledReservationRuleProducts = ruleProductsForResource;
2910
+ occupancyMinutes = pickFirstDurationMinutesFromProducts(ruleProductsForResource);
2695
2911
  if (occupancyMinutes !== undefined) {
2696
2912
  tempOrder.metadata.table_occupancy_duration = occupancyMinutes;
2697
2913
  }
2698
- if (hasCustomCapacityProduct(loaded)) {
2914
+ if (hasCustomCapacityProduct(ruleProductsForResource)) {
2699
2915
  pendingRequestEntryPax = 1;
2700
- paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
2916
+ paxBounds = pickFirstCustomCapacityPaxBounds(ruleProductsForResource);
2701
2917
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.min) !== undefined) pendingRequestPaxMin = paxBounds.min;
2702
2918
  if ((paxBounds === null || paxBounds === void 0 ? void 0 : paxBounds.max) !== undefined) pendingRequestPaxMax = paxBounds.max;
2703
2919
  }
@@ -2705,22 +2921,83 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2705
2921
  this.enabledReservationRuleProducts = [];
2706
2922
  error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
2707
2923
  this.logMethodError('loadReservationRuleProducts', error, {
2708
- resourceId: resourceId,
2924
+ resourceId: normalizedResourceId,
2709
2925
  reservationLinkIds: reservationLinkIds,
2710
2926
  scheduleDate: scheduleDate,
2711
2927
  scheduleDatetime: scheduleDatetime,
2712
2928
  cacheId: this.cacheId
2713
2929
  });
2930
+ if (Array.isArray(loaded)) {
2931
+ this.enabledReservationRuleProducts = loaded;
2932
+ _occupancyMinutes = pickFirstDurationMinutesFromProducts(loaded);
2933
+ if (_occupancyMinutes !== undefined) {
2934
+ tempOrder.metadata.table_occupancy_duration = _occupancyMinutes;
2935
+ }
2936
+ if (hasCustomCapacityProduct(loaded)) {
2937
+ pendingRequestEntryPax = 1;
2938
+ _paxBounds = pickFirstCustomCapacityPaxBounds(loaded);
2939
+ if ((_paxBounds === null || _paxBounds === void 0 ? void 0 : _paxBounds.min) !== undefined) pendingRequestPaxMin = _paxBounds.min;
2940
+ if ((_paxBounds === null || _paxBounds === void 0 ? void 0 : _paxBounds.max) !== undefined) pendingRequestPaxMax = _paxBounds.max;
2941
+ }
2942
+ } else {
2943
+ this.enabledReservationRuleProducts = [];
2944
+ _error = loaded instanceof Error ? loaded : new Error('预约规则商品列表接口返回异常');
2945
+ this.logMethodError('loadReservationRuleProducts', _error, {
2946
+ resourceId: resourceId,
2947
+ reservationLinkIds: reservationLinkIds,
2948
+ scheduleDate: scheduleDate,
2949
+ scheduleDatetime: scheduleDatetime,
2950
+ cacheId: this.cacheId
2951
+ });
2952
+ }
2714
2953
  }
2715
- case 46:
2716
- _context36.next = 48;
2717
- return this.fetchResourceOccupyDetailByResourceId(resourceId);
2718
- case 48:
2719
- occupyDetail = _context36.sent;
2720
- // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2954
+
2955
+ // Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
2956
+ _context37.next = 50;
2957
+ return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
2958
+ case 50:
2959
+ occupyDetails = _context37.sent;
2960
+ occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
2721
2961
  // 计算当前桌台的 resourceSelectType(single/multiple/capacity)
2722
- resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id)); // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2962
+ resourceSelectType = this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
2963
+ allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
2964
+ additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
2965
+ if (!(additionalOrderResult.reason === 'multiple_orders')) {
2966
+ _context37.next = 61;
2967
+ break;
2968
+ }
2969
+ multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
2970
+ mode: 'multiple_orders'
2971
+ });
2972
+ this.store.resource = multipleOrdersState;
2973
+ _availabilityInfo = {
2974
+ mode: 'multiple_orders',
2975
+ deskmate_valid: multipleOrdersState.deskmate_valid,
2976
+ relation_id: multipleOrdersState.relationId,
2977
+ table_form_id: multipleOrdersState.tableFormId,
2978
+ table_form_record: multipleOrdersState.table_form_record
2979
+ };
2980
+ this.logMethodSuccess('checkResourceAvailable', {
2981
+ resourceId: normalizedResourceId,
2982
+ mode: _availabilityInfo.mode,
2983
+ 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,
2984
+ resourceSelectType: resourceSelectType
2985
+ });
2986
+ return _context37.abrupt("return", _availabilityInfo);
2987
+ case 61:
2988
+ // Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
2723
2989
  resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
2990
+ additionalOrderId = additionalOrderResult.order_id;
2991
+ if (additionalOrderId) {
2992
+ resourceState.mode = 'additional_order';
2993
+ resourceState.order_id = additionalOrderId;
2994
+ } else if (additionalOrderResult.reason === 'add_items_disabled') {
2995
+ resourceState.mode = 'resource_busy';
2996
+ resourceState.order_id = '0';
2997
+ } else if (resourceSelectType === 'multiple' && resourceState.isFull) {
2998
+ resourceState.mode = 'resource_busy';
2999
+ resourceState.order_id = '0';
3000
+ }
2724
3001
  this.store.resource = resourceState;
2725
3002
 
2726
3003
  // Step5: 把预约规则商品阶段暂存的 requestEntryPax 等注入 store.resource
@@ -2749,47 +3026,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2749
3026
  } : {}), this.store.resource.requestPaxMax !== undefined ? {
2750
3027
  requestPaxMax: this.store.resource.requestPaxMax
2751
3028
  } : {});
2752
- tempOrder.relation_id = resourceId || ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.relation_id);
2753
- tempOrder.table_form_id = resourceState.tableFormId;
2754
- tempOrder.resource_id = resourceId;
2755
- (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.persistTempOrder();
3029
+ (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || _this$store$order6.persistTempOrder();
2756
3030
 
2757
3031
  // 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
2758
3032
  if (!(availabilityInfo.mode === 'idle')) {
2759
- _context36.next = 63;
3033
+ _context37.next = 73;
2760
3034
  break;
2761
3035
  }
2762
- _context36.next = 63;
3036
+ _context37.next = 73;
2763
3037
  return this.addNewOrder();
2764
- case 63:
2765
- // 如果是加单模式,tempOrder 需要记录 lastOrderId,提交的时候走加单接口
2766
- if (availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code') {
2767
- tempOrder.order_id = resourceState.lastOrderId;
2768
- }
2769
- if (!tempOrder.order_id) {
2770
- _context36.next = 72;
2771
- break;
2772
- }
2773
- _context36.next = 67;
2774
- return (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getSalesOrderByLookup({
2775
- lookup: tempOrder.order_id
2776
- });
2777
- case 67:
2778
- res = _context36.sent;
2779
- // 找到下单的时候输入的 entryPaxNumber
2780
- 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) {
2781
- var _p$metadata;
2782
- return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
2783
- })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
2784
- if (!entryPaxNumber) {
2785
- _context36.next = 72;
2786
- break;
3038
+ case 73:
3039
+ isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
3040
+ if (isAdditionalOrderMode) {
3041
+ tempOrder.order_id = additionalOrderId;
2787
3042
  }
2788
- _context36.next = 72;
2789
- return this.setEntryPaxNumber(entryPaxNumber);
2790
- case 72:
2791
3043
  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);
2792
- historicalItems = hasOrderId && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
3044
+ historicalItems = isAdditionalOrderMode && Array.isArray(lastOrderInfo === null || lastOrderInfo === void 0 ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce(function (acc, p) {
2793
3045
  if (typeof (p === null || p === void 0 ? void 0 : p.product_id) !== 'number') return acc;
2794
3046
  acc.push(_objectSpread({
2795
3047
  product_id: p.product_id,
@@ -2799,13 +3051,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2799
3051
  } : {}));
2800
3052
  return acc;
2801
3053
  }, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
2802
- _context36.next = 76;
3054
+ _context37.next = 79;
2803
3055
  return this.setItemRuleRuntimeConfig({
2804
- serviceType: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.businessCode,
2805
- submissionIndex: hasOrderId ? 1 : 0,
3056
+ serviceType: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode,
3057
+ submissionIndex: isAdditionalOrderMode ? 1 : 0,
2806
3058
  historicalItems: historicalItems
2807
3059
  });
2808
- case 76:
3060
+ case 79:
2809
3061
  // operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
2810
3062
  // 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
2811
3063
  if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
@@ -2814,44 +3066,90 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2814
3066
  availabilityInfo.closed_behavior = closedBehaviorValue;
2815
3067
  }
2816
3068
  this.logMethodSuccess('checkResourceAvailable', {
2817
- resourceId: resourceId,
3069
+ resourceId: normalizedResourceId,
2818
3070
  mode: availabilityInfo.mode,
2819
3071
  orderId: availabilityInfo.order_id,
2820
3072
  relationId: availabilityInfo.relation_id,
2821
3073
  tableFormId: availabilityInfo.table_form_id,
2822
- persistedRelationId: tempOrder.relation_id,
2823
- persistedResourceId: tempOrder.resource_id,
3074
+ persistedRelationId: (_this$store$resource3 = this.store.resource) === null || _this$store$resource3 === void 0 ? void 0 : _this$store$resource3.relationId,
3075
+ persistedResourceId: (_this$store$resource4 = this.store.resource) === null || _this$store$resource4 === void 0 ? void 0 : _this$store$resource4.relationId,
2824
3076
  deskmateValid: availabilityInfo.deskmate_valid,
2825
3077
  resourceSelectType: resourceState.resourceSelectType,
2826
3078
  isExclusive: resourceState.isExclusive,
2827
3079
  isFull: resourceState.isFull
2828
3080
  });
2829
- return _context36.abrupt("return", availabilityInfo);
2830
- case 81:
2831
- _context36.prev = 81;
2832
- _context36.t0 = _context36["catch"](1);
2833
- this.logMethodError('checkResourceAvailable', _context36.t0.message, {
2834
- resourceId: resourceId
3081
+ return _context37.abrupt("return", availabilityInfo);
3082
+ case 84:
3083
+ _context37.prev = 84;
3084
+ _context37.t0 = _context37["catch"](3);
3085
+ this.logMethodError('checkResourceAvailable', _context37.t0.message, {
3086
+ resourceId: normalizedResourceId
2835
3087
  });
2836
- throw _context36.t0;
2837
- case 85:
3088
+ throw _context37.t0;
3089
+ case 88:
2838
3090
  case "end":
2839
- return _context36.stop();
3091
+ return _context37.stop();
2840
3092
  }
2841
- }, _callee36, this, [[1, 81]]);
3093
+ }, _callee37, this, [[3, 84]]);
2842
3094
  }));
2843
- function checkResourceAvailable(_x18, _x19) {
3095
+ function checkResourceAvailable(_x20) {
2844
3096
  return _checkResourceAvailable.apply(this, arguments);
2845
3097
  }
2846
3098
  return checkResourceAvailable;
3099
+ }() // 恢复之前订单的数据,读取 entrypax
3100
+ }, {
3101
+ key: "restorePreviousOrderData",
3102
+ value: function () {
3103
+ var _restorePreviousOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
3104
+ var orderModule, tempOrder, _res$data, res, entryPaxNumber;
3105
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3106
+ while (1) switch (_context38.prev = _context38.next) {
3107
+ case 0:
3108
+ orderModule = this.store.order;
3109
+ if (orderModule) {
3110
+ _context38.next = 3;
3111
+ break;
3112
+ }
3113
+ return _context38.abrupt("return");
3114
+ case 3:
3115
+ tempOrder = orderModule.ensureTempOrder();
3116
+ if (!tempOrder.order_id) {
3117
+ _context38.next = 12;
3118
+ break;
3119
+ }
3120
+ _context38.next = 7;
3121
+ return orderModule.getOrderInfo(tempOrder.order_id);
3122
+ case 7:
3123
+ res = _context38.sent;
3124
+ // 找到下单的时候输入的 entryPaxNumber
3125
+ 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) {
3126
+ var _p$metadata;
3127
+ return (_p$metadata = p.metadata) === null || _p$metadata === void 0 ? void 0 : _p$metadata.collect_pax;
3128
+ })) === null || _res$data === void 0 || (_res$data = _res$data.metadata) === null || _res$data === void 0 ? void 0 : _res$data.collect_pax;
3129
+ if (!entryPaxNumber) {
3130
+ _context38.next = 12;
3131
+ break;
3132
+ }
3133
+ _context38.next = 12;
3134
+ return this.setEntryPaxNumber(entryPaxNumber);
3135
+ case 12:
3136
+ case "end":
3137
+ return _context38.stop();
3138
+ }
3139
+ }, _callee38, this);
3140
+ }));
3141
+ function restorePreviousOrderData() {
3142
+ return _restorePreviousOrderData.apply(this, arguments);
3143
+ }
3144
+ return restorePreviousOrderData;
2847
3145
  }() // 如果是加单的情况,提供返回当前订单相关信息的能力
2848
3146
  }, {
2849
3147
  key: "getAdditionalOrderInfo",
2850
3148
  value: function () {
2851
- var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3149
+ var _getAdditionalOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
2852
3150
  var result;
2853
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2854
- while (1) switch (_context37.prev = _context37.next) {
3151
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3152
+ while (1) switch (_context39.prev = _context39.next) {
2855
3153
  case 0:
2856
3154
  this.logMethodStart('getAdditionalOrderInfo');
2857
3155
  result = {
@@ -2865,12 +3163,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2865
3163
  orderId: result.orderId,
2866
3164
  orderStatus: result.orderStatus
2867
3165
  });
2868
- return _context37.abrupt("return", result);
3166
+ return _context39.abrupt("return", result);
2869
3167
  case 4:
2870
3168
  case "end":
2871
- return _context37.stop();
3169
+ return _context39.stop();
2872
3170
  }
2873
- }, _callee37, this);
3171
+ }, _callee39, this);
2874
3172
  }));
2875
3173
  function getAdditionalOrderInfo() {
2876
3174
  return _getAdditionalOrderInfo.apply(this, arguments);
@@ -2880,33 +3178,34 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2880
3178
  }, {
2881
3179
  key: "getProductList",
2882
3180
  value: function () {
2883
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2884
- var _this$otherParams15;
2885
- var menu_list_ids, res, productList, formattedRes;
2886
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2887
- while (1) switch (_context38.prev = _context38.next) {
3181
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
3182
+ var _this$otherParams19;
3183
+ var associatedMenus, menu_list_ids, res, productList, formattedRes;
3184
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3185
+ while (1) switch (_context40.prev = _context40.next) {
2888
3186
  case 0:
2889
3187
  this.logMethodStart('getProductList');
2890
3188
  // 可以直接通过配置里的 menu 读取
2891
- menu_list_ids = ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 || (_this$otherParams15 = _this$otherParams15.dineInConfig) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15['menu.associated_menus'].map(function (n) {
3189
+ associatedMenus = (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 || (_this$otherParams19 = _this$otherParams19.dineInConfig) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19['menu.associated_menus'];
3190
+ menu_list_ids = associatedMenus.map(function (n) {
2892
3191
  return Number(n.value);
2893
- })) || [];
2894
- _context38.prev = 2;
3192
+ }) || [];
3193
+ _context40.prev = 3;
2895
3194
  if (this.store.products) {
2896
- _context38.next = 5;
3195
+ _context40.next = 6;
2897
3196
  break;
2898
3197
  }
2899
3198
  throw new Error('products 模块未初始化');
2900
- case 5:
2901
- _context38.next = 7;
3199
+ case 6:
3200
+ _context40.next = 8;
2902
3201
  return this.store.products.loadProducts({
2903
3202
  menu_list_ids: menu_list_ids,
2904
3203
  cacheId: this.cacheId,
2905
3204
  schedule_date: dayjs().format('YYYY-MM-DD'),
2906
3205
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2907
3206
  });
2908
- case 7:
2909
- res = _context38.sent;
3207
+ case 8:
3208
+ res = _context40.sent;
2910
3209
  productList = this.assertProductListLoaded('getProductList', res, {
2911
3210
  menu_list_ids: menu_list_ids,
2912
3211
  cacheId: this.cacheId
@@ -2915,22 +3214,22 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2915
3214
  this.logMethodSuccess('getProductList', {
2916
3215
  menuCount: menu_list_ids.length
2917
3216
  });
2918
- return _context38.abrupt("return", formattedRes);
2919
- case 14:
2920
- _context38.prev = 14;
2921
- _context38.t0 = _context38["catch"](2);
2922
- if (!(_context38.t0 !== null && _context38.t0 !== void 0 && _context38.t0.__scanOrderLogged)) {
2923
- this.logMethodError('getProductList', _context38.t0, {
3217
+ return _context40.abrupt("return", formattedRes);
3218
+ case 15:
3219
+ _context40.prev = 15;
3220
+ _context40.t0 = _context40["catch"](3);
3221
+ if (!(_context40.t0 !== null && _context40.t0 !== void 0 && _context40.t0.__scanOrderLogged)) {
3222
+ this.logMethodError('getProductList', _context40.t0, {
2924
3223
  menu_list_ids: menu_list_ids,
2925
3224
  cacheId: this.cacheId
2926
3225
  });
2927
3226
  }
2928
- throw _context38.t0;
2929
- case 18:
3227
+ throw _context40.t0;
3228
+ case 19:
2930
3229
  case "end":
2931
- return _context38.stop();
3230
+ return _context40.stop();
2932
3231
  }
2933
- }, _callee38, this, [[2, 14]]);
3232
+ }, _callee40, this, [[3, 15]]);
2934
3233
  }));
2935
3234
  function getProductList() {
2936
3235
  return _getProductList.apply(this, arguments);
@@ -2945,15 +3244,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2945
3244
  }, {
2946
3245
  key: "setOtherParams",
2947
3246
  value: function () {
2948
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
3247
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
2949
3248
  var _ref8,
2950
3249
  _ref8$cover,
2951
3250
  cover,
2952
- _args39 = arguments;
2953
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2954
- while (1) switch (_context39.prev = _context39.next) {
3251
+ _args41 = arguments;
3252
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3253
+ while (1) switch (_context41.prev = _context41.next) {
2955
3254
  case 0:
2956
- _ref8 = _args39.length > 1 && _args39[1] !== undefined ? _args39[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
3255
+ _ref8 = _args41.length > 1 && _args41[1] !== undefined ? _args41[1] : {}, _ref8$cover = _ref8.cover, cover = _ref8$cover === void 0 ? false : _ref8$cover;
2957
3256
  if (cover) {
2958
3257
  this.otherParams = params;
2959
3258
  } else {
@@ -2961,11 +3260,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
2961
3260
  }
2962
3261
  case 2:
2963
3262
  case "end":
2964
- return _context39.stop();
3263
+ return _context41.stop();
2965
3264
  }
2966
- }, _callee39, this);
3265
+ }, _callee41, this);
2967
3266
  }));
2968
- function setOtherParams(_x20) {
3267
+ function setOtherParams(_x21) {
2969
3268
  return _setOtherParams.apply(this, arguments);
2970
3269
  }
2971
3270
  return setOtherParams;
@@ -3055,10 +3354,10 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3055
3354
  }, {
3056
3355
  key: "setEntryPaxNumber",
3057
3356
  value: function () {
3058
- var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(number) {
3357
+ var _setEntryPaxNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(number) {
3059
3358
  var pax, t;
3060
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3061
- while (1) switch (_context40.prev = _context40.next) {
3359
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3360
+ while (1) switch (_context42.prev = _context42.next) {
3062
3361
  case 0:
3063
3362
  pax = normalizeSubmitCollectPaxValue(number);
3064
3363
  this.store.entryPaxNumber = pax;
@@ -3079,18 +3378,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3079
3378
  }
3080
3379
  });
3081
3380
  this.itemRulePrefillApplied = false;
3082
- _context40.next = 7;
3381
+ _context42.next = 7;
3083
3382
  return this.refreshItemRuleQuantityLimits();
3084
3383
  case 7:
3085
- _context40.next = 9;
3384
+ _context42.next = 9;
3086
3385
  return this.refreshCartValidationPassed();
3087
3386
  case 9:
3088
3387
  case "end":
3089
- return _context40.stop();
3388
+ return _context42.stop();
3090
3389
  }
3091
- }, _callee40, this);
3390
+ }, _callee42, this);
3092
3391
  }));
3093
- function setEntryPaxNumber(_x21) {
3392
+ function setEntryPaxNumber(_x22) {
3094
3393
  return _setEntryPaxNumber.apply(this, arguments);
3095
3394
  }
3096
3395
  return setEntryPaxNumber;
@@ -3100,15 +3399,119 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3100
3399
  value: function getEntryPaxNumber() {
3101
3400
  return this.store.entryPaxNumber;
3102
3401
  }
3402
+ }, {
3403
+ key: "syncAdditionalOrderFromResource",
3404
+ value: function () {
3405
+ var _syncAdditionalOrderFromResource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(resourceId) {
3406
+ var _ref9, _ref10, _ref11, _this$store$resource5, _this$store$resource6, _occupyDetails$2, _this$store$resource7, _this$otherParams20, _this$store$order8;
3407
+ var tempOrder, normalizedResourceId, _result, occupyDetails, occupyDetail, resourceSelectType, allowAddItems, result;
3408
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3409
+ while (1) switch (_context43.prev = _context43.next) {
3410
+ case 0:
3411
+ if (this.store.order) {
3412
+ _context43.next = 2;
3413
+ break;
3414
+ }
3415
+ throw new Error('order 模块未初始化');
3416
+ case 2:
3417
+ tempOrder = this.store.order.ensureTempOrder();
3418
+ normalizedResourceId = String((_ref9 = (_ref10 = (_ref11 = resourceId !== null && resourceId !== void 0 ? resourceId : tempOrder.resource_id) !== null && _ref11 !== void 0 ? _ref11 : (_this$store$resource5 = this.store.resource) === null || _this$store$resource5 === void 0 ? void 0 : _this$store$resource5.relationId) !== null && _ref10 !== void 0 ? _ref10 : (_this$store$resource6 = this.store.resource) === null || _this$store$resource6 === void 0 ? void 0 : _this$store$resource6.relation_id) !== null && _ref9 !== void 0 ? _ref9 : '').trim();
3419
+ this.logMethodStart('syncAdditionalOrderFromResource', {
3420
+ resourceId: normalizedResourceId
3421
+ });
3422
+ if (normalizedResourceId) {
3423
+ _context43.next = 9;
3424
+ break;
3425
+ }
3426
+ _result = {
3427
+ matched: false,
3428
+ reason: 'missing_resource_id'
3429
+ };
3430
+ this.logMethodSuccess('syncAdditionalOrderFromResource', _result);
3431
+ return _context43.abrupt("return", _result);
3432
+ case 9:
3433
+ _context43.next = 11;
3434
+ return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
3435
+ case 11:
3436
+ occupyDetails = _context43.sent;
3437
+ occupyDetail = (_occupyDetails$2 = occupyDetails[0]) !== null && _occupyDetails$2 !== void 0 ? _occupyDetails$2 : null;
3438
+ resourceSelectType = ((_this$store$resource7 = this.store.resource) === null || _this$store$resource7 === void 0 ? void 0 : _this$store$resource7.resourceSelectType) || this.resolveResourceSelectType(toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id));
3439
+ allowAddItems = toBoolean((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 || (_this$otherParams20 = _this$otherParams20.dineInConfig) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20['sale.allow_add_items']);
3440
+ result = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
3441
+ if (!(!result.matched || !result.order_id)) {
3442
+ _context43.next = 19;
3443
+ break;
3444
+ }
3445
+ this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3446
+ resourceId: normalizedResourceId,
3447
+ resourceSelectType: resourceSelectType,
3448
+ allowAddItems: allowAddItems
3449
+ }));
3450
+ return _context43.abrupt("return", result);
3451
+ case 19:
3452
+ tempOrder.order_id = result.order_id;
3453
+ tempOrder.resource_id = normalizedResourceId;
3454
+ tempOrder.relation_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_record_id) || normalizedResourceId || tempOrder.relation_id;
3455
+ tempOrder.table_form_id = toPositiveString(occupyDetail === null || occupyDetail === void 0 ? void 0 : occupyDetail.form_id) || tempOrder.table_form_id;
3456
+ (_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || _this$store$order8.persistTempOrder();
3457
+ this.logMethodSuccess('syncAdditionalOrderFromResource', _objectSpread(_objectSpread({}, result), {}, {
3458
+ resourceId: normalizedResourceId,
3459
+ resourceSelectType: resourceSelectType,
3460
+ allowAddItems: allowAddItems
3461
+ }));
3462
+ return _context43.abrupt("return", result);
3463
+ case 26:
3464
+ case "end":
3465
+ return _context43.stop();
3466
+ }
3467
+ }, _callee43, this);
3468
+ }));
3469
+ function syncAdditionalOrderFromResource(_x23) {
3470
+ return _syncAdditionalOrderFromResource.apply(this, arguments);
3471
+ }
3472
+ return syncAdditionalOrderFromResource;
3473
+ }() // 读取预约规则商品的资源选择类型:single=单个预约,multiple=多个预约,capacity=容量型预约
3474
+ // 依赖 checkResourceAvailable 已根据预约规则商品与 occupy-detail 的 form_id 计算并缓存 store.resource
3475
+ }, {
3476
+ key: "getReservationResourceSelectType",
3477
+ value: function getReservationResourceSelectType() {
3478
+ var _this$store$resource8;
3479
+ this.logMethodStart('getReservationResourceSelectType');
3480
+ var resourceSelectType = (_this$store$resource8 = this.store.resource) === null || _this$store$resource8 === void 0 ? void 0 : _this$store$resource8.resourceSelectType;
3481
+ var result = _objectSpread(_objectSpread({}, resourceSelectType ? {
3482
+ resourceSelectType: resourceSelectType
3483
+ } : {}), {}, {
3484
+ isSingleReservation: resourceSelectType === 'single',
3485
+ isMultipleReservation: resourceSelectType === 'multiple',
3486
+ isCapacityReservation: resourceSelectType === 'capacity'
3487
+ });
3488
+ this.logMethodSuccess('getReservationResourceSelectType', result);
3489
+ return result;
3490
+ }
3491
+
3492
+ // 判定后台是否开启允许加餐
3493
+ // 依赖 checkResourceAvailable 已缓存的 dineInConfig
3494
+ }, {
3495
+ key: "checkAllowAddItems",
3496
+ value: function checkAllowAddItems() {
3497
+ var _this$otherParams21;
3498
+ this.logMethodStart('checkAllowAddItems');
3499
+ var dineInConfig = ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.dineInConfig) || {};
3500
+ var result = {
3501
+ enabled: toBoolean(dineInConfig['sale.allow_add_items'])
3502
+ };
3503
+ this.logMethodSuccess('checkAllowAddItems', result);
3504
+ return result;
3505
+ }
3103
3506
 
3104
3507
  // 读取取餐/送餐开关
3105
3508
  // 依赖 checkResourceAvailable 已缓存的 dineInConfig
3106
3509
  }, {
3107
3510
  key: "getFulfillmentModes",
3108
3511
  value: function getFulfillmentModes() {
3109
- var _this$otherParams16;
3512
+ var _this$otherParams22;
3110
3513
  this.logMethodStart('getFulfillmentModes');
3111
- var dineInConfig = ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.dineInConfig) || {};
3514
+ var dineInConfig = ((_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.dineInConfig) || {};
3112
3515
  var result = {
3113
3516
  enablePickup: Boolean(dineInConfig['fulfillment.enable_pickup']),
3114
3517
  enableTableService: Boolean(dineInConfig['fulfillment.enable_table_service'])
@@ -3122,9 +3525,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3122
3525
  }, {
3123
3526
  key: "checkManualPickupRef",
3124
3527
  value: function checkManualPickupRef() {
3125
- var _this$otherParams17;
3528
+ var _this$otherParams23;
3126
3529
  this.logMethodStart('checkManualPickupRef');
3127
- var dineInConfig = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.dineInConfig) || {};
3530
+ var dineInConfig = ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.dineInConfig) || {};
3128
3531
  var refMode = dineInConfig['fulfillment.fulfillment_ref_mode'];
3129
3532
  var manualInputType = dineInConfig['fulfillment.manual_input_type'];
3130
3533
  var enabled = refMode === 'manual_input';
@@ -3142,6 +3545,6 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
3142
3545
  }
3143
3546
  }]);
3144
3547
  return ScanOrderImpl;
3145
- }(BaseModule);
3548
+ }(BaseSalesImpl);
3146
3549
  _defineProperty(ScanOrderImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
3147
3550
  _defineProperty(ScanOrderImpl, "UI_STATE_KEY_PREFIX", 'pisell.scanOrder.uiState:');