@pisell/pisellos 2.3.184 → 2.3.186

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 (78) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/inventory/index.d.ts +92 -0
  4. package/dist/inventory/index.js +509 -0
  5. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  6. package/dist/modules/Discount/index.js +1 -0
  7. package/dist/modules/Order/index.d.ts +25 -3
  8. package/dist/modules/Order/index.js +1770 -1311
  9. package/dist/modules/Order/types.d.ts +7 -0
  10. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  11. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  12. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  13. package/dist/modules/Order/utils.js +12 -1
  14. package/dist/modules/Product/index.d.ts +1 -1
  15. package/dist/modules/Product/types.d.ts +5 -0
  16. package/dist/modules/ProductList/index.js +33 -12
  17. package/dist/modules/Rules/index.d.ts +2 -0
  18. package/dist/modules/Rules/index.js +29 -21
  19. package/dist/solution/BaseSales/index.d.ts +18 -1
  20. package/dist/solution/BaseSales/index.js +1762 -1434
  21. package/dist/solution/BaseSales/types.d.ts +3 -0
  22. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  23. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  24. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  25. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  26. package/dist/solution/BookingByStep/index.d.ts +2 -2
  27. package/dist/solution/BookingTicket/index.d.ts +13 -1
  28. package/dist/solution/BookingTicket/index.js +197 -108
  29. package/dist/solution/BookingTicket/types.d.ts +14 -2
  30. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  31. package/dist/solution/BookingTicket/utils/addProductDecision.js +4 -3
  32. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  33. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +88 -0
  34. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  35. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  36. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
  37. package/dist/solution/UnifiedBookingSales/index.js +102 -64
  38. package/dist/utils/platform.d.ts +2 -0
  39. package/dist/utils/platform.js +6 -0
  40. package/lib/index.d.ts +1 -0
  41. package/lib/index.js +12 -0
  42. package/lib/inventory/index.d.ts +92 -0
  43. package/lib/inventory/index.js +287 -0
  44. package/lib/modules/Discount/index.js +1 -0
  45. package/lib/modules/Order/index.d.ts +25 -3
  46. package/lib/modules/Order/index.js +192 -38
  47. package/lib/modules/Order/types.d.ts +7 -0
  48. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  49. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  50. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  51. package/lib/modules/Order/utils.js +13 -0
  52. package/lib/modules/Product/index.d.ts +1 -1
  53. package/lib/modules/Product/types.d.ts +5 -0
  54. package/lib/modules/ProductList/index.js +15 -0
  55. package/lib/modules/Rules/index.d.ts +2 -0
  56. package/lib/modules/Rules/index.js +6 -0
  57. package/lib/solution/BaseSales/index.d.ts +18 -1
  58. package/lib/solution/BaseSales/index.js +214 -50
  59. package/lib/solution/BaseSales/types.d.ts +3 -0
  60. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  61. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  62. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  63. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  64. package/lib/solution/BookingByStep/index.d.ts +2 -2
  65. package/lib/solution/BookingTicket/index.d.ts +13 -1
  66. package/lib/solution/BookingTicket/index.js +37 -2
  67. package/lib/solution/BookingTicket/types.d.ts +14 -2
  68. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  69. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -3
  70. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +8 -0
  71. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +54 -0
  72. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  73. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  74. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
  75. package/lib/solution/UnifiedBookingSales/index.js +37 -4
  76. package/lib/utils/platform.d.ts +2 -0
  77. package/lib/utils/platform.js +7 -0
  78. package/package.json +1 -1
@@ -48,7 +48,7 @@ import { AvailabilityRemoteOccupancyCache } from "./remoteOccupancyCache";
48
48
  import { BusinessAvailabilityController } from "./businessAvailability";
49
49
  import { BookingTicket } from "../BookingTicket";
