@pisell/pisellos 2.3.123 → 2.3.125

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.
@@ -32,7 +32,7 @@ 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
37
  import dayjs from 'dayjs';
38
38
  import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
@@ -130,6 +130,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
130
130
  _defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
131
131
  /** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
132
132
  _defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
133
+ /** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
134
+ _defineProperty(_assertThisInitialized(_this), "pointCardSnapshotCodeCandidates", new Map());
133
135
  _defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
134
136
  _defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
135
137
  _defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
@@ -1586,9 +1588,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1586
1588
  key: "clearCustomerWalletRuntimeState",
1587
1589
  value: function clearCustomerWalletRuntimeState() {
1588
1590
  this.customerWalletPrepareConfigEpoch += 1;
1591
+ this.pointCardSnapshotCodeCandidates.clear();
1589
1592
  this.store.availableWalletIds = [];
1590
1593
  this.store.virtualCurrencyList = [];
1591
1594
  }
1595
+ }, {
1596
+ key: "rememberPointCardSnapshotCodeCandidates",
1597
+ value: function rememberPointCardSnapshotCodeCandidates(value) {
1598
+ var _this5 = this;
1599
+ collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
1600
+ var id = _ref18.id,
1601
+ code = _ref18.code;
1602
+ if (!_this5.pointCardSnapshotCodeCandidates.has(id)) {
1603
+ _this5.pointCardSnapshotCodeCandidates.set(id, code);
1604
+ }
1605
+ });
1606
+ }
1607
+ }, {
1608
+ key: "getRememberedPointCardSnapshotCodeCandidates",
1609
+ value: function getRememberedPointCardSnapshotCodeCandidates() {
1610
+ return _toConsumableArray(this.pointCardSnapshotCodeCandidates).map(function (_ref19) {
1611
+ var _ref20 = _slicedToArray(_ref19, 2),
1612
+ id = _ref20[0],
1613
+ code = _ref20[1];
1614
+ return {
1615
+ id: id,
1616
+ code: code
1617
+ };
1618
+ });
1619
+ }
1620
+ }, {
1621
+ key: "getPointCardSnapshotOrderIdentityKey",
1622
+ value: function getPointCardSnapshotOrderIdentityKey(identity) {
1623
+ if (identity !== null && identity !== void 0 && identity.externalSaleNumber) {
1624
+ return "external:".concat(identity.externalSaleNumber);
1625
+ }
1626
+ if ((identity === null || identity === void 0 ? void 0 : identity.orderId) !== undefined && identity.orderId !== null) {
1627
+ return "order:".concat(identity.orderId);
1628
+ }
1629
+ if (identity !== null && identity !== void 0 && identity.localId) return "local:".concat(identity.localId);
1630
+ if (identity !== null && identity !== void 0 && identity.orderNumber) return "number:".concat(identity.orderNumber);
1631
+ return '';
1632
+ }
1633
+ }, {
1634
+ key: "isPointCardSnapshotMergeContextCurrent",
1635
+ value: function isPointCardSnapshotMergeContextCurrent(context) {
1636
+ var _context$customerId, _this$store$tempOrder4, _this$store$tempOrder5;
1637
+ if (!context) return true;
1638
+ 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 : '')) {
1639
+ return false;
1640
+ }
1641
+ var expectedOrderKey = this.getPointCardSnapshotOrderIdentityKey(context.orderIdentity);
1642
+ return !expectedOrderKey || expectedOrderKey === this.getPointCardSnapshotOrderIdentityKey(this.getOrderIdentity());
1643
+ }
1592
1644
  }, {
1593
1645
  key: "writeCustomerWalletSnapshotsFromPrepareConfig",
1594
1646
  value: function writeCustomerWalletSnapshotsFromPrepareConfig(params) {
@@ -1596,9 +1648,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1596
1648
  var tempOrder = this.store.tempOrder;
1597
1649
  if (!tempOrder) return;
1598
1650
  if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
1651
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
1599
1652
  var virtualCurrencyList = Array.isArray(params.virtualCurrencyList) ? params.virtualCurrencyList : [];
1600
- tempOrder.order_meta_list = _objectSpread(_objectSpread({}, normalizeOrderMetaList(tempOrder.order_meta_list) || {}), {}, {
1601
- point_cards_snapshot: buildPointCardSnapshotFromWalletPassList(params.availableWalletPassList),
1653
+ var snapshotsWithExistingCodes = _mergePointCardSnapshotCodes(params.availableWalletPassList, currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot);
1654
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1655
+ point_cards_snapshot: _mergePointCardSnapshotCodes(snapshotsWithExistingCodes, this.getRememberedPointCardSnapshotCodeCandidates()),
1602
1656
  virtual_currency_snapshot: buildVirtualCurrencySnapshotFromList(virtualCurrencyList)
1603
1657
  });
1604
1658
  this.store.availableWalletIds = _toConsumableArray(params.availableWalletIds);
@@ -1606,6 +1660,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1606
1660
  this.persistTempOrder();
1607
1661
  this.saveDraftInBackground();
1608
1662
  }
1663
+
1664
+ /**
1665
+ * 将 Payment WalletPass 返回的实例 code 回填到当前订单 Snapshot。
1666
+ * 这里只按资产 ID 补空值,不新增卡、不覆盖 prepare/config 冻结的余额。
1667
+ */
1668
+ }, {
1669
+ key: "mergePointCardSnapshotCodes",
1670
+ value: function mergePointCardSnapshotCodes(walletPassList, context) {
1671
+ var tempOrder = this.store.tempOrder;
1672
+ var currentOrderMetaList = normalizeOrderMetaList(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_meta_list);
1673
+ var currentSnapshots = (currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot) || [];
1674
+ if (!tempOrder || !this.isPointCardSnapshotMergeContextCurrent(context)) {
1675
+ return currentSnapshots;
1676
+ }
1677
+ this.rememberPointCardSnapshotCodeCandidates(walletPassList);
1678
+ if (!currentSnapshots.length) return currentSnapshots;
1679
+ var nextSnapshots = _mergePointCardSnapshotCodes(currentSnapshots, this.getRememberedPointCardSnapshotCodeCandidates());
1680
+ var hasChanged = nextSnapshots.some(function (snapshot, index) {
1681
+ var _currentSnapshots$ind;
1682
+ return snapshot.code !== ((_currentSnapshots$ind = currentSnapshots[index]) === null || _currentSnapshots$ind === void 0 ? void 0 : _currentSnapshots$ind.code);
1683
+ });
1684
+ if (!hasChanged) return currentSnapshots;
1685
+ tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
1686
+ point_cards_snapshot: nextSnapshots
1687
+ });
1688
+ this.persistTempOrder();
1689
+ this.saveDraftInBackground();
1690
+ return nextSnapshots;
1691
+ }
1609
1692
  }, {
1610
1693
  key: "createExternalSaleNumber",
1611
1694
  value: function createExternalSaleNumber() {
@@ -1706,15 +1789,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1706
1789
  }, {
1707
1790
  key: "extractOrderIdFromSubmitResult",
1708
1791
  value: function extractOrderIdFromSubmitResult(result) {
1709
- var _ref18, _ref19, _ref20, _result$data$order_id, _result$data, _result$data2;
1710
- 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;
1792
+ var _ref21, _ref22, _ref23, _result$data$order_id, _result$data, _result$data2;
1793
+ 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;
1711
1794
  }
1712
1795
  }, {
1713
1796
  key: "calculatePaymentEffectiveAmount",
1714
1797
  value: function calculatePaymentEffectiveAmount(payment) {
1715
- var _ref21, _payment$origin_amoun;
1798
+ var _ref24, _payment$origin_amoun;
1716
1799
  var amount = new Decimal(payment.amount || 0);
1717
- 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);
1800
+ 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);
1718
1801
  var serviceFee = new Decimal(payment.service_fee || 0);
1719
1802
  // TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
1720
1803
  var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
@@ -1724,23 +1807,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1724
1807
  }, {
1725
1808
  key: "calculatePaymentTotal",
1726
1809
  value: function calculatePaymentTotal(payments) {
1727
- var _this5 = this;
1810
+ var _this6 = this;
1728
1811
  return mapPaymentItemsToOrderPayments(payments, {
1729
1812
  includeVoided: false
1730
1813
  }).reduce(function (sum, payment) {
1731
1814
  if (!isPaidPaymentRecord(payment)) return sum;
1732
- return sum.plus(_this5.calculatePaymentEffectiveAmount(payment));
1815
+ return sum.plus(_this6.calculatePaymentEffectiveAmount(payment));
1733
1816
  }, new Decimal(0));
1734
1817
  }
1735
1818
  }, {
1736
1819
  key: "calculateOrderPaidPaymentTotal",
1737
1820
  value: function calculateOrderPaidPaymentTotal(payments) {
1738
- var _this6 = this;
1821
+ var _this7 = this;
1739
1822
  return mapPaymentItemsToOrderPayments(payments, {
1740
1823
  includeVoided: false
1741
1824
  }).reduce(function (sum, payment) {
1742
1825
  if (!isPaidPaymentRecord(payment)) return sum;
1743
- return sum.plus(_this6.calculatePaymentGapAmount(payment));
1826
+ return sum.plus(_this7.calculatePaymentGapAmount(payment));
1744
1827
  }, new Decimal(0));
1745
1828
  }
1746
1829
  }, {
@@ -1876,13 +1959,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1876
1959
  }, {
1877
1960
  key: "calculateDepositPaidAmount",
1878
1961
  value: function calculateDepositPaidAmount(payments) {
1879
- var _this7 = this;
1962
+ var _this8 = this;
1880
1963
  return (payments || []).reduce(function (sum, payment) {
1881
1964
  var paymentRecord = payment;
1882
1965
  if (!isPaidPaymentRecord(paymentRecord)) return sum;
1883
1966
  var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
1884
1967
  if (!isDepositPayment) return sum;
1885
- return sum.plus(_this7.calculatePaymentGapAmount(paymentRecord));
1968
+ return sum.plus(_this8.calculatePaymentGapAmount(paymentRecord));
1886
1969
  }, new Decimal(0));
1887
1970
  }
1888
1971
  }, {
@@ -1919,28 +2002,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1919
2002
  }, {
1920
2003
  key: "getPaymentNumberDevicePrefixSync",
1921
2004
  value: function getPaymentNumberDevicePrefixSync() {
1922
- var _this8 = this;
2005
+ var _this9 = this;
1923
2006
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1924
- return _this8.getPaymentNumberAppData(key);
2007
+ return _this9.getPaymentNumberAppData(key);
1925
2008
  });
