@pisell/pisellos 0.10.2 → 0.10.4

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 (139) 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 +0 -9
  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/BaseModule.d.ts +1 -0
  14. package/dist/modules/BaseModule.js +24 -28
  15. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -3
  16. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
  17. package/dist/modules/OpenData/index.d.ts +2 -0
  18. package/dist/modules/OpenData/index.js +8 -0
  19. package/dist/modules/Order/index.d.ts +41 -10
  20. package/dist/modules/Order/index.js +943 -546
  21. package/dist/modules/Order/payment-utils.d.ts +26 -0
  22. package/dist/modules/Order/payment-utils.js +225 -0
  23. package/dist/modules/Order/types.d.ts +43 -2
  24. package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
  25. package/dist/modules/Order/utils.js +10 -6
  26. package/dist/modules/Payment/index.d.ts +2 -0
  27. package/dist/modules/Payment/index.js +79 -50
  28. package/dist/modules/Payment/types.d.ts +107 -28
  29. package/dist/modules/Payment/types.js +20 -3
  30. package/dist/modules/Payment/walletpass.d.ts +38 -1
  31. package/dist/modules/Payment/walletpass.js +917 -114
  32. package/dist/modules/ProductList/index.js +1 -1
  33. package/dist/modules/Rules/index.d.ts +3 -0
  34. package/dist/modules/Rules/index.js +130 -99
  35. package/dist/server/index.d.ts +16 -0
  36. package/dist/server/index.js +2084 -1188
  37. package/dist/server/modules/index.d.ts +1 -1
  38. package/dist/server/modules/order/index.d.ts +70 -4
  39. package/dist/server/modules/order/index.js +1816 -728
  40. package/dist/server/modules/order/types.d.ts +25 -3
  41. package/dist/server/modules/order/types.js +7 -1
  42. package/dist/solution/BaseSales/index.d.ts +114 -14
  43. package/dist/solution/BaseSales/index.js +1848 -478
  44. package/dist/solution/BaseSales/types.d.ts +55 -1
  45. package/dist/solution/BaseSales/types.js +2 -1
  46. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  47. package/dist/solution/BaseSales/utils/cartPromotion.js +90 -31
  48. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  49. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
  50. package/dist/solution/BookingByStep/index.d.ts +1 -1
  51. package/dist/solution/BookingTicket/index.d.ts +8 -16
  52. package/dist/solution/BookingTicket/index.js +138 -52
  53. package/dist/solution/BookingTicket/types.d.ts +1 -0
  54. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
  55. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  56. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
  57. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  58. package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
  59. package/dist/solution/Sales/index.d.ts +1 -0
  60. package/dist/solution/Sales/index.js +10 -2
  61. package/dist/solution/ScanOrder/index.js +31 -20
  62. package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
  63. package/dist/solution/UnifiedBookingSales/index.js +392 -304
  64. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
  65. package/dist/solution/VenueBooking/index.d.ts +1 -0
  66. package/dist/solution/VenueBooking/index.js +34 -24
  67. package/dist/types/index.d.ts +1 -0
  68. package/dist/utils/payment-number.d.ts +9 -0
  69. package/dist/utils/payment-number.js +69 -0
  70. package/lib/core/index.d.ts +2 -0
  71. package/lib/core/index.js +4 -0
  72. package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
  73. package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
  74. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
  75. package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
  76. package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
  77. package/lib/model/strategy/adapter/promotion/examples.js +91 -0
  78. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  79. package/lib/model/strategy/adapter/promotion/index.js +2 -0
  80. package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
  81. package/lib/model/strategy/adapter/promotion/type.js +2 -0
  82. package/lib/modules/BaseModule.d.ts +1 -0
  83. package/lib/modules/BaseModule.js +24 -37
  84. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  85. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  86. package/lib/modules/OpenData/index.d.ts +2 -0
  87. package/lib/modules/OpenData/index.js +5 -0
  88. package/lib/modules/Order/index.d.ts +41 -10
  89. package/lib/modules/Order/index.js +322 -86
  90. package/lib/modules/Order/payment-utils.d.ts +26 -0
  91. package/lib/modules/Order/payment-utils.js +224 -0
  92. package/lib/modules/Order/types.d.ts +43 -2
  93. package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
  94. package/lib/modules/Order/utils.js +11 -4
  95. package/lib/modules/Payment/index.d.ts +2 -0
  96. package/lib/modules/Payment/index.js +34 -13
  97. package/lib/modules/Payment/types.d.ts +107 -28
  98. package/lib/modules/Payment/types.js +4 -3
  99. package/lib/modules/Payment/walletpass.d.ts +38 -1
  100. package/lib/modules/Payment/walletpass.js +730 -21
  101. package/lib/modules/ProductList/index.js +9 -1
  102. package/lib/modules/Rules/index.d.ts +3 -0
  103. package/lib/modules/Rules/index.js +39 -10
  104. package/lib/server/index.d.ts +16 -0
  105. package/lib/server/index.js +677 -28
  106. package/lib/server/modules/index.d.ts +1 -1
  107. package/lib/server/modules/order/index.d.ts +70 -4
  108. package/lib/server/modules/order/index.js +818 -69
  109. package/lib/server/modules/order/types.d.ts +25 -3
  110. package/lib/server/modules/order/types.js +1 -0
  111. package/lib/solution/BaseSales/index.d.ts +114 -14
  112. package/lib/solution/BaseSales/index.js +907 -58
  113. package/lib/solution/BaseSales/types.d.ts +55 -1
  114. package/lib/solution/BaseSales/types.js +2 -1
  115. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
  116. package/lib/solution/BaseSales/utils/cartPromotion.js +63 -12
  117. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
  118. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
  119. package/lib/solution/BookingByStep/index.d.ts +1 -1
  120. package/lib/solution/BookingTicket/index.d.ts +8 -16
  121. package/lib/solution/BookingTicket/index.js +63 -9
  122. package/lib/solution/BookingTicket/types.d.ts +1 -0
  123. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
  124. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
  125. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
  126. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
  127. package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
  128. package/lib/solution/Sales/index.d.ts +1 -0
  129. package/lib/solution/Sales/index.js +5 -3
  130. package/lib/solution/ScanOrder/index.js +8 -0
  131. package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
  132. package/lib/solution/UnifiedBookingSales/index.js +48 -2
  133. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
  134. package/lib/solution/VenueBooking/index.d.ts +1 -0
  135. package/lib/solution/VenueBooking/index.js +13 -6
  136. package/lib/types/index.d.ts +1 -0
  137. package/lib/utils/payment-number.d.ts +9 -0
  138. package/lib/utils/payment-number.js +64 -0
  139. package/package.json +1 -1
@@ -498,15 +498,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
498
498
  return _this;
499
499
  }
500
500
  _createClass(UnifiedBookingSalesImpl, [{
501
- key: "shouldUseCheckoutSyncTask",
502
- value:
501
+ key: "isSessionStoragePersistEnabled",
502
+ value: function isSessionStoragePersistEnabled() {
503
+ var _this$otherParams;
504
+ return Boolean(this.cacheId && ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.enableSessionStoragePersist) === true);
505
+ }
506
+ }, {
507
+ key: "shouldUseSessionStorageForSubModule",
508
+ value: function shouldUseSessionStorageForSubModule(moduleName) {
509
+ return this.isSessionStoragePersistEnabled() && moduleName === 'order';
510
+ }
511
+
503
512
  /**
504
513
  * Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
505
514
  * 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
506
515
  */
507
- function shouldUseCheckoutSyncTask() {
508
- var _this$otherParams;
509
- var configured = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.checkoutSyncTaskEnabled;
516
+ }, {
517
+ key: "shouldUseCheckoutSyncTask",
518
+ value: function shouldUseCheckoutSyncTask() {
519
+ var _this$otherParams2;
520
+ var configured = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.checkoutSyncTaskEnabled;
510
521
  return typeof configured === 'boolean' ? configured : false;
511
522
  }
512
523
 
@@ -532,7 +543,64 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
532
543
  }
533
544
  return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "createSubModule", this).call(this, moduleName);
534
545
  }
