@pisell/pisellos 0.10.50 → 0.10.52

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 (64) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  3. package/dist/modules/FulfillmentTiming/index.js +407 -0
  4. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  5. package/dist/modules/FulfillmentTiming/types.js +1 -0
  6. package/dist/modules/OpenData/types.d.ts +6 -0
  7. package/dist/modules/Order/index.d.ts +18 -1
  8. package/dist/modules/Order/index.js +322 -195
  9. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  10. package/dist/modules/Order/pickupTiming.js +53 -0
  11. package/dist/modules/Order/types.d.ts +11 -1
  12. package/dist/modules/Order/utils.d.ts +10 -0
  13. package/dist/modules/Order/utils.js +145 -85
  14. package/dist/modules/Rules/index.js +3 -2
  15. package/dist/modules/Schedule/index.d.ts +8 -0
  16. package/dist/modules/Schedule/index.js +134 -37
  17. package/dist/modules/index.d.ts +1 -0
  18. package/dist/modules/index.js +1 -0
  19. package/dist/server/modules/order/index.d.ts +8 -0
  20. package/dist/server/modules/order/index.js +506 -453
  21. package/dist/server/modules/order/types.d.ts +1 -0
  22. package/dist/server/utils/small-ticket.js +165 -94
  23. package/dist/solution/BaseSales/index.d.ts +24 -0
  24. package/dist/solution/BaseSales/index.js +1231 -1037
  25. package/dist/solution/BaseSales/pickupTiming.d.ts +43 -0
  26. package/dist/solution/BaseSales/pickupTiming.js +589 -0
  27. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  28. package/dist/solution/BookingByStep/index.d.ts +1 -1
  29. package/dist/solution/BookingTicket/index.d.ts +2 -2
  30. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  31. package/dist/solution/UnifiedBookingSales/index.d.ts +13 -4
  32. package/dist/solution/UnifiedBookingSales/index.js +873 -708
  33. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  34. package/lib/modules/FulfillmentTiming/index.js +359 -0
  35. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  36. package/lib/modules/FulfillmentTiming/types.js +5 -0
  37. package/lib/modules/OpenData/types.d.ts +6 -0
  38. package/lib/modules/Order/index.d.ts +18 -1
  39. package/lib/modules/Order/index.js +101 -3
  40. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  41. package/lib/modules/Order/pickupTiming.js +61 -0
  42. package/lib/modules/Order/types.d.ts +11 -1
  43. package/lib/modules/Order/utils.d.ts +10 -0
  44. package/lib/modules/Order/utils.js +58 -4
  45. package/lib/modules/Rules/index.js +3 -2
  46. package/lib/modules/Schedule/index.d.ts +8 -0
  47. package/lib/modules/Schedule/index.js +64 -11
  48. package/lib/modules/index.d.ts +1 -0
  49. package/lib/modules/index.js +11 -0
  50. package/lib/server/modules/order/index.d.ts +8 -0
  51. package/lib/server/modules/order/index.js +19 -0
  52. package/lib/server/modules/order/types.d.ts +1 -0
  53. package/lib/server/utils/small-ticket.js +86 -22
  54. package/lib/solution/BaseSales/index.d.ts +24 -0
  55. package/lib/solution/BaseSales/index.js +109 -1
  56. package/lib/solution/BaseSales/pickupTiming.d.ts +43 -0
  57. package/lib/solution/BaseSales/pickupTiming.js +269 -0
  58. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  59. package/lib/solution/BookingByStep/index.d.ts +1 -1
  60. package/lib/solution/BookingTicket/index.d.ts +2 -2
  61. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  62. package/lib/solution/UnifiedBookingSales/index.d.ts +13 -4
  63. package/lib/solution/UnifiedBookingSales/index.js +130 -46
  64. package/package.json +1 -1
@@ -32,8 +32,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
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
33
  import { BaseModule } from "../BaseModule";
34
34
  import { OrderHooks } from "./types";
35
- 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, buildPointCardSnapshotFromWalletPassList, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
35
+ 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";
36
36
  import { isNormalProduct } from "../Product/utils";
37
+ import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
37
38
  import dayjs from 'dayjs';
38
39
  import { getDiscountLifecycleReason } from "../Discount/availability";
39
40
  import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
@@ -170,6 +171,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
170
171
  _defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
