@pisell/pisellos 2.3.195 → 2.3.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  2. package/dist/modules/BookingContext/utils/calendarBooking.js +207 -0
  3. package/dist/modules/BookingContext/utils/index.d.ts +1 -0
  4. package/dist/modules/BookingContext/utils/index.js +1 -0
  5. package/dist/modules/BookingContext/utils/productExtend.d.ts +6 -0
  6. package/dist/modules/BookingContext/utils/productExtend.js +21 -0
  7. package/dist/modules/Order/index.d.ts +3 -0
  8. package/dist/modules/Order/index.js +127 -46
  9. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  10. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  11. package/dist/modules/Product/index.d.ts +1 -1
  12. package/dist/modules/ResourcePlanner/planner.js +24 -0
  13. package/dist/modules/ResourcePlanner/types.d.ts +7 -0
  14. package/dist/server/index.js +207 -193
  15. package/dist/server/modules/order/index.js +2 -1
  16. package/dist/shared/receipt/small-ticket.d.ts +3 -0
  17. package/dist/shared/receipt/small-ticket.js +26 -3
  18. package/dist/solution/BookingByStep/index.d.ts +2 -2
  19. package/dist/solution/BookingTicket/index.d.ts +2 -14
  20. package/dist/solution/BookingTicket/index.js +8 -4
  21. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  22. package/dist/solution/BookingTicket/utils/addProductDecision.js +35 -8
  23. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  24. package/dist/solution/BookingTicket/utils/resolveUniqueCartDetail.js +188 -0
  25. package/dist/solution/OrderInvoicePreview/index.js +13 -8
  26. package/dist/solution/UnifiedBookingSales/index.d.ts +16 -2
  27. package/dist/solution/UnifiedBookingSales/index.js +1670 -1377
  28. package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
  29. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
  30. package/lib/modules/BookingContext/utils/calendarBooking.d.ts +15 -0
  31. package/lib/modules/BookingContext/utils/calendarBooking.js +156 -0
  32. package/lib/modules/BookingContext/utils/index.d.ts +1 -0
  33. package/lib/modules/BookingContext/utils/index.js +11 -0
  34. package/lib/modules/BookingContext/utils/productExtend.d.ts +6 -0
  35. package/lib/modules/BookingContext/utils/productExtend.js +23 -0
  36. package/lib/modules/Order/index.d.ts +3 -0
  37. package/lib/modules/Order/index.js +85 -16
  38. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  39. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  40. package/lib/modules/Product/index.d.ts +1 -1
  41. package/lib/modules/ResourcePlanner/planner.js +23 -0
  42. package/lib/modules/ResourcePlanner/types.d.ts +7 -0
  43. package/lib/server/index.js +21 -5
  44. package/lib/server/modules/order/index.js +2 -1
  45. package/lib/shared/receipt/small-ticket.d.ts +3 -0
  46. package/lib/shared/receipt/small-ticket.js +24 -1
  47. package/lib/solution/BookingByStep/index.d.ts +2 -2
  48. package/lib/solution/BookingTicket/index.d.ts +2 -14
  49. package/lib/solution/BookingTicket/index.js +4 -2
  50. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -0
  51. package/lib/solution/BookingTicket/utils/addProductDecision.js +33 -3
  52. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.d.ts +8 -0
  53. package/lib/solution/BookingTicket/utils/resolveUniqueCartDetail.js +136 -0
  54. package/lib/solution/OrderInvoicePreview/index.js +6 -1
  55. package/lib/solution/UnifiedBookingSales/index.d.ts +16 -2
  56. package/lib/solution/UnifiedBookingSales/index.js +176 -36
  57. package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
  58. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
  59. package/package.json +1 -1
@@ -1507,6 +1507,96 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1507
1507
  }
1508
1508
  };
1509
1509
  }
