@pisell/pisellos 2.3.23 → 2.3.25

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.
@@ -560,33 +560,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
560
560
  return ((_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.getDiscountList()) || [];
561
561
  }
562
562
  }, {
563
- key: "ensureEditDiscountConfigForProductChange",
563
+ key: "syncScannedDiscountsToOriginalDiscountList",
564
564
  value: function () {
565
- var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tempOrder) {
566
- var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount6;
567
- var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
565
+ var _syncScannedDiscountsToOriginalDiscountList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(discountList) {
566
+ var _this$store$discount6, _this$store$discount7, _this$store$discount8, _this$store$discount9;
567
+ var scanDiscounts, scanDiscountIds, originalDiscounts, nextOriginalDiscounts;
568
568
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
569
569
  while (1) switch (_context4.prev = _context4.next) {
570
+ case 0:
571
+ scanDiscounts = (discountList || []).filter(function (discount) {
572
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
573
+ });
574
+ if (scanDiscounts.length) {
575
+ _context4.next = 3;
576
+ break;
577
+ }
578
+ return _context4.abrupt("return");
579
+ case 3:
580
+ scanDiscountIds = new Set(scanDiscounts.map(function (discount) {
581
+ return discount === null || discount === void 0 ? void 0 : discount.id;
582
+ }));
583
+ originalDiscounts = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || (_this$store$discount7 = _this$store$discount6.getOriginalDiscountList) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.call(_this$store$discount6)) || [];
584
+ nextOriginalDiscounts = [].concat(_toConsumableArray(scanDiscounts), _toConsumableArray(originalDiscounts.filter(function (discount) {
585
+ return !scanDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
586
+ })));
587
+ _context4.next = 8;
588
+ return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || (_this$store$discount9 = _this$store$discount8.setOriginalDiscountList) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.call(_this$store$discount8, nextOriginalDiscounts);
589
+ case 8:
590
+ case "end":
591
+ return _context4.stop();
592
+ }
593
+ }, _callee4, this);
594
+ }));
595
+ function syncScannedDiscountsToOriginalDiscountList(_x4) {
596
+ return _syncScannedDiscountsToOriginalDiscountList.apply(this, arguments);
597
+ }
598
+ return syncScannedDiscountsToOriginalDiscountList;
599
+ }()
600
+ }, {
601
+ key: "ensureEditDiscountConfigForProductChange",
602
+ value: function () {
603
+ var _ensureEditDiscountConfigForProductChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tempOrder) {
604
+ var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _this$store$discount10;
605
+ var orderId, customerId, currentDiscountList, hasRuntimeDiscounts;
606
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
607
+ while (1) switch (_context5.prev = _context5.next) {
570
608
  case 0:
571
609
  orderId = tempOrder.order_id;
572
610
  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);
573
611
  if (!(!orderId || !customerId || customerId === 1)) {
574
- _context4.next = 4;
612
+ _context5.next = 4;
575
613
  break;
576
614
  }
577
- return _context4.abrupt("return");
615
+ return _context5.abrupt("return");
578
616
  case 4:
579
- currentDiscountList = ((_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 ? void 0 : _this$store$discount6.getDiscountList()) || [];
617
+ currentDiscountList = ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.getDiscountList()) || [];
580
618
  hasRuntimeDiscounts = currentDiscountList.some(function (discount) {
581
619
  return !(discount !== null && discount !== void 0 && discount.isEditMode);
582
620
  });
583
621
  if (!hasRuntimeDiscounts) {
584
- _context4.next = 8;
622
+ _context5.next = 8;
585
623
  break;
586
624
  }
587
- return _context4.abrupt("return");
625
+ return _context5.abrupt("return");
588
626
  case 8:
589
- _context4.next = 10;
627
+ _context5.next = 10;
590
628
  return this.loadDiscountConfig({
591
629
  customerId: customerId,
592
630
  action: 'edit',
@@ -595,11 +633,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
595
633
  });
596
634
  case 10:
597
635
  case "end":
598
- return _context4.stop();
636
+ return _context5.stop();
599
637
  }
600
- }, _callee4, this);
638
+ }, _callee5, this);
601
639
  }));
