@pisell/pisellos 2.3.218 → 2.3.220

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 (32) hide show
  1. package/dist/modules/OpenData/types.d.ts +3 -0
  2. package/dist/modules/Order/index.d.ts +1 -1
  3. package/dist/modules/Order/index.js +6 -3
  4. package/dist/modules/Order/types.d.ts +1 -1
  5. package/dist/modules/Order/utils.d.ts +4 -0
  6. package/dist/modules/Order/utils.js +105 -53
  7. package/dist/modules/Product/index.d.ts +1 -1
  8. package/dist/solution/BaseSales/index.d.ts +2 -0
  9. package/dist/solution/BaseSales/index.js +65 -37
  10. package/dist/solution/BaseSales/types.d.ts +2 -0
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.d.ts +16 -0
  13. package/dist/solution/BookingTicket/index.js +679 -332
  14. package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +78 -0
  15. package/dist/solution/BookingTicket/utils/redeemArrival.js +175 -0
  16. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  17. package/lib/modules/OpenData/types.d.ts +3 -0
  18. package/lib/modules/Order/index.d.ts +1 -1
  19. package/lib/modules/Order/index.js +4 -1
  20. package/lib/modules/Order/types.d.ts +1 -1
  21. package/lib/modules/Order/utils.d.ts +4 -0
  22. package/lib/modules/Order/utils.js +45 -1
  23. package/lib/modules/Product/index.d.ts +1 -1
  24. package/lib/solution/BaseSales/index.d.ts +2 -0
  25. package/lib/solution/BaseSales/index.js +27 -6
  26. package/lib/solution/BaseSales/types.d.ts +2 -0
  27. package/lib/solution/BookingByStep/index.d.ts +1 -1
  28. package/lib/solution/BookingTicket/index.d.ts +16 -0
  29. package/lib/solution/BookingTicket/index.js +171 -5
  30. package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +78 -0
  31. package/lib/solution/BookingTicket/utils/redeemArrival.js +156 -0
  32. package/package.json +1 -1
@@ -37,6 +37,7 @@ import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from
37
37
  import { getProductExtend as getProductExtendUtil, getResourceByIds as getResourceByIdsUtil, getResourceErrors as getResourceErrorsUtil, derivePresetStartTimeFromDate } from "../../modules/BookingContext";
38
38
  import { BaseSalesImpl } from "../BaseSales";
39
39
  import Scan from "./utils/scan";
40
+ import { applyRedeemArrival, buildArrivalCheckoutQuery, createArrivalLogger, describeChangedBookings, readArrivalWindow } from "./utils/redeemArrival";
40
41
  import { formatOrderCustomerPatch } from "./utils/orderCustomer";
41
42
  import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
42
43
  import scanCache from "./utils/scan/scanCache";
@@ -187,11 +188,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
187
188
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
188
189
  _defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshTarget", null);
189
190
  _defineProperty(_assertThisInitialized(_this), "orderCustomerPromotionRefreshInFlight", null);
191
+ // Retain the settled result too: a failed refresh must remain observable by checkout callers.
192
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerRefreshTask", Promise.resolve());
193
+ _defineProperty(_assertThisInitialized(_this), "orderCustomerRefreshRevision", 0);
190
194
  _defineProperty(_assertThisInitialized(_this), "orderCustomerContactRequest", null);
191
195
  _defineProperty(_assertThisInitialized(_this), "customerResolveRequests", new Map());
192
196
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlight", null);
193
197
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlightTarget", null);
194
198
  _defineProperty(_assertThisInitialized(_this), "openDataTarget", null);
199
+ _defineProperty(_assertThisInitialized(_this), "redeemStatusWrite", void 0);
200
+ _defineProperty(_assertThisInitialized(_this), "arrivalQueue", Promise.resolve());
195
201
  return _this;
196
202
  }
197
203
  _createClass(BookingTicketImpl, [{
@@ -1854,12 +1860,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1854
1860
  }
1855
1861
  return;
1856
1862
  }
1863
+ var enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
1857
1864
  var next = this.buildOrderCustomerPayload();
1858
1865
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next && options !== null && options !== void 0 && options.source ? _objectSpread(_objectSpread({}, next), {}, {
1859
1866
  source: options.source
1860
1867
  }) : next);
1861
- this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1862
- // 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
1868
+ if (enableMemberCartConsistency) {
1869
+ this.refreshMemberCartContext(patch.customer_id);
1870
+ return;
1871
+ }
1872
+ void this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
1863
1873
  var promotionRefreshTask = this.store.order.applyPromotion().then(function () {
1864
1874
  return undefined;
1865
1875
  });
@@ -1873,6 +1883,85 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1873
1883
  _this3.orderCustomerPromotionRefreshInFlight = null;
1874
1884
  });
1875
1885
  }
1886
+
1887
+ /** Shared by customer changes and an explicit retry; keep the selected customer/cart intact. */
1888
+ }, {
1889
+ key: "refreshMemberCartContext",
1890
+ value: function refreshMemberCartContext(customerId) {
1891
+ var _this4 = this;
1892
+ var revision = ++this.orderCustomerRefreshRevision;
1893
+ var orderKey = this.getCustomerContactOrderKey();
1894
+ var isCurrent = function isCurrent() {
1895
+ var _this4$store$order$ge;
1896
+ return revision === _this4.orderCustomerRefreshRevision && _this4.getCustomerContactOrderKey() === orderKey && Number(((_this4$store$order$ge = _this4.store.order.getOrderCustomer()) === null || _this4$store$order$ge === void 0 ? void 0 : _this4$store$order$ge.customer_id) || 0) === Number(customerId || 0);
1897
+ };
1898
+ var task = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
1899
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1900
+ while (1) switch (_context26.prev = _context26.next) {
1901
+ case 0:
1902
+ if (!customerId) {
1903
+ _context26.next = 5;
1904
+ break;
1905
+ }
1906
+ _context26.next = 3;
1907
+ return _this4.refreshDiscountConfigAfterOrderCustomerChange(customerId);
1908
+ case 3:
1909
+ _context26.next = 7;
1910
+ break;
1911
+ case 5:
1912
+ _context26.next = 7;
1913
+ return _this4.loadDiscountConfig({
1914
+ force: true
1915
+ });
1916
+ case 7:
1917
+ if (!isCurrent()) {
1918
+ _context26.next = 10;
1919
+ break;
1920
+ }
1921
+ _context26.next = 10;
1922
+ return _this4.store.order.applyPromotion();
1923
+ case 10:
1924
+ case "end":
1925
+ return _context26.stop();
1926
+ }
1927
+ }, _callee26);
1928
+ }))();
1929
+ this.orderCustomerRefreshTask = task;
1930
+ this.orderCustomerPromotionRefreshInFlight = task;
1931
+ void task.catch(function (error) {
1932
+ if (isCurrent()) console.error('[BookingTicket] Member cart refresh failed', error);
1933
+ }).finally(function () {
1934
+ if (_this4.orderCustomerPromotionRefreshInFlight === task) _this4.orderCustomerPromotionRefreshInFlight = null;
1935
+ });
1936
+ }
1937
+ }, {
1938
+ key: "retryOrderCustomerRefresh",
1939
+ value: function () {
1940
+ var _retryOrderCustomerRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1941
+ var _this$store$order$get4, _this$store$order$get5;
1942
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1943
+ while (1) switch (_context27.prev = _context27.next) {
1944
+ case 0:
1945
+ if (this.isMemberCartConsistencyEnabled()) {
1946
+ _context27.next = 2;
1947
+ break;
1948
+ }
1949
+ return _context27.abrupt("return");
1950
+ case 2:
1951
+ this.refreshMemberCartContext((_this$store$order$get4 = (_this$store$order$get5 = this.store.order.getOrderCustomer()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.customer_id) !== null && _this$store$order$get4 !== void 0 ? _this$store$order$get4 : null);
1952
+ _context27.next = 5;
1953
+ return this.waitForOrderCustomerRefresh();
1954
+ case 5:
1955
+ case "end":
1956
+ return _context27.stop();
1957
+ }
1958
+ }, _callee27, this);
1959
+ }));
1960
+ function retryOrderCustomerRefresh() {
1961
+ return _retryOrderCustomerRefresh.apply(this, arguments);
1962
+ }
1963
+ return retryOrderCustomerRefresh;
1964
+ }()
1876
1965
  }, {
1877
1966
  key: "resetOrderCustomerContactInfo",
1878
1967
  value: function resetOrderCustomerContactInfo() {
@@ -1909,25 +1998,25 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1909
1998
  }, {
1910
1999
  key: "replaceTempOrder",
1911
2000
  value: function () {
1912
- var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2001
+ var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
1913
2002
  var _get2;
1914
2003
  var _len2,
1915
2004
  args,
1916
2005
  _key2,
1917
- _args26 = arguments;
1918
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1919
- while (1) switch (_context26.prev = _context26.next) {
2006
+ _args28 = arguments;
2007
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2008
+ while (1) switch (_context28.prev = _context28.next) {
1920
2009
  case 0:
1921
2010
  this.orderCustomerContactRequest = null;
1922
- for (_len2 = _args26.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1923
- args[_key2] = _args26[_key2];
2011
+ for (_len2 = _args28.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2012
+ args[_key2] = _args28[_key2];
1924
2013
  }
1925
- return _context26.abrupt("return", (_get2 = _get(_getPrototypeOf(BookingTicketImpl.prototype), "replaceTempOrder", this)).call.apply(_get2, [this].concat(args)));
2014
+ return _context28.abrupt("return", (_get2 = _get(_getPrototypeOf(BookingTicketImpl.prototype), "replaceTempOrder", this)).call.apply(_get2, [this].concat(args)));
1926
2015
  case 3:
1927
2016
  case "end":
1928
- return _context26.stop();
2017
+ return _context28.stop();
1929
2018
  }
1930
- }, _callee26, this);
2019
+ }, _callee28, this);
1931
2020
  }));
1932
2021
  function replaceTempOrder() {
1933
2022
  return _replaceTempOrder.apply(this, arguments);
@@ -1937,21 +2026,21 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1937
2026
  }, {
1938
2027
  key: "applyDefaultOrderCustomerContactInfo",
1939
2028
  value: function () {
1940
- var _applyDefaultOrderCustomerContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(contact) {
1941
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1942
- while (1) switch (_context27.prev = _context27.next) {
2029
+ var _applyDefaultOrderCustomerContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(contact) {
2030
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2031
+ while (1) switch (_context29.prev = _context29.next) {
1943
2032
  case 0:
1944
2033
  this.store.order.updateTempOrderContactsInfo(cloneDeep(contact));
1945
2034
  // Metadata may finish after promotion/discount refresh; publish the updated cart explicitly.
1946
- _context27.next = 3;
2035
+ _context29.next = 3;
1947
2036
  return this.effectsEmit('onTempOrderReplaced', {
1948
2037
  tempOrder: this.getTempOrder()
1949
2038
  });
1950
2039
  case 3:
1951
2040
  case "end":
1952
- return _context27.stop();
2041
+ return _context29.stop();
1953
2042
  }
1954
- }, _callee27, this);
2043
+ }, _callee29, this);
1955
2044
  }));