1510
+
1511
+ /** Reuse an approved calendar cache; only the final commit may mutate the order. */
1512
+ async prepareDirectAddCalendarBooking(cacheItem, options = {}) {
1513
+ if ((0, _platform.normalizeRuntimePlatform)(this.otherParams?.platform) !== 'pos' || cacheItem?._data?.calendarManualBooking || cacheItem?.duration?.type === 'days') return null;
1514
+ if (!cacheItem?._data?.calendarBookingPreparationKey || (0, _utils.calendarBookingNeedsInput)(cacheItem)) {
1515
+ throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', 'Calendar booking still requires product input.');
1516
+ }
1517
+ const productId = Number(cacheItem.product_id ?? cacheItem.id);
1518
+ const bookingCount = Number(options.bookingCount ?? cacheItem._extend?.quantity ?? 1);
1519
+ const capacity = cacheItem._extend?.capacity || [];
1520
+ const partySize = Array.isArray(capacity) ? Math.max(1, capacity.reduce((sum, item) => sum + Number(item.value), 0)) : NaN;
1521
+ if (!Number.isSafeInteger(productId) || productId <= 0 || !Number.isInteger(bookingCount) || bookingCount <= 0 || !Array.isArray(capacity) || !capacity.every(item => Number.isInteger(Number(item.value)) && Number(item.value) >= 0) || !Number.isInteger(partySize)) throw new _ResourcePlanner.AvailabilityError('INVALID_RESERVATION_QUANTITY', 'Invalid calendar booking quantity.');
1522
+ const product = normalizeProductForAvailability(cacheItem, this.getAvailabilityScheduleCatalog(), this.getAvailabilityRuntimeOffsetMinutes());
1523
+ if (product.kind !== 'duration' && product.kind !== 'session') return null;
1524
+ const range = {
1525
+ startAt: `${(0, _dayjs.default)(cacheItem._extend.start_date).format('YYYY-MM-DD')}T${cacheItem._extend.start_time}:00${(0, _localClock.formatFixedOffset)(this.getAvailabilityRuntimeOffsetMinutes())}`,
1526
+ endAt: `${(0, _dayjs.default)(cacheItem._extend.end_date).format('YYYY-MM-DD')}T${cacheItem._extend.end_time}:00${(0, _localClock.formatFixedOffset)(this.getAvailabilityRuntimeOffsetMinutes())}`
1527
+ };
1528
+ const requirementSelections = [];
1529
+ for (const [formId, rows] of Object.entries(cacheItem._extend?.resource || {})) {
1530
+ if (!Array.isArray(rows)) throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', 'Invalid selected calendar resources.');
1531
+ if (!rows.length) continue;
1532
+ const groups = (product.requirementGroups || []).filter(group => String(group.formId) === formId);
1533
+ if (groups.length !== 1 || rows.some(row => row.form_id != null && String(row.form_id) !== formId)) {
1534
+ throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', 'Calendar resource group does not belong to this product.');
1535
+ }
1536
+ requirementSelections.push({
1537
+ requirementGroupId: groups[0].id,
1538
+ formId: groups[0].formId,
1539
+ resourceIds: rows.map(row => row.relation_id ?? row.resource_id)
1540
+ });
1541
+ }
1542
+ const order = this.getTempOrder();
1543
+ const calendarOrderSessionId = this.getOrderSessionId();
1544
+ const scope = JSON.stringify(this.getAvailabilityScopeDescriptor());
1545
+ const assertCurrent = () => {
1546
+ options.availabilityCommitGuard?.();
1547
+ if (calendarOrderSessionId && !this.isOrderSessionCurrent(calendarOrderSessionId) || this.getTempOrder() !== order || JSON.stringify(this.getAvailabilityScopeDescriptor()) !== scope) {
1548
+ throw new _ResourcePlanner.AvailabilityError('AVAILABILITY_SELECTION_STALE', 'Calendar booking order changed.');
1549
+ }
1550
+ };
1551
+ let contextId;
1552
+ try {
1553
+ assertCurrent();
1554
+ const context = await this.prepareAvailabilityProjection({
1555
+ productIds: [productId],
1556
+ dateRange: {
1557
+ startDate: range.startAt.slice(0, 10),
1558
+ endDate: range.endAt.slice(0, 10)
1559
+ },
1560
+ rawProducts: [...this.unifiedProductCatalog.filter(item => String(item.id) !== String(productId)), cacheItem]
1561
+ });
1562
+ contextId = context.contextId;
1563
+ assertCurrent();
1564
+ const groups = await this.getProductTimeRanges(contextId, {
1565
+ productIds: [productId],
1566
+ requestedRangesByProductId: {
1567
+ [String(productId)]: range
1568
+ }
1569
+ });
1570
+ assertCurrent();
1571
+ const ranges = groups.find(group => String(group.productId) === String(productId))?.ranges || [];
1572
+ if (ranges.length !== 1) throw new _ResourcePlanner.AvailabilityError('REVALIDATION_FAILED', 'Calendar booking requires one exact interval.');
1573
+ const candidate = ranges[0];
1574
+ const contextEntry = this.getAvailabilityContextEntry(contextId);
1575
+ contextEntry.calendarOrderSessionId = calendarOrderSessionId ?? undefined;
1576
+ const projection = this.getActiveAvailabilityProjectionEntry(contextEntry).projection;
1577
+ const forced = buildPosForcedAvailabilityAssignments({
1578
+ product,
1579
+ resources: projection.resources,
1580
+ candidate,
1581
+ requirementSelections,
1582
+ partySize
1583
+ });
1584
+ if (forced.conflicts.length) throw new _ResourcePlanner.AvailabilityError('REVALIDATION_FAILED', 'Invalid calendar resource selection.', {
1585
+ validation: forced
1586
+ });
1587
+ return {
1588
+ cacheItem,
1589
+ contextId,
1590
+ candidate,
1591
+ requirementSelections,
1592
+ partySize,
1593
+ bookingCount
1594
+ };
1595
+ } catch (error) {
1596
+ if (contextId) this.releaseAvailabilityContext(contextId);
1597
+ throw error;
1598
+ }
1599
+ }
1510
1600
  async resolveAvailabilityPrepareDefaults(params) {
1511
1601
  const needsOperatingHours = params.businessHours === undefined;
1512
1602
  const needsTimeSlice = params.slotStepMinutes === undefined;
@@ -2739,16 +2829,25 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2739
2829
  if (this.venueCatalogMenus?.promise === promise) this.venueCatalogMenus = undefined;
2740
2830
  });
