@pisell/pisellos 2.3.100 → 2.3.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  2. package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
  3. package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/modules/Discount/index.d.ts +2 -0
  6. package/dist/modules/Discount/index.js +38 -5
  7. package/dist/modules/Discount/types.d.ts +11 -0
  8. package/dist/modules/Order/index.d.ts +14 -0
  9. package/dist/modules/Order/index.js +617 -368
  10. package/dist/modules/Order/types.d.ts +11 -3
  11. package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
  12. package/dist/modules/Order/utils/virtualSettlement.js +284 -0
  13. package/dist/modules/Order/utils.d.ts +1 -0
  14. package/dist/modules/Order/utils.js +63 -24
  15. package/dist/modules/Product/types.d.ts +23 -0
  16. package/dist/modules/Rules/index.d.ts +5 -0
  17. package/dist/modules/Rules/index.js +27 -12
  18. package/dist/modules/SalesSummary/index.d.ts +1 -0
  19. package/dist/modules/SalesSummary/index.js +4 -3
  20. package/dist/modules/SalesSummary/types.d.ts +1 -0
  21. package/dist/modules/SalesSummary/utils.d.ts +1 -0
  22. package/dist/modules/SalesSummary/utils.js +21 -1
  23. package/dist/solution/BaseSales/index.d.ts +10 -1
  24. package/dist/solution/BaseSales/index.js +1099 -784
  25. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  26. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
  27. package/dist/solution/BookingByStep/index.d.ts +2 -2
  28. package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
  29. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
  30. package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
  31. package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
  32. package/lib/modules/Discount/index.d.ts +2 -0
  33. package/lib/modules/Discount/index.js +31 -2
  34. package/lib/modules/Discount/types.d.ts +11 -0
  35. package/lib/modules/Order/index.d.ts +14 -0
  36. package/lib/modules/Order/index.js +195 -15
  37. package/lib/modules/Order/types.d.ts +11 -3
  38. package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
  39. package/lib/modules/Order/utils/virtualSettlement.js +262 -0
  40. package/lib/modules/Order/utils.d.ts +1 -0
  41. package/lib/modules/Order/utils.js +57 -20
  42. package/lib/modules/Product/types.d.ts +23 -0
  43. package/lib/modules/Rules/index.d.ts +5 -0
  44. package/lib/modules/Rules/index.js +20 -11
  45. package/lib/modules/SalesSummary/index.d.ts +1 -0
  46. package/lib/modules/SalesSummary/index.js +4 -2
  47. package/lib/modules/SalesSummary/types.d.ts +1 -0
  48. package/lib/modules/SalesSummary/utils.d.ts +1 -0
  49. package/lib/modules/SalesSummary/utils.js +17 -1
  50. package/lib/solution/BaseSales/index.d.ts +10 -1
  51. package/lib/solution/BaseSales/index.js +211 -9
  52. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  53. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
  54. package/lib/solution/BookingByStep/index.d.ts +2 -2
  55. package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
  56. package/package.json +1 -1
@@ -44,6 +44,7 @@ import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum } fro
44
44
  import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
45
45
  import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, repairDuplicateProductLineIdentities as repairDuplicateOrderProductLineIdentities, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
46
46
  import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
47
+ import { applyTempOrderSettlementState, getSelectedSettlementSnapshot, getSettlementKey, getTempOrderSettlementKey, getTempOrderSettlementSnapshot, isVirtualSettlementOrder, normalizeVirtualSettlementOrderProduct, normalizeVirtualSettlementProducts, OrderSettlementConflictError, releaseTempOrderSettlementState, VirtualCurrencyAssetNotFoundError, VirtualCurrencyBalanceError } from "./utils/virtualSettlement";
47
48
  import { DiscountModule } from "../Discount";
48
49
  import { RulesModule } from "../Rules";
49
50
  import { UnavailableReason } from "../Rules/types";
@@ -340,6 +341,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
340
341
  this.store.tempOrder = null;
341
342
  this.store.summary = createEmptySummary();
342
343
  this.store.availableWalletIds = [];
344
+ this.store.virtualCurrencyList = [];
343
345
  this.store.lastOrderInfo = undefined;
344
346
  this.store.syncState = undefined;
345
347
  this.store.discountList = [];
@@ -352,6 +354,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
352
354
  if (!Array.isArray(this.store.availableWalletIds)) {
353
355
  this.store.availableWalletIds = [];
354
356
  }
357
+ if (!Array.isArray(this.store.virtualCurrencyList)) {
358
+ this.store.virtualCurrencyList = [];
359
+ }
355
360
  this.request = this.core.getPlugin('request');
356
361
  appPlugin = this.core.getPlugin('app');
357
362
  if (!appPlugin) {
@@ -367,7 +372,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
367
372
  this.otherParams = otherParams;
368
373
  this.registerDiscountModules(options);
369
374
  this.logInfo('OrderModule initialized successfully');
370
- case 20:
375
+ case 21:
371
376
  case "end":
372
377
  return _context.stop();
373
378
  }
@@ -455,6 +460,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
455
460
  this.otherParams = otherParams;
456
461
  }
457
462
 
463
+ /** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
464
+ }, {
465
+ key: "isOnlineStorePlatform",
466
+ value: function isOnlineStorePlatform() {
467
+ var _this$otherParams;
468
+ var platform = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase();
469
+ return platform === 'pc' || platform === 'h5';
470
+ }
471
+
458
472
  /**
459
473
  * 记录信息日志
460
474
  */
@@ -560,6 +574,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
560
574
  with_wallet_pass_holder: 1,
561
575
  with_available_wallet_flag: 1,
562
576
  with_available_wallet_pass_flag: 1,
577
+ with_virtual_currency: 1,
563
578
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
564
579
  }, orderId ? {
565
580
  order_id: orderId
@@ -568,8 +583,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
568
583
  prepareConfigResult = _context3.sent;
569
584
  discountList = prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.discountList;
570
585
  this.store.availableWalletIds = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.availableWalletIds) || [];
586
+ this.store.virtualCurrencyList = (prepareConfigResult === null || prepareConfigResult === void 0 ? void 0 : prepareConfigResult.virtualCurrencyList) || [];
571
587
  if (!discountList) {
572
- _context3.next = 18;
588
+ _context3.next = 19;
573
589
  break;
574
590
  }
575
591
  currentDiscountList = ((_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.getDiscountList()) || [];
@@ -590,17 +606,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
590
606
  return true;
591
607
  });
592
608
  mergedDiscountList = [].concat(_toConsumableArray(currentEditDiscounts), _toConsumableArray(currentScanDiscounts), _toConsumableArray(runtimeDiscounts));
593
- _context3.next = 16;
609
+ _context3.next = 17;
594
610
  return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setOriginalDiscountList(mergedDiscountList);
595
- case 16:
596
- _context3.next = 18;
611
+ case 17:
612
+ _context3.next = 19;
597
613
  return (_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.setDiscountList(mergedDiscountList);
598
- case 18:
614
+ case 19:
599
615
  if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
600
616
  this.applyDiscount();
601
617
  }
602
618
  return _context3.abrupt("return", this.getDiscountList());
603
- case 20:
619
+ case 21:
604
620
  case "end":
605
621
  return _context3.stop();
606
622
  }
@@ -622,6 +638,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
622
638
  value: function getAvailableWalletIds() {
623
639
  return Array.isArray(this.store.availableWalletIds) ? _toConsumableArray(this.store.availableWalletIds) : [];
624
640
  }
641
+ }, {
642
+ key: "getVirtualCurrencyList",
643
+ value: function getVirtualCurrencyList() {
644
+ return cloneDeep(this.store.virtualCurrencyList || []);
645
+ }
625
646
  }, {
626
647
  key: "syncScannedDiscountsToOriginalDiscountList",
627
648
  value: function () {
@@ -714,26 +735,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
714
735
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
715
736
  while (1) switch (_context6.prev = _context6.next) {
716
737
  case 0:
717
- _context6.next = 2;
738
+ if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
739
+ _context6.next = 2;
740
+ break;
741
+ }
742
+ return _context6.abrupt("return", {
743
+ type: 'clientCalc',
744
+ isAvailable: false,
745
+ isAccepted: false,
746
+ discountList: [],
747
+ scannedDiscountList: [],
748
+ unavailableReason: UnavailableReason.ProductNotApplicable
749
+ });
750
+ case 2:
751
+ _context6.next = 4;
718
752
  return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
719
753
  customerId: customerId
720
754
  });
721
- case 2:
755
+ case 4:
722
756
  _context6.t0 = _context6.sent;
723
757
  if (_context6.t0) {
724
- _context6.next = 5;
758
+ _context6.next = 7;
725
759
  break;
726
760
  }
727
761
  _context6.t0 = {
728
762
  discountList: [],
729
763
  unavailableReasonKey: null
730
764
  };
731
- case 5:
765
+ case 7:
732
766
  resultDiscountWithReason = _context6.t0;
733
767
  resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
734
768
  rulesModule = this.store.rules;
735
769
  if (rulesModule) {
736
- _context6.next = 10;
770
+ _context6.next = 12;
737
771
  break;
738
772
  }
739
773
  return _context6.abrupt("return", {
@@ -744,9 +778,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
744
778
  scannedDiscountList: resultDiscountList,
745
779
  unavailableReason: UnavailableReason.Unknown
746
780
  });
747
- case 10:
781
+ case 12:
748
782
  if (resultDiscountList.length) {
749
- _context6.next = 12;
783
+ _context6.next = 14;
750
784
  break;
751
785
  }
752
786
  return _context6.abrupt("return", {
@@ -757,7 +791,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
757
791
  scannedDiscountList: resultDiscountList,
758
792
  unavailableReasonKey: unavailableReasonKey
759
793
  });
760
- case 12:
794
+ case 14:
761
795
  withScanList = resultDiscountList.map(function (item) {
762
796
  return _objectSpread(_objectSpread({}, item), {}, {
763
797
  isScan: true
@@ -771,12 +805,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
771
805
  return m.id === n.id;
772
806
  });
773
807
  }))) {
774
- _context6.next = 18;
808
+ _context6.next = 20;
775
809
  break;
776
810
  }
777
- _context6.next = 17;
811
+ _context6.next = 19;
778
812
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
779
- case 17:
813
+ case 19:
780
814
  return _context6.abrupt("return", {
781
815
  type: 'clientCalc',
782
816
  isAvailable: true,
@@ -784,7 +818,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
784
818
  discountList: this.getDiscountList(),
785
819
  scannedDiscountList: resultDiscountList
786
820
  });
787
- case 18:
821
+ case 20:
788
822
  tempOrder = this.store.tempOrder;
