@pisell/pisellos 0.10.50 → 0.10.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  3. package/dist/modules/FulfillmentTiming/index.js +407 -0
  4. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  5. package/dist/modules/FulfillmentTiming/types.js +1 -0
  6. package/dist/modules/OpenData/types.d.ts +6 -0
  7. package/dist/modules/Order/index.d.ts +18 -1
  8. package/dist/modules/Order/index.js +322 -195
  9. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  10. package/dist/modules/Order/pickupTiming.js +53 -0
  11. package/dist/modules/Order/types.d.ts +11 -1
  12. package/dist/modules/Order/utils.d.ts +10 -0
  13. package/dist/modules/Order/utils.js +145 -85
  14. package/dist/modules/Rules/index.js +3 -2
  15. package/dist/modules/index.d.ts +1 -0
  16. package/dist/modules/index.js +1 -0
  17. package/dist/server/modules/order/index.d.ts +8 -0
  18. package/dist/server/modules/order/index.js +506 -453
  19. package/dist/server/modules/order/types.d.ts +1 -0
  20. package/dist/server/utils/small-ticket.js +165 -94
  21. package/dist/solution/BaseSales/index.d.ts +23 -0
  22. package/dist/solution/BaseSales/index.js +1214 -1031
  23. package/dist/solution/BaseSales/pickupTiming.d.ts +37 -0
  24. package/dist/solution/BaseSales/pickupTiming.js +482 -0
  25. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  26. package/dist/solution/BookingByStep/index.d.ts +1 -1
  27. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  28. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -0
  29. package/dist/solution/UnifiedBookingSales/index.js +583 -531
  30. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  31. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  32. package/lib/modules/FulfillmentTiming/index.js +359 -0
  33. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  34. package/lib/modules/FulfillmentTiming/types.js +5 -0
  35. package/lib/modules/OpenData/types.d.ts +6 -0
  36. package/lib/modules/Order/index.d.ts +18 -1
  37. package/lib/modules/Order/index.js +101 -3
  38. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  39. package/lib/modules/Order/pickupTiming.js +61 -0
  40. package/lib/modules/Order/types.d.ts +11 -1
  41. package/lib/modules/Order/utils.d.ts +10 -0
  42. package/lib/modules/Order/utils.js +58 -4
  43. package/lib/modules/Rules/index.js +3 -2
  44. package/lib/modules/index.d.ts +1 -0
  45. package/lib/modules/index.js +11 -0
  46. package/lib/server/modules/order/index.d.ts +8 -0
  47. package/lib/server/modules/order/index.js +19 -0
  48. package/lib/server/modules/order/types.d.ts +1 -0
  49. package/lib/server/utils/small-ticket.js +86 -22
  50. package/lib/solution/BaseSales/index.d.ts +23 -0
  51. package/lib/solution/BaseSales/index.js +102 -1
  52. package/lib/solution/BaseSales/pickupTiming.d.ts +37 -0
  53. package/lib/solution/BaseSales/pickupTiming.js +222 -0
  54. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  55. package/lib/solution/BookingByStep/index.d.ts +1 -1
  56. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  57. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -0
  58. package/lib/solution/UnifiedBookingSales/index.js +20 -0
  59. package/package.json +1 -1
@@ -33,6 +33,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
33
33
  import { BaseModule } from "../../modules/BaseModule";
34
34
  import { BaseSalesHookNames } from "./types";
35
35
  import { OrderModule } from "../../modules/Order";
36
+ import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
37
+ import { PickupTimingController } from "./pickupTiming";
36
38
  import Decimal from 'decimal.js';
37
39
  import { cloneDeep, isEqual, mergeWith } from 'lodash-es';
38
40
  import { createModule } from "../BookingByStep/types";
@@ -44,7 +46,7 @@ import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrder
44
46
  import dayjs from 'dayjs';
45
47
  export * from "./types";
46
48
  import { isProductQueryHandledByOsServer, PRODUCT_QUERY_DATA_VARIANT_RELATIONS, resolveClientDataVariants, tryResolveClientDataVariants } from "../../modules/ProductList/clientDataVariants";
47
- import { isCustomerUserPlatform } from "../../utils/platform";
49
+ import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/platform";
48
50
  import { QuotationModule } from "../../modules/Quotation";
49
51
  import { transformBaseProductToOrderProduct as _transformBaseProductToOrderProduct } from "./utils/transformBaseProductToOrderProduct";
50
52
  import { calculateBaseSalesProductBookingPrice } from "./utils/quotationPrice";
@@ -552,6 +554,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
552
554
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeHydrateInFlight", null);
553
555
  _defineProperty(_assertThisInitialized(_this), "queuedServerOrderChanges", []);
554
556
  _defineProperty(_assertThisInitialized(_this), "serverOrderChangeSyncEnabled", false);
557
+ _defineProperty(_assertThisInitialized(_this), "pickupTimingEnabled", false);
558
+ _defineProperty(_assertThisInitialized(_this), "pickupTimingController", void 0);
555
559
  return _this;
556
560
  }
557
561
 
@@ -1572,6 +1576,117 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1572
1576
  return (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel;
1573
1577
  }
1574
1578
 
1579
+ /** Only solutions opting into Pickup Timing supply effective OpenData. */
1580
+ }, {
1581
+ key: "loadPickupTimingOpenData",
1582
+ value: (function () {
1583
+ var _loadPickupTimingOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_force) {
1584
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1585
+ while (1) switch (_context10.prev = _context10.next) {
1586
+ case 0:
1587
+ return _context10.abrupt("return", {});
1588
+ case 1:
1589
+ case "end":
1590
+ return _context10.stop();
1591
+ }
1592
+ }, _callee10);
1593
+ }));
1594
+ function loadPickupTimingOpenData(_x9) {
1595
+ return _loadPickupTimingOpenData.apply(this, arguments);
1596
+ }
1597
+ return loadPickupTimingOpenData;
1598
+ }())
1599
+ }, {
1600
+ key: "isPickupTimingEnabled",
1601
+ value: function isPickupTimingEnabled() {
1602
+ var _this$otherParams9;
1603
+ return this.pickupTimingEnabled && ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.enablePickupTiming) !== false;
1604
+ }
1605
+ }, {
1606
+ key: "getPickupTimingContextData",
1607
+ value: function getPickupTimingContextData(key) {
1608
+ var _this$core4;
1609
+ var context = (_this$core4 = this.core) === null || _this$core4 === void 0 ? void 0 : _this$core4.context;
1610
+ var getData = context === null || context === void 0 ? void 0 : context.getData;
1611
+ return typeof getData === 'function' ? getData.call(context, key) : undefined;
1612
+ }
1613
+ }, {
1614
+ key: "getPickupTimingScope",
1615
+ value: function getPickupTimingScope() {
1616
+ var _this$otherParams$bus, _this$otherParams10, _this$otherParams11, _this$otherParams12;
1617
+ return JSON.stringify({
1618
+ shop: this.getPickupTimingContextData('shop_id'),
1619
+ businessCode: (_this$otherParams$bus = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.business_code,
1620
+ channel: this.getSubmitOrderSalesChannel(),
1621
+ timezone: this.getPickupTimingContextData('timezone'),
1622
+ platform: normalizeRuntimePlatform((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
1623
+ cacheId: this.cacheId
1624
+ });
1625
+ }
1626
+ }, {
1627
+ key: "getPickupTimingController",
1628
+ value: function getPickupTimingController() {
1629
+ var _this8 = this;
1630
+ if (!this.pickupTimingController) {
1631
+ this.pickupTimingController = new PickupTimingController({
1632
+ getOrder: function getOrder() {
1633
+ if (!_this8.store.order) throw new Error('order 模块未初始化');
1634
+ return _this8.store.order;
1635
+ },
1636
+ getSchedule: function getSchedule() {
1637
+ return _this8.store.schedule;
1638
+ },
1639
+ loadOpenData: function loadOpenData(force) {
1640
+ return _this8.loadPickupTimingOpenData(force);
1641
+ },
1642
+ getTimezone: function getTimezone() {
1643
+ var _this8$getPickupTimin;
1644
+ return String((_this8$getPickupTimin = _this8.getPickupTimingContextData('timezone')) !== null && _this8$getPickupTimin !== void 0 ? _this8$getPickupTimin : '');
1645
+ },
1646
+ getScope: function getScope() {
1647
+ return _this8.getPickupTimingScope();
1648
+ },
1649
+ isPos: function isPos() {
1650
+ var _this8$otherParams;
1651
+ return normalizeRuntimePlatform((_this8$otherParams = _this8.otherParams) === null || _this8$otherParams === void 0 ? void 0 : _this8$otherParams.platform) === 'pos';
1652
+ }
1653
+ });
1654
+ }
1655
+ return this.pickupTimingController;
1656
+ }
1657
+ }, {
1658
+ key: "getPickupTimingAvailability",
1659
+ value: function getPickupTimingAvailability(params) {
1660
+ return this.getPickupTimingController().getAvailability(params);
1661
+ }
1662
+ }, {
1663
+ key: "getPickupTimingSelection",
1664
+ value: function getPickupTimingSelection() {
1665
+ return this.getPickupTimingController().getSelection();
1666
+ }
1667
+ }, {
1668
+ key: "setPickupTimingSelection",
1669
+ value: function setPickupTimingSelection(selection) {
1670
+ return this.getPickupTimingController().setSelection(selection);
1671
+ }
1672
+ }, {
1673
+ key: "validatePickupTimingSelection",
1674
+ value: function validatePickupTimingSelection(selection) {
1675
+ return this.getPickupTimingController().validate(selection);
1676
+ }
1677
+ }, {
1678
+ key: "preparePickupTimingForCheckout",
1679
+ value: function preparePickupTimingForCheckout(options) {
1680
+ if (!this.isPickupTimingEnabled()) {
1681
+ var _this$getTempOrder;
1682
+ return Promise.resolve({
1683
+ serviceType: String(((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 || (_this$getTempOrder = _this$getTempOrder.metadata) === null || _this$getTempOrder === void 0 || (_this$getTempOrder = _this$getTempOrder.shop_service_data) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.service_type) || ''),
1684
+ mode: 'asap'
1685
+ });
1686
+ }
1687
+ return this.getPickupTimingController().prepare(options);
1688
+ }
1689
+
1575
1690
  /** Subclasses with target-scoped OpenData override this guard before reusing the cache. */
1576
1691
  }, {
1577
1692
  key: "isInvoiceOpenDataCacheCurrent",
@@ -1581,8 +1696,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1581
1696
  }, {
1582
1697
  key: "getFulfillmentRefModeConfigs",
1583
1698
  value: function getFulfillmentRefModeConfigs() {
1584
- var _this$otherParams9, _this$otherParams10, _this$store, _this$store$getOpenDa;
1585
- var candidates = [(_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.openData, (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.dineInConfig, (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.openData) === null || _this$store === void 0 || (_this$store$getOpenDa = _this$store.getOpenData) === null || _this$store$getOpenDa === void 0 ? void 0 : _this$store$getOpenDa.call(_this$store)];
1699
+ var _this$otherParams13, _this$otherParams14, _this$store, _this$store$getOpenDa;
1700
+ var candidates = [(_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.openData, (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.dineInConfig, (_this$store = this.store) === null || _this$store === void 0 || (_this$store = _this$store.openData) === null || _this$store === void 0 || (_this$store$getOpenDa = _this$store.getOpenData) === null || _this$store$getOpenDa === void 0 ? void 0 : _this$store$getOpenDa.call(_this$store)];
1586
1701
  return candidates.filter(function (candidate) {
1587
1702
  return candidate && _typeof(candidate) === 'object' && !Array.isArray(candidate);
1588
1703
  });
@@ -1718,60 +1833,60 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1718
1833
  }, {
1719
1834
  key: "syncOtherParamsToSubModules",
1720
1835
  value: (function () {
1721
- var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(changedParams) {
1722
- var _this8 = this;
1836
+ var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(changedParams) {
1837
+ var _this9 = this;
1723
1838
  var _ref30,
1724
1839
  _ref30$cover,
1725
1840
  cover,
1726
- _args11 = arguments;
1727
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1728
- while (1) switch (_context11.prev = _context11.next) {
1841
+ _args12 = arguments;
1842
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1843
+ while (1) switch (_context12.prev = _context12.next) {
1729
1844
  case 0:
1730
- _ref30 = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
1731
- _context11.next = 3;
1845
+ _ref30 = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
1846
+ _context12.next = 3;
1732
1847
  return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
1733
- var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref31) {
1848
+ var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref31) {
1734
1849
  var _ref33, moduleName, subModule, targetModule, nextSubModuleOtherParams;
1735
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1736
- while (1) switch (_context10.prev = _context10.next) {
1850
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1851
+ while (1) switch (_context11.prev = _context11.next) {
1737
1852
  case 0:
1738
1853
  _ref33 = _slicedToArray(_ref31, 2), moduleName = _ref33[0], subModule = _ref33[1];
1739
- if (!_this8.reusedSharedSubModuleNames.has(moduleName)) {
1740
- _context10.next = 3;
1854
+ if (!_this9.reusedSharedSubModuleNames.has(moduleName)) {
1855
+ _context11.next = 3;
1741
1856
  break;
1742
1857
  }
1743
- return _context10.abrupt("return");
1858
+ return _context11.abrupt("return");
1744
1859
  case 3:
1745
1860
  targetModule = subModule;
1746
1861
  if (!(!targetModule || typeof targetModule.updateOtherParams !== 'function')) {
1747
- _context10.next = 6;
1862
+ _context11.next = 6;
1748
1863
  break;
1749
1864
  }
1750
- return _context10.abrupt("return");
1865
+ return _context11.abrupt("return");
1751
1866
  case 6:
1752
- nextSubModuleOtherParams = _this8.buildSubModuleOtherParams(moduleName);
1753
- _context10.next = 9;
1867
+ nextSubModuleOtherParams = _this9.buildSubModuleOtherParams(moduleName);
1868
+ _context11.next = 9;
1754
1869
  return targetModule.updateOtherParams(nextSubModuleOtherParams, {
1755
1870
  changedParams: changedParams,
1756
1871
  cover: cover
1757
1872
  });
1758
1873
  case 9:
1759
1874
  case "end":
1760
- return _context10.stop();
1875
+ return _context11.stop();
1761
1876
  }
1762
- }, _callee10);
1877
+ }, _callee11);
1763
1878
  }));
1764
- return function (_x10) {
1879
+ return function (_x11) {
1765
1880
  return _ref32.apply(this, arguments);
1766
1881
  };
1767
1882
  }()));
1768
1883
  case 3:
1769
1884
  case "end":
1770
- return _context11.stop();
1885
+ return _context12.stop();
1771
1886
  }
1772
- }, _callee11, this);
1887
+ }, _callee12, this);
1773
1888
  }));
1774
- function syncOtherParamsToSubModules(_x9) {
1889
+ function syncOtherParamsToSubModules(_x10) {
1775
1890
  return _syncOtherParamsToSubModules.apply(this, arguments);
1776
1891
  }
1777
1892
  return syncOtherParamsToSubModules;
@@ -1821,29 +1936,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1821
1936
  }, {
1822
1937
  key: "getPaymentNumberDevicePrefixSync",
1823
1938
  value: function getPaymentNumberDevicePrefixSync() {
1824
- var _this9 = this;
1939
+ var _this10 = this;
1825
1940
  if (!this.appPlugin) return 'LOCAL';
1826
1941
  return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
1827
- return _this9.getAppData(key);
1942
+ return _this10.getAppData(key);
1828
1943
  });
1829
1944
  }
1830
1945
  }, {
1831
1946
  key: "getPaymentNumberDevicePrefixAsync",
1832
1947
  value: function getPaymentNumberDevicePrefixAsync() {
1833
- var _this10 = this;
1948
+ var _this11 = this;
1834
1949
  if (!this.appPlugin) return Promise.resolve('LOCAL');
1835
1950
  if (this.paymentNumberDevicePrefix) {
1836
1951
  return Promise.resolve(this.paymentNumberDevicePrefix);
1837
1952
  }
1838
1953
  return resolvePaymentNumberDevicePrefix(function (key) {
1839
- return _this10.getAppData(key);
1954
+ return _this11.getAppData(key);
1840
1955
  });
1841
1956
  }
1842
1957
  }, {
1843
1958
  key: "isMultiCurrencySettlementEnabled",
1844
1959
  value: function isMultiCurrencySettlementEnabled() {
1845
- var _this$otherParams11;
1846
- return ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.enableMultiCurrencySettlement) === true;
1960
+ var _this$otherParams15;
1961
+ return ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.enableMultiCurrencySettlement) === true;
1847
1962
  }
1848
1963
  }, {
1849
1964
  key: "isActiveVirtualSettlementOrder",
@@ -1914,27 +2029,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1914
2029
  }, {
1915
2030
  key: "initialize",
1916
2031
  value: function () {
1917
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(core) {
1918
- var _this$otherParams12,
2032
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(core) {
2033
+ var _this$otherParams16,
1919
2034
  _this$appPlugin2,
1920
2035
  _this$appPlugin2$getA,
1921
- _this11 = this,
1922
- _this$otherParams13;
2036
+ _this12 = this,
2037
+ _this$otherParams17;
1923
2038
  var options,
1924
2039
  app,
1925
2040
  targetCacheData,
1926
2041
  moduleNames,
1927
- _args12 = arguments;
1928
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1929
- while (1) switch (_context12.prev = _context12.next) {
2042
+ _args13 = arguments;
2043
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2044
+ while (1) switch (_context13.prev = _context13.next) {
1930
2045
  case 0:
1931
- options = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {};
2046
+ options = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : {};
1932
2047
  this.core = core;
1933
2048
  this.initializeOptions = options || {};
1934
2049
  this.paymentNumberDevicePrefix = null;
1935
2050
  // this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
1936
2051
  this.otherParams = options.otherParams || {};
1937
- this.cacheId = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.cacheId;
2052
+ this.cacheId = (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.cacheId;
1938
2053
  this.reusedSharedSubModuleNames.clear();
1939
2054
  this.window = core.getPlugin('window');
1940
2055
  this.request = core.getPlugin('request');
@@ -1949,48 +2064,48 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1949
2064
  targetCacheData = this.readSessionCacheData();
1950
2065
  moduleNames = this.getRegisteredModuleNames();
1951
2066
  moduleNames.forEach(function (step) {
1952
- var reusedModule = _this11.getReusableSharedSubModule(step);
2067
+ var reusedModule = _this12.getReusableSharedSubModule(step);
1953
2068
  if (reusedModule) {
1954
- _this11.store[step] = reusedModule;
1955
- _this11.reusedSharedSubModuleNames.add(step);
2069
+ _this12.store[step] = reusedModule;
2070
+ _this12.reusedSharedSubModuleNames.add(step);
1956
2071
  return;
1957
2072
  }
1958
- var targetModule = _this11.createSubModule(step);
2073
+ var targetModule = _this12.createSubModule(step);
1959
2074
  if (!targetModule) {
1960
2075
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
1961
2076
  }
1962
- var hooks = _this11.getSubModuleHooks(step);
1963
- _this11.store[step] = targetModule;
1964
- _this11.core.registerModule(targetModule, _objectSpread(_objectSpread({
1965
- initialState: _this11.shouldUseSessionStorageForSubModule(step) ? (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {} : {}
2077
+ var hooks = _this12.getSubModuleHooks(step);
2078
+ _this12.store[step] = targetModule;
2079
+ _this12.core.registerModule(targetModule, _objectSpread(_objectSpread({
2080
+ initialState: _this12.shouldUseSessionStorageForSubModule(step) ? (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {} : {}
1966
2081
  }, hooks ? {
1967
2082
  hooks: hooks
1968
2083
  } : {}), {}, {
1969
- otherParams: _this11.buildSubModuleOtherParams(step)
2084
+ otherParams: _this12.buildSubModuleOtherParams(step)
1970
2085
  }));
1971
2086
  });
1972
2087
  if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
1973
- _context12.next = 19;
2088
+ _context13.next = 19;
1974
2089
  break;
1975
2090
  }
1976
- _context12.next = 19;
2091
+ _context13.next = 19;
1977
2092
  return this.store.schedule.loadAllSchedule();
1978
2093
  case 19:
1979
- if (this.store.order && typeof ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.enableTempOrderPersist) === 'boolean') {
2094
+ if (this.store.order && typeof ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.enableTempOrderPersist) === 'boolean') {
1980
2095
  this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
1981
2096
  }
1982
- _context12.next = 22;
2097
+ _context13.next = 22;
1983
2098
  return this.getPaymentMethodsAsync();
1984
2099
  case 22:
1985
2100
  this.registerServerOrderChangeSync();
1986
2101
  this.core.effects.emit("".concat(this.name, ":onInited"), {});
1987
2102
  case 24:
1988
2103
  case "end":
1989
- return _context12.stop();
2104
+ return _context13.stop();
1990
2105
  }
1991
- }, _callee12, this);
2106
+ }, _callee13, this);
1992
2107
  }));
1993
- function initialize(_x11) {
2108
+ function initialize(_x12) {
1994
2109
  return _initialize.apply(this, arguments);
1995
2110
  }
1996
2111
  return initialize;
@@ -1998,17 +2113,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1998
2113
  }, {
1999
2114
  key: "destroy",
2000
2115
  value: function () {
2001
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2116
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
2002
2117
  var _this$serverOrderChan2,
2003
- _this12 = this;
2004
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2005
- while (1) switch (_context13.prev = _context13.next) {
2118
+ _this13 = this;
2119
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
2120
+ while (1) switch (_context14.prev = _context14.next) {
2006
2121
  case 0:
2007
2122
  (_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
2008
2123
  this.serverOrderChangeUnsubscribe = null;
2009
2124
  Object.keys(this.store).forEach(function (key) {
2010
- if (_this12.reusedSharedSubModuleNames.has(key)) return;
2011
- var sub = _this12.store[key];
2125
+ if (_this13.reusedSharedSubModuleNames.has(key)) return;
2126
+ var sub = _this13.store[key];
2012
2127
  if (sub && typeof sub.destroy === 'function') {
2013
2128
  try {
2014
2129
  sub.destroy();
@@ -2022,15 +2137,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2022
2137
  this.queuedServerOrderChanges = [];
2023
2138
  this.salesDetailLoadSequence += 1;
2024
2139
  this.walletAssetsRefreshSequence += 1;
2025
- _context13.next = 10;
2140
+ _context14.next = 10;
2026
2141
  return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
2027
2142
  case 10:
2028
2143
  _get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
2029
2144
  case 11:
2030
2145
  case "end":
2031
- return _context13.stop();
2146
+ return _context14.stop();
2032
2147
  }
2033
- }, _callee13, this);
2148
+ }, _callee14, this);
2034
2149
  }));
2035
2150
  function destroy() {
2036
2151
  return _destroy.apply(this, arguments);
@@ -2047,20 +2162,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2047
2162
  }, {
2048
2163
  key: "loadSalesDetail",
2049
2164
  value: (function () {
2050
- var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderIdOrParams) {
2165
+ var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderIdOrParams) {
2051
2166
  var loadSequence, _ref38, _ref39, _ref40, _ref41, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, loadedSalesDetail, shouldFilterPendingPayments, remoteRecord, mergeSourceRecord, currentTempOrder, mergedRecord, record;
2052
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
2053
- while (1) switch (_context14.prev = _context14.next) {
2167
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2168
+ while (1) switch (_context15.prev = _context15.next) {
2054
2169
  case 0:
2055
2170
  if (this.store.order) {
2056
- _context14.next = 2;
2171
+ _context15.next = 2;
2057
2172
  break;
2058
2173
  }
2059
2174
  throw new Error('order 模块未初始化');
2060
2175
  case 2:
2061
2176
  loadSequence = ++this.salesDetailLoadSequence;
2062
2177
  this.salesDetailLoadInFlightCount += 1;
2063
- _context14.prev = 4;
2178
+ _context15.prev = 4;
2064
2179
  params = _typeof(orderIdOrParams) === 'object' ? orderIdOrParams : {
2065
2180
  orderId: orderIdOrParams
2066
2181
  };
@@ -2068,30 +2183,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2068
2183
  preloadedSalesDetail = params.preloadedSalesDetail;
2069
2184
  lookup = (_ref38 = (_ref39 = (_ref40 = (_ref41 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref41 !== void 0 ? _ref41 : params.orderNumber) !== null && _ref40 !== void 0 ? _ref40 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref39 !== void 0 ? _ref39 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref38 !== void 0 ? _ref38 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
2070
2185
  if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
2071
- _context14.next = 11;
2186
+ _context15.next = 11;
2072
2187
  break;
2073
2188
  }
2074
2189
  throw new Error('加载销售详情需要 orderId、externalSaleNumber 或 orderNumber');
2075
2190
  case 11:
2076
2191
  if (!(preloadedSalesDetail !== null && preloadedSalesDetail !== void 0)) {
2077
- _context14.next = 15;
2192
+ _context15.next = 15;
2078
2193
  break;
2079
2194
  }
2080
- _context14.t0 = preloadedSalesDetail;
2081
- _context14.next = 18;
2195
+ _context15.t0 = preloadedSalesDetail;
2196
+ _context15.next = 18;
2082
2197
  break;
2083
2198
  case 15:
2084
- _context14.next = 17;
2199
+ _context15.next = 17;
2085
2200
  return this.store.order.getSalesOrderByLookup({
2086
2201
  lookup: lookup,
2087
2202
  forceRemote: params.forceRemote
2088
2203
  });
2089
2204
  case 17:
2090
- _context14.t0 = _context14.sent;
2205
+ _context15.t0 = _context15.sent;
2091
2206
  case 18:
2092
- loadedRecord = _context14.t0;
2207
+ loadedRecord = _context15.t0;
2093
2208
  if (!(!preloadedSalesDetail && (!loadedRecord || loadedRecord.code !== 200))) {
2094
- _context14.next = 22;
2209
+ _context15.next = 22;
2095
2210
  break;
2096
2211
  }
2097
2212
  message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
@@ -2104,41 +2219,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2104
2219
  currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
2105
2220
  mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, mergeSourceRecord, 'preserve-local') : mergeSourceRecord;
2106
2221
  record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
2107
- _context14.next = 31;
2222
+ _context15.next = 31;
2108
2223
  return this.hydrateLatestLoadedSalesDetail(record, loadSequence, {
2109
2224
  hydrateSource: params.hydrateSource,
2110
2225
  merge: params.merge
2111
2226
  });
2112
2227
  case 31:
2113
- return _context14.abrupt("return", _context14.sent);
2228
+ return _context15.abrupt("return", _context15.sent);
2114
2229
  case 32:
2115
- _context14.prev = 32;
2230
+ _context15.prev = 32;
2116
2231
  this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
2117
2232
  if (!(this.salesDetailLoadInFlightCount === 0)) {
2118
- _context14.next = 43;
2233
+ _context15.next = 43;
2119
2234
  break;
2120
2235
  }
2121
- _context14.prev = 35;
2122
- _context14.next = 38;
2236
+ _context15.prev = 35;
2237
+ _context15.next = 38;
2123
2238
  return this.drainQueuedServerOrderChanges();
2124
2239
  case 38:
2125
- _context14.next = 43;
2240
+ _context15.next = 43;
2126
2241
  break;
2127
2242
  case 40:
2128
- _context14.prev = 40;
2129
- _context14.t1 = _context14["catch"](35);
2243
+ _context15.prev = 40;
2244
+ _context15.t1 = _context15["catch"](35);
2130
2245
  this.logError('drain queued server order changes failed', {
2131
- error: _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1)
2246
+ error: _context15.t1 instanceof Error ? _context15.t1.message : String(_context15.t1)
2132
2247
  });
2133
2248
  case 43:
2134
- return _context14.finish(32);
2249
+ return _context15.finish(32);
2135
2250
  case 44:
2136
2251
  case "end":
2137
- return _context14.stop();
2252
+ return _context15.stop();
2138
2253
  }
2139
- }, _callee14, this, [[4,, 32, 44], [35, 40]]);
2254
+ }, _callee15, this, [[4,, 32, 44], [35, 40]]);
2140
2255
  }));
2141
- function loadSalesDetail(_x12) {
2256
+ function loadSalesDetail(_x13) {
2142
2257
  return _loadSalesDetail.apply(this, arguments);
2143
2258
  }
2144
2259
  return loadSalesDetail;
@@ -2170,9 +2285,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2170
2285
  key: "getRootBooking",
2171
2286
  value: function getRootBooking() {
2172
2287
  if (!this.currentSalesDetail) return null;
2173
- if (this.currentSalesDetail.rootBooking) return this.currentSalesDetail.rootBooking;
2288
+ if (this.currentSalesDetail.rootBooking && !isFulfillmentTimingBooking(this.currentSalesDetail.rootBooking)) {
2289
+ return this.currentSalesDetail.rootBooking;
2290
+ }
2174
2291
  var bookings = this.currentSalesDetail.bookings || [];
2175
2292
  return bookings.find(function (booking) {
2293
+ if (isFulfillmentTimingBooking(booking)) return false;
2176
2294
  var parentId = booking === null || booking === void 0 ? void 0 : booking.parent_id;
2177
2295
  return parentId === 0 || parentId === null || parentId === undefined;
2178
2296
  }) || null;
@@ -2218,34 +2336,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2218
2336
  }, {
2219
2337
  key: "replaceTempOrder",
2220
2338
  value: function () {
2221
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
2339
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
2222
2340
  var nextTempOrder;
2223
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2224
- while (1) switch (_context15.prev = _context15.next) {
2341
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2342
+ while (1) switch (_context16.prev = _context16.next) {
2225
2343
  case 0:
2226
2344
  if (this.store.order) {
2227
- _context15.next = 2;
2345
+ _context16.next = 2;
2228
2346
  break;
2229
2347
  }
2230
2348
  throw new Error('order 模块未初始化');
2231
2349
  case 2:
2232
- _context15.next = 4;
2350
+ _context16.next = 4;
2233
2351
  return this.store.order.replaceTempOrder(tempOrder, options);
2234
2352
  case 4:
2235
- nextTempOrder = _context15.sent;
2236
- _context15.next = 7;
2353
+ nextTempOrder = _context16.sent;
2354
+ _context16.next = 7;
2237
2355
  return this.effectsEmit('onTempOrderReplaced', {
2238
2356
  tempOrder: nextTempOrder
2239
2357
  });
2240
2358
  case 7:
2241
- return _context15.abrupt("return", nextTempOrder);
2359
+ return _context16.abrupt("return", nextTempOrder);
2242
2360
  case 8:
2243
2361
  case "end":
2244
- return _context15.stop();
2362
+ return _context16.stop();
2245
2363
  }
2246
- }, _callee15, this);
2364
+ }, _callee16, this);
2247
2365
  }));