1956
2045
  function applyDefaultOrderCustomerContactInfo(_x17) {
1957
2046
  return _applyDefaultOrderCustomerContactInfo.apply(this, arguments);
@@ -1963,7 +2052,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1963
2052
  value: function prefillOrderCustomerContactInfo(customer, customerChanged) {
1964
2053
  var _order$_extend2,
1965
2054
  _this$otherParams9,
1966
- _this4 = this;
2055
+ _this5 = this;
1967
2056
  var order = this.getTempOrder();
1968
2057
  var customerId = Number(order === null || order === void 0 ? void 0 : order.customer_id);
1969
2058
  if (!order || !Number.isInteger(customerId) || customerId <= 1 || order.contacts_info != null || (_order$_extend2 = order._extend) !== null && _order$_extend2 !== void 0 && _order$_extend2.contactInfoEdited) return;
@@ -1980,8 +2069,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1980
2069
  if (customer.contacts_info !== undefined) return;
1981
2070
  var userPlatform = isCustomerUserPlatform((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.platform);
1982
2071
  var getAuthenticatedCustomerId = function getAuthenticatedCustomerId() {
1983
- var _this4$core, _this4$core$getPlugin, _this4$core$getPlugin2;
1984
- return Number((_this4$core = _this4.core) === null || _this4$core === void 0 || (_this4$core$getPlugin = _this4$core.getPlugin) === null || _this4$core$getPlugin === void 0 || (_this4$core$getPlugin = _this4$core$getPlugin.call(_this4$core, 'user')) === null || _this4$core$getPlugin === void 0 || (_this4$core$getPlugin2 = _this4$core$getPlugin.get) === null || _this4$core$getPlugin2 === void 0 || (_this4$core$getPlugin2 = _this4$core$getPlugin2.call(_this4$core$getPlugin)) === null || _this4$core$getPlugin2 === void 0 ? void 0 : _this4$core$getPlugin2.id);
2072
+ var _this5$core, _this5$core$getPlugin, _this5$core$getPlugin2;
2073
+ return Number((_this5$core = _this5.core) === null || _this5$core === void 0 || (_this5$core$getPlugin = _this5$core.getPlugin) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin = _this5$core$getPlugin.call(_this5$core, 'user')) === null || _this5$core$getPlugin === void 0 || (_this5$core$getPlugin2 = _this5$core$getPlugin.get) === null || _this5$core$getPlugin2 === void 0 || (_this5$core$getPlugin2 = _this5$core$getPlugin2.call(_this5$core$getPlugin)) === null || _this5$core$getPlugin2 === void 0 ? void 0 : _this5$core$getPlugin2.id);
1985
2074
  };
1986
2075
  if (userPlatform && getAuthenticatedCustomerId() !== customerId) return;
1987
2076
  var scope = this.getCustomerContactScope();
@@ -1996,76 +2085,76 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1996
2085
  };
1997
2086
  this.orderCustomerContactRequest = pending;
1998
2087
  var loadContact = /*#__PURE__*/function () {
1999
- var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2088
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2000
2089
  var _result4, resolved;
2001
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2002
- while (1) switch (_context28.prev = _context28.next) {
2090
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2091
+ while (1) switch (_context30.prev = _context30.next) {
2003
2092
  case 0:
2004
2093
  if (!userPlatform) {
2005
- _context28.next = 7;
2094
+ _context30.next = 7;
2006
2095
  break;
2007
2096
  }
2008
- _context28.next = 3;
2009
- return _this4.request.get('/customer/metadata', {
2097
+ _context30.next = 3;
2098
+ return _this5.request.get('/customer/metadata', {
2010
2099
  key: 'contacts_info'
2011
2100
  });
2012
2101
  case 3:
2013
- _result4 = _context28.sent;
2102
+ _result4 = _context30.sent;
2014
2103
  if (!((_result4 === null || _result4 === void 0 ? void 0 : _result4.code) !== 200 || (_result4 === null || _result4 === void 0 ? void 0 : _result4.status) === false)) {
2015
- _context28.next = 6;
2104
+ _context30.next = 6;
2016
2105
  break;
2017
2106
  }
2018
2107
  throw new Error('Customer contact lookup failed');
2019
2108
  case 6:
2020
- return _context28.abrupt("return", isContactRecord(_result4.data) ? _result4.data : null);
2109
+ return _context30.abrupt("return", isContactRecord(_result4.data) ? _result4.data : null);
2021
2110
  case 7:
2022
- _context28.next = 9;
2023
- return _this4.resolveCustomerById(customerId);
2111
+ _context30.next = 9;
2112
+ return _this5.resolveCustomerById(customerId);
2024
2113
  case 9:
2025
- resolved = _context28.sent;
2026
- return _context28.abrupt("return", Number(resolved === null || resolved === void 0 ? void 0 : resolved.id) === customerId ? extractCustomerContactInfo(resolved) : null);
2114
+ resolved = _context30.sent;
2115
+ return _context30.abrupt("return", Number(resolved === null || resolved === void 0 ? void 0 : resolved.id) === customerId ? extractCustomerContactInfo(resolved) : null);
2027
2116
  case 11:
2028
2117
  case "end":
2029
- return _context28.stop();
2118
+ return _context30.stop();
2030
2119
  }
2031
- }, _callee28);
2120
+ }, _callee30);
2032
2121
  }));
2033
2122
  return function loadContact() {
2034
- return _ref11.apply(this, arguments);
2123
+ return _ref12.apply(this, arguments);
2035
2124
  };
2036
2125
  }();
2037
2126
  pending.promise = loadContact().then( /*#__PURE__*/function () {
2038
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(value) {
2127
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(value) {
2039
2128
  var _current$_extend;
2040
2129
  var current;
2041
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2042
- while (1) switch (_context29.prev = _context29.next) {
2130
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2131
+ while (1) switch (_context31.prev = _context31.next) {
2043
2132
  case 0:
2044
- current = _this4.getTempOrder();
2045
- if (!(_this4.orderCustomerContactRequest !== pending || _this4.getCustomerContactOrderKey() !== orderKey || Number(current === null || current === void 0 ? void 0 : current.customer_id) !== customerId || scope !== _this4.getCustomerContactScope() || current !== null && current !== void 0 && (_current$_extend = current._extend) !== null && _current$_extend !== void 0 && _current$_extend.contactInfoEdited || (current === null || current === void 0 ? void 0 : current.contacts_info) != null || userPlatform && getAuthenticatedCustomerId() !== customerId)) {
2046
- _context29.next = 3;
2133
+ current = _this5.getTempOrder();
2134
+ if (!(_this5.orderCustomerContactRequest !== pending || _this5.getCustomerContactOrderKey() !== orderKey || Number(current === null || current === void 0 ? void 0 : current.customer_id) !== customerId || scope !== _this5.getCustomerContactScope() || current !== null && current !== void 0 && (_current$_extend = current._extend) !== null && _current$_extend !== void 0 && _current$_extend.contactInfoEdited || (current === null || current === void 0 ? void 0 : current.contacts_info) != null || userPlatform && getAuthenticatedCustomerId() !== customerId)) {
2135
+ _context31.next = 3;
2047
2136
  break;
2048
2137
  }
2049
- return _context29.abrupt("return");
2138
+ return _context31.abrupt("return");
2050
2139
  case 3:
2051
2140
  if (!value) {
2052
- _context29.next = 6;
2141
+ _context31.next = 6;
2053
2142
  break;
2054
2143
  }
2055
- _context29.next = 6;
2056
- return _this4.applyDefaultOrderCustomerContactInfo(value);
2144
+ _context31.next = 6;
2145
+ return _this5.applyDefaultOrderCustomerContactInfo(value);
2057
2146
  case 6:
2058
2147
  case "end":
2059
- return _context29.stop();
2148
+ return _context31.stop();
2060
2149
  }
2061
- }, _callee29);
2150
+ }, _callee31);
2062
2151
  }));
2063
2152
  return function (_x18) {
2064
- return _ref12.apply(this, arguments);
2153
+ return _ref13.apply(this, arguments);
2065
2154
  };
2066
2155
  }()).catch(function () {
2067
2156
  // A failed default does not prevent manual entry; a subsequent sync can retry.
2068
- if (_this4.orderCustomerContactRequest === pending) _this4.orderCustomerContactRequest = null;
2157
+ if (_this5.orderCustomerContactRequest === pending) _this5.orderCustomerContactRequest = null;
2069
2158
  console.warn('[BookingTicket] Failed to load saved customer contact information');
2070
2159
  });
2071
2160
  }
@@ -2078,31 +2167,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2078
2167
  }, {
2079
2168
  key: "validateContactInfo",
2080
2169
  value: function () {
2081
- var _validateContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2170
+ var _validateContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2082
2171
  var _this$getTempOrder, _this$getTempOrder2;
2083
2172
  var orderKey, customerId, scope;
2084
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2085
- while (1) switch (_context30.prev = _context30.next) {
2173
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2174
+ while (1) switch (_context32.prev = _context32.next) {
2086
2175
  case 0:
2087
2176
  orderKey = this.getCustomerContactOrderKey();
2088
2177
  customerId = (_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.customer_id;
2089
2178
  scope = this.getCustomerContactScope();
2090
- _context30.next = 5;
2179
+ _context32.next = 5;
2091
2180
  return this.waitForOrderCustomerContactInfo();
2092
2181
  case 5:
2093
2182
  if (!(this.getCustomerContactOrderKey() !== orderKey || ((_this$getTempOrder2 = this.getTempOrder()) === null || _this$getTempOrder2 === void 0 ? void 0 : _this$getTempOrder2.customer_id) !== customerId || this.getCustomerContactScope() !== scope)) {
2094
- _context30.next = 7;
2183
+ _context32.next = 7;
2095
2184
  break;
2096
2185
  }
2097
2186
  throw new Error('The order changed. Please try again.');
2098
2187
  case 7:
2099
- _context30.next = 9;
2188
+ _context32.next = 9;
2100
2189
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "validateContactInfo", this).call(this);
2101
2190
  case 9:
2102
2191
  case "end":
2103
- return _context30.stop();
2192
+ return _context32.stop();
2104
2193
  }
2105
- }, _callee30, this);
2194
+ }, _callee32, this);
2106
2195
  }));
2107
2196
  function validateContactInfo() {
2108
2197
  return _validateContactInfo.apply(this, arguments);
@@ -2135,7 +2224,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2135
2224
  value: function clearOrderCustomer(options) {
2136
2225
  var _discountModule$setOr,
2137
2226
  _discountModule$setDi,
2138
- _this5 = this;
2227
+ _this6 = this;
2228
+ var enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
2229
+ var refreshRevision = enableMemberCartConsistency ? ++this.orderCustomerRefreshRevision : undefined;
2139
2230
  this.orderCustomerContactRequest = null;
2140
2231
  if (!(options !== null && options !== void 0 && options.preserveContactInfo)) this.resetOrderCustomerContactInfo();
2141
2232
  if (!(options !== null && options !== void 0 && options.preserveContactInfo)) this.store.order.updateTempOrderContactsInfo(null);
@@ -2147,19 +2238,25 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2147
2238
  void (discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, []));
2148
2239
  void (discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []));
2149
2240
  this.store.order.applyDiscount();