789
823
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
790
824
  _ref12 = rulesModule.isDiscountListAvailable({
@@ -805,32 +839,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
805
839
  retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
806
840
  resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
807
841
  if (!(isAvailable && normalizedNewDiscountList)) {
808
- _context6.next = 34;
842
+ _context6.next = 36;
809
843
  break;
810
844
  }
811
- _context6.next = 28;
845
+ _context6.next = 30;
812
846
  return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
813
- case 28:
847
+ case 30:
814
848
  this.applyDiscount();
815
- _context6.next = 31;
849
+ _context6.next = 33;
816
850
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
817
- case 31:
851
+ case 33:
818
852
  resolvedDiscountList = this.getDiscountList();
819
- _context6.next = 40;
853
+ _context6.next = 42;
820
854
  break;
821
- case 34:
855
+ case 36:
822
856
  if (!(shouldRetainForLater && retainedDiscountList)) {
823
- _context6.next = 40;
857
+ _context6.next = 42;
824
858
  break;
825
859
  }
826
- _context6.next = 37;
827
- return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
828
- case 37:
829
860
  _context6.next = 39;
830
- return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
861
+ return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
831
862
  case 39:
863
+ _context6.next = 41;
864
+ return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
865
+ case 41:
832
866
  resolvedDiscountList = this.getDiscountList();
833
- case 40:
867
+ case 42:
834
868
  return _context6.abrupt("return", {
835
869
  type: 'clientCalc',
836
870
  isAvailable: isAvailable || false,
@@ -839,7 +873,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
839
873
  scannedDiscountList: resultDiscountList,
840
874
  unavailableReason: unavailableReason
841
875
  });
842
- case 41:
876
+ case 43:
843
877
  case "end":
844
878
  return _context6.stop();
845
879
  }
@@ -853,7 +887,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
853
887
  }, {
854
888
  key: "applyDiscount",
855
889
  value: function applyDiscount(options) {
856
- var _this$store$discount14,
890
+ var _this$store$discount16,
857
891
  _this$store$summary2,
858
892
  _this2 = this;
859
893
  var tempOrder = this.store.tempOrder;
@@ -861,9 +895,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
861
895
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
862
896
  // appliedProductDetails / savedAmount 复位。
863
897
  if (!tempOrder) return;
898
+ if (this.isActiveVirtualSettlementOrder(tempOrder)) {
899
+ var _this$store$discount14, _this$store$discount15;
900
+ tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
901
+ tempOrder.discount_list = [];
902
+ tempOrder.shop_discount = '0.00';
903
+ void ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.setDiscountList([]));
904
+ void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
905
+ return;
906
+ }
864
907
  this.syncLinkedBookingHoldersToProducts(tempOrder);
865
908
  delete tempOrder.discount_list;
866
- var discountList = ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.getDiscountList()) || [];
909
+ var discountList = ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.getDiscountList()) || [];
867
910
  var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
868
911
  if (shouldSkipDiscountCalculation) return;
869
912
  var rulesModule = this.store.rules;
@@ -897,9 +940,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
897
940
  consolidateDiscountFreeProductLines(tempOrder);
898
941
  }
899
942
  if (result !== null && result !== void 0 && result.discountList) {
900
- var _this$store$discount15;
943
+ var _this$store$discount17;
901
944
  OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
902
- (_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 || _this$store$discount15.setDiscountList(result.discountList);
945
+ (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
903
946
  }
904
947
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
905
948
  return _this2.productHasCustomerBoundDiscount(product);
@@ -988,15 +1031,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
988
1031
  }
989
1032
  return _context9.abrupt("return");
990
1033
  case 7:
991
- strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
992
- if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
1034
+ if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
993
1035
  _context9.next = 10;
994
1036
  break;
995
1037
  }
1038
+ tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
996
1039
  return _context9.abrupt("return");
997
1040
  case 10:
1041
+ strategyConfigs = (_this$promotionEvalua = (_this$promotionEvalua2 = this.promotionEvaluator).getStrategyConfigs) === null || _this$promotionEvalua === void 0 ? void 0 : _this$promotionEvalua.call(_this$promotionEvalua2);
1042
+ if (!(Array.isArray(strategyConfigs) && strategyConfigs.length === 0)) {
1043
+ _context9.next = 13;
1044
+ break;
1045
+ }
1046
+ return _context9.abrupt("return");
1047
+ case 13:
998
1048
  this.isApplyingPromotion = true;
999
- _context9.prev = 11;
1049
+ _context9.prev = 14;
1000
1050
  result = processCartPromotion(tempOrder.products, this.promotionEvaluator); // step 1: toRemove —— 直接过滤
1001
1051
  if (result.giftActions.toRemove.length > 0) {
1002
1052
  removeSet = new Set(result.giftActions.toRemove.map(String));
@@ -1008,16 +1058,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1008
1058
 
1009
1059
  // step 2: toReduce —— 调整数量
1010
1060
  _iterator3 = _createForOfIteratorHelper(result.giftActions.toReduce);
1011
- _context9.prev = 15;
1061
+ _context9.prev = 18;
1012
1062
  _iterator3.s();
1013
- case 17:
1063
+ case 20:
1014
1064
  if ((_step3 = _iterator3.n()).done) {
1015
- _context9.next = 37;
1065
+ _context9.next = 40;
1016
1066
  break;
1017
1067
  }
1018
1068
  reduce = _step3.value;
1019
1069
  _iterator6 = _createForOfIteratorHelper(reduce.items);
1020
- _context9.prev = 20;
1070
+ _context9.prev = 23;
1021
1071
  _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
1022
1072
  var item, product;
1023
1073
  return _regeneratorRuntime().wrap(function _loop2$(_context8) {
@@ -1037,47 +1087,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1037
1087
  }, _loop2);
1038
1088
  });
1039
1089
  _iterator6.s();
1040
- case 23:
1090
+ case 26:
1041
1091
  if ((_step6 = _iterator6.n()).done) {
1042
- _context9.next = 27;
1092
+ _context9.next = 30;
1043
1093
  break;
1044
1094
  }
1045
- return _context9.delegateYield(_loop2(), "t0", 25);
1046
- case 25:
1047
- _context9.next = 23;
1095
+ return _context9.delegateYield(_loop2(), "t0", 28);
1096
+ case 28:
1097
+ _context9.next = 26;
1048
1098
  break;
1049
- case 27:
1050
- _context9.next = 32;
1099
+ case 30:
1100
+ _context9.next = 35;
1051
1101
  break;
1052
- case 29:
1053
- _context9.prev = 29;
1054
- _context9.t1 = _context9["catch"](20);
1055
- _iterator6.e(_context9.t1);
1056
1102
  case 32:
1057
1103
  _context9.prev = 32;
1058
- _iterator6.f();
1059
- return _context9.finish(32);
1104
+ _context9.t1 = _context9["catch"](23);
1105
+ _iterator6.e(_context9.t1);
1060
1106
  case 35:
1061
- _context9.next = 17;
1107
+ _context9.prev = 35;
1108
+ _iterator6.f();
1109
+ return _context9.finish(35);
1110
+ case 38:
1111
+ _context9.next = 20;
1062
1112
  break;
1063
- case 37:
1064
- _context9.next = 42;
1113
+ case 40:
1114
+ _context9.next = 45;
1065
1115
  break;
1066
- case 39:
1067
- _context9.prev = 39;
1068
- _context9.t2 = _context9["catch"](15);
1069
- _iterator3.e(_context9.t2);
1070
1116
  case 42:
1071
1117
  _context9.prev = 42;
1072
- _iterator3.f();
1073
- return _context9.finish(42);
1118
+ _context9.t2 = _context9["catch"](18);
1119
+ _iterator3.e(_context9.t2);
1074
1120
  case 45:
1121
+ _context9.prev = 45;
1122
+ _iterator3.f();
1123
+ return _context9.finish(45);
1124
+ case 48:
1075
1125
  if (!(result.giftActions.toAdd.length > 0)) {
1076
- _context9.next = 68;
1126
+ _context9.next = 71;
1077
1127
  break;
1078
1128
  }
1079
1129
  if (this.giftSelectResolver) {
1080
- _context9.next = 50;
1130
+ _context9.next = 53;
1081
1131
  break;
1082
1132
  }
1083
1133
  if (result.giftActions.toAdd.some(function (g) {
@@ -1088,11 +1138,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1088
1138
  } else {
1089
1139
  console.warn('[OrderModule] giftSelectResolver not set, skip applying single-option gifts', result.giftActions.toAdd);
1090
1140
  }
1091
- _context9.next = 68;
1141
+ _context9.next = 71;
1092
1142
  break;
1093
- case 50:
1143
+ case 53:
1094
1144
  _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
1095
- _context9.prev = 51;
1145
+ _context9.prev = 54;
1096
1146
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
1097
1147
  var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
1098
1148
  return _regeneratorRuntime().wrap(function _loop$(_context7) {
@@ -1190,33 +1240,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1190
1240
  }, _loop, null, [[6, 39], [14, 31, 34, 37]]);
1191
1241
  });
1192
1242
  _iterator4.s();
1193
- case 54:
1243
+ case 57:
1194
1244
  if ((_step4 = _iterator4.n()).done) {
1195
- _context9.next = 60;
1245
+ _context9.next = 63;
1196
1246
  break;
1197
1247
  }
1198
- return _context9.delegateYield(_loop(), "t3", 56);
1199
- case 56:
1248
+ return _context9.delegateYield(_loop(), "t3", 59);
1249
+ case 59:
1200
1250
  if (!_context9.t3) {
1201
- _context9.next = 58;
1251
+ _context9.next = 61;
1202
1252
  break;
1203
1253
  }
1204
- return _context9.abrupt("continue", 58);
1205
- case 58:
1206
- _context9.next = 54;
1254
+ return _context9.abrupt("continue", 61);
1255
+ case 61:
1256
+ _context9.next = 57;
1207
1257
  break;
1208
- case 60:
1209
- _context9.next = 65;
1258
+ case 63:
1259
+ _context9.next = 68;
1210
1260
  break;
1211
- case 62:
1212
- _context9.prev = 62;
1213
- _context9.t4 = _context9["catch"](51);
1214
- _iterator4.e(_context9.t4);
1215
1261
  case 65:
1216
1262
  _context9.prev = 65;
1217
- _iterator4.f();
1218
- return _context9.finish(65);
1263
+ _context9.t4 = _context9["catch"](54);
1264
+ _iterator4.e(_context9.t4);
1219
1265
  case 68:
1266
+ _context9.prev = 68;
1267
+ _iterator4.f();
1268
+ return _context9.finish(68);
1269
+ case 71:
1220
1270
  tempOrder.products = result.products;
1221
1271
  this.lastUnfulfilledPromotions = result.unfulfilledPromotions;
1222
1272
  this.lastGiftActions = result.giftActions;
@@ -1234,21 +1284,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1234
1284
  products: tempOrder.products
1235
1285
  };
1236
1286
  this.effectsEmit('onPromotionApplied', payload);
1237
- _context9.next = 78;
1287
+ _context9.next = 81;
1238
1288
  break;
1239
- case 75:
1240
- _context9.prev = 75;
1241
- _context9.t5 = _context9["catch"](11);
1242
- console.error('[OrderModule] applyPromotion failed', _context9.t5);
1243
1289
  case 78:
1244
1290
  _context9.prev = 78;
1245
- this.isApplyingPromotion = false;
1246
- return _context9.finish(78);
1291
+ _context9.t5 = _context9["catch"](14);
1292
+ console.error('[OrderModule] applyPromotion failed', _context9.t5);
1247
1293
  case 81:
1294
+ _context9.prev = 81;
1295
+ this.isApplyingPromotion = false;
1296
+ return _context9.finish(81);
1297
+ case 84:
1248
1298
  case "end":
1249
1299
  return _context9.stop();
1250
1300
  }
1251
- }, _callee7, this, [[11, 75, 78, 81], [15, 39, 42, 45], [20, 29, 32, 35], [51, 62, 65, 68]]);
1301
+ }, _callee7, this, [[14, 78, 81, 84], [18, 42, 45, 48], [23, 32, 35, 38], [54, 65, 68, 71]]);
1252
1302
  }));