2248
- function replaceTempOrder(_x13, _x14) {
2366
+ function replaceTempOrder(_x14, _x15) {
2249
2367
  return _replaceTempOrder.apply(this, arguments);
2250
2368
  }
2251
2369
  return replaceTempOrder;
@@ -2301,24 +2419,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2301
2419
  }, {
2302
2420
  key: "setSalesNote",
2303
2421
  value: function () {
2304
- var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(input) {
2305
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2306
- while (1) switch (_context16.prev = _context16.next) {
2422
+ var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(input) {
2423
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2424
+ while (1) switch (_context17.prev = _context17.next) {
2307
2425
  case 0:
2308
2426
  if (this.store.order) {
2309
- _context16.next = 2;
2427
+ _context17.next = 2;
2310
2428
  break;
2311
2429
  }
2312
2430
  throw new Error('order 模块未初始化');
2313
2431
  case 2:
2314
- return _context16.abrupt("return", this.store.order.setSalesNote(input));
2432
+ return _context17.abrupt("return", this.store.order.setSalesNote(input));
2315
2433
  case 3:
2316
2434
  case "end":
2317
- return _context16.stop();
2435
+ return _context17.stop();
2318
2436
  }
2319
- }, _callee16, this);
2437
+ }, _callee17, this);
2320
2438
  }));
2321
- function setSalesNote(_x15) {
2439
+ function setSalesNote(_x16) {
2322
2440
  return _setSalesNote.apply(this, arguments);
2323
2441
  }
2324
2442
  return setSalesNote;
@@ -2326,25 +2444,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2326
2444
  }, {
2327
2445
  key: "removeSalesNote",
2328
2446
  value: function () {
2329
- var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(uuid) {
2330
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2331
- while (1) switch (_context17.prev = _context17.next) {
2447
+ var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(uuid) {
2448
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2449
+ while (1) switch (_context18.prev = _context18.next) {
2332
2450
  case 0:
2333
2451
  if (this.store.order) {
2334
- _context17.next = 2;
2452
+ _context18.next = 2;
2335
2453
  break;
2336
2454
  }
2337
2455
  throw new Error('order 模块未初始化');
2338
2456
  case 2:
2339
- _context17.next = 4;
2457
+ _context18.next = 4;
2340
2458
  return this.store.order.removeSalesNote(uuid);
2341
2459
  case 4:
2342
2460
  case "end":
2343
- return _context17.stop();
2461
+ return _context18.stop();
2344
2462
  }
2345
- }, _callee17, this);
2463
+ }, _callee18, this);
2346
2464
  }));
2347
- function removeSalesNote(_x16) {
2465
+ function removeSalesNote(_x17) {
2348
2466
  return _removeSalesNote.apply(this, arguments);
2349
2467
  }
2350
2468
  return removeSalesNote;
@@ -2352,23 +2470,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2352
2470
  }, {
2353
2471
  key: "clearSalesNotes",
2354
2472
  value: function () {
2355
- var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
2356
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2357
- while (1) switch (_context18.prev = _context18.next) {
2473
+ var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2474
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2475
+ while (1) switch (_context19.prev = _context19.next) {
2358
2476
  case 0:
2359
2477
  if (this.store.order) {
2360
- _context18.next = 2;
2478
+ _context19.next = 2;
2361
2479
  break;
2362
2480
  }
2363
2481
  throw new Error('order 模块未初始化');
2364
2482
  case 2:
2365
- _context18.next = 4;
2483
+ _context19.next = 4;
2366
2484
  return this.store.order.clearSalesNotes();
2367
2485
  case 4:
2368
2486
  case "end":
2369
- return _context18.stop();
2487
+ return _context19.stop();
2370
2488
  }
2371
- }, _callee18, this);
2489
+ }, _callee19, this);
2372
2490
  }));
2373
2491
  function clearSalesNotes() {
2374
2492
  return _clearSalesNotes.apply(this, arguments);
@@ -2425,6 +2543,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2425
2543
  if (!this.store.order) throw new Error('order 模块未初始化');
2426
2544
  return this.store.order.updateTempOrderServiceType(serviceType);
2427
2545
  }
2546
+ }, {
2547
+ key: "getPickupTimingBooking",
2548
+ value: function getPickupTimingBooking() {
2549
+ var _this$store$order4;
2550
+ return ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getPickupTimingBooking()) || null;
2551
+ }
2552
+ }, {
2553
+ key: "setPickupTimingBooking",
2554
+ value: function setPickupTimingBooking(input) {
2555
+ if (!this.store.order) throw new Error('order 模块未初始化');
2556
+ return this.store.order.setPickupTimingBooking(input);
2557
+ }
2558
+ }, {
2559
+ key: "clearPickupTimingBooking",
2560
+ value: function clearPickupTimingBooking() {
2561
+ var _this$store$order5;
2562
+ (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || _this$store$order5.clearPickupTimingBooking();
2563
+ }
2428
2564
  }, {
2429
2565
  key: "updateTempOrderContactsInfo",
2430
2566
  value: function updateTempOrderContactsInfo(contactsInfo) {
@@ -2458,40 +2594,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2458
2594
  }, {
2459
2595
  key: "addNewOrder",
2460
2596
  value: function () {
2461
- var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
2597
+ var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2462
2598
  var tempOrder;
2463
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2464
- while (1) switch (_context19.prev = _context19.next) {
2599
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2600
+ while (1) switch (_context20.prev = _context20.next) {
2465
2601
  case 0:
2466
- _context19.prev = 0;
2602
+ _context20.prev = 0;
2467
2603
  if (this.store.order) {
2468
- _context19.next = 3;
2604
+ _context20.next = 3;
2469
2605
  break;
2470
2606
  }
2471
2607
  throw new Error('order 模块未初始化');
2472
2608
  case 3:
2473
- _context19.next = 5;
2609
+ _context20.next = 5;
2474
2610
  return this.store.order.addNewOrder();
2475
2611
  case 5:
2476
- tempOrder = _context19.sent;
2612
+ tempOrder = _context20.sent;
2477
2613
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
2478
- _context19.next = 10;
2614
+ _context20.next = 10;
2479
2615
  break;
2480
2616
  }
2481
2617
  this.store.order.persistTempOrder();
2482
- _context19.next = 10;
2618
+ _context20.next = 10;
2483
2619
  return this.store.order.saveDraft();
2484
2620
  case 10:
2485
- return _context19.abrupt("return", tempOrder);
2621
+ return _context20.abrupt("return", tempOrder);
2486
2622
  case 13:
2487
- _context19.prev = 13;
2488
- _context19.t0 = _context19["catch"](0);
2489
- throw _context19.t0;
2623
+ _context20.prev = 13;
2624
+ _context20.t0 = _context20["catch"](0);
2625
+ throw _context20.t0;
2490
2626
  case 16:
2491
2627
  case "end":
2492
- return _context19.stop();
2628
+ return _context20.stop();
2493
2629
  }
2494
- }, _callee19, this, [[0, 13]]);
2630
+ }, _callee20, this, [[0, 13]]);
2495
2631
  }));
2496
2632
  function addNewOrder() {
2497
2633
  return _addNewOrder.apply(this, arguments);
@@ -2501,22 +2637,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2501
2637
  }, {
2502
2638
  key: "saveDraft",
2503
2639
  value: function () {
2504
- var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
2505
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2506
- while (1) switch (_context20.prev = _context20.next) {
2640
+ var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2641
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2642
+ while (1) switch (_context21.prev = _context21.next) {
2507
2643
  case 0:
2508
2644
  if (this.store.order) {
2509
- _context20.next = 2;
2645
+ _context21.next = 2;
2510
2646
  break;
2511
2647
  }
2512
2648
  throw new Error('order 模块未初始化');
2513
2649
  case 2:
2514
- return _context20.abrupt("return", this.store.order.saveDraft());
2650
+ return _context21.abrupt("return", this.store.order.saveDraft());
2515
2651
  case 3:
2516
2652
  case "end":
2517
- return _context20.stop();
2653
+ return _context21.stop();
2518
2654
  }
2519
- }, _callee20, this);
2655
+ }, _callee21, this);
2520
2656
  }));
2521
2657
  function saveDraft() {
2522
2658
  return _saveDraft.apply(this, arguments);
@@ -2527,14 +2663,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2527
2663
  }, {
2528
2664
  key: "restoreOrder",
2529
2665
  value: function () {
2530
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2666
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2531
2667
  var _this$store$payment, tempOrder, appDataChanged, wallet;
2532
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2533
- while (1) switch (_context21.prev = _context21.next) {
2668
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2669
+ while (1) switch (_context22.prev = _context22.next) {
2534
2670
  case 0:
2535
- _context21.prev = 0;
2671
+ _context22.prev = 0;
2536
2672
  if (this.store.order) {
2537
- _context21.next = 3;
2673
+ _context22.next = 3;
2538
2674
  break;
2539
2675
  }
2540
2676
  throw new Error('scanOrder 解决方案需要 order 模块支持');
@@ -2547,37 +2683,37 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2547
2683
  this.hasManualDiscountSelection = false;
2548
2684
  wallet = (_this$store$payment = this.store.payment) === null || _this$store$payment === void 0 ? void 0 : _this$store$payment.wallet;
2549
2685
  if (!wallet) {
2550
- _context21.next = 14;
2686
+ _context22.next = 14;
2551
2687
  break;
2552
2688
  }
2553
2689
  this.walletAssetsRefreshSequence += 1;
2554
2690
  wallet.clearAllCache();
2555
- _context21.next = 14;
2691
+ _context22.next = 14;
2556
2692
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
2557
2693
  case 14:
2558
- _context21.next = 16;
2694
+ _context22.next = 16;
2559
2695
  return this.effectsEmit('onTempOrderReplaced', {
2560
2696
  tempOrder: tempOrder
2561
2697
  });
2562
2698
  case 16:
2563
2699
  if (!(appDataChanged && this.isTempOrderPersistEnabled())) {
2564
- _context21.next = 20;
2700
+ _context22.next = 20;
2565
2701
  break;
2566
2702
  }
2567
2703
  this.store.order.persistTempOrder();
2568
- _context21.next = 20;
2704
+ _context22.next = 20;
2569
2705
  return this.store.order.saveDraft();
2570
2706
  case 20:
2571
- return _context21.abrupt("return", tempOrder);
2707
+ return _context22.abrupt("return", tempOrder);
2572
2708
  case 23:
2573
- _context21.prev = 23;
2574
- _context21.t0 = _context21["catch"](0);
2575
- throw _context21.t0;
2709
+ _context22.prev = 23;
2710
+ _context22.t0 = _context22["catch"](0);
2711
+ throw _context22.t0;
2576
2712
  case 26:
2577
2713
  case "end":
2578
- return _context21.stop();
2714
+ return _context22.stop();
2579
2715
  }
2580
- }, _callee21, this, [[0, 23]]);
2716
+ }, _callee22, this, [[0, 23]]);
2581
2717
  }));
2582
2718
  function restoreOrder() {
2583
2719
  return _restoreOrder.apply(this, arguments);
@@ -2591,22 +2727,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2591
2727
  }, {
2592
2728
  key: "clearOrderCartLines",
2593
2729
  value: (function () {
2594
- var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2730
+ var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2595
2731
  var tempOrder;
2596
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2597
- while (1) switch (_context22.prev = _context22.next) {
2732
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2733
+ while (1) switch (_context23.prev = _context23.next) {
2598
2734
  case 0:
2599
- _context22.prev = 0;
2735
+ _context23.prev = 0;
2600
2736
  if (this.store.order) {
2601
- _context22.next = 3;
2737
+ _context23.next = 3;
2602
2738
  break;
2603
2739
  }
2604
2740
  throw new Error('order 模块未初始化');
2605
2741
  case 3:
2606
- _context22.next = 5;
2742
+ _context23.next = 5;
2607
2743
  return this.store.order.clearOrderCartLines();
2608
2744
  case 5:
2609
- tempOrder = _context22.sent;
2745
+ tempOrder = _context23.sent;
2610
2746
  if (this.currentSalesDetail) {
2611
2747
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
2612
2748
  products: [],
@@ -2616,29 +2752,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2616
2752
  discount_list: []
2617
2753
  });
2618
2754
  }
2619
- _context22.next = 9;
2755
+ _context23.next = 9;
2620
2756
  return this.effectsEmit('onTempOrderReplaced', {
2621
2757
  tempOrder: tempOrder
2622
2758
  });
2623
2759
  case 9:
2624
2760
  if (!(this.syncAppDataToTempOrder(tempOrder) && this.isTempOrderPersistEnabled())) {
2625
- _context22.next = 13;
2761
+ _context23.next = 13;
2626
2762
  break;
2627
2763
  }
2628
2764
  this.store.order.persistTempOrder();
2629
- _context22.next = 13;
2765
+ _context23.next = 13;
2630
2766
  return this.store.order.saveDraft();
2631
2767
  case 13:
2632
- return _context22.abrupt("return", tempOrder);
2768
+ return _context23.abrupt("return", tempOrder);
2633
2769
  case 16:
2634
- _context22.prev = 16;
2635
- _context22.t0 = _context22["catch"](0);
2636
- throw _context22.t0;
2770
+ _context23.prev = 16;
2771
+ _context23.t0 = _context23["catch"](0);
2772
+ throw _context23.t0;
2637
2773
  case 19:
2638
2774
  case "end":
2639
- return _context22.stop();
2775
+ return _context23.stop();
2640
2776
  }
2641
- }, _callee22, this, [[0, 16]]);
2777
+ }, _callee23, this, [[0, 16]]);
2642
2778
  }));
2643
2779
  function clearOrderCartLines() {
2644
2780
  return _clearOrderCartLines.apply(this, arguments);
@@ -2648,21 +2784,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2648
2784
  }, {
2649
2785
  key: "clearOrderForSettlementSwitch",
2650
2786
  value: (function () {
2651
- var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2787
+ var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2652
2788
  var tempOrder;
2653
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2654
- while (1) switch (_context23.prev = _context23.next) {
2789
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2790
+ while (1) switch (_context24.prev = _context24.next) {
2655
2791
  case 0:
2656
2792
  if (this.store.order) {
2657
- _context23.next = 2;
2793
+ _context24.next = 2;
2658
2794
  break;
2659
2795
  }
2660
2796
  throw new Error('order 模块未初始化');
2661
2797
  case 2:
2662
- _context23.next = 4;
2798
+ _context24.next = 4;
2663
2799
  return this.store.order.clearOrderForSettlementSwitch();
2664
2800
  case 4:
2665
- tempOrder = _context23.sent;
2801
+ tempOrder = _context24.sent;
2666
2802
  if (this.currentSalesDetail) {
2667
2803
  this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
2668
2804
  products: [],
@@ -2673,12 +2809,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2673
2809
  payments: []
2674
2810
  });
2675
2811
  }
2676
- return _context23.abrupt("return", tempOrder);
2812
+ return _context24.abrupt("return", tempOrder);
2677
2813
  case 7:
2678
2814
  case "end":
2679
- return _context23.stop();
2815
+ return _context24.stop();
2680
2816
  }
2681
- }, _callee23, this);
2817
+ }, _callee24, this);
2682
2818
  }));
2683
2819
  function clearOrderForSettlementSwitch() {
2684
2820
  return _clearOrderForSettlementSwitch.apply(this, arguments);
@@ -2695,32 +2831,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2695
2831
  }, {
2696
2832
  key: "getSummary",
2697
2833
  value: function () {
2698
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2834
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2699
2835
  var summary;
2700
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2701
- while (1) switch (_context24.prev = _context24.next) {
2836
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2837
+ while (1) switch (_context25.prev = _context25.next) {
2702
2838
  case 0:
2703
- _context24.prev = 0;
2839
+ _context25.prev = 0;
2704
2840
  if (this.store.order) {
2705
- _context24.next = 3;
2841
+ _context25.next = 3;
2706
2842
  break;
2707
2843
  }
2708
2844
  throw new Error('order 模块未初始化');
2709
2845
  case 3:
2710
- _context24.next = 5;
2846
+ _context25.next = 5;
2711
2847
  return this.store.order.getOrderSummary();
2712
2848
  case 5:
2713
- summary = _context24.sent;
2714
- return _context24.abrupt("return", summary);
2849
+ summary = _context25.sent;
2850
+ return _context25.abrupt("return", summary);
2715
2851
  case 9:
2716
- _context24.prev = 9;
2717
- _context24.t0 = _context24["catch"](0);
2718
- throw _context24.t0;
2852
+ _context25.prev = 9;
2853
+ _context25.t0 = _context25["catch"](0);
2854
+ throw _context25.t0;
2719
2855
  case 12:
2720
2856
  case "end":
2721
- return _context24.stop();
2857
+ return _context25.stop();
2722
2858
  }
2723
- }, _callee24, this, [[0, 9]]);
2859
+ }, _callee25, this, [[0, 9]]);
2724
2860
  }));