1926
2009
  }
1927
2010
  }, {
1928
2011
  key: "getPaymentNumberDevicePrefixAsync",
1929
2012
  value: function getPaymentNumberDevicePrefixAsync() {
1930
- var _this9 = this;
2013
+ var _this10 = this;
1931
2014
  return resolvePaymentNumberDevicePrefix(function (key) {
1932
- return _this9.getPaymentNumberAppData(key);
2015
+ return _this10.getPaymentNumberAppData(key);
1933
2016
  });
1934
2017
  }
1935
2018
  }, {
1936
2019
  key: "normalizePaymentSource",
1937
2020
  value: function normalizePaymentSource(payment, options) {
1938
- var _ref22, _paymentRecord$origin;
2021
+ var _ref25, _paymentRecord$origin;
1939
2022
  var paymentRecord = payment;
1940
2023
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1941
2024
  var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
1942
2025
  metadata: metadata,
1943
- origin_amount: (_ref22 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref22 !== void 0 ? _ref22 : '0.00'
2026
+ origin_amount: (_ref25 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref25 !== void 0 ? _ref25 : '0.00'
1944
2027
  }), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
1945
2028
  if (paymentRecord.status !== undefined) {
1946
2029
  normalized.status = paymentRecord.status;
@@ -2059,16 +2142,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2059
2142
  }, {
2060
2143
  key: "calculatePaidPaymentSummary",
2061
2144
  value: function calculatePaidPaymentSummary(payments) {
2062
- var _this10 = this;
2145
+ var _this11 = this;
2063
2146
  return (payments || []).reduce(function (summary, payment) {
2064
2147
  var paymentRecord = payment;
2065
2148
  if (!isPaidPaymentRecord(paymentRecord)) return summary;
2066
2149
  return {
2067
2150
  customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
2068
- orderPaidAmount: summary.orderPaidAmount.plus(_this10.calculatePaymentOrderAmount(paymentRecord)),
2069
- gapPaidAmount: summary.gapPaidAmount.plus(_this10.calculatePaymentGapAmount(paymentRecord)),
2070
- payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this10.calculatePaymentServiceFee(paymentRecord)),
2071
- roundingAmount: summary.roundingAmount.plus(_this10.calculatePaymentRoundingAmount(paymentRecord))
2151
+ orderPaidAmount: summary.orderPaidAmount.plus(_this11.calculatePaymentOrderAmount(paymentRecord)),
2152
+ gapPaidAmount: summary.gapPaidAmount.plus(_this11.calculatePaymentGapAmount(paymentRecord)),
2153
+ payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this11.calculatePaymentServiceFee(paymentRecord)),
2154
+ roundingAmount: summary.roundingAmount.plus(_this11.calculatePaymentRoundingAmount(paymentRecord))
2072
2155
  };
2073
2156
  }, {
2074
2157
  customerPaidAmount: new Decimal(0),
@@ -2275,15 +2358,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2275
2358
  }, {
2276
2359
  key: "normalizeFingerprintValue",
2277
2360
  value: function normalizeFingerprintValue(value) {
2278
- var _this11 = this;
2361
+ var _this12 = this;
2279
2362
  if (Array.isArray(value)) {
2280
2363
  return value.map(function (item) {
2281
- return _this11.normalizeFingerprintValue(item);
2364
+ return _this12.normalizeFingerprintValue(item);
2282
2365
  });
2283
2366
  }
2284
2367
  if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
2285
2368
  return Object.keys(value).sort().reduce(function (result, key) {
2286
- result[key] = _this11.normalizeFingerprintValue(value[key]);
2369
+ result[key] = _this12.normalizeFingerprintValue(value[key]);
2287
2370
  return result;
2288
2371
  }, {});
2289
2372
  }
@@ -2296,9 +2379,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2296
2379
  _product$payment_pric,
2297
2380
  _sku$code,
2298
2381
  _sku$barcode,
2299
- _ref23,
2382
+ _ref26,
2300
2383
  _sku$variant_id,
2301
- _this12 = this;
2384
+ _this13 = this;
2302
2385
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2303
2386
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2304
2387
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2323,37 +2406,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2323
2406
  product_sku: this.normalizeFingerprintValue({
2324
2407
  code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
2325
2408
  barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
2326
- 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,
2409
+ 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,
2327
2410
  variant: sku.variant || [],
2328
2411
  option: getProductSkuOptions(product || {}).map(function (option) {
2329
- var _ref24, _option$id, _option$option_group_, _ref25, _option$option_group_2, _option$num, _option$add_price;
2412
+ var _ref27, _option$id, _option$option_group_, _ref28, _option$option_group_2, _option$num, _option$add_price;
2330
2413
  return {
2331
- 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,
2414
+ 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,
2332
2415
  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,
2333
- 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,
2416
+ 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,
2334
2417
  num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
2335
- add_price: _this12.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)
2418
+ 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)
2336
2419
  };
2337
2420
  })
2338
2421
  }),
2339
2422
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2340
- var _ref26, _ref27, _bundle$bundle_produc, _ref28, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2423
+ var _ref29, _ref30, _bundle$bundle_produc, _ref31, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
2341
2424
  return {
2342
- 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,
2343
- 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,
2425
+ 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,
2426
+ 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,
2344
2427
  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),
2345
- price: _this12.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2346
- bundle_selling_price: _this12.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2428
+ price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
2429
+ bundle_selling_price: _this13.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
2347
2430
  price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
2348
2431
  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 : ''
2349
2432
  };
2350
2433
  })),
