@pisell/pisellos 0.10.79 → 0.10.81

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.
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
@@ -7156,7 +7156,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7156
7156
  case 0:
7157
7157
  return _context44.abrupt("return", this.queueCartCommand(function () {
7158
7158
  return _this49.removeProductsFromOrderDraft(identities, options);
7159
- }, Boolean(options === null || options === void 0 ? void 0 : options.isCurrentOrder)));
7159
+ }, Boolean((options === null || options === void 0 ? void 0 : options.isCurrentOrder) || (options === null || options === void 0 ? void 0 : options.beforeApply))));
7160
7160
  case 1:
7161
7161
  case "end":
7162
7162
  return _context44.stop();
@@ -7172,8 +7172,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7172
7172
  key: "removeProductsFromOrderDraft",
7173
7173
  value: function () {
7174
7174
  var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(identities, options) {
7175
- var _this50 = this;
7176
- var _this$store$tempOrder10, mutation, tempOrder, identity, isCurrentOrder, beforeCommit, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator28, _step28, _loop5, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
7175
+ var _options$beforeApply3,
7176
+ _this50 = this;
7177
+ var _this$store$tempOrder10, _this$store$tempOrder11, guarded, mutation, tempOrder, identity, isCurrentOrder, beforeCommit, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator28, _step28, _loop5, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
7177
7178
  return _regeneratorRuntime().wrap(function _callee41$(_context46) {
7178
7179
  while (1) switch (_context46.prev = _context46.next) {
7179
7180
  case 0:
@@ -7183,8 +7184,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7183
7184
  }
7184
7185
  return _context46.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
7185
7186
  case 2:
7187
+ // Validate inside the command queue, before creating or mutating the draft.
7188
+ if (identities.length) options === null || options === void 0 || (_options$beforeApply3 = options.beforeApply) === null || _options$beforeApply3 === void 0 || _options$beforeApply3.call(options);
7189
+ if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
7190
+ _context46.next = 5;
7191
+ break;
7192
+ }
7193
+ return _context46.abrupt("return", ((_this$store$tempOrder11 = this.store.tempOrder) === null || _this$store$tempOrder11 === void 0 ? void 0 : _this$store$tempOrder11.products) || []);
7194
+ case 5:
7195
+ guarded = Boolean((options === null || options === void 0 ? void 0 : options.isCurrentOrder) || (options === null || options === void 0 ? void 0 : options.beforeApply));
7186
7196
  mutation = this.beginCartMutation({
7187
- forceDraft: Boolean(options === null || options === void 0 ? void 0 : options.isCurrentOrder)
7197
+ forceDraft: guarded
7188
7198
  });
7189
7199
  tempOrder = mutation.draft;
7190
7200
  identity = [mutation.current.order_id, mutation.current.external_sale_number];
@@ -7192,17 +7202,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7192
7202
  var _options$isCurrentOrd3, _options$isCurrentOrd4;
7193
7203
  return _this50.store.tempOrder === mutation.current && mutation.current.order_id === identity[0] && mutation.current.external_sale_number === identity[1] && ((_options$isCurrentOrd3 = options === null || options === void 0 || (_options$isCurrentOrd4 = options.isCurrentOrder) === null || _options$isCurrentOrd4 === void 0 ? void 0 : _options$isCurrentOrd4.call(options)) !== null && _options$isCurrentOrd3 !== void 0 ? _options$isCurrentOrd3 : true);
7194
7204
  };
7195
- beforeCommit = options !== null && options !== void 0 && options.isCurrentOrder ? function () {
7205
+ beforeCommit = guarded ? function () {
7206
+ var _options$beforeApply4;
7207
+ // Inventory validation can await. Recheck the live source snapshot before
7208
+ // publication; never run this row-snapshot guard during finalization.
7209
+ options === null || options === void 0 || (_options$beforeApply4 = options.beforeApply) === null || _options$beforeApply4 === void 0 || _options$beforeApply4.call(options);
7196
7210
  if (!isCurrentOrder()) throw Object.assign(new Error('Order product removal interrupted by an order change'), {
7197
7211
  code: 'AVAILABILITY_SELECTION_STALE'
7198
7212
  });
7199
7213
  } : undefined;
7200
7214
  if (identities.length) {
7201
- _context46.next = 9;
7215
+ _context46.next = 13;
7202
7216
  break;
7203
7217
  }
7204
7218
  return _context46.abrupt("return", tempOrder.products);
7205
- case 9:
7219
+ case 13:
7206
7220
  // 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
7207
7221
  this.ensureSalesNotesLoadedForMutation(tempOrder);
7208
7222
  this.repairDuplicateProductLineIdentities(tempOrder);
@@ -7234,7 +7248,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7234
7248
  }
7235
7249
  linkedBookingUidsToRemove = new Set();
7236
7250
  _iterator28 = _createForOfIteratorHelper(matchedProducts);
7237
- _context46.prev = 22;
7251
+ _context46.prev = 26;
7238
7252
  _loop5 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop5() {
7239
7253
  var _metadata11, _metadata12, _metadata13, _metadata14;
7240
7254
  var product, productUid, productBookingUid, isAddTimeProduct;
@@ -7269,33 +7283,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7269
7283
  }, _loop5);
7270
7284
  });
7271
7285
  _iterator28.s();