1253
1303
  function applyPromotion() {
1254
1304
  return _applyPromotion.apply(this, arguments);
@@ -2476,7 +2526,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2476
2526
  }, {
2477
2527
  key: "restoreOrder",
2478
2528
  value: function restoreOrder() {
2479
- var _this$store$discount16, _this$store$discount17;
2529
+ var _this$store$discount18, _this$store$discount19;
2480
2530
  this.logInfo('restoreOrder start', {});
2481
2531
  this.sessionStorageRestoreRecord = null;
2482
2532
  var freshTempOrder = this.createDefaultTempOrderInstance();
@@ -2485,8 +2535,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2485
2535
  this.store.summary = createEmptySummary();
2486
2536
  this.store.lastOrderInfo = undefined;
2487
2537
  this.store.syncState = undefined;
2488
- void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList([]));
2489
- void ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList([]));
2538
+ void ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.setOriginalDiscountList([]));
2539
+ void ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.setDiscountList([]));
2490
2540
  this.persistTempOrder();
2491
2541
  return freshTempOrder;
2492
2542
  }
@@ -2691,8 +2741,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2691
2741
  value: function sanitizeTempOrderProducts(tempOrder) {
2692
2742
  var _this15 = this;
2693
2743
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2694
- return _this15.sanitizeOrderProductForTempOrder(product);
2744
+ return _this15.sanitizeOrderProductForTempOrder(_this15.normalizeVirtualSettlementProductIfEnabled(product));
2695
2745
  });
2746
+ this.syncTempOrderSettlementState(tempOrder);
2696
2747
  ensureUniqueProductLineUids(tempOrder);
2697
2748
  }
2698
2749
  }, {
@@ -2873,7 +2924,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2873
2924
  }, {
2874
2925
  key: "buildTempOrderHolderFromBookings",
2875
2926
  value: function buildTempOrderHolderFromBookings(tempOrder) {
2876
- var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
2927
+ var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
2877
2928
  var holderRecords = [];
2878
2929
  var holderNames = [];
2879
2930
  var baseHolder = null;
@@ -2926,7 +2977,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2926
2977
  if (holderNames.length) {
2927
2978
  nextHolder.name = holderNames.join(',');
2928
2979
  }
2929
- if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.isFranchisee) {
2980
+ if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.isFranchisee) {
2930
2981
  nextHolder.is_source_shop = 1;
2931
2982
  }
2932
2983
  return nextHolder;
@@ -3025,7 +3076,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3025
3076
  key: "recalculateSummary",
3026
3077
  value: function () {
3027
3078
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
3028
- var _this$otherParams2, _ref46, _salesSummaryResult$e;
3079
+ var _this$otherParams3, _ref46, _salesSummaryResult$e;
3029
3080
  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;
3030
3081
  return _regeneratorRuntime().wrap(function _callee12$(_context14) {
3031
3082
  while (1) switch (_context14.prev = _context14.next) {
@@ -3090,8 +3141,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3090
3141
  return salesSummary.getSummary(_objectSpread({
3091
3142
  products: summaryProducts,
3092
3143
  isPriceIncludeTax: tempOrder.is_price_include_tax,
3093
- shopDiscount: tempOrder.shop_discount
3094
- }, (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.channel ? {
3144
+ shopDiscount: tempOrder.shop_discount,
3145
+ virtualSettlementMode: this.shouldUseVirtualSettlementSummary(tempOrder)
3146
+ }, (_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.channel ? {
3095
3147
  channel: this.otherParams.channel
3096
3148
  } : {}));
3097
3149
  case 28:
@@ -3624,11 +3676,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3624
3676
  }, {
3625
3677
  key: "shouldSkipDiscountCalculation",
3626
3678
  value: function shouldSkipDiscountCalculation(tempOrder) {
3627
- var _this$store$discount18,
3628
- _this$store$discount19,
3679
+ var _this$store$discount20,
3680
+ _this$store$discount21,
3629
3681
  _this22 = this;
3630
3682
  if (this.hasActiveCustomerBoundDiscount) return false;
3631
- var discountList = ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 || (_this$store$discount19 = _this$store$discount18.getDiscountList) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.call(_this$store$discount18)) || [];
3683
+ var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
3632
3684
  if (discountList.length > 0) return false;
3633
3685
  return !(tempOrder.products || []).some(function (product) {
3634
3686
  return _this22.productHasCustomerBoundDiscount(product);
@@ -3750,6 +3802,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3750
3802
  var nextCustomerId = (_tempOrder$customer_i5 = tempOrder.customer_id) !== null && _tempOrder$customer_i5 !== void 0 ? _tempOrder$customer_i5 : null;
3751
3803
  if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
3752
3804
  this.store.availableWalletIds = [];
3805
+ this.store.virtualCurrencyList = [];
3753
3806
  clearTempOrderHolderAssignments(tempOrder);
3754
3807
  this.clearCustomerBoundDiscounts(tempOrder);
3755
3808
  this.applyDiscount();
@@ -3795,6 +3848,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3795
3848
  tempOrder.customer = null;
3796
3849
  if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
3797
3850
  this.store.availableWalletIds = [];
3851
+ this.store.virtualCurrencyList = [];
3798
3852
  this.clearCustomerBoundDiscounts(tempOrder);
3799
3853
  this.applyDiscount();
3800
3854
  this.persistTempOrder();
@@ -4260,6 +4314,99 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4260
4314
  var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.booking_uid;
4261
4315
  return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
4262
4316
  }
4317
+ }, {
4318
+ key: "isMultiCurrencySettlementEnabled",
4319
+ value: function isMultiCurrencySettlementEnabled() {
4320
+ var _this$otherParams4;
4321
+ return ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.enableMultiCurrencySettlement) === true;
4322
+ }
4323
+ }, {
4324
+ key: "isActiveVirtualSettlementOrder",
4325
+ value: function isActiveVirtualSettlementOrder(tempOrder) {
4326
+ return this.isMultiCurrencySettlementEnabled() && isVirtualSettlementOrder(tempOrder);
4327
+ }
4328
+ }, {
4329
+ key: "shouldUseVirtualSettlementSummary",
4330
+ value: function shouldUseVirtualSettlementSummary(tempOrder) {
4331
+ var _tempOrder$metadata;
4332
+ return this.isActiveVirtualSettlementOrder(tempOrder) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata = tempOrder.metadata) === null || _tempOrder$metadata === void 0 || (_tempOrder$metadata = _tempOrder$metadata.currency_settlement_config) === null || _tempOrder$metadata === void 0 ? void 0 : _tempOrder$metadata.settlement_type) === 'virtual_currency';
4333
+ }
4334
+ }, {
4335
+ key: "normalizeVirtualSettlementProductIfEnabled",
4336
+ value: function normalizeVirtualSettlementProductIfEnabled(product) {
4337
+ return this.isMultiCurrencySettlementEnabled() ? normalizeVirtualSettlementOrderProduct(product) : product;
4338
+ }
4339
+ }, {
4340
+ key: "assertAndLockProductSettlement",
4341
+ value: function assertAndLockProductSettlement(tempOrder, product) {
4342
+ var _ref60, _ref61, _product$selling_pric;
4343
+ if (!this.isMultiCurrencySettlementEnabled()) return;
4344
+ var currentKey = getTempOrderSettlementKey(tempOrder);
4345
+ var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
4346
+ if (currentKey && currentKey !== incomingKey) {
4347
+ throw new OrderSettlementConflictError(currentKey, incomingKey);
4348
+ }
4349
+ var snapshot = getSelectedSettlementSnapshot(product);
4350
+ if ((snapshot === null || snapshot === void 0 ? void 0 : snapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1) {
4351
+ var currencyProductId = Number(snapshot.currency_product_id);
4352
+ var asset = (this.store.virtualCurrencyList || []).find(function (item) {
4353
+ return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
4354
+ });
4355
+ if (!asset) {
4356
+ throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
4357
+ }
4358
+ var existedAmount = tempOrder.products.reduce(function (sum, item) {
4359
+ return sum.plus(new Decimal(item.selling_price || 0).times(item.num || 1));
4360
+ }, new Decimal(0));
4361
+ var requiredAmount = existedAmount.plus(new Decimal(snapshot.price || 0).times(product.num || 1));
4362
+ var balance = new Decimal(asset.balance || 0);
4363
+ if (balance.lt(requiredAmount)) {
4364
+ throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
4365
+ }
4366
+ }
4367
+ applyTempOrderSettlementState(tempOrder, snapshot || {
4368
+ settlement_type: 'legal_currency',
4369
+ price: (_ref60 = (_ref61 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref61 !== void 0 ? _ref61 : product.payment_price) !== null && _ref60 !== void 0 ? _ref60 : 0,
4370
+ unit_label: tempOrder.currency_code,
4371
+ symbol: tempOrder.currency_symbol,
4372
+ amount_format: tempOrder.currency_format
4373
+ });
4374
+ }
4375
+ }, {
4376
+ key: "syncTempOrderSettlementState",
4377
+ value: function syncTempOrderSettlementState(tempOrder) {
4378
+ if (!this.isMultiCurrencySettlementEnabled()) return;
4379
+ tempOrder.metadata = tempOrder.metadata || {};
4380
+ if (!tempOrder.products.length) {
4381
+ releaseTempOrderSettlementState(tempOrder);
4382
+ return;
4383
+ }
4384
+ var snapshot = getTempOrderSettlementSnapshot(tempOrder);
4385
+ if (snapshot) {
4386
+ applyTempOrderSettlementState(tempOrder, snapshot);
4387
+ return;
4388
+ }
4389
+ tempOrder.metadata.cart_settlement_key = 'legal_currency';
4390
+ }
4391
+ }, {
4392
+ key: "prepareVirtualSettlementTempOrder",
4393
+ value: function prepareVirtualSettlementTempOrder(tempOrder) {
4394
+ if (!this.isMultiCurrencySettlementEnabled()) return;
4395
+ this.syncTempOrderSettlementState(tempOrder);
4396
+ if (!this.isActiveVirtualSettlementOrder(tempOrder)) return;
4397
+ tempOrder.products = normalizeVirtualSettlementProducts(tempOrder.products);
4398
+ tempOrder.discount_list = [];
4399
+ tempOrder.shop_discount = '0.00';
4400
+ tempOrder.surcharge_fee = '0.00';
4401
+ tempOrder.surcharges = [];
4402
+ var virtualOrder = tempOrder;
4403
+ virtualOrder.discount_amount = '0.00';
4404
+ virtualOrder.product_tax_fee = '0.00';
4405
+ virtualOrder.tax_fee = '0.00';
4406
+ virtualOrder.shipping_fee = '0.00';
4407
+ virtualOrder.shipping_tax_fee = '0.00';
4408
+ virtualOrder.tip_fee = '0.00';
4409
+ }
4263
4410
 
4264
4411
  // ─── TempOrder: 商品 CRUD ───
4265
4412
 
@@ -4273,35 +4420,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4273
4420
  key: "finalizeProductOrderMutation",
4274
4421
  value: function () {
4275
4422
  var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(tempOrder, options) {
4423
+ var isVirtualSettlement;
4276
4424
  return _regeneratorRuntime().wrap(function _callee21$(_context23) {
4277
4425
  while (1) switch (_context23.prev = _context23.next) {
4278
4426
  case 0:
4279
4427
  this.syncTempOrderHolderFromBookings(tempOrder);
4280
- if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
4281
- _context23.next = 4;
4428
+ this.prepareVirtualSettlementTempOrder(tempOrder);
4429
+ isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
4430
+ if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
4431
+ _context23.next = 6;
4282
4432
  break;
4283
4433
  }
4284
- _context23.next = 4;
4434
+ _context23.next = 6;
4285
4435
  return this.ensureEditDiscountConfigForProductChange(tempOrder);
4286
- case 4:
4287
- if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
4288
- _context23.next = 7;
4436
+ case 6:
4437
+ if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
4438
+ _context23.next = 9;
4289
4439
  break;
4290
4440
  }
4291
- _context23.next = 7;
4441
+ _context23.next = 9;
4292
4442
  return this.applyPromotion();
4293
- case 7:
4294
- if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
4443
+ case 9:
4444
+ if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
4295
4445
  this.applyDiscount();
4296
4446
  }
4297
4447
  this.sanitizeTempOrderProducts(tempOrder);
4298
- _context23.next = 11;
4448
+ _context23.next = 13;
4299
4449
  return this.recalculateSummary({
4300
4450
  createIfMissing: true
4301
4451
  });
4302
- case 11:
4452
+ case 13:
4303
4453
  this.persistTempOrder();
4304
- case 12:
4454
+ case 14:
4305
4455
  case "end":
4306
4456
  return _context23.stop();
4307
4457
  }
@@ -4339,9 +4489,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4339
4489
  booking: booking
4340
4490
  }) : null;
4341
4491
  var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
4492
+ this.assertAndLockProductSettlement(tempOrder, productToAdd);
4342
4493
  var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
4343
4494
  var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
4344
- var normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
4495
+ var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
4345
4496
  if (disableMerge) {
4346
4497
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, _defineProperty({}, PRODUCT_LINE_MERGE_DISABLED_METADATA_KEY, true));
4347
4498
  }
@@ -4399,11 +4550,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4399
4550
  var _targetProduct$metada;
4400
4551
  var targetProduct = matchedProduct;
4401
4552
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
4402
- var normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4553
+ var normalizedProduct = _this29.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4403
4554
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
4404
4555
  unique_identification_number: targetUid
4405
4556
  })
4406
- })));
4557
+ }))));
4407
4558
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4408
4559
  var nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