2725
2861
  function getSummary() {
2726
2862
  return _getSummary.apply(this, arguments);
@@ -2730,10 +2866,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2730
2866
  }, {
2731
2867
  key: "getHistoricalProductDiscountList",
2732
2868
  value: function getHistoricalProductDiscountList(products) {
2733
- var _this13 = this;
2869
+ var _this14 = this;
2734
2870
  var historyDiscountList = [];
2735
2871
  products.forEach(function (item) {
2736
- if (!_this13.isPersistedOrderProduct(item)) return;
2872
+ if (!_this14.isPersistedOrderProduct(item)) return;
2737
2873
  (item.discount_list || []).forEach(function (discount) {
2738
2874
  var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
2739
2875
  var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
@@ -2793,11 +2929,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2793
2929
  }, {
2794
2930
  key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
2795
2931
  value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
2796
- var _this14 = this;
2932
+ var _this15 = this;
2797
2933
  if (params.discountAction !== 'edit') return false;
2798
2934
  if (!params.products.length) return false;
2799
2935
  var hasDraftProduct = params.products.some(function (product) {
2800
- return !_this14.isPersistedOrderProduct(product);
2936
+ return !_this15.isPersistedOrderProduct(product);
2801
2937
  });
2802
2938
  if (hasDraftProduct) return false;
2803
2939
 
@@ -2859,31 +2995,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2859
2995
  }, {
2860
2996
  key: "getDiscountConfigOrderIdentityKey",
2861
2997
  value: function getDiscountConfigOrderIdentityKey(tempOrder) {
2862
- var _this$store$order4, _this$store$order4$ge, _ref42, _identity$orderId, _tempOrder$request_un, _ref43, _identity$externalSal, _ref44, _ref45, _identity$localId, _tempOrder$_extend3;
2863
- var identity = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getOrderIdentity) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4);
2998
+ var _this$store$order6, _this$store$order6$ge, _ref42, _identity$orderId, _tempOrder$request_un, _ref43, _identity$externalSal, _ref44, _ref45, _identity$localId, _tempOrder$_extend3;
2999
+ var identity = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$ge = _this$store$order6.getOrderIdentity) === null || _this$store$order6$ge === void 0 ? void 0 : _this$store$order6$ge.call(_this$store$order6);
2864
3000
  return JSON.stringify([(_ref42 = (_identity$orderId = identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _identity$orderId !== void 0 ? _identity$orderId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _ref42 !== void 0 ? _ref42 : '', (_tempOrder$request_un = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.request_unique_idempotency_token) !== null && _tempOrder$request_un !== void 0 ? _tempOrder$request_un : '', (_ref43 = (_identity$externalSal = identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) !== null && _identity$externalSal !== void 0 ? _identity$externalSal : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) !== null && _ref43 !== void 0 ? _ref43 : '', (_ref44 = (_ref45 = (_identity$localId = identity === null || identity === void 0 ? void 0 : identity.localId) !== null && _identity$localId !== void 0 ? _identity$localId : tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.localId) !== null && _ref45 !== void 0 ? _ref45 : this.cacheId) !== null && _ref44 !== void 0 ? _ref44 : '']);
2865
3001
  }
2866
3002
  }, {
2867
3003
  key: "loadDiscountConfig",
2868
3004
  value: function () {
2869
- var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
3005
+ var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
2870
3006
  var _this$store$order$get2,
2871
- _this$store$order5,
3007
+ _this$store$order7,
2872
3008
  _tempOrder$customer2,
2873
3009
  _tempOrder$_extend4,
2874
3010
  _tempOrder$_extend5,
2875
3011
  _discountModule$getDi,
2876
3012
  _discountModule$getOr,
2877
3013
  _this$store$order$get3,
2878
- _this$store$order6,
2879
- _this15 = this,
3014
+ _this$store$order8,
3015
+ _this16 = this,
2880
3016
  _discountModule$getDi3;
2881
- var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, requestOrderIdentityKey, discountConfigCacheKey, requestEpoch, isCurrentRequest, getCurrentResult, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _this$store$order$get4, _this$store$order7, _discountModule$setOr, prepareConfigPromise, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend6, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
2882
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2883
- while (1) switch (_context25.prev = _context25.next) {
3017
+ var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, requestOrderIdentityKey, discountConfigCacheKey, requestEpoch, isCurrentRequest, getCurrentResult, searchedDiscountList, searchedDiscountIds, preparedDiscountList, _this$store$order$get4, _this$store$order9, _discountModule$setOr, prepareConfigPromise, _discountModule$setOr2, _discountModule$setDi, nextDiscountList, shouldSkipAutoApplyFetchedDiscounts, _orderStore$summary, orderTotalAmount, result, _iterator3, _step3, _product$metadata5, _tempOrder$_extend6, _product$metadata$sou, _product$metadata6, _product$metadata7, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
3018
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3019
+ while (1) switch (_context26.prev = _context26.next) {
2884
3020
  case 0:
2885
3021
  if (this.store.order) {
2886
- _context25.next = 2;
3022
+ _context26.next = 2;
2887
3023
  break;
2888
3024
  }
2889
3025
  throw new Error('order 模块未初始化');
@@ -2892,7 +3028,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2892
3028
  orderStore = this.store.order.store || {};
2893
3029
  discountModule = orderStore.discount;
2894
3030
  rulesModule = orderStore.rules;
2895
- orderId = tempOrder.order_id || ((_this$store$order$get2 = (_this$store$order5 = this.store.order).getOrderIdentity) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.call(_this$store$order5)) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.orderId);
3031
+ orderId = tempOrder.order_id || ((_this$store$order$get2 = (_this$store$order7 = this.store.order).getOrderIdentity) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.call(_this$store$order7)) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.orderId);
2896
3032
  customerId = Number((params === null || params === void 0 ? void 0 : params.customerId) || tempOrder.customer_id || ((_tempOrder$customer2 = tempOrder.customer) === null || _tempOrder$customer2 === void 0 ? void 0 : _tempOrder$customer2.id) || ((_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.customerSnapshot) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.id) || ((_tempOrder$_extend5 = tempOrder._extend) === null || _tempOrder$_extend5 === void 0 || (_tempOrder$_extend5 = _tempOrder$_extend5.customerSnapshot) === null || _tempOrder$_extend5 === void 0 ? void 0 : _tempOrder$_extend5.customer_id) || 0);
2897
3033
  currentDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
2898
3034
  originalDiscountList = (discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
@@ -2902,20 +3038,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2902
3038
  discountAction = (params === null || params === void 0 ? void 0 : params.action) || (orderId ? 'edit' : 'create');
2903
3039
  requestOrderIdentityKey = this.getDiscountConfigOrderIdentityKey(tempOrder);
2904
3040
  discountConfigCacheKey = JSON.stringify([customerId, discountAction, Number(orderId) || 0, requestOrderIdentityKey]);
2905
- requestEpoch = (_this$store$order$get3 = (_this$store$order6 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order6);
3041
+ requestEpoch = (_this$store$order$get3 = (_this$store$order8 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order8);
2906
3042
  isCurrentRequest = function isCurrentRequest() {
2907
- var _this15$store$order, _this15$store$order$g, _this15$store$order2, _this15$store$order2$;
2908
- var currentTempOrder = (_this15$store$order = _this15.store.order) === null || _this15$store$order === void 0 || (_this15$store$order$g = _this15$store$order.getTempOrder) === null || _this15$store$order$g === void 0 ? void 0 : _this15$store$order$g.call(_this15$store$order);
2909
- return Boolean(currentTempOrder && (requestEpoch === undefined || ((_this15$store$order2 = _this15.store.order) === null || _this15$store$order2 === void 0 || (_this15$store$order2$ = _this15$store$order2.getCustomerWalletPrepareConfigEpoch) === null || _this15$store$order2$ === void 0 ? void 0 : _this15$store$order2$.call(_this15$store$order2)) === requestEpoch) && _this15.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && _this15.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
3043
+ var _this16$store$order, _this16$store$order$g, _this16$store$order2, _this16$store$order2$;
3044
+ var currentTempOrder = (_this16$store$order = _this16.store.order) === null || _this16$store$order === void 0 || (_this16$store$order$g = _this16$store$order.getTempOrder) === null || _this16$store$order$g === void 0 ? void 0 : _this16$store$order$g.call(_this16$store$order);
3045
+ return Boolean(currentTempOrder && (requestEpoch === undefined || ((_this16$store$order2 = _this16.store.order) === null || _this16$store$order2 === void 0 || (_this16$store$order2$ = _this16$store$order2.getCustomerWalletPrepareConfigEpoch) === null || _this16$store$order2$ === void 0 ? void 0 : _this16$store$order2$.call(_this16$store$order2)) === requestEpoch) && _this16.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && _this16.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
2910
3046
  };
2911
3047
  getCurrentResult = function getCurrentResult() {
2912
- var _this15$store$order3, _this15$store$order3$, _discountModule$getDi2;
2913
- var currentTempOrder = (_this15$store$order3 = _this15.store.order) === null || _this15$store$order3 === void 0 || (_this15$store$order3$ = _this15$store$order3.getTempOrder) === null || _this15$store$order3$ === void 0 ? void 0 : _this15$store$order3$.call(_this15$store$order3);
3048
+ var _this16$store$order3, _this16$store$order3$, _discountModule$getDi2;
3049
+ var currentTempOrder = (_this16$store$order3 = _this16.store.order) === null || _this16$store$order3 === void 0 || (_this16$store$order3$ = _this16$store$order3.getTempOrder) === null || _this16$store$order3$ === void 0 ? void 0 : _this16$store$order3$.call(_this16$store$order3);
2914
3050
  return {
2915
3051
  productList: (currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.products) || [],
2916
3052
  discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [],
2917
- availableWalletIds: _this15.getAvailableWalletIds(),
2918
- virtualCurrencyList: _this15.getVirtualCurrencyList()
3053
+ availableWalletIds: _this16.getAvailableWalletIds(),
3054
+ virtualCurrencyList: _this16.getVirtualCurrencyList()
2919
3055
  };
2920
3056
  }; // Walk-In 不请求 prepare config;当前搜索/扫码券必须继续参与本次重算。
2921
3057
  // current 优先于 original,保留搜索后的最新选择与可用状态。
@@ -2929,15 +3065,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2929
3065
  return !searchedDiscountIds.has(String(discount.id));
2930
3066
  })));
2931
3067
  if (!(customerId && customerId !== 1)) {
2932
- _context25.next = 37;
3068
+ _context26.next = 37;
2933
3069
  break;
2934
3070
  }
2935
3071
  if (!(!(params !== null && params !== void 0 && params.force) && this.discountConfigCacheKey === discountConfigCacheKey)) {
2936
- _context25.next = 25;
3072
+ _context26.next = 25;
2937
3073
  break;
2938
3074
  }
2939
3075
  preparedDiscountList = originalDiscountList;
2940
- _context25.next = 37;
3076
+ _context26.next = 37;
2941
3077
  break;
2942
3078
  case 25:
2943
3079
  prepareConfigPromise = this.store.order.loadDiscountConfig({
@@ -2946,59 +3082,59 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2946
3082
  orderId: Number(orderId) || undefined,
2947
3083
  apply: false
2948
3084
  }); // OrderModule increments this epoch synchronously before its first await.
2949
- requestEpoch = (_this$store$order$get4 = (_this$store$order7 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order7);
2950
- _context25.next = 29;
3085
+ requestEpoch = (_this$store$order$get4 = (_this$store$order9 = this.store.order).getCustomerWalletPrepareConfigEpoch) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order9);
3086
+ _context26.next = 29;
2951
3087
  return prepareConfigPromise;
2952
3088
  case 29:
2953
- preparedDiscountList = _context25.sent;
3089
+ preparedDiscountList = _context26.sent;
2954
3090
  if (isCurrentRequest()) {
2955
- _context25.next = 32;
3091
+ _context26.next = 32;
2956
3092
  break;
2957
3093
  }
2958
- return _context25.abrupt("return", getCurrentResult());
3094
+ return _context26.abrupt("return", getCurrentResult());
2959
3095
  case 32:
2960
- _context25.next = 34;
3096
+ _context26.next = 34;
2961
3097
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
2962
3098
  case 34:
2963
3099
  if (isCurrentRequest()) {
2964
- _context25.next = 36;
3100
+ _context26.next = 36;
2965
3101
  break;
2966
3102
  }
2967
- return _context25.abrupt("return", getCurrentResult());
3103
+ return _context26.abrupt("return", getCurrentResult());
2968
3104
  case 36:
2969
3105
  this.discountConfigCacheKey = discountConfigCacheKey;
2970
3106
  case 37:
2971
3107
  if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
2972
- _context25.next = 51;
3108
+ _context26.next = 51;
2973
3109
  break;
2974
3110
  }
2975
3111
  if (isCurrentRequest()) {
2976
- _context25.next = 40;
3112
+ _context26.next = 40;
2977
3113
  break;
2978
3114
  }
2979
- return _context25.abrupt("return", getCurrentResult());
3115
+ return _context26.abrupt("return", getCurrentResult());
2980
3116
  case 40:
2981
- _context25.next = 42;
3117
+ _context26.next = 42;
2982
3118
  return discountModule === null || discountModule === void 0 || (_discountModule$setOr2 = discountModule.setOriginalDiscountList) === null || _discountModule$setOr2 === void 0 ? void 0 : _discountModule$setOr2.call(discountModule, []);
2983
3119
  case 42:
2984
3120
  if (isCurrentRequest()) {
2985
- _context25.next = 44;
3121
+ _context26.next = 44;
2986
3122
  break;
2987
3123
  }
2988
- return _context25.abrupt("return", getCurrentResult());
3124
+ return _context26.abrupt("return", getCurrentResult());
2989
3125
  case 44:
2990
- _context25.next = 46;
3126
+ _context26.next = 46;
2991
3127
  return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []);
2992
3128
  case 46:
2993
3129
  if (isCurrentRequest()) {
2994
- _context25.next = 48;
3130
+ _context26.next = 48;
2995
3131
  break;
2996
3132
  }
2997
- return _context25.abrupt("return", getCurrentResult());
3133
+ return _context26.abrupt("return", getCurrentResult());
2998
3134
  case 48:
2999
3135
  tempOrder.discount_list = [];
3000
3136
  tempOrder.shop_discount = '0.00';
3001
- return _context25.abrupt("return", {
3137
+ return _context26.abrupt("return", {
3002
3138
  productList: tempOrder.products || [],
3003
3139
  discountList: [],
3004
3140
  availableWalletIds: this.getAvailableWalletIds(),
@@ -3006,10 +3142,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3006
3142
  });
3007
3143
  case 51:
3008
3144
  if (!(hasManualDiscountSelection && currentDiscountList.length)) {
3009
- _context25.next = 53;
3145
+ _context26.next = 53;
3010
3146
  break;
3011
3147
  }
3012
- return _context25.abrupt("return", {
3148
+ return _context26.abrupt("return", {
3013
3149
  productList: tempOrder.products || [],
3014
3150
  discountList: currentDiscountList,
3015
3151
  availableWalletIds: this.getAvailableWalletIds(),
@@ -3019,19 +3155,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3019
3155
  nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi3 = discountModule.getDiscountList) === null || _discountModule$getDi3 === void 0 ? void 0 : _discountModule$getDi3.call(discountModule)) || [], tempOrder.products || []);
3020
3156
  nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
3021
3157
  if (isCurrentRequest()) {
3022
- _context25.next = 57;
3158
+ _context26.next = 57;
3023
3159
  break;
3024
3160
  }
3025
- return _context25.abrupt("return", getCurrentResult());
3161
+ return _context26.abrupt("return", getCurrentResult());
3026
3162
  case 57:
3027
- _context25.next = 59;
3163
+ _context26.next = 59;
3028
3164
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3029
3165
  case 59:
3030
3166
  if (isCurrentRequest()) {
3031
- _context25.next = 61;
3167
+ _context26.next = 61;
3032
3168
  break;
3033
3169
  }
3034
- return _context25.abrupt("return", getCurrentResult());
3170
+ return _context26.abrupt("return", getCurrentResult());
3035
3171
  case 61:
3036
3172
  shouldSkipAutoApplyFetchedDiscounts = this.shouldSkipAutoApplyFetchedDiscountsInEditMode({
3037
3173
  discountAction: discountAction,
@@ -3040,28 +3176,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3040
3176
  nextDiscountList: nextDiscountList
3041
3177
  });
3042
3178
  if (!shouldSkipAutoApplyFetchedDiscounts) {
3043
- _context25.next = 75;
3179
+ _context26.next = 75;
3044
3180
  break;
3045
3181
  }
3046
- _context25.next = 65;
3182
+ _context26.next = 65;
3047
3183
  return this.store.order.recalculateSummary({
3048
3184
  createIfMissing: true
3049
3185
  });
3050
3186
  case 65:
3051
3187
  if (isCurrentRequest()) {
3052
- _context25.next = 67;
3188
+ _context26.next = 67;
3053
3189
  break;
3054
3190
  }
3055
- return _context25.abrupt("return", getCurrentResult());
3191
+ return _context26.abrupt("return", getCurrentResult());
3056
3192
  case 67:
3057
3193
  this.store.order.persistTempOrder();
3058
3194
  if (isCurrentRequest()) {
3059
- _context25.next = 70;
3195
+ _context26.next = 70;
3060
3196
  break;
3061
3197
  }
3062
- return _context25.abrupt("return", getCurrentResult());
3198
+ return _context26.abrupt("return", getCurrentResult());
3063
3199
  case 70:
3064
- _context25.next = 72;
3200
+ _context26.next = 72;
3065
3201
  return this.effectsEmit('onDiscountApplied', {
3066
3202
  productList: tempOrder.products || [],
3067
3203
  discountList: nextDiscountList,
@@ -3070,12 +3206,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3070
3206
  });
3071
3207
  case 72:
3072
3208
  if (isCurrentRequest()) {
3073
- _context25.next = 74;
3209
+ _context26.next = 74;
3074
3210
  break;
3075
3211
  }
3076
- return _context25.abrupt("return", getCurrentResult());
3212
+ return _context26.abrupt("return", getCurrentResult());
3077
3213
  case 74:
3078
- return _context25.abrupt("return", {
3214
+ return _context26.abrupt("return", {
3079
3215
  productList: tempOrder.products || [],
3080
3216
  discountList: nextDiscountList,
3081
3217
  availableWalletIds: this.getAvailableWalletIds(),
@@ -3083,14 +3219,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3083
3219
  });
3084
3220
  case 75:
3085
3221
  if (!rulesModule) {
3086
- _context25.next = 117;
3222
+ _context26.next = 117;
3087
3223
  break;
3088
3224
  }
3089
3225
  if (isCurrentRequest()) {
3090
- _context25.next = 78;
3226
+ _context26.next = 78;
3091
3227
  break;
3092
3228
  }
3093
- return _context25.abrupt("return", getCurrentResult());
3229
+ return _context26.abrupt("return", getCurrentResult());
3094
3230
  case 78:
3095
3231
  orderTotalAmount = Number(((_orderStore$summary = orderStore.summary) === null || _orderStore$summary === void 0 ? void 0 : _orderStore$summary.total_amount) || 0);
3096
3232
  result = rulesModule.calcDiscount({
@@ -3109,21 +3245,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3109
3245
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
3110
3246
  }
3111
3247
  _iterator3 = _createForOfIteratorHelper(tempOrder.products || []);
3112
- _context25.prev = 82;
3248
+ _context26.prev = 82;
3113
3249
  _iterator3.s();
3114
3250
  case 84:
3115
3251
  if ((_step3 = _iterator3.n()).done) {
3116
- _context25.next = 99;
3252
+ _context26.next = 99;
3117
3253
  break;
3118
3254
  }
3119
3255
  product = _step3.value;
3120
3256
  productUid = (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number;
3121
3257
  runtimeOrigin = productUid ? (_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 || (_tempOrder$_extend6 = _tempOrder$_extend6.productsByUid) === null || _tempOrder$_extend6 === void 0 || (_tempOrder$_extend6 = _tempOrder$_extend6[productUid]) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.origin : undefined;
3122
3258
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
3123
- _context25.next = 90;
3259
+ _context26.next = 90;
3124
3260
  break;
3125
3261
  }
3126
- return _context25.abrupt("continue", 97);
3262
+ return _context26.abrupt("continue", 97);
3127
3263
  case 90:
3128
3264
  totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
3129
3265
  return sum + Number(pd.amount || 0);
@@ -3141,70 +3277,70 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3141
3277
  bundle: product.product_bundle
3142
3278
  });
3143
3279
  case 97:
3144
- _context25.next = 84;
3280
+ _context26.next = 84;
3145
3281
  break;
3146
3282
  case 99:
3147
- _context25.next = 104;
3283
+ _context26.next = 104;
3148
3284
  break;
3149
3285
  case 101:
3150
- _context25.prev = 101;
3151
- _context25.t0 = _context25["catch"](82);
3152
- _iterator3.e(_context25.t0);
3286
+ _context26.prev = 101;
3287
+ _context26.t0 = _context26["catch"](82);
3288
+ _iterator3.e(_context26.t0);
3153
3289
  case 104:
3154
- _context25.prev = 104;
3290
+ _context26.prev = 104;
3155
3291
  _iterator3.f();
3156
- return _context25.finish(104);
3292
+ return _context26.finish(104);
3157
3293
  case 107:
3158
3294
  if (!result.discountList) {
3159
- _context25.next = 117;
3295
+ _context26.next = 117;
3160
3296
  break;
3161
3297
  }
3162
3298
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
3163
3299
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
3164
3300
  if (isCurrentRequest()) {
3165
- _context25.next = 112;
3301
+ _context26.next = 112;
3166
3302
  break;
3167
3303
  }
3168
- return _context25.abrupt("return", getCurrentResult());
3304
+ return _context26.abrupt("return", getCurrentResult());
3169
3305
  case 112:
3170
- _context25.next = 114;
3306
+ _context26.next = 114;
3171
3307
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3172
3308
  case 114:
3173
3309
  if (isCurrentRequest()) {
3174
- _context25.next = 116;
3310
+ _context26.next = 116;
3175
3311
  break;
3176
3312
  }
3177
- return _context25.abrupt("return", getCurrentResult());
3313
+ return _context26.abrupt("return", getCurrentResult());
3178
3314
  case 116:
3179
3315
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
3180
3316
  return discount.isSelected;
3181
3317
  });
3182
3318
  case 117:
3183
3319
  if (isCurrentRequest()) {
3184
- _context25.next = 119;
3320
+ _context26.next = 119;
3185
3321
  break;
3186
3322
  }
3187
- return _context25.abrupt("return", getCurrentResult());
3323
+ return _context26.abrupt("return", getCurrentResult());
3188
3324
  case 119:
3189
- _context25.next = 121;
3325
+ _context26.next = 121;
3190
3326
  return this.store.order.recalculateSummary({
3191
3327
  createIfMissing: true
3192
3328
  });
3193
3329
  case 121:
3194
3330
  if (isCurrentRequest()) {
3195
- _context25.next = 123;
3331
+ _context26.next = 123;
3196
3332
  break;
3197
3333
  }
3198
- return _context25.abrupt("return", getCurrentResult());
3334
+ return _context26.abrupt("return", getCurrentResult());
3199
3335
  case 123:
3200
3336
  this.store.order.persistTempOrder();
3201
3337
  if (isCurrentRequest()) {
3202
- _context25.next = 126;
3338
+ _context26.next = 126;
3203
3339
  break;
3204
3340
  }
3205
- return _context25.abrupt("return", getCurrentResult());
3341
+ return _context26.abrupt("return", getCurrentResult());
3206
3342
  case 126:
3207
- _context25.next = 128;
3343
+ _context26.next = 128;
3208
3344
  return this.effectsEmit('onDiscountApplied', {
3209
3345
  productList: tempOrder.products || [],
3210
3346
  discountList: nextDiscountList,
@@ -3213,12 +3349,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3213
3349
  });
3214
3350
  case 128:
3215
3351
  if (isCurrentRequest()) {
3216
- _context25.next = 130;
3352
+ _context26.next = 130;
3217
3353
  break;
3218
3354
  }
3219
- return _context25.abrupt("return", getCurrentResult());
3355
+ return _context26.abrupt("return", getCurrentResult());
3220
3356
  case 130:
3221
- return _context25.abrupt("return", {
3357
+ return _context26.abrupt("return", {
3222
3358
  productList: tempOrder.products || [],
3223
3359
  discountList: nextDiscountList,
3224
3360
  availableWalletIds: this.getAvailableWalletIds(),
@@ -3226,11 +3362,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3226
3362
  });
3227
3363
  case 131:
3228
3364
  case "end":
3229
- return _context25.stop();
3365
+ return _context26.stop();
3230
3366
  }
3231
- }, _callee25, this, [[82, 101, 104, 107]]);
3367
+ }, _callee26, this, [[82, 101, 104, 107]]);
3232
3368
  }));
3233
- function loadDiscountConfig(_x17) {
3369
+ function loadDiscountConfig(_x18) {
3234
3370
  return _loadDiscountConfig.apply(this, arguments);
3235
3371
  }
3236
3372
  return loadDiscountConfig;
@@ -3238,35 +3374,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3238
3374
  }, {
3239
3375
  key: "getAvailableWalletIds",
3240
3376
  value: function getAvailableWalletIds() {
3241
- var _this$store$order8;
3242
- if (!((_this$store$order8 = this.store.order) !== null && _this$store$order8 !== void 0 && _this$store$order8.getAvailableWalletIds)) return [];
3377
+ var _this$store$order10;
3378
+ if (!((_this$store$order10 = this.store.order) !== null && _this$store$order10 !== void 0 && _this$store$order10.getAvailableWalletIds)) return [];
3243
3379
  return this.store.order.getAvailableWalletIds();
3244
3380
  }
3245
3381
  }, {
3246
3382
  key: "getVirtualCurrencyList",
3247
3383
  value: function getVirtualCurrencyList() {
3248
- var _this$store$order9;
3249
- if (!((_this$store$order9 = this.store.order) !== null && _this$store$order9 !== void 0 && _this$store$order9.getVirtualCurrencyList)) return [];
3384
+ var _this$store$order11;
3385
+ if (!((_this$store$order11 = this.store.order) !== null && _this$store$order11 !== void 0 && _this$store$order11.getVirtualCurrencyList)) return [];
3250
3386
  return this.store.order.getVirtualCurrencyList();
3251
3387
  }
3252
3388
  }, {
3253
3389
  key: "bestDiscount",
3254
3390
  value: function () {
3255
- var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(cb) {
3391
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(cb) {
3256
3392
  var _discountModule$getOr2, _discountModule$getDi4;
3257
3393
  var tempOrder, _result2, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _orderStore$summary2, orderTotalAmount;
3258
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3259
- while (1) switch (_context26.prev = _context26.next) {
3394
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3395
+ while (1) switch (_context27.prev = _context27.next) {
3260
3396
  case 0:
3261
3397
  if (this.store.order) {
3262
- _context26.next = 2;
3398
+ _context27.next = 2;
3263
3399
  break;
3264
3400
  }
3265
3401
  throw new Error('order 模块未初始化');
3266
3402
  case 2:
3267
3403
  tempOrder = this.store.order.ensureTempOrder();
3268
3404
  if (!this.isActiveVirtualSettlementOrder(tempOrder)) {
3269
- _context26.next = 7;
3405
+ _context27.next = 7;
3270
3406
  break;
3271
3407
  }
3272
3408
  _result2 = {
@@ -3274,7 +3410,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3274
3410
  discountList: []
3275
3411
  };
3276
3412
  cb === null || cb === void 0 || cb(_result2);
3277
- return _context26.abrupt("return", _result2);
3413
+ return _context27.abrupt("return", _result2);
3278
3414
  case 7:
3279
3415
  orderStore = this.store.order.store || {};
3280
3416
  discountModule = orderStore.discount;
@@ -3286,11 +3422,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3286
3422
  productList: tempOrder.products || [],
3287
3423
  discountList: nextDiscountList
3288
3424
  };
3289
- _context26.next = 16;
3425
+ _context27.next = 16;
3290
3426
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3291
3427
  case 16:
3292
3428
  if (!rulesModule) {
3293
- _context26.next = 27;
3429
+ _context27.next = 27;
3294
3430
  break;
3295
3431
  }
3296
3432
  orderTotalAmount = Number(((_orderStore$summary2 = orderStore.summary) === null || _orderStore$summary2 === void 0 ? void 0 : _orderStore$summary2.total_amount) || 0);
@@ -3309,12 +3445,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3309
3445
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
3310
3446
  }
3311
3447
  if (!result.discountList) {
3312
- _context26.next = 27;
3448
+ _context27.next = 27;
3313
3449
  break;
3314
3450
  }
3315
3451
  nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
3316
3452
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
3317
- _context26.next = 25;
3453
+ _context27.next = 25;
3318
3454
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
3319
3455
  case 25:
3320
3456
  tempOrder.discount_list = nextDiscountList.filter(function (discount) {
@@ -3325,13 +3461,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3325
3461
  discountList: nextDiscountList
3326
3462
  };
3327
3463
  case 27:
3328
- _context26.next = 29;
3464
+ _context27.next = 29;
3329
3465
  return this.store.order.recalculateSummary({
3330
3466
  createIfMissing: true
3331
3467
  });
3332
3468
  case 29:
3333
3469
  this.store.order.persistTempOrder();
3334
- _context26.next = 32;
3470
+ _context27.next = 32;
3335
3471
  return this.effectsEmit('onDiscountApplied', {
3336
3472
  productList: tempOrder.products || [],
3337
3473
  discountList: nextDiscountList,
@@ -3340,14 +3476,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3340
3476
  });
3341
3477
  case 32:
3342
3478
  cb === null || cb === void 0 || cb(result);
3343
- return _context26.abrupt("return", result);
3479
+ return _context27.abrupt("return", result);
3344
3480
  case 34:
3345
3481
  case "end":
3346
- return _context26.stop();
3482
+ return _context27.stop();
3347
3483
  }
3348
- }, _callee26, this);
3484
+ }, _callee27, this);
3349
3485
  }));
3350
- function bestDiscount(_x18) {
3486
+ function bestDiscount(_x19) {
3351
3487
  return _bestDiscount.apply(this, arguments);
3352
3488
  }
3353
3489
  return bestDiscount;
@@ -3376,41 +3512,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3376
3512
  }, {
3377
3513
  key: "replaceDiscountStoreLists",
3378
3514
  value: (function () {
3379
- var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3515
+ var _replaceDiscountStoreLists = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3380
3516
  var _store2;
3381
3517
  var discountModule;
3382
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3383
- while (1) switch (_context27.prev = _context27.next) {
3518
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3519
+ while (1) switch (_context28.prev = _context28.next) {
3384
3520
  case 0:
3385
3521
  if (this.store.order) {
3386
- _context27.next = 2;
3522
+ _context28.next = 2;
3387
3523
  break;
3388
3524
  }
3389
3525
  throw new Error('order 模块未初始化');
3390
3526
  case 2:
3391
3527
  discountModule = (_store2 = this.store.order.store) === null || _store2 === void 0 ? void 0 : _store2.discount;
3392
3528
  if (discountModule) {
3393
- _context27.next = 5;
3529
+ _context28.next = 5;
3394
3530
  break;
3395
3531
  }
3396
- return _context27.abrupt("return");
3532
+ return _context28.abrupt("return");
3397
3533
  case 5:
3398
3534
  if (!params.originalDiscountList) {
3399
- _context27.next = 8;
3535
+ _context28.next = 8;
3400
3536
  break;
3401
3537
  }
3402
- _context27.next = 8;
3538
+ _context28.next = 8;
3403
3539
  return discountModule.setOriginalDiscountList(params.originalDiscountList);
3404
3540
  case 8:
3405
- _context27.next = 10;
3541
+ _context28.next = 10;
3406
3542
  return discountModule.setDiscountList(params.discountList);
3407
3543
  case 10:
3408
3544
  case "end":
3409
- return _context27.stop();
3545
+ return _context28.stop();
3410
3546
  }
3411
- }, _callee27, this);
3547
+ }, _callee28, this);
3412
3548
  }));