602
- function ensureEditDiscountConfigForProductChange(_x4) {
640
+ function ensureEditDiscountConfigForProductChange(_x5) {
603
641
  return _ensureEditDiscountConfigForProductChange.apply(this, arguments);
604
642
  }
605
643
  return ensureEditDiscountConfigForProductChange;
@@ -607,35 +645,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
607
645
  }, {
608
646
  key: "scanCode",
609
647
  value: function () {
610
- var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
611
- var _this$store$discount7, _tempOrder$holder, _this$store$summary;
612
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount8;
613
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
614
- while (1) switch (_context5.prev = _context5.next) {
648
+ var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
649
+ var _this$store$discount11, _tempOrder$holder, _this$store$summary;
650
+ var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
651
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
652
+ while (1) switch (_context6.prev = _context6.next) {
615
653
  case 0:
616
- _context5.next = 2;
617
- return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.batchSearch(code, {
654
+ _context6.next = 2;
655
+ return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
618
656
  customerId: customerId
619
657
  });
620
658
  case 2:
621
- _context5.t0 = _context5.sent;
622
- if (_context5.t0) {
623
- _context5.next = 5;
659
+ _context6.t0 = _context6.sent;
660
+ if (_context6.t0) {
661
+ _context6.next = 5;
624
662
  break;
625
663
  }
626
- _context5.t0 = {
664
+ _context6.t0 = {
627
665
  discountList: [],
628
666
  unavailableReasonKey: null
629
667
  };
630
668
  case 5:
631
- resultDiscountWithReason = _context5.t0;
669
+ resultDiscountWithReason = _context6.t0;
632
670
  resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
633
671
  rulesModule = this.store.rules;
634
672
  if (rulesModule) {
635
- _context5.next = 10;
673
+ _context6.next = 10;
636
674
  break;
637
675
  }
638
- return _context5.abrupt("return", {
676
+ return _context6.abrupt("return", {
639
677
  type: 'clientCalc',
640
678
  isAvailable: false,
641
679
  discountList: this.getDiscountList(),
@@ -644,10 +682,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
644
682
  });
645
683
  case 10:
646
684
  if (resultDiscountList.length) {
647
- _context5.next = 12;
685
+ _context6.next = 12;
648
686
  break;
649
687
  }
650
- return _context5.abrupt("return", {
688
+ return _context6.abrupt("return", {
651
689
  type: 'server',
652
690
  isAvailable: false,
653
691
  discountList: this.getDiscountList(),
@@ -668,16 +706,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
668
706
  return m.id === n.id;
669
707
  });
670
708
  }))) {
671
- _context5.next = 16;
709
+ _context6.next = 18;
672
710
  break;
673
711
  }
674
- return _context5.abrupt("return", {
712
+ _context6.next = 17;
713
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
714
+ case 17:
715
+ return _context6.abrupt("return", {
675
716
  type: 'clientCalc',
676
717
  isAvailable: true,
677
718
  discountList: this.getDiscountList(),
678
719
  scannedDiscountList: resultDiscountList
679
720
  });
680
- case 16:
721
+ case 18:
681
722
  tempOrder = this.store.tempOrder;
682
723
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
683
724
  _ref13 = rulesModule.isDiscountListAvailable({
@@ -693,24 +734,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
693
734
  isAvailable: false,
694
735
  discountList: this.getDiscountList()
695
736
  }, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
696
- if (isAvailable && newDiscountList) {
697
- (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(newDiscountList);
698
- this.applyDiscount();
737
+ if (!(isAvailable && newDiscountList)) {
738
+ _context6.next = 26;
739
+ break;
699
740
  }
700
- return _context5.abrupt("return", {
741
+ (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
742
+ this.applyDiscount();
743
+ _context6.next = 26;
744
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
745
+ case 26:
746
+ return _context6.abrupt("return", {
701
747
  type: 'clientCalc',
702
748
  isAvailable: isAvailable || false,
703
749
  discountList: newDiscountList || this.getDiscountList(),
704
750
  scannedDiscountList: resultDiscountList,
705
751
  unavailableReason: unavailableReason
706
752
  });
707
- case 21:
753
+ case 27:
708
754
  case "end":
709
- return _context5.stop();
755
+ return _context6.stop();
710
756
  }
711
- }, _callee5, this);
757
+ }, _callee6, this);
712
758
  }));
713
- function scanCode(_x5, _x6) {
759
+ function scanCode(_x6, _x7) {
714
760
  return _scanCode.apply(this, arguments);
715
761
  }
716
762
  return scanCode;
@@ -718,7 +764,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
718
764
  }, {
719
765
  key: "applyDiscount",
720
766
  value: function applyDiscount(options) {
721
- var _this$store$discount9,
767
+ var _this$store$discount13,
722
768
  _this$store$summary2,
723
769
  _this2 = this;
724
770
  var tempOrder = this.store.tempOrder;
@@ -728,7 +774,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
728
774
  if (!tempOrder) return;
729
775
  this.syncLinkedBookingHoldersToProducts(tempOrder);
730
776
  delete tempOrder.discount_list;
731
- var discountList = ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.getDiscountList()) || [];
777
+ var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
732
778
  var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
733
779
  if (shouldSkipDiscountCalculation) return;
734
780
  var rulesModule = this.store.rules;
@@ -760,9 +806,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
760
806
  }));
761
807
  }
762
808
  if (result !== null && result !== void 0 && result.discountList) {
763
- var _this$store$discount10;
809
+ var _this$store$discount14;
764
810
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
765
- (_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 || _this$store$discount10.setDiscountList(result.discountList);
811
+ (_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
766
812
  }
767
813
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
768
814
  return _this2.productHasCustomerBoundDiscount(product);
@@ -824,42 +870,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
824
870
  }, {
825
871
  key: "applyPromotion",
826
872
  value: (function () {
827
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
873
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
828
874
  var _this$promotionEvalua,
829
875
  _this$promotionEvalua2,
830
876
  _this3 = this;
831
877
  var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
832
- return _regeneratorRuntime().wrap(function _callee6$(_context8) {
833
- while (1) switch (_context8.prev = _context8.next) {
878
+ return _regeneratorRuntime().wrap(function _callee7$(_context9) {
879
+ while (1) switch (_context9.prev = _context9.next) {
834
880
  case 0:
835
881
  if (!this.isApplyingPromotion) {
836
- _context8.next = 2;
882
+ _context9.next = 2;
837
883
  break;
838
884
  }
839
- return _context8.abrupt("return");
885
+ return _context9.abrupt("return");
840
886
  case 2:
841
887
  if (this.promotionEvaluator) {
842
- _context8.next = 4;
888
+ _context9.next = 4;
843
889
  break;
844
890
  }
845
- return _context8.abrupt("return");
891
+ return _context9.abrupt("return");
846
892
  case 4:
847
893
  tempOrder = this.store.tempOrder;
848
894
  if (tempOrder) {
849
- _context8.next = 7;
895
+ _context9.next = 7;
850
896
  break;
851
897
  }
852
- return _context8.abrupt("return");
898
+ return _context9.abrupt("return");
853
899
  case 7:
854
900
  strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
855
901
  if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
856
- _context8.next = 10;
902
+ _context9.next = 10;
857
903
  break;
858
904
  }
859
- return _context8.abrupt("return");
905
+ return _context9.abrupt("return");
860
906
  case 10:
861
907
  this.isApplyingPromotion = true;
862
- _context8.prev = 11;
908
+ _context9.prev = 11;
863
909
  result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
864
910
  if (result.giftActions.toRemove.length > 0) {
865
911
  removeSet = new Set(result.giftActions.toRemove.map(String));
@@ -871,20 +917,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
871
917
 
872
918
  // step 2: toReduce —— 调整数量
873
919
  _iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
874
- _context8.prev = 15;
920
+ _context9.prev = 15;
875
921
  _iterator3.s();
876
922
  case 17:
877
923
  if ((_step3 = _iterator3.n()).done) {
878
- _context8.next = 37;
924
+ _context9.next = 37;
879
925
  break;
880
926
  }
881
927
  reduce = _step3.value;
882
928
  _iterator6 = _createForOfIteratorHelper(reduce.items);
883
- _context8.prev = 20;
929
+ _context9.prev = 20;
884
930
  _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
885
931
  var item, product;
886
- return _regeneratorRuntime().wrap(function _loop2$(_context7) {
887
- while (1) switch (_context7.prev = _context7.next) {
932
+ return _regeneratorRuntime().wrap(function _loop2$(_context8) {
933
+ while (1) switch (_context8.prev = _context8.next) {
888
934
  case 0:
889
935
  item = _step6.value;
890
936
  product = result.products.find(function (p) {
@@ -895,52 +941,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
895
941
  }
896
942
  case 3:
897
943
  case "end":
898
- return _context7.stop();
944
+ return _context8.stop();
899
945
  }
900
946
  }, _loop2);
901
947
  });
902
948
  _iterator6.s();
903
949
  case 23:
904
950
  if ((_step6 = _iterator6.n()).done) {
905
- _context8.next = 27;
951
+ _context9.next = 27;
906
952
  break;
907
953
  }
908
- return _context8.delegateYield(_loop2(), "t0", 25);
954
+ return _context9.delegateYield(_loop2(), "t0", 25);
909
955
  case 25:
910
- _context8.next = 23;
956
+ _context9.next = 23;
911
957
  break;
912
958
  case 27:
913
- _context8.next = 32;
959
+ _context9.next = 32;
914
960
  break;
915
961
  case 29:
916
- _context8.prev = 29;
917
- _context8.t1 = _context8["catch"](20);
918
- _iterator6.e(_context8.t1);
962
+ _context9.prev = 29;
963
+ _context9.t1 = _context9["catch"](20);
964
+ _iterator6.e(_context9.t1);
919
965
  case 32:
920
- _context8.prev = 32;
966
+ _context9.prev = 32;
921
967
  _iterator6.f();
922
- return _context8.finish(32);
968
+ return _context9.finish(32);
923
969
  case 35:
924
- _context8.next = 17;
970
+ _context9.next = 17;
925
971
  break;
926
972
  case 37:
927
- _context8.next = 42;
973
+ _context9.next = 42;
928
974
  break;
929
975
  case 39:
930
- _context8.prev = 39;
931
- _context8.t2 = _context8["catch"](15);
932
- _iterator3.e(_context8.t2);
976
+ _context9.prev = 39;
977
+ _context9.t2 = _context9["catch"](15);
978
+ _iterator3.e(_context9.t2);
933
979
  case 42:
934
- _context8.prev = 42;
980
+ _context9.prev = 42;
935
981
  _iterator3.f();
936
- return _context8.finish(42);
982
+ return _context9.finish(42);
937
983
  case 45:
938
984
  if (!(result.giftActions.toAdd.length > 0)) {
939
- _context8.next = 68;
985
+ _context9.next = 68;
940
986
  break;
941
987
  }
942
988
  if (this.giftSelectResolver) {
943
- _context8.next = 50;
989
+ _context9.next = 50;
944
990
  break;
945
991
  }
946
992
  if (result.giftActions.toAdd.some(function (g) {
@@ -951,19 +997,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
951
997
  } else {
952
998
  console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
953
999
  }
954
- _context8.next = 68;
1000
+ _context9.next = 68;
955
1001
  break;
956
1002
  case 50:
957
1003
  _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
958
- _context8.prev = 51;
1004
+ _context9.prev = 51;
959
1005
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
960
1006
  var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
961
- return _regeneratorRuntime().wrap(function _loop$(_context6) {
962
- while (1) switch (_context6.prev = _context6.next) {
1007
+ return _regeneratorRuntime().wrap(function _loop$(_context7) {
1008
+ while (1) switch (_context7.prev = _context7.next) {
963
1009
  case 0:
964
1010
  addAction = _step4.value;
965
1011
  if (!(addAction.giftOptions.length === 1)) {
966
- _context6.next = 6;
1012
+ _context7.next = 6;
967
1013
  break;
968
1014
  }
969
1015
  sameStrategy = result.products.find(function (p) {
@@ -971,14 +1017,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
971
1017
  return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
972
1018
  });
973
1019
  if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
974
- _context6.next = 6;
1020
+ _context7.next = 6;
975
1021
  break;
976
1022
  }
977
1023
  sameStrategy.num = (Number(sameStrategy.num) || 0) + (addAction.giftCount || 1);
978
- return _context6.abrupt("return", 1);
1024
+ return _context7.abrupt("return", 1);
979
1025
  case 6:
980
- _context6.prev = 6;
981
- _context6.next = 9;
1026
+ _context7.prev = 6;
1027
+ _context7.next = 9;
982
1028
  return _this3.giftSelectResolver({
983
1029
  strategyId: addAction.strategyId,
984
1030
  strategyName: addAction.strategyName,
@@ -987,31 +1033,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
987
1033
  sourceProductIds: addAction.sourceProductIds
988
1034
  });
989
1035
  case 9:
990
- giftResult = _context6.sent;
1036
+ giftResult = _context7.sent;
991
1037
  giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
992
1038
  giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
993
1039
  if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
994
- _context6.next = 37;
1040
+ _context7.next = 37;
995
1041
  break;
996
1042
  }
997
1043
  _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
998
- _context6.prev = 14;
1044
+ _context7.prev = 14;
999
1045
  _iterator5.s();
1000
1046
  case 16:
1001
1047
  if ((_step5 = _iterator5.n()).done) {
1002
- _context6.next = 29;
1048
+ _context7.next = 29;
1003
1049
  break;
1004
1050
  }
1005
1051
  _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
1006
1052
  if (gp) {
1007
- _context6.next = 20;
1053
+ _context7.next = 20;
1008
1054
  break;
1009
1055
  }
1010
- return _context6.abrupt("continue", 27);
1056
+ return _context7.abrupt("continue", 27);
1011
1057
  case 20:
1012
1058
  booking = giftBookings[index];
1013
1059
  if (!booking) {
1014
- _context6.next = 26;
1060
+ _context7.next = 26;
1015
1061
  break;
1016
1062
  }
1017
1063
  linked = _this3.createLinkedProductAndBooking({
@@ -1020,65 +1066,65 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1020
1066
  });
1021
1067
  result.products.push(linked.product);
1022
1068
  tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
1023
- return _context6.abrupt("continue", 27);
1069
+ return _context7.abrupt("continue", 27);
1024
1070
  case 26:
1025
1071
  // normalize 略过:调用方应保证返回完整 OrderProduct。
1026
1072
  result.products.push(gp);
1027
1073
  case 27:
1028
- _context6.next = 16;
1074
+ _context7.next = 16;
1029
1075
  break;
1030
1076
  case 29:
1031
- _context6.next = 34;
1077
+ _context7.next = 34;
1032
1078
  break;
1033
1079
  case 31:
1034
- _context6.prev = 31;
1035
- _context6.t0 = _context6["catch"](14);
1036
- _iterator5.e(_context6.t0);
1080
+ _context7.prev = 31;
1081
+ _context7.t0 = _context7["catch"](14);
1082
+ _iterator5.e(_context7.t0);
1037
1083
  case 34:
1038
- _context6.prev = 34;
1084
+ _context7.prev = 34;
1039
1085
  _iterator5.f();
1040
- return _context6.finish(34);
1086
+ return _context7.finish(34);
1041
1087
  case 37:
1042
- _context6.next = 42;
1088
+ _context7.next = 42;
1043
1089
  break;
1044
1090
  case 39:
1045
- _context6.prev = 39;
1046
- _context6.t1 = _context6["catch"](6);
1091
+ _context7.prev = 39;
1092
+ _context7.t1 = _context7["catch"](6);
1047
1093
  // 用户取消 / 选择失败 → 视为放弃本次新增
1048
- console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context6.t1);
1094
+ console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context7.t1);
1049
1095
  case 42:
1050
1096
  case "end":
1051
- return _context6.stop();
1097
+ return _context7.stop();
1052
1098
  }
1053
1099
  }, _loop, null, [[6, 39], [14, 31, 34, 37]]);
1054
1100
  });
1055
1101
  _iterator4.s();
1056
1102
  case 54:
1057
1103
  if ((_step4 = _iterator4.n()).done) {
1058
- _context8.next = 60;
1104
+ _context9.next = 60;
1059
1105
  break;
1060
1106
  }
1061
- return _context8.delegateYield(_loop(), "t3", 56);
1107
+ return _context9.delegateYield(_loop(), "t3", 56);
1062
1108
  case 56:
1063
- if (!_context8.t3) {
1064
- _context8.next = 58;
1109
+ if (!_context9.t3) {
1110
+ _context9.next = 58;
1065
1111
  break;
1066
1112
  }
1067
- return _context8.abrupt("continue", 58);
1113
+ return _context9.abrupt("continue", 58);
1068
1114
  case 58:
1069
- _context8.next = 54;
1115
+ _context9.next = 54;
1070
1116
  break;
1071
1117
  case 60:
1072
- _context8.next = 65;
1118
+ _context9.next = 65;
1073
1119
  break;
1074
1120
  case 62:
1075
- _context8.prev = 62;
1076
- _context8.t4 = _context8["catch"](51);
1077
- _iterator4.e(_context8.t4);
1121
+ _context9.prev = 62;
1122
+ _context9.t4 = _context9["catch"](51);
1123
+ _iterator4.e(_context9.t4);
1078
1124
  case 65:
1079
- _context8.prev = 65;
1125
+ _context9.prev = 65;
1080
1126
  _iterator4.f();
1081
- return _context8.finish(65);
1127
+ return _context9.finish(65);
1082
1128
  case 68:
1083
1129
  tempOrder.products = result.products;
1084
1130
  this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
@@ -1097,21 +1143,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1097
1143
  products: tempOrder.products
1098
1144
  };
1099
1145
  this.effectsEmit('onPromotionApplied', payload);
1100
- _context8.next = 78;
1146
+ _context9.next = 78;
1101
1147
  break;
1102
1148
  case 75:
1103
- _context8.prev = 75;
1104
- _context8.t5 = _context8["catch"](11);
1105
- console.error('[OrderModule] applyPromotion failed', _context8.t5);
1149
+ _context9.prev = 75;
1150
+ _context9.t5 = _context9["catch"](11);
1151
+ console.error('[OrderModule] applyPromotion failed', _context9.t5);
1106
1152
  case 78:
1107
- _context8.prev = 78;
1153
+ _context9.prev = 78;
1108
1154
  this.isApplyingPromotion = false;
1109
- return _context8.finish(78);
1155
+ return _context9.finish(78);
1110
1156
  case 81:
1111
1157
  case "end":
1112
- return _context8.stop();
1158
+ return _context9.stop();
1113
1159
  }
1114
- }, _callee6, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
1160
+ }, _callee7, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
1115
1161
  }));
1116
1162
  function applyPromotion() {
1117
1163
  return _applyPromotion.apply(this, arguments);
@@ -1233,14 +1279,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1233
1279
  }, {
1234
1280
  key: "saveDraft",
1235
1281
  value: function () {
1236
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1237
- return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1238
- while (1) switch (_context9.prev = _context9.next) {
1282
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1283
+ return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1284
+ while (1) switch (_context10.prev = _context10.next) {
1239
1285
  case 0:
1240
1286
  case "end":
1241
- return _context9.stop();
1287
+ return _context10.stop();
1242
1288
  }
1243
- }, _callee7);
1289
+ }, _callee8);
1244
1290
  }));
1245
1291
  function saveDraft() {
1246
1292
  return _saveDraft.apply(this, arguments);
@@ -1255,18 +1301,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1255
1301
  }, {
1256
1302
  key: "hydrateTempOrderFromLocalRecord",
1257
1303
  value: function () {
1258
- var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(record) {
1259
- return _regeneratorRuntime().wrap(function _callee8$(_context10) {
1260
- while (1) switch (_context10.prev = _context10.next) {
1304
+ var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(record) {
1305
+ return _regeneratorRuntime().wrap(function _callee9$(_context11) {
1306
+ while (1) switch (_context11.prev = _context11.next) {
1261
1307
  case 0:
1262
- return _context10.abrupt("return", this.hydrateTempOrderFromRecord(record));
1308
+ return _context11.abrupt("return", this.hydrateTempOrderFromRecord(record));
1263
1309
  case 1:
1264
1310
  case "end":
1265
- return _context10.stop();
1311
+ return _context11.stop();
1266
1312
  }
1267
- }, _callee8, this);
1313
+ }, _callee9, this);
1268
1314
  }));
1269
- function hydrateTempOrderFromLocalRecord(_x7) {
1315
+ function hydrateTempOrderFromLocalRecord(_x8) {
1270
1316
  return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
1271
1317
  }
1272
1318
  return hydrateTempOrderFromLocalRecord;
@@ -2161,7 +2207,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2161
2207
  }, {
2162
2208
  key: "restoreOrder",
2163
2209
  value: function restoreOrder() {
2164
- var _this$store$discount11, _this$store$discount12;
2210
+ var _this$store$discount15, _this$store$discount16;
2165
2211
  this.logInfo('restoreOrder start', {});
2166
2212
  var freshTempOrder = this.createDefaultTempOrderInstance();
2167
2213
  this.ensureExternalSaleNumber(freshTempOrder);
@@ -2169,8 +2215,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2169
2215
  this.store.summary = createEmptySummary();
2170
2216
  this.store.lastOrderInfo = undefined;
2171
2217
  this.store.syncState = undefined;
2172
- void ((_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.setOriginalDiscountList([]));
2173
- void ((_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList([]));
2218
+ void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
2219
+ void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
2174
2220
  this.persistTempOrder();
2175
2221
  return freshTempOrder;
2176
2222
  }
@@ -2182,13 +2228,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2182
2228
  }, {
2183
2229
  key: "replaceTempOrder",
2184
2230
  value: function () {
2185
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
2231
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(tempOrder, options) {
2186
2232
  var nextTempOrder;
2187
- return _regeneratorRuntime().wrap(function _callee9$(_context11) {
2188
- while (1) switch (_context11.prev = _context11.next) {
2233
+ return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2234
+ while (1) switch (_context12.prev = _context12.next) {
2189
2235
  case 0:
2190
2236
  if (isTempOrder(tempOrder)) {
2191
- _context11.next = 2;
2237
+ _context12.next = 2;
2192
2238
  break;
2193
2239
  }
2194
2240
  throw new Error('无效的 tempOrder 数据');
@@ -2198,15 +2244,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2198
2244
  });
2199
2245
  this.store.tempOrder = nextTempOrder;
2200
2246
  if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
2201
- _context11.next = 9;
2247
+ _context12.next = 9;
2202
2248
  break;
2203
2249
  }
2204
- _context11.next = 7;
2250
+ _context12.next = 7;
2205
2251
  return this.recalculateSummary({
2206
2252
  createIfMissing: false
2207
2253
  });
2208
2254
  case 7:
2209
- _context11.next = 10;
2255
+ _context12.next = 10;
2210
2256
  break;
2211
2257
  case 9:
2212
2258
  this.store.summary = createEmptySummary();
@@ -2215,20 +2261,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2215
2261
  this.persistTempOrder();
2216
2262
  }
2217
2263
  if (!(options !== null && options !== void 0 && options.saveDraft)) {
2218
- _context11.next = 14;
2264
+ _context12.next = 14;
2219
2265
  break;
2220
2266
  }
2221
- _context11.next = 14;
2267
+ _context12.next = 14;
2222
2268
  return this.saveDraft();
2223
2269
  case 14:
2224
- return _context11.abrupt("return", nextTempOrder);
2270
+ return _context12.abrupt("return", nextTempOrder);
2225
2271
  case 15:
2226
2272
  case "end":
2227
- return _context11.stop();
2273
+ return _context12.stop();
2228
2274
  }
2229
- }, _callee9, this);
2275
+ }, _callee10, this);
2230
2276
  }));
2231
- function replaceTempOrder(_x8, _x9) {
2277
+ function replaceTempOrder(_x9, _x10) {
2232
2278
  return _replaceTempOrder.apply(this, arguments);
2233
2279
  }
2234
2280
  return replaceTempOrder;
@@ -2314,32 +2360,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2314
2360
  }, {
2315
2361
  key: "addNewOrder",
2316
2362
  value: function () {
2317
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
2363
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
2318
2364
  var tempOrder;
2319
- return _regeneratorRuntime().wrap(function _callee10$(_context12) {
2320
- while (1) switch (_context12.prev = _context12.next) {
2365
+ return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2366
+ while (1) switch (_context13.prev = _context13.next) {
2321
2367
  case 0:
2322
2368
  tempOrder = this.ensureTempOrder();
2323
2369
  this.ensureExternalSaleNumber(tempOrder);
2324
- _context12.next = 4;
2370
+ _context13.next = 4;
2325
2371
  return this.recalculateSummary({
2326
2372
  createIfMissing: true
2327
2373
  });
2328
2374
  case 4:
2329
2375
  this.persistTempOrder();
2330
2376
  if (!this.draftPersistEnabled) {
2331
- _context12.next = 8;
2377
+ _context13.next = 8;
2332
2378
  break;
2333
2379
  }
2334
- _context12.next = 8;
2380
+ _context13.next = 8;
2335
2381
  return this.saveDraft();
2336
2382
  case 8:
2337
- return _context12.abrupt("return", tempOrder);
2383
+ return _context13.abrupt("return", tempOrder);
2338
2384
  case 9:
2339
2385
  case "end":
2340
- return _context12.stop();
2386
+ return _context13.stop();
2341
2387
  }
2342
- }, _callee10, this);
2388
+ }, _callee11, this);
2343
2389
  }));
2344
2390
  function addNewOrder() {
2345
2391
  return _addNewOrder.apply(this, arguments);
@@ -2691,18 +2737,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2691
2737
  }, {
2692
2738
  key: "recalculateSummary",
2693
2739
  value: function () {
2694
- var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
2740
+ var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
2695
2741
  var _this$otherParams2, _ref47, _salesSummaryResult$e;
2696
2742
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
2697
- return _regeneratorRuntime().wrap(function _callee11$(_context13) {
2698
- while (1) switch (_context13.prev = _context13.next) {
2743
+ return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2744
+ while (1) switch (_context14.prev = _context14.next) {
2699
2745
  case 0:
2700
2746
  tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
2701
2747
  if (tempOrder) {
2702
- _context13.next = 3;
2748
+ _context14.next = 3;
2703
2749
  break;
2704
2750
  }
2705
- return _context13.abrupt("return", null);
2751
+ return _context14.abrupt("return", null);
2706
2752
  case 3:
2707
2753
  this.sanitizeTempOrderProducts(tempOrder);
2708
2754
  originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
@@ -2710,10 +2756,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2710
2756
  shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
2711
2757
  snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
2712
2758
  if (!snapshotSummary) {
2713
- _context13.next = 10;
2759
+ _context14.next = 10;
2714
2760
  break;
2715
2761
  }
2716
- return _context13.abrupt("return", snapshotSummary);
2762
+ return _context14.abrupt("return", snapshotSummary);
2717
2763
  case 10:
2718
2764
  shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
2719
2765
  summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
@@ -2725,7 +2771,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2725
2771
  totalRefundAmount = existedSummary.total_refund_amount || '0.00';
2726
2772
  paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
2727
2773
  if (salesSummary) {
2728
- _context13.next = 26;
2774
+ _context14.next = 26;
2729
2775
  break;
2730
2776
  }
2731
2777
  emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
@@ -2751,9 +2797,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2751
2797
  previousSummary: existedSummary,
2752
2798
  summary: emptySummary
2753
2799
  });
2754
- return _context13.abrupt("return", this.store.summary);
2800
+ return _context14.abrupt("return", this.store.summary);
2755
2801
  case 26:
2756
- _context13.next = 28;
2802
+ _context14.next = 28;
2757
2803
  return salesSummary.getSummary(_objectSpread({
2758
2804
  products: summaryProducts,
2759
2805
  isPriceIncludeTax: tempOrder.is_price_include_tax,
@@ -2762,7 +2808,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2762
2808
  channel: this.otherParams.channel
2763
2809
  } : {}));
2764
2810
  case 28:
2765
- salesSummaryResult = _context13.sent;
2811
+ salesSummaryResult = _context14.sent;
2766
2812
  if (shouldFullRecalculateFromSnapshot) {
2767
2813
  tempOrder.products = summaryProducts;
2768
2814
  }
@@ -2807,14 +2853,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2807
2853
  previousSummary: existedSummary,
2808
2854
  summary: summary
2809
2855
  });
2810
- return _context13.abrupt("return", this.store.summary);
2856
+ return _context14.abrupt("return", this.store.summary);
2811
2857
  case 46:
2812
2858
  case "end":
2813
- return _context13.stop();
2859
+ return _context14.stop();
2814
2860
  }
2815
- }, _callee11, this);
2861
+ }, _callee12, this);
2816
2862
  }));