535
-
546
+ }, {
547
+ key: "addNewOrder",
548
+ value: function () {
549
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
550
+ var _this$store$order, _this$store$order$con, _this$store$order2, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$order3;
551
+ var sessionRecord, tempOrder, customerId;
552
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
553
+ while (1) switch (_context.prev = _context.next) {
554
+ case 0:
555
+ sessionRecord = this.isSessionStoragePersistEnabled() ? (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$con = _this$store$order.consumeSessionStorageRestore) === null || _this$store$order$con === void 0 ? void 0 : _this$store$order$con.call(_this$store$order) : null;
556
+ if (sessionRecord) {
557
+ _context.next = 3;
558
+ break;
559
+ }
560
+ return _context.abrupt("return", _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "addNewOrder", this).call(this));
561
+ case 3:
562
+ _context.next = 5;
563
+ return this.loadSalesDetail({
564
+ preloadedSalesDetail: sessionRecord,
565
+ hydrateSource: 'sessionStorage'
566
+ });
567
+ case 5:
568
+ _context.next = 7;
569
+ return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "addNewOrder", this).call(this);
570
+ case 7:
571
+ tempOrder = _context.sent;
572
+ (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
573
+ customerId = Number(tempOrder.customer_id || ((_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || ((_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || ((_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id) || 0);
574
+ if (!(customerId > 1)) {
575
+ _context.next = 19;
576
+ break;
577
+ }
578
+ _context.prev = 11;
579
+ _context.next = 14;
580
+ return this.loadDiscountConfig({
581
+ customerId: customerId,
582
+ action: tempOrder.order_id ? 'edit' : 'create'
583
+ });
584
+ case 14:
585
+ _context.next = 19;
586
+ break;
587
+ case 16:
588
+ _context.prev = 16;
589
+ _context.t0 = _context["catch"](11);
590
+ console.warn('[UnifiedBookingSales] Failed to refresh discounts after session restore', _context.t0);
591
+ case 19:
592
+ return _context.abrupt("return", ((_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder()) || tempOrder);
593
+ case 20:
594
+ case "end":
595
+ return _context.stop();
596
+ }
597
+ }, _callee, this, [[11, 16]]);
598
+ }));
599
+ function addNewOrder() {
600
+ return _addNewOrder.apply(this, arguments);
601
+ }
602
+ return addNewOrder;
603
+ }()
536
604
  /**
537
605
  * Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
538
606
  * business/channel target so a reused solution instance cannot leak another entry's menus.
@@ -540,13 +608,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
540
608
  }, {
541
609
  key: "loadOpenData",
542
610
  value: (function () {
543
- var _loadOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(params) {
611
+ var _loadOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
544
612
  var businessCode, channel, target, cachedData, lastFetchedAt, openData;
545
- return _regeneratorRuntime().wrap(function _callee$(_context) {
546
- while (1) switch (_context.prev = _context.next) {
613
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
614
+ while (1) switch (_context2.prev = _context2.next) {
547
615
  case 0:
548
616
  if (this.store.openData) {
549
- _context.next = 2;
617
+ _context2.next = 2;
550
618
  break;
551
619
  }
552
620
  throw new Error('[UnifiedBookingSales] openData 模块未初始化');
@@ -554,7 +622,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
554
622
  businessCode = String(params.businessCode || '').trim();
555
623
  channel = String(params.channel || '').trim();
556
624
  if (!(!businessCode || !channel)) {
557
- _context.next = 6;
625
+ _context2.next = 6;
558
626
  break;
559
627
  }
560
628
  throw new Error('[UnifiedBookingSales] OpenData 需要 businessCode 与 channel');
@@ -563,28 +631,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
563
631
  cachedData = this.store.openData.getOpenData();
564
632
  lastFetchedAt = this.store.openData.getLastFetchedAt();
565
633
  if (!(!params.force && this.openDataTarget === target && cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
566
- _context.next = 11;
634
+ _context2.next = 11;
567
635
  break;
568
636
  }
569
- return _context.abrupt("return", cachedData);
637
+ return _context2.abrupt("return", cachedData);
570
638
  case 11:
571
639
  if (!this.loadOpenDataInFlight) {
572
- _context.next = 19;
640
+ _context2.next = 19;
573
641
  break;
574
642
  }
575
643
  if (!(this.loadOpenDataInFlightTarget === target)) {
576
- _context.next = 16;
644
+ _context2.next = 16;
577
645
  break;
578
646
  }
579
- _context.next = 15;
647
+ _context2.next = 15;
580
648
  return this.loadOpenDataInFlight;
581
649
  case 15:
582
- return _context.abrupt("return", _context.sent);
650
+ return _context2.abrupt("return", _context2.sent);
583
651
  case 16:
584
- _context.next = 18;
652
+ _context2.next = 18;
585
653
  return this.loadOpenDataInFlight;
586
654
  case 18:
587
- return _context.abrupt("return", this.loadOpenData(params));
655
+ return _context2.abrupt("return", this.loadOpenData(params));
588
656
  case 19:
589
657
  this.loadOpenDataInFlightTarget = target;
590
658
  this.loadOpenDataInFlight = this.store.openData.fetchOpenData({
@@ -592,26 +660,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
592
660
  target: target,
593
661
  section_code: [].concat(OPEN_DATA_SECTION_CODES)
594
662
  });
595
- _context.prev = 21;
596
- _context.next = 24;
663
+ _context2.prev = 21;
664
+ _context2.next = 24;
597
665
  return this.loadOpenDataInFlight;
598
666
  case 24:
599
- openData = _context.sent;
667
+ openData = _context2.sent;
600
668
  this.openDataTarget = target;
601
669
  this.otherParams.openData = openData;
602
670
  this.otherParams.businessCode = businessCode;
603
671
  this.otherParams.channel = channel;
604
- return _context.abrupt("return", openData);
672
+ return _context2.abrupt("return", openData);
605
673
  case 30:
606
- _context.prev = 30;
674
+ _context2.prev = 30;
607
675
  this.loadOpenDataInFlight = null;
608
676
  this.loadOpenDataInFlightTarget = null;
609
- return _context.finish(30);
677
+ return _context2.finish(30);
610
678
  case 34:
611
679
  case "end":
612
- return _context.stop();
680
+ return _context2.stop();
613
681
  }
614
- }, _callee, this, [[21,, 30, 34]]);
682
+ }, _callee2, this, [[21,, 30, 34]]);
615
683
  }));
616
684
  function loadOpenData(_x) {
617
685
  return _loadOpenData.apply(this, arguments);
@@ -621,17 +689,37 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
621
689
  }, {
622
690
  key: "getOpenData",
623
691
  value: function () {
624
- var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
625
- var _this$store$openData;
626
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
627
- while (1) switch (_context2.prev = _context2.next) {
692
+ var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
693
+ var _this$otherParams3, _this$otherParams4, _this$store$openData;
694
+ var businessCode, channel, target, cachedData;
695
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
696
+ while (1) switch (_context3.prev = _context3.next) {
628
697
  case 0:
629
- return _context2.abrupt("return", ((_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData()) || null);
630
- case 1:
698
+ businessCode = String(((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.businessCode) || '').trim();
699
+ channel = String(((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.channel) || '').trim();
700
+ if (!(!businessCode || !channel)) {
701
+ _context3.next = 4;
702
+ break;
703
+ }
704
+ return _context3.abrupt("return", null);
705
+ case 4:
706
+ target = "".concat(businessCode, "+").concat(channel);
707
+ cachedData = ((_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData()) || null;
708
+ if (!(cachedData && this.openDataTarget === target)) {
709
+ _context3.next = 8;
710
+ break;
711
+ }
712
+ return _context3.abrupt("return", cachedData);
713
+ case 8:
714
+ return _context3.abrupt("return", this.loadOpenData({
715
+ businessCode: businessCode,
716
+ channel: channel
717
+ }));
718
+ case 9:
631
719
  case "end":
632
- return _context2.stop();
720
+ return _context3.stop();
633
721
  }
634
- }, _callee2, this);
722
+ }, _callee3, this);
635
723
  }));
636
724
  function getOpenData() {
637
725
  return _getOpenData.apply(this, arguments);
@@ -645,27 +733,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
645
733
  }, {
646
734
  key: "loadProducts",
647
735
  value: (function () {
648
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
736
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
649
737
  var params,
650
738
  options,
651
739
  schedule_date,
652
740
  schedule_datetime,
653
741
  result,
654
- _args3 = arguments;
655
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
656
- while (1) switch (_context3.prev = _context3.next) {
742
+ _args4 = arguments;
743
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
744
+ while (1) switch (_context4.prev = _context4.next) {
657
745
  case 0:
658
- params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
659
- options = _args3.length > 1 ? _args3[1] : undefined;
746
+ params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
747
+ options = _args4.length > 1 ? _args4[1] : undefined;
660
748
  if (this.store.products) {
661
- _context3.next = 4;
749
+ _context4.next = 4;
662
750
  break;
663
751
  }
664
752
  throw new Error('[UnifiedBookingSales] products 模块未初始化');
665
753
  case 4:
666
754
  schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
667
755
  schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
668
- _context3.next = 8;
756
+ _context4.next = 8;
669
757
  return this.store.products.loadProducts(_objectSpread(_objectSpread({
670
758
  with_count: ['bundleGroup', 'optionGroup'],
671
759
  with_schedule: 1
@@ -675,17 +763,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
675
763
  cacheId: this.cacheId
676
764
  }), options);
677
765
  case 8:
678
- result = _context3.sent;
766
+ result = _context4.sent;
679
767
  this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
680
- _context3.next = 12;
768
+ _context4.next = 12;
681
769
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
682
770
  case 12:
683
- return _context3.abrupt("return", result);
771
+ return _context4.abrupt("return", result);
684
772
  case 13:
685
773
  case "end":
686
- return _context3.stop();
774
+ return _context4.stop();
687
775
  }
688
- }, _callee3, this);
776
+ }, _callee4, this);
689
777
  }));
690
778
  function loadProducts() {
691
779
  return _loadProducts.apply(this, arguments);
@@ -695,22 +783,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
695
783
  }, {
696
784
  key: "loadScheduleAvailableDate",
697
785
  value: (function () {
698
- var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
699
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
700
- while (1) switch (_context4.prev = _context4.next) {
786
+ var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
787
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
788
+ while (1) switch (_context5.prev = _context5.next) {
701
789
  case 0:
702
790
  if (this.store.schedule) {
703
- _context4.next = 2;
791
+ _context5.next = 2;
704
792
  break;
705
793
  }
706
794
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
707
795
  case 2:
708
- return _context4.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
796
+ return _context5.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
709
797
  case 3:
710
798
  case "end":
711
- return _context4.stop();
799
+ return _context5.stop();
712
800
  }
713
- }, _callee4, this);
801
+ }, _callee5, this);
714
802
  }));
715
803
  function loadScheduleAvailableDate(_x2) {
716
804
  return _loadScheduleAvailableDate.apply(this, arguments);
@@ -726,15 +814,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
726
814
  }, {
727
815
  key: "loadProductsByScheduleDate",
728
816
  value: (function () {
729
- var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
817
+ var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
730
818
  var _this$store$schedule$, _this$store$schedule, _this$store$schedule$2, _this$store$schedule2, _this$store$schedule$3, _this$store$schedule3, _this$store$schedule$4, _this$store$schedule4;
731
819
  var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator, _step, productId, result;
732
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
733
- while (1) switch (_context5.prev = _context5.next) {
820
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
821
+ while (1) switch (_context6.prev = _context6.next) {
734
822
  case 0:
735
823
  date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
736
824
  if (this.store.schedule) {
737
- _context5.next = 3;
825
+ _context6.next = 3;
738
826
  break;
739
827
  }
740
828
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
@@ -745,10 +833,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
745
833
  });
746
834
  hasOtherProducts = (((_this$store$schedule$2 = (_this$store$schedule2 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$2 === void 0 ? void 0 : _this$store$schedule$2.call(_this$store$schedule2)) || []).length > 0;
747
835
  if (!(!hasCachedDate && !hasOtherProducts)) {
748
- _context5.next = 9;
836
+ _context6.next = 9;
749
837
  break;
750
838
  }
751
- _context5.next = 9;
839
+ _context6.next = 9;
752
840
  return this.loadScheduleAvailableDate({
753
841
  startDate: date,
754
842
  endDate: date,
@@ -768,45 +856,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
768
856
  return !productIdFilter || productIdFilter.has(String(id));
769
857
  });
770
858
  if (availableProductIds.length) {
771
- _context5.next = 17;
859
+ _context6.next = 17;
772
860
  break;
773
861
  }
774
862
  this.unifiedProductCatalog = [];
775
- _context5.next = 16;
863
+ _context6.next = 16;
776
864
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
777
865
  case 16:
778
- return _context5.abrupt("return", []);
866
+ return _context6.abrupt("return", []);
779
867
  case 17:
780
- _context5.next = 19;
868
+ _context6.next = 19;
781
869
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
782
870
  product_ids: availableProductIds,
783
871
  schedule_date: date
784
872
  }));
785
873
  case 19:
786
- products = _context5.sent;
874
+ products = _context6.sent;
787
875
  if (!(products.length || availableProductIds.length <= 1)) {
788
- _context5.next = 22;
876
+ _context6.next = 22;
789
877
  break;
790
878
  }
791
- return _context5.abrupt("return", products);
879
+ return _context6.abrupt("return", products);
792
880
  case 22:
793
881
  fallbackProducts = [];
794
882
  _iterator = _createForOfIteratorHelper(availableProductIds);
795
- _context5.prev = 24;
883
+ _context6.prev = 24;
796
884
  _iterator.s();
797
885
  case 26:
798
886
  if ((_step = _iterator.n()).done) {
799
- _context5.next = 34;
887
+ _context6.next = 34;
800
888
  break;
801
889
  }
802
890
  productId = _step.value;
803
- _context5.next = 30;
891
+ _context6.next = 30;
804
892
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
805
893
  product_ids: [productId],
806
894
  schedule_date: date
807
895
  }));
808
896
  case 30:
809
- result = _context5.sent;
897
+ result = _context6.sent;
810
898
  result.forEach(function (product) {
811
899
  var _id;
812
900
  var id = (_id = product === null || product === void 0 ? void 0 : product.id) !== null && _id !== void 0 ? _id : product === null || product === void 0 ? void 0 : product.product_id;
@@ -818,30 +906,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
818
906
  }
819
907
  });
820
908
  case 32:
821
- _context5.next = 26;
909
+ _context6.next = 26;
822
910
  break;
823
911
  case 34:
824
- _context5.next = 39;
912
+ _context6.next = 39;
825
913
  break;
826
914
  case 36:
827
- _context5.prev = 36;
828
- _context5.t0 = _context5["catch"](24);
829
- _iterator.e(_context5.t0);
915
+ _context6.prev = 36;
916
+ _context6.t0 = _context6["catch"](24);
917
+ _iterator.e(_context6.t0);
830
918
  case 39:
831
- _context5.prev = 39;
919
+ _context6.prev = 39;
832
920
  _iterator.f();
833
- return _context5.finish(39);
921
+ return _context6.finish(39);
834
922
  case 42:
835
923
  this.unifiedProductCatalog = [].concat(fallbackProducts);
836
- _context5.next = 45;
924
+ _context6.next = 45;
837
925
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
838
926
  case 45:
839
- return _context5.abrupt("return", fallbackProducts);
927
+ return _context6.abrupt("return", fallbackProducts);
840
928
  case 46:
841
929
  case "end":
842
- return _context5.stop();
930
+ return _context6.stop();
843
931
  }
844
- }, _callee5, this, [[24, 36, 39, 42]]);
932
+ }, _callee6, this, [[24, 36, 39, 42]]);
845
933
  }));
846
934
  function loadProductsByScheduleDate(_x3) {
847
935
  return _loadProductsByScheduleDate.apply(this, arguments);
@@ -895,7 +983,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
895
983
  }, {
896
984
  key: "applyPlannerDiscounts",
897
985
  value: (function () {
898
- var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
986
+ var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
899
987
  var _params$customerId;
900
988
  var params,
901
989
  tempOrder,
@@ -912,24 +1000,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
912
1000
  discount,
913
1001
  discountId,
914
1002
  nextTempOrder,
915
- _args6 = arguments;
916
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
917
- while (1) switch (_context6.prev = _context6.next) {
1003
+ _args7 = arguments;
1004
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1005
+ while (1) switch (_context7.prev = _context7.next) {
918
1006
  case 0:
919
- params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
1007
+ params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
920
1008
  tempOrder = this.getTempOrder();
921
1009
  requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
922
1010
  parsedCustomerId = Number(requestedCustomerId);
923
1011
  customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
924
- _context6.next = 7;
1012
+ _context7.next = 7;
925
1013
  return this.getSummary();
926
1014
  case 7:
927
- summaryBefore = _context6.sent;
1015
+ summaryBefore = _context7.sent;
928
1016
  if (customerId) {
929
- _context6.next = 10;
1017
+ _context7.next = 10;
930
1018
  break;
931
1019
  }
932
- return _context6.abrupt("return", buildPlannerDiscountResult({
1020
+ return _context7.abrupt("return", buildPlannerDiscountResult({
933
1021
  customerId: null,
934
1022
  discountList: this.getDiscountList(),
935
1023
  products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
@@ -938,7 +1026,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
938
1026
  status: 'no_customer'
939
1027
  }));
940
1028
  case 10:
941
- _context6.next = 12;
1029
+ _context7.next = 12;
942
1030
  return this.loadDiscountConfig({
943
1031
  customerId: customerId,
944
1032
  action: 'create'
@@ -950,7 +1038,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
950
1038
  return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
951
1039
  });
952
1040
  if (!preferredDiscount) {
953
- _context6.next = 40;
1041
+ _context7.next = 40;
954
1042
  break;
955
1043
  }
956
1044
  // A requested card is an explicit UI choice, not a best-effort preference. Clear prior
@@ -962,98 +1050,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
962
1050
  return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
963
1051
  });
964
1052
  _iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
965
- _context6.prev = 18;
1053
+ _context7.prev = 18;
966
1054
  _iterator2.s();
967
1055
  case 20:
968
1056
  if ((_step2 = _iterator2.n()).done) {
969
- _context6.next = 28;
1057
+ _context7.next = 28;
970
1058
  break;
971
1059
  }
972
1060
  discount = _step2.value;
973
1061
  discountId = Number(resolvePlannerDiscountId(discount));
974
1062
  if (!Number.isFinite(discountId)) {
975
- _context6.next = 26;
1063
+ _context7.next = 26;
976
1064
  break;
977
1065
  }
978
- _context6.next = 26;
1066
+ _context7.next = 26;
979
1067
  return this.setDiscountSelected({
980
1068
  discountId: discountId,
981
1069
  isSelected: false
982
1070
  });
983
1071
  case 26:
984
- _context6.next = 20;
1072
+ _context7.next = 20;
985
1073
  break;
986
1074
  case 28:
987
- _context6.next = 33;
1075
+ _context7.next = 33;
988
1076
  break;
989
1077
  case 30:
990
- _context6.prev = 30;
991
- _context6.t0 = _context6["catch"](18);
992
- _iterator2.e(_context6.t0);
1078
+ _context7.prev = 30;
1079
+ _context7.t0 = _context7["catch"](18);
1080
+ _iterator2.e(_context7.t0);
993
1081
  case 33:
994
- _context6.prev = 33;
1082
+ _context7.prev = 33;
995
1083
  _iterator2.f();
996
- return _context6.finish(33);
1084
+ return _context7.finish(33);
997
1085
  case 36:
998
- _context6.next = 38;
1086
+ _context7.next = 38;
999
1087
  return this.setDiscountSelected({
1000
1088
  discountId: Number(preferredId),
1001
1089
  isSelected: true
1002
1090
  });
1003
1091
  case 38:
1004
- _context6.next = 49;
1092
+ _context7.next = 49;
1005
1093
  break;
1006
1094
  case 40:
1007
1095
  if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
1008
- _context6.next = 46;
1096
+ _context7.next = 46;
1009
1097
  break;
1010
1098
  }
1011
1099
  if (!(params.applyBestDiscount !== false)) {
1012
- _context6.next = 44;
1100
+ _context7.next = 44;
1013
1101
  break;
1014
1102
  }
1015
- _context6.next = 44;
1103
+ _context7.next = 44;
1016
1104
  return this.bestDiscount();
1017
1105
  case 44:
1018
- _context6.next = 49;
1106
+ _context7.next = 49;
1019
1107
  break;
1020
1108
  case 46:
1021
1109
  if (!(params.applyBestDiscount !== false)) {
1022
- _context6.next = 49;
1110
+ _context7.next = 49;
1023
1111
  break;
1024
1112
  }
1025
- _context6.next = 49;
1113
+ _context7.next = 49;
1026
1114
  return this.bestDiscount();
1027
1115
  case 49:
1028
1116
  nextTempOrder = this.getTempOrder();
1029
- _context6.t1 = buildPlannerDiscountResult;
1030
- _context6.t2 = customerId;
1031
- _context6.t3 = this.getDiscountList();
1032
- _context6.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
1033
- _context6.t5 = summaryBefore;
1034
- _context6.next = 57;
1117
+ _context7.t1 = buildPlannerDiscountResult;
1118
+ _context7.t2 = customerId;
1119
+ _context7.t3 = this.getDiscountList();
1120
+ _context7.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
1121
+ _context7.t5 = summaryBefore;
1122
+ _context7.next = 57;
1035
1123
  return this.getSummary();
1036
1124
  case 57:
1037
- _context6.t6 = _context6.sent;
1038
- _context6.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
1039
- _context6.t8 = preferredDiscountId;
1040
- _context6.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
1041
- _context6.t10 = {
1042
- customerId: _context6.t2,
1043
- discountList: _context6.t3,
1044
- products: _context6.t4,
1045
- summaryBefore: _context6.t5,
1046
- summaryAfter: _context6.t6,
1047
- status: _context6.t7,
1048
- preferredDiscountId: _context6.t8,
1049
- preferredDiscountFound: _context6.t9
1125
+ _context7.t6 = _context7.sent;
1126
+ _context7.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
1127
+ _context7.t8 = preferredDiscountId;
1128
+ _context7.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
1129
+ _context7.t10 = {
1130
+ customerId: _context7.t2,
1131
+ discountList: _context7.t3,
1132
+ products: _context7.t4,
1133
+ summaryBefore: _context7.t5,
1134
+ summaryAfter: _context7.t6,
1135
+ status: _context7.t7,
1136
+ preferredDiscountId: _context7.t8,
1137
+ preferredDiscountFound: _context7.t9
1050
1138
  };
1051
- return _context6.abrupt("return", (0, _context6.t1)(_context6.t10));
1139
+ return _context7.abrupt("return", (0, _context7.t1)(_context7.t10));
1052
1140
  case 63:
1053
1141
  case "end":
1054
- return _context6.stop();
1142
+ return _context7.stop();
1055
1143
  }
1056
- }, _callee6, this, [[18, 30, 33, 36]]);
1144
+ }, _callee7, this, [[18, 30, 33, 36]]);
1057
1145
  }));
1058
1146
  function applyPlannerDiscounts() {
1059
1147
  return _applyPlannerDiscounts.apply(this, arguments);
@@ -1095,27 +1183,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1095
1183
  }, {
1096
1184
  key: "removeExistingStagedLines",
1097
1185
  value: (function () {
1098
- var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(ownershipKey) {
1186
+ var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ownershipKey) {
1099
1187
  var _this$getTempOrder;
1100
1188
  var existingLines;
1101
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1102
- while (1) switch (_context7.prev = _context7.next) {
1189
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1190
+ while (1) switch (_context8.prev = _context8.next) {
1103
1191
  case 0:
1104
1192
  existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
1105
1193
  var _product$metadata3;
1106
1194
  return (product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3[ownershipKey]) === true;
1107
1195
  });
1108
1196
  if (!(existingLines.length > 0)) {
1109
- _context7.next = 4;
1197
+ _context8.next = 4;
1110
1198
  break;
1111
1199
  }
1112
- _context7.next = 4;
1200
+ _context8.next = 4;
1113
1201
  return this.removeProductsFromOrder(existingLines.map(buildPlannerLineIdentity));
1114
1202
  case 4:
1115
1203
  case "end":
1116
- return _context7.stop();
1204
+ return _context8.stop();
1117
1205
  }
1118
- }, _callee7, this);
1206
+ }, _callee8, this);
1119
1207
  }));
1120
1208
  function removeExistingStagedLines(_x4) {
1121
1209
  return _removeExistingStagedLines.apply(this, arguments);
@@ -1125,25 +1213,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1125
1213
  }, {
1126
1214
  key: "stageProducts",
1127
1215
  value: function () {
1128
- var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params, ownershipKey) {
1216
+ var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params, ownershipKey) {
1129
1217
  var _params$rawProducts;
1130
1218
  var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
1131
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1132
- while (1) switch (_context8.prev = _context8.next) {
1219
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1220
+ while (1) switch (_context9.prev = _context9.next) {
1133
1221
  case 0:
1134
1222
  productIds = params.productIds || [];
1135
1223
  if (productIds.length) {
1136
- _context8.next = 3;
1224
+ _context9.next = 3;
1137
1225
  break;
1138
1226
  }
1139
- return _context8.abrupt("return", this.getTempOrder());
1227
+ return _context9.abrupt("return", this.getTempOrder());
1140
1228
  case 3:
1141
1229
  if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
1142
- _context8.next = 7;
1230
+ _context9.next = 7;
1143
1231
  break;
1144
1232
  }
1145
1233
  this.unifiedProductCatalog = params.rawProducts;
1146
- _context8.next = 12;
1234
+ _context9.next = 12;
1147
1235
  break;
1148
1236
  case 7:
1149
1237
  existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
@@ -1154,15 +1242,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1154
1242
  return !existingIds.has(String(id));
1155
1243
  });
1156
1244
  if (!(missingIds.length || params.productLoadParams)) {
1157
- _context8.next = 12;
1245
+ _context9.next = 12;
1158
1246
  break;
1159
1247
  }
1160
- _context8.next = 12;
1248
+ _context9.next = 12;
1161
1249
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
1162
1250
  product_ids: productIds.map(Number).filter(Number.isFinite)
1163
1251
  }));
1164
1252
  case 12:
1165
- _context8.next = 14;
1253
+ _context9.next = 14;
1166
1254
  return this.removeExistingStagedLines(ownershipKey);
1167
1255
  case 14:
1168
1256
  productIdSet = new Set(productIds.map(function (id) {
@@ -1175,28 +1263,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1175
1263
  _i = 0, _arr = selectedProducts;
1176
1264
  case 17:
1177
1265
  if (!(_i < _arr.length)) {
1178
- _context8.next = 26;
1266
+ _context9.next = 26;
1179
1267
  break;
1180
1268
  }
1181
1269
  sourceProduct = _arr[_i];
1182
1270
  productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
1183
1271
  if (!productInput) {
1184
- _context8.next = 23;
1272
+ _context9.next = 23;
1185
1273
  break;
1186
1274
  }
1187
- _context8.next = 23;
1275
+ _context9.next = 23;
1188
1276
  return this.addProductToOrder(productInput);
1189
1277
  case 23:
1190
1278
  _i++;
1191
- _context8.next = 17;
1279
+ _context9.next = 17;
1192
1280
  break;
1193
1281
  case 26:
1194
- return _context8.abrupt("return", this.getTempOrder());
1282
+ return _context9.abrupt("return", this.getTempOrder());
1195
1283
  case 27:
1196
1284
  case "end":
1197
- return _context8.stop();
1285
+ return _context9.stop();
1198
1286
  }
1199
- }, _callee8, this);
1287
+ }, _callee9, this);
1200
1288
  }));
1201
1289
  function stageProducts(_x5, _x6) {
1202
1290
  return _stageProducts.apply(this, arguments);
@@ -1210,16 +1298,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1210
1298
  }, {
1211
1299
  key: "stagePlannerProducts",
1212
1300
  value: (function () {
1213
- var _stagePlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
1214
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1215
- while (1) switch (_context9.prev = _context9.next) {
1301
+ var _stagePlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1302
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1303
+ while (1) switch (_context10.prev = _context10.next) {
1216
1304
  case 0:
1217
- return _context9.abrupt("return", this.stageProducts(params, 'unified_booking_sales'));
1305
+ return _context10.abrupt("return", this.stageProducts(params, 'unified_booking_sales'));
1218
1306
  case 1:
1219
1307
  case "end":
1220
- return _context9.stop();
1308
+ return _context10.stop();
1221
1309
  }
1222
- }, _callee9, this);
1310
+ }, _callee10, this);
1223
1311
  }));
1224
1312
  function stagePlannerProducts(_x7) {
1225
1313
  return _stagePlannerProducts.apply(this, arguments);
@@ -1234,16 +1322,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1234
1322
  }, {
1235
1323
  key: "stageRetailProducts",
1236
1324
  value: (function () {
1237
- var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1238
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1239
- while (1) switch (_context10.prev = _context10.next) {
1325
+ var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
1326
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1327
+ while (1) switch (_context11.prev = _context11.next) {
1240
1328
  case 0:
1241
- return _context10.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
1329
+ return _context11.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
1242
1330
  case 1:
1243
1331
  case "end":
1244
- return _context10.stop();
1332
+ return _context11.stop();
1245
1333
  }
1246
- }, _callee10, this);
1334
+ }, _callee11, this);
1247
1335
  }));
1248
1336
  function stageRetailProducts(_x8) {
1249
1337
  return _stageRetailProducts.apply(this, arguments);
@@ -1259,15 +1347,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1259
1347
  }, {
1260
1348
  key: "addRetailProduct",
1261
1349
  value: (function () {
1262
- var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
1350
+ var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
1263
1351
  var _params$quantity, _ref18, _params$productId, _params$product, _params$product2;
1264
1352
  var quantity, productId, sourceProduct, products, orderProduct;
1265
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1266
- while (1) switch (_context11.prev = _context11.next) {
1353
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1354
+ while (1) switch (_context12.prev = _context12.next) {
1267
1355
  case 0:
1268
1356
  quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
1269
1357
  if (!(!Number.isFinite(quantity) || quantity <= 0)) {
1270
- _context11.next = 3;
1358
+ _context12.next = 3;
1271
1359
  break;
1272
1360
  }
1273
1361
  throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
@@ -1281,22 +1369,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1281
1369
  });
1282
1370
  }
1283
1371
  if (!(!sourceProduct && productId !== undefined && productId !== null)) {
1284
- _context11.next = 11;
1372
+ _context12.next = 11;
1285
1373
  break;
1286
1374
  }
1287
- _context11.next = 9;
1375
+ _context12.next = 9;
1288
1376
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
1289
1377
  product_ids: [Number(productId)].filter(Number.isFinite)
1290
1378
  }));
1291
1379
  case 9:
1292
- products = _context11.sent;
1380
+ products = _context12.sent;
1293
1381
  sourceProduct = products.find(function (product) {
1294
1382
  var _product$id4;
1295
1383
  return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
1296
1384
  });
1297
1385
  case 11:
1298
1386
  if (sourceProduct) {
1299
- _context11.next = 13;
1387
+ _context12.next = 13;
1300
1388
  break;
1301
1389
  }
1302
1390
  throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
@@ -1305,17 +1393,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1305
1393
  quantity: quantity
1306
1394
  }), 'unified_booking_sales_retail');
1307
1395
  if (orderProduct) {
1308
- _context11.next = 16;
1396
+ _context12.next = 16;
1309
1397
  break;
1310
1398
  }
1311
1399
  throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
1312
1400
  case 16:
1313
- return _context11.abrupt("return", this.addProductToOrder(orderProduct));
1401
+ return _context12.abrupt("return", this.addProductToOrder(orderProduct));
1314
1402
  case 17:
1315
1403
  case "end":
1316
- return _context11.stop();
1404
+ return _context12.stop();
1317
1405
  }
1318
- }, _callee11, this);
1406
+ }, _callee12, this);
1319
1407
  }));
1320
1408
  function addRetailProduct(_x9) {
1321
1409
  return _addRetailProduct.apply(this, arguments);
@@ -1325,42 +1413,42 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1325
1413
  }, {
1326
1414
  key: "loadPlannerProducts",
1327
1415
  value: (function () {
1328
- var _loadPlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
1416
+ var _loadPlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
1329
1417
  var _params$context, _params$rawProducts2, _params$productLoadPa, _this$getProductCatal;
1330
1418
  var productIds, _params$productLoadPa2;
1331
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1332
- while (1) switch (_context12.prev = _context12.next) {
1419
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1420
+ while (1) switch (_context13.prev = _context13.next) {
1333
1421
  case 0:
1334
1422
  if (!((_params$context = params.context) !== null && _params$context !== void 0 && (_params$context = _params$context.products) !== null && _params$context !== void 0 && _params$context.length)) {
1335
- _context12.next = 2;
1423
+ _context13.next = 2;
1336
1424
  break;
1337
1425
  }
1338
- return _context12.abrupt("return", params.context.products);
1426
+ return _context13.abrupt("return", params.context.products);
1339
1427
  case 2:
1340
1428
  if (!((_params$rawProducts2 = params.rawProducts) !== null && _params$rawProducts2 !== void 0 && _params$rawProducts2.length)) {
1341
- _context12.next = 4;
1429
+ _context13.next = 4;
1342
1430
  break;
1343
1431
  }
1344
- return _context12.abrupt("return", params.rawProducts.map(normalizeProductForPlanner));
1432
+ return _context13.abrupt("return", params.rawProducts.map(normalizeProductForPlanner));
1345
1433
  case 4:
1346
1434
  productIds = params.productIds || ((_params$productLoadPa = params.productLoadParams) === null || _params$productLoadPa === void 0 ? void 0 : _params$productLoadPa.product_ids) || [];
1347
1435
  if (!(productIds.length > 0 || params.productLoadParams)) {
1348
- _context12.next = 8;
1436
+ _context13.next = 8;
1349
1437
  break;
1350
1438
  }
1351
- _context12.next = 8;
1439
+ _context13.next = 8;
1352
1440
  return this.loadProducts(_objectSpread(_objectSpread(_objectSpread({}, params.date ? {
1353
1441
  schedule_date: params.date
1354
1442
  } : {}), params.productLoadParams || {}), {}, {
1355
1443
  product_ids: productIds.length ? productIds.map(Number).filter(Number.isFinite) : (_params$productLoadPa2 = params.productLoadParams) === null || _params$productLoadPa2 === void 0 ? void 0 : _params$productLoadPa2.product_ids
1356
1444
  }));
1357
1445
  case 8:
1358
- return _context12.abrupt("return", (((_this$getProductCatal = this.getProductCatalog) === null || _this$getProductCatal === void 0 ? void 0 : _this$getProductCatal.call(this).products) || []).map(normalizeProductForPlanner));
1446
+ return _context13.abrupt("return", (((_this$getProductCatal = this.getProductCatalog) === null || _this$getProductCatal === void 0 ? void 0 : _this$getProductCatal.call(this).products) || []).map(normalizeProductForPlanner));
1359
1447
  case 9:
1360
1448
  case "end":
1361
- return _context12.stop();
1449
+ return _context13.stop();
1362
1450
  }
1363
- }, _callee12, this);
1451
+ }, _callee13, this);
1364
1452
  }));
1365
1453
  function loadPlannerProducts(_x10) {
1366
1454
  return _loadPlannerProducts.apply(this, arguments);
@@ -1370,32 +1458,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1370
1458
  }, {
1371
1459
  key: "ensurePlannerSchedulesLoaded",
1372
1460
  value: (function () {
1373
- var _ensurePlannerSchedulesLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1461
+ var _ensurePlannerSchedulesLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1374
1462
  var _this$store$schedule$5, _this$store$schedule5, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7;
1375
1463
  var scheduleList;
1376
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1377
- while (1) switch (_context13.prev = _context13.next) {
1464
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1465
+ while (1) switch (_context14.prev = _context14.next) {
1378
1466
  case 0:
1379
1467
  if (this.store.schedule) {
1380
- _context13.next = 2;
1468
+ _context14.next = 2;
1381
1469
  break;
1382
1470
  }
1383
1471
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
1384
1472
  case 2:
1385
1473
  scheduleList = ((_this$store$schedule$5 = (_this$store$schedule5 = this.store.schedule).getScheduleList) === null || _this$store$schedule$5 === void 0 ? void 0 : _this$store$schedule$5.call(_this$store$schedule5)) || [];
1386
1474
  if (!(!((_this$store$schedule$6 = (_this$store$schedule6 = this.store.schedule).isScheduleListLoaded) !== null && _this$store$schedule$6 !== void 0 && _this$store$schedule$6.call(_this$store$schedule6)) || scheduleList.length === 0)) {
1387
- _context13.next = 6;
1475
+ _context14.next = 6;
1388
1476
  break;
1389
1477
  }
1390
- _context13.next = 6;
1478
+ _context14.next = 6;
1391
1479
  return this.store.schedule.loadAllSchedule();
1392
1480
  case 6:
1393
- return _context13.abrupt("return", ((_this$store$schedule$7 = (_this$store$schedule7 = this.store.schedule).getScheduleList) === null || _this$store$schedule$7 === void 0 ? void 0 : _this$store$schedule$7.call(_this$store$schedule7)) || []);
1481
+ return _context14.abrupt("return", ((_this$store$schedule$7 = (_this$store$schedule7 = this.store.schedule).getScheduleList) === null || _this$store$schedule$7 === void 0 ? void 0 : _this$store$schedule$7.call(_this$store$schedule7)) || []);
1394
1482
  case 7:
1395
1483
  case "end":
1396
- return _context13.stop();
1484
+ return _context14.stop();
1397
1485
  }
1398
- }, _callee13, this);
1486
+ }, _callee14, this);
1399
1487
  }));
1400
1488
  function ensurePlannerSchedulesLoaded() {
1401
1489
  return _ensurePlannerSchedulesLoaded.apply(this, arguments);
@@ -1410,33 +1498,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1410
1498
  }, {
1411
1499
  key: "ensurePlannerSchedulesForResources",
1412
1500
  value: (function () {
1413
- var _ensurePlannerSchedulesForResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(rawResources) {
1501
+ var _ensurePlannerSchedulesForResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(rawResources) {
1414
1502
  var scheduleList, scheduleIds, _this$store$schedule$8, _this$store$schedule8;
1415
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1416
- while (1) switch (_context14.prev = _context14.next) {
1503
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1504
+ while (1) switch (_context15.prev = _context15.next) {
1417
1505
  case 0:
1418
- _context14.next = 2;
1506
+ _context15.next = 2;
1419
1507
  return this.ensurePlannerSchedulesLoaded();
1420
1508
  case 2:
1421
- scheduleList = _context14.sent;
1509
+ scheduleList = _context15.sent;
1422
1510
  scheduleIds = collectRawScheduleIds(rawResources);
1423
1511
  if (scheduleListHasIds(scheduleList, scheduleIds)) {
1424
- _context14.next = 8;
1512
+ _context15.next = 8;
1425
1513
  break;
1426
1514
  }
1427
- _context14.next = 7;
1515
+ _context15.next = 7;
1428
1516
  return this.store.schedule.loadAllSchedule({
1429
1517
  useCache: false
1430
1518
  });
1431
1519
  case 7:
1432
1520
  scheduleList = ((_this$store$schedule$8 = (_this$store$schedule8 = this.store.schedule).getScheduleList) === null || _this$store$schedule$8 === void 0 ? void 0 : _this$store$schedule$8.call(_this$store$schedule8)) || [];
1433
1521
  case 8:
1434
- return _context14.abrupt("return", scheduleList);
1522
+ return _context15.abrupt("return", scheduleList);
1435
1523
  case 9:
1436
1524
  case "end":
1437
- return _context14.stop();
1525
+ return _context15.stop();
1438
1526
  }
1439
- }, _callee14, this);
1527
+ }, _callee15, this);
1440
1528
  }));
1441
1529
  function ensurePlannerSchedulesForResources(_x11) {
1442
1530
  return _ensurePlannerSchedulesForResources.apply(this, arguments);
@@ -1452,12 +1540,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1452
1540
  }, {
1453
1541
  key: "fetchPlannerResourcesV2",
1454
1542
  value: (function () {
1455
- var _fetchPlannerResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
1543
+ var _fetchPlannerResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1456
1544
  var response, data;
1457
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1458
- while (1) switch (_context15.prev = _context15.next) {
1545
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1546
+ while (1) switch (_context16.prev = _context16.next) {
1459
1547
  case 0:
1460
- _context15.next = 2;
1548
+ _context16.next = 2;
1461
1549
  return this.request.get('/schedule/resource/list/v2', {
1462
1550
  start_date: params.dateRange.start,
1463
1551
  end_date: params.dateRange.end,
@@ -1467,26 +1555,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1467
1555
  useCache: false
1468
1556
  });
1469
1557
  case 2:
1470
- response = _context15.sent;
1558
+ response = _context16.sent;
1471
1559
  data = response === null || response === void 0 ? void 0 : response.data;
1472
1560
  if (!Array.isArray(data)) {
1473
- _context15.next = 6;
1561
+ _context16.next = 6;
1474
1562
  break;
1475
1563
  }
1476
- return _context15.abrupt("return", data);
1564
+ return _context16.abrupt("return", data);
1477
1565
  case 6:
1478
1566
  if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
1479
- _context15.next = 8;
1567
+ _context16.next = 8;
1480
1568
  break;
1481
1569
  }
1482
- return _context15.abrupt("return", data.list);
1570
+ return _context16.abrupt("return", data.list);
1483
1571
  case 8:
1484
- return _context15.abrupt("return", []);
1572
+ return _context16.abrupt("return", []);
1485
1573
  case 9:
1486
1574
  case "end":
1487
- return _context15.stop();
1575
+ return _context16.stop();
1488
1576
  }
1489
- }, _callee15, this);
1577
+ }, _callee16, this);
1490
1578
  }));
1491
1579
  function fetchPlannerResourcesV2(_x12) {
1492
1580
  return _fetchPlannerResourcesV.apply(this, arguments);
@@ -1501,7 +1589,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1501
1589
  }, {
1502
1590
  key: "loadPlannerResources",
1503
1591
  value: (function () {
1504
- var _loadPlannerResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
1592
+ var _loadPlannerResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
1505
1593
  var _params$context2, _params$rawResources, _params$context5;
1506
1594
  var products,
1507
1595
  _params$context3,
@@ -1510,25 +1598,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1510
1598
  rawResources,
1511
1599
  scheduleList,
1512
1600
  materialized,
1513
- _args16 = arguments;
1514
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1515
- while (1) switch (_context16.prev = _context16.next) {
1601
+ _args17 = arguments;
1602
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1603
+ while (1) switch (_context17.prev = _context17.next) {
1516
1604
  case 0:
1517
- products = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : [];
1605
+ products = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : [];
1518
1606
  if (!((_params$context2 = params.context) !== null && _params$context2 !== void 0 && (_params$context2 = _params$context2.resources) !== null && _params$context2 !== void 0 && _params$context2.length)) {
1519
- _context16.next = 3;
1607
+ _context17.next = 3;
1520
1608
  break;
1521
1609
  }
1522
- return _context16.abrupt("return", {
1610
+ return _context17.abrupt("return", {
1523
1611
  resources: params.context.resources,
1524
1612
  externalEvents: params.context.externalEvents || []
1525
1613
  });
1526
1614
  case 3:
1527
1615
  if (!((_params$rawResources = params.rawResources) !== null && _params$rawResources !== void 0 && _params$rawResources.length)) {
1528
- _context16.next = 5;
1616
+ _context17.next = 5;
1529
1617
  break;
1530
1618
  }
1531
- return _context16.abrupt("return", {
1619
+ return _context17.abrupt("return", {
1532
1620
  resources: params.rawResources.map(normalizeResource).filter(function (resource) {
1533
1621
  return resource !== null;
1534
1622
  }),
@@ -1537,39 +1625,39 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1537
1625
  case 5:
1538
1626
  resourceIds = collectPlannerResourceIds(products, params.resourceIds || []);
1539
1627
  if (!(!params.useResourceDateApi || !params.dateRange || resourceIds.length === 0)) {
1540
- _context16.next = 8;
1628
+ _context17.next = 8;
1541
1629
  break;
1542
1630
  }
1543
- return _context16.abrupt("return", {
1631
+ return _context17.abrupt("return", {
1544
1632
  resources: [],
1545
1633
  externalEvents: ((_params$context4 = params.context) === null || _params$context4 === void 0 ? void 0 : _params$context4.externalEvents) || []
1546
1634
  });
1547
1635
  case 8:
1548
- _context16.next = 10;
1636
+ _context17.next = 10;
1549
1637
  return this.fetchPlannerResourcesV2({
1550
1638
  dateRange: params.dateRange,
1551
1639
  resourceIds: resourceIds
1552
1640
  });
1553
1641
  case 10:
1554
- rawResources = _context16.sent;
1555
- _context16.next = 13;
1642
+ rawResources = _context17.sent;
1643
+ _context17.next = 13;
1556
1644
  return this.ensurePlannerSchedulesForResources(rawResources);
1557
1645
  case 13:
1558
- scheduleList = _context16.sent;
1646
+ scheduleList = _context17.sent;
1559
1647
  materialized = buildPlannerResourcesFromV2({
1560
1648
  rawResources: rawResources,
1561
1649
  scheduleList: scheduleList,
1562
1650
  dateRange: params.dateRange
1563
1651
  });
1564
- return _context16.abrupt("return", {
1652
+ return _context17.abrupt("return", {
1565
1653
  resources: materialized.resources,
1566
1654
  externalEvents: [].concat(_toConsumableArray(((_params$context5 = params.context) === null || _params$context5 === void 0 ? void 0 : _params$context5.externalEvents) || []), _toConsumableArray(materialized.externalEvents))
1567
1655
  });
1568
1656
  case 16:
1569
1657
  case "end":
1570
- return _context16.stop();
1658
+ return _context17.stop();
1571
1659
  }
1572
- }, _callee16, this);
1660
+ }, _callee17, this);
1573
1661
  }));
1574
1662
  function loadPlannerResources(_x13) {
1575
1663
  return _loadPlannerResources.apply(this, arguments);
@@ -1584,25 +1672,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1584
1672
  }, {
1585
1673
  key: "loadPlannerContext",
1586
1674
  value: (function () {
1587
- var _loadPlannerContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1675
+ var _loadPlannerContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1588
1676
  var params,
1589
1677
  products,
1590
1678
  plannerResources,
1591
1679
  context,
1592
1680
  snapshot,
1593
- _args17 = arguments;
1594
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1595
- while (1) switch (_context17.prev = _context17.next) {
1681
+ _args18 = arguments;
1682
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1683
+ while (1) switch (_context18.prev = _context18.next) {
1596
1684
  case 0:
1597
- params = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
1598
- _context17.next = 3;
1685
+ params = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
1686
+ _context18.next = 3;
1599
1687
  return this.loadPlannerProducts(params);
1600
1688
  case 3:
1601
- products = _context17.sent;
1602
- _context17.next = 6;
1689
+ products = _context18.sent;
1690
+ _context18.next = 6;
1603
1691
  return this.loadPlannerResources(params, products);
1604
1692
  case 6:
1605
- plannerResources = _context17.sent;
1693
+ plannerResources = _context18.sent;
1606
1694
  context = _objectSpread(_objectSpread({}, params.context || {}), {}, {
1607
1695
  products: products,
1608
1696
  resources: plannerResources.resources,
@@ -1617,15 +1705,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1617
1705
  endTime: params.endTime,
1618
1706
  resourceIds: params.resourceIds || []
1619
1707
  });
1620
- _context17.next = 12;
1708
+ _context18.next = 12;
1621
1709
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onPlannerContextLoaded), snapshot);
1622
1710
  case 12:
1623
- return _context17.abrupt("return", this.getPlanner().getSnapshot());
1711
+ return _context18.abrupt("return", this.getPlanner().getSnapshot());
1624
1712
  case 13:
1625
1713
  case "end":
1626
- return _context17.stop();
1714
+ return _context18.stop();
1627
1715
  }
1628
- }, _callee17, this);
1716
+ }, _callee18, this);
1629
1717
  }));
1630
1718
  function loadPlannerContext() {
1631
1719
  return _loadPlannerContext.apply(this, arguments);
@@ -1635,19 +1723,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1635
1723
  }, {
1636
1724
  key: "queryPlannerAvailability",
1637
1725
  value: (function () {
1638
- var _queryPlannerAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1726
+ var _queryPlannerAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1639
1727
  var query,
1640
- _args18 = arguments;
1641
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1642
- while (1) switch (_context18.prev = _context18.next) {
1728
+ _args19 = arguments;
1729
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1730
+ while (1) switch (_context19.prev = _context19.next) {
1643
1731
  case 0:
1644
- query = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
1645
- return _context18.abrupt("return", this.getPlanner().queryAvailability(query));
1732
+ query = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
1733
+ return _context19.abrupt("return", this.getPlanner().queryAvailability(query));
1646
1734
  case 2:
1647
1735
  case "end":
1648
- return _context18.stop();
1736
+ return _context19.stop();
1649
1737
  }
1650
- }, _callee18, this);
1738
+ }, _callee19, this);
1651
1739
  }));
1652
1740
  function queryPlannerAvailability() {
1653
1741
  return _queryPlannerAvailability.apply(this, arguments);
@@ -1675,24 +1763,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1675
1763
  }, {
1676
1764
  key: "autoAssignPlanner",
1677
1765
  value: (function () {
1678
- var _autoAssignPlanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1766
+ var _autoAssignPlanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1679
1767
  var query,
1680
1768
  result,
1681
- _args19 = arguments;
1682
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1683
- while (1) switch (_context19.prev = _context19.next) {
1769
+ _args20 = arguments;
1770
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1771
+ while (1) switch (_context20.prev = _context20.next) {
1684
1772
  case 0:
1685
- query = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
1773
+ query = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
1686
1774
  result = this.getPlanner().autoAssign(query);
1687
1775
  if (result.conflicts.length) {
1688
1776
  console.warn('[UnifiedBookingSales] autoAssignPlanner 存在未分配项', result.conflicts);
1689
1777
  }
1690
- return _context19.abrupt("return", this.getPlanner().getSnapshot());
1778
+ return _context20.abrupt("return", this.getPlanner().getSnapshot());
1691
1779
  case 4:
1692
1780
  case "end":
1693
- return _context19.stop();
1781
+ return _context20.stop();
1694
1782
  }
1695
- }, _callee19, this);
1783
+ }, _callee20, this);
1696
1784
  }));
1697
1785
  function autoAssignPlanner() {
1698
1786
  return _autoAssignPlanner.apply(this, arguments);
@@ -1719,7 +1807,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1719
1807
  }, {
1720
1808
  key: "commitPlannerSelection",
1721
1809
  value: (function () {
1722
- var _commitPlannerSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1810
+ var _commitPlannerSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1723
1811
  var params,
1724
1812
  snapshot,
1725
1813
  assignments,
@@ -1734,11 +1822,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1734
1822
  productInput,
1735
1823
  submitResult,
1736
1824
  result,
1737
- _args20 = arguments;
1738
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1739
- while (1) switch (_context20.prev = _context20.next) {
1825
+ _args21 = arguments;
1826
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1827
+ while (1) switch (_context21.prev = _context21.next) {
1740
1828
  case 0:
1741
- params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
1829
+ params = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
1742
1830
  if (params.selection) {
1743
1831
  this.setPlannerSelection(params.selection);
1744
1832
  }
@@ -1750,10 +1838,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1750
1838
  snapshot = this.getPlannerSnapshot();
1751
1839
  assignments = snapshot.selection.assignments || [];
1752
1840
  if (!(assignments.length === 0)) {
1753
- _context20.next = 7;
1841
+ _context21.next = 7;
1754
1842
  break;
1755
1843
  }
1756
- return _context20.abrupt("return", {
1844
+ return _context21.abrupt("return", {
1757
1845
  tempOrder: this.getTempOrder(),
1758
1846
  assignments: assignments,
1759
1847
  validation: {
@@ -1767,10 +1855,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1767
1855
  case 7:
1768
1856
  validation = this.validatePlannerSelection();
1769
1857
  if (validation.ok) {
1770
- _context20.next = 10;
1858
+ _context21.next = 10;
1771
1859
  break;
1772
1860
  }
1773
- return _context20.abrupt("return", {
1861
+ return _context21.abrupt("return", {
1774
1862
  tempOrder: this.getTempOrder(),
1775
1863
  assignments: assignments,
1776
1864
  validation: validation
@@ -1779,7 +1867,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1779
1867
  productsById = new Map(snapshot.context.products.map(function (product) {
1780
1868
  return [String(product.id), product];
1781
1869
  }));
1782
- _context20.next = 13;
1870
+ _context21.next = 13;
1783
1871
  return this.removeExistingStagedLines('unified_booking_sales');
1784
1872
  case 13:
1785
1873
  assignmentGroups = new Map();
@@ -1788,20 +1876,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1788
1876
  assignmentGroups.set(key, [].concat(_toConsumableArray(assignmentGroups.get(key) || []), [assignment]));
1789
1877
  });
1790
1878
  _iterator3 = _createForOfIteratorHelper(assignmentGroups.values());
1791
- _context20.prev = 16;
1879
+ _context21.prev = 16;
1792
1880
  _iterator3.s();
1793
1881
  case 18:
1794
1882
  if ((_step3 = _iterator3.n()).done) {
1795
- _context20.next = 31;
1883
+ _context21.next = 31;
1796
1884
  break;
1797
1885
  }
1798
1886
  groupAssignments = _step3.value;
1799
1887
  product = productsById.get(String(groupAssignments[0].productId));
1800
1888
  if (product) {
1801
- _context20.next = 23;
1889
+ _context21.next = 23;
1802
1890
  break;
1803
1891
  }
1804
- return _context20.abrupt("continue", 29);
1892
+ return _context21.abrupt("continue", 29);
1805
1893
  case 23:
1806
1894
  sourceProduct = product.raw || {
1807
1895
  id: product.id,
@@ -1810,39 +1898,39 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1810
1898
  };
1811
1899
  productInput = this.buildUnifiedOrderProduct(sourceProduct, 'unified_booking_sales', product);
1812
1900
  if (productInput) {
1813
- _context20.next = 27;
1901
+ _context21.next = 27;
1814
1902
  break;
1815
1903
  }
1816
- return _context20.abrupt("continue", 29);
1904
+ return _context21.abrupt("continue", 29);
1817
1905
  case 27:
1818
- _context20.next = 29;
1906
+ _context21.next = 29;
1819
1907
  return this.addProductToOrder(productInput, buildBookingFromAssignments({
1820
1908
  assignments: groupAssignments,
1821
1909
  product: product
1822
1910
  }));
1823
1911
  case 29:
1824
- _context20.next = 18;
1912
+ _context21.next = 18;
1825
1913
  break;
1826
1914
  case 31:
1827
- _context20.next = 36;
1915
+ _context21.next = 36;
1828
1916
  break;
1829
1917
  case 33:
1830
- _context20.prev = 33;
1831
- _context20.t0 = _context20["catch"](16);
1832
- _iterator3.e(_context20.t0);
1918
+ _context21.prev = 33;
1919
+ _context21.t0 = _context21["catch"](16);
1920
+ _iterator3.e(_context21.t0);
1833
1921
  case 36:
1834
- _context20.prev = 36;
1922
+ _context21.prev = 36;
1835
1923
  _iterator3.f();
1836
- return _context20.finish(36);
1924
+ return _context21.finish(36);
1837
1925
  case 39:
1838
1926
  if (!params.submitAfterCommit) {
1839
- _context20.next = 43;
1927
+ _context21.next = 43;
1840
1928
  break;
1841
1929
  }
1842
- _context20.next = 42;
1930
+ _context21.next = 42;
1843
1931
  return this.submitSalesOrder();
1844
1932
  case 42:
1845
- submitResult = _context20.sent;
1933
+ submitResult = _context21.sent;
1846
1934
  case 43:
1847
1935
  result = {
1848
1936
  tempOrder: this.getTempOrder(),
@@ -1850,15 +1938,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1850
1938
  validation: validation,
1851
1939
  submitResult: submitResult
1852
1940
  };
1853
- _context20.next = 46;
1941
+ _context21.next = 46;
1854
1942
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onPlannerCommitted), result);
1855
1943
  case 46:
1856
- return _context20.abrupt("return", result);
1944
+ return _context21.abrupt("return", result);
1857
1945
  case 47:
1858
1946
  case "end":
1859
- return _context20.stop();
1947
+ return _context21.stop();
1860
1948
  }
1861
- }, _callee20, this, [[16, 33, 36, 39]]);
1949
+ }, _callee21, this, [[16, 33, 36, 39]]);
1862
1950
  }));
1863
1951
  function commitPlannerSelection() {
1864
1952
  return _commitPlannerSelection.apply(this, arguments);