2150
- void this.store.order.recalculateSummary({
2241
+ var customerOrderKey = enableMemberCartConsistency ? this.getCustomerContactOrderKey() : undefined;
2242
+ var refreshTask = this.store.order.recalculateSummary({
2151
2243
  createIfMissing: true
2152
2244
  }).then(function () {
2153
2245
  var _discountModule$getDi;
2154
- var tempOrder = _this5.store.order.ensureTempOrder();
2155
- _this5.store.order.persistTempOrder();
2156
- return _this5.effectsEmit('onDiscountApplied', {
2246
+ if (enableMemberCartConsistency && (_this6.orderCustomerRefreshRevision !== refreshRevision || _this6.getCustomerContactOrderKey() !== customerOrderKey)) return;
2247
+ var tempOrder = _this6.store.order.ensureTempOrder();
2248
+ _this6.store.order.persistTempOrder();
2249
+ return _this6.effectsEmit('onDiscountApplied', {
2157
2250
  productList: tempOrder.products || [],
2158
2251
  discountList: (discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [],
2159
2252
  selectedDiscountList: tempOrder.discount_list || [],
2160
2253
  tempOrder: tempOrder
2161
2254
  });
2162
- }).catch(function (error) {
2255
+ });
2256
+ if (enableMemberCartConsistency) this.orderCustomerRefreshTask = refreshTask.then(function () {
2257
+ return undefined;
2258
+ });
2259
+ void (enableMemberCartConsistency ? this.orderCustomerRefreshTask : refreshTask).catch(function (error) {
2163
2260
  console.error('Failed to recalculate summary after clearing customer:', error);
2164
2261
  });
2165
2262
  this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), null);
@@ -2177,24 +2274,24 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2177
2274
  }, {
2178
2275
  key: "restoreOrder",
2179
2276
  value: (function () {
2180
- var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2277
+ var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2181
2278
  var _this$store$customer;
2182
2279
  var tempOrder;
2183
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2184
- while (1) switch (_context31.prev = _context31.next) {
2280
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2281
+ while (1) switch (_context33.prev = _context33.next) {
2185
2282
  case 0:
2186
- _context31.next = 2;
2283
+ _context33.next = 2;
2187
2284
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "restoreOrder", this).call(this);
2188
2285
  case 2:
2189
- tempOrder = _context31.sent;
2286
+ tempOrder = _context33.sent;
2190
2287
  this.clearOrderCustomer();
2191
2288
  (_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || _this$store$customer.setSelectedCustomer(null);
2192
- return _context31.abrupt("return", tempOrder);
2289
+ return _context33.abrupt("return", tempOrder);
2193
2290
  case 6:
2194
2291
  case "end":
2195
- return _context31.stop();
2292
+ return _context33.stop();
2196
2293
  }
2197
- }, _callee31, this);
2294
+ }, _callee33, this);
2198
2295
  }));
2199
2296
  function restoreOrder() {
2200
2297
  return _restoreOrder.apply(this, arguments);
@@ -2214,12 +2311,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2214
2311
  }, {
2215
2312
  key: "refreshDiscountConfigAfterOrderCustomerChange",
2216
2313
  value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
2217
- var _this$store$order$get4,
2314
+ var _this$store$order$get6,
2218
2315
  _this$store$order6,
2219
2316
  _this$getOrderIdentit,
2220
- _this6 = this;
2317
+ _this7 = this;
2221
2318
  if (!customerId || customerId === 1) return Promise.resolve();
2222
- var tempOrder = (_this$store$order$get4 = (_this$store$order6 = this.store.order).getTempOrder) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order6);
2319
+ var tempOrder = (_this$store$order$get6 = (_this$store$order6 = this.store.order).getTempOrder) === null || _this$store$order$get6 === void 0 ? void 0 : _this$store$order$get6.call(_this$store$order6);
2223
2320
  var orderIdentity = (_this$getOrderIdentit = this.getOrderIdentity) === null || _this$getOrderIdentit === void 0 ? void 0 : _this$getOrderIdentit.call(this);
2224
2321
  var orderId = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || (orderIdentity === null || orderIdentity === void 0 ? void 0 : orderIdentity.orderId);
2225
2322
  var action = !orderId || String(orderId).startsWith('local_order') ? 'create' : 'edit';
@@ -2229,50 +2326,50 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2229
2326
  return this.orderCustomerDiscountRefreshInFlight;
2230
2327
  }
2231
2328
  var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
2232
- var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32() {
2233
- var _this6$store$order$ge, _this6$store$order, _this6$getOrderIdenti;
2329
+ var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
2330
+ var _this7$store$order$ge, _this7$store$order, _this7$getOrderIdenti;
2234
2331
  var currentCustomer, currentTempOrder, currentOrderIdentity, currentOrderId, currentAction, currentOrderTarget;
2235
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2236
- while (1) switch (_context32.prev = _context32.next) {
2332
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2333
+ while (1) switch (_context34.prev = _context34.next) {
2237
2334
  case 0:
2238
2335
  if (!previousRefresh) {
2239
- _context32.next = 3;
2336
+ _context34.next = 3;
2240
2337
  break;
2241
2338
  }
2242
- _context32.next = 3;
2339
+ _context34.next = 3;
2243
2340
  return previousRefresh.catch(function () {
2244
2341
  return undefined;
2245
2342
  });
2246
2343
  case 3:
2247
- currentCustomer = _this6.store.order.getOrderCustomer();
2344
+ currentCustomer = _this7.store.order.getOrderCustomer();
2248
2345
  if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
2249
- _context32.next = 6;
2346
+ _context34.next = 6;
2250
2347
  break;
2251
2348
  }
2252
- return _context32.abrupt("return");
2349
+ return _context34.abrupt("return");
2253
2350
  case 6:
2254
- currentTempOrder = (_this6$store$order$ge = (_this6$store$order = _this6.store.order).getTempOrder) === null || _this6$store$order$ge === void 0 ? void 0 : _this6$store$order$ge.call(_this6$store$order);
2255
- currentOrderIdentity = (_this6$getOrderIdenti = _this6.getOrderIdentity) === null || _this6$getOrderIdenti === void 0 ? void 0 : _this6$getOrderIdenti.call(_this6);
2351
+ currentTempOrder = (_this7$store$order$ge = (_this7$store$order = _this7.store.order).getTempOrder) === null || _this7$store$order$ge === void 0 ? void 0 : _this7$store$order$ge.call(_this7$store$order);
2352
+ currentOrderIdentity = (_this7$getOrderIdenti = _this7.getOrderIdentity) === null || _this7$getOrderIdenti === void 0 ? void 0 : _this7$getOrderIdenti.call(_this7);
2256
2353
  currentOrderId = (currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.order_id) || (currentOrderIdentity === null || currentOrderIdentity === void 0 ? void 0 : currentOrderIdentity.orderId);
2257
2354
  currentAction = !currentOrderId || String(currentOrderId).startsWith('local_order') ? 'create' : 'edit';
2258
2355
  currentOrderTarget = currentOrderId ? "order:".concat(String(currentOrderId)) : "external:".concat(String((currentTempOrder === null || currentTempOrder === void 0 ? void 0 : currentTempOrder.external_sale_number) || (currentOrderIdentity === null || currentOrderIdentity === void 0 ? void 0 : currentOrderIdentity.externalSaleNumber) || (currentOrderIdentity === null || currentOrderIdentity === void 0 ? void 0 : currentOrderIdentity.localId) || 'new'));
2259
2356
  if (!("".concat(customerId, ":").concat(currentAction, ":").concat(currentOrderTarget) !== refreshTarget)) {
2260
- _context32.next = 13;
2357
+ _context34.next = 13;
2261
2358
  break;
2262
2359
  }
2263
- return _context32.abrupt("return");
2360
+ return _context34.abrupt("return");
2264
2361
  case 13:
2265
- _context32.next = 15;
2266
- return _this6.loadDiscountConfig({
2362
+ _context34.next = 15;
2363
+ return _this7.loadDiscountConfig({
2267
2364
  customerId: customerId,
2268
2365
  action: action,
2269
2366
  force: true
2270
2367
  });
2271
2368
  case 15:
2272
2369
  case "end":
2273
- return _context32.stop();
2370
+ return _context34.stop();
2274
2371
  }
2275
- }, _callee32);
2372
+ }, _callee34);
2276
2373
  }))();
2277
2374
  this.orderCustomerDiscountRefreshInFlight = refreshTask;
2278
2375
  this.orderCustomerDiscountRefreshCustomerId = customerId;
@@ -2280,10 +2377,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2280
2377
  refreshTask.catch(function (error) {
2281
2378
  console.error('Failed to load discount config after customer change:', error);
2282
2379
  }).finally(function () {
2283
- if (_this6.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
2284
- _this6.orderCustomerDiscountRefreshInFlight = null;
2285
- _this6.orderCustomerDiscountRefreshCustomerId = null;
2286
- _this6.orderCustomerDiscountRefreshTarget = null;
2380
+ if (_this7.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
2381
+ _this7.orderCustomerDiscountRefreshInFlight = null;
2382
+ _this7.orderCustomerDiscountRefreshCustomerId = null;
2383
+ _this7.orderCustomerDiscountRefreshTarget = null;
2287
2384
  });
2288
2385
  return refreshTask;
2289
2386
  }
@@ -2292,31 +2389,62 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2292
2389
  value: function waitForOrderCustomerPromotionRefresh() {
2293
2390
  return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
2294
2391
  }
2392
+
2393
+ /** Wait before reading cart rows: member coupons can split or consolidate them. */
2394
+ }, {
2395
+ key: "waitForOrderCustomerRefresh",
2396
+ value: (function () {
2397
+ var _waitForOrderCustomerRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2398
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2399
+ while (1) switch (_context35.prev = _context35.next) {
2400
+ case 0:
2401
+ if (this.isMemberCartConsistencyEnabled()) {
2402
+ _context35.next = 2;
2403
+ break;
2404
+ }
2405
+ return _context35.abrupt("return");
2406
+ case 2:
2407
+ _context35.next = 4;
2408
+ return Promise.resolve();
2409
+ case 4:
2410
+ _context35.next = 6;
2411
+ return this.orderCustomerRefreshTask;
2412
+ case 6:
2413
+ case "end":
2414
+ return _context35.stop();
2415
+ }
2416
+ }, _callee35, this);
2417
+ }));
2418
+ function waitForOrderCustomerRefresh() {
2419
+ return _waitForOrderCustomerRefresh.apply(this, arguments);
2420
+ }
2421
+ return waitForOrderCustomerRefresh;
2422
+ }())
2295
2423
  }, {
2296
2424
  key: "prepareProductPriceQueryContext",
2297
2425
  value: function () {
2298
- var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(customerId) {
2426
+ var _prepareProductPriceQueryContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(customerId) {
2299
2427
  var normalizedCustomerId, refreshTask, shouldWait;
2300
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2301
- while (1) switch (_context33.prev = _context33.next) {
2428
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2429
+ while (1) switch (_context36.prev = _context36.next) {
2302
2430
  case 0:
2303
- _context33.next = 2;
2431
+ _context36.next = 2;
2304
2432
  return Promise.resolve();
2305
2433
  case 2:
2306
2434
  normalizedCustomerId = Number(customerId || 0);
2307
2435
  refreshTask = this.orderCustomerDiscountRefreshInFlight;
2308
2436
  shouldWait = normalizedCustomerId > 1 && this.orderCustomerDiscountRefreshCustomerId === normalizedCustomerId && Boolean(refreshTask);
2309
2437
  if (!(shouldWait && refreshTask)) {
2310
- _context33.next = 8;
2438
+ _context36.next = 8;
2311
2439
  break;
2312
2440
  }
2313
- _context33.next = 8;
2441
+ _context36.next = 8;
2314
2442
  return refreshTask;
2315
2443
  case 8:
2316
2444
  case "end":
2317
- return _context33.stop();
2445
+ return _context36.stop();
2318
2446
  }
2319
- }, _callee33, this);
2447
+ }, _callee36, this);
2320
2448
  }));