3413
- function replaceDiscountStoreLists(_x19) {
3549
+ function replaceDiscountStoreLists(_x20) {
3414
3550
  return _replaceDiscountStoreLists.apply(this, arguments);
3415
3551
  }
3416
3552
  return replaceDiscountStoreLists;
@@ -3418,34 +3554,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3418
3554
  }, {
3419
3555
  key: "scanPromotionCode",
3420
3556
  value: function () {
3421
- var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(code, customerId) {
3557
+ var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(code, customerId) {
3422
3558
  var raw, tempOrder;
3423
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3424
- while (1) switch (_context28.prev = _context28.next) {
3559
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3560
+ while (1) switch (_context29.prev = _context29.next) {
3425
3561
  case 0:
3426
- _context28.prev = 0;
3562
+ _context29.prev = 0;
3427
3563
  if (this.store.order) {
3428
- _context28.next = 3;
3564
+ _context29.next = 3;
3429
3565
  break;
3430
3566
  }
3431
3567
  throw new Error('order 模块未初始化');
3432
3568
  case 3:
3433
- _context28.next = 5;
3569
+ _context29.next = 5;
3434
3570
  return this.store.order.scanCode(code, customerId);
3435
3571
  case 5:
3436
- raw = _context28.sent;
3572
+ raw = _context29.sent;
3437
3573
  if (!raw.isAvailable) {
3438
- _context28.next = 13;
3574
+ _context29.next = 13;
3439
3575
  break;
3440
3576
  }
3441
- _context28.next = 9;
3577
+ _context29.next = 9;
3442
3578
  return this.store.order.recalculateSummary({
3443
3579
  createIfMissing: true
3444
3580
  });
3445
3581
  case 9:
3446
3582
  this.store.order.persistTempOrder();
3447
3583
  tempOrder = this.store.order.ensureTempOrder();
3448
- _context28.next = 13;
3584
+ _context29.next = 13;
3449
3585
  return this.effectsEmit('onDiscountApplied', {
3450
3586
  productList: tempOrder.products || [],
3451
3587
  discountList: this.store.order.getDiscountList(),
@@ -3453,7 +3589,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3453
3589
  tempOrder: tempOrder
3454
3590
  });
3455
3591
  case 13:
3456
- return _context28.abrupt("return", _objectSpread(_objectSpread({
3592
+ return _context29.abrupt("return", _objectSpread(_objectSpread({
3457
3593
  isAvailable: raw.isAvailable
3458
3594
  }, raw.isAccepted !== undefined ? {
3459
3595
  isAccepted: raw.isAccepted
@@ -3463,16 +3599,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3463
3599
  scannedDiscountList: raw.scannedDiscountList
3464
3600
  }));
3465
3601
  case 16:
3466
- _context28.prev = 16;
3467
- _context28.t0 = _context28["catch"](0);
3468
- throw _context28.t0;
3602
+ _context29.prev = 16;
3603
+ _context29.t0 = _context29["catch"](0);
3604
+ throw _context29.t0;
3469
3605
  case 19:
3470
3606
  case "end":
3471
- return _context28.stop();
3607
+ return _context29.stop();
3472
3608
  }
3473
- }, _callee28, this, [[0, 16]]);
3609
+ }, _callee29, this, [[0, 16]]);
3474
3610
  }));
3475
- function scanPromotionCode(_x20, _x21) {
3611
+ function scanPromotionCode(_x21, _x22) {
3476
3612
  return _scanPromotionCode.apply(this, arguments);
3477
3613
  }
3478
3614
  return scanPromotionCode;
@@ -3480,35 +3616,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3480
3616
  }, {
3481
3617
  key: "setDiscountSelected",
3482
3618
  value: function () {
3483
- var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3619
+ var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3484
3620
  var currentOrder, _store3, _store3$setDiscountLi, list, updated, tempOrder, orderStore, _discountModule, rulesModule, nextDiscountList, _orderStore$summary3, orderTotalAmount, result, beforeSelectedIds, _iterator4, _step4, d, selectedResourceIds, filterSelectedDiscountDetails, _iterator5, _step5, _product$metadata8, _tempOrder$_extend7, _product$metadata$sou2, _product$metadata9, _product$metadata10, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
3485
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3486
- while (1) switch (_context29.prev = _context29.next) {
3621
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3622
+ while (1) switch (_context30.prev = _context30.next) {
3487
3623
  case 0:
3488
- _context29.prev = 0;
3624
+ _context30.prev = 0;
3489
3625
  if (this.store.order) {
3490
- _context29.next = 3;
3626
+ _context30.next = 3;
3491
3627
  break;
3492
3628
  }
3493
3629
  throw new Error('order 模块未初始化');
3494
3630
  case 3:
3495
3631
  currentOrder = this.store.order.ensureTempOrder();
3496
3632
  if (!this.isActiveVirtualSettlementOrder(currentOrder)) {
3497
- _context29.next = 13;
3633
+ _context30.next = 13;
3498
3634
  break;
3499
3635
  }
3500
3636
  currentOrder.discount_list = [];
3501
3637
  currentOrder.shop_discount = '0.00';
3502
- _context29.next = 9;
3638
+ _context30.next = 9;
3503
3639
  return (_store3 = this.store.order.store) === null || _store3 === void 0 || (_store3 = _store3.discount) === null || _store3 === void 0 || (_store3$setDiscountLi = _store3.setDiscountList) === null || _store3$setDiscountLi === void 0 ? void 0 : _store3$setDiscountLi.call(_store3, []);
3504
3640
  case 9:
3505
- _context29.next = 11;
3641
+ _context30.next = 11;
3506
3642
  return this.store.order.recalculateSummary({
3507
3643
  createIfMissing: true
3508
3644
  });
3509
3645
  case 11:
3510
3646
  this.store.order.persistTempOrder();
3511
- return _context29.abrupt("return");
3647
+ return _context30.abrupt("return");
3512
3648
  case 13:
3513
3649
  list = this.store.order.getDiscountList();
3514
3650
  updated = list.map(function (d) {
@@ -3523,7 +3659,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3523
3659
  _discountModule = orderStore.discount;
3524
3660
  rulesModule = orderStore.rules;
3525
3661
  nextDiscountList = updated;
3526
- _context29.next = 23;
3662
+ _context30.next = 23;
3527
3663
  return _discountModule === null || _discountModule === void 0 ? void 0 : _discountModule.setDiscountList(updated);
3528
3664
  case 23:
3529
3665
  if (rulesModule) {
@@ -3585,21 +3721,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3585
3721
  });
3586
3722
  };
3587
3723
  _iterator5 = _createForOfIteratorHelper(tempOrder.products);
3588
- _context29.prev = 27;
3724
+ _context30.prev = 27;
3589
3725
  _iterator5.s();
3590
3726
  case 29:
3591
3727
  if ((_step5 = _iterator5.n()).done) {
3592
- _context29.next = 46;
3728
+ _context30.next = 46;
3593
3729
  break;
3594
3730
  }
3595
3731
  product = _step5.value;
3596
3732
  productUid = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.unique_identification_number;
3597
3733
  runtimeOrigin = productUid ? (_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 || (_tempOrder$_extend7 = _tempOrder$_extend7.productsByUid) === null || _tempOrder$_extend7 === void 0 || (_tempOrder$_extend7 = _tempOrder$_extend7[productUid]) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.origin : undefined;
3598
3734
  if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || isBaseSalesManualProductDiscountProduct(product))) {
3599
- _context29.next = 35;
3735
+ _context30.next = 35;
3600
3736
  break;
3601
3737
  }
3602
- return _context29.abrupt("continue", 44);
3738
+ return _context30.abrupt("continue", 44);
3603
3739
  case 35:
3604
3740
  product.discount_list = filterSelectedDiscountDetails(product.discount_list);
3605
3741
  if (Array.isArray(product.product_bundle)) {
@@ -3635,28 +3771,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3635
3771
  bundle: product.product_bundle
3636
3772
  });
3637
3773
  case 44:
3638
- _context29.next = 29;
3774
+ _context30.next = 29;
3639
3775
  break;
3640
3776
  case 46:
3641
- _context29.next = 51;
3777
+ _context30.next = 51;
3642
3778
  break;
3643
3779
  case 48:
3644
- _context29.prev = 48;
3645
- _context29.t0 = _context29["catch"](27);
3646
- _iterator5.e(_context29.t0);
3780
+ _context30.prev = 48;
3781
+ _context30.t0 = _context30["catch"](27);
3782
+ _iterator5.e(_context30.t0);
3647
3783
  case 51:
3648
- _context29.prev = 51;
3784
+ _context30.prev = 51;
3649
3785
  _iterator5.f();
3650
- return _context29.finish(51);
3786
+ return _context30.finish(51);
3651
3787
  case 54:
3652
3788
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
3653
- _context29.next = 57;
3789
+ _context30.next = 57;
3654
3790
  return _discountModule === null || _discountModule === void 0 ? void 0 : _discountModule.setDiscountList(nextDiscountList);
3655
3791
  case 57:
3656
3792
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
3657
3793
  return d.isSelected;
3658
3794
  });
3659
- _context29.next = 60;
3795
+ _context30.next = 60;
3660
3796
  return this.store.order.recalculateSummary({
3661
3797
  createIfMissing: true
3662
3798
  });
@@ -3668,19 +3804,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3668
3804
  selectedDiscountList: tempOrder.discount_list,
3669
3805
  tempOrder: tempOrder
3670
3806
  });
3671
- _context29.next = 67;
3807
+ _context30.next = 67;
3672
3808
  break;
3673
3809
  case 64:
3674
- _context29.prev = 64;
3675
- _context29.t1 = _context29["catch"](0);
3676
- throw _context29.t1;
3810
+ _context30.prev = 64;
3811
+ _context30.t1 = _context30["catch"](0);
3812
+ throw _context30.t1;
3677
3813
  case 67:
3678
3814
  case "end":
3679
- return _context29.stop();
3815
+ return _context30.stop();
3680
3816
  }
3681
- }, _callee29, this, [[0, 64], [27, 48, 51, 54]]);
3817
+ }, _callee30, this, [[0, 64], [27, 48, 51, 54]]);
3682
3818
  }));
3683
- function setDiscountSelected(_x22) {
3819
+ function setDiscountSelected(_x23) {
3684
3820
  return _setDiscountSelected.apply(this, arguments);
3685
3821
  }
3686
3822
  return setDiscountSelected;
@@ -3688,23 +3824,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3688
3824
  }, {
3689
3825
  key: "applyDiscountCalculationResult",
3690
3826
  value: function () {
3691
- var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(result) {
3827
+ var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(result) {
3692
3828
  var tempOrder, orderStore, _discountModule2;
3693
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3694
- while (1) switch (_context30.prev = _context30.next) {
3829
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3830
+ while (1) switch (_context31.prev = _context31.next) {
3695
3831
  case 0:
3696
- _context30.prev = 0;
3832
+ _context31.prev = 0;
3697
3833
  if (this.store.order) {
3698
- _context30.next = 3;
3834
+ _context31.next = 3;
3699
3835
  break;
3700
3836
  }
3701
3837
  throw new Error('order 模块未初始化');
3702
3838
  case 3:
3703
3839
  if (result) {
3704
- _context30.next = 5;
3840
+ _context31.next = 5;
3705
3841
  break;
3706
3842
  }
3707
- return _context30.abrupt("return");
3843
+ return _context31.abrupt("return");
3708
3844
  case 5:
3709
3845
  tempOrder = this.store.order.ensureTempOrder();
3710
3846
  orderStore = this.store.order.store || {};
@@ -3713,24 +3849,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3713
3849
  tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
3714
3850
  }
3715
3851
  if (!result.discountList) {
3716
- _context30.next = 14;
3852
+ _context31.next = 14;
3717
3853
  break;
3718
3854
  }
3719
3855
  OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
3720
- _context30.next = 13;
3856
+ _context31.next = 13;
3721
3857
  return _discountModule2 === null || _discountModule2 === void 0 ? void 0 : _discountModule2.setDiscountList(result.discountList);
3722
3858
  case 13:
3723
3859
  tempOrder.discount_list = result.discountList.filter(function (discount) {
3724
3860
  return discount.isSelected;
3725
3861
  });
3726
3862
  case 14:
3727
- _context30.next = 16;
3863
+ _context31.next = 16;
3728
3864
  return this.store.order.recalculateSummary({
3729
3865
  createIfMissing: true
3730
3866
  });
3731
3867
  case 16:
3732
3868
  this.store.order.persistTempOrder();
3733
- _context30.next = 19;
3869
+ _context31.next = 19;
3734
3870
  return this.effectsEmit('onDiscountApplied', {
3735
3871
  productList: tempOrder.products || [],
3736
3872
  discountList: result.discountList || [],
@@ -3738,19 +3874,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3738
3874
  tempOrder: tempOrder
3739
3875
  });
3740
3876
  case 19:
3741
- _context30.next = 24;
3877
+ _context31.next = 24;
3742
3878
  break;
3743
3879
  case 21:
3744
- _context30.prev = 21;
3745
- _context30.t0 = _context30["catch"](0);
3746
- throw _context30.t0;
3880
+ _context31.prev = 21;
3881
+ _context31.t0 = _context31["catch"](0);
3882
+ throw _context31.t0;
3747
3883
  case 24:
3748
3884
  case "end":
3749
- return _context30.stop();
3885
+ return _context31.stop();
3750
3886
  }
3751
- }, _callee30, this, [[0, 21]]);
3887
+ }, _callee31, this, [[0, 21]]);
3752
3888
  }));
3753
- function applyDiscountCalculationResult(_x23) {
3889
+ function applyDiscountCalculationResult(_x24) {
3754
3890
  return _applyDiscountCalculationResult.apply(this, arguments);
3755
3891
  }
3756
3892
  return applyDiscountCalculationResult;
@@ -3758,18 +3894,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3758
3894
  }, {
3759
3895
  key: "submitScanOrder",
3760
3896
  value: function () {
3761
- var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
3762
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3763
- while (1) switch (_context31.prev = _context31.next) {
3897
+ var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
3898
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3899
+ while (1) switch (_context32.prev = _context32.next) {
3764
3900
  case 0:
3765
- return _context31.abrupt("return", this.submitSalesOrder(params));
3901
+ return _context32.abrupt("return", this.submitSalesOrder(params));
3766
3902
  case 1:
3767
3903
  case "end":
3768
- return _context31.stop();
3904
+ return _context32.stop();
3769
3905
  }
3770
- }, _callee31, this);
3906
+ }, _callee32, this);
3771
3907
  }));
3772
- function submitScanOrder(_x24) {
3908
+ function submitScanOrder(_x25) {
3773
3909
  return _submitScanOrder.apply(this, arguments);
3774
3910
  }
3775
3911
  return submitScanOrder;
@@ -3777,46 +3913,46 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3777
3913
  }, {
3778
3914
  key: "buildVirtualSettlementSubmitData",
3779
3915
  value: function () {
3780
- var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
3916
+ var _buildVirtualSettlementSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
3781
3917
  var _tempOrder$metadata$c, _tempOrder$metadata2;
3782
3918
  var tempOrder, snapshot, currencyProductId, summary, amount, customerId, asset, currencyCode, currencySymbol, currencyFormat, balance, amountText, paymentNumber, payment, _paymentMethod$custom, paymentMethods, paymentMethod;
3783
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3784
- while (1) switch (_context32.prev = _context32.next) {
3919
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3920
+ while (1) switch (_context33.prev = _context33.next) {
3785
3921
  case 0:
3786
3922
  if (this.store.order) {
3787
- _context32.next = 2;
3923
+ _context33.next = 2;
3788
3924
  break;
3789
3925
  }
3790
- return _context32.abrupt("return", null);
3926
+ return _context33.abrupt("return", null);
3791
3927
  case 2:
3792
3928
  tempOrder = this.store.order.getTempOrder();
3793
3929
  if (this.isActiveVirtualSettlementOrder(tempOrder)) {
3794
- _context32.next = 5;
3930
+ _context33.next = 5;
3795
3931
  break;
3796
3932
  }
3797
- return _context32.abrupt("return", null);
3933
+ return _context33.abrupt("return", null);
3798
3934
  case 5:
3799
3935
  snapshot = getTempOrderSettlementSnapshot(tempOrder);
3800
3936
  currencyProductId = Number((_tempOrder$metadata$c = tempOrder === null || tempOrder === void 0 || (_tempOrder$metadata2 = tempOrder.metadata) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.currency_settlement_config) === null || _tempOrder$metadata2 === void 0 || (_tempOrder$metadata2 = _tempOrder$metadata2.settlement_ids) === null || _tempOrder$metadata2 === void 0 ? void 0 : _tempOrder$metadata2[0]) !== null && _tempOrder$metadata$c !== void 0 ? _tempOrder$metadata$c : snapshot === null || snapshot === void 0 ? void 0 : snapshot.currency_product_id);
3801
3937
  if (!(!snapshot || !Number.isFinite(currencyProductId) || currencyProductId <= 0)) {
3802
- _context32.next = 9;
3938
+ _context33.next = 9;
3803
3939
  break;
3804
3940
  }
3805
3941
  throw new Error('Virtual currency settlement configuration is invalid.');
3806
3942
  case 9:
3807
- _context32.next = 11;
3943
+ _context33.next = 11;
3808
3944
  return this.store.order.recalculateSummary({
3809
3945
  createIfMissing: true
3810
3946
  });
3811
3947
  case 11:
3812
- summary = _context32.sent;
3948
+ summary = _context33.sent;
3813
3949
  amount = new Decimal((summary === null || summary === void 0 ? void 0 : summary.total_amount) || 0).toDecimalPlaces(2);
3814
3950
  customerId = Number((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || 0);
3815
3951
  if (!(amount.gt(0) && customerId > 0 && customerId !== 1)) {
3816
- _context32.next = 17;
3952
+ _context33.next = 17;
3817
3953
  break;
3818
3954
  }
3819
- _context32.next = 17;
3955
+ _context33.next = 17;
3820
3956
  return this.store.order.loadDiscountConfig({
3821
3957
  customerId: customerId,
3822
3958
  action: tempOrder !== null && tempOrder !== void 0 && tempOrder.order_id ? 'edit' : 'create',
@@ -3831,10 +3967,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3831
3967
  currencySymbol = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || '');
3832
3968
  currencyFormat = String((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_format) || 'symbol_first');
3833
3969
  if (!amount.lte(0)) {
3834
- _context32.next = 23;
3970
+ _context33.next = 23;
3835
3971
  break;
3836
3972
  }
3837
- return _context32.abrupt("return", {
3973
+ return _context33.abrupt("return", {
3838
3974
  payments: [],
3839
3975
  snapshot: snapshot,
3840
3976
  currencyProductId: currencyProductId,
@@ -3844,14 +3980,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3844
3980
  });
3845
3981
  case 23:
3846
3982
  if (asset) {
3847
- _context32.next = 25;
3983
+ _context33.next = 25;
3848
3984
  break;
3849
3985
  }
3850
3986
  throw new Error('No matching virtual currency card is available.');
3851
3987
  case 25:
3852
3988
  balance = new Decimal(asset.balance || 0);
3853
3989
  if (!balance.lt(amount)) {
3854
- _context32.next = 28;
3990
+ _context33.next = 28;
3855
3991
  break;
3856
3992
  }
3857
3993
  throw new Error('Insufficient virtual currency balance.');
@@ -3859,7 +3995,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3859
3995
  amountText = amount.toFixed(2);
3860
3996
  paymentNumber = "LOCAL_".concat(createUuidV4());
3861
3997
  if (!this.store.order.isOnlineStorePlatform()) {
3862
- _context32.next = 34;
3998
+ _context33.next = 34;
3863
3999
  break;
3864
4000
  }
3865
4001
  payment = {
@@ -3876,18 +4012,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3876
4012
  },
3877
4013
  wallet_pass_use_value: amountText
3878
4014
  };
3879
- _context32.next = 41;
4015
+ _context33.next = 41;
3880
4016
  break;
3881
4017
  case 34:
3882
- _context32.next = 36;
4018
+ _context33.next = 36;
3883
4019
  return this.getPaymentMethodsAsync();
3884
4020
  case 36:
3885
- paymentMethods = _context32.sent;
4021
+ paymentMethods = _context33.sent;
3886
4022
  paymentMethod = paymentMethods.find(function (method) {
3887
4023
  return String(method.code || '').toUpperCase() === 'PRODUCTVOUCHER';
3888
4024
  });
3889
4025
  if (paymentMethod) {
3890
- _context32.next = 40;
4026
+ _context33.next = 40;
3891
4027
  break;
3892
4028
  }
3893
4029
  throw new Error('PRODUCTVOUCHER payment method is unavailable.');
@@ -3911,7 +4047,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3911
4047
  metadata: {}
3912
4048
  };
3913
4049
  case 41:
3914
- return _context32.abrupt("return", {
4050
+ return _context33.abrupt("return", {
3915
4051
  payments: [payment],
3916
4052
  snapshot: snapshot,
3917
4053
  currencyProductId: currencyProductId,
@@ -3921,9 +4057,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3921
4057
  });
3922
4058
  case 42:
3923
4059
  case "end":
3924
- return _context32.stop();
4060
+ return _context33.stop();
3925
4061
  }
3926
- }, _callee32, this);
4062
+ }, _callee33, this);
3927
4063
  }));
3928
4064
  function buildVirtualSettlementSubmitData() {
3929
4065
  return _buildVirtualSettlementSubmitData.apply(this, arguments);
@@ -3939,22 +4075,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3939
4075
  }, {
3940
4076
  key: "submitSalesOrder",
3941
4077
  value: (function () {
3942
- var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
3943
- var _params$smallTicketDa, _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
4078
+ var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4079
+ var _params$smallTicketDa, _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21;
3944
4080
  var virtualSettlement, inferredPaymentStatus, smallTicketDataFlag, virtualSettlementEnhancePayload, enhancePayload, submitParams;
3945
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3946
- while (1) switch (_context33.prev = _context33.next) {
4081
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4082
+ while (1) switch (_context34.prev = _context34.next) {
3947
4083
  case 0:
3948
4084
  if (this.store.order) {
3949
- _context33.next = 2;
4085
+ _context34.next = 2;
3950
4086
  break;
3951
4087
  }
3952
4088
  throw new Error('BaseSales 解决方案需要 order 模块支持');
3953
4089
  case 2:
3954
- _context33.next = 4;
4090
+ if (!this.isPickupTimingEnabled()) {
4091
+ _context34.next = 5;
4092
+ break;
4093
+ }
4094
+ _context34.next = 5;
4095
+ return this.preparePickupTimingForCheckout({
4096
+ freeze: true
4097
+ });
4098
+ case 5:
4099
+ _context34.next = 7;
3955
4100
  return this.buildVirtualSettlementSubmitData();
3956
- case 4:
3957
- virtualSettlement = _context33.sent;
4101
+ case 7:
4102
+ virtualSettlement = _context34.sent;
3958
4103
  // this.store.order.persistTempOrder();
3959
4104
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
3960
4105
  smallTicketDataFlag = (_params$smallTicketDa = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa !== void 0 ? _params$smallTicketDa : this.getDefaultCheckoutSmallTicketDataFlag();
@@ -3978,10 +4123,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3978
4123
  enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(virtualSettlementEnhancePayload);
3979
4124
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
3980
4125
  cacheId: this.cacheId,
3981
- platform: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform,
3982
- businessCode: ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.businessCode) || ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.business_code),
4126
+ platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
4127
+ businessCode: ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
3983
4128
  channel: this.getSubmitOrderSalesChannel(),
3984
- type: (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.type,
4129
+ type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type,
3985
4130
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
3986
4131
  }, virtualSettlement ? {
3987
4132
  payments: virtualSettlement.payments
@@ -3998,14 +4143,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3998
4143
  } : {}), enhancePayload !== undefined ? {
3999
4144
  enhancePayload: enhancePayload
4000
4145
  } : {});
4001
- return _context33.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
4002
- case 11:
4146
+ return _context34.abrupt("return", this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams));
4147
+ case 14:
4003
4148
  case "end":
4004
- return _context33.stop();
4149
+ return _context34.stop();
4005
4150
  }
4006
- }, _callee33, this);
4151
+ }, _callee34, this);
4007
4152
  }));
4008
- function submitSalesOrder(_x25) {
4153
+ function submitSalesOrder(_x26) {
4009
4154
  return _submitSalesOrder.apply(this, arguments);
4010
4155
  }
4011
4156
  return submitSalesOrder;
@@ -4013,33 +4158,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4013
4158
  }, {
4014
4159
  key: "saveSalesOrderDraft",
4015
4160
  value: function () {
4016
- var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4017
- var _params$platform, _this$otherParams18, _this$otherParams19, _this$otherParams20, _params$channel, _params$type, _this$otherParams21;
4018
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4019
- while (1) switch (_context34.prev = _context34.next) {
4161
+ var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4162
+ var _params$platform, _this$otherParams22, _this$otherParams23, _this$otherParams24, _params$channel, _params$type, _this$otherParams25;
4163
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4164
+ while (1) switch (_context35.prev = _context35.next) {
4020
4165
  case 0:
4021
4166
  if (this.store.order) {
4022
- _context34.next = 2;
4167
+ _context35.next = 2;
4023
4168
  break;
4024
4169
  }
4025
4170
  throw new Error('BaseSales 解决方案需要 order 模块支持');
4026
4171
  case 2:
4027
- return _context34.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
4172
+ if (!this.isPickupTimingEnabled()) {
4173
+ _context35.next = 5;
4174
+ break;
4175
+ }
4176
+ _context35.next = 5;
4177
+ return this.preparePickupTimingForCheckout({
4178
+ freeze: false
4179
+ });
4180
+ case 5:
4181
+ return _context35.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
4028
4182
  cacheId: this.cacheId,
4029
- platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
4030
- businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode) || ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.business_code),
4183
+ platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform,
4184
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) || ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code),
4031
4185
  channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
4032
- type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
4186
+ type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.type
4033
4187
  }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
4034
4188
  enhancePayload: params.enhancePayload
4035
4189
  } : {})));
4036
- case 3:
4190
+ case 6:
4037
4191
  case "end":
4038
- return _context34.stop();
4192
+ return _context35.stop();
4039
4193
  }
4040
- }, _callee34, this);
4194
+ }, _callee35, this);
4041
4195
  }));
4042
- function saveSalesOrderDraft(_x26) {
4196
+ function saveSalesOrderDraft(_x27) {
4043
4197
  return _saveSalesOrderDraft.apply(this, arguments);
4044
4198
  }
4045
4199
  return saveSalesOrderDraft;
@@ -4047,27 +4201,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4047
4201
  }, {
4048
4202
  key: "submitTempOrderAsync",
4049
4203
  value: function () {
4050
- var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
4051
- var _params$smallTicketDa2, _this$otherParams22, _this$otherParams23, _this$otherParams24, _this$otherParams25;
4204
+ var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
4205
+ var _params$smallTicketDa2, _this$otherParams26, _this$otherParams27, _this$otherParams28, _this$otherParams29;
4052
4206
  var inferredPaymentStatus, smallTicketDataFlag, enhancePayload, submitParams;
4053
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4054
- while (1) switch (_context35.prev = _context35.next) {
4207
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4208
+ while (1) switch (_context36.prev = _context36.next) {
4055
4209
  case 0:
4056
4210
  if (this.store.order) {
4057
- _context35.next = 2;
4211
+ _context36.next = 2;
4058
4212
  break;
4059
4213
  }
4060
4214
  throw new Error('BaseSales 解决方案需要 order 模块支持');
4061
4215
  case 2:
4216
+ if (!this.isPickupTimingEnabled()) {
4217
+ _context36.next = 5;
4218
+ break;
4219
+ }
4220
+ _context36.next = 5;
4221
+ return this.preparePickupTimingForCheckout({
4222
+ freeze: true
4223
+ });
4224
+ case 5:
4062
4225
  inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
4063
4226
  smallTicketDataFlag = (_params$smallTicketDa2 = params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== null && _params$smallTicketDa2 !== void 0 ? _params$smallTicketDa2 : this.getDefaultCheckoutSmallTicketDataFlag();
4064
4227
  enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params === null || params === void 0 ? void 0 : params.enhancePayload);
4065
4228
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
4066
4229
  cacheId: this.cacheId,
4067
- platform: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform,
4068
- businessCode: ((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) || ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code),
4230
+ platform: (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform,
4231
+ businessCode: ((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.businessCode) || ((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.business_code),
4069
4232
  channel: this.getSubmitOrderSalesChannel(),
4070
- type: (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.type,
4233
+ type: (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.type,
4071
4234
  request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
4072
4235
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
4073
4236
  payments: params.payments
@@ -4080,14 +4243,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4080
4243
  } : {}), enhancePayload !== undefined ? {
4081
4244
  enhancePayload: enhancePayload
4082
4245
  } : {});
4083
- return _context35.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
4084
- case 7:
4246
+ return _context36.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
4247
+ case 10:
4085
4248
  case "end":
4086
- return _context35.stop();
4249
+ return _context36.stop();
4087
4250
  }
4088
- }, _callee35, this);
4251
+ }, _callee36, this);
4089
4252
  }));