4409
4560
  tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
@@ -4465,7 +4616,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4465
4616
  value: (function () {
4466
4617
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(product, booking, options) {
4467
4618
  var _this30 = this;
4468
- var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine, singleBooking, committedProduct, _committedProduct, _committedProduct2;
4619
+ var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref62, _productRecord$num, productRecord, splitCount, i, singleLine, singleBooking, committedProduct, _committedProduct, _committedProduct2;
4469
4620
  return _regeneratorRuntime().wrap(function _callee22$(_context24) {
4470
4621
  while (1) switch (_context24.prev = _context24.next) {
4471
4622
  case 0:
@@ -4523,7 +4674,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4523
4674
  break;
4524
4675
  }
4525
4676
  productRecord = product;
4526
- splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
4677
+ splitCount = getSafeProductNum((_ref62 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
4527
4678
  if (!(splitCount > 1)) {
4528
4679
  _context24.next = 30;
4529
4680
  break;
@@ -4631,7 +4782,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4631
4782
  key: "addProductsToOrder",
4632
4783
  value: (function () {
4633
4784
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(items, options) {
4634
- var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
4785
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref63, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
4635
4786
  return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4636
4787
  while (1) switch (_context25.prev = _context25.next) {
4637
4788
  case 0:
@@ -4663,7 +4814,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4663
4814
  break;
4664
4815
  }
4665
4816
  productRecord = product;
4666
- splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
4817
+ splitCount = getSafeProductNum((_ref63 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref63 !== void 0 ? _ref63 : 1);
4667
4818
  if (!(splitCount > 1)) {
4668
4819
  _context25.next = 28;
4669
4820
  break;
@@ -4753,9 +4904,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4753
4904
  }, {
4754
4905
  key: "getBundleRuntimeIdentity",
4755
4906
  value: function getBundleRuntimeIdentity(bundle) {
4756
- var _ref62, _bundle$bundle_id2, _ref63, _bundle$bundle_group_2, _ref64, _ref65, _bundle$bundle_produc3, _ref66, _bundle$bundle_varian3;
4907
+ var _ref64, _bundle$bundle_id2, _ref65, _bundle$bundle_group_2, _ref66, _ref67, _bundle$bundle_produc3, _ref68, _bundle$bundle_varian3;
4757
4908
  if (!bundle || _typeof(bundle) !== 'object') return '';
4758
- return [(_ref62 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref63 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_ref65 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref65 !== void 0 ? _ref65 : bundle.product_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref66 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref66 !== void 0 ? _ref66 : 0].join('|');
4909
+ return [(_ref64 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref65 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref65 !== void 0 ? _ref65 : '', (_ref66 = (_ref67 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref67 !== void 0 ? _ref67 : bundle.product_id) !== null && _ref66 !== void 0 ? _ref66 : '', (_ref68 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref68 !== void 0 ? _ref68 : 0].join('|');
4759
4910
  }
4760
4911
  }, {
4761
4912
  key: "preservePersistedBundlePriceFields",
@@ -4906,13 +5057,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4906
5057
  delete nextProduct.metadata.main_product_original_price;
4907
5058
  delete nextProduct.metadata.price_schema_version;
4908
5059
  } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
4909
- var _ref67, _targetProduct$metada10, _targetProduct$metada11, _ref68, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5060
+ var _ref69, _targetProduct$metada10, _targetProduct$metada11, _ref70, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
4910
5061
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
4911
5062
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
4912
5063
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
4913
5064
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
4914
- var _previousMainOriginal = new Decimal(Number((_ref67 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref67 !== void 0 ? _ref67 : 0) || 0);
4915
- var _previousMainSelling = new Decimal(Number((_ref68 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref68 !== void 0 ? _ref68 : _previousMainOriginal.toNumber()) || 0);
5065
+ var _previousMainOriginal = new Decimal(Number((_ref69 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref69 !== void 0 ? _ref69 : 0) || 0);
5066
+ var _previousMainSelling = new Decimal(Number((_ref70 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref70 !== void 0 ? _ref70 : _previousMainOriginal.toNumber()) || 0);
4916
5067
  var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
4917
5068
  var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
4918
5069
  var _nextMainOriginal = previousSource.plus(nextOptionSum);
@@ -4932,7 +5083,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4932
5083
  }
4933
5084
  // normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
4934
5085
  // 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
4935
- var normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
5086
+ var normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct)));
4936
5087
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
4937
5088
  var preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada15 = targetProduct.metadata) === null || _targetProduct$metada15 === void 0 ? void 0 : _targetProduct$metada15.booking_uid);
4938
5089
  if (!booking && preservedBookingUid) {
@@ -5055,7 +5206,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5055
5206
  value: function () {
5056
5207
  var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
5057
5208
  var _targetProduct$metada17;
5058
- var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
5209
+ var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance;
5059
5210
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5060
5211
  while (1) switch (_context28.prev = _context28.next) {
5061
5212
  case 0:
@@ -5093,30 +5244,63 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5093
5244
  throw new Error('[Order] 目标商品不存在,无法更新数量');
5094
5245
  case 13:
5095
5246
  targetProduct = tempOrder.products[productIndex];
5096
- normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
5247
+ normalizedProduct = this.normalizeVirtualSettlementProductIfEnabled(normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
5097
5248
  num: getSafeProductNum(num),
5098
5249
  metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
5099
5250
  unique_identification_number: ((_targetProduct$metada17 = targetProduct.metadata) === null || _targetProduct$metada17 === void 0 ? void 0 : _targetProduct$metada17.unique_identification_number) || unique_identification_number
5100
5251
  })
5101
- }));
5252
+ })));
5102
5253
  normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
5254
+ settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
5255
+ if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
5256
+ _context28.next = 26;
5257
+ break;
5258
+ }
5259
+ currencyProductId = Number(settlementSnapshot.currency_product_id);
5260
+ asset = (this.store.virtualCurrencyList || []).find(function (item) {
5261
+ return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
5262
+ });
5263
+ if (asset) {
5264
+ _context28.next = 22;
5265
+ break;
5266
+ }
5267
+ throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
5268
+ case 22:
5269
+ requiredAmount = tempOrder.products.reduce(function (sum, item, index) {
5270
+ var current = index === productIndex ? normalizedProduct : item;
5271
+ var currentSnapshot = getSelectedSettlementSnapshot(current);
5272
+ return sum.plus(new Decimal((currentSnapshot === null || currentSnapshot === void 0 ? void 0 : currentSnapshot.price) || current.selling_price || 0).times(current.num || 1));
5273
+ }, new Decimal(0));
5274
+ balance = new Decimal(asset.balance || 0);
5275
+ if (!balance.lt(requiredAmount)) {
5276
+ _context28.next = 26;
5277
+ break;
5278
+ }
5279
+ throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
5280
+ case 26:
5103
5281
  tempOrder.products[productIndex] = normalizedProduct;
5104
- _context28.next = 19;
5282
+ this.prepareVirtualSettlementTempOrder(tempOrder);
5283
+ if (this.isActiveVirtualSettlementOrder(tempOrder)) {
5284
+ _context28.next = 32;
5285
+ break;
5286
+ }
5287
+ _context28.next = 31;
5105
5288
  return this.applyPromotion();
5106
- case 19:
5289
+ case 31:
5107
5290
  this.applyDiscount();
5291
+ case 32:
5108
5292
  this.sanitizeTempOrderProducts(tempOrder);
5109
- _context28.next = 23;
5293
+ _context28.next = 35;
5110
5294
  return this.recalculateSummary({
5111
5295
  createIfMissing: true
5112
5296
  });
5113
- case 23:
5297
+ case 35:
5114
5298
  this.persistTempOrder();
5115
5299
  this.logInfo('updateOrderProductQuantity success', {
5116
5300
  params: params
5117
5301
  });
5118
5302
  return _context28.abrupt("return", tempOrder.products);
5119
- case 26:
5303
+ case 38:
5120
5304
  case "end":
5121
5305
  return _context28.stop();
5122
5306
  }
@@ -5387,6 +5571,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5387
5571
  this.ensureSalesNotesLoadedForMutation(tempOrder);
5388
5572
  tempOrder.products = [];
5389
5573
  tempOrder.bookings = [];
5574
+ releaseTempOrderSettlementState(tempOrder);
5390
5575
  this.removeSalesNotesForMissingProductLines(tempOrder);
5391
5576
  this.syncTempOrderHolderFromBookings(tempOrder);
5392
5577
  if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
@@ -5394,20 +5579,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5394
5579
  productsByUid: {}
5395
5580
  });
5396
5581
  }
5397
- _context33.next = 9;
5582
+ _context33.next = 10;
5398
5583
  return this.applyPromotion();
5399
- case 9:
5584
+ case 10:
5400
5585
  this.applyDiscount();
5401
5586
  this.sanitizeTempOrderProducts(tempOrder);
5402
- _context33.next = 13;
5587
+ _context33.next = 14;
5403
5588
  return this.recalculateSummary({
5404
5589
  createIfMissing: true
5405
5590
  });
5406
- case 13:
5591
+ case 14:
5407
5592
  this.persistTempOrder();
5408
5593
  this.logInfo('clearOrderCartLines success', {});
5409
5594
  return _context33.abrupt("return", tempOrder);
5410
- case 16:
5595
+ case 17:
5411
5596
  case "end":
5412
5597
  return _context33.stop();
5413
5598
  }
@@ -5417,28 +5602,86 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5417
5602
  return _clearOrderCartLines.apply(this, arguments);
5418
5603
  }
5419
5604
  return clearOrderCartLines;
5605
+ }()
5606
+ /**
5607
+ * 切换购物车结算单位时清理所有会影响新币种的订单状态,但保留当前客户。
5608
+ */
5609
+ )
5610
+ }, {
5611
+ key: "clearOrderForSettlementSwitch",
5612
+ value: (function () {
5613
+ var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
5614
+ var _this$store$discount22, _this$store$discount23;
5615
+ var tempOrder;
5616
+ return _regeneratorRuntime().wrap(function _callee31$(_context34) {
5617
+ while (1) switch (_context34.prev = _context34.next) {
5618
+ case 0:
5619
+ tempOrder = this.ensureTempOrder();
5620
+ this.ensureSalesNotesLoadedForMutation(tempOrder);
5621
+ tempOrder.products = [];
5622
+ tempOrder.bookings = [];
5623
+ this.removeSalesNotesForMissingProductLines(tempOrder);
5624
+ tempOrder.discount_list = [];
5625
+ tempOrder.payments = [];
5626
+ tempOrder.refunds = [];
5627
+ tempOrder.shop_discount = '0.00';
5628
+ tempOrder.surcharges = [];
5629
+ releaseTempOrderSettlementState(tempOrder);
5630
+ this.syncTempOrderHolderFromBookings(tempOrder);
5631
+ if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
5632
+ tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
5633
+ productsByUid: {}
5634
+ });
5635
+ }
5636
+ _context34.next = 15;
5637
+ return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
5638
+ case 15:
5639
+ _context34.next = 17;
5640
+ return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
5641
+ case 17:
5642
+ this.hasActiveCustomerBoundDiscount = false;
5643
+ this.lastUnfulfilledPromotions = [];
5644
+ this.lastGiftActions = null;
5645
+ _context34.next = 22;
5646
+ return this.recalculateSummary({
5647
+ createIfMissing: true
5648
+ });
5649
+ case 22:
5650
+ this.persistTempOrder();
5651
+ this.logInfo('clearOrderForSettlementSwitch success', {});
5652
+ return _context34.abrupt("return", tempOrder);
5653
+ case 25:
5654
+ case "end":
5655
+ return _context34.stop();
5656
+ }
5657
+ }, _callee31, this);
5658
+ }));
5659
+ function clearOrderForSettlementSwitch() {
5660
+ return _clearOrderForSettlementSwitch.apply(this, arguments);
5661
+ }
5662
+ return clearOrderForSettlementSwitch;
5420
5663
  }() // ─── TempOrder: 提交 ───
