@pisell/pisellos 0.10.71 → 0.10.73
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +2 -2
- package/dist/modules/BookingContext/index.js +55 -25
- package/dist/modules/BookingContext/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +13 -4
- package/dist/modules/Order/index.js +1401 -764
- package/dist/modules/Order/types.d.ts +24 -1
- package/dist/modules/Order/types.js +4 -0
- package/dist/server/index.js +5 -2
- package/dist/solution/BaseSales/index.d.ts +2 -2
- package/dist/solution/BaseSales/index.js +8 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +15 -0
- package/dist/solution/UnifiedBookingSales/index.js +1082 -596
- package/dist/solution/UnifiedBookingSales/types.d.ts +17 -1
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/BookingContext/index.d.ts +2 -2
- package/lib/modules/BookingContext/index.js +42 -10
- package/lib/modules/BookingContext/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +13 -4
- package/lib/modules/Order/index.js +284 -24
- package/lib/modules/Order/types.d.ts +24 -1
- package/lib/modules/Order/types.js +2 -0
- package/lib/server/index.js +5 -1
- package/lib/solution/BaseSales/index.d.ts +2 -2
- package/lib/solution/BaseSales/index.js +2 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +15 -0
- package/lib/solution/UnifiedBookingSales/index.js +343 -44
- package/lib/solution/UnifiedBookingSales/types.d.ts +17 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
var _excluded = ["
|
|
1
|
+
var _excluded = ["product_ids"],
|
|
2
|
+
_excluded2 = ["product_id", "product_ids"],
|
|
3
|
+
_excluded3 = ["date", "custom_page_id", "channel", "product_ids"];
|
|
2
4
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
6
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -41,6 +43,7 @@ import { isProductFlexibleDuration, isSessionProduct, isBookingProduct, isMultiD
|
|
|
41
43
|
import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings, normalizeSalesSettings } from "../../modules/OpenData";
|
|
42
44
|
import { getBookingBoundary, getBookingHolderIds, normalizeBookingDateTime, resolveDefaultBookingStart } from "./salesSettings";
|
|
43
45
|
import { getScheduleStartEndTimePoints } from "../../modules/Schedule/getDateIsInSchedule";
|
|
46
|
+
import { PRODUCT_QUERY_DATA_VARIANT_RELATIONS, resolveClientDataVariants } from "../../modules/ProductList/clientDataVariants";
|
|
44
47
|
import { AvailabilityError, createAvailabilityProjection, getProductTimeRanges as getProjectionProductTimeRanges, queryAvailabilityProjection, validateAvailabilitySelection } from "../../modules/ResourcePlanner";
|
|
45
48
|
import { UnifiedBookingSalesHooks } from "./types";
|
|
46
49
|
import { AvailabilityRemoteOccupancyCache } from "./remoteOccupancyCache";
|
|
@@ -1137,12 +1140,17 @@ function buildBookingFromAvailabilitySelection(params) {
|
|
|
1137
1140
|
}
|
|
1138
1141
|
} : {});
|
|
1139
1142
|
}),
|
|
1140
|
-
metadata: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bookingUid ? {
|
|
1143
|
+
metadata: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, bookingUid ? {
|
|
1141
1144
|
unique_identification_number: bookingUid
|
|
1142
1145
|
} : {}), {}, {
|
|
1143
1146
|
unified_booking_sales: true,
|
|
1144
1147
|
availability_candidate_key: candidate.key,
|
|
1145
1148
|
availability_source: candidate.source,
|
|
1149
|
+
availability_business_date: candidate.businessDate || candidate.date,
|
|
1150
|
+
availability_timezone: candidate.timezone
|
|
1151
|
+
}, candidate.primaryScheduleRef ? {
|
|
1152
|
+
availability_primary_schedule_ref: cloneDeep(candidate.primaryScheduleRef)
|
|
1153
|
+
} : {}), {}, {
|
|
1146
1154
|
availability_slice_start_at: candidate.startAt,
|
|
1147
1155
|
availability_slice_end_at: candidate.endAt,
|
|
1148
1156
|
availability_schedule_refs: candidate.scheduleRefs
|
|
@@ -2564,9 +2572,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2564
2572
|
return [booking];
|
|
2565
2573
|
});
|
|
2566
2574
|
}
|
|
2575
|
+
}, {
|
|
2576
|
+
key: "shouldApplyMultipleBookingScheduling",
|
|
2577
|
+
value: function shouldApplyMultipleBookingScheduling() {
|
|
2578
|
+
var _this$otherParams21;
|
|
2579
|
+
var platform = normalizeRuntimePlatform((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.platform);
|
|
2580
|
+
return platform === 'pos' || platform === 'webpos';
|
|
2581
|
+
}
|
|
2567
2582
|
}, {
|
|
2568
2583
|
key: "resolveLoadedDefaultBookingStart",
|
|
2569
2584
|
value: function resolveLoadedDefaultBookingStart(holderIds, fallback) {
|
|
2585
|
+
// Customer channels keep their entry default instead of following cart bookings.
|
|
2586
|
+
// Keep this callback installed so BookingContext cannot fall back to Board.
|
|
2587
|
+
if (!this.shouldApplyMultipleBookingScheduling()) return normalizeBookingDateTime(fallback);
|
|
2570
2588
|
var settings = this.getLoadedSalesSettings();
|
|
2571
2589
|
return resolveDefaultBookingStart({
|
|
2572
2590
|
bookings: this.getProductBookingsForScheduling(),
|
|
@@ -2584,11 +2602,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2584
2602
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2585
2603
|
while (1) switch (_context17.prev = _context17.next) {
|
|
2586
2604
|
case 0:
|
|
2587
|
-
|
|
2588
|
-
|
|
2605
|
+
if (this.shouldApplyMultipleBookingScheduling()) {
|
|
2606
|
+
_context17.next = 2;
|
|
2607
|
+
break;
|
|
2608
|
+
}
|
|
2609
|
+
return _context17.abrupt("return", normalizeBookingDateTime(params.fallback));
|
|
2589
2610
|
case 2:
|
|
2611
|
+
_context17.next = 4;
|
|
2612
|
+
return this.getSalesSettings();
|
|
2613
|
+
case 4:
|
|
2590
2614
|
return _context17.abrupt("return", this.resolveLoadedDefaultBookingStart(params.holderIds, params.fallback));
|
|
2591
|
-
case
|
|
2615
|
+
case 5:
|
|
2592
2616
|
case "end":
|
|
2593
2617
|
return _context17.stop();
|
|
2594
2618
|
}
|
|
@@ -2647,70 +2671,76 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2647
2671
|
while (1) switch (_context18.prev = _context18.next) {
|
|
2648
2672
|
case 0:
|
|
2649
2673
|
options = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
|
|
2650
|
-
if (
|
|
2674
|
+
if (this.shouldApplyMultipleBookingScheduling()) {
|
|
2651
2675
|
_context18.next = 3;
|
|
2652
2676
|
break;
|
|
2653
2677
|
}
|
|
2654
2678
|
return _context18.abrupt("return", cacheItem);
|
|
2655
2679
|
case 3:
|
|
2680
|
+
if (!(!(cacheItem !== null && cacheItem !== void 0 && cacheItem.new) || !isBookingProduct(cacheItem) || isSessionProduct(cacheItem) || cacheItem !== null && cacheItem !== void 0 && (_cacheItem$_extend = cacheItem._extend) !== null && _cacheItem$_extend !== void 0 && (_cacheItem$_extend = _cacheItem$_extend.other) !== null && _cacheItem$_extend !== void 0 && _cacheItem$_extend.session)) {
|
|
2681
|
+
_context18.next = 5;
|
|
2682
|
+
break;
|
|
2683
|
+
}
|
|
2684
|
+
return _context18.abrupt("return", cacheItem);
|
|
2685
|
+
case 5:
|
|
2656
2686
|
extend = cacheItem._extend || {};
|
|
2657
2687
|
currentStart = getBookingBoundary(extend, 'start');
|
|
2658
2688
|
automaticStart = normalizeBookingDateTime((_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.salesDefaultBookingStart);
|
|
2659
2689
|
if (!(extend.start_time && (!automaticStart || !currentStart || dayjs(currentStart).valueOf() !== dayjs(automaticStart).valueOf()))) {
|
|
2660
|
-
_context18.next =
|
|
2690
|
+
_context18.next = 10;
|
|
2661
2691
|
break;
|
|
2662
2692
|
}
|
|
2663
2693
|
return _context18.abrupt("return", cacheItem);
|
|
2664
|
-
case
|
|
2694
|
+
case 10:
|
|
2665
2695
|
explicitStart = normalizeBookingDateTime(options.explicitStart);
|
|
2666
2696
|
if (!(options.explicitStart !== undefined && !explicitStart)) {
|
|
2667
|
-
_context18.next =
|
|
2697
|
+
_context18.next = 13;
|
|
2668
2698
|
break;
|
|
2669
2699
|
}
|
|
2670
2700
|
throw new Error('The explicit booking start must be a valid date and time.');
|
|
2671
|
-
case
|
|
2701
|
+
case 13:
|
|
2672
2702
|
holderIds = (_options$holderIds = options.holderIds) !== null && _options$holderIds !== void 0 ? _options$holderIds : getBookingHolderIds(cacheItem);
|
|
2673
2703
|
fallback = (_ref34 = (_normalizeBookingDate = normalizeBookingDateTime((_cacheItem$_data2 = cacheItem._data) === null || _cacheItem$_data2 === void 0 ? void 0 : _cacheItem$_data2.salesDefaultBookingFallback)) !== null && _normalizeBookingDate !== void 0 ? _normalizeBookingDate : currentStart) !== null && _ref34 !== void 0 ? _ref34 : normalizeBookingDateTime(String(this.getBookingDate() || ''));
|
|
2674
2704
|
if (!(explicitStart !== null && explicitStart !== void 0)) {
|
|
2675
|
-
_context18.next =
|
|
2705
|
+
_context18.next = 19;
|
|
2676
2706
|
break;
|
|
2677
2707
|
}
|
|
2678
2708
|
_context18.t0 = explicitStart;
|
|
2679
|
-
_context18.next =
|
|
2709
|
+
_context18.next = 22;
|
|
2680
2710
|
break;
|
|
2681
|
-
case
|
|
2682
|
-
_context18.next =
|
|
2711
|
+
case 19:
|
|
2712
|
+
_context18.next = 21;
|
|
2683
2713
|
return this.resolveDefaultBookingStart({
|
|
2684
2714
|
holderIds: holderIds,
|
|
2685
2715
|
fallback: fallback
|
|
2686
2716
|
});
|
|
2687
|
-
case
|
|
2717
|
+
case 21:
|
|
2688
2718
|
_context18.t0 = _context18.sent;
|
|
2689
|
-
case
|
|
2719
|
+
case 22:
|
|
2690
2720
|
nextStart = _context18.t0;
|
|
2691
2721
|
if (nextStart) {
|
|
2692
|
-
_context18.next =
|
|
2722
|
+
_context18.next = 25;
|
|
2693
2723
|
break;
|
|
2694
2724
|
}
|
|
2695
2725
|
return _context18.abrupt("return", cacheItem);
|
|
2696
|
-
case
|
|
2726
|
+
case 25:
|
|
2697
2727
|
if (!(currentStart && dayjs(nextStart).valueOf() === dayjs(currentStart).valueOf())) {
|
|
2698
|
-
_context18.next =
|
|
2728
|
+
_context18.next = 32;
|
|
2699
2729
|
break;
|
|
2700
2730
|
}
|
|
2701
2731
|
if (explicitStart) {
|
|
2702
|
-
_context18.next =
|
|
2732
|
+
_context18.next = 28;
|
|
2703
2733
|
break;
|
|
2704
2734
|
}
|
|
2705
2735
|
return _context18.abrupt("return", cacheItem);
|
|
2706
|
-
case
|
|
2736
|
+
case 28:
|
|
2707
2737
|
data = _objectSpread({}, cacheItem._data);
|
|
2708
2738
|
delete data.salesDefaultBookingStart;
|
|
2709
2739
|
delete data.salesDefaultBookingFallback;
|
|
2710
2740
|
return _context18.abrupt("return", _objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
2711
2741
|
_data: data
|
|
2712
2742
|
}));
|
|
2713
|
-
case
|
|
2743
|
+
case 32:
|
|
2714
2744
|
nextExtend = _objectSpread(_objectSpread({}, extend), {}, {
|
|
2715
2745
|
start_date: nextStart.slice(0, 10),
|
|
2716
2746
|
start_time: nextStart.slice(11)
|
|
@@ -2734,7 +2764,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2734
2764
|
}), {
|
|
2735
2765
|
holderIds: holderIds
|
|
2736
2766
|
}));
|
|
2737
|
-
case
|
|
2767
|
+
case 36:
|
|
2738
2768
|
case "end":
|
|
2739
2769
|
return _context18.stop();
|
|
2740
2770
|
}
|
|
@@ -2749,13 +2779,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2749
2779
|
key: "loadPickupTimingOpenData",
|
|
2750
2780
|
value: function () {
|
|
2751
2781
|
var _loadPickupTimingOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(_force) {
|
|
2752
|
-
var _ref35, _this$otherParams$bus2, _this$
|
|
2782
|
+
var _ref35, _this$otherParams$bus2, _this$otherParams22, _this$otherParams23;
|
|
2753
2783
|
var scope, businessCode, config;
|
|
2754
2784
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2755
2785
|
while (1) switch (_context19.prev = _context19.next) {
|
|
2756
2786
|
case 0:
|
|
2757
2787
|
scope = this.getPickupTimingScope();
|
|
2758
|
-
businessCode = String((_ref35 = (_this$otherParams$bus2 = (_this$
|
|
2788
|
+
businessCode = String((_ref35 = (_this$otherParams$bus2 = (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _this$otherParams$bus2 !== void 0 ? _this$otherParams$bus2 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code) !== null && _ref35 !== void 0 ? _ref35 : '').trim();
|
|
2759
2789
|
_context19.next = 4;
|
|
2760
2790
|
return this.loadOpenData({
|
|
2761
2791
|
businessCode: businessCode,
|
|
@@ -2918,7 +2948,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2918
2948
|
key: "resolveProductAllergyRequirement",
|
|
2919
2949
|
value: (function () {
|
|
2920
2950
|
var _resolveProductAllergyRequirement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2921
|
-
var _this$
|
|
2951
|
+
var _this$otherParams24, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref38, _runtimeConfig$servic, _this$otherParams25, _ref39, _ref40, _params$channel, _this$otherParams26, _this$otherParams27, _runtimeConfig$submis;
|
|
2922
2952
|
var productId, strategyConfigs, productVariantId, runtimeConfig, runtimePax, cartItems;
|
|
2923
2953
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2924
2954
|
while (1) switch (_context23.prev = _context23.next) {
|
|
@@ -2941,7 +2971,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2941
2971
|
return _context23.abrupt("return", null);
|
|
2942
2972
|
case 8:
|
|
2943
2973
|
productVariantId = normalizePositiveInteger(params.productVariantId);
|
|
2944
|
-
runtimeConfig = ((_this$
|
|
2974
|
+
runtimeConfig = ((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.itemRule) || {};
|
|
2945
2975
|
runtimePax = runtimeConfig.pax || {};
|
|
2946
2976
|
cartItems = (((_this$getOrderProduct = this.getOrderProducts) === null || _this$getOrderProduct === void 0 ? void 0 : _this$getOrderProduct.call(this)) || []).map(function (item) {
|
|
2947
2977
|
var _item$product_id, _item$product_variant, _ref37, _item$num;
|
|
@@ -2960,8 +2990,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2960
2990
|
child: Number((_runtimePax$child = runtimePax.child) !== null && _runtimePax$child !== void 0 ? _runtimePax$child : 0) || 0
|
|
2961
2991
|
},
|
|
2962
2992
|
cartItems: cartItems,
|
|
2963
|
-
serviceType: String((_ref38 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$
|
|
2964
|
-
channel: String((_ref39 = (_ref40 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$
|
|
2993
|
+
serviceType: String((_ref38 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.serviceType) !== null && _ref38 !== void 0 ? _ref38 : ''),
|
|
2994
|
+
channel: String((_ref39 = (_ref40 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.channel) !== null && _ref40 !== void 0 ? _ref40 : (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform) !== null && _ref39 !== void 0 ? _ref39 : ''),
|
|
2965
2995
|
currentProduct: _objectSpread({
|
|
2966
2996
|
product_id: productId
|
|
2967
2997
|
}, productVariantId ? {
|
|
@@ -3051,9 +3081,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3051
3081
|
}, {
|
|
3052
3082
|
key: "isInvoiceOpenDataCacheCurrent",
|
|
3053
3083
|
value: function isInvoiceOpenDataCacheCurrent() {
|
|
3054
|
-
var _this$
|
|
3055
|
-
var businessCode = String(((_this$
|
|
3056
|
-
var channel = String(((_this$
|
|
3084
|
+
var _this$otherParams28, _this$otherParams29;
|
|
3085
|
+
var businessCode = String(((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.businessCode) || '').trim();
|
|
3086
|
+
var channel = String(((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.channel) || '').trim();
|
|
3057
3087
|
if (!businessCode || !channel) return false;
|
|
3058
3088
|
return this.openDataTarget === "".concat(businessCode, "+").concat(channel) && this.runtimeOpenDataScope === this.getRuntimeOpenDataScope();
|
|
3059
3089
|
}
|
|
@@ -3104,8 +3134,6 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3104
3134
|
var params,
|
|
3105
3135
|
options,
|
|
3106
3136
|
catalogScope,
|
|
3107
|
-
schedule_date,
|
|
3108
|
-
schedule_datetime,
|
|
3109
3137
|
result,
|
|
3110
3138
|
_args27 = arguments;
|
|
3111
3139
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
@@ -3113,8 +3141,225 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3113
3141
|
case 0:
|
|
3114
3142
|
params = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {};
|
|
3115
3143
|
options = _args27.length > 1 ? _args27[1] : undefined;
|
|
3144
|
+
catalogScope = this.otherParams.catalogScopeKey;
|
|
3145
|
+
_context27.next = 5;
|
|
3146
|
+
return this.loadCatalogProducts(params, options);
|
|
3147
|
+
case 5:
|
|
3148
|
+
result = _context27.sent;
|
|
3149
|
+
if (!(catalogScope !== this.otherParams.catalogScopeKey)) {
|
|
3150
|
+
_context27.next = 8;
|
|
3151
|
+
break;
|
|
3152
|
+
}
|
|
3153
|
+
throw Object.assign(new Error('Product scope changed'), {
|
|
3154
|
+
name: 'AbortError'
|
|
3155
|
+
});
|
|
3156
|
+
case 8:
|
|
3157
|
+
this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
|
|
3158
|
+
_context27.next = 11;
|
|
3159
|
+
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
|
|
3160
|
+
case 11:
|
|
3161
|
+
return _context27.abrupt("return", result);
|
|
3162
|
+
case 12:
|
|
3163
|
+
case "end":
|
|
3164
|
+
return _context27.stop();
|
|
3165
|
+
}
|
|
3166
|
+
}, _callee27, this);
|
|
3167
|
+
}));
|
|
3168
|
+
function loadProducts() {
|
|
3169
|
+
return _loadProducts.apply(this, arguments);
|
|
3170
|
+
}
|
|
3171
|
+
return loadProducts;
|
|
3172
|
+
}()
|
|
3173
|
+
/**
|
|
3174
|
+
* Queries one explicitly configured menu scope without publishing the sales catalog.
|
|
3175
|
+
* The returned graph is detached from ProductList's shared ID cache. Callers own its
|
|
3176
|
+
* membership and must requery/reprice with the service datetime after a context change.
|
|
3177
|
+
* Missing/invalid menu configuration fails closed instead of querying every product.
|
|
3178
|
+
*/
|
|
3179
|
+
)
|
|
3180
|
+
}, {
|
|
3181
|
+
key: "queryCatalogSnapshot",
|
|
3182
|
+
value: (function () {
|
|
3183
|
+
var _queryCatalogSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
3184
|
+
var _cloneDeep, product_ids, scopeParams, result, list;
|
|
3185
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3186
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3187
|
+
case 0:
|
|
3188
|
+
if (!(!Array.isArray(params.menu_list_ids) || params.menu_list_ids.length === 0 || params.menu_list_ids.some(function (id) {
|
|
3189
|
+
return !Number.isInteger(id) || id <= 0;
|
|
3190
|
+
}))) {
|
|
3191
|
+
_context28.next = 2;
|
|
3192
|
+
break;
|
|
3193
|
+
}
|
|
3194
|
+
return _context28.abrupt("return", []);
|
|
3195
|
+
case 2:
|
|
3196
|
+
_cloneDeep = cloneDeep(params), product_ids = _cloneDeep.product_ids, scopeParams = _objectWithoutProperties(_cloneDeep, _excluded); // The OS Server ID-query branch intentionally bypasses menus. Apply IDs only after
|
|
3197
|
+
// querying the configured menu so an isolated scope cannot leak other products.
|
|
3198
|
+
_context28.next = 5;
|
|
3199
|
+
return this.loadCatalogProducts(_objectSpread(_objectSpread({}, scopeParams), {}, {
|
|
3200
|
+
menu_list_ids: _toConsumableArray(new Set(params.menu_list_ids))
|
|
3201
|
+
}));
|
|
3202
|
+
case 5:
|
|
3203
|
+
result = _context28.sent;
|
|
3204
|
+
list = Array.isArray(result) ? result : [];
|
|
3205
|
+
return _context28.abrupt("return", cloneDeep(product_ids !== null && product_ids !== void 0 && product_ids.length ? list.filter(function (product) {
|
|
3206
|
+
return product_ids.some(function (id) {
|
|
3207
|
+
return Number(id) === Number(product.id);
|
|
3208
|
+
});
|
|
3209
|
+
}) : list));
|
|
3210
|
+
case 8:
|
|
3211
|
+
case "end":
|
|
3212
|
+
return _context28.stop();
|
|
3213
|
+
}
|
|
3214
|
+
}, _callee28, this);
|
|
3215
|
+
}));
|
|
3216
|
+
function queryCatalogSnapshot(_x15) {
|
|
3217
|
+
return _queryCatalogSnapshot.apply(this, arguments);
|
|
3218
|
+
}
|
|
3219
|
+
return queryCatalogSnapshot;
|
|
3220
|
+
}() /** Full SKU/bundle detail, after verifying membership in the explicit day/menu scope. */)
|
|
3221
|
+
}, {
|
|
3222
|
+
key: "queryCatalogProductDetail",
|
|
3223
|
+
value: (function () {
|
|
3224
|
+
var _queryCatalogProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
3225
|
+
var _this$otherParams30, _this$core$server, _this$core$server$has, _this$otherParams31, _this$otherParams32, _this$otherParams$bus3, _this$otherParams33, _this$otherParams34, _this$core$getPlugin, _this$core3, _this$core$getPlugin$, _this$otherParams35, _response$data$item, _response$data2, _raw$id2, _this$store$products, _this$store$products$;
|
|
3226
|
+
var _cloneDeep2, product_id, _ignoredIds, catalogParams, schedule_date, schedule_datetime, scopedParams, member, baseUrl, localPath, handledByOsServer, channelMap, channel, businessCode, strategy_context, customerId, queryPayload, response, raw, resolved, detail, _i2, _arr2, key;
|
|
3227
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3228
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3229
|
+
case 0:
|
|
3230
|
+
_cloneDeep2 = cloneDeep(params), product_id = _cloneDeep2.product_id, _ignoredIds = _cloneDeep2.product_ids, catalogParams = _objectWithoutProperties(_cloneDeep2, _excluded2);
|
|
3231
|
+
if (!(!Number.isInteger(product_id) || product_id <= 0)) {
|
|
3232
|
+
_context29.next = 3;
|
|
3233
|
+
break;
|
|
3234
|
+
}
|
|
3235
|
+
return _context29.abrupt("return", undefined);
|
|
3236
|
+
case 3:
|
|
3237
|
+
schedule_date = catalogParams.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
3238
|
+
schedule_datetime = catalogParams.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
|
|
3239
|
+
scopedParams = _objectSpread(_objectSpread({}, catalogParams), {}, {
|
|
3240
|
+
schedule_date: schedule_date,
|
|
3241
|
+
schedule_datetime: schedule_datetime
|
|
3242
|
+
});
|
|
3243
|
+
_context29.next = 8;
|
|
3244
|
+
return this.queryCatalogSnapshot(scopedParams);
|
|
3245
|
+
case 8:
|
|
3246
|
+
member = _context29.sent.find(function (item) {
|
|
3247
|
+
return Number(item.id) === product_id;
|
|
3248
|
+
});
|
|
3249
|
+
if (member) {
|
|
3250
|
+
_context29.next = 11;
|
|
3251
|
+
break;
|
|
3252
|
+
}
|
|
3253
|
+
return _context29.abrupt("return", undefined);
|
|
3254
|
+
case 11:
|
|
3255
|
+
baseUrl = String(this.request.baseUrl || (isCustomerUserPlatform((_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.platform) ? '/h5' : '/shop')).replace(/\/+$/, '');
|
|
3256
|
+
localPath = "/product/query/".concat(product_id);
|
|
3257
|
+
handledByOsServer = ((_this$core$server = this.core.server) === null || _this$core$server === void 0 || (_this$core$server$has = _this$core$server.hasRoute) === null || _this$core$server$has === void 0 ? void 0 : _this$core$server$has.call(_this$core$server, 'get', "".concat(baseUrl).concat(localPath))) === true;
|
|
3258
|
+
channelMap = {
|
|
3259
|
+
online_store: 'online-store',
|
|
3260
|
+
scan_to_order: 'online-store',
|
|
3261
|
+
'scan-to-order': 'online-store',
|
|
3262
|
+
scan_to_order_2: 'online-store',
|
|
3263
|
+
scan_to_order_3: 'scantoorder3'
|
|
3264
|
+
};
|
|
3265
|
+
channel = channelMap[(_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.channel] || ((_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.channel);
|
|
3266
|
+
businessCode = (_this$otherParams$bus3 = (_this$otherParams33 = this.otherParams) === null || _this$otherParams33 === void 0 ? void 0 : _this$otherParams33.businessCode) !== null && _this$otherParams$bus3 !== void 0 ? _this$otherParams$bus3 : (_this$otherParams34 = this.otherParams) === null || _this$otherParams34 === void 0 ? void 0 : _this$otherParams34.business_code;
|
|
3267
|
+
strategy_context = _objectSpread(_objectSpread(_objectSpread({}, channel ? {
|
|
3268
|
+
channel: channel
|
|
3269
|
+
} : {}), businessCode ? {
|
|
3270
|
+
business_code: businessCode
|
|
3271
|
+
} : {}), scopedParams.strategy_context || {});
|
|
3272
|
+
customerId = scopedParams.customer_id;
|
|
3273
|
+
if (customerId == null) customerId = (_this$core$getPlugin = (_this$core3 = this.core).getPlugin) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin = _this$core$getPlugin.call(_this$core3, 'user')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.get) === null || _this$core$getPlugin$ === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin$.call(_this$core$getPlugin)) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.id;
|
|
3274
|
+
queryPayload = _objectSpread(_objectSpread({}, scopedParams), {}, {
|
|
3275
|
+
customer_id: customerId,
|
|
3276
|
+
strategy_context: strategy_context,
|
|
3277
|
+
application_code: channel,
|
|
3278
|
+
is_eject: 1,
|
|
3279
|
+
open_bundle: 1,
|
|
3280
|
+
with_schedule: 1,
|
|
3281
|
+
with: _toConsumableArray(PRODUCT_QUERY_DATA_VARIANT_RELATIONS)
|
|
3282
|
+
}, isCustomerUserPlatform((_this$otherParams35 = this.otherParams) === null || _this$otherParams35 === void 0 ? void 0 : _this$otherParams35.platform) ? {} : {
|
|
3283
|
+
open_quotation: 1
|
|
3284
|
+
});
|
|
3285
|
+
_context29.next = 23;
|
|
3286
|
+
return this.request.get(baseUrl === '/shop' ? localPath : "/product/show/".concat(product_id), queryPayload, {
|
|
3287
|
+
osServer: true,
|
|
3288
|
+
useCache: false,
|
|
3289
|
+
customToast: function customToast() {}
|
|
3290
|
+
});
|
|
3291
|
+
case 23:
|
|
3292
|
+
response = _context29.sent;
|
|
3293
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) === false || Number(response === null || response === void 0 ? void 0 : response.code) >= 400)) {
|
|
3294
|
+
_context29.next = 26;
|
|
3295
|
+
break;
|
|
3296
|
+
}
|
|
3297
|
+
throw new Error('[UnifiedBookingSales] Product detail query failed');
|
|
3298
|
+
case 26:
|
|
3299
|
+
raw = (_response$data$item = response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.item) !== null && _response$data$item !== void 0 ? _response$data$item : response === null || response === void 0 ? void 0 : response.data;
|
|
3300
|
+
if (!(!raw || Number((_raw$id2 = raw.id) !== null && _raw$id2 !== void 0 ? _raw$id2 : raw.product_id) !== product_id)) {
|
|
3301
|
+
_context29.next = 29;
|
|
3302
|
+
break;
|
|
3303
|
+
}
|
|
3304
|
+
return _context29.abrupt("return", undefined);
|
|
3305
|
+
case 29:
|
|
3306
|
+
if (!(raw.status && raw.status !== 'published')) {
|
|
3307
|
+
_context29.next = 31;
|
|
3308
|
+
break;
|
|
3309
|
+
}
|
|
3310
|
+
return _context29.abrupt("return", undefined);
|
|
3311
|
+
case 31:
|
|
3312
|
+
if (!handledByOsServer) (_this$store$products = this.store.products) === null || _this$store$products === void 0 || (_this$store$products$ = _this$store$products.rememberRawProductQueryResult) === null || _this$store$products$ === void 0 || _this$store$products$.call(_this$store$products, [cloneDeep(raw)]);
|
|
3313
|
+
resolved = resolveClientDataVariants({
|
|
3314
|
+
core: this.core,
|
|
3315
|
+
otherParams: this.otherParams,
|
|
3316
|
+
products: [cloneDeep(raw)],
|
|
3317
|
+
queryPayload: queryPayload,
|
|
3318
|
+
handledByOsServer: handledByOsServer
|
|
3319
|
+
})[0]; // Detail owns relation arrays. Never synthesize empty groups from list counts.
|
|
3320
|
+
if (resolved) {
|
|
3321
|
+
_context29.next = 35;
|
|
3322
|
+
break;
|
|
3323
|
+
}
|
|
3324
|
+
return _context29.abrupt("return", undefined);
|
|
3325
|
+
case 35:
|
|
3326
|
+
detail = _objectSpread(_objectSpread(_objectSpread({}, member), resolved), {}, {
|
|
3327
|
+
metadata: _objectSpread(_objectSpread({}, member.metadata || {}), resolved.metadata || {})
|
|
3328
|
+
});
|
|
3329
|
+
for (_i2 = 0, _arr2 = ['bundle_group', 'bundle_groups', 'option_group', 'variant_group', 'variant']; _i2 < _arr2.length; _i2++) {
|
|
3330
|
+
key = _arr2[_i2];
|
|
3331
|
+
if (!Object.prototype.hasOwnProperty.call(resolved, key)) delete detail[key];
|
|
3332
|
+
}
|
|
3333
|
+
return _context29.abrupt("return", cloneDeep(detail));
|
|
3334
|
+
case 38:
|
|
3335
|
+
case "end":
|
|
3336
|
+
return _context29.stop();
|
|
3337
|
+
}
|
|
3338
|
+
}, _callee29, this);
|
|
3339
|
+
}));
|
|
3340
|
+
function queryCatalogProductDetail(_x16) {
|
|
3341
|
+
return _queryCatalogProductDetail.apply(this, arguments);
|
|
3342
|
+
}
|
|
3343
|
+
return queryCatalogProductDetail;
|
|
3344
|
+
}())
|
|
3345
|
+
}, {
|
|
3346
|
+
key: "loadCatalogProducts",
|
|
3347
|
+
value: function () {
|
|
3348
|
+
var _loadCatalogProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
3349
|
+
var params,
|
|
3350
|
+
options,
|
|
3351
|
+
catalogScope,
|
|
3352
|
+
schedule_date,
|
|
3353
|
+
schedule_datetime,
|
|
3354
|
+
result,
|
|
3355
|
+
_args30 = arguments;
|
|
3356
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3357
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3358
|
+
case 0:
|
|
3359
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
3360
|
+
options = _args30.length > 1 ? _args30[1] : undefined;
|
|
3116
3361
|
if (this.store.products) {
|
|
3117
|
-
|
|
3362
|
+
_context30.next = 4;
|
|
3118
3363
|
break;
|
|
3119
3364
|
}
|
|
3120
3365
|
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
@@ -3122,7 +3367,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3122
3367
|
catalogScope = this.otherParams.catalogScopeKey;
|
|
3123
3368
|
schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
3124
3369
|
schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
|
|
3125
|
-
|
|
3370
|
+
_context30.next = 9;
|
|
3126
3371
|
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
3127
3372
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
3128
3373
|
with_schedule: 1
|
|
@@ -3132,53 +3377,49 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3132
3377
|
cacheId: this.cacheId
|
|
3133
3378
|
}), options);
|
|
3134
3379
|
case 9:
|
|
3135
|
-
result =
|
|
3380
|
+
result = _context30.sent;
|
|
3136
3381
|
if (!(catalogScope !== this.otherParams.catalogScopeKey)) {
|
|
3137
|
-
|
|
3382
|
+
_context30.next = 12;
|
|
3138
3383
|
break;
|
|
3139
3384
|
}
|
|
3140
3385
|
throw Object.assign(new Error('Product scope changed'), {
|
|
3141
3386
|
name: 'AbortError'
|
|
3142
3387
|
});
|
|
3143
3388
|
case 12:
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
|
|
3147
|
-
case 15:
|
|
3148
|
-
return _context27.abrupt("return", result);
|
|
3149
|
-
case 16:
|
|
3389
|
+
return _context30.abrupt("return", result);
|
|
3390
|
+
case 13:
|
|
3150
3391
|
case "end":
|
|
3151
|
-
return
|
|
3392
|
+
return _context30.stop();
|
|
3152
3393
|
}
|
|
3153
|
-
},
|
|
3394
|
+
}, _callee30, this);
|
|
3154
3395
|
}));
|
|
3155
|
-
function
|
|
3156
|
-
return
|
|
3396
|
+
function loadCatalogProducts() {
|
|
3397
|
+
return _loadCatalogProducts.apply(this, arguments);
|
|
3157
3398
|
}
|
|
3158
|
-
return
|
|
3159
|
-
}()
|
|
3399
|
+
return loadCatalogProducts;
|
|
3400
|
+
}()
|
|
3160
3401
|
}, {
|
|
3161
3402
|
key: "queryProducts",
|
|
3162
3403
|
value: function () {
|
|
3163
|
-
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3404
|
+
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
3164
3405
|
var params,
|
|
3165
|
-
|
|
3166
|
-
return _regeneratorRuntime().wrap(function
|
|
3167
|
-
while (1) switch (
|
|
3406
|
+
_args31 = arguments;
|
|
3407
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3408
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3168
3409
|
case 0:
|
|
3169
|
-
params =
|
|
3410
|
+
params = _args31.length > 0 && _args31[0] !== undefined ? _args31[0] : {};
|
|
3170
3411
|
if (this.store.products) {
|
|
3171
|
-
|
|
3412
|
+
_context31.next = 3;
|
|
3172
3413
|
break;
|
|
3173
3414
|
}
|
|
3174
3415
|
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
3175
3416
|
case 3:
|
|
3176
|
-
return
|
|
3417
|
+
return _context31.abrupt("return", this.store.products.queryProducts(params));
|
|
3177
3418
|
case 4:
|
|
3178
3419
|
case "end":
|
|
3179
|
-
return
|
|
3420
|
+
return _context31.stop();
|
|
3180
3421
|
}
|
|
3181
|
-
},
|
|
3422
|
+
}, _callee31, this);
|
|
3182
3423
|
}));
|
|
3183
3424
|
function queryProducts() {
|
|
3184
3425
|
return _queryProducts.apply(this, arguments);
|
|
@@ -3188,24 +3429,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3188
3429
|
}, {
|
|
3189
3430
|
key: "loadScheduleAvailableDate",
|
|
3190
3431
|
value: (function () {
|
|
3191
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3192
|
-
return _regeneratorRuntime().wrap(function
|
|
3193
|
-
while (1) switch (
|
|
3432
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3433
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3434
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3194
3435
|
case 0:
|
|
3195
3436
|
if (this.store.schedule) {
|
|
3196
|
-
|
|
3437
|
+
_context32.next = 2;
|
|
3197
3438
|
break;
|
|
3198
3439
|
}
|
|
3199
3440
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
3200
3441
|
case 2:
|
|
3201
|
-
return
|
|
3442
|
+
return _context32.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
|
|
3202
3443
|
case 3:
|
|
3203
3444
|
case "end":
|
|
3204
|
-
return
|
|
3445
|
+
return _context32.stop();
|
|
3205
3446
|
}
|
|
3206
|
-
},
|
|
3447
|
+
}, _callee32, this);
|
|
3207
3448
|
}));
|
|
3208
|
-
function loadScheduleAvailableDate(
|
|
3449
|
+
function loadScheduleAvailableDate(_x17) {
|
|
3209
3450
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
3210
3451
|
}
|
|
3211
3452
|
return loadScheduleAvailableDate;
|
|
@@ -3219,15 +3460,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3219
3460
|
}, {
|
|
3220
3461
|
key: "loadProductsByScheduleDate",
|
|
3221
3462
|
value: (function () {
|
|
3222
|
-
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3463
|
+
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3223
3464
|
var _this$store$schedule$, _this$store$schedule, _this$store$schedule$2, _this$store$schedule2, _this$store$schedule$3, _this$store$schedule3, _this$store$schedule$4, _this$store$schedule4;
|
|
3224
3465
|
var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator, _step, productId, result;
|
|
3225
|
-
return _regeneratorRuntime().wrap(function
|
|
3226
|
-
while (1) switch (
|
|
3466
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3467
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3227
3468
|
case 0:
|
|
3228
|
-
date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params,
|
|
3469
|
+
date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded3);
|
|
3229
3470
|
if (this.store.schedule) {
|
|
3230
|
-
|
|
3471
|
+
_context33.next = 3;
|
|
3231
3472
|
break;
|
|
3232
3473
|
}
|
|
3233
3474
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
@@ -3238,10 +3479,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3238
3479
|
});
|
|
3239
3480
|
hasOtherProducts = (((_this$store$schedule$2 = (_this$store$schedule2 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$2 === void 0 ? void 0 : _this$store$schedule$2.call(_this$store$schedule2)) || []).length > 0;
|
|
3240
3481
|
if (!(!hasCachedDate && !hasOtherProducts)) {
|
|
3241
|
-
|
|
3482
|
+
_context33.next = 9;
|
|
3242
3483
|
break;
|
|
3243
3484
|
}
|
|
3244
|
-
|
|
3485
|
+
_context33.next = 9;
|
|
3245
3486
|
return this.loadScheduleAvailableDate({
|
|
3246
3487
|
startDate: date,
|
|
3247
3488
|
endDate: date,
|
|
@@ -3261,45 +3502,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3261
3502
|
return !productIdFilter || productIdFilter.has(String(id));
|
|
3262
3503
|
});
|
|
3263
3504
|
if (availableProductIds.length) {
|
|
3264
|
-
|
|
3505
|
+
_context33.next = 17;
|
|
3265
3506
|
break;
|
|
3266
3507
|
}
|
|
3267
3508
|
this.unifiedProductCatalog = [];
|
|
3268
|
-
|
|
3509
|
+
_context33.next = 16;
|
|
3269
3510
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
|
|
3270
3511
|
case 16:
|
|
3271
|
-
return
|
|
3512
|
+
return _context33.abrupt("return", []);
|
|
3272
3513
|
case 17:
|
|
3273
|
-
|
|
3514
|
+
_context33.next = 19;
|
|
3274
3515
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
3275
3516
|
product_ids: availableProductIds,
|
|
3276
3517
|
schedule_date: date
|
|
3277
3518
|
}));
|
|
3278
3519
|
case 19:
|
|
3279
|
-
products =
|
|
3520
|
+
products = _context33.sent;
|
|
3280
3521
|
if (!(products.length || availableProductIds.length <= 1)) {
|
|
3281
|
-
|
|
3522
|
+
_context33.next = 22;
|
|
3282
3523
|
break;
|
|
3283
3524
|
}
|
|
3284
|
-
return
|
|
3525
|
+
return _context33.abrupt("return", products);
|
|
3285
3526
|
case 22:
|
|
3286
3527
|
fallbackProducts = [];
|
|
3287
3528
|
_iterator = _createForOfIteratorHelper(availableProductIds);
|
|
3288
|
-
|
|
3529
|
+
_context33.prev = 24;
|
|
3289
3530
|
_iterator.s();
|
|
3290
3531
|
case 26:
|
|
3291
3532
|
if ((_step = _iterator.n()).done) {
|
|
3292
|
-
|
|
3533
|
+
_context33.next = 34;
|
|
3293
3534
|
break;
|
|
3294
3535
|
}
|
|
3295
3536
|
productId = _step.value;
|
|
3296
|
-
|
|
3537
|
+
_context33.next = 30;
|
|
3297
3538
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
3298
3539
|
product_ids: [productId],
|
|
3299
3540
|
schedule_date: date
|
|
3300
3541
|
}));
|
|
3301
3542
|
case 30:
|
|
3302
|
-
result =
|
|
3543
|
+
result = _context33.sent;
|
|
3303
3544
|
result.forEach(function (product) {
|
|
3304
3545
|
var _id;
|
|
3305
3546
|
var id = (_id = product === null || product === void 0 ? void 0 : product.id) !== null && _id !== void 0 ? _id : product === null || product === void 0 ? void 0 : product.product_id;
|
|
@@ -3311,32 +3552,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3311
3552
|
}
|
|
3312
3553
|
});
|
|
3313
3554
|
case 32:
|
|
3314
|
-
|
|
3555
|
+
_context33.next = 26;
|
|
3315
3556
|
break;
|
|
3316
3557
|
case 34:
|
|
3317
|
-
|
|
3558
|
+
_context33.next = 39;
|
|
3318
3559
|
break;
|
|
3319
3560
|
case 36:
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
_iterator.e(
|
|
3561
|
+
_context33.prev = 36;
|
|
3562
|
+
_context33.t0 = _context33["catch"](24);
|
|
3563
|
+
_iterator.e(_context33.t0);
|
|
3323
3564
|
case 39:
|
|
3324
|
-
|
|
3565
|
+
_context33.prev = 39;
|
|
3325
3566
|
_iterator.f();
|
|
3326
|
-
return
|
|
3567
|
+
return _context33.finish(39);
|
|
3327
3568
|
case 42:
|
|
3328
3569
|
this.unifiedProductCatalog = [].concat(fallbackProducts);
|
|
3329
|
-
|
|
3570
|
+
_context33.next = 45;
|
|
3330
3571
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
|
|
3331
3572
|
case 45:
|
|
3332
|
-
return
|
|
3573
|
+
return _context33.abrupt("return", fallbackProducts);
|
|
3333
3574
|
case 46:
|
|
3334
3575
|
case "end":
|
|
3335
|
-
return
|
|
3576
|
+
return _context33.stop();
|
|
3336
3577
|
}
|
|
3337
|
-
},
|
|
3578
|
+
}, _callee33, this, [[24, 36, 39, 42]]);
|
|
3338
3579
|
}));
|
|
3339
|
-
function loadProductsByScheduleDate(
|
|
3580
|
+
function loadProductsByScheduleDate(_x18) {
|
|
3340
3581
|
return _loadProductsByScheduleDate.apply(this, arguments);
|
|
3341
3582
|
}
|
|
3342
3583
|
return loadProductsByScheduleDate;
|
|
@@ -3389,7 +3630,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3389
3630
|
}, {
|
|
3390
3631
|
key: "applyPlannerDiscounts",
|
|
3391
3632
|
value: (function () {
|
|
3392
|
-
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3633
|
+
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
3393
3634
|
var _params$customerId;
|
|
3394
3635
|
var params,
|
|
3395
3636
|
tempOrder,
|
|
@@ -3406,24 +3647,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3406
3647
|
discount,
|
|
3407
3648
|
discountId,
|
|
3408
3649
|
nextTempOrder,
|
|
3409
|
-
|
|
3410
|
-
return _regeneratorRuntime().wrap(function
|
|
3411
|
-
while (1) switch (
|
|
3650
|
+
_args34 = arguments;
|
|
3651
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3652
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3412
3653
|
case 0:
|
|
3413
|
-
params =
|
|
3654
|
+
params = _args34.length > 0 && _args34[0] !== undefined ? _args34[0] : {};
|
|
3414
3655
|
tempOrder = this.getTempOrder();
|
|
3415
3656
|
requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
3416
3657
|
parsedCustomerId = Number(requestedCustomerId);
|
|
3417
3658
|
customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
|
|
3418
|
-
|
|
3659
|
+
_context34.next = 7;
|
|
3419
3660
|
return this.getSummary();
|
|
3420
3661
|
case 7:
|
|
3421
|
-
summaryBefore =
|
|
3662
|
+
summaryBefore = _context34.sent;
|
|
3422
3663
|
if (customerId) {
|
|
3423
|
-
|
|
3664
|
+
_context34.next = 10;
|
|
3424
3665
|
break;
|
|
3425
3666
|
}
|
|
3426
|
-
return
|
|
3667
|
+
return _context34.abrupt("return", buildPlannerDiscountResult({
|
|
3427
3668
|
customerId: null,
|
|
3428
3669
|
discountList: this.getDiscountList(),
|
|
3429
3670
|
products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
@@ -3432,7 +3673,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3432
3673
|
status: 'no_customer'
|
|
3433
3674
|
}));
|
|
3434
3675
|
case 10:
|
|
3435
|
-
|
|
3676
|
+
_context34.next = 12;
|
|
3436
3677
|
return this.loadDiscountConfig({
|
|
3437
3678
|
customerId: customerId,
|
|
3438
3679
|
action: 'create'
|
|
@@ -3444,7 +3685,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3444
3685
|
return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
|
|
3445
3686
|
});
|
|
3446
3687
|
if (!preferredDiscount) {
|
|
3447
|
-
|
|
3688
|
+
_context34.next = 40;
|
|
3448
3689
|
break;
|
|
3449
3690
|
}
|
|
3450
3691
|
// A requested card is an explicit UI choice, not a best-effort preference. Clear prior
|
|
@@ -3456,98 +3697,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3456
3697
|
return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
|
|
3457
3698
|
});
|
|
3458
3699
|
_iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
|
|
3459
|
-
|
|
3700
|
+
_context34.prev = 18;
|
|
3460
3701
|
_iterator2.s();
|
|
3461
3702
|
case 20:
|
|
3462
3703
|
if ((_step2 = _iterator2.n()).done) {
|
|
3463
|
-
|
|
3704
|
+
_context34.next = 28;
|
|
3464
3705
|
break;
|
|
3465
3706
|
}
|
|
3466
3707
|
discount = _step2.value;
|
|
3467
3708
|
discountId = Number(resolvePlannerDiscountId(discount));
|
|
3468
3709
|
if (!Number.isFinite(discountId)) {
|
|
3469
|
-
|
|
3710
|
+
_context34.next = 26;
|
|
3470
3711
|
break;
|
|
3471
3712
|
}
|
|
3472
|
-
|
|
3713
|
+
_context34.next = 26;
|
|
3473
3714
|
return this.setDiscountSelected({
|
|
3474
3715
|
discountId: discountId,
|
|
3475
3716
|
isSelected: false
|
|
3476
3717
|
});
|
|
3477
3718
|
case 26:
|
|
3478
|
-
|
|
3719
|
+
_context34.next = 20;
|
|
3479
3720
|
break;
|
|
3480
3721
|
case 28:
|
|
3481
|
-
|
|
3722
|
+
_context34.next = 33;
|
|
3482
3723
|
break;
|
|
3483
3724
|
case 30:
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
_iterator2.e(
|
|
3725
|
+
_context34.prev = 30;
|
|
3726
|
+
_context34.t0 = _context34["catch"](18);
|
|
3727
|
+
_iterator2.e(_context34.t0);
|
|
3487
3728
|
case 33:
|
|
3488
|
-
|
|
3729
|
+
_context34.prev = 33;
|
|
3489
3730
|
_iterator2.f();
|
|
3490
|
-
return
|
|
3731
|
+
return _context34.finish(33);
|
|
3491
3732
|
case 36:
|
|
3492
|
-
|
|
3733
|
+
_context34.next = 38;
|
|
3493
3734
|
return this.setDiscountSelected({
|
|
3494
3735
|
discountId: Number(preferredId),
|
|
3495
3736
|
isSelected: true
|
|
3496
3737
|
});
|
|
3497
3738
|
case 38:
|
|
3498
|
-
|
|
3739
|
+
_context34.next = 49;
|
|
3499
3740
|
break;
|
|
3500
3741
|
case 40:
|
|
3501
3742
|
if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
|
|
3502
|
-
|
|
3743
|
+
_context34.next = 46;
|
|
3503
3744
|
break;
|
|
3504
3745
|
}
|
|
3505
3746
|
if (!(params.applyBestDiscount !== false)) {
|
|
3506
|
-
|
|
3747
|
+
_context34.next = 44;
|
|
3507
3748
|
break;
|
|
3508
3749
|
}
|
|
3509
|
-
|
|
3750
|
+
_context34.next = 44;
|
|
3510
3751
|
return this.bestDiscount();
|
|
3511
3752
|
case 44:
|
|
3512
|
-
|
|
3753
|
+
_context34.next = 49;
|
|
3513
3754
|
break;
|
|
3514
3755
|
case 46:
|
|
3515
3756
|
if (!(params.applyBestDiscount !== false)) {
|
|
3516
|
-
|
|
3757
|
+
_context34.next = 49;
|
|
3517
3758
|
break;
|
|
3518
3759
|
}
|
|
3519
|
-
|
|
3760
|
+
_context34.next = 49;
|
|
3520
3761
|
return this.bestDiscount();
|
|
3521
3762
|
case 49:
|
|
3522
3763
|
nextTempOrder = this.getTempOrder();
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3764
|
+
_context34.t1 = buildPlannerDiscountResult;
|
|
3765
|
+
_context34.t2 = customerId;
|
|
3766
|
+
_context34.t3 = this.getDiscountList();
|
|
3767
|
+
_context34.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
|
|
3768
|
+
_context34.t5 = summaryBefore;
|
|
3769
|
+
_context34.next = 57;
|
|
3529
3770
|
return this.getSummary();
|
|
3530
3771
|
case 57:
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
customerId:
|
|
3537
|
-
discountList:
|
|
3538
|
-
products:
|
|
3539
|
-
summaryBefore:
|
|
3540
|
-
summaryAfter:
|
|
3541
|
-
status:
|
|
3542
|
-
preferredDiscountId:
|
|
3543
|
-
preferredDiscountFound:
|
|
3772
|
+
_context34.t6 = _context34.sent;
|
|
3773
|
+
_context34.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
|
|
3774
|
+
_context34.t8 = preferredDiscountId;
|
|
3775
|
+
_context34.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
|
|
3776
|
+
_context34.t10 = {
|
|
3777
|
+
customerId: _context34.t2,
|
|
3778
|
+
discountList: _context34.t3,
|
|
3779
|
+
products: _context34.t4,
|
|
3780
|
+
summaryBefore: _context34.t5,
|
|
3781
|
+
summaryAfter: _context34.t6,
|
|
3782
|
+
status: _context34.t7,
|
|
3783
|
+
preferredDiscountId: _context34.t8,
|
|
3784
|
+
preferredDiscountFound: _context34.t9
|
|
3544
3785
|
};
|
|
3545
|
-
return
|
|
3786
|
+
return _context34.abrupt("return", (0, _context34.t1)(_context34.t10));
|
|
3546
3787
|
case 63:
|
|
3547
3788
|
case "end":
|
|
3548
|
-
return
|
|
3789
|
+
return _context34.stop();
|
|
3549
3790
|
}
|
|
3550
|
-
},
|
|
3791
|
+
}, _callee34, this, [[18, 30, 33, 36]]);
|
|
3551
3792
|
}));
|
|
3552
3793
|
function applyPlannerDiscounts() {
|
|
3553
3794
|
return _applyPlannerDiscounts.apply(this, arguments);
|
|
@@ -3572,9 +3813,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3572
3813
|
sourceProduct: sourceProduct
|
|
3573
3814
|
});
|
|
3574
3815
|
if (orderProduct && _typeof(orderProduct) === 'object') {
|
|
3816
|
+
var venueMetadata = Object.fromEntries(['venue_booking_role', 'venue_booking_parent_uid', 'venue_booking_service_datetime', 'venue_booking_scope_key'].filter(function (key) {
|
|
3817
|
+
var _sourceProduct$metada2;
|
|
3818
|
+
return ((_sourceProduct$metada2 = sourceProduct.metadata) === null || _sourceProduct$metada2 === void 0 ? void 0 : _sourceProduct$metada2[key]) !== undefined;
|
|
3819
|
+
}).map(function (key) {
|
|
3820
|
+
return [key, sourceProduct.metadata[key]];
|
|
3821
|
+
}));
|
|
3575
3822
|
// BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
|
|
3576
3823
|
// quotation shelf after that transform so neither booking adds nor edits lose quote identity.
|
|
3577
|
-
orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), quotationShelfId !== undefined ? {
|
|
3824
|
+
orderProduct.metadata = _objectSpread(_objectSpread(_objectSpread({}, orderProduct.metadata || {}), venueMetadata), {}, _defineProperty({}, ownershipKey, true), quotationShelfId !== undefined ? {
|
|
3578
3825
|
quotation_shelf_id: quotationShelfId
|
|
3579
3826
|
} : {});
|
|
3580
3827
|
}
|
|
@@ -3585,29 +3832,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3585
3832
|
}, {
|
|
3586
3833
|
key: "removeExistingStagedLines",
|
|
3587
3834
|
value: (function () {
|
|
3588
|
-
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3835
|
+
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(ownershipKey) {
|
|
3589
3836
|
var _this$getTempOrder2;
|
|
3590
3837
|
var existingLines;
|
|
3591
|
-
return _regeneratorRuntime().wrap(function
|
|
3592
|
-
while (1) switch (
|
|
3838
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3839
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3593
3840
|
case 0:
|
|
3594
3841
|
existingLines = (((_this$getTempOrder2 = this.getTempOrder()) === null || _this$getTempOrder2 === void 0 ? void 0 : _this$getTempOrder2.products) || []).filter(function (product) {
|
|
3595
3842
|
var _product$metadata5;
|
|
3596
3843
|
return (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5[ownershipKey]) === true;
|
|
3597
3844
|
});
|
|
3598
3845
|
if (!(existingLines.length > 0)) {
|
|
3599
|
-
|
|
3846
|
+
_context35.next = 4;
|
|
3600
3847
|
break;
|
|
3601
3848
|
}
|
|
3602
|
-
|
|
3849
|
+
_context35.next = 4;
|
|
3603
3850
|
return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
|
|
3604
3851
|
case 4:
|
|
3605
3852
|
case "end":
|
|
3606
|
-
return
|
|
3853
|
+
return _context35.stop();
|
|
3607
3854
|
}
|
|
3608
|
-
},
|
|
3855
|
+
}, _callee35, this);
|
|
3609
3856
|
}));
|
|
3610
|
-
function removeExistingStagedLines(
|
|
3857
|
+
function removeExistingStagedLines(_x19) {
|
|
3611
3858
|
return _removeExistingStagedLines.apply(this, arguments);
|
|
3612
3859
|
}
|
|
3613
3860
|
return removeExistingStagedLines;
|
|
@@ -3615,25 +3862,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3615
3862
|
}, {
|
|
3616
3863
|
key: "stageProducts",
|
|
3617
3864
|
value: function () {
|
|
3618
|
-
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3865
|
+
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params, ownershipKey) {
|
|
3619
3866
|
var _params$rawProducts;
|
|
3620
|
-
var productIds, existingIds, missingIds, productIdSet, selectedProducts,
|
|
3621
|
-
return _regeneratorRuntime().wrap(function
|
|
3622
|
-
while (1) switch (
|
|
3867
|
+
var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i3, _arr3, sourceProduct, productInput;
|
|
3868
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3869
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3623
3870
|
case 0:
|
|
3624
3871
|
productIds = params.productIds || [];
|
|
3625
3872
|
if (productIds.length) {
|
|
3626
|
-
|
|
3873
|
+
_context36.next = 3;
|
|
3627
3874
|
break;
|
|
3628
3875
|
}
|
|
3629
|
-
return
|
|
3876
|
+
return _context36.abrupt("return", this.getTempOrder());
|
|
3630
3877
|
case 3:
|
|
3631
3878
|
if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
|
|
3632
|
-
|
|
3879
|
+
_context36.next = 7;
|
|
3633
3880
|
break;
|
|
3634
3881
|
}
|
|
3635
3882
|
this.unifiedProductCatalog = params.rawProducts;
|
|
3636
|
-
|
|
3883
|
+
_context36.next = 12;
|
|
3637
3884
|
break;
|
|
3638
3885
|
case 7:
|
|
3639
3886
|
existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
|
|
@@ -3644,15 +3891,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3644
3891
|
return !existingIds.has(String(id));
|
|
3645
3892
|
});
|
|
3646
3893
|
if (!(missingIds.length || params.productLoadParams)) {
|
|
3647
|
-
|
|
3894
|
+
_context36.next = 12;
|
|
3648
3895
|
break;
|
|
3649
3896
|
}
|
|
3650
|
-
|
|
3897
|
+
_context36.next = 12;
|
|
3651
3898
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
3652
3899
|
product_ids: productIds.map(Number).filter(Number.isFinite)
|
|
3653
3900
|
}));
|
|
3654
3901
|
case 12:
|
|
3655
|
-
|
|
3902
|
+
_context36.next = 14;
|
|
3656
3903
|
return this.removeExistingStagedLines(ownershipKey);
|
|
3657
3904
|
case 14:
|
|
3658
3905
|
productIdSet = new Set(productIds.map(function (id) {
|
|
@@ -3662,33 +3909,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3662
3909
|
var _product$id2;
|
|
3663
3910
|
return productIdSet.has(String((_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id));
|
|
3664
3911
|
});
|
|
3665
|
-
|
|
3912
|
+
_i3 = 0, _arr3 = selectedProducts;
|
|
3666
3913
|
case 17:
|
|
3667
|
-
if (!(
|
|
3668
|
-
|
|
3914
|
+
if (!(_i3 < _arr3.length)) {
|
|
3915
|
+
_context36.next = 26;
|
|
3669
3916
|
break;
|
|
3670
3917
|
}
|
|
3671
|
-
sourceProduct =
|
|
3918
|
+
sourceProduct = _arr3[_i3];
|
|
3672
3919
|
productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
|
|
3673
3920
|
if (!productInput) {
|
|
3674
|
-
|
|
3921
|
+
_context36.next = 23;
|
|
3675
3922
|
break;
|
|
3676
3923
|
}
|
|
3677
|
-
|
|
3924
|
+
_context36.next = 23;
|
|
3678
3925
|
return this.addProductToOrder(productInput);
|
|
3679
3926
|
case 23:
|
|
3680
|
-
|
|
3681
|
-
|
|
3927
|
+
_i3++;
|
|
3928
|
+
_context36.next = 17;
|
|
3682
3929
|
break;
|
|
3683
3930
|
case 26:
|
|
3684
|
-
return
|
|
3931
|
+
return _context36.abrupt("return", this.getTempOrder());
|
|
3685
3932
|
case 27:
|
|
3686
3933
|
case "end":
|
|
3687
|
-
return
|
|
3934
|
+
return _context36.stop();
|
|
3688
3935
|
}
|
|
3689
|
-
},
|
|
3936
|
+
}, _callee36, this);
|
|
3690
3937
|
}));
|
|
3691
|
-
function stageProducts(
|
|
3938
|
+
function stageProducts(_x20, _x21) {
|
|
3692
3939
|
return _stageProducts.apply(this, arguments);
|
|
3693
3940
|
}
|
|
3694
3941
|
return stageProducts;
|
|
@@ -3700,18 +3947,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3700
3947
|
}, {
|
|
3701
3948
|
key: "stageRetailProducts",
|
|
3702
3949
|
value: (function () {
|
|
3703
|
-
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3704
|
-
return _regeneratorRuntime().wrap(function
|
|
3705
|
-
while (1) switch (
|
|
3950
|
+
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
3951
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3952
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3706
3953
|
case 0:
|
|
3707
|
-
return
|
|
3954
|
+
return _context37.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
|
|
3708
3955
|
case 1:
|
|
3709
3956
|
case "end":
|
|
3710
|
-
return
|
|
3957
|
+
return _context37.stop();
|
|
3711
3958
|
}
|
|
3712
|
-
},
|
|
3959
|
+
}, _callee37, this);
|
|
3713
3960
|
}));
|
|
3714
|
-
function stageRetailProducts(
|
|
3961
|
+
function stageRetailProducts(_x22) {
|
|
3715
3962
|
return _stageRetailProducts.apply(this, arguments);
|
|
3716
3963
|
}
|
|
3717
3964
|
return stageRetailProducts;
|
|
@@ -3725,15 +3972,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3725
3972
|
}, {
|
|
3726
3973
|
key: "addRetailProduct",
|
|
3727
3974
|
value: (function () {
|
|
3728
|
-
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3729
|
-
var _params$quantity,
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3975
|
+
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
3976
|
+
var _params$quantity,
|
|
3977
|
+
_ref47,
|
|
3978
|
+
_params$productId,
|
|
3979
|
+
_params$product,
|
|
3980
|
+
_params$product2,
|
|
3981
|
+
_metadata2,
|
|
3982
|
+
_this10 = this;
|
|
3983
|
+
var quantity, productId, sourceProduct, products, orderProduct, order, meta, parentUid, scopeKey, service, identity, isCurrentOrder, guard;
|
|
3984
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3985
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3733
3986
|
case 0:
|
|
3734
3987
|
quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
|
|
3735
3988
|
if (!(!Number.isFinite(quantity) || quantity <= 0)) {
|
|
3736
|
-
|
|
3989
|
+
_context38.next = 3;
|
|
3737
3990
|
break;
|
|
3738
3991
|
}
|
|
3739
3992
|
throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
|
|
@@ -3747,22 +4000,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3747
4000
|
});
|
|
3748
4001
|
}
|
|
3749
4002
|
if (!(!sourceProduct && productId !== undefined && productId !== null)) {
|
|
3750
|
-
|
|
4003
|
+
_context38.next = 11;
|
|
3751
4004
|
break;
|
|
3752
4005
|
}
|
|
3753
|
-
|
|
4006
|
+
_context38.next = 9;
|
|
3754
4007
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
3755
4008
|
product_ids: [Number(productId)].filter(Number.isFinite)
|
|
3756
4009
|
}));
|
|
3757
4010
|
case 9:
|
|
3758
|
-
products =
|
|
4011
|
+
products = _context38.sent;
|
|
3759
4012
|
sourceProduct = products.find(function (product) {
|
|
3760
4013
|
var _product$id4;
|
|
3761
4014
|
return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
|
|
3762
4015
|
});
|
|
3763
4016
|
case 11:
|
|
3764
4017
|
if (sourceProduct) {
|
|
3765
|
-
|
|
4018
|
+
_context38.next = 13;
|
|
3766
4019
|
break;
|
|
3767
4020
|
}
|
|
3768
4021
|
throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
|
|
@@ -3771,19 +4024,55 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3771
4024
|
quantity: quantity
|
|
3772
4025
|
}), 'unified_booking_sales_retail');
|
|
3773
4026
|
if (orderProduct) {
|
|
3774
|
-
|
|
4027
|
+
_context38.next = 16;
|
|
3775
4028
|
break;
|
|
3776
4029
|
}
|
|
3777
4030
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
3778
4031
|
case 16:
|
|
3779
|
-
|
|
3780
|
-
|
|
4032
|
+
if (!(((_metadata2 = orderProduct.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.venue_booking_role) === 'party_extra')) {
|
|
4033
|
+
_context38.next = 29;
|
|
4034
|
+
break;
|
|
4035
|
+
}
|
|
4036
|
+
order = this.getTempOrder();
|
|
4037
|
+
meta = orderProduct.metadata;
|
|
4038
|
+
parentUid = String(meta.venue_booking_parent_uid || '');
|
|
4039
|
+
scopeKey = String(meta.venue_booking_scope_key || '');
|
|
4040
|
+
service = String(meta.venue_booking_service_datetime || '');
|
|
4041
|
+
identity = [order === null || order === void 0 ? void 0 : order.order_id, order === null || order === void 0 ? void 0 : order.external_sale_number];
|
|
4042
|
+
isCurrentOrder = function isCurrentOrder() {
|
|
4043
|
+
return _this10.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];
|
|
4044
|
+
};
|
|
4045
|
+
guard = function guard() {
|
|
4046
|
+
var _params$availabilityC, _parent$metadata, _parent$metadata2, _parent$metadata3;
|
|
4047
|
+
(_params$availabilityC = params.availabilityCommitGuard) === null || _params$availabilityC === void 0 || _params$availabilityC.call(params);
|
|
4048
|
+
var parent = ((order === null || order === void 0 ? void 0 : order.products) || []).find(function (line) {
|
|
4049
|
+
return getProductLineUid(line) === parentUid;
|
|
4050
|
+
});
|
|
4051
|
+
var parentService = String((parent === null || parent === void 0 || (_parent$metadata = parent.metadata) === null || _parent$metadata === void 0 ? void 0 : _parent$metadata.venue_booking_service_datetime) || '');
|
|
4052
|
+
if (!isCurrentOrder() || !order || order.order_id || !parentUid || !scopeKey || (parent === null || parent === void 0 || (_parent$metadata2 = parent.metadata) === null || _parent$metadata2 === void 0 ? void 0 : _parent$metadata2.venue_booking_role) !== 'party_main' || (parent === null || parent === void 0 || (_parent$metadata3 = parent.metadata) === null || _parent$metadata3 === void 0 ? void 0 : _parent$metadata3.venue_booking_scope_key) !== scopeKey || !service || !parentService || !dayjs(service).isValid() || !dayjs(parentService).isValid() || dayjs(service).format('YYYY-MM-DD HH:mm:ss') !== dayjs(parentService).format('YYYY-MM-DD HH:mm:ss')) throw _this10.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'Party 主商品或服务时间已变化,请重新确认附加商品');
|
|
4053
|
+
};
|
|
4054
|
+
guard();
|
|
4055
|
+
delete orderProduct.unique_identification_number;
|
|
4056
|
+
delete orderProduct.metadata.unique_identification_number;
|
|
4057
|
+
return _context38.abrupt("return", this.addProductToOrder(orderProduct, undefined, {
|
|
4058
|
+
disableMerge: true,
|
|
4059
|
+
availabilityCommitGuard: guard,
|
|
4060
|
+
availabilityCommitTargetGuard: isCurrentOrder,
|
|
4061
|
+
salesNotes: params.salesNotes
|
|
4062
|
+
}));
|
|
4063
|
+
case 29:
|
|
4064
|
+
return _context38.abrupt("return", this.addProductToOrder(orderProduct, undefined, _objectSpread(_objectSpread({}, params.availabilityCommitGuard ? {
|
|
4065
|
+
availabilityCommitGuard: params.availabilityCommitGuard
|
|
4066
|
+
} : {}), params.salesNotes ? {
|
|
4067
|
+
salesNotes: params.salesNotes
|
|
4068
|
+
} : {})));
|
|
4069
|
+
case 30:
|
|
3781
4070
|
case "end":
|
|
3782
|
-
return
|
|
4071
|
+
return _context38.stop();
|
|
3783
4072
|
}
|
|
3784
|
-
},
|
|
4073
|
+
}, _callee38, this);
|
|
3785
4074
|
}));
|
|
3786
|
-
function addRetailProduct(
|
|
4075
|
+
function addRetailProduct(_x23) {
|
|
3787
4076
|
return _addRetailProduct.apply(this, arguments);
|
|
3788
4077
|
}
|
|
3789
4078
|
return addRetailProduct;
|
|
@@ -3847,8 +4136,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3847
4136
|
params: params
|
|
3848
4137
|
});
|
|
3849
4138
|
}
|
|
3850
|
-
if (!hasProductAnchor && !params.catalogScope) {
|
|
3851
|
-
throw new AvailabilityError('MISSING_CATALOG_SCOPE', '缺少 productIds 时必须提供 catalogScope', {
|
|
4139
|
+
if (!hasProductAnchor && !params.catalogScope && !Array.isArray(params.rawProducts)) {
|
|
4140
|
+
throw new AvailabilityError('MISSING_CATALOG_SCOPE', '缺少 productIds 时必须提供 catalogScope 或 rawProducts', {
|
|
3852
4141
|
params: params
|
|
3853
4142
|
});
|
|
3854
4143
|
}
|
|
@@ -3883,7 +4172,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3883
4172
|
}, {
|
|
3884
4173
|
key: "buildAvailabilityOperatingHoursSnapshot",
|
|
3885
4174
|
value: function buildAvailabilityOperatingHoursSnapshot(params) {
|
|
3886
|
-
var
|
|
4175
|
+
var _this11 = this;
|
|
3887
4176
|
var descriptor = params.prepare._availabilityOperatingHours || {
|
|
3888
4177
|
source: params.prepare.businessHours ? 'prepare_business_hours' : 'default_business_hours',
|
|
3889
4178
|
scheduleIds: []
|
|
@@ -3893,7 +4182,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3893
4182
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3894
4183
|
startAt: "".concat(date, "T").concat(params.businessHours.startTime, ":00"),
|
|
3895
4184
|
endAt: "".concat(date, "T").concat(params.businessHours.endTime, ":00"),
|
|
3896
|
-
fixedOffsetMinutes:
|
|
4185
|
+
fixedOffsetMinutes: _this11.getAvailabilityRuntimeOffsetMinutes(),
|
|
3897
4186
|
rollOverEnd: true
|
|
3898
4187
|
});
|
|
3899
4188
|
return range ? [{
|
|
@@ -3928,7 +4217,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3928
4217
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3929
4218
|
startAt: slot.start_at,
|
|
3930
4219
|
endAt: slot.end_at,
|
|
3931
|
-
fixedOffsetMinutes:
|
|
4220
|
+
fixedOffsetMinutes: _this11.getAvailabilityRuntimeOffsetMinutes(),
|
|
3932
4221
|
rollOverEnd: true
|
|
3933
4222
|
});
|
|
3934
4223
|
return range ? [{
|
|
@@ -3944,7 +4233,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3944
4233
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3945
4234
|
startAt: slot.start_at,
|
|
3946
4235
|
endAt: slot.end_at,
|
|
3947
|
-
fixedOffsetMinutes:
|
|
4236
|
+
fixedOffsetMinutes: _this11.getAvailabilityRuntimeOffsetMinutes(),
|
|
3948
4237
|
rollOverEnd: true
|
|
3949
4238
|
});
|
|
3950
4239
|
return range ? [{
|
|
@@ -3971,53 +4260,58 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3971
4260
|
}, {
|
|
3972
4261
|
key: "loadAvailabilityProducts",
|
|
3973
4262
|
value: function () {
|
|
3974
|
-
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3975
|
-
var
|
|
3976
|
-
_prepare$
|
|
3977
|
-
|
|
4263
|
+
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
4264
|
+
var _this12 = this,
|
|
4265
|
+
_prepare$catalogScope3,
|
|
4266
|
+
_prepare$catalogScope4,
|
|
3978
4267
|
_prepare$resourceIds;
|
|
3979
|
-
var prepare, dateRange, explicitProductIds, rawProducts, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
|
|
3980
|
-
return _regeneratorRuntime().wrap(function
|
|
3981
|
-
while (1) switch (
|
|
4268
|
+
var prepare, dateRange, explicitProductIds, publishCatalog, loadProducts, rawProducts, _prepare$catalogScope2, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
|
|
4269
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4270
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3982
4271
|
case 0:
|
|
3983
4272
|
prepare = params.prepare, dateRange = params.dateRange;
|
|
3984
4273
|
explicitProductIds = prepare.productIds || [];
|
|
4274
|
+
publishCatalog = prepare.publishCatalog !== false;
|
|
4275
|
+
loadProducts = function loadProducts(query) {
|
|
4276
|
+
var _prepare$catalogScope;
|
|
4277
|
+
return publishCatalog ? _this12.loadProducts(query) : ((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'productList' ? _this12.queryCatalogSnapshot(query) : _this12.loadCatalogProducts(query);
|
|
4278
|
+
};
|
|
3985
4279
|
rawProducts = [];
|
|
3986
4280
|
if (!Array.isArray(prepare.rawProducts)) {
|
|
3987
|
-
|
|
4281
|
+
_context39.next = 10;
|
|
3988
4282
|
break;
|
|
3989
4283
|
}
|
|
3990
4284
|
rawProducts = prepare.rawProducts;
|
|
3991
|
-
this.unifiedProductCatalog = _toConsumableArray(rawProducts);
|
|
3992
|
-
|
|
4285
|
+
if (publishCatalog) this.unifiedProductCatalog = _toConsumableArray(rawProducts);
|
|
4286
|
+
_context39.next = 36;
|
|
3993
4287
|
break;
|
|
3994
|
-
case
|
|
4288
|
+
case 10:
|
|
3995
4289
|
if (!(explicitProductIds.length > 0)) {
|
|
3996
|
-
|
|
4290
|
+
_context39.next = 16;
|
|
3997
4291
|
break;
|
|
3998
4292
|
}
|
|
3999
|
-
|
|
4000
|
-
return
|
|
4293
|
+
_context39.next = 13;
|
|
4294
|
+
return loadProducts(_objectSpread(_objectSpread({}, !publishCatalog && ((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList' ? prepare.catalogScope.params : {}), {}, {
|
|
4001
4295
|
product_ids: explicitProductIds,
|
|
4002
4296
|
schedule_date: dateRange.startDate
|
|
4003
|
-
});
|
|
4004
|
-
case
|
|
4005
|
-
rawProducts =
|
|
4006
|
-
|
|
4297
|
+
}));
|
|
4298
|
+
case 13:
|
|
4299
|
+
rawProducts = _context39.sent;
|
|
4300
|
+
_context39.next = 36;
|
|
4007
4301
|
break;
|
|
4008
|
-
case
|
|
4009
|
-
if (!(((_prepare$
|
|
4010
|
-
|
|
4302
|
+
case 16:
|
|
4303
|
+
if (!(((_prepare$catalogScope3 = prepare.catalogScope) === null || _prepare$catalogScope3 === void 0 ? void 0 : _prepare$catalogScope3.type) === 'schedule')) {
|
|
4304
|
+
_context39.next = 32;
|
|
4011
4305
|
break;
|
|
4012
4306
|
}
|
|
4013
|
-
|
|
4307
|
+
_context39.next = 19;
|
|
4014
4308
|
return this.loadScheduleAvailableDate({
|
|
4015
4309
|
startDate: dateRange.startDate,
|
|
4016
4310
|
endDate: dateRange.endDate,
|
|
4017
4311
|
custom_page_id: Number(prepare.catalogScope.customPageId) || undefined,
|
|
4018
4312
|
channel: prepare.catalogScope.channel
|
|
4019
4313
|
});
|
|
4020
|
-
case
|
|
4314
|
+
case 19:
|
|
4021
4315
|
dateSet = new Set(dateRangeDays(dateRange));
|
|
4022
4316
|
scheduleProductIds = (((_this$store$schedule$6 = (_this$store$schedule6 = this.store.schedule).getAvailabilityScheduleDateList) === null || _this$store$schedule$6 === void 0 ? void 0 : _this$store$schedule$6.call(_this$store$schedule6)) || []).filter(function (item) {
|
|
4023
4317
|
return dateSet.has(item.date);
|
|
@@ -4026,44 +4320,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4026
4320
|
});
|
|
4027
4321
|
productIds = uniqueAvailabilityIds([].concat(_toConsumableArray(scheduleProductIds), _toConsumableArray(((_this$store$schedule$7 = (_this$store$schedule7 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$7 === void 0 ? void 0 : _this$store$schedule$7.call(_this$store$schedule7)) || [])));
|
|
4028
4322
|
if (!(productIds.length > 0)) {
|
|
4029
|
-
|
|
4323
|
+
_context39.next = 29;
|
|
4030
4324
|
break;
|
|
4031
4325
|
}
|
|
4032
4326
|
assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
|
|
4033
|
-
|
|
4034
|
-
return
|
|
4327
|
+
_context39.next = 26;
|
|
4328
|
+
return loadProducts({
|
|
4035
4329
|
product_ids: productIds,
|
|
4036
4330
|
schedule_date: dateRange.startDate
|
|
4037
4331
|
});
|
|
4038
|
-
case
|
|
4039
|
-
rawProducts =
|
|
4040
|
-
|
|
4041
|
-
break;
|
|
4042
|
-
case 27:
|
|
4043
|
-
this.unifiedProductCatalog = [];
|
|
4044
|
-
case 28:
|
|
4045
|
-
_context36.next = 34;
|
|
4332
|
+
case 26:
|
|
4333
|
+
rawProducts = _context39.sent;
|
|
4334
|
+
_context39.next = 30;
|
|
4046
4335
|
break;
|
|
4336
|
+
case 29:
|
|
4337
|
+
if (publishCatalog) this.unifiedProductCatalog = [];
|
|
4047
4338
|
case 30:
|
|
4048
|
-
|
|
4049
|
-
|
|
4339
|
+
_context39.next = 36;
|
|
4340
|
+
break;
|
|
4341
|
+
case 32:
|
|
4342
|
+
if (!(((_prepare$catalogScope4 = prepare.catalogScope) === null || _prepare$catalogScope4 === void 0 ? void 0 : _prepare$catalogScope4.type) === 'productList')) {
|
|
4343
|
+
_context39.next = 36;
|
|
4050
4344
|
break;
|
|
4051
4345
|
}
|
|
4052
|
-
|
|
4053
|
-
return
|
|
4346
|
+
_context39.next = 35;
|
|
4347
|
+
return loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
|
|
4054
4348
|
schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
|
|
4055
4349
|
}));
|
|
4056
|
-
case
|
|
4057
|
-
rawProducts =
|
|
4058
|
-
case
|
|
4350
|
+
case 35:
|
|
4351
|
+
rawProducts = _context39.sent;
|
|
4352
|
+
case 36:
|
|
4059
4353
|
normalized = rawProducts.map(function (product) {
|
|
4060
|
-
return normalizeProductForAvailability(product, params.scheduleList,
|
|
4354
|
+
return normalizeProductForAvailability(product, params.scheduleList, _this12.getAvailabilityRuntimeOffsetMinutes());
|
|
4061
4355
|
});
|
|
4062
4356
|
if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
|
|
4063
|
-
|
|
4357
|
+
_context39.next = 39;
|
|
4064
4358
|
break;
|
|
4065
4359
|
}
|
|
4066
|
-
return
|
|
4360
|
+
return _context39.abrupt("return", normalized.filter(function (product) {
|
|
4067
4361
|
var _product$requirementG2;
|
|
4068
4362
|
return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
|
|
4069
4363
|
var _group$resourceIds3;
|
|
@@ -4074,18 +4368,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4074
4368
|
});
|
|
4075
4369
|
});
|
|
4076
4370
|
}));
|
|
4077
|
-
case
|
|
4371
|
+
case 39:
|
|
4078
4372
|
productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
|
|
4079
|
-
return
|
|
4373
|
+
return _context39.abrupt("return", productIdSet ? normalized.filter(function (product) {
|
|
4080
4374
|
return productIdSet.has(String(product.id));
|
|
4081
4375
|
}) : normalized);
|
|
4082
|
-
case
|
|
4376
|
+
case 41:
|
|
4083
4377
|
case "end":
|
|
4084
|
-
return
|
|
4378
|
+
return _context39.stop();
|
|
4085
4379
|
}
|
|
4086
|
-
},
|
|
4380
|
+
}, _callee39, this);
|
|
4087
4381
|
}));
|
|
4088
|
-
function loadAvailabilityProducts(
|
|
4382
|
+
function loadAvailabilityProducts(_x24) {
|
|
4089
4383
|
return _loadAvailabilityProducts.apply(this, arguments);
|
|
4090
4384
|
}
|
|
4091
4385
|
return loadAvailabilityProducts;
|
|
@@ -4098,12 +4392,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4098
4392
|
}, {
|
|
4099
4393
|
key: "fetchAvailabilityResourcesV2",
|
|
4100
4394
|
value: (function () {
|
|
4101
|
-
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4395
|
+
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
4102
4396
|
var response, data;
|
|
4103
|
-
return _regeneratorRuntime().wrap(function
|
|
4104
|
-
while (1) switch (
|
|
4397
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4398
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4105
4399
|
case 0:
|
|
4106
|
-
|
|
4400
|
+
_context40.next = 2;
|
|
4107
4401
|
return this.request.get('/schedule/resource/list/v2', {
|
|
4108
4402
|
start_date: params.dateRange.startDate,
|
|
4109
4403
|
end_date: params.dateRange.endDate,
|
|
@@ -4113,28 +4407,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4113
4407
|
useCache: false
|
|
4114
4408
|
});
|
|
4115
4409
|
case 2:
|
|
4116
|
-
response =
|
|
4410
|
+
response = _context40.sent;
|
|
4117
4411
|
data = response === null || response === void 0 ? void 0 : response.data;
|
|
4118
4412
|
if (!Array.isArray(data)) {
|
|
4119
|
-
|
|
4413
|
+
_context40.next = 6;
|
|
4120
4414
|
break;
|
|
4121
4415
|
}
|
|
4122
|
-
return
|
|
4416
|
+
return _context40.abrupt("return", data);
|
|
4123
4417
|
case 6:
|
|
4124
4418
|
if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
|
|
4125
|
-
|
|
4419
|
+
_context40.next = 8;
|
|
4126
4420
|
break;
|
|
4127
4421
|
}
|
|
4128
|
-
return
|
|
4422
|
+
return _context40.abrupt("return", data.list);
|
|
4129
4423
|
case 8:
|
|
4130
|
-
return
|
|
4424
|
+
return _context40.abrupt("return", []);
|
|
4131
4425
|
case 9:
|
|
4132
4426
|
case "end":
|
|
4133
|
-
return
|
|
4427
|
+
return _context40.stop();
|
|
4134
4428
|
}
|
|
4135
|
-
},
|
|
4429
|
+
}, _callee40, this);
|
|
4136
4430
|
}));
|
|
4137
|
-
function fetchAvailabilityResourcesV2(
|
|
4431
|
+
function fetchAvailabilityResourcesV2(_x25) {
|
|
4138
4432
|
return _fetchAvailabilityResourcesV.apply(this, arguments);
|
|
4139
4433
|
}
|
|
4140
4434
|
return fetchAvailabilityResourcesV2;
|
|
@@ -4142,17 +4436,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4142
4436
|
}, {
|
|
4143
4437
|
key: "fetchAndPublishAvailabilityResourcesV2",
|
|
4144
4438
|
value: function () {
|
|
4145
|
-
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4439
|
+
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
4146
4440
|
var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
|
|
4147
|
-
return _regeneratorRuntime().wrap(function
|
|
4148
|
-
while (1) switch (
|
|
4441
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4442
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4149
4443
|
case 0:
|
|
4150
4444
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
4151
4445
|
if (!(normalizedResourceIds.length === 0)) {
|
|
4152
|
-
|
|
4446
|
+
_context41.next = 3;
|
|
4153
4447
|
break;
|
|
4154
4448
|
}
|
|
4155
|
-
return
|
|
4449
|
+
return _context41.abrupt("return", []);
|
|
4156
4450
|
case 3:
|
|
4157
4451
|
scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
4158
4452
|
cacheParams = {
|
|
@@ -4162,7 +4456,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4162
4456
|
};
|
|
4163
4457
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
4164
4458
|
if (!cachedRawResources) {
|
|
4165
|
-
|
|
4459
|
+
_context41.next = 9;
|
|
4166
4460
|
break;
|
|
4167
4461
|
}
|
|
4168
4462
|
if (params.useCacheOnHit) {
|
|
@@ -4174,23 +4468,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4174
4468
|
console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
|
|
4175
4469
|
});
|
|
4176
4470
|
}
|
|
4177
|
-
return
|
|
4471
|
+
return _context41.abrupt("return", cachedRawResources);
|
|
4178
4472
|
case 9:
|
|
4179
|
-
|
|
4473
|
+
_context41.next = 11;
|
|
4180
4474
|
return this.refreshAvailabilityRemoteResourceQuery({
|
|
4181
4475
|
timezone: params.timezone,
|
|
4182
4476
|
dateRange: params.dateRange,
|
|
4183
4477
|
resourceIds: normalizedResourceIds
|
|
4184
4478
|
});
|
|
4185
4479
|
case 11:
|
|
4186
|
-
return
|
|
4480
|
+
return _context41.abrupt("return", _context41.sent);
|
|
4187
4481
|
case 12:
|
|
4188
4482
|
case "end":
|
|
4189
|
-
return
|
|
4483
|
+
return _context41.stop();
|
|
4190
4484
|
}
|
|
4191
|
-
},
|
|
4485
|
+
}, _callee41, this);
|
|
4192
4486
|
}));
|
|
4193
|
-
function fetchAndPublishAvailabilityResourcesV2(
|
|
4487
|
+
function fetchAndPublishAvailabilityResourcesV2(_x26) {
|
|
4194
4488
|
return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
|
|
4195
4489
|
}
|
|
4196
4490
|
return fetchAndPublishAvailabilityResourcesV2;
|
|
@@ -4198,17 +4492,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4198
4492
|
}, {
|
|
4199
4493
|
key: "refreshAvailabilityRemoteResourceQuery",
|
|
4200
4494
|
value: function () {
|
|
4201
|
-
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4495
|
+
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
4202
4496
|
var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
|
|
4203
|
-
return _regeneratorRuntime().wrap(function
|
|
4204
|
-
while (1) switch (
|
|
4497
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4498
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4205
4499
|
case 0:
|
|
4206
4500
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
4207
4501
|
if (!(normalizedResourceIds.length === 0)) {
|
|
4208
|
-
|
|
4502
|
+
_context42.next = 3;
|
|
4209
4503
|
break;
|
|
4210
4504
|
}
|
|
4211
|
-
return
|
|
4505
|
+
return _context42.abrupt("return", []);
|
|
4212
4506
|
case 3:
|
|
4213
4507
|
queryKey = this.buildAvailabilityRemoteResourceQueryKey({
|
|
4214
4508
|
timezone: params.timezone,
|
|
@@ -4218,13 +4512,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4218
4512
|
epoch = this.availabilityRemoteResourceEpoch;
|
|
4219
4513
|
existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
4220
4514
|
if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
|
|
4221
|
-
|
|
4515
|
+
_context42.next = 10;
|
|
4222
4516
|
break;
|
|
4223
4517
|
}
|
|
4224
|
-
|
|
4518
|
+
_context42.next = 9;
|
|
4225
4519
|
return existing.promise;
|
|
4226
4520
|
case 9:
|
|
4227
|
-
return
|
|
4521
|
+
return _context42.abrupt("return", _context42.sent);
|
|
4228
4522
|
case 10:
|
|
4229
4523
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
4230
4524
|
writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
@@ -4236,11 +4530,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4236
4530
|
epoch: epoch,
|
|
4237
4531
|
promise: promise
|
|
4238
4532
|
});
|
|
4239
|
-
|
|
4240
|
-
|
|
4533
|
+
_context42.prev = 14;
|
|
4534
|
+
_context42.next = 17;
|
|
4241
4535
|
return promise;
|
|
4242
4536
|
case 17:
|
|
4243
|
-
rawResources =
|
|
4537
|
+
rawResources = _context42.sent;
|
|
4244
4538
|
if (epoch === this.availabilityRemoteResourceEpoch) {
|
|
4245
4539
|
this.availabilityRemoteOccupancyCache.publish({
|
|
4246
4540
|
scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
|
|
@@ -4251,21 +4545,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4251
4545
|
version: writeVersion
|
|
4252
4546
|
});
|
|
4253
4547
|
}
|
|
4254
|
-
return
|
|
4548
|
+
return _context42.abrupt("return", rawResources);
|
|
4255
4549
|
case 20:
|
|
4256
|
-
|
|
4550
|
+
_context42.prev = 20;
|
|
4257
4551
|
current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
4258
4552
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
4259
4553
|
this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
|
|
4260
4554
|
}
|
|
4261
|
-
return
|
|
4555
|
+
return _context42.finish(20);
|
|
4262
4556
|
case 24:
|
|
4263
4557
|
case "end":
|
|
4264
|
-
return
|
|
4558
|
+
return _context42.stop();
|
|
4265
4559
|
}
|
|
4266
|
-
},
|
|
4560
|
+
}, _callee42, this, [[14,, 20, 24]]);
|
|
4267
4561
|
}));
|
|
4268
|
-
function refreshAvailabilityRemoteResourceQuery(
|
|
4562
|
+
function refreshAvailabilityRemoteResourceQuery(_x27) {
|
|
4269
4563
|
return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
|
|
4270
4564
|
}
|
|
4271
4565
|
return refreshAvailabilityRemoteResourceQuery;
|
|
@@ -4273,26 +4567,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4273
4567
|
}, {
|
|
4274
4568
|
key: "loadAvailabilityResources",
|
|
4275
4569
|
value: function () {
|
|
4276
|
-
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4277
|
-
var resourceIds, cachedRawResources, rawResources;
|
|
4278
|
-
return _regeneratorRuntime().wrap(function
|
|
4279
|
-
while (1) switch (
|
|
4570
|
+
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
4571
|
+
var resourceIds, cachedRawResources, remoteQuery, rawResources;
|
|
4572
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4573
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4280
4574
|
case 0:
|
|
4281
4575
|
resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
|
|
4282
4576
|
if (!(resourceIds.length === 0)) {
|
|
4283
|
-
|
|
4577
|
+
_context43.next = 3;
|
|
4284
4578
|
break;
|
|
4285
4579
|
}
|
|
4286
|
-
return
|
|
4580
|
+
return _context43.abrupt("return", {
|
|
4287
4581
|
resources: [],
|
|
4288
4582
|
resourceOccupancies: []
|
|
4289
4583
|
});
|
|
4290
4584
|
case 3:
|
|
4291
|
-
if (!Array.isArray(params.rawResources)) {
|
|
4292
|
-
|
|
4585
|
+
if (!(Array.isArray(params.rawResources) && params.fetchPolicy !== 'refresh')) {
|
|
4586
|
+
_context43.next = 5;
|
|
4293
4587
|
break;
|
|
4294
4588
|
}
|
|
4295
|
-
return
|
|
4589
|
+
return _context43.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
4296
4590
|
rawResources: params.rawResources,
|
|
4297
4591
|
scheduleList: params.scheduleList,
|
|
4298
4592
|
dateRange: params.dateRange,
|
|
@@ -4300,7 +4594,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4300
4594
|
}));
|
|
4301
4595
|
case 5:
|
|
4302
4596
|
if (!(params.fetchPolicy === 'cache_only')) {
|
|
4303
|
-
|
|
4597
|
+
_context43.next = 10;
|
|
4304
4598
|
break;
|
|
4305
4599
|
}
|
|
4306
4600
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read({
|
|
@@ -4309,43 +4603,58 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4309
4603
|
dateRange: params.dateRange
|
|
4310
4604
|
});
|
|
4311
4605
|
if (!cachedRawResources) {
|
|
4312
|
-
|
|
4606
|
+
_context43.next = 9;
|
|
4313
4607
|
break;
|
|
4314
4608
|
}
|
|
4315
|
-
return
|
|
4609
|
+
return _context43.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
4316
4610
|
rawResources: cachedRawResources,
|
|
4317
4611
|
scheduleList: params.scheduleList,
|
|
4318
4612
|
dateRange: params.dateRange,
|
|
4319
4613
|
fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
|
|
4320
4614
|
}));
|
|
4321
4615
|
case 9:
|
|
4322
|
-
return
|
|
4616
|
+
return _context43.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
|
|
4323
4617
|
resources: [],
|
|
4324
4618
|
resourceOccupancies: []
|
|
4325
4619
|
});
|
|
4326
4620
|
case 10:
|
|
4327
|
-
|
|
4328
|
-
return this.fetchAndPublishAvailabilityResourcesV2({
|
|
4621
|
+
remoteQuery = {
|
|
4329
4622
|
timezone: params.timezone,
|
|
4330
4623
|
dateRange: params.dateRange,
|
|
4331
|
-
resourceIds: resourceIds
|
|
4624
|
+
resourceIds: resourceIds
|
|
4625
|
+
};
|
|
4626
|
+
if (!(params.fetchPolicy === 'refresh')) {
|
|
4627
|
+
_context43.next = 17;
|
|
4628
|
+
break;
|
|
4629
|
+
}
|
|
4630
|
+
_context43.next = 14;
|
|
4631
|
+
return this.refreshAvailabilityRemoteResourceQuery(remoteQuery);
|
|
4632
|
+
case 14:
|
|
4633
|
+
_context43.t0 = _context43.sent;
|
|
4634
|
+
_context43.next = 20;
|
|
4635
|
+
break;
|
|
4636
|
+
case 17:
|
|
4637
|
+
_context43.next = 19;
|
|
4638
|
+
return this.fetchAndPublishAvailabilityResourcesV2(_objectSpread(_objectSpread({}, remoteQuery), {}, {
|
|
4332
4639
|
useCacheOnHit: true
|
|
4333
|
-
});
|
|
4334
|
-
case
|
|
4335
|
-
|
|
4336
|
-
|
|
4640
|
+
}));
|
|
4641
|
+
case 19:
|
|
4642
|
+
_context43.t0 = _context43.sent;
|
|
4643
|
+
case 20:
|
|
4644
|
+
rawResources = _context43.t0;
|
|
4645
|
+
return _context43.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
4337
4646
|
rawResources: rawResources,
|
|
4338
4647
|
scheduleList: params.scheduleList,
|
|
4339
4648
|
dateRange: params.dateRange,
|
|
4340
4649
|
fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
|
|
4341
4650
|
}));
|
|
4342
|
-
case
|
|
4651
|
+
case 22:
|
|
4343
4652
|
case "end":
|
|
4344
|
-
return
|
|
4653
|
+
return _context43.stop();
|
|
4345
4654
|
}
|
|
4346
|
-
},
|
|
4655
|
+
}, _callee43, this);
|
|
4347
4656
|
}));
|
|
4348
|
-
function loadAvailabilityResources(
|
|
4657
|
+
function loadAvailabilityResources(_x28) {
|
|
4349
4658
|
return _loadAvailabilityResources.apply(this, arguments);
|
|
4350
4659
|
}
|
|
4351
4660
|
return loadAvailabilityResources;
|
|
@@ -4418,7 +4727,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4418
4727
|
}, {
|
|
4419
4728
|
key: "collectCartResourceOccupancies",
|
|
4420
4729
|
value: function collectCartResourceOccupancies(tempOrder, exclusions) {
|
|
4421
|
-
var
|
|
4730
|
+
var _this13 = this;
|
|
4422
4731
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
4423
4732
|
return bookings.flatMap(function (booking) {
|
|
4424
4733
|
var _ref49, _booking$product_uid2, _booking$metadata2;
|
|
@@ -4435,7 +4744,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4435
4744
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
4436
4745
|
startAt: startAt,
|
|
4437
4746
|
endAt: endAt,
|
|
4438
|
-
fixedOffsetMinutes:
|
|
4747
|
+
fixedOffsetMinutes: _this13.getAvailabilityRuntimeOffsetMinutes(),
|
|
4439
4748
|
rollOverEnd: false
|
|
4440
4749
|
});
|
|
4441
4750
|
if (!range) return [];
|
|
@@ -4453,7 +4762,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4453
4762
|
resource: resource
|
|
4454
4763
|
}
|
|
4455
4764
|
};
|
|
4456
|
-
return
|
|
4765
|
+
return _this13.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
|
|
4457
4766
|
});
|
|
4458
4767
|
});
|
|
4459
4768
|
}
|
|
@@ -4520,16 +4829,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4520
4829
|
}, {
|
|
4521
4830
|
key: "assertContextualQueryFreshness",
|
|
4522
4831
|
value: function assertContextualQueryFreshness(context, request) {
|
|
4523
|
-
var
|
|
4832
|
+
var _this14 = this;
|
|
4524
4833
|
if (request.target === 'time') {
|
|
4525
4834
|
request.candidates.forEach(function (candidate) {
|
|
4526
|
-
|
|
4835
|
+
_this14.assertAvailabilityCandidateFreshness(context, candidate);
|
|
4527
4836
|
});
|
|
4528
4837
|
return;
|
|
4529
4838
|
}
|
|
4530
4839
|
if (request.target === 'resource') {
|
|
4531
4840
|
request.selectedRanges.forEach(function (candidate) {
|
|
4532
|
-
|
|
4841
|
+
_this14.assertAvailabilityCandidateFreshness(context, candidate);
|
|
4533
4842
|
});
|
|
4534
4843
|
}
|
|
4535
4844
|
}
|
|
@@ -4576,8 +4885,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4576
4885
|
}, {
|
|
4577
4886
|
key: "buildAvailabilityProjectionSnapshot",
|
|
4578
4887
|
value: function () {
|
|
4579
|
-
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4580
|
-
var
|
|
4888
|
+
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
4889
|
+
var _this15 = this;
|
|
4581
4890
|
var options,
|
|
4582
4891
|
normalizedPrepareParams,
|
|
4583
4892
|
timezoneLabel,
|
|
@@ -4598,11 +4907,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4598
4907
|
durationCandidateAnchorAt,
|
|
4599
4908
|
orderRevision,
|
|
4600
4909
|
projection,
|
|
4601
|
-
|
|
4602
|
-
return _regeneratorRuntime().wrap(function
|
|
4603
|
-
while (1) switch (
|
|
4910
|
+
_args44 = arguments;
|
|
4911
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4912
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4604
4913
|
case 0:
|
|
4605
|
-
options =
|
|
4914
|
+
options = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {};
|
|
4606
4915
|
normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
4607
4916
|
timezoneLabel = String(normalizedPrepareParams.timezone);
|
|
4608
4917
|
dateRange = normalizedPrepareParams.dateRange;
|
|
@@ -4616,15 +4925,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4616
4925
|
scheduleList: scheduleList,
|
|
4617
4926
|
businessHours: businessHours
|
|
4618
4927
|
});
|
|
4619
|
-
|
|
4928
|
+
_context44.next = 11;
|
|
4620
4929
|
return this.loadAvailabilityProducts({
|
|
4621
4930
|
prepare: normalizedPrepareParams,
|
|
4622
4931
|
dateRange: dateRange,
|
|
4623
4932
|
scheduleList: scheduleList
|
|
4624
4933
|
});
|
|
4625
4934
|
case 11:
|
|
4626
|
-
products =
|
|
4627
|
-
|
|
4935
|
+
products = _context44.sent;
|
|
4936
|
+
_context44.next = 14;
|
|
4628
4937
|
return this.loadAvailabilityResources({
|
|
4629
4938
|
timezone: timezoneLabel,
|
|
4630
4939
|
dateRange: dateRange,
|
|
@@ -4632,18 +4941,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4632
4941
|
products: products,
|
|
4633
4942
|
rawResources: normalizedPrepareParams.rawResources,
|
|
4634
4943
|
scheduleList: scheduleList,
|
|
4635
|
-
|
|
4944
|
+
// An explicit internal policy (notably commit's cache_only) remains authoritative.
|
|
4945
|
+
fetchPolicy: options.resourceFetchPolicy || (normalizedPrepareParams.refreshOccupancies ? 'refresh' : 'default'),
|
|
4636
4946
|
fallbackResources: options.fallbackResources
|
|
4637
4947
|
});
|
|
4638
4948
|
case 14:
|
|
4639
|
-
loadedResources =
|
|
4949
|
+
loadedResources = _context44.sent;
|
|
4640
4950
|
tempOrder = this.getTempOrder();
|
|
4641
4951
|
exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
|
|
4642
4952
|
injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
|
|
4643
4953
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
4644
4954
|
startAt: occupancy.startAt,
|
|
4645
4955
|
endAt: occupancy.endAt,
|
|
4646
|
-
fixedOffsetMinutes:
|
|
4956
|
+
fixedOffsetMinutes: _this15.getAvailabilityRuntimeOffsetMinutes(),
|
|
4647
4957
|
rollOverEnd: false
|
|
4648
4958
|
});
|
|
4649
4959
|
if (!range) return [];
|
|
@@ -4653,7 +4963,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4653
4963
|
})];
|
|
4654
4964
|
});
|
|
4655
4965
|
remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
|
|
4656
|
-
return !
|
|
4966
|
+
return !_this15.occupancyIsExcluded(occupancy, exclusions);
|
|
4657
4967
|
});
|
|
4658
4968
|
cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
|
|
4659
4969
|
preparedAt = this.getAvailabilityRuntimeDateTime();
|
|
@@ -4682,18 +4992,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4682
4992
|
prepareParams: normalizedPrepareParams,
|
|
4683
4993
|
durationCandidateAnchorAt: durationCandidateAnchorAt
|
|
4684
4994
|
});
|
|
4685
|
-
return
|
|
4995
|
+
return _context44.abrupt("return", {
|
|
4686
4996
|
projection: projection,
|
|
4687
4997
|
prepareParams: normalizedPrepareParams,
|
|
4688
4998
|
orderRevision: orderRevision
|
|
4689
4999
|
});
|
|
4690
5000
|
case 26:
|
|
4691
5001
|
case "end":
|
|
4692
|
-
return
|
|
5002
|
+
return _context44.stop();
|
|
4693
5003
|
}
|
|
4694
|
-
},
|
|
5004
|
+
}, _callee44, this);
|
|
4695
5005
|
}));
|
|
4696
|
-
function buildAvailabilityProjectionSnapshot(
|
|
5006
|
+
function buildAvailabilityProjectionSnapshot(_x29) {
|
|
4697
5007
|
return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
|
|
4698
5008
|
}
|
|
4699
5009
|
return buildAvailabilityProjectionSnapshot;
|
|
@@ -4701,10 +5011,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4701
5011
|
}, {
|
|
4702
5012
|
key: "getSharedPreparedAvailabilitySnapshot",
|
|
4703
5013
|
value: function () {
|
|
4704
|
-
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5014
|
+
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
4705
5015
|
var lifecycleGeneration, normalizedParams, hasRawInputs, prepareKey, snapshot, existing, promise, _snapshot, current;
|
|
4706
|
-
return _regeneratorRuntime().wrap(function
|
|
4707
|
-
while (1) switch (
|
|
5016
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
5017
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4708
5018
|
case 0:
|
|
4709
5019
|
lifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
4710
5020
|
normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
@@ -4723,15 +5033,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4723
5033
|
}
|
|
4724
5034
|
})) : this.buildAvailabilityPrepareKey(normalizedParams);
|
|
4725
5035
|
if (!hasRawInputs) {
|
|
4726
|
-
|
|
5036
|
+
_context45.next = 11;
|
|
4727
5037
|
break;
|
|
4728
5038
|
}
|
|
4729
|
-
|
|
5039
|
+
_context45.next = 7;
|
|
4730
5040
|
return this.buildAvailabilityProjectionSnapshot(normalizedParams);
|
|
4731
5041
|
case 7:
|
|
4732
|
-
snapshot =
|
|
5042
|
+
snapshot = _context45.sent;
|
|
4733
5043
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
4734
|
-
|
|
5044
|
+
_context45.next = 10;
|
|
4735
5045
|
break;
|
|
4736
5046
|
}
|
|
4737
5047
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -4740,7 +5050,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4740
5050
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
4741
5051
|
});
|
|
4742
5052
|
case 10:
|
|
4743
|
-
return
|
|
5053
|
+
return _context45.abrupt("return", {
|
|
4744
5054
|
prepareKey: prepareKey,
|
|
4745
5055
|
snapshot: snapshot
|
|
4746
5056
|
});
|
|
@@ -4754,13 +5064,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4754
5064
|
promise: promise
|
|
4755
5065
|
});
|
|
4756
5066
|
}
|
|
4757
|
-
|
|
4758
|
-
|
|
5067
|
+
_context45.prev = 14;
|
|
5068
|
+
_context45.next = 17;
|
|
4759
5069
|
return promise;
|
|
4760
5070
|
case 17:
|
|
4761
|
-
_snapshot =
|
|
5071
|
+
_snapshot = _context45.sent;
|
|
4762
5072
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
4763
|
-
|
|
5073
|
+
_context45.next = 20;
|
|
4764
5074
|
break;
|
|
4765
5075
|
}
|
|
4766
5076
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -4769,24 +5079,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4769
5079
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
4770
5080
|
});
|
|
4771
5081
|
case 20:
|
|
4772
|
-
return
|
|
5082
|
+
return _context45.abrupt("return", {
|
|
4773
5083
|
prepareKey: prepareKey,
|
|
4774
5084
|
snapshot: _snapshot
|
|
4775
5085
|
});
|
|
4776
5086
|
case 21:
|
|
4777
|
-
|
|
5087
|
+
_context45.prev = 21;
|
|
4778
5088
|
current = this.availabilityPrepareInFlight.get(prepareKey);
|
|
4779
5089
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
4780
5090
|
this.availabilityPrepareInFlight.delete(prepareKey);
|
|
4781
5091
|
}
|
|
4782
|
-
return
|
|
5092
|
+
return _context45.finish(21);
|
|
4783
5093
|
case 25:
|
|
4784
5094
|
case "end":
|
|
4785
|
-
return
|
|
5095
|
+
return _context45.stop();
|
|
4786
5096
|
}
|
|
4787
|
-
},
|
|
5097
|
+
}, _callee45, this, [[14,, 21, 25]]);
|
|
4788
5098
|
}));
|
|
4789
|
-
function getSharedPreparedAvailabilitySnapshot(
|
|
5099
|
+
function getSharedPreparedAvailabilitySnapshot(_x30) {
|
|
4790
5100
|
return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
|
|
4791
5101
|
}
|
|
4792
5102
|
return getSharedPreparedAvailabilitySnapshot;
|
|
@@ -4794,51 +5104,51 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4794
5104
|
}, {
|
|
4795
5105
|
key: "refreshAvailabilityContextProjection",
|
|
4796
5106
|
value: function () {
|
|
4797
|
-
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4798
|
-
var
|
|
5107
|
+
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
5108
|
+
var _this16 = this;
|
|
4799
5109
|
var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
|
|
4800
|
-
return _regeneratorRuntime().wrap(function
|
|
4801
|
-
while (1) switch (
|
|
5110
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
5111
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4802
5112
|
case 0:
|
|
4803
5113
|
existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
4804
5114
|
if (!existingInFlight) {
|
|
4805
|
-
|
|
5115
|
+
_context47.next = 5;
|
|
4806
5116
|
break;
|
|
4807
5117
|
}
|
|
4808
|
-
|
|
5118
|
+
_context47.next = 4;
|
|
4809
5119
|
return existingInFlight;
|
|
4810
5120
|
case 4:
|
|
4811
|
-
return
|
|
5121
|
+
return _context47.abrupt("return", _context47.sent);
|
|
4812
5122
|
case 5:
|
|
4813
5123
|
context = this.getAvailabilityContextEntry(params.contextId);
|
|
4814
5124
|
expectedVersion = context.activeVersion;
|
|
4815
5125
|
expectedRefreshNonce = context.refreshNonce;
|
|
4816
5126
|
expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
4817
|
-
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5127
|
+
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
4818
5128
|
var snapshot, currentContext, projectionEntry;
|
|
4819
|
-
return _regeneratorRuntime().wrap(function
|
|
4820
|
-
while (1) switch (
|
|
5129
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
5130
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4821
5131
|
case 0:
|
|
4822
|
-
|
|
4823
|
-
return
|
|
5132
|
+
_context46.next = 2;
|
|
5133
|
+
return _this16.buildAvailabilityProjectionSnapshot(_this16.cloneAvailabilityPrepareParams(context.prepareParams), {
|
|
4824
5134
|
durationCandidateAnchorAt: context.durationCandidateAnchorAt
|
|
4825
5135
|
});
|
|
4826
5136
|
case 2:
|
|
4827
|
-
snapshot =
|
|
4828
|
-
currentContext =
|
|
5137
|
+
snapshot = _context46.sent;
|
|
5138
|
+
currentContext = _this16.availabilityContextRegistry.get(params.contextId);
|
|
4829
5139
|
if (currentContext) {
|
|
4830
|
-
|
|
5140
|
+
_context46.next = 6;
|
|
4831
5141
|
break;
|
|
4832
5142
|
}
|
|
4833
|
-
return
|
|
5143
|
+
return _context46.abrupt("return", null);
|
|
4834
5144
|
case 6:
|
|
4835
|
-
if (!(expectedLifecycleGeneration !==
|
|
4836
|
-
|
|
5145
|
+
if (!(expectedLifecycleGeneration !== _this16.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
|
|
5146
|
+
_context46.next = 8;
|
|
4837
5147
|
break;
|
|
4838
5148
|
}
|
|
4839
|
-
return
|
|
5149
|
+
return _context46.abrupt("return", null);
|
|
4840
5150
|
case 8:
|
|
4841
|
-
projectionEntry =
|
|
5151
|
+
projectionEntry = _this16.storeAvailabilityProjectionEntry({
|
|
4842
5152
|
contextId: currentContext.contextId,
|
|
4843
5153
|
prepareParams: snapshot.prepareParams,
|
|
4844
5154
|
prepareKey: currentContext.prepareKey,
|
|
@@ -4846,8 +5156,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4846
5156
|
orderRevision: snapshot.orderRevision,
|
|
4847
5157
|
incrementVersion: true
|
|
4848
5158
|
});
|
|
4849
|
-
|
|
4850
|
-
return
|
|
5159
|
+
_context46.next = 11;
|
|
5160
|
+
return _this16.emitAvailabilityDiagnostic({
|
|
4851
5161
|
action: 'refresh',
|
|
4852
5162
|
contextId: currentContext.contextId,
|
|
4853
5163
|
contextVersion: projectionEntry.contextVersion,
|
|
@@ -4858,33 +5168,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4858
5168
|
reason: params.reason
|
|
4859
5169
|
});
|
|
4860
5170
|
case 11:
|
|
4861
|
-
return
|
|
5171
|
+
return _context46.abrupt("return", projectionEntry);
|
|
4862
5172
|
case 12:
|
|
4863
5173
|
case "end":
|
|
4864
|
-
return
|
|
5174
|
+
return _context46.stop();
|
|
4865
5175
|
}
|
|
4866
|
-
},
|
|
5176
|
+
}, _callee46);
|
|
4867
5177
|
}))();
|
|
4868
5178
|
this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
|
|
4869
|
-
|
|
4870
|
-
|
|
5179
|
+
_context47.prev = 11;
|
|
5180
|
+
_context47.next = 14;
|
|
4871
5181
|
return refreshPromise;
|
|
4872
5182
|
case 14:
|
|
4873
|
-
return
|
|
5183
|
+
return _context47.abrupt("return", _context47.sent);
|
|
4874
5184
|
case 15:
|
|
4875
|
-
|
|
5185
|
+
_context47.prev = 15;
|
|
4876
5186
|
current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
4877
5187
|
if (current === refreshPromise) {
|
|
4878
5188
|
this.availabilityProjectionRefreshInFlight.delete(params.contextId);
|
|
4879
5189
|
}
|
|
4880
|
-
return
|
|
5190
|
+
return _context47.finish(15);
|
|
4881
5191
|
case 19:
|
|
4882
5192
|
case "end":
|
|
4883
|
-
return
|
|
5193
|
+
return _context47.stop();
|
|
4884
5194
|
}
|
|
4885
|
-
},
|
|
5195
|
+
}, _callee47, this, [[11,, 15, 19]]);
|
|
4886
5196
|
}));
|
|
4887
|
-
function refreshAvailabilityContextProjection(
|
|
5197
|
+
function refreshAvailabilityContextProjection(_x31) {
|
|
4888
5198
|
return _refreshAvailabilityContextProjection.apply(this, arguments);
|
|
4889
5199
|
}
|
|
4890
5200
|
return refreshAvailabilityContextProjection;
|
|
@@ -4892,53 +5202,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4892
5202
|
}, {
|
|
4893
5203
|
key: "ensureAvailabilityContextProjection",
|
|
4894
5204
|
value: function () {
|
|
4895
|
-
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5205
|
+
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(contextId, reason) {
|
|
4896
5206
|
var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
|
|
4897
|
-
return _regeneratorRuntime().wrap(function
|
|
4898
|
-
while (1) switch (
|
|
5207
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
5208
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4899
5209
|
case 0:
|
|
4900
5210
|
retries = 0;
|
|
4901
5211
|
case 1:
|
|
4902
5212
|
if (!(retries < 3)) {
|
|
4903
|
-
|
|
5213
|
+
_context48.next = 19;
|
|
4904
5214
|
break;
|
|
4905
5215
|
}
|
|
4906
5216
|
context = this.getAvailabilityContextEntry(contextId);
|
|
4907
5217
|
currentOrderRevision = this.getCurrentOrderRevision();
|
|
4908
5218
|
projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
|
|
4909
5219
|
if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
|
|
4910
|
-
|
|
5220
|
+
_context48.next = 7;
|
|
4911
5221
|
break;
|
|
4912
5222
|
}
|
|
4913
|
-
return
|
|
5223
|
+
return _context48.abrupt("return", {
|
|
4914
5224
|
context: context,
|
|
4915
5225
|
projectionEntry: projectionEntry,
|
|
4916
5226
|
refreshed: false
|
|
4917
5227
|
});
|
|
4918
5228
|
case 7:
|
|
4919
|
-
|
|
5229
|
+
_context48.next = 9;
|
|
4920
5230
|
return this.refreshAvailabilityContextProjection({
|
|
4921
5231
|
contextId: contextId,
|
|
4922
5232
|
reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
|
|
4923
5233
|
previousOrderRevision: context.lastKnownOrderRevision
|
|
4924
5234
|
});
|
|
4925
5235
|
case 9:
|
|
4926
|
-
refreshedProjectionEntry =
|
|
5236
|
+
refreshedProjectionEntry = _context48.sent;
|
|
4927
5237
|
if (refreshedProjectionEntry) {
|
|
4928
|
-
|
|
5238
|
+
_context48.next = 13;
|
|
4929
5239
|
break;
|
|
4930
5240
|
}
|
|
4931
5241
|
retries += 1;
|
|
4932
|
-
return
|
|
5242
|
+
return _context48.abrupt("continue", 1);
|
|
4933
5243
|
case 13:
|
|
4934
5244
|
if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4935
|
-
|
|
5245
|
+
_context48.next = 16;
|
|
4936
5246
|
break;
|
|
4937
5247
|
}
|
|
4938
5248
|
retries += 1;
|
|
4939
|
-
return
|
|
5249
|
+
return _context48.abrupt("continue", 1);
|
|
4940
5250
|
case 16:
|
|
4941
|
-
return
|
|
5251
|
+
return _context48.abrupt("return", {
|
|
4942
5252
|
context: this.getAvailabilityContextEntry(contextId),
|
|
4943
5253
|
projectionEntry: refreshedProjectionEntry,
|
|
4944
5254
|
refreshed: true
|
|
@@ -4950,11 +5260,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4950
5260
|
});
|
|
4951
5261
|
case 20:
|
|
4952
5262
|
case "end":
|
|
4953
|
-
return
|
|
5263
|
+
return _context48.stop();
|
|
4954
5264
|
}
|
|
4955
|
-
},
|
|
5265
|
+
}, _callee48, this);
|
|
4956
5266
|
}));
|
|
4957
|
-
function ensureAvailabilityContextProjection(
|
|
5267
|
+
function ensureAvailabilityContextProjection(_x32, _x33) {
|
|
4958
5268
|
return _ensureAvailabilityContextProjection.apply(this, arguments);
|
|
4959
5269
|
}
|
|
4960
5270
|
return ensureAvailabilityContextProjection;
|
|
@@ -4962,18 +5272,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4962
5272
|
}, {
|
|
4963
5273
|
key: "tryAcquireAvailabilityCommitLock",
|
|
4964
5274
|
value: function () {
|
|
4965
|
-
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5275
|
+
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(contextId) {
|
|
4966
5276
|
var _currentContext$activ;
|
|
4967
5277
|
var _waitingContext$activ, waitingContext, currentContext;
|
|
4968
|
-
return _regeneratorRuntime().wrap(function
|
|
4969
|
-
while (1) switch (
|
|
5278
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
5279
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4970
5280
|
case 0:
|
|
4971
5281
|
if (!this.availabilityCommitLocks.has(contextId)) {
|
|
4972
|
-
|
|
5282
|
+
_context49.next = 5;
|
|
4973
5283
|
break;
|
|
4974
5284
|
}
|
|
4975
5285
|
waitingContext = this.availabilityContextRegistry.get(contextId);
|
|
4976
|
-
|
|
5286
|
+
_context49.next = 4;
|
|
4977
5287
|
return this.emitAvailabilityDiagnostic({
|
|
4978
5288
|
action: 'commit_lock_wait',
|
|
4979
5289
|
contextId: contextId,
|
|
@@ -4990,7 +5300,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4990
5300
|
case 5:
|
|
4991
5301
|
this.availabilityCommitLocks.add(contextId);
|
|
4992
5302
|
currentContext = this.availabilityContextRegistry.get(contextId);
|
|
4993
|
-
|
|
5303
|
+
_context49.next = 9;
|
|
4994
5304
|
return this.emitAvailabilityDiagnostic({
|
|
4995
5305
|
action: 'commit_lock_acquired',
|
|
4996
5306
|
contextId: contextId,
|
|
@@ -5002,11 +5312,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5002
5312
|
});
|
|
5003
5313
|
case 9:
|
|
5004
5314
|
case "end":
|
|
5005
|
-
return
|
|
5315
|
+
return _context49.stop();
|
|
5006
5316
|
}
|
|
5007
|
-
},
|
|
5317
|
+
}, _callee49, this);
|
|
5008
5318
|
}));
|
|
5009
|
-
function tryAcquireAvailabilityCommitLock(
|
|
5319
|
+
function tryAcquireAvailabilityCommitLock(_x34) {
|
|
5010
5320
|
return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
|
|
5011
5321
|
}
|
|
5012
5322
|
return tryAcquireAvailabilityCommitLock;
|
|
@@ -5014,15 +5324,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5014
5324
|
}, {
|
|
5015
5325
|
key: "releaseAvailabilityCommitLock",
|
|
5016
5326
|
value: function () {
|
|
5017
|
-
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5327
|
+
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(contextId) {
|
|
5018
5328
|
var _releasedContext$acti;
|
|
5019
5329
|
var releasedContext;
|
|
5020
|
-
return _regeneratorRuntime().wrap(function
|
|
5021
|
-
while (1) switch (
|
|
5330
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
5331
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
5022
5332
|
case 0:
|
|
5023
5333
|
this.availabilityCommitLocks.delete(contextId);
|
|
5024
5334
|
releasedContext = this.availabilityContextRegistry.get(contextId);
|
|
5025
|
-
|
|
5335
|
+
_context50.next = 4;
|
|
5026
5336
|
return this.emitAvailabilityDiagnostic({
|
|
5027
5337
|
action: 'commit_lock_released',
|
|
5028
5338
|
contextId: contextId,
|
|
@@ -5034,11 +5344,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5034
5344
|
});
|
|
5035
5345
|
case 4:
|
|
5036
5346
|
case "end":
|
|
5037
|
-
return
|
|
5347
|
+
return _context50.stop();
|
|
5038
5348
|
}
|
|
5039
|
-
},
|
|
5349
|
+
}, _callee50, this);
|
|
5040
5350
|
}));
|
|
5041
|
-
function releaseAvailabilityCommitLock(
|
|
5351
|
+
function releaseAvailabilityCommitLock(_x35) {
|
|
5042
5352
|
return _releaseAvailabilityCommitLock.apply(this, arguments);
|
|
5043
5353
|
}
|
|
5044
5354
|
return releaseAvailabilityCommitLock;
|
|
@@ -5046,20 +5356,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5046
5356
|
}, {
|
|
5047
5357
|
key: "prepareAvailabilityProjection",
|
|
5048
5358
|
value: (function () {
|
|
5049
|
-
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5359
|
+
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
5050
5360
|
var paramsWithDefaults, _yield$this$getShared, prepareKey, snapshot, contextId, projectionEntry, context, handle, payload;
|
|
5051
|
-
return _regeneratorRuntime().wrap(function
|
|
5052
|
-
while (1) switch (
|
|
5361
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
5362
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
5053
5363
|
case 0:
|
|
5054
5364
|
this.assertAvailabilityPrepareParams(params);
|
|
5055
|
-
|
|
5365
|
+
_context51.next = 3;
|
|
5056
5366
|
return this.resolveAvailabilityPrepareDefaults(params);
|
|
5057
5367
|
case 3:
|
|
5058
|
-
paramsWithDefaults =
|
|
5059
|
-
|
|
5368
|
+
paramsWithDefaults = _context51.sent;
|
|
5369
|
+
_context51.next = 6;
|
|
5060
5370
|
return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
|
|
5061
5371
|
case 6:
|
|
5062
|
-
_yield$this$getShared =
|
|
5372
|
+
_yield$this$getShared = _context51.sent;
|
|
5063
5373
|
prepareKey = _yield$this$getShared.prepareKey;
|
|
5064
5374
|
snapshot = _yield$this$getShared.snapshot;
|
|
5065
5375
|
contextId = this.createAvailabilityContextId();
|
|
@@ -5080,7 +5390,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5080
5390
|
refreshed: false,
|
|
5081
5391
|
reason: 'prepare'
|
|
5082
5392
|
};
|
|
5083
|
-
|
|
5393
|
+
_context51.next = 16;
|
|
5084
5394
|
return this.emitAvailabilityDiagnostic({
|
|
5085
5395
|
action: 'prepare',
|
|
5086
5396
|
contextId: contextId,
|
|
@@ -5091,17 +5401,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5091
5401
|
reason: 'prepare'
|
|
5092
5402
|
});
|
|
5093
5403
|
case 16:
|
|
5094
|
-
|
|
5404
|
+
_context51.next = 18;
|
|
5095
5405
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
|
|
5096
5406
|
case 18:
|
|
5097
|
-
return
|
|
5407
|
+
return _context51.abrupt("return", handle);
|
|
5098
5408
|
case 19:
|
|
5099
5409
|
case "end":
|
|
5100
|
-
return
|
|
5410
|
+
return _context51.stop();
|
|
5101
5411
|
}
|
|
5102
|
-
},
|
|
5412
|
+
}, _callee51, this);
|
|
5103
5413
|
}));
|
|
5104
|
-
function prepareAvailabilityProjection(
|
|
5414
|
+
function prepareAvailabilityProjection(_x36) {
|
|
5105
5415
|
return _prepareAvailabilityProjection.apply(this, arguments);
|
|
5106
5416
|
}
|
|
5107
5417
|
return prepareAvailabilityProjection;
|
|
@@ -5109,54 +5419,58 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5109
5419
|
}, {
|
|
5110
5420
|
key: "getProductTimeRanges",
|
|
5111
5421
|
value: (function () {
|
|
5112
|
-
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5422
|
+
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(contextId) {
|
|
5113
5423
|
var _this$otherParams$pla,
|
|
5114
|
-
_this$
|
|
5115
|
-
|
|
5424
|
+
_this$otherParams36,
|
|
5425
|
+
_this17 = this;
|
|
5116
5426
|
var request,
|
|
5117
5427
|
_yield$this$ensureAva,
|
|
5118
5428
|
context,
|
|
5119
5429
|
projectionEntry,
|
|
5120
5430
|
contextVersion,
|
|
5431
|
+
strictAvailability,
|
|
5121
5432
|
isPosAvailabilityRequest,
|
|
5122
5433
|
allowOutsideOperatingHoursForRequestedStartTimes,
|
|
5123
|
-
|
|
5124
|
-
return _regeneratorRuntime().wrap(function
|
|
5125
|
-
while (1) switch (
|
|
5434
|
+
_args52 = arguments;
|
|
5435
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5436
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
5126
5437
|
case 0:
|
|
5127
|
-
request =
|
|
5128
|
-
|
|
5438
|
+
request = _args52.length > 1 && _args52[1] !== undefined ? _args52[1] : {};
|
|
5439
|
+
_context52.next = 3;
|
|
5129
5440
|
return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
|
|
5130
5441
|
case 3:
|
|
5131
|
-
_yield$this$ensureAva =
|
|
5442
|
+
_yield$this$ensureAva = _context52.sent;
|
|
5132
5443
|
context = _yield$this$ensureAva.context;
|
|
5133
5444
|
projectionEntry = _yield$this$ensureAva.projectionEntry;
|
|
5134
5445
|
contextVersion = context.activeVersion;
|
|
5135
|
-
|
|
5136
|
-
|
|
5446
|
+
strictAvailability = context.prepareParams.strictAvailability === true;
|
|
5447
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla = (_this$otherParams36 = this.otherParams) === null || _this$otherParams36 === void 0 ? void 0 : _this$otherParams36.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos';
|
|
5448
|
+
allowOutsideOperatingHoursForRequestedStartTimes = isPosAvailabilityRequest && !strictAvailability && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
|
|
5137
5449
|
return Array.isArray(startTimes) && startTimes.length > 0;
|
|
5138
5450
|
});
|
|
5139
|
-
return
|
|
5451
|
+
return _context52.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
|
|
5140
5452
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
5453
|
+
} : {}), strictAvailability ? {
|
|
5454
|
+
allowOutsideOperatingHoursForRequestedStartTimes: false
|
|
5141
5455
|
} : {}), {
|
|
5142
5456
|
evaluatedAt: this.getAvailabilityRuntimeDateTime(),
|
|
5143
|
-
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
5144
|
-
allowSessionCustomRanges: isPosAvailabilityRequest,
|
|
5145
|
-
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
5457
|
+
useExactDurationCandidateMinute: isPosAvailabilityRequest && !strictAvailability,
|
|
5458
|
+
allowSessionCustomRanges: isPosAvailabilityRequest && !strictAvailability,
|
|
5459
|
+
allowExcludedScheduleDateOverride: isPosAvailabilityRequest && !strictAvailability
|
|
5146
5460
|
}).map(function (group) {
|
|
5147
5461
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
5148
5462
|
ranges: group.ranges.map(function (candidate) {
|
|
5149
|
-
return
|
|
5463
|
+
return _this17.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
|
|
5150
5464
|
})
|
|
5151
5465
|
});
|
|
5152
5466
|
}));
|
|
5153
|
-
case
|
|
5467
|
+
case 11:
|
|
5154
5468
|
case "end":
|
|
5155
|
-
return
|
|
5469
|
+
return _context52.stop();
|
|
5156
5470
|
}
|
|
5157
|
-
},
|
|
5471
|
+
}, _callee52, this);
|
|
5158
5472
|
}));
|
|
5159
|
-
function getProductTimeRanges(
|
|
5473
|
+
function getProductTimeRanges(_x37) {
|
|
5160
5474
|
return _getProductTimeRanges.apply(this, arguments);
|
|
5161
5475
|
}
|
|
5162
5476
|
return getProductTimeRanges;
|
|
@@ -5164,24 +5478,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5164
5478
|
}, {
|
|
5165
5479
|
key: "queryBookingAvailability",
|
|
5166
5480
|
value: (function () {
|
|
5167
|
-
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5168
|
-
var _this$otherParams$pla2, _this$
|
|
5169
|
-
var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
|
|
5170
|
-
return _regeneratorRuntime().wrap(function
|
|
5171
|
-
while (1) switch (
|
|
5481
|
+
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(contextId, request) {
|
|
5482
|
+
var _this$otherParams$pla2, _this$otherParams37;
|
|
5483
|
+
var _yield$this$ensureAva2, context, projectionEntry, refreshed, strictAvailability, isPosAvailabilityRequest, result, contextVersion, contextualResult;
|
|
5484
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5485
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
5172
5486
|
case 0:
|
|
5173
|
-
|
|
5487
|
+
_context53.next = 2;
|
|
5174
5488
|
return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
5175
5489
|
case 2:
|
|
5176
|
-
_yield$this$ensureAva2 =
|
|
5490
|
+
_yield$this$ensureAva2 = _context53.sent;
|
|
5177
5491
|
context = _yield$this$ensureAva2.context;
|
|
5178
5492
|
projectionEntry = _yield$this$ensureAva2.projectionEntry;
|
|
5179
5493
|
refreshed = _yield$this$ensureAva2.refreshed;
|
|
5180
5494
|
this.assertContextualQueryFreshness(context, request);
|
|
5181
|
-
|
|
5495
|
+
strictAvailability = context.prepareParams.strictAvailability === true;
|
|
5496
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams37 = this.otherParams) === null || _this$otherParams37 === void 0 ? void 0 : _this$otherParams37.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
|
|
5182
5497
|
result = queryAvailabilityProjection(projectionEntry.projection, request, {
|
|
5183
|
-
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
5184
|
-
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
5498
|
+
useExactDurationCandidateMinute: isPosAvailabilityRequest && !strictAvailability,
|
|
5499
|
+
allowExcludedScheduleDateOverride: isPosAvailabilityRequest && !strictAvailability
|
|
5185
5500
|
});
|
|
5186
5501
|
contextVersion = context.activeVersion;
|
|
5187
5502
|
contextualResult = result.target === 'time' ? _objectSpread(_objectSpread({}, result), {}, {
|
|
@@ -5209,22 +5524,36 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5209
5524
|
});
|
|
5210
5525
|
})
|
|
5211
5526
|
}) : result;
|
|
5212
|
-
return
|
|
5527
|
+
return _context53.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
|
|
5213
5528
|
contextId: context.contextId,
|
|
5214
5529
|
contextVersion: contextVersion,
|
|
5215
5530
|
refreshed: refreshed
|
|
5216
5531
|
}));
|
|
5217
|
-
case
|
|
5532
|
+
case 13:
|
|
5218
5533
|
case "end":
|
|
5219
|
-
return
|
|
5534
|
+
return _context53.stop();
|
|
5220
5535
|
}
|
|
5221
|
-
},
|
|
5536
|
+
}, _callee53, this);
|
|
5222
5537
|
}));
|
|
5223
|
-
function queryBookingAvailability(
|
|
5538
|
+
function queryBookingAvailability(_x38, _x39) {
|
|
5224
5539
|
return _queryBookingAvailability.apply(this, arguments);
|
|
5225
5540
|
}
|
|
5226
5541
|
return queryBookingAvailability;
|
|
5227
|
-
}())
|
|
5542
|
+
}() /** Reads detached resource metadata from the current context; never refreshes or performs I/O. */)
|
|
5543
|
+
}, {
|
|
5544
|
+
key: "getAvailabilityResources",
|
|
5545
|
+
value: function getAvailabilityResources(contextId, expectedVersion) {
|
|
5546
|
+
var context = this.getAvailabilityContextEntry(contextId);
|
|
5547
|
+
var entry = this.getActiveAvailabilityProjectionEntry(context);
|
|
5548
|
+
if (!entry || entry.contextVersion !== context.activeVersion || entry.orderRevision !== this.getCurrentOrderRevision() || expectedVersion !== undefined && context.activeVersion !== expectedVersion) {
|
|
5549
|
+
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '资源上下文已变化,请重新查询当前候选', {
|
|
5550
|
+
contextId: contextId,
|
|
5551
|
+
expectedVersion: expectedVersion,
|
|
5552
|
+
currentContextVersion: context.activeVersion
|
|
5553
|
+
});
|
|
5554
|
+
}
|
|
5555
|
+
return cloneDeep(_toConsumableArray(entry.projection.resources));
|
|
5556
|
+
}
|
|
5228
5557
|
}, {
|
|
5229
5558
|
key: "releaseAvailabilityContext",
|
|
5230
5559
|
value: function releaseAvailabilityContext(contextId) {
|
|
@@ -5290,69 +5619,103 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5290
5619
|
}, {
|
|
5291
5620
|
key: "commitAvailabilitySelection",
|
|
5292
5621
|
value: (function () {
|
|
5293
|
-
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5294
|
-
var
|
|
5295
|
-
|
|
5296
|
-
|
|
5622
|
+
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(contextId, params) {
|
|
5623
|
+
var _this$availabilityCon,
|
|
5624
|
+
_params$availabilityC2,
|
|
5625
|
+
_this$store$order11,
|
|
5626
|
+
_this$store$order11$e,
|
|
5627
|
+
_this18 = this;
|
|
5628
|
+
var normalizedContextId, isEditingSelection, isPartyReplacement, strictAvailability, hasCommitGuard, guardedOrder, getGuardedCommitIdentity, guardedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref54, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams38, _params$orderProduct$3, _params$orderProduct6, _existingBooking$hold, _existingBooking$meta, _ref55, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$meta3, _existingBooking$hold2, _transformed$metadata, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, relatedRetailProducts, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref56, _transformed$product_4, update, _this$getTempOrder5, _this$getTempOrder6, _params$salesNotes, _params$salesNotes2, _ref57, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
|
|
5629
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5630
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
5297
5631
|
case 0:
|
|
5298
5632
|
normalizedContextId = String(contextId || '').trim();
|
|
5299
5633
|
if (normalizedContextId) {
|
|
5300
|
-
|
|
5634
|
+
_context54.next = 3;
|
|
5301
5635
|
break;
|
|
5302
5636
|
}
|
|
5303
5637
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
|
|
5304
5638
|
candidate: params.candidate
|
|
5305
5639
|
});
|
|
5306
5640
|
case 3:
|
|
5307
|
-
|
|
5641
|
+
isEditingSelection = params.mode === 'edit' || params.mode === 'replace';
|
|
5642
|
+
isPartyReplacement = params.mode === 'replace' || params.relatedRetailProducts !== undefined;
|
|
5643
|
+
if (!(isPartyReplacement && (!isEditingSelection || !Array.isArray(params.relatedRetailProducts)))) {
|
|
5644
|
+
_context54.next = 7;
|
|
5645
|
+
break;
|
|
5646
|
+
}
|
|
5647
|
+
throw new AvailabilityError('INVALID_TARGET_FILTER', 'Party replacement requires edit/replace mode and the confirmed complete extras array');
|
|
5648
|
+
case 7:
|
|
5649
|
+
strictAvailability = ((_this$availabilityCon = this.availabilityContextRegistry.get(normalizedContextId)) === null || _this$availabilityCon === void 0 ? void 0 : _this$availabilityCon.prepareParams.strictAvailability) === true;
|
|
5650
|
+
hasCommitGuard = strictAvailability || isPartyReplacement || Boolean(params.availabilityCommitGuard);
|
|
5651
|
+
(_params$availabilityC2 = params.availabilityCommitGuard) === null || _params$availabilityC2 === void 0 || _params$availabilityC2.call(params);
|
|
5652
|
+
// Stabilize the locally generated sale identity before taking the guard snapshot.
|
|
5653
|
+
if (hasCommitGuard) (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$e = _this$store$order11.ensureTempOrder) === null || _this$store$order11$e === void 0 || _this$store$order11$e.call(_this$store$order11);
|
|
5654
|
+
guardedOrder = hasCommitGuard ? this.getTempOrder() : null;
|
|
5655
|
+
getGuardedCommitIdentity = function getGuardedCommitIdentity() {
|
|
5656
|
+
var _this18$otherParams$s, _this18$otherParams, _this18$otherParams2, _this18$core, _this18$getTempOrder, _this18$getTempOrder2;
|
|
5657
|
+
return JSON.stringify(stableValue({
|
|
5658
|
+
scope: _this18.getAvailabilityScopeDescriptor(),
|
|
5659
|
+
shopId: (_this18$otherParams$s = (_this18$otherParams = _this18.otherParams) === null || _this18$otherParams === void 0 ? void 0 : _this18$otherParams.shop_id) !== null && _this18$otherParams$s !== void 0 ? _this18$otherParams$s : (_this18$otherParams2 = _this18.otherParams) === null || _this18$otherParams2 === void 0 ? void 0 : _this18$otherParams2.shopId,
|
|
5660
|
+
contextShopId: (_this18$core = _this18.core) === null || _this18$core === void 0 || (_this18$core = _this18$core.context) === null || _this18$core === void 0 ? void 0 : _this18$core.shop_id,
|
|
5661
|
+
orderId: (_this18$getTempOrder = _this18.getTempOrder()) === null || _this18$getTempOrder === void 0 ? void 0 : _this18$getTempOrder.order_id,
|
|
5662
|
+
externalSaleNumber: (_this18$getTempOrder2 = _this18.getTempOrder()) === null || _this18$getTempOrder2 === void 0 ? void 0 : _this18$getTempOrder2.external_sale_number
|
|
5663
|
+
}));
|
|
5664
|
+
};
|
|
5665
|
+
guardedCommitIdentity = hasCommitGuard ? getGuardedCommitIdentity() : '';
|
|
5666
|
+
availabilityCommitTargetGuard = function availabilityCommitTargetGuard() {
|
|
5667
|
+
return _this18.getTempOrder() === guardedOrder && getGuardedCommitIdentity() === guardedCommitIdentity;
|
|
5668
|
+
};
|
|
5669
|
+
guardedCommitPublished = false;
|
|
5670
|
+
_context54.next = 18;
|
|
5308
5671
|
return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
|
|
5309
|
-
case
|
|
5310
|
-
|
|
5672
|
+
case 18:
|
|
5673
|
+
_context54.prev = 18;
|
|
5311
5674
|
bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
|
|
5312
5675
|
if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
|
|
5313
|
-
|
|
5676
|
+
_context54.next = 22;
|
|
5314
5677
|
break;
|
|
5315
5678
|
}
|
|
5316
5679
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
|
|
5317
5680
|
bookingCount: params.bookingCount
|
|
5318
5681
|
});
|
|
5319
|
-
case
|
|
5320
|
-
if (!(
|
|
5321
|
-
|
|
5682
|
+
case 22:
|
|
5683
|
+
if (!(isEditingSelection && bookingCount !== 1)) {
|
|
5684
|
+
_context54.next = 24;
|
|
5322
5685
|
break;
|
|
5323
5686
|
}
|
|
5324
5687
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
|
|
5325
5688
|
bookingCount: bookingCount
|
|
5326
5689
|
});
|
|
5327
|
-
case
|
|
5690
|
+
case 24:
|
|
5328
5691
|
orderProductQuantity = (_ref54 = (_params$orderProduct$ = (_params$orderProduct = params.orderProduct) === null || _params$orderProduct === void 0 ? void 0 : _params$orderProduct.num) !== null && _params$orderProduct$ !== void 0 ? _params$orderProduct$ : (_params$orderProduct2 = params.orderProduct) === null || _params$orderProduct2 === void 0 ? void 0 : _params$orderProduct2.quantity) !== null && _ref54 !== void 0 ? _ref54 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
|
|
5329
5692
|
if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
|
|
5330
|
-
|
|
5693
|
+
_context54.next = 27;
|
|
5331
5694
|
break;
|
|
5332
5695
|
}
|
|
5333
5696
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
|
|
5334
5697
|
bookingCount: bookingCount,
|
|
5335
5698
|
orderProductQuantity: orderProductQuantity
|
|
5336
5699
|
});
|
|
5337
|
-
case
|
|
5700
|
+
case 27:
|
|
5338
5701
|
partySize = Number(params.partySize);
|
|
5339
5702
|
if (!(!Number.isInteger(partySize) || partySize <= 0)) {
|
|
5340
|
-
|
|
5703
|
+
_context54.next = 30;
|
|
5341
5704
|
break;
|
|
5342
5705
|
}
|
|
5343
5706
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
|
|
5344
5707
|
partySize: params.partySize
|
|
5345
5708
|
});
|
|
5346
|
-
case
|
|
5347
|
-
|
|
5709
|
+
case 30:
|
|
5710
|
+
_context54.next = 32;
|
|
5348
5711
|
return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
5349
|
-
case
|
|
5350
|
-
_yield$this$ensureAva3 =
|
|
5712
|
+
case 32:
|
|
5713
|
+
_yield$this$ensureAva3 = _context54.sent;
|
|
5351
5714
|
context = _yield$this$ensureAva3.context;
|
|
5352
5715
|
projectionEntry = _yield$this$ensureAva3.projectionEntry;
|
|
5353
5716
|
refreshed = _yield$this$ensureAva3.refreshed;
|
|
5354
5717
|
if (!refreshed) {
|
|
5355
|
-
|
|
5718
|
+
_context54.next = 38;
|
|
5356
5719
|
break;
|
|
5357
5720
|
}
|
|
5358
5721
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -5360,14 +5723,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5360
5723
|
currentContextVersion: context.activeVersion,
|
|
5361
5724
|
candidateContextVersion: params.candidate.availabilityContextVersion
|
|
5362
5725
|
});
|
|
5363
|
-
case
|
|
5726
|
+
case 38:
|
|
5364
5727
|
boundEditingUids = context.prepareParams.editingProductLineUids || [];
|
|
5365
|
-
if (!
|
|
5366
|
-
|
|
5728
|
+
if (!isEditingSelection) {
|
|
5729
|
+
_context54.next = 44;
|
|
5367
5730
|
break;
|
|
5368
5731
|
}
|
|
5369
5732
|
if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
|
|
5370
|
-
|
|
5733
|
+
_context54.next = 42;
|
|
5371
5734
|
break;
|
|
5372
5735
|
}
|
|
5373
5736
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
|
|
@@ -5375,21 +5738,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5375
5738
|
productLineUid: params.productLineUid,
|
|
5376
5739
|
editingProductLineUids: boundEditingUids
|
|
5377
5740
|
});
|
|
5378
|
-
case
|
|
5379
|
-
|
|
5741
|
+
case 42:
|
|
5742
|
+
_context54.next = 46;
|
|
5380
5743
|
break;
|
|
5381
|
-
case
|
|
5744
|
+
case 44:
|
|
5382
5745
|
if (!(boundEditingUids.length > 0)) {
|
|
5383
|
-
|
|
5746
|
+
_context54.next = 46;
|
|
5384
5747
|
break;
|
|
5385
5748
|
}
|
|
5386
5749
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
|
|
5387
5750
|
contextId: normalizedContextId,
|
|
5388
5751
|
editingProductLineUids: boundEditingUids
|
|
5389
5752
|
});
|
|
5390
|
-
case
|
|
5753
|
+
case 46:
|
|
5391
5754
|
if (!(projectionEntry.contextVersion !== context.activeVersion)) {
|
|
5392
|
-
|
|
5755
|
+
_context54.next = 48;
|
|
5393
5756
|
break;
|
|
5394
5757
|
}
|
|
5395
5758
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -5397,9 +5760,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5397
5760
|
currentContextVersion: context.activeVersion,
|
|
5398
5761
|
projectionContextVersion: projectionEntry.contextVersion
|
|
5399
5762
|
});
|
|
5400
|
-
case
|
|
5763
|
+
case 48:
|
|
5401
5764
|
if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
5402
|
-
|
|
5765
|
+
_context54.next = 50;
|
|
5403
5766
|
break;
|
|
5404
5767
|
}
|
|
5405
5768
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
@@ -5408,9 +5771,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5408
5771
|
projectionOrderRevision: projectionEntry.orderRevision,
|
|
5409
5772
|
currentOrderRevision: this.getCurrentOrderRevision()
|
|
5410
5773
|
});
|
|
5411
|
-
case
|
|
5774
|
+
case 50:
|
|
5412
5775
|
if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
|
|
5413
|
-
|
|
5776
|
+
_context54.next = 52;
|
|
5414
5777
|
break;
|
|
5415
5778
|
}
|
|
5416
5779
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
|
|
@@ -5418,35 +5781,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5418
5781
|
candidateContextVersion: params.candidate.availabilityContextVersion,
|
|
5419
5782
|
currentContextVersion: context.activeVersion
|
|
5420
5783
|
});
|
|
5421
|
-
case
|
|
5784
|
+
case 52:
|
|
5422
5785
|
this.assertAvailabilityCandidateFreshness(context, params.candidate);
|
|
5423
5786
|
orderProductId = (_params$orderProduct$2 = (_params$orderProduct4 = params.orderProduct) === null || _params$orderProduct4 === void 0 ? void 0 : _params$orderProduct4.product_id) !== null && _params$orderProduct$2 !== void 0 ? _params$orderProduct$2 : (_params$orderProduct5 = params.orderProduct) === null || _params$orderProduct5 === void 0 ? void 0 : _params$orderProduct5.id;
|
|
5424
5787
|
if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
|
|
5425
|
-
|
|
5788
|
+
_context54.next = 56;
|
|
5426
5789
|
break;
|
|
5427
5790
|
}
|
|
5428
5791
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
|
|
5429
5792
|
orderProductId: orderProductId,
|
|
5430
5793
|
candidateProductId: params.candidate.productId
|
|
5431
5794
|
});
|
|
5432
|
-
case
|
|
5433
|
-
if (!(
|
|
5434
|
-
|
|
5795
|
+
case 56:
|
|
5796
|
+
if (!(isEditingSelection && !params.productLineUid)) {
|
|
5797
|
+
_context54.next = 58;
|
|
5435
5798
|
break;
|
|
5436
5799
|
}
|
|
5437
5800
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
|
|
5438
|
-
case
|
|
5439
|
-
editingLine =
|
|
5440
|
-
if (!(
|
|
5441
|
-
|
|
5801
|
+
case 58:
|
|
5802
|
+
editingLine = isEditingSelection ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
|
|
5803
|
+
if (!(isEditingSelection && !editingLine)) {
|
|
5804
|
+
_context54.next = 61;
|
|
5442
5805
|
break;
|
|
5443
5806
|
}
|
|
5444
5807
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
|
|
5445
5808
|
productLineUid: params.productLineUid
|
|
5446
5809
|
});
|
|
5447
|
-
case
|
|
5448
|
-
if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
|
|
5449
|
-
|
|
5810
|
+
case 61:
|
|
5811
|
+
if (!(editingLine && params.mode !== 'replace' && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
|
|
5812
|
+
_context54.next = 63;
|
|
5450
5813
|
break;
|
|
5451
5814
|
}
|
|
5452
5815
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
|
|
@@ -5454,15 +5817,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5454
5817
|
productLineProductId: (_editingLine$product_2 = editingLine.product_id) !== null && _editingLine$product_2 !== void 0 ? _editingLine$product_2 : editingLine.id,
|
|
5455
5818
|
candidateProductId: params.candidate.productId
|
|
5456
5819
|
});
|
|
5457
|
-
case
|
|
5820
|
+
case 63:
|
|
5458
5821
|
if (Array.isArray(params.requirementSelections)) {
|
|
5459
|
-
|
|
5822
|
+
_context54.next = 65;
|
|
5460
5823
|
break;
|
|
5461
5824
|
}
|
|
5462
5825
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
|
|
5463
5826
|
requirementSelections: params.requirementSelections
|
|
5464
5827
|
});
|
|
5465
|
-
case
|
|
5828
|
+
case 65:
|
|
5466
5829
|
baseProjection = projectionEntry.projection;
|
|
5467
5830
|
commitWriteGuard = {
|
|
5468
5831
|
contextId: normalizedContextId,
|
|
@@ -5473,11 +5836,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5473
5836
|
};
|
|
5474
5837
|
prepareParams = baseProjection.meta.prepareParams;
|
|
5475
5838
|
if (prepareParams) {
|
|
5476
|
-
|
|
5839
|
+
_context54.next = 70;
|
|
5477
5840
|
break;
|
|
5478
5841
|
}
|
|
5479
5842
|
throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
5480
|
-
case
|
|
5843
|
+
case 70:
|
|
5481
5844
|
fallbackResources = {
|
|
5482
5845
|
resources: cloneDeep(_toConsumableArray(baseProjection.resources || [])),
|
|
5483
5846
|
resourceOccupancies: cloneDeep(_toConsumableArray(baseProjection.resourceOccupancies || []).filter(function (occupancy) {
|
|
@@ -5485,28 +5848,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5485
5848
|
})),
|
|
5486
5849
|
includesInjectedRawOccupancies: true
|
|
5487
5850
|
};
|
|
5488
|
-
|
|
5851
|
+
_context54.next = 73;
|
|
5489
5852
|
return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
|
|
5490
|
-
editingProductLineUids:
|
|
5853
|
+
editingProductLineUids: isEditingSelection && params.productLineUid ? [params.productLineUid] : []
|
|
5491
5854
|
}), {
|
|
5492
5855
|
resourceFetchPolicy: 'cache_only',
|
|
5493
5856
|
fallbackResources: fallbackResources,
|
|
5494
5857
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
5495
5858
|
});
|
|
5496
|
-
case
|
|
5497
|
-
commitSnapshot =
|
|
5859
|
+
case 73:
|
|
5860
|
+
commitSnapshot = _context54.sent;
|
|
5498
5861
|
refreshedProjection = commitSnapshot.projection;
|
|
5499
5862
|
if (!(String((_refreshedProjection$ = refreshedProjection.meta.orderRevision) !== null && _refreshedProjection$ !== void 0 ? _refreshedProjection$ : '') !== String((_baseProjection$meta$2 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$2 !== void 0 ? _baseProjection$meta$2 : ''))) {
|
|
5500
|
-
|
|
5863
|
+
_context54.next = 80;
|
|
5501
5864
|
break;
|
|
5502
5865
|
}
|
|
5503
|
-
|
|
5866
|
+
_context54.next = 78;
|
|
5504
5867
|
return this.refreshAvailabilityContextProjection({
|
|
5505
5868
|
contextId: normalizedContextId,
|
|
5506
5869
|
reason: 'commit_order_revision_changed',
|
|
5507
5870
|
previousOrderRevision: String((_baseProjection$meta$3 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$3 !== void 0 ? _baseProjection$meta$3 : '')
|
|
5508
5871
|
});
|
|
5509
|
-
case
|
|
5872
|
+
case 78:
|
|
5510
5873
|
latestContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5511
5874
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '最终缓存重校验期间购物车已变化,请重新获取候选', {
|
|
5512
5875
|
contextId: normalizedContextId,
|
|
@@ -5517,11 +5880,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5517
5880
|
snapshotId: baseProjection.meta.snapshotId,
|
|
5518
5881
|
refreshedSnapshotId: refreshedProjection.meta.snapshotId
|
|
5519
5882
|
});
|
|
5520
|
-
case
|
|
5883
|
+
case 80:
|
|
5521
5884
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
5522
5885
|
candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
|
|
5523
5886
|
candidateStartTime = getCandidateStartTime(params.candidate);
|
|
5524
|
-
allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$
|
|
5887
|
+
allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$otherParams38 = this.otherParams) === null || _this$otherParams38 === void 0 ? void 0 : _this$otherParams38.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos' && !strictAvailability;
|
|
5525
5888
|
refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
|
|
5526
5889
|
productIds: [params.candidate.productId],
|
|
5527
5890
|
dateRange: {
|
|
@@ -5534,18 +5897,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5534
5897
|
durationStartTimesByProductId: _defineProperty({}, String(params.candidate.productId), [candidateStartTime])
|
|
5535
5898
|
}, allowPosAvailabilityOverride ? {
|
|
5536
5899
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
5537
|
-
} : {}) : {}) : {}), {
|
|
5900
|
+
} : {}) : {}) : {}), _objectSpread(_objectSpread({}, strictAvailability ? {
|
|
5901
|
+
evaluatedAt: this.getAvailabilityRuntimeDateTime()
|
|
5902
|
+
} : {}), {}, {
|
|
5538
5903
|
useExactDurationCandidateMinute: allowPosAvailabilityOverride,
|
|
5539
5904
|
allowSessionCustomRanges: allowPosAvailabilityOverride,
|
|
5540
5905
|
allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
|
|
5541
|
-
}).flatMap(function (group) {
|
|
5906
|
+
})).flatMap(function (group) {
|
|
5542
5907
|
return group.ranges;
|
|
5543
5908
|
});
|
|
5544
5909
|
refreshedCandidateBase = refreshedRanges.find(function (candidate) {
|
|
5545
5910
|
return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
|
|
5546
5911
|
});
|
|
5547
5912
|
if (refreshedCandidateBase) {
|
|
5548
|
-
|
|
5913
|
+
_context54.next = 88;
|
|
5549
5914
|
break;
|
|
5550
5915
|
}
|
|
5551
5916
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
|
|
@@ -5553,18 +5918,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5553
5918
|
candidate: params.candidate,
|
|
5554
5919
|
refreshedSnapshotId: refreshedProjection.meta.snapshotId
|
|
5555
5920
|
});
|
|
5556
|
-
case
|
|
5921
|
+
case 88:
|
|
5557
5922
|
product = refreshedProjection.products.find(function (item) {
|
|
5558
5923
|
return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
|
|
5559
5924
|
});
|
|
5560
5925
|
if (product) {
|
|
5561
|
-
|
|
5926
|
+
_context54.next = 91;
|
|
5562
5927
|
break;
|
|
5563
5928
|
}
|
|
5564
5929
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
|
|
5565
5930
|
productId: refreshedCandidateBase.productId
|
|
5566
5931
|
});
|
|
5567
|
-
case
|
|
5932
|
+
case 91:
|
|
5568
5933
|
validation = validateAvailabilitySelection(refreshedProjection, {
|
|
5569
5934
|
candidate: refreshedCandidateBase,
|
|
5570
5935
|
requirementSelections: params.requirementSelections,
|
|
@@ -5595,7 +5960,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5595
5960
|
});
|
|
5596
5961
|
}
|
|
5597
5962
|
if (validation.ok) {
|
|
5598
|
-
|
|
5963
|
+
_context54.next = 96;
|
|
5599
5964
|
break;
|
|
5600
5965
|
}
|
|
5601
5966
|
capacityConflict = validation.conflicts.find(function (conflict) {
|
|
@@ -5605,7 +5970,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5605
5970
|
validation: validation,
|
|
5606
5971
|
refreshedSnapshotId: refreshedProjection.meta.snapshotId
|
|
5607
5972
|
});
|
|
5608
|
-
case
|
|
5973
|
+
case 96:
|
|
5609
5974
|
// Revalidation failure must leave the caller's candidate reusable. Only publish the
|
|
5610
5975
|
// refreshed projection/version after candidate and resource validation has passed;
|
|
5611
5976
|
// otherwise a second Confirm from the still-open modal would incorrectly become stale.
|
|
@@ -5618,7 +5983,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5618
5983
|
incrementVersion: true
|
|
5619
5984
|
});
|
|
5620
5985
|
revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5621
|
-
|
|
5986
|
+
_context54.next = 100;
|
|
5622
5987
|
return this.emitAvailabilityDiagnostic({
|
|
5623
5988
|
action: 'refresh',
|
|
5624
5989
|
contextId: normalizedContextId,
|
|
@@ -5629,7 +5994,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5629
5994
|
previousOrderRevision: baseProjection.meta.orderRevision,
|
|
5630
5995
|
reason: 'commit_cached_occupancy_revalidation'
|
|
5631
5996
|
});
|
|
5632
|
-
case
|
|
5997
|
+
case 100:
|
|
5633
5998
|
commitWriteGuard = {
|
|
5634
5999
|
contextId: normalizedContextId,
|
|
5635
6000
|
expectedVersion: revalidatedContext.activeVersion,
|
|
@@ -5637,17 +6002,38 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5637
6002
|
expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
|
|
5638
6003
|
expectedOrderRevision: revalidationEntry.orderRevision
|
|
5639
6004
|
};
|
|
5640
|
-
refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase);
|
|
6005
|
+
refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase); // Order may await line/runtime setup. Its guarded transaction invokes this
|
|
6006
|
+
// again immediately before publishing, while the live cart is unchanged.
|
|
6007
|
+
availabilityCommitGuard = hasCommitGuard ? function () {
|
|
6008
|
+
var _params$availabilityC3;
|
|
6009
|
+
(_params$availabilityC3 = params.availabilityCommitGuard) === null || _params$availabilityC3 === void 0 || _params$availabilityC3.call(params);
|
|
6010
|
+
_this18.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
6011
|
+
if (!availabilityCommitTargetGuard()) {
|
|
6012
|
+
throw _this18.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '预约加购期间订单或业务已变化');
|
|
6013
|
+
}
|
|
6014
|
+
if (!strictAvailability) return;
|
|
6015
|
+
var currentValidation = validateAvailabilitySelection(refreshedProjection, {
|
|
6016
|
+
candidate: refreshedCandidateBase,
|
|
6017
|
+
requirementSelections: params.requirementSelections,
|
|
6018
|
+
partySize: partySize,
|
|
6019
|
+
bookingCount: bookingCount
|
|
6020
|
+
});
|
|
6021
|
+
if (!currentValidation.ok) {
|
|
6022
|
+
throw new AvailabilityError('REVALIDATION_FAILED', '所选时间在加购前已不可用,请重新选择', {
|
|
6023
|
+
validation: currentValidation
|
|
6024
|
+
});
|
|
6025
|
+
}
|
|
6026
|
+
} : undefined;
|
|
5641
6027
|
existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
|
|
5642
6028
|
existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
|
|
5643
|
-
if (!(
|
|
5644
|
-
|
|
6029
|
+
if (!(isEditingSelection && !existingBookingUid)) {
|
|
6030
|
+
_context54.next = 107;
|
|
5645
6031
|
break;
|
|
5646
6032
|
}
|
|
5647
6033
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
|
|
5648
6034
|
productLineUid: params.productLineUid
|
|
5649
6035
|
});
|
|
5650
|
-
case
|
|
6036
|
+
case 107:
|
|
5651
6037
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
5652
6038
|
booking = buildBookingFromAvailabilitySelection({
|
|
5653
6039
|
assignments: validation.assignments,
|
|
@@ -5655,34 +6041,75 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5655
6041
|
product: product,
|
|
5656
6042
|
resources: refreshedProjection.resources,
|
|
5657
6043
|
bookingUid: existingBookingUid || undefined,
|
|
5658
|
-
holder: (
|
|
5659
|
-
holderIds: (
|
|
6044
|
+
holder: (_params$orderProduct$3 = (_params$orderProduct6 = params.orderProduct) === null || _params$orderProduct6 === void 0 || (_params$orderProduct6 = _params$orderProduct6._extend) === null || _params$orderProduct6 === void 0 ? void 0 : _params$orderProduct6.holder) !== null && _params$orderProduct$3 !== void 0 ? _params$orderProduct$3 : params.mode === 'replace' ? undefined : (_existingBooking$hold = existingBooking === null || existingBooking === void 0 ? void 0 : existingBooking.holder) !== null && _existingBooking$hold !== void 0 ? _existingBooking$hold : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
|
|
6045
|
+
holderIds: (_ref55 = (_params$orderProduct$4 = (_params$orderProduct7 = params.orderProduct) === null || _params$orderProduct7 === void 0 || (_params$orderProduct7 = _params$orderProduct7._extend) === null || _params$orderProduct7 === void 0 ? void 0 : _params$orderProduct7.holder_id) !== null && _params$orderProduct$4 !== void 0 ? _params$orderProduct$4 : (_params$orderProduct8 = params.orderProduct) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8._extend) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8.holder) === null || _params$orderProduct8 === void 0 ? void 0 : _params$orderProduct8.form_record) !== null && _ref55 !== void 0 ? _ref55 : params.mode === 'replace' ? undefined : (_existingBooking$meta2 = existingBooking === null || existingBooking === void 0 || (_existingBooking$meta3 = existingBooking.metadata) === null || _existingBooking$meta3 === void 0 ? void 0 : _existingBooking$meta3.holder_id) !== null && _existingBooking$meta2 !== void 0 ? _existingBooking$meta2 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold2 = existingBooking.holder) === null || _existingBooking$hold2 === void 0 ? void 0 : _existingBooking$hold2.form_record
|
|
5660
6046
|
});
|
|
6047
|
+
if (params.mode === 'replace') {
|
|
6048
|
+
// A different product must not inherit the previous product/resource's completed forms.
|
|
6049
|
+
booking.holder = booking.holder || null;
|
|
6050
|
+
booking.relation_forms = [];
|
|
6051
|
+
}
|
|
5661
6052
|
transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
|
|
5662
6053
|
num: bookingCount,
|
|
5663
6054
|
quantity: bookingCount
|
|
5664
6055
|
}), 'unified_booking_sales', product);
|
|
5665
6056
|
if (transformed) {
|
|
5666
|
-
|
|
6057
|
+
_context54.next = 113;
|
|
5667
6058
|
break;
|
|
5668
6059
|
}
|
|
5669
6060
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
|
|
5670
6061
|
orderProduct: params.orderProduct
|
|
5671
6062
|
});
|
|
5672
|
-
case
|
|
6063
|
+
case 113:
|
|
5673
6064
|
transformed.num = bookingCount;
|
|
5674
6065
|
transformed.metadata = _objectSpread(_objectSpread({}, transformed.metadata || {}), {}, {
|
|
5675
6066
|
unified_booking_sales: true,
|
|
5676
6067
|
availability_candidate_key: refreshedCandidate.key,
|
|
5677
6068
|
availability_context_id: normalizedContextId,
|
|
5678
6069
|
availability_context_version: refreshedCandidate.availabilityContextVersion
|
|
5679
|
-
})
|
|
6070
|
+
}, ['tickets', 'party_main'].includes((_transformed$metadata = transformed.metadata) === null || _transformed$metadata === void 0 ? void 0 : _transformed$metadata.venue_booking_role) ? {
|
|
6071
|
+
venue_booking_service_datetime: "".concat(booking.start_date, " ").concat(booking.start_time)
|
|
6072
|
+
} : {});
|
|
5680
6073
|
productLineUid = '';
|
|
5681
6074
|
bookingUid = '';
|
|
5682
6075
|
productLineUids = [];
|
|
5683
6076
|
bookingUids = [];
|
|
6077
|
+
if (!(isPartyReplacement && editingLine && params.productLineUid)) {
|
|
6078
|
+
_context54.next = 130;
|
|
6079
|
+
break;
|
|
6080
|
+
}
|
|
6081
|
+
relatedRetailProducts = params.relatedRetailProducts.map(function (source) {
|
|
6082
|
+
var line = _this18.buildUnifiedOrderProduct(source, 'unified_booking_sales_retail');
|
|
6083
|
+
if (!line) throw new AvailabilityError('INVALID_TARGET_FILTER', '无法生成附加商品订单行');
|
|
6084
|
+
// This is the only replacement-specific UID restore. Order checks ownership/collisions.
|
|
6085
|
+
var sourceUid = getProductLineUid(source);
|
|
6086
|
+
if (sourceUid) {
|
|
6087
|
+
line.metadata = _objectSpread(_objectSpread({}, line.metadata || {}), {}, {
|
|
6088
|
+
unique_identification_number: sourceUid
|
|
6089
|
+
});
|
|
6090
|
+
}
|
|
6091
|
+
return line;
|
|
6092
|
+
});
|
|
6093
|
+
_context54.next = 123;
|
|
6094
|
+
return this.store.order.replaceBookingProductWithRelatedRetail({
|
|
6095
|
+
productLineUid: params.productLineUid,
|
|
6096
|
+
product: transformed,
|
|
6097
|
+
booking: booking,
|
|
6098
|
+
relatedRetailProducts: relatedRetailProducts,
|
|
6099
|
+
availabilityCommitGuard: availabilityCommitGuard,
|
|
6100
|
+
availabilityCommitTargetGuard: availabilityCommitTargetGuard
|
|
6101
|
+
});
|
|
6102
|
+
case 123:
|
|
6103
|
+
guardedCommitPublished = true;
|
|
6104
|
+
productLineUid = params.productLineUid;
|
|
6105
|
+
bookingUid = existingBookingUid;
|
|
6106
|
+
productLineUids = [productLineUid];
|
|
6107
|
+
bookingUids = [bookingUid];
|
|
6108
|
+
_context54.next = 164;
|
|
6109
|
+
break;
|
|
6110
|
+
case 130:
|
|
5684
6111
|
if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
|
|
5685
|
-
|
|
6112
|
+
_context54.next = 150;
|
|
5686
6113
|
break;
|
|
5687
6114
|
}
|
|
5688
6115
|
transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
|
|
@@ -5692,10 +6119,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5692
6119
|
unique_identification_number: params.productLineUid,
|
|
5693
6120
|
booking_uid: existingBookingUid
|
|
5694
6121
|
});
|
|
5695
|
-
|
|
5696
|
-
return this.updateOrderProduct(_objectSpread(_objectSpread({
|
|
6122
|
+
update = _objectSpread(_objectSpread({
|
|
5697
6123
|
product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
|
|
5698
|
-
product_variant_id: (
|
|
6124
|
+
product_variant_id: (_ref56 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref56 !== void 0 ? _ref56 : 0,
|
|
5699
6125
|
unique_identification_number: params.productLineUid,
|
|
5700
6126
|
updates: transformed,
|
|
5701
6127
|
booking: booking
|
|
@@ -5703,27 +6129,48 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5703
6129
|
allow_booking_reprice: params.allowBookingReprice
|
|
5704
6130
|
} : {}), params.allowBookingDiscountReapply !== undefined ? {
|
|
5705
6131
|
allow_booking_discount_reapply: params.allowBookingDiscountReapply
|
|
5706
|
-
} : {})
|
|
5707
|
-
|
|
6132
|
+
} : {});
|
|
6133
|
+
if (!availabilityCommitGuard) {
|
|
6134
|
+
_context54.next = 142;
|
|
6135
|
+
break;
|
|
6136
|
+
}
|
|
6137
|
+
_context54.next = 139;
|
|
6138
|
+
return this.updateOrderProducts([update], {
|
|
6139
|
+
beforeApply: availabilityCommitGuard,
|
|
6140
|
+
isCurrentOrder: availabilityCommitTargetGuard
|
|
6141
|
+
});
|
|
6142
|
+
case 139:
|
|
6143
|
+
guardedCommitPublished = true;
|
|
6144
|
+
_context54.next = 144;
|
|
6145
|
+
break;
|
|
6146
|
+
case 142:
|
|
6147
|
+
_context54.next = 144;
|
|
6148
|
+
return this.updateOrderProduct(update);
|
|
6149
|
+
case 144:
|
|
5708
6150
|
productLineUid = params.productLineUid;
|
|
5709
6151
|
bookingUid = existingBookingUid;
|
|
5710
6152
|
productLineUids = [productLineUid];
|
|
5711
6153
|
bookingUids = [bookingUid];
|
|
5712
|
-
|
|
6154
|
+
_context54.next = 164;
|
|
5713
6155
|
break;
|
|
5714
|
-
case
|
|
6156
|
+
case 150:
|
|
5715
6157
|
beforeProductLineUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.products) || []).map(function (line) {
|
|
5716
6158
|
return getProductLineUid(line);
|
|
5717
6159
|
}).filter(Boolean));
|
|
5718
6160
|
beforeBookingUids = new Set((((_this$getTempOrder6 = this.getTempOrder()) === null || _this$getTempOrder6 === void 0 ? void 0 : _this$getTempOrder6.bookings) || []).map(function (item) {
|
|
5719
6161
|
return getBookingUid(item);
|
|
5720
6162
|
}).filter(Boolean));
|
|
5721
|
-
|
|
5722
|
-
|
|
6163
|
+
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
6164
|
+
_context54.next = 155;
|
|
6165
|
+
return this.addProductToOrder(transformed, booking, (_params$salesNotes = params.salesNotes) !== null && _params$salesNotes !== void 0 && _params$salesNotes.length || availabilityCommitGuard ? _objectSpread(_objectSpread({}, (_params$salesNotes2 = params.salesNotes) !== null && _params$salesNotes2 !== void 0 && _params$salesNotes2.length ? {
|
|
5723
6166
|
salesNotes: params.salesNotes
|
|
5724
|
-
} :
|
|
5725
|
-
|
|
5726
|
-
|
|
6167
|
+
} : {}), availabilityCommitGuard ? {
|
|
6168
|
+
availabilityCommitGuard: availabilityCommitGuard,
|
|
6169
|
+
availabilityCommitTargetGuard: availabilityCommitTargetGuard
|
|
6170
|
+
} : {}) : undefined);
|
|
6171
|
+
case 155:
|
|
6172
|
+
products = _context54.sent;
|
|
6173
|
+
guardedCommitPublished = hasCommitGuard;
|
|
5727
6174
|
addedLines = products.filter(function (line) {
|
|
5728
6175
|
var _line$product_id, _line$metadata;
|
|
5729
6176
|
return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
|
|
@@ -5731,7 +6178,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5731
6178
|
productLineUids = addedLines.map(function (line) {
|
|
5732
6179
|
return getProductLineUid(line);
|
|
5733
6180
|
}).filter(Boolean);
|
|
5734
|
-
addedBookings = (((
|
|
6181
|
+
addedBookings = (((_ref57 = hasCommitGuard ? guardedOrder : this.getTempOrder()) === null || _ref57 === void 0 ? void 0 : _ref57.bookings) || []).filter(function (item) {
|
|
5735
6182
|
var _item$metadata;
|
|
5736
6183
|
return ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.availability_candidate_key) === refreshedCandidate.key && !beforeBookingUids.has(getBookingUid(item));
|
|
5737
6184
|
});
|
|
@@ -5740,19 +6187,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5740
6187
|
}).filter(Boolean);
|
|
5741
6188
|
if (bookingUids.length === 0) {
|
|
5742
6189
|
bookingUids = addedLines.map(function (line) {
|
|
5743
|
-
var
|
|
5744
|
-
return String((
|
|
6190
|
+
var _ref58, _line$booking_uid, _line$metadata2;
|
|
6191
|
+
return String((_ref58 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) !== null && _ref58 !== void 0 ? _ref58 : '');
|
|
5745
6192
|
}).filter(Boolean);
|
|
5746
6193
|
}
|
|
5747
6194
|
productLineUid = productLineUids[productLineUids.length - 1] || '';
|
|
5748
6195
|
bookingUid = bookingUids[bookingUids.length - 1] || '';
|
|
5749
|
-
case
|
|
5750
|
-
|
|
5751
|
-
|
|
6196
|
+
case 164:
|
|
6197
|
+
targetStillCurrent = !hasCommitGuard || availabilityCommitTargetGuard();
|
|
6198
|
+
if (targetStillCurrent) this.invalidateAvailabilityContextsAfterCommit();else this.removeAvailabilityContext(normalizedContextId);
|
|
6199
|
+
nextContext = hasCommitGuard ? this.availabilityContextRegistry.get(normalizedContextId) : this.getAvailabilityContextEntry(normalizedContextId);
|
|
5752
6200
|
result = {
|
|
5753
6201
|
contextId: normalizedContextId,
|
|
5754
|
-
contextVersion: nextContext.activeVersion,
|
|
5755
|
-
tempOrder: this.getTempOrder(),
|
|
6202
|
+
contextVersion: (_nextContext$activeVe = nextContext === null || nextContext === void 0 ? void 0 : nextContext.activeVersion) !== null && _nextContext$activeVe !== void 0 ? _nextContext$activeVe : refreshedCandidate.availabilityContextVersion,
|
|
6203
|
+
tempOrder: hasCommitGuard ? guardedOrder : this.getTempOrder(),
|
|
5756
6204
|
validation: validation,
|
|
5757
6205
|
candidate: refreshedCandidate,
|
|
5758
6206
|
productLineUid: productLineUid,
|
|
@@ -5760,23 +6208,61 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5760
6208
|
productLineUids: productLineUids,
|
|
5761
6209
|
bookingUids: bookingUids
|
|
5762
6210
|
};
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
6211
|
+
if (!targetStillCurrent) {
|
|
6212
|
+
_context54.next = 182;
|
|
6213
|
+
break;
|
|
6214
|
+
}
|
|
6215
|
+
// A notification failure after publication must not invite a duplicate add.
|
|
6216
|
+
emit = function emit() {
|
|
6217
|
+
return _this18.core.effects.emit("".concat(_this18.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
6218
|
+
};
|
|
6219
|
+
if (!guardedCommitPublished) {
|
|
6220
|
+
_context54.next = 180;
|
|
6221
|
+
break;
|
|
6222
|
+
}
|
|
6223
|
+
_context54.prev = 171;
|
|
6224
|
+
_context54.next = 174;
|
|
6225
|
+
return emit();
|
|
6226
|
+
case 174:
|
|
6227
|
+
_context54.next = 178;
|
|
6228
|
+
break;
|
|
6229
|
+
case 176:
|
|
6230
|
+
_context54.prev = 176;
|
|
6231
|
+
_context54.t0 = _context54["catch"](171);
|
|
6232
|
+
case 178:
|
|
6233
|
+
_context54.next = 182;
|
|
6234
|
+
break;
|
|
6235
|
+
case 180:
|
|
6236
|
+
_context54.next = 182;
|
|
6237
|
+
return emit();
|
|
6238
|
+
case 182:
|
|
6239
|
+
return _context54.abrupt("return", result);
|
|
6240
|
+
case 183:
|
|
6241
|
+
_context54.prev = 183;
|
|
6242
|
+
release = this.releaseAvailabilityCommitLock(normalizedContextId);
|
|
6243
|
+
if (!guardedCommitPublished) {
|
|
6244
|
+
_context54.next = 190;
|
|
6245
|
+
break;
|
|
6246
|
+
}
|
|
6247
|
+
_context54.next = 188;
|
|
6248
|
+
return release.catch(function () {
|
|
6249
|
+
return undefined;
|
|
6250
|
+
});
|
|
6251
|
+
case 188:
|
|
6252
|
+
_context54.next = 192;
|
|
6253
|
+
break;
|
|
6254
|
+
case 190:
|
|
6255
|
+
_context54.next = 192;
|
|
6256
|
+
return release;
|
|
6257
|
+
case 192:
|
|
6258
|
+
return _context54.finish(183);
|
|
6259
|
+
case 193:
|
|
5774
6260
|
case "end":
|
|
5775
|
-
return
|
|
6261
|
+
return _context54.stop();
|
|
5776
6262
|
}
|
|
5777
|
-
},
|
|
6263
|
+
}, _callee54, this, [[18,, 183, 193], [171, 176]]);
|
|
5778
6264
|
}));
|
|
5779
|
-
function commitAvailabilitySelection(
|
|
6265
|
+
function commitAvailabilitySelection(_x40, _x41) {
|
|
5780
6266
|
return _commitAvailabilitySelection.apply(this, arguments);
|
|
5781
6267
|
}
|
|
5782
6268
|
return commitAvailabilitySelection;
|