4090
- function submitTempOrderAsync(_x27) {
4253
+ function submitTempOrderAsync(_x28) {
4091
4254
  return _submitTempOrderAsync.apply(this, arguments);
4092
4255
  }
4093
4256
  return submitTempOrderAsync;
@@ -4099,8 +4262,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4099
4262
  }, {
4100
4263
  key: "shouldUseCheckoutSyncTask",
4101
4264
  value: function shouldUseCheckoutSyncTask() {
4102
- var _this$otherParams26;
4103
- var configured = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.checkoutSyncTaskEnabled;
4265
+ var _this$otherParams30;
4266
+ var configured = (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.checkoutSyncTaskEnabled;
4104
4267
  return typeof configured === 'boolean' ? configured : true;
4105
4268
  }
4106
4269
 
@@ -4113,14 +4276,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4113
4276
  }, {
4114
4277
  key: "printLocalOrderReceipt",
4115
4278
  value: function () {
4116
- var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(lookup) {
4117
- var _this$otherParams27, _this$otherParams28, _this$otherParams29, _this$otherParams30;
4118
- var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order10, _data;
4119
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4120
- while (1) switch (_context36.prev = _context36.next) {
4279
+ var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(lookup) {
4280
+ var _this$otherParams31, _this$otherParams32, _this$otherParams33, _this$otherParams34;
4281
+ var hasLookup, lookupPayload, context, payload, invoiceLayoutConfig, invoiceTemplateSettings, printPayload, response, _this$store$order$app, _this$store$order12, _data;
4282
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4283
+ while (1) switch (_context37.prev = _context37.next) {
4121
4284
  case 0:
4122
4285
  if (this.store.order) {
4123
- _context36.next = 2;
4286
+ _context37.next = 2;
4124
4287
  break;
4125
4288
  }
4126
4289
  throw new Error('BaseSales 解决方案需要 order 模块支持');
@@ -4132,10 +4295,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4132
4295
  external_sale_number: lookup
4133
4296
  };
4134
4297
  context = {
4135
- platform: (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform,
4136
- businessCode: ((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.businessCode) || ((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.business_code),
4298
+ platform: (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.platform,
4299
+ businessCode: ((_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.businessCode) || ((_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.business_code),
4137
4300
  channel: this.getSubmitOrderSalesChannel(),
4138
- type: (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.type
4301
+ type: (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.type
4139
4302
  };
4140
4303
  payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
4141
4304
  lookup_order_from_db: 1,
@@ -4158,28 +4321,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4158
4321
  } : {}), invoiceTemplateSettings ? {
4159
4322
  template_settings: cloneDeep(invoiceTemplateSettings)
4160
4323
  } : {});
4161
- _context36.next = 11;
4324
+ _context37.next = 11;
4162
4325
  return this.request.post('/local/print-order', printPayload, {
4163
4326
  osServer: true,
4164
4327
  customToast: function customToast() {}
4165
4328
  });
4166
4329
  case 11:
4167
- response = _context36.sent;
4330
+ response = _context37.sent;
4168
4331
  if (hasLookup) {
4169
- _context36.next = 15;
4332
+ _context37.next = 15;
4170
4333
  break;
4171
4334
  }
4172
- _context36.next = 15;
4173
- return (_this$store$order$app = (_this$store$order10 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order10, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
4335
+ _context37.next = 15;
4336
+ return (_this$store$order$app = (_this$store$order12 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order12, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
4174
4337
  case 15:
4175
- return _context36.abrupt("return", response);
4338
+ return _context37.abrupt("return", response);
4176
4339
  case 16:
4177
4340
  case "end":
4178
- return _context36.stop();
4341
+ return _context37.stop();
4179
4342
  }
4180
- }, _callee36, this);
4343
+ }, _callee37, this);
4181
4344
  }));
4182
- function printLocalOrderReceipt(_x28) {
4345
+ function printLocalOrderReceipt(_x29) {
4183
4346
  return _printLocalOrderReceipt.apply(this, arguments);
4184
4347
  }
4185
4348
  return printLocalOrderReceipt;
@@ -4187,9 +4350,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4187
4350
  }, {
4188
4351
  key: "getSubmitPaymentStatus",
4189
4352
  value: function getSubmitPaymentStatus(paymentStatus) {
4190
- var _this$store$order11, _this$store$order11$g;
4353
+ var _this$store$order13, _this$store$order13$g;
4191
4354
  if (paymentStatus !== undefined) return paymentStatus;
4192
- var amountSnapshot = (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$g = _this$store$order11.getOrderAmountSnapshot) === null || _this$store$order11$g === void 0 ? void 0 : _this$store$order11$g.call(_this$store$order11);
4355
+ var amountSnapshot = (_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 || (_this$store$order13$g = _this$store$order13.getOrderAmountSnapshot) === null || _this$store$order13$g === void 0 ? void 0 : _this$store$order13$g.call(_this$store$order13);
4193
4356
  if (!amountSnapshot) return undefined;
4194
4357
  try {
4195
4358
  return new Decimal(amountSnapshot.amountGap || 0).lte(0) ? 'paid' : undefined;
@@ -4200,19 +4363,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4200
4363
  }, {
4201
4364
  key: "syncPaymentsToOrder",
4202
4365
  value: function () {
4203
- var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
4204
- var _ref47, _params$businessCode, _this$otherParams31, _this$otherParams32, _params$channel2;
4366
+ var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
4367
+ var _ref47, _params$businessCode, _this$otherParams35, _this$otherParams36, _params$channel2;
4205
4368
  var businessCode, channel, enhancePayload, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
4206
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4207
- while (1) switch (_context37.prev = _context37.next) {
4369
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4370
+ while (1) switch (_context38.prev = _context38.next) {
4208
4371
  case 0:
4209
4372
  if (this.store.order) {
4210
- _context37.next = 2;
4373
+ _context38.next = 2;
4211
4374
  break;
4212
4375
  }
4213
4376
  throw new Error('order 模块未初始化');
4214
4377
  case 2:
4215
- businessCode = (_ref47 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) !== null && _ref47 !== void 0 ? _ref47 : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.business_code;
4378
+ businessCode = (_ref47 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.businessCode) !== null && _ref47 !== void 0 ? _ref47 : (_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.business_code;
4216
4379
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
4217
4380
  enhancePayload = this.buildSubmitPayloadEnhancerWithOpenDataConfig(params.enhancePayload);
4218
4381
  syncParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, params), {}, {
@@ -4226,14 +4389,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4226
4389
  } : {});
4227
4390
  syncState = this.store.order.getOrderSyncState();
4228
4391
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
4229
- _context37.next = 10;
4392
+ _context38.next = 10;
4230
4393
  break;
4231
4394
  }
4232
4395
  this.queueLatestAutoPaymentSync();
4233
- return _context37.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4396
+ return _context38.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
4234
4397
  case 10:
4235
4398
  payments = params.payments || [];
4236
- _context37.next = 13;
4399
+ _context38.next = 13;
4237
4400
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
4238
4401
  payments: payments,
4239
4402
  params: syncParams,
@@ -4241,11 +4404,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4241
4404
  orderSnapshot: this.store.order.getOrderSnapshot()
4242
4405
  });
4243
4406
  case 13:
4244
- _context37.prev = 13;
4245
- _context37.next = 16;
4407
+ _context38.prev = 13;
4408
+ _context38.next = 16;
4246
4409
  return this.store.order.syncPaymentsToOrder(syncParams);
4247
4410
  case 16:
4248
- syncResult = _context37.sent;
4411
+ syncResult = _context38.sent;
4249
4412
  latestPayments = this.store.order.getOrderPayments();
4250
4413
  amountSnapshot = this.store.order.getOrderAmountSnapshot();
4251
4414
  orderSnapshot = this.store.order.getOrderSnapshot();
@@ -4263,25 +4426,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4263
4426
  depositAmount: syncResult.depositAmount,
4264
4427
  orderExpectedAmount: syncResult.orderExpectedAmount
4265
4428
  };
4266
- _context37.next = 23;
4429
+ _context38.next = 23;
4267
4430
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
4268
4431
  case 23:
4269
4432
  if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
4270
- _context37.next = 26;
4433
+ _context38.next = 26;
4271
4434
  break;
4272
4435
  }
4273
- _context37.next = 26;
4436
+ _context38.next = 26;
4274
4437
  return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
4275
4438
  case 26:
4276
4439
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4277
- return _context37.abrupt("return", syncResult);
4440
+ return _context38.abrupt("return", syncResult);
4278
4441
  case 30:
4279
- _context37.prev = 30;
4280
- _context37.t0 = _context37["catch"](13);
4281
- _context37.next = 34;
4442
+ _context38.prev = 30;
4443
+ _context38.t0 = _context38["catch"](13);
4444
+ _context38.next = 34;
4282
4445
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
4283
4446
  ok: false,
4284
- error: _context37.t0,
4447
+ error: _context38.t0,
4285
4448
  payments: this.store.order.getOrderPayments(),
4286
4449
  params: syncParams,
4287
4450
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
@@ -4289,14 +4452,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4289
4452
  });
4290
4453
  case 34:
4291
4454
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4292
- throw _context37.t0;
4455
+ throw _context38.t0;
4293
4456
  case 36:
4294
4457
  case "end":
4295
- return _context37.stop();
4458
+ return _context38.stop();
4296
4459
  }
4297
- }, _callee37, this, [[13, 30]]);
4460
+ }, _callee38, this, [[13, 30]]);
4298
4461
  }));
4299
- function syncPaymentsToOrder(_x29) {
4462
+ function syncPaymentsToOrder(_x30) {
4300
4463
  return _syncPaymentsToOrder.apply(this, arguments);
4301
4464
  }
4302
4465
  return syncPaymentsToOrder;
@@ -4333,58 +4496,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4333
4496
  }, {
4334
4497
  key: "scheduleQueuedAutoPaymentSyncFlush",
4335
4498
  value: function scheduleQueuedAutoPaymentSyncFlush() {
4336
- var _this16 = this;
4499
+ var _this17 = this;
4337
4500
  var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
4338
4501
  if (!this.queuedAutoPaymentSync) return;
4339
4502
  if (this.autoPaymentSyncTimer) return;
4340
4503
  this.autoPaymentSyncTimer = setTimeout(function () {
4341
- _this16.autoPaymentSyncTimer = null;
4342
- void _this16.flushQueuedAutoPaymentSync();
4504
+ _this17.autoPaymentSyncTimer = null;
4505
+ void _this17.flushQueuedAutoPaymentSync();
4343
4506
  }, delay);
4344
4507
  }
4345
4508
  }, {
4346
4509
  key: "flushQueuedAutoPaymentSync",
4347
4510
  value: function () {
4348
- var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
4511
+ var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
4349
4512
  var payments;
4350
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4351
- while (1) switch (_context38.prev = _context38.next) {
4513
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4514
+ while (1) switch (_context39.prev = _context39.next) {
4352
4515
  case 0:
4353
4516
  if (this.store.order) {
4354
- _context38.next = 2;
4517
+ _context39.next = 2;
4355
4518
  break;
4356
4519
  }
4357
- return _context38.abrupt("return");
4520
+ return _context39.abrupt("return");
4358
4521
  case 2:
4359
4522
  if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
4360
- _context38.next = 4;
4523
+ _context39.next = 4;
4361
4524
  break;
4362
4525
  }
4363
- return _context38.abrupt("return");
4526
+ return _context39.abrupt("return");
4364
4527
  case 4:
4365
4528
  if (!(this.store.order.getOrderSyncState() === 'submitting')) {
4366
- _context38.next = 7;
4529
+ _context39.next = 7;
4367
4530
  break;
4368
4531
  }
4369
4532
  this.scheduleQueuedAutoPaymentSyncFlush();
4370
- return _context38.abrupt("return");
4533
+ return _context39.abrupt("return");
4371
4534
  case 7:
4372
4535
  this.autoPaymentSyncFlushing = true;
4373
- _context38.prev = 8;
4536
+ _context39.prev = 8;
4374
4537
  case 9:
4375
4538
  if (!this.queuedAutoPaymentSync) {
4376
- _context38.next = 18;
4539
+ _context39.next = 18;
4377
4540
  break;
4378
4541
  }
4379
4542
  this.queuedAutoPaymentSync = false;
4380
4543
  payments = this.store.order.getOrderPayments();
4381
4544
  if (payments.length) {
4382
- _context38.next = 14;
4545
+ _context39.next = 14;
4383
4546
  break;
4384
4547
  }
4385
- return _context38.abrupt("continue", 9);
4548
+ return _context39.abrupt("continue", 9);
4386
4549
  case 14:
4387
- _context38.next = 16;
4550
+ _context39.next = 16;
4388
4551
  return this.syncPaymentsToOrder({
4389
4552
  payments: payments,
4390
4553
  paymentStatus: this.getPaymentStatusForSync(payments),
@@ -4392,29 +4555,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4392
4555
  smallTicketDataFlag: 1
4393
4556
  });
4394
4557
  case 16:
4395
- _context38.next = 9;
4558
+ _context39.next = 9;
4396
4559
  break;
4397
4560
  case 18:
4398
- _context38.next = 23;
4561
+ _context39.next = 23;
4399
4562
  break;
4400
4563
  case 20:
4401
- _context38.prev = 20;
4402
- _context38.t0 = _context38["catch"](8);
4564
+ _context39.prev = 20;
4565
+ _context39.t0 = _context39["catch"](8);
4403
4566
  this.logError('queued auto sync payments failed', {
4404
- error: _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0)
4567
+ error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
4405
4568
  });
4406
4569
  case 23:
4407
- _context38.prev = 23;
4570
+ _context39.prev = 23;
4408
4571
  this.autoPaymentSyncFlushing = false;
4409
4572
  if (this.queuedAutoPaymentSync) {
4410
4573
  this.scheduleQueuedAutoPaymentSyncFlush(0);
4411
4574
  }
4412
- return _context38.finish(23);
4575
+ return _context39.finish(23);
4413
4576
  case 27:
4414
4577
  case "end":
4415
- return _context38.stop();
4578
+ return _context39.stop();
4416
4579
  }
4417
- }, _callee38, this, [[8, 20, 23, 27]]);
4580
+ }, _callee39, this, [[8, 20, 23, 27]]);
4418
4581
  }));
4419
4582
  function flushQueuedAutoPaymentSync() {
4420
4583
  return _flushQueuedAutoPaymentSync.apply(this, arguments);
@@ -4438,35 +4601,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4438
4601
  }, {
4439
4602
  key: "addOrderPaymentAsync",
4440
4603
  value: (function () {
4441
- var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(payment) {
4604
+ var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(payment) {
4442
4605
  var paymentRecord, hasPaymentNumber, devicePrefix;
4443
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4444
- while (1) switch (_context39.prev = _context39.next) {
4606
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4607
+ while (1) switch (_context40.prev = _context40.next) {
4445
4608
  case 0:
4446
4609
  paymentRecord = payment;
4447
4610
  hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
4448
4611
  if (!hasPaymentNumber) {
4449
- _context39.next = 6;
4612
+ _context40.next = 6;
4450
4613
  break;
4451
4614
  }
4452
- _context39.t0 = 'LOCAL';
4453
- _context39.next = 9;
4615
+ _context40.t0 = 'LOCAL';
4616
+ _context40.next = 9;
4454
4617
  break;
4455
4618
  case 6:
4456
- _context39.next = 8;
4619
+ _context40.next = 8;
4457
4620
  return this.getPaymentNumberDevicePrefixAsync();
4458
4621
  case 8:
4459
- _context39.t0 = _context39.sent;
4622
+ _context40.t0 = _context40.sent;
4460
4623
  case 9:
4461
- devicePrefix = _context39.t0;
4462
- return _context39.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4624
+ devicePrefix = _context40.t0;
4625
+ return _context40.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
4463
4626
  case 11:
4464
4627
  case "end":
4465
- return _context39.stop();
4628
+ return _context40.stop();
4466
4629
  }
4467
- }, _callee39, this);
4630
+ }, _callee40, this);
4468
4631
  }));
4469
- function addOrderPaymentAsync(_x30) {
4632
+ function addOrderPaymentAsync(_x31) {
4470
4633
  return _addOrderPaymentAsync.apply(this, arguments);
4471
4634
  }
4472
4635
  return addOrderPaymentAsync;
@@ -4474,12 +4637,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4474
4637
  }, {
4475
4638
  key: "addOrderPaymentWithDevicePrefix",
4476
4639
  value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
4477
- var _this$otherParams33,
4640
+ var _this$otherParams37,
4478
4641
  _paymentRecord$paymen,
4479
4642
  _paymentRecord$create,
4480
4643
  _ref48,
4481
4644
  _paymentRecord$origin,
4482
- _this17 = this;
4645
+ _this18 = this;
4483
4646
  if (!this.store.order) throw new Error('order 模块未初始化');
4484
4647
  var paymentRecord = payment;
4485
4648
  var paymentAmount = new Decimal(paymentRecord.amount || 0);
@@ -4490,7 +4653,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4490
4653
  return this.store.order.getOrderPayments();
4491
4654
  }
4492
4655
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
4493
- var shopWalletPassId = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.shop_wallet_pass_id;
4656
+ var shopWalletPassId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.shop_wallet_pass_id;
4494
4657
  if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
4495
4658
  metadata.shop_wallet_pass_id = shopWalletPassId;
4496
4659
  }
@@ -4523,7 +4686,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4523
4686
  submitWhenPaid: true,
4524
4687
  smallTicketDataFlag: 1
4525
4688
  }).catch(function (error) {
4526
- _this17.logError('auto sync payments failed', {
4689
+ _this18.logError('auto sync payments failed', {
4527
4690
  error: error instanceof Error ? error.message : String(error)
4528
4691
  });
4529
4692
  });
@@ -4535,7 +4698,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4535
4698
  }, {
4536
4699
  key: "updateOrderPayment",
4537
4700
  value: (function () {
4538
- var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(paymentIdentity, updates) {
4701
+ var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paymentIdentity, updates) {
4539
4702
  var _result$payment, _result$payment2;
4540
4703
  var options,
4541
4704
  matchMode,
@@ -4552,13 +4715,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4552
4715
  shouldSubmit,
4553
4716
  syncResult,
4554
4717
  _options$smallTicketD2,
4555
- _args40 = arguments;
4556
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
4557
- while (1) switch (_context40.prev = _context40.next) {
4718
+ _args41 = arguments;
4719
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4720
+ while (1) switch (_context41.prev = _context41.next) {
4558
4721
  case 0:
4559
- options = _args40.length > 2 && _args40[2] !== undefined ? _args40[2] : {};
4722
+ options = _args41.length > 2 && _args41[2] !== undefined ? _args41[2] : {};
4560
4723
  if (this.store.order) {
4561
- _context40.next = 3;
4724
+ _context41.next = 3;
4562
4725
  break;
4563
4726
  }
4564
4727
  throw new Error('order 模块未初始化');
@@ -4567,15 +4730,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4567
4730
  previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
4568
4731
  previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
4569
4732
  if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
4570
- _context40.next = 13;
4733
+ _context41.next = 13;
4571
4734
  break;
4572
4735
  }
4573
4736
  currentPayments = this.store.order.getOrderPayments();
4574
4737
  if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
4575
- _context40.next = 12;
4738
+ _context41.next = 12;
4576
4739
  break;
4577
4740
  }
4578
- _context40.next = 11;
4741
+ _context41.next = 11;
4579
4742
  return this.syncPaymentsToOrder({
4580
4743
  payments: currentPayments,
4581
4744
  paymentStatus: this.getPaymentStatusForSync(currentPayments),
@@ -4583,9 +4746,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4583
4746
  smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
4584
4747
  });
4585
4748
  case 11:
4586
- _syncResult = _context40.sent;
4749
+ _syncResult = _context41.sent;
4587
4750
  case 12:
4588
- return _context40.abrupt("return", _objectSpread({
4751
+ return _context41.abrupt("return", _objectSpread({
4589
4752
  updated: false,
4590
4753
  payment: previousPayment,
4591
4754
  payments: currentPayments,
@@ -4594,44 +4757,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4594
4757
  syncResult: _syncResult
4595
4758
  } : {}));
4596
4759
  case 13:
4597
- _context40.next = 15;
4760
+ _context41.next = 15;
4598
4761
  return this.store.order.updateOrderPayment(paymentIdentity, updates, {
4599
4762
  matchBy: matchMode
4600
4763
  });
4601
4764
  case 15:
4602
- result = _context40.sent;
4765
+ result = _context41.sent;
4603
4766
  if (!(options.persistDraft !== false)) {
4604
- _context40.next = 29;
4767
+ _context41.next = 29;
4605
4768
  break;
4606
4769
  }
4607
- _context40.prev = 17;
4608
- _context40.next = 20;
4770
+ _context41.prev = 17;
4771
+ _context41.next = 20;
4609
4772
  return this.saveSalesOrderDraft();
4610
4773
  case 20:
4611
- draftResult = _context40.sent;
4612
- _context40.next = 29;
4774
+ draftResult = _context41.sent;
4775
+ _context41.next = 29;
4613
4776
  break;
4614
4777
  case 23:
4615
- _context40.prev = 23;
4616
- _context40.t0 = _context40["catch"](17);
4617
- draftError = _context40.t0;
4778
+ _context41.prev = 23;
4779
+ _context41.t0 = _context41["catch"](17);
4780
+ draftError = _context41.t0;
4618
4781
  this.logError('updateOrderPayment: 保存支付草稿失败', {
4619
4782
  paymentIdentity: paymentIdentity,
4620
- error: _context40.t0 instanceof Error ? _context40.t0.message : String(_context40.t0)
4783
+ error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
4621
4784
  });
4622
4785
  if (options.submitWhenPaid) {
4623
- _context40.next = 29;
4786
+ _context41.next = 29;
4624
4787
  break;
4625
4788
  }
4626
- throw _context40.t0;
4789
+ throw _context41.t0;
4627
4790
  case 29:
4628
4791
  becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
4629
4792
  shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
4630
4793
  if (!shouldSubmit) {
4631
- _context40.next = 35;
4794
+ _context41.next = 35;
4632
4795
  break;
4633
4796
  }
4634
- _context40.next = 34;
4797
+ _context41.next = 34;
4635
4798
  return this.syncPaymentsToOrder({
4636
4799
  payments: result.payments,
4637
4800
  paymentStatus: this.getPaymentStatusForSync(result.payments),
@@ -4639,9 +4802,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4639
4802
  smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
4640
4803
  });
4641
4804
  case 34:
4642
- syncResult = _context40.sent;
4805
+ syncResult = _context41.sent;
4643
4806
  case 35:
4644
- return _context40.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
4807
+ return _context41.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
4645
4808
  draftResult: draftResult
4646
4809
  } : {}), draftError !== undefined ? {
4647
4810
  draftError: draftError
@@ -4650,11 +4813,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4650
4813
  } : {}));
4651
4814
  case 36:
4652
4815
  case "end":
4653
- return _context40.stop();
4816
+ return _context41.stop();
4654
4817
  }
4655
- }, _callee40, this, [[17, 23]]);
4818
+ }, _callee41, this, [[17, 23]]);
4656
4819
  }));
4657
- function updateOrderPayment(_x31, _x32) {
4820
+ function updateOrderPayment(_x32, _x33) {
4658
4821
  return _updateOrderPayment.apply(this, arguments);
4659
4822
  }
4660
4823
  return updateOrderPayment;
@@ -4676,24 +4839,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4676
4839
  }, {
4677
4840
  key: "updateVoucherOrderPaymentsAsync",
4678
4841
  value: function () {
4679
- var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(payments, options) {
4680
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
4681
- while (1) switch (_context41.prev = _context41.next) {
4842
+ var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(payments, options) {
4843
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4844
+ while (1) switch (_context42.prev = _context42.next) {
4682
4845
  case 0:
4683
4846
  if (this.store.order) {
4684
- _context41.next = 2;
4847
+ _context42.next = 2;
4685
4848
  break;
4686
4849
  }
4687
4850
  throw new Error('order 模块未初始化');
4688
4851
  case 2:
4689
- return _context41.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
4852
+ return _context42.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
4690
4853
  case 3:
4691
4854
  case "end":
4692
- return _context41.stop();
4855
+ return _context42.stop();
4693
4856
  }
4694
- }, _callee41, this);
4857
+ }, _callee42, this);
4695
4858
  }));
4696
- function updateVoucherOrderPaymentsAsync(_x33, _x34) {
4859
+ function updateVoucherOrderPaymentsAsync(_x34, _x35) {
4697
4860
  return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
4698
4861
  }
4699
4862
  return updateVoucherOrderPaymentsAsync;
@@ -4719,8 +4882,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4719
4882
  }, {
4720
4883
  key: "getWalletProductList",
4721
4884
  value: function getWalletProductList() {
4722
- var _this$store$order12, _tempOrder$products;
4723
- var tempOrder = (_this$store$order12 = this.store.order) === null || _this$store$order12 === void 0 ? void 0 : _this$store$order12.getTempOrder();
4885
+ var _this$store$order14, _tempOrder$products;
4886
+ var tempOrder = (_this$store$order14 = this.store.order) === null || _this$store$order14 === void 0 ? void 0 : _this$store$order14.getTempOrder();
4724
4887
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
4725
4888
  // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
4726
4889
  // debugger
@@ -4780,8 +4943,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4780
4943
  }, {
4781
4944
  key: "buildWalletInitBusinessData",
4782
4945
  value: function buildWalletInitBusinessData(params) {
4783
- var _this$store$order13, _params$order_wait_pa, _ref49, _tempOrder$is_price_i;
4784
- var snapshot = (_this$store$order13 = this.store.order) === null || _this$store$order13 === void 0 ? void 0 : _this$store$order13.getOrderSnapshot();
4946
+ var _this$store$order15, _params$order_wait_pa, _ref49, _tempOrder$is_price_i;
4947
+ var snapshot = (_this$store$order15 = this.store.order) === null || _this$store$order15 === void 0 ? void 0 : _this$store$order15.getOrderSnapshot();
4785
4948
  var tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
4786
4949
  var amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
4787
4950
  if (!tempOrder || !amount) return null;
@@ -4804,20 +4967,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4804
4967
  }, {
4805
4968
  key: "initWalletData",
4806
4969
  value: function () {
4807
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
4808
- var _snapshot$identity;
4970
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
4971
+ var _this$store$order$mer, _this$store$order16, _snapshot$identity;
4809
4972
  var snapshot, walletBusinessData, result;
4810
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
4811
- while (1) switch (_context42.prev = _context42.next) {
4973
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4974
+ while (1) switch (_context43.prev = _context43.next) {
4812
4975
  case 0:
4813
4976
  if (this.store.order) {
4814
- _context42.next = 2;
4977
+ _context43.next = 2;
4815
4978
  break;
4816
4979
  }
4817
4980
  throw new Error('order 模块未初始化');
4818
4981
  case 2:
4819
4982
  if (this.store.payment) {
4820
- _context42.next = 4;
4983
+ _context43.next = 4;
4821
4984
  break;
4822
4985
  }
4823
4986
  throw new Error('payment 模块未初始化');
@@ -4825,10 +4988,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4825
4988
  snapshot = this.store.order.getOrderSnapshot();
4826
4989
  walletBusinessData = this.buildWalletInitBusinessData(params);
4827
4990
  if (walletBusinessData) {
4828
- _context42.next = 8;
4991
+ _context43.next = 8;
4829
4992
  break;
4830
4993
  }
4831
- return _context42.abrupt("return", {
4994
+ return _context43.abrupt("return", {
4832
4995
  walletRecommendList: [],
4833
4996
  userIdentificationCodes: [],
4834
4997
  transformList: [],
@@ -4836,11 +4999,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4836
4999
  products: []
4837
5000
  });
4838
5001
  case 8:
4839
- _context42.next = 10;
5002
+ _context43.next = 10;
4840
5003
  return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
4841
5004
  case 10:
4842
- result = _context42.sent;
4843
- _context42.next = 13;
5005
+ result = _context43.sent;
5006
+ (_this$store$order$mer = (_this$store$order16 = this.store.order).mergePointCardSnapshotCodes) === null || _this$store$order$mer === void 0 || _this$store$order$mer.call(_this$store$order16, result.userIdentificationCodes, {
5007
+ customerId: walletBusinessData.customer_id,
5008
+ orderIdentity: snapshot === null || snapshot === void 0 ? void 0 : snapshot.identity
5009
+ });
5010
+ _context43.next = 14;
4844
5011
  return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
4845
5012
  orderId: snapshot === null || snapshot === void 0 || (_snapshot$identity = snapshot.identity) === null || _snapshot$identity === void 0 ? void 0 : _snapshot$identity.orderId,
4846
5013
  customerId: walletBusinessData.customer_id,
@@ -4851,15 +5018,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4851
5018
  },
4852
5019
  timestamp: Date.now()
4853
5020
  });
4854
- case 13:
4855
- return _context42.abrupt("return", result);
4856
5021
  case 14:
5022
+ return _context43.abrupt("return", result);
5023
+ case 15:
4857
5024
  case "end":
4858
- return _context42.stop();
5025
+ return _context43.stop();
4859
5026
  }
4860
- }, _callee42, this);
5027
+ }, _callee43, this);
4861
5028
  }));