2321
2449
  function prepareProductPriceQueryContext(_x19) {
2322
2450
  return _prepareProductPriceQueryContext.apply(this, arguments);
@@ -2371,27 +2499,27 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2371
2499
  }, {
2372
2500
  key: "changeCustomerPage",
2373
2501
  value: (function () {
2374
- var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(page, pageSize) {
2502
+ var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(page, pageSize) {
2375
2503
  var _result5;
2376
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2377
- while (1) switch (_context34.prev = _context34.next) {
2504
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2505
+ while (1) switch (_context37.prev = _context37.next) {
2378
2506
  case 0:
2379
- _context34.prev = 0;
2380
- _context34.next = 3;
2507
+ _context37.prev = 0;
2508
+ _context37.next = 3;
2381
2509
  return this.store.customer.changeCustomerPage(page, pageSize);
2382
2510
  case 3:
2383
- _result5 = _context34.sent;
2384
- return _context34.abrupt("return", _result5);
2511
+ _result5 = _context37.sent;
2512
+ return _context37.abrupt("return", _result5);
2385
2513
  case 7:
2386
- _context34.prev = 7;
2387
- _context34.t0 = _context34["catch"](0);
2388
- console.error('Failed to change customer page:', _context34.t0);
2389
- throw _context34.t0;
2514
+ _context37.prev = 7;
2515
+ _context37.t0 = _context37["catch"](0);
2516
+ console.error('Failed to change customer page:', _context37.t0);
2517
+ throw _context37.t0;
2390
2518
  case 11:
2391
2519
  case "end":
2392
- return _context34.stop();
2520
+ return _context37.stop();
2393
2521
  }
2394
- }, _callee34, this, [[0, 7]]);
2522
+ }, _callee37, this, [[0, 7]]);
2395
2523
  }));
2396
2524
  function changeCustomerPage(_x20, _x21) {
2397
2525
  return _changeCustomerPage.apply(this, arguments);
@@ -2406,28 +2534,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2406
2534
  }, {
2407
2535
  key: "loadMoreCustomers",
2408
2536
  value: (function () {
2409
- var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
2537
+ var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
2410
2538
  var _result6;
2411
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2412
- while (1) switch (_context35.prev = _context35.next) {
2539
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2540
+ while (1) switch (_context38.prev = _context38.next) {
2413
2541
  case 0:
2414
- _context35.prev = 0;
2415
- _context35.next = 3;
2542
+ _context38.prev = 0;
2543
+ _context38.next = 3;
2416
2544
  return this.store.customer.loadMoreCustomers();
2417
2545
  case 3:
2418
- _result6 = _context35.sent;
2546
+ _result6 = _context38.sent;
2419
2547
  this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result6);
2420
- return _context35.abrupt("return", _result6);
2548
+ return _context38.abrupt("return", _result6);
2421
2549
  case 8:
2422
- _context35.prev = 8;
2423
- _context35.t0 = _context35["catch"](0);
2424
- console.error('Failed to load more customers:', _context35.t0);
2425
- throw _context35.t0;
2550
+ _context38.prev = 8;
2551
+ _context38.t0 = _context38["catch"](0);
2552
+ console.error('Failed to load more customers:', _context38.t0);
2553
+ throw _context38.t0;
2426
2554
  case 12:
2427
2555
  case "end":
2428
- return _context35.stop();
2556
+ return _context38.stop();
2429
2557
  }
2430
- }, _callee35, this, [[0, 8]]);
2558
+ }, _callee38, this, [[0, 8]]);
2431
2559
  }));
2432
2560
  function loadMoreCustomers() {
2433
2561
  return _loadMoreCustomers.apply(this, arguments);
@@ -2443,31 +2571,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2443
2571
  }, {
2444
2572
  key: "resetAndLoadCustomers",
2445
2573
  value: (function () {
2446
- var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
2574
+ var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
2447
2575
  var params,
2448
2576
  _result7,
2449
- _args36 = arguments;
2450
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2451
- while (1) switch (_context36.prev = _context36.next) {
2577
+ _args39 = arguments;
2578
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2579
+ while (1) switch (_context39.prev = _context39.next) {
2452
2580
  case 0:
2453
- params = _args36.length > 0 && _args36[0] !== undefined ? _args36[0] : {};
2454
- _context36.prev = 1;
2455
- _context36.next = 4;
2581
+ params = _args39.length > 0 && _args39[0] !== undefined ? _args39[0] : {};
2582
+ _context39.prev = 1;
2583
+ _context39.next = 4;
2456
2584
  return this.store.customer.resetAndLoadCustomers(params);
2457
2585
  case 4:
2458
- _result7 = _context36.sent;
2586
+ _result7 = _context39.sent;
2459
2587
  this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result7);
2460
- return _context36.abrupt("return", _result7);
2588
+ return _context39.abrupt("return", _result7);
2461
2589
  case 9:
2462
- _context36.prev = 9;
2463
- _context36.t0 = _context36["catch"](1);
2464
- console.error('Failed to reset and load customers:', _context36.t0);
2465
- throw _context36.t0;
2590
+ _context39.prev = 9;
2591
+ _context39.t0 = _context39["catch"](1);
2592
+ console.error('Failed to reset and load customers:', _context39.t0);
2593
+ throw _context39.t0;
2466
2594
  case 13:
2467
2595
  case "end":
2468
- return _context36.stop();
2596
+ return _context39.stop();
2469
2597
  }
2470
- }, _callee36, this, [[1, 9]]);
2598
+ }, _callee39, this, [[1, 9]]);
2471
2599
  }));
2472
2600
  function resetAndLoadCustomers() {
2473
2601
  return _resetAndLoadCustomers.apply(this, arguments);
@@ -2512,9 +2640,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2512
2640
  }, {
2513
2641
  key: "scanGlobalListener",
2514
2642
  value: function scanGlobalListener(callback) {
2515
- var _this7 = this;
2643
+ var _this8 = this;
2516
2644
  var localSearch = function localSearch(v) {
2517
- return _this7.store.products.findProductsByCodeOrBarcode(v);
2645
+ return _this8.store.products.findProductsByCodeOrBarcode(v);
2518
2646
  };
2519
2647
  var scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
2520
2648
  var safeCallback = function safeCallback(d) {
@@ -2628,16 +2756,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2628
2756
  }, {
2629
2757
  key: "getOtherParams",
2630
2758
  value: (function () {
2631
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
2632
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2633
- while (1) switch (_context37.prev = _context37.next) {
2759
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
2760
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
2761
+ while (1) switch (_context40.prev = _context40.next) {
2634
2762
  case 0:
2635
- return _context37.abrupt("return", this.otherParams);
2763
+ return _context40.abrupt("return", this.otherParams);
2636
2764
  case 1:
2637
2765
  case "end":
2638
- return _context37.stop();
2766
+ return _context40.stop();
2639
2767
  }
2640
- }, _callee37, this);
2768
+ }, _callee40, this);
2641
2769
  }));
2642
2770
  function getOtherParams() {
2643
2771
  return _getOtherParams.apply(this, arguments);
@@ -2747,7 +2875,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2747
2875
  var _extra$date,
2748
2876
  _extra$presetStartTim,
2749
2877
  _this$getOrderSession,
2750
- _this8 = this,
2878
+ _this9 = this,
2751
2879
  _this$otherParams10;
2752
2880
  var state = this.store.bookingContext.getState();
2753
2881
  var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
@@ -2760,7 +2888,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2760
2888
  }, extra || {}), {}, {
2761
2889
  orderSessionId: (_this$getOrderSession = this.getOrderSessionId()) !== null && _this$getOrderSession !== void 0 ? _this$getOrderSession : undefined,
2762
2890
  isOrderSessionCurrent: function isOrderSessionCurrent(sessionId) {
2763
- return _this8.isOrderSessionCurrent(sessionId);
2891
+ return _this9.isOrderSessionCurrent(sessionId);
2764
2892
  },
2765
2893
  platform: String(((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform) || '').trim().toLowerCase()
2766
2894
  });
@@ -2858,17 +2986,17 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2858
2986
  key: "buildAddProductCtx",
2859
2987
  value: function buildAddProductCtx(extra) {
2860
2988
  var _extra$date2,
2861
- _ref14,
2989
+ _ref15,
2862
2990
  _this$getOrderCustome4,
2863
2991
  _this$getOrderCustome5,
2864
- _this$store$order$get5,
2992
+ _this$store$order$get7,
2865
2993
  _extra$presetStartTim2,
2866
2994
  _this$getOrderSession2,
2867
- _this9 = this,
2995
+ _this10 = this,
2868
2996
  _this$otherParams11;
2869
2997
  var bookingContextState = this.store.bookingContext.getState();
2870
2998
  var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
2871
- var orderCustomerId = (_ref14 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get5 = this.store.order.getTempOrder()) === null || _this$store$order$get5 === void 0 ? void 0 : _this$store$order$get5.customer_id) !== null && _ref14 !== void 0 ? _ref14 : undefined;
2999
+ var orderCustomerId = (_ref15 = (_this$getOrderCustome4 = (_this$getOrderCustome5 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome5 === void 0 ? void 0 : _this$getOrderCustome5.id) !== null && _this$getOrderCustome4 !== void 0 ? _this$getOrderCustome4 : (_this$store$order$get7 = this.store.order.getTempOrder()) === null || _this$store$order$get7 === void 0 ? void 0 : _this$store$order$get7.customer_id) !== null && _ref15 !== void 0 ? _ref15 : undefined;
2872
3000
  return _objectSpread(_objectSpread({
2873
3001
  bookingConfig: bookingContextState.bookingConfig,
2874
3002
  resourcesOrigin: bookingContextState.resourcesOrigin,
@@ -2880,7 +3008,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2880
3008
  channel: this.getSubmitOrderSalesChannel(),
2881
3009
  orderSessionId: (_this$getOrderSession2 = this.getOrderSessionId()) !== null && _this$getOrderSession2 !== void 0 ? _this$getOrderSession2 : undefined,
2882
3010
  isOrderSessionCurrent: function isOrderSessionCurrent(sessionId) {
2883
- return _this9.isOrderSessionCurrent(sessionId);
3011
+ return _this10.isOrderSessionCurrent(sessionId);
2884
3012
  },
2885
3013
  platform: String(((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.platform) || '').trim().toLowerCase()
2886
3014
  });
@@ -2984,16 +3112,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
2984
3112
  }, {
2985
3113
  key: "updateProductInOrder",
2986
3114
  value: (function () {
2987
- var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
2988
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2989
- while (1) switch (_context38.prev = _context38.next) {
3115
+ var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3116
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3117
+ while (1) switch (_context41.prev = _context41.next) {
2990
3118
  case 0:
2991
- return _context38.abrupt("return", this.updateOrderProduct(params));
3119
+ return _context41.abrupt("return", this.updateOrderProduct(params));
2992
3120
  case 1:
2993
3121
  case "end":
2994
- return _context38.stop();
3122
+ return _context41.stop();
2995
3123
  }
2996
- }, _callee38, this);
3124
+ }, _callee41, this);
2997
3125
  }));