171
172
  /** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
172
173
  _defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
174
+ /** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
175
+ _defineProperty(_assertThisInitialized(_this), "pointCardSnapshotCodeCandidates", new Map());
173
176
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
174
177
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
175
178
  _defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
@@ -1716,9 +1719,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1716
1719
  key: "clearCustomerWalletRuntimeState",
1717
1720
  value: function clearCustomerWalletRuntimeState() {
1718
1721
  this.customerWalletPrepareConfigEpoch += 1;
1722
+ this.pointCardSnapshotCodeCandidates.clear();
1719
1723
  this.store.availableWalletIds = [];
1720
1724
  this.store.virtualCurrencyList = [];
1721
1725
  }
1726
+ }, {
1727
+ key: "rememberPointCardSnapshotCodeCandidates",
1728
+ value: function rememberPointCardSnapshotCodeCandidates(value) {
1729
+ var _this6 = this;
1730
+ collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
1731
+ var id = _ref18.id,
1732
+ code = _ref18.code;
1733
+ if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
1734
+ _this6.pointCardSnapshotCodeCandidates.set(id, code);
1735
+ }
1736
+ });
1737
+ }
1738
+ }, {
1739
+ key: "getRememberedPointCardSnapshotCodeCandidates",
1740
+ value: function getRememberedPointCardSnapshotCodeCandidates() {
1741
+ return _toConsumableArray(this.pointCardSnapshotCodeCandidates).map(function (_ref19) {
1742
+ var _ref20 = _slicedToArray(_ref19, 2),
1743
+ id = _ref20[0],
1744
+ code = _ref20[1];
1745
+ return {
1746
+ id: id,
1747
+ code: code
1748
+ };
1749
+ });
1750
+ }
1751
+ }, {
1752
+ key: "getPointCardSnapshotOrderIdentityKey",
1753
+ value: function getPointCardSnapshotOrderIdentityKey(identity) {
1754
+ if (identity !== null && identity !== void 0 && identity.externalSaleNumber) {
1755
+ return "external:".concat(identity.externalSaleNumber);
1756
+ }
1757
+ if ((identity === null || identity === void 0 ? void 0 : identity.orderId) !== undefined && identity.orderId !== null) {
1758
+ return "order:".concat(identity.orderId);
1759
+ }
1760
+ if (identity !== null && identity !== void 0 && identity.localId) return "local:".concat(identity.localId);
1761
+ if (identity !== null && identity !== void 0 && identity.orderNumber) return "number:".concat(identity.orderNumber);
1762
+ return '';
1763
+ }
1764
+ }, {
1765
+ key: "isPointCardSnapshotMergeContextCurrent",
1766
+ value: function isPointCardSnapshotMergeContextCurrent(context) {
1767
+ var _context$customerId, _this$store$tempOrder4, _this$store$tempOrder5;
1768
+ if (!context) return true;
1769
+ if (context.customerId !== undefined && String((_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '') !== String((_this$store$tempOrder4 = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customer_id) !== null && _this$store$tempOrder4 !== void 0 ? _this$store$tempOrder4 : '')) {
1770
+ return false;
1771
+ }
1772
+ var expectedOrderKey = this.getPointCardSnapshotOrderIdentityKey(context.orderIdentity);
1773
+ return !expectedOrderKey || expectedOrderKey === this.getPointCardSnapshotOrderIdentityKey(this.getOrderIdentity());
1774
+ }
1722
1775
  }, {
1723
1776
  key: "writeCustomerWalletSnapshotsFromPrepareConfig",
1724
1777
  value: function writeCustomerWalletSnapshotsFromPrepareConfig(params) {
@@ -1726,9 +1779,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1726
1779
  var tempOrder = this.store.tempOrder;
1727
1780
  if (!tempOrder) return;
1728
1781
  if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
1782
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
1729
1783
  var virtualCurrencyList = Array.isArray(params.virtualCurrencyList) ? params.virtualCurrencyList : [];
1730
- tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
1731
- point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList),
1784
+ var snapshotsWithExistingCodes = _mergePointCardSnapshotCodes(params.availableWalletPassList, currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot);
1785
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1786
+ point_cards_snapshot: _mergePointCardSnapshotCodes(snapshotsWithExistingCodes, this.getRememberedPointCardSnapshotCodeCandidates()),
1732
1787
  virtual_currency_snapshot: buildVirtualCurrencySnapshotFromList(virtualCurrencyList)
1733
1788
  });
1734
1789
  this.store.availableWalletIds = _toConsumableArray(params.availableWalletIds);
@@ -1736,6 +1791,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1736
1791
  this.persistTempOrder();
1737
1792
  this.saveDraftInBackground();
1738
1793
  }
1794
+
1795
+ /**
1796
+ * 将 Payment WalletPass 返回的实例 code 回填到当前订单 Snapshot。
1797
+ * 这里只按资产 ID 补空值,不新增卡、不覆盖 prepare/config 冻结的余额。
1798
+ */
1799
+ }, {
1800
+ key: "mergePointCardSnapshotCodes",
1801
+ value: function mergePointCardSnapshotCodes(walletPassList, context) {
1802
+ var tempOrder = this.store.tempOrder;
1803
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_meta_list);
1804
+ var currentSnapshots = (currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot) || [];
1805
+ if (!tempOrder || !this.isPointCardSnapshotMergeContextCurrent(context)) {
1806
+ return currentSnapshots;
1807
+ }
1808
+ this.rememberPointCardSnapshotCodeCandidates(walletPassList);
1809
+ if (!currentSnapshots.length) return currentSnapshots;
1810
+ var nextSnapshots = _mergePointCardSnapshotCodes(currentSnapshots, this.getRememberedPointCardSnapshotCodeCandidates());
1811
+ var hasChanged = nextSnapshots.some(function (snapshot, index) {
1812
+ var _currentSnapshots$ind;
1813
+ return snapshot.code !== ((_currentSnapshots$ind = currentSnapshots[index]) === null || _currentSnapshots$ind === void 0 ? void 0 : _currentSnapshots$ind.code);
1814
+ });
1815
+ if (!hasChanged) return currentSnapshots;
1816
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1817
+ point_cards_snapshot: nextSnapshots
1818
+ });
1819
+ this.persistTempOrder();
1820
+ this.saveDraftInBackground();
1821
+ return nextSnapshots;
1822
+ }
1739
1823
  }, {
1740
1824
  key: "createExternalSaleNumber",
1741
1825
  value: function createExternalSaleNumber() {
@@ -1836,15 +1920,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1836
1920
  }, {
1837
1921
  key: "extractOrderIdFromSubmitResult",
1838
1922
  value: function extractOrderIdFromSubmitResult(result) {
1839
- var _ref18, _ref19, _ref20, _result$data$order_id, _result$data, _result$data2;
1840
- return (_ref18 = (_ref19 = (_ref20 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref20 !== void 0 ? _ref20 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref19 !== void 0 ? _ref19 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref18 !== void 0 ? _ref18 : null;
1923
+ var _ref21, _ref22, _ref23, _result$data$order_id, _result$data, _result$data2;
1924
+ return (_ref21 = (_ref22 = (_ref23 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref23 !== void 0 ? _ref23 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref22 !== void 0 ? _ref22 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref21 !== void 0 ? _ref21 : null;
1841
1925
  }
1842
1926
  }, {
1843
1927
  key: "calculatePaymentEffectiveAmount",
1844
1928
  value: function calculatePaymentEffectiveAmount(payment) {
1845
- var _ref21, _payment$origin_amoun;
1929
+ var _ref24, _payment$origin_amoun;
1846
1930
  var amount = new Decimal(payment.amount || 0);
1847
- var originAmount = new Decimal((_ref21 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref21 !== void 0 ? _ref21 : 0);
1931
+ var originAmount = new Decimal((_ref24 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref24 !== void 0 ? _ref24 : 0);
1848
1932
  var serviceFee = new Decimal(payment.service_fee || 0);
1849
1933
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1850
1934
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -1854,23 +1938,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1854
1938
  }, {
1855
1939
  key: "calculatePaymentTotal",
1856
1940
  value: function calculatePaymentTotal(payments) {
1857
- var _this6 = this;
1941
+ var _this7 = this;
1858
1942
  return mapPaymentItemsToOrderPayments(payments, {
1859
1943
  includeVoided: false
1860
1944
  }).reduce(function (sum, payment) {
1861
1945
  if (!isPaidPaymentRecord(payment)) return sum;
1862
- return sum.plus(_this6.calculatePaymentEffectiveAmount(payment));
1946
+ return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
1863
1947
  }, new Decimal(0));
1864
1948
  }
1865
1949
  }, {
1866
1950
  key: "calculateOrderPaidPaymentTotal",
1867
1951
  value: function calculateOrderPaidPaymentTotal(payments) {
1868
- var _this7 = this;
1952
+ var _this8 = this;
1869
1953
  return mapPaymentItemsToOrderPayments(payments, {
1870
1954
  includeVoided: false
1871
1955
  }).reduce(function (sum, payment) {
1872
1956
  if (!isPaidPaymentRecord(payment)) return sum;
1873
- return sum.plus(_this7.calculatePaymentGapAmount(payment));
1957
+ return sum.plus(_this8.calculatePaymentGapAmount(payment));
1874
1958
  }, new Decimal(0));
1875
1959
  }
1876
1960
  }, {
@@ -2006,13 +2090,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2006
2090
  }, {
2007
2091
  key: "calculateDepositPaidAmount",
2008
2092
  value: function calculateDepositPaidAmount(payments) {
2009
- var _this8 = this;
2093
+ var _this9 = this;
2010
2094
  return (payments || []).reduce(function (sum, payment) {
2011
2095
  var paymentRecord = payment;
2012
2096
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
2013
2097
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
2014
2098
  if (!isDepositPayment) return sum;
2015
- return sum.plus(_this8.calculatePaymentGapAmount(paymentRecord));
2099
+ return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
2016
2100
  }, new Decimal(0));
2017
2101
  }
2018
2102
  }, {
@@ -2049,28 +2133,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2049
2133
  }, {
2050
2134
  key: "getPaymentNumberDevicePrefixSync",
2051
2135
  value: function getPaymentNumberDevicePrefixSync() {
2052
- var _this9 = this;
2136
+ var _this10 = this;
2053
2137
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
2054
- return _this9.getPaymentNumberAppData(key);
2138
+ return _this10.getPaymentNumberAppData(key);
2055
2139
  });
2056
2140
  }
2057
2141
  }, {
2058
2142
  key: "getPaymentNumberDevicePrefixAsync",
2059
2143
  value: function getPaymentNumberDevicePrefixAsync() {
2060
- var _this10 = this;
2144
+ var _this11 = this;
2061
2145
  return resolvePaymentNumberDevicePrefix(function (key) {
2062
- return _this10.getPaymentNumberAppData(key);
2146
+ return _this11.getPaymentNumberAppData(key);
2063
2147
  });
2064
2148
  }
2065
2149
  }, {
2066
2150
  key: "normalizePaymentSource",
2067
2151
  value: function normalizePaymentSource(payment, options) {
2068
- var _ref22, _paymentRecord$origin;
2152
+ var _ref25, _paymentRecord$origin;
2069
2153
  var paymentRecord = payment;
2070
2154
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
2071
2155
  var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
2072
2156
  metadata: metadata,
2073
- origin_amount: (_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : '0.00'
2157
+ origin_amount: (_ref25 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref25 !== void 0 ? _ref25 : '0.00'
2074
2158
  }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
2075
2159
  if (paymentRecord.status !== undefined) {
2076
2160
  normalized.status = paymentRecord.status;
@@ -2189,16 +2273,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2189
2273
  }, {
2190
2274
  key: "calculatePaidPaymentSummary",
2191
2275
  value: function calculatePaidPaymentSummary(payments) {
2192
- var _this11 = this;
2276
+ var _this12 = this;
2193
2277
  return (payments || []).reduce(function (summary, payment) {
2194
2278
  var paymentRecord = payment;
2195
2279
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
2196
2280
  return {
2197
2281
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
2198
- orderPaidAmount: summary.orderPaidAmount.plus(_this11.calculatePaymentOrderAmount(paymentRecord)),
2199
- gapPaidAmount: summary.gapPaidAmount.plus(_this11.calculatePaymentGapAmount(paymentRecord)),
2200
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this11.calculatePaymentServiceFee(paymentRecord)),
2201
- roundingAmount: summary.roundingAmount.plus(_this11.calculatePaymentRoundingAmount(paymentRecord))
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))
2202
2286
  };
2203
2287
  }, {
2204
2288
  customerPaidAmount: new Decimal(0),
@@ -2405,15 +2489,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2405
2489
  }, {
2406
2490
  key: "normalizeFingerprintValue",
2407
2491
  value: function normalizeFingerprintValue(value) {
2408
- var _this12 = this;
2492
+ var _this13 = this;
2409
2493
  if (Array.isArray(value)) {
2410
2494
  return value.map(function (item) {
2411
- return _this12.normalizeFingerprintValue(item);
2495
+ return _this13.normalizeFingerprintValue(item);
2412
2496
  });
2413
2497
  }
2414
2498
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
2415
2499
  return Object.keys(value).sort().reduce(function (result, key) {
2416
- result[key] = _this12.normalizeFingerprintValue(value[key]);
2500
+ result[key] = _this13.normalizeFingerprintValue(value[key]);
2417
2501
  return result;
2418
2502
  }, {});
2419
2503
  }
@@ -2426,9 +2510,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2426
2510
  _product$payment_pric,
2427
2511
  _sku$code,
2428
2512
  _sku$barcode,
2429
- _ref23,
2513
+ _ref26,
2430
2514
  _sku$variant_id,
2431
- _this13 = this;
2515
+ _this14 = this;
2432
2516
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2433
2517
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2434
2518
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2456,37 +2540,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2456
2540
  product_sku: this.normalizeFingerprintValue({
2457
2541
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
2458
2542
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
2459
- variant_id: (_ref23 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref23 !== void 0 ? _ref23 : 0,
2543
+ variant_id: (_ref26 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref26 !== void 0 ? _ref26 : 0,
2460
2544
  variant: sku.variant || [],
2461
2545
  option: getProductSkuOptions(product || {}).map(function (option) {
2462
- var _ref24, _option$id, _option$option_group_, _ref25, _option$option_group_2, _option$num, _option$add_price;
2546
+ var _ref27, _option$id, _option$option_group_, _ref28, _option$option_group_2, _option$num, _option$add_price;
2463
2547
  return {
2464
- id: (_ref24 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref24 !== void 0 ? _ref24 : null,
2548
+ id: (_ref27 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref27 !== void 0 ? _ref27 : null,
2465
2549
  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,
2466
- option_group_item_id: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : null,
2550
+ 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,
2467
2551
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2468
- add_price: _this13.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)
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)
2469
2553
  };
2470
2554
  })
2471
2555
  }),
2472
2556
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2473
- var _ref26, _ref27, _bundle$bundle_produc, _ref28, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2557
+ var _ref29, _ref30, _bundle$bundle_produc, _ref31, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2474
2558
  return {
2475
- bundle_product_id: (_ref26 = (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref26 !== void 0 ? _ref26 : null,
2476
- bundle_variant_id: (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : 0,
2559
+ 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
+ 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,
2477
2561
  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),
2478
- price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2479
- bundle_selling_price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
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),
2480
2564
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
2481
2565
  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 : ''
2482
2566
  };
2483
2567
  })),
2484
2568
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2485
- var _ref29, _discount$type2, _ref30, _ref31, _discount$discount_id, _discount$discount;
2569
+ var _ref32, _discount$type2, _ref33, _ref34, _discount$discount_id, _discount$discount;
2486
2570
  return {
2487
- type: (_ref29 = (_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 && _ref29 !== void 0 ? _ref29 : '',
2488
- discount_id: (_ref30 = (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref30 !== void 0 ? _ref30 : null,
2489
- amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2571
+ 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
+ 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)
2490
2574
  };
2491
2575
  }))
2492
2576
  };
@@ -2494,9 +2578,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2494
2578
  }, {
2495
2579
  key: "buildOrderProductsFingerprint",
2496
2580
  value: function buildOrderProductsFingerprint(products) {
2497
- var _this14 = this;
2581
+ var _this15 = this;
2498
2582
  var items = (products || []).map(function (product) {
2499
- return _this14.buildProductFingerprintItem(product);
2583
+ return _this15.buildProductFingerprintItem(product);
2500
2584
  });
2501
2585
  items.sort(function (left, right) {
2502
2586
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2509,16 +2593,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2509
2593
  var _product$product_id3,
2510
2594
  _product$product_vari2,
2511
2595
  _product$num2,
2512
- _ref32,
2596
+ _ref35,
2513
2597
  _metadata$unique_iden,
2514
2598
  _metadata$price_overr,
2515
2599
  _metadata$is_manual_d,
2516
2600
  _metadata$product_dis,
2517
2601
  _sku$code2,
2518
2602
  _sku$barcode2,
2519
- _ref33,
2603
+ _ref36,
2520
2604
  _sku$variant_id2,
2521
- _this15 = this;
2605
+ _this16 = this;
2522
2606
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2523
2607
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2524
2608
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2535,7 +2619,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2535
2619
  extension_type: extensionType,
2536
2620
  num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
2537
2621
  metadata: {
2538
- unique_identification_number: (_ref32 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref32 !== void 0 ? _ref32 : '',
2622
+ unique_identification_number: (_ref35 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref35 !== void 0 ? _ref35 : '',
2539
2623
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
2540
2624
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
2541
2625
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -2543,47 +2627,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2543
2627
  product_sku: this.normalizeFingerprintValue({
2544
2628
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
2545
2629
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
2546
- variant_id: (_ref33 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref33 !== void 0 ? _ref33 : 0,
2630
+ variant_id: (_ref36 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
2547
2631
  variant: sku.variant || [],
2548
2632
  option: getProductSkuOptions(product || {}).map(function (option) {
2549
- var _ref34, _option$id2, _option$option_group_3, _ref35, _option$option_group_4, _option$num2, _option$add_price2;
2633
+ var _ref37, _option$id2, _option$option_group_3, _ref38, _option$option_group_4, _option$num2, _option$add_price2;
2550
2634
  return {
2551
- id: (_ref34 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref34 !== void 0 ? _ref34 : null,
2635
+ id: (_ref37 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref37 !== void 0 ? _ref37 : null,
2552
2636
  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,
2553
- option_group_item_id: (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : null,
2637
+ 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,
2554
2638
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2555
- add_price: _this15.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)
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)
2556
2640
  };
2557
2641
  })
2558
2642
  }),
2559
2643
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2560
- var _ref36, _bundle$bundle_id, _ref37, _bundle$bundle_group_, _ref38, _ref39, _bundle$bundle_produc2, _ref40, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2644
+ var _ref39, _bundle$bundle_id, _ref40, _bundle$bundle_group_, _ref41, _ref42, _bundle$bundle_produc2, _ref43, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
2561
2645
  return {
2562
- bundle_id: (_ref36 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref36 !== void 0 ? _ref36 : null,
2563
- bundle_group_id: (_ref37 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref37 !== void 0 ? _ref37 : null,
2564
- bundle_product_id: (_ref38 = (_ref39 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref39 !== void 0 ? _ref39 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref38 !== void 0 ? _ref38 : null,
2565
- bundle_variant_id: (_ref40 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref40 !== void 0 ? _ref40 : 0,
2646
+ bundle_id: (_ref39 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref39 !== void 0 ? _ref39 : null,
2647
+ bundle_group_id: (_ref40 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref40 !== void 0 ? _ref40 : null,
2648
+ bundle_product_id: (_ref41 = (_ref42 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref42 !== void 0 ? _ref42 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref41 !== void 0 ? _ref41 : null,
2649
+ bundle_variant_id: (_ref43 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref43 !== void 0 ? _ref43 : 0,
2566
2650
  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),
2567
2651
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2568
2652
  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 : '',
2569
- option: _this15.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2570
- var _ref41, _option$id3, _option$option_group_5, _ref42, _option$option_group_6, _option$num3, _option$add_price3;
2653
+ option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2654
+ var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
2571
2655
  return {
2572
- id: (_ref41 = (_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 && _ref41 !== void 0 ? _ref41 : null,
2656
+ 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,
2573
2657
  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,
2574
- option_group_item_id: (_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : null,
2658
+ 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,
2575
2659
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2576
- add_price: _this15.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)
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)
2577
2661
  };
2578
2662
  }))
2579
2663
  };
2580
2664
  })),
2581
2665
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2582
- var _ref43, _discount$type4, _ref44, _ref45, _discount$discount_id2, _discount$discount2;
2666
+ var _ref46, _discount$type4, _ref47, _ref48, _discount$discount_id2, _discount$discount2;
2583
2667
  return {
2584
- type: (_ref43 = (_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 && _ref43 !== void 0 ? _ref43 : '',
2585
- discount_id: (_ref44 = (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref44 !== void 0 ? _ref44 : null,
2586
- amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2668
+ 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
+ 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)
2587
2671
  };
2588
2672
  }))
2589
2673
  };
@@ -2591,9 +2675,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2591
2675
  }, {
2592
2676
  key: "buildOrderProductsStructuralFingerprint",
2593
2677
  value: function buildOrderProductsStructuralFingerprint(products) {
2594
- var _this16 = this;
2678
+ var _this17 = this;
2595
2679
  var items = (products || []).map(function (product) {
2596
- return _this16.buildProductStructuralFingerprintItem(product);
2680
+ return _this17.buildProductStructuralFingerprintItem(product);
2597
2681
  });
2598
2682
  items.sort(function (left, right) {
2599
2683
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2909,11 +2993,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2909
2993
  }, {
2910
2994
  key: "getOrderIdentity",
2911
2995
  value: function getOrderIdentity() {
2912
- var _ref46, _ref47, _tempOrder$order_id, _tempOrder$_extend7;
2996
+ var _ref49, _ref50, _tempOrder$order_id, _tempOrder$_extend7;
2913
2997
  var tempOrder = this.store.tempOrder;
2914
2998
  if (!tempOrder) return null;
2915
2999
  var lastOrderInfo = this.store.lastOrderInfo || {};
2916
- var orderId = (_ref46 = (_ref47 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref47 !== void 0 ? _ref47 : lastOrderInfo.id) !== null && _ref46 !== void 0 ? _ref46 : null;
3000
+ var orderId = (_ref49 = (_ref50 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref50 !== void 0 ? _ref50 : lastOrderInfo.id) !== null && _ref49 !== void 0 ? _ref49 : null;
2917
3001
  return {
2918
3002
  localId: this.cacheId || ((_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.localId),
2919
3003
  orderId: orderId,
@@ -3045,9 +3129,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3045
3129
  }, {
3046
3130
  key: "sanitizeTempOrderProducts",
3047
3131
  value: function sanitizeTempOrderProducts(tempOrder) {
3048
- var _this17 = this;
3132
+ var _this18 = this;
3049
3133
  tempOrder.products = (tempOrder.products || []).map(function (product) {
3050
- return _this17.sanitizeOrderProductForTempOrder(_this17.normalizeVirtualSettlementProductIfEnabled(product));
3134
+ return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
3051
3135
  });
3052
3136
  this.syncTempOrderSettlementState(tempOrder);
3053
3137
  ensureUniqueProductLineUids(tempOrder);
@@ -3083,11 +3167,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3083
3167
  }, {
3084
3168
  key: "captureProductRuntime",
3085
3169
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
3086
- var _extend$productsByUid, _ref48, _rawProduct$_origin;
3170
+ var _extend$productsByUid, _ref51, _rawProduct$_origin;
3087
3171
  var uid = existedUid || this.getProductUid(normalizedProduct);
3088
3172
  var extend = this.ensureExtend(tempOrder);
3089
3173
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
3090
- var origin = (_ref48 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref48 !== void 0 ? _ref48 : existed.origin;
3174
+ var origin = (_ref51 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref51 !== void 0 ? _ref51 : existed.origin;
3091
3175
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
3092
3176
  origin: origin
3093
3177
  } : {});
@@ -3167,7 +3251,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3167
3251
  }, {
3168
3252
  key: "syncLinkedBookingHoldersToProducts",
3169
3253
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
3170
- var _this18 = this;
3254
+ var _this19 = this;
3171
3255
  var bookings = tempOrder.bookings || [];
3172
3256
  var products = tempOrder.products || [];
3173
3257
  if (!bookings.length || !products.length) return;
@@ -3176,6 +3260,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3176
3260
  bookings.forEach(function (booking) {
3177
3261
  var _booking$metadata2, _booking$metadata3;
3178
3262
  if (!booking || _typeof(booking) !== 'object') return;
3263
+ if (isFulfillmentTimingBooking(booking)) return;
3179
3264
  var productUid = booking.product_uid || ((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid);
3180
3265
  if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
3181
3266
  bookingByProductUid.set(String(productUid), booking);
@@ -3192,7 +3277,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3192
3277
  var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
3193
3278
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
3194
3279
  if (linkedBooking) {
3195
- _this18.setProductHolderFromBooking(product, linkedBooking);
3280
+ _this19.setProductHolderFromBooking(product, linkedBooking);
3196
3281
  }
3197
3282
  });
3198
3283
  }
@@ -3230,7 +3315,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3230
3315
  }, {
3231
3316
  key: "buildTempOrderHolderFromBookings",
3232
3317
  value: function buildTempOrderHolderFromBookings(tempOrder) {
3233
- var _baseHolder$customer_, _baseHolder, _ref49, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3318
+ var _baseHolder$customer_, _baseHolder, _ref52, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3234
3319
  var holderRecords = [];
3235
3320
  var holderNames = [];
3236
3321
  var baseHolder = null;
@@ -3240,6 +3325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3240
3325
  try {
3241
3326
  for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
3242
3327
  var booking = _step18.value;
3328
+ if (isFulfillmentTimingBooking(booking)) continue;
3243
3329
  var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
3244
3330
  if (!baseHolder && holder) {
3245
3331
  baseHolder = holder;
@@ -3277,7 +3363,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3277
3363
  }
3278
3364
  var nextHolder = {
3279
3365
  customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
3280
- form_id: (_ref49 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref49 !== void 0 ? _ref49 : 0,
3366
+ form_id: (_ref52 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref52 !== void 0 ? _ref52 : 0,
3281
3367
  form_record: holderRecords
3282
3368
  };
3283
3369
  if (holderNames.length) {
@@ -3298,7 +3384,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3298
3384
  }, {
3299
3385
  key: "syncTempOrderHolderFromBookings",
3300
3386
  value: function syncTempOrderHolderFromBookings(tempOrder) {
3301
- var bookings = tempOrder.bookings || [];
3387
+ var bookings = (tempOrder.bookings || []).filter(function (booking) {
3388
+ return !isFulfillmentTimingBooking(booking);
3389
+ });
3302
3390
  var hasHolderSource = bookings.some(function (booking) {
3303
3391
  var _booking$metadata4;
3304
3392
  return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata4 = booking.metadata) === null || _booking$metadata4 === void 0 ? void 0 : _booking$metadata4.holder_id) !== undefined;
@@ -3320,9 +3408,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3320
3408
  }, {
3321
3409
  key: "findBookingIndexByUniqueIdentificationNumber",
3322
3410
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
3323
- var _this19 = this;
3411
+ var _this20 = this;
3324
3412
  return (tempOrder.bookings || []).findIndex(function (booking) {
3325
- return _this19.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3413
+ return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3326
3414
  });
3327
3415
  }
3328
3416
  }, {
@@ -3330,12 +3418,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3330
3418
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
3331
3419
  var _product$metadata5,
3332
3420
  _product$metadata6,
3333
- _this20 = this;
3421
+ _this21 = this;
3334
3422
  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);
3335
3423
  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);
3336
3424
  if (!productUid && !bookingUid) return;
3337
3425
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
3338
- var currentBookingUid = _this20.getBookingUniqueIdentificationNumber(booking);
3426
+ if (isFulfillmentTimingBooking(booking)) return true;
3427
+ var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
3339
3428
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
3340
3429
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
3341
3430
  return true;
@@ -3382,7 +3471,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3382
3471
  key: "recalculateSummary",
3383
3472
  value: function () {
3384
3473
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
3385
- var _this$otherParams3, _ref50, _salesSummaryResult$e;
3474
+ var _this$otherParams3, _ref53, _salesSummaryResult$e;
3386
3475
  var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
3387
3476
  return _regeneratorRuntime().wrap(function _callee13$(_context15) {
3388
3477
  while (1) switch (_context15.prev = _context15.next) {
@@ -3461,7 +3550,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3461
3550
  roundingAmount = paidPaymentSummary.roundingAmount;
3462
3551
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
3463
3552
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
3464
- expectAmount = hasSalesSummaryAmount ? new Decimal((_ref50 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref50 !== void 0 ? _ref50 : 0) : null;
3553
+ expectAmount = hasSalesSummaryAmount ? new Decimal((_ref53 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref53 !== void 0 ? _ref53 : 0) : null;
3465
3554
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
3466
3555
  rounding_amount: roundingAmount.toFixed(2)
3467
3556
  }, expectAmount ? {
@@ -3584,8 +3673,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3584
3673
  }, {
3585
3674
  key: "getTempOrderNote",
3586
3675
  value: function getTempOrderNote() {
3587
- var _this$store$tempOrder4;
3588
- return ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.note) || '';
3676
+ var _this$store$tempOrder6;
3677
+ return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.note) || '';
3589
3678
  }
3590
3679
  }, {
3591
3680
  key: "ensureSalesNotesRuntimeState",
@@ -3637,7 +3726,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3637
3726
  }, {
3638
3727
  key: "removeSalesNotesForMissingProductLines",
3639
3728
  value: function removeSalesNotesForMissingProductLines(tempOrder) {
3640
- var _this21 = this;
3729
+ var _this22 = this;
3641
3730
  var state = this.ensureSalesNotesRuntimeState(tempOrder);
3642
3731
  if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3643
3732
  return;
@@ -3649,7 +3738,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3649
3738
  return typeof uid === 'string' && uid.length > 0;
3650
3739
  }));
3651
3740
  var nextNotes = tempOrder.notes.filter(function (note) {
3652
- var primary = _this21.getSalesNotePrimaryRelation(note);
3741
+ var primary = _this22.getSalesNotePrimaryRelation(note);
3653
3742
  if (!primary || primary.target_type !== 'order_detail') return true;
3654
3743
  return remainingProductUids.has(primary.target_uuid);
3655
3744
  });
@@ -3661,7 +3750,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3661
3750
  key: "setSalesNoteOnTempOrder",
3662
3751
  value: function setSalesNoteOnTempOrder(tempOrder, input) {
3663
3752
  var _input$target,
3664
- _this22 = this,
3753
+ _this23 = this,
3665
3754
  _tempOrder$shop_order;
3666
3755
  this.ensureSalesNotesLoadedForMutation(tempOrder);
3667
3756
  var note_type = String(input.note_type || '').trim();
@@ -3685,7 +3774,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3685
3774
  var notes = tempOrder.notes || [];
3686
3775
  // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3687
3776
  var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3688
- var primary = _this22.getSalesNotePrimaryRelation(note);
3777
+ var primary = _this23.getSalesNotePrimaryRelation(note);
3689
3778
  return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3690
3779
  }) : -1;
3691
3780
  var existing = existingIndex >= 0 ? notes[existingIndex] : null;
@@ -3922,10 +4011,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3922
4011
  }, {
3923
4012
  key: "updateTempOrderServiceType",
3924
4013
  value: function updateTempOrderServiceType(serviceType) {
4014
+ if (serviceType !== 'pick_up') {
4015
+ var tempOrder = this.ensureTempOrder();
4016
+ tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
4017
+ return !isFulfillmentTimingBooking(booking);
4018
+ });
4019
+ }
3925
4020
  return this.updateTempOrderShopServiceData({
3926
4021
  service_type: serviceType
3927
4022
  });
3928
4023
  }
4024
+ }, {
4025
+ key: "getPickupTimingBooking",
4026
+ value: function getPickupTimingBooking() {
4027
+ var _this$store$tempOrder7;
4028
+ return (((_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.bookings) || []).find(isFulfillmentTimingBooking) || null;
4029
+ }
4030
+ }, {
4031
+ key: "setPickupTimingBooking",
4032
+ value: function setPickupTimingBooking(input) {
4033
+ var tempOrder = this.ensureTempOrder();
4034
+ var bookings = tempOrder.bookings || [];
4035
+ var firstIndex = bookings.findIndex(isFulfillmentTimingBooking);
4036
+ var nextBooking = buildPickupTimingBooking(input, bookings[firstIndex]);
4037
+ // Keep the first row's identity and position; repair duplicate marked rows only.
4038
+ tempOrder.bookings = firstIndex === -1 ? [].concat(_toConsumableArray(bookings), [nextBooking]) : bookings.flatMap(function (booking, index) {
4039
+ return index === firstIndex ? [nextBooking] : isFulfillmentTimingBooking(booking) ? [] : [booking];
4040
+ });
4041
+ this.notifyTempOrderChanged();
4042
+ return nextBooking;
4043
+ }
4044
+ }, {
4045
+ key: "clearPickupTimingBooking",
4046
+ value: function clearPickupTimingBooking() {
4047
+ var _tempOrder$bookings;
4048
+ var tempOrder = this.store.tempOrder;
4049
+ if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.some(isFulfillmentTimingBooking))) return;
4050
+ tempOrder.bookings = tempOrder.bookings.filter(function (booking) {
4051
+ return !isFulfillmentTimingBooking(booking);
4052
+ });
4053
+ this.notifyTempOrderChanged();
4054
+ }
3929
4055
  }, {
3930
4056
  key: "updateTempOrderContactsInfo",
3931
4057
  value: function updateTempOrderContactsInfo(contactsInfo) {
@@ -3937,17 +4063,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3937
4063
  }, {
3938
4064
  key: "buildTempOrderCustomer",
3939
4065
  value: function buildTempOrderCustomer(params) {
3940
- var _ref51, _ref52, _ref53, _source$name, _ref54, _ref55, _ref56, _source$customer_name, _source$id, _source$customer_id, _ref57, _source$country_calli, _source$phone, _source$email;
4066
+ var _ref54, _ref55, _ref56, _source$name, _ref57, _ref58, _ref59, _source$customer_name, _source$id, _source$customer_id, _ref60, _source$country_calli, _source$phone, _source$email;
3941
4067
  if (!params.customerId) return null;
3942
4068
  var source = params.source ? cloneDeep(params.source) : {};
3943
- var name = (_ref51 = (_ref52 = (_ref53 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref53 !== void 0 ? _ref53 : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.customer_name) !== null && _ref51 !== void 0 ? _ref51 : params.customerName;
3944
- var customerName = (_ref54 = (_ref55 = (_ref56 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref56 !== void 0 ? _ref56 : source.display_name) !== null && _ref55 !== void 0 ? _ref55 : source.name) !== null && _ref54 !== void 0 ? _ref54 : params.customerName;
4069
+ var name = (_ref54 = (_ref55 = (_ref56 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref56 !== void 0 ? _ref56 : source.customerName) !== null && _ref55 !== void 0 ? _ref55 : source.customer_name) !== null && _ref54 !== void 0 ? _ref54 : params.customerName;
4070
+ var customerName = (_ref57 = (_ref58 = (_ref59 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref59 !== void 0 ? _ref59 : source.display_name) !== null && _ref58 !== void 0 ? _ref58 : source.name) !== null && _ref57 !== void 0 ? _ref57 : params.customerName;
3945
4071
  return _objectSpread(_objectSpread({}, source), {}, {
3946
4072
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
3947
4073
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
3948
4074
  name: String(name || ''),
3949
4075
  customer_name: String(customerName || ''),
3950
- country_calling_code: String((_ref57 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref57 !== void 0 ? _ref57 : params.countryCallingCode),
4076
+ country_calling_code: String((_ref60 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : params.countryCallingCode),
3951
4077
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
3952
4078
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
3953
4079
  });
@@ -3967,15 +4093,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3967
4093
  }, {
3968
4094
  key: "productHasCustomerBoundDiscount",
3969
4095
  value: function productHasCustomerBoundDiscount(product) {
3970
- var _this23 = this;
4096
+ var _this24 = this;
3971
4097
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3972
- return _this23.isCustomerBoundDiscount(discount);
4098
+ return _this24.isCustomerBoundDiscount(discount);
3973
4099
  })) {
3974
4100
  return true;
3975
4101
  }
3976
4102
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3977
4103
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3978
- return _this23.isCustomerBoundDiscount(discount);
4104
+ return _this24.isCustomerBoundDiscount(discount);
3979
4105
  });
3980
4106
  });
3981
4107
  }
@@ -3984,18 +4110,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3984
4110
  value: function shouldSkipDiscountCalculation(tempOrder) {
3985
4111
  var _this$store$discount20,
3986
4112
  _this$store$discount21,
3987
- _this24 = this;
4113
+ _this25 = this;
3988
4114
  if (this.hasActiveCustomerBoundDiscount) return false;
3989
4115
  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)) || [];
3990
4116
  if (discountList.length > 0) return false;
3991
4117
  return !(tempOrder.products || []).some(function (product) {
3992
- return _this24.productHasCustomerBoundDiscount(product);
4118
+ return _this25.productHasCustomerBoundDiscount(product);
3993
4119
  });
3994
4120
  }
3995
4121
  }, {
3996
4122
  key: "clearCustomerBoundDiscounts",
3997
4123
  value: function clearCustomerBoundDiscounts(tempOrder) {
3998
- var _this25 = this,
4124
+ var _this26 = this,
3999
4125
  _discountModule$getDi,
4000
4126
  _discountModule$getOr,
4001
4127
  _discountModule$setDi,
@@ -4004,7 +4130,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4004
4130
  var filterDiscountList = function filterDiscountList(discountList) {
4005
4131
  if (!Array.isArray(discountList)) return [];
4006
4132
  return discountList.filter(function (discount) {
4007
- var shouldRemove = _this25.isCustomerBoundDiscount(discount);
4133
+ var shouldRemove = _this26.isCustomerBoundDiscount(discount);
4008
4134
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
4009
4135
  return !shouldRemove;
4010
4136
  });
@@ -4031,12 +4157,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4031
4157
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
4032
4158
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
4033
4159
  var nextDiscounts = currentDiscounts.filter(function (discount) {
4034
- if (_this25.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4035
- return !_this25.isCustomerBoundDiscount(discount);
4160
+ if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4161
+ return !_this26.isCustomerBoundDiscount(discount);
4036
4162
  });
4037
4163
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
4038
- if (_this25.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4039
- return !_this25.isCustomerBoundDiscount(discount);
4164
+ if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
4165
+ return !_this26.isCustomerBoundDiscount(discount);
4040
4166
  });
4041
4167
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
4042
4168
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -4051,14 +4177,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4051
4177
  }, {
4052
4178
  key: "updateTempOrderCustomer",
4053
4179
  value: function updateTempOrderCustomer(customer) {
4054
- var _tempOrder$customer_i3, _ref58, _ref59, _customer$customer_id, _ref60, _ref61, _ref62, _customer$customer_na, _ref63, _customer$country_cal, _tempOrder$customer_i4;
4180
+ var _tempOrder$customer_i3, _ref61, _ref62, _customer$customer_id, _ref63, _ref64, _ref65, _customer$customer_na, _ref66, _customer$country_cal, _tempOrder$customer_i4;
4055
4181
  var tempOrder = this.ensureTempOrder();
4056
4182
  var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
4057
- var customerId = (_ref58 = (_ref59 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref59 !== void 0 ? _ref59 : customer.id) !== null && _ref58 !== void 0 ? _ref58 : null;
4058
- var customerName = (_ref60 = (_ref61 = (_ref62 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref62 !== void 0 ? _ref62 : customer.display_name) !== null && _ref61 !== void 0 ? _ref61 : customer.name) !== null && _ref60 !== void 0 ? _ref60 : '';
4183
+ var customerId = (_ref61 = (_ref62 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref62 !== void 0 ? _ref62 : customer.id) !== null && _ref61 !== void 0 ? _ref61 : null;
4184
+ var customerName = (_ref63 = (_ref64 = (_ref65 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref65 !== void 0 ? _ref65 : customer.display_name) !== null && _ref64 !== void 0 ? _ref64 : customer.name) !== null && _ref63 !== void 0 ? _ref63 : '';
4059
4185
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
4060
4186
  tempOrder.customer_name = String(customerName || '');
4061
- tempOrder.country_calling_code = String((_ref63 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref63 !== void 0 ? _ref63 : '');
4187
+ tempOrder.country_calling_code = String((_ref66 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref66 !== void 0 ? _ref66 : '');
4062
4188
  tempOrder.phone = String(customer.phone || '');
4063
4189
  tempOrder.email = String(customer.email || '');
4064
4190
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -4139,8 +4265,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4139
4265
  }, {
4140
4266
  key: "getOrderCustomerSnapshot",
4141
4267
  value: function getOrderCustomerSnapshot() {
4142
- var _this$store$tempOrder5;
4143
- var snapshot = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 || (_this$store$tempOrder5 = _this$store$tempOrder5._extend) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customerSnapshot;
4268
+ var _this$store$tempOrder8;
4269
+ var snapshot = (_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 || (_this$store$tempOrder8 = _this$store$tempOrder8._extend) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.customerSnapshot;
4144
4270
  return snapshot ? cloneDeep(snapshot) : null;
4145
4271
  }
4146
4272
  }, {
@@ -4200,10 +4326,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4200
4326
  }, {
4201
4327
  key: "setOrderPayments",
4202
4328
  value: function setOrderPayments(payments) {
4203
- var _this26 = this;
4329
+ var _this27 = this;
4204
4330
  var tempOrder = this.ensureTempOrder();
4205
4331
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
4206
- return _this26.normalizePaymentSource(payment, {
4332
+ return _this27.normalizePaymentSource(payment, {
4207
4333
  defaultPaid: false
4208
4334
  });
4209
4335
  }));
@@ -4258,7 +4384,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4258
4384
  }, {
4259
4385
  key: "addOrderPaymentWithDevicePrefix",
4260
4386
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4261
- var _this27 = this;
4387
+ var _this28 = this;
4262
4388
  this.logInfo('addOrderPayment', {
4263
4389
  payment: payment
4264
4390
  });
@@ -4276,7 +4402,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4276
4402
  void this.recalculateSummary({
4277
4403
  createIfMissing: true
4278
4404
  }).catch(function (error) {
4279
- _this27.logError('recalculate summary after addOrderPayment failed', {
4405
+ _this28.logError('recalculate summary after addOrderPayment failed', {
4280
4406
  error: error instanceof Error ? error.message : String(error)
4281
4407
  });
4282
4408
  });
@@ -4389,7 +4515,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4389
4515
  }, {
4390
4516
  key: "applyPaymentLifecycleChange",
4391
4517
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4392
- var _this28 = this;
4518
+ var _this29 = this;
4393
4519
  this.updateTempOrderPaymentStatus(tempOrder);
4394
4520
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4395
4521
  this.persistTempOrder();
@@ -4399,7 +4525,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4399
4525
  void this.recalculateSummary({
4400
4526
  createIfMissing: true
4401
4527
  }).catch(function (error) {
4402
- _this28.logError("recalculate summary after ".concat(logContext, " failed"), {
4528
+ _this29.logError("recalculate summary after ".concat(logContext, " failed"), {
4403
4529
  error: error instanceof Error ? error.message : String(error)
4404
4530
  });
4405
4531
  });
@@ -4443,7 +4569,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4443
4569
  }, {
4444
4570
  key: "updateVoucherOrderPayments",
4445
4571
  value: function updateVoucherOrderPayments(payments, options) {
4446
- var _this29 = this;
4572
+ var _this30 = this;
4447
4573
  var tempOrder = this.ensureTempOrder();
4448
4574
  var isOrderPaymentType = function isOrderPaymentType(value) {
4449
4575
  return value === 'normal' || value === 'deposit';
@@ -4478,7 +4604,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4478
4604
  });
4479
4605
  };
4480
4606
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4481
- return _this29.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4607
+ return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4482
4608
  defaultPaid: false,
4483
4609
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4484
4610
  });
@@ -4531,7 +4657,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4531
4657
  void this.recalculateSummary({
4532
4658
  createIfMissing: true
4533
4659
  }).catch(function (error) {
4534
- _this29.logError('recalculate summary after updateVoucherOrderPayments failed', {
4660
+ _this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
4535
4661
  error: error instanceof Error ? error.message : String(error)
4536
4662
  });
4537
4663
  });
@@ -4589,7 +4715,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4589
4715
  key: "shouldMergeProductToOrder",
4590
4716
  value: function shouldMergeProductToOrder(params) {
4591
4717
  var _this$orderHooks,
4592
- _this30 = this;
4718
+ _this31 = this;
4593
4719
  var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
4594
4720
  if (!onBeforeMergeProductToOrder) return true;
4595
4721
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -4597,7 +4723,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4597
4723
  }));
4598
4724
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4599
4725
  return Promise.resolve(result).then(function (resolved) {
4600
- return _this30.normalizeShouldMergeProductResult(resolved);
4726
+ return _this31.normalizeShouldMergeProductResult(resolved);
4601
4727
  });
4602
4728
  }
4603
4729
  return this.normalizeShouldMergeProductResult(result);
@@ -4646,7 +4772,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4646
4772
  }, {
4647
4773
  key: "assertAndLockProductSettlement",
4648
4774
  value: function assertAndLockProductSettlement(tempOrder, product) {
4649
- var _ref64, _ref65, _product$selling_pric;
4775
+ var _ref67, _ref68, _product$selling_pric;
4650
4776
  if (!this.isMultiCurrencySettlementEnabled()) return;
4651
4777
  var currentKey = getTempOrderSettlementKey(tempOrder);
4652
4778
  var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
@@ -4673,7 +4799,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4673
4799
  }
4674
4800
  applyTempOrderSettlementState(tempOrder, snapshot || {
4675
4801
  settlement_type: 'legal_currency',
4676
- price: (_ref64 = (_ref65 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref65 !== void 0 ? _ref65 : product.payment_price) !== null && _ref64 !== void 0 ? _ref64 : 0,
4802
+ price: (_ref67 = (_ref68 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref68 !== void 0 ? _ref68 : product.payment_price) !== null && _ref67 !== void 0 ? _ref67 : 0,
4677
4803
  unit_label: tempOrder.currency_code,
4678
4804
  symbol: tempOrder.currency_symbol,
4679
4805
  amount_format: tempOrder.currency_format
@@ -4798,7 +4924,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4798
4924
  _metadata,
4799
4925
  _productToAdd$metadat,
4800
4926
  _origin,
4801
- _this31 = this;
4927
+ _this32 = this;
4802
4928
  var linked = booking ? this.createLinkedProductAndBooking({
4803
4929
  product: product,
4804
4930
  booking: booking
@@ -4834,26 +4960,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4834
4960
  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;
4835
4961
  var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4836
4962
  var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4837
- if (_this31.hasGoodPassDiscount(item)) return false;
4838
- var isRuntimeEntitlementPass = _this31.isRuntimeEntitlementAppend(item, tempOrder);
4963
+ if (_this32.hasGoodPassDiscount(item)) return false;
4964
+ var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
4839
4965
  if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
4840
4966
  return false;
4841
4967
  }
4842
- if (isIncomingEntitlementAppend && _this31.isPersistedProductLine(item)) {
4968
+ if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
4843
4969
  return false;
4844
4970
  }
4845
- var hasExistingProductNote = _this31.hasOrderProductLineNote(item);
4971
+ var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
4846
4972
  if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
4847
4973
  return false;
4848
4974
  }
4849
4975
  var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
4850
- if (isRuntimeEntitlementPass && !_this31.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
4976
+ if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
4851
4977
  return false;
4852
4978
  }
4853
4979
  if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
4854
4980
  return false;
4855
4981
  }
4856
- if (_this31.isPersistedProductLine(item)) return false;
4982
+ if (_this32.isPersistedProductLine(item)) return false;
4857
4983
  if (item.product_id !== productToAdd.product_id) return false;
4858
4984
  if (item.product_variant_id !== productToAdd.product_variant_id) return false;
4859
4985
  var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
@@ -4864,7 +4990,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4864
4990
  var commitProductLine = function commitProductLine(shouldMerge) {
4865
4991
  var committedProduct;
4866
4992
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
4867
- _this31.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4993
+ _this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4868
4994
  if (linked) {
4869
4995
  normalizedIncoming.booking_uid = linked.bookingUid;
4870
4996
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -4882,7 +5008,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4882
5008
  var _targetProduct$metada;
4883
5009
  var targetProduct = matchedProduct;
4884
5010
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
4885
- var normalizedProduct = _this31.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
5011
+ var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4886
5012
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
4887
5013
  unique_identification_number: targetUid
4888
5014
  })
@@ -4905,7 +5031,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4905
5031
  order_detail_id: targetProduct.order_detail_id,
4906
5032
  num: nextNum
4907
5033
  });
4908
- _this31.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
5034
+ _this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4909
5035
  committedProduct = tempOrder.products[matchedIndex];
4910
5036
  if (matchedIndex !== tempOrder.products.length - 1) {
4911
5037
  var mergedProduct = tempOrder.products[matchedIndex];
@@ -4943,14 +5069,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4943
5069
  }, {
4944
5070
  key: "createSplitBookingLine",
4945
5071
  value: function createSplitBookingLine(product, booking, index, splitCount) {
4946
- var _booking$metadata6, _ref66, _ref67, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
5072
+ var _booking$metadata6, _ref69, _ref70, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
4947
5073
  var singleLine = cloneDeep(product);
4948
5074
  singleLine.num = 1;
4949
5075
  delete singleLine.product_quantity;
4950
5076
  var singleBooking = cloneDeep(booking);
4951
5077
  var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
4952
5078
  var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
4953
- var rawHolderIds = (_ref66 = (_ref67 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref67 !== void 0 ? _ref67 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref66 !== void 0 ? _ref66 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
5079
+ var rawHolderIds = (_ref69 = (_ref70 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref70 !== void 0 ? _ref70 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref69 !== void 0 ? _ref69 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
4954
5080
  var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
4955
5081
  return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
4956
5082
  }).filter(function (holderId) {
@@ -5015,8 +5141,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5015
5141
  key: "addProductToOrder",
5016
5142
  value: (function () {
5017
5143
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
5018
- var _this32 = this;
5019
- var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref68, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5144
+ var _this33 = this;
5145
+ var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
5020
5146
  return _regeneratorRuntime().wrap(function _callee23$(_context25) {
5021
5147
  while (1) switch (_context25.prev = _context25.next) {
5022
5148
  case 0:
@@ -5044,7 +5170,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5044
5170
  throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
5045
5171
  }
5046
5172
  salesNoteDrafts.forEach(function (draft) {
5047
- _this32.setSalesNoteOnTempOrder(tempOrder, {
5173
+ _this33.setSalesNoteOnTempOrder(tempOrder, {
5048
5174
  note_type: draft.note_type,
5049
5175
  target: {
5050
5176
  target_type: 'order_detail',
@@ -5074,7 +5200,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5074
5200
  break;
5075
5201
  }
5076
5202
  productRecord = product;
5077
- splitCount = getSafeProductNum((_ref68 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref68 !== void 0 ? _ref68 : 1);
5203
+ splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
5078
5204
  if (!(splitCount > 1)) {
5079
5205
  _context25.next = 27;
5080
5206
  break;
@@ -5179,7 +5305,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5179
5305
  key: "addProductsToOrder",
5180
5306
  value: (function () {
5181
5307
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
5182
- var tempOrder, _iterator20, _step20, item, product, booking, _ref69, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5308
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5183
5309
  return _regeneratorRuntime().wrap(function _callee24$(_context26) {
5184
5310
  while (1) switch (_context26.prev = _context26.next) {
5185
5311
  case 0:
@@ -5211,7 +5337,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5211
5337
  break;
5212
5338
  }
5213
5339
  productRecord = product;
5214
- splitCount = getSafeProductNum((_ref69 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref69 !== void 0 ? _ref69 : 1);
5340
+ splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
5215
5341
  if (!(splitCount > 1)) {
5216
5342
  _context26.next = 26;
5217
5343
  break;
@@ -5324,26 +5450,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5324
5450
  }, {
5325
5451
  key: "hasSameEntitlementMergePriceConfig",
5326
5452
  value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
5327
- var _this33 = this;
5453
+ var _this34 = this;
5328
5454
  var buildPriceConfig = function buildPriceConfig(product) {
5329
5455
  var metadata = product.metadata || {};
5330
5456
  var bundle = (product.product_bundle || []).map(function (item) {
5331
- var _ref70, _item$bundle_id, _ref71, _ref72, _item$bundle_product_, _ref73, _item$bundle_variant_, _ref74, _item$price_type, _ref75, _item$price_type_ext;
5457
+ var _ref73, _item$bundle_id, _ref74, _ref75, _item$bundle_product_, _ref76, _item$bundle_variant_, _ref77, _item$price_type, _ref78, _item$price_type_ext;
5332
5458
  return {
5333
- bundle_id: (_ref70 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref70 !== void 0 ? _ref70 : null,
5334
- bundle_product_id: (_ref71 = (_ref72 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref72 !== void 0 ? _ref72 : item.product_id) !== null && _ref71 !== void 0 ? _ref71 : null,
5335
- bundle_variant_id: (_ref73 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref73 !== void 0 ? _ref73 : 0,
5336
- price_type: (_ref74 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref74 !== void 0 ? _ref74 : '',
5337
- price_type_ext: (_ref75 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref75 !== void 0 ? _ref75 : ''
5459
+ bundle_id: (_ref73 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref73 !== void 0 ? _ref73 : null,
5460
+ bundle_product_id: (_ref74 = (_ref75 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref75 !== void 0 ? _ref75 : item.product_id) !== null && _ref74 !== void 0 ? _ref74 : null,
5461
+ bundle_variant_id: (_ref76 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref76 !== void 0 ? _ref76 : 0,
5462
+ price_type: (_ref77 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref77 !== void 0 ? _ref77 : '',
5463
+ price_type_ext: (_ref78 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref78 !== void 0 ? _ref78 : ''
5338
5464
  };
5339
5465
  }).sort(function (left, right) {
5340
5466
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
5341
5467
  });
5342
5468
  return JSON.stringify({
5343
- original_price: _this33.normalizeFingerprintMoney(product.original_price),
5344
- source_product_price: _this33.normalizeFingerprintMoney(metadata.source_product_price),
5345
- main_product_original_price: _this33.normalizeFingerprintMoney(metadata.main_product_original_price),
5346
- price_override: _this33.normalizeFingerprintMoney(metadata.price_override),
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),
5347
5473
  is_manual_discount: Boolean(metadata.is_manual_discount),
5348
5474
  bundle: bundle
5349
5475
  });
@@ -5353,24 +5479,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5353
5479
  }, {
5354
5480
  key: "getBundleRuntimeIdentity",
5355
5481
  value: function getBundleRuntimeIdentity(bundle) {
5356
- var _ref76, _bundle$bundle_id2, _ref77, _bundle$bundle_group_2, _ref78, _ref79, _bundle$bundle_produc3, _ref80, _bundle$bundle_varian3;
5482
+ var _ref79, _bundle$bundle_id2, _ref80, _bundle$bundle_group_2, _ref81, _ref82, _bundle$bundle_produc3, _ref83, _bundle$bundle_varian3;
5357
5483
  if (!bundle || _typeof(bundle) !== 'object') return '';
5358
- return [(_ref76 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref76 !== void 0 ? _ref76 : '', (_ref77 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref77 !== void 0 ? _ref77 : '', (_ref78 = (_ref79 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref79 !== void 0 ? _ref79 : bundle.product_id) !== null && _ref78 !== void 0 ? _ref78 : '', (_ref80 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref80 !== void 0 ? _ref80 : 0].join('|');
5484
+ return [(_ref79 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref79 !== void 0 ? _ref79 : '', (_ref80 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref80 !== void 0 ? _ref80 : '', (_ref81 = (_ref82 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref82 !== void 0 ? _ref82 : bundle.product_id) !== null && _ref81 !== void 0 ? _ref81 : '', (_ref83 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref83 !== void 0 ? _ref83 : 0].join('|');
5359
5485
  }
5360
5486
  }, {
5361
5487
  key: "preservePersistedBundlePriceFields",
5362
5488
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5363
- var _this34 = this;
5489
+ var _this35 = this;
5364
5490
  if (!Array.isArray(nextBundles)) return nextBundles;
5365
5491
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5366
5492
  var previousByIdentity = new Map();
5367
5493
  previousBundles.forEach(function (bundle) {
5368
- var identity = _this34.getBundleRuntimeIdentity(bundle);
5494
+ var identity = _this35.getBundleRuntimeIdentity(bundle);
5369
5495
  if (identity) previousByIdentity.set(identity, bundle);
5370
5496
  });
5371
5497
  return nextBundles.map(function (bundle, index) {
5372
5498
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5373
- var previous = previousByIdentity.get(_this34.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5499
+ var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5374
5500
  if (!previous || _typeof(previous) !== 'object') return bundle;
5375
5501
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5376
5502
  cover: previous.cover
@@ -5506,13 +5632,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5506
5632
  delete nextProduct.metadata.main_product_original_price;
5507
5633
  delete nextProduct.metadata.price_schema_version;
5508
5634
  } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5509
- var _ref81, _targetProduct$metada10, _targetProduct$metada11, _ref82, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5635
+ var _ref84, _targetProduct$metada10, _targetProduct$metada11, _ref85, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5510
5636
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
5511
5637
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
5512
5638
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
5513
5639
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
5514
- var _previousMainOriginal = new Decimal(Number((_ref81 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref81 !== void 0 ? _ref81 : 0) || 0);
5515
- var _previousMainSelling = new Decimal(Number((_ref82 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref82 !== void 0 ? _ref82 : _previousMainOriginal.toNumber()) || 0);
5640
+ var _previousMainOriginal = new Decimal(Number((_ref84 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref84 !== void 0 ? _ref84 : 0) || 0);
5641
+ var _previousMainSelling = new Decimal(Number((_ref85 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref85 !== void 0 ? _ref85 : _previousMainOriginal.toNumber()) || 0);
5516
5642
  var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
5517
5643
  var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
5518
5644
  var _nextMainOriginal = previousSource.plus(nextOptionSum);
@@ -5612,7 +5738,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5612
5738
  key: "updateOrderProducts",
5613
5739
  value: function () {
5614
5740
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
5615
- var _this35 = this;
5741
+ var _this36 = this;
5616
5742
  var tempOrder, reapplyBookingDiscountProductUids;
5617
5743
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5618
5744
  while (1) switch (_context28.prev = _context28.next) {
@@ -5625,7 +5751,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5625
5751
  return _context28.abrupt("return", tempOrder.products);
5626
5752
  case 3:
5627
5753
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
5628
- var updatedProductUid = _this35.applyOrderProductUpdateToTempOrder(tempOrder, params);
5754
+ var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params);
5629
5755
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
5630
5756
  if (params.allow_booking_discount_reapply && updatedProductUid) {
5631
5757
  acc.push(String(updatedProductUid));
@@ -5852,7 +5978,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5852
5978
  key: "removeProductsFromOrder",
5853
5979
  value: (function () {
5854
5980
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
5855
- var _this36 = this;
5981
+ var _this37 = this;
5856
5982
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
5857
5983
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5858
5984
  while (1) switch (_context32.prev = _context32.next) {
@@ -5917,7 +6043,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5917
6043
  }
5918
6044
  if (productUid !== undefined && productUid !== null && productUid !== '') {
5919
6045
  bookingsBeforeRemove.forEach(function (booking) {
5920
- var bookingUid = _this36.getBookingUniqueIdentificationNumber(booking);
6046
+ var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
5921
6047
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
5922
6048
  linkedBookingUidsToRemove.add(bookingUid);
5923
6049
  }
@@ -6132,23 +6258,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6132
6258
  }, {
6133
6259
  key: "buildCurrentSubmitPayloadForLocalPrint",
6134
6260
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
6135
- var _params$cacheId, _this$otherParams5, _ref83, _params$businessCode, _this$otherParams6, _this$otherParams7;
6261
+ var _params$cacheId, _this$otherParams5, _ref86, _params$businessCode, _this$otherParams6, _this$otherParams7;
6136
6262
  var tempOrder = this.ensureTempOrder();
6137
6263
  this.persistTempOrder();
6138
6264
  var payload = buildSubmitPayload({
6139
6265
  tempOrder: tempOrder,
6140
6266
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
6141
6267
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
6142
- businessCode: (_ref83 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref83 !== void 0 ? _ref83 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6268
+ businessCode: (_ref86 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref86 !== void 0 ? _ref86 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6143
6269
  channel: params === null || params === void 0 ? void 0 : params.channel,
6144
6270
  type: params === null || params === void 0 ? void 0 : params.type,
6145
6271
  summary: this.store.summary || createEmptySummary(),
6146
6272
  enhance: function enhance(nextPayload) {
6147
- var _ref84, _tempOrder$order_numb, _ref85, _tempOrder$shop_order2, _ref86, _tempOrder$shop_full_;
6273
+ var _ref87, _tempOrder$order_numb, _ref88, _tempOrder$shop_order2, _ref89, _tempOrder$shop_full_;
6148
6274
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
6149
- order_number: (_ref84 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref84 !== void 0 ? _ref84 : null,
6150
- shop_order_number: (_ref85 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref85 !== void 0 ? _ref85 : null,
6151
- shop_full_order_number: (_ref86 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref86 !== void 0 ? _ref86 : null,
6275
+ order_number: (_ref87 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref87 !== void 0 ? _ref87 : null,
6276
+ shop_order_number: (_ref88 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref88 !== void 0 ? _ref88 : null,
6277
+ shop_full_order_number: (_ref89 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref89 !== void 0 ? _ref89 : null,
6152
6278
  small_ticket_data_flag: 1
6153
6279
  });
6154
6280
  }
@@ -6312,7 +6438,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6312
6438
  key: "runSubmitTempOrder",
6313
6439
  value: function () {
6314
6440
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6315
- var _params$cacheId3, _this$otherParams12, _ref87, _ref88, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6441
+ var _params$cacheId3, _this$otherParams12, _ref90, _ref91, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6316
6442
  var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
6317
6443
  return _regeneratorRuntime().wrap(function _callee37$(_context40) {
6318
6444
  while (1) switch (_context40.prev = _context40.next) {
@@ -6379,7 +6505,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6379
6505
  tempOrder: tempOrder,
6380
6506
  cacheId: effectiveCacheId,
6381
6507
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
6382
- businessCode: (_ref87 = (_ref88 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref88 !== void 0 ? _ref88 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref87 !== void 0 ? _ref87 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6508
+ businessCode: (_ref90 = (_ref91 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref91 !== void 0 ? _ref91 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref90 !== void 0 ? _ref90 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6383
6509
  channel: params === null || params === void 0 ? void 0 : params.channel,
6384
6510
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
6385
6511
  summary: latestSummary,
@@ -6549,10 +6675,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6549
6675
  value: function extractSubmitErrorResponse(error) {
6550
6676
  var _error$response,
6551
6677
  _error$response2,
6552
- _this37 = this;
6678
+ _this38 = this;
6553
6679
  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];
6554
6680
  return candidates.find(function (candidate) {
6555
- return _this37.isSubmitErrorResponse(candidate);
6681
+ return _this38.isSubmitErrorResponse(candidate);
6556
6682
  }) || null;
6557
6683
  }
6558
6684
  }, {
@@ -6580,7 +6706,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6580
6706
  key: "syncPaymentsToOrder",
6581
6707
  value: function () {
6582
6708
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6583
- var _this38 = this,
6709
+ var _this39 = this,
6584
6710
  _params$confirmPendin;
6585
6711
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
6586
6712
  return _regeneratorRuntime().wrap(function _callee39$(_context42) {
@@ -6605,7 +6731,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6605
6731
  case 9:
6606
6732
  devicePrefix = _context42.t0;
6607
6733
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
6608
- return _this38.normalizePaymentSource(payment, {
6734
+ return _this39.normalizePaymentSource(payment, {
6609
6735
  defaultPaid: false,
6610
6736
  devicePrefix: devicePrefix
6611
6737
  });
@@ -6684,7 +6810,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6684
6810
  }, {
6685
6811
  key: "createOrder",
6686
6812
  value: function createOrder(params) {
6687
- var _this39 = this;
6813
+ var _this40 = this;
6688
6814
  var order = _objectSpread({
6689
6815
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
6690
6816
  // 要从外面拿,virtual
@@ -6716,7 +6842,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6716
6842
 
6717
6843
  // 为预约补齐 holder 信息
6718
6844
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
6719
- ensureCartItemOriginHolder(item, _this39.window);
6845
+ ensureCartItemOriginHolder(item, _this40.window);
6720
6846
  }
6721
6847
 
6722
6848
  // 购物车是否为普通商品
@@ -7419,7 +7545,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7419
7545
  }, {
7420
7546
  key: "normalizeTempOrderForRuntime",
7421
7547
  value: function normalizeTempOrderForRuntime(raw, options) {
7422
- var _this40 = this,
7548
+ var _this41 = this,
7423
7549
  _raw$_extend;
7424
7550
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
7425
7551
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -7444,12 +7570,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7444
7570
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
7445
7571
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
7446
7572
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
7447
- return _this40.normalizeHydratedOrderProduct(p, {
7573
+ return _this41.normalizeHydratedOrderProduct(p, {
7448
7574
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
7449
7575
  });
7450
7576
  }) : [];
7451
7577
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
7452
- var booking = _this40.normalizeHydratedBookingHolder(b || {});
7578
+ var booking = _this41.normalizeHydratedBookingHolder(b || {});
7453
7579
  return _objectSpread(_objectSpread({}, booking), {}, {
7454
7580
  is_all: normalizeBookingIsAll(booking),
7455
7581
  sub_type: normalizeBookingSubType(booking)
@@ -7499,7 +7625,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7499
7625
  _step24;
7500
7626
  try {
7501
7627
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
7502
- var _product$metadata14, _ref89, _ref90, _existed$origin, _rawProduct$metadata;
7628
+ var _product$metadata14, _ref92, _ref93, _existed$origin, _rawProduct$metadata;
7503
7629
  var _step24$value = _slicedToArray(_step24.value, 2),
7504
7630
  index = _step24$value[0],
7505
7631
  product = _step24$value[1];
@@ -7507,7 +7633,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7507
7633
  if (!uid) continue;
7508
7634
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
7509
7635
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
7510
- var origin = (_ref89 = (_ref90 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref90 !== void 0 ? _ref90 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref89 !== void 0 ? _ref89 : rawProduct;
7636
+ var origin = (_ref92 = (_ref93 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref93 !== void 0 ? _ref93 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref92 !== void 0 ? _ref92 : rawProduct;
7511
7637
  var originSnapshot = cloneDeep(origin);
7512
7638
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
7513
7639
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -7636,10 +7762,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7636
7762
  }, {
7637
7763
  key: "normalizeHydratedProductOptionItem",
7638
7764
  value: function normalizeHydratedProductOptionItem(optionItem) {
7639
- var _ref91, _optionItem$num, _ref92, _optionItem$add_price;
7640
- var rawNum = (_ref91 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref91 !== void 0 ? _ref91 : 1;
7765
+ var _ref94, _optionItem$num, _ref95, _optionItem$add_price;
7766
+ var rawNum = (_ref94 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref94 !== void 0 ? _ref94 : 1;
7641
7767
  var parsedNum = Number(rawNum);
7642
- var rawPrice = (_ref92 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref92 !== void 0 ? _ref92 : 0;
7768
+ var rawPrice = (_ref95 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref95 !== void 0 ? _ref95 : 0;
7643
7769
  var parsedPrice = Number(rawPrice);
7644
7770
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
7645
7771
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -7656,7 +7782,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7656
7782
  }, {
7657
7783
  key: "normalizeHydratedOrderProduct",
7658
7784
  value: function normalizeHydratedOrderProduct(product, options) {
7659
- var _this41 = this;
7785
+ var _this42 = this;
7660
7786
  var row = _objectSpread({}, product || {});
7661
7787
  if (row.num === undefined && row.product_quantity !== undefined) {
7662
7788
  row.num = row.product_quantity;
@@ -7664,7 +7790,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7664
7790
  var productSku = ensureProductSku(row);
7665
7791
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
7666
7792
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
7667
- return _this41.normalizeHydratedProductOptionItem(optionItem || {});
7793
+ return _this42.normalizeHydratedProductOptionItem(optionItem || {});
7668
7794
  }))
7669
7795
  });
7670
7796
  delete row["product_".concat('option', "_item")];
@@ -7752,8 +7878,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7752
7878
  }, {
7753
7879
  key: "getVouchers",
7754
7880
  value: function getVouchers() {
7755
- var _this$store$tempOrder6;
7756
- return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.vouchers) || [];
7881
+ var _this$store$tempOrder9;
7882
+ return ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.vouchers) || [];
7757
7883
  }
7758
7884
  }], [{
7759
7885
  key: "populateSavedAmounts",
@@ -7847,4 +7973,5 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7847
7973
  }
7848
7974
  }]);
7849
7975
  return OrderModule;
7850
- }(BaseModule);
7976
+ }(BaseModule);
7977
+ export { isFulfillmentTimingBooking } from "./pickupTiming";