5421
5664
  )
5422
5665
  }, {
5423
5666
  key: "buildCurrentSubmitPayloadForLocalPrint",
5424
5667
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
5425
- var _params$cacheId, _this$otherParams3, _ref69, _params$businessCode, _this$otherParams4, _this$otherParams5;
5668
+ var _params$cacheId, _this$otherParams5, _ref71, _params$businessCode, _this$otherParams6, _this$otherParams7;
5426
5669
  var tempOrder = this.ensureTempOrder();
5427
5670
  this.persistTempOrder();
5428
5671
  var payload = buildSubmitPayload({
5429
5672
  tempOrder: tempOrder,
5430
5673
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
5431
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
5432
- businessCode: (_ref69 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref69 !== void 0 ? _ref69 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
5674
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
5675
+ businessCode: (_ref71 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref71 !== void 0 ? _ref71 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
5433
5676
  channel: params === null || params === void 0 ? void 0 : params.channel,
5434
5677
  type: params === null || params === void 0 ? void 0 : params.type,
5435
5678
  summary: this.store.summary || createEmptySummary(),
5436
5679
  enhance: function enhance(nextPayload) {
5437
- var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order2, _ref72, _tempOrder$shop_full_;
5680
+ var _ref72, _tempOrder$order_numb, _ref73, _tempOrder$shop_order2, _ref74, _tempOrder$shop_full_;
5438
5681
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
5439
- order_number: (_ref70 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
5440
- shop_order_number: (_ref71 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
5441
- shop_full_order_number: (_ref72 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
5682
+ order_number: (_ref72 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
5683
+ shop_order_number: (_ref73 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref73 !== void 0 ? _ref73 : null,
5684
+ shop_full_order_number: (_ref74 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref74 !== void 0 ? _ref74 : null,
5442
5685
  small_ticket_data_flag: 1
5443
5686
  });
5444
5687
  }
@@ -5449,17 +5692,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5449
5692
  }, {
5450
5693
  key: "applyLocalPrintOrderNumbers",
5451
5694
  value: function () {
5452
- var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order) {
5695
+ var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(order) {
5453
5696
  var tempOrder, shopOrderNumber, shopFullOrderNumber;
5454
- return _regeneratorRuntime().wrap(function _callee31$(_context34) {
5455
- while (1) switch (_context34.prev = _context34.next) {
5697
+ return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5698
+ while (1) switch (_context35.prev = _context35.next) {
5456
5699
  case 0:
5457
5700
  tempOrder = this.ensureTempOrder();
5458
5701
  if (!(!order || _typeof(order) !== 'object')) {
5459
- _context34.next = 3;
5702
+ _context35.next = 3;
5460
5703
  break;
5461
5704
  }
5462
- return _context34.abrupt("return", tempOrder);
5705
+ return _context35.abrupt("return", tempOrder);
5463
5706
  case 3:
5464
5707
  shopOrderNumber = order.shop_order_number;
5465
5708
  shopFullOrderNumber = order.shop_full_order_number;
@@ -5470,15 +5713,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5470
5713
  tempOrder.shop_full_order_number = String(shopFullOrderNumber);
5471
5714
  }
5472
5715
  this.persistTempOrder();
5473
- _context34.next = 10;
5716
+ _context35.next = 10;
5474
5717
  return this.saveDraft();
5475
5718
  case 10:
5476
- return _context34.abrupt("return", tempOrder);
5719
+ return _context35.abrupt("return", tempOrder);
5477
5720
  case 11:
5478
5721
  case "end":
5479
- return _context34.stop();
5722
+ return _context35.stop();
5480
5723
  }
5481
- }, _callee31, this);
5724
+ }, _callee32, this);
5482
5725
  }));
5483
5726
  function applyLocalPrintOrderNumbers(_x37) {
5484
5727
  return _applyLocalPrintOrderNumbers.apply(this, arguments);
@@ -5488,42 +5731,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5488
5731
  }, {
5489
5732
  key: "saveTempOrderAsDraft",
5490
5733
  value: function () {
5491
- var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
5492
- var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
5734
+ var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5735
+ var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
5493
5736
  var tempOrder, latestSummary, payload;
5494
- return _regeneratorRuntime().wrap(function _callee32$(_context35) {
5495
- while (1) switch (_context35.prev = _context35.next) {
5737
+ return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5738
+ while (1) switch (_context36.prev = _context36.next) {
5496
5739
  case 0:
5497
5740
  tempOrder = this.ensureTempOrder();
5498
5741
  this.ensureExternalSaleNumber(tempOrder);
5499
5742
  this.persistTempOrder();
5500
- _context35.next = 5;
5743
+ _context36.next = 5;
5501
5744
  return this.recalculateSummary({
5502
5745
  createIfMissing: true
5503
5746
  });
5504
5747
  case 5:
5505
- _context35.t1 = _context35.sent;
5506
- if (_context35.t1) {
5507
- _context35.next = 8;
5748
+ _context36.t1 = _context36.sent;
5749
+ if (_context36.t1) {
5750
+ _context36.next = 8;
5508
5751
  break;
5509
5752
  }
5510
- _context35.t1 = this.store.summary;
5753
+ _context36.t1 = this.store.summary;
5511
5754
  case 8:
5512
- _context35.t0 = _context35.t1;
5513
- if (_context35.t0) {
5514
- _context35.next = 11;
5755
+ _context36.t0 = _context36.t1;
5756
+ if (_context36.t0) {
5757
+ _context36.next = 11;
5515
5758
  break;
5516
5759
  }
5517
- _context35.t0 = createEmptySummary();
5760
+ _context36.t0 = createEmptySummary();
5518
5761
  case 11:
5519
- latestSummary = _context35.t0;
5762
+ latestSummary = _context36.t0;
5520
5763
  payload = buildSubmitPayload({
5521
5764
  tempOrder: tempOrder,
5522
5765
  cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
5523
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
5524
- businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code) || tempOrder.business_code,
5766
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform),
5767
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.business_code) || tempOrder.business_code,
5525
5768
  channel: params === null || params === void 0 ? void 0 : params.channel,
5526
- type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
5769
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.type,
5527
5770
  summary: latestSummary,
5528
5771
  enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
5529
5772
  });
@@ -5537,15 +5780,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5537
5780
  externalSaleNumber: payload.external_sale_number,
5538
5781
  productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
5539
5782
  });
5540
- return _context35.abrupt("return", this.request.post('/order/sales/draft', payload, {
5783
+ return _context36.abrupt("return", this.request.post('/order/sales/draft', payload, {
5541
5784
  osServer: true,
5542
5785
  customToast: function customToast() {}
5543
5786
  }));
5544
5787
  case 18:
5545
5788
  case "end":
5546
- return _context35.stop();
5789
+ return _context36.stop();
5547
5790
  }
5548
- }, _callee32, this);
5791
+ }, _callee33, this);
5549
5792
  }));
5550
5793
  function saveTempOrderAsDraft(_x38) {
5551
5794
  return _saveTempOrderAsDraft.apply(this, arguments);
@@ -5561,16 +5804,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5561
5804
  }, {
5562
5805
  key: "submitTempOrder",
5563
5806
  value: (function () {
5564
- var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
5565
- return _regeneratorRuntime().wrap(function _callee33$(_context36) {
5566
- while (1) switch (_context36.prev = _context36.next) {
5807
+ var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5808
+ return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5809
+ while (1) switch (_context37.prev = _context37.next) {
5567
5810
  case 0:
5568
- return _context36.abrupt("return", this.runSubmitTempOrder(params));
5811
+ return _context37.abrupt("return", this.runSubmitTempOrder(params));
5569
5812
  case 1:
5570
5813
  case "end":
5571
- return _context36.stop();
5814
+ return _context37.stop();
5572
5815
  }
5573
- }, _callee33, this);
5816
+ }, _callee34, this);
5574
5817
  }));
5575
5818
  function submitTempOrder(_x39) {
5576
5819
  return _submitTempOrder.apply(this, arguments);
@@ -5580,18 +5823,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5580
5823
  }, {
5581
5824
  key: "submitTempOrderAsync",
5582
5825
  value: function () {
5583
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
5584
- return _regeneratorRuntime().wrap(function _callee34$(_context37) {
5585
- while (1) switch (_context37.prev = _context37.next) {
5826
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5827
+ return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5828
+ while (1) switch (_context38.prev = _context38.next) {
5586
5829
  case 0:
5587
- return _context37.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5830
+ return _context38.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
5588
5831
  syncMode: true
5589
5832
  })));
5590
5833
  case 1:
5591
5834
  case "end":
5592
- return _context37.stop();
5835
+ return _context38.stop();
5593
5836
  }
5594
- }, _callee34, this);
5837
+ }, _callee35, this);
5595
5838
  }));