4862
- function initWalletData(_x35) {
5029
+ function initWalletData(_x36) {
4863
5030
  return _initWalletData.apply(this, arguments);
4864
5031
  }
4865
5032
  return initWalletData;
@@ -4867,8 +5034,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4867
5034
  }, {
4868
5035
  key: "getCommittedWalletAssets",
4869
5036
  value: function getCommittedWalletAssets() {
4870
- var _this$store$order14, _this$store$order14$g;
4871
- var payments = ((_this$store$order14 = this.store.order) === null || _this$store$order14 === void 0 || (_this$store$order14$g = _this$store$order14.getOrderPayments) === null || _this$store$order14$g === void 0 ? void 0 : _this$store$order14$g.call(_this$store$order14)) || [];
5037
+ var _this$store$order17, _this$store$order17$g;
5038
+ var payments = ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 || (_this$store$order17$g = _this$store$order17.getOrderPayments) === null || _this$store$order17$g === void 0 ? void 0 : _this$store$order17$g.call(_this$store$order17)) || [];
4872
5039
  var committed = payments.filter(function (payment) {
4873
5040
  var voucherId = payment === null || payment === void 0 ? void 0 : payment.voucher_id;
4874
5041
  if (voucherId === undefined || voucherId === null || voucherId === 0) {
@@ -4910,27 +5077,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4910
5077
  }, {
4911
5078
  key: "publishWalletAssetsState",
4912
5079
  value: function () {
4913
- var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(state) {
5080
+ var _publishWalletAssetsState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(state) {
4914
5081
  var changeSource,
4915
- _args43 = arguments;
4916
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
4917
- while (1) switch (_context43.prev = _context43.next) {
5082
+ _args44 = arguments;
5083
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
5084
+ while (1) switch (_context44.prev = _context44.next) {
4918
5085
  case 0:
4919
- changeSource = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : 'derived';
4920
- _context43.next = 3;
5086
+ changeSource = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : 'derived';
5087
+ _context44.next = 3;
4921
5088
  return this.effectsEmit(BaseSalesHookNames.onWalletAssetsStateChanged, {
4922
5089
  state: state,
4923
5090
  changeSource: changeSource
4924
5091
  });
4925
5092
  case 3:
4926
- return _context43.abrupt("return", state);
5093
+ return _context44.abrupt("return", state);
4927
5094
  case 4:
4928
5095
  case "end":
4929
- return _context43.stop();
5096
+ return _context44.stop();
4930
5097
  }
4931
- }, _callee43, this);
5098
+ }, _callee44, this);
4932
5099
  }));
4933
- function publishWalletAssetsState(_x36) {
5100
+ function publishWalletAssetsState(_x37) {
4934
5101
  return _publishWalletAssetsState.apply(this, arguments);
4935
5102
  }
4936
5103
  return publishWalletAssetsState;
@@ -4938,26 +5105,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4938
5105
  }, {
4939
5106
  key: "syncSelectedWalletAssets",
4940
5107
  value: function () {
4941
- var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(state) {
5108
+ var _syncSelectedWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(state) {
4942
5109
  var paymentMethods, methodByCode, preparePayments, selectedAssetById, voucherPayments, payments;
4943
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
4944
- while (1) switch (_context44.prev = _context44.next) {
5110
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5111
+ while (1) switch (_context45.prev = _context45.next) {
4945
5112
  case 0:
4946
5113
  if (!(!this.store.order || !this.store.payment)) {
4947
- _context44.next = 2;
5114
+ _context45.next = 2;
4948
5115
  break;
4949
5116
  }
4950
5117
  throw new Error('订单或支付模块未初始化');
4951
5118
  case 2:
4952
5119
  paymentMethods = this.getPaymentMethods();
4953
5120
  if (!(!paymentMethods.length && state.selectedItems.length)) {
4954
- _context44.next = 7;
5121
+ _context45.next = 7;
4955
5122
  break;
4956
5123
  }
4957
- _context44.next = 6;
5124
+ _context45.next = 6;
4958
5125
  return this.getPaymentMethodsAsync();
4959
5126
  case 6:
4960
- paymentMethods = _context44.sent;
5127
+ paymentMethods = _context45.sent;
4961
5128
  case 7:
4962
5129
  methodByCode = new Map(paymentMethods.map(function (method) {
4963
5130
  return [String(method.code || '').toUpperCase(), method];
@@ -4999,19 +5166,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4999
5166
  payments = this.updateVoucherOrderPayments(voucherPayments, {
5000
5167
  status: 'payment_pending'
5001
5168
  });
5002
- _context44.next = 14;
5169
+ _context45.next = 14;
5003
5170
  return this.store.order.recalculateSummary({
5004
5171
  createIfMissing: true
5005
5172
  });
5006
5173
  case 14:
5007
- return _context44.abrupt("return", payments);
5174
+ return _context45.abrupt("return", payments);
5008
5175
  case 15:
5009
5176
  case "end":
5010
- return _context44.stop();
5177
+ return _context45.stop();
5011
5178
  }
5012
- }, _callee44, this);
5179
+ }, _callee45, this);
5013
5180
  }));
5014
- function syncSelectedWalletAssets(_x37) {
5181
+ function syncSelectedWalletAssets(_x38) {
5015
5182
  return _syncSelectedWalletAssets.apply(this, arguments);
5016
5183
  }
5017
5184
  return syncSelectedWalletAssets;
@@ -5045,29 +5212,31 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5045
5212
  }, {
5046
5213
  key: "importWalletAssetsSnapshot",
5047
5214
  value: (function () {
5048
- var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(snapshot) {
5215
+ var _importWalletAssetsSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(snapshot) {
5216
+ var _this$store$order18, _this$store$order18$m;
5049
5217
  var state;
5050
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5051
- while (1) switch (_context45.prev = _context45.next) {
5218
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5219
+ while (1) switch (_context46.prev = _context46.next) {
5052
5220
  case 0:
5053
5221
  if (this.store.payment) {
5054
- _context45.next = 2;
5222
+ _context46.next = 2;
5055
5223
  break;
5056
5224
  }
5057
5225
  throw new Error('payment 模块未初始化');
5058
5226
  case 2:
5059
5227
  state = this.store.payment.wallet.importWalletAssetsSnapshot(snapshot);
5060
- _context45.next = 5;
5228
+ (_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 || (_this$store$order18$m = _this$store$order18.mergePointCardSnapshotCodes) === null || _this$store$order18$m === void 0 || _this$store$order18$m.call(_this$store$order18, state.items);
5229
+ _context46.next = 6;
5061
5230
  return this.syncSelectedWalletAssets(state);
5062
- case 5:
5063
- return _context45.abrupt("return", this.publishWalletAssetsState(state));
5064
5231
  case 6:
5232
+ return _context46.abrupt("return", this.publishWalletAssetsState(state));
5233
+ case 7:
5065
5234
  case "end":
5066
- return _context45.stop();
5235
+ return _context46.stop();
5067
5236
  }
5068
- }, _callee45, this);
5237
+ }, _callee46, this);
5069
5238
  }));
5070
- function importWalletAssetsSnapshot(_x38) {
5239
+ function importWalletAssetsSnapshot(_x39) {
5071
5240
  return _importWalletAssetsSnapshot.apply(this, arguments);
5072
5241
  }
5073
5242
  return importWalletAssetsSnapshot;
@@ -5079,20 +5248,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5079
5248
  }, {
5080
5249
  key: "refreshWalletAssets",
5081
5250
  value: (function () {
5082
- var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
5083
- var _previousState$custom, _businessData$custome;
5084
- var refreshSequence, wallet, businessData, emptyState, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, committed;
5085
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5086
- while (1) switch (_context46.prev = _context46.next) {
5251
+ var _refreshWalletAssets = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
5252
+ var _this$store$order$get6, _previousState$custom, _businessData$custome;
5253
+ var refreshSequence, wallet, businessData, emptyState, pointCardSnapshotMergeContext, previousState, hasPreviousWalletContext, customerChanged, clearedState, refreshTask, state, _this$store$order$mer2, _this$store$order19, _wallet$getUserIdenti, committed;
5254
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5255
+ while (1) switch (_context47.prev = _context47.next) {
5087
5256
  case 0:
5088
5257
  if (this.store.order) {
5089
- _context46.next = 2;
5258
+ _context47.next = 2;
5090
5259
  break;
5091
5260
  }
5092
5261
  throw new Error('order 模块未初始化');
5093
5262
  case 2:
5094
5263
  if (this.store.payment) {
5095
- _context46.next = 4;
5264
+ _context47.next = 4;
5096
5265
  break;
5097
5266
  }
5098
5267
  throw new Error('payment 模块未初始化');
@@ -5101,7 +5270,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5101
5270
  wallet = this.store.payment.wallet;
5102
5271
  businessData = this.buildWalletInitBusinessData(params);
5103
5272
  if (businessData) {
5104
- _context46.next = 12;
5273
+ _context47.next = 12;
5105
5274
  break;
5106
5275
  }
5107
5276
  wallet.clearAllCache();
@@ -5109,54 +5278,59 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5109
5278
  this.updateVoucherOrderPayments([], {
5110
5279
  status: 'payment_pending'
5111
5280
  });
5112
- return _context46.abrupt("return", this.publishWalletAssetsState(emptyState));
5281
+ return _context47.abrupt("return", this.publishWalletAssetsState(emptyState));
5113
5282
  case 12:
5283
+ pointCardSnapshotMergeContext = {
5284
+ customerId: businessData.customer_id,
5285
+ orderIdentity: (_this$store$order$get6 = this.store.order.getOrderSnapshot()) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.identity
5286
+ };
5114
5287
  previousState = wallet.getWalletAssetsState();
5115
5288
  hasPreviousWalletContext = previousState.status !== 'idle' || previousState.items.length > 0 || previousState.selectedIds.length > 0 || previousState.customerId !== undefined;
5116
5289
  customerChanged = hasPreviousWalletContext && String((_previousState$custom = previousState.customerId) !== null && _previousState$custom !== void 0 ? _previousState$custom : '') !== String((_businessData$custome = businessData.customer_id) !== null && _businessData$custome !== void 0 ? _businessData$custome : '');
5117
5290
  if (!customerChanged) {
5118
- _context46.next = 20;
5291
+ _context47.next = 21;
5119
5292
  break;
5120
5293
  }
5121
5294
  clearedState = wallet.clearWalletAssetSelection();
5122
5295
  this.updateVoucherOrderPayments([], {
5123
5296
  status: 'payment_pending'
5124
5297
  });
5125
- _context46.next = 20;
5298
+ _context47.next = 21;
5126
5299
  return this.publishWalletAssetsState(clearedState);
5127
- case 20:
5300
+ case 21:
5128
5301
  refreshTask = wallet.refreshWalletAssetsFromBusinessAsync(businessData, {
5129
5302
  preserveSelection: (params === null || params === void 0 ? void 0 : params.preserveSelection) !== false && !customerChanged,
5130
5303
  retainSearchResultCodes: params === null || params === void 0 ? void 0 : params.retainSearchResultCodes
5131
5304
  });
5132
- _context46.next = 23;
5305
+ _context47.next = 24;
5133
5306
  return this.publishWalletAssetsState(wallet.getWalletAssetsState());
5134
- case 23:
5135
- _context46.next = 25;
5307
+ case 24:
5308
+ _context47.next = 26;
5136
5309
  return refreshTask;
5137
- case 25:
5138
- state = _context46.sent;
5310
+ case 26:
5311
+ state = _context47.sent;
5139
5312
  if (!(refreshSequence !== this.walletAssetsRefreshSequence)) {
5140
- _context46.next = 28;
5313
+ _context47.next = 29;
5141
5314
  break;
5142
5315
  }
5143
- return _context46.abrupt("return", wallet.getWalletAssetsState());
5144
- case 28:
5316
+ return _context47.abrupt("return", wallet.getWalletAssetsState());
5317
+ case 29:
5145
5318
  if (state.status !== 'error') {
5146
5319
  committed = this.getCommittedWalletAssets();
5147
5320
  state = wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5321
+ (_this$store$order$mer2 = (_this$store$order19 = this.store.order).mergePointCardSnapshotCodes) === null || _this$store$order$mer2 === void 0 || _this$store$order$mer2.call(_this$store$order19, ((_wallet$getUserIdenti = wallet.getUserIdentificationCodes) === null || _wallet$getUserIdenti === void 0 ? void 0 : _wallet$getUserIdenti.call(wallet)) || [], pointCardSnapshotMergeContext);
5148
5322
  }
5149
- _context46.next = 31;
5323
+ _context47.next = 32;
5150
5324
  return this.syncSelectedWalletAssets(state);
5151
- case 31:
5152
- return _context46.abrupt("return", this.publishWalletAssetsState(state));
5153
5325
  case 32:
5326
+ return _context47.abrupt("return", this.publishWalletAssetsState(state));
5327
+ case 33:
5154
5328
  case "end":
5155
- return _context46.stop();
5329
+ return _context47.stop();
5156
5330
  }
5157
- }, _callee46, this);
5331
+ }, _callee47, this);
5158
5332
  }));
5159
- function refreshWalletAssets(_x39) {
5333
+ function refreshWalletAssets(_x40) {
5160
5334
  return _refreshWalletAssets.apply(this, arguments);
5161
5335
  }
5162
5336
  return refreshWalletAssets;
@@ -5164,13 +5338,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5164
5338
  }, {
5165
5339
  key: "selectWalletAsset",
5166
5340
  value: (function () {
5167
- var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
5341
+ var _selectWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
5168
5342
  var state;
5169
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5170
- while (1) switch (_context47.prev = _context47.next) {
5343
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5344
+ while (1) switch (_context48.prev = _context48.next) {
5171
5345
  case 0:
5172
5346
  if (this.store.payment) {
5173
- _context47.next = 2;
5347
+ _context48.next = 2;
5174
5348
  break;
5175
5349
  }
5176
5350
  throw new Error('payment 模块未初始化');
@@ -5179,17 +5353,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5179
5353
  selected: params.selected,
5180
5354
  source: params.source
5181
5355
  });
5182
- _context47.next = 5;
5356
+ _context48.next = 5;
5183
5357
  return this.syncSelectedWalletAssets(state);
5184
5358
  case 5:
5185
- return _context47.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5359
+ return _context48.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5186
5360
  case 6:
5187
5361
  case "end":
5188
- return _context47.stop();
5362
+ return _context48.stop();
5189
5363
  }
5190
- }, _callee47, this);
5364
+ }, _callee48, this);
5191
5365
  }));
5192
- function selectWalletAsset(_x40) {
5366
+ function selectWalletAsset(_x41) {
5193
5367
  return _selectWalletAsset.apply(this, arguments);
5194
5368
  }
5195
5369
  return selectWalletAsset;
@@ -5197,29 +5371,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5197
5371
  }, {
5198
5372
  key: "updateWalletAssetAmount",
5199
5373
  value: (function () {
5200
- var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
5374
+ var _updateWalletAssetAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
5201
5375
  var state;
5202
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5203
- while (1) switch (_context48.prev = _context48.next) {
5376
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5377
+ while (1) switch (_context49.prev = _context49.next) {
5204
5378
  case 0:
5205
5379
  if (this.store.payment) {
5206
- _context48.next = 2;
5380
+ _context49.next = 2;
5207
5381
  break;
5208
5382
  }
5209
5383
  throw new Error('payment 模块未初始化');
5210
5384
  case 2:
5211
5385
  state = this.store.payment.wallet.updateWalletAssetAmount(params.assetId, params.amount);
5212
- _context48.next = 5;
5386
+ _context49.next = 5;
5213
5387
  return this.syncSelectedWalletAssets(state);
5214
5388
  case 5:
5215
- return _context48.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5389
+ return _context49.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5216
5390
  case 6:
5217
5391
  case "end":
5218
- return _context48.stop();
5392
+ return _context49.stop();
5219
5393
  }
5220
- }, _callee48, this);
5394
+ }, _callee49, this);
5221
5395
  }));
5222
- function updateWalletAssetAmount(_x41) {
5396
+ function updateWalletAssetAmount(_x42) {
5223
5397
  return _updateWalletAssetAmount.apply(this, arguments);
5224
5398
  }
5225
5399
  return updateWalletAssetAmount;
@@ -5227,13 +5401,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5227
5401
  }, {
5228
5402
  key: "scanWalletAsset",
5229
5403
  value: (function () {
5230
- var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(code) {
5404
+ var _scanWalletAsset = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(code) {
5231
5405
  var wallet, businessData, result;
5232
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5233
- while (1) switch (_context49.prev = _context49.next) {
5406
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5407
+ while (1) switch (_context50.prev = _context50.next) {
5234
5408
  case 0:
5235
5409
  if (this.store.payment) {
5236
- _context49.next = 2;
5410
+ _context50.next = 2;
5237
5411
  break;
5238
5412
  }
5239
5413
  throw new Error('payment 模块未初始化');
@@ -5243,28 +5417,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5243
5417
  if (businessData) {
5244
5418
  wallet.generateWalletParams(businessData);
5245
5419
  }
5246
- _context49.next = 7;
5420
+ _context50.next = 7;
5247
5421
  return wallet.scanWalletAssetAsync(code);
5248
5422
  case 7:
5249
- result = _context49.sent;
5423
+ result = _context50.sent;
5250
5424
  if (!(result.type === 'normalCode')) {
5251
- _context49.next = 13;
5425
+ _context50.next = 13;
5252
5426
  break;
5253
5427
  }
5254
- _context49.next = 11;
5428
+ _context50.next = 11;
5255
5429
  return this.syncSelectedWalletAssets(result.state);
5256
5430
  case 11:
5257
- _context49.next = 13;
5431
+ _context50.next = 13;
5258
5432
  return this.publishWalletAssetsState(result.state, 'local');
5259
5433
  case 13:
5260
- return _context49.abrupt("return", result);
5434
+ return _context50.abrupt("return", result);
5261
5435
  case 14:
5262
5436
  case "end":
5263
- return _context49.stop();
5437
+ return _context50.stop();
5264
5438
  }
5265
- }, _callee49, this);
5439
+ }, _callee50, this);
5266
5440
  }));
5267
- function scanWalletAsset(_x42) {
5441
+ function scanWalletAsset(_x43) {
5268
5442
  return _scanWalletAsset.apply(this, arguments);
5269
5443
  }
5270
5444
  return scanWalletAsset;
@@ -5272,27 +5446,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5272
5446
  }, {
5273
5447
  key: "clearWalletAssetSelection",
5274
5448
  value: (function () {
5275
- var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
5449
+ var _clearWalletAssetSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
5276
5450
  var state;
5277
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5278
- while (1) switch (_context50.prev = _context50.next) {
5451
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5452
+ while (1) switch (_context51.prev = _context51.next) {
5279
5453
  case 0:
5280
5454
  if (this.store.payment) {
5281
- _context50.next = 2;
5455
+ _context51.next = 2;
5282
5456
  break;
5283
5457
  }
5284
5458
  throw new Error('payment 模块未初始化');
5285
5459
  case 2:
5286
5460
  state = this.store.payment.wallet.clearWalletAssetSelection();
5287
- _context50.next = 5;
5461
+ _context51.next = 5;
5288
5462
  return this.syncSelectedWalletAssets(state);
5289
5463
  case 5:
5290
- return _context50.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5464
+ return _context51.abrupt("return", this.publishWalletAssetsState(state, 'local'));
5291
5465
  case 6:
5292
5466
  case "end":
5293
- return _context50.stop();
5467
+ return _context51.stop();
5294
5468
  }
5295
- }, _callee50, this);
5469
+ }, _callee51, this);
5296
5470
  }));
5297
5471
  function clearWalletAssetSelection() {
5298
5472
  return _clearWalletAssetSelection.apply(this, arguments);
@@ -5309,11 +5483,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5309
5483
  }, {
5310
5484
  key: "updateOrderCustomer",
5311
5485
  value: function updateOrderCustomer(customer) {
5312
- var _this$store$order$get6, _this$store$order15, _this$store$order$get7, _this$store$order16;
5486
+ var _this$store$order$get7, _this$store$order20, _this$store$order$get8, _this$store$order21;
5313
5487
  if (!this.store.order) throw new Error('order 模块未初始化');
5314
- var previousCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get6 = (_this$store$order15 = this.store.order).getTempOrder) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order15));
5488
+ var previousCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get7 = (_this$store$order20 = this.store.order).getTempOrder) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order20));
5315
5489
  var result = this.store.order.updateTempOrderCustomer(customer);
5316
- var nextCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get7 = (_this$store$order16 = this.store.order).getTempOrder) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.call(_this$store$order16));
5490
+ var nextCustomerId = this.resolveDiscountConfigCustomerId((_this$store$order$get8 = (_this$store$order21 = this.store.order).getTempOrder) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order21));
5317
5491
  if (String(previousCustomerId) !== String(nextCustomerId)) {
5318
5492
  this.discountConfigCacheKey = null;
5319
5493
  this.hasManualDiscountSelection = false;
@@ -5329,35 +5503,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5329
5503
  }, {
5330
5504
  key: "getPaymentMethodsAsync",
5331
5505
  value: (function () {
5332
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51() {
5506
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
5333
5507
  var response, paymentMethods;
5334
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5335
- while (1) switch (_context51.prev = _context51.next) {
5508
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5509
+ while (1) switch (_context52.prev = _context52.next) {
5336
5510
  case 0:
5337
- _context51.prev = 0;
5338
- _context51.next = 3;
5511
+ _context52.prev = 0;
5512
+ _context52.next = 3;
5339
5513
  return this.request.get('/pay/custom-payment/all', {
5340
5514
  filterPaymentMethods: true
5341
5515
  }, {
5342
5516
  osServer: true
5343
5517
  });
5344
5518
  case 3:
5345
- response = _context51.sent;
5519
+ response = _context52.sent;
5346
5520
  paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
5347
5521
  this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
5348
- return _context51.abrupt("return", this.getPaymentMethods());
5522
+ return _context52.abrupt("return", this.getPaymentMethods());
5349
5523
  case 9:
5350
- _context51.prev = 9;
5351
- _context51.t0 = _context51["catch"](0);
5524
+ _context52.prev = 9;
5525
+ _context52.t0 = _context52["catch"](0);
5352
5526
  this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
5353
- error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0)
5527
+ error: _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0)
5354
5528
  });
5355
- return _context51.abrupt("return", this.getPaymentMethods());
5529
+ return _context52.abrupt("return", this.getPaymentMethods());
5356
5530
  case 13:
5357
5531
  case "end":
5358
- return _context51.stop();
5532
+ return _context52.stop();
5359
5533
  }
5360
- }, _callee51, this, [[0, 9]]);
5534
+ }, _callee52, this, [[0, 9]]);
5361
5535
  }));