7272
- case 25:
7286
+ case 29:
7273
7287
  if ((_step28 = _iterator28.n()).done) {
7274
- _context46.next = 31;
7288
+ _context46.next = 35;
7275
7289
  break;
7276
7290
  }
7277
- return _context46.delegateYield(_loop5(), "t0", 27);
7278
- case 27:
7291
+ return _context46.delegateYield(_loop5(), "t0", 31);
7292
+ case 31:
7279
7293
  if (!_context46.t0) {
7280
- _context46.next = 29;
7294
+ _context46.next = 33;
7281
7295
  break;
7282
7296
  }
7283
- return _context46.abrupt("continue", 29);
7284
- case 29:
7285
- _context46.next = 25;
7297
+ return _context46.abrupt("continue", 33);
7298
+ case 33:
7299
+ _context46.next = 29;
7286
7300
  break;
7287
- case 31:
7288
- _context46.next = 36;
7301
+ case 35:
7302
+ _context46.next = 40;
7289
7303
  break;
7290
- case 33:
7291
- _context46.prev = 33;
7292
- _context46.t1 = _context46["catch"](22);
7304
+ case 37:
7305
+ _context46.prev = 37;
7306
+ _context46.t1 = _context46["catch"](26);
7293
7307
  _iterator28.e(_context46.t1);
7294
- case 36:
7295
- _context46.prev = 36;
7308
+ case 40:
7309
+ _context46.prev = 40;
7296
7310
  _iterator28.f();
7297
- return _context46.finish(36);
7298
- case 39:
7311
+ return _context46.finish(40);
7312
+ case 43:
7299
7313
  if (linkedBookingUidsToRemove.size > 0) {
7300
7314
  // 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
7301
7315
  tempOrder.products = (tempOrder.products || []).filter(function (line) {
@@ -7326,28 +7340,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
7326
7340
  }));
7327
7341
  this.removeSalesNotesForMissingProductLines(tempOrder);
7328
7342
  if (!mutation.commit) {
7329
- _context46.next = 47;
7343
+ _context46.next = 51;
7330
7344
  break;
7331
7345
  }
7332
- _context46.next = 46;
7346
+ _context46.next = 50;
7333
7347
  return mutation.commit(beforeCommit);
7334
- case 46:
7348
+ case 50:
7335
7349
  tempOrder = _context46.sent;
7336
- case 47:
7337
- _context46.next = 49;
7338
- return this.finalizeAfterProductsMutation(tempOrder, options !== null && options !== void 0 && options.isCurrentOrder ? {
7350
+ case 51:
7351
+ _context46.next = 53;
7352
+ return this.finalizeAfterProductsMutation(tempOrder, guarded ? {
7339
7353
  isCurrentOrder: isCurrentOrder
7340
7354
  } : undefined);
7341
- case 49:
7355
+ case 53:
7342
7356
  this.logInfo('removeProductsFromOrder success', {
7343
7357
  identities: identities
7344
7358
  });
7345
7359
  return _context46.abrupt("return", tempOrder.products);
7346
- case 51:
7360
+ case 55:
7347
7361
  case "end":
7348
7362
  return _context46.stop();
7349
7363
  }
7350
- }, _callee41, this, [[22, 33, 36, 39]]);
7364
+ }, _callee41, this, [[26, 37, 40, 43]]);
7351
7365
  }));
