@pisell/pisellos 0.10.80 → 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.
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/index.js +66 -57
- package/dist/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/dist/solution/UnifiedBookingSales/venueCatalogSession.js +11 -5
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/index.js +37 -33
- package/lib/solution/UnifiedBookingSales/types.d.ts +1 -0
- package/lib/solution/UnifiedBookingSales/venueCatalogSession.js +9 -5
- package/package.json +1 -1
|
@@ -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(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "session" | "duration";
|
|
53
53
|
}
|
|
@@ -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
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
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
|
-
|
|
3727
|
-
|
|
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.
|
|
3731
|
-
_context34.next =
|
|
3742
|
+
_context34.t1 = [];
|
|
3743
|
+
_context34.next = 26;
|
|
3732
3744
|
break;
|
|
3733
|
-
case
|
|
3734
|
-
_context34.next =
|
|
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
|
|
3743
|
-
_context34.
|
|
3744
|
-
case
|
|
3745
|
-
products = _context34.
|
|
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
|
|
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 =
|
|
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
|
|
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
|
|
4865
|
+
case 29:
|
|
4838
4866
|
if (!(((_metadata3 = orderProduct.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.venue_booking_role) === 'party_extra')) {
|
|
4839
|
-
_context46.next =
|
|
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
|
|
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
|
|
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$
|
|
7202
|
-
return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_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$
|
|
7217
|
-
return String((_ref64 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$
|
|
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
|
|
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.
|
|
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
|
-
|
|
38
|
-
|
|
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
|
|
|
@@ -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(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "session" | "duration";
|
|
53
53
|
}
|
|
@@ -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
|
|
2467
|
-
const
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
34
|
+
return ids.flatMap(id => {
|
|
32
35
|
const menu = records.find(row => Number(row.form_record_id) === id);
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|