2817
- function recalculateSummary(_x10) {
2863
+ function recalculateSummary(_x11) {
2818
2864
  return _recalculateSummary.apply(this, arguments);
2819
2865
  }
2820
2866
  return recalculateSummary;
@@ -2822,30 +2868,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2822
2868
  }, {
2823
2869
  key: "getOrderSummary",
2824
2870
  value: function () {
2825
- var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
2871
+ var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2826
2872
  var summary;
2827
- return _regeneratorRuntime().wrap(function _callee12$(_context14) {
2828
- while (1) switch (_context14.prev = _context14.next) {
2873
+ return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2874
+ while (1) switch (_context15.prev = _context15.next) {
2829
2875
  case 0:
2830
- _context14.next = 2;
2876
+ _context15.next = 2;
2831
2877
  return this.recalculateSummary({
2832
2878
  createIfMissing: true
2833
2879
  });
2834
2880
  case 2:
2835
- summary = _context14.sent;
2881
+ summary = _context15.sent;
2836
2882
  if (summary) {
2837
- _context14.next = 5;
2883
+ _context15.next = 5;
2838
2884
  break;
2839
2885
  }
2840
- return _context14.abrupt("return", createEmptySummary());
2886
+ return _context15.abrupt("return", createEmptySummary());
2841
2887
  case 5:
2842
2888
  this.persistTempOrder();
2843
- return _context14.abrupt("return", summary);
2889
+ return _context15.abrupt("return", summary);
2844
2890
  case 7:
2845
2891
  case "end":
2846
- return _context14.stop();
2892
+ return _context15.stop();
2847
2893
  }
2848
- }, _callee12, this);
2894
+ }, _callee13, this);
2849
2895
  }));
2850
2896
  function getOrderSummary() {
2851
2897
  return _getOrderSummary.apply(this, arguments);
@@ -2869,23 +2915,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2869
2915
  }, {
2870
2916
  key: "syncTempOrderNoteToRemote",
2871
2917
  value: function () {
2872
- var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
2873
- return _regeneratorRuntime().wrap(function _callee13$(_context15) {
2874
- while (1) switch (_context15.prev = _context15.next) {
2918
+ var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderId, note) {
2919
+ return _regeneratorRuntime().wrap(function _callee14$(_context16) {
2920
+ while (1) switch (_context16.prev = _context16.next) {
2875
2921
  case 0:
2876
- _context15.next = 2;
2922
+ _context16.next = 2;
2877
2923
  return this.request.put("/order/order/".concat(orderId, "/note"), {
2878
2924
  note: note
2879
2925
  });
2880
2926
  case 2:
2881
- return _context15.abrupt("return", note);
2927
+ return _context16.abrupt("return", note);
2882
2928
  case 3:
2883
2929
  case "end":
2884
- return _context15.stop();
2930
+ return _context16.stop();
2885
2931
  }
2886
- }, _callee13, this);
2932
+ }, _callee14, this);
2887
2933
  }));
2888
- function syncTempOrderNoteToRemote(_x11, _x12) {
2934
+ function syncTempOrderNoteToRemote(_x12, _x13) {
2889
2935
  return _syncTempOrderNoteToRemote.apply(this, arguments);
2890
2936
  }
2891
2937
  return syncTempOrderNoteToRemote;
@@ -2993,11 +3039,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2993
3039
  }, {
2994
3040
  key: "shouldSkipDiscountCalculation",
2995
3041
  value: function shouldSkipDiscountCalculation(tempOrder) {
2996
- var _this$store$discount13,
2997
- _this$store$discount14,
3042
+ var _this$store$discount17,
3043
+ _this$store$discount18,
2998
3044
  _this17 = this;
2999
3045
  if (this.hasActiveCustomerBoundDiscount) return false;
3000
- var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 || (_this$store$discount14 = _this$store$discount13.getDiscountList) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.call(_this$store$discount13)) || [];
3046
+ var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
3001
3047
  if (discountList.length > 0) return false;
3002
3048
  return !(tempOrder.products || []).some(function (product) {
3003
3049
  return _this17.productHasCustomerBoundDiscount(product);
@@ -3461,45 +3507,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3461
3507
  }, {
3462
3508
  key: "shouldMergeProductToOrder",
3463
3509
  value: function () {
3464
- var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
3510
+ var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
3465
3511
  var _this$orderHooks;
3466
3512
  var onBeforeMergeProductToOrder, result;
3467
- return _regeneratorRuntime().wrap(function _callee14$(_context16) {
3468
- while (1) switch (_context16.prev = _context16.next) {
3513
+ return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3514
+ while (1) switch (_context17.prev = _context17.next) {
3469
3515
  case 0:
3470
3516
  onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
3471
3517
  if (onBeforeMergeProductToOrder) {
3472
- _context16.next = 3;
3518
+ _context17.next = 3;
3473
3519
  break;
3474
3520
  }
3475
- return _context16.abrupt("return", true);
3521
+ return _context17.abrupt("return", true);
3476
3522
  case 3:
3477
- _context16.next = 5;
3523
+ _context17.next = 5;
3478
3524
  return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
3479
3525
  defaultShouldMerge: true
3480
3526
  }));
3481
3527
  case 5:
3482
- result = _context16.sent;
3528
+ result = _context17.sent;
3483
3529
  if (!(typeof result === 'boolean')) {
3484
- _context16.next = 8;
3530
+ _context17.next = 8;
3485
3531
  break;
3486
3532
  }
3487
- return _context16.abrupt("return", result);
3533
+ return _context17.abrupt("return", result);
3488
3534
  case 8:
3489
3535
  if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
3490
- _context16.next = 10;
3536
+ _context17.next = 10;
3491
3537
  break;
3492
3538
  }
3493
- return _context16.abrupt("return", result.shouldMerge);
3539
+ return _context17.abrupt("return", result.shouldMerge);
3494
3540
  case 10:
3495
- return _context16.abrupt("return", true);
3541
+ return _context17.abrupt("return", true);
3496
3542
  case 11:
3497
3543
  case "end":
3498
- return _context16.stop();
3544
+ return _context17.stop();
3499
3545
  }
3500
- }, _callee14, this);
3546
+ }, _callee15, this);
3501
3547
  }));
