@pisell/pisellos 2.3.196 → 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 (33) hide show
  1. package/dist/modules/Order/index.d.ts +3 -0
  2. package/dist/modules/Order/index.js +127 -46
  3. package/dist/modules/Order/unpaidAmountGap.d.ts +6 -0
  4. package/dist/modules/Order/unpaidAmountGap.js +72 -0
  5. package/dist/modules/Product/index.d.ts +1 -1
  6. package/dist/server/index.js +180 -176
  7. package/dist/server/modules/order/index.js +2 -1
  8. package/dist/shared/receipt/small-ticket.d.ts +3 -0
  9. package/dist/shared/receipt/small-ticket.js +26 -3
  10. package/dist/solution/BookingByStep/index.d.ts +1 -1
  11. package/dist/solution/BookingTicket/index.d.ts +1 -13
  12. package/dist/solution/OrderInvoicePreview/index.js +13 -8
  13. package/dist/solution/UnifiedBookingSales/index.d.ts +2 -0
  14. package/dist/solution/UnifiedBookingSales/index.js +66 -57
  15. package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
  16. package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
  17. package/lib/modules/Order/index.d.ts +3 -0
  18. package/lib/modules/Order/index.js +85 -16
  19. package/lib/modules/Order/unpaidAmountGap.d.ts +6 -0
  20. package/lib/modules/Order/unpaidAmountGap.js +60 -0
  21. package/lib/modules/Product/index.d.ts +1 -1
  22. package/lib/server/index.js +16 -4
  23. package/lib/server/modules/order/index.js +2 -1
  24. package/lib/shared/receipt/small-ticket.d.ts +3 -0
  25. package/lib/shared/receipt/small-ticket.js +24 -1
  26. package/lib/solution/BookingByStep/index.d.ts +1 -1
  27. package/lib/solution/BookingTicket/index.d.ts +1 -13
  28. package/lib/solution/OrderInvoicePreview/index.js +6 -1
  29. package/lib/solution/UnifiedBookingSales/index.d.ts +2 -0
  30. package/lib/solution/UnifiedBookingSales/index.js +37 -33
  31. package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
  32. package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
  33. package/package.json +1 -1
@@ -2829,16 +2829,25 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2829
2829
  if (this.venueCatalogMenus?.promise === promise) this.venueCatalogMenus = undefined;
2830
2830
  });
2831
2831
  }
2832
- const pricingMenus = await this.venueCatalogMenus.promise;
2833
- const menus = (0, _venueCatalogSession.validateVenueMenus)(pricingMenus, menuIds);
2832
+ const menuCache = this.venueCatalogMenus;
2833
+ const pricingMenus = await menuCache.promise;
2834
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
+ }
2835
2843
  // A menu query with a date may exclude future members. Read the raw ID union
2836
2844
  // without menu/time/customer pricing filters, then filter collection/all menus locally.
2837
2845
  const onlyIds = menus.every(menu => menu.partyroom_package.type === 'products');
2838
2846
  const onlyCollections = menus.every(menu => menu.partyroom_package.type === 'product_collection');
2839
2847
  const productIds = onlyIds ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => Number(product.product_id))))] : undefined;
2840
2848
  const collections = onlyCollections ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => String(product.product_collection_id))))] : undefined;
2841
- 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({
2842
2851
  product_ids: productIds,
2843
2852
  collection: collections,
2844
2853
  category_ids: params.category_ids,
@@ -2849,7 +2858,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2849
2858
  const pool = {
2850
2859
  menus,
2851
2860
  pricingMenus: (0, _lodashEs.cloneDeep)(pricingMenus),
2852
- 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)))
2853
2862
  };
2854
2863
  entry.pool = (0, _lodashEs.cloneDeep)(pool);
2855
2864
  // Legacy marketing lookups can reuse complete records without changing
@@ -3302,6 +3311,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3302
3311
  });
3303
3312
  if (orderProduct && typeof orderProduct === 'object') {
3304
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
+ }
3305
3322
  // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
3306
3323
  // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
3307
3324
  orderProduct.metadata = {
@@ -3320,6 +3337,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3320
3337
  quotation_shelf_id: quotationShelfId
3321
3338
  } : {})
3322
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
+ }
3323
3348
  }
3324
3349
  return orderProduct;
3325
3350
  }
@@ -3369,6 +3394,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3369
3394
  return true;
3370
3395
  }
3371
3396
 
3397
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
3398
+ supportsVenueExtraHolders() {
3399
+ return true;
3400
+ }
3401
+
3372
3402
  /**
3373
3403
  * Adds one retail line without replacing the cart's existing retail selection.
3374
3404
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -3415,18 +3445,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3415
3445
  }
3416
3446
  };
3417
3447
  guard();
3418
- // 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.
3419
3449
  delete orderProduct.unique_identification_number;
3420
3450
  delete meta.unique_identification_number;
3421
3451
  delete meta.venue_booking_parent_uid;
3422
- orderProduct.holder_config = {
3423
- status: 'disable',
3424
- required: 0
3425
- };
3426
- meta.holder_config = {
3427
- status: 'disable',
3428
- required: 0
3429
- };
3430
3452
  return this.addProductToOrder(orderProduct, undefined, {
3431
3453
  disableMerge: true,
3432
3454
  availabilityCommitGuard: guard,
@@ -3443,8 +3465,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3443
3465
  // Its parent UID owns the extra; the parent's appointment time does not price it.
3444
3466
  const purchaseDatetime = String(meta.venue_booking_service_datetime || '');
3445
3467
  const normalizedPurchaseDatetime = purchaseDatetime.length === 16 ? `${purchaseDatetime}:00` : purchaseDatetime;
3446
- const identity = [order?.order_id, order?.external_sale_number];
3447
- 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];
3448
3470
  const guard = () => {
3449
3471
  params.availabilityCommitGuard?.();
3450
3472
  const parent = (order?.products || []).find(line => getProductLineUid(line) === parentUid);
@@ -3453,14 +3475,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3453
3475
  guard();
3454
3476
  delete orderProduct.unique_identification_number;
3455
3477
  delete orderProduct.metadata.unique_identification_number;
3456
- orderProduct.holder_config = {
3457
- status: 'disable',
3458
- required: 0
3459
- };
3460
- orderProduct.metadata.holder_config = {
3461
- status: 'disable',
3462
- required: 0
3463
- };
3464
3478
  return this.addProductToOrder(orderProduct, undefined, {
3465
3479
  disableMerge: true,
3466
3480
  availabilityCommitGuard: guard,
@@ -5115,16 +5129,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
5115
5129
  const relatedRetailProducts = params.relatedRetailProducts.map(source => {
5116
5130
  const line = this.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
5117
5131
  if (!line) throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
5118
- if (line.metadata?.venue_booking_role === 'party_extra') {
5119
- line.holder_config = {
5120
- status: 'disable',
5121
- required: 0
5122
- };
5123
- line.metadata.holder_config = {
5124
- status: 'disable',
5125
- required: 0
5126
- };
5127
- }
5128
5132
  // This is the only replacement-specific UID restore. Order checks ownership/collisions.
5129
5133
  const sourceUid = getProductLineUid(source);
5130
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.196",
4
+ "version": "2.3.197",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",