2351
2434
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2352
- var _ref29, _discount$type2, _ref30, _ref31, _discount$discount_id, _discount$discount;
2435
+ var _ref32, _discount$type2, _ref33, _ref34, _discount$discount_id, _discount$discount;
2353
2436
  return {
2354
- 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 : '',
2355
- 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,
2356
- amount: _this12.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2437
+ 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 : '',
2438
+ 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,
2439
+ amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2357
2440
  };
2358
2441
  }))
2359
2442
  };
@@ -2361,9 +2444,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2361
2444
  }, {
2362
2445
  key: "buildOrderProductsFingerprint",
2363
2446
  value: function buildOrderProductsFingerprint(products) {
2364
- var _this13 = this;
2447
+ var _this14 = this;
2365
2448
  var items = (products || []).map(function (product) {
2366
- return _this13.buildProductFingerprintItem(product);
2449
+ return _this14.buildProductFingerprintItem(product);
2367
2450
  });
2368
2451
  items.sort(function (left, right) {
2369
2452
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2376,16 +2459,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2376
2459
  var _product$product_id3,
2377
2460
  _product$product_vari2,
2378
2461
  _product$num2,
2379
- _ref32,
2462
+ _ref35,
2380
2463
  _metadata$unique_iden,
2381
2464
  _metadata$price_overr,
2382
2465
  _metadata$is_manual_d,
2383
2466
  _metadata$product_dis,
2384
2467
  _sku$code2,
2385
2468
  _sku$barcode2,
2386
- _ref33,
2469
+ _ref36,
2387
2470
  _sku$variant_id2,
2388
- _this14 = this;
2471
+ _this15 = this;
2389
2472
  var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
2390
2473
  var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
2391
2474
  var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
@@ -2399,7 +2482,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2399
2482
  extension_type: extensionType,
2400
2483
  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),
2401
2484
  metadata: {
2402
- 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 : '',
2485
+ 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 : '',
2403
2486
  price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
2404
2487
  is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
2405
2488
  product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
@@ -2407,47 +2490,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2407
2490
  product_sku: this.normalizeFingerprintValue({
2408
2491
  code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
2409
2492
  barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
2410
- 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,
2493
+ 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,
2411
2494
  variant: sku.variant || [],
2412
2495
  option: getProductSkuOptions(product || {}).map(function (option) {
2413
- var _ref34, _option$id2, _option$option_group_3, _ref35, _option$option_group_4, _option$num2, _option$add_price2;
2496
+ var _ref37, _option$id2, _option$option_group_3, _ref38, _option$option_group_4, _option$num2, _option$add_price2;
2414
2497
  return {
2415
- 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,
2498
+ 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,
2416
2499
  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,
2417
- 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,
2500
+ 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,
2418
2501
  num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
2419
- add_price: _this14.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)
2502
+ 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)
2420
2503
  };
2421
2504
  })
2422
2505
  }),
2423
2506
  product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
2424
- 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;
2507
+ 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;
2425
2508
  return {
2426
- 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,
2427
- 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,
2428
- 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,
2429
- 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,
2509
+ 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,
2510
+ 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,
2511
+ 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,
2512
+ 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,
2430
2513
  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),
2431
2514
  price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
2432
2515
  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 : '',
2433
- option: _this14.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2434
- var _ref41, _option$id3, _option$option_group_5, _ref42, _option$option_group_6, _option$num3, _option$add_price3;
2516
+ option: _this15.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
2517
+ var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
2435
2518
  return {
2436
- 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,
2519
+ 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,
2437
2520
  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,
2438
- 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,
2521
+ 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,
2439
2522
  num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
2440
- add_price: _this14.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)
2523
+ 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)
2441
2524
  };
2442
2525
  }))
2443
2526
  };
2444
2527
  })),
2445
2528
  discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
2446
- var _ref43, _discount$type4, _ref44, _ref45, _discount$discount_id2, _discount$discount2;
2529
+ var _ref46, _discount$type4, _ref47, _ref48, _discount$discount_id2, _discount$discount2;
2447
2530
  return {
2448
- 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 : '',
2449
- 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,
2450
- amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2531
+ 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 : '',
2532
+ 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,
2533
+ amount: _this15.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
2451
2534
  };
2452
2535
  }))
2453
2536
  };
