@pisell/pisellos 0.10.53 → 0.10.55

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 (68) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  5. package/dist/modules/BusinessAvailability/index.js +204 -0
  6. package/dist/modules/OpenData/index.js +1 -1
  7. package/dist/modules/OpenData/types.d.ts +2 -0
  8. package/dist/modules/Order/index.d.ts +5 -2
  9. package/dist/modules/Order/index.js +320 -247
  10. package/dist/modules/Order/types.d.ts +8 -0
  11. package/dist/modules/Payment/index.js +9 -10
  12. package/dist/plugins/request.d.ts +3 -0
  13. package/dist/server/utils/small-ticket.d.ts +1 -85
  14. package/dist/server/utils/small-ticket.js +2 -2576
  15. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  16. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  17. package/dist/shared/receipt/small-ticket.d.ts +85 -0
  18. package/dist/shared/receipt/small-ticket.js +2576 -0
  19. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  20. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  21. package/dist/solution/BaseSales/index.d.ts +4 -15
  22. package/dist/solution/BaseSales/index.js +131 -86
  23. package/dist/solution/BaseSales/types.d.ts +11 -0
  24. package/dist/solution/BookingByStep/index.d.ts +1 -1
  25. package/dist/solution/BookingTicket/index.js +41 -13
  26. package/dist/solution/OrderInvoicePreview/index.d.ts +56 -0
  27. package/dist/solution/OrderInvoicePreview/index.js +269 -0
  28. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  29. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  30. package/dist/solution/UnifiedBookingSales/index.d.ts +11 -0
  31. package/dist/solution/UnifiedBookingSales/index.js +154 -75
  32. package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
  33. package/dist/solution/index.d.ts +1 -0
  34. package/dist/solution/index.js +2 -1
  35. package/lib/index.d.ts +2 -0
  36. package/lib/index.js +21 -1
  37. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  38. package/lib/modules/BusinessAvailability/index.js +146 -0
  39. package/lib/modules/OpenData/index.js +1 -1
  40. package/lib/modules/OpenData/types.d.ts +2 -0
  41. package/lib/modules/Order/index.d.ts +5 -2
  42. package/lib/modules/Order/index.js +67 -13
  43. package/lib/modules/Order/types.d.ts +8 -0
  44. package/lib/modules/Payment/index.js +3 -4
  45. package/lib/plugins/request.d.ts +3 -0
  46. package/lib/server/utils/small-ticket.d.ts +1 -85
  47. package/lib/server/utils/small-ticket.js +9 -2335
  48. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  49. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  50. package/lib/shared/receipt/small-ticket.d.ts +85 -0
  51. package/lib/shared/receipt/small-ticket.js +2342 -0
  52. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  53. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  54. package/lib/solution/BaseSales/index.d.ts +4 -15
  55. package/lib/solution/BaseSales/index.js +45 -24
  56. package/lib/solution/BaseSales/types.d.ts +11 -0
  57. package/lib/solution/BookingByStep/index.d.ts +1 -1
  58. package/lib/solution/BookingTicket/index.js +37 -4
  59. package/lib/solution/OrderInvoicePreview/index.d.ts +56 -0
  60. package/lib/solution/OrderInvoicePreview/index.js +194 -0
  61. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  62. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  63. package/lib/solution/UnifiedBookingSales/index.d.ts +11 -0
  64. package/lib/solution/UnifiedBookingSales/index.js +54 -0
  65. package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
  66. package/lib/solution/index.d.ts +1 -0
  67. package/lib/solution/index.js +11 -0
  68. package/package.json +1 -1
@@ -30,6 +30,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
30
30
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
+ import { loadSalesOrderSnapshot } from "../../shared/sales/loadSalesOrderSnapshot";
33
34
  import { BaseModule } from "../BaseModule";
34
35
  import { OrderHooks } from "./types";
35
36
  import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
@@ -520,6 +521,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
520
521
  this.otherParams = otherParams;
521
522
  }
522
523
 