2741
2831
  }
2742
- const pricingMenus = await this.venueCatalogMenus.promise;
2743
- const menus = (0, _venueCatalogSession.validateVenueMenus)(pricingMenus, menuIds);
2832
+ const menuCache = this.venueCatalogMenus;
2833
+ const pricingMenus = await menuCache.promise;
2744
2834
  assertCurrent();
2835
+ let menus;
2836
+ try {
2837
+ menus = (0, _venueCatalogSession.validateVenueMenus)(pricingMenus, menuIds);
2838
+ } catch (error) {
2839
+ // A malformed selected menu must be fetched again on explicit retry.
2840
+ if (this.venueCatalogMenus === menuCache) this.venueCatalogMenus = undefined;
2841
+ throw error;
2842
+ }
2745
2843
  // A menu query with a date may exclude future members. Read the raw ID union
2746
2844
  // without menu/time/customer pricing filters, then filter collection/all menus locally.
2747
2845
  const onlyIds = menus.every(menu => menu.partyroom_package.type === 'products');
2748
2846
  const onlyCollections = menus.every(menu => menu.partyroom_package.type === 'product_collection');
2749
2847
  const productIds = onlyIds ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => Number(product.product_id))))] : undefined;
2750
2848
  const collections = onlyCollections ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => String(product.product_collection_id))))] : undefined;
2751
- const products = onlyIds && !productIds?.length ? [] : await this.store.products.loadVenueCatalogPool({
2849
+ const emptySelection = productIds?.length === 0 || collections?.length === 0;
2850
+ const products = emptySelection ? [] : await this.store.products.loadVenueCatalogPool({
2752
2851
  product_ids: productIds,
2753
2852
  collection: collections,
2754
2853
  category_ids: params.category_ids,
@@ -2759,7 +2858,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2759
2858
  const pool = {
2760
2859
  menus,
2761
2860
  pricingMenus: (0, _lodashEs.cloneDeep)(pricingMenus),
2762
- products: products.filter(product => menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu)))
2861
+ products: products.filter(product => !('deleted_at' in product && product.deleted_at) && (!product.status || product.status === 'published') && menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu)))
2763
2862
  };