@@ -2455,9 +2538,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2455
2538
  }, {
2456
2539
  key: "buildOrderProductsStructuralFingerprint",
2457
2540
  value: function buildOrderProductsStructuralFingerprint(products) {
2458
- var _this15 = this;
2541
+ var _this16 = this;
2459
2542
  var items = (products || []).map(function (product) {
2460
- return _this15.buildProductStructuralFingerprintItem(product);
2543
+ return _this16.buildProductStructuralFingerprintItem(product);
2461
2544
  });
2462
2545
  items.sort(function (left, right) {
2463
2546
  return JSON.stringify(left).localeCompare(JSON.stringify(right));
@@ -2773,11 +2856,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2773
2856
  }, {
2774
2857
  key: "getOrderIdentity",
2775
2858
  value: function getOrderIdentity() {
2776
- var _ref46, _ref47, _tempOrder$order_id, _tempOrder$_extend7;
2859
+ var _ref49, _ref50, _tempOrder$order_id, _tempOrder$_extend7;
2777
2860
  var tempOrder = this.store.tempOrder;
2778
2861
  if (!tempOrder) return null;
2779
2862
  var lastOrderInfo = this.store.lastOrderInfo || {};
2780
- 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;
2863
+ 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;
2781
2864
  return {
2782
2865
  localId: this.cacheId || ((_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.localId),
2783
2866
  orderId: orderId,
@@ -2909,9 +2992,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2909
2992
  }, {
2910
2993
  key: "sanitizeTempOrderProducts",
2911
2994
  value: function sanitizeTempOrderProducts(tempOrder) {
2912
- var _this16 = this;
2995
+ var _this17 = this;
2913
2996
  tempOrder.products = (tempOrder.products || []).map(function (product) {
2914
- return _this16.sanitizeOrderProductForTempOrder(_this16.normalizeVirtualSettlementProductIfEnabled(product));
2997
+ return _this17.sanitizeOrderProductForTempOrder(_this17.normalizeVirtualSettlementProductIfEnabled(product));
2915
2998
  });
2916
2999
  this.syncTempOrderSettlementState(tempOrder);
2917
3000
  ensureUniqueProductLineUids(tempOrder);
@@ -2947,11 +3030,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2947
3030
  }, {
2948
3031
  key: "captureProductRuntime",
2949
3032
  value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
2950
- var _extend$productsByUid, _ref48, _rawProduct$_origin;
3033
+ var _extend$productsByUid, _ref51, _rawProduct$_origin;
2951
3034
  var uid = existedUid || this.getProductUid(normalizedProduct);
2952
3035
  var extend = this.ensureExtend(tempOrder);
2953
3036
  var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
2954
- var origin = (_ref48 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref48 !== void 0 ? _ref48 : existed.origin;
3037
+ var origin = (_ref51 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref51 !== void 0 ? _ref51 : existed.origin;
2955
3038
  extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
2956
3039
  origin: origin
2957
3040
  } : {});
@@ -3031,7 +3114,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3031
3114
  }, {
3032
3115
  key: "syncLinkedBookingHoldersToProducts",
3033
3116
  value: function syncLinkedBookingHoldersToProducts(tempOrder) {
3034
- var _this17 = this;
3117
+ var _this18 = this;
3035
3118
  var bookings = tempOrder.bookings || [];
3036
3119
  var products = tempOrder.products || [];
3037
3120
  if (!bookings.length || !products.length) return;
@@ -3056,7 +3139,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3056
3139
  var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
3057
3140
  var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
3058
3141
  if (linkedBooking) {
3059
- _this17.setProductHolderFromBooking(product, linkedBooking);
3142
+ _this18.setProductHolderFromBooking(product, linkedBooking);
3060
3143
  }
3061
3144
  });
3062
3145
  }
@@ -3094,7 +3177,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3094
3177
  }, {
3095
3178
  key: "buildTempOrderHolderFromBookings",
3096
3179
  value: function buildTempOrderHolderFromBookings(tempOrder) {
3097
- var _baseHolder$customer_, _baseHolder, _ref49, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3180
+ var _baseHolder$customer_, _baseHolder, _ref52, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
3098
3181
  var holderRecords = [];
3099
3182
  var holderNames = [];
3100
3183
  var baseHolder = null;
@@ -3141,7 +3224,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3141
3224
  }
3142
3225
  var nextHolder = {
3143
3226
  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,
3144
- 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,
3227
+ 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,
3145
3228
  form_record: holderRecords
3146
3229
  };
3147
3230
  if (holderNames.length) {
@@ -3184,9 +3267,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3184
3267
  }, {
3185
3268
  key: "findBookingIndexByUniqueIdentificationNumber",
3186
3269
  value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
3187
- var _this18 = this;
3270
+ var _this19 = this;
3188
3271
  return (tempOrder.bookings || []).findIndex(function (booking) {
3189
- return _this18.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3272
+ return _this19.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
3190
3273
  });
3191
3274
  }
3192
3275
  }, {
@@ -3194,12 +3277,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3194
3277
  value: function removeLinkedBookingsForProduct(tempOrder, product) {
3195
3278
  var _product$metadata5,
3196
3279
  _product$metadata6,
3197
- _this19 = this;
3280
+ _this20 = this;
3198
3281
  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);
3199
3282
  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);
3200
3283
  if (!productUid && !bookingUid) return;
3201
3284
  tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
3202
- var currentBookingUid = _this19.getBookingUniqueIdentificationNumber(booking);
3285
+ var currentBookingUid = _this20.getBookingUniqueIdentificationNumber(booking);
3203
3286
  if (bookingUid && currentBookingUid === String(bookingUid)) return false;
3204
3287
  if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
3205
3288
  return true;
@@ -3246,7 +3329,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3246
3329
  key: "recalculateSummary",
3247
3330
  value: function () {
3248
3331
  var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
3249
- var _this$otherParams3, _ref50, _salesSummaryResult$e;
3332
+ var _this$otherParams3, _ref53, _salesSummaryResult$e;
3250
3333
  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;
3251
3334
  return _regeneratorRuntime().wrap(function _callee13$(_context15) {
3252
3335
  while (1) switch (_context15.prev = _context15.next) {
@@ -3325,7 +3408,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3325
3408
  roundingAmount = paidPaymentSummary.roundingAmount;
3326
3409
  payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
3327
3410
  hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
3328
- 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;
3411
+ 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;
3329
3412
  amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
3330
3413
  rounding_amount: roundingAmount.toFixed(2)
3331
3414
  }, expectAmount ? {
@@ -3448,8 +3531,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3448
3531
  }, {
3449
3532
  key: "getTempOrderNote",
3450
3533
  value: function getTempOrderNote() {
3451
- var _this$store$tempOrder4;
3452
- return ((_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.note) || '';
3534
+ var _this$store$tempOrder6;
3535
+ return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.note) || '';
3453
3536
  }
3454
3537
  }, {
3455
3538
  key: "ensureSalesNotesRuntimeState",
@@ -3501,7 +3584,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3501
3584
  }, {
3502
3585
  key: "removeSalesNotesForMissingProductLines",
3503
3586
  value: function removeSalesNotesForMissingProductLines(tempOrder) {
3504
- var _this20 = this;
3587
+ var _this21 = this;
3505
3588
  var state = this.ensureSalesNotesRuntimeState(tempOrder);
3506
3589
  if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
3507
3590
  return;
@@ -3513,7 +3596,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3513
3596
  return typeof uid === 'string' && uid.length > 0;
3514
3597
  }));
3515
3598
  var nextNotes = tempOrder.notes.filter(function (note) {
3516
- var primary = _this20.getSalesNotePrimaryRelation(note);
3599
+ var primary = _this21.getSalesNotePrimaryRelation(note);
3517
3600
  if (!primary || primary.target_type !== 'order_detail') return true;
3518
3601
  return remainingProductUids.has(primary.target_uuid);
3519
3602
  });
@@ -3525,7 +3608,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3525
3608
  key: "setSalesNoteOnTempOrder",
3526
3609
  value: function setSalesNoteOnTempOrder(tempOrder, input) {
3527
3610
  var _input$target,
3528
- _this21 = this,
3611
+ _this22 = this,
3529
3612
  _tempOrder$shop_order;
3530
3613
  this.ensureSalesNotesLoadedForMutation(tempOrder);
3531
3614
  var note_type = String(input.note_type || '').trim();
@@ -3549,7 +3632,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3549
3632
  var notes = tempOrder.notes || [];
3550
3633
  // 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
3551
3634
  var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
3552
- var primary = _this21.getSalesNotePrimaryRelation(note);
3635
+ var primary = _this22.getSalesNotePrimaryRelation(note);
3553
3636
  return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
3554
3637
  }) : -1;
3555
3638
  var existing = existingIndex >= 0 ? notes[existingIndex] : null;
@@ -3801,17 +3884,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3801
3884
  }, {
3802
3885
  key: "buildTempOrderCustomer",
3803
3886
  value: function buildTempOrderCustomer(params) {
3804
- 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;
3887
+ 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;
3805
3888
  if (!params.customerId) return null;
3806
3889
  var source = params.source ? cloneDeep(params.source) : {};
3807
- 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;
3808
- 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;
3890
+ 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;
3891
+ 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;
3809
3892
  return _objectSpread(_objectSpread({}, source), {}, {
3810
3893
  id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
3811
3894
  customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
3812
3895
  name: String(name || ''),
3813
3896
  customer_name: String(customerName || ''),
3814
- 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),
3897
+ 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),
3815
3898
  phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
3816
3899
  email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
3817
3900
  });
@@ -3831,15 +3914,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3831
3914
  }, {
3832
3915
  key: "productHasCustomerBoundDiscount",
3833
3916
  value: function productHasCustomerBoundDiscount(product) {
3834
- var _this22 = this;
3917
+ var _this23 = this;
3835
3918
  if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
3836
- return _this22.isCustomerBoundDiscount(discount);
3919
+ return _this23.isCustomerBoundDiscount(discount);
3837
3920
  })) {
3838
3921
  return true;
3839
3922
  }
3840
3923
  return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
3841
3924
  return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
3842
- return _this22.isCustomerBoundDiscount(discount);
3925
+ return _this23.isCustomerBoundDiscount(discount);
3843
3926
  });
3844
3927
  });