3502
- function shouldMergeProductToOrder(_x13) {
3548
+ function shouldMergeProductToOrder(_x14) {
3503
3549
  return _shouldMergeProductToOrder.apply(this, arguments);
3504
3550
  }
3505
3551
  return shouldMergeProductToOrder;
@@ -3535,30 +3581,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3535
3581
  }, {
3536
3582
  key: "finalizeProductOrderMutation",
3537
3583
  value: function () {
3538
- var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
3539
- return _regeneratorRuntime().wrap(function _callee15$(_context17) {
3540
- while (1) switch (_context17.prev = _context17.next) {
3584
+ var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
3585
+ return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3586
+ while (1) switch (_context18.prev = _context18.next) {
3541
3587
  case 0:
3542
3588
  this.syncTempOrderHolderFromBookings(tempOrder);
3543
3589
  if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
3544
- _context17.next = 4;
3590
+ _context18.next = 4;
3545
3591
  break;
3546
3592
  }
3547
- _context17.next = 4;
3593
+ _context18.next = 4;
3548
3594
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
3549
3595
  case 4:
3550
3596
  if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
3551
- _context17.next = 7;
3597
+ _context18.next = 7;
3552
3598
  break;
3553
3599
  }
3554
- _context17.next = 7;
3600
+ _context18.next = 7;
3555
3601
  return this.applyPromotion();
3556
3602
  case 7:
3557
3603
  if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
3558
3604
  this.applyDiscount();
3559
3605
  }
3560
3606
  this.sanitizeTempOrderProducts(tempOrder);
3561
- _context17.next = 11;
3607
+ _context18.next = 11;
3562
3608
  return this.recalculateSummary({
3563
3609
  createIfMissing: true
3564
3610
  });
@@ -3566,11 +3612,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3566
3612
  this.persistTempOrder();
3567
3613
  case 12:
3568
3614
  case "end":
3569
- return _context17.stop();
3615
+ return _context18.stop();
3570
3616
  }
3571
- }, _callee15, this);
3617
+ }, _callee16, this);
3572
3618
  }));
3573
- function finalizeProductOrderMutation(_x14, _x15) {
3619
+ function finalizeProductOrderMutation(_x15, _x16) {
3574
3620
  return _finalizeProductOrderMutation.apply(this, arguments);
3575
3621
  }
3576
3622
  return finalizeProductOrderMutation;
@@ -3585,13 +3631,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3585
3631
  }, {
3586
3632
  key: "appendProductLineToTempOrder",
3587
3633
  value: (function () {
3588
- var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, product, booking) {
3634
+ var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking) {
3589
3635
  var _booking_uid,
3590
3636
  _metadata,
3591
3637
  _this22 = this;
3592
3638
  var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList;
3593
- return _regeneratorRuntime().wrap(function _callee16$(_context18) {
3594
- while (1) switch (_context18.prev = _context18.next) {
3639
+ return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3640
+ while (1) switch (_context19.prev = _context19.next) {
3595
3641
  case 0:
3596
3642
  linked = booking ? this.createLinkedProductAndBooking({
3597
3643
  product: product,
@@ -3624,10 +3670,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3624
3670
  matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
3625
3671
  existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
3626
3672
  if (!matchedProduct) {
3627
- _context18.next = 20;
3673
+ _context19.next = 20;
3628
3674
  break;
3629
3675
  }
3630
- _context18.next = 17;
3676
+ _context19.next = 17;
3631
3677
  return this.shouldMergeProductToOrder({
3632
3678
  incomingProduct: productToAdd,
3633
3679
  normalizedIncoming: normalizedIncoming,
@@ -3639,13 +3685,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3639
3685
  booking: booking
3640
3686
  });
3641
3687
  case 17:
3642
- _context18.t0 = _context18.sent;
3643
- _context18.next = 21;
3688
+ _context19.t0 = _context19.sent;
3689
+ _context19.next = 21;
3644
3690
  break;
3645
3691
  case 20:
3646
- _context18.t0 = false;
3692
+ _context19.t0 = false;
3647
3693
  case 21:
3648
- shouldMerge = _context18.t0;
3694
+ shouldMerge = _context19.t0;
3649
3695
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
3650
3696
  this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
3651
3697
  if (linked) {
@@ -3699,11 +3745,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3699
3745
  }
3700
3746
  case 24:
3701
3747
  case "end":
3702
- return _context18.stop();
3748
+ return _context19.stop();
3703
3749
  }
3704
- }, _callee16, this);
3750
+ }, _callee17, this);
3705
3751
  }));
3706
- function appendProductLineToTempOrder(_x16, _x17, _x18) {
3752
+ function appendProductLineToTempOrder(_x17, _x18, _x19) {
3707
3753
  return _appendProductLineToTempOrder.apply(this, arguments);
3708
3754
  }
3709
3755
  return appendProductLineToTempOrder;
@@ -3719,61 +3765,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3719
3765
  }, {
3720
3766
  key: "addProductToOrder",
3721
3767
  value: (function () {
3722
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(product, booking) {
3768
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking) {
3723
3769
  var tempOrder, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
3724
- return _regeneratorRuntime().wrap(function _callee17$(_context19) {
3725
- while (1) switch (_context19.prev = _context19.next) {
3770
+ return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3771
+ while (1) switch (_context20.prev = _context20.next) {
3726
3772
  case 0:
3727
3773
  tempOrder = this.ensureTempOrder();
3728
3774
  if (!booking) {
3729
- _context19.next = 18;
3775
+ _context20.next = 18;
3730
3776
  break;
3731
3777
  }
3732
3778
  productRecord = product;
3733
3779
  splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
3734
3780
  if (!(splitCount > 1)) {
3735
- _context19.next = 18;
3781
+ _context20.next = 18;
3736
3782
  break;
3737
3783
  }
3738
3784
  i = 0;
3739
3785
  case 6:
3740
3786
  if (!(i < splitCount)) {
3741
- _context19.next = 15;
3787
+ _context20.next = 15;
3742
3788
  break;
3743
3789
  }
3744
3790
  singleLine = cloneDeep(productRecord);
3745
3791
  singleLine.num = 1;
3746
3792
  delete singleLine.product_quantity;
3747
- _context19.next = 12;
3793
+ _context20.next = 12;
3748
3794
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3749
3795
  case 12:
3750
3796
  i += 1;
3751
- _context19.next = 6;
3797
+ _context20.next = 6;
3752
3798
  break;
3753
3799
  case 15:
3754
- _context19.next = 17;
3800
+ _context20.next = 17;
3755
3801
  return this.finalizeProductOrderMutation(tempOrder);
3756
3802
  case 17:
3757
- return _context19.abrupt("return", tempOrder.products);
3803
+ return _context20.abrupt("return", tempOrder.products);
3758
3804
  case 18:
3759
- _context19.next = 20;
3805
+ _context20.next = 20;
3760
3806
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3761
3807
  case 20:
3762
- _context19.next = 22;
3808
+ _context20.next = 22;
3763
3809
  return this.finalizeProductOrderMutation(tempOrder);
3764
3810
  case 22:
3765
3811
  this.logInfo('addProductToOrder success', {
3766
3812
  product_id: product.product_id,
3767
3813
  with_booking: !!booking
3768
3814
  });
3769
- return _context19.abrupt("return", tempOrder.products);
3815
+ return _context20.abrupt("return", tempOrder.products);
3770
3816
  case 24:
3771
3817
  case "end":
3772
- return _context19.stop();
3818
+ return _context20.stop();
3773
3819
  }
3774
- }, _callee17, this);
3820
+ }, _callee18, this);
3775
3821
  }));
3776
- function addProductToOrder(_x19, _x20) {
3822
+ function addProductToOrder(_x20, _x21) {
3777
3823
  return _addProductToOrder.apply(this, arguments);
3778
3824
  }
3779
3825
  return addProductToOrder;
@@ -3791,93 +3837,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3791
3837
  }, {
3792
3838
  key: "addProductsToOrder",
3793
3839
  value: (function () {
3794
- var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(items, options) {
3840
+ var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
3795
3841
  var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
3796
- return _regeneratorRuntime().wrap(function _callee18$(_context20) {
3797
- while (1) switch (_context20.prev = _context20.next) {
3842
+ return _regeneratorRuntime().wrap(function _callee19$(_context21) {
3843
+ while (1) switch (_context21.prev = _context21.next) {
3798
3844
  case 0:
3799
3845
  tempOrder = this.ensureTempOrder();
3800
3846
  if (!(!Array.isArray(items) || items.length === 0)) {
3801
- _context20.next = 3;
3847
+ _context21.next = 3;
3802
3848
  break;
3803
3849
  }
3804
- return _context20.abrupt("return", tempOrder.products);
3850
+ return _context21.abrupt("return", tempOrder.products);
3805
3851
  case 3:
3806
3852
  _iterator20 = _createForOfIteratorHelper(items || []);
3807
- _context20.prev = 4;
3853
+ _context21.prev = 4;
3808
3854
  _iterator20.s();
3809
3855
  case 6:
3810
3856
  if ((_step20 = _iterator20.n()).done) {
3811
- _context20.next = 30;
3857
+ _context21.next = 30;
3812
3858
  break;
3813
3859
  }
3814
3860
  item = _step20.value;
3815
3861
  product = item.product, booking = item.booking;
3816
3862
  if (product) {
3817
- _context20.next = 11;
3863
+ _context21.next = 11;
3818
3864
  break;
3819
3865
  }
3820
- return _context20.abrupt("continue", 28);
3866
+ return _context21.abrupt("continue", 28);
3821
3867
  case 11:
3822
3868
  if (!booking) {
3823
- _context20.next = 26;
3869
+ _context21.next = 26;
3824
3870
  break;
3825
3871
  }
3826
3872
  productRecord = product;
3827
3873
  splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
3828
3874
  if (!(splitCount > 1)) {
3829
- _context20.next = 26;
3875
+ _context21.next = 26;
3830
3876
  break;
3831
3877
  }
3832
3878
  i = 0;
3833
3879
  case 16:
3834
3880
  if (!(i < splitCount)) {
3835
- _context20.next = 25;
3881
+ _context21.next = 25;
3836
3882
  break;
3837
3883
  }
3838
3884
  singleLine = cloneDeep(productRecord);
3839
3885
  singleLine.num = 1;
3840
3886
  delete singleLine.product_quantity;
3841
- _context20.next = 22;
3887
+ _context21.next = 22;
3842
3888
  return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
3843
3889
  case 22:
3844
3890
  i += 1;
3845
- _context20.next = 16;
3891
+ _context21.next = 16;
3846
3892
  break;
3847
3893
  case 25:
3848
- return _context20.abrupt("continue", 28);
3894
+ return _context21.abrupt("continue", 28);
3849
3895
  case 26:
3850
- _context20.next = 28;
3896
+ _context21.next = 28;
3851
3897
  return this.appendProductLineToTempOrder(tempOrder, product, booking);
3852
3898
  case 28:
3853
- _context20.next = 6;
3899
+ _context21.next = 6;
3854
3900
  break;
3855
3901
  case 30:
3856
- _context20.next = 35;
3902
+ _context21.next = 35;
3857
3903
  break;
3858
3904
  case 32:
3859
- _context20.prev = 32;
3860
- _context20.t0 = _context20["catch"](4);
3861
- _iterator20.e(_context20.t0);
3905
+ _context21.prev = 32;
3906
+ _context21.t0 = _context21["catch"](4);
3907
+ _iterator20.e(_context21.t0);
3862
3908
  case 35:
3863
- _context20.prev = 35;
3909
+ _context21.prev = 35;
3864
3910
  _iterator20.f();
3865
- return _context20.finish(35);
3911
+ return _context21.finish(35);
3866
3912
  case 38:
3867
- _context20.next = 40;
3913
+ _context21.next = 40;
3868
3914
  return this.finalizeProductOrderMutation(tempOrder, options);
3869
3915
  case 40:
3870
3916
  this.logInfo('addProductsToOrder success', {
3871
3917
  itemsCount: items.length
3872
3918
  });
3873
- return _context20.abrupt("return", tempOrder.products);
3919
+ return _context21.abrupt("return", tempOrder.products);
3874
3920
  case 42:
3875
3921
  case "end":
3876
- return _context20.stop();
3922
+ return _context21.stop();
3877
3923
  }
3878
- }, _callee18, this, [[4, 32, 35, 38]]);
3924
+ }, _callee19, this, [[4, 32, 35, 38]]);
3879
3925
  }));
3880
- function addProductsToOrder(_x21, _x22) {
3926
+ function addProductsToOrder(_x22, _x23) {
3881
3927
  return _addProductsToOrder.apply(this, arguments);
3882
3928
  }
3883
3929
  return addProductsToOrder;
@@ -4074,21 +4120,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4074
4120
  }, {
4075
4121
  key: "updateOrderProduct",
4076
4122
  value: function () {
4077
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
4123
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
4078
4124
  var tempOrder, updatedProductUid;
4079
- return _regeneratorRuntime().wrap(function _callee19$(_context21) {
4080
- while (1) switch (_context21.prev = _context21.next) {
4125
+ return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4126
+ while (1) switch (_context22.prev = _context22.next) {
4081
4127
  case 0:
4082
4128
  tempOrder = this.ensureTempOrder();
4083
4129
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
4084
- _context21.next = 4;
4130
+ _context22.next = 4;
4085
4131
  return this.applyPromotion();
4086
4132
  case 4:
4087
4133
  this.applyDiscount({
4088
4134
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
4089
4135
  });
4090
4136
  this.sanitizeTempOrderProducts(tempOrder);
4091
- _context21.next = 8;
4137
+ _context22.next = 8;
4092
4138
  return this.recalculateSummary({
4093
4139
  createIfMissing: true
4094
4140
  });
@@ -4097,14 +4143,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4097
4143
  this.logInfo('updateOrderProduct success', {
4098
4144
  params: params
4099
4145
  });
4100
- return _context21.abrupt("return", tempOrder.products);
4146
+ return _context22.abrupt("return", tempOrder.products);
4101
4147
  case 11:
4102
4148
  case "end":
4103
- return _context21.stop();
4149
+ return _context22.stop();
4104
4150
  }
4105
- }, _callee19, this);
4151
+ }, _callee20, this);
4106
4152
  }));
4107
- function updateOrderProduct(_x23) {
4153
+ function updateOrderProduct(_x24) {
4108
4154
  return _updateOrderProduct.apply(this, arguments);
4109
4155
  }
4110
4156
  return updateOrderProduct;
@@ -4112,18 +4158,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4112
4158
  }, {
4113
4159
  key: "updateOrderProducts",
4114
4160
  value: function () {
4115
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(paramsList) {
4161
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
4116
4162
  var _this24 = this;
4117
4163
  var tempOrder, reapplyBookingDiscountProductUids;
4118
- return _regeneratorRuntime().wrap(function _callee20$(_context22) {
4119
- while (1) switch (_context22.prev = _context22.next) {
4164
+ return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4165
+ while (1) switch (_context23.prev = _context23.next) {
4120
4166
  case 0:
4121
4167
  tempOrder = this.ensureTempOrder();
4122
4168
  if (paramsList.length) {
4123
- _context22.next = 3;
4169
+ _context23.next = 3;
4124
4170
  break;
4125
4171
  }
4126
- return _context22.abrupt("return", tempOrder.products);
4172
+ return _context23.abrupt("return", tempOrder.products);
4127
4173
  case 3:
4128
4174
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
4129
4175
  var updatedProductUid = _this24.applyOrderProductUpdateToTempOrder(tempOrder, params);
@@ -4133,7 +4179,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4133
4179
  }
4134
4180
  return acc;
4135
4181
  }, []);
4136
- _context22.next = 6;
4182
+ _context23.next = 6;
4137
4183
  return this.finalizeAfterProductsMutation(tempOrder, {
4138
4184
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
4139
4185
  });
@@ -4141,14 +4187,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4141
4187
  this.logInfo('updateOrderProduct success', {
4142
4188
  paramsList: paramsList
4143
4189
  });
4144
- return _context22.abrupt("return", tempOrder.products);
4190
+ return _context23.abrupt("return", tempOrder.products);
4145
4191
  case 8:
4146
4192
  case "end":
4147
- return _context22.stop();
4193
+ return _context23.stop();
4148
4194
  }
4149
- }, _callee20, this);
4195
+ }, _callee21, this);
4150
4196
  }));