5362
5536
  function getPaymentMethodsAsync() {
5363
5537
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -5382,8 +5556,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5382
5556
  }, {
5383
5557
  key: "getPendingWalletPaymentAmount",
5384
5558
  value: function getPendingWalletPaymentAmount() {
5385
- var _this$store$order17, _this$store$order17$g;
5386
- var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order17 = this.store.order) === null || _this$store$order17 === void 0 || (_this$store$order17$g = _this$store$order17.getOrderPayments) === null || _this$store$order17$g === void 0 ? void 0 : _this$store$order17$g.call(_this$store$order17)) || [];
5559
+ var _this$store$order22, _this$store$order22$g;
5560
+ var payments = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ((_this$store$order22 = this.store.order) === null || _this$store$order22 === void 0 || (_this$store$order22$g = _this$store$order22.getOrderPayments) === null || _this$store$order22$g === void 0 ? void 0 : _this$store$order22$g.call(_this$store$order22)) || [];
5387
5561
  return payments.reduce(function (total, payment) {
5388
5562
  if ((payment === null || payment === void 0 ? void 0 : payment.status) !== 'payment_pending' || (payment === null || payment === void 0 ? void 0 : payment.voucher_id) === undefined || Number(payment.voucher_id) === 0) {
5389
5563
  return total;
@@ -5400,14 +5574,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5400
5574
  }, {
5401
5575
  key: "getCashPaymentConfig",
5402
5576
  value: (function () {
5403
- var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
5404
- var _this$store$order18, _this$store$order18$g, _this$store$order19, _this$store$order19$g, _this$otherParams34;
5577
+ var _getCashPaymentConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5578
+ var _this$store$order23, _this$store$order23$g, _this$store$order24, _this$store$order24$g, _this$otherParams38;
5405
5579
  var paymentMethods, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, currency, recommendedAmounts;
5406
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5407
- while (1) switch (_context52.prev = _context52.next) {
5580
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5581
+ while (1) switch (_context53.prev = _context53.next) {
5408
5582
  case 0:
5409
5583
  if (this.store.payment) {
5410
- _context52.next = 2;
5584
+ _context53.next = 2;
5411
5585
  break;
5412
5586
  }
5413
5587
  throw new Error('payment 模块未初始化');
@@ -5415,21 +5589,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5415
5589
  paymentMethods = this.getPaymentMethods();
5416
5590
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
5417
5591
  if (paymentMethod) {
5418
- _context52.next = 9;
5592
+ _context53.next = 9;
5419
5593
  break;
5420
5594
  }
5421
- _context52.next = 7;
5595
+ _context53.next = 7;
5422
5596
  return this.getPaymentMethodsAsync();
5423
5597
  case 7:
5424
- paymentMethods = _context52.sent;
5598
+ paymentMethods = _context53.sent;
5425
5599
  paymentMethod = this.findCashPaymentMethod(paymentMethods);
5426
5600
  case 9:
5427
- amountSnapshot = (_this$store$order18 = this.store.order) === null || _this$store$order18 === void 0 || (_this$store$order18$g = _this$store$order18.getOrderAmountSnapshot) === null || _this$store$order18$g === void 0 ? void 0 : _this$store$order18$g.call(_this$store$order18);
5601
+ amountSnapshot = (_this$store$order23 = this.store.order) === null || _this$store$order23 === void 0 || (_this$store$order23$g = _this$store$order23.getOrderAmountSnapshot) === null || _this$store$order23$g === void 0 ? void 0 : _this$store$order23$g.call(_this$store$order23);
5428
5602
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5429
5603
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0).toDecimalPlaces(2).toNumber();
5430
- currency = ((_this$store$order19 = this.store.order) === null || _this$store$order19 === void 0 || (_this$store$order19$g = _this$store$order19.getTempOrder) === null || _this$store$order19$g === void 0 || (_this$store$order19$g = _this$store$order19$g.call(_this$store$order19)) === null || _this$store$order19$g === void 0 ? void 0 : _this$store$order19$g.currency_code) || ((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.currency) || 'USD';
5604
+ currency = ((_this$store$order24 = this.store.order) === null || _this$store$order24 === void 0 || (_this$store$order24$g = _this$store$order24.getTempOrder) === null || _this$store$order24$g === void 0 || (_this$store$order24$g = _this$store$order24$g.call(_this$store$order24)) === null || _this$store$order24$g === void 0 ? void 0 : _this$store$order24$g.currency_code) || ((_this$otherParams38 = this.otherParams) === null || _this$otherParams38 === void 0 ? void 0 : _this$otherParams38.currency) || 'USD';
5431
5605
  recommendedAmounts = amountDue > 0 ? this.store.payment.cash.getRecommendedAmount(amountDue, currency) : [];
5432
- return _context52.abrupt("return", {
5606
+ return _context53.abrupt("return", {
5433
5607
  available: Boolean(paymentMethod && amountDue > 0),
5434
5608
  paymentMethod: paymentMethod,
5435
5609
  amountDue: amountDue,
@@ -5437,9 +5611,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5437
5611
  });
5438
5612
  case 15:
5439
5613
  case "end":
5440
- return _context52.stop();
5614
+ return _context53.stop();
5441
5615
  }
5442
- }, _callee52, this);
5616
+ }, _callee53, this);
5443
5617
  }));
5444
5618
  function getCashPaymentConfig() {
5445
5619
  return _getCashPaymentConfig.apply(this, arguments);
@@ -5456,42 +5630,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5456
5630
  }, {
5457
5631
  key: "confirmWalletPayment",
5458
5632
  value: (function () {
5459
- var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
5460
- var _this$store$order$get8, _this$store$order20, _this$store$order$get10, _this$store$order$get11, _this$store$order22;
5461
- var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get9, _this$store$order21, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5462
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5463
- while (1) switch (_context53.prev = _context53.next) {
5633
+ var _confirmWalletPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
5634
+ var _this$store$order$get9, _this$store$order25, _this$store$order$get11, _this$store$order$get12, _this$store$order27;
5635
+ var beforePayments, pendingWalletAmount, amountSnapshot, _this$store$order$get10, _this$store$order26, _submitResult, _latestAmountSnapshot, effectiveAmountDue, beforePaymentStatus, submitResult, restoredTempOrder, committed, walletState, latestAmountSnapshot;
5636
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5637
+ while (1) switch (_context54.prev = _context54.next) {
5464
5638
  case 0:
5465
5639
  if (this.store.order) {
5466
- _context53.next = 2;
5640
+ _context54.next = 2;
5467
5641
  break;
5468
5642
  }
5469
5643
  throw new Error('order 模块未初始化');
5470
5644
  case 2:
5471
5645
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5472
5646
  pendingWalletAmount = this.getPendingWalletPaymentAmount(beforePayments);
5473
- amountSnapshot = (_this$store$order$get8 = (_this$store$order20 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get8 === void 0 ? void 0 : _this$store$order$get8.call(_this$store$order20);
5647
+ amountSnapshot = (_this$store$order$get9 = (_this$store$order25 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.call(_this$store$order25);
5474
5648
  if (!pendingWalletAmount.lte(0)) {
5475
- _context53.next = 14;
5649
+ _context54.next = 14;
5476
5650
  break;
5477
5651
  }
5478
5652
  this.logWarning('confirmWalletPayment: 未发现待确认 Wallet 支付,跳过 Wallet 确认并按普通订单提交', {
5479
5653
  amountGap: amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap
5480
5654
  });
5481
- _context53.next = 9;
5655
+ _context54.next = 9;
5482
5656
  return this.submitSalesOrder({
5483
5657
  smallTicketDataFlag: 1
5484
5658
  });
5485
5659
  case 9:
5486
- _submitResult = _context53.sent;
5660
+ _submitResult = _context54.sent;
5487
5661
  if (!isRejectedSalesSubmitResult(_submitResult)) {
5488
- _context53.next = 12;
5662
+ _context54.next = 12;
5489
5663
  break;
5490
5664
  }
5491
5665
  throw new Error(getSalesSubmitErrorMessage(_submitResult, '订单提交失败'));
5492
5666
  case 12:
5493
- _latestAmountSnapshot = (_this$store$order$get9 = (_this$store$order21 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get9 === void 0 ? void 0 : _this$store$order$get9.call(_this$store$order21);
5494
- return _context53.abrupt("return", {
5667
+ _latestAmountSnapshot = (_this$store$order$get10 = (_this$store$order26 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get10 === void 0 ? void 0 : _this$store$order$get10.call(_this$store$order26);
5668
+ return _context54.abrupt("return", {
5495
5669
  submitResult: _submitResult,
5496
5670
  payments: this.store.order.getOrderPayments(),
5497
5671
  isOrderFullyPaid: new Decimal((_latestAmountSnapshot === null || _latestAmountSnapshot === void 0 ? void 0 : _latestAmountSnapshot.amountGap) || 0).lte(0)
@@ -5499,74 +5673,74 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5499
5673
  case 14:
5500
5674
  effectiveAmountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5501
5675
  if (!effectiveAmountDue.gt(0.01)) {
5502
- _context53.next = 17;
5676
+ _context54.next = 17;
5503
5677
  break;
5504
5678
  }
5505
5679
  throw new Error('Wallet 支付尚未覆盖全部待支付金额');
5506
5680
  case 17:
5507
- beforePaymentStatus = (_this$store$order$get10 = this.store.order.getTempOrder()) === null || _this$store$order$get10 === void 0 ? void 0 : _this$store$order$get10.payment_status;
5508
- _context53.prev = 18;
5509
- _context53.next = 21;
5681
+ beforePaymentStatus = (_this$store$order$get11 = this.store.order.getTempOrder()) === null || _this$store$order$get11 === void 0 ? void 0 : _this$store$order$get11.payment_status;
5682
+ _context54.prev = 18;
5683
+ _context54.next = 21;
5510
5684
  return this.submitSalesOrder({
5511
5685
  smallTicketDataFlag: 1,
5512
5686
  confirmPendingVoucherPayments: true
5513
5687
  });
5514
5688
  case 21:
5515
- submitResult = _context53.sent;
5689
+ submitResult = _context54.sent;
5516
5690
  if (!isRejectedSalesSubmitResult(submitResult)) {
5517
- _context53.next = 24;
5691
+ _context54.next = 24;
5518
5692
  break;
5519
5693
  }
5520
5694
  throw new Error(getSalesSubmitErrorMessage(submitResult, 'Wallet 支付确认失败'));
5521
5695
  case 24:
5522
- _context53.next = 34;
5696
+ _context54.next = 34;
5523
5697
  break;
5524
5698
  case 26:
5525
- _context53.prev = 26;
5526
- _context53.t0 = _context53["catch"](18);
5699
+ _context54.prev = 26;
5700
+ _context54.t0 = _context54["catch"](18);
5527
5701
  this.store.order.setOrderPayments(beforePayments);
5528
5702
  restoredTempOrder = this.store.order.getTempOrder();
5529
5703
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5530
5704
  restoredTempOrder.payment_status = beforePaymentStatus;
5531
5705
  this.store.order.persistTempOrder();
5532
5706
  }
5533
- _context53.next = 33;
5707
+ _context54.next = 33;
5534
5708
  return this.store.order.recalculateSummary({
5535
5709
  createIfMissing: true
5536
5710
  });
5537
5711
  case 33:
5538
- throw _context53.t0;
5712
+ throw _context54.t0;
5539
5713
  case 34:
5540
5714
  if (!this.store.payment) {
5541
- _context53.next = 45;
5715
+ _context54.next = 45;
5542
5716
  break;
5543
5717
  }
5544
- _context53.prev = 35;
5718
+ _context54.prev = 35;
5545
5719
  committed = this.getCommittedWalletAssets();
5546
5720
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5547
- _context53.next = 40;
5721
+ _context54.next = 40;
5548
5722
  return this.publishWalletAssetsState(walletState, 'local');
5549
5723
  case 40:
5550
- _context53.next = 45;
5724
+ _context54.next = 45;
5551
5725
  break;
5552
5726
  case 42:
5553
- _context53.prev = 42;
5554
- _context53.t1 = _context53["catch"](35);
5727
+ _context54.prev = 42;
5728
+ _context54.t1 = _context54["catch"](35);
5555
5729
  this.logWarning('confirmWalletPayment: Wallet committed 状态同步失败', {
5556
- error: _context53.t1 instanceof Error ? _context53.t1.message : String(_context53.t1)
5730
+ error: _context54.t1 instanceof Error ? _context54.t1.message : String(_context54.t1)
5557
5731
  });
5558
5732
  case 45:
5559
- latestAmountSnapshot = (_this$store$order$get11 = (_this$store$order22 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get11 === void 0 ? void 0 : _this$store$order$get11.call(_this$store$order22);
5560
- return _context53.abrupt("return", {
5733
+ latestAmountSnapshot = (_this$store$order$get12 = (_this$store$order27 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get12 === void 0 ? void 0 : _this$store$order$get12.call(_this$store$order27);
5734
+ return _context54.abrupt("return", {
5561
5735
  submitResult: submitResult,
5562
5736
  payments: this.store.order.getOrderPayments(),
5563
5737
  isOrderFullyPaid: new Decimal((latestAmountSnapshot === null || latestAmountSnapshot === void 0 ? void 0 : latestAmountSnapshot.amountGap) || 0).lte(0)
5564
5738
  });
5565
5739
  case 47:
5566
5740
  case "end":
5567
- return _context53.stop();
5741
+ return _context54.stop();
5568
5742
  }
5569
- }, _callee53, this, [[18, 26], [35, 42]]);
5743
+ }, _callee54, this, [[18, 26], [35, 42]]);
5570
5744
  }));
5571
5745
  function confirmWalletPayment() {
5572
5746
  return _confirmWalletPayment.apply(this, arguments);
@@ -5581,38 +5755,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5581
5755
  }, {
5582
5756
  key: "payCash",
5583
5757
  value: (function () {
5584
- var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
5585
- var _this$store$order$get12, _params$actualPaidAmo, _this$otherParams35, _this$window, _this$window$postMess;
5758
+ var _payCash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5759
+ var _this$store$order$get13, _params$actualPaidAmo, _this$otherParams39, _this$window, _this$window$postMess;
5586
5760
  var amount, config, paymentMethod, roundingAmount, effectivePaymentAmount, beforePayments, beforePaymentStatus, uniquePaymentNumber, paymentTimestamp, actualPaidAmount, changeAmount, shopWalletPassId, payments, payment, syncResult, committed, walletState, restoredTempOrder;
5587
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5588
- while (1) switch (_context54.prev = _context54.next) {
5761
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5762
+ while (1) switch (_context55.prev = _context55.next) {
5589
5763
  case 0:
5590
5764
  if (this.store.order) {
5591
- _context54.next = 2;
5765
+ _context55.next = 2;
5592
5766
  break;
5593
5767
  }
5594
5768
  throw new Error('order 模块未初始化');
5595
5769
  case 2:
5596
5770
  amount = Number(params.amount || 0);
5597
5771
  if (!(!Number.isFinite(amount) || amount <= 0)) {
5598
- _context54.next = 5;
5772
+ _context55.next = 5;
5599
5773
  break;
5600
5774
  }
5601
5775
  throw new Error('现金支付金额必须大于 0');
5602
5776
  case 5:
5603
- _context54.next = 7;
5777
+ _context55.next = 7;
5604
5778
  return this.getCashPaymentConfig();
5605
5779
  case 7:
5606
- config = _context54.sent;
5780
+ config = _context55.sent;
5607
5781
  paymentMethod = config.paymentMethod;
5608
5782
  if (paymentMethod) {
5609
- _context54.next = 11;
5783
+ _context55.next = 11;
5610
5784
  break;
5611
5785
  }
5612
5786
  throw new Error('未找到可用的 CASHMANUAL 支付方式');
5613
5787
  case 11:
5614
5788
  if (!(config.amountDue <= 0)) {
5615
- _context54.next = 13;
5789
+ _context55.next = 13;
5616
5790
  break;
5617
5791
  }
5618
5792
  throw new Error('当前订单没有待支付金额');
@@ -5620,24 +5794,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5620
5794
  roundingAmount = Number(params.roundingAmount || 0);
5621
5795
  effectivePaymentAmount = new Decimal(amount).minus(roundingAmount);
5622
5796
  if (!effectivePaymentAmount.gt(new Decimal(config.amountDue).plus(0.01))) {
5623
- _context54.next = 17;
5797
+ _context55.next = 17;
5624
5798
  break;
5625
5799
  }
5626
5800
  throw new Error('现金支付金额超过当前待支付金额');
5627
5801
  case 17:
5628
5802
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5629
- beforePaymentStatus = (_this$store$order$get12 = this.store.order.getTempOrder()) === null || _this$store$order$get12 === void 0 ? void 0 : _this$store$order$get12.payment_status;
5803
+ beforePaymentStatus = (_this$store$order$get13 = this.store.order.getTempOrder()) === null || _this$store$order$get13 === void 0 ? void 0 : _this$store$order$get13.payment_status;
5630
5804
  uniquePaymentNumber = createUuidV4();
5631
5805
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5632
5806
  actualPaidAmount = Number((_params$actualPaidAmo = params.actualPaidAmount) !== null && _params$actualPaidAmo !== void 0 ? _params$actualPaidAmo : amount);
5633
5807
  changeAmount = Number(params.changeAmount || 0);
5634
- shopWalletPassId = (_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.shop_wallet_pass_id;
5808
+ shopWalletPassId = (_this$otherParams39 = this.otherParams) === null || _this$otherParams39 === void 0 ? void 0 : _this$otherParams39.shop_wallet_pass_id;
5635
5809
  if (!(!Number.isFinite(actualPaidAmount) || actualPaidAmount + 0.01 < amount)) {
5636
- _context54.next = 26;
5810
+ _context55.next = 26;
5637
5811
  break;
5638
5812
  }
5639
5813
  throw new Error('顾客实收现金不能小于支付金额');
5640
5814
  case 26:
5815
+ if (!this.isPickupTimingEnabled()) {
5816
+ _context55.next = 29;
5817
+ break;
5818
+ }
5819
+ _context55.next = 29;
5820
+ return this.preparePickupTimingForCheckout({
5821
+ freeze: true
5822
+ });
5823
+ case 29:
5641
5824
  (_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.interaction) === null || _this$window === void 0 || (_this$window = _this$window.utils) === null || _this$window === void 0 || (_this$window$postMess = _this$window.postMessageToApp) === null || _this$window$postMess === void 0 || _this$window$postMess.call(_this$window, {
5642
5825
  module: 'till',
5643
5826
  key: 'open_till',
@@ -5668,59 +5851,59 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5668
5851
  var _item$metadata2;
5669
5852
  return (item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_payment_number) === uniquePaymentNumber;
5670
5853
  });
5671
- _context54.prev = 29;
5672
- _context54.next = 32;
5854
+ _context55.prev = 32;
5855
+ _context55.next = 35;
5673
5856
  return this.syncPaymentsToOrder({
5674
5857
  payments: payments,
5675
5858
  submitWhenPaid: true,
5676
5859
  smallTicketDataFlag: 1,
5677
5860
  confirmPendingVoucherPayments: true
5678
5861
  });
5679
- case 32:
5680
- syncResult = _context54.sent;
5862
+ case 35:
5863
+ syncResult = _context55.sent;
5681
5864
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
5682
- _context54.next = 35;
5865
+ _context55.next = 38;
5683
5866
  break;
5684
5867
  }
5685
5868
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
5686
- case 35:
5869
+ case 38:
5687
5870
  if (!this.store.payment) {
5688
- _context54.next = 40;
5871
+ _context55.next = 43;
5689
5872
  break;
5690
5873
  }
5691
5874
  committed = this.getCommittedWalletAssets();
5692
5875
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5693
- _context54.next = 40;
5876
+ _context55.next = 43;
5694
5877
  return this.publishWalletAssetsState(walletState, 'local');
5695
- case 40:
5696
- return _context54.abrupt("return", {
5878
+ case 43:
5879
+ return _context55.abrupt("return", {
5697
5880
  payment: payment || {},
5698
5881
  payments: this.store.order.getOrderPayments(),
5699
5882
  syncResult: syncResult,
5700
5883
  isOrderFullyPaid: syncResult.isOrderFullyPaid
5701
5884
  });
5702
- case 43:
5703
- _context54.prev = 43;
5704
- _context54.t0 = _context54["catch"](29);
5885
+ case 46:
5886
+ _context55.prev = 46;
5887
+ _context55.t0 = _context55["catch"](32);
5705
5888
  this.store.order.setOrderPayments(beforePayments);
5706
5889
  restoredTempOrder = this.store.order.getTempOrder();
5707
5890
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5708
5891
  restoredTempOrder.payment_status = beforePaymentStatus;
5709
5892
  this.store.order.persistTempOrder();
5710
5893
  }
5711
- _context54.next = 50;
5894
+ _context55.next = 53;
5712
5895
  return this.store.order.recalculateSummary({
5713
5896
  createIfMissing: true
5714
5897
  });
5715
- case 50:
5716
- throw _context54.t0;
5717
- case 51:
5898
+ case 53:
5899
+ throw _context55.t0;
5900
+ case 54:
5718
5901
  case "end":
5719
- return _context54.stop();
5902
+ return _context55.stop();
5720
5903
  }
5721
- }, _callee54, this, [[29, 43]]);
5904
+ }, _callee55, this, [[32, 46]]);
5722
5905
  }));
5723
- function payCash(_x43) {
5906
+ function payCash(_x44) {
5724
5907
  return _payCash.apply(this, arguments);
5725
5908
  }
5726
5909
  return payCash;
@@ -5736,21 +5919,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5736
5919
  }, {
5737
5920
  key: "commitPaymentMethodPayment",
5738
5921
  value: (function () {
5739
- var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
5740
- var _this$store$order$get13, _this$store$order23, _this$store$order$get14, _params$metadata, _params$originAmount;
5922
+ var _commitPaymentMethodPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
5923
+ var _this$store$order$get14, _this$store$order28, _this$store$order$get15, _params$metadata, _params$originAmount;
5741
5924
  var amount, paymentMethods, findPaymentMethod, paymentMethod, amountSnapshot, pendingWalletAmount, amountDue, beforePayments, beforePaymentStatus, paymentTimestamp, metadata, serviceCharge, serviceFee, payments, payment, syncResult, committed, walletState, restoredTempOrder;
5742
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5743
- while (1) switch (_context55.prev = _context55.next) {
5925
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5926
+ while (1) switch (_context56.prev = _context56.next) {
5744
5927
  case 0:
5745
5928
  if (this.store.order) {
5746
- _context55.next = 2;
5929
+ _context56.next = 2;
5747
5930
  break;
5748
5931
  }
5749
5932
  throw new Error('order 模块未初始化');
5750
5933
  case 2:
5751
5934
  amount = Number(params.amount || 0);
5752
5935
  if (!(!Number.isFinite(amount) || amount <= 0)) {
5753
- _context55.next = 5;
5936
+ _context56.next = 5;
5754
5937
  break;
5755
5938
  }
5756
5939
  throw new Error('支付金额必须大于 0');
@@ -5766,38 +5949,38 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5766
5949
  };
5767
5950
  paymentMethod = findPaymentMethod();
5768
5951
  if (paymentMethod) {
5769
- _context55.next = 13;
5952
+ _context56.next = 13;
5770
5953
  break;
5771
5954
  }
5772
- _context55.next = 11;
5955
+ _context56.next = 11;
5773
5956
  return this.getPaymentMethodsAsync();
5774
5957
  case 11:
5775
- paymentMethods = _context55.sent;
5958
+ paymentMethods = _context56.sent;
5776
5959
  paymentMethod = findPaymentMethod();
5777
5960
  case 13:
5778
5961
  if (paymentMethod) {
5779
- _context55.next = 15;
5962
+ _context56.next = 15;
5780
5963
  break;
5781
5964
  }
5782
5965
  throw new Error("\u672A\u627E\u5230\u53EF\u7528\u7684\u652F\u4ED8\u65B9\u5F0F\uFF1A".concat(params.paymentMethodCode || params.paymentMethodId || ''));
5783
5966
  case 15:
5784
- amountSnapshot = (_this$store$order$get13 = (_this$store$order23 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get13 === void 0 ? void 0 : _this$store$order$get13.call(_this$store$order23);
5967
+ amountSnapshot = (_this$store$order$get14 = (_this$store$order28 = this.store.order).getOrderAmountSnapshot) === null || _this$store$order$get14 === void 0 ? void 0 : _this$store$order$get14.call(_this$store$order28);
5785
5968
  pendingWalletAmount = this.getPendingWalletPaymentAmount();
5786
5969
  amountDue = Decimal.max(new Decimal((amountSnapshot === null || amountSnapshot === void 0 ? void 0 : amountSnapshot.amountGap) || 0).minus(pendingWalletAmount), 0);
5787
5970
  if (!amountDue.lte(0)) {
5788
- _context55.next = 20;
5971
+ _context56.next = 20;
5789
5972
  break;
5790
5973
  }
5791
5974
  throw new Error('当前订单没有待支付金额');
5792
5975
  case 20:
5793
5976
  if (!new Decimal(amount).gt(amountDue.plus(0.01))) {
5794
- _context55.next = 22;
5977
+ _context56.next = 22;
5795
5978
  break;
5796
5979
  }
5797
5980
  throw new Error('支付金额超过当前待支付金额');
5798
5981
  case 22:
5799
5982
  beforePayments = cloneDeep(this.store.order.getOrderPayments());
5800
- beforePaymentStatus = (_this$store$order$get14 = this.store.order.getTempOrder()) === null || _this$store$order$get14 === void 0 ? void 0 : _this$store$order$get14.payment_status;
5983
+ beforePaymentStatus = (_this$store$order$get15 = this.store.order.getTempOrder()) === null || _this$store$order$get15 === void 0 ? void 0 : _this$store$order$get15.payment_status;
5801
5984
  paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
5802
5985
  metadata = _objectSpread(_objectSpread({}, params.metadata || {}), {}, {
5803
5986
  unique_payment_number: ((_params$metadata = params.metadata) === null || _params$metadata === void 0 ? void 0 : _params$metadata.unique_payment_number) || createUuidV4()
@@ -5830,8 +6013,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5830
6013
  var _item$metadata3;
5831
6014
  return (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.unique_payment_number) === metadata.unique_payment_number;
5832
6015
  });
5833
- _context55.prev = 30;
5834
- _context55.next = 33;
6016
+ _context56.prev = 30;
6017
+ _context56.next = 33;
5835
6018
  return this.syncPaymentsToOrder({
5836
6019
  payments: payments,
5837
6020
  submitWhenPaid: true,
@@ -5839,50 +6022,50 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5839
6022
  confirmPendingVoucherPayments: true
5840
6023
  });
5841
6024
  case 33:
5842
- syncResult = _context55.sent;
6025
+ syncResult = _context56.sent;
5843
6026
  if (!isRejectedSalesSubmitResult(syncResult.submitResult)) {
5844
- _context55.next = 36;
6027
+ _context56.next = 36;
5845
6028
  break;
5846
6029
  }
5847
6030
  throw new Error(getSalesSubmitErrorMessage(syncResult.submitResult, '订单提交失败'));
5848
6031
  case 36:
5849
6032
  if (!this.store.payment) {
5850
- _context55.next = 41;
6033
+ _context56.next = 41;
5851
6034
  break;
5852
6035
  }
5853
6036
  committed = this.getCommittedWalletAssets();
5854
6037
  walletState = this.store.payment.wallet.setCommittedWalletAssets(committed.ids, committed.assets);
5855
- _context55.next = 41;
6038
+ _context56.next = 41;
5856
6039
  return this.publishWalletAssetsState(walletState, 'local');
5857
6040
  case 41:
5858
- return _context55.abrupt("return", {
6041
+ return _context56.abrupt("return", {
5859
6042
  payment: payment || {},
5860
6043
  payments: this.store.order.getOrderPayments(),
5861
6044
  syncResult: syncResult,
5862
6045
  isOrderFullyPaid: syncResult.isOrderFullyPaid
5863
6046
  });
5864
6047
  case 44:
5865
- _context55.prev = 44;
5866
- _context55.t0 = _context55["catch"](30);
6048
+ _context56.prev = 44;
6049
+ _context56.t0 = _context56["catch"](30);
5867
6050
  this.store.order.setOrderPayments(beforePayments);
5868
6051
  restoredTempOrder = this.store.order.getTempOrder();
5869
6052
  if (restoredTempOrder && beforePaymentStatus !== undefined) {
5870
6053
  restoredTempOrder.payment_status = beforePaymentStatus;
5871
6054
  this.store.order.persistTempOrder();
5872
6055
  }
5873
- _context55.next = 51;
6056
+ _context56.next = 51;
5874
6057
  return this.store.order.recalculateSummary({
5875
6058
  createIfMissing: true
5876
6059
  });
5877
6060
  case 51:
5878
- throw _context55.t0;
6061
+ throw _context56.t0;
5879
6062
  case 52:
5880
6063
  case "end":
5881
- return _context55.stop();
6064
+ return _context56.stop();
5882
6065
  }
5883
- }, _callee55, this, [[30, 44]]);
6066
+ }, _callee56, this, [[30, 44]]);
5884
6067
  }));
5885
- function commitPaymentMethodPayment(_x44) {
6068
+ function commitPaymentMethodPayment(_x45) {
5886
6069
  return _commitPaymentMethodPayment.apply(this, arguments);
5887
6070
  }
5888
6071
  return commitPaymentMethodPayment;
@@ -5897,40 +6080,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5897
6080
  }, {
5898
6081
  key: "roundAmount",
5899
6082
  value: (function () {
5900
- var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
6083
+ var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
5901
6084
  var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
5902
6085
  var amount, cashManualPayment;
5903
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5904
- while (1) switch (_context56.prev = _context56.next) {
6086
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
6087
+ while (1) switch (_context57.prev = _context57.next) {
5905
6088
  case 0:
5906
6089
  amount = params.amount;
5907
6090
  cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
5908
6091
  return paymentMethod.code === 'CASHMANUAL';
5909
6092
  });
5910
6093
  if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
5911
- _context56.next = 4;
6094
+ _context57.next = 4;
5912
6095
  break;
5913
6096
  }
5914
- return _context56.abrupt("return", {
6097
+ return _context57.abrupt("return", {
5915
6098
  originalAmount: amount.toString(),
5916
6099
  roundedAmount: amount.toString(),
5917
6100
  roundingDifference: '0.00'
5918
6101
  });
5919
6102
  case 4:
5920
6103
  if (this.payment) {
5921
- _context56.next = 6;
6104
+ _context57.next = 6;
5922
6105
  break;
5923
6106
  }
5924
6107
  throw new Error('payment 模块未初始化');
5925
6108
  case 6:
5926
- return _context56.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
6109
+ return _context57.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
5927
6110
  case 7:
5928
6111
  case "end":
5929
- return _context56.stop();
6112
+ return _context57.stop();
5930
6113
  }
5931
- }, _callee56, this);
6114
+ }, _callee57, this);
5932
6115
  }));
5933
- function roundAmount(_x45) {
6116
+ function roundAmount(_x46) {
5934
6117
  return _roundAmount.apply(this, arguments);
5935
6118
  }
5936
6119
  return roundAmount;
@@ -5945,49 +6128,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
5945
6128
  }, {
5946
6129
  key: "sendCustomerPayLink",
5947
6130
  value: (function () {
5948
- var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
6131
+ var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
5949
6132
  var orderIds, _ref52, _ref53, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
5950
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
5951
- while (1) switch (_context57.prev = _context57.next) {
6133
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6134
+ while (1) switch (_context58.prev = _context58.next) {
5952
6135
  case 0:
5953
6136
  if (this.store.order) {
5954
- _context57.next = 2;
6137
+ _context58.next = 2;
5955
6138
  break;
5956
6139
  }
5957
6140
  throw new Error('order 模块未初始化');
5958
6141
  case 2:
5959
6142
  orderIds = params.order_ids || params.orderIds || [];
5960
6143
  if (!(!orderIds.length || params.submitBeforeSend)) {
5961
- _context57.next = 11;
6144
+ _context58.next = 11;
5962
6145
  break;
5963
6146
  }
5964
- _context57.next = 6;
6147
+ _context58.next = 6;
5965
6148
  return this.submitSalesOrder({
5966
6149
  smallTicketDataFlag: 1
5967
6150
  });
5968
6151
  case 6:
5969
- submitResult = _context57.sent;
6152
+ submitResult = _context58.sent;
5970
6153
  orderId = (_ref52 = (_ref53 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref53 !== void 0 ? _ref53 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref52 !== void 0 ? _ref52 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
5971
6154
  if (orderId) {
5972
- _context57.next = 10;
6155
+ _context58.next = 10;
5973
6156
  break;
5974
6157
  }
5975
6158
  throw new Error('本地订单提交云端失败,无法发送支付链接');
5976
6159
  case 10:
5977
6160
  orderIds = [orderId];
5978
6161
  case 11:
5979
- return _context57.abrupt("return", this.store.order.sendCustomerPayLink({
6162
+ return _context58.abrupt("return", this.store.order.sendCustomerPayLink({
5980
6163
  emails: params.emails,
5981
6164
  notify_action: params.notify_action,
5982
6165
  order_ids: orderIds
5983
6166
  }));
5984
6167
  case 12:
5985
6168
  case "end":
5986
- return _context57.stop();
6169
+ return _context58.stop();
5987
6170
  }
5988
- }, _callee57, this);
6171
+ }, _callee58, this);
5989
6172
  }));
5990
- function sendCustomerPayLink(_x46) {
6173
+ function sendCustomerPayLink(_x47) {
5991
6174
  return _sendCustomerPayLink.apply(this, arguments);
5992
6175
  }
5993
6176
  return sendCustomerPayLink;
@@ -6000,20 +6183,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6000
6183
  }, {
6001
6184
  key: "calculateProductBookingPrice",
6002
6185
  value: function () {
6003
- var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
6186
+ var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(params) {
6004
6187
  var _params$customer_id;
6005
6188
  var useCustomerUserPricing, quotation, customerId, channel, _yield$this$resolvePr, _yield$this$resolvePr2, authoritativeProduct, product;
6006
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6007
- while (1) switch (_context58.prev = _context58.next) {
6189
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6190
+ while (1) switch (_context59.prev = _context59.next) {
6008
6191
  case 0:
6009
6192
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
6010
6193
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
6011
6194
  customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
6012
- _context58.next = 5;
6195
+ _context59.next = 5;
6013
6196
  return this.prepareProductPriceQueryContext(customerId);
6014
6197
  case 5:
6015
6198
  channel = this.getPriceQueryChannel(params.channel);
6016
- _context58.next = 8;
6199
+ _context59.next = 8;
6017
6200
  return this.resolveProductsForPriceQuery({
6018
6201
  priceQueries: [params],
6019
6202
  schedule: this.getPriceQuerySchedule(params),
@@ -6021,22 +6204,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6021
6204
  channel: channel
6022
6205
  });
6023
6206
  case 8:
6024
- _yield$this$resolvePr = _context58.sent;
6207
+ _yield$this$resolvePr = _context59.sent;
6025
6208
  _yield$this$resolvePr2 = _slicedToArray(_yield$this$resolvePr, 1);
6026
6209
  authoritativeProduct = _yield$this$resolvePr2[0];
6027
6210
  product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
6028
6211
  if (useCustomerUserPricing) {
6029
- _context58.next = 15;
6212
+ _context59.next = 15;
6030
6213
  break;
6031
6214
  }
6032
- _context58.next = 15;
6215
+ _context59.next = 15;
6033
6216
  return this.loadQuotationForPriceQuery({
6034
6217
  quotation: quotation,
6035
6218
  customer_id: customerId,
6036
6219
  channel: channel
6037
6220
  });
6038
6221
  case 15:
6039
- return _context58.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
6222
+ return _context59.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
6040
6223
  channel: channel,
6041
6224
  product: product,
6042
6225
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
@@ -6045,11 +6228,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6045
6228
  })));
6046
6229
  case 16:
6047
6230
  case "end":
6048
- return _context58.stop();
6231
+ return _context59.stop();
6049
6232
  }
6050
- }, _callee58, this);
6233
+ }, _callee59, this);
6051
6234
  }));
6052
- function calculateProductBookingPrice(_x47) {
6235
+ function calculateProductBookingPrice(_x48) {
6053
6236
  return _calculateProductBookingPrice.apply(this, arguments);
6054
6237
  }
6055
6238
  return calculateProductBookingPrice;
@@ -6057,7 +6240,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6057
6240
  }, {
6058
6241
  key: "getQuotationCustomerScopeInfo",
6059
6242
  value: function getQuotationCustomerScopeInfo() {
6060
- var _this18 = this;
6243
+ var _this19 = this;
6061
6244
  var quotation = this.store.quotation;
6062
6245
  if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
6063
6246
  return quotation.getQuotationCustomerScopeInfo();
@@ -6069,7 +6252,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6069
6252
  }).map(function (item) {
6070
6253
  var localSeen = new Set();
6071
6254
  var customers = item.customer.filter(function (customer) {
6072
- var customerId = _this18.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
6255
+ var customerId = _this19.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
6073
6256
  if (!customerId || localSeen.has(customerId)) return false;
6074
6257
  localSeen.add(customerId);
6075
6258
  if (!customerById.has(customerId)) customerById.set(customerId, customer);
@@ -6096,8 +6279,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6096
6279
  }, {
6097
6280
  key: "hasSmartPricingStrategies",
6098
6281
  value: function hasSmartPricingStrategies() {
6099
- var _this$core4;
6100
- var evaluator = (_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.dataVariantEvaluator;
6282
+ var _this$core5;
6283
+ var evaluator = (_this$core5 = this.core) === null || _this$core5 === void 0 || (_this$core5 = _this$core5.context) === null || _this$core5 === void 0 ? void 0 : _this$core5.dataVariantEvaluator;
6101
6284
  if (!evaluator || typeof evaluator.getStrategyConfigs !== 'function') {
6102
6285
  return false;
6103
6286
  }
@@ -6133,23 +6316,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6133
6316
  }, {
6134
6317
  key: "calculateProductBookingPrices",
6135
6318
  value: function () {
6136
- var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(paramsList) {
6137
- var _this19 = this;
6319
+ var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(paramsList) {
6320
+ var _this20 = this;
6138
6321
  var useCustomerUserPricing, quotation, currentOrderCustomerId, resolvedChannels, authoritativeProducts, groups, quotationContexts;
6139
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6140
- while (1) switch (_context60.prev = _context60.next) {
6322
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6323
+ while (1) switch (_context61.prev = _context61.next) {
6141
6324
  case 0:
6142
6325
  if (paramsList.length) {
6143
- _context60.next = 2;
6326
+ _context61.next = 2;
6144
6327
  break;
6145
6328
  }
6146
- return _context60.abrupt("return", []);
6329
+ return _context61.abrupt("return", []);
6147
6330
  case 2:
6148
6331
  useCustomerUserPricing = this.isCustomerUserPriceQuery();
6149
6332
  quotation = useCustomerUserPricing ? undefined : this.store.quotation;
6150
6333
  currentOrderCustomerId = this.getCurrentOrderCustomerId();
6151
6334
  resolvedChannels = paramsList.map(function (params) {
6152
- return _this19.getPriceQueryChannel(params.channel);
6335
+ return _this20.getPriceQueryChannel(params.channel);
6153
6336
  });
6154
6337
  authoritativeProducts = paramsList.map(function () {
6155
6338
  return null;
@@ -6157,10 +6340,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6157
6340
  groups = new Map();
6158
6341
  paramsList.forEach(function (params, index) {
6159
6342
  var _params$customer_id2;
6160
- var schedule = _this19.getPriceQuerySchedule(params);
6343
+ var schedule = _this20.getPriceQuerySchedule(params);
6161
6344
  var channel = resolvedChannels[index];
6162
6345
  var customerId = (_params$customer_id2 = params.customer_id) !== null && _params$customer_id2 !== void 0 ? _params$customer_id2 : currentOrderCustomerId;
6163
- var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this19.normalizePriceContextCustomerId(customerId) || ''].join('|');
6346
+ var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || '', _this20.normalizePriceContextCustomerId(customerId) || ''].join('|');
6164
6347
  var group = groups.get(groupKey) || {
6165
6348
  indices: [],
6166
6349
  schedule: schedule,
@@ -6170,44 +6353,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6170
6353
  group.indices.push(index);
6171
6354
  groups.set(groupKey, group);
6172
6355
  });
6173
- _context60.next = 11;
6356
+ _context61.next = 11;
6174
6357
  return Promise.all(Array.from(groups.values()).map( /*#__PURE__*/function () {
6175
- var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(group) {
6358
+ var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(group) {
6176
6359
  var priceQueries, resolvedProducts;
6177
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6178
- while (1) switch (_context59.prev = _context59.next) {
6360
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6361
+ while (1) switch (_context60.prev = _context60.next) {
6179
6362
  case 0:
6180
- _context59.next = 2;
6181
- return _this19.prepareProductPriceQueryContext(group.customerId);
6363
+ _context60.next = 2;
6364
+ return _this20.prepareProductPriceQueryContext(group.customerId);
6182
6365
  case 2:
6183
6366
  priceQueries = group.indices.map(function (index) {
6184
6367
  return paramsList[index];
6185
6368
  });
6186
- _context59.next = 5;
6187
- return _this19.resolveProductsForPriceQuery({
6369
+ _context60.next = 5;
6370
+ return _this20.resolveProductsForPriceQuery({
6188
6371
  priceQueries: priceQueries,
6189
6372
  schedule: group.schedule,
6190
6373
  customerId: group.customerId,
6191
6374
  channel: group.channel
6192
6375
  });
6193
6376
  case 5:
6194
- resolvedProducts = _context59.sent;
6377
+ resolvedProducts = _context60.sent;
6195
6378
  group.indices.forEach(function (originalIndex, groupIndex) {
6196
6379
  authoritativeProducts[originalIndex] = resolvedProducts[groupIndex] || null;
6197
6380
  });
6198
6381
  case 7:
6199
6382
  case "end":
6200
- return _context59.stop();
6383
+ return _context60.stop();
6201
6384
  }
6202
- }, _callee59);
6385
+ }, _callee60);
6203
6386
  }));
6204
- return function (_x49) {
6387
+ return function (_x50) {
6205
6388
  return _ref54.apply(this, arguments);
6206
6389
  };
6207
6390
  }()));
6208
6391
  case 11:
6209
6392
  if (useCustomerUserPricing) {
6210
- _context60.next = 16;
6393
+ _context61.next = 16;
6211
6394
  break;
6212
6395
  }
6213
6396
  quotationContexts = new Map();
@@ -6221,18 +6404,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6221
6404
  customer_id: (_params$customer_id3 = params.customer_id) !== null && _params$customer_id3 !== void 0 ? _params$customer_id3 : currentOrderCustomerId
6222
6405
  });
6223
6406
  });
6224
- _context60.next = 16;
6407
+ _context61.next = 16;
6225
6408
  return Promise.all(Array.from(quotationContexts.values()).map(function (context) {
6226
- return _this19.loadQuotationForPriceQuery(_objectSpread({
6409
+ return _this20.loadQuotationForPriceQuery(_objectSpread({
6227
6410
  quotation: quotation
6228
6411
  }, context));
6229
6412
  }));
6230
6413
  case 16:
6231
- return _context60.abrupt("return", paramsList.map(function (params, index) {
6414
+ return _context61.abrupt("return", paramsList.map(function (params, index) {
6232
6415
  var _params$customer_id4;
6233
6416
  var productInput = params.product || {};
6234
6417
  var authoritativeProduct = authoritativeProducts[index];
6235
- var product = _this19.mergeProductForPriceQuery(productInput, authoritativeProduct);
6418
+ var product = _this20.mergeProductForPriceQuery(productInput, authoritativeProduct);
6236
6419
  var customerId = (_params$customer_id4 = params.customer_id) !== null && _params$customer_id4 !== void 0 ? _params$customer_id4 : currentOrderCustomerId;
6237
6420
  var channel = resolvedChannels[index];
6238
6421
  return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
@@ -6240,16 +6423,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6240
6423
  product: product,
6241
6424
  fallback_price: authoritativeProduct ? undefined : params.fallback_price,
6242
6425
  customer_id: customerId,
6243
- quotation: authoritativeProduct && _this19.preferAuthoritativeProductQueryPrice() ? undefined : quotation
6426
+ quotation: authoritativeProduct && _this20.preferAuthoritativeProductQueryPrice() ? undefined : quotation
6244
6427
  }));
6245
6428
  }));
6246
6429
  case 17:
6247
6430
  case "end":
6248
- return _context60.stop();
6431
+ return _context61.stop();
6249
6432
  }
6250
- }, _callee60, this);
6433
+ }, _callee61, this);
6251
6434
  }));
6252
- function calculateProductBookingPrices(_x48) {
6435
+ function calculateProductBookingPrices(_x49) {
6253
6436
  return _calculateProductBookingPrices.apply(this, arguments);
6254
6437
  }
6255
6438
  return calculateProductBookingPrices;
@@ -6257,42 +6440,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6257
6440
  }, {
6258
6441
  key: "addProductToOrder",
6259
6442
  value: function () {
6260
- var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(product, booking, options) {
6261
- var products;
6262
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6263
- while (1) switch (_context61.prev = _context61.next) {
6264
- case 0:
6265
- _context61.prev = 0;
6266
- if (this.store.order) {
6267
- _context61.next = 3;
6268
- break;
6269
- }
6270
- throw new Error('order 模块未初始化');
6271
- case 3:
6272
- _context61.next = 5;
6273
- return this.store.order.addProductToOrder(product, booking, options);
6274
- case 5:
6275
- products = _context61.sent;
6276
- return _context61.abrupt("return", products);
6277
- case 9:
6278
- _context61.prev = 9;
6279
- _context61.t0 = _context61["catch"](0);
6280
- throw _context61.t0;
6281
- case 12:
6282
- case "end":
6283
- return _context61.stop();
6284
- }
6285
- }, _callee61, this, [[0, 9]]);
6286
- }));
6287
- function addProductToOrder(_x50, _x51, _x52) {
6288
- return _addProductToOrder.apply(this, arguments);
6289
- }
6290
- return addProductToOrder;
6291
- }()
6292
- }, {
6293
- key: "updateOrderProduct",
6294
- value: function () {
6295
- var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
6443
+ var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(product, booking, options) {
6296
6444
  var products;
6297
6445
  return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6298
6446
  while (1) switch (_context62.prev = _context62.next) {
@@ -6305,7 +6453,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6305
6453
  throw new Error('order 模块未初始化');
6306
6454
  case 3:
6307
6455
  _context62.next = 5;
6308
- return this.store.order.updateOrderProduct(params);
6456
+ return this.store.order.addProductToOrder(product, booking, options);
6309
6457
  case 5:
6310
6458
  products = _context62.sent;
6311
6459
  return _context62.abrupt("return", products);
@@ -6319,15 +6467,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6319
6467
  }
6320
6468
  }, _callee62, this, [[0, 9]]);
6321
6469
  }));