5596
5839
  function submitTempOrderAsync(_x40) {
5597
5840
  return _submitTempOrderAsync.apply(this, arguments);
@@ -5601,16 +5844,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5601
5844
  }, {
5602
5845
  key: "runSubmitTempOrder",
5603
5846
  value: function () {
5604
- var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
5605
- var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
5606
- var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
5607
- return _regeneratorRuntime().wrap(function _callee35$(_context38) {
5608
- while (1) switch (_context38.prev = _context38.next) {
5847
+ var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
5848
+ var _params$cacheId3, _this$otherParams12, _ref75, _ref76, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
5849
+ var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
5850
+ return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5851
+ while (1) switch (_context39.prev = _context39.next) {
5609
5852
  case 0:
5610
5853
  tempOrder = this.ensureTempOrder();
5854
+ this.prepareVirtualSettlementTempOrder(tempOrder);
5855
+ isOnlineStorePlatform = this.isOnlineStorePlatform();
5611
5856
  shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
5612
5857
  hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
5613
- preparedPaymentOverride = hasPaymentOverride ? this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments) : undefined;
5858
+ if (hasPaymentOverride) {
5859
+ preparedPaymentOverride = isOnlineStorePlatform ? (params === null || params === void 0 ? void 0 : params.payments) || [] : this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments);
5860
+ }
5614
5861
  if (!hasPaymentOverride) {
5615
5862
  if (shouldConfirmPendingVoucherPayments) {
5616
5863
  this.confirmPendingVoucherPayments({
@@ -5625,33 +5872,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5625
5872
  }
5626
5873
  }
5627
5874
  this.persistTempOrder();
5628
- _context38.next = 8;
5875
+ _context39.next = 10;
5629
5876
  return this.recalculateSummary({
5630
5877
  createIfMissing: true
5631
5878
  });
5632
- case 8:
5633
- _context38.t1 = _context38.sent;
5634
- if (_context38.t1) {
5635
- _context38.next = 11;
5879
+ case 10:
5880
+ _context39.t1 = _context39.sent;
5881
+ if (_context39.t1) {
5882
+ _context39.next = 13;
5636
5883
  break;
5637
5884
  }
5638
- _context38.t1 = this.store.summary;
5639
- case 11:
5640
- _context38.t0 = _context38.t1;
5641
- if (_context38.t0) {
5642
- _context38.next = 14;
5885
+ _context39.t1 = this.store.summary;
5886
+ case 13:
5887
+ _context39.t0 = _context39.t1;
5888
+ if (_context39.t0) {
5889
+ _context39.next = 16;
5643
5890
  break;
5644
5891
  }
5645
- _context38.t0 = createEmptySummary();
5646
- case 14:
5647
- latestSummary = _context38.t0;
5892
+ _context39.t0 = createEmptySummary();
5893
+ case 16:
5894
+ latestSummary = _context39.t0;
5648
5895
  effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
5649
5896
  hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
5897
+ shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
5650
5898
  hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
5651
5899
  enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
5652
5900
  var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
5653
5901
  payments: preparedPaymentOverride || []
5654
- } : {}), hasPaymentStatusOverride && !shouldConfirmPendingVoucherPayments ? {
5902
+ } : {}), shouldOverridePaymentStatus ? {
5655
5903
  payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
5656
5904
  } : {}), hasSmallTicketDataFlagOverride ? {
5657
5905
  small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
@@ -5663,12 +5911,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5663
5911
  payload = buildSubmitPayload({
5664
5912
  tempOrder: tempOrder,
5665
5913
  cacheId: effectiveCacheId,
5666
- platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
5667
- businessCode: (_ref73 = (_ref74 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
5914
+ platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
5915
+ businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
5668
5916
  channel: params === null || params === void 0 ? void 0 : params.channel,
5669
5917
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
5670
5918
  summary: latestSummary,
5671
5919
  request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
5920
+ includePaymentStatus: !isOnlineStorePlatform,
5672
5921
  enhance: enhancePayload
5673
5922
  });
5674
5923
  if (params !== null && params !== void 0 && params.syncMode) {
@@ -5678,10 +5927,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5678
5927
  if (!payload.created_at) {
5679
5928
  payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
5680
5929
  }
5681
- _context38.next = 25;
5930
+ _context39.next = 28;
5682
5931
  return this.saveDraft();
5683
- case 25:
5684
- _context38.prev = 25;
5932
+ case 28:
5933
+ _context39.prev = 28;
5685
5934
  this.logInfo('submitTempOrder calling sales checkout', {
5686
5935
  orderId: payload.order_id,
5687
5936
  externalSaleNumber: payload.external_sale_number,
@@ -5691,44 +5940,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5691
5940
  smallTicketDataFlag: payload.small_ticket_data_flag,
5692
5941
  syncMode: payload.sync_mode
5693
5942
  });
5694
- _context38.next = 29;
5943
+ _context39.next = 32;
5695
5944
  return this.submitSalesOrder({
5696
5945
  query: payload
5697
5946
  });
5698
- case 29:
5699
- result = _context38.sent;
5700
- _context38.next = 42;
5701
- break;
5702
5947
  case 32:
5703
- _context38.prev = 32;
5704
- _context38.t2 = _context38["catch"](25);
5705
- backendErrorResponse = this.extractSubmitErrorResponse(_context38.t2);
5948
+ result = _context39.sent;
5949
+ _context39.next = 45;
5950
+ break;
5951
+ case 35:
5952
+ _context39.prev = 35;
5953
+ _context39.t2 = _context39["catch"](28);
5954
+ backendErrorResponse = this.extractSubmitErrorResponse(_context39.t2);
5706
5955
  if (!backendErrorResponse) {
5707
- _context38.next = 39;
5956
+ _context39.next = 42;
5708
5957
  break;
5709
5958
  }
5710
5959
  this.store.syncState = 'failed';
5711
5960
  this.logSubmitBackendRejected(backendErrorResponse, payload);
5712
- return _context38.abrupt("return", backendErrorResponse);
5713
- case 39:
5961
+ return _context39.abrupt("return", backendErrorResponse);
5962
+ case 42:
5714
5963
  this.store.syncState = 'failed';
5715
5964
  this.logError('submitTempOrder failed', {
5716
- error: _context38.t2 instanceof Error ? _context38.t2.message : String(_context38.t2),
5965
+ error: _context39.t2 instanceof Error ? _context39.t2.message : String(_context39.t2),
5717
5966
  orderId: payload.order_id,
5718
5967
  externalSaleNumber: payload.external_sale_number,
5719
5968
  paymentStatus: payload.payment_status,
5720
5969
  paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
5721
5970
  });
5722
- throw _context38.t2;
5723
- case 42:
5971
+ throw _context39.t2;
5972
+ case 45:
5724
5973
  if (!this.isSubmitResponseRejected(result)) {
5725
- _context38.next = 46;
5974
+ _context39.next = 49;
5726
5975
  break;
5727
5976
  }
5728
5977
  this.store.syncState = 'failed';
5729
5978
  this.logSubmitBackendRejected(result, payload);
5730
- return _context38.abrupt("return", result);
5731
- case 46:
5979
+ return _context39.abrupt("return", result);
5980
+ case 49:
5732
5981
  isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
5733
5982
  if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
5734
5983
  salesNotesState = this.ensureSalesNotesRuntimeState(tempOrder);
@@ -5743,25 +5992,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5743
5992
  })
5744
5993
  });
5745
5994
  if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
5746
- _context38.next = 55;
5995
+ _context39.next = 58;
5747
5996
  break;
5748
5997
  }
5749
5998
  tempOrder.order_id = submittedOrderId;
5750
5999
  resultRecord = result;
5751
- _context38.next = 55;
6000
+ _context39.next = 58;
5752
6001
  return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
5753
- case 55:
6002
+ case 58:
5754
6003
  if (isLocalPendingSubmit) {
5755
6004
  this.store.syncState = 'local';
5756
6005
  } else if (submittedOrderId === null || submittedOrderId === undefined) {
5757
6006
  this.store.syncState = 'submitted';
5758
6007
  }
5759
- return _context38.abrupt("return", result);
5760
- case 57:
6008
+ return _context39.abrupt("return", result);
6009
+ case 60:
5761
6010
  case "end":
5762
- return _context38.stop();
6011
+ return _context39.stop();
5763
6012
  }
5764
- }, _callee35, this, [[25, 32]]);
6013
+ }, _callee36, this, [[28, 35]]);
5765
6014
  }));
5766
6015
  function runSubmitTempOrder(_x41) {
5767
6016
  return _runSubmitTempOrder.apply(this, arguments);
@@ -5771,10 +6020,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5771
6020
  }, {
5772
6021
  key: "markLocalOrderSynced",
5773
6022
  value: function () {
5774
- var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId, remoteOrder) {
6023
+ var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(orderId, remoteOrder) {
5775
6024
  var tempOrder;
5776
- return _regeneratorRuntime().wrap(function _callee36$(_context39) {
5777
- while (1) switch (_context39.prev = _context39.next) {
6025
+ return _regeneratorRuntime().wrap(function _callee37$(_context40) {
6026
+ while (1) switch (_context40.prev = _context40.next) {
5778
6027
  case 0:
5779
6028
  tempOrder = this.ensureTempOrder();
5780
6029
  tempOrder.order_id = orderId;
@@ -5782,13 +6031,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5782
6031
  this.store.lastOrderInfo = remoteOrder;
5783
6032
  this.store.syncState = 'submitted';
5784
6033
  this.persistTempOrder();
5785
- _context39.next = 8;
6034
+ _context40.next = 8;
5786
6035
  return this.saveDraft();
5787
6036
  case 8:
5788
6037
  case "end":
5789
- return _context39.stop();
6038
+ return _context40.stop();
5790
6039
  }
5791
- }, _callee36, this);
6040
+ }, _callee37, this);
5792
6041
  }));
5793
6042
  function markLocalOrderSynced(_x42, _x43) {
5794
6043
  return _markLocalOrderSynced.apply(this, arguments);
@@ -5863,31 +6112,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5863
6112
  }, {
5864
6113
  key: "syncPaymentsToOrder",
5865
6114
  value: function () {
5866
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6115
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
5867
6116
  var _this35 = this,
5868
6117
  _params$confirmPendin;
5869
6118
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
5870
- return _regeneratorRuntime().wrap(function _callee37$(_context40) {
5871
- while (1) switch (_context40.prev = _context40.next) {
6119
+ return _regeneratorRuntime().wrap(function _callee38$(_context41) {
6120
+ while (1) switch (_context41.prev = _context41.next) {
5872
6121
  case 0:
5873
6122
  tempOrder = this.ensureTempOrder();
5874
6123
  needsPaymentNumber = (params.payments || []).some(function (payment) {
5875
6124
  return String(payment.payment_number || '').trim() === '';
5876
6125
  });
5877
6126
  if (!needsPaymentNumber) {
5878
- _context40.next = 8;
6127
+ _context41.next = 8;
5879
6128
  break;
5880
6129
  }
5881
- _context40.next = 5;
6130
+ _context41.next = 5;
5882
6131
  return this.getPaymentNumberDevicePrefixAsync();
5883
6132
  case 5:
5884
- _context40.t0 = _context40.sent;
5885
- _context40.next = 9;
6133
+ _context41.t0 = _context41.sent;
6134
+ _context41.next = 9;
5886
6135
  break;
5887
6136
  case 8:
5888
- _context40.t0 = 'LOCAL';
6137
+ _context41.t0 = 'LOCAL';
5889
6138
  case 9:
5890
- devicePrefix = _context40.t0;
6139
+ devicePrefix = _context41.t0;
5891
6140
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
5892
6141
  return _this35.normalizePaymentSource(payment, {
5893
6142
  defaultPaid: false,
@@ -5902,20 +6151,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5902
6151
  tempOrder.payments = effectivePayments;
5903
6152
  tempOrder.payment_status = paymentStatus;
5904
6153
  this.persistTempOrder();
5905
- _context40.next = 21;
6154
+ _context41.next = 21;
5906
6155
  return this.saveDraft();
5907
6156
  case 21:
5908
6157
  if (params.submitWhenPaid) {
5909
- _context40.next = 23;
6158
+ _context41.next = 23;
5910
6159
  break;
5911
6160
  }
5912
- return _context40.abrupt("return", completion);
6161
+ return _context41.abrupt("return", completion);
5913
6162
  case 23:
5914
6163
  if (!(this.store.syncState === 'submitting')) {
5915
- _context40.next = 25;
6164
+ _context41.next = 25;
5916
6165
  break;
5917
6166
  }
5918
- return _context40.abrupt("return", completion);
6167
+ return _context41.abrupt("return", completion);
5919
6168
  case 25:
5920
6169
  this.store.syncState = 'submitting';
5921
6170
  paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
@@ -5935,30 +6184,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5935
6184
  enhancePayload: enhancePayload
5936
6185
  };
5937
6186
  if (!(params.checkoutSyncTaskEnabled === false)) {
5938
- _context40.next = 35;
6187
+ _context41.next = 35;
5939
6188
  break;
5940
6189
  }
5941
- _context40.next = 32;
6190
+ _context41.next = 32;
5942
6191
  return this.submitTempOrderAsync(submitParams);
5943
6192
  case 32:
5944
- _context40.t1 = _context40.sent;
5945
- _context40.next = 38;
6193
+ _context41.t1 = _context41.sent;
6194
+ _context41.next = 38;
5946
6195
  break;
5947
6196
  case 35:
5948
- _context40.next = 37;
6197
+ _context41.next = 37;
5949
6198
  return this.submitTempOrder(submitParams);
5950
6199
  case 37:
5951
- _context40.t1 = _context40.sent;
6200
+ _context41.t1 = _context41.sent;
5952
6201
  case 38:
5953
- submitResult = _context40.t1;
5954
- return _context40.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
6202
+ submitResult = _context41.t1;
6203
+ return _context41.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
5955
6204
  submitResult: submitResult
5956
6205
  }));
5957
6206
  case 40:
5958
6207
  case "end":
5959
- return _context40.stop();
6208
+ return _context41.stop();
5960
6209
  }
5961
- }, _callee37, this);
6210
+ }, _callee38, this);
5962
6211
  }));