4151
- function updateOrderProducts(_x24) {
4197
+ function updateOrderProducts(_x25) {
4152
4198
  return _updateOrderProducts.apply(this, arguments);
4153
4199
  }
4154
4200
  return updateOrderProducts;
@@ -4156,11 +4202,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4156
4202
  }, {
4157
4203
  key: "updateOrderProductQuantity",
4158
4204
  value: function () {
4159
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
4205
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
4160
4206
  var _targetProduct$metada10;
4161
4207
  var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
4162
- return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4163
- while (1) switch (_context23.prev = _context23.next) {
4208
+ return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4209
+ while (1) switch (_context24.prev = _context24.next) {
4164
4210
  case 0:
4165
4211
  product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
4166
4212
  tempOrder = this.ensureTempOrder();
@@ -4189,7 +4235,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4189
4235
  productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
4190
4236
  }
4191
4237
  if (!(productIndex === -1)) {
4192
- _context23.next = 12;
4238
+ _context24.next = 12;
4193
4239
  break;
4194
4240
  }
4195
4241
  throw new Error('[Order] 目标商品不存在,无法更新数量');
@@ -4203,12 +4249,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4203
4249
  }));
4204
4250
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4205
4251
  tempOrder.products[productIndex] = normalizedProduct;
4206
- _context23.next = 18;
4252
+ _context24.next = 18;
4207
4253
  return this.applyPromotion();
4208
4254
  case 18:
4209
4255
  this.applyDiscount();
4210
4256
  this.sanitizeTempOrderProducts(tempOrder);
4211
- _context23.next = 22;
4257
+ _context24.next = 22;
4212
4258
  return this.recalculateSummary({
4213
4259
  createIfMissing: true
4214
4260
  });
@@ -4217,14 +4263,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4217
4263
  this.logInfo('updateOrderProductQuantity success', {
4218
4264
  params: params
4219
4265
  });
4220
- return _context23.abrupt("return", tempOrder.products);
4266
+ return _context24.abrupt("return", tempOrder.products);
4221
4267
  case 25:
4222
4268
  case "end":
4223
- return _context23.stop();
4269
+ return _context24.stop();
4224
4270
  }
4225
- }, _callee21, this);
4271
+ }, _callee22, this);
4226
4272
  }));
4227
- function updateOrderProductQuantity(_x25) {
4273
+ function updateOrderProductQuantity(_x26) {
4228
4274
  return _updateOrderProductQuantity.apply(this, arguments);
4229
4275
  }
4230
4276
  return updateOrderProductQuantity;
@@ -4265,19 +4311,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4265
4311
  }, {
4266
4312
  key: "finalizeAfterProductsMutation",
4267
4313
  value: (function () {
4268
- var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(tempOrder, options) {
4269
- return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4270
- while (1) switch (_context24.prev = _context24.next) {
4314
+ var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
4315
+ return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4316
+ while (1) switch (_context25.prev = _context25.next) {
4271
4317
  case 0:
4272
4318
  this.syncTempOrderHolderFromBookings(tempOrder);
4273
- _context24.next = 3;
4319
+ _context25.next = 3;
4274
4320
  return this.applyPromotion();
4275
4321
  case 3:
4276
4322
  this.applyDiscount({
4277
4323
  reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
4278
4324
  });
4279
4325
  this.sanitizeTempOrderProducts(tempOrder);
4280
- _context24.next = 7;
4326
+ _context25.next = 7;
4281
4327
  return this.recalculateSummary({
4282
4328
  createIfMissing: true
4283
4329
  });
@@ -4285,11 +4331,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4285
4331
  this.persistTempOrder();
4286
4332
  case 8:
4287
4333
  case "end":
4288
- return _context24.stop();
4334
+ return _context25.stop();
4289
4335
  }
4290
- }, _callee22, this);
4336
+ }, _callee23, this);
4291
4337
  }));
4292
- function finalizeAfterProductsMutation(_x26, _x27) {
4338
+ function finalizeAfterProductsMutation(_x27, _x28) {
4293
4339
  return _finalizeAfterProductsMutation.apply(this, arguments);
4294
4340
  }
4295
4341
  return finalizeAfterProductsMutation;
@@ -4304,18 +4350,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4304
4350
  }, {
4305
4351
  key: "removeProductsFromOrder",
4306
4352
  value: (function () {
4307
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(identities) {
4353
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities) {
4308
4354
  var _this25 = this;
4309
4355
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
4310
- return _regeneratorRuntime().wrap(function _callee23$(_context26) {
4311
- while (1) switch (_context26.prev = _context26.next) {
4356
+ return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4357
+ while (1) switch (_context27.prev = _context27.next) {
4312
4358
  case 0:
4313
4359
  tempOrder = this.ensureTempOrder();
4314
4360
  if (identities.length) {
4315
- _context26.next = 3;
4361
+ _context27.next = 3;
4316
4362
  break;
4317
4363
  }
4318
- return _context26.abrupt("return", tempOrder.products);
4364
+ return _context27.abrupt("return", tempOrder.products);
4319
4365
  case 3:
4320
4366
  productsBeforeRemove = tempOrder.products || [];
4321
4367
  bookingsBeforeRemove = tempOrder.bookings || [];
@@ -4338,22 +4384,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4338
4384
  }
4339
4385
  linkedBookingUidsToRemove = new Set();
4340
4386
  _iterator21 = _createForOfIteratorHelper(matchedProducts);
4341
- _context26.prev = 11;
4387
+ _context27.prev = 11;
4342
4388
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
4343
4389
  var _metadata8, _metadata9, _metadata10, _metadata11;
4344
4390
  var product, productUid, productBookingUid, isAddTimeProduct;
4345
- return _regeneratorRuntime().wrap(function _loop3$(_context25) {
4346
- while (1) switch (_context25.prev = _context25.next) {
4391
+ return _regeneratorRuntime().wrap(function _loop3$(_context26) {
4392
+ while (1) switch (_context26.prev = _context26.next) {
4347
4393
  case 0:
4348
4394
  product = _step21.value;
4349
4395
  productUid = (product === null || product === void 0 || (_metadata8 = product.metadata) === null || _metadata8 === void 0 ? void 0 : _metadata8.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
4350
4396
  productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata9 = product.metadata) === null || _metadata9 === void 0 ? void 0 : _metadata9.booking_uid);
4351
4397
  isAddTimeProduct = (product === null || product === void 0 || (_metadata10 = product.metadata) === null || _metadata10 === void 0 ? void 0 : _metadata10.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.product_add_schedule_time) !== null;
4352
4398
  if (!isAddTimeProduct) {
4353
- _context25.next = 6;
4399
+ _context26.next = 6;
4354
4400
  break;
4355
4401
  }
4356
- return _context25.abrupt("return", 1);
4402
+ return _context26.abrupt("return", 1);
4357
4403
  case 6:
4358
4404
  if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
4359
4405
  linkedBookingUidsToRemove.add(String(productBookingUid));
@@ -4368,37 +4414,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4368
4414
  }
4369
4415
  case 8:
4370
4416
  case "end":
4371
- return _context25.stop();
4417
+ return _context26.stop();
4372
4418
  }
4373
4419
  }, _loop3);
4374
4420
  });
4375
4421
  _iterator21.s();
4376
4422
  case 14:
4377
4423
  if ((_step21 = _iterator21.n()).done) {
4378
- _context26.next = 20;
4424
+ _context27.next = 20;
4379
4425
  break;
4380
4426
  }
4381
- return _context26.delegateYield(_loop3(), "t0", 16);
4427
+ return _context27.delegateYield(_loop3(), "t0", 16);
4382
4428
  case 16:
4383
- if (!_context26.t0) {
4384
- _context26.next = 18;
4429
+ if (!_context27.t0) {
4430
+ _context27.next = 18;
4385
4431
  break;
4386
4432
  }
4387
- return _context26.abrupt("continue", 18);
4433
+ return _context27.abrupt("continue", 18);
4388
4434
  case 18:
4389
- _context26.next = 14;
4435
+ _context27.next = 14;
4390
4436
  break;
4391
4437
  case 20:
4392
- _context26.next = 25;
4438
+ _context27.next = 25;
4393
4439
  break;
4394
4440
  case 22:
4395
- _context26.prev = 22;
4396
- _context26.t1 = _context26["catch"](11);
4397
- _iterator21.e(_context26.t1);
4441
+ _context27.prev = 22;
4442
+ _context27.t1 = _context27["catch"](11);
4443
+ _iterator21.e(_context27.t1);
4398
4444
  case 25:
4399
- _context26.prev = 25;
4445
+ _context27.prev = 25;
4400
4446
  _iterator21.f();
4401
- return _context26.finish(25);
4447
+ return _context27.finish(25);
4402
4448
  case 28:
4403
4449
  if (linkedBookingUidsToRemove.size > 0) {
4404
4450
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
@@ -4409,20 +4455,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4409
4455
  return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
4410
4456
  });
4411
4457
  }
4412
- _context26.next = 31;
4458
+ _context27.next = 31;
4413
4459
  return this.finalizeAfterProductsMutation(tempOrder);
4414
4460
  case 31:
4415
4461
  this.logInfo('removeProductsFromOrder success', {
4416
4462
  identities: identities
4417
4463
  });
4418
- return _context26.abrupt("return", tempOrder.products);
4464
+ return _context27.abrupt("return", tempOrder.products);
4419
4465
  case 33:
4420
4466
  case "end":
4421
- return _context26.stop();
4467
+ return _context27.stop();
4422
4468
  }
4423
- }, _callee23, this, [[11, 22, 25, 28]]);
4469
+ }, _callee24, this, [[11, 22, 25, 28]]);
4424
4470
  }));