3845
3928
  }
@@ -3848,18 +3931,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3848
3931
  value: function shouldSkipDiscountCalculation(tempOrder) {
3849
3932
  var _this$store$discount20,
3850
3933
  _this$store$discount21,
3851
- _this23 = this;
3934
+ _this24 = this;
3852
3935
  if (this.hasActiveCustomerBoundDiscount) return false;
3853
3936
  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)) || [];
3854
3937
  if (discountList.length > 0) return false;
3855
3938
  return !(tempOrder.products || []).some(function (product) {
3856
- return _this23.productHasCustomerBoundDiscount(product);
3939
+ return _this24.productHasCustomerBoundDiscount(product);
3857
3940
  });
3858
3941
  }
3859
3942
  }, {
3860
3943
  key: "clearCustomerBoundDiscounts",
3861
3944
  value: function clearCustomerBoundDiscounts(tempOrder) {
3862
- var _this24 = this,
3945
+ var _this25 = this,
3863
3946
  _discountModule$getDi,
3864
3947
  _discountModule$getOr,
3865
3948
  _discountModule$setDi,
@@ -3868,7 +3951,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3868
3951
  var filterDiscountList = function filterDiscountList(discountList) {
3869
3952
  if (!Array.isArray(discountList)) return [];
3870
3953
  return discountList.filter(function (discount) {
3871
- var shouldRemove = _this24.isCustomerBoundDiscount(discount);
3954
+ var shouldRemove = _this25.isCustomerBoundDiscount(discount);
3872
3955
  if (shouldRemove) didRemoveCustomerBoundDiscount = true;
3873
3956
  return !shouldRemove;
3874
3957
  });
@@ -3895,12 +3978,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3895
3978
  var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
3896
3979
  var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
3897
3980
  var nextDiscounts = currentDiscounts.filter(function (discount) {
3898
- if (_this24.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3899
- return !_this24.isCustomerBoundDiscount(discount);
3981
+ if (_this25.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3982
+ return !_this25.isCustomerBoundDiscount(discount);
3900
3983
  });
3901
3984
  var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
3902
- if (_this24.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3903
- return !_this24.isCustomerBoundDiscount(discount);
3985
+ if (_this25.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
3986
+ return !_this25.isCustomerBoundDiscount(discount);
3904
3987
  });
3905
3988
  void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
3906
3989
  void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
@@ -3915,14 +3998,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3915
3998
  }, {
3916
3999
  key: "updateTempOrderCustomer",
3917
4000
  value: function updateTempOrderCustomer(customer) {
3918
- var _tempOrder$customer_i3, _ref58, _ref59, _customer$customer_id, _ref60, _ref61, _ref62, _customer$customer_na, _ref63, _customer$country_cal, _tempOrder$customer_i4;
4001
+ var _tempOrder$customer_i3, _ref61, _ref62, _customer$customer_id, _ref63, _ref64, _ref65, _customer$customer_na, _ref66, _customer$country_cal, _tempOrder$customer_i4;
3919
4002
  var tempOrder = this.ensureTempOrder();
3920
4003
  var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
3921
- 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;
3922
- 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 : '';
4004
+ 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;
4005
+ 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 : '';
3923
4006
  tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
3924
4007
  tempOrder.customer_name = String(customerName || '');
3925
- 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 : '');
4008
+ 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 : '');
3926
4009
  tempOrder.phone = String(customer.phone || '');
3927
4010
  tempOrder.email = String(customer.email || '');
3928
4011
  tempOrder.customer = this.buildTempOrderCustomer({
@@ -4003,8 +4086,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4003
4086
  }, {
4004
4087
  key: "getOrderCustomerSnapshot",
4005
4088
  value: function getOrderCustomerSnapshot() {
4006
- var _this$store$tempOrder5;
4007
- 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;
4089
+ var _this$store$tempOrder7;
4090
+ var snapshot = (_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 || (_this$store$tempOrder7 = _this$store$tempOrder7._extend) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.customerSnapshot;
4008
4091
  return snapshot ? cloneDeep(snapshot) : null;
4009
4092
  }
4010
4093
  }, {
@@ -4064,10 +4147,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4064
4147
  }, {
4065
4148
  key: "setOrderPayments",
4066
4149
  value: function setOrderPayments(payments) {
4067
- var _this25 = this;
4150
+ var _this26 = this;
4068
4151
  var tempOrder = this.ensureTempOrder();
4069
4152
  tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
4070
- return _this25.normalizePaymentSource(payment, {
4153
+ return _this26.normalizePaymentSource(payment, {
4071
4154
  defaultPaid: false
4072
4155
  });
4073
4156
  }));
@@ -4122,7 +4205,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4122
4205
  }, {
4123
4206
  key: "addOrderPaymentWithDevicePrefix",
4124
4207
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4125
- var _this26 = this;
4208
+ var _this27 = this;
4126
4209
  this.logInfo('addOrderPayment', {
4127
4210
  payment: payment
4128
4211
  });
@@ -4140,7 +4223,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4140
4223
  void this.recalculateSummary({
4141
4224
  createIfMissing: true
4142
4225
  }).catch(function (error) {
4143
- _this26.logError('recalculate summary after addOrderPayment failed', {
4226
+ _this27.logError('recalculate summary after addOrderPayment failed', {
4144
4227
  error: error instanceof Error ? error.message : String(error)
4145
4228
  });
4146
4229
  });
@@ -4253,7 +4336,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4253
4336
  }, {
4254
4337
  key: "applyPaymentLifecycleChange",
4255
4338
  value: function applyPaymentLifecycleChange(tempOrder, options) {
4256
- var _this27 = this;
4339
+ var _this28 = this;
4257
4340
  this.updateTempOrderPaymentStatus(tempOrder);
4258
4341
  if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
4259
4342
  this.persistTempOrder();
@@ -4263,7 +4346,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4263
4346
  void this.recalculateSummary({
4264
4347
  createIfMissing: true
4265
4348
  }).catch(function (error) {
4266
- _this27.logError("recalculate summary after ".concat(logContext, " failed"), {
4349
+ _this28.logError("recalculate summary after ".concat(logContext, " failed"), {
4267
4350
  error: error instanceof Error ? error.message : String(error)
4268
4351
  });
4269
4352
  });
@@ -4307,7 +4390,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4307
4390
  }, {
4308
4391
  key: "updateVoucherOrderPayments",
4309
4392
  value: function updateVoucherOrderPayments(payments, options) {
4310
- var _this28 = this;
4393
+ var _this29 = this;
4311
4394
  var tempOrder = this.ensureTempOrder();
4312
4395
  var isOrderPaymentType = function isOrderPaymentType(value) {
4313
4396
  return value === 'normal' || value === 'deposit';
@@ -4342,7 +4425,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4342
4425
  });
4343
4426
  };
4344
4427
  var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
4345
- return _this28.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4428
+ return _this29.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
4346
4429
  defaultPaid: false,
4347
4430
  devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
4348
4431
  });
@@ -4395,7 +4478,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4395
4478
  void this.recalculateSummary({
4396
4479
  createIfMissing: true
4397
4480
  }).catch(function (error) {
4398
- _this28.logError('recalculate summary after updateVoucherOrderPayments failed', {
4481
+ _this29.logError('recalculate summary after updateVoucherOrderPayments failed', {
4399
4482
  error: error instanceof Error ? error.message : String(error)
4400
4483
  });
4401
4484
  });
@@ -4453,7 +4536,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4453
4536
  key: "shouldMergeProductToOrder",
4454
4537
  value: function shouldMergeProductToOrder(params) {
4455
4538
  var _this$orderHooks,
4456
- _this29 = this;
4539
+ _this30 = this;
4457
4540
  var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
4458
4541
  if (!onBeforeMergeProductToOrder) return true;
4459
4542
  var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
@@ -4461,7 +4544,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4461
4544
  }));
4462
4545
  if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
4463
4546
  return Promise.resolve(result).then(function (resolved) {
4464
- return _this29.normalizeShouldMergeProductResult(resolved);
4547
+ return _this30.normalizeShouldMergeProductResult(resolved);
4465
4548
  });
4466
4549
  }
4467
4550
  return this.normalizeShouldMergeProductResult(result);
@@ -4510,7 +4593,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4510
4593
  }, {
4511
4594
  key: "assertAndLockProductSettlement",
4512
4595
  value: function assertAndLockProductSettlement(tempOrder, product) {
4513
- var _ref64, _ref65, _product$selling_pric;
4596
+ var _ref67, _ref68, _product$selling_pric;
4514
4597
  if (!this.isMultiCurrencySettlementEnabled()) return;
4515
4598
  var currentKey = getTempOrderSettlementKey(tempOrder);
4516
4599
  var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
@@ -4537,7 +4620,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4537
4620
  }
4538
4621
  applyTempOrderSettlementState(tempOrder, snapshot || {
4539
4622
  settlement_type: 'legal_currency',
4540
- 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,
4623
+ 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,
4541
4624
  unit_label: tempOrder.currency_code,
4542
4625
  symbol: tempOrder.currency_symbol,
4543
4626
  amount_format: tempOrder.currency_format
@@ -4662,7 +4745,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4662
4745
  _metadata,
4663
4746
  _productToAdd$metadat,
4664
4747
  _origin,
4665
- _this30 = this;
4748
+ _this31 = this;
4666
4749
  var linked = booking ? this.createLinkedProductAndBooking({
4667
4750
  product: product,
4668
4751
  booking: booking
@@ -4696,8 +4779,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4696
4779
  var shouldForceNewLine = disableMerge || !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
4697
4780
  var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
4698
4781
  var _item$metadata3;
4699
- if (_this30.hasGoodPassDiscount(item)) return false;
4700
- if (_this30.hasOrderProductLineNote(item)) return false;
4782
+ if (_this31.hasGoodPassDiscount(item)) return false;
4783
+ if (_this31.hasOrderProductLineNote(item)) return false;
4701
4784
  if (isManualProductDiscountProduct(item)) return false;
4702
4785
  if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
4703
4786
  if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
@@ -4711,7 +4794,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4711
4794
  var commitProductLine = function commitProductLine(shouldMerge) {
4712
4795
  var committedProduct;
4713
4796
  if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
4714
- _this30.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4797
+ _this31.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
4715
4798
  if (linked) {
4716
4799
  normalizedIncoming.booking_uid = linked.bookingUid;
4717
4800
  normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
@@ -4729,7 +4812,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4729
4812
  var _targetProduct$metada;
4730
4813
  var targetProduct = matchedProduct;
4731
4814
  var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
4732
- var normalizedProduct = _this30.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4815
+ var normalizedProduct = _this31.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
4733
4816
  metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
4734
4817
  unique_identification_number: targetUid
4735
4818
  })
@@ -4752,7 +4835,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4752
4835
  order_detail_id: targetProduct.order_detail_id,
4753
4836
  num: nextNum
4754
4837
  });
4755
- _this30.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4838
+ _this31.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
4756
4839
  committedProduct = tempOrder.products[matchedIndex];
4757
4840
  if (matchedIndex !== tempOrder.products.length - 1) {
4758
4841
  var mergedProduct = tempOrder.products[matchedIndex];
@@ -4790,14 +4873,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4790
4873
  }, {
4791
4874
  key: "createSplitBookingLine",
4792
4875
  value: function createSplitBookingLine(product, booking, index, splitCount) {
4793
- var _booking$metadata6, _ref66, _ref67, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
4876
+ var _booking$metadata6, _ref69, _ref70, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
4794
4877
  var singleLine = cloneDeep(product);
4795
4878
  singleLine.num = 1;
4796
4879
  delete singleLine.product_quantity;
4797
4880
  var singleBooking = cloneDeep(booking);
4798
4881
  var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
4799
4882
  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;
4800
- 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;
4883
+ 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;
4801
4884
  var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
4802
4885
  return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
4803
4886
  }).filter(function (holderId) {
@@ -4862,8 +4945,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4862
4945
  key: "addProductToOrder",
4863
4946
  value: (function () {
4864
4947
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
4865
- var _this31 = this;
4866
- var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref68, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
4948
+ var _this32 = this;
4949
+ var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
4867
4950
  return _regeneratorRuntime().wrap(function _callee23$(_context25) {
4868
4951
  while (1) switch (_context25.prev = _context25.next) {
4869
4952
  case 0:
@@ -4891,7 +4974,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4891
4974
  throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
4892
4975
  }
4893
4976
  salesNoteDrafts.forEach(function (draft) {
4894
- _this31.setSalesNoteOnTempOrder(tempOrder, {
4977
+ _this32.setSalesNoteOnTempOrder(tempOrder, {
4895
4978
  note_type: draft.note_type,
4896
4979
  target: {
4897
4980
  target_type: 'order_detail',
@@ -4921,7 +5004,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4921
5004
  break;
4922
5005
  }
4923
5006
  productRecord = product;
4924
- splitCount = getSafeProductNum((_ref68 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref68 !== void 0 ? _ref68 : 1);
5007
+ splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
4925
5008
  if (!(splitCount > 1)) {
4926
5009
  _context25.next = 27;
4927
5010
  break;
@@ -5026,7 +5109,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5026
5109
  key: "addProductsToOrder",
5027
5110
  value: (function () {
5028
5111
  var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
5029
- var tempOrder, _iterator20, _step20, item, product, booking, _ref69, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5112
+ var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
5030
5113
  return _regeneratorRuntime().wrap(function _callee24$(_context26) {
5031
5114
  while (1) switch (_context26.prev = _context26.next) {
5032
5115
  case 0:
@@ -5058,7 +5141,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5058
5141
  break;
5059
5142
  }
5060
5143
  productRecord = product;
5061
- splitCount = getSafeProductNum((_ref69 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref69 !== void 0 ? _ref69 : 1);
5144
+ splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
5062
5145
  if (!(splitCount > 1)) {
5063
5146
  _context26.next = 26;
5064
5147
  break;
@@ -5146,24 +5229,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5146
5229
  }, {
5147
5230
  key: "getBundleRuntimeIdentity",
5148
5231
  value: function getBundleRuntimeIdentity(bundle) {
5149
- var _ref70, _bundle$bundle_id2, _ref71, _bundle$bundle_group_2, _ref72, _ref73, _bundle$bundle_produc3, _ref74, _bundle$bundle_varian3;
5232
+ var _ref73, _bundle$bundle_id2, _ref74, _bundle$bundle_group_2, _ref75, _ref76, _bundle$bundle_produc3, _ref77, _bundle$bundle_varian3;
5150
5233
  if (!bundle || _typeof(bundle) !== 'object') return '';
5151
- return [(_ref70 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref70 !== void 0 ? _ref70 : '', (_ref71 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref71 !== void 0 ? _ref71 : '', (_ref72 = (_ref73 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref73 !== void 0 ? _ref73 : bundle.product_id) !== null && _ref72 !== void 0 ? _ref72 : '', (_ref74 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref74 !== void 0 ? _ref74 : 0].join('|');
5234
+ return [(_ref73 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref73 !== void 0 ? _ref73 : '', (_ref74 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref74 !== void 0 ? _ref74 : '', (_ref75 = (_ref76 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref76 !== void 0 ? _ref76 : bundle.product_id) !== null && _ref75 !== void 0 ? _ref75 : '', (_ref77 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref77 !== void 0 ? _ref77 : 0].join('|');
5152
5235
  }
5153
5236
  }, {
5154
5237
  key: "preservePersistedBundlePriceFields",
5155
5238
  value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
5156
- var _this32 = this;
5239
+ var _this33 = this;
5157
5240
  if (!Array.isArray(nextBundles)) return nextBundles;
5158
5241
  if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
5159
5242
  var previousByIdentity = new Map();
5160
5243
  previousBundles.forEach(function (bundle) {
5161
- var identity = _this32.getBundleRuntimeIdentity(bundle);
5244
+ var identity = _this33.getBundleRuntimeIdentity(bundle);
5162
5245
  if (identity) previousByIdentity.set(identity, bundle);
5163
5246
  });
5164
5247
  return nextBundles.map(function (bundle, index) {
5165
5248
  if (!bundle || _typeof(bundle) !== 'object') return bundle;
5166
- var previous = previousByIdentity.get(_this32.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5249
+ var previous = previousByIdentity.get(_this33.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
5167
5250
  if (!previous || _typeof(previous) !== 'object') return bundle;
5168
5251
  return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
5169
5252
  cover: previous.cover
@@ -5299,13 +5382,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5299
5382
  delete nextProduct.metadata.main_product_original_price;
5300
5383
  delete nextProduct.metadata.price_schema_version;
5301
5384
  } else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
5302
- var _ref75, _targetProduct$metada10, _targetProduct$metada11, _ref76, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5385
+ var _ref78, _targetProduct$metada10, _targetProduct$metada11, _ref79, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
5303
5386
  // 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
5304
5387
  // 但必须让 original 与 selling 一起随新的 option 金额移动。
5305
5388
  var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
5306
5389
  var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
5307
- var _previousMainOriginal = new Decimal(Number((_ref75 = (_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 && _ref75 !== void 0 ? _ref75 : 0) || 0);
5308
- var _previousMainSelling = new Decimal(Number((_ref76 = (_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 && _ref76 !== void 0 ? _ref76 : _previousMainOriginal.toNumber()) || 0);
5390
+ var _previousMainOriginal = new Decimal(Number((_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 0) || 0);
5391
+ var _previousMainSelling = new Decimal(Number((_ref79 = (_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 && _ref79 !== void 0 ? _ref79 : _previousMainOriginal.toNumber()) || 0);
5309
5392
  var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
5310
5393
  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);
5311
5394
  var _nextMainOriginal = previousSource.plus(nextOptionSum);
@@ -5405,7 +5488,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5405
5488
  key: "updateOrderProducts",
5406
5489
  value: function () {
5407
5490
  var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
5408
- var _this33 = this;
5491
+ var _this34 = this;
5409
5492
  var tempOrder, reapplyBookingDiscountProductUids;
5410
5493
  return _regeneratorRuntime().wrap(function _callee26$(_context28) {
5411
5494
  while (1) switch (_context28.prev = _context28.next) {
@@ -5418,7 +5501,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5418
5501
  return _context28.abrupt("return", tempOrder.products);
5419
5502
  case 3:
5420
5503
  reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
5421
- var updatedProductUid = _this33.applyOrderProductUpdateToTempOrder(tempOrder, params);
5504
+ var updatedProductUid = _this34.applyOrderProductUpdateToTempOrder(tempOrder, params);
5422
5505
  // 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
5423
5506
  if (params.allow_booking_discount_reapply && updatedProductUid) {
5424
5507
  acc.push(String(updatedProductUid));
@@ -5644,7 +5727,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5644
5727
  key: "removeProductsFromOrder",
5645
5728
  value: (function () {
5646
5729
  var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
5647
- var _this34 = this;
5730
+ var _this35 = this;
5648
5731
  var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
5649
5732
  return _regeneratorRuntime().wrap(function _callee29$(_context32) {
5650
5733
  while (1) switch (_context32.prev = _context32.next) {
@@ -5709,7 +5792,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5709
5792
  }
5710
5793
  if (productUid !== undefined && productUid !== null && productUid !== '') {
5711
5794
  bookingsBeforeRemove.forEach(function (booking) {
5712
- var bookingUid = _this34.getBookingUniqueIdentificationNumber(booking);
5795
+ var bookingUid = _this35.getBookingUniqueIdentificationNumber(booking);
5713
5796
  if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
5714
5797
  linkedBookingUidsToRemove.add(bookingUid);
5715
5798
  }
@@ -5924,23 +6007,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5924
6007
  }, {
5925
6008
  key: "buildCurrentSubmitPayloadForLocalPrint",
5926
6009
  value: function buildCurrentSubmitPayloadForLocalPrint(params) {
5927
- var _params$cacheId, _this$otherParams5, _ref77, _params$businessCode, _this$otherParams6, _this$otherParams7;
6010
+ var _params$cacheId, _this$otherParams5, _ref80, _params$businessCode, _this$otherParams6, _this$otherParams7;
5928
6011
  var tempOrder = this.ensureTempOrder();
5929
6012
  this.persistTempOrder();
5930
6013
  var payload = buildSubmitPayload({
5931
6014
  tempOrder: tempOrder,
5932
6015
  cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
5933
6016
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
5934
- businessCode: (_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
6017
+ businessCode: (_ref80 = (_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 && _ref80 !== void 0 ? _ref80 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
5935
6018
  channel: params === null || params === void 0 ? void 0 : params.channel,
5936
6019
  type: params === null || params === void 0 ? void 0 : params.type,
5937
6020
  summary: this.store.summary || createEmptySummary(),
5938
6021
  enhance: function enhance(nextPayload) {
5939
- var _ref78, _tempOrder$order_numb, _ref79, _tempOrder$shop_order2, _ref80, _tempOrder$shop_full_;
6022
+ var _ref81, _tempOrder$order_numb, _ref82, _tempOrder$shop_order2, _ref83, _tempOrder$shop_full_;
5940
6023
  return _objectSpread(_objectSpread({}, nextPayload), {}, {
5941
- order_number: (_ref78 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref78 !== void 0 ? _ref78 : null,
5942
- shop_order_number: (_ref79 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref79 !== void 0 ? _ref79 : null,
5943
- shop_full_order_number: (_ref80 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref80 !== void 0 ? _ref80 : null,
6024
+ order_number: (_ref81 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref81 !== void 0 ? _ref81 : null,
6025
+ shop_order_number: (_ref82 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref82 !== void 0 ? _ref82 : null,
6026
+ shop_full_order_number: (_ref83 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref83 !== void 0 ? _ref83 : null,
5944
6027
  small_ticket_data_flag: 1
5945
6028
  });
5946
6029
  }
@@ -6104,7 +6187,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6104
6187
  key: "runSubmitTempOrder",
6105
6188
  value: function () {
6106
6189
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
6107
- var _params$cacheId3, _this$otherParams12, _ref81, _ref82, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6190
+ var _params$cacheId3, _this$otherParams12, _ref84, _ref85, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
6108
6191
  var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
6109
6192
  return _regeneratorRuntime().wrap(function _callee37$(_context40) {
6110
6193
  while (1) switch (_context40.prev = _context40.next) {
@@ -6171,7 +6254,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6171
6254
  tempOrder: tempOrder,
6172
6255
  cacheId: effectiveCacheId,
6173
6256
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
6174
- businessCode: (_ref81 = (_ref82 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref82 !== void 0 ? _ref82 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref81 !== void 0 ? _ref81 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6257
+ businessCode: (_ref84 = (_ref85 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref85 !== void 0 ? _ref85 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref84 !== void 0 ? _ref84 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
6175
6258
  channel: params === null || params === void 0 ? void 0 : params.channel,
6176
6259
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
6177
6260
  summary: latestSummary,
@@ -6341,10 +6424,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6341
6424
  value: function extractSubmitErrorResponse(error) {
6342
6425
  var _error$response,
6343
6426
  _error$response2,
6344
- _this35 = this;
6427
+ _this36 = this;
6345
6428
  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];
6346
6429
  return candidates.find(function (candidate) {
6347
- return _this35.isSubmitErrorResponse(candidate);
6430
+ return _this36.isSubmitErrorResponse(candidate);
6348
6431
  }) || null;
6349
6432
  }
6350
6433
  }, {
@@ -6372,7 +6455,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6372
6455
  key: "syncPaymentsToOrder",
6373
6456
  value: function () {
6374
6457
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
6375
- var _this36 = this,
6458
+ var _this37 = this,
6376
6459
  _params$confirmPendin;
6377
6460
  var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
6378
6461
  return _regeneratorRuntime().wrap(function _callee39$(_context42) {
@@ -6397,7 +6480,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6397
6480
  case 9:
6398
6481
  devicePrefix = _context42.t0;
6399
6482
  mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
6400
- return _this36.normalizePaymentSource(payment, {
6483
+ return _this37.normalizePaymentSource(payment, {
6401
6484
  defaultPaid: false,
6402
6485
  devicePrefix: devicePrefix
6403
6486
  });
@@ -6476,7 +6559,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6476
6559
  }, {
6477
6560
  key: "createOrder",
6478
6561
  value: function createOrder(params) {
6479
- var _this37 = this;
6562
+ var _this38 = this;
6480
6563
  var order = _objectSpread({
6481
6564
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
6482
6565
  // 要从外面拿,virtual
@@ -6508,7 +6591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6508
6591
 
6509
6592
  // 为预约补齐 holder 信息
6510
6593
  if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
6511
- ensureCartItemOriginHolder(item, _this37.window);
6594
+ ensureCartItemOriginHolder(item, _this38.window);
6512
6595
  }
6513
6596
 
6514
6597
  // 购物车是否为普通商品
@@ -7211,7 +7294,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7211
7294
  }, {
7212
7295
  key: "normalizeTempOrderForRuntime",
7213
7296
  value: function normalizeTempOrderForRuntime(raw, options) {
7214
- var _this38 = this,
7297
+ var _this39 = this,
7215
7298
  _raw$_extend;
7216
7299
  var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
7217
7300
  var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
@@ -7236,12 +7319,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7236
7319
  nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
7237
7320
  var rawProducts = Array.isArray(raw.products) ? raw.products : [];
7238
7321
  nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
7239
- return _this38.normalizeHydratedOrderProduct(p, {
7322
+ return _this39.normalizeHydratedOrderProduct(p, {
7240
7323
  makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
7241
7324
  });
7242
7325
  }) : [];
7243
7326
  nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
7244
- var booking = _this38.normalizeHydratedBookingHolder(b || {});
7327
+ var booking = _this39.normalizeHydratedBookingHolder(b || {});
7245
7328
  return _objectSpread(_objectSpread({}, booking), {}, {
7246
7329
  is_all: normalizeBookingIsAll(booking),
7247
7330
  sub_type: normalizeBookingSubType(booking)
@@ -7291,7 +7374,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7291
7374
  _step24;
7292
7375
  try {
7293
7376
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
7294
- var _product$metadata12, _ref83, _ref84, _existed$origin, _rawProduct$metadata;
7377
+ var _product$metadata12, _ref86, _ref87, _existed$origin, _rawProduct$metadata;
7295
7378
  var _step24$value = _slicedToArray(_step24.value, 2),
7296
7379
  index = _step24$value[0],
7297
7380
  product = _step24$value[1];
@@ -7299,7 +7382,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7299
7382
  if (!uid) continue;
7300
7383
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
7301
7384
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
7302
- var origin = (_ref83 = (_ref84 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref84 !== void 0 ? _ref84 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref83 !== void 0 ? _ref83 : rawProduct;
7385
+ var origin = (_ref86 = (_ref87 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref87 !== void 0 ? _ref87 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref86 !== void 0 ? _ref86 : rawProduct;
7303
7386
  var originSnapshot = cloneDeep(origin);
7304
7387
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
7305
7388
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -7428,10 +7511,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7428
7511
  }, {
7429
7512
  key: "normalizeHydratedProductOptionItem",
7430
7513
  value: function normalizeHydratedProductOptionItem(optionItem) {
7431
- var _ref85, _optionItem$num, _ref86, _optionItem$add_price;
7432
- var rawNum = (_ref85 = (_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 && _ref85 !== void 0 ? _ref85 : 1;
7514
+ var _ref88, _optionItem$num, _ref89, _optionItem$add_price;
7515
+ var rawNum = (_ref88 = (_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 && _ref88 !== void 0 ? _ref88 : 1;
7433
7516
  var parsedNum = Number(rawNum);
7434
- var rawPrice = (_ref86 = (_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 && _ref86 !== void 0 ? _ref86 : 0;
7517
+ var rawPrice = (_ref89 = (_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 && _ref89 !== void 0 ? _ref89 : 0;
7435
7518
  var parsedPrice = Number(rawPrice);
7436
7519
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
7437
7520
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -7448,7 +7531,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7448
7531
  }, {
7449
7532
  key: "normalizeHydratedOrderProduct",
7450
7533
  value: function normalizeHydratedOrderProduct(product, options) {
7451
- var _this39 = this;
7534
+ var _this40 = this;
7452
7535
  var row = _objectSpread({}, product || {});
7453
7536
  if (row.num === undefined && row.product_quantity !== undefined) {
7454
7537
  row.num = row.product_quantity;
@@ -7456,7 +7539,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7456
7539
  var productSku = ensureProductSku(row);
7457
7540
  row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
7458
7541
  option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
7459
- return _this39.normalizeHydratedProductOptionItem(optionItem || {});
7542
+ return _this40.normalizeHydratedProductOptionItem(optionItem || {});
7460
7543
  }))
7461
7544
  });
7462
7545
  delete row["product_".concat('option', "_item")];
@@ -7544,8 +7627,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7544
7627
  }, {
7545
7628
  key: "getVouchers",
7546
7629
  value: function getVouchers() {
7547
- var _this$store$tempOrder6;
7548
- return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.vouchers) || [];
7630
+ var _this$store$tempOrder8;
7631
+ return ((_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.vouchers) || [];
7549
7632
  }
7550
7633
  }], [{
7551
7634
  key: "populateSavedAmounts",