2998
3126
  function updateProductInOrder(_x22) {
2999
3127
  return _updateProductInOrder.apply(this, arguments);
@@ -3017,24 +3145,24 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3017
3145
  }, {
3018
3146
  key: "handleGlobalScanCode",
3019
3147
  value: (function () {
3020
- var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(code, bridge) {
3021
- var _this10 = this;
3148
+ var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(code, bridge) {
3149
+ var _this11 = this;
3022
3150
  var trimmed, _bridge$onNotify, _bridge$refresh, beforeScanCommit, beforeScanDialog, guardCallback, guardedBridge, _promotion$isAccepted, promotion, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, host, _result8, _bridge$onNotify3, _bridge$isCurrent;
3023
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3024
- while (1) switch (_context40.prev = _context40.next) {
3151
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3152
+ while (1) switch (_context43.prev = _context43.next) {
3025
3153
  case 0:
3026
3154
  trimmed = typeof code === 'string' ? code.trim() : '';
3027
3155
  if (trimmed) {
3028
- _context40.next = 4;
3156
+ _context43.next = 4;
3029
3157
  break;
3030
3158
  }
3031
3159
  bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
3032
- return _context40.abrupt("return", {
3160
+ return _context43.abrupt("return", {
3033
3161
  status: 'failed',
3034
3162
  reason: 'empty_code'
3035
3163
  });
3036
3164
  case 4:
3037
- _context40.prev = 4;
3165
+ _context43.prev = 4;
3038
3166
  // Capture before lookup/UI awaits, so a result cannot land in a new cart.
3039
3167
  // Unscoped POS Order modules return a no-op guard.
3040
3168
  beforeScanCommit = this.store.order.createCartIntentCommitGuard('add_product');
@@ -3061,23 +3189,23 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3061
3189
  } : undefined
3062
3190
  }) : undefined;
3063
3191
  if (!((guardedBridge === null || guardedBridge === void 0 ? void 0 : guardedBridge.scanScope) === 'product-voucher')) {
3064
- _context40.next = 16;
3192
+ _context43.next = 16;
3065
3193
  break;
3066
3194
  }
3067
3195
  if (guardedBridge.applyPromotionCode) {
3068
- _context40.next = 12;
3196
+ _context43.next = 12;
3069
3197
  break;
3070
3198
  }
3071
- return _context40.abrupt("return", {
3199
+ return _context43.abrupt("return", {
3072
3200
  status: 'failed',
3073
3201
  reason: 'no_bridge'
3074
3202
  });
3075
3203
  case 12:
3076
- _context40.next = 14;
3204
+ _context43.next = 14;
3077
3205
  return guardedBridge.applyPromotionCode(trimmed);
3078
3206
  case 14:
3079
- promotion = _context40.sent;
3080
- return _context40.abrupt("return", ((_promotion$isAccepted = promotion.isAccepted) !== null && _promotion$isAccepted !== void 0 ? _promotion$isAccepted : promotion.isAvailable) ? {
3207
+ promotion = _context43.sent;
3208
+ return _context43.abrupt("return", ((_promotion$isAccepted = promotion.isAccepted) !== null && _promotion$isAccepted !== void 0 ? _promotion$isAccepted : promotion.isAvailable) ? {
3081
3209
  status: 'success',
3082
3210
  kind: 'promotion'
3083
3211
  } : {
@@ -3086,23 +3214,23 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3086
3214
  });
3087
3215
  case 16:
3088
3216
  localSearch = function localSearch(v) {
3089
- return _this10.store.products.findProductsByCodeOrBarcode(v);
3217
+ return _this11.store.products.findProductsByCodeOrBarcode(v);
3090
3218
  };
3091
3219
  scanCallback = handleGlobalScan(this.request, localSearch, this.getSubmitOrderSalesChannel());
3092
- _context40.next = 20;
3220
+ _context43.next = 20;
3093
3221
  return scanCallback({
3094
3222
  type: 'nativeScanner',
3095
3223
  value: trimmed
3096
3224
  });
3097
3225
  case 20:
3098
- raw = _context40.sent;
3226
+ raw = _context43.sent;
3099
3227
  formatted = formatGlobalScanResult(raw, trimmed);
3100
3228
  if (formatted) {
3101
- _context40.next = 25;
3229
+ _context43.next = 25;
3102
3230
  break;
3103
3231
  }
3104
3232
  bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
3105
- return _context40.abrupt("return", {
3233
+ return _context43.abrupt("return", {
3106
3234
  status: 'failed',
3107
3235
  reason: 'not_found'
3108
3236
  });
@@ -3110,73 +3238,73 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3110
3238
  host = {
3111
3239
  setOrderCustomer: function setOrderCustomer(customer) {
3112
3240
  beforeScanCommit();
3113
- _this10.setOrderCustomer(customer);
3241
+ _this11.setOrderCustomer(customer);
3114
3242
  },
3115
3243
  getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
3116
- return _this10.getOrderCustomerSnapshot();
3244
+ return _this11.getOrderCustomerSnapshot();
3117
3245
  },
3118
3246
  resolveCustomerById: function resolveCustomerById(customerId) {
3119
- return _this10.resolveCustomerById(customerId);
3247
+ return _this11.resolveCustomerById(customerId);
3120
3248
  },
3121
3249
  getBusinessCode: function getBusinessCode() {
3122
- var _this10$otherParams;
3123
- return (_this10$otherParams = _this10.otherParams) === null || _this10$otherParams === void 0 ? void 0 : _this10$otherParams.businessCode;
3250
+ var _this11$otherParams;
3251
+ return (_this11$otherParams = _this11.otherParams) === null || _this11$otherParams === void 0 ? void 0 : _this11$otherParams.businessCode;
3124
3252
  },
3125
3253
  buildAddProductCtx: function buildAddProductCtx(extra) {
3126
- return _this10.buildAddProductCtx(extra);
3254
+ return _this11.buildAddProductCtx(extra);
3127
3255
  },
3128
3256
  decideAddProduct: function decideAddProduct(item, options) {
3129
- return _this10.decideAddProduct(item, options);
3257
+ return _this11.decideAddProduct(item, options);
3130
3258
  },
3131
3259
  decideAfterDetail: function decideAfterDetail(cacheItem, options) {
3132
- return _this10.decideAfterDetail(cacheItem, options);
3260
+ return _this11.decideAfterDetail(cacheItem, options);
3133
3261
  },
3134
3262
  transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
3135
- return _this10.transformDetailToProductAndBooking(input);
3263
+ return _this11.transformDetailToProductAndBooking(input);
3136
3264
  },
3137
3265
  addProductToOrder: function addProductToOrder(product, booking) {
3138
3266
  beforeScanCommit();
3139
- return _this10.addProductToOrder(product, booking);
3267
+ return _this11.addProductToOrder(product, booking);
3140
3268
  },
3141
3269
  refreshWalletAssets: function refreshWalletAssets(params) {
3142
- return _this10.refreshWalletAssets(params);
3270
+ return _this11.refreshWalletAssets(params);
3143
3271
  },
3144
3272
  scanWalletAsset: function scanWalletAsset(scanCode) {
3145
3273
  beforeScanCommit();
3146
- return _this10.scanWalletAsset(scanCode);
3274
+ return _this11.scanWalletAsset(scanCode);
3147
3275
  }
3148
3276
  };
3149
3277
  if (!((guardedBridge === null || guardedBridge === void 0 ? void 0 : guardedBridge.scanScope) === 'product-voucher-collection')) {
3150
- _context40.next = 32;
3278
+ _context43.next = 32;
3151
3279
  break;
3152
3280
  }
3153
- _context40.next = 29;
3281
+ _context43.next = 29;
3154
3282
  return applyProductVoucherCollectionScan(_objectSpread(_objectSpread({}, host), {}, {
3155
3283
  loadCustomerDiscounts: function () {
3156
- var _loadCustomerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
3157
- var _this10$getOrderCusto;
3284
+ var _loadCustomerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3285
+ var _this11$getOrderCusto;
3158
3286
  var customerId;
3159
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
3160
- while (1) switch (_context39.prev = _context39.next) {
3287
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3288
+ while (1) switch (_context42.prev = _context42.next) {
3161
3289
  case 0:
3162
3290
  beforeScanCommit();
3163
- customerId = Number(((_this10$getOrderCusto = _this10.getOrderCustomer()) === null || _this10$getOrderCusto === void 0 ? void 0 : _this10$getOrderCusto.customer_id) || 0);
3291
+ customerId = Number(((_this11$getOrderCusto = _this11.getOrderCustomer()) === null || _this11$getOrderCusto === void 0 ? void 0 : _this11$getOrderCusto.customer_id) || 0);
3164
3292
  if (!(customerId <= 1)) {
3165
- _context39.next = 4;
3293
+ _context42.next = 4;
3166
3294
  break;
3167
3295
  }
3168
- return _context39.abrupt("return", []);
3296
+ return _context42.abrupt("return", []);
3169
3297
  case 4:
3170
- _context39.next = 6;
3171
- return _this10.refreshDiscountConfigAfterOrderCustomerChange(customerId);
3298
+ _context42.next = 6;
3299
+ return _this11.refreshDiscountConfigAfterOrderCustomerChange(customerId);
3172
3300
  case 6:
3173
3301
  beforeScanCommit();
3174
- return _context39.abrupt("return", _this10.getDiscountList());
3302
+ return _context42.abrupt("return", _this11.getDiscountList());
3175
3303
  case 8:
3176
3304
  case "end":
3177
- return _context39.stop();
3305
+ return _context42.stop();
3178
3306
  }
3179
- }, _callee39);
3307
+ }, _callee42);
3180
3308
  }));
3181
3309
  function loadCustomerDiscounts() {
3182
3310
  return _loadCustomerDiscounts.apply(this, arguments);
@@ -3185,49 +3313,49 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3185
3313
  }()
3186
3314
  }), formatted, guardedBridge);
3187
3315
  case 29:
3188
- _context40.t0 = _context40.sent;
3189
- _context40.next = 35;
3316
+ _context43.t0 = _context43.sent;
3317
+ _context43.next = 35;
3190
3318
  break;
3191
3319
  case 32:
3192
- _context40.next = 34;
3320
+ _context43.next = 34;
3193
3321
  return applyGlobalScan(host, formatted, guardedBridge);
3194
3322
  case 34:
3195
- _context40.t0 = _context40.sent;
3323
+ _context43.t0 = _context43.sent;
3196
3324
  case 35:
3197
- _result8 = _context40.t0;
3325
+ _result8 = _context43.t0;
3198
3326
  bridge === null || bridge === void 0 || (_bridge$refresh = bridge.refresh) === null || _bridge$refresh === void 0 || _bridge$refresh.call(bridge);
3199
- return _context40.abrupt("return", _result8);
3327
+ return _context43.abrupt("return", _result8);
3200
3328
  case 40:
3201
- _context40.prev = 40;
3202
- _context40.t1 = _context40["catch"](4);
3329
+ _context43.prev = 40;
3330
+ _context43.t1 = _context43["catch"](4);
3203
3331
  if (!((bridge === null || bridge === void 0 ? void 0 : bridge.scanScope) === 'product-voucher-collection')) {
3204
- _context40.next = 46;
3332
+ _context43.next = 46;
3205
3333
  break;
3206
3334
  }
3207
3335
  if (!(((_bridge$isCurrent = bridge.isCurrent) === null || _bridge$isCurrent === void 0 ? void 0 : _bridge$isCurrent.call(bridge)) === false)) {
3208
- _context40.next = 45;
3336
+ _context43.next = 45;
3209
3337
  break;
3210
3338
  }
3211
- return _context40.abrupt("return", {
3339
+ return _context43.abrupt("return", {
3212
3340
  status: 'cancelled'
3213
3341
  });
3214
3342
  case 45:
3215
- return _context40.abrupt("return", {
3343
+ return _context43.abrupt("return", {
3216
3344
  status: 'failed',
3217
3345
  reason: 'entry_resolution_failed'
3218
3346
  });
3219
3347
  case 46:
3220
- console.error('[BookingTicket] handleGlobalScanCode failed', _context40.t1);
3348
+ console.error('[BookingTicket] handleGlobalScanCode failed', _context43.t1);
3221
3349
  bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
3222
- return _context40.abrupt("return", {
3350
+ return _context43.abrupt("return", {
3223
3351
  status: 'failed',
3224
3352
  reason: 'not_found'
3225
3353
  });
3226
3354
  case 49:
3227
3355
  case "end":
3228
- return _context40.stop();
3356
+ return _context43.stop();
3229
3357
  }
3230
- }, _callee40, this, [[4, 40]]);
3358
+ }, _callee43, this, [[4, 40]]);
3231
3359
  }));
3232
3360
  function handleGlobalScanCode(_x23, _x24) {
3233
3361
  return _handleGlobalScanCode.apply(this, arguments);
@@ -3237,37 +3365,37 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3237
3365
  }, {
3238
3366
  key: "getGlobalScanCodeType",
3239
3367
  value: (function () {
3240
- var _getGlobalScanCodeType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(code) {
3241
- var _this11 = this,
3368
+ var _getGlobalScanCodeType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(code) {
3369
+ var _this12 = this,
3242
3370
  _formatGlobalScanResu,
3243
3371
  _formatGlobalScanResu2;
3244
3372
  var trimmed, scan, raw;
3245
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3246
- while (1) switch (_context41.prev = _context41.next) {
3373
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3374
+ while (1) switch (_context44.prev = _context44.next) {
3247
3375
  case 0:
3248
3376
  trimmed = typeof code === 'string' ? code.trim() : '';
3249
3377
  if (trimmed) {
3250
- _context41.next = 3;
3378
+ _context44.next = 3;
3251
3379
  break;
3252
3380
  }
3253
- return _context41.abrupt("return", null);
3381
+ return _context44.abrupt("return", null);
3254
3382
  case 3:
3255
3383
  scan = handleGlobalScan(this.request, function (value) {
3256
- return _this11.store.products.findProductsByCodeOrBarcode(value);
3384
+ return _this12.store.products.findProductsByCodeOrBarcode(value);
3257
3385
  }, this.getSubmitOrderSalesChannel());
3258
- _context41.next = 6;
3386
+ _context44.next = 6;
3259
3387
  return scan({
3260
3388
  type: 'nativeScanner',
3261
3389
  value: trimmed
3262
3390
  });
3263
3391
  case 6:
3264
- raw = _context41.sent;
3265
- return _context41.abrupt("return", (_formatGlobalScanResu = (_formatGlobalScanResu2 = formatGlobalScanResult(raw, trimmed)) === null || _formatGlobalScanResu2 === void 0 ? void 0 : _formatGlobalScanResu2.searchType) !== null && _formatGlobalScanResu !== void 0 ? _formatGlobalScanResu : null);
3392
+ raw = _context44.sent;
3393
+ return _context44.abrupt("return", (_formatGlobalScanResu = (_formatGlobalScanResu2 = formatGlobalScanResult(raw, trimmed)) === null || _formatGlobalScanResu2 === void 0 ? void 0 : _formatGlobalScanResu2.searchType) !== null && _formatGlobalScanResu !== void 0 ? _formatGlobalScanResu : null);
3266
3394
  case 8:
3267
3395
  case "end":
3268
- return _context41.stop();
3396
+ return _context44.stop();
3269
3397
  }
3270
- }, _callee41, this);
3398
+ }, _callee44, this);
3271
3399
  }));
3272
3400
  function getGlobalScanCodeType(_x25) {
3273
3401
  return _getGlobalScanCodeType.apply(this, arguments);
@@ -3289,7 +3417,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3289
3417
  }, {
3290
3418
  key: "buildAddTimeOrderLine",
3291
3419
  value: function buildAddTimeOrderLine(input, bookingUid) {
3292
- var _input$num, _product$id, _product$product_id, _ref15, _product$product_vari, _ref16, _product$variant_id, _product$original_pri, _ref17, _ref18, _product$option, _product$product_sku, _ref19, _ref20, _product$bundle, _product$id2;
3420
+ var _input$num, _product$id, _product$product_id, _ref16, _product$product_vari, _ref17, _product$variant_id, _product$original_pri, _ref18, _ref19, _product$option, _product$product_sku, _ref20, _ref21, _product$bundle, _product$id2;
3293
3421
  var product = input === null || input === void 0 ? void 0 : input.product;
3294
3422
  if (!product || _typeof(product) !== 'object') {
3295
3423
  throw new Error('[BookingTicket] addAddTimeProductToBooking: product 不能为空');
@@ -3300,8 +3428,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3300
3428
  var payload = {
3301
3429
  id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id,
3302
3430
  product_id: (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id,
3303
- product_variant_id: (_ref15 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id) !== null && _ref15 !== void 0 ? _ref15 : 0,
3304
- variant_id: (_ref16 = (_product$variant_id = product.variant_id) !== null && _product$variant_id !== void 0 ? _product$variant_id : product.product_variant_id) !== null && _ref16 !== void 0 ? _ref16 : 0,
3431
+ product_variant_id: (_ref16 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id) !== null && _ref16 !== void 0 ? _ref16 : 0,
3432
+ variant_id: (_ref17 = (_product$variant_id = product.variant_id) !== null && _product$variant_id !== void 0 ? _product$variant_id : product.product_variant_id) !== null && _ref17 !== void 0 ? _ref17 : 0,
3305
3433
  quantity: quantity,
3306
3434
  num: quantity,
3307
3435
  price: price,
@@ -3310,8 +3438,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3310
3438
  line_total: price,
3311
3439
  total: price,
3312
3440
  product_sku: product.product_sku,
3313
- option: (_ref17 = (_ref18 = (_product$option = product.option) !== null && _product$option !== void 0 ? _product$option : product.options) !== null && _ref18 !== void 0 ? _ref18 : (_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) !== null && _ref17 !== void 0 ? _ref17 : [],
3314
- bundle: (_ref19 = (_ref20 = (_product$bundle = product.bundle) !== null && _product$bundle !== void 0 ? _product$bundle : product.bundles) !== null && _ref20 !== void 0 ? _ref20 : product.product_bundle) !== null && _ref19 !== void 0 ? _ref19 : []
3441
+ option: (_ref18 = (_ref19 = (_product$option = product.option) !== null && _product$option !== void 0 ? _product$option : product.options) !== null && _ref19 !== void 0 ? _ref19 : (_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) !== null && _ref18 !== void 0 ? _ref18 : [],
3442
+ bundle: (_ref20 = (_ref21 = (_product$bundle = product.bundle) !== null && _product$bundle !== void 0 ? _product$bundle : product.bundles) !== null && _ref21 !== void 0 ? _ref21 : product.product_bundle) !== null && _ref20 !== void 0 ? _ref20 : []
3315
3443
  };
3316
3444
  var orderLine = this.transformBaseProductToOrderProduct({
3317
3445
  payload: payload,
@@ -3351,11 +3479,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3351
3479
  }, {
3352
3480
  key: "addAddTimeProductToBooking",
3353
3481
  value: (function () {
3354
- var _addAddTimeProductToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(input) {
3355
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3356
- while (1) switch (_context42.prev = _context42.next) {
3482
+ var _addAddTimeProductToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(input) {
3483
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3484
+ while (1) switch (_context45.prev = _context45.next) {
3357
3485
  case 0:
3358
- return _context42.abrupt("return", this.addAddTimeProductsToBooking({
3486
+ return _context45.abrupt("return", this.addAddTimeProductsToBooking({
3359
3487
  booking: input.booking,
3360
3488
  products: [input],
3361
3489
  coveredMinutes: input.coveredMinutes,
@@ -3363,9 +3491,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3363
3491
  }));
3364
3492
  case 1:
3365
3493
  case "end":
3366
- return _context42.stop();
3494
+ return _context45.stop();
3367
3495
  }
3368
- }, _callee42, this);
3496
+ }, _callee45, this);
3369
3497
  }));
3370
3498
  function addAddTimeProductToBooking(_x26) {
3371
3499
  return _addAddTimeProductToBooking.apply(this, arguments);
@@ -3385,27 +3513,27 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3385
3513
  }, {
3386
3514
  key: "addAddTimeProductsToBooking",
3387
3515
  value: (function () {
3388
- var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(input) {
3389
- var _this12 = this,
3516
+ var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(input) {
3517
+ var _this13 = this,
3390
3518
  _input$bookingPatch;
3391
3519
  var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator2, _step2, line;
3392
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3393
- while (1) switch (_context43.prev = _context43.next) {
3520
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3521
+ while (1) switch (_context46.prev = _context46.next) {
3394
3522
  case 0:
3395
3523
  bookingUid = resolveBookingUidForAddTime(input === null || input === void 0 ? void 0 : input.booking);
3396
3524
  if (bookingUid) {
3397
- _context43.next = 3;
3525
+ _context46.next = 3;
3398
3526
  break;
3399
3527
  }
3400
3528
  throw new Error('[BookingTicket] addAddTimeProductToBooking: booking.metadata.unique_identification_number 缺失');
3401
3529
  case 3:
3402
3530
  orderLines = (input.products || []).map(function (line) {
3403
3531
  return {
3404
- product: _this12.buildAddTimeOrderLine(line, bookingUid)
3532
+ product: _this13.buildAddTimeOrderLine(line, bookingUid)
3405
3533
  };
3406
3534
  });
3407
3535
  if (this.store.order) {
3408
- _context43.next = 6;
3536
+ _context46.next = 6;
3409
3537
  break;
3410
3538
  }
3411
3539
  throw new Error('order 模块未初始化');
@@ -3419,53 +3547,53 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3419
3547
  });
3420
3548
  }
3421
3549
  if (!(typeof this.store.order.addProductsToOrder === 'function')) {
3422
- _context43.next = 11;
3550
+ _context46.next = 11;
3423
3551
  break;
3424
3552
  }
3425
- return _context43.abrupt("return", this.store.order.addProductsToOrder(orderLines));
3553
+ return _context46.abrupt("return", this.store.order.addProductsToOrder(orderLines));
3426
3554
  case 11:
3427
3555
  result = [];
3428
3556
  _iterator2 = _createForOfIteratorHelper(orderLines);
3429
- _context43.prev = 13;
3557
+ _context46.prev = 13;
3430
3558
  _iterator2.s();
3431
3559
  case 15:
3432
3560
  if ((_step2 = _iterator2.n()).done) {
3433
- _context43.next = 29;
3561
+ _context46.next = 29;
3434
3562
  break;
3435
3563
  }
3436
3564
  line = _step2.value;
3437
- _context43.t0 = result.splice;
3438
- _context43.t1 = result;
3439
- _context43.t2 = [0, result.length];
3440
- _context43.t3 = _toConsumableArray;
3441
- _context43.next = 23;
3565
+ _context46.t0 = result.splice;
3566
+ _context46.t1 = result;
3567
+ _context46.t2 = [0, result.length];
3568
+ _context46.t3 = _toConsumableArray;
3569
+ _context46.next = 23;
3442
3570
  return this.addProductToOrder(line.product);
3443
3571
  case 23:
3444
- _context43.t4 = _context43.sent;
3445
- _context43.t5 = (0, _context43.t3)(_context43.t4);
3446
- _context43.t6 = _context43.t2.concat.call(_context43.t2, _context43.t5);
3447
- _context43.t0.apply.call(_context43.t0, _context43.t1, _context43.t6);
3572
+ _context46.t4 = _context46.sent;
3573
+ _context46.t5 = (0, _context46.t3)(_context46.t4);
3574
+ _context46.t6 = _context46.t2.concat.call(_context46.t2, _context46.t5);
3575
+ _context46.t0.apply.call(_context46.t0, _context46.t1, _context46.t6);
3448
3576
  case 27:
3449
- _context43.next = 15;
3577
+ _context46.next = 15;
3450
3578
  break;
3451
3579
  case 29:
3452
- _context43.next = 34;
3580
+ _context46.next = 34;
3453
3581
  break;
3454
3582
  case 31:
3455
- _context43.prev = 31;
3456
- _context43.t7 = _context43["catch"](13);
3457
- _iterator2.e(_context43.t7);
3583
+ _context46.prev = 31;
3584
+ _context46.t7 = _context46["catch"](13);
3585
+ _iterator2.e(_context46.t7);
3458
3586
  case 34:
3459
- _context43.prev = 34;
3587
+ _context46.prev = 34;
3460
3588
  _iterator2.f();
3461
- return _context43.finish(34);
3589
+ return _context46.finish(34);
3462
3590
  case 37:
3463
- return _context43.abrupt("return", result);
3591
+ return _context46.abrupt("return", result);
3464
3592
  case 38:
3465
3593
  case "end":
3466
- return _context43.stop();
3594
+ return _context46.stop();
3467
3595
  }
3468
- }, _callee43, this, [[13, 31, 34, 37]]);
3596
+ }, _callee46, this, [[13, 31, 34, 37]]);
3469
3597
  }));
3470
3598
  function addAddTimeProductsToBooking(_x27) {
3471
3599
  return _addAddTimeProductsToBooking.apply(this, arguments);
@@ -3475,47 +3603,47 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3475
3603
  }, {
3476
3604
  key: "setOtherParams",
3477
3605
  value: function () {
3478
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3479
- var _this13 = this;
3480
- var _ref21,
3481
- _ref21$cover,
3606
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
3607
+ var _this14 = this;
3608
+ var _ref22,
3609
+ _ref22$cover,
3482
3610
  cover,
3483
3611
  nextParams,
3484
3612
  invoiceContextChanged,
3485
- _args44 = arguments;
3486
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3487
- while (1) switch (_context44.prev = _context44.next) {
3613
+ _args47 = arguments;
3614
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3615
+ while (1) switch (_context47.prev = _context47.next) {
3488
3616
  case 0:
3489
- _ref21 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref21$cover = _ref21.cover, cover = _ref21$cover === void 0 ? false : _ref21$cover;
3617
+ _ref22 = _args47.length > 1 && _args47[1] !== undefined ? _args47[1] : {}, _ref22$cover = _ref22.cover, cover = _ref22$cover === void 0 ? false : _ref22$cover;
3490
3618
  nextParams = cover ? params : _objectSpread(_objectSpread({}, this.otherParams), params);
3491
3619
  if (['businessCode', 'business_code', 'channel', 'platform', 'shop_id', 'tenantId', 'cacheId'].some(function (key) {
3492
- var _this13$otherParams;
3493
- return (nextParams === null || nextParams === void 0 ? void 0 : nextParams[key]) !== ((_this13$otherParams = _this13.otherParams) === null || _this13$otherParams === void 0 ? void 0 : _this13$otherParams[key]);
3620
+ var _this14$otherParams;
3621
+ return (nextParams === null || nextParams === void 0 ? void 0 : nextParams[key]) !== ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams[key]);
3494
3622
  })) this.orderCustomerContactRequest = null;
3495
- _context44.next = 5;
3623
+ _context47.next = 5;
3496
3624
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "setOtherParams", this).call(this, params, {
3497
3625
  cover: cover
3498
3626
  });
3499
3627
  case 5:
3500
3628
  invoiceContextChanged = (params === null || params === void 0 ? void 0 : params.businessCode) !== undefined || (params === null || params === void 0 ? void 0 : params.business_code) !== undefined || (params === null || params === void 0 ? void 0 : params.channel) !== undefined || (params === null || params === void 0 ? void 0 : params.platform) !== undefined || Object.prototype.hasOwnProperty.call(params, 'openData');
3501
3629
  if (!invoiceContextChanged) {
3502
- _context44.next = 9;
3630
+ _context47.next = 9;
3503
3631
  break;
3504
3632
  }
3505
- _context44.next = 9;
3633
+ _context47.next = 9;
3506
3634
  return this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
3507
3635
  case 9:
3508
3636
  if (!((params === null || params === void 0 ? void 0 : params.businessCode) !== undefined || (params === null || params === void 0 ? void 0 : params.business_code) !== undefined || Object.prototype.hasOwnProperty.call(params !== null && params !== void 0 ? params : {}, 'openData'))) {
3509
- _context44.next = 12;
3637
+ _context47.next = 12;
3510
3638
  break;
3511
3639
  }
3512
- _context44.next = 12;
3640
+ _context47.next = 12;
3513
3641
  return this.configureIdGeneratorFromOpenData();
3514
3642
  case 12:
3515
3643
  case "end":
3516
- return _context44.stop();
3644
+ return _context47.stop();
3517
3645
  }
3518
- }, _callee44, this);
3646
+ }, _callee47, this);
3519
3647
  }));
3520
3648
  function setOtherParams(_x28) {
3521
3649
  return _setOtherParams.apply(this, arguments);
@@ -3534,15 +3662,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3534
3662
  }, {
3535
3663
  key: "handlePrintWristband",
3536
3664
  value: function () {
3537
- var _handlePrintWristband = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
3665
+ var _handlePrintWristband = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
3538
3666
  var _this$getOrderIdentit2;
3539
3667
  var deviceTask, deviceId, idempotencyKey;
3540
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3541
- while (1) switch (_context45.prev = _context45.next) {
3668
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
3669
+ while (1) switch (_context48.prev = _context48.next) {
3542
3670
  case 0:
3543
3671
  deviceTask = this.getDeviceTaskPlugin();
3544
3672
  if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
3545
- _context45.next = 4;
3673
+ _context48.next = 4;
3546
3674
  break;
3547
3675
  }
3548
3676
  this.logger.addLog({
@@ -3552,7 +3680,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3552
3680
  voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
3553
3681
  }
3554
3682
  });
3555
- return _context45.abrupt("return");
3683
+ return _context48.abrupt("return");
3556
3684
  case 4:
3557
3685
  this.logger.addLog({
3558
3686
  type: 'info',
@@ -3561,20 +3689,23 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3561
3689
  voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
3562
3690
  }
3563
3691
  });
3564
- _context45.next = 7;
3692
+ _context48.next = 7;
3565
3693
  return this.getShortNumberOrDeviceId();
3566
3694
  case 7:
3567
- deviceId = _context45.sent;
3695
+ deviceId = _context48.sent;
3568
3696
  idempotencyKey = createUuidV4();
3569
3697
  deviceTask.dispatch({
3570
3698
  action: 'print_all',
3571
3699
  device_id: deviceId,
3572
3700
  payload: {
3573
3701
  type: 'WRISTBAND',
3574
- data: {
3575
- order_id: (_this$getOrderIdentit2 = this.getOrderIdentity()) === null || _this$getOrderIdentit2 === void 0 ? void 0 : _this$getOrderIdentit2.orderId,
3702
+ data: _objectSpread(_objectSpread({
3703
+ order_id: (_this$getOrderIdentit2 = this.getOrderIdentity()) === null || _this$getOrderIdentit2 === void 0 ? void 0 : _this$getOrderIdentit2.orderId
3704
+ }, params.voucher_times && {
3705
+ voucher_times: params.voucher_times
3706
+ }), {}, {
3576
3707
  voucher_ids: Array.isArray(params.voucher_ids) ? params.voucher_ids : [params.voucher_ids]
3577
- }
3708
+ })
3578
3709
  },
3579
3710
  idempotency_key: idempotencyKey,
3580
3711
  name: 'PRINT_WRISTBAND',
@@ -3584,23 +3715,36 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3584
3715
  });
3585
3716
  case 10:
3586
3717
  case "end":
3587
- return _context45.stop();
3718
+ return _context48.stop();
3588
3719
  }
3589
- }, _callee45, this);
3720
+ }, _callee48, this);
3590
3721
  }));