4425
- function removeProductsFromOrder(_x28) {
4471
+ function removeProductsFromOrder(_x29) {
4426
4472
  return _removeProductsFromOrder.apply(this, arguments);
4427
4473
  }
4428
4474
  return removeProductsFromOrder;
@@ -4430,18 +4476,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4430
4476
  }, {
4431
4477
  key: "removeProductFromOrder",
4432
4478
  value: function () {
4433
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identity) {
4434
- return _regeneratorRuntime().wrap(function _callee24$(_context27) {
4435
- while (1) switch (_context27.prev = _context27.next) {
4479
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity) {
4480
+ return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4481
+ while (1) switch (_context28.prev = _context28.next) {
4436
4482
  case 0:
4437
- return _context27.abrupt("return", this.removeProductsFromOrder([identity]));
4483
+ return _context28.abrupt("return", this.removeProductsFromOrder([identity]));
4438
4484
  case 1:
4439
4485
  case "end":
4440
- return _context27.stop();
4486
+ return _context28.stop();
4441
4487
  }
4442
- }, _callee24, this);
4488
+ }, _callee25, this);
4443
4489
  }));
4444
- function removeProductFromOrder(_x29) {
4490
+ function removeProductFromOrder(_x30) {
4445
4491
  return _removeProductFromOrder.apply(this, arguments);
4446
4492
  }
4447
4493
  return removeProductFromOrder;
@@ -4453,10 +4499,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4453
4499
  }, {
4454
4500
  key: "clearOrderCartLines",
4455
4501
  value: (function () {
4456
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
4502
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
4457
4503
  var tempOrder;
4458
- return _regeneratorRuntime().wrap(function _callee25$(_context28) {
4459
- while (1) switch (_context28.prev = _context28.next) {
4504
+ return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4505
+ while (1) switch (_context29.prev = _context29.next) {
4460
4506
  case 0:
4461
4507
  tempOrder = this.ensureTempOrder();
4462
4508
  tempOrder.products = [];
@@ -4467,24 +4513,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4467
4513
  productsByUid: {}
4468
4514
  });
4469
4515
  }
4470
- _context28.next = 7;
4516
+ _context29.next = 7;
4471
4517
  return this.applyPromotion();
4472
4518
  case 7:
4473
4519
  this.applyDiscount();
4474
4520
  this.sanitizeTempOrderProducts(tempOrder);
4475
- _context28.next = 11;
4521
+ _context29.next = 11;
4476
4522
  return this.recalculateSummary({
4477
4523
  createIfMissing: true
4478
4524
  });
4479
4525
  case 11:
4480
4526
  this.persistTempOrder();
4481
4527
  this.logInfo('clearOrderCartLines success', {});
4482
- return _context28.abrupt("return", tempOrder);
4528
+ return _context29.abrupt("return", tempOrder);
4483
4529
  case 14:
4484
4530
  case "end":
4485
- return _context28.stop();
4531
+ return _context29.stop();
4486
4532
  }
4487
- }, _callee25, this);
4533
+ }, _callee26, this);
4488
4534
  }));
4489
4535
  function clearOrderCartLines() {
4490
4536
  return _clearOrderCartLines.apply(this, arguments);
@@ -4522,17 +4568,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4522
4568
  }, {
4523
4569
  key: "applyLocalPrintOrderNumbers",
4524
4570
  value: function () {
4525
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order) {
4571
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
4526
4572
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
4527
- return _regeneratorRuntime().wrap(function _callee26$(_context29) {
4528
- while (1) switch (_context29.prev = _context29.next) {
4573
+ return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4574
+ while (1) switch (_context30.prev = _context30.next) {
4529
4575
  case 0:
4530
4576
  tempOrder = this.ensureTempOrder();
4531
4577
  if (!(!order || _typeof(order) !== 'object')) {
4532
- _context29.next = 3;
4578
+ _context30.next = 3;
4533
4579
  break;
4534
4580
  }
4535
- return _context29.abrupt("return", tempOrder);
4581
+ return _context30.abrupt("return", tempOrder);
4536
4582
  case 3:
4537
4583
  shopOrderNumber = order.shop_order_number;
4538
4584
  shopFullOrderNumber = order.shop_full_order_number;
@@ -4543,17 +4589,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4543
4589
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
4544
4590
  }
4545
4591
  this.persistTempOrder();
4546
- _context29.next = 10;
4592
+ _context30.next = 10;
4547
4593
  return this.saveDraft();
4548
4594
  case 10:
4549
- return _context29.abrupt("return", tempOrder);
4595
+ return _context30.abrupt("return", tempOrder);
4550
4596
  case 11:
4551
4597
  case "end":
4552
- return _context29.stop();
4598
+ return _context30.stop();
4553
4599
  }
4554
- }, _callee26, this);
4600
+ }, _callee27, this);
4555
4601
  }));
4556
- function applyLocalPrintOrderNumbers(_x30) {
4602
+ function applyLocalPrintOrderNumbers(_x31) {
4557
4603
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
4558
4604
  }
4559
4605
  return applyLocalPrintOrderNumbers;
@@ -4567,18 +4613,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4567
4613
  }, {
4568
4614
  key: "submitTempOrder",
4569
4615
  value: (function () {
4570
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
4571
- return _regeneratorRuntime().wrap(function _callee27$(_context30) {
4572
- while (1) switch (_context30.prev = _context30.next) {
4616
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4617
+ return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4618
+ while (1) switch (_context31.prev = _context31.next) {
4573
4619
  case 0:
4574
- return _context30.abrupt("return", this.runSubmitTempOrder(params));
4620
+ return _context31.abrupt("return", this.runSubmitTempOrder(params));
4575
4621
  case 1:
4576
4622
  case "end":
4577
- return _context30.stop();
4623
+ return _context31.stop();
4578
4624
  }
4579
- }, _callee27, this);
4625
+ }, _callee28, this);
4580
4626
  }));
4581
- function submitTempOrder(_x31) {
4627
+ function submitTempOrder(_x32) {
4582
4628
  return _submitTempOrder.apply(this, arguments);
4583
4629
  }
4584
4630
  return submitTempOrder;
@@ -4586,20 +4632,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4586
4632
  }, {
4587
4633
  key: "submitTempOrderAsync",
4588
4634
  value: function () {
4589
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
4590
- return _regeneratorRuntime().wrap(function _callee28$(_context31) {
4591
- while (1) switch (_context31.prev = _context31.next) {
4635
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4636
+ return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4637
+ while (1) switch (_context32.prev = _context32.next) {
4592
4638
  case 0:
4593
- return _context31.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4639
+ return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
4594
4640
  syncMode: true
4595
4641
  })));
4596
4642
  case 1:
4597
4643
  case "end":
4598
- return _context31.stop();
4644
+ return _context32.stop();
4599
4645
  }
4600
- }, _callee28, this);
4646
+ }, _callee29, this);
4601
4647
  }));
4602
- function submitTempOrderAsync(_x32) {
4648
+ function submitTempOrderAsync(_x33) {
4603
4649
  return _submitTempOrderAsync.apply(this, arguments);
4604
4650
  }
4605
4651
  return submitTempOrderAsync;
@@ -4607,11 +4653,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4607
4653
  }, {
4608
4654
  key: "runSubmitTempOrder",
4609
4655
  value: function () {
4610
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
4656
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
4611
4657
  var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
4612
4658
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4613
- return _regeneratorRuntime().wrap(function _callee29$(_context32) {
4614
- while (1) switch (_context32.prev = _context32.next) {
4659
+ return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4660
+ while (1) switch (_context33.prev = _context33.next) {
4615
4661
  case 0:
4616
4662
  tempOrder = this.ensureTempOrder();
4617
4663
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
@@ -4631,26 +4677,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4631
4677
  }
4632
4678
  }
4633
4679
  this.persistTempOrder();
4634
- _context32.next = 8;
4680
+ _context33.next = 8;
4635
4681
  return this.recalculateSummary({
4636
4682
  createIfMissing: true
4637
4683
  });
4638
4684
  case 8:
4639
- _context32.t1 = _context32.sent;
4640
- if (_context32.t1) {
4641
- _context32.next = 11;
4685
+ _context33.t1 = _context33.sent;
4686
+ if (_context33.t1) {
4687
+ _context33.next = 11;
4642
4688
  break;
4643
4689
  }
4644
- _context32.t1 = this.store.summary;
4690
+ _context33.t1 = this.store.summary;
4645
4691
  case 11:
4646
- _context32.t0 = _context32.t1;
4647
- if (_context32.t0) {
4648
- _context32.next = 14;
4692
+ _context33.t0 = _context33.t1;
4693
+ if (_context33.t0) {
4694
+ _context33.next = 14;
4649
4695
  break;
4650
4696
  }
4651
- _context32.t0 = createEmptySummary();
4697
+ _context33.t0 = createEmptySummary();
4652
4698
  case 14:
4653
- latestSummary = _context32.t0;
4699
+ latestSummary = _context33.t0;
4654
4700
  effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
4655
4701
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
4656
4702
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
@@ -4685,10 +4731,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4685
4731
  if (!payload.created_at) {
4686
4732
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
4687
4733
  }
4688
- _context32.next = 26;
4734
+ _context33.next = 26;
4689
4735
  return this.saveDraft();
4690
4736
  case 26:
4691
- _context32.prev = 26;
4737
+ _context33.prev = 26;
4692
4738
  this.logInfo('submitTempOrder calling sales checkout', {
4693
4739
  orderId: payload.order_id,
4694
4740
  externalSaleNumber: payload.external_sale_number,
@@ -4698,43 +4744,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4698
4744
  smallTicketDataFlag: payload.small_ticket_data_flag,
4699
4745
  syncMode: payload.sync_mode
4700
4746
  });
4701
- _context32.next = 30;
4747
+ _context33.next = 30;
4702
4748
  return this.submitSalesOrder({
4703
4749
  query: payload
4704
4750
  });
4705
4751
  case 30:
4706
- result = _context32.sent;
4707
- _context32.next = 43;
4752
+ result = _context33.sent;
4753
+ _context33.next = 43;
4708
4754
  break;
4709
4755
  case 33:
4710
- _context32.prev = 33;
4711
- _context32.t2 = _context32["catch"](26);
4712
- backendErrorResponse = this.extractSubmitErrorResponse(_context32.t2);
4756
+ _context33.prev = 33;
4757
+ _context33.t2 = _context33["catch"](26);
4758
+ backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
4713
4759
  if (!backendErrorResponse) {
4714
- _context32.next = 40;
4760
+ _context33.next = 40;
4715
4761
  break;
4716
4762
  }
4717
4763
  this.store.syncState = 'failed';
4718
4764
  this.logSubmitBackendRejected(backendErrorResponse, payload);
4719
- return _context32.abrupt("return", backendErrorResponse);
4765
+ return _context33.abrupt("return", backendErrorResponse);
4720
4766
  case 40:
4721
4767
  this.store.syncState = 'failed';
4722
4768
  this.logError('submitTempOrder failed', {
4723
- error: _context32.t2 instanceof Error ? _context32.t2.message : String(_context32.t2),
4769
+ error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
4724
4770
  orderId: payload.order_id,
4725
4771
  externalSaleNumber: payload.external_sale_number,
4726
4772
  paymentStatus: payload.payment_status,
4727
4773
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
4728
4774
  });
4729
- throw _context32.t2;
4775
+ throw _context33.t2;
4730
4776
  case 43:
4731
4777
  if (!this.isSubmitResponseRejected(result)) {
4732
- _context32.next = 47;
4778
+ _context33.next = 47;
4733
4779
  break;
4734
4780
  }
4735
4781
  this.store.syncState = 'failed';
4736
4782
  this.logSubmitBackendRejected(result, payload);
4737
- return _context32.abrupt("return", result);
4783
+ return _context33.abrupt("return", result);
4738
4784
  case 47:
4739
4785
  submittedOrderId = this.extractOrderIdFromSubmitResult(result);
4740
4786
  this.logInfo('runSubmitTempOrder: 提交成功', {
@@ -4745,15 +4791,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4745
4791
  })
4746
4792
  });
4747
4793
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
4748
- _context32.next = 56;
4794
+ _context33.next = 56;
4749
4795
  break;
4750
4796
  }
4751
4797
  tempOrder.order_id = submittedOrderId;
4752
4798
  resultRecord = result;
4753
- _context32.next = 54;
4799
+ _context33.next = 54;
4754
4800
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
4755
4801
  case 54:
4756
- _context32.next = 57;
4802
+ _context33.next = 57;
4757
4803
  break;
4758
4804
  case 56:
4759
4805
  if (this.isLocalPendingSubmitResult(result)) {
@@ -4762,14 +4808,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4762
4808
  this.store.syncState = 'submitted';
4763
4809
  }
4764
4810
  case 57:
4765
- return _context32.abrupt("return", result);
4811
+ return _context33.abrupt("return", result);
4766
4812
  case 58:
4767
4813
  case "end":
4768
- return _context32.stop();
4814
+ return _context33.stop();
4769
4815
  }
4770
- }, _callee29, this, [[26, 33]]);
4816
+ }, _callee30, this, [[26, 33]]);
4771
4817
  }));