50
50
  import { addLocalCalendarDays, captureRuntimeOffsetMinutes, extractFixedOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, parseLocalDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
51
- import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/platform";
51
+ import { isCustomerUserPlatform, isSelfServicePlatform, normalizeRuntimePlatform } from "../../utils/platform";
52
52
  import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
53
53
  export * from "./types";
54
54
  export * from "./salesSettings";
@@ -1834,16 +1834,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1834
1834
  key: "setOtherParams",
1835
1835
  value: function () {
1836
1836
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
1837
- var _this$otherParams10, _this$otherParams12;
1837
+ var _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams15;
1838
1838
  var _ref31,
1839
1839
  _ref31$cover,
1840
1840
  cover,
1841
1841
  previousScope,
1842
+ previousCatalogScope,
1842
1843
  previousItemRuleConfig,
1843
1844
  explicitlySetsOpenData,
1844
1845
  nextParams,
1845
1846
  nextScope,
1846
- _this$otherParams11,
1847
+ _this$otherParams14,
1847
1848
  shouldResetAvailabilityState,
1848
1849
  _args4 = arguments;
1849
1850
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
@@ -1851,33 +1852,42 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1851
1852
  case 0:
1852
1853
  _ref31 = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
1853
1854
  previousScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
1854
- previousItemRuleConfig = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.itemRule;
1855
+ previousCatalogScope = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.catalogScopeKey;
1856
+ previousItemRuleConfig = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.itemRule;
1855
1857
  explicitlySetsOpenData = Object.prototype.hasOwnProperty.call(params, 'openData');
1856
1858
  nextParams = cover ? params : _objectSpread(_objectSpread({}, this.otherParams), params);
1857
1859
  if (explicitlySetsOpenData || this.getRuntimeOpenDataScope() !== this.getRuntimeOpenDataScope(nextParams)) {
1858
1860
  this.clearOpenDataCache();
1859
1861
  }
1860
- _context4.next = 8;
1862
+ _context4.next = 9;
1861
1863
  return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "setOtherParams", this).call(this, params, {
1862
1864
  cover: cover
1863
1865
  });
1864
- case 8:
1866
+ case 9:
1867
+ if (!(previousCatalogScope !== ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.catalogScopeKey) && (previousCatalogScope || (_this$otherParams13 = this.otherParams) !== null && _this$otherParams13 !== void 0 && _this$otherParams13.catalogScopeKey))) {
1868
+ _context4.next = 13;
1869
+ break;
1870
+ }
1871
+ this.unifiedProductCatalog = [];
1872
+ _context4.next = 13;
1873
+ return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
1874
+ case 13:
1865
1875
  nextScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
1866
1876
  if (explicitlySetsOpenData) {
1867
- this.openDataTarget = (_this$otherParams11 = this.otherParams) !== null && _this$otherParams11 !== void 0 && _this$otherParams11.openData && nextScope.businessCode && nextScope.channel ? "".concat(nextScope.businessCode, "+").concat(nextScope.channel) : null;
1877
+ this.openDataTarget = (_this$otherParams14 = this.otherParams) !== null && _this$otherParams14 !== void 0 && _this$otherParams14.openData && nextScope.businessCode && nextScope.channel ? "".concat(nextScope.businessCode, "+").concat(nextScope.channel) : null;
1868
1878
  }
1869
1879
  shouldResetAvailabilityState = previousScope.cacheId !== nextScope.cacheId || previousScope.businessCode !== nextScope.businessCode || previousScope.channel !== nextScope.channel || previousScope.platform !== nextScope.platform || previousScope.businessTimezone !== nextScope.businessTimezone;
1870
1880
  if (!shouldResetAvailabilityState) {
1871
- _context4.next = 14;
1881
+ _context4.next = 19;
1872
1882
  break;
1873
1883
  }
1874
- _context4.next = 14;
1884
+ _context4.next = 19;
1875
1885
  return this.resetAvailabilityProjectionState('set_other_params_reset');
1876
- case 14:
1877
- if (shouldResetAvailabilityState || explicitlySetsOpenData || previousItemRuleConfig !== ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.itemRule)) {
1886
+ case 19:
1887
+ if (shouldResetAvailabilityState || explicitlySetsOpenData || previousItemRuleConfig !== ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.itemRule)) {
1878
1888
  this.resetAllergyItemRuleState();
1879
1889
  }
1880
- case 15:
1890
+ case 20:
1881
1891
  case "end":
1882
1892
  return _context4.stop();
1883
1893
  }
@@ -2117,8 +2127,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2117
2127
  }, {
2118
2128
  key: "isSessionStoragePersistEnabled",
2119
2129
  value: function isSessionStoragePersistEnabled() {
2120
- var _this$otherParams13;
2121
- return Boolean(this.cacheId && ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.enableSessionStoragePersist) === true);
2130
+ var _this$otherParams16;
2131
+ return Boolean(this.cacheId && ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.enableSessionStoragePersist) === true);
2122
2132
  }