6322
- function updateOrderProduct(_x53) {
6323
- return _updateOrderProduct.apply(this, arguments);
6470
+ function addProductToOrder(_x51, _x52, _x53) {
6471
+ return _addProductToOrder.apply(this, arguments);
6324
6472
  }
6325
- return updateOrderProduct;
6473
+ return addProductToOrder;
6326
6474
  }()
6327
6475
  }, {
6328
- key: "updateOrderProducts",
6476
+ key: "updateOrderProduct",
6329
6477
  value: function () {
6330
- var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(paramsList) {
6478
+ var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
6331
6479
  var products;
6332
6480
  return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6333
6481
  while (1) switch (_context63.prev = _context63.next) {
@@ -6340,7 +6488,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6340
6488
  throw new Error('order 模块未初始化');
6341
6489
  case 3:
6342
6490
  _context63.next = 5;
6343
- return this.store.order.updateOrderProducts(paramsList);
6491
+ return this.store.order.updateOrderProduct(params);
6344
6492
  case 5:
6345
6493
  products = _context63.sent;
6346
6494
  return _context63.abrupt("return", products);
@@ -6354,15 +6502,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6354
6502
  }
6355
6503
  }, _callee63, this, [[0, 9]]);
6356
6504
  }));
6357
- function updateOrderProducts(_x54) {
6358
- return _updateOrderProducts.apply(this, arguments);
6505
+ function updateOrderProduct(_x54) {
6506
+ return _updateOrderProduct.apply(this, arguments);
6359
6507
  }
6360
- return updateOrderProducts;
6508
+ return updateOrderProduct;
6361
6509
  }()
6362
6510
  }, {
6363
- key: "updateOrderProductQuantity",
6511
+ key: "updateOrderProducts",
6364
6512
  value: function () {
6365
- var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
6513
+ var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(paramsList) {
6366
6514
  var products;
6367
6515
  return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6368
6516
  while (1) switch (_context64.prev = _context64.next) {
@@ -6375,7 +6523,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6375
6523
  throw new Error('order 模块未初始化');
6376
6524
  case 3:
6377
6525
  _context64.next = 5;
6378
- return this.store.order.updateOrderProductQuantity(params);
6526
+ return this.store.order.updateOrderProducts(paramsList);
6379
6527
  case 5:
6380
6528
  products = _context64.sent;
6381
6529
  return _context64.abrupt("return", products);
@@ -6389,7 +6537,42 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6389
6537
  }
6390
6538
  }, _callee64, this, [[0, 9]]);
6391
6539
  }));
6392
- function updateOrderProductQuantity(_x55) {
6540
+ function updateOrderProducts(_x55) {
6541
+ return _updateOrderProducts.apply(this, arguments);
6542
+ }
6543
+ return updateOrderProducts;
6544
+ }()
6545
+ }, {
6546
+ key: "updateOrderProductQuantity",
6547
+ value: function () {
6548
+ var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
6549
+ var products;
6550
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6551
+ while (1) switch (_context65.prev = _context65.next) {
6552
+ case 0:
6553
+ _context65.prev = 0;
6554
+ if (this.store.order) {
6555
+ _context65.next = 3;
6556
+ break;
6557
+ }
6558
+ throw new Error('order 模块未初始化');
6559
+ case 3:
6560
+ _context65.next = 5;
6561
+ return this.store.order.updateOrderProductQuantity(params);
6562
+ case 5:
6563
+ products = _context65.sent;
6564
+ return _context65.abrupt("return", products);
6565
+ case 9:
6566
+ _context65.prev = 9;
6567
+ _context65.t0 = _context65["catch"](0);
6568
+ throw _context65.t0;
6569
+ case 12:
6570
+ case "end":
6571
+ return _context65.stop();
6572
+ }
6573
+ }, _callee65, this, [[0, 9]]);
6574
+ }));
6575
+ function updateOrderProductQuantity(_x56) {
6393
6576
  return _updateOrderProductQuantity.apply(this, arguments);
6394
6577
  }
6395
6578
  return updateOrderProductQuantity;
@@ -6412,12 +6595,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6412
6595
  }, {
6413
6596
  key: "setOrderProductLineNote",
6414
6597
  value: (function () {
6415
- var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(identity, note) {
6598
+ var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(identity, note) {
6416
6599
  var params, products;
6417
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
6418
- while (1) switch (_context65.prev = _context65.next) {
6600
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6601
+ while (1) switch (_context66.prev = _context66.next) {
6419
6602
  case 0:
6420
- _context65.prev = 0;
6603
+ _context66.prev = 0;
6421
6604
  params = {
6422
6605
  product_id: identity.product_id,
6423
6606
  product_variant_id: identity.product_variant_id,
@@ -6432,22 +6615,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6432
6615
  params.product_sku = identity.product_sku;
6433
6616
  }
6434
6617
  if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
6435
- _context65.next = 7;
6618
+ _context66.next = 7;
6436
6619
  return this.updateOrderProduct(params);
6437
6620
  case 7:
6438
- products = _context65.sent;
6439
- return _context65.abrupt("return", products);
6621
+ products = _context66.sent;
6622
+ return _context66.abrupt("return", products);
6440
6623
  case 11:
6441
- _context65.prev = 11;
6442
- _context65.t0 = _context65["catch"](0);
6443
- throw _context65.t0;
6624
+ _context66.prev = 11;
6625
+ _context66.t0 = _context66["catch"](0);
6626
+ throw _context66.t0;
6444
6627
  case 14:
6445
6628
  case "end":
6446
- return _context65.stop();
6629
+ return _context66.stop();
6447
6630
  }
6448
- }, _callee65, this, [[0, 11]]);
6631
+ }, _callee66, this, [[0, 11]]);
6449
6632
  }));
6450
- function setOrderProductLineNote(_x56, _x57) {
6633
+ function setOrderProductLineNote(_x57, _x58) {
6451
6634
  return _setOrderProductLineNote.apply(this, arguments);
6452
6635
  }
6453
6636
  return setOrderProductLineNote;
@@ -6462,32 +6645,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6462
6645
  }, {
6463
6646
  key: "removeProductsFromOrder",
6464
6647
  value: (function () {
6465
- var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(identities, options) {
6466
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
6467
- while (1) switch (_context66.prev = _context66.next) {
6648
+ var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(identities, options) {
6649
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6650
+ while (1) switch (_context67.prev = _context67.next) {
6468
6651
  case 0:
6469
- _context66.prev = 0;
6652
+ _context67.prev = 0;
6470
6653
  if (this.store.order) {
6471
- _context66.next = 3;
6654
+ _context67.next = 3;
6472
6655
  break;
6473
6656
  }
6474
6657
  throw new Error('order 模块未初始化');
6475
6658
  case 3:
6476
- _context66.next = 5;
6659
+ _context67.next = 5;
6477
6660
  return this.store.order.removeProductsFromOrder(identities, options);
6478
6661
  case 5:
6479
- return _context66.abrupt("return", _context66.sent);
6662
+ return _context67.abrupt("return", _context67.sent);
6480
6663
  case 8:
6481
- _context66.prev = 8;
6482
- _context66.t0 = _context66["catch"](0);
6483
- throw _context66.t0;
6664
+ _context67.prev = 8;
6665
+ _context67.t0 = _context67["catch"](0);
6666
+ throw _context67.t0;
6484
6667
  case 11:
6485
6668
  case "end":
6486
- return _context66.stop();
6669
+ return _context67.stop();
6487
6670
  }
6488
- }, _callee66, this, [[0, 8]]);
6671
+ }, _callee67, this, [[0, 8]]);
6489
6672
  }));
6490
- function removeProductsFromOrder(_x58, _x59) {
6673
+ function removeProductsFromOrder(_x59, _x60) {
6491
6674
  return _removeProductsFromOrder.apply(this, arguments);
6492
6675
  }
6493
6676
  return removeProductsFromOrder;
@@ -6495,18 +6678,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6495
6678
  }, {
6496
6679
  key: "removeProductFromOrder",
6497
6680
  value: function () {
6498
- var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(identity, options) {
6499
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
6500
- while (1) switch (_context67.prev = _context67.next) {
6681
+ var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(identity, options) {
6682
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6683
+ while (1) switch (_context68.prev = _context68.next) {
6501
6684
  case 0:
6502
- return _context67.abrupt("return", this.removeProductsFromOrder([identity], options));
6685
+ return _context68.abrupt("return", this.removeProductsFromOrder([identity], options));
6503
6686
  case 1:
6504
6687
  case "end":
6505
- return _context67.stop();
6688
+ return _context68.stop();
6506
6689
  }
6507
- }, _callee67, this);
6690
+ }, _callee68, this);
6508
6691
  }));
6509
- function removeProductFromOrder(_x60, _x61) {
6692
+ function removeProductFromOrder(_x61, _x62) {
6510
6693
  return _removeProductFromOrder.apply(this, arguments);
6511
6694
  }
6512
6695
  return removeProductFromOrder;
@@ -6556,23 +6739,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6556
6739
  }, {
6557
6740
  key: "applyPromotion",
6558
6741
  value: (function () {
6559
- var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68() {
6560
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
6561
- while (1) switch (_context68.prev = _context68.next) {
6742
+ var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69() {
6743
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6744
+ while (1) switch (_context69.prev = _context69.next) {
6562
6745
  case 0:
6563
6746
  if (this.store.order) {
6564
- _context68.next = 2;
6747
+ _context69.next = 2;
6565
6748
  break;
6566
6749
  }
6567
6750
  throw new Error('order 模块未初始化');
6568
6751
  case 2:
6569
- _context68.next = 4;
6752
+ _context69.next = 4;
6570
6753
  return this.store.order.applyPromotion();
6571
6754
  case 4:
6572
6755
  case "end":
6573
- return _context68.stop();
6756
+ return _context69.stop();
6574
6757
  }
6575
- }, _callee68, this);
6758
+ }, _callee69, this);
6576
6759
  }));
6577
6760
  function applyPromotion() {
6578
6761
  return _applyPromotion.apply(this, arguments);
@@ -6582,16 +6765,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6582
6765
  }, {
6583
6766
  key: "getUnfulfilledPromotions",
6584
6767
  value: function getUnfulfilledPromotions() {
6585
- var _this$store$order24;
6586
- return ((_this$store$order24 = this.store.order) === null || _this$store$order24 === void 0 ? void 0 : _this$store$order24.getUnfulfilledPromotions()) || [];
6768
+ var _this$store$order29;
6769
+ return ((_this$store$order29 = this.store.order) === null || _this$store$order29 === void 0 ? void 0 : _this$store$order29.getUnfulfilledPromotions()) || [];
6587
6770
  }
6588
6771
 
6589
6772
  /** 最近一次促销计算输出的赠品操作 diff。 */
6590
6773
  }, {
6591
6774
  key: "getLastGiftActions",
6592
6775
  value: function getLastGiftActions() {
6593
- var _this$store$order25;
6594
- return ((_this$store$order25 = this.store.order) === null || _this$store$order25 === void 0 ? void 0 : _this$store$order25.getLastGiftActions()) || null;
6776
+ var _this$store$order30;
6777
+ return ((_this$store$order30 = this.store.order) === null || _this$store$order30 === void 0 ? void 0 : _this$store$order30.getLastGiftActions()) || null;
6595
6778
  }
6596
6779
 
6597
6780
  // 获取商品列表
@@ -6599,18 +6782,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6599
6782
  }, {
6600
6783
  key: "getProductList",
6601
6784
  value: function () {
6602
- var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69() {
6603
- var _this$otherParams36;
6785
+ var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70() {
6786
+ var _this$otherParams40;
6604
6787
  var menu_list_ids, _this$store$products, res;
6605
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
6606
- while (1) switch (_context69.prev = _context69.next) {
6788
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6789
+ while (1) switch (_context70.prev = _context70.next) {
6607
6790
  case 0:
6608
6791
  // 可以直接通过配置里的 menu 读取
6609
- menu_list_ids = ((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 || (_this$otherParams36 = _this$otherParams36.dineInConfig) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36['menu.associated_menus'].map(function (n) {
6792
+ menu_list_ids = ((_this$otherParams40 = this.otherParams) === null || _this$otherParams40 === void 0 || (_this$otherParams40 = _this$otherParams40.dineInConfig) === null || _this$otherParams40 === void 0 ? void 0 : _this$otherParams40['menu.associated_menus'].map(function (n) {
6610
6793
  return Number(n.value);
6611
6794
  })) || [];
6612
- _context69.prev = 1;
6613
- _context69.next = 4;
6795
+ _context70.prev = 1;
6796
+ _context70.next = 4;
6614
6797
  return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
6615
6798
  menu_list_ids: menu_list_ids,
6616
6799
  cacheId: this.cacheId,
@@ -6618,17 +6801,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6618
6801
  schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
6619
6802
  });
6620
6803
  case 4:
6621
- res = _context69.sent;
6622
- return _context69.abrupt("return", res);
6804
+ res = _context70.sent;
6805
+ return _context70.abrupt("return", res);
6623
6806
  case 8:
6624
- _context69.prev = 8;
6625
- _context69.t0 = _context69["catch"](1);
6626
- throw _context69.t0;
6807
+ _context70.prev = 8;
6808
+ _context70.t0 = _context70["catch"](1);
6809
+ throw _context70.t0;
6627
6810
  case 11:
6628
6811
  case "end":
6629
- return _context69.stop();
6812
+ return _context70.stop();
6630
6813
  }
6631
- }, _callee69, this, [[1, 8]]);
6814
+ }, _callee70, this, [[1, 8]]);
6632
6815
  }));
6633
6816
  function getProductList() {
6634
6817
  return _getProductList.apply(this, arguments);
@@ -6643,33 +6826,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
6643
6826
  }, {
6644
6827
  key: "setOtherParams",
6645
6828
  value: function () {
6646
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
6647
- var _this$otherParams37;
6829
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
6830
+ var _this$otherParams41;
6648
6831
  var _ref55,
6649
6832
  _ref55$cover,
6650
6833
  cover,
6651
- _args70 = arguments;
6652
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
6653
- while (1) switch (_context70.prev = _context70.next) {
6834
+ _args71 = arguments;
6835
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
6836
+ while (1) switch (_context71.prev = _context71.next) {
6654
6837
  case 0:
6655
- _ref55 = _args70.length > 1 && _args70[1] !== undefined ? _args70[1] : {}, _ref55$cover = _ref55.cover, cover = _ref55$cover === void 0 ? false : _ref55$cover;
6838
+ _ref55 = _args71.length > 1 && _args71[1] !== undefined ? _args71[1] : {}, _ref55$cover = _ref55.cover, cover = _ref55$cover === void 0 ? false : _ref55$cover;
6656
6839
  if (cover) {
6657
6840
  this.otherParams = _objectSpread({}, params);
6658
6841
  } else {
6659
6842
  this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
6660
6843
  }
6661
- this.cacheId = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.cacheId;
6662
- _context70.next = 5;
6844
+ this.cacheId = (_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.cacheId;
6845
+ _context71.next = 5;
6663
6846
  return this.syncOtherParamsToSubModules(params, {
6664
6847
  cover: cover
6665
6848
  });
6666
6849
  case 5:
6667
6850
  case "end":
6668
- return _context70.stop();
6851
+ return _context71.stop();
6669
6852
  }
6670
- }, _callee70, this);
6853
+ }, _callee71, this);
6671
6854
  }));
6672
- function setOtherParams(_x62) {
6855
+ function setOtherParams(_x63) {
6673
6856
  return _setOtherParams.apply(this, arguments);
6674
6857
  }
6675
6858
  return setOtherParams;