4772
- function runSubmitTempOrder(_x33) {
4818
+ function runSubmitTempOrder(_x34) {
4773
4819
  return _runSubmitTempOrder.apply(this, arguments);
4774
4820
  }
4775
4821
  return runSubmitTempOrder;
@@ -4777,10 +4823,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4777
4823
  }, {
4778
4824
  key: "markLocalOrderSynced",
4779
4825
  value: function () {
4780
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(orderId, remoteOrder) {
4826
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
4781
4827
  var tempOrder;
4782
- return _regeneratorRuntime().wrap(function _callee30$(_context33) {
4783
- while (1) switch (_context33.prev = _context33.next) {
4828
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4829
+ while (1) switch (_context34.prev = _context34.next) {
4784
4830
  case 0:
4785
4831
  tempOrder = this.ensureTempOrder();
4786
4832
  tempOrder.order_id = orderId;
@@ -4788,15 +4834,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4788
4834
  this.store.lastOrderInfo = remoteOrder;
4789
4835
  this.store.syncState = 'submitted';
4790
4836
  this.persistTempOrder();
4791
- _context33.next = 8;
4837
+ _context34.next = 8;
4792
4838
  return this.saveDraft();
4793
4839
  case 8:
4794
4840
  case "end":
4795
- return _context33.stop();
4841
+ return _context34.stop();
4796
4842
  }
4797
- }, _callee30, this);
4843
+ }, _callee31, this);
4798
4844
  }));
4799
- function markLocalOrderSynced(_x34, _x35) {
4845
+ function markLocalOrderSynced(_x35, _x36) {
4800
4846
  return _markLocalOrderSynced.apply(this, arguments);
4801
4847
  }
4802
4848
  return markLocalOrderSynced;
@@ -4869,11 +4915,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4869
4915
  }, {
4870
4916
  key: "syncPaymentsToOrder",
4871
4917
  value: function () {
4872
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4918
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
4873
4919
  var _params$confirmPendin;
4874
4920
  var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, paidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
4875
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4876
- while (1) switch (_context34.prev = _context34.next) {
4921
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
4922
+ while (1) switch (_context35.prev = _context35.next) {
4877
4923
  case 0:
4878
4924
  tempOrder = this.ensureTempOrder();
4879
4925
  mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
@@ -4885,24 +4931,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4885
4931
  tempOrder.payments = effectivePayments;
4886
4932
  tempOrder.payment_status = paymentStatus;
4887
4933
  this.persistTempOrder();
4888
- _context34.next = 12;
4934
+ _context35.next = 12;
4889
4935
  return this.saveDraft();
4890
4936
  case 12:
4891
4937
  if (params.submitWhenPaid) {
4892
- _context34.next = 14;
4938
+ _context35.next = 14;
4893
4939
  break;
4894
4940
  }
4895
- return _context34.abrupt("return", completion);
4941
+ return _context35.abrupt("return", completion);
4896
4942
  case 14:
4897
4943
  if (!(this.store.syncState === 'submitting')) {
4898
- _context34.next = 16;
4944
+ _context35.next = 16;
4899
4945
  break;
4900
4946
  }
4901
- return _context34.abrupt("return", completion);
4947
+ return _context35.abrupt("return", completion);
4902
4948
  case 16:
4903
4949
  this.store.syncState = 'submitting';
4904
4950
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
4905
- _context34.next = 20;
4951
+ _context35.next = 20;
4906
4952
  return this.submitTempOrder({
4907
4953
  payments: effectivePayments,
4908
4954
  paymentStatus: paymentStatus,
@@ -4918,17 +4964,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4918
4964
  }
4919
4965
  });
4920
4966
  case 20:
4921
- submitResult = _context34.sent;
4922
- return _context34.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4967
+ submitResult = _context35.sent;
4968
+ return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
4923
4969
  submitResult: submitResult
4924
4970
  }));
4925
4971
  case 22:
4926
4972
  case "end":
4927
- return _context34.stop();
4973
+ return _context35.stop();
4928
4974
  }
4929
- }, _callee31, this);
4975
+ }, _callee32, this);
4930
4976
  }));
4931
- function syncPaymentsToOrder(_x36) {
4977
+ function syncPaymentsToOrder(_x37) {
4932
4978
  return _syncPaymentsToOrder.apply(this, arguments);
4933
4979
  }
4934
4980
  return syncPaymentsToOrder;
@@ -5017,11 +5063,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5017
5063
  }, {
5018
5064
  key: "submitOrder",
5019
5065
  value: function () {
5020
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(order) {
5066
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
5021
5067
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
5022
5068
  var url, query, fetchUrl, params;
5023
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5024
- while (1) switch (_context35.prev = _context35.next) {
5069
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5070
+ while (1) switch (_context36.prev = _context36.next) {
5025
5071
  case 0:
5026
5072
  this.logInfo('submitOrder called', {
5027
5073
  url: order.url,
@@ -5041,14 +5087,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5041
5087
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
5042
5088
  scheduleDate: params.schedule_date
5043
5089
  });
5044
- return _context35.abrupt("return", this.request.post(fetchUrl, params));
5090
+ return _context36.abrupt("return", this.request.post(fetchUrl, params));
5045
5091
  case 6:
5046
5092
  case "end":
5047
- return _context35.stop();
5093
+ return _context36.stop();
5048
5094
  }
5049
- }, _callee32, this);
5095
+ }, _callee33, this);
5050
5096
  }));
5051
- function submitOrder(_x37) {
5097
+ function submitOrder(_x38) {
5052
5098
  return _submitOrder.apply(this, arguments);
5053
5099
  }
5054
5100
  return submitOrder;
@@ -5056,13 +5102,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5056
5102
  }, {
5057
5103
  key: "cancelOrder",
5058
5104
  value: function () {
5059
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5105
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5060
5106
  var payload;
5061
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5062
- while (1) switch (_context36.prev = _context36.next) {
5107
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5108
+ while (1) switch (_context37.prev = _context37.next) {
5063
5109
  case 0:
5064
5110
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
5065
- _context36.next = 2;
5111
+ _context37.next = 2;
5066
5112
  break;
5067
5113
  }
5068
5114
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -5078,16 +5124,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5078
5124
  method: 'PUT',
5079
5125
  orderIdsCount: params.order_ids.length
5080
5126
  });
5081
- return _context36.abrupt("return", this.request.put('/order/update-status', payload, {
5127
+ return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
5082
5128
  isShopApi: true
5083
5129
  }));
5084
5130
  case 5:
5085
5131
  case "end":
5086
- return _context36.stop();
5132
+ return _context37.stop();
5087
5133
  }
5088
- }, _callee33, this);
5134
+ }, _callee34, this);
5089
5135
  }));
5090
- function cancelOrder(_x38) {
5136
+ function cancelOrder(_x39) {
5091
5137
  return _cancelOrder.apply(this, arguments);
5092
5138
  }
5093
5139
  return cancelOrder;
@@ -5095,19 +5141,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5095
5141
  }, {
5096
5142
  key: "changeBookingStatus",
5097
5143
  value: function () {
5098
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5144
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5099
5145
  var url, payload;
5100
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5101
- while (1) switch (_context37.prev = _context37.next) {
5146
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5147
+ while (1) switch (_context38.prev = _context38.next) {
5102
5148
  case 0:
5103
5149
  if (params.booking_id) {
5104
- _context37.next = 2;
5150
+ _context38.next = 2;
5105
5151
  break;
5106
5152
  }
5107
5153
  throw new Error('变更预约状态失败:booking_id 不能为空');
5108
5154
  case 2:
5109
5155
  if (params.appointment_status) {
5110
- _context37.next = 4;
5156
+ _context38.next = 4;
5111
5157
  break;
5112
5158
  }
5113
5159
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -5122,16 +5168,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5122
5168
  bookingId: params.booking_id,
5123
5169
  appointmentStatus: params.appointment_status
5124
5170
  });
5125
- return _context37.abrupt("return", this.request.put(url, payload, {
5171
+ return _context38.abrupt("return", this.request.put(url, payload, {
5126
5172
  isShopApi: true
5127
5173
  }));
5128
5174
  case 8:
5129
5175
  case "end":
5130
- return _context37.stop();
5176
+ return _context38.stop();
5131
5177
  }
5132
- }, _callee34, this);
5178
+ }, _callee35, this);
5133
5179
  }));
5134
- function changeBookingStatus(_x39) {
5180
+ function changeBookingStatus(_x40) {
5135
5181
  return _changeBookingStatus.apply(this, arguments);
5136
5182
  }
5137
5183
  return changeBookingStatus;
@@ -5149,11 +5195,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5149
5195
  }, {
5150
5196
  key: "createOrderByCheckout",
5151
5197
  value: (function () {
5152
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5198
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5153
5199
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
5154
5200
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
5155
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5156
- while (1) switch (_context38.prev = _context38.next) {
5201
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5202
+ while (1) switch (_context39.prev = _context39.next) {
5157
5203
  case 0:
5158
5204
  // 过滤掉由在线店铺下单的 payment 支付数据
5159
5205
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -5187,7 +5233,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5187
5233
  relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
5188
5234
  paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
5189
5235
  });
5190
- _context38.prev = 4;
5236
+ _context39.prev = 4;
5191
5237
  // 构建订单数据,设置默认值并允许 params 覆盖
5192
5238
  orderData = _objectSpread({
5193
5239
  sales_channel: 'my_pisel',
@@ -5249,13 +5295,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5249
5295
  hasOrderId: !!orderData.order_id,
5250
5296
  smallTicketDataFlag: orderData.small_ticket_data_flag
5251
5297
  });
5252
- _context38.next = 12;
5298
+ _context39.next = 12;
5253
5299
  return this.request.post('/order/checkout', orderData, {
5254
5300
  osServer: true,
5255
5301
  customToast: function customToast() {}
5256
5302
  });
5257
5303
  case 12:
5258
- response = _context38.sent;
5304
+ response = _context39.sent;
5259
5305
  this.logInfo('Order API called successfully', {
5260
5306
  response: response
5261
5307
  });
@@ -5263,22 +5309,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5263
5309
  success: !!response,
5264
5310
  hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
5265
5311
  });
5266
- return _context38.abrupt("return", response);
5312
+ return _context39.abrupt("return", response);
5267
5313
  case 18:
5268
- _context38.prev = 18;
5269
- _context38.t0 = _context38["catch"](4);
5270
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context38.t0);
5314
+ _context39.prev = 18;
5315
+ _context39.t0 = _context39["catch"](4);
5316
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
5271
5317
  this.logInfo('Order API called failed', {
5272
- error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
5318
+ error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
5273
5319
  });
