@pisell/pisellos 2.3.39 → 2.3.41

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