3591
3722
  function handlePrintWristband(_x29) {
3592
3723
  return _handlePrintWristband.apply(this, arguments);
3593
3724
  }
3594
3725
  return handlePrintWristband;
3595
- }() // 触发核销
3726
+ }()
3727
+ }, {
3728
+ key: "getRedeemArrivalWindow",
3729
+ value: function getRedeemArrivalWindow() {
3730
+ var _this$store$openData$, _this$store$openData2, _this$store$openData3;
3731
+ return readArrivalWindow((_this$store$openData$ = (_this$store$openData2 = this.store.openData) === null || _this$store$openData2 === void 0 || (_this$store$openData3 = _this$store$openData2.getOpenData) === null || _this$store$openData3 === void 0 ? void 0 : _this$store$openData3.call(_this$store$openData2)) !== null && _this$store$openData$ !== void 0 ? _this$store$openData$ : this.getInjectedOpenDataConfig());
3732
+ }
3733
+ }, {
3734
+ key: "isRedeemArrivalEnabled",
3735
+ value: function isRedeemArrivalEnabled() {
3736
+ return Boolean(this.getRedeemArrivalWindow());
3737
+ }
3738
+
3739
+ // 触发核销
3596
3740
  }, {
3597
3741
  key: "handleRedeem",
3598
3742
  value: function () {
3599
- var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
3600
- var _this$store$order8, _this$store$order8$ge, _this$store$order9, _ref22, _tempOrder$order_id2;
3601
- var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, identity, externalSaleNumber, orderId, orderLookup;
3602
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3603
- while (1) switch (_context46.prev = _context46.next) {
3743
+ var _handleRedeem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(params) {
3744
+ var _this$store$order8, _this$store$order8$ge, _this$store$order9, _ref23, _tempOrder$order_id2;
3745
+ var voucherIds, status, voucherIdSet, tempOrder, vouchers, hasUpdatedVoucher, nextVouchers, write, identity, externalSaleNumber, orderId, orderLookup;
3746
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
3747
+ while (1) switch (_context49.prev = _context49.next) {
3604
3748
  case 0:
3605
3749
  voucherIds = Array.isArray(params.voucher_ids) ? params.voucher_ids : [];
3606
3750
  status = params.is_checkin ? 'used' : 'unused';
@@ -3624,33 +3768,40 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3624
3768
  });
3625
3769
  });
3626
3770
  if (!(tempOrder && hasUpdatedVoucher)) {
3627
- _context46.next = 11;
3771
+ _context49.next = 17;
3628
3772
  break;
3629
3773
  }
3630
- _context46.next = 11;
3631
- return this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
3774
+ write = this.replaceTempOrder(_objectSpread(_objectSpread({}, tempOrder), {}, {
3632
3775
  vouchers: nextVouchers
3633
3776
  }), {
3634
3777
  preserveOrderSessionId: this.getOrderSessionId() || undefined
3635
3778
  });
3636
- case 11:
3779
+ this.redeemStatusWrite = write;
3780
+ _context49.prev = 11;
3781
+ _context49.next = 14;
3782
+ return write;
3783
+ case 14:
3784
+ _context49.prev = 14;
3785
+ if (this.redeemStatusWrite === write) this.redeemStatusWrite = undefined;
3786
+ return _context49.finish(14);
3787
+ case 17:
3637
3788
  this.core.effects.emit("".concat(this.name, ":onVouchersChange"), {});
3638
3789
  if (!(voucherIds.length === 0)) {
3639
- _context46.next = 14;
3790
+ _context49.next = 20;
3640
3791
  break;
3641
3792
  }
3642
- return _context46.abrupt("return", {
3793
+ return _context49.abrupt("return", {
3643
3794
  code: 200,
3644
3795
  status: true,
3645
3796
  message: '',
3646
3797
  data: []
3647
3798
  });
3648
- case 14:
3799
+ case 20:
3649
3800
  identity = this.getOrderIdentity();
3650
3801
  externalSaleNumber = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.external_sale_number) || (identity === null || identity === void 0 ? void 0 : identity.externalSaleNumber) || undefined;
3651
- orderId = (_ref22 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref22 !== void 0 ? _ref22 : undefined;
3802
+ orderId = (_ref23 = (_tempOrder$order_id2 = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) !== null && _tempOrder$order_id2 !== void 0 ? _tempOrder$order_id2 : identity === null || identity === void 0 ? void 0 : identity.orderId) !== null && _ref23 !== void 0 ? _ref23 : undefined;
3652
3803
  orderLookup = externalSaleNumber || orderId || (identity === null || identity === void 0 ? void 0 : identity.orderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopOrderNumber) || (identity === null || identity === void 0 ? void 0 : identity.shopFullOrderNumber) || undefined;
3653
- return _context46.abrupt("return", this.request.post('/machinecode/batch', {
3804
+ return _context49.abrupt("return", this.request.post('/machinecode/batch', {
3654
3805
  ids: voucherIds,
3655
3806
  status: status,
3656
3807
  order_lookup: orderLookup,
@@ -3659,17 +3810,213 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3659
3810
  }, {
3660
3811
  osServer: true
3661
3812
  }));
3662
- case 19:
3813
+ case 25:
3663
3814
  case "end":
3664
- return _context46.stop();
3815
+ return _context49.stop();
3665
3816
  }
3666
- }, _callee46, this);
3817
+ }, _callee49, this, [[11,, 14, 17]]);
3667
3818
  }));