5274
- throw _context38.t0;
5320
+ throw _context39.t0;
5275
5321
  case 23:
5276
5322
  case "end":
5277
- return _context38.stop();
5323
+ return _context39.stop();
5278
5324
  }
5279
- }, _callee35, this, [[4, 18]]);
5325
+ }, _callee36, this, [[4, 18]]);
5280
5326
  }));
5281
- function createOrderByCheckout(_x40) {
5327
+ function createOrderByCheckout(_x41) {
5282
5328
  return _createOrderByCheckout.apply(this, arguments);
5283
5329
  }
5284
5330
  return createOrderByCheckout;
@@ -5286,24 +5332,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5286
5332
  }, {
5287
5333
  key: "submitSalesOrder",
5288
5334
  value: function () {
5289
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5335
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5290
5336
  var url, query, fetchUrl;
5291
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5292
- while (1) switch (_context39.prev = _context39.next) {
5337
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5338
+ while (1) switch (_context40.prev = _context40.next) {
5293
5339
  case 0:
5294
5340
  url = params.url, query = params.query;
5295
5341
  fetchUrl = url || '/order/sales/checkout';
5296
- return _context39.abrupt("return", this.request.post(fetchUrl, query, {
5342
+ return _context40.abrupt("return", this.request.post(fetchUrl, query, {
5297
5343
  osServer: true,
5298
5344
  customToast: function customToast() {}
5299
5345
  }));
5300
5346
  case 3:
5301
5347
  case "end":
5302
- return _context39.stop();
5348
+ return _context40.stop();
5303
5349
  }
5304
- }, _callee36, this);
5350
+ }, _callee37, this);
5305
5351
  }));
5306
- function submitSalesOrder(_x41) {
5352
+ function submitSalesOrder(_x42) {
5307
5353
  return _submitSalesOrder.apply(this, arguments);
5308
5354
  }
5309
5355
  return submitSalesOrder;
@@ -5317,37 +5363,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5317
5363
  }, {
5318
5364
  key: "sendCustomerPayLink",
5319
5365
  value: (function () {
5320
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
5366
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5321
5367
  var _params$emails;
5322
5368
  var orderIds;
5323
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5324
- while (1) switch (_context40.prev = _context40.next) {
5369
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5370
+ while (1) switch (_context41.prev = _context41.next) {
5325
5371
  case 0:
5326
5372
  orderIds = params.order_ids || params.orderIds || [];
5327
5373
  if (orderIds.length) {
5328
- _context40.next = 3;
5374
+ _context41.next = 3;
5329
5375
  break;
5330
5376
  }
5331
5377
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
5332
5378
  case 3:
5333
5379
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
5334
- _context40.next = 5;
5380
+ _context41.next = 5;
5335
5381
  break;
5336
5382
  }
5337
5383
  throw new Error('发送支付链接需要至少一个邮箱');
5338
5384
  case 5:
5339
- return _context40.abrupt("return", this.request.post('/order/batch-email', {
5385
+ return _context41.abrupt("return", this.request.post('/order/batch-email', {
5340
5386
  order_ids: orderIds,
5341
5387
  notify_action: params.notify_action || 'order_payment_reminder',
5342
5388
  emails: params.emails
5343
5389
  }));
5344
5390
  case 6:
5345
5391
  case "end":
5346
- return _context40.stop();
5392
+ return _context41.stop();
5347
5393
  }
5348
- }, _callee37, this);
5394
+ }, _callee38, this);
5349
5395
  }));
5350
- function sendCustomerPayLink(_x42) {
5396
+ function sendCustomerPayLink(_x43) {
5351
5397
  return _sendCustomerPayLink.apply(this, arguments);
5352
5398
  }
5353
5399
  return sendCustomerPayLink;
@@ -5355,14 +5401,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5355
5401
  }, {
5356
5402
  key: "getSalesOrderByLookup",
5357
5403
  value: function () {
5358
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5404
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
5359
5405
  var lookup, res;
5360
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
5361
- while (1) switch (_context41.prev = _context41.next) {
5406
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5407
+ while (1) switch (_context42.prev = _context42.next) {
5362
5408
  case 0:
5363
5409
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
5364
5410
  if (lookup) {
5365
- _context41.next = 3;
5411
+ _context42.next = 3;
5366
5412
  break;
5367
5413
  }
5368
5414
  throw new Error('加载销售详情需要 lookup');
@@ -5371,7 +5417,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5371
5417
  if (lookup.startsWith('LOCAL_')) {
5372
5418
  params.forceRemote = false;
5373
5419
  }
5374
- _context41.next = 6;
5420
+ _context42.next = 6;
5375
5421
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
5376
5422
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
5377
5423
  }, params.forceRemote ? {
@@ -5380,18 +5426,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5380
5426
  osServer: true
5381
5427
  });
5382
5428
  case 6:
5383
- res = _context41.sent;
5429
+ res = _context42.sent;
5384
5430
  if (res.code === 200) {
5385
5431
  this.store.lastOrderInfo = res.data;
5386
5432
  }
5387
- return _context41.abrupt("return", res);
5433
+ return _context42.abrupt("return", res);
5388
5434
  case 9:
5389
5435
  case "end":
5390
- return _context41.stop();
5436
+ return _context42.stop();
5391
5437
  }
5392
- }, _callee38, this);
5438
+ }, _callee39, this);
5393
5439
  }));
5394
- function getSalesOrderByLookup(_x43) {
5440
+ function getSalesOrderByLookup(_x44) {
5395
5441
  return _getSalesOrderByLookup.apply(this, arguments);
5396
5442
  }
5397
5443
  return getSalesOrderByLookup;
@@ -5405,14 +5451,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5405
5451
  }, {
5406
5452
  key: "hydrateTempOrderFromRecord",
5407
5453
  value: (function () {
5408
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(record, options) {
5409
- var _this$store$discount15;
5410
- var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount16, _this$store$discount17;
5411
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
5412
- while (1) switch (_context42.prev = _context42.next) {
5454
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
5455
+ var _this$store$discount19;
5456
+ var raw, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
5457
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5458
+ while (1) switch (_context43.prev = _context43.next) {
5413
5459
  case 0:
5414
5460
  raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
5415
- nextTempOrder = this.normalizeTempOrderForRuntime(raw);
5461
+ nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
5462
+ makeEditMark: true
5463
+ });
5416
5464
  rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
5417
5465
  summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
5418
5466
  return _objectSpread({}, s || {});
@@ -5433,37 +5481,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5433
5481
  });
5434
5482
  this.store.lastOrderInfo = raw.lastOrderInfo || raw;
5435
5483
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
5436
- currentDiscounts = typeof ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5437
- shouldSkipEmptyDiscountSync = hydratedEditDiscounts.length === 0 && currentDiscounts.length === 0;
5484
+ currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
5485
+ currentScanDiscounts = currentDiscounts.filter(function (discount) {
5486
+ return discount === null || discount === void 0 ? void 0 : discount.isScan;
5487
+ });
5488
+ hydratedDiscountIds = new Set(hydratedEditDiscounts.map(function (discount) {
5489
+ return discount === null || discount === void 0 ? void 0 : discount.id;
5490
+ }));
5491
+ retainedScanDiscounts = currentScanDiscounts.filter(function (discount) {
5492
+ return !hydratedDiscountIds.has(discount === null || discount === void 0 ? void 0 : discount.id);
5493
+ });
5494
+ nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
5495
+ shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
5438
5496
  if (shouldSkipEmptyDiscountSync) {
5439
- _context42.next = 17;
5497
+ _context43.next = 21;
5440
5498
  break;
5441
5499
  }
5442
- OrderModule.populateSavedAmounts(nextTempOrder.products, hydratedEditDiscounts);
5443
- _context42.next = 15;
5444
- return (_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList(hydratedEditDiscounts);
5445
- case 15:
5446
- _context42.next = 17;
5447
- return (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList(hydratedEditDiscounts);
5448
- case 17:
5500
+ OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
5501
+ _context43.next = 19;
5502
+ return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
5503
+ case 19:
5504
+ _context43.next = 21;
5505
+ return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
5506
+ case 21:
5449
5507
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
5450
- _context42.next = 20;
5508
+ _context43.next = 24;
5451
5509
  break;
5452
5510
  }
5453
- _context42.next = 20;
5511
+ _context43.next = 24;
5454
5512
  return this.recalculateSummary({
5455
5513
  createIfMissing: false
5456
5514
  });
5457
- case 20:
5515
+ case 24:
5458
5516
  this.persistTempOrder();
5459
- return _context42.abrupt("return", nextTempOrder);
5460
- case 22:
5517
+ return _context43.abrupt("return", nextTempOrder);
5518
+ case 26:
5461
5519
  case "end":
5462
- return _context42.stop();
5520
+ return _context43.stop();
5463
5521
  }
5464
- }, _callee39, this);
5522
+ }, _callee40, this);
5465
5523
  }));
5466
- function hydrateTempOrderFromRecord(_x44, _x45) {
5524
+ function hydrateTempOrderFromRecord(_x45, _x46) {
5467
5525
  return _hydrateTempOrderFromRecord.apply(this, arguments);
5468
5526
  }
5469
5527
  return hydrateTempOrderFromRecord;
@@ -5527,7 +5585,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5527
5585
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
5528
5586
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
5529
5587
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
5530
- return _this27.normalizeHydratedOrderProduct(p);
5588
+ return _this27.normalizeHydratedOrderProduct(p, {
5589
+ makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
5590
+ });
5531
5591
  }) : [];
5532
5592
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
5533
5593
  var booking = _this27.normalizeHydratedBookingHolder(b || {});
@@ -5698,7 +5758,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5698
5758
  }
5699
5759
  }, {
5700
5760
  key: "normalizeHydratedOrderProduct",
5701
- value: function normalizeHydratedOrderProduct(product) {
5761
+ value: function normalizeHydratedOrderProduct(product, options) {
5702
5762
  var _this28 = this;
5703
5763
  var row = _objectSpread({}, product || {});
5704
5764
  if (row.num === undefined && row.product_quantity !== undefined) {
@@ -5722,7 +5782,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5722
5782
  row.metadata.unique_identification_number = createUuidV4();
5723
5783
  }
5724
5784
  // 从云端、本地数据库中获取到的商品数据,先打上 runtime 标记,提供给 UI 做 saved items.
5725
- row.metadata.is_edit_for_runtime = true;
5785
+ if (options !== null && options !== void 0 && options.makeEditMark) {
5786
+ row.metadata.is_edit_for_runtime = true;
5787
+ }
5726
5788
  var normalized = normalizeOrderProduct(row);
5727
5789
  normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
5728
5790
  var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
@@ -5742,27 +5804,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5742
5804
  }, {
5743
5805
  key: "getOrderInfo",
5744
5806
  value: function () {
5745
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(order_id) {
5807
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
5746
5808
  var res;
5747
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
5748
- while (1) switch (_context43.prev = _context43.next) {
5809
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
5810
+ while (1) switch (_context44.prev = _context44.next) {
5749
5811
  case 0:
5750
- _context43.next = 2;
5812
+ _context44.next = 2;
5751
5813
  return this.request.get("/order/sales/".concat(order_id), {
5752
5814
  with: ['products', 'bookings']
5753
5815
  }, {
5754
5816
  osServer: true
5755
5817
  });
5756
5818
  case 2:
5757
- res = _context43.sent;
5758
- return _context43.abrupt("return", res);
5819
+ res = _context44.sent;
5820
+ return _context44.abrupt("return", res);
5759
5821
  case 4:
5760
5822
  case "end":
5761
- return _context43.stop();
5823
+ return _context44.stop();
5762
5824
  }
5763
- }, _callee40, this);
5825
+ }, _callee41, this);
5764
5826
  }));
5765
- function getOrderInfo(_x46) {
5827
+ function getOrderInfo(_x47) {
5766
5828
  return _getOrderInfo.apply(this, arguments);
5767
5829
  }
5768
5830
  return getOrderInfo;