2764
2863
  entry.pool = (0, _lodashEs.cloneDeep)(pool);
2765
2864
  // Legacy marketing lookups can reuse complete records without changing
@@ -3212,6 +3311,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3212
3311
  });
3213
3312
  if (orderProduct && typeof orderProduct === 'object') {
3214
3313
  const venueMetadata = Object.fromEntries(['venue_booking_role', 'venue_booking_parent_uid', 'venue_booking_service_datetime', 'venue_booking_scope_key'].filter(key => sourceProduct.metadata?.[key] !== undefined).map(key => [key, sourceProduct.metadata[key]]));
3314
+ const isVenueExtra = ownershipKey === 'unified_booking_sales_retail' && ['tickets_extra', 'party_extra'].includes(venueMetadata.venue_booking_role);
3315
+ if (isVenueExtra && sourceProduct.metadata?.venue_extra_holder_variant_id !== undefined) {
3316
+ // null explicitly clears a previous SKU override. The adapter pairs the marker
3317
+ // with its resolved policy, independent of the product's original settings.
3318
+ venueMetadata.venue_extra_holder_variant_id = sourceProduct.metadata.venue_extra_holder_variant_id;
3319
+ const holderConfig = sourceProduct.holder_config ?? sourceProduct.metadata.holder_config;
3320
+ if (holderConfig) venueMetadata.holder_config = (0, _lodashEs.cloneDeep)(holderConfig);
3321
+ }
3215
3322
  // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
3216
3323
  // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
3217
3324
  orderProduct.metadata = {
@@ -3230,6 +3337,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3230
3337
  quotation_shelf_id: quotationShelfId
3231
3338
  } : {})
3232
3339
  };
3340
+ // Extras use retail order-detail relations even when the catalog product
3341
+ // also has a bookable duration. Order binds the patch to the final line UID.
3342
+ if (isVenueExtra && Array.isArray(sourceProduct._extend?.holder_relations)) {
3343
+ orderProduct._extend = {
3344
+ ...orderProduct._extend,
3345
+ holder_relations: (0, _lodashEs.cloneDeep)(sourceProduct._extend.holder_relations)
3346
+ };
3347
+ }
3233
3348
  }
3234
3349
  return orderProduct;
3235
3350
  }
@@ -3279,6 +3394,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3279
3394
  return true;
3280
3395
  }
3281
3396
 