524
+ /** Internal intent boundary shared with asynchronous scanner/detail flows. */
525
+ }, {
526
+ key: "createCartIntentCommitGuard",
527
+ value: function createCartIntentCommitGuard(action) {
528
+ var _this$orderHooks,
529
+ _this$orderHooks2,
530
+ _this2 = this;
531
+ var tempOrder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder;
532
+ var hook = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.beforeCartIntentCommit;
533
+ if (!hook) return function () {};
534
+ var getScope = (_this$orderHooks2 = this.orderHooks) === null || _this$orderHooks2 === void 0 ? void 0 : _this$orderHooks2.getCartIntentScope;
535
+ var scope = getScope === null || getScope === void 0 ? void 0 : getScope();
536
+ var otherParams = this.otherParams;
537
+ var committed = false;
538
+ return function () {
539
+ var _this2$orderHooks, _this2$orderHooks2;
540
+ if (_this2.store.tempOrder !== tempOrder || _this2.otherParams !== otherParams || ((_this2$orderHooks = _this2.orderHooks) === null || _this2$orderHooks === void 0 ? void 0 : _this2$orderHooks.beforeCartIntentCommit) !== hook || ((_this2$orderHooks2 = _this2.orderHooks) === null || _this2$orderHooks2 === void 0 ? void 0 : _this2$orderHooks2.getCartIntentScope) !== getScope || (getScope === null || getScope === void 0 ? void 0 : getScope()) !== scope) {
541
+ throw new Error('[Order] Cart intent belongs to a previous order or business');
542
+ }
543
+ // Derived gifts, discounts and persistence belong to the accepted intent,
544
+ // but an asynchronous continuation must never target a different cart.
545
+ if (committed) return;
546
+ hook({
547
+ action: action,
548
+ tempOrder: tempOrder
549
+ });
550
+ committed = true;
551
+ };
552
+ }
553
+
523
554
  /** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
524
555
  }, {
525
556
  key: "isOnlineStorePlatform",
@@ -611,10 +642,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
611
642
  }, {
612
643
  key: "createDefaultRulesHooks",
613
644
  value: function createDefaultRulesHooks() {
614
- var _this2 = this;
645
+ var _this3 = this;
615
646
  return createDefaultOrderRulesHooks(function () {
616
- var _this2$store$tempOrde;
617
- return ((_this2$store$tempOrde = _this2.store.tempOrder) === null || _this2$store$tempOrde === void 0 ? void 0 : _this2$store$tempOrde.bookings) || [];
647
+ var _this3$store$tempOrde;
648
+ return ((_this3$store$tempOrde = _this3.store.tempOrder) === null || _this3$store$tempOrde === void 0 ? void 0 : _this3$store$tempOrde.bookings) || [];
618
649
  });
619
650
  }
620
651
 
@@ -637,7 +668,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
637
668
  var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
638
669
  var _this$store$tempOrder,
639
670
  _this$store$discount,
640
- _this3 = this,
671
+ _this4 = this,
641
672
  _this$store$tempOrder2;
642
673
  var orderId, requestEpoch, requestOrderIdentityKey, prepareConfigResult, isCurrentRequest, discountList, _this$store$discount2, _this$store$discount3, _this$store$discount4, currentDiscountList, currentCommittedDiscounts, currentScanDiscounts, currentScanDiscountById, committedDiscountById, mergedCommittedDiscountIds, refreshedScanDiscountIds, runtimeDiscountIds, runtimeDiscounts, retainedCommittedDiscounts, retainedScanDiscounts, mergedDiscountList;
643
674
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -665,8 +696,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
665
696
  case 5:
666
697
  prepareConfigResult = _context3.sent;
667
698
  isCurrentRequest = function isCurrentRequest() {
668
- var _this3$store$tempOrde, _this3$store$tempOrde2;
669
- return requestEpoch === _this3.customerWalletPrepareConfigEpoch && _this3.getDiscountConfigOrderIdentityKey(_this3.store.tempOrder) === requestOrderIdentityKey && String((_this3$store$tempOrde = (_this3$store$tempOrde2 = _this3.store.tempOrder) === null || _this3$store$tempOrde2 === void 0 ? void 0 : _this3$store$tempOrde2.customer_id) !== null && _this3$store$tempOrde !== void 0 ? _this3$store$tempOrde : '') === String(params.customerId);
699
+ var _this4$store$tempOrde, _this4$store$tempOrde2;
700
+ return requestEpoch === _this4.customerWalletPrepareConfigEpoch && _this4.getDiscountConfigOrderIdentityKey(_this4.store.tempOrder) === requestOrderIdentityKey && String((_this4$store$tempOrde = (_this4$store$tempOrde2 = _this4.store.tempOrder) === null || _this4$store$tempOrde2 === void 0 ? void 0 : _this4$store$tempOrde2.customer_id) !== null && _this4$store$tempOrde !== void 0 ? _this4$store$tempOrde : '') === String(params.customerId);
670
701
  };
671
702
  if (isCurrentRequest()) {
672
703
  _context3.next = 9;
@@ -898,12 +929,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
898
929
  value: function () {
899
930
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
900
931
  var _this$store$discount11, _tempOrder$holder, _this$store$summary;
901
- var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
932
+ var beforeCommit, resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref16, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, scannedIds, evaluatedScannedDiscounts, shouldRetainForLater, normalizedNewDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13, retainedDiscounts;
902
933
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
903
934
  while (1) switch (_context6.prev = _context6.next) {
904
935
  case 0:
936
+ beforeCommit = this.createCartIntentCommitGuard('scan_promotion');
905
937
  if (!this.isActiveVirtualSettlementOrder(this.store.tempOrder)) {
906
- _context6.next = 2;
938
+ _context6.next = 3;
907
939
  break;
908
940
  }
909
941
  return _context6.abrupt("return", {
@@ -914,27 +946,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
914
946
  scannedDiscountList: [],
915
947
  unavailableReason: UnavailableReason.ProductNotApplicable
916
948
  });
917
- case 2:
918
- _context6.next = 4;
949
+ case 3:
950
+ _context6.next = 5;
919
951
  return (_this$store$discount11 = this.store.discount) === null || _this$store$discount11 === void 0 ? void 0 : _this$store$discount11.batchSearch(code, {
920
952
  customerId: customerId
921
953
  });
922
- case 4:
954
+ case 5:
923
955
  _context6.t0 = _context6.sent;
924
956
  if (_context6.t0) {
925
- _context6.next = 7;
957
+ _context6.next = 8;
926
958
  break;
927
959
  }
928
960
  _context6.t0 = {
929
961
  discountList: [],
930
962
  unavailableReasonKey: null
931
963
  };
932
- case 7:
964
+ case 8:
933
965
  resultDiscountWithReason = _context6.t0;
934
966
  resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
935
967
  rulesModule = this.store.rules;
936
968
  if (rulesModule) {
937
- _context6.next = 12;
969
+ _context6.next = 13;
938
970
  break;
939
971
  }
940
972
  return _context6.abrupt("return", {
@@ -945,9 +977,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
945
977
  scannedDiscountList: resultDiscountList,
946
978
  unavailableReason: UnavailableReason.Unknown
947
979
  });
948
- case 12:
980
+ case 13:
949
981
  if (resultDiscountList.length) {
950
- _context6.next = 14;
982
+ _context6.next = 15;
951
983
  break;
952
984
  }
953
985
  return _context6.abrupt("return", {
@@ -958,7 +990,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
958
990
  scannedDiscountList: resultDiscountList,
959
991
  unavailableReasonKey: unavailableReasonKey
960
992
  });
961
- case 14:
993
+ case 15:
962
994
  withScanList = resultDiscountList.map(function (item) {
963
995
  return _objectSpread(_objectSpread({}, item), {}, {
964
996
  isScan: true
@@ -972,12 +1004,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
972
1004
  return m.id === n.id;
973
1005
  });
974
1006
  }))) {
975
- _context6.next = 20;
1007
+ _context6.next = 22;
976
1008
  break;
977
1009
  }
978
- _context6.next = 19;
1010
+ beforeCommit();
1011
+ _context6.next = 21;
979
1012
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
980
- case 19:
1013
+ case 21:
981
1014
  return _context6.abrupt("return", {
982
1015
  type: 'clientCalc',
983
1016
  isAvailable: true,
@@ -985,7 +1018,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
985
1018
  discountList: this.getDiscountList(),
986
1019
  scannedDiscountList: resultDiscountList
987
1020
  });
988
- case 20:
1021
+ case 22:
989
1022
  tempOrder = this.store.tempOrder;
990
1023
  holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
991
1024
  _ref16 = rulesModule.isDiscountListAvailable({
@@ -1011,12 +1044,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1011
1044
  normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
1012
1045
  resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
1013
1046
  if (!(isAvailable && normalizedNewDiscountList)) {
1014
- _context6.next = 37;
1047
+ _context6.next = 40;
1015
1048
  break;
1016
1049
  }
1017
- _context6.next = 31;
1050
+ beforeCommit();
1051
+ _context6.next = 34;
1018
1052
  return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
1019
- case 31:
1053
+ case 34:
1020
1054
  // 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
1021
1055
  this.applyDiscount({
1022
1056
  preferredEntitlementPassIds: withScanList.filter(function (discount) {
@@ -1025,17 +1059,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1025
1059
  return discount.id;
1026
1060
  })
1027
1061
  });
1028
- _context6.next = 34;
1062
+ _context6.next = 37;
1029
1063
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1030
- case 34:
1064
+ case 37:
1031
1065
  resolvedDiscountList = this.getDiscountList();
1032
- _context6.next = 45;
1066
+ _context6.next = 49;
1033
1067
  break;
1034
- case 37:
1068
+ case 40:
1035
1069
  if (!shouldRetainForLater) {
1036
- _context6.next = 45;
1070
+ _context6.next = 49;
1037
1071
  break;
1038
1072
  }
1073
+ beforeCommit();
1039
1074
  // 只合并本次识别的卡券;不把试算产生的其他选券状态写回订单。
1040
1075
  retainedDiscounts = new Map(this.getDiscountList().map(function (discount) {
1041
1076
  return [String(discount.id), discount];
@@ -1050,14 +1085,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1050
1085
  savedAmount: 0
1051
1086
  }));
1052
1087
  });
1053
- _context6.next = 42;
1088
+ _context6.next = 46;
1054
1089
  return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(_toConsumableArray(retainedDiscounts.values()));
1055
- case 42:
1056
- _context6.next = 44;
1090
+ case 46:
1091
+ _context6.next = 48;
1057
1092
  return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
1058
- case 44:
1093
+ case 48:
1059
1094
  resolvedDiscountList = this.getDiscountList();
1060
- case 45:
1095
+ case 49:
1061
1096
  return _context6.abrupt("return", {
1062
1097
  type: 'clientCalc',
1063
1098
  isAvailable: isAvailable || false,
@@ -1066,7 +1101,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1066
1101
  scannedDiscountList: evaluatedScannedDiscounts,
1067
1102
  unavailableReason: unavailableReason
1068
1103
  });
1069
- case 46:
1104
+ case 50:
1070
1105
  case "end":
1071
1106
  return _context6.stop();
1072
1107
  }
@@ -1082,7 +1117,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1082
1117
  value: function applyDiscount(options) {
1083
1118
  var _this$store$discount16,
1084
1119
  _this$store$summary2,
1085
- _this4 = this;
1120
+ _this5 = this;
1086
1121
  var tempOrder = this.store.tempOrder;
1087
1122
  // 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
1088
1123
  // 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
@@ -1139,7 +1174,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1139
1174
  (_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || _this$store$discount17.setDiscountList(result.discountList);
1140
1175
  }
1141
1176
  this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
1142
- return _this4.productHasCustomerBoundDiscount(product);
1177
+ return _this5.productHasCustomerBoundDiscount(product);
1143
1178
  });
1144
1179
  }
1145
1180
 
@@ -1202,7 +1237,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1202
1237
  var _evaluatePromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
1203
1238
  var _this$promotionEvalua,
1204
1239
  _this$promotionEvalua2,
1205
- _this5 = this;
1240
+ _this6 = this;
1206
1241
  var tempOrder, strategyConfigs, result, removeSet, _iterator3, _step3, reduce, _iterator6, _step6, _loop2, _iterator4, _step4, _loop, payload;
1207
1242
  return _regeneratorRuntime().wrap(function _callee7$(_context9) {
1208
1243
  while (1) switch (_context9.prev = _context9.next) {
@@ -1361,7 +1396,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1361
1396
  case 6:
1362
1397
  _context7.prev = 6;
1363
1398
  _context7.next = 9;
1364
- return _this5.giftSelectResolver({
1399
+ return _this6.giftSelectResolver({
1365
1400
  strategyId: addAction.strategyId,
1366
1401
  strategyName: addAction.strategyName,
1367
1402
  giftCount: addAction.giftCount,
@@ -1396,7 +1431,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1396
1431
  _context7.next = 26;
1397
1432
  break;
1398
1433
  }
1399
- linked = _this5.createLinkedProductAndBooking({
1434
+ linked = _this6.createLinkedProductAndBooking({
1400
1435
  product: gp,
1401
1436
  booking: booking
1402
1437
  });
@@ -1726,12 +1761,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1726
1761
  }, {
1727
1762
  key: "rememberPointCardSnapshotCodeCandidates",
1728
1763
  value: function rememberPointCardSnapshotCodeCandidates(value) {
1729
- var _this6 = this;
1764
+ var _this7 = this;
1730
1765
  collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
1731
1766
  var id = _ref18.id,
1732
1767
  code = _ref18.code;
1733
- if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
1734
- _this6.pointCardSnapshotCodeCandidates.set(id, code);
1768
+ if (!_this7.pointCardSnapshotCodeCandidates.has(id)) {
1769
+ _this7.pointCardSnapshotCodeCandidates.set(id, code);
1735
1770
  }
1736
1771
  });
1737
1772
  }
@@ -1938,23 +1973,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1938
1973
  }, {
1939
1974
  key: "calculatePaymentTotal",
1940
1975
  value: function calculatePaymentTotal(payments) {
1941
- var _this7 = this;
1976
+ var _this8 = this;
1942
1977
  return mapPaymentItemsToOrderPayments(payments, {
1943
1978
  includeVoided: false
1944
1979
  }).reduce(function (sum, payment) {
1945
1980
  if (!isPaidPaymentRecord(payment)) return sum;
1946
- return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
1981
+ return sum.plus(_this8.calculatePaymentEffectiveAmount(payment));
1947
1982
  }, new Decimal(0));
1948
1983
  }
1949
1984
  }, {
1950
1985
  key: "calculateOrderPaidPaymentTotal",
1951
1986
  value: function calculateOrderPaidPaymentTotal(payments) {
1952
- var _this8 = this;
1987
+ var _this9 = this;
1953
1988
  return mapPaymentItemsToOrderPayments(payments, {
1954
1989
  includeVoided: false
1955
1990
  }).reduce(function (sum, payment) {
1956
1991
  if (!isPaidPaymentRecord(payment)) return sum;
1957
- return sum.plus(_this8.calculatePaymentGapAmount(payment));
1992
+ return sum.plus(_this9.calculatePaymentGapAmount(payment));
1958
1993
  }, new Decimal(0));
1959
1994
  }
1960
1995
  }, {
@@ -2090,13 +2125,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2090
2125
  }, {
2091
2126
  key: "calculateDepositPaidAmount",
2092
2127
  value: function calculateDepositPaidAmount(payments) {
2093
- var _this9 = this;
2128
+ var _this10 = this;
2094
2129
  return (payments || []).reduce(function (sum, payment) {
2095
2130
  var paymentRecord = payment;
2096
2131
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
2097
2132
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
2098
2133
  if (!isDepositPayment) return sum;
2099
- return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
2134
+ return sum.plus(_this10.calculatePaymentGapAmount(paymentRecord));
2100
2135
  }, new Decimal(0));
2101
2136
  }
2102
2137
  }, {
@@ -2133,17 +2168,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2133
2168
  }, {
2134
2169
  key: "getPaymentNumberDevicePrefixSync",
2135
2170
  value: function getPaymentNumberDevicePrefixSync() {
2136
- var _this10 = this;
2171
+ var _this11 = this;
2137
2172
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
2138
- return _this10.getPaymentNumberAppData(key);
2173
+ return _this11.getPaymentNumberAppData(key);
2139
2174
  });
2140
2175
  }
2141
2176
  }, {
2142
2177
  key: "getPaymentNumberDevicePrefixAsync",
2143
2178
  value: function getPaymentNumberDevicePrefixAsync() {
2144
- var _this11 = this;
2179
+ var _this12 = this;
2145
2180
  return resolvePaymentNumberDevicePrefix(function (key) {
2146
- return _this11.getPaymentNumberAppData(key);
2181
+ return _this12.getPaymentNumberAppData(key);
2147
2182
  });
2148
2183
  }
2149
2184
  }, {
@@ -2273,16 +2308,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2273
2308
  }, {
2274
2309
  key: "calculatePaidPaymentSummary",
2275
2310
  value: function calculatePaidPaymentSummary(payments) {
2276
- var _this12 = this;
2311
+ var _this13 = this;
2277
2312
  return (payments || []).reduce(function (summary, payment) {
2278
2313
  var paymentRecord = payment;
2279
2314
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
2280
2315
  return {
2281
2316
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
2282
- orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
2283
- gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
2284
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
2285
- roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
2317
+ orderPaidAmount: summary.orderPaidAmount.plus(_this13.calculatePaymentOrderAmount(paymentRecord)),
2318
+ gapPaidAmount: summary.gapPaidAmount.plus(_this13.calculatePaymentGapAmount(paymentRecord)),
2319
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this13.calculatePaymentServiceFee(paymentRecord)),
2320
+ roundingAmount: summary.roundingAmount.plus(_this13.calculatePaymentRoundingAmount(paymentRecord))
2286
2321
  };
2287
2322
  }, {
2288
2323
  customerPaidAmount: new Decimal(0),
@@ -2489,15 +2524,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2489
2524
  }, {
2490
2525
  key: "normalizeFingerprintValue",
2491
2526
  value: function normalizeFingerprintValue(value) {
2492
- var _this13 = this;
2527
+ var _this14 = this;
2493
2528
  if (Array.isArray(value)) {
2494
2529
  return value.map(function (item) {
2495
- return _this13.normalizeFingerprintValue(item);
2530
+ return _this14.normalizeFingerprintValue(item);
2496
2531
  });
2497
2532
  }
2498
2533
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
2499
2534
  return Object.keys(value).sort().reduce(function (result, key) {
2500
- result[key] = _this13.normalizeFingerprintValue(value[key]);
2535
+ result[key] = _this14.normalizeFingerprintValue(value[key]);
2501
2536
  return result;
2502
2537
  }, {});
2503
2538
  }
@@ -2512,7 +2547,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2512
2547
  _sku$barcode,
2513
2548
  _ref26,
2514
2549
  _sku$variant_id,
2515
- _this14 = this;
2550
+ _this15 = this;
2516
2551
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2517
2552
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2518
2553
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2549,7 +2584,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2549
2584
  option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
2550
2585
  option_group_item_id: (_ref28 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref28 !== void 0 ? _ref28 : null,
2551
2586
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2552
- add_price: _this14.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
2587
+ add_price: _this15.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
2553
2588
  };
2554
2589
  })
2555
2590
  }),
@@ -2559,8 +2594,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2559
2594
  bundle_product_id: (_ref29 = (_ref30 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref30 !== void 0 ? _ref30 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref29 !== void 0 ? _ref29 : null,
2560
2595
  bundle_variant_id: (_ref31 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref31 !== void 0 ? _ref31 : 0,
2561
2596
  num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2562
- price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2563
- bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2597
+ price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2598
+ bundle_selling_price: _this15.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2564
2599
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
2565
2600
  price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
2566
2601
  };
@@ -2570,7 +2605,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2570
2605
  return {
2571
2606
  type: (_ref32 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref32 !== void 0 ? _ref32 : '',
2572
2607
  discount_id: (_ref33 = (_ref34 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref34 !== void 0 ? _ref34 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref33 !== void 0 ? _ref33 : null,
2573
- amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2608
+ amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2574
2609
  };
2575
2610
  }))
2576
2611
  };
@@ -2578,9 +2613,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2578
2613
  }, {
2579
2614
  key: "buildOrderProductsFingerprint",
2580
2615
  value: function buildOrderProductsFingerprint(products) {
2581
- var _this15 = this;
2616
+ var _this16 = this;
2582
2617
  var items = (products || []).map(function (product) {
2583
- return _this15.buildProductFingerprintItem(product);
2618
+ return _this16.buildProductFingerprintItem(product);
2584
2619
  });
2585
2620
  items.sort(function (left, right) {
2586
2621
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2602,7 +2637,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2602
2637
  _sku$barcode2,
2603
2638
  _ref36,
2604
2639
  _sku$variant_id2,
2605
- _this16 = this;
2640
+ _this17 = this;
2606
2641
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2607
2642
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2608
2643
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2636,7 +2671,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2636
2671
  option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
2637
2672
  option_group_item_id: (_ref38 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
2638
2673
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2639
- add_price: _this16.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2674
+ add_price: _this17.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
2640
2675
  };
2641
2676
  })
2642
2677
  }),
@@ -2650,14 +2685,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2650
2685
  num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
2651
2686
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2652
2687
  price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
2653
- option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2688
+ option: _this17.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2654
2689
  var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
2655
2690
  return {
2656
2691
  id: (_ref44 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref44 !== void 0 ? _ref44 : null,
2657
2692
  option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
2658
2693
  option_group_item_id: (_ref45 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref45 !== void 0 ? _ref45 : null,
2659
2694
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2660
- add_price: _this16.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2695
+ add_price: _this17.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
2661
2696
  };
2662
2697
  }))
2663
2698
  };
@@ -2667,7 +2702,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2667
2702
  return {
2668
2703
  type: (_ref46 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref46 !== void 0 ? _ref46 : '',
2669
2704
  discount_id: (_ref47 = (_ref48 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref48 !== void 0 ? _ref48 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref47 !== void 0 ? _ref47 : null,
2670
- amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2705
+ amount: _this17.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2671
2706
  };
2672
2707
  }))
2673
2708
  };
@@ -2675,9 +2710,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2675
2710
  }, {
2676
2711
  key: "buildOrderProductsStructuralFingerprint",
2677
2712
  value: function buildOrderProductsStructuralFingerprint(products) {
2678
- var _this17 = this;
2713
+ var _this18 = this;
2679
2714
  var items = (products || []).map(function (product) {
2680
- return _this17.buildProductStructuralFingerprintItem(product);
2715
+ return _this18.buildProductStructuralFingerprintItem(product);
2681
2716
  });
2682
2717
  items.sort(function (left, right) {
2683
2718
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -3129,9 +3164,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3129
3164
  }, {
3130
3165
  key: "sanitizeTempOrderProducts",
3131
3166
  value: function sanitizeTempOrderProducts(tempOrder) {
3132
- var _this18 = this;
3167
+ var _this19 = this;
3133
3168
  tempOrder.products = (tempOrder.products || []).map(function (product) {
3134
- return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
3169
+ return _this19.sanitizeOrderProductForTempOrder(_this19.normalizeVirtualSettlementProductIfEnabled(product));
3135
3170
  });
3136
3171
  this.syncTempOrderSettlementState(tempOrder);
3137
3172
  ensureUniqueProductLineUids(tempOrder);
@@ -3251,7 +3286,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3251
3286
  }, {
3252
3287
  key: "syncLinkedBookingHoldersToProducts",
3253
3288
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
3254
- var _this19 = this;
3289
+ var _this20 = this;
3255
3290
  var bookings = tempOrder.bookings || [];
3256
3291
  var products = tempOrder.products || [];
3257
3292
  if (!bookings.length || !products.length) return;
@@ -3277,7 +3312,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3277
3312
  var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
3278
3313
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
3279
3314
  if (linkedBooking) {
3280
- _this19.setProductHolderFromBooking(product, linkedBooking);
3315
+ _this20.setProductHolderFromBooking(product, linkedBooking);
3281
3316
  }
3282
3317
  });
3283
3318
  }
@@ -3408,9 +3443,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3408
3443
  }, {
3409
3444
  key: "findBookingIndexByUniqueIdentificationNumber",
3410
3445
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
3411
- var _this20 = this;
3446
+ var _this21 = this;
3412
3447
  return (tempOrder.bookings || []).findIndex(function (booking) {
3413
- return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3448
+ return _this21.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3414
3449
  });
3415
3450
  }
3416
3451
  }, {
@@ -3418,13 +3453,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3418
3453
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
3419
3454
  var _product$metadata5,
3420
3455
  _product$metadata6,
3421
- _this21 = this;
3456
+ _this22 = this;
3422
3457
  var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
3423
3458
  var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
3424
3459
  if (!productUid && !bookingUid) return;
3425
3460
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
3426
3461
  if (isFulfillmentTimingBooking(booking)) return true;
3427
- var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
3462
+ var currentBookingUid = _this22.getBookingUniqueIdentificationNumber(booking);
3428
3463
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
3429
3464
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
3430
3465
  return true;
@@ -3726,7 +3761,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3726
3761
  }, {
3727
3762
  key: "removeSalesNotesForMissingProductLines",
3728
3763
  value: function removeSalesNotesForMissingProductLines(tempOrder) {
3729
- var _this22 = this;
3764
+ var _this23 = this;
3730
3765
  var state = this.ensureSalesNotesRuntimeState(tempOrder);
3731
3766
  if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3732
3767
  return;
@@ -3738,7 +3773,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3738
3773
  return typeof uid === 'string' && uid.length > 0;
3739
3774
  }));
3740
3775
  var nextNotes = tempOrder.notes.filter(function (note) {
3741
- var primary = _this22.getSalesNotePrimaryRelation(note);
3776
+ var primary = _this23.getSalesNotePrimaryRelation(note);
3742
3777
  if (!primary || primary.target_type !== 'order_detail') return true;
3743
3778
  return remainingProductUids.has(primary.target_uuid);
3744
3779
  });
@@ -3750,7 +3785,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3750
3785
  key: "setSalesNoteOnTempOrder",
3751
3786
  value: function setSalesNoteOnTempOrder(tempOrder, input) {
3752
3787
  var _input$target,
3753
- _this23 = this,
3788
+ _this24 = this,
3754
3789
  _tempOrder$shop_order;
3755
3790
  this.ensureSalesNotesLoadedForMutation(tempOrder);
3756
3791
  var note_type = String(input.note_type || '').trim();
@@ -3774,7 +3809,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3774
3809
  var notes = tempOrder.notes || [];
3775
3810
  // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3776
3811
  var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3777
- var primary = _this23.getSalesNotePrimaryRelation(note);
3812
+ var primary = _this24.getSalesNotePrimaryRelation(note);
3778
3813
  return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3779
3814
  }) : -1;
3780
3815
  var existing = existingIndex >= 0 ? notes[existingIndex] : null;
@@ -4093,15 +4128,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4093
4128
  }, {
4094
4129
  key: "productHasCustomerBoundDiscount",
4095
4130
  value: function productHasCustomerBoundDiscount(product) {
4096
- var _this24 = this;
4131
+ var _this25 = this;
4097
4132
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
4098
- return _this24.isCustomerBoundDiscount(discount);
4133
+ return _this25.isCustomerBoundDiscount(discount);
4099
4134
  })) {
4100
4135
  return true;
4101
4136
  }
4102
4137
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
4103
4138
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
4104
- return _this24.isCustomerBoundDiscount(discount);
4139
+ return _this25.isCustomerBoundDiscount(discount);
4105
4140
  });
4106
4141
  });
4107
4142
  }
@@ -4110,18 +4145,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4110
4145
  value: function shouldSkipDiscountCalculation(tempOrder) {
4111
4146
  var _this$store$discount20,
4112
4147
  _this$store$discount21,
4113
- _this25 = this;
4148
+ _this26 = this;
4114
4149
  if (this.hasActiveCustomerBoundDiscount) return false;
4115
4150
  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)) || [];
4116
4151
  if (discountList.length > 0) return false;
4117
4152
  return !(tempOrder.products || []).some(function (product) {
4118
- return _this25.productHasCustomerBoundDiscount(product);
4153
+ return _this26.productHasCustomerBoundDiscount(product);
4119
4154
  });
4120
4155
  }
4121
4156
  }, {
4122
4157
  key: "clearCustomerBoundDiscounts",
4123
4158
  value: function clearCustomerBoundDiscounts(tempOrder) {
4124
- var _this26 = this,
4159
+ var _this27 = this,
4125
4160
  _discountModule$getDi,
4126
4161
  _discountModule$getOr,
4127
4162
  _discountModule$setDi,
@@ -4130,7 +4165,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4130
4165
  var filterDiscountList = function filterDiscountList(discountList) {
4131
4166
  if (!Array.isArray(discountList)) return [];
4132
4167
  return discountList.filter(function (discount) {
4133
- var shouldRemove = _this26.isCustomerBoundDiscount(discount);
4168
+ var shouldRemove = _this27.isCustomerBoundDiscount(discount);
4134
4169
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
4135
4170
  return !shouldRemove;
4136
4171
  });
@@ -4157,12 +4192,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4157
4192
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
4158
4193
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
4159
4194
  var nextDiscounts = currentDiscounts.filter(function (discount) {
4160
- if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4161
- return !_this26.isCustomerBoundDiscount(discount);
4195
+ if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4196
+ return !_this27.isCustomerBoundDiscount(discount);
4162
4197
  });
4163
4198
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
4164
- if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4165
- return !_this26.isCustomerBoundDiscount(discount);
4199
+ if (_this27.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4200
+ return !_this27.isCustomerBoundDiscount(discount);
4166
4201
  });
4167
4202
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
4168
4203
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -4326,10 +4361,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4326
4361
  }, {
4327
4362
  key: "setOrderPayments",
4328
4363
  value: function setOrderPayments(payments) {
4329
- var _this27 = this;
4364
+ var _this28 = this;
4330
4365
  var tempOrder = this.ensureTempOrder();
4331
4366
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
4332
- return _this27.normalizePaymentSource(payment, {
4367
+ return _this28.normalizePaymentSource(payment, {
4333
4368
  defaultPaid: false
4334
4369
  });
4335
4370
  }));
@@ -4384,7 +4419,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4384
4419
  }, {
4385
4420
  key: "addOrderPaymentWithDevicePrefix",
4386
4421
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4387
- var _this28 = this;
4422
+ var _this29 = this;
4388
4423
  this.logInfo('addOrderPayment', {
4389
4424
  payment: payment
4390
4425
  });
@@ -4402,7 +4437,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4402
4437
  void this.recalculateSummary({
4403
4438
  createIfMissing: true
4404
4439
  }).catch(function (error) {
4405
- _this28.logError('recalculate summary after addOrderPayment failed', {
4440
+ _this29.logError('recalculate summary after addOrderPayment failed', {
4406
4441
  error: error instanceof Error ? error.message : String(error)
4407
4442
  });
4408
4443
  });
@@ -4515,7 +4550,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4515
4550
  }, {
4516
4551
  key: "applyPaymentLifecycleChange",
4517
4552
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4518
- var _this29 = this;
4553
+ var _this30 = this;
4519
4554
  this.updateTempOrderPaymentStatus(tempOrder);
4520
4555
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4521
4556
  this.persistTempOrder();
@@ -4525,7 +4560,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4525
4560
  void this.recalculateSummary({
4526
4561
  createIfMissing: true
4527
4562
  }).catch(function (error) {
4528
- _this29.logError("recalculate summary after ".concat(logContext, " failed"), {
4563
+ _this30.logError("recalculate summary after ".concat(logContext, " failed"), {
4529
4564
  error: error instanceof Error ? error.message : String(error)
4530
4565
  });
4531
4566
  });
@@ -4569,7 +4604,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4569
4604
  }, {
4570
4605
  key: "updateVoucherOrderPayments",
4571
4606
  value: function updateVoucherOrderPayments(payments, options) {
4572
- var _this30 = this;
4607
+ var _this31 = this;
4573
4608
  var tempOrder = this.ensureTempOrder();
4574
4609
  var isOrderPaymentType = function isOrderPaymentType(value) {
4575
4610
  return value === 'normal' || value === 'deposit';
@@ -4604,7 +4639,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4604
4639
  });
4605
4640
  };
4606
4641
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4607
- return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4642
+ return _this31.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4608
4643
  defaultPaid: false,
4609
4644
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4610
4645
  });
@@ -4657,7 +4692,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4657
4692
  void this.recalculateSummary({
4658
4693
  createIfMissing: true
4659
4694
  }).catch(function (error) {
4660
- _this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
4695
+ _this31.logError('recalculate summary after updateVoucherOrderPayments failed', {
4661
4696
  error: error instanceof Error ? error.message : String(error)
4662
4697
  });
4663
4698
  });
@@ -4714,16 +4749,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4714
4749
  }, {
4715
4750
  key: "shouldMergeProductToOrder",
4716
4751
  value: function shouldMergeProductToOrder(params) {
4717
- var _this$orderHooks,
4718
- _this31 = this;
4719
- var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
4752
+ var _this$orderHooks3,
4753
+ _this32 = this;
4754
+ var onBeforeMergeProductToOrder = (_this$orderHooks3 = this.orderHooks) === null || _this$orderHooks3 === void 0 ? void 0 : _this$orderHooks3.onBeforeMergeProductToOrder;
4720
4755
  if (!onBeforeMergeProductToOrder) return true;
4721
4756
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
4722
4757
  defaultShouldMerge: true
4723
4758
  }));
4724
4759
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4725
4760
  return Promise.resolve(result).then(function (resolved) {
4726
- return _this31.normalizeShouldMergeProductResult(resolved);
4761
+ return _this32.normalizeShouldMergeProductResult(resolved);
4727
4762
  });
4728
4763
  }
4729
4764
  return this.normalizeShouldMergeProductResult(result);
@@ -4924,14 +4959,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4924
4959
  _metadata,
4925
4960
  _productToAdd$metadat,
4926
4961
  _origin,
4927
- _this32 = this;
4962
+ _this33 = this;
4928
4963
  var linked = booking ? this.createLinkedProductAndBooking({
4929
4964
  product: product,
4930
4965
  booking: booking
4931
4966
  }) : null;
4932
4967
  var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
4933
4968
  var disableMerge = (options === null || options === void 0 ? void 0 : options.disableMerge) === true;
4934
- this.assertAndLockProductSettlement(tempOrder, productToAdd);
4935
4969
  var incomingFingerprint = disableMerge ? '' : buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
4936
4970
  var normalizedIncoming = this.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd)));
4937
4971
  if (disableMerge) {
@@ -4960,26 +4994,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4960
4994
  var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
4961
4995
  var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4962
4996
  var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4963
- if (_this32.hasGoodPassDiscount(item)) return false;
4964
- var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
4997
+ if (_this33.hasGoodPassDiscount(item)) return false;
4998
+ var isRuntimeEntitlementPass = _this33.isRuntimeEntitlementAppend(item, tempOrder);
4965
4999
  if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
4966
5000
  return false;
4967
5001
  }
4968
- if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
5002
+ if (isIncomingEntitlementAppend && _this33.isPersistedProductLine(item)) {
4969
5003
  return false;
4970
5004
  }
4971
- var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
5005
+ var hasExistingProductNote = _this33.hasOrderProductLineNote(item);
4972
5006
  if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
4973
5007
  return false;
4974
5008
  }
4975
5009
  var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
4976
- if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
5010
+ if (isRuntimeEntitlementPass && !_this33.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
4977
5011
  return false;
4978
5012
  }
4979
5013
  if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
4980
5014
  return false;
4981
5015
  }
4982
- if (_this32.isPersistedProductLine(item)) return false;
5016
+ if (_this33.isPersistedProductLine(item)) return false;
4983
5017
  if (item.product_id !== productToAdd.product_id) return false;
4984
5018
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
4985
5019
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -4988,9 +5022,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4988
5022
  var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
4989
5023
  var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
4990
5024
  var commitProductLine = function commitProductLine(shouldMerge) {
5025
+ var _options$beforeCommit;
5026
+ options === null || options === void 0 || (_options$beforeCommit = options.beforeCommit) === null || _options$beforeCommit === void 0 || _options$beforeCommit.call(options);
5027
+ _this33.assertAndLockProductSettlement(tempOrder, productToAdd);
4991
5028
  var committedProduct;
4992
5029
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
4993
- _this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
5030
+ _this33.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4994
5031
  if (linked) {
4995
5032
  normalizedIncoming.booking_uid = linked.bookingUid;
4996
5033
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -5008,7 +5045,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5008
5045
  var _targetProduct$metada;
5009
5046
  var targetProduct = matchedProduct;
5010
5047
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
5011
- var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
5048
+ var normalizedProduct = _this33.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
5012
5049
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
5013
5050
  unique_identification_number: targetUid
5014
5051
  })
@@ -5031,7 +5068,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5031
5068
  order_detail_id: targetProduct.order_detail_id,
5032
5069
  num: nextNum
5033
5070
  });
5034
- _this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
5071
+ _this33.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
5035
5072
  committedProduct = tempOrder.products[matchedIndex];
5036
5073
  if (matchedIndex !== tempOrder.products.length - 1) {
5037
5074
  var mergedProduct = tempOrder.products[matchedIndex];
@@ -5141,12 +5178,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5141
5178
  key: "addProductToOrder",
5142
5179
  value: (function () {
5143
5180
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
5144
- var _this33 = this;
5145
- var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5181
+ var _this34 = this;
5182
+ var tempOrder, beforeCommit, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5146
5183
  return _regeneratorRuntime().wrap(function _callee23$(_context25) {
5147
5184
  while (1) switch (_context25.prev = _context25.next) {
5148
5185
  case 0:
5149
5186
  tempOrder = this.ensureTempOrder();
5187
+ beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
5150
5188
  salesNoteDrafts = ((options === null || options === void 0 ? void 0 : options.salesNotes) || []).map(function (draft) {
5151
5189
  return {
5152
5190
  note_type: String(draft.note_type || '').trim(),
@@ -5170,7 +5208,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5170
5208
  throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
5171
5209
  }
5172
5210
  salesNoteDrafts.forEach(function (draft) {
5173
- _this33.setSalesNoteOnTempOrder(tempOrder, {
5211
+ _this34.setSalesNoteOnTempOrder(tempOrder, {
5174
5212
  note_type: draft.note_type,
5175
5213
  target: {
5176
5214
  target_type: 'order_detail',
@@ -5194,21 +5232,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5194
5232
  return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
5195
5233
  }) : -1;
5196
5234
  insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
5197
- _context25.prev = 8;
5235
+ _context25.prev = 9;
5198
5236
  if (!booking) {
5199
- _context25.next = 33;
5237
+ _context25.next = 34;
5200
5238
  break;
5201
5239
  }
5202
5240
  productRecord = product;
5203
5241
  splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
5204
5242
  if (!(splitCount > 1)) {
5205
- _context25.next = 27;
5243
+ _context25.next = 28;
5206
5244
  break;
5207
5245
  }
5208
5246
  i = 0;
5209
- case 14:
5247
+ case 15:
5210
5248
  if (!(i < splitCount)) {
5211
- _context25.next = 25;
5249
+ _context25.next = 26;
5212
5250
  break;
5213
5251
  }
5214
5252
  splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
@@ -5226,65 +5264,68 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5226
5264
  delete splitLine.booking.metadata.unique_identification_number;
5227
5265
  }
5228
5266
  }
5229
- _context25.next = 19;
5267
+ _context25.next = 20;
5230
5268
  return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
5231
5269
  insertAtIndex: insertAtIndex,
5232
- disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
5270
+ disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5271
+ beforeCommit: beforeCommit
5233
5272
  });
5234
- case 19:
5273
+ case 20:
5235
5274
  committedProduct = _context25.sent;
5236
5275
  attachSalesNoteDrafts(committedProduct);
5237
5276
  if (insertAtIndex !== undefined) insertAtIndex += 1;
5238
- case 22:
5277
+ case 23:
5239
5278
  i += 1;
5240
- _context25.next = 14;
5279
+ _context25.next = 15;
5241
5280
  break;
5242
- case 25:
5243
- _context25.next = 31;
5281
+ case 26:
5282
+ _context25.next = 32;
5244
5283
  break;
5245
- case 27:
5246
- _context25.next = 29;
5284
+ case 28:
5285
+ _context25.next = 30;
5247
5286
  return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
5248
5287
  insertAtIndex: insertAtIndex,
5249
- disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
5288
+ disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5289
+ beforeCommit: beforeCommit
5250
5290
  });
5251
- case 29:
5291
+ case 30:
5252
5292
  _committedProduct = _context25.sent;
5253
5293
  attachSalesNoteDrafts(_committedProduct);
5254
- case 31:
5255
- _context25.next = 37;
5294
+ case 32:
5295
+ _context25.next = 38;
5256
5296
  break;
5257
- case 33:
5258
- _context25.next = 35;
5297
+ case 34:
5298
+ _context25.next = 36;
5259
5299
  return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
5260
5300
  insertAtIndex: insertAtIndex,
5261
- disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge
5301
+ disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
5302
+ beforeCommit: beforeCommit
5262
5303
  });
5263
- case 35:
5304
+ case 36:
5264
5305
  _committedProduct2 = _context25.sent;
5265
5306
  attachSalesNoteDrafts(_committedProduct2);
5266
- case 37:
5267
- _context25.next = 43;
5307
+ case 38:
5308
+ _context25.next = 44;
5268
5309
  break;
5269
- case 39:
5270
- _context25.prev = 39;
5271
- _context25.t0 = _context25["catch"](8);
5310
+ case 40:
5311
+ _context25.prev = 40;
5312
+ _context25.t0 = _context25["catch"](9);
5272
5313
  rollbackProductAndNotesMutation();
5273
5314
  throw _context25.t0;
5274
- case 43:
5275
- _context25.next = 45;
5315
+ case 44:
5316
+ _context25.next = 46;
5276
5317
  return this.finalizeProductOrderMutation(tempOrder);
5277
- case 45:
5318
+ case 46:
5278
5319
  this.logInfo('addProductToOrder success', {
5279
5320
  product_id: product.product_id,
5280
5321
  with_booking: !!booking
5281
5322
  });
5282
5323
  return _context25.abrupt("return", tempOrder.products);
5283
- case 47:
5324
+ case 48:
5284
5325
  case "end":
5285
5326
  return _context25.stop();
5286
5327
  }
5287
- }, _callee23, this, [[8, 39]]);
5328
+ }, _callee23, this, [[9, 40]]);
5288
5329
  }));
5289
5330
  function addProductToOrder(_x23, _x24, _x25) {
5290
5331
  return _addProductToOrder.apply(this, arguments);
@@ -5305,7 +5346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5305
5346
  key: "addProductsToOrder",
5306
5347
  value: (function () {
5307
5348
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
5308
- var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5349
+ var tempOrder, beforeCommit, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5309
5350
  return _regeneratorRuntime().wrap(function _callee24$(_context26) {
5310
5351
  while (1) switch (_context26.prev = _context26.next) {
5311
5352
  case 0:
@@ -5316,87 +5357,92 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5316
5357
  }
5317
5358
  return _context26.abrupt("return", tempOrder.products);
5318
5359
  case 3:
5360
+ beforeCommit = this.createCartIntentCommitGuard('add_product', tempOrder);
5319
5361
  _iterator20 = _createForOfIteratorHelper(items || []);
5320
- _context26.prev = 4;
5362
+ _context26.prev = 5;
5321
5363
  _iterator20.s();
5322
- case 6:
5364
+ case 7:
5323
5365
  if ((_step20 = _iterator20.n()).done) {
5324
- _context26.next = 32;
5366
+ _context26.next = 33;
5325
5367
  break;
5326
5368
  }
5327
5369
  item = _step20.value;
5328
5370
  product = item.product, booking = item.booking;
5329
5371
  if (product) {
5330
- _context26.next = 11;
5372
+ _context26.next = 12;
5331
5373
  break;
5332
5374
  }
5333
- return _context26.abrupt("continue", 30);
5334
- case 11:
5375
+ return _context26.abrupt("continue", 31);
5376
+ case 12:
5335
5377
  if (!booking) {
5336
- _context26.next = 26;
5378
+ _context26.next = 27;
5337
5379
  break;
5338
5380
  }
5339
5381
  productRecord = product;
5340
5382
  splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
5341
5383
  if (!(splitCount > 1)) {
5342
- _context26.next = 26;
5384
+ _context26.next = 27;
5343
5385
  break;
5344
5386
  }
5345
5387
  i = 0;
5346
- case 16:
5388
+ case 17:
5347
5389
  if (!(i < splitCount)) {
5348
- _context26.next = 25;
5390
+ _context26.next = 26;
5349
5391
  break;
5350
5392
  }
5351
5393
  splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
5352
- _appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking);
5394
+ _appendResult = this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
5395
+ beforeCommit: beforeCommit
5396
+ });
5353
5397
  if (!_appendResult) {
5354
- _context26.next = 22;
5398
+ _context26.next = 23;
5355
5399
  break;
5356
5400
  }
5357
- _context26.next = 22;
5401
+ _context26.next = 23;
5358
5402
  return _appendResult;
5359
- case 22:
5403
+ case 23:
5360
5404
  i += 1;
5361
- _context26.next = 16;
5405
+ _context26.next = 17;
5362
5406
  break;
5363
- case 25:
5364
- return _context26.abrupt("continue", 30);
5365
5407
  case 26:
5366
- appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
5408
+ return _context26.abrupt("continue", 31);
5409
+ case 27:
5410
+ appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
5411
+ beforeCommit: beforeCommit
5412
+ });
5367
5413
  if (!appendResult) {
5368
- _context26.next = 30;
5414
+ _context26.next = 31;
5369
5415
  break;
5370
5416
  }
5371
- _context26.next = 30;
5417
+ _context26.next = 31;
5372
5418
  return appendResult;
5373
- case 30:
5374
- _context26.next = 6;
5419
+ case 31:
5420
+ _context26.next = 7;
5375
5421
  break;
5376
- case 32:
5377
- _context26.next = 37;
5422
+ case 33:
5423
+ _context26.next = 38;
5378
5424
  break;
5379
- case 34:
5380
- _context26.prev = 34;
5381
- _context26.t0 = _context26["catch"](4);
5425
+ case 35:
5426
+ _context26.prev = 35;
5427
+ _context26.t0 = _context26["catch"](5);
5382
5428
  _iterator20.e(_context26.t0);
5383
- case 37:
5384
- _context26.prev = 37;
5429
+ case 38:
5430
+ _context26.prev = 38;
5385
5431
  _iterator20.f();
5386
- return _context26.finish(37);
5387
- case 40:
5388
- _context26.next = 42;
5432
+ return _context26.finish(38);
5433
+ case 41:
5434
+ _context26.next = 43;
5389
5435
  return this.finalizeProductOrderMutation(tempOrder, options);
5390
- case 42:
5436
+ case 43:
5391
5437
  this.logInfo('addProductsToOrder success', {
5392
5438
  itemsCount: items.length
5393
5439
  });
5394
5440
  return _context26.abrupt("return", tempOrder.products);
5395
- case 44:
5441
+ case 45:
5396
5442
  case "end":
5397
5443
  return _context26.stop();
5398
5444
  }
5399
- }, _callee24, this, [[4, 34, 37, 40]]);
5445
+ }, _callee24, this, [[5, 35, 38, 41]]);
5400
5446
  }));
5401
5447
  function addProductsToOrder(_x26, _x27) {
5402
5448
  return _addProductsToOrder.apply(this, arguments);
@@ -5450,7 +5496,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5450
5496
  }, {
5451
5497
  key: "hasSameEntitlementMergePriceConfig",
5452
5498
  value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
5453
- var _this34 = this;
5499
+ var _this35 = this;
5454
5500
  var buildPriceConfig = function buildPriceConfig(product) {
5455
5501
  var metadata = product.metadata || {};
5456
5502
  var bundle = (product.product_bundle || []).map(function (item) {
@@ -5466,10 +5512,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5466
5512
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
5467
5513
  });
5468
5514
  return JSON.stringify({
5469
- original_price: _this34.normalizeFingerprintMoney(product.original_price),
5470
- source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
5471
- main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
5472
- price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
5515
+ original_price: _this35.normalizeFingerprintMoney(product.original_price),
5516
+ source_product_price: _this35.normalizeFingerprintMoney(metadata.source_product_price),
5517
+ main_product_original_price: _this35.normalizeFingerprintMoney(metadata.main_product_original_price),
5518
+ price_override: _this35.normalizeFingerprintMoney(metadata.price_override),
5473
5519
  is_manual_discount: Boolean(metadata.is_manual_discount),
5474
5520
  bundle: bundle
5475
5521
  });
@@ -5486,17 +5532,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5486
5532
  }, {
5487
5533
  key: "preservePersistedBundlePriceFields",
5488
5534
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5489
- var _this35 = this;
5535
+ var _this36 = this;
5490
5536
  if (!Array.isArray(nextBundles)) return nextBundles;
5491
5537
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5492
5538
  var previousByIdentity = new Map();
5493
5539
  previousBundles.forEach(function (bundle) {
5494
- var identity = _this35.getBundleRuntimeIdentity(bundle);
5540
+ var identity = _this36.getBundleRuntimeIdentity(bundle);
5495
5541
  if (identity) previousByIdentity.set(identity, bundle);
5496
5542
  });
5497
5543
  return nextBundles.map(function (bundle, index) {
5498
5544
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5499
- var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5545
+ var previous = previousByIdentity.get(_this36.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5500
5546
  if (!previous || _typeof(previous) !== 'object') return bundle;
5501
5547
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5502
5548
  cover: previous.cover
@@ -5510,6 +5556,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5510
5556
  });
5511
5557
  });
5512
5558
  }
5559
+ }, {
5560
+ key: "isRestrictedCartProductUpdate",
5561
+ value: function isRestrictedCartProductUpdate(tempOrder, params) {
5562
+ var _this$orderHooks4, _params$updates;
5563
+ if (!((_this$orderHooks4 = this.orderHooks) !== null && _this$orderHooks4 !== void 0 && _this$orderHooks4.beforeCartIntentCommit)) return false;
5564
+ if (params.booking || Object.keys(params.updates || {}).some(function (key) {
5565
+ return key !== 'num';
5566
+ })) {
5567
+ return true;
5568
+ }
5569
+ if (((_params$updates = params.updates) === null || _params$updates === void 0 ? void 0 : _params$updates.num) === undefined) return false;
5570
+ var uid = params.unique_identification_number;
5571
+ var product = uid !== undefined ? tempOrder.products.find(function (item) {
5572
+ var _item$metadata4;
5573
+ return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === String(uid);
5574
+ }) : tempOrder.products[getProductIdentityIndex(tempOrder.products, params)];
5575
+ return !product || getSafeProductNum(params.updates.num) > product.num;
5576
+ }
5513
5577
  }, {
5514
5578
  key: "applyOrderProductUpdateToTempOrder",
5515
5579
  value: function applyOrderProductUpdateToTempOrder(tempOrder, params) {
@@ -5541,8 +5605,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5541
5605
  if (unique_identification_number !== undefined) {
5542
5606
  var targetUid = String(unique_identification_number);
5543
5607
  productIndex = tempOrder.products.findIndex(function (item) {
5544
- var _item$metadata4;
5545
- return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
5608
+ var _item$metadata5;
5609
+ return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
5546
5610
  });
5547
5611
  }
5548
5612
  if (productIndex === -1) {
@@ -5703,27 +5767,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5703
5767
  while (1) switch (_context27.prev = _context27.next) {
5704
5768
  case 0:
5705
5769
  tempOrder = this.ensureTempOrder();
5770
+ if (this.isRestrictedCartProductUpdate(tempOrder, params)) {
5771
+ this.createCartIntentCommitGuard('update_product', tempOrder)();
5772
+ }
5706
5773
  updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
5707
- _context27.next = 4;
5774
+ _context27.next = 5;
5708
5775
  return this.evaluatePromotion();
5709
- case 4:
5776
+ case 5:
5710
5777
  promotionPayload = _context27.sent;
5711
5778
  this.applyDiscount({
5712
5779
  reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
5713
5780
  });
5714
5781
  this.sanitizeTempOrderProducts(tempOrder);
5715
- _context27.next = 9;
5782
+ _context27.next = 10;
5716
5783
  return this.recalculateSummary({
5717
5784
  createIfMissing: true
5718
5785
  });
5719
- case 9:
5786
+ case 10:
5720
5787
  this.persistTempOrder();
5721
5788
  this.emitPromotionApplied(promotionPayload);
5722
5789
  this.logInfo('updateOrderProduct success', {
5723
5790
  params: params
5724
5791
  });
5725
5792
  return _context27.abrupt("return", tempOrder.products);
5726
- case 13:
5793
+ case 14:
5727
5794
  case "end":
5728
5795
  return _context27.stop();
5729
5796
  }
@@ -5738,7 +5805,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5738
5805
  key: "updateOrderProducts",
5739
5806
  value: function () {
5740
5807
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
5741
- var _this36 = this;
5808
+ var _this37 = this;
5742
5809
  var tempOrder, reapplyBookingDiscountProductUids;
5743
5810
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5744
5811
  while (1) switch (_context28.prev = _context28.next) {
@@ -5750,24 +5817,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5750
5817
  }
5751
5818
  return _context28.abrupt("return", tempOrder.products);
5752
5819
  case 3:
5820
+ if (paramsList.some(function (params) {
5821
+ return _this37.isRestrictedCartProductUpdate(tempOrder, params);
5822
+ })) {
5823
+ this.createCartIntentCommitGuard('update_product', tempOrder)();
5824
+ }
5753
5825
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
5754
- var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params);
5826
+ var updatedProductUid = _this37.applyOrderProductUpdateToTempOrder(tempOrder, params);
5755
5827
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
5756
5828
  if (params.allow_booking_discount_reapply && updatedProductUid) {
5757
5829
  acc.push(String(updatedProductUid));
5758
5830
  }
5759
5831
  return acc;
5760
5832
  }, []);
5761
- _context28.next = 6;
5833
+ _context28.next = 7;
5762
5834
  return this.finalizeAfterProductsMutation(tempOrder, {
5763
5835
  reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
5764
5836
  });
5765
- case 6:
5837
+ case 7:
5766
5838
  this.logInfo('updateOrderProduct success', {
5767
5839
  paramsList: paramsList
5768
5840
  });
5769
5841
  return _context28.abrupt("return", tempOrder.products);
5770
- case 8:
5842
+ case 9:
5771
5843
  case "end":
5772
5844
  return _context28.stop();
5773
5845
  }
@@ -5807,8 +5879,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5807
5879
  if (unique_identification_number !== undefined) {
5808
5880
  targetUid = String(unique_identification_number);
5809
5881
  productIndex = tempOrder.products.findIndex(function (item) {
5810
- var _item$metadata5;
5811
- return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
5882
+ var _item$metadata6;
5883
+ return String(((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number || '') === targetUid;
5812
5884
  });
5813
5885
  }
5814
5886
  if (productIndex === -1) {
@@ -5856,39 +5928,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5856
5928
  }
5857
5929
  throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
5858
5930
  case 27:
5931
+ if (normalizedProduct.num > targetProduct.num) {
5932
+ this.createCartIntentCommitGuard('increase_quantity', tempOrder)();
5933
+ }
5859
5934
  tempOrder.products[productIndex] = normalizedProduct;
5860
5935
  this.prepareVirtualSettlementTempOrder(tempOrder);
5861
5936
  isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
5862
5937
  if (isVirtualSettlement) {
5863
- _context29.next = 36;
5938
+ _context29.next = 37;
5864
5939
  break;
5865
5940
  }
5866
- _context29.next = 33;
5941
+ _context29.next = 34;
5867
5942
  return this.evaluatePromotion();
5868
- case 33:
5943
+ case 34:
5869
5944
  _context29.t0 = _context29.sent;
5870
- _context29.next = 37;
5945
+ _context29.next = 38;
5871
5946
  break;
5872
- case 36:
5873
- _context29.t0 = null;
5874
5947
  case 37:
5948
+ _context29.t0 = null;
5949
+ case 38:
5875
5950
  promotionPayload = _context29.t0;
5876
5951
  if (!isVirtualSettlement) {
5877
5952
  this.applyDiscount();
5878
5953
  }
5879
5954
  this.sanitizeTempOrderProducts(tempOrder);
5880
- _context29.next = 42;
5955
+ _context29.next = 43;
5881
5956
  return this.recalculateSummary({
5882
5957
  createIfMissing: true
5883
5958
  });
5884
- case 42:
5959
+ case 43:
5885
5960
  this.persistTempOrder();
5886
5961
  this.emitPromotionApplied(promotionPayload);
5887
5962
  this.logInfo('updateOrderProductQuantity success', {
5888
5963
  params: params
5889
5964
  });
5890
5965
  return _context29.abrupt("return", tempOrder.products);
5891
- case 46:
5966
+ case 47:
5892
5967
  case "end":
5893
5968
  return _context29.stop();
5894
5969
  }
@@ -5978,7 +6053,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5978
6053
  key: "removeProductsFromOrder",
5979
6054
  value: (function () {
5980
6055
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
5981
- var _this37 = this;
6056
+ var _this38 = this;
5982
6057
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
5983
6058
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5984
6059
  while (1) switch (_context32.prev = _context32.next) {
@@ -5997,8 +6072,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5997
6072
  bookingsBeforeRemove = tempOrder.bookings || [];
5998
6073
  preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
5999
6074
  anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
6000
- var _item$metadata6;
6001
- var uid = ((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number;
6075
+ var _item$metadata7;
6076
+ var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
6002
6077
  return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
6003
6078
  }) : -1;
6004
6079
  productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
@@ -6043,7 +6118,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6043
6118
  }
6044
6119
  if (productUid !== undefined && productUid !== null && productUid !== '') {
6045
6120
  bookingsBeforeRemove.forEach(function (booking) {
6046
- var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
6121
+ var bookingUid = _this38.getBookingUniqueIdentificationNumber(booking);
6047
6122
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
6048
6123
  linkedBookingUidsToRemove.add(bookingUid);
6049
6124
  }
@@ -6094,8 +6169,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6094
6169
  }
6095
6170
  if (preserveDisplayPosition && anchorIndex >= 0) {
6096
6171
  remainingProductIndex = tempOrder.products.findIndex(function (item) {
6097
- var _item$metadata7;
6098
- var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
6172
+ var _item$metadata8;
6173
+ var uid = ((_item$metadata8 = item.metadata) === null || _item$metadata8 === void 0 ? void 0 : _item$metadata8.unique_identification_number) || item.unique_identification_number;
6099
6174
  return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
6100
6175
  });
6101
6176
  if (remainingProductIndex >= 0) {
@@ -6675,10 +6750,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6675
6750
  value: function extractSubmitErrorResponse(error) {
6676
6751
  var _error$response,
6677
6752
  _error$response2,
6678
- _this38 = this;
6753
+ _this39 = this;
6679
6754
  var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
6680
6755
  return candidates.find(function (candidate) {
6681
- return _this38.isSubmitErrorResponse(candidate);
6756
+ return _this39.isSubmitErrorResponse(candidate);
6682
6757
  }) || null;
6683
6758
  }
6684
6759
  }, {
@@ -6706,7 +6781,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6706
6781
  key: "syncPaymentsToOrder",
6707
6782
  value: function () {
6708
6783
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6709
- var _this39 = this,
6784
+ var _this40 = this,
6710
6785
  _params$confirmPendin;
6711
6786
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
6712
6787
  return _regeneratorRuntime().wrap(function _callee39$(_context42) {
@@ -6731,7 +6806,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6731
6806
  case 9:
6732
6807
  devicePrefix = _context42.t0;
6733
6808
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
6734
- return _this39.normalizePaymentSource(payment, {
6809
+ return _this40.normalizePaymentSource(payment, {
6735
6810
  defaultPaid: false,
6736
6811
  devicePrefix: devicePrefix
6737
6812
  });
@@ -6810,7 +6885,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6810
6885
  }, {
6811
6886
  key: "createOrder",
6812
6887
  value: function createOrder(params) {
6813
- var _this40 = this;
6888
+ var _this41 = this;
6814
6889
  var order = _objectSpread({
6815
6890
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
6816
6891
  // 要从外面拿,virtual
@@ -6842,7 +6917,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6842
6917
 
6843
6918
  // 为预约补齐 holder 信息
6844
6919
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
6845
- ensureCartItemOriginHolder(item, _this40.window);
6920
+ ensureCartItemOriginHolder(item, _this41.window);
6846
6921
  }
6847
6922
 
6848
6923
  // 购物车是否为普通商品
@@ -7241,12 +7316,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7241
7316
  params.forceRemote = false;
7242
7317
  }
7243
7318
  _context49.next = 6;
7244
- return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
7245
- with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'order_meta_list', 'refunds', 'notes']
7246
- }, params.forceRemote ? {
7247
- forceRemote: true
7248
- } : {}), {
7249
- osServer: true
7319
+ return loadSalesOrderSnapshot(this.request, {
7320
+ lookup: lookup,
7321
+ transport: 'os-server',
7322
+ forceRemote: params.forceRemote
7250
7323
  });
7251
7324
  case 6:
7252
7325
  res = _context49.sent;
@@ -7545,7 +7618,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7545
7618
  }, {
7546
7619
  key: "normalizeTempOrderForRuntime",
7547
7620
  value: function normalizeTempOrderForRuntime(raw, options) {
7548
- var _this41 = this,
7621
+ var _this42 = this,
7549
7622
  _raw$_extend;
7550
7623
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
7551
7624
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -7570,12 +7643,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7570
7643
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
7571
7644
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
7572
7645
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
7573
- return _this41.normalizeHydratedOrderProduct(p, {
7646
+ return _this42.normalizeHydratedOrderProduct(p, {
7574
7647
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
7575
7648
  });
7576
7649
  }) : [];
7577
7650
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
7578
- var booking = _this41.normalizeHydratedBookingHolder(b || {});
7651
+ var booking = _this42.normalizeHydratedBookingHolder(b || {});
7579
7652
  return _objectSpread(_objectSpread({}, booking), {}, {
7580
7653
  is_all: normalizeBookingIsAll(booking),
7581
7654
  sub_type: normalizeBookingSubType(booking)
@@ -7782,7 +7855,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7782
7855
  }, {
7783
7856
  key: "normalizeHydratedOrderProduct",
7784
7857
  value: function normalizeHydratedOrderProduct(product, options) {
7785
- var _this42 = this;
7858
+ var _this43 = this;
7786
7859
  var row = _objectSpread({}, product || {});
7787
7860
  if (row.num === undefined && row.product_quantity !== undefined) {
7788
7861
  row.num = row.product_quantity;
@@ -7790,7 +7863,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7790
7863
  var productSku = ensureProductSku(row);
7791
7864
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
7792
7865
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
7793
- return _this42.normalizeHydratedProductOptionItem(optionItem || {});
7866
+ return _this43.normalizeHydratedProductOptionItem(optionItem || {});
7794
7867
  }))
7795
7868
  });
7796
7869
  delete row["product_".concat('option', "_item")];