@pisell/pisellos 2.3.130 → 2.3.132

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 (37) hide show
  1. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  2. package/dist/modules/BusinessAvailability/index.js +204 -0
  3. package/dist/modules/OpenData/types.d.ts +2 -0
  4. package/dist/modules/Order/index.d.ts +5 -2
  5. package/dist/modules/Order/index.js +315 -241
  6. package/dist/modules/Order/types.d.ts +8 -0
  7. package/dist/solution/BaseSales/index.d.ts +4 -15
  8. package/dist/solution/BaseSales/index.js +151 -89
  9. package/dist/solution/BaseSales/types.d.ts +11 -0
  10. package/dist/solution/BookingByStep/index.d.ts +1 -1
  11. package/dist/solution/BookingTicket/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.js +41 -13
  13. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  14. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  15. package/dist/solution/UnifiedBookingSales/index.d.ts +11 -0
  16. package/dist/solution/UnifiedBookingSales/index.js +154 -75
  17. package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
  18. package/dist/solution/VenueBooking/index.js +45 -44
  19. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  20. package/lib/modules/BusinessAvailability/index.js +146 -0
  21. package/lib/modules/OpenData/types.d.ts +2 -0
  22. package/lib/modules/Order/index.d.ts +5 -2
  23. package/lib/modules/Order/index.js +62 -6
  24. package/lib/modules/Order/types.d.ts +8 -0
  25. package/lib/solution/BaseSales/index.d.ts +4 -15
  26. package/lib/solution/BaseSales/index.js +64 -24
  27. package/lib/solution/BaseSales/types.d.ts +11 -0
  28. package/lib/solution/BookingByStep/index.d.ts +1 -1
  29. package/lib/solution/BookingTicket/index.d.ts +1 -1
  30. package/lib/solution/BookingTicket/index.js +37 -4
  31. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  32. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  33. package/lib/solution/UnifiedBookingSales/index.d.ts +11 -0
  34. package/lib/solution/UnifiedBookingSales/index.js +54 -0
  35. package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
  36. package/lib/solution/VenueBooking/index.js +9 -8
  37. package/package.json +1 -1
@@ -5,9 +5,11 @@ import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../module
5
5
  import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
6
6
  import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
7
7
  import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesResolveProductAllergyRequirementParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
8
+ import type { BusinessAvailability } from '../../modules/BusinessAvailability';
8
9
  import { BookingTicket } from '../BookingTicket';
9
10
  import type { AllergyRequirement } from '../../model/strategy/adapter/itemRule';
10
11
  export * from './types';
12
+ export type { BusinessAvailability, BusinessClosedBehavior } from '../../modules/BusinessAvailability';
11
13
  export { AvailabilityError } from '../../modules/ResourcePlanner';
12
14
  /**
13
15
  * Converts Rules/Order discount internals into a small UI-facing diagnostic. The result keeps
@@ -60,6 +62,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
60
62
  protected defaultVersion: string;
61
63
  protected store: UnifiedBookingSalesState;
62
64
  protected pickupTimingEnabled: boolean;
65
+ private businessAvailabilityController?;
63
66
  private runtimeOpenDataScope;
64
67
  private runtimeOpenDataSnapshot;
65
68
  private runtimeOpenDataModule;
@@ -86,6 +89,14 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
86
89
  private allergyItemRuleConfigsPromise;
87
90
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
88
91
  protected getSubmitOrderSalesChannel(): string;
92
+ /** Only the explicit Kiosk Sales consumer entry enables this policy; POS stays unchanged. */
93
+ protected isBusinessAvailabilityEnabled(): boolean;
94
+ protected getBusinessAvailabilityScope(): string;
95
+ private getBusinessAvailabilityController;
96
+ getBusinessAvailability(): Promise<BusinessAvailability>;
97
+ /** Internal final-write assertion; does not fetch OpenData or Schedule. */
98
+ assertBusinessAvailability(): void;
99
+ protected getSubModuleHooks(moduleName: string): any;
89
100
  private createAvailabilityFacadeError;
90
101
  private getAvailabilityScopeDescriptor;
91
102
  private normalizeAvailabilityIdList;
@@ -49,6 +49,7 @@ Object.keys(_types).forEach(function (key) {
49
49
  });
50
50
  });
51
51
  var _remoteOccupancyCache = require("./remoteOccupancyCache");
52
+ var _businessAvailability = require("./businessAvailability");
52
53
  var _BookingTicket = require("../BookingTicket");
53
54
  var _localClock = require("../../modules/ResourcePlanner/localClock");