3397
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
3398
+ supportsVenueExtraHolders() {
3399
+ return true;
3400
+ }
3401
+
3282
3402
  /**
3283
3403
  * Adds one retail line without replacing the cart's existing retail selection.
3284
3404
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -3325,18 +3445,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3325
3445
  }
3326
3446
  };
3327
3447
  guard();
3328
- // Retail extras are order-owned, with their own UID and no Holder/booking.
3448
+ // Retail extras are order-owned, with their own UID and no booking.
3329
3449
  delete orderProduct.unique_identification_number;
3330
3450
  delete meta.unique_identification_number;
3331
3451
  delete meta.venue_booking_parent_uid;
3332
- orderProduct.holder_config = {
3333
- status: 'disable',
3334
- required: 0
3335
- };
3336
- meta.holder_config = {
3337
- status: 'disable',
3338
- required: 0
3339
- };
3340
3452
  return this.addProductToOrder(orderProduct, undefined, {
3341
3453
  disableMerge: true,
3342
3454
  availabilityCommitGuard: guard,
@@ -3353,8 +3465,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3353
3465
  // Its parent UID owns the extra; the parent's appointment time does not price it.
3354
3466
  const purchaseDatetime = String(meta.venue_booking_service_datetime || '');
3355
3467
  const normalizedPurchaseDatetime = purchaseDatetime.length === 16 ? `${purchaseDatetime}:00` : purchaseDatetime;
3356
- const identity = [order?.order_id, order?.external_sale_number];
3357
- const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1];
3468
+ const identity = [order?.order_id, order?.external_sale_number, order?.customer_id];
3469
+ const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1] && order?.customer_id === identity[2];
3358
3470
  const guard = () => {
3359
3471
  params.availabilityCommitGuard?.();
3360
3472
  const parent = (order?.products || []).find(line => getProductLineUid(line) === parentUid);
@@ -3363,14 +3475,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3363
3475
  guard();
3364
3476
  delete orderProduct.unique_identification_number;
3365
3477
  delete orderProduct.metadata.unique_identification_number;
3366
- orderProduct.holder_config = {
3367
- status: 'disable',
3368
- required: 0
3369
- };
3370
- orderProduct.metadata.holder_config = {
3371
- status: 'disable',
3372
- required: 0
3373
- };
3374
3478
  return this.addProductToOrder(orderProduct, undefined, {
3375
3479
  disableMerge: true,
3376
3480
  availabilityCommitGuard: guard,
@@ -3598,12 +3702,12 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3598
3702
  schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
3599
3703
  });
3600
3704
  }
3601
- const normalized = rawProducts.map(product => normalizeProductForAvailability(product, params.scheduleList, this.getAvailabilityRuntimeOffsetMinutes()));
3705
+ const productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
3706
+ const normalized = (productIdSet ? rawProducts.filter(product => productIdSet.has(String(product.id ?? product.product_id))) : rawProducts).map(product => normalizeProductForAvailability(product, params.scheduleList, this.getAvailabilityRuntimeOffsetMinutes()));
3602
3707
  if (!explicitProductIds.length && prepare.resourceIds?.length) {
3603
3708
  return normalized.filter(product => product.requirementGroups?.some(group => group.resourceIds?.some(resourceId => prepare.resourceIds.some(id => sameAvailabilityId(id, resourceId)))));
3604
3709
  }
3605
- const productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
3606
- return productIdSet ? normalized.filter(product => productIdSet.has(String(product.id))) : normalized;
3710
+ return normalized;
3607
3711
  }
3608
3712
 
3609
3713
  /**
@@ -4036,6 +4140,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4036
4140
  lastPreparedAt: params.projection.meta.preparedAt,
4037
4141
  lastSnapshotId: params.projection.meta.snapshotId,
4038
4142
  durationCandidateAnchorAt: previousContext?.durationCandidateAnchorAt ?? this.getAvailabilityDurationCandidateAnchorAt(params.projection),
4143
+ calendarOrderSessionId: previousContext?.calendarOrderSessionId,
4039
4144
  refreshNonce: previousContext?.refreshNonce ?? 0,
4040
4145
  lifecycleGeneration: this.availabilityLifecycleGeneration
4041
4146
  };
@@ -4370,6 +4475,27 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4370
4475
  const isPosAvailabilityRequest = String(this.otherParams?.platform ?? '').trim().toLowerCase() === 'pos';
4371
4476
  const isEditingContext = Boolean(context.prepareParams.editingProductLineUids?.length);
4372
4477
  const editingOffset = (0, _localClock.extractFixedOffsetMinutes)(projectionEntry.projection.meta.now) ?? this.getAvailabilityRuntimeOffsetMinutes();
4478
+ const hasRequestedRanges = Object.keys(request.requestedRangesByProductId || {}).length > 0;
4479
+ if (hasRequestedRanges && (!isPosAvailabilityRequest || strictAvailability || request.rememberedStartAtByProductId || request.rememberedTimeByProductId)) {
4480
+ throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '明确预约范围仅支持 POS 手工选择');
4481
+ }
4482
+ // Calendar entry carries absolute instants. Convert both endpoints once to
4483
+ // the projection clock; never reinterpret their HH:mm as a business date.
4484
+ const requestedRangesByProductId = hasRequestedRanges ? Object.fromEntries(Object.entries(request.requestedRangesByProductId).map(([productId, range]) => {
4485
+ try {
4486
+ const normalizeEndpoint = value => {
4487
+ const scalar = (0, _localClock.localDateTimeToScalar)((0, _localClock.parseLocalDateTime)(value));
4488
+ const inputOffset = (0, _localClock.extractFixedOffsetMinutes)(value) ?? editingOffset;
4489
+ return (0, _localClock.formatLocalDateTime)(scalar + (editingOffset - inputOffset) * 60000, editingOffset);
4490
+ };
4491
+ return [productId, {
4492
+ startAt: normalizeEndpoint(range.startAt),
4493
+ endAt: normalizeEndpoint(range.endAt)
4494
+ }];
4495
+ } catch {
4496
+ throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '手工预约范围必须包含完整有效起止日期时间');
4497
+ }
4498
+ })) : undefined;
4373
4499
  // This new editing input represents an absolute instant. Normalize it once
4374
4500
  // to the projection's fixed business clock before the wall-clock planner.
4375
4501
  const editingStartAtByProductId = isEditingContext && request.editingStartAtByProductId ? Object.fromEntries(Object.entries(request.editingStartAtByProductId).map(([productId, startAt]) => {
@@ -4399,6 +4525,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4399
4525
  ...request,
4400
4526
  dateRange,
4401
4527
  editingStartAtByProductId,
4528
+ requestedRangesByProductId,
4402
4529
  rememberedStartAtByProductId,
4403
4530
  rememberedTimeByProductId,
4404
4531
  ...(rememberedStartAtByProductId || rememberedTimeByProductId ? {
@@ -4417,6 +4544,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4417
4544
  rememberedTimeByProductId,
4418
4545
  useExactDurationCandidateMinute: isPosAvailabilityRequest && !strictAvailability,
4419
4546
  allowSessionCustomRanges: isPosAvailabilityRequest && !strictAvailability,
4547
+ allowRequestedRanges: isPosAvailabilityRequest && !strictAvailability && !rememberedStartAtByProductId && !rememberedTimeByProductId,
4420
4548
  allowExcludedScheduleDateOverride: isPosAvailabilityRequest && !strictAvailability
4421
4549
  }).map(group => ({
4422
4550
  ...group,
@@ -4563,6 +4691,19 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4563
4691
  candidate: params.candidate
4564
4692
  });
4565
4693
  }
4694
+ const calendarOrderSessionId = this.availabilityContextRegistry.get(normalizedContextId)?.calendarOrderSessionId;
4695
+ if (calendarOrderSessionId) {
4696
+ const callerGuard = params.availabilityCommitGuard;
4697
+ params = {
4698
+ ...params,
4699
+ availabilityCommitGuard: () => {
4700
+ callerGuard?.();
4701
+ if (!this.isOrderSessionCurrent(calendarOrderSessionId)) {
4702
+ throw new _ResourcePlanner.AvailabilityError('AVAILABILITY_SELECTION_STALE', 'Calendar booking order session changed.');
4703
+ }
4704
+ }
4705
+ };
4706
+ }
4566
4707
  const isEditingSelection = params.mode === 'edit' || params.mode === 'replace';
4567
4708
  const isPartyReplacement = params.mode === 'replace' || params.relatedRetailProducts !== undefined;
4568
4709
  if (isPartyReplacement && (!isEditingSelection || !Array.isArray(params.relatedRetailProducts))) {
@@ -4762,6 +4903,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4762
4903
  startDate: candidateBusinessDate,
4763
4904
  endDate: candidateBusinessDate
4764
4905
  },
4906
+ ...(allowPosAvailabilityOverride && params.candidate.source === 'duration_window' ? {
4907
+ requestedRangesByProductId: {
4908
+ [String(params.candidate.productId)]: {
4909
+ startAt: params.candidate.bookingStartAt,
4910
+ endAt: params.candidate.bookingEndAt
4911
+ }
4912
+ }
4913
+ } : {}),
4765
4914
  ...(rememberedTimeByProductId ? {
4766
4915
  rememberedTimeByProductId
4767
4916
  } : isRememberedSelection ? {
@@ -4798,6 +4947,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4798
4947
  rememberedTimeByProductId,
4799
4948
  useExactDurationCandidateMinute: allowPosAvailabilityOverride,
4800
4949
  allowSessionCustomRanges: allowPosAvailabilityOverride,
4950
+ allowRequestedRanges: allowPosAvailabilityOverride,
4801
4951
  allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
4802
4952
  }).flatMap(group => group.ranges);
4803
4953
  const refreshedCandidateBase = refreshedRanges.find(candidate => candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt);
@@ -4979,16 +5129,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4979
5129
  const relatedRetailProducts = params.relatedRetailProducts.map(source => {
4980
5130
  const line = this.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
4981
5131
  if (!line) throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
4982
- if (line.metadata?.venue_booking_role === 'party_extra') {
4983
- line.holder_config = {
4984
- status: 'disable',
4985
- required: 0
4986
- };
4987
- line.metadata.holder_config = {
4988
- status: 'disable',
4989
- required: 0
4990
- };
4991
- }
4992
5132
  // This is the only replacement-specific UID restore. Order checks ownership/collisions.
4993
5133
  const sourceUid = getProductLineUid(source);
4994
5134
  if (sourceUid) {
@@ -310,6 +310,7 @@ export interface UnifiedBookingSalesApi {
310
310
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
311
311
  queryProducts: (params?: ProductListStoreQueryParams) => Promise<ProductData[]>;
312
312
  stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
313
+ supportsVenueExtraHolders: () => boolean;
313
314
  addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
314
315
  prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
315
316
  getProductTimeRanges: (contextId: string, request?: GetProductTimeRangesRequest) => Promise<ContextualProductTimeRangeGroup[]>;
@@ -22,22 +22,26 @@ function readVenueCatalogList(response, description) {
22
22
  throw venueCatalogError('VENUE_CATALOG_LOAD_FAILED', response?.message || `${description} could not be loaded.`);
23
23
  }
24
24
  const total = response.data.total ?? response.data.total_count ?? response.data.total_num;
25
- if (total != null && Number.isFinite(Number(total)) && Number(total) > list.length) {
25
+ if (total == null ? list.length >= 999 : !Number.isSafeInteger(Number(total)) || Number(total) < 0 || Number(total) > list.length) {
26
26
  throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', `${description} is incomplete. A complete catalog response is required.`);
27
27
  }
28
+ if (list.some(row => !Number.isSafeInteger(Number(row?.form_record_id)) || Number(row.form_record_id) <= 0)) {
29
+ throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', `${description} contains a record without a valid menu ID.`);
30
+ }
28
31
  return list;
29
32
  }
30
33
  function validateVenueMenus(records, ids) {
31
- return ids.map(id => {
34
+ return ids.flatMap(id => {
32
35
  const menu = records.find(row => Number(row.form_record_id) === id);
33
- const config = menu?.partyroom_package;
34
- if (!menu || !['product_all', 'products', 'product_collection'].includes(config?.type) || !Array.isArray(menu.schedule) || menu.schedule.some(value => !Number.isSafeInteger(Number(value)) || Number(value) <= 0) || config.type !== 'product_all' && (!Array.isArray(config.products) || config.products.some(row => {
36
+ if (!menu || menu.deleted_at || menu.status && menu.status !== 'valid') return [];
37
+ const config = menu.partyroom_package;
38
+ if (!['product_all', 'products', 'product_collection'].includes(config?.type) || !Array.isArray(menu.schedule) || menu.schedule.some(value => !Number.isSafeInteger(Number(value)) || Number(value) <= 0) || config.type !== 'product_all' && (!Array.isArray(config.products) || config.products.some(row => {
35
39
  const value = Number(row?.[config.type === 'products' ? 'product_id' : 'product_collection_id']);
36
40
  return !Number.isSafeInteger(value) || value <= 0;
37
41
  }))) {
38
42
  throw venueCatalogError('VENUE_MENU_INCOMPLETE', 'The configured menu is incomplete. Reload the booking page.');
39
43
  }
40
- return (0, _lodashEs.cloneDeep)(menu);
44
+ return [(0, _lodashEs.cloneDeep)(menu)];
41
45
  });
42
46
  }
43
47
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.195",
4
+ "version": "2.3.197",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",