5963
6212
  function syncPaymentsToOrder(_x44) {
5964
6213
  return _syncPaymentsToOrder.apply(this, arguments);
@@ -6057,11 +6306,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6057
6306
  }, {
6058
6307
  key: "submitOrder",
6059
6308
  value: function () {
6060
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(order) {
6309
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(order) {
6061
6310
  var _order$query$cartItem, _params$bookings, _params$relation_prod;
6062
6311
  var url, query, fetchUrl, params;
6063
- return _regeneratorRuntime().wrap(function _callee38$(_context41) {
6064
- while (1) switch (_context41.prev = _context41.next) {
6312
+ return _regeneratorRuntime().wrap(function _callee39$(_context42) {
6313
+ while (1) switch (_context42.prev = _context42.next) {
6065
6314
  case 0:
6066
6315
  this.logInfo('submitOrder called', {
6067
6316
  url: order.url,
@@ -6081,12 +6330,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6081
6330
  relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
6082
6331
  scheduleDate: params.schedule_date
6083
6332
  });
6084
- return _context41.abrupt("return", this.request.post(fetchUrl, params));
6333
+ return _context42.abrupt("return", this.request.post(fetchUrl, params));
6085
6334
  case 6:
6086
6335
  case "end":
6087
- return _context41.stop();
6336
+ return _context42.stop();
6088
6337
  }
6089
- }, _callee38, this);
6338
+ }, _callee39, this);
6090
6339
  }));
6091
6340
  function submitOrder(_x45) {
6092
6341
  return _submitOrder.apply(this, arguments);
@@ -6096,13 +6345,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6096
6345
  }, {
6097
6346
  key: "cancelOrder",
6098
6347
  value: function () {
6099
- var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6348
+ var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
6100
6349
  var payload;
6101
- return _regeneratorRuntime().wrap(function _callee39$(_context42) {
6102
- while (1) switch (_context42.prev = _context42.next) {
6350
+ return _regeneratorRuntime().wrap(function _callee40$(_context43) {
6351
+ while (1) switch (_context43.prev = _context43.next) {
6103
6352
  case 0:
6104
6353
  if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
6105
- _context42.next = 2;
6354
+ _context43.next = 2;
6106
6355
  break;
6107
6356
  }
6108
6357
  throw new Error('取消订单失败:order_ids 不能为空');
@@ -6118,14 +6367,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6118
6367
  method: 'PUT',
6119
6368
  orderIdsCount: params.order_ids.length
6120
6369
  });
6121
- return _context42.abrupt("return", this.request.put('/order/update-status', payload, {
6370
+ return _context43.abrupt("return", this.request.put('/order/update-status', payload, {
6122
6371
  isShopApi: true
6123
6372
  }));
6124
6373
  case 5:
6125
6374
  case "end":
6126
- return _context42.stop();
6375
+ return _context43.stop();
6127
6376
  }
6128
- }, _callee39, this);
6377
+ }, _callee40, this);
6129
6378
  }));
6130
6379
  function cancelOrder(_x46) {
6131
6380
  return _cancelOrder.apply(this, arguments);
@@ -6135,19 +6384,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6135
6384
  }, {
6136
6385
  key: "changeBookingStatus",
6137
6386
  value: function () {
6138
- var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
6387
+ var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
6139
6388
  var url, payload;
6140
- return _regeneratorRuntime().wrap(function _callee40$(_context43) {
6141
- while (1) switch (_context43.prev = _context43.next) {
6389
+ return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6390
+ while (1) switch (_context44.prev = _context44.next) {
6142
6391
  case 0:
6143
6392
  if (params.booking_id) {
6144
- _context43.next = 2;
6393
+ _context44.next = 2;
6145
6394
  break;
6146
6395
  }
6147
6396
  throw new Error('变更预约状态失败:booking_id 不能为空');
6148
6397
  case 2:
6149
6398
  if (params.appointment_status) {
6150
- _context43.next = 4;
6399
+ _context44.next = 4;
6151
6400
  break;
6152
6401
  }
6153
6402
  throw new Error('变更预约状态失败:appointment_status 不能为空');
@@ -6162,14 +6411,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6162
6411
  bookingId: params.booking_id,
6163
6412
  appointmentStatus: params.appointment_status
6164
6413
  });
6165
- return _context43.abrupt("return", this.request.put(url, payload, {
6414
+ return _context44.abrupt("return", this.request.put(url, payload, {
6166
6415
  isShopApi: true
6167
6416
  }));
6168
6417
  case 8:
6169
6418
  case "end":
6170
- return _context43.stop();
6419
+ return _context44.stop();
6171
6420
  }
6172
- }, _callee40, this);
6421
+ }, _callee41, this);
6173
6422
  }));
6174
6423
  function changeBookingStatus(_x47) {
6175
6424
  return _changeBookingStatus.apply(this, arguments);
@@ -6189,11 +6438,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6189
6438
  }, {
6190
6439
  key: "createOrderByCheckout",
6191
6440
  value: (function () {
6192
- var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
6441
+ var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
6193
6442
  var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
6194
6443
  var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
6195
- return _regeneratorRuntime().wrap(function _callee41$(_context44) {
6196
- while (1) switch (_context44.prev = _context44.next) {
6444
+ return _regeneratorRuntime().wrap(function _callee42$(_context45) {
6445
+ while (1) switch (_context45.prev = _context45.next) {
6197
6446
  case 0:
6198
6447
  // 过滤掉由在线店铺下单的 payment 支付数据
6199
6448
  onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
@@ -6218,7 +6467,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6218
6467
  return p.code;
6219
6468
  })) || []
6220
6469
  });
6221
- _context44.prev = 3;
6470
+ _context45.prev = 3;
6222
6471
  // 构建订单数据,设置默认值并允许 params 覆盖
6223
6472
  orderData = _objectSpread({
6224
6473
  sales_channel: 'my_pisel',
@@ -6266,30 +6515,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6266
6515
  hasOrderId: !!orderData.order_id,
6267
6516
  smallTicketDataFlag: orderData.small_ticket_data_flag
6268
6517
  });
6269
- _context44.next = 10;
6518
+ _context45.next = 10;
6270
6519
  return this.request.post('/order/checkout', orderData, {
6271
6520
  osServer: true,
6272
6521
  customToast: function customToast() {}
6273
6522
  });
6274
6523
  case 10:
6275
- response = _context44.sent;
6524
+ response = _context45.sent;
6276
6525
  this.logInfo('Order API called successfully', {
6277
6526
  response: response
6278
6527
  });
6279
- return _context44.abrupt("return", response);
6528
+ return _context45.abrupt("return", response);
6280
6529
  case 15:
6281
- _context44.prev = 15;
6282
- _context44.t0 = _context44["catch"](3);
6283
- console.error('[Order] createOrderByCheckout 创建订单失败:', _context44.t0);
6530
+ _context45.prev = 15;
6531
+ _context45.t0 = _context45["catch"](3);
6532
+ console.error('[Order] createOrderByCheckout 创建订单失败:', _context45.t0);
6284
6533
  this.logInfo('Order API called failed', {
6285
- error: _context44.t0 instanceof Error ? _context44.t0.message : String(_context44.t0)
6534
+ error: _context45.t0 instanceof Error ? _context45.t0.message : String(_context45.t0)
6286
6535
  });
6287
- throw _context44.t0;
6536
+ throw _context45.t0;
6288
6537
  case 20:
6289
6538
  case "end":
6290
- return _context44.stop();
6539
+ return _context45.stop();
6291
6540
  }
6292
- }, _callee41, this, [[3, 15]]);
6541
+ }, _callee42, this, [[3, 15]]);
6293
6542
  }));