2123
2133
  }, {
2124
2134
  key: "shouldUseSessionStorageForSubModule",
@@ -2185,12 +2195,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2185
2195
  key: "ensureLocalOrderNumbersForCheckout",
2186
2196
  value: (function () {
2187
2197
  var _ensureLocalOrderNumbersForCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
2188
- var _this$otherParams14, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2;
2198
+ var _this$otherParams17, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2;
2189
2199
  var order, tempOrder, biz, idGenerator;
2190
2200
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
2191
2201
  while (1) switch (_context8.prev = _context8.next) {
2192
2202
  case 0:
2193
- if (!(normalizeRuntimePlatform((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform) !== 'kiosk')) {
2203
+ if (!(normalizeRuntimePlatform((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform) !== 'kiosk')) {
2194
2204
  _context8.next = 2;
2195
2205
  break;
2196
2206
  }
@@ -2275,18 +2285,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2275
2285
  return ensureLocalOrderNumbersForCheckout;
2276
2286
  }()
2277
2287
  /**
2278
- * PC/H5/Kiosk 结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
2288
+ * PC/H5 及自助终端结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
2279
2289
  * 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
2280
2290
  */
2281
2291
  )
2282
2292
  }, {
2283
2293
  key: "shouldUseCheckoutSyncTask",
2284
2294
  value: function shouldUseCheckoutSyncTask() {
2285
- var _this$otherParams15, _this$otherParams16;
2286
- var configured = (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.checkoutSyncTaskEnabled;
2295
+ var _this$otherParams18, _this$otherParams19;
2296
+ var configured = (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.checkoutSyncTaskEnabled;
2287
2297
  if (configured === true) return true;
2288
- var platform = normalizeRuntimePlatform((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.platform);
2289
- return !isCustomerUserPlatform(platform) && platform !== 'kiosk';
2298
+ var platform = normalizeRuntimePlatform((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform);
2299
+ return !isCustomerUserPlatform(platform) && !isSelfServicePlatform(platform);
2290
2300
  }
2291
2301
 
2292
2302
  /** UnifiedBookingSales 的真实结账默认请求收据数据,供云端确认后再本地打印。 */
@@ -2440,8 +2450,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2440
2450
  }, {
2441
2451
  key: "isAuthenticatedCustomerUserPlatform",
2442
2452
  value: function isAuthenticatedCustomerUserPlatform() {
2443
- var _this$otherParams17;
2444
- return isCustomerUserPlatform((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform);
2453
+ var _this$otherParams20;
2454
+ return isCustomerUserPlatform((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.platform);
2445
2455
  }
2446
2456
  }, {
2447
2457
  key: "resolveDiscountOrderIdentity",
@@ -2781,7 +2791,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2781
2791
  key: "getSalesSettings",
2782
2792
  value: (function () {
2783
2793
  var _getSalesSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
2784
- var _this$otherParams18;
2794
+ var _this$otherParams21;
2785
2795
  var config;
2786
2796
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2787
2797
  while (1) switch (_context18.prev = _context18.next) {
@@ -2796,7 +2806,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2796
2806
  }
2797
2807
  throw new Error('Sales settings are unavailable without a business context.');
2798
2808
  case 5:
2799
- return _context18.abrupt("return", normalizeSalesSettings(config, (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform));
2809
+ return _context18.abrupt("return", normalizeSalesSettings(config, (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.platform));
2800
2810
  case 6:
2801
2811
  case "end":
2802
2812
  return _context18.stop();
@@ -2811,11 +2821,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2811
2821
  }, {
2812
2822
  key: "getLoadedSalesSettings",
2813
2823
  value: function getLoadedSalesSettings() {
2814
- var _this$otherParams19;
2824
+ var _this$otherParams22;
2815
2825
  if (!this.runtimeOpenDataSnapshot) {
2816
2826
  throw new Error('Sales settings are not loaded. Call getSalesSettings before preparing a booking.');
2817
2827
  }
2818
- return normalizeSalesSettings(this.runtimeOpenDataSnapshot, (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform);
2828
+ return normalizeSalesSettings(this.runtimeOpenDataSnapshot, (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform);
2819
2829
  }
2820
2830
  }, {
2821
2831
  key: "getProductBookingsForScheduling",
@@ -2835,8 +2845,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2835
2845
  }, {
2836
2846
  key: "shouldApplyMultipleBookingScheduling",
2837
2847
  value: function shouldApplyMultipleBookingScheduling() {
2838
- var _this$otherParams20;
2839
- var platform = normalizeRuntimePlatform((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.platform);
2848
+ var _this$otherParams23;
2849
+ var platform = normalizeRuntimePlatform((_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform);
2840
2850
  return platform === 'pos' || platform === 'webpos';
2841
2851
  }
2842
2852
  }, {
@@ -3039,13 +3049,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3039
3049
  key: "loadPickupTimingOpenData",
3040
3050
  value: function () {
3041
3051
  var _loadPickupTimingOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(_force) {
3042
- var _ref35, _this$otherParams$bus2, _this$otherParams21, _this$otherParams22;
3052
+ var _ref35, _this$otherParams$bus2, _this$otherParams24, _this$otherParams25;
3043
3053
  var scope, businessCode, config;
3044
3054
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
3045
3055
  while (1) switch (_context21.prev = _context21.next) {
3046
3056
  case 0:
3047
3057
  scope = this.getPickupTimingScope();
3048
- businessCode = String((_ref35 = (_this$otherParams$bus2 = (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.businessCode) !== null && _this$otherParams$bus2 !== void 0 ? _this$otherParams$bus2 : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.business_code) !== null && _ref35 !== void 0 ? _ref35 : '').trim();
3058
+ businessCode = String((_ref35 = (_this$otherParams$bus2 = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.businessCode) !== null && _this$otherParams$bus2 !== void 0 ? _this$otherParams$bus2 : (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.business_code) !== null && _ref35 !== void 0 ? _ref35 : '').trim();
3049
3059
  _context21.next = 4;
3050
3060
  return this.loadOpenData({
3051
3061
  businessCode: businessCode,
@@ -3131,13 +3141,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3131
3141
  key: "validateRequiredProducts",
3132
3142
  value: (function () {
3133
3143
  var _validateRequiredProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
3134
- var _ref36, _this$otherParams$bus3, _this$otherParams23, _this$otherParams24, _this$otherParams$cha3, _this$otherParams25, _this$otherParams26;
3144
+ var _ref36, _this$otherParams$bus3, _this$otherParams26, _this$otherParams27, _this$otherParams$cha3, _this$otherParams28, _this$otherParams29;
3135
3145
  var businessCode, channel, scope, order, runtimeConfig, configs, _response$data2, openData, ids, response, strategyConfigs, cartItems, result, _result$failedChecks$, error;
3136
3146
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3137
3147
  while (1) switch (_context23.prev = _context23.next) {
3138
3148
  case 0:
3139
- businessCode = String((_ref36 = (_this$otherParams$bus3 = (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) !== null && _this$otherParams$bus3 !== void 0 ? _this$otherParams$bus3 : (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code) !== null && _ref36 !== void 0 ? _ref36 : '').trim();
3140
- channel = String((_this$otherParams$cha3 = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.channel) !== null && _this$otherParams$cha3 !== void 0 ? _this$otherParams$cha3 : '').trim();
3149
+ businessCode = String((_ref36 = (_this$otherParams$bus3 = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.businessCode) !== null && _this$otherParams$bus3 !== void 0 ? _this$otherParams$bus3 : (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.business_code) !== null && _ref36 !== void 0 ? _ref36 : '').trim();
3150
+ channel = String((_this$otherParams$cha3 = (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.channel) !== null && _this$otherParams$cha3 !== void 0 ? _this$otherParams$cha3 : '').trim();
3141
3151
  if (!(businessCode !== 'venue_ticket' || channel !== 'online_ordering')) {
3142
3152
  _context23.next = 4;
3143
3153
  break;
@@ -3146,7 +3156,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3146
3156
  case 4:
3147
3157
  scope = this.getPickupTimingScope();
3148
3158
  order = this.getTempOrder();
3149
- runtimeConfig = ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.itemRule) || {};
3159
+ runtimeConfig = ((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.itemRule) || {};
3150
3160
  configs = normalizeItemRuleStrategyConfigs(runtimeConfig.strategyConfigs);
3151
3161
  if (configs.length) {
3152
3162
  _context23.next = 23;
@@ -3375,7 +3385,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3375
3385
  key: "resolveProductAllergyRequirement",
3376
3386
  value: (function () {
3377
3387
  var _resolveProductAllergyRequirement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3378
- var _this$otherParams27, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref39, _runtimeConfig$servic, _this$otherParams28, _ref40, _ref41, _params$channel, _this$otherParams29, _this$otherParams30, _runtimeConfig$submis;
3388
+ var _this$otherParams30, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref39, _runtimeConfig$servic, _this$otherParams31, _ref40, _ref41, _params$channel, _this$otherParams32, _this$otherParams33, _runtimeConfig$submis;
3379
3389
  var productId, strategyConfigs, productVariantId, runtimeConfig, runtimePax, cartItems;
3380
3390
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3381
3391
  while (1) switch (_context27.prev = _context27.next) {
@@ -3398,7 +3408,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3398
3408
  return _context27.abrupt("return", null);
3399
3409
  case 8:
3400
3410
  productVariantId = normalizePositiveInteger(params.productVariantId);
3401
- runtimeConfig = ((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.itemRule) || {};
3411
+ runtimeConfig = ((_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.itemRule) || {};
3402
3412
  runtimePax = runtimeConfig.pax || {};
3403
3413
  cartItems = (((_this$getOrderProduct = this.getOrderProducts) === null || _this$getOrderProduct === void 0 ? void 0 : _this$getOrderProduct.call(this)) || []).map(function (item) {
3404
3414
  var _item$product_id, _item$product_variant, _ref38, _item$num;
@@ -3417,8 +3427,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3417
3427
  child: Number((_runtimePax$child = runtimePax.child) !== null && _runtimePax$child !== void 0 ? _runtimePax$child : 0) || 0
3418
3428
  },
3419
3429
  cartItems: cartItems,
3420
- serviceType: String((_ref39 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.serviceType) !== null && _ref39 !== void 0 ? _ref39 : ''),
3421
- channel: String((_ref40 = (_ref41 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.channel) !== null && _ref41 !== void 0 ? _ref41 : (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.platform) !== null && _ref40 !== void 0 ? _ref40 : ''),
3430
+ serviceType: String((_ref39 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.serviceType) !== null && _ref39 !== void 0 ? _ref39 : ''),
3431
+ channel: String((_ref40 = (_ref41 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.channel) !== null && _ref41 !== void 0 ? _ref41 : (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.platform) !== null && _ref40 !== void 0 ? _ref40 : ''),
3422
3432
  currentProduct: _objectSpread({
3423
3433
  product_id: productId
3424
3434
  }, productVariantId ? {
@@ -3508,9 +3518,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3508
3518
  }, {
3509
3519
  key: "isInvoiceOpenDataCacheCurrent",
3510
3520
  value: function isInvoiceOpenDataCacheCurrent() {
3511
- var _this$otherParams31, _this$otherParams32;
3512
- var businessCode = String(((_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.businessCode) || '').trim();
3513
- var channel = String(((_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.channel) || '').trim();
3521
+ var _this$otherParams34, _this$otherParams35;
3522
+ var businessCode = String(((_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.businessCode) || '').trim();
3523
+ var channel = String(((_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.channel) || '').trim();
3514
3524
  if (!businessCode || !channel) return false;
3515
3525
  return this.openDataTarget === "".concat(businessCode, "+").concat(channel) && this.runtimeOpenDataScope === this.getRuntimeOpenDataScope();
3516
3526
  }
@@ -3534,7 +3544,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3534
3544
  throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
3535
3545
  case 3:
3536
3546
  policyUrl = 'shop-policy';
3537
- if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
3547
+ if (isSelfServicePlatform(this.otherParams.platform) || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
3538
3548
  policyUrl = 'policy';
3539
3549
  }
3540
3550
  return _context30.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
@@ -3560,6 +3570,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3560
3570
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
3561
3571
  var params,
3562
3572
  options,
3573
+ catalogScope,
3563
3574
  schedule_date,
3564
3575
  schedule_datetime,
3565
3576
  result,
@@ -3575,9 +3586,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3575
3586
  }
3576
3587
  throw new Error('[UnifiedBookingSales] products 模块未初始化');
3577
3588
  case 4:
3589
+ catalogScope = this.otherParams.catalogScopeKey;
3578
3590
  schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
3579
3591
  schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
3580
- _context31.next = 8;
3592
+ _context31.next = 9;
3581
3593
  return this.store.products.loadProducts(_objectSpread(_objectSpread({
3582
3594
  with_count: ['bundleGroup', 'optionGroup'],
3583
3595
  with_schedule: 1
@@ -3586,14 +3598,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3586
3598
  schedule_datetime: schedule_datetime,
3587
3599
  cacheId: this.cacheId
3588
3600
  }), options);
3589
- case 8:
3601
+ case 9:
3590
3602
  result = _context31.sent;
3603
+ if (!(catalogScope !== this.otherParams.catalogScopeKey)) {
3604
+ _context31.next = 12;
3605
+ break;
3606
+ }
3607
+ throw Object.assign(new Error('Product scope changed'), {
3608
+ name: 'AbortError'
3609
+ });
3610
+ case 12:
3591
3611
  this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
3592
- _context31.next = 12;
3612
+ _context31.next = 15;
3593
3613
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
3594
- case 12:
3614
+ case 15:
3595
3615
  return _context31.abrupt("return", result);
3596
- case 13:
3616
+ case 16:
3597
3617
  case "end":
3598
3618
  return _context31.stop();
3599
3619
  }
@@ -4004,10 +4024,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4004
4024
  }, {
4005
4025
  key: "buildUnifiedOrderProduct",
4006
4026
  value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
4007
- var _ref42, _sourceProduct$_exten, _sourceProduct$_exten2, _sourceProduct$metada, _sourceProduct$id, _ref43, _sourceProduct$produc, _ref44, _ref45, _sourceProduct$quanti, _sourceProduct$price, _ref46, _ref47, _sourceProduct$sellin;
4027
+ var _sourceProduct$_exten, _this$otherParams36, _bookingQuote$pricing, _ref42, _sourceProduct$_exten2, _sourceProduct$_exten3, _sourceProduct$metada, _sourceProduct$id, _ref43, _sourceProduct$produc, _ref44, _ref45, _sourceProduct$quanti, _sourceProduct$price, _ref46, _ref47, _sourceProduct$sellin;
4008
4028
  var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
4009
- var quotationShelfId = (_ref42 = (_sourceProduct$_exten = (_sourceProduct$_exten2 = sourceProduct._extend) === null || _sourceProduct$_exten2 === void 0 ? void 0 : _sourceProduct$_exten2.quotation_shelf_id) !== null && _sourceProduct$_exten !== void 0 ? _sourceProduct$_exten : sourceProduct.quotation_shelf_id) !== null && _ref42 !== void 0 ? _ref42 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
4010
- var orderProduct = this.transformBaseProductToOrderProduct({
4029
+ var bookingQuote = (_sourceProduct$_exten = sourceProduct._extend) === null || _sourceProduct$_exten === void 0 ? void 0 : _sourceProduct$_exten.bookingPriceQuote;
4030
+ var isPos = normalizeRuntimePlatform((_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.platform) === 'pos';
4031
+ var quoteMethod = isPos ? bookingQuote === null || bookingQuote === void 0 || (_bookingQuote$pricing = bookingQuote.pricing_method) === null || _bookingQuote$pricing === void 0 ? void 0 : _bookingQuote$pricing.type : undefined;
4032
+ var hasDurationQuote = quoteMethod === 'duration_based';
4033
+ var quoteSourcePrice = bookingQuote === null || bookingQuote === void 0 ? void 0 : bookingQuote.sourceUnitPrice;
4034
+ var quoteDuration = bookingQuote === null || bookingQuote === void 0 ? void 0 : bookingQuote.duration;
4035
+ if (hasDurationQuote && (quoteSourcePrice === undefined || quoteSourcePrice === null || quoteSourcePrice === '' || !Number.isFinite(Number(quoteSourcePrice)) || Number(quoteSourcePrice) < 0 || (quoteDuration === null || quoteDuration === void 0 ? void 0 : quoteDuration.type) !== 'minutes' || !Number.isFinite(Number(quoteDuration.value)) || Number(quoteDuration.value) <= 0)) {
4036
+ throw Object.assign(new Error('按时长计价结果无效,请重新选择预约时间。'), {
4037
+ code: 'DURATION_PRICING_UNAVAILABLE'
4038
+ });
4039
+ }
4040
+ var quotationShelfId = (_ref42 = (_sourceProduct$_exten2 = (_sourceProduct$_exten3 = sourceProduct._extend) === null || _sourceProduct$_exten3 === void 0 ? void 0 : _sourceProduct$_exten3.quotation_shelf_id) !== null && _sourceProduct$_exten2 !== void 0 ? _sourceProduct$_exten2 : sourceProduct.quotation_shelf_id) !== null && _ref42 !== void 0 ? _ref42 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
4041
+ var orderProduct = this.transformBaseProductToOrderProduct(_objectSpread({
4011
4042
  payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
4012
4043
  id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
4013
4044
  product_id: (_ref43 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref43 !== void 0 ? _ref43 : product === null || product === void 0 ? void 0 : product.id,
@@ -4017,11 +4048,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4017
4048
  metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
4018
4049
  }),
4019
4050
  sourceProduct: sourceProduct
4020
- });
4051
+ }, hasDurationQuote ? {
4052
+ quotedSourceProductPrice: quoteSourcePrice
4053
+ } : {}));
4021
4054
  if (orderProduct && _typeof(orderProduct) === 'object') {
4022
4055
  // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
4023
4056
  // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
4024
- orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), quotationShelfId !== undefined ? {
4057
+ orderProduct.metadata = _objectSpread(_objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), hasDurationQuote || quoteMethod === 'fixed_price' ? {
4058
+ pricing_method: {
4059
+ type: quoteMethod
4060
+ },
4061
+ duration: hasDurationQuote ? _objectSpread({}, quoteDuration) : undefined
4062
+ } : {}), quotationShelfId !== undefined ? {
4025
4063
  quotation_shelf_id: quotationShelfId
4026
4064
  } : {});
4027
4065
  }
@@ -5586,7 +5624,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5586
5624
  value: (function () {
5587
5625
  var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(contextId) {
5588
5626
  var _this$otherParams$pla2,
5589
- _this$otherParams33,
5627
+ _this$otherParams37,
5590
5628
  _context$prepareParam,
5591
5629
  _extractFixedOffsetMi,
5592
5630
  _this16 = this;
@@ -5616,7 +5654,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5616
5654
  context = _yield$this$ensureAva.context;
5617
5655
  projectionEntry = _yield$this$ensureAva.projectionEntry;
5618
5656
  contextVersion = context.activeVersion;
5619
- isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
5657
+ isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
5620
5658
  isEditingContext = Boolean((_context$prepareParam = context.prepareParams.editingProductLineUids) === null || _context$prepareParam === void 0 ? void 0 : _context$prepareParam.length);
5621
5659
  editingOffset = (_extractFixedOffsetMi = extractFixedOffsetMinutes(projectionEntry.projection.meta.now)) !== null && _extractFixedOffsetMi !== void 0 ? _extractFixedOffsetMi : this.getAvailabilityRuntimeOffsetMinutes(); // This new editing input represents an absolute instant. Normalize it once
5622
5660
  // to the projection's fixed business clock before the wall-clock planner.
@@ -5684,7 +5722,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5684
5722
  key: "queryBookingAvailability",
5685
5723
  value: (function () {
5686
5724
  var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(contextId, request) {
5687
- var _this$otherParams$pla3, _this$otherParams34, _context$prepareParam2;
5725
+ var _this$otherParams$pla3, _this$otherParams38, _context$prepareParam2;
5688
5726
  var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, queryRequest, result, contextVersion, contextualResult;
5689
5727
  return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5690
5728
  while (1) switch (_context54.prev = _context54.next) {
@@ -5697,7 +5735,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5697
5735
  projectionEntry = _yield$this$ensureAva2.projectionEntry;
5698
5736
  refreshed = _yield$this$ensureAva2.refreshed;
5699
5737
  this.assertContextualQueryFreshness(context, request);
5700
- isPosAvailabilityRequest = String((_this$otherParams$pla3 = (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
5738
+ isPosAvailabilityRequest = String((_this$otherParams$pla3 = (_this$otherParams38 = this.otherParams) === null || _this$otherParams38 === void 0 ? void 0 : _this$otherParams38.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
5701
5739
  queryRequest = request.target === 'date' || request.target === 'product' ? _objectSpread(_objectSpread({}, request), {}, {
5702
5740
  dateRange: request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection)
5703
5741
  }) : request;
@@ -5814,14 +5852,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5814
5852
  value: function () {
5815
5853
  var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(startDate) {
5816
5854
  var _this$getTempOrder5,
5817
- _this$otherParams35,
5855
+ _this$otherParams39,
5818
5856
  _this17 = this;
5819
5857
  var products, targetDate, identities;
5820
5858
  return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5821
5859
  while (1) switch (_context55.prev = _context55.next) {
5822
5860
  case 0:
5823
5861
  products = ((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.products) || [];
5824
- if (!(((_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.enforceSingleBookingStartDate) !== true)) {
5862
+ if (!(((_this$otherParams39 = this.otherParams) === null || _this$otherParams39 === void 0 ? void 0 : _this$otherParams39.enforceSingleBookingStartDate) !== true)) {
5825
5863
  _context55.next = 3;
5826
5864
  break;
5827
5865
  }
@@ -5861,12 +5899,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5861
5899
  value: (function () {
5862
5900
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(contextId, params) {
5863
5901
  var _this$otherParams$pla4,
5864
- _this$otherParams36,
5902
+ _this$otherParams40,
5865
5903
  _params$availabilityC,
5866
5904
  _this$store$order11,
5867
5905
  _this$store$order11$e,
5868
5906
  _this18 = this;
5869
- var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref57, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$otherParams37, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla6, _this$otherParams38, _ref58, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref59, _ref60, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, _params$orderProduct9, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref61, _transformed$product_4, _this$getTempOrder6, _this$getTempOrder7, _params$salesNotes, _params$salesNotes2, _ref62, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
5907
+ var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref57, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$otherParams41, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla6, _this$otherParams42, _ref58, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref59, _ref60, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, _params$orderProduct9, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref61, _transformed$product_4, _this$getTempOrder6, _this$getTempOrder7, _params$salesNotes, _params$salesNotes2, _ref62, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
5870
5908
  return _regeneratorRuntime().wrap(function _callee56$(_context56) {
5871
5909
  while (1) switch (_context56.prev = _context56.next) {
5872
5910
  case 0:
@@ -5880,7 +5918,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5880
5918
  });
5881
5919
  case 3:
5882
5920
  isRememberedSelection = params.selectionIntent === 'remembered';
5883
- if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
5921
+ if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$otherParams40 = this.otherParams) === null || _this$otherParams40 === void 0 ? void 0 : _this$otherParams40.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
5884
5922
  _context56.next = 6;
5885
5923
  break;
5886
5924
  }
@@ -6069,7 +6107,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6069
6107
  selectedProduct = baseProjection.products.find(function (item) {
6070
6108
  return sameAvailabilityId(item.id, params.candidate.productId);
6071
6109
  });
6072
- if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
6110
+ if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams41 = this.otherParams) === null || _this$otherParams41 === void 0 ? void 0 : _this$otherParams41.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
6073
6111
  _context56.next = 67;
6074
6112
  break;
6075
6113
  }
@@ -6132,7 +6170,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
6132
6170
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
6133
6171
  candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
6134
6172
  candidateStartTime = getCandidateStartTime(params.candidate);
6135
- allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$otherParams38 = this.otherParams) === null || _this$otherParams38 === void 0 ? void 0 : _this$otherParams38.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection;
6173
+ allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$otherParams42 = this.otherParams) === null || _this$otherParams42 === void 0 ? void 0 : _this$otherParams42.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection;
6136
6174
  candidateBusinessDate = params.candidate.businessDate || ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) === 'duration' && this.usesDurationTimeGrid(refreshedProjection) ? getDurationBusinessDate(refreshedProjection, params.candidate.startAt) : params.candidate.startAt.slice(0, 10));
6137
6175
  refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
6138
6176
  productIds: [params.candidate.productId],
@@ -6,3 +6,5 @@ export declare function normalizeRuntimePlatform(platform: unknown): string;
6
6
  * PC and H5 are authenticated-customer clients rather than staff terminals.
7
7
  */
8
8
  export declare function isCustomerUserPlatform(platform: unknown): boolean;
9
+ /** Kiosk and vending retain distinct channels but share self-service checkout behavior. */
10
+ export declare function isSelfServicePlatform(platform: unknown): boolean;
@@ -1,4 +1,5 @@
1
1
  var CUSTOMER_USER_PLATFORMS = new Set(['pc', 'h5']);
2
+ var SELF_SERVICE_PLATFORMS = new Set(['kiosk', 'vending']);
2
3
 
3
4
  /**
4
5
  * Normalize the runtime platform passed through solution/module otherParams.
@@ -12,4 +13,9 @@ export function normalizeRuntimePlatform(platform) {
12
13
  */
13
14
  export function isCustomerUserPlatform(platform) {
14
15
  return CUSTOMER_USER_PLATFORMS.has(normalizeRuntimePlatform(platform));
16
+ }
17
+
18
+ /** Kiosk and vending retain distinct channels but share self-service checkout behavior. */
19
+ export function isSelfServicePlatform(platform) {
20
+ return SELF_SERVICE_PLATFORMS.has(normalizeRuntimePlatform(platform));
15
21
  }
package/lib/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export * from './modules';
7
7
  export * from './plugins';
8
8
  export * from './solution';
9
9
  export * from './model';
10
+ export * from './inventory';
10
11
  export { PisellOSCore } from './core';
11
12
  import PisellOSCore from './core';
12
13
  export default PisellOSCore;
package/lib/index.js CHANGED
@@ -80,6 +80,18 @@ Object.keys(_model).forEach(function (key) {
80
80
  }
81
81
  });
82
82
  });
83
+ var _inventory = require("./inventory");
84
+ Object.keys(_inventory).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
87
+ if (key in exports && exports[key] === _inventory[key]) return;
88
+ Object.defineProperty(exports, key, {
89
+ enumerable: true,
90
+ get: function () {
91
+ return _inventory[key];
92
+ }
93
+ });
94
+ });
83
95
  var _core = _interopRequireWildcard(require("./core"));
84
96
  var _smallTicket = require("./shared/receipt/small-ticket");
85
97
  Object.keys(_smallTicket).forEach(function (key) {
@@ -0,0 +1,92 @@
1
+ /** Optional, instance-scoped sales inventory. Never stored in ProductData or order payloads. */
2
+ export type InventoryRecord = Record<string, any>;
3
+ export type InventoryRefreshReason = 'catalog-entry' | 'detail-open' | 'checkout' | 'manual';
4
+ export interface InventoryAvailability {
5
+ status: 'ready' | 'loading' | 'stale' | 'error' | 'unmapped';
6
+ quantity?: number;
7
+ message?: string;
8
+ }
9
+ export interface InventorySelectionAvailability {
10
+ availability: InventoryAvailability;
11
+ /** Stock remaining after other cart lines using the same inventory key. */
12
+ availableQuantity: number;
13
+ /** The existing line can still be reduced when stock is unavailable. */
14
+ retainedQuantity: number;
15
+ maxQuantity: number;
16
+ }
17
+ export interface InventorySource {
18
+ readonly scopeKey: string;
19
+ assertCurrent(): void;
20
+ keyOf(product: InventoryRecord, variant?: InventoryRecord): string | undefined;
21
+ read(context: {
22
+ reason: InventoryRefreshReason;
23
+ signal: AbortSignal;
24
+ }): Promise<ReadonlyMap<string, {
25
+ quantity: number | null;
26
+ message?: string;
27
+ }>>;
28
+ message(reason: 'unavailable' | 'unmapped' | 'insufficient', values?: {
29
+ key: string;
30
+ quantity: number;
31
+ }): string;
32
+ }
33
+ export interface CheckoutInventoryLine {
34
+ readonly lineId: string;
35
+ readonly productId: string | number;
36
+ readonly variantId: string | number;
37
+ readonly quantity: number;
38
+ readonly inventoryKey: string;
39
+ }
40
+ export interface CheckoutRuntimeSnapshot {
41
+ readonly scopeKey: string;
42
+ readonly revision: number;
43
+ readonly lines: readonly CheckoutInventoryLine[];
44
+ }
45
+ export interface SalesCheckoutHooks {
46
+ beforeCheckout?(context: {
47
+ items: readonly InventoryRecord[];
48
+ signal?: AbortSignal;
49
+ }): Promise<void>;
50
+ }
51
+ export declare const salesGuardError: (message: string) => Error & {
52
+ code: string;
53
+ };
54
+ export declare class InventoryController {
55
+ private readonly source;
56
+ readonly identity: symbol;
57
+ readonly scopeKey: string;
58
+ private entries;
59
+ private lastQuantities;
60
+ private products;
61
+ private keys;
62
+ private catalogProducts;
63
+ private listeners;
64
+ private revision;
65
+ private state;
66
+ private pending?;
67
+ private disposed;
68
+ constructor(source: InventorySource);
69
+ getRevision: () => number;
70
+ subscribe: (listener: () => void) => () => void;
71
+ private publish;
72
+ private assertCurrent;
73
+ activate(): void;
74
+ dispose(): void;
75
+ invalidate(): void;
76
+ /** Catalog replaces identities; partial detail only merges its variants, never its prices. */
77
+ registerProducts(products: readonly InventoryRecord[], complete?: boolean): void;
78
+ /** Consumers share I/O; cancelling one detail does not cancel another consumer. */
79
+ refresh(context: {
80
+ reason: InventoryRefreshReason;
81
+ signal?: AbortSignal;
82
+ force?: boolean;
83
+ }): Promise<void>;
84
+ availabilityForKey(key?: string): InventoryAvailability;
85
+ availability(product: InventoryRecord, variantId?: string | number): InventoryAvailability;
86
+ private keyForLine;
87
+ /** Advisory UI limit only. The serialized cart guard remains authoritative. */
88
+ selectionAvailability(product: InventoryRecord, variantId: string | number, items: readonly InventoryRecord[], editingItem?: InventoryRecord): InventorySelectionAvailability;
89
+ private totals;
90
+ validate(proposed: readonly InventoryRecord[], current?: readonly InventoryRecord[], allowReductions?: boolean): void;
91
+ freezeCheckout(items: readonly InventoryRecord[]): CheckoutRuntimeSnapshot;
92
+ }