54
55
  var _platform = require("../../utils/platform");
@@ -1199,6 +1200,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1199
1200
  defaultVersion = '1.0.0';
1200
1201
  store = {};
1201
1202
  pickupTimingEnabled = true;
1203
+ businessAvailabilityController;
1202
1204
  runtimeOpenDataScope = null;
1203
1205
  runtimeOpenDataSnapshot = null;
1204
1206
  runtimeOpenDataModule = null;
@@ -1241,6 +1243,57 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1241
1243
  const channel = String(this.otherParams?.channel ?? '').trim();
1242
1244
  return channel || super.getSubmitOrderSalesChannel();
1243
1245
  }
1246
+
1247
+ /** Only the explicit Kiosk Sales consumer entry enables this policy; POS stays unchanged. */
1248
+ isBusinessAvailabilityEnabled() {
1249
+ return this.otherParams?.enableBusinessAvailability === true && ['pc', 'h5', 'kiosk'].includes((0, _platform.normalizeRuntimePlatform)(this.otherParams?.platform));
1250
+ }
1251
+ getBusinessAvailabilityScope() {
1252
+ return `${this.getRuntimeOpenDataScope()}:${this.runtimeOpenDataGeneration}`;
1253
+ }
1254
+ getBusinessAvailabilityController() {
1255
+ if (!this.businessAvailabilityController) {
1256
+ this.businessAvailabilityController = new _businessAvailability.BusinessAvailabilityController({
1257
+ loadOpenData: () => this.loadOpenDataConfig(),
1258
+ getSchedule: () => this.store.schedule,
1259
+ getTimezone: () => String(this.otherParams?.businessTimezone || this.getPickupTimingContextData('timezone') || ''),
1260
+ getScope: () => this.getBusinessAvailabilityScope()
1261
+ });
1262
+ }
1263
+ return this.businessAvailabilityController;
1264
+ }
1265
+ getBusinessAvailability() {
1266
+ return this.getBusinessAvailabilityController().getAvailability();
1267
+ }
1268
+
1269
+ /** Internal final-write assertion; does not fetch OpenData or Schedule. */
1270
+ assertBusinessAvailability() {
1271
+ if (this.isBusinessAvailabilityEnabled()) this.getBusinessAvailabilityController().assertAvailable();
1272
+ }
1273
+ getSubModuleHooks(moduleName) {
1274
+ const hooks = super.getSubModuleHooks(moduleName);
1275
+ if (moduleName !== 'order' || !this.isBusinessAvailabilityEnabled()) return hooks;
1276
+ let lastScope;
1277
+ let lastExistingScope;
1278
+ let scopeToken = {};
1279
+ return {
1280
+ ...hooks,
1281
+ getCartIntentScope: () => {
1282
+ const scope = this.getBusinessAvailabilityScope();
1283
+ const existingScope = hooks?.getCartIntentScope?.();
1284
+ if (scope !== lastScope || !Object.is(existingScope, lastExistingScope)) {
1285
+ lastScope = scope;
1286
+ lastExistingScope = existingScope;
1287
+ scopeToken = {};
1288
+ }
1289
+ return scopeToken;
1290
+ },
1291
+ beforeCartIntentCommit: context => {
1292
+ this.assertBusinessAvailability();
1293
+ hooks?.beforeCartIntentCommit?.(context);
1294
+ }
1295
+ };
1296
+ }
1244
1297
  createAvailabilityFacadeError(code, message, details) {
1245
1298
  return new _ResourcePlanner.AvailabilityError(code, message, details);
1246
1299
  }
@@ -1714,6 +1767,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1714
1767
  });
1715
1768
  }
1716
1769
  resetRuntimeOpenData() {
1770
+ this.businessAvailabilityController?.invalidate();
1717
1771
  this.runtimeOpenDataGeneration += 1;
1718
1772
  this.runtimeOpenDataScope = null;
1719
1773
  this.runtimeOpenDataSnapshot = null;
@@ -216,6 +216,8 @@ export interface UnifiedBookingSalesDiscountResult {
216
216
  summaryAfter?: unknown;
217
217
  }
218
218
  export interface UnifiedBookingSalesApi {
219
+ /** Uses cached business settings and evaluates the current store-local clock. */
220
+ getBusinessAvailability: () => Promise<import('../../modules/BusinessAvailability').BusinessAvailability>;
219
221
  loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
220
222
  /** Returns the latest OpenData payload cached by this solution instance. */
221
223
  getOpenData: () => Promise<OpenDataConfig | null>;
@@ -248,7 +248,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
248
248
  };
249
249
  }