3668
3819
  function handleRedeem(_x30) {
3669
3820
  return _handleRedeem.apply(this, arguments);
3670
3821
  }
3671
3822
  return handleRedeem;
3672
3823
  }()
3824
+ }, {
3825
+ key: "updateTicketArrival",
3826
+ value: function () {
3827
+ var _updateTicketArrival = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(voucherIds) {
3828
+ var _this$store$order10,
3829
+ _this$store$order10$g,
3830
+ _this15 = this;
3831
+ var window, tempOrder, log, operation, arrivalTime, session, updateArrival, completion;
3832
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
3833
+ while (1) switch (_context51.prev = _context51.next) {
3834
+ case 0:
3835
+ window = this.getRedeemArrivalWindow();
3836
+ tempOrder = (_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$g = _this$store$order10.getTempOrder) === null || _this$store$order10$g === void 0 ? void 0 : _this$store$order10$g.call(_this$store$order10);
3837
+ log = createArrivalLogger(this.logger, tempOrder, voucherIds);
3838
+ if (!(!window || !tempOrder)) {
3839
+ _context51.next = 6;
3840
+ break;
3841
+ }
3842
+ log('skipped', {
3843
+ reason: !window ? 'no_effective_window' : 'missing_order'
3844
+ });
3845
+ return _context51.abrupt("return");
3846
+ case 6:
3847
+ log('started', {
3848
+ early_minutes: window.earlyMinutes,
3849
+ late_minutes: window.lateMinutes
3850
+ });
3851
+ operation = 'prepare';
3852
+ arrivalTime = new Date();
3853
+ session = this.getOrderSessionId();
3854
+ updateArrival = /*#__PURE__*/function () {
3855
+ var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50() {
3856
+ var _this15$store$order, _this15$store$order$g, _next$summary;
3857
+ var current, sameOrder, order, arrival, next, query, checkout, latest, patch, voucherTimes;
3858
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
3859
+ while (1) switch (_context50.prev = _context50.next) {
3860
+ case 0:
3861
+ if (!_this15.redeemStatusWrite) {
3862
+ _context50.next = 3;
3863
+ break;
3864
+ }
3865
+ _context50.next = 3;
3866
+ return _this15.redeemStatusWrite.catch(function () {});
3867
+ case 3:
3868
+ current = (_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);
3869
+ sameOrder = function sameOrder() {
3870
+ var _this15$store$order2, _this15$store$order2$;
3871
+ var active = (_this15$store$order2 = _this15.store.order) === null || _this15$store$order2 === void 0 || (_this15$store$order2$ = _this15$store$order2.getTempOrder) === null || _this15$store$order2$ === void 0 ? void 0 : _this15$store$order2$.call(_this15$store$order2);
3872
+ return active && (session == null || _this15.getOrderSessionId() === session) && active.order_id === tempOrder.order_id && active.external_sale_number === tempOrder.external_sale_number;
3873
+ };
3874
+ order = current && sameOrder() ? current : tempOrder;
3875
+ arrival = applyRedeemArrival(order, new Set(voucherIds.map(String)), arrivalTime, window, function (reason) {
3876
+ return log('skipped', {
3877
+ reason: reason
3878
+ });
3879
+ });
3880
+ if (arrival) {
3881
+ _context50.next = 9;
3882
+ break;
3883
+ }
3884
+ return _context50.abrupt("return");
3885
+ case 9:
3886
+ next = _objectSpread(_objectSpread({}, order), arrival);
3887
+ _context50.t0 = buildArrivalCheckoutQuery;
3888
+ _context50.t1 = next;
3889
+ if (!((_next$summary = next.summary) !== null && _next$summary !== void 0)) {
3890
+ _context50.next = 16;
3891
+ break;
3892
+ }
3893
+ _context50.t2 = _next$summary;
3894
+ _context50.next = 24;
3895
+ break;
3896
+ case 16:
3897
+ if (!sameOrder()) {
3898
+ _context50.next = 22;
3899
+ break;
3900
+ }
3901
+ _context50.next = 19;
3902
+ return _this15.getSummary();
3903
+ case 19:
3904
+ _context50.t3 = _context50.sent;
3905
+ _context50.next = 23;
3906
+ break;
3907
+ case 22:
3908
+ _context50.t3 = undefined;
3909
+ case 23:
3910
+ _context50.t2 = _context50.t3;
3911
+ case 24:
3912
+ _context50.t4 = _context50.t2;
3913
+ query = (0, _context50.t0)(_context50.t1, _context50.t4);
3914
+ operation = 'checkout';
3915
+ log('checkout_requested', {
3916
+ bookings: describeChangedBookings(order.bookings, arrival.bookings)
3917
+ });
3918
+ _context50.next = 30;
3919
+ return _this15.store.order.submitSalesOrder({
3920
+ query: query
3921
+ });
3922
+ case 30:
3923
+ checkout = _context50.sent;
3924
+ if (!((checkout === null || checkout === void 0 ? void 0 : checkout.status) === false || (checkout === null || checkout === void 0 ? void 0 : checkout.code) != null && checkout.code !== 200)) {
3925
+ _context50.next = 34;
3926
+ break;
3927
+ }
3928
+ log('checkout_rejected', {
3929
+ code: checkout.code,
3930
+ status: checkout.status,
3931
+ message: checkout.message
3932
+ }, true);
3933
+ return _context50.abrupt("return", checkout);
3934
+ case 34:
3935
+ log('checkout_accepted', {
3936
+ code: checkout === null || checkout === void 0 ? void 0 : checkout.code
3937
+ });
3938
+ operation = 'local_update';
3939
+ if (!_this15.redeemStatusWrite) {
3940
+ _context50.next = 39;
3941
+ break;
3942
+ }
3943
+ _context50.next = 39;
3944
+ return _this15.redeemStatusWrite.catch(function () {});
3945
+ case 39:
3946
+ if (!sameOrder()) {
3947
+ _context50.next = 52;
3948
+ break;
3949
+ }
3950
+ latest = _this15.store.order.getTempOrder();
3951
+ patch = applyRedeemArrival(latest, new Set(voucherIds.map(String)), arrivalTime, window);
3952
+ if (!patch) {
3953
+ _context50.next = 49;
3954
+ break;
3955
+ }
3956
+ _context50.next = 45;
3957
+ return _this15.replaceTempOrder(_objectSpread(_objectSpread({}, latest), patch), {
3958
+ preserveOrderSessionId: _this15.getOrderSessionId() || undefined
3959
+ });
3960
+ case 45:
3961
+ log('local_updated');
3962
+ _this15.core.effects.emit("".concat(_this15.name, ":onVouchersChange"), {});
3963
+ _context50.next = 50;
3964
+ break;
3965
+ case 49:
3966
+ log('local_skipped', {
3967
+ reason: 'no_pending_change'
3968
+ });
3969
+ case 50:
3970
+ _context50.next = 53;
3971
+ break;
3972
+ case 52:
3973
+ log('local_skipped', {
3974
+ reason: 'order_changed'
3975
+ });
3976
+ case 53:
3977
+ // 从本次 checkout 已接受的快照取票面时间,避免打印接口短暂返回旧值。
3978
+ voucherTimes = {};
3979
+ arrival.vouchers.forEach(function (voucher, index) {
3980
+ if (voucher !== order.vouchers[index] && voucher.voucher_id != null && voucher.start_time && voucher.end_time) {
3981
+ voucherTimes[String(voucher.voucher_id)] = {
3982
+ start_time: voucher.start_time,
3983
+ end_time: voucher.end_time
3984
+ };
3985
+ }
3986
+ });
3987
+ return _context50.abrupt("return", Object.keys(voucherTimes).length ? _objectSpread(_objectSpread({}, checkout), {}, {
3988
+ voucher_times: voucherTimes
3989
+ }) : checkout);
3990
+ case 56:
3991
+ case "end":
3992
+ return _context50.stop();
3993
+ }
3994
+ }, _callee50);
3995
+ }));
3996
+ return function updateArrival() {
3997
+ return _ref24.apply(this, arguments);
3998
+ };
3999
+ }();
4000
+ completion = this.arrivalQueue.then(updateArrival).catch(function (error) {
4001
+ log('failed', {
4002
+ operation: operation,
4003
+ message: error instanceof Error ? error.message : String(error)
4004
+ }, true);
4005
+ throw error;
4006
+ });
4007
+ this.arrivalQueue = completion.then(function () {}, function () {});
4008
+ return _context51.abrupt("return", completion);
4009
+ case 14:
4010
+ case "end":
4011
+ return _context51.stop();
4012
+ }
4013
+ }, _callee51, this);
4014
+ }));
4015
+ function updateTicketArrival(_x31) {
4016
+ return _updateTicketArrival.apply(this, arguments);
4017
+ }
4018
+ return updateTicketArrival;
4019
+ }()
3673
4020
  /**
3674
4021
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
3675
4022
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -3677,13 +4024,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3677
4024
  }, {
3678
4025
  key: "destroy",
3679
4026
  value: (function () {
3680
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
4027
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
3681
4028
  var _this$scan;
3682
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3683
- while (1) switch (_context47.prev = _context47.next) {
4029
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4030
+ while (1) switch (_context52.prev = _context52.next) {
3684
4031
  case 0:
3685
4032
  this.orderCustomerContactRequest = null;
3686
- _context47.next = 3;
4033
+ _context52.next = 3;
3687
4034
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
3688
4035
  case 3:
3689
4036
  try {
@@ -3694,9 +4041,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
3694
4041
  scanCache.clear();
3695
4042
  case 5:
3696
4043
  case "end":
3697
- return _context47.stop();
4044
+ return _context52.stop();
3698
4045
  }
3699
- }, _callee47, this);
4046
+ }, _callee52, this);
3700
4047
  }));
3701
4048
  function destroy() {
3702
4049
  return _destroy.apply(this, arguments);