7352
7366
  function removeProductsFromOrderDraft(_x53, _x54) {
7353
7367
  return _removeProductsFromOrderDraft.apply(this, arguments);
@@ -9144,8 +9158,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
9144
9158
  }, {
9145
9159
  key: "getVouchers",
9146
9160
  value: function getVouchers() {
9147
- var _this$store$tempOrder11;
9148
- return ((_this$store$tempOrder11 = this.store.tempOrder) === null || _this$store$tempOrder11 === void 0 ? void 0 : _this$store$tempOrder11.vouchers) || [];
9161
+ var _this$store$tempOrder12;
9162
+ return ((_this$store$tempOrder12 = this.store.tempOrder) === null || _this$store$tempOrder12 === void 0 ? void 0 : _this$store$tempOrder12.vouchers) || [];
9149
9163
  }
9150
9164
  }], [{
9151
9165
  key: "populateSavedAmounts",
@@ -482,6 +482,8 @@ export interface ReplaceBookingProductWithRelatedRetailParams {
482
482
  * 预约合并行减量时仍删除最新真实行,再把剩余代表行移动到被删除代表行原位置。
483
483
  */
484
484
  export interface RemoveProductsFromOrderOptions {
485
+ /** Synchronous, read-only validation before draft mutation and again before publication after async guards; may throw. Never called during finalization. */
486
+ beforeApply?: () => void;
485
487
  /** Prevent an asynchronous deletion/finalization from crossing order or business scopes. */
486
488
  isCurrentOrder?: () => boolean;
487
489
  preserveDisplayPosition?: {
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "session" | "duration";
53
53
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
373
373
  };
374
374
  setOtherData(key: string, value: any): void;
375
375
  getOtherData(key: string): any;
376
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
376
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
377
377
  /**
378
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
379
379
  *
@@ -479,7 +479,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
479
479
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
480
480
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
481
481
  */
482
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
482
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
483
+ action: "reloadCatalog";
484
+ } | {
485
+ action: "add";
486
+ cacheItem: any;
487
+ } | {
488
+ action: "requiresDetail";
489
+ payload: AddProductRequiresDetailPayload;
490
+ } | {
491
+ action: "requiresBookingEdit";
492
+ cacheItem: any;
493
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
494
+ };
483
495
  /** 规格弹窗 callback 后的第二段决策。 */
484
496
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
485
497
  /**
@@ -289,6 +289,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
289
289
  stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
290
290
  /** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
291
291
  supportsVenueTicketExtras(): boolean;
292
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
293
+ supportsVenueExtraHolders(): boolean;
292
294
  /**
293
295
  * Adds one retail line without replacing the cart's existing retail selection.
294
296
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -3675,7 +3675,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3675
3675
  assertCurrent: assertCurrent,
3676
3676
  load: function () {
3677
3677
  var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
3678
- var promise, pricingMenus, menus, onlyIds, onlyCollections, productIds, collections, products, pool;
3678
+ var promise, menuCache, pricingMenus, menus, onlyIds, onlyCollections, productIds, collections, emptySelection, products, pool;
3679
3679
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3680
3680
  while (1) switch (_context34.prev = _context34.next) {
3681
3681
  case 0:
@@ -3699,12 +3699,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3699
3699
  if (((_this14$venueCatalogM = _this14.venueCatalogMenus) === null || _this14$venueCatalogM === void 0 ? void 0 : _this14$venueCatalogM.promise) === promise) _this14.venueCatalogMenus = undefined;
3700
3700
  });
3701
3701
  }
3702
- _context34.next = 3;
3703
- return _this14.venueCatalogMenus.promise;
3704
- case 3:
3702
+ menuCache = _this14.venueCatalogMenus;
3703
+ _context34.next = 4;
3704
+ return menuCache.promise;
3705
+ case 4:
3705
3706
  pricingMenus = _context34.sent;
3706
- menus = validateVenueMenus(pricingMenus, menuIds);
3707
3707
  assertCurrent();
3708
+ _context34.prev = 6;
3709
+ menus = validateVenueMenus(pricingMenus, menuIds);
3710
+ _context34.next = 14;
3711
+ break;
3712
+ case 10:
3713
+ _context34.prev = 10;
3714
+ _context34.t0 = _context34["catch"](6);
3715
+ // A malformed selected menu must be fetched again on explicit retry.
3716
+ if (_this14.venueCatalogMenus === menuCache) _this14.venueCatalogMenus = undefined;
3717
+ throw _context34.t0;
3718
+ case 14:
3708
3719
  // A menu query with a date may exclude future members. Read the raw ID union
3709
3720
  // without menu/time/customer pricing filters, then filter collection/all menus locally.
3710
3721
  onlyIds = menus.every(function (menu) {
@@ -3723,15 +3734,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3723
3734
  return String(product.product_collection_id);
3724
3735
  });
3725
3736
  }))) : undefined;
3726
- if (!(onlyIds && !(productIds !== null && productIds !== void 0 && productIds.length))) {
3727
- _context34.next = 14;
3737
+ emptySelection = (productIds === null || productIds === void 0 ? void 0 : productIds.length) === 0 || (collections === null || collections === void 0 ? void 0 : collections.length) === 0;
3738
+ if (!emptySelection) {
3739
+ _context34.next = 23;
3728
3740
  break;
3729
3741
  }
3730
- _context34.t0 = [];
3731
- _context34.next = 17;
3742
+ _context34.t1 = [];
3743
+ _context34.next = 26;
3732
3744
  break;
3733
- case 14:
3734
- _context34.next = 16;
3745
+ case 23:
3746
+ _context34.next = 25;
3735
3747
  return _this14.store.products.loadVenueCatalogPool({
3736
3748
  product_ids: productIds,
3737
3749
  collection: collections,
@@ -3739,16 +3751,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3739
3751
  extension_type: params.extension_type,
3740
3752
  cacheId: _this14.cacheId
3741
3753
  });
3742
- case 16:
3743
- _context34.t0 = _context34.sent;
3744
- case 17:
3745
- products = _context34.t0;
3754
+ case 25:
3755
+ _context34.t1 = _context34.sent;
3756
+ case 26:
3757
+ products = _context34.t1;
3746
3758
  assertCurrent();
3747
3759
  pool = {
3748
3760
  menus: menus,
3749
3761
  pricingMenus: cloneDeep(pricingMenus),
3750
3762
  products: products.filter(function (product) {
3751
- return menus.some(function (menu) {
3763
+ return !('deleted_at' in product && product.deleted_at) && (!product.status || product.status === 'published') && menus.some(function (menu) {
3752
3764
  return productMatchesVenueMenu(product, menu);
3753
3765
  });
3754
3766
  })
@@ -3759,11 +3771,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3759
3771
  _this14.store.products.rememberRawProductQueryResult(cloneDeep(pool.products));
3760
3772
  _this14.store.products.addProduct(cloneDeep(pool.products));
3761
3773
  return _context34.abrupt("return", pool);
3762
- case 24:
3774
+ case 33:
3763
3775
  case "end":
3764
3776
  return _context34.stop();
3765
3777
  }
3766
- }, _callee34);
3778
+ }, _callee34, null, [[6, 10]]);
3767
3779
  }));
3768
3780
  function load() {
3769
3781
  return _load.apply(this, arguments);
@@ -4571,17 +4583,34 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4571
4583
  sourceProduct: sourceProduct
4572
4584
  });
4573
4585
  if (orderProduct && _typeof(orderProduct) === 'object') {
4586
+ var _sourceProduct$metada3, _sourceProduct$_exten3;
4574
4587
  var venueMetadata = Object.fromEntries(['venue_booking_role', 'venue_booking_parent_uid', 'venue_booking_service_datetime', 'venue_booking_scope_key'].filter(function (key) {
4575
4588
  var _sourceProduct$metada2;
4576
4589
  return ((_sourceProduct$metada2 = sourceProduct.metadata) === null || _sourceProduct$metada2 === void 0 ? void 0 : _sourceProduct$metada2[key]) !== undefined;
4577
4590
  }).map(function (key) {
4578
4591
  return [key, sourceProduct.metadata[key]];
4579
4592
  }));
4593
+ var isVenueExtra = ownershipKey === 'unified_booking_sales_retail' && ['tickets_extra', 'party_extra'].includes(venueMetadata.venue_booking_role);
4594
+ if (isVenueExtra && ((_sourceProduct$metada3 = sourceProduct.metadata) === null || _sourceProduct$metada3 === void 0 ? void 0 : _sourceProduct$metada3.venue_extra_holder_variant_id) !== undefined) {
4595
+ var _sourceProduct$holder;
4596
+ // null explicitly clears a previous SKU override. The adapter pairs the marker
4597
+ // with its resolved policy, independent of the product's original settings.
4598
+ venueMetadata.venue_extra_holder_variant_id = sourceProduct.metadata.venue_extra_holder_variant_id;
4599
+ var holderConfig = (_sourceProduct$holder = sourceProduct.holder_config) !== null && _sourceProduct$holder !== void 0 ? _sourceProduct$holder : sourceProduct.metadata.holder_config;
4600
+ if (holderConfig) venueMetadata.holder_config = cloneDeep(holderConfig);
4601
+ }
4580
4602
  // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
4581
4603
  // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
4582
4604
  orderProduct.metadata = _objectSpread(_objectSpread(_objectSpread({}, orderProduct.metadata || {}), venueMetadata), {}, _defineProperty({}, ownershipKey, true), quotationShelfId !== undefined ? {
4583
4605
  quotation_shelf_id: quotationShelfId
4584
4606
  } : {});
4607
+ // Extras use retail order-detail relations even when the catalog product
4608
+ // also has a bookable duration. Order binds the patch to the final line UID.
4609
+ if (isVenueExtra && Array.isArray((_sourceProduct$_exten3 = sourceProduct._extend) === null || _sourceProduct$_exten3 === void 0 ? void 0 : _sourceProduct$_exten3.holder_relations)) {
4610
+ orderProduct._extend = _objectSpread(_objectSpread({}, orderProduct._extend), {}, {
4611
+ holder_relations: cloneDeep(sourceProduct._extend.holder_relations)
4612
+ });
4613
+ }
4585
4614
  }
4586
4615
  return orderProduct;
4587
4616
  }
@@ -4727,6 +4756,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4727
4756
  return true;
4728
4757
  }
4729
4758
 
4759
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
4760
+ }, {
4761
+ key: "supportsVenueExtraHolders",
4762
+ value: function supportsVenueExtraHolders() {
4763
+ return true;
4764
+ }
4765
+
4730
4766
  /**
4731
4767
  * Adds one retail line without replacing the cart's existing retail selection.
4732
4768
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -4794,7 +4830,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4794
4830
  throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
4795
4831
  case 16:
4796
4832
  if (!(((_metadata2 = orderProduct.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.venue_booking_role) === 'tickets_extra')) {
4797
- _context46.next = 31;
4833
+ _context46.next = 29;
4798
4834
  break;
4799
4835
  }
4800
4836
  order = this.getTempOrder();
@@ -4816,27 +4852,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4816
4852
  }
4817
4853
  };
4818
4854
  guard();
4819
- // Retail extras are order-owned, with their own UID and no Holder/booking.
4855
+ // Retail extras are order-owned, with their own UID and no booking.
4820
4856
  delete orderProduct.unique_identification_number;
4821
4857
  delete meta.unique_identification_number;
4822
4858
  delete meta.venue_booking_parent_uid;
4823
- orderProduct.holder_config = {
4824
- status: 'disable',
4825
- required: 0
4826
- };
4827
- meta.holder_config = {
4828
- status: 'disable',
4829
- required: 0
4830
- };
4831
4859
  return _context46.abrupt("return", this.addProductToOrder(orderProduct, undefined, {
4832
4860
  disableMerge: true,
4833
4861
  availabilityCommitGuard: guard,
4834
4862
  availabilityCommitTargetGuard: isCurrentOrder,
4835
4863
  salesNotes: params.salesNotes
4836
4864
  }));
4837
- case 31:
4865
+ case 29:
4838
4866
  if (!(((_metadata3 = orderProduct.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.venue_booking_role) === 'party_extra')) {
4839
- _context46.next = 47;
4867
+ _context46.next = 43;
4840
4868
  break;
4841
4869
  }
4842
4870
  _order = this.getTempOrder();
@@ -4846,9 +4874,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4846
4874
  // Its parent UID owns the extra; the parent's appointment time does not price it.
4847
4875
  _purchaseDatetime = String(_meta.venue_booking_service_datetime || '');
4848
4876
  normalizedPurchaseDatetime = _purchaseDatetime.length === 16 ? "".concat(_purchaseDatetime, ":00") : _purchaseDatetime;
4849
- _identity = [_order === null || _order === void 0 ? void 0 : _order.order_id, _order === null || _order === void 0 ? void 0 : _order.external_sale_number];
4877
+ _identity = [_order === null || _order === void 0 ? void 0 : _order.order_id, _order === null || _order === void 0 ? void 0 : _order.external_sale_number, _order === null || _order === void 0 ? void 0 : _order.customer_id];
4850
4878
  _isCurrentOrder = function _isCurrentOrder() {
4851
- return _this16.getTempOrder() === _order && (_order === null || _order === void 0 ? void 0 : _order.order_id) === _identity[0] && (_order === null || _order === void 0 ? void 0 : _order.external_sale_number) === _identity[1];
4879
+ return _this16.getTempOrder() === _order && (_order === null || _order === void 0 ? void 0 : _order.order_id) === _identity[0] && (_order === null || _order === void 0 ? void 0 : _order.external_sale_number) === _identity[1] && (_order === null || _order === void 0 ? void 0 : _order.customer_id) === _identity[2];
4852
4880
  };
4853
4881
  _guard = function _guard() {
4854
4882
  var _params$availabilityC2, _parent$metadata, _parent$metadata2;
@@ -4861,27 +4889,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4861
4889
  _guard();
4862
4890
  delete orderProduct.unique_identification_number;
4863
4891
  delete orderProduct.metadata.unique_identification_number;
4864
- orderProduct.holder_config = {
4865
- status: 'disable',
4866
- required: 0
4867
- };
4868
- orderProduct.metadata.holder_config = {
4869
- status: 'disable',
4870
- required: 0
4871
- };
4872
4892
  return _context46.abrupt("return", this.addProductToOrder(orderProduct, undefined, {
4873
4893
  disableMerge: true,
4874
4894
  availabilityCommitGuard: _guard,
4875
4895
  availabilityCommitTargetGuard: _isCurrentOrder,
4876
4896
  salesNotes: params.salesNotes
4877
4897
  }));
4878
- case 47:
4898
+ case 43:
4879
4899
  return _context46.abrupt("return", this.addProductToOrder(orderProduct, undefined, _objectSpread(_objectSpread({}, params.availabilityCommitGuard ? {
4880
4900
  availabilityCommitGuard: params.availabilityCommitGuard
4881
4901
  } : {}), params.salesNotes ? {
4882
4902
  salesNotes: params.salesNotes
4883
4903
  } : {})));
4884
- case 48:
4904
+ case 44:
4885
4905
  case "end":
4886
4906
  return _context46.stop();
4887
4907
  }
@@ -7094,19 +7114,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7094
7114
  break;
7095
7115
  }
7096
7116
  relatedRetailProducts = params.relatedRetailProducts.map(function (source) {
7097
- var _line$metadata3;
7098
7117
  var line = _this27.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
7099
7118
  if (!line) throw new AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
7100
- if (((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.venue_booking_role) === 'party_extra') {
7101
- line.holder_config = {
7102
- status: 'disable',
7103
- required: 0
7104
- };
7105
- line.metadata.holder_config = {
7106
- status: 'disable',
7107
- required: 0
7108
- };
7109
- }
7110
7119
  // This is the only replacement-specific UID restore. Order checks ownership/collisions.
7111
7120
  var sourceUid = getProductLineUid(source);
7112
7121
  if (sourceUid) {
@@ -7198,8 +7207,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7198
7207
  products = _context63.sent;
7199
7208
  guardedCommitPublished = hasCommitGuard;
7200
7209
  addedLines = products.filter(function (line) {
7201
- var _line$product_id, _line$metadata4;
7202
- return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
7210
+ var _line$product_id, _line$metadata3;
7211
+ return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
7203
7212
  });
7204
7213
  productLineUids = addedLines.map(function (line) {
7205
7214
  return getProductLineUid(line);
@@ -7213,8 +7222,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
7213
7222
  }).filter(Boolean);
7214
7223
  if (bookingUids.length === 0) {
7215
7224
  bookingUids = addedLines.map(function (line) {
7216
- var _ref64, _line$booking_uid, _line$metadata5;
7217
- return String((_ref64 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata5 = line.metadata) === null || _line$metadata5 === void 0 ? void 0 : _line$metadata5.booking_uid) !== null && _ref64 !== void 0 ? _ref64 : '');
7225
+ var _ref64, _line$booking_uid, _line$metadata4;
7226
+ return String((_ref64 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.booking_uid) !== null && _ref64 !== void 0 ? _ref64 : '');
7218
7227
  }).filter(Boolean);
7219
7228
  }
7220
7229
  productLineUid = productLineUids[productLineUids.length - 1] || '';
@@ -295,6 +295,7 @@ export interface UnifiedBookingSalesApi {
295
295
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
296
296
  queryProducts: (params?: ProductListStoreQueryParams) => Promise<ProductData[]>;
297
297
  stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
298
+ supportsVenueExtraHolders: () => boolean;
298
299
  addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
299
300
  prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
300
301
  getProductTimeRanges: (contextId: string, request?: GetProductTimeRangesRequest) => Promise<ContextualProductTimeRangeGroup[]>;
@@ -24,18 +24,24 @@ export function readVenueCatalogList(response, description) {
24
24
  throw venueCatalogError('VENUE_CATALOG_LOAD_FAILED', (response === null || response === void 0 ? void 0 : response.message) || "".concat(description, " could not be loaded."));
25
25
  }
26
26
  var total = (_ref = (_response$data$total = response.data.total) !== null && _response$data$total !== void 0 ? _response$data$total : response.data.total_count) !== null && _ref !== void 0 ? _ref : response.data.total_num;
27
- if (total != null && Number.isFinite(Number(total)) && Number(total) > list.length) {
27
+ if (total == null ? list.length >= 999 : !Number.isSafeInteger(Number(total)) || Number(total) < 0 || Number(total) > list.length) {
28
28
  throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', "".concat(description, " is incomplete. A complete catalog response is required."));
29
29
  }
30
+ if (list.some(function (row) {
31
+ return !Number.isSafeInteger(Number(row === null || row === void 0 ? void 0 : row.form_record_id)) || Number(row.form_record_id) <= 0;
32
+ })) {
33
+ throw venueCatalogError('VENUE_CATALOG_INCOMPLETE', "".concat(description, " contains a record without a valid menu ID."));
34
+ }
30
35
  return list;
31
36
  }
32
37
  export function validateVenueMenus(records, ids) {
33
- return ids.map(function (id) {
38
+ return ids.flatMap(function (id) {
34
39
  var menu = records.find(function (row) {
35
40
  return Number(row.form_record_id) === id;
36
41
  });
37
- var config = menu === null || menu === void 0 ? void 0 : menu.partyroom_package;
38
- if (!menu || !['product_all', 'products', 'product_collection'].includes(config === null || config === void 0 ? void 0 : config.type) || !Array.isArray(menu.schedule) || menu.schedule.some(function (value) {
42
+ if (!menu || menu.deleted_at || menu.status && menu.status !== 'valid') return [];
43
+ var config = menu.partyroom_package;
44
+ if (!['product_all', 'products', 'product_collection'].includes(config === null || config === void 0 ? void 0 : config.type) || !Array.isArray(menu.schedule) || menu.schedule.some(function (value) {
39
45
  return !Number.isSafeInteger(Number(value)) || Number(value) <= 0;
40
46
  }) || config.type !== 'product_all' && (!Array.isArray(config.products) || config.products.some(function (row) {
41
47
  var value = Number(row === null || row === void 0 ? void 0 : row[config.type === 'products' ? 'product_id' : 'product_collection_id']);
@@ -43,7 +49,7 @@ export function validateVenueMenus(records, ids) {
43
49
  }))) {
44
50
  throw venueCatalogError('VENUE_MENU_INCOMPLETE', 'The configured menu is incomplete. Reload the booking page.');
45
51
  }
46
- return cloneDeep(menu);
52
+ return [cloneDeep(menu)];
47
53
  });
48
54
  }
49
55
 
@@ -4790,19 +4790,28 @@ class OrderModule extends _BaseModule.BaseModule {
4790
4790
  * await order.removeProductsFromOrder([identityA, identityB]);
4791
4791
  */
4792
4792
  async removeProductsFromOrder(identities, options) {
4793
- return this.queueCartCommand(() => this.removeProductsFromOrderDraft(identities, options), Boolean(options?.isCurrentOrder));
4793
+ return this.queueCartCommand(() => this.removeProductsFromOrderDraft(identities, options), Boolean(options?.isCurrentOrder || options?.beforeApply));
4794
4794
  }
4795
4795
  async removeProductsFromOrderDraft(identities, options) {
4796
4796
  if (options?.isCurrentOrder && !options.isCurrentOrder()) {
4797
4797
  return this.store.tempOrder?.products || [];
4798
4798
  }
4799
+ // Validate inside the command queue, before creating or mutating the draft.
4800
+ if (identities.length) options?.beforeApply?.();
4801
+ if (options?.isCurrentOrder && !options.isCurrentOrder()) {
4802
+ return this.store.tempOrder?.products || [];
4803
+ }
4804
+ const guarded = Boolean(options?.isCurrentOrder || options?.beforeApply);
4799
4805
  const mutation = this.beginCartMutation({
4800
- forceDraft: Boolean(options?.isCurrentOrder)
4806
+ forceDraft: guarded
4801
4807
  });
4802
4808
  let tempOrder = mutation.draft;
4803
4809
  const identity = [mutation.current.order_id, mutation.current.external_sale_number];
4804
4810
  const isCurrentOrder = () => this.store.tempOrder === mutation.current && mutation.current.order_id === identity[0] && mutation.current.external_sale_number === identity[1] && (options?.isCurrentOrder?.() ?? true);
4805
- const beforeCommit = options?.isCurrentOrder ? () => {
4811
+ const beforeCommit = guarded ? () => {
4812
+ // Inventory validation can await. Recheck the live source snapshot before
4813
+ // publication; never run this row-snapshot guard during finalization.
4814
+ options?.beforeApply?.();
4806
4815
  if (!isCurrentOrder()) throw Object.assign(new Error('Order product removal interrupted by an order change'), {
4807
4816
  code: 'AVAILABILITY_SELECTION_STALE'
4808
4817
  });
@@ -4875,7 +4884,7 @@ class OrderModule extends _BaseModule.BaseModule {
4875
4884
  (0, _holderRelations.removeProductHolderRelations)(tempOrder, productsBeforeRemove.filter(product => !tempOrder.products.includes(product)));
4876
4885
  this.removeSalesNotesForMissingProductLines(tempOrder);
4877
4886
  if (mutation.commit) tempOrder = await mutation.commit(beforeCommit);
4878
- await this.finalizeAfterProductsMutation(tempOrder, options?.isCurrentOrder ? {
4887
+ await this.finalizeAfterProductsMutation(tempOrder, guarded ? {
4879
4888
  isCurrentOrder
4880
4889
  } : undefined);
4881
4890
  this.logInfo('removeProductsFromOrder success', {
@@ -482,6 +482,8 @@ export interface ReplaceBookingProductWithRelatedRetailParams {
482
482
  * 预约合并行减量时仍删除最新真实行,再把剩余代表行移动到被删除代表行原位置。
483
483
  */
484
484
  export interface RemoveProductsFromOrderOptions {
485
+ /** Synchronous, read-only validation before draft mutation and again before publication after async guards; may throw. Never called during finalization. */
486
+ beforeApply?: () => void;
485
487
  /** Prevent an asynchronous deletion/finalization from crossing order or business scopes. */
486
488
  isCurrentOrder?: () => boolean;
487
489
  preserveDisplayPosition?: {
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "session" | "duration";
53
53
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -373,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
373
373
  };
374
374
  setOtherData(key: string, value: any): void;
375
375
  getOtherData(key: string): any;
376
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
376
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
377
377
  /**
378
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
379
379
  *
@@ -479,7 +479,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
479
479
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
480
480
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
481
481
  */
482
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
482
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
483
+ action: "reloadCatalog";
484
+ } | {
485
+ action: "add";
486
+ cacheItem: any;
487
+ } | {
488
+ action: "requiresDetail";
489
+ payload: AddProductRequiresDetailPayload;
490
+ } | {
491
+ action: "requiresBookingEdit";
492
+ cacheItem: any;
493
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
494
+ };
483
495
  /** 规格弹窗 callback 后的第二段决策。 */
484
496
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
485
497
  /**
@@ -289,6 +289,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
289
289
  stageRetailProducts(params: UnifiedBookingSalesStageRetailProductsParams): Promise<Record<string, any> | null>;
290
290
  /** Explicit capability: order-scoped Tickets extras use guarded writes without implicit SKU merging. */
291
291
  supportsVenueTicketExtras(): boolean;
292
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
293
+ supportsVenueExtraHolders(): boolean;
292
294
  /**
293
295
  * Adds one retail line without replacing the cart's existing retail selection.
294
296
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -2463,16 +2463,25 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2463
2463
  if (this.venueCatalogMenus?.promise === promise) this.venueCatalogMenus = undefined;
2464
2464
  });
2465
2465
  }
2466
- const pricingMenus = await this.venueCatalogMenus.promise;
2467
- const menus = (0, _venueCatalogSession.validateVenueMenus)(pricingMenus, menuIds);
2466
+ const menuCache = this.venueCatalogMenus;
2467
+ const pricingMenus = await menuCache.promise;
2468
2468
  assertCurrent();
2469
+ let menus;
2470
+ try {
2471
+ menus = (0, _venueCatalogSession.validateVenueMenus)(pricingMenus, menuIds);
2472
+ } catch (error) {
2473
+ // A malformed selected menu must be fetched again on explicit retry.
2474
+ if (this.venueCatalogMenus === menuCache) this.venueCatalogMenus = undefined;
2475
+ throw error;
2476
+ }
2469
2477
  // A menu query with a date may exclude future members. Read the raw ID union
2470
2478
  // without menu/time/customer pricing filters, then filter collection/all menus locally.
2471
2479
  const onlyIds = menus.every(menu => menu.partyroom_package.type === 'products');
2472
2480
  const onlyCollections = menus.every(menu => menu.partyroom_package.type === 'product_collection');
2473
2481
  const productIds = onlyIds ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => Number(product.product_id))))] : undefined;
2474
2482
  const collections = onlyCollections ? [...new Set(menus.flatMap(menu => menu.partyroom_package.products.map(product => String(product.product_collection_id))))] : undefined;
2475
- const products = onlyIds && !productIds?.length ? [] : await this.store.products.loadVenueCatalogPool({
2483
+ const emptySelection = productIds?.length === 0 || collections?.length === 0;
2484
+ const products = emptySelection ? [] : await this.store.products.loadVenueCatalogPool({
2476
2485
  product_ids: productIds,
2477
2486
  collection: collections,
2478
2487
  category_ids: params.category_ids,
@@ -2483,7 +2492,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2483
2492
  const pool = {
2484
2493
  menus,
2485
2494
  pricingMenus: (0, _lodashEs.cloneDeep)(pricingMenus),
2486
- products: products.filter(product => menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu)))
2495
+ products: products.filter(product => !('deleted_at' in product && product.deleted_at) && (!product.status || product.status === 'published') && menus.some(menu => (0, _venueCatalogSession.productMatchesVenueMenu)(product, menu)))
2487
2496
  };
2488
2497
  entry.pool = (0, _lodashEs.cloneDeep)(pool);
2489
2498
  // Legacy marketing lookups can reuse complete records without changing
@@ -2922,6 +2931,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2922
2931
  });
2923
2932
  if (orderProduct && typeof orderProduct === 'object') {
2924
2933
  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]]));
2934
+ const isVenueExtra = ownershipKey === 'unified_booking_sales_retail' && ['tickets_extra', 'party_extra'].includes(venueMetadata.venue_booking_role);
2935
+ if (isVenueExtra && sourceProduct.metadata?.venue_extra_holder_variant_id !== undefined) {
2936
+ // null explicitly clears a previous SKU override. The adapter pairs the marker
2937
+ // with its resolved policy, independent of the product's original settings.
2938
+ venueMetadata.venue_extra_holder_variant_id = sourceProduct.metadata.venue_extra_holder_variant_id;
2939
+ const holderConfig = sourceProduct.holder_config ?? sourceProduct.metadata.holder_config;
2940
+ if (holderConfig) venueMetadata.holder_config = (0, _lodashEs.cloneDeep)(holderConfig);
2941
+ }
2925
2942
  // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
2926
2943
  // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
2927
2944
  orderProduct.metadata = {
@@ -2932,6 +2949,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2932
2949
  quotation_shelf_id: quotationShelfId
2933
2950
  } : {})
2934
2951
  };
2952
+ // Extras use retail order-detail relations even when the catalog product
2953
+ // also has a bookable duration. Order binds the patch to the final line UID.
2954
+ if (isVenueExtra && Array.isArray(sourceProduct._extend?.holder_relations)) {
2955
+ orderProduct._extend = {
2956
+ ...orderProduct._extend,
2957
+ holder_relations: (0, _lodashEs.cloneDeep)(sourceProduct._extend.holder_relations)
2958
+ };
2959
+ }
2935
2960
  }
2936
2961
  return orderProduct;
2937
2962
  }
@@ -2981,6 +3006,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2981
3006
  return true;
2982
3007
  }
2983
3008
 
3009
+ /** The venue retail write path accepts per-line Holder relations for both templates. */
3010
+ supportsVenueExtraHolders() {
3011
+ return true;
3012
+ }
3013
+
2984
3014
  /**
2985
3015
  * Adds one retail line without replacing the cart's existing retail selection.
2986
3016
  * This is intentionally separate from stageRetailProducts(), whose contract is
@@ -3027,18 +3057,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3027
3057
  }
3028
3058
  };
3029
3059
  guard();
3030
- // Retail extras are order-owned, with their own UID and no Holder/booking.
3060
+ // Retail extras are order-owned, with their own UID and no booking.
3031
3061
  delete orderProduct.unique_identification_number;
3032
3062
  delete meta.unique_identification_number;
3033
3063
  delete meta.venue_booking_parent_uid;
3034
- orderProduct.holder_config = {
3035
- status: 'disable',
3036
- required: 0
3037
- };
3038
- meta.holder_config = {
3039
- status: 'disable',
3040
- required: 0
3041
- };
3042
3064
  return this.addProductToOrder(orderProduct, undefined, {
3043
3065
  disableMerge: true,
3044
3066
  availabilityCommitGuard: guard,
@@ -3055,8 +3077,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3055
3077
  // Its parent UID owns the extra; the parent's appointment time does not price it.
3056
3078
  const purchaseDatetime = String(meta.venue_booking_service_datetime || '');
3057
3079
  const normalizedPurchaseDatetime = purchaseDatetime.length === 16 ? `${purchaseDatetime}:00` : purchaseDatetime;
3058
- const identity = [order?.order_id, order?.external_sale_number];
3059
- const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1];
3080
+ const identity = [order?.order_id, order?.external_sale_number, order?.customer_id];
3081
+ const isCurrentOrder = () => this.getTempOrder() === order && order?.order_id === identity[0] && order?.external_sale_number === identity[1] && order?.customer_id === identity[2];
3060
3082
  const guard = () => {
3061
3083
  params.availabilityCommitGuard?.();
3062
3084
  const parent = (order?.products || []).find(line => getProductLineUid(line) === parentUid);
@@ -3065,14 +3087,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
3065
3087
  guard();
3066
3088
  delete orderProduct.unique_identification_number;
3067
3089
  delete orderProduct.metadata.unique_identification_number;
3068
- orderProduct.holder_config = {
3069
- status: 'disable',
3070
- required: 0
3071
- };
3072
- orderProduct.metadata.holder_config = {
3073
- status: 'disable',
3074
- required: 0
3075
- };
3076
3090
  return this.addProductToOrder(orderProduct, undefined, {
3077
3091
  disableMerge: true,
3078
3092
  availabilityCommitGuard: guard,
@@ -4530,16 +4544,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
4530
4544
  const relatedRetailProducts = params.relatedRetailProducts.map(source => {
4531
4545
  const line = this.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
4532
4546
  if (!line) throw new _ResourcePlanner.AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
4533
- if (line.metadata?.venue_booking_role === 'party_extra') {
4534
- line.holder_config = {
4535
- status: 'disable',
4536
- required: 0
4537
- };
4538
- line.metadata.holder_config = {
4539
- status: 'disable',
4540
- required: 0
4541
- };
4542
- }
4543
4547
  // This is the only replacement-specific UID restore. Order checks ownership/collisions.
4544
4548
  const sourceUid = getProductLineUid(source);
4545
4549
  if (sourceUid) {
@@ -295,6 +295,7 @@ export interface UnifiedBookingSalesApi {
295
295
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
296
296
  queryProducts: (params?: ProductListStoreQueryParams) => Promise<ProductData[]>;
297
297
  stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
298
+ supportsVenueExtraHolders: () => boolean;
298
299
  addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
299
300
  prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
300
301
  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": "0.10.79",
4
+ "version": "0.10.81",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",