250
250
  readProductOriginFromTempOrder(tempOrder, product) {
251
- const uid = product.metadata?.unique_identification_number || product.identity_key;
251
+ const uid = (0, _utils3.getOrderProductLineUid)(product);
252
252
  if (uid && tempOrder._extend?.productsByUid?.[uid]?.origin) {
253
253
  return tempOrder._extend.productsByUid[uid].origin;
254
254
  }
@@ -1107,7 +1107,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1107
1107
  tempOrder.bookings = tempOrder.bookings || [];
1108
1108
  for (let i = 0; i < merged.length; i++) {
1109
1109
  const group = merged[i];
1110
- const identityKey = (0, _slotMerge.buildVenueIdentityKey)(resourceId, i);
1110
+ const productUid = (0, _slotMerge.buildVenueIdentityKey)(resourceId, i);
1111
1111
  const bookingUuid = (0, _utils3.createUuidV4)();
1112
1112
  const startMoment = (0, _dayjs.default)(group.startTime, 'YYYY-MM-DD HH:mm');
1113
1113
  const endMoment = (0, _dayjs.default)(group.endTime, 'YYYY-MM-DD HH:mm');
@@ -1180,12 +1180,12 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1180
1180
  const normalizedVenueOrderProduct = (0, _utils.normalizeOrderProduct)({
1181
1181
  product_id: mapping.productId,
1182
1182
  product_variant_id: 0,
1183
- identity_key: identityKey,
1184
1183
  num: 1,
1185
1184
  selling_price: group.totalPrice,
1186
1185
  original_price: group.totalPrice,
1187
1186
  is_charge_tax: venueProduct?.is_charge_tax ?? 0,
1188
1187
  metadata: {
1188
+ unique_identification_number: productUid,
1189
1189
  venue_booking: true,
1190
1190
  ...(productTitle ? {
1191
1191
  product_title: productTitle
@@ -1210,7 +1210,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1210
1210
  ...normalizedVenueOrderProduct,
1211
1211
  product_title: productTitle
1212
1212
  } : normalizedVenueOrderProduct;
1213
- this.attachProductOriginToTempOrder(tempOrder, identityKey, venueProductOrigin);
1213
+ this.attachProductOriginToTempOrder(tempOrder, productUid, venueProductOrigin);
1214
1214
  tempOrder.products.push(venueOrderProduct);
1215
1215
  const booking = (0, _slotMerge.buildVenueBookingEntry)({
1216
1216
  group,
@@ -1218,7 +1218,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1218
1218
  mapping,
1219
1219
  rawResource,
1220
1220
  bookingUuid,
1221
- productUid: identityKey,
1221
+ productUid,
1222
1222
  childResources: childRawResources
1223
1223
  });
1224
1224
  tempOrder.bookings.push(booking);
@@ -1624,7 +1624,8 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1624
1624
  const venueBookingUids = new Set();
1625
1625
  for (const product of tempOrder.products || []) {
1626
1626
  if (!product?.metadata?.venue_booking) continue;
1627
- if (product.identity_key) venueProductUids.add(String(product.identity_key));
1627
+ const productUid = (0, _utils3.getOrderProductLineUid)(product);
1628
+ if (productUid) venueProductUids.add(productUid);
1628
1629
  if (product.metadata?.booking_uid) {
1629
1630
  venueBookingUids.add(String(product.metadata.booking_uid));
1630
1631
  }
@@ -1853,7 +1854,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1853
1854
  },
1854
1855
  _origin: origin
1855
1856
  });
1856
- const productUid = String(product.metadata?.unique_identification_number || '');
1857
+ const productUid = (0, _utils3.getOrderProductLineUid)(product) || '';
1857
1858
  this.attachProductOriginToTempOrder(tempOrder, productUid, origin);
1858
1859
  tempOrder.products.push(product);
1859
1860
  hasChanges = true;
@@ -1879,7 +1880,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
1879
1880
  }
1880
1881
  };
1881
1882
  if (delta > 0 || Boolean(sourceItem && (!previousOrigin || previousOrigin?.price !== sourceItem?.price))) {
1882
- const productUid = String(nextProduct.metadata?.unique_identification_number || '');
1883
+ const productUid = (0, _utils3.getOrderProductLineUid)(nextProduct) || '';
1883
1884
  this.attachProductOriginToTempOrder(tempOrder, productUid, nextOrigin);
1884
1885
  tempOrder.products[productIndex] = nextProduct;
1885
1886
  hasChanges = true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.130",
4
+ "version": "2.3.132",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",