6294
6543
  function createOrderByCheckout(_x48) {
6295
6544
  return _createOrderByCheckout.apply(this, arguments);
@@ -6299,22 +6548,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6299
6548
  }, {
6300
6549
  key: "submitSalesOrder",
6301
6550
  value: function () {
6302
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
6551
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
6303
6552
  var url, query, fetchUrl;
6304
- return _regeneratorRuntime().wrap(function _callee42$(_context45) {
6305
- while (1) switch (_context45.prev = _context45.next) {
6553
+ return _regeneratorRuntime().wrap(function _callee43$(_context46) {
6554
+ while (1) switch (_context46.prev = _context46.next) {
6306
6555
  case 0:
6307
6556
  url = params.url, query = params.query;
6308
6557
  fetchUrl = url || '/order/sales/checkout';
6309
- return _context45.abrupt("return", this.request.post(fetchUrl, query, {
6558
+ return _context46.abrupt("return", this.request.post(fetchUrl, query, {
6310
6559
  osServer: true,
6311
6560
  customToast: function customToast() {}
6312
6561
  }));
6313
6562
  case 3:
6314
6563
  case "end":
6315
- return _context45.stop();
6564
+ return _context46.stop();
6316
6565
  }
6317
- }, _callee42, this);
6566
+ }, _callee43, this);
6318
6567
  }));
6319
6568
  function submitSalesOrder(_x49) {
6320
6569
  return _submitSalesOrder.apply(this, arguments);
@@ -6330,35 +6579,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6330
6579
  }, {
6331
6580
  key: "sendCustomerPayLink",
6332
6581
  value: (function () {
6333
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
6582
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
6334
6583
  var _params$emails;
6335
6584
  var orderIds;
6336
- return _regeneratorRuntime().wrap(function _callee43$(_context46) {
6337
- while (1) switch (_context46.prev = _context46.next) {
6585
+ return _regeneratorRuntime().wrap(function _callee44$(_context47) {
6586
+ while (1) switch (_context47.prev = _context47.next) {
6338
6587
  case 0:
6339
6588
  orderIds = params.order_ids || params.orderIds || [];
6340
6589
  if (orderIds.length) {
6341
- _context46.next = 3;
6590
+ _context47.next = 3;
6342
6591
  break;
6343
6592
  }
6344
6593
  throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
6345
6594
  case 3:
6346
6595
  if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
6347
- _context46.next = 5;
6596
+ _context47.next = 5;
6348
6597
  break;
6349
6598
  }
6350
6599
  throw new Error('发送支付链接需要至少一个邮箱');
6351
6600
  case 5:
6352
- return _context46.abrupt("return", this.request.post('/order/batch-email', {
6601
+ return _context47.abrupt("return", this.request.post('/order/batch-email', {
6353
6602
  order_ids: orderIds,
6354
6603
  notify_action: params.notify_action || 'order_payment_reminder',
6355
6604
  emails: params.emails
6356
6605
  }));
6357
6606
  case 6:
6358
6607
  case "end":
6359
- return _context46.stop();
6608
+ return _context47.stop();
6360
6609
  }
6361
- }, _callee43, this);
6610
+ }, _callee44, this);
6362
6611
  }));
6363
6612
  function sendCustomerPayLink(_x50) {
6364
6613
  return _sendCustomerPayLink.apply(this, arguments);
@@ -6368,14 +6617,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6368
6617
  }, {
6369
6618
  key: "getSalesOrderByLookup",
6370
6619
  value: function () {
6371
- var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
6620
+ var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
6372
6621
  var lookup, res;
6373
- return _regeneratorRuntime().wrap(function _callee44$(_context47) {
6374
- while (1) switch (_context47.prev = _context47.next) {
6622
+ return _regeneratorRuntime().wrap(function _callee45$(_context48) {
6623
+ while (1) switch (_context48.prev = _context48.next) {
6375
6624
  case 0:
6376
6625
  lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
6377
6626
  if (lookup) {
6378
- _context47.next = 3;
6627
+ _context48.next = 3;
6379
6628
  break;
6380
6629
  }
6381
6630
  throw new Error('加载销售详情需要 lookup');
@@ -6384,7 +6633,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6384
6633
  if (lookup.startsWith('LOCAL_')) {
6385
6634
  params.forceRemote = false;
6386
6635
  }
6387
- _context47.next = 6;
6636
+ _context48.next = 6;
6388
6637
  return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
6389
6638
  with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds', 'notes']
6390
6639
  }, params.forceRemote ? {
@@ -6393,16 +6642,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6393
6642
  osServer: true
6394
6643
  });
6395
6644
  case 6:
6396
- res = _context47.sent;
6645
+ res = _context48.sent;
6397
6646
  if (res.code === 200) {
6398
6647
  this.store.lastOrderInfo = res.data;
6399
6648
  }
6400
- return _context47.abrupt("return", res);
6649
+ return _context48.abrupt("return", res);
6401
6650
  case 9:
6402
6651
  case "end":
6403
- return _context47.stop();
6652
+ return _context48.stop();
6404
6653
  }
6405
- }, _callee44, this);
6654
+ }, _callee45, this);
6406
6655
  }));
6407
6656
  function getSalesOrderByLookup(_x51) {
6408
6657
  return _getSalesOrderByLookup.apply(this, arguments);
@@ -6418,11 +6667,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6418
6667
  }, {
6419
6668
  key: "hydrateTempOrderFromRecord",
6420
6669
  value: (function () {
6421
- var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(record, options) {
6422
- var _sourceRaw$_extend, _this$store$discount22;
6423
- var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount20, _this$store$discount21, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount23, _this$store$discount24;
6424
- return _regeneratorRuntime().wrap(function _callee45$(_context48) {
6425
- while (1) switch (_context48.prev = _context48.next) {
6670
+ var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(record, options) {
6671
+ var _sourceRaw$_extend, _this$store$discount26;
6672
+ var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
6673
+ return _regeneratorRuntime().wrap(function _callee46$(_context49) {
6674
+ while (1) switch (_context49.prev = _context49.next) {
6426
6675
  case 0:
6427
6676
  sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
6428
6677
  duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
@@ -6463,7 +6712,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6463
6712
  });
6464
6713
  this.store.tempOrder = nextTempOrder;
6465
6714
  if (!isSessionStorageHydrate) {
6466
- _context48.next = 30;
6715
+ _context49.next = 30;
6467
6716
  break;
6468
6717
  }
6469
6718
  // 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
@@ -6479,23 +6728,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6479
6728
  nextTempOrder.discount_list = restoredSessionDiscounts;
6480
6729
  this.store.summary = createEmptySummary();
6481
6730
  this.store.lastOrderInfo = undefined;
6482
- _context48.next = 23;
6483
- return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
6731
+ _context49.next = 23;
6732
+ return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
6484
6733
  case 23:
6485
- _context48.next = 25;
6486
- return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(cloneDeep(restoredSessionDiscounts));
6734
+ _context49.next = 25;
6735
+ return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
6487
6736
  case 25:
6488
6737
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
6489
- _context48.next = 28;
6738
+ _context49.next = 28;
6490
6739
  break;
6491
6740
  }
6492
- _context48.next = 28;
6741
+ _context49.next = 28;
6493
6742
  return this.recalculateSummary({
6494
6743
  createIfMissing: false
6495
6744
  });
6496
6745
  case 28:
6497
6746
  this.persistTempOrder();
6498
- return _context48.abrupt("return", nextTempOrder);
6747
+ return _context49.abrupt("return", nextTempOrder);
6499
6748
  case 30:
6500
6749
  // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
6501
6750
  sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
@@ -6534,7 +6783,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6534
6783
  this.store.syncState = 'local';
6535
6784
  }
6536
6785
  hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
6537
- currentDiscounts = typeof ((_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
6786
+ currentDiscounts = typeof ((_this$store$discount26 = this.store.discount) === null || _this$store$discount26 === void 0 ? void 0 : _this$store$discount26.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
6538
6787
  currentScanDiscounts = currentDiscounts.filter(function (discount) {
6539
6788
  return discount === null || discount === void 0 ? void 0 : discount.isScan;
6540
6789
  });
@@ -6547,32 +6796,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6547
6796
  nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
6548
6797
  shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
6549
6798
  if (shouldSkipEmptyDiscountSync) {
6550
- _context48.next = 54;
6799
+ _context49.next = 54;
6551
6800
  break;
6552
6801
  }
6553
6802
  OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
6554
- _context48.next = 52;
6555
- return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList(nextDiscounts);
6803
+ _context49.next = 52;
6804
+ return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
6556
6805
  case 52:
6557
- _context48.next = 54;
6558
- return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setDiscountList(nextDiscounts);
6806
+ _context49.next = 54;
6807
+ return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
6559
6808
  case 54:
6560
6809
  if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
6561
- _context48.next = 57;
6810
+ _context49.next = 57;
6562
6811
  break;
6563
6812
  }
6564
- _context48.next = 57;
6813
+ _context49.next = 57;
6565
6814
  return this.recalculateSummary({
6566
6815
  createIfMissing: false
6567
6816
  });
6568
6817
  case 57:
6569
6818
  this.persistTempOrder();
6570
- return _context48.abrupt("return", nextTempOrder);
6819
+ return _context49.abrupt("return", nextTempOrder);
6571
6820
  case 59:
6572
6821
  case "end":
6573
- return _context48.stop();
6822
+ return _context49.stop();
6574
6823
  }
6575
- }, _callee45, this);
6824
+ }, _callee46, this);
6576
6825
  }));
6577
6826
  function hydrateTempOrderFromRecord(_x52, _x53) {
6578
6827
  return _hydrateTempOrderFromRecord.apply(this, arguments);
@@ -6767,7 +7016,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6767
7016
  _step24;
6768
7017
  try {
6769
7018
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
6770
- var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
7019
+ var _product$metadata11, _ref77, _ref78, _existed$origin, _rawProduct$metadata;
6771
7020
  var _step24$value = _slicedToArray(_step24.value, 2),
6772
7021
  index = _step24$value[0],
6773
7022
  product = _step24$value[1];
@@ -6775,7 +7024,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6775
7024
  if (!uid) continue;
6776
7025
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
6777
7026
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
6778
- var origin = (_ref75 = (_ref76 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref76 !== void 0 ? _ref76 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref75 !== void 0 ? _ref75 : rawProduct;
7027
+ var origin = (_ref77 = (_ref78 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref78 !== void 0 ? _ref78 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref77 !== void 0 ? _ref77 : rawProduct;
6779
7028
  var originSnapshot = cloneDeep(origin);
6780
7029
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
6781
7030
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -6904,10 +7153,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6904
7153
  }, {
6905
7154
  key: "normalizeHydratedProductOptionItem",
6906
7155
  value: function normalizeHydratedProductOptionItem(optionItem) {
6907
- var _ref77, _optionItem$num, _ref78, _optionItem$add_price;
6908
- var rawNum = (_ref77 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref77 !== void 0 ? _ref77 : 1;
7156
+ var _ref79, _optionItem$num, _ref80, _optionItem$add_price;
7157
+ var rawNum = (_ref79 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref79 !== void 0 ? _ref79 : 1;
6909
7158
  var parsedNum = Number(rawNum);
6910
- var rawPrice = (_ref78 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref78 !== void 0 ? _ref78 : 0;
7159
+ var rawPrice = (_ref80 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref80 !== void 0 ? _ref80 : 0;
6911
7160
  var parsedPrice = Number(rawPrice);
6912
7161
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
6913
7162
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -6961,7 +7210,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6961
7210
  });
6962
7211
  if (result.metadata) delete result.metadata.price_schema_version;
6963
7212
  var restored = restoreHydratedBundleDiscounts(result, normalizeOrderProductDiscountList);
6964
- return this.sanitizeOrderProductForTempOrder(restored);
7213
+ return this.sanitizeOrderProductForTempOrder(this.normalizeVirtualSettlementProductIfEnabled(restored));
6965
7214
  }
6966
7215
  }, {
6967
7216
  key: "getLastOrderInfo",
@@ -6972,25 +7221,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6972
7221
  }, {
6973
7222
  key: "getOrderInfo",
6974
7223
  value: function () {
6975
- var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(order_id) {
7224
+ var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(order_id) {
6976
7225
  var res;
6977
- return _regeneratorRuntime().wrap(function _callee46$(_context49) {
6978
- while (1) switch (_context49.prev = _context49.next) {
7226
+ return _regeneratorRuntime().wrap(function _callee47$(_context50) {
7227
+ while (1) switch (_context50.prev = _context50.next) {
6979
7228
  case 0:
6980
- _context49.next = 2;
7229
+ _context50.next = 2;
6981
7230
  return this.request.get("/order/sales/".concat(order_id), {
6982
7231
  with: ['products', 'bookings', 'notes']
6983
7232
  }, {
6984
7233
  osServer: true
6985
7234
  });
6986
7235
  case 2:
6987
- res = _context49.sent;
6988
- return _context49.abrupt("return", res);
7236
+ res = _context50.sent;
7237
+ return _context50.abrupt("return", res);
6989
7238
  case 4:
6990
7239
  case "end":
6991
- return _context49.stop();
7240
+ return _context50.stop();
6992
7241
  }
6993
- }, _callee46, this);
7242
+ }, _callee47, this);
6994
7243
  }));
6995
7244
  function getOrderInfo(_x54) {
6996
7245
  return _getOrderInfo.apply(this, arguments);