@pisell/pisellos 2.2.313 → 2.2.315
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/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +74 -7
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +13 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/dist/model/strategy/adapter/itemRule/type.js +10 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/dist/modules/BookingContext/utils/productExtend.js +62 -18
- package/dist/modules/BookingContext/utils/resources.js +1 -1
- package/dist/modules/BusinessAvailability/index.d.ts +30 -0
- package/dist/modules/BusinessAvailability/index.js +204 -0
- package/dist/modules/Cart/index.js +4 -3
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/dist/modules/Cart/utils/cartProduct.js +59 -32
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/OpenData/types.d.ts +14 -0
- package/dist/modules/Order/index.d.ts +14 -2
- package/dist/modules/Order/index.js +856 -486
- package/dist/modules/Order/localEftposState.d.ts +13 -0
- package/dist/modules/Order/localEftposState.js +39 -0
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +30 -2
- package/dist/modules/Order/utils.js +25 -7
- package/dist/modules/Payment/index.js +9 -10
- package/dist/modules/Product/types.d.ts +11 -0
- package/dist/modules/ProductList/index.js +1 -1
- package/dist/modules/ResourcePlanner/planner.d.ts +2 -0
- package/dist/modules/ResourcePlanner/planner.js +332 -23
- package/dist/modules/ResourcePlanner/types.d.ts +29 -0
- package/dist/modules/Schedule/index.d.ts +8 -0
- package/dist/modules/Schedule/index.js +141 -39
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/request.d.ts +7 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1536 -1309
- package/dist/server/modules/form/index.d.ts +19 -0
- package/dist/server/modules/form/index.js +205 -0
- package/dist/server/modules/form/types.d.ts +13 -0
- package/dist/server/modules/form/types.js +3 -0
- package/dist/server/modules/index.d.ts +3 -0
- package/dist/server/modules/index.js +4 -0
- package/dist/server/modules/order/index.d.ts +15 -0
- package/dist/server/modules/order/index.js +920 -688
- package/dist/server/modules/order/types.d.ts +1 -0
- package/dist/server/test.json +1 -1
- package/dist/server/utils/small-ticket.d.ts +1 -85
- package/dist/server/utils/small-ticket.js +2 -2542
- package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/dist/shared/payment/loadPaymentMethods.js +66 -0
- package/dist/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/dist/shared/receipt/customerInvoiceLanguages.js +60 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/dist/shared/receipt/loadCustomerInvoiceLayout.js +184 -0
- package/dist/shared/receipt/small-ticket.d.ts +96 -0
- package/dist/shared/receipt/small-ticket.js +2751 -0
- package/dist/shared/receipt/templateVisibility.d.ts +23 -0
- package/dist/shared/receipt/templateVisibility.js +64 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/dist/solution/BaseSales/fulfillmentItemRules.js +750 -0
- package/dist/solution/BaseSales/index.d.ts +39 -16
- package/dist/solution/BaseSales/index.js +1754 -1154
- package/dist/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/dist/solution/BaseSales/pickupTiming.js +616 -0
- package/dist/solution/BaseSales/types.d.ts +11 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +4 -2
- package/dist/solution/BookingByStep/index.js +8 -3
- package/dist/solution/BookingTicket/index.d.ts +8 -2
- package/dist/solution/BookingTicket/index.js +513 -436
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/dist/solution/OrderInvoicePreview/index.js +340 -0
- package/dist/solution/RegisterAndLogin/config.js +54 -11
- package/dist/solution/RegisterAndLogin/index.d.ts +2 -0
- package/dist/solution/RegisterAndLogin/index.js +1 -1
- package/dist/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/dist/solution/RegisterAndLogin/utils.js +36 -16
- package/dist/solution/Sales/index.js +1 -1
- package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/dist/solution/UnifiedBookingSales/index.js +1714 -905
- package/dist/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/dist/solution/VenueBooking/index.d.ts +15 -2
- package/dist/solution/VenueBooking/index.js +1062 -785
- package/dist/solution/VenueBooking/types.d.ts +2 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +273 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +6 -3
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +21 -1
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +54 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +3 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +9 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +40 -1
- package/lib/model/strategy/adapter/itemRule/type.js +10 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +7 -0
- package/lib/modules/BookingContext/utils/productExtend.js +45 -2
- package/lib/modules/BookingContext/utils/resources.js +1 -1
- package/lib/modules/BusinessAvailability/index.d.ts +30 -0
- package/lib/modules/BusinessAvailability/index.js +146 -0
- package/lib/modules/Cart/index.js +4 -2
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +3 -1
- package/lib/modules/Cart/utils/cartProduct.js +39 -20
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/OpenData/types.d.ts +14 -0
- package/lib/modules/Order/index.d.ts +14 -2
- package/lib/modules/Order/index.js +240 -38
- package/lib/modules/Order/localEftposState.d.ts +13 -0
- package/lib/modules/Order/localEftposState.js +44 -0
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +30 -2
- package/lib/modules/Order/utils.js +21 -5
- package/lib/modules/Payment/index.js +3 -4
- package/lib/modules/Product/types.d.ts +11 -0
- package/lib/modules/ProductList/index.js +1 -1
- package/lib/modules/ResourcePlanner/planner.d.ts +2 -0
- package/lib/modules/ResourcePlanner/planner.js +252 -8
- package/lib/modules/ResourcePlanner/types.d.ts +29 -0
- package/lib/modules/Schedule/index.d.ts +8 -0
- package/lib/modules/Schedule/index.js +68 -12
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/plugins/request.d.ts +7 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +158 -37
- package/lib/server/modules/form/index.d.ts +19 -0
- package/lib/server/modules/form/index.js +73 -0
- package/lib/server/modules/form/types.d.ts +13 -0
- package/lib/server/modules/form/types.js +9 -0
- package/lib/server/modules/index.d.ts +3 -0
- package/lib/server/modules/index.js +15 -1
- package/lib/server/modules/order/index.d.ts +15 -0
- package/lib/server/modules/order/index.js +114 -3
- package/lib/server/modules/order/types.d.ts +1 -0
- package/lib/server/test.json +1 -1
- package/lib/server/utils/small-ticket.d.ts +1 -85
- package/lib/server/utils/small-ticket.js +9 -2305
- package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
- package/lib/shared/payment/loadPaymentMethods.js +40 -0
- package/lib/shared/receipt/customerInvoiceLanguages.d.ts +8 -0
- package/lib/shared/receipt/customerInvoiceLanguages.js +58 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +27 -0
- package/lib/shared/receipt/loadCustomerInvoiceLayout.js +124 -0
- package/lib/shared/receipt/small-ticket.d.ts +96 -0
- package/lib/shared/receipt/small-ticket.js +2546 -0
- package/lib/shared/receipt/templateVisibility.d.ts +23 -0
- package/lib/shared/receipt/templateVisibility.js +63 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
- package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.d.ts +27 -0
- package/lib/solution/BaseSales/fulfillmentItemRules.js +259 -0
- package/lib/solution/BaseSales/index.d.ts +39 -16
- package/lib/solution/BaseSales/index.js +333 -31
- package/lib/solution/BaseSales/pickupTiming.d.ts +47 -0
- package/lib/solution/BaseSales/pickupTiming.js +290 -0
- package/lib/solution/BaseSales/types.d.ts +11 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -2
- package/lib/solution/BookingByStep/index.js +7 -3
- package/lib/solution/BookingTicket/index.d.ts +8 -2
- package/lib/solution/BookingTicket/index.js +65 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -1
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/OrderInvoicePreview/index.d.ts +66 -0
- package/lib/solution/OrderInvoicePreview/index.js +246 -0
- package/lib/solution/RegisterAndLogin/config.js +57 -11
- package/lib/solution/RegisterAndLogin/index.d.ts +2 -0
- package/lib/solution/RegisterAndLogin/index.js +9 -1
- package/lib/solution/RegisterAndLogin/utils.d.ts +12 -4
- package/lib/solution/RegisterAndLogin/utils.js +24 -17
- package/lib/solution/Sales/index.js +1 -1
- package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
- package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +36 -4
- package/lib/solution/UnifiedBookingSales/index.js +561 -74
- package/lib/solution/UnifiedBookingSales/types.d.ts +16 -2
- package/lib/solution/VenueBooking/index.d.ts +15 -2
- package/lib/solution/VenueBooking/index.js +243 -96
- package/lib/solution/VenueBooking/types.d.ts +2 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +7 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +224 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +5 -2
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +11 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _excluded = ["date", "custom_page_id", "channel", "product_ids"];
|
|
2
|
-
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
2
|
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
3
|
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; }
|
|
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; } } }; }
|
|
5
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
6
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
7
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
@@ -36,20 +36,22 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
37
|
import { cloneDeep } from 'lodash-es';
|
|
38
38
|
import { OpenDataModule } from "../../modules";
|
|
39
|
-
import {
|
|
39
|
+
import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
|
|
40
|
+
import { cacheItemToBookingInput } from "../../modules/BookingContext/utils/cacheItemToBookingInput";
|
|
41
|
+
import { flexibleObj, getServiceTimes, getUsableTime, isProductFlexibleDuration, isSessionProduct } from "../../modules/BookingContext/utils";
|
|
40
42
|
import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from "../../modules/OpenData";
|
|
41
43
|
import { getScheduleStartEndTimePoints } from "../../modules/Schedule/getDateIsInSchedule";
|
|
42
|
-
import { AvailabilityError, createAvailabilityProjection, getProductTimeRanges as getProjectionProductTimeRanges, queryAvailabilityProjection, validateAvailabilitySelection } from "../../modules/ResourcePlanner";
|
|
44
|
+
import { AvailabilityError, createAvailabilityProjection, getDurationBusinessDate, getProductTimeRanges as getProjectionProductTimeRanges, queryAvailabilityProjection, validateAvailabilitySelection } from "../../modules/ResourcePlanner";
|
|
43
45
|
import { UnifiedBookingSalesHooks } from "./types";
|
|
44
46
|
import { AvailabilityRemoteOccupancyCache } from "./remoteOccupancyCache";
|
|
47
|
+
import { BusinessAvailabilityController } from "./businessAvailability";
|
|
45
48
|
import { BookingTicket } from "../BookingTicket";
|
|
46
|
-
import { addLocalCalendarDays, captureRuntimeOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, parseLocalDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
|
|
49
|
+
import { addLocalCalendarDays, captureRuntimeOffsetMinutes, extractFixedOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, parseLocalDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
|
|
47
50
|
import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/platform";
|
|
48
51
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
49
52
|
export * from "./types";
|
|
50
53
|
export { AvailabilityError } from "../../modules/ResourcePlanner";
|
|
51
54
|
var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents', 'basic', 'checkout', 'availability'];
|
|
52
|
-
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
53
55
|
function normalizePositiveInteger(value) {
|
|
54
56
|
var normalized = Number(value);
|
|
55
57
|
if (!Number.isInteger(normalized) || normalized <= 0) return undefined;
|
|
@@ -939,6 +941,20 @@ function getProductLineUid(product) {
|
|
|
939
941
|
var _ref18, _product$metadata$uni, _product$metadata2;
|
|
940
942
|
return String((_ref18 = (_product$metadata$uni = product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref18 !== void 0 ? _ref18 : '');
|
|
941
943
|
}
|
|
944
|
+
function getVisibleCalendarDate(value) {
|
|
945
|
+
if (typeof value !== 'string') return null;
|
|
946
|
+
var raw = value.trim();
|
|
947
|
+
try {
|
|
948
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) {
|
|
949
|
+
parseLocalDate(raw);
|
|
950
|
+
} else {
|
|
951
|
+
parseLocalDateTime(raw);
|
|
952
|
+
}
|
|
953
|
+
return raw.slice(0, 10);
|
|
954
|
+
} catch (_error) {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
942
958
|
export function buildAvailabilityLineIdentity(product) {
|
|
943
959
|
var _product$product_vari;
|
|
944
960
|
return {
|
|
@@ -1313,6 +1329,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1313
1329
|
_defineProperty(_assertThisInitialized(_this), "defaultName", 'unifiedBookingSales');
|
|
1314
1330
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
1315
1331
|
_defineProperty(_assertThisInitialized(_this), "store", {});
|
|
1332
|
+
_defineProperty(_assertThisInitialized(_this), "pickupTimingEnabled", true);
|
|
1333
|
+
_defineProperty(_assertThisInitialized(_this), "businessAvailabilityController", void 0);
|
|
1334
|
+
_defineProperty(_assertThisInitialized(_this), "runtimeOpenDataScope", null);
|
|
1335
|
+
_defineProperty(_assertThisInitialized(_this), "runtimeOpenDataSnapshot", null);
|
|
1336
|
+
_defineProperty(_assertThisInitialized(_this), "runtimeOpenDataModule", null);
|
|
1337
|
+
_defineProperty(_assertThisInitialized(_this), "runtimeOpenDataCore", void 0);
|
|
1338
|
+
_defineProperty(_assertThisInitialized(_this), "runtimeOpenDataGeneration", 0);
|
|
1339
|
+
_defineProperty(_assertThisInitialized(_this), "runtimeOpenDataDestroyed", false);
|
|
1316
1340
|
_defineProperty(_assertThisInitialized(_this), "unifiedProductCatalog", []);
|
|
1317
1341
|
_defineProperty(_assertThisInitialized(_this), "availabilityRuntimeOffsetMinutes", null);
|
|
1318
1342
|
_defineProperty(_assertThisInitialized(_this), "availabilityScheduleCatalog", null);
|
|
@@ -1337,30 +1361,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1337
1361
|
key: "initialize",
|
|
1338
1362
|
value: function () {
|
|
1339
1363
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
|
|
1340
|
-
var _ref23, _this$otherParams$bus, _this$otherParams, _this$otherParams2, _this$otherParams$cha, _this$otherParams3, _this$otherParams4;
|
|
1341
1364
|
var options,
|
|
1342
|
-
|
|
1343
|
-
openDataChannel,
|
|
1365
|
+
openDataGeneration,
|
|
1344
1366
|
_args = arguments;
|
|
1345
1367
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1346
1368
|
while (1) switch (_context.prev = _context.next) {
|
|
1347
1369
|
case 0:
|
|
1348
1370
|
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
1371
|
+
this.resetRuntimeOpenData();
|
|
1372
|
+
this.runtimeOpenDataDestroyed = false;
|
|
1373
|
+
openDataGeneration = this.runtimeOpenDataGeneration;
|
|
1349
1374
|
this.availabilityScheduleCatalog = null;
|
|
1350
|
-
this.openDataTarget = null;
|
|
1351
1375
|
this.availabilityRuntimeOffsetMinutes = captureRuntimeOffsetMinutes();
|
|
1352
1376
|
this.clearAvailabilityRemoteResourceState();
|
|
1353
1377
|
this.resetAllergyItemRuleState();
|
|
1354
|
-
_context.next =
|
|
1378
|
+
_context.next = 10;
|
|
1355
1379
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "initialize", this).call(this, core, options);
|
|
1356
|
-
case
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
this.openDataTarget = "".concat(openDataBusinessCode, "+").concat(openDataChannel);
|
|
1380
|
+
case 10:
|
|
1381
|
+
if (!(this.runtimeOpenDataDestroyed || openDataGeneration !== this.runtimeOpenDataGeneration)) {
|
|
1382
|
+
_context.next = 12;
|
|
1383
|
+
break;
|
|
1361
1384
|
}
|
|
1362
|
-
|
|
1385
|
+
throw new Error('Store settings changed. Please try again.');
|
|
1363
1386
|
case 12:
|
|
1387
|
+
this.captureAvailabilityScheduleCatalog();
|
|
1388
|
+
_context.next = 15;
|
|
1389
|
+
return this.ensureAllergyItemRuleConfigsLoaded();
|
|
1390
|
+
case 15:
|
|
1364
1391
|
case "end":
|
|
1365
1392
|
return _context.stop();
|
|
1366
1393
|
}
|
|
@@ -1374,10 +1401,86 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1374
1401
|
}, {
|
|
1375
1402
|
key: "getSubmitOrderSalesChannel",
|
|
1376
1403
|
value: function getSubmitOrderSalesChannel() {
|
|
1377
|
-
var _this$otherParams$
|
|
1378
|
-
var channel = String((_this$otherParams$
|
|
1404
|
+
var _this$otherParams$cha, _this$otherParams;
|
|
1405
|
+
var channel = String((_this$otherParams$cha = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
|
|
1379
1406
|
return channel || _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "getSubmitOrderSalesChannel", this).call(this);
|
|
1380
1407
|
}
|
|
1408
|
+
|
|
1409
|
+
/** Only the explicit Kiosk Sales consumer entry enables this policy; POS stays unchanged. */
|
|
1410
|
+
}, {
|
|
1411
|
+
key: "isBusinessAvailabilityEnabled",
|
|
1412
|
+
value: function isBusinessAvailabilityEnabled() {
|
|
1413
|
+
var _this$otherParams2, _this$otherParams3;
|
|
1414
|
+
return ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.enableBusinessAvailability) === true && ['pc', 'h5', 'kiosk'].includes(normalizeRuntimePlatform((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform));
|
|
1415
|
+
}
|
|
1416
|
+
}, {
|
|
1417
|
+
key: "getBusinessAvailabilityScope",
|
|
1418
|
+
value: function getBusinessAvailabilityScope() {
|
|
1419
|
+
return "".concat(this.getRuntimeOpenDataScope(), ":").concat(this.runtimeOpenDataGeneration);
|
|
1420
|
+
}
|
|
1421
|
+
}, {
|
|
1422
|
+
key: "getBusinessAvailabilityController",
|
|
1423
|
+
value: function getBusinessAvailabilityController() {
|
|
1424
|
+
var _this2 = this;
|
|
1425
|
+
if (!this.businessAvailabilityController) {
|
|
1426
|
+
this.businessAvailabilityController = new BusinessAvailabilityController({
|
|
1427
|
+
loadOpenData: function loadOpenData() {
|
|
1428
|
+
return _this2.loadOpenDataConfig();
|
|
1429
|
+
},
|
|
1430
|
+
getSchedule: function getSchedule() {
|
|
1431
|
+
return _this2.store.schedule;
|
|
1432
|
+
},
|
|
1433
|
+
getTimezone: function getTimezone() {
|
|
1434
|
+
var _this2$otherParams;
|
|
1435
|
+
return String(((_this2$otherParams = _this2.otherParams) === null || _this2$otherParams === void 0 ? void 0 : _this2$otherParams.businessTimezone) || _this2.getPickupTimingContextData('timezone') || '');
|
|
1436
|
+
},
|
|
1437
|
+
getScope: function getScope() {
|
|
1438
|
+
return _this2.getBusinessAvailabilityScope();
|
|
1439
|
+
}
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
return this.businessAvailabilityController;
|
|
1443
|
+
}
|
|
1444
|
+
}, {
|
|
1445
|
+
key: "getBusinessAvailability",
|
|
1446
|
+
value: function getBusinessAvailability() {
|
|
1447
|
+
return this.getBusinessAvailabilityController().getAvailability();
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/** Internal final-write assertion; does not fetch OpenData or Schedule. */
|
|
1451
|
+
}, {
|
|
1452
|
+
key: "assertBusinessAvailability",
|
|
1453
|
+
value: function assertBusinessAvailability() {
|
|
1454
|
+
if (this.isBusinessAvailabilityEnabled()) this.getBusinessAvailabilityController().assertAvailable();
|
|
1455
|
+
}
|
|
1456
|
+
}, {
|
|
1457
|
+
key: "getSubModuleHooks",
|
|
1458
|
+
value: function getSubModuleHooks(moduleName) {
|
|
1459
|
+
var _this3 = this;
|
|
1460
|
+
var hooks = _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "getSubModuleHooks", this).call(this, moduleName);
|
|
1461
|
+
if (moduleName !== 'order' || !this.isBusinessAvailabilityEnabled()) return hooks;
|
|
1462
|
+
var lastScope;
|
|
1463
|
+
var lastExistingScope;
|
|
1464
|
+
var scopeToken = {};
|
|
1465
|
+
return _objectSpread(_objectSpread({}, hooks), {}, {
|
|
1466
|
+
getCartIntentScope: function getCartIntentScope() {
|
|
1467
|
+
var _hooks$getCartIntentS;
|
|
1468
|
+
var scope = _this3.getBusinessAvailabilityScope();
|
|
1469
|
+
var existingScope = hooks === null || hooks === void 0 || (_hooks$getCartIntentS = hooks.getCartIntentScope) === null || _hooks$getCartIntentS === void 0 ? void 0 : _hooks$getCartIntentS.call(hooks);
|
|
1470
|
+
if (scope !== lastScope || !Object.is(existingScope, lastExistingScope)) {
|
|
1471
|
+
lastScope = scope;
|
|
1472
|
+
lastExistingScope = existingScope;
|
|
1473
|
+
scopeToken = {};
|
|
1474
|
+
}
|
|
1475
|
+
return scopeToken;
|
|
1476
|
+
},
|
|
1477
|
+
beforeCartIntentCommit: function beforeCartIntentCommit(context) {
|
|
1478
|
+
var _hooks$beforeCartInte;
|
|
1479
|
+
_this3.assertBusinessAvailability();
|
|
1480
|
+
hooks === null || hooks === void 0 || (_hooks$beforeCartInte = hooks.beforeCartIntentCommit) === null || _hooks$beforeCartInte === void 0 || _hooks$beforeCartInte.call(hooks, context);
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1381
1484
|
}, {
|
|
1382
1485
|
key: "createAvailabilityFacadeError",
|
|
1383
1486
|
value: function createAvailabilityFacadeError(code, message, details) {
|
|
@@ -1386,16 +1489,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1386
1489
|
}, {
|
|
1387
1490
|
key: "getAvailabilityScopeDescriptor",
|
|
1388
1491
|
value: function getAvailabilityScopeDescriptor() {
|
|
1389
|
-
var
|
|
1492
|
+
var _ref23, _otherParams$business, _otherParams$channel, _otherParams$platform, _otherParams$business2;
|
|
1390
1493
|
var otherParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.otherParams || {};
|
|
1391
1494
|
return {
|
|
1392
1495
|
cacheId: this.cacheId || '',
|
|
1393
|
-
businessCode: String((
|
|
1496
|
+
businessCode: String((_ref23 = (_otherParams$business = otherParams.businessCode) !== null && _otherParams$business !== void 0 ? _otherParams$business : otherParams.business_code) !== null && _ref23 !== void 0 ? _ref23 : ''),
|
|
1394
1497
|
channel: String((_otherParams$channel = otherParams.channel) !== null && _otherParams$channel !== void 0 ? _otherParams$channel : ''),
|
|
1395
1498
|
platform: String((_otherParams$platform = otherParams.platform) !== null && _otherParams$platform !== void 0 ? _otherParams$platform : ''),
|
|
1396
1499
|
businessTimezone: String((_otherParams$business2 = otherParams.businessTimezone) !== null && _otherParams$business2 !== void 0 ? _otherParams$business2 : '')
|
|
1397
1500
|
};
|
|
1398
1501
|
}
|
|
1502
|
+
}, {
|
|
1503
|
+
key: "usesDurationTimeGrid",
|
|
1504
|
+
value: function usesDurationTimeGrid(projection) {
|
|
1505
|
+
var _this$otherParams$pla, _this$otherParams4;
|
|
1506
|
+
var platform = String((_this$otherParams$pla = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase();
|
|
1507
|
+
return (platform === 'pos' || platform === 'kiosk') && (!projection || projection.products.some(function (product) {
|
|
1508
|
+
return product.kind === 'duration';
|
|
1509
|
+
}));
|
|
1510
|
+
}
|
|
1511
|
+
}, {
|
|
1512
|
+
key: "getCurrentAvailabilityBusinessDate",
|
|
1513
|
+
value: function getCurrentAvailabilityBusinessDate(projection) {
|
|
1514
|
+
return getDurationBusinessDate(projection, this.getAvailabilityRuntimeDateTime());
|
|
1515
|
+
}
|
|
1516
|
+
}, {
|
|
1517
|
+
key: "getAvailabilityBusinessDateRange",
|
|
1518
|
+
value: function getAvailabilityBusinessDateRange(projection) {
|
|
1519
|
+
var prepare = projection.meta.prepareParams;
|
|
1520
|
+
var range = prepare === null || prepare === void 0 ? void 0 : prepare.dateRange;
|
|
1521
|
+
if (!this.usesDurationTimeGrid(projection) || !(range !== null && range !== void 0 && range.startDate) || !range.endDate) {
|
|
1522
|
+
return projection.meta.coverage;
|
|
1523
|
+
}
|
|
1524
|
+
var businessDate = this.getCurrentAvailabilityBusinessDate(projection);
|
|
1525
|
+
var today = this.getAvailabilityRuntimeDateTime().slice(0, 10);
|
|
1526
|
+
return {
|
|
1527
|
+
startDate: range.startDate === today && businessDate < today ? businessDate : range.startDate,
|
|
1528
|
+
endDate: range.endDate
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1399
1531
|
}, {
|
|
1400
1532
|
key: "normalizeAvailabilityIdList",
|
|
1401
1533
|
value: function normalizeAvailabilityIdList(values) {
|
|
@@ -1404,15 +1536,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1404
1536
|
values.forEach(function (value) {
|
|
1405
1537
|
uniqueMap.set(String(value), value);
|
|
1406
1538
|
});
|
|
1407
|
-
return Array.from(uniqueMap.entries()).sort(function (
|
|
1539
|
+
return Array.from(uniqueMap.entries()).sort(function (_ref24, _ref25) {
|
|
1540
|
+
var _ref26 = _slicedToArray(_ref24, 1),
|
|
1541
|
+
left = _ref26[0];
|
|
1408
1542
|
var _ref27 = _slicedToArray(_ref25, 1),
|
|
1409
|
-
|
|
1410
|
-
var _ref28 = _slicedToArray(_ref26, 1),
|
|
1411
|
-
right = _ref28[0];
|
|
1543
|
+
right = _ref27[0];
|
|
1412
1544
|
return left.localeCompare(right);
|
|
1413
|
-
}).map(function (
|
|
1414
|
-
var
|
|
1415
|
-
value =
|
|
1545
|
+
}).map(function (_ref28) {
|
|
1546
|
+
var _ref29 = _slicedToArray(_ref28, 2),
|
|
1547
|
+
value = _ref29[1];
|
|
1416
1548
|
return value;
|
|
1417
1549
|
});
|
|
1418
1550
|
}
|
|
@@ -1427,9 +1559,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1427
1559
|
}, {
|
|
1428
1560
|
key: "normalizeAvailabilityPrepareDescriptor",
|
|
1429
1561
|
value: function normalizeAvailabilityPrepareDescriptor(params) {
|
|
1430
|
-
var _this$
|
|
1562
|
+
var _this$otherParams5;
|
|
1431
1563
|
this.assertAvailabilityPrepareParams(params);
|
|
1432
|
-
var timezone = String(params.timezone || ((_this$
|
|
1564
|
+
var timezone = String(params.timezone || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessTimezone) || Intl.DateTimeFormat().resolvedOptions().timeZone || 'Asia/Shanghai');
|
|
1433
1565
|
assertValidAvailabilityTimezone(timezone);
|
|
1434
1566
|
var dateRange = this.normalizeAvailabilityDateRange(params, timezone);
|
|
1435
1567
|
var slotStepMinutes = params.slotStepMinutes || DEFAULT_AVAILABILITY_SLOT_STEP_MINUTES;
|
|
@@ -1455,61 +1587,191 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1455
1587
|
mode: mode
|
|
1456
1588
|
}));
|
|
1457
1589
|
}
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* 列表直加没有经过 SKU availability flow,legacy cacheItem 的灵活时长可能落到
|
|
1593
|
+
* 23:59。提交前用同一套营业排期补齐结束时间,保留已选开始时间、资源和 Holder。
|
|
1594
|
+
* 仅供直加调用;手动时间选择和 availability candidate 不经过此方法。
|
|
1595
|
+
*/
|
|
1596
|
+
}, {
|
|
1597
|
+
key: "prepareDirectAddFlexibleBooking",
|
|
1598
|
+
value: (function () {
|
|
1599
|
+
var _prepareDirectAddFlexibleBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cacheItem) {
|
|
1600
|
+
var _prepare$_availabilit, _merged$, _getUsableTime;
|
|
1601
|
+
var extend, _getServiceTimes, startDate, date, dateRange, prepare, operatingHours, start, nextDay, windows, merged, _iterator, _step, window, previous, end, resourceEndAt, resourceEnd, duration, endDate;
|
|
1602
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1603
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1604
|
+
case 0:
|
|
1605
|
+
if (!(!isProductFlexibleDuration(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.duration) || isSessionProduct(cacheItem))) {
|
|
1606
|
+
_context2.next = 2;
|
|
1607
|
+
break;
|
|
1608
|
+
}
|
|
1609
|
+
return _context2.abrupt("return", cacheItem);
|
|
1610
|
+
case 2:
|
|
1611
|
+
extend = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend;
|
|
1612
|
+
_getServiceTimes = getServiceTimes(cacheItem), startDate = _getServiceTimes.startDate;
|
|
1613
|
+
if (!(!(extend !== null && extend !== void 0 && extend.start_date) || !(extend !== null && extend !== void 0 && extend.start_time) || !startDate.isValid())) {
|
|
1614
|
+
_context2.next = 6;
|
|
1615
|
+
break;
|
|
1616
|
+
}
|
|
1617
|
+
throw new AvailabilityError('INVALID_TARGET_FILTER', '灵活时长商品缺少有效开始时间');
|
|
1618
|
+
case 6:
|
|
1619
|
+
date = startDate.format('YYYY-MM-DD'); // 带上前一天,覆盖凌晨仍处在前一营业时段内的情况。
|
|
1620
|
+
dateRange = {
|
|
1621
|
+
startDate: startDate.subtract(1, 'day').format('YYYY-MM-DD'),
|
|
1622
|
+
endDate: date
|
|
1623
|
+
};
|
|
1624
|
+
_context2.next = 10;
|
|
1625
|
+
return this.resolveAvailabilityPrepareDefaults({
|
|
1626
|
+
dateRange: dateRange
|
|
1627
|
+
});
|
|
1628
|
+
case 10:
|
|
1629
|
+
prepare = _context2.sent;
|
|
1630
|
+
if (!(((_prepare$_availabilit = prepare._availabilityOperatingHours) === null || _prepare$_availabilit === void 0 ? void 0 : _prepare$_availabilit.source) !== 'open_data_schedule')) {
|
|
1631
|
+
_context2.next = 13;
|
|
1632
|
+
break;
|
|
1633
|
+
}
|
|
1634
|
+
return _context2.abrupt("return", cacheItem);
|
|
1635
|
+
case 13:
|
|
1636
|
+
operatingHours = this.buildAvailabilityOperatingHoursSnapshot({
|
|
1637
|
+
prepare: prepare,
|
|
1638
|
+
dateRange: dateRange,
|
|
1639
|
+
scheduleList: this.getAvailabilityScheduleCatalog(),
|
|
1640
|
+
businessHours: DEFAULT_AVAILABILITY_BUSINESS_HOURS
|
|
1641
|
+
});
|
|
1642
|
+
if (!(operatingHours.missingScheduleIds.length > 0)) {
|
|
1643
|
+
_context2.next = 16;
|
|
1644
|
+
break;
|
|
1645
|
+
}
|
|
1646
|
+
throw new AvailabilityError('OPERATING_HOURS_RESOLVE_FAILED', '店铺营业时间排期缺失,请重试', {
|
|
1647
|
+
missingScheduleIds: operatingHours.missingScheduleIds
|
|
1648
|
+
});
|
|
1649
|
+
case 16:
|
|
1650
|
+
start = localDateTimeToScalar(parseLocalDateTime(startDate.format('YYYY-MM-DDTHH:mm:00')));
|
|
1651
|
+
nextDay = localDateTimeToScalar(parseLocalDateTime("".concat(startDate.add(1, 'day').format('YYYY-MM-DD'), "T00:00:00")));
|
|
1652
|
+
windows = operatingHours.windows.map(function (window) {
|
|
1653
|
+
return {
|
|
1654
|
+
start: localDateTimeToScalar(parseLocalDateTime(window.startAt)),
|
|
1655
|
+
end: localDateTimeToScalar(parseLocalDateTime(window.endAt))
|
|
1656
|
+
};
|
|
1657
|
+
}).filter(function (window) {
|
|
1658
|
+
return window.end > start && window.start < nextDay;
|
|
1659
|
+
}).sort(function (left, right) {
|
|
1660
|
+
return left.start - right.start;
|
|
1661
|
+
});
|
|
1662
|
+
merged = [];
|
|
1663
|
+
_iterator = _createForOfIteratorHelper(windows);
|
|
1664
|
+
try {
|
|
1665
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1666
|
+
window = _step.value;
|
|
1667
|
+
previous = merged[merged.length - 1];
|
|
1668
|
+
if (previous && window.start <= previous.end) {
|
|
1669
|
+
previous.end = Math.max(previous.end, window.end);
|
|
1670
|
+
} else {
|
|
1671
|
+
merged.push(_objectSpread({}, window));
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
// POS 可以提前售票;保留开始分钟,结束取当前或当天下一段营业时间。
|
|
1675
|
+
// 不跨越午休,也不把闭店后的直加顺延到次日。
|
|
1676
|
+
} catch (err) {
|
|
1677
|
+
_iterator.e(err);
|
|
1678
|
+
} finally {
|
|
1679
|
+
_iterator.f();
|
|
1680
|
+
}
|
|
1681
|
+
end = (_merged$ = merged[0]) === null || _merged$ === void 0 ? void 0 : _merged$.end;
|
|
1682
|
+
resourceEndAt = (_getUsableTime = getUsableTime(cacheItem)) === null || _getUsableTime === void 0 || (_getUsableTime = _getUsableTime._extend) === null || _getUsableTime === void 0 || (_getUsableTime = _getUsableTime.usableTime) === null || _getUsableTime === void 0 ? void 0 : _getUsableTime.end_at;
|
|
1683
|
+
if (resourceEndAt) {
|
|
1684
|
+
resourceEnd = localDateTimeToScalar(parseLocalDateTime(dayjs(resourceEndAt).format('YYYY-MM-DDTHH:mm:00')));
|
|
1685
|
+
if (end !== undefined) end = Math.min(end, resourceEnd);
|
|
1686
|
+
}
|
|
1687
|
+
if (!(end === undefined || end <= start)) {
|
|
1688
|
+
_context2.next = 27;
|
|
1689
|
+
break;
|
|
1690
|
+
}
|
|
1691
|
+
throw new AvailabilityError('REVALIDATION_FAILED', '当前时间没有可用营业时段,请选择预约时间');
|
|
1692
|
+
case 27:
|
|
1693
|
+
duration = Math.floor((end - start) / 60000);
|
|
1694
|
+
if (!(duration <= 0)) {
|
|
1695
|
+
_context2.next = 30;
|
|
1696
|
+
break;
|
|
1697
|
+
}
|
|
1698
|
+
throw new AvailabilityError('REVALIDATION_FAILED', '灵活时长商品的结束时间必须晚于开始时间');
|
|
1699
|
+
case 30:
|
|
1700
|
+
endDate = dayjs(formatLocalDateTime(start + duration * 60000));
|
|
1701
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, cacheItem), {}, {
|
|
1702
|
+
_extend: _objectSpread(_objectSpread({}, extend), {}, {
|
|
1703
|
+
duration: flexibleObj.create(duration),
|
|
1704
|
+
endDate: endDate,
|
|
1705
|
+
end_date: endDate.format('YYYY-MM-DD'),
|
|
1706
|
+
end_time: endDate.format('HH:mm')
|
|
1707
|
+
})
|
|
1708
|
+
}));
|
|
1709
|
+
case 32:
|
|
1710
|
+
case "end":
|
|
1711
|
+
return _context2.stop();
|
|
1712
|
+
}
|
|
1713
|
+
}, _callee2, this);
|
|
1714
|
+
}));
|
|
1715
|
+
function prepareDirectAddFlexibleBooking(_x2) {
|
|
1716
|
+
return _prepareDirectAddFlexibleBooking.apply(this, arguments);
|
|
1717
|
+
}
|
|
1718
|
+
return prepareDirectAddFlexibleBooking;
|
|
1719
|
+
}())
|
|
1458
1720
|
}, {
|
|
1459
1721
|
key: "resolveAvailabilityPrepareDefaults",
|
|
1460
1722
|
value: function () {
|
|
1461
|
-
var _resolveAvailabilityPrepareDefaults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1462
|
-
var
|
|
1723
|
+
var _resolveAvailabilityPrepareDefaults = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
1724
|
+
var _ref30, _this$otherParams$bus, _this$otherParams6, _this$otherParams7, _this$otherParams$cha2, _this$otherParams8, _this$otherParams9, _openData, _openData2, _openData3;
|
|
1463
1725
|
var needsOperatingHours, needsTimeSlice, businessCode, channel, currentTarget, openData, operatingScheduleIds, configuredTimeSlice;
|
|
1464
|
-
return _regeneratorRuntime().wrap(function
|
|
1465
|
-
while (1) switch (
|
|
1726
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
1727
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
1466
1728
|
case 0:
|
|
1467
1729
|
needsOperatingHours = params.businessHours === undefined;
|
|
1468
1730
|
needsTimeSlice = params.slotStepMinutes === undefined;
|
|
1469
1731
|
if (!(!needsOperatingHours && !needsTimeSlice)) {
|
|
1470
|
-
|
|
1732
|
+
_context3.next = 4;
|
|
1471
1733
|
break;
|
|
1472
1734
|
}
|
|
1473
|
-
return
|
|
1735
|
+
return _context3.abrupt("return", _objectSpread(_objectSpread({}, params), {}, {
|
|
1474
1736
|
_availabilityOperatingHours: {
|
|
1475
1737
|
source: 'prepare_business_hours',
|
|
1476
1738
|
scheduleIds: []
|
|
1477
1739
|
}
|
|
1478
1740
|
}));
|
|
1479
1741
|
case 4:
|
|
1480
|
-
businessCode = String((
|
|
1481
|
-
channel = String((_this$otherParams$
|
|
1742
|
+
businessCode = String((_ref30 = (_this$otherParams$bus = (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code) !== null && _ref30 !== void 0 ? _ref30 : '').trim();
|
|
1743
|
+
channel = String((_this$otherParams$cha2 = (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel) !== null && _this$otherParams$cha2 !== void 0 ? _this$otherParams$cha2 : '').trim();
|
|
1482
1744
|
currentTarget = businessCode && channel ? "".concat(businessCode, "+").concat(channel) : null;
|
|
1483
|
-
openData = !currentTarget || this.openDataTarget === currentTarget ? (_this$
|
|
1745
|
+
openData = (!currentTarget || this.openDataTarget === currentTarget) && (this.runtimeOpenDataScope === null || this.runtimeOpenDataScope === this.getRuntimeOpenDataScope()) ? (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.openData : null;
|
|
1484
1746
|
if (!(!openData && this.store.openData)) {
|
|
1485
|
-
|
|
1747
|
+
_context3.next = 20;
|
|
1486
1748
|
break;
|
|
1487
1749
|
}
|
|
1488
|
-
|
|
1489
|
-
|
|
1750
|
+
_context3.prev = 9;
|
|
1751
|
+
_context3.next = 12;
|
|
1490
1752
|
return this.getOpenData();
|
|
1491
1753
|
case 12:
|
|
1492
|
-
openData =
|
|
1493
|
-
|
|
1754
|
+
openData = _context3.sent;
|
|
1755
|
+
_context3.next = 20;
|
|
1494
1756
|
break;
|
|
1495
1757
|
case 15:
|
|
1496
|
-
|
|
1497
|
-
|
|
1758
|
+
_context3.prev = 15;
|
|
1759
|
+
_context3.t0 = _context3["catch"](9);
|
|
1498
1760
|
if (!needsOperatingHours) {
|
|
1499
|
-
|
|
1761
|
+
_context3.next = 19;
|
|
1500
1762
|
break;
|
|
1501
1763
|
}
|
|
1502
1764
|
throw this.createAvailabilityFacadeError('OPERATING_HOURS_RESOLVE_FAILED', '无法读取店铺营业时间配置,请重试', {
|
|
1503
1765
|
businessCode: businessCode,
|
|
1504
1766
|
channel: channel,
|
|
1505
|
-
cause:
|
|
1767
|
+
cause: _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0)
|
|
1506
1768
|
});
|
|
1507
1769
|
case 19:
|
|
1508
|
-
console.warn('[UnifiedBookingSales] OpenData 时间切片配置加载失败,回退为默认值',
|
|
1770
|
+
console.warn('[UnifiedBookingSales] OpenData 时间切片配置加载失败,回退为默认值', _context3.t0);
|
|
1509
1771
|
case 20:
|
|
1510
1772
|
operatingScheduleIds = this.normalizeAvailabilityIdList(Array.isArray((_openData = openData) === null || _openData === void 0 ? void 0 : _openData['availability.operating_hours']) ? (_openData2 = openData) === null || _openData2 === void 0 ? void 0 : _openData2['availability.operating_hours'] : undefined) || [];
|
|
1511
1773
|
configuredTimeSlice = needsTimeSlice ? normalizePositiveInteger((_openData3 = openData) === null || _openData3 === void 0 ? void 0 : _openData3['reservation.time_slice']) : undefined;
|
|
1512
|
-
return
|
|
1774
|
+
return _context3.abrupt("return", _objectSpread(_objectSpread(_objectSpread({}, params), configuredTimeSlice ? {
|
|
1513
1775
|
slotStepMinutes: configuredTimeSlice
|
|
1514
1776
|
} : {}), {}, {
|
|
1515
1777
|
_availabilityOperatingHours: needsOperatingHours ? {
|
|
@@ -1522,11 +1784,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1522
1784
|
}));
|
|
1523
1785
|
case 23:
|
|
1524
1786
|
case "end":
|
|
1525
|
-
return
|
|
1787
|
+
return _context3.stop();
|
|
1526
1788
|
}
|
|
1527
|
-
},
|
|
1789
|
+
}, _callee3, this, [[9, 15]]);
|
|
1528
1790
|
}));
|
|
1529
|
-
function resolveAvailabilityPrepareDefaults(
|
|
1791
|
+
function resolveAvailabilityPrepareDefaults(_x3) {
|
|
1530
1792
|
return _resolveAvailabilityPrepareDefaults.apply(this, arguments);
|
|
1531
1793
|
}
|
|
1532
1794
|
return resolveAvailabilityPrepareDefaults;
|
|
@@ -1569,52 +1831,57 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1569
1831
|
}, {
|
|
1570
1832
|
key: "setOtherParams",
|
|
1571
1833
|
value: function () {
|
|
1572
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1573
|
-
var _this$
|
|
1574
|
-
var
|
|
1575
|
-
|
|
1834
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
1835
|
+
var _this$otherParams10, _this$otherParams12;
|
|
1836
|
+
var _ref31,
|
|
1837
|
+
_ref31$cover,
|
|
1576
1838
|
cover,
|
|
1577
1839
|
previousScope,
|
|
1578
1840
|
previousItemRuleConfig,
|
|
1579
1841
|
explicitlySetsOpenData,
|
|
1842
|
+
nextParams,
|
|
1580
1843
|
nextScope,
|
|
1581
|
-
_this$
|
|
1844
|
+
_this$otherParams11,
|
|
1582
1845
|
shouldResetAvailabilityState,
|
|
1583
|
-
|
|
1584
|
-
return _regeneratorRuntime().wrap(function
|
|
1585
|
-
while (1) switch (
|
|
1846
|
+
_args4 = arguments;
|
|
1847
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
1848
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
1586
1849
|
case 0:
|
|
1587
|
-
|
|
1850
|
+
_ref31 = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
|
|
1588
1851
|
previousScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
|
|
1589
|
-
previousItemRuleConfig = (_this$
|
|
1852
|
+
previousItemRuleConfig = (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.itemRule;
|
|
1590
1853
|
explicitlySetsOpenData = Object.prototype.hasOwnProperty.call(params, 'openData');
|
|
1591
|
-
|
|
1854
|
+
nextParams = cover ? params : _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
1855
|
+
if (explicitlySetsOpenData || this.getRuntimeOpenDataScope() !== this.getRuntimeOpenDataScope(nextParams)) {
|
|
1856
|
+
this.clearOpenDataCache();
|
|
1857
|
+
}
|
|
1858
|
+
_context4.next = 8;
|
|
1592
1859
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "setOtherParams", this).call(this, params, {
|
|
1593
1860
|
cover: cover
|
|
1594
1861
|
});
|
|
1595
|
-
case
|
|
1862
|
+
case 8:
|
|
1596
1863
|
nextScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
|
|
1597
1864
|
if (explicitlySetsOpenData) {
|
|
1598
|
-
this.openDataTarget = (_this$
|
|
1865
|
+
this.openDataTarget = (_this$otherParams11 = this.otherParams) !== null && _this$otherParams11 !== void 0 && _this$otherParams11.openData && nextScope.businessCode && nextScope.channel ? "".concat(nextScope.businessCode, "+").concat(nextScope.channel) : null;
|
|
1599
1866
|
}
|
|
1600
1867
|
shouldResetAvailabilityState = previousScope.cacheId !== nextScope.cacheId || previousScope.businessCode !== nextScope.businessCode || previousScope.channel !== nextScope.channel || previousScope.platform !== nextScope.platform || previousScope.businessTimezone !== nextScope.businessTimezone;
|
|
1601
1868
|
if (!shouldResetAvailabilityState) {
|
|
1602
|
-
|
|
1869
|
+
_context4.next = 14;
|
|
1603
1870
|
break;
|
|
1604
1871
|
}
|
|
1605
|
-
|
|
1872
|
+
_context4.next = 14;
|
|
1606
1873
|
return this.resetAvailabilityProjectionState('set_other_params_reset');
|
|
1607
|
-
case
|
|
1608
|
-
if (shouldResetAvailabilityState || explicitlySetsOpenData || previousItemRuleConfig !== ((_this$
|
|
1874
|
+
case 14:
|
|
1875
|
+
if (shouldResetAvailabilityState || explicitlySetsOpenData || previousItemRuleConfig !== ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.itemRule)) {
|
|
1609
1876
|
this.resetAllergyItemRuleState();
|
|
1610
1877
|
}
|
|
1611
|
-
case
|
|
1878
|
+
case 15:
|
|
1612
1879
|
case "end":
|
|
1613
|
-
return
|
|
1880
|
+
return _context4.stop();
|
|
1614
1881
|
}
|
|
1615
|
-
},
|
|
1882
|
+
}, _callee4, this);
|
|
1616
1883
|
}));
|
|
1617
|
-
function setOtherParams(
|
|
1884
|
+
function setOtherParams(_x4) {
|
|
1618
1885
|
return _setOtherParams.apply(this, arguments);
|
|
1619
1886
|
}
|
|
1620
1887
|
return setOtherParams;
|
|
@@ -1622,23 +1889,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1622
1889
|
}, {
|
|
1623
1890
|
key: "destroy",
|
|
1624
1891
|
value: function () {
|
|
1625
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1626
|
-
return _regeneratorRuntime().wrap(function
|
|
1627
|
-
while (1) switch (
|
|
1892
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
1893
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
1894
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
1628
1895
|
case 0:
|
|
1896
|
+
this.runtimeOpenDataDestroyed = true;
|
|
1897
|
+
this.clearOpenDataCache();
|
|
1629
1898
|
this.availabilityScheduleCatalog = null;
|
|
1630
1899
|
this.availabilityRuntimeOffsetMinutes = null;
|
|
1631
|
-
|
|
1900
|
+
_context5.next = 6;
|
|
1632
1901
|
return this.resetAvailabilityProjectionState('destroy');
|
|
1633
|
-
case
|
|
1902
|
+
case 6:
|
|
1634
1903
|
this.resetAllergyItemRuleState();
|
|
1635
|
-
|
|
1904
|
+
_context5.next = 9;
|
|
1636
1905
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "destroy", this).call(this);
|
|
1637
|
-
case
|
|
1906
|
+
case 9:
|
|
1638
1907
|
case "end":
|
|
1639
|
-
return
|
|
1908
|
+
return _context5.stop();
|
|
1640
1909
|
}
|
|
1641
|
-
},
|
|
1910
|
+
}, _callee5, this);
|
|
1642
1911
|
}));
|
|
1643
1912
|
function destroy() {
|
|
1644
1913
|
return _destroy.apply(this, arguments);
|
|
@@ -1702,30 +1971,37 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1702
1971
|
}, {
|
|
1703
1972
|
key: "createAvailabilityContextRef",
|
|
1704
1973
|
value: function createAvailabilityContextRef(context) {
|
|
1705
|
-
|
|
1974
|
+
var _this$getActiveAvaila;
|
|
1975
|
+
var projection = (_this$getActiveAvaila = this.getActiveAvailabilityProjectionEntry(context)) === null || _this$getActiveAvaila === void 0 ? void 0 : _this$getActiveAvaila.projection;
|
|
1976
|
+
return _objectSpread({
|
|
1706
1977
|
contextId: context.contextId
|
|
1707
|
-
}
|
|
1978
|
+
}, projection && this.usesDurationTimeGrid(projection) ? {
|
|
1979
|
+
durationTimeSelection: {
|
|
1980
|
+
version: 1,
|
|
1981
|
+
currentBusinessDate: this.getCurrentAvailabilityBusinessDate(projection)
|
|
1982
|
+
}
|
|
1983
|
+
} : {});
|
|
1708
1984
|
}
|
|
1709
1985
|
}, {
|
|
1710
1986
|
key: "emitAvailabilityDiagnostic",
|
|
1711
1987
|
value: function () {
|
|
1712
|
-
var _emitAvailabilityDiagnostic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1988
|
+
var _emitAvailabilityDiagnostic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(payload) {
|
|
1713
1989
|
var _this$core, _this$core$emit;
|
|
1714
|
-
return _regeneratorRuntime().wrap(function
|
|
1715
|
-
while (1) switch (
|
|
1990
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
1991
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
1716
1992
|
case 0:
|
|
1717
|
-
|
|
1993
|
+
_context6.next = 2;
|
|
1718
1994
|
return (_this$core = this.core) === null || _this$core === void 0 || (_this$core = _this$core.effects) === null || _this$core === void 0 || (_this$core$emit = _this$core.emit) === null || _this$core$emit === void 0 ? void 0 : _this$core$emit.call(_this$core, "".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionDiagnostic), _objectSpread(_objectSpread({}, payload), {}, {
|
|
1719
1995
|
registrySize: this.availabilityContextRegistry.size,
|
|
1720
1996
|
projectionPoolSize: this.availabilityProjectionPool.size
|
|
1721
1997
|
}));
|
|
1722
1998
|
case 2:
|
|
1723
1999
|
case "end":
|
|
1724
|
-
return
|
|
2000
|
+
return _context6.stop();
|
|
1725
2001
|
}
|
|
1726
|
-
},
|
|
2002
|
+
}, _callee6, this);
|
|
1727
2003
|
}));
|
|
1728
|
-
function emitAvailabilityDiagnostic(
|
|
2004
|
+
function emitAvailabilityDiagnostic(_x5) {
|
|
1729
2005
|
return _emitAvailabilityDiagnostic.apply(this, arguments);
|
|
1730
2006
|
}
|
|
1731
2007
|
return emitAvailabilityDiagnostic;
|
|
@@ -1789,7 +2065,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1789
2065
|
}, {
|
|
1790
2066
|
key: "invalidateAvailabilityContextsAfterCommit",
|
|
1791
2067
|
value: function invalidateAvailabilityContextsAfterCommit() {
|
|
1792
|
-
var
|
|
2068
|
+
var _this4 = this;
|
|
1793
2069
|
this.availabilityLifecycleGeneration += 1;
|
|
1794
2070
|
var nextOrderRevision = this.getCurrentOrderRevision();
|
|
1795
2071
|
this.availabilityProjectionPool.clear();
|
|
@@ -1800,15 +2076,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1800
2076
|
context.activeProjectionKey = null;
|
|
1801
2077
|
context.lastKnownOrderRevision = nextOrderRevision;
|
|
1802
2078
|
context.refreshNonce += 1;
|
|
1803
|
-
context.lifecycleGeneration =
|
|
2079
|
+
context.lifecycleGeneration = _this4.availabilityLifecycleGeneration;
|
|
1804
2080
|
});
|
|
1805
2081
|
}
|
|
1806
2082
|
}, {
|
|
1807
2083
|
key: "resetAvailabilityProjectionState",
|
|
1808
2084
|
value: function () {
|
|
1809
|
-
var _resetAvailabilityProjectionState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1810
|
-
return _regeneratorRuntime().wrap(function
|
|
1811
|
-
while (1) switch (
|
|
2085
|
+
var _resetAvailabilityProjectionState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(action) {
|
|
2086
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
2087
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
1812
2088
|
case 0:
|
|
1813
2089
|
this.availabilityLifecycleGeneration += 1;
|
|
1814
2090
|
this.availabilityContextRegistry.clear();
|
|
@@ -1817,7 +2093,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1817
2093
|
this.availabilityProjectionRefreshInFlight.clear();
|
|
1818
2094
|
this.availabilityCommitLocks.clear();
|
|
1819
2095
|
this.clearAvailabilityRemoteResourceState();
|
|
1820
|
-
|
|
2096
|
+
_context7.next = 9;
|
|
1821
2097
|
return this.emitAvailabilityDiagnostic({
|
|
1822
2098
|
action: action,
|
|
1823
2099
|
contextId: null,
|
|
@@ -1827,11 +2103,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1827
2103
|
});
|
|
1828
2104
|
case 9:
|
|
1829
2105
|
case "end":
|
|
1830
|
-
return
|
|
2106
|
+
return _context7.stop();
|
|
1831
2107
|
}
|
|
1832
|
-
},
|
|
2108
|
+
}, _callee7, this);
|
|
1833
2109
|
}));
|
|
1834
|
-
function resetAvailabilityProjectionState(
|
|
2110
|
+
function resetAvailabilityProjectionState(_x6) {
|
|
1835
2111
|
return _resetAvailabilityProjectionState.apply(this, arguments);
|
|
1836
2112
|
}
|
|
1837
2113
|
return resetAvailabilityProjectionState;
|
|
@@ -1839,8 +2115,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1839
2115
|
}, {
|
|
1840
2116
|
key: "isSessionStoragePersistEnabled",
|
|
1841
2117
|
value: function isSessionStoragePersistEnabled() {
|
|
1842
|
-
var _this$
|
|
1843
|
-
return Boolean(this.cacheId && ((_this$
|
|
2118
|
+
var _this$otherParams13;
|
|
2119
|
+
return Boolean(this.cacheId && ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.enableSessionStoragePersist) === true);
|
|
1844
2120
|
}
|
|
1845
2121
|
}, {
|
|
1846
2122
|
key: "shouldUseSessionStorageForSubModule",
|
|
@@ -1902,10 +2178,105 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1902
2178
|
(_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$cle = _this$store$order.clearSessionStoragePersistedTempOrder) === null || _this$store$order$cle === void 0 || _this$store$order$cle.call(_this$store$order);
|
|
1903
2179
|
}
|
|
1904
2180
|
|
|
2181
|
+
/** 在 Kiosk 拉起支付设备前补齐订单号,同一订单重试复用已分配的号码。 */
|
|
2182
|
+
}, {
|
|
2183
|
+
key: "ensureLocalOrderNumbersForCheckout",
|
|
2184
|
+
value: (function () {
|
|
2185
|
+
var _ensureLocalOrderNumbersForCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
2186
|
+
var _this$otherParams14, _this$appPlugin, _this$appPlugin$getAp, _this$appPlugin$getAp2;
|
|
2187
|
+
var order, tempOrder, biz, idGenerator;
|
|
2188
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
2189
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
2190
|
+
case 0:
|
|
2191
|
+
if (!(normalizeRuntimePlatform((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.platform) !== 'kiosk')) {
|
|
2192
|
+
_context8.next = 2;
|
|
2193
|
+
break;
|
|
2194
|
+
}
|
|
2195
|
+
return _context8.abrupt("return");
|
|
2196
|
+
case 2:
|
|
2197
|
+
order = this.store.order;
|
|
2198
|
+
tempOrder = order === null || order === void 0 ? void 0 : order.getTempOrder();
|
|
2199
|
+
if (tempOrder) {
|
|
2200
|
+
_context8.next = 6;
|
|
2201
|
+
break;
|
|
2202
|
+
}
|
|
2203
|
+
throw new Error('当前订单不存在,无法生成订单编号');
|
|
2204
|
+
case 6:
|
|
2205
|
+
if (!(tempOrder.shop_order_number && tempOrder.shop_full_order_number)) {
|
|
2206
|
+
_context8.next = 8;
|
|
2207
|
+
break;
|
|
2208
|
+
}
|
|
2209
|
+
return _context8.abrupt("return");
|
|
2210
|
+
case 8:
|
|
2211
|
+
biz = this.getBookingTicketBusinessCode();
|
|
2212
|
+
if (biz) {
|
|
2213
|
+
_context8.next = 11;
|
|
2214
|
+
break;
|
|
2215
|
+
}
|
|
2216
|
+
throw new Error('当前订单缺少业务类型,无法生成订单编号');
|
|
2217
|
+
case 11:
|
|
2218
|
+
idGenerator = (_this$appPlugin = this.appPlugin) === null || _this$appPlugin === void 0 || (_this$appPlugin$getAp = _this$appPlugin.getApp) === null || _this$appPlugin$getAp === void 0 || (_this$appPlugin$getAp = _this$appPlugin$getAp.call(_this$appPlugin)) === null || _this$appPlugin$getAp === void 0 || (_this$appPlugin$getAp2 = _this$appPlugin$getAp.getPlugin) === null || _this$appPlugin$getAp2 === void 0 ? void 0 : _this$appPlugin$getAp2.call(_this$appPlugin$getAp, 'idGenerator');
|
|
2219
|
+
if (!(!tempOrder.shop_order_number && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateShopOrderNumber) !== 'function' || !tempOrder.shop_full_order_number && typeof (idGenerator === null || idGenerator === void 0 ? void 0 : idGenerator.generateReceiptId) !== 'function')) {
|
|
2220
|
+
_context8.next = 14;
|
|
2221
|
+
break;
|
|
2222
|
+
}
|
|
2223
|
+
throw new Error('订单编号生成器不可用,请重启应用后重试');
|
|
2224
|
+
case 14:
|
|
2225
|
+
_context8.prev = 14;
|
|
2226
|
+
if (tempOrder.shop_order_number) {
|
|
2227
|
+
_context8.next = 19;
|
|
2228
|
+
break;
|
|
2229
|
+
}
|
|
2230
|
+
_context8.next = 18;
|
|
2231
|
+
return idGenerator.generateShopOrderNumber({
|
|
2232
|
+
biz: biz
|
|
2233
|
+
});
|
|
2234
|
+
case 18:
|
|
2235
|
+
tempOrder.shop_order_number = _context8.sent;
|
|
2236
|
+
case 19:
|
|
2237
|
+
if (tempOrder.shop_full_order_number) {
|
|
2238
|
+
_context8.next = 23;
|
|
2239
|
+
break;
|
|
2240
|
+
}
|
|
2241
|
+
_context8.next = 22;
|
|
2242
|
+
return idGenerator.generateReceiptId({
|
|
2243
|
+
biz: biz
|
|
2244
|
+
});
|
|
2245
|
+
case 22:
|
|
2246
|
+
tempOrder.shop_full_order_number = _context8.sent;
|
|
2247
|
+
case 23:
|
|
2248
|
+
if (!(order.getTempOrder() !== tempOrder)) {
|
|
2249
|
+
_context8.next = 25;
|
|
2250
|
+
break;
|
|
2251
|
+
}
|
|
2252
|
+
throw new Error('当前订单已切换,请重新发起支付');
|
|
2253
|
+
case 25:
|
|
2254
|
+
if (!(!tempOrder.shop_order_number || !tempOrder.shop_full_order_number)) {
|
|
2255
|
+
_context8.next = 27;
|
|
2256
|
+
break;
|
|
2257
|
+
}
|
|
2258
|
+
throw new Error('订单编号生成失败,请重试');
|
|
2259
|
+
case 27:
|
|
2260
|
+
_context8.prev = 27;
|
|
2261
|
+
// 部分生成成功时也保留号码,后续只补仍然缺失的字段。
|
|
2262
|
+
if (order.getTempOrder() === tempOrder) order.persistTempOrder();
|
|
2263
|
+
return _context8.finish(27);
|
|
2264
|
+
case 30:
|
|
2265
|
+
case "end":
|
|
2266
|
+
return _context8.stop();
|
|
2267
|
+
}
|
|
2268
|
+
}, _callee8, this, [[14,, 27, 30]]);
|
|
2269
|
+
}));
|
|
2270
|
+
function ensureLocalOrderNumbersForCheckout() {
|
|
2271
|
+
return _ensureLocalOrderNumbersForCheckout.apply(this, arguments);
|
|
2272
|
+
}
|
|
2273
|
+
return ensureLocalOrderNumbersForCheckout;
|
|
2274
|
+
}()
|
|
1905
2275
|
/**
|
|
1906
2276
|
* PC/H5/Kiosk 结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
|
|
1907
2277
|
* 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
|
|
1908
2278
|
*/
|
|
2279
|
+
)
|
|
1909
2280
|
}, {
|
|
1910
2281
|
key: "shouldUseCheckoutSyncTask",
|
|
1911
2282
|
value: function shouldUseCheckoutSyncTask() {
|
|
@@ -1938,77 +2309,77 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1938
2309
|
}, {
|
|
1939
2310
|
key: "addNewOrder",
|
|
1940
2311
|
value: function () {
|
|
1941
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2312
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1942
2313
|
var _this$store$order2, _this$store$order2$co, _this$store$order4;
|
|
1943
2314
|
var sessionRecord, tempOrder, _this$store$order3, didSyncAuthenticatedCustomer;
|
|
1944
|
-
return _regeneratorRuntime().wrap(function
|
|
1945
|
-
while (1) switch (
|
|
2315
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
2316
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1946
2317
|
case 0:
|
|
1947
2318
|
sessionRecord = this.isSessionStoragePersistEnabled() ? (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$co = _this$store$order2.consumeSessionStorageRestore) === null || _this$store$order2$co === void 0 ? void 0 : _this$store$order2$co.call(_this$store$order2) : null;
|
|
1948
2319
|
if (!sessionRecord) {
|
|
1949
|
-
|
|
2320
|
+
_context9.next = 4;
|
|
1950
2321
|
break;
|
|
1951
2322
|
}
|
|
1952
|
-
|
|
2323
|
+
_context9.next = 4;
|
|
1953
2324
|
return this.loadSalesDetail({
|
|
1954
2325
|
preloadedSalesDetail: sessionRecord,
|
|
1955
2326
|
hydrateSource: 'sessionStorage'
|
|
1956
2327
|
});
|
|
1957
2328
|
case 4:
|
|
1958
|
-
|
|
2329
|
+
_context9.next = 6;
|
|
1959
2330
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "addNewOrder", this).call(this);
|
|
1960
2331
|
case 6:
|
|
1961
|
-
tempOrder =
|
|
2332
|
+
tempOrder = _context9.sent;
|
|
1962
2333
|
if (sessionRecord) {
|
|
1963
2334
|
(_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || _this$store$order3.persistTempOrder();
|
|
1964
2335
|
}
|
|
1965
2336
|
if (!this.isAuthenticatedCustomerUserPlatform()) {
|
|
1966
|
-
|
|
2337
|
+
_context9.next = 23;
|
|
1967
2338
|
break;
|
|
1968
2339
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
2340
|
+
_context9.prev = 9;
|
|
2341
|
+
_context9.next = 12;
|
|
1971
2342
|
return this.syncAuthenticatedOrderCustomer();
|
|
1972
2343
|
case 12:
|
|
1973
|
-
didSyncAuthenticatedCustomer =
|
|
2344
|
+
didSyncAuthenticatedCustomer = _context9.sent;
|
|
1974
2345
|
if (!(!didSyncAuthenticatedCustomer && sessionRecord)) {
|
|
1975
|
-
|
|
2346
|
+
_context9.next = 16;
|
|
1976
2347
|
break;
|
|
1977
2348
|
}
|
|
1978
|
-
|
|
2349
|
+
_context9.next = 16;
|
|
1979
2350
|
return this.refreshLegacySessionCustomerDiscounts(tempOrder);
|
|
1980
2351
|
case 16:
|
|
1981
|
-
|
|
2352
|
+
_context9.next = 21;
|
|
1982
2353
|
break;
|
|
1983
2354
|
case 18:
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
console.warn('[UnifiedBookingSales] Failed to sync authenticated order customer after addNewOrder',
|
|
2355
|
+
_context9.prev = 18;
|
|
2356
|
+
_context9.t0 = _context9["catch"](9);
|
|
2357
|
+
console.warn('[UnifiedBookingSales] Failed to sync authenticated order customer after addNewOrder', _context9.t0);
|
|
1987
2358
|
case 21:
|
|
1988
|
-
|
|
2359
|
+
_context9.next = 32;
|
|
1989
2360
|
break;
|
|
1990
2361
|
case 23:
|
|
1991
2362
|
if (!sessionRecord) {
|
|
1992
|
-
|
|
2363
|
+
_context9.next = 32;
|
|
1993
2364
|
break;
|
|
1994
2365
|
}
|
|
1995
|
-
|
|
1996
|
-
|
|
2366
|
+
_context9.prev = 24;
|
|
2367
|
+
_context9.next = 27;
|
|
1997
2368
|
return this.refreshLegacySessionCustomerDiscounts(tempOrder);
|
|
1998
2369
|
case 27:
|
|
1999
|
-
|
|
2370
|
+
_context9.next = 32;
|
|
2000
2371
|
break;
|
|
2001
2372
|
case 29:
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
console.warn('[UnifiedBookingSales] Failed to refresh cached customer discounts after addNewOrder',
|
|
2373
|
+
_context9.prev = 29;
|
|
2374
|
+
_context9.t1 = _context9["catch"](24);
|
|
2375
|
+
console.warn('[UnifiedBookingSales] Failed to refresh cached customer discounts after addNewOrder', _context9.t1);
|
|
2005
2376
|
case 32:
|
|
2006
|
-
return
|
|
2377
|
+
return _context9.abrupt("return", ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder()) || tempOrder);
|
|
2007
2378
|
case 33:
|
|
2008
2379
|
case "end":
|
|
2009
|
-
return
|
|
2380
|
+
return _context9.stop();
|
|
2010
2381
|
}
|
|
2011
|
-
},
|
|
2382
|
+
}, _callee9, this, [[9, 18], [24, 29]]);
|
|
2012
2383
|
}));
|
|
2013
2384
|
function addNewOrder() {
|
|
2014
2385
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -2018,46 +2389,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2018
2389
|
}, {
|
|
2019
2390
|
key: "syncAuthenticatedOrderCustomer",
|
|
2020
2391
|
value: function () {
|
|
2021
|
-
var _syncAuthenticatedOrderCustomer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2392
|
+
var _syncAuthenticatedOrderCustomer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
2022
2393
|
var _this$core2, _this$core2$getPlugin, _this$core2$getPlugin2, _this$store$customer, _this$store$customer$;
|
|
2023
2394
|
var authenticatedCustomer, authenticatedCustomerId, tempOrder, cachedCustomerId;
|
|
2024
|
-
return _regeneratorRuntime().wrap(function
|
|
2025
|
-
while (1) switch (
|
|
2395
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
2396
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
2026
2397
|
case 0:
|
|
2027
2398
|
if (this.isAuthenticatedCustomerUserPlatform()) {
|
|
2028
|
-
|
|
2399
|
+
_context10.next = 2;
|
|
2029
2400
|
break;
|
|
2030
2401
|
}
|
|
2031
|
-
return
|
|
2402
|
+
return _context10.abrupt("return", false);
|
|
2032
2403
|
case 2:
|
|
2033
2404
|
authenticatedCustomer = (_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2$getPlugin = _this$core2.getPlugin) === null || _this$core2$getPlugin === void 0 || (_this$core2$getPlugin = _this$core2$getPlugin.call(_this$core2, 'user')) === null || _this$core2$getPlugin === void 0 || (_this$core2$getPlugin2 = _this$core2$getPlugin.get) === null || _this$core2$getPlugin2 === void 0 ? void 0 : _this$core2$getPlugin2.call(_this$core2$getPlugin);
|
|
2034
2405
|
authenticatedCustomerId = toCustomerId(authenticatedCustomer === null || authenticatedCustomer === void 0 ? void 0 : authenticatedCustomer.id);
|
|
2035
2406
|
if (authenticatedCustomerId) {
|
|
2036
|
-
|
|
2407
|
+
_context10.next = 6;
|
|
2037
2408
|
break;
|
|
2038
2409
|
}
|
|
2039
|
-
return
|
|
2410
|
+
return _context10.abrupt("return", false);
|
|
2040
2411
|
case 6:
|
|
2041
2412
|
tempOrder = this.getTempOrder();
|
|
2042
2413
|
cachedCustomerId = resolveTempOrderCustomerId(tempOrder);
|
|
2043
2414
|
if (!(cachedCustomerId !== null && cachedCustomerId !== authenticatedCustomerId)) {
|
|
2044
|
-
|
|
2415
|
+
_context10.next = 11;
|
|
2045
2416
|
break;
|
|
2046
2417
|
}
|
|
2047
|
-
|
|
2418
|
+
_context10.next = 11;
|
|
2048
2419
|
return this.resetCachedCustomerDiscountState();
|
|
2049
2420
|
case 11:
|
|
2050
2421
|
(_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || (_this$store$customer$ = _this$store$customer.setSelectedCustomer) === null || _this$store$customer$ === void 0 || _this$store$customer$.call(_this$store$customer, authenticatedCustomer);
|
|
2051
2422
|
this.setOrderCustomer(authenticatedCustomer);
|
|
2052
|
-
|
|
2423
|
+
_context10.next = 15;
|
|
2053
2424
|
return Promise.all([this.refreshDiscountConfigAfterOrderCustomerChange(authenticatedCustomerId), this.waitForOrderCustomerPromotionRefresh()]);
|
|
2054
2425
|
case 15:
|
|
2055
|
-
return
|
|
2426
|
+
return _context10.abrupt("return", true);
|
|
2056
2427
|
case 16:
|
|
2057
2428
|
case "end":
|
|
2058
|
-
return
|
|
2429
|
+
return _context10.stop();
|
|
2059
2430
|
}
|
|
2060
|
-
},
|
|
2431
|
+
}, _callee10, this);
|
|
2061
2432
|
}));
|
|
2062
2433
|
function syncAuthenticatedOrderCustomer() {
|
|
2063
2434
|
return _syncAuthenticatedOrderCustomer.apply(this, arguments);
|
|
@@ -2085,11 +2456,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2085
2456
|
}, {
|
|
2086
2457
|
key: "resetCachedCustomerDiscountState",
|
|
2087
2458
|
value: function () {
|
|
2088
|
-
var _resetCachedCustomerDiscountState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2459
|
+
var _resetCachedCustomerDiscountState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
2089
2460
|
var _this$store$order6, _this$store$order6$cl, _this$store$customer2, _this$store$customer3, _this$store$order7, _discountModule$getOr, _discountModule$getDi, _discountModule$setOr, _discountModule$setDi, _this$store$order8, _this$store$order8$ap, _this$store$order9, _this$store$order9$re, _this$store$order10, _this$store$order10$p;
|
|
2090
2461
|
var orderStore, discountModule, filteredOriginalDiscounts, filteredCurrentDiscounts;
|
|
2091
|
-
return _regeneratorRuntime().wrap(function
|
|
2092
|
-
while (1) switch (
|
|
2462
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2463
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
2093
2464
|
case 0:
|
|
2094
2465
|
(_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$cl = _this$store$order6.clearOrderCustomer) === null || _this$store$order6$cl === void 0 || _this$store$order6$cl.call(_this$store$order6);
|
|
2095
2466
|
(_this$store$customer2 = this.store.customer) === null || _this$store$customer2 === void 0 || (_this$store$customer3 = _this$store$customer2.setSelectedCustomer) === null || _this$store$customer3 === void 0 || _this$store$customer3.call(_this$store$customer2, null);
|
|
@@ -2099,14 +2470,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2099
2470
|
discountModule = orderStore.discount;
|
|
2100
2471
|
filteredOriginalDiscounts = filterCustomerBoundDiscounts((discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || []);
|
|
2101
2472
|
filteredCurrentDiscounts = filterCustomerBoundDiscounts((discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || []);
|
|
2102
|
-
|
|
2473
|
+
_context11.next = 10;
|
|
2103
2474
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, filteredOriginalDiscounts);
|
|
2104
2475
|
case 10:
|
|
2105
|
-
|
|
2476
|
+
_context11.next = 12;
|
|
2106
2477
|
return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, filteredCurrentDiscounts);
|
|
2107
2478
|
case 12:
|
|
2108
2479
|
(_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || (_this$store$order8$ap = _this$store$order8.applyDiscount) === null || _this$store$order8$ap === void 0 || _this$store$order8$ap.call(_this$store$order8);
|
|
2109
|
-
|
|
2480
|
+
_context11.next = 15;
|
|
2110
2481
|
return (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || (_this$store$order9$re = _this$store$order9.recalculateSummary) === null || _this$store$order9$re === void 0 ? void 0 : _this$store$order9$re.call(_this$store$order9, {
|
|
2111
2482
|
createIfMissing: true
|
|
2112
2483
|
});
|
|
@@ -2114,9 +2485,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2114
2485
|
(_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$p = _this$store$order10.persistTempOrder) === null || _this$store$order10$p === void 0 || _this$store$order10$p.call(_this$store$order10);
|
|
2115
2486
|
case 16:
|
|
2116
2487
|
case "end":
|
|
2117
|
-
return
|
|
2488
|
+
return _context11.stop();
|
|
2118
2489
|
}
|
|
2119
|
-
},
|
|
2490
|
+
}, _callee11, this);
|
|
2120
2491
|
}));
|
|
2121
2492
|
function resetCachedCustomerDiscountState() {
|
|
2122
2493
|
return _resetCachedCustomerDiscountState.apply(this, arguments);
|
|
@@ -2126,130 +2497,261 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2126
2497
|
}, {
|
|
2127
2498
|
key: "refreshLegacySessionCustomerDiscounts",
|
|
2128
2499
|
value: function () {
|
|
2129
|
-
var _refreshLegacySessionCustomerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2500
|
+
var _refreshLegacySessionCustomerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(tempOrder) {
|
|
2130
2501
|
var customerId, loadDiscountConfig;
|
|
2131
|
-
return _regeneratorRuntime().wrap(function
|
|
2132
|
-
while (1) switch (
|
|
2502
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2503
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
2133
2504
|
case 0:
|
|
2134
2505
|
customerId = resolveTempOrderCustomerId(tempOrder);
|
|
2135
2506
|
if (customerId) {
|
|
2136
|
-
|
|
2507
|
+
_context12.next = 3;
|
|
2137
2508
|
break;
|
|
2138
2509
|
}
|
|
2139
|
-
return
|
|
2510
|
+
return _context12.abrupt("return", undefined);
|
|
2140
2511
|
case 3:
|
|
2141
2512
|
loadDiscountConfig = _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "loadDiscountConfig", this).bind(this);
|
|
2142
|
-
|
|
2513
|
+
_context12.next = 6;
|
|
2143
2514
|
return loadDiscountConfig({
|
|
2144
2515
|
customerId: customerId,
|
|
2145
2516
|
action: this.resolveDiscountAction(this.resolveDiscountOrderIdentity(tempOrder))
|
|
2146
2517
|
});
|
|
2147
2518
|
case 6:
|
|
2148
|
-
return
|
|
2519
|
+
return _context12.abrupt("return", _context12.sent);
|
|
2149
2520
|
case 7:
|
|
2150
2521
|
case "end":
|
|
2151
|
-
return
|
|
2522
|
+
return _context12.stop();
|
|
2152
2523
|
}
|
|
2153
|
-
},
|
|
2524
|
+
}, _callee12, this);
|
|
2154
2525
|
}));
|
|
2155
|
-
function refreshLegacySessionCustomerDiscounts(
|
|
2526
|
+
function refreshLegacySessionCustomerDiscounts(_x7) {
|
|
2156
2527
|
return _refreshLegacySessionCustomerDiscounts.apply(this, arguments);
|
|
2157
2528
|
}
|
|
2158
2529
|
return refreshLegacySessionCustomerDiscounts;
|
|
2159
2530
|
}()
|
|
2160
|
-
/**
|
|
2161
|
-
* Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
|
|
2162
|
-
* business/channel target so a reused solution instance cannot leak another entry's menus.
|
|
2163
|
-
*/
|
|
2164
2531
|
}, {
|
|
2165
|
-
key: "
|
|
2166
|
-
value:
|
|
2167
|
-
var
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2532
|
+
key: "getRuntimeOpenDataScope",
|
|
2533
|
+
value: function getRuntimeOpenDataScope() {
|
|
2534
|
+
var _ref32, _otherParams$business3;
|
|
2535
|
+
var otherParams = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.otherParams;
|
|
2536
|
+
return JSON.stringify({
|
|
2537
|
+
shop: this.getPickupTimingContextData('shop_id'),
|
|
2538
|
+
appShop: this.appPlugin ? this.getAppData('shop_id') : undefined,
|
|
2539
|
+
tenant: this.appPlugin ? this.getAppData('tenant_id') : undefined,
|
|
2540
|
+
businessCode: String((_ref32 = (_otherParams$business3 = otherParams === null || otherParams === void 0 ? void 0 : otherParams.businessCode) !== null && _otherParams$business3 !== void 0 ? _otherParams$business3 : otherParams === null || otherParams === void 0 ? void 0 : otherParams.business_code) !== null && _ref32 !== void 0 ? _ref32 : '').trim(),
|
|
2541
|
+
channel: String((otherParams === null || otherParams === void 0 ? void 0 : otherParams.channel) || _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "getSubmitOrderSalesChannel", this).call(this)).trim(),
|
|
2542
|
+
platform: normalizeRuntimePlatform(otherParams === null || otherParams === void 0 ? void 0 : otherParams.platform),
|
|
2543
|
+
timezone: this.getPickupTimingContextData('timezone'),
|
|
2544
|
+
businessTimezone: otherParams === null || otherParams === void 0 ? void 0 : otherParams.businessTimezone,
|
|
2545
|
+
cacheId: otherParams === this.otherParams ? this.cacheId : otherParams === null || otherParams === void 0 ? void 0 : otherParams.cacheId
|
|
2546
|
+
});
|
|
2547
|
+
}
|
|
2548
|
+
}, {
|
|
2549
|
+
key: "resetRuntimeOpenData",
|
|
2550
|
+
value: function resetRuntimeOpenData() {
|
|
2551
|
+
var _this$businessAvailab, _this$store$openData, _this$store$openData$;
|
|
2552
|
+
(_this$businessAvailab = this.businessAvailabilityController) === null || _this$businessAvailab === void 0 || _this$businessAvailab.invalidate();
|
|
2553
|
+
this.runtimeOpenDataGeneration += 1;
|
|
2554
|
+
this.runtimeOpenDataScope = null;
|
|
2555
|
+
this.runtimeOpenDataSnapshot = null;
|
|
2556
|
+
this.runtimeOpenDataModule = null;
|
|
2557
|
+
this.runtimeOpenDataCore = undefined;
|
|
2558
|
+
this.openDataTarget = null;
|
|
2559
|
+
this.loadOpenDataInFlight = null;
|
|
2560
|
+
this.loadOpenDataInFlightTarget = null;
|
|
2561
|
+
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), {}, {
|
|
2562
|
+
openData: null
|
|
2563
|
+
});
|
|
2564
|
+
(_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 || (_this$store$openData$ = _this$store$openData.clearCache) === null || _this$store$openData$ === void 0 || _this$store$openData$.call(_this$store$openData);
|
|
2565
|
+
}
|
|
2566
|
+
}, {
|
|
2567
|
+
key: "prepareInvoiceTemplateAtSolutionReady",
|
|
2568
|
+
value: function () {
|
|
2569
|
+
var _prepareInvoiceTemplateAtSolutionReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(injectedOpenData) {
|
|
2570
|
+
var businessCode;
|
|
2571
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
2572
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2171
2573
|
case 0:
|
|
2172
|
-
|
|
2173
|
-
|
|
2574
|
+
businessCode = this.getBookingTicketBusinessCode();
|
|
2575
|
+
if (!(!businessCode || !this.store.openData)) {
|
|
2576
|
+
_context13.next = 3;
|
|
2174
2577
|
break;
|
|
2175
2578
|
}
|
|
2176
|
-
|
|
2177
|
-
case
|
|
2579
|
+
return _context13.abrupt("return");
|
|
2580
|
+
case 3:
|
|
2581
|
+
if (injectedOpenData) {
|
|
2582
|
+
this.otherParams.openData = injectedOpenData;
|
|
2583
|
+
this.openDataTarget = "".concat(businessCode, "+").concat(this.getSubmitOrderSalesChannel());
|
|
2584
|
+
}
|
|
2585
|
+
_context13.prev = 4;
|
|
2586
|
+
_context13.next = 7;
|
|
2587
|
+
return this.loadOpenDataConfig();
|
|
2588
|
+
case 7:
|
|
2589
|
+
_context13.next = 12;
|
|
2590
|
+
break;
|
|
2591
|
+
case 9:
|
|
2592
|
+
_context13.prev = 9;
|
|
2593
|
+
_context13.t0 = _context13["catch"](4);
|
|
2594
|
+
console.warn('[UnifiedBookingSales] Invoice 模板预加载失败,使用默认配置', _context13.t0);
|
|
2595
|
+
case 12:
|
|
2596
|
+
case "end":
|
|
2597
|
+
return _context13.stop();
|
|
2598
|
+
}
|
|
2599
|
+
}, _callee13, this, [[4, 9]]);
|
|
2600
|
+
}));
|
|
2601
|
+
function prepareInvoiceTemplateAtSolutionReady(_x8) {
|
|
2602
|
+
return _prepareInvoiceTemplateAtSolutionReady.apply(this, arguments);
|
|
2603
|
+
}
|
|
2604
|
+
return prepareInvoiceTemplateAtSolutionReady;
|
|
2605
|
+
}()
|
|
2606
|
+
}, {
|
|
2607
|
+
key: "loadOpenDataConfig",
|
|
2608
|
+
value: function () {
|
|
2609
|
+
var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
2610
|
+
var businessCode;
|
|
2611
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2612
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2613
|
+
case 0:
|
|
2614
|
+
businessCode = this.getBookingTicketBusinessCode();
|
|
2615
|
+
if (businessCode) {
|
|
2616
|
+
_context14.next = 3;
|
|
2617
|
+
break;
|
|
2618
|
+
}
|
|
2619
|
+
return _context14.abrupt("return", null);
|
|
2620
|
+
case 3:
|
|
2621
|
+
return _context14.abrupt("return", this.loadOpenData({
|
|
2622
|
+
businessCode: businessCode,
|
|
2623
|
+
channel: this.getSubmitOrderSalesChannel()
|
|
2624
|
+
}));
|
|
2625
|
+
case 4:
|
|
2626
|
+
case "end":
|
|
2627
|
+
return _context14.stop();
|
|
2628
|
+
}
|
|
2629
|
+
}, _callee14, this);
|
|
2630
|
+
}));
|
|
2631
|
+
function loadOpenDataConfig() {
|
|
2632
|
+
return _loadOpenDataConfig.apply(this, arguments);
|
|
2633
|
+
}
|
|
2634
|
+
return loadOpenDataConfig;
|
|
2635
|
+
}() /** A successful configuration belongs to this business runtime until an explicit refresh. */
|
|
2636
|
+
}, {
|
|
2637
|
+
key: "loadOpenData",
|
|
2638
|
+
value: (function () {
|
|
2639
|
+
var _loadOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
2640
|
+
var _this5 = this;
|
|
2641
|
+
var module, businessCode, channel, target, scope, injectedOpenData, generation, core, request;
|
|
2642
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2643
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2644
|
+
case 0:
|
|
2645
|
+
module = this.store.openData;
|
|
2646
|
+
if (module) {
|
|
2647
|
+
_context16.next = 3;
|
|
2648
|
+
break;
|
|
2649
|
+
}
|
|
2650
|
+
throw new Error('[UnifiedBookingSales] openData 模块未初始化');
|
|
2651
|
+
case 3:
|
|
2652
|
+
if (!this.runtimeOpenDataDestroyed) {
|
|
2653
|
+
_context16.next = 5;
|
|
2654
|
+
break;
|
|
2655
|
+
}
|
|
2656
|
+
throw new Error('Store settings changed. Please try again.');
|
|
2657
|
+
case 5:
|
|
2178
2658
|
businessCode = String(params.businessCode || '').trim();
|
|
2179
2659
|
channel = String(params.channel || '').trim();
|
|
2180
2660
|
if (!(!businessCode || !channel)) {
|
|
2181
|
-
|
|
2661
|
+
_context16.next = 9;
|
|
2182
2662
|
break;
|
|
2183
2663
|
}
|
|
2184
2664
|
throw new Error('[UnifiedBookingSales] OpenData 需要 businessCode 与 channel');
|
|
2185
|
-
case
|
|
2665
|
+
case 9:
|
|
2186
2666
|
target = "".concat(businessCode, "+").concat(channel);
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2667
|
+
this.otherParams.businessCode = businessCode;
|
|
2668
|
+
this.otherParams.channel = channel;
|
|
2669
|
+
scope = this.getRuntimeOpenDataScope();
|
|
2670
|
+
if (params.force) {
|
|
2671
|
+
this.clearOpenDataCache();
|
|
2192
2672
|
}
|
|
2193
|
-
if (
|
|
2194
|
-
|
|
2195
|
-
|
|
2673
|
+
if (this.runtimeOpenDataScope !== scope || this.runtimeOpenDataModule !== module || this.runtimeOpenDataCore !== this.core) {
|
|
2674
|
+
// Only the first, explicitly injected target may seed a new runtime snapshot.
|
|
2675
|
+
injectedOpenData = this.runtimeOpenDataScope === null && (!this.openDataTarget || this.openDataTarget === target) && isRecord(this.otherParams.openData) ? this.otherParams.openData : null;
|
|
2676
|
+
if (this.runtimeOpenDataScope !== null) {
|
|
2677
|
+
// The caller's Pickup Timing scope already changes with this runtime scope.
|
|
2678
|
+
this.resetRuntimeOpenData();
|
|
2679
|
+
}
|
|
2680
|
+
this.runtimeOpenDataScope = scope;
|
|
2681
|
+
this.runtimeOpenDataModule = module;
|
|
2682
|
+
this.runtimeOpenDataCore = this.core;
|
|
2683
|
+
this.runtimeOpenDataSnapshot = injectedOpenData;
|
|
2196
2684
|
}
|
|
2197
|
-
_context11.next = 13;
|
|
2198
|
-
return this.store.openData.ensureInvoiceTemplateSettings(target);
|
|
2199
|
-
case 13:
|
|
2200
|
-
return _context11.abrupt("return", cachedData);
|
|
2201
|
-
case 14:
|
|
2202
2685
|
if (!this.loadOpenDataInFlight) {
|
|
2203
|
-
|
|
2686
|
+
_context16.next = 17;
|
|
2204
2687
|
break;
|
|
2205
2688
|
}
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2689
|
+
return _context16.abrupt("return", this.loadOpenDataInFlight);
|
|
2690
|
+
case 17:
|
|
2691
|
+
generation = this.runtimeOpenDataGeneration;
|
|
2692
|
+
core = this.core;
|
|
2693
|
+
request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
2694
|
+
var openData, _module$ensureInvoice;
|
|
2695
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
2696
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2697
|
+
case 0:
|
|
2698
|
+
openData = _this5.runtimeOpenDataSnapshot;
|
|
2699
|
+
if (!openData) {
|
|
2700
|
+
_context15.next = 6;
|
|
2701
|
+
break;
|
|
2702
|
+
}
|
|
2703
|
+
_context15.next = 4;
|
|
2704
|
+
return (_module$ensureInvoice = module.ensureInvoiceTemplateSettings) === null || _module$ensureInvoice === void 0 ? void 0 : _module$ensureInvoice.call(module, target, openData);
|
|
2705
|
+
case 4:
|
|
2706
|
+
_context15.next = 9;
|
|
2707
|
+
break;
|
|
2708
|
+
case 6:
|
|
2709
|
+
_context15.next = 8;
|
|
2710
|
+
return module.fetchOpenData({
|
|
2711
|
+
scope: 'board',
|
|
2712
|
+
target: target,
|
|
2713
|
+
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
2714
|
+
});
|
|
2715
|
+
case 8:
|
|
2716
|
+
openData = _context15.sent;
|
|
2717
|
+
case 9:
|
|
2718
|
+
if (!(_this5.runtimeOpenDataDestroyed || generation !== _this5.runtimeOpenDataGeneration || scope !== _this5.getRuntimeOpenDataScope() || module !== _this5.store.openData || core !== _this5.core)) {
|
|
2719
|
+
_context15.next = 11;
|
|
2720
|
+
break;
|
|
2721
|
+
}
|
|
2722
|
+
throw new Error('Store settings changed. Please try again.');
|
|
2723
|
+
case 11:
|
|
2724
|
+
_this5.runtimeOpenDataSnapshot = openData;
|
|
2725
|
+
_this5.openDataTarget = target;
|
|
2726
|
+
_this5.otherParams.openData = openData;
|
|
2727
|
+
return _context15.abrupt("return", openData);
|
|
2728
|
+
case 15:
|
|
2729
|
+
case "end":
|
|
2730
|
+
return _context15.stop();
|
|
2731
|
+
}
|
|
2732
|
+
}, _callee15);
|
|
2733
|
+
}))();
|
|
2220
2734
|
this.loadOpenDataInFlightTarget = target;
|
|
2221
|
-
request = this.store.openData.fetchOpenData({
|
|
2222
|
-
scope: 'board',
|
|
2223
|
-
target: target,
|
|
2224
|
-
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
2225
|
-
});
|
|
2226
2735
|
this.loadOpenDataInFlight = request;
|
|
2227
|
-
|
|
2228
|
-
|
|
2736
|
+
_context16.prev = 22;
|
|
2737
|
+
_context16.next = 25;
|
|
2229
2738
|
return request;
|
|
2230
|
-
case
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
this.otherParams.openData = openData;
|
|
2235
|
-
this.otherParams.businessCode = businessCode;
|
|
2236
|
-
this.otherParams.channel = channel;
|
|
2237
|
-
}
|
|
2238
|
-
return _context11.abrupt("return", openData);
|
|
2239
|
-
case 31:
|
|
2240
|
-
_context11.prev = 31;
|
|
2739
|
+
case 25:
|
|
2740
|
+
return _context16.abrupt("return", _context16.sent);
|
|
2741
|
+
case 26:
|
|
2742
|
+
_context16.prev = 26;
|
|
2241
2743
|
if (this.loadOpenDataInFlight === request) {
|
|
2242
2744
|
this.loadOpenDataInFlight = null;
|
|
2243
2745
|
this.loadOpenDataInFlightTarget = null;
|
|
2244
2746
|
}
|
|
2245
|
-
return
|
|
2246
|
-
case
|
|
2747
|
+
return _context16.finish(26);
|
|
2748
|
+
case 29:
|
|
2247
2749
|
case "end":
|
|
2248
|
-
return
|
|
2750
|
+
return _context16.stop();
|
|
2249
2751
|
}
|
|
2250
|
-
},
|
|
2752
|
+
}, _callee16, this, [[22,, 26, 29]]);
|
|
2251
2753
|
}));
|
|
2252
|
-
function loadOpenData(
|
|
2754
|
+
function loadOpenData(_x9) {
|
|
2253
2755
|
return _loadOpenData.apply(this, arguments);
|
|
2254
2756
|
}
|
|
2255
2757
|
return loadOpenData;
|
|
@@ -2257,35 +2759,58 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2257
2759
|
}, {
|
|
2258
2760
|
key: "getOpenData",
|
|
2259
2761
|
value: function () {
|
|
2260
|
-
var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2264
|
-
while (1) switch (_context12.prev = _context12.next) {
|
|
2762
|
+
var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
2763
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2764
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2265
2765
|
case 0:
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
if (!(!businessCode || !channel)) {
|
|
2269
|
-
_context12.next = 4;
|
|
2270
|
-
break;
|
|
2271
|
-
}
|
|
2272
|
-
return _context12.abrupt("return", null);
|
|
2273
|
-
case 4:
|
|
2274
|
-
return _context12.abrupt("return", this.loadOpenData({
|
|
2275
|
-
businessCode: businessCode,
|
|
2276
|
-
channel: channel
|
|
2277
|
-
}));
|
|
2278
|
-
case 5:
|
|
2766
|
+
return _context17.abrupt("return", this.loadOpenDataConfig());
|
|
2767
|
+
case 1:
|
|
2279
2768
|
case "end":
|
|
2280
|
-
return
|
|
2769
|
+
return _context17.stop();
|
|
2281
2770
|
}
|
|
2282
|
-
},
|
|
2771
|
+
}, _callee17, this);
|
|
2283
2772
|
}));
|
|
2284
2773
|
function getOpenData() {
|
|
2285
2774
|
return _getOpenData.apply(this, arguments);
|
|
2286
2775
|
}
|
|
2287
2776
|
return getOpenData;
|
|
2288
2777
|
}()
|
|
2778
|
+
}, {
|
|
2779
|
+
key: "loadPickupTimingOpenData",
|
|
2780
|
+
value: function () {
|
|
2781
|
+
var _loadPickupTimingOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(_force) {
|
|
2782
|
+
var _ref34, _this$otherParams$bus2, _this$otherParams18, _this$otherParams19;
|
|
2783
|
+
var scope, businessCode, config;
|
|
2784
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2785
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2786
|
+
case 0:
|
|
2787
|
+
scope = this.getPickupTimingScope();
|
|
2788
|
+
businessCode = String((_ref34 = (_this$otherParams$bus2 = (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) !== null && _this$otherParams$bus2 !== void 0 ? _this$otherParams$bus2 : (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.business_code) !== null && _ref34 !== void 0 ? _ref34 : '').trim();
|
|
2789
|
+
_context18.next = 4;
|
|
2790
|
+
return this.loadOpenData({
|
|
2791
|
+
businessCode: businessCode,
|
|
2792
|
+
channel: this.getSubmitOrderSalesChannel()
|
|
2793
|
+
});
|
|
2794
|
+
case 4:
|
|
2795
|
+
config = _context18.sent;
|
|
2796
|
+
if (!(scope !== this.getPickupTimingScope())) {
|
|
2797
|
+
_context18.next = 7;
|
|
2798
|
+
break;
|
|
2799
|
+
}
|
|
2800
|
+
throw new Error('Store settings changed. Please try again.');
|
|
2801
|
+
case 7:
|
|
2802
|
+
return _context18.abrupt("return", config);
|
|
2803
|
+
case 8:
|
|
2804
|
+
case "end":
|
|
2805
|
+
return _context18.stop();
|
|
2806
|
+
}
|
|
2807
|
+
}, _callee18, this);
|
|
2808
|
+
}));
|
|
2809
|
+
function loadPickupTimingOpenData(_x10) {
|
|
2810
|
+
return _loadPickupTimingOpenData.apply(this, arguments);
|
|
2811
|
+
}
|
|
2812
|
+
return loadPickupTimingOpenData;
|
|
2813
|
+
}()
|
|
2289
2814
|
}, {
|
|
2290
2815
|
key: "resetAllergyItemRuleState",
|
|
2291
2816
|
value: function resetAllergyItemRuleState() {
|
|
@@ -2296,19 +2821,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2296
2821
|
}, {
|
|
2297
2822
|
key: "fetchAllergyItemRuleConfigs",
|
|
2298
2823
|
value: function () {
|
|
2299
|
-
var _fetchAllergyItemRuleConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2824
|
+
var _fetchAllergyItemRuleConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(strategyModelIds) {
|
|
2300
2825
|
var _response$data, response, list;
|
|
2301
|
-
return _regeneratorRuntime().wrap(function
|
|
2302
|
-
while (1) switch (
|
|
2826
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2827
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2303
2828
|
case 0:
|
|
2304
2829
|
if (strategyModelIds.length) {
|
|
2305
|
-
|
|
2830
|
+
_context19.next = 2;
|
|
2306
2831
|
break;
|
|
2307
2832
|
}
|
|
2308
|
-
return
|
|
2833
|
+
return _context19.abrupt("return", []);
|
|
2309
2834
|
case 2:
|
|
2310
|
-
|
|
2311
|
-
|
|
2835
|
+
_context19.prev = 2;
|
|
2836
|
+
_context19.next = 5;
|
|
2312
2837
|
return this.request.get('/promotion', {
|
|
2313
2838
|
skip: 1,
|
|
2314
2839
|
num: 99,
|
|
@@ -2316,28 +2841,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2316
2841
|
ids: strategyModelIds
|
|
2317
2842
|
});
|
|
2318
2843
|
case 5:
|
|
2319
|
-
response =
|
|
2844
|
+
response = _context19.sent;
|
|
2320
2845
|
if (!((response === null || response === void 0 ? void 0 : response.code) !== 200 || !Array.isArray(response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list))) {
|
|
2321
|
-
|
|
2846
|
+
_context19.next = 8;
|
|
2322
2847
|
break;
|
|
2323
2848
|
}
|
|
2324
2849
|
throw new Error('[UnifiedBookingSales] 商品过敏策略加载失败');
|
|
2325
2850
|
case 8:
|
|
2326
2851
|
list = response.data.list;
|
|
2327
|
-
return
|
|
2852
|
+
return _context19.abrupt("return", normalizeItemRuleStrategyConfigs(list.map(function (item) {
|
|
2328
2853
|
return item === null || item === void 0 ? void 0 : item.metadata;
|
|
2329
2854
|
})));
|
|
2330
2855
|
case 12:
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
throw
|
|
2856
|
+
_context19.prev = 12;
|
|
2857
|
+
_context19.t0 = _context19["catch"](2);
|
|
2858
|
+
throw _context19.t0;
|
|
2334
2859
|
case 15:
|
|
2335
2860
|
case "end":
|
|
2336
|
-
return
|
|
2861
|
+
return _context19.stop();
|
|
2337
2862
|
}
|
|
2338
|
-
},
|
|
2863
|
+
}, _callee19, this, [[2, 12]]);
|
|
2339
2864
|
}));
|
|
2340
|
-
function fetchAllergyItemRuleConfigs(
|
|
2865
|
+
function fetchAllergyItemRuleConfigs(_x11) {
|
|
2341
2866
|
return _fetchAllergyItemRuleConfigs.apply(this, arguments);
|
|
2342
2867
|
}
|
|
2343
2868
|
return fetchAllergyItemRuleConfigs;
|
|
@@ -2345,70 +2870,72 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2345
2870
|
}, {
|
|
2346
2871
|
key: "ensureAllergyItemRuleConfigsLoaded",
|
|
2347
2872
|
value: function () {
|
|
2348
|
-
var _ensureAllergyItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2349
|
-
var
|
|
2350
|
-
return _regeneratorRuntime().wrap(function
|
|
2351
|
-
while (1) switch (
|
|
2873
|
+
var _ensureAllergyItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2874
|
+
var _this6 = this;
|
|
2875
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2876
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2352
2877
|
case 0:
|
|
2353
2878
|
if (!(this.allergyItemRuleConfigs.length > 0)) {
|
|
2354
|
-
|
|
2879
|
+
_context21.next = 2;
|
|
2355
2880
|
break;
|
|
2356
2881
|
}
|
|
2357
|
-
return
|
|
2882
|
+
return _context21.abrupt("return", this.allergyItemRuleConfigs);
|
|
2358
2883
|
case 2:
|
|
2359
2884
|
if (!this.allergyItemRuleConfigsPromise) {
|
|
2360
|
-
|
|
2885
|
+
_context21.next = 4;
|
|
2361
2886
|
break;
|
|
2362
2887
|
}
|
|
2363
|
-
return
|
|
2888
|
+
return _context21.abrupt("return", this.allergyItemRuleConfigsPromise);
|
|
2364
2889
|
case 4:
|
|
2365
|
-
this.allergyItemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2366
|
-
var
|
|
2890
|
+
this.allergyItemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2891
|
+
var _this6$otherParams;
|
|
2367
2892
|
var staticConfigs, openData, enabled, strategyModelIds, loaded;
|
|
2368
|
-
return _regeneratorRuntime().wrap(function
|
|
2369
|
-
while (1) switch (
|
|
2893
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2894
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2370
2895
|
case 0:
|
|
2371
|
-
staticConfigs = normalizeItemRuleStrategyConfigs((
|
|
2896
|
+
staticConfigs = normalizeItemRuleStrategyConfigs((_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 || (_this6$otherParams = _this6$otherParams.itemRule) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.strategyConfigs);
|
|
2372
2897
|
if (!(staticConfigs.length > 0)) {
|
|
2373
|
-
|
|
2898
|
+
_context20.next = 5;
|
|
2374
2899
|
break;
|
|
2375
2900
|
}
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
return
|
|
2901
|
+
_this6.allergyItemRuleConfigs = staticConfigs;
|
|
2902
|
+
_this6.allergyItemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2903
|
+
return _context20.abrupt("return", staticConfigs);
|
|
2379
2904
|
case 5:
|
|
2380
|
-
|
|
2381
|
-
return
|
|
2905
|
+
_context20.next = 7;
|
|
2906
|
+
return _this6.getOpenData();
|
|
2382
2907
|
case 7:
|
|
2383
|
-
openData =
|
|
2908
|
+
openData = _context20.sent;
|
|
2384
2909
|
enabled = toConfiguredBoolean(openData === null || openData === void 0 ? void 0 : openData['sale.enable_item_rules']);
|
|
2385
2910
|
strategyModelIds = normalizePositiveIntegerList(openData === null || openData === void 0 ? void 0 : openData['sale.enabled_item_rules']);
|
|
2386
2911
|
if (!(!enabled || !strategyModelIds.length)) {
|
|
2387
|
-
|
|
2912
|
+
_context20.next = 13;
|
|
2388
2913
|
break;
|
|
2389
2914
|
}
|
|
2390
|
-
|
|
2391
|
-
return
|
|
2915
|
+
_this6.allergyItemRuleEvaluator.setStrategyConfigs([]);
|
|
2916
|
+
return _context20.abrupt("return", []);
|
|
2392
2917
|
case 13:
|
|
2393
|
-
|
|
2394
|
-
return
|
|
2918
|
+
_context20.next = 15;
|
|
2919
|
+
return _this6.fetchAllergyItemRuleConfigs(strategyModelIds);
|
|
2395
2920
|
case 15:
|
|
2396
|
-
loaded =
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
return
|
|
2921
|
+
loaded = _context20.sent;
|
|
2922
|
+
_this6.allergyItemRuleConfigs = loaded;
|
|
2923
|
+
_this6.allergyItemRuleEvaluator.setStrategyConfigs(loaded);
|
|
2924
|
+
return _context20.abrupt("return", loaded);
|
|
2400
2925
|
case 19:
|
|
2401
2926
|
case "end":
|
|
2402
|
-
return
|
|
2927
|
+
return _context20.stop();
|
|
2403
2928
|
}
|
|
2404
|
-
},
|
|
2405
|
-
}))()
|
|
2406
|
-
|
|
2929
|
+
}, _callee20);
|
|
2930
|
+
}))().catch(function () {
|
|
2931
|
+
return [];
|
|
2932
|
+
});
|
|
2933
|
+
return _context21.abrupt("return", this.allergyItemRuleConfigsPromise);
|
|
2407
2934
|
case 6:
|
|
2408
2935
|
case "end":
|
|
2409
|
-
return
|
|
2936
|
+
return _context21.stop();
|
|
2410
2937
|
}
|
|
2411
|
-
},
|
|
2938
|
+
}, _callee21, this);
|
|
2412
2939
|
}));
|
|
2413
2940
|
function ensureAllergyItemRuleConfigsLoaded() {
|
|
2414
2941
|
return _ensureAllergyItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -2422,51 +2949,51 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2422
2949
|
}, {
|
|
2423
2950
|
key: "resolveProductAllergyRequirement",
|
|
2424
2951
|
value: (function () {
|
|
2425
|
-
var _resolveProductAllergyRequirement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2426
|
-
var _this$otherParams20, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child,
|
|
2952
|
+
var _resolveProductAllergyRequirement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2953
|
+
var _this$otherParams20, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref37, _runtimeConfig$servic, _this$otherParams21, _ref38, _ref39, _params$channel, _this$otherParams22, _this$otherParams23, _runtimeConfig$submis;
|
|
2427
2954
|
var productId, strategyConfigs, productVariantId, runtimeConfig, runtimePax, cartItems;
|
|
2428
|
-
return _regeneratorRuntime().wrap(function
|
|
2429
|
-
while (1) switch (
|
|
2955
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2956
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2430
2957
|
case 0:
|
|
2431
2958
|
productId = normalizePositiveInteger(params.productId);
|
|
2432
2959
|
if (productId) {
|
|
2433
|
-
|
|
2960
|
+
_context22.next = 3;
|
|
2434
2961
|
break;
|
|
2435
2962
|
}
|
|
2436
|
-
return
|
|
2963
|
+
return _context22.abrupt("return", null);
|
|
2437
2964
|
case 3:
|
|
2438
|
-
|
|
2965
|
+
_context22.next = 5;
|
|
2439
2966
|
return this.ensureAllergyItemRuleConfigsLoaded();
|
|
2440
2967
|
case 5:
|
|
2441
|
-
strategyConfigs =
|
|
2968
|
+
strategyConfigs = _context22.sent;
|
|
2442
2969
|
if (strategyConfigs.length) {
|
|
2443
|
-
|
|
2970
|
+
_context22.next = 8;
|
|
2444
2971
|
break;
|
|
2445
2972
|
}
|
|
2446
|
-
return
|
|
2973
|
+
return _context22.abrupt("return", null);
|
|
2447
2974
|
case 8:
|
|
2448
2975
|
productVariantId = normalizePositiveInteger(params.productVariantId);
|
|
2449
2976
|
runtimeConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.itemRule) || {};
|
|
2450
2977
|
runtimePax = runtimeConfig.pax || {};
|
|
2451
2978
|
cartItems = (((_this$getOrderProduct = this.getOrderProducts) === null || _this$getOrderProduct === void 0 ? void 0 : _this$getOrderProduct.call(this)) || []).map(function (item) {
|
|
2452
|
-
var _item$product_id, _item$product_variant,
|
|
2979
|
+
var _item$product_id, _item$product_variant, _ref36, _item$num;
|
|
2453
2980
|
return {
|
|
2454
2981
|
product_id: Number((_item$product_id = item === null || item === void 0 ? void 0 : item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : item === null || item === void 0 ? void 0 : item.id),
|
|
2455
2982
|
product_variant_id: Number((_item$product_variant = item === null || item === void 0 ? void 0 : item.product_variant_id) !== null && _item$product_variant !== void 0 ? _item$product_variant : 0) || undefined,
|
|
2456
|
-
quantity: Number((
|
|
2983
|
+
quantity: Number((_ref36 = (_item$num = item === null || item === void 0 ? void 0 : item.num) !== null && _item$num !== void 0 ? _item$num : item === null || item === void 0 ? void 0 : item.quantity) !== null && _ref36 !== void 0 ? _ref36 : 0)
|
|
2457
2984
|
};
|
|
2458
2985
|
}).filter(function (item) {
|
|
2459
2986
|
return Number.isFinite(item.product_id) && item.product_id > 0 && Number.isFinite(item.quantity) && item.quantity > 0;
|
|
2460
2987
|
});
|
|
2461
|
-
return
|
|
2988
|
+
return _context22.abrupt("return", this.allergyItemRuleEvaluator.getAllergyRequirement({
|
|
2462
2989
|
pax: {
|
|
2463
2990
|
total: Number((_runtimePax$total = runtimePax.total) !== null && _runtimePax$total !== void 0 ? _runtimePax$total : 0) || 0,
|
|
2464
2991
|
adult: Number((_runtimePax$adult = runtimePax.adult) !== null && _runtimePax$adult !== void 0 ? _runtimePax$adult : 0) || 0,
|
|
2465
2992
|
child: Number((_runtimePax$child = runtimePax.child) !== null && _runtimePax$child !== void 0 ? _runtimePax$child : 0) || 0
|
|
2466
2993
|
},
|
|
2467
2994
|
cartItems: cartItems,
|
|
2468
|
-
serviceType: String((
|
|
2469
|
-
channel: String((
|
|
2995
|
+
serviceType: String((_ref37 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.serviceType) !== null && _ref37 !== void 0 ? _ref37 : ''),
|
|
2996
|
+
channel: String((_ref38 = (_ref39 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.channel) !== null && _ref39 !== void 0 ? _ref39 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform) !== null && _ref38 !== void 0 ? _ref38 : ''),
|
|
2470
2997
|
currentProduct: _objectSpread({
|
|
2471
2998
|
product_id: productId
|
|
2472
2999
|
}, productVariantId ? {
|
|
@@ -2478,11 +3005,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2478
3005
|
}));
|
|
2479
3006
|
case 13:
|
|
2480
3007
|
case "end":
|
|
2481
|
-
return
|
|
3008
|
+
return _context22.stop();
|
|
2482
3009
|
}
|
|
2483
|
-
},
|
|
3010
|
+
}, _callee22, this);
|
|
2484
3011
|
}));
|
|
2485
|
-
function resolveProductAllergyRequirement(
|
|
3012
|
+
function resolveProductAllergyRequirement(_x12) {
|
|
2486
3013
|
return _resolveProductAllergyRequirement.apply(this, arguments);
|
|
2487
3014
|
}
|
|
2488
3015
|
return resolveProductAllergyRequirement;
|
|
@@ -2490,35 +3017,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2490
3017
|
}, {
|
|
2491
3018
|
key: "clearOpenDataCache",
|
|
2492
3019
|
value: function clearOpenDataCache() {
|
|
2493
|
-
this.
|
|
2494
|
-
this.
|
|
2495
|
-
this.loadOpenDataInFlightTarget = null;
|
|
2496
|
-
_get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "clearOpenDataCache", this).call(this);
|
|
3020
|
+
this.resetRuntimeOpenData();
|
|
3021
|
+
this.resetPickupTimingCache();
|
|
2497
3022
|
}
|
|
2498
3023
|
}, {
|
|
2499
3024
|
key: "getInvoiceLayoutConfig",
|
|
2500
3025
|
value: function () {
|
|
2501
|
-
var _getInvoiceLayoutConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3026
|
+
var _getInvoiceLayoutConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
2502
3027
|
var openData;
|
|
2503
|
-
return _regeneratorRuntime().wrap(function
|
|
2504
|
-
while (1) switch (
|
|
3028
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
3029
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2505
3030
|
case 0:
|
|
2506
|
-
|
|
3031
|
+
_context23.next = 2;
|
|
2507
3032
|
return this.getOpenData();
|
|
2508
3033
|
case 2:
|
|
2509
|
-
openData =
|
|
3034
|
+
openData = _context23.sent;
|
|
2510
3035
|
if (!(!openData || !this.store.openData)) {
|
|
2511
|
-
|
|
3036
|
+
_context23.next = 5;
|
|
2512
3037
|
break;
|
|
2513
3038
|
}
|
|
2514
|
-
return
|
|
3039
|
+
return _context23.abrupt("return", getDefaultInvoiceLayoutConfig());
|
|
2515
3040
|
case 5:
|
|
2516
|
-
return
|
|
3041
|
+
return _context23.abrupt("return", this.store.openData.getInvoiceLayoutConfig());
|
|
2517
3042
|
case 6:
|
|
2518
3043
|
case "end":
|
|
2519
|
-
return
|
|
3044
|
+
return _context23.stop();
|
|
2520
3045
|
}
|
|
2521
|
-
},
|
|
3046
|
+
}, _callee23, this);
|
|
2522
3047
|
}));
|
|
2523
3048
|
function getInvoiceLayoutConfig() {
|
|
2524
3049
|
return _getInvoiceLayoutConfig.apply(this, arguments);
|
|
@@ -2528,27 +3053,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2528
3053
|
}, {
|
|
2529
3054
|
key: "getInvoiceTemplateSettings",
|
|
2530
3055
|
value: function () {
|
|
2531
|
-
var _getInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3056
|
+
var _getInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2532
3057
|
var openData;
|
|
2533
|
-
return _regeneratorRuntime().wrap(function
|
|
2534
|
-
while (1) switch (
|
|
3058
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
3059
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2535
3060
|
case 0:
|
|
2536
|
-
|
|
3061
|
+
_context24.next = 2;
|
|
2537
3062
|
return this.getOpenData();
|
|
2538
3063
|
case 2:
|
|
2539
|
-
openData =
|
|
3064
|
+
openData = _context24.sent;
|
|
2540
3065
|
if (!(!openData || !this.store.openData)) {
|
|
2541
|
-
|
|
3066
|
+
_context24.next = 5;
|
|
2542
3067
|
break;
|
|
2543
3068
|
}
|
|
2544
|
-
return
|
|
3069
|
+
return _context24.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
2545
3070
|
case 5:
|
|
2546
|
-
return
|
|
3071
|
+
return _context24.abrupt("return", this.store.openData.getInvoiceTemplateSettings());
|
|
2547
3072
|
case 6:
|
|
2548
3073
|
case "end":
|
|
2549
|
-
return
|
|
3074
|
+
return _context24.stop();
|
|
2550
3075
|
}
|
|
2551
|
-
},
|
|
3076
|
+
}, _callee24, this);
|
|
2552
3077
|
}));
|
|
2553
3078
|
function getInvoiceTemplateSettings() {
|
|
2554
3079
|
return _getInvoiceTemplateSettings.apply(this, arguments);
|
|
@@ -2562,7 +3087,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2562
3087
|
var businessCode = String(((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.businessCode) || '').trim();
|
|
2563
3088
|
var channel = String(((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.channel) || '').trim();
|
|
2564
3089
|
if (!businessCode || !channel) return false;
|
|
2565
|
-
return this.openDataTarget === "".concat(businessCode, "+").concat(channel);
|
|
3090
|
+
return this.openDataTarget === "".concat(businessCode, "+").concat(channel) && this.runtimeOpenDataScope === this.getRuntimeOpenDataScope();
|
|
2566
3091
|
}
|
|
2567
3092
|
|
|
2568
3093
|
/**
|
|
@@ -2571,14 +3096,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2571
3096
|
}, {
|
|
2572
3097
|
key: "getProtocol",
|
|
2573
3098
|
value: (function () {
|
|
2574
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3099
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(policyId) {
|
|
2575
3100
|
var normalizedPolicyId, policyUrl;
|
|
2576
|
-
return _regeneratorRuntime().wrap(function
|
|
2577
|
-
while (1) switch (
|
|
3101
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
3102
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2578
3103
|
case 0:
|
|
2579
3104
|
normalizedPolicyId = String(policyId !== null && policyId !== void 0 ? policyId : '').trim();
|
|
2580
3105
|
if (normalizedPolicyId) {
|
|
2581
|
-
|
|
3106
|
+
_context25.next = 3;
|
|
2582
3107
|
break;
|
|
2583
3108
|
}
|
|
2584
3109
|
throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
|
|
@@ -2587,14 +3112,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2587
3112
|
if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
|
|
2588
3113
|
policyUrl = 'policy';
|
|
2589
3114
|
}
|
|
2590
|
-
return
|
|
3115
|
+
return _context25.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
|
|
2591
3116
|
case 6:
|
|
2592
3117
|
case "end":
|
|
2593
|
-
return
|
|
3118
|
+
return _context25.stop();
|
|
2594
3119
|
}
|
|
2595
|
-
},
|
|
3120
|
+
}, _callee25, this);
|
|
2596
3121
|
}));
|
|
2597
|
-
function getProtocol(
|
|
3122
|
+
function getProtocol(_x13) {
|
|
2598
3123
|
return _getProtocol.apply(this, arguments);
|
|
2599
3124
|
}
|
|
2600
3125
|
return getProtocol;
|
|
@@ -2607,27 +3132,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2607
3132
|
}, {
|
|
2608
3133
|
key: "loadProducts",
|
|
2609
3134
|
value: (function () {
|
|
2610
|
-
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3135
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
2611
3136
|
var params,
|
|
2612
3137
|
options,
|
|
2613
3138
|
schedule_date,
|
|
2614
3139
|
schedule_datetime,
|
|
2615
3140
|
result,
|
|
2616
|
-
|
|
2617
|
-
return _regeneratorRuntime().wrap(function
|
|
2618
|
-
while (1) switch (
|
|
3141
|
+
_args26 = arguments;
|
|
3142
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3143
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2619
3144
|
case 0:
|
|
2620
|
-
params =
|
|
2621
|
-
options =
|
|
3145
|
+
params = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {};
|
|
3146
|
+
options = _args26.length > 1 ? _args26[1] : undefined;
|
|
2622
3147
|
if (this.store.products) {
|
|
2623
|
-
|
|
3148
|
+
_context26.next = 4;
|
|
2624
3149
|
break;
|
|
2625
3150
|
}
|
|
2626
3151
|
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
2627
3152
|
case 4:
|
|
2628
3153
|
schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
2629
3154
|
schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
|
|
2630
|
-
|
|
3155
|
+
_context26.next = 8;
|
|
2631
3156
|
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
2632
3157
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
2633
3158
|
with_schedule: 1
|
|
@@ -2637,17 +3162,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2637
3162
|
cacheId: this.cacheId
|
|
2638
3163
|
}), options);
|
|
2639
3164
|
case 8:
|
|
2640
|
-
result =
|
|
3165
|
+
result = _context26.sent;
|
|
2641
3166
|
this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
|
|
2642
|
-
|
|
3167
|
+
_context26.next = 12;
|
|
2643
3168
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
|
|
2644
3169
|
case 12:
|
|
2645
|
-
return
|
|
3170
|
+
return _context26.abrupt("return", result);
|
|
2646
3171
|
case 13:
|
|
2647
3172
|
case "end":
|
|
2648
|
-
return
|
|
3173
|
+
return _context26.stop();
|
|
2649
3174
|
}
|
|
2650
|
-
},
|
|
3175
|
+
}, _callee26, this);
|
|
2651
3176
|
}));
|
|
2652
3177
|
function loadProducts() {
|
|
2653
3178
|
return _loadProducts.apply(this, arguments);
|
|
@@ -2657,25 +3182,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2657
3182
|
}, {
|
|
2658
3183
|
key: "queryProducts",
|
|
2659
3184
|
value: function () {
|
|
2660
|
-
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3185
|
+
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
2661
3186
|
var params,
|
|
2662
|
-
|
|
2663
|
-
return _regeneratorRuntime().wrap(function
|
|
2664
|
-
while (1) switch (
|
|
3187
|
+
_args27 = arguments;
|
|
3188
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3189
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2665
3190
|
case 0:
|
|
2666
|
-
params =
|
|
3191
|
+
params = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {};
|
|
2667
3192
|
if (this.store.products) {
|
|
2668
|
-
|
|
3193
|
+
_context27.next = 3;
|
|
2669
3194
|
break;
|
|
2670
3195
|
}
|
|
2671
3196
|
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
2672
3197
|
case 3:
|
|
2673
|
-
return
|
|
3198
|
+
return _context27.abrupt("return", this.store.products.queryProducts(params));
|
|
2674
3199
|
case 4:
|
|
2675
3200
|
case "end":
|
|
2676
|
-
return
|
|
3201
|
+
return _context27.stop();
|
|
2677
3202
|
}
|
|
2678
|
-
},
|
|
3203
|
+
}, _callee27, this);
|
|
2679
3204
|
}));
|
|
2680
3205
|
function queryProducts() {
|
|
2681
3206
|
return _queryProducts.apply(this, arguments);
|
|
@@ -2685,24 +3210,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2685
3210
|
}, {
|
|
2686
3211
|
key: "loadScheduleAvailableDate",
|
|
2687
3212
|
value: (function () {
|
|
2688
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2689
|
-
return _regeneratorRuntime().wrap(function
|
|
2690
|
-
while (1) switch (
|
|
3213
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
3214
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3215
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2691
3216
|
case 0:
|
|
2692
3217
|
if (this.store.schedule) {
|
|
2693
|
-
|
|
3218
|
+
_context28.next = 2;
|
|
2694
3219
|
break;
|
|
2695
3220
|
}
|
|
2696
3221
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
2697
3222
|
case 2:
|
|
2698
|
-
return
|
|
3223
|
+
return _context28.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
|
|
2699
3224
|
case 3:
|
|
2700
3225
|
case "end":
|
|
2701
|
-
return
|
|
3226
|
+
return _context28.stop();
|
|
2702
3227
|
}
|
|
2703
|
-
},
|
|
3228
|
+
}, _callee28, this);
|
|
2704
3229
|
}));
|
|
2705
|
-
function loadScheduleAvailableDate(
|
|
3230
|
+
function loadScheduleAvailableDate(_x14) {
|
|
2706
3231
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
2707
3232
|
}
|
|
2708
3233
|
return loadScheduleAvailableDate;
|
|
@@ -2716,15 +3241,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2716
3241
|
}, {
|
|
2717
3242
|
key: "loadProductsByScheduleDate",
|
|
2718
3243
|
value: (function () {
|
|
2719
|
-
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3244
|
+
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
2720
3245
|
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;
|
|
2721
|
-
var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts,
|
|
2722
|
-
return _regeneratorRuntime().wrap(function
|
|
2723
|
-
while (1) switch (
|
|
3246
|
+
var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator2, _step2, productId, result;
|
|
3247
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3248
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2724
3249
|
case 0:
|
|
2725
3250
|
date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
|
|
2726
3251
|
if (this.store.schedule) {
|
|
2727
|
-
|
|
3252
|
+
_context29.next = 3;
|
|
2728
3253
|
break;
|
|
2729
3254
|
}
|
|
2730
3255
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
@@ -2735,10 +3260,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2735
3260
|
});
|
|
2736
3261
|
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;
|
|
2737
3262
|
if (!(!hasCachedDate && !hasOtherProducts)) {
|
|
2738
|
-
|
|
3263
|
+
_context29.next = 9;
|
|
2739
3264
|
break;
|
|
2740
3265
|
}
|
|
2741
|
-
|
|
3266
|
+
_context29.next = 9;
|
|
2742
3267
|
return this.loadScheduleAvailableDate({
|
|
2743
3268
|
startDate: date,
|
|
2744
3269
|
endDate: date,
|
|
@@ -2758,45 +3283,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2758
3283
|
return !productIdFilter || productIdFilter.has(String(id));
|
|
2759
3284
|
});
|
|
2760
3285
|
if (availableProductIds.length) {
|
|
2761
|
-
|
|
3286
|
+
_context29.next = 17;
|
|
2762
3287
|
break;
|
|
2763
3288
|
}
|
|
2764
3289
|
this.unifiedProductCatalog = [];
|
|
2765
|
-
|
|
3290
|
+
_context29.next = 16;
|
|
2766
3291
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
|
|
2767
3292
|
case 16:
|
|
2768
|
-
return
|
|
3293
|
+
return _context29.abrupt("return", []);
|
|
2769
3294
|
case 17:
|
|
2770
|
-
|
|
3295
|
+
_context29.next = 19;
|
|
2771
3296
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
2772
3297
|
product_ids: availableProductIds,
|
|
2773
3298
|
schedule_date: date
|
|
2774
3299
|
}));
|
|
2775
3300
|
case 19:
|
|
2776
|
-
products =
|
|
3301
|
+
products = _context29.sent;
|
|
2777
3302
|
if (!(products.length || availableProductIds.length <= 1)) {
|
|
2778
|
-
|
|
3303
|
+
_context29.next = 22;
|
|
2779
3304
|
break;
|
|
2780
3305
|
}
|
|
2781
|
-
return
|
|
3306
|
+
return _context29.abrupt("return", products);
|
|
2782
3307
|
case 22:
|
|
2783
3308
|
fallbackProducts = [];
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
3309
|
+
_iterator2 = _createForOfIteratorHelper(availableProductIds);
|
|
3310
|
+
_context29.prev = 24;
|
|
3311
|
+
_iterator2.s();
|
|
2787
3312
|
case 26:
|
|
2788
|
-
if ((
|
|
2789
|
-
|
|
3313
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
3314
|
+
_context29.next = 34;
|
|
2790
3315
|
break;
|
|
2791
3316
|
}
|
|
2792
|
-
productId =
|
|
2793
|
-
|
|
3317
|
+
productId = _step2.value;
|
|
3318
|
+
_context29.next = 30;
|
|
2794
3319
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
2795
3320
|
product_ids: [productId],
|
|
2796
3321
|
schedule_date: date
|
|
2797
3322
|
}));
|
|
2798
3323
|
case 30:
|
|
2799
|
-
result =
|
|
3324
|
+
result = _context29.sent;
|
|
2800
3325
|
result.forEach(function (product) {
|
|
2801
3326
|
var _id;
|
|
2802
3327
|
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;
|
|
@@ -2808,32 +3333,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2808
3333
|
}
|
|
2809
3334
|
});
|
|
2810
3335
|
case 32:
|
|
2811
|
-
|
|
3336
|
+
_context29.next = 26;
|
|
2812
3337
|
break;
|
|
2813
3338
|
case 34:
|
|
2814
|
-
|
|
3339
|
+
_context29.next = 39;
|
|
2815
3340
|
break;
|
|
2816
3341
|
case 36:
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
3342
|
+
_context29.prev = 36;
|
|
3343
|
+
_context29.t0 = _context29["catch"](24);
|
|
3344
|
+
_iterator2.e(_context29.t0);
|
|
2820
3345
|
case 39:
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
return
|
|
3346
|
+
_context29.prev = 39;
|
|
3347
|
+
_iterator2.f();
|
|
3348
|
+
return _context29.finish(39);
|
|
2824
3349
|
case 42:
|
|
2825
3350
|
this.unifiedProductCatalog = [].concat(fallbackProducts);
|
|
2826
|
-
|
|
3351
|
+
_context29.next = 45;
|
|
2827
3352
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
|
|
2828
3353
|
case 45:
|
|
2829
|
-
return
|
|
3354
|
+
return _context29.abrupt("return", fallbackProducts);
|
|
2830
3355
|
case 46:
|
|
2831
3356
|
case "end":
|
|
2832
|
-
return
|
|
3357
|
+
return _context29.stop();
|
|
2833
3358
|
}
|
|
2834
|
-
},
|
|
3359
|
+
}, _callee29, this, [[24, 36, 39, 42]]);
|
|
2835
3360
|
}));
|
|
2836
|
-
function loadProductsByScheduleDate(
|
|
3361
|
+
function loadProductsByScheduleDate(_x15) {
|
|
2837
3362
|
return _loadProductsByScheduleDate.apply(this, arguments);
|
|
2838
3363
|
}
|
|
2839
3364
|
return loadProductsByScheduleDate;
|
|
@@ -2886,7 +3411,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2886
3411
|
}, {
|
|
2887
3412
|
key: "applyPlannerDiscounts",
|
|
2888
3413
|
value: (function () {
|
|
2889
|
-
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3414
|
+
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2890
3415
|
var _params$customerId;
|
|
2891
3416
|
var params,
|
|
2892
3417
|
tempOrder,
|
|
@@ -2898,29 +3423,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2898
3423
|
preferredDiscount,
|
|
2899
3424
|
preferredId,
|
|
2900
3425
|
selectedOtherDiscounts,
|
|
2901
|
-
|
|
2902
|
-
|
|
3426
|
+
_iterator3,
|
|
3427
|
+
_step3,
|
|
2903
3428
|
discount,
|
|
2904
3429
|
discountId,
|
|
2905
3430
|
nextTempOrder,
|
|
2906
|
-
|
|
2907
|
-
return _regeneratorRuntime().wrap(function
|
|
2908
|
-
while (1) switch (
|
|
3431
|
+
_args30 = arguments;
|
|
3432
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3433
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2909
3434
|
case 0:
|
|
2910
|
-
params =
|
|
3435
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
2911
3436
|
tempOrder = this.getTempOrder();
|
|
2912
3437
|
requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
2913
3438
|
parsedCustomerId = Number(requestedCustomerId);
|
|
2914
3439
|
customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
|
|
2915
|
-
|
|
3440
|
+
_context30.next = 7;
|
|
2916
3441
|
return this.getSummary();
|
|
2917
3442
|
case 7:
|
|
2918
|
-
summaryBefore =
|
|
3443
|
+
summaryBefore = _context30.sent;
|
|
2919
3444
|
if (customerId) {
|
|
2920
|
-
|
|
3445
|
+
_context30.next = 10;
|
|
2921
3446
|
break;
|
|
2922
3447
|
}
|
|
2923
|
-
return
|
|
3448
|
+
return _context30.abrupt("return", buildPlannerDiscountResult({
|
|
2924
3449
|
customerId: null,
|
|
2925
3450
|
discountList: this.getDiscountList(),
|
|
2926
3451
|
products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
@@ -2929,7 +3454,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2929
3454
|
status: 'no_customer'
|
|
2930
3455
|
}));
|
|
2931
3456
|
case 10:
|
|
2932
|
-
|
|
3457
|
+
_context30.next = 12;
|
|
2933
3458
|
return this.loadDiscountConfig({
|
|
2934
3459
|
customerId: customerId,
|
|
2935
3460
|
action: 'create'
|
|
@@ -2941,7 +3466,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2941
3466
|
return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
|
|
2942
3467
|
});
|
|
2943
3468
|
if (!preferredDiscount) {
|
|
2944
|
-
|
|
3469
|
+
_context30.next = 40;
|
|
2945
3470
|
break;
|
|
2946
3471
|
}
|
|
2947
3472
|
// A requested card is an explicit UI choice, not a best-effort preference. Clear prior
|
|
@@ -2952,99 +3477,99 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2952
3477
|
var _resolvePlannerDiscou2;
|
|
2953
3478
|
return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
|
|
2954
3479
|
});
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
3480
|
+
_iterator3 = _createForOfIteratorHelper(selectedOtherDiscounts);
|
|
3481
|
+
_context30.prev = 18;
|
|
3482
|
+
_iterator3.s();
|
|
2958
3483
|
case 20:
|
|
2959
|
-
if ((
|
|
2960
|
-
|
|
3484
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
3485
|
+
_context30.next = 28;
|
|
2961
3486
|
break;
|
|
2962
3487
|
}
|
|
2963
|
-
discount =
|
|
3488
|
+
discount = _step3.value;
|
|
2964
3489
|
discountId = Number(resolvePlannerDiscountId(discount));
|
|
2965
3490
|
if (!Number.isFinite(discountId)) {
|
|
2966
|
-
|
|
3491
|
+
_context30.next = 26;
|
|
2967
3492
|
break;
|
|
2968
3493
|
}
|
|
2969
|
-
|
|
3494
|
+
_context30.next = 26;
|
|
2970
3495
|
return this.setDiscountSelected({
|
|
2971
3496
|
discountId: discountId,
|
|
2972
3497
|
isSelected: false
|
|
2973
3498
|
});
|
|
2974
3499
|
case 26:
|
|
2975
|
-
|
|
3500
|
+
_context30.next = 20;
|
|
2976
3501
|
break;
|
|
2977
3502
|
case 28:
|
|
2978
|
-
|
|
3503
|
+
_context30.next = 33;
|
|
2979
3504
|
break;
|
|
2980
3505
|
case 30:
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3506
|
+
_context30.prev = 30;
|
|
3507
|
+
_context30.t0 = _context30["catch"](18);
|
|
3508
|
+
_iterator3.e(_context30.t0);
|
|
2984
3509
|
case 33:
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
return
|
|
3510
|
+
_context30.prev = 33;
|
|
3511
|
+
_iterator3.f();
|
|
3512
|
+
return _context30.finish(33);
|
|
2988
3513
|
case 36:
|
|
2989
|
-
|
|
3514
|
+
_context30.next = 38;
|
|
2990
3515
|
return this.setDiscountSelected({
|
|
2991
3516
|
discountId: Number(preferredId),
|
|
2992
3517
|
isSelected: true
|
|
2993
3518
|
});
|
|
2994
3519
|
case 38:
|
|
2995
|
-
|
|
3520
|
+
_context30.next = 49;
|
|
2996
3521
|
break;
|
|
2997
3522
|
case 40:
|
|
2998
3523
|
if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
|
|
2999
|
-
|
|
3524
|
+
_context30.next = 46;
|
|
3000
3525
|
break;
|
|
3001
3526
|
}
|
|
3002
3527
|
if (!(params.applyBestDiscount !== false)) {
|
|
3003
|
-
|
|
3528
|
+
_context30.next = 44;
|
|
3004
3529
|
break;
|
|
3005
3530
|
}
|
|
3006
|
-
|
|
3531
|
+
_context30.next = 44;
|
|
3007
3532
|
return this.bestDiscount();
|
|
3008
3533
|
case 44:
|
|
3009
|
-
|
|
3534
|
+
_context30.next = 49;
|
|
3010
3535
|
break;
|
|
3011
3536
|
case 46:
|
|
3012
3537
|
if (!(params.applyBestDiscount !== false)) {
|
|
3013
|
-
|
|
3538
|
+
_context30.next = 49;
|
|
3014
3539
|
break;
|
|
3015
3540
|
}
|
|
3016
|
-
|
|
3541
|
+
_context30.next = 49;
|
|
3017
3542
|
return this.bestDiscount();
|
|
3018
3543
|
case 49:
|
|
3019
3544
|
nextTempOrder = this.getTempOrder();
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3545
|
+
_context30.t1 = buildPlannerDiscountResult;
|
|
3546
|
+
_context30.t2 = customerId;
|
|
3547
|
+
_context30.t3 = this.getDiscountList();
|
|
3548
|
+
_context30.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
|
|
3549
|
+
_context30.t5 = summaryBefore;
|
|
3550
|
+
_context30.next = 57;
|
|
3026
3551
|
return this.getSummary();
|
|
3027
3552
|
case 57:
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
customerId:
|
|
3034
|
-
discountList:
|
|
3035
|
-
products:
|
|
3036
|
-
summaryBefore:
|
|
3037
|
-
summaryAfter:
|
|
3038
|
-
status:
|
|
3039
|
-
preferredDiscountId:
|
|
3040
|
-
preferredDiscountFound:
|
|
3553
|
+
_context30.t6 = _context30.sent;
|
|
3554
|
+
_context30.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
|
|
3555
|
+
_context30.t8 = preferredDiscountId;
|
|
3556
|
+
_context30.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
|
|
3557
|
+
_context30.t10 = {
|
|
3558
|
+
customerId: _context30.t2,
|
|
3559
|
+
discountList: _context30.t3,
|
|
3560
|
+
products: _context30.t4,
|
|
3561
|
+
summaryBefore: _context30.t5,
|
|
3562
|
+
summaryAfter: _context30.t6,
|
|
3563
|
+
status: _context30.t7,
|
|
3564
|
+
preferredDiscountId: _context30.t8,
|
|
3565
|
+
preferredDiscountFound: _context30.t9
|
|
3041
3566
|
};
|
|
3042
|
-
return
|
|
3567
|
+
return _context30.abrupt("return", (0, _context30.t1)(_context30.t10));
|
|
3043
3568
|
case 63:
|
|
3044
3569
|
case "end":
|
|
3045
|
-
return
|
|
3570
|
+
return _context30.stop();
|
|
3046
3571
|
}
|
|
3047
|
-
},
|
|
3572
|
+
}, _callee30, this, [[18, 30, 33, 36]]);
|
|
3048
3573
|
}));
|
|
3049
3574
|
function applyPlannerDiscounts() {
|
|
3050
3575
|
return _applyPlannerDiscounts.apply(this, arguments);
|
|
@@ -3054,16 +3579,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3054
3579
|
}, {
|
|
3055
3580
|
key: "buildUnifiedOrderProduct",
|
|
3056
3581
|
value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
|
|
3057
|
-
var
|
|
3582
|
+
var _ref40, _sourceProduct$_exten, _sourceProduct$_exten2, _sourceProduct$metada, _sourceProduct$id, _ref41, _sourceProduct$produc, _ref42, _ref43, _sourceProduct$quanti, _sourceProduct$price, _ref44, _ref45, _sourceProduct$sellin;
|
|
3058
3583
|
var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
|
|
3059
|
-
var quotationShelfId = (
|
|
3584
|
+
var quotationShelfId = (_ref40 = (_sourceProduct$_exten = (_sourceProduct$_exten2 = sourceProduct._extend) === null || _sourceProduct$_exten2 === void 0 ? void 0 : _sourceProduct$_exten2.quotation_shelf_id) !== null && _sourceProduct$_exten !== void 0 ? _sourceProduct$_exten : sourceProduct.quotation_shelf_id) !== null && _ref40 !== void 0 ? _ref40 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
|
|
3060
3585
|
var orderProduct = this.transformBaseProductToOrderProduct({
|
|
3061
3586
|
payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
|
|
3062
3587
|
id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
|
|
3063
|
-
product_id: (
|
|
3064
|
-
quantity: (
|
|
3588
|
+
product_id: (_ref41 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref41 !== void 0 ? _ref41 : product === null || product === void 0 ? void 0 : product.id,
|
|
3589
|
+
quantity: (_ref42 = (_ref43 = (_sourceProduct$quanti = sourceProduct.quantity) !== null && _sourceProduct$quanti !== void 0 ? _sourceProduct$quanti : sourceProduct.num) !== null && _ref43 !== void 0 ? _ref43 : product === null || product === void 0 ? void 0 : product.quantity) !== null && _ref42 !== void 0 ? _ref42 : 1,
|
|
3065
3590
|
price: (_sourceProduct$price = sourceProduct.price) !== null && _sourceProduct$price !== void 0 ? _sourceProduct$price : normalizedProductRaw.price,
|
|
3066
|
-
selling_price: (
|
|
3591
|
+
selling_price: (_ref44 = (_ref45 = (_sourceProduct$sellin = sourceProduct.selling_price) !== null && _sourceProduct$sellin !== void 0 ? _sourceProduct$sellin : sourceProduct.price) !== null && _ref45 !== void 0 ? _ref45 : normalizedProductRaw.selling_price) !== null && _ref44 !== void 0 ? _ref44 : normalizedProductRaw.price,
|
|
3067
3592
|
metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
|
|
3068
3593
|
}),
|
|
3069
3594
|
sourceProduct: sourceProduct
|
|
@@ -3082,29 +3607,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3082
3607
|
}, {
|
|
3083
3608
|
key: "removeExistingStagedLines",
|
|
3084
3609
|
value: (function () {
|
|
3085
|
-
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3610
|
+
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(ownershipKey) {
|
|
3086
3611
|
var _this$getTempOrder;
|
|
3087
3612
|
var existingLines;
|
|
3088
|
-
return _regeneratorRuntime().wrap(function
|
|
3089
|
-
while (1) switch (
|
|
3613
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3614
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3090
3615
|
case 0:
|
|
3091
3616
|
existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
|
|
3092
3617
|
var _product$metadata4;
|
|
3093
3618
|
return (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4[ownershipKey]) === true;
|
|
3094
3619
|
});
|
|
3095
3620
|
if (!(existingLines.length > 0)) {
|
|
3096
|
-
|
|
3621
|
+
_context31.next = 4;
|
|
3097
3622
|
break;
|
|
3098
3623
|
}
|
|
3099
|
-
|
|
3624
|
+
_context31.next = 4;
|
|
3100
3625
|
return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
|
|
3101
3626
|
case 4:
|
|
3102
3627
|
case "end":
|
|
3103
|
-
return
|
|
3628
|
+
return _context31.stop();
|
|
3104
3629
|
}
|
|
3105
|
-
},
|
|
3630
|
+
}, _callee31, this);
|
|
3106
3631
|
}));
|
|
3107
|
-
function removeExistingStagedLines(
|
|
3632
|
+
function removeExistingStagedLines(_x16) {
|
|
3108
3633
|
return _removeExistingStagedLines.apply(this, arguments);
|
|
3109
3634
|
}
|
|
3110
3635
|
return removeExistingStagedLines;
|
|
@@ -3112,25 +3637,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3112
3637
|
}, {
|
|
3113
3638
|
key: "stageProducts",
|
|
3114
3639
|
value: function () {
|
|
3115
|
-
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3640
|
+
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params, ownershipKey) {
|
|
3116
3641
|
var _params$rawProducts;
|
|
3117
3642
|
var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
|
|
3118
|
-
return _regeneratorRuntime().wrap(function
|
|
3119
|
-
while (1) switch (
|
|
3643
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3644
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3120
3645
|
case 0:
|
|
3121
3646
|
productIds = params.productIds || [];
|
|
3122
3647
|
if (productIds.length) {
|
|
3123
|
-
|
|
3648
|
+
_context32.next = 3;
|
|
3124
3649
|
break;
|
|
3125
3650
|
}
|
|
3126
|
-
return
|
|
3651
|
+
return _context32.abrupt("return", this.getTempOrder());
|
|
3127
3652
|
case 3:
|
|
3128
3653
|
if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
|
|
3129
|
-
|
|
3654
|
+
_context32.next = 7;
|
|
3130
3655
|
break;
|
|
3131
3656
|
}
|
|
3132
3657
|
this.unifiedProductCatalog = params.rawProducts;
|
|
3133
|
-
|
|
3658
|
+
_context32.next = 12;
|
|
3134
3659
|
break;
|
|
3135
3660
|
case 7:
|
|
3136
3661
|
existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
|
|
@@ -3141,15 +3666,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3141
3666
|
return !existingIds.has(String(id));
|
|
3142
3667
|
});
|
|
3143
3668
|
if (!(missingIds.length || params.productLoadParams)) {
|
|
3144
|
-
|
|
3669
|
+
_context32.next = 12;
|
|
3145
3670
|
break;
|
|
3146
3671
|
}
|
|
3147
|
-
|
|
3672
|
+
_context32.next = 12;
|
|
3148
3673
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
3149
3674
|
product_ids: productIds.map(Number).filter(Number.isFinite)
|
|
3150
3675
|
}));
|
|
3151
3676
|
case 12:
|
|
3152
|
-
|
|
3677
|
+
_context32.next = 14;
|
|
3153
3678
|
return this.removeExistingStagedLines(ownershipKey);
|
|
3154
3679
|
case 14:
|
|
3155
3680
|
productIdSet = new Set(productIds.map(function (id) {
|
|
@@ -3162,30 +3687,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3162
3687
|
_i = 0, _arr = selectedProducts;
|
|
3163
3688
|
case 17:
|
|
3164
3689
|
if (!(_i < _arr.length)) {
|
|
3165
|
-
|
|
3690
|
+
_context32.next = 26;
|
|
3166
3691
|
break;
|
|
3167
3692
|
}
|
|
3168
3693
|
sourceProduct = _arr[_i];
|
|
3169
3694
|
productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
|
|
3170
3695
|
if (!productInput) {
|
|
3171
|
-
|
|
3696
|
+
_context32.next = 23;
|
|
3172
3697
|
break;
|
|
3173
3698
|
}
|
|
3174
|
-
|
|
3699
|
+
_context32.next = 23;
|
|
3175
3700
|
return this.addProductToOrder(productInput);
|
|
3176
3701
|
case 23:
|
|
3177
3702
|
_i++;
|
|
3178
|
-
|
|
3703
|
+
_context32.next = 17;
|
|
3179
3704
|
break;
|
|
3180
3705
|
case 26:
|
|
3181
|
-
return
|
|
3706
|
+
return _context32.abrupt("return", this.getTempOrder());
|
|
3182
3707
|
case 27:
|
|
3183
3708
|
case "end":
|
|
3184
|
-
return
|
|
3709
|
+
return _context32.stop();
|
|
3185
3710
|
}
|
|
3186
|
-
},
|
|
3711
|
+
}, _callee32, this);
|
|
3187
3712
|
}));
|
|
3188
|
-
function stageProducts(
|
|
3713
|
+
function stageProducts(_x17, _x18) {
|
|
3189
3714
|
return _stageProducts.apply(this, arguments);
|
|
3190
3715
|
}
|
|
3191
3716
|
return stageProducts;
|
|
@@ -3197,18 +3722,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3197
3722
|
}, {
|
|
3198
3723
|
key: "stageRetailProducts",
|
|
3199
3724
|
value: (function () {
|
|
3200
|
-
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3201
|
-
return _regeneratorRuntime().wrap(function
|
|
3202
|
-
while (1) switch (
|
|
3725
|
+
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3726
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3727
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3203
3728
|
case 0:
|
|
3204
|
-
return
|
|
3729
|
+
return _context33.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
|
|
3205
3730
|
case 1:
|
|
3206
3731
|
case "end":
|
|
3207
|
-
return
|
|
3732
|
+
return _context33.stop();
|
|
3208
3733
|
}
|
|
3209
|
-
},
|
|
3734
|
+
}, _callee33, this);
|
|
3210
3735
|
}));
|
|
3211
|
-
function stageRetailProducts(
|
|
3736
|
+
function stageRetailProducts(_x19) {
|
|
3212
3737
|
return _stageRetailProducts.apply(this, arguments);
|
|
3213
3738
|
}
|
|
3214
3739
|
return stageRetailProducts;
|
|
@@ -3222,20 +3747,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3222
3747
|
}, {
|
|
3223
3748
|
key: "addRetailProduct",
|
|
3224
3749
|
value: (function () {
|
|
3225
|
-
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3226
|
-
var _params$quantity,
|
|
3750
|
+
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3751
|
+
var _params$quantity, _ref46, _params$productId, _params$product, _params$product2;
|
|
3227
3752
|
var quantity, productId, sourceProduct, products, orderProduct;
|
|
3228
|
-
return _regeneratorRuntime().wrap(function
|
|
3229
|
-
while (1) switch (
|
|
3753
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3754
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3230
3755
|
case 0:
|
|
3231
3756
|
quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
|
|
3232
3757
|
if (!(!Number.isFinite(quantity) || quantity <= 0)) {
|
|
3233
|
-
|
|
3758
|
+
_context34.next = 3;
|
|
3234
3759
|
break;
|
|
3235
3760
|
}
|
|
3236
3761
|
throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
|
|
3237
3762
|
case 3:
|
|
3238
|
-
productId = (
|
|
3763
|
+
productId = (_ref46 = (_params$productId = params.productId) !== null && _params$productId !== void 0 ? _params$productId : (_params$product = params.product) === null || _params$product === void 0 ? void 0 : _params$product.id) !== null && _ref46 !== void 0 ? _ref46 : (_params$product2 = params.product) === null || _params$product2 === void 0 ? void 0 : _params$product2.product_id;
|
|
3239
3764
|
sourceProduct = params.product;
|
|
3240
3765
|
if (!sourceProduct && productId !== undefined && productId !== null) {
|
|
3241
3766
|
sourceProduct = this.unifiedProductCatalog.find(function (product) {
|
|
@@ -3244,22 +3769,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3244
3769
|
});
|
|
3245
3770
|
}
|
|
3246
3771
|
if (!(!sourceProduct && productId !== undefined && productId !== null)) {
|
|
3247
|
-
|
|
3772
|
+
_context34.next = 11;
|
|
3248
3773
|
break;
|
|
3249
3774
|
}
|
|
3250
|
-
|
|
3775
|
+
_context34.next = 9;
|
|
3251
3776
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
3252
3777
|
product_ids: [Number(productId)].filter(Number.isFinite)
|
|
3253
3778
|
}));
|
|
3254
3779
|
case 9:
|
|
3255
|
-
products =
|
|
3780
|
+
products = _context34.sent;
|
|
3256
3781
|
sourceProduct = products.find(function (product) {
|
|
3257
3782
|
var _product$id4;
|
|
3258
3783
|
return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
|
|
3259
3784
|
});
|
|
3260
3785
|
case 11:
|
|
3261
3786
|
if (sourceProduct) {
|
|
3262
|
-
|
|
3787
|
+
_context34.next = 13;
|
|
3263
3788
|
break;
|
|
3264
3789
|
}
|
|
3265
3790
|
throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
|
|
@@ -3268,19 +3793,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3268
3793
|
quantity: quantity
|
|
3269
3794
|
}), 'unified_booking_sales_retail');
|
|
3270
3795
|
if (orderProduct) {
|
|
3271
|
-
|
|
3796
|
+
_context34.next = 16;
|
|
3272
3797
|
break;
|
|
3273
3798
|
}
|
|
3274
3799
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
3275
3800
|
case 16:
|
|
3276
|
-
return
|
|
3801
|
+
return _context34.abrupt("return", this.addProductToOrder(orderProduct));
|
|
3277
3802
|
case 17:
|
|
3278
3803
|
case "end":
|
|
3279
|
-
return
|
|
3804
|
+
return _context34.stop();
|
|
3280
3805
|
}
|
|
3281
|
-
},
|
|
3806
|
+
}, _callee34, this);
|
|
3282
3807
|
}));
|
|
3283
|
-
function addRetailProduct(
|
|
3808
|
+
function addRetailProduct(_x20) {
|
|
3284
3809
|
return _addRetailProduct.apply(this, arguments);
|
|
3285
3810
|
}
|
|
3286
3811
|
return addRetailProduct;
|
|
@@ -3380,7 +3905,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3380
3905
|
}, {
|
|
3381
3906
|
key: "buildAvailabilityOperatingHoursSnapshot",
|
|
3382
3907
|
value: function buildAvailabilityOperatingHoursSnapshot(params) {
|
|
3383
|
-
var
|
|
3908
|
+
var _this7 = this;
|
|
3384
3909
|
var descriptor = params.prepare._availabilityOperatingHours || {
|
|
3385
3910
|
source: params.prepare.businessHours ? 'prepare_business_hours' : 'default_business_hours',
|
|
3386
3911
|
scheduleIds: []
|
|
@@ -3390,13 +3915,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3390
3915
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3391
3916
|
startAt: "".concat(date, "T").concat(params.businessHours.startTime, ":00"),
|
|
3392
3917
|
endAt: "".concat(date, "T").concat(params.businessHours.endTime, ":00"),
|
|
3393
|
-
fixedOffsetMinutes:
|
|
3918
|
+
fixedOffsetMinutes: _this7.getAvailabilityRuntimeOffsetMinutes(),
|
|
3394
3919
|
rollOverEnd: true
|
|
3395
3920
|
});
|
|
3396
3921
|
return range ? [{
|
|
3397
3922
|
startAt: range.startAt,
|
|
3398
3923
|
endAt: range.endAt,
|
|
3399
|
-
source: descriptor.source
|
|
3924
|
+
source: descriptor.source,
|
|
3925
|
+
businessDate: date,
|
|
3926
|
+
openingAnchorAt: range.startAt
|
|
3400
3927
|
}] : [];
|
|
3401
3928
|
});
|
|
3402
3929
|
return {
|
|
@@ -3425,13 +3952,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3425
3952
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3426
3953
|
startAt: slot.start_at,
|
|
3427
3954
|
endAt: slot.end_at,
|
|
3428
|
-
fixedOffsetMinutes:
|
|
3955
|
+
fixedOffsetMinutes: _this7.getAvailabilityRuntimeOffsetMinutes(),
|
|
3429
3956
|
rollOverEnd: true
|
|
3430
3957
|
});
|
|
3431
3958
|
return range ? [{
|
|
3432
3959
|
startAt: range.startAt,
|
|
3433
3960
|
endAt: range.endAt,
|
|
3434
|
-
source: "operating_schedule:".concat(descriptor.scheduleIds.map(String).join(','))
|
|
3961
|
+
source: "operating_schedule:".concat(descriptor.scheduleIds.map(String).join(',')),
|
|
3962
|
+
businessDate: date
|
|
3435
3963
|
}] : [];
|
|
3436
3964
|
});
|
|
3437
3965
|
});
|
|
@@ -3441,13 +3969,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3441
3969
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3442
3970
|
startAt: slot.start_at,
|
|
3443
3971
|
endAt: slot.end_at,
|
|
3444
|
-
fixedOffsetMinutes:
|
|
3972
|
+
fixedOffsetMinutes: _this7.getAvailabilityRuntimeOffsetMinutes(),
|
|
3445
3973
|
rollOverEnd: true
|
|
3446
3974
|
});
|
|
3447
3975
|
return range ? [{
|
|
3448
3976
|
startAt: range.startAt,
|
|
3449
3977
|
endAt: range.endAt,
|
|
3450
3978
|
source: "operating_schedule_excluded:".concat(schedule.id),
|
|
3979
|
+
businessDate: date,
|
|
3451
3980
|
raw: {
|
|
3452
3981
|
scheduleId: schedule.id,
|
|
3453
3982
|
excludedDate: date
|
|
@@ -3456,6 +3985,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3456
3985
|
});
|
|
3457
3986
|
});
|
|
3458
3987
|
});
|
|
3988
|
+
// All lunch-break windows share the first opening of their business day.
|
|
3989
|
+
var openings = new Map();
|
|
3990
|
+
[].concat(_toConsumableArray(windows), _toConsumableArray(excludedWindows)).forEach(function (window) {
|
|
3991
|
+
var date = window.businessDate || window.startAt.slice(0, 10);
|
|
3992
|
+
var previous = openings.get(date);
|
|
3993
|
+
if (!previous || window.startAt < previous) openings.set(date, window.startAt);
|
|
3994
|
+
});
|
|
3995
|
+
[].concat(_toConsumableArray(windows), _toConsumableArray(excludedWindows)).forEach(function (window) {
|
|
3996
|
+
window.openingAnchorAt = openings.get(window.businessDate || window.startAt.slice(0, 10));
|
|
3997
|
+
});
|
|
3459
3998
|
return _objectSpread({
|
|
3460
3999
|
source: descriptor.source,
|
|
3461
4000
|
scheduleIds: _toConsumableArray(descriptor.scheduleIds),
|
|
@@ -3468,46 +4007,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3468
4007
|
}, {
|
|
3469
4008
|
key: "loadAvailabilityProducts",
|
|
3470
4009
|
value: function () {
|
|
3471
|
-
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4010
|
+
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3472
4011
|
var _prepare$catalogScope,
|
|
3473
4012
|
_prepare$catalogScope2,
|
|
3474
|
-
|
|
4013
|
+
_this8 = this,
|
|
3475
4014
|
_prepare$resourceIds;
|
|
3476
4015
|
var prepare, dateRange, explicitProductIds, rawProducts, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
|
|
3477
|
-
return _regeneratorRuntime().wrap(function
|
|
3478
|
-
while (1) switch (
|
|
4016
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
4017
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3479
4018
|
case 0:
|
|
3480
4019
|
prepare = params.prepare, dateRange = params.dateRange;
|
|
3481
4020
|
explicitProductIds = prepare.productIds || [];
|
|
3482
4021
|
rawProducts = [];
|
|
3483
4022
|
if (!Array.isArray(prepare.rawProducts)) {
|
|
3484
|
-
|
|
4023
|
+
_context35.next = 8;
|
|
3485
4024
|
break;
|
|
3486
4025
|
}
|
|
3487
4026
|
rawProducts = prepare.rawProducts;
|
|
3488
4027
|
this.unifiedProductCatalog = _toConsumableArray(rawProducts);
|
|
3489
|
-
|
|
4028
|
+
_context35.next = 34;
|
|
3490
4029
|
break;
|
|
3491
4030
|
case 8:
|
|
3492
4031
|
if (!(explicitProductIds.length > 0)) {
|
|
3493
|
-
|
|
4032
|
+
_context35.next = 14;
|
|
3494
4033
|
break;
|
|
3495
4034
|
}
|
|
3496
|
-
|
|
4035
|
+
_context35.next = 11;
|
|
3497
4036
|
return this.loadProducts({
|
|
3498
4037
|
product_ids: explicitProductIds,
|
|
3499
4038
|
schedule_date: dateRange.startDate
|
|
3500
4039
|
});
|
|
3501
4040
|
case 11:
|
|
3502
|
-
rawProducts =
|
|
3503
|
-
|
|
4041
|
+
rawProducts = _context35.sent;
|
|
4042
|
+
_context35.next = 34;
|
|
3504
4043
|
break;
|
|
3505
4044
|
case 14:
|
|
3506
4045
|
if (!(((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'schedule')) {
|
|
3507
|
-
|
|
4046
|
+
_context35.next = 30;
|
|
3508
4047
|
break;
|
|
3509
4048
|
}
|
|
3510
|
-
|
|
4049
|
+
_context35.next = 17;
|
|
3511
4050
|
return this.loadScheduleAvailableDate({
|
|
3512
4051
|
startDate: dateRange.startDate,
|
|
3513
4052
|
endDate: dateRange.endDate,
|
|
@@ -3523,44 +4062,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3523
4062
|
});
|
|
3524
4063
|
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)) || [])));
|
|
3525
4064
|
if (!(productIds.length > 0)) {
|
|
3526
|
-
|
|
4065
|
+
_context35.next = 27;
|
|
3527
4066
|
break;
|
|
3528
4067
|
}
|
|
3529
4068
|
assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
|
|
3530
|
-
|
|
4069
|
+
_context35.next = 24;
|
|
3531
4070
|
return this.loadProducts({
|
|
3532
4071
|
product_ids: productIds,
|
|
3533
4072
|
schedule_date: dateRange.startDate
|
|
3534
4073
|
});
|
|
3535
4074
|
case 24:
|
|
3536
|
-
rawProducts =
|
|
3537
|
-
|
|
4075
|
+
rawProducts = _context35.sent;
|
|
4076
|
+
_context35.next = 28;
|
|
3538
4077
|
break;
|
|
3539
4078
|
case 27:
|
|
3540
4079
|
this.unifiedProductCatalog = [];
|
|
3541
4080
|
case 28:
|
|
3542
|
-
|
|
4081
|
+
_context35.next = 34;
|
|
3543
4082
|
break;
|
|
3544
4083
|
case 30:
|
|
3545
4084
|
if (!(((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList')) {
|
|
3546
|
-
|
|
4085
|
+
_context35.next = 34;
|
|
3547
4086
|
break;
|
|
3548
4087
|
}
|
|
3549
|
-
|
|
4088
|
+
_context35.next = 33;
|
|
3550
4089
|
return this.loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
|
|
3551
4090
|
schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
|
|
3552
4091
|
}));
|
|
3553
4092
|
case 33:
|
|
3554
|
-
rawProducts =
|
|
4093
|
+
rawProducts = _context35.sent;
|
|
3555
4094
|
case 34:
|
|
3556
4095
|
normalized = rawProducts.map(function (product) {
|
|
3557
|
-
return normalizeProductForAvailability(product, params.scheduleList,
|
|
4096
|
+
return normalizeProductForAvailability(product, params.scheduleList, _this8.getAvailabilityRuntimeOffsetMinutes());
|
|
3558
4097
|
});
|
|
3559
4098
|
if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
|
|
3560
|
-
|
|
4099
|
+
_context35.next = 37;
|
|
3561
4100
|
break;
|
|
3562
4101
|
}
|
|
3563
|
-
return
|
|
4102
|
+
return _context35.abrupt("return", normalized.filter(function (product) {
|
|
3564
4103
|
var _product$requirementG2;
|
|
3565
4104
|
return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
|
|
3566
4105
|
var _group$resourceIds3;
|
|
@@ -3573,16 +4112,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3573
4112
|
}));
|
|
3574
4113
|
case 37:
|
|
3575
4114
|
productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
|
|
3576
|
-
return
|
|
4115
|
+
return _context35.abrupt("return", productIdSet ? normalized.filter(function (product) {
|
|
3577
4116
|
return productIdSet.has(String(product.id));
|
|
3578
4117
|
}) : normalized);
|
|
3579
4118
|
case 39:
|
|
3580
4119
|
case "end":
|
|
3581
|
-
return
|
|
4120
|
+
return _context35.stop();
|
|
3582
4121
|
}
|
|
3583
|
-
},
|
|
4122
|
+
}, _callee35, this);
|
|
3584
4123
|
}));
|
|
3585
|
-
function loadAvailabilityProducts(
|
|
4124
|
+
function loadAvailabilityProducts(_x21) {
|
|
3586
4125
|
return _loadAvailabilityProducts.apply(this, arguments);
|
|
3587
4126
|
}
|
|
3588
4127
|
return loadAvailabilityProducts;
|
|
@@ -3595,12 +4134,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3595
4134
|
}, {
|
|
3596
4135
|
key: "fetchAvailabilityResourcesV2",
|
|
3597
4136
|
value: (function () {
|
|
3598
|
-
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4137
|
+
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3599
4138
|
var response, data;
|
|
3600
|
-
return _regeneratorRuntime().wrap(function
|
|
3601
|
-
while (1) switch (
|
|
4139
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
4140
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3602
4141
|
case 0:
|
|
3603
|
-
|
|
4142
|
+
_context36.next = 2;
|
|
3604
4143
|
return this.request.get('/schedule/resource/list/v2', {
|
|
3605
4144
|
start_date: params.dateRange.startDate,
|
|
3606
4145
|
end_date: params.dateRange.endDate,
|
|
@@ -3610,28 +4149,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3610
4149
|
useCache: false
|
|
3611
4150
|
});
|
|
3612
4151
|
case 2:
|
|
3613
|
-
response =
|
|
4152
|
+
response = _context36.sent;
|
|
3614
4153
|
data = response === null || response === void 0 ? void 0 : response.data;
|
|
3615
4154
|
if (!Array.isArray(data)) {
|
|
3616
|
-
|
|
4155
|
+
_context36.next = 6;
|
|
3617
4156
|
break;
|
|
3618
4157
|
}
|
|
3619
|
-
return
|
|
4158
|
+
return _context36.abrupt("return", data);
|
|
3620
4159
|
case 6:
|
|
3621
4160
|
if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
|
|
3622
|
-
|
|
4161
|
+
_context36.next = 8;
|
|
3623
4162
|
break;
|
|
3624
4163
|
}
|
|
3625
|
-
return
|
|
4164
|
+
return _context36.abrupt("return", data.list);
|
|
3626
4165
|
case 8:
|
|
3627
|
-
return
|
|
4166
|
+
return _context36.abrupt("return", []);
|
|
3628
4167
|
case 9:
|
|
3629
4168
|
case "end":
|
|
3630
|
-
return
|
|
4169
|
+
return _context36.stop();
|
|
3631
4170
|
}
|
|
3632
|
-
},
|
|
4171
|
+
}, _callee36, this);
|
|
3633
4172
|
}));
|
|
3634
|
-
function fetchAvailabilityResourcesV2(
|
|
4173
|
+
function fetchAvailabilityResourcesV2(_x22) {
|
|
3635
4174
|
return _fetchAvailabilityResourcesV.apply(this, arguments);
|
|
3636
4175
|
}
|
|
3637
4176
|
return fetchAvailabilityResourcesV2;
|
|
@@ -3639,17 +4178,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3639
4178
|
}, {
|
|
3640
4179
|
key: "fetchAndPublishAvailabilityResourcesV2",
|
|
3641
4180
|
value: function () {
|
|
3642
|
-
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4181
|
+
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
3643
4182
|
var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
|
|
3644
|
-
return _regeneratorRuntime().wrap(function
|
|
3645
|
-
while (1) switch (
|
|
4183
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
4184
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3646
4185
|
case 0:
|
|
3647
4186
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3648
4187
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3649
|
-
|
|
4188
|
+
_context37.next = 3;
|
|
3650
4189
|
break;
|
|
3651
4190
|
}
|
|
3652
|
-
return
|
|
4191
|
+
return _context37.abrupt("return", []);
|
|
3653
4192
|
case 3:
|
|
3654
4193
|
scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
3655
4194
|
cacheParams = {
|
|
@@ -3659,7 +4198,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3659
4198
|
};
|
|
3660
4199
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3661
4200
|
if (!cachedRawResources) {
|
|
3662
|
-
|
|
4201
|
+
_context37.next = 9;
|
|
3663
4202
|
break;
|
|
3664
4203
|
}
|
|
3665
4204
|
if (params.useCacheOnHit) {
|
|
@@ -3671,23 +4210,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3671
4210
|
console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
|
|
3672
4211
|
});
|
|
3673
4212
|
}
|
|
3674
|
-
return
|
|
4213
|
+
return _context37.abrupt("return", cachedRawResources);
|
|
3675
4214
|
case 9:
|
|
3676
|
-
|
|
4215
|
+
_context37.next = 11;
|
|
3677
4216
|
return this.refreshAvailabilityRemoteResourceQuery({
|
|
3678
4217
|
timezone: params.timezone,
|
|
3679
4218
|
dateRange: params.dateRange,
|
|
3680
4219
|
resourceIds: normalizedResourceIds
|
|
3681
4220
|
});
|
|
3682
4221
|
case 11:
|
|
3683
|
-
return
|
|
4222
|
+
return _context37.abrupt("return", _context37.sent);
|
|
3684
4223
|
case 12:
|
|
3685
4224
|
case "end":
|
|
3686
|
-
return
|
|
4225
|
+
return _context37.stop();
|
|
3687
4226
|
}
|
|
3688
|
-
},
|
|
4227
|
+
}, _callee37, this);
|
|
3689
4228
|
}));
|
|
3690
|
-
function fetchAndPublishAvailabilityResourcesV2(
|
|
4229
|
+
function fetchAndPublishAvailabilityResourcesV2(_x23) {
|
|
3691
4230
|
return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
|
|
3692
4231
|
}
|
|
3693
4232
|
return fetchAndPublishAvailabilityResourcesV2;
|
|
@@ -3695,17 +4234,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3695
4234
|
}, {
|
|
3696
4235
|
key: "refreshAvailabilityRemoteResourceQuery",
|
|
3697
4236
|
value: function () {
|
|
3698
|
-
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4237
|
+
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
3699
4238
|
var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
|
|
3700
|
-
return _regeneratorRuntime().wrap(function
|
|
3701
|
-
while (1) switch (
|
|
4239
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
4240
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3702
4241
|
case 0:
|
|
3703
4242
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3704
4243
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3705
|
-
|
|
4244
|
+
_context38.next = 3;
|
|
3706
4245
|
break;
|
|
3707
4246
|
}
|
|
3708
|
-
return
|
|
4247
|
+
return _context38.abrupt("return", []);
|
|
3709
4248
|
case 3:
|
|
3710
4249
|
queryKey = this.buildAvailabilityRemoteResourceQueryKey({
|
|
3711
4250
|
timezone: params.timezone,
|
|
@@ -3715,13 +4254,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3715
4254
|
epoch = this.availabilityRemoteResourceEpoch;
|
|
3716
4255
|
existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3717
4256
|
if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
|
|
3718
|
-
|
|
4257
|
+
_context38.next = 10;
|
|
3719
4258
|
break;
|
|
3720
4259
|
}
|
|
3721
|
-
|
|
4260
|
+
_context38.next = 9;
|
|
3722
4261
|
return existing.promise;
|
|
3723
4262
|
case 9:
|
|
3724
|
-
return
|
|
4263
|
+
return _context38.abrupt("return", _context38.sent);
|
|
3725
4264
|
case 10:
|
|
3726
4265
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
3727
4266
|
writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
@@ -3733,11 +4272,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3733
4272
|
epoch: epoch,
|
|
3734
4273
|
promise: promise
|
|
3735
4274
|
});
|
|
3736
|
-
|
|
3737
|
-
|
|
4275
|
+
_context38.prev = 14;
|
|
4276
|
+
_context38.next = 17;
|
|
3738
4277
|
return promise;
|
|
3739
4278
|
case 17:
|
|
3740
|
-
rawResources =
|
|
4279
|
+
rawResources = _context38.sent;
|
|
3741
4280
|
if (epoch === this.availabilityRemoteResourceEpoch) {
|
|
3742
4281
|
this.availabilityRemoteOccupancyCache.publish({
|
|
3743
4282
|
scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
|
|
@@ -3748,21 +4287,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3748
4287
|
version: writeVersion
|
|
3749
4288
|
});
|
|
3750
4289
|
}
|
|
3751
|
-
return
|
|
4290
|
+
return _context38.abrupt("return", rawResources);
|
|
3752
4291
|
case 20:
|
|
3753
|
-
|
|
4292
|
+
_context38.prev = 20;
|
|
3754
4293
|
current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3755
4294
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
3756
4295
|
this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
|
|
3757
4296
|
}
|
|
3758
|
-
return
|
|
4297
|
+
return _context38.finish(20);
|
|
3759
4298
|
case 24:
|
|
3760
4299
|
case "end":
|
|
3761
|
-
return
|
|
4300
|
+
return _context38.stop();
|
|
3762
4301
|
}
|
|
3763
|
-
},
|
|
4302
|
+
}, _callee38, this, [[14,, 20, 24]]);
|
|
3764
4303
|
}));
|
|
3765
|
-
function refreshAvailabilityRemoteResourceQuery(
|
|
4304
|
+
function refreshAvailabilityRemoteResourceQuery(_x24) {
|
|
3766
4305
|
return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
|
|
3767
4306
|
}
|
|
3768
4307
|
return refreshAvailabilityRemoteResourceQuery;
|
|
@@ -3770,26 +4309,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3770
4309
|
}, {
|
|
3771
4310
|
key: "loadAvailabilityResources",
|
|
3772
4311
|
value: function () {
|
|
3773
|
-
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4312
|
+
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
3774
4313
|
var resourceIds, cachedRawResources, rawResources;
|
|
3775
|
-
return _regeneratorRuntime().wrap(function
|
|
3776
|
-
while (1) switch (
|
|
4314
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4315
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3777
4316
|
case 0:
|
|
3778
4317
|
resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
|
|
3779
4318
|
if (!(resourceIds.length === 0)) {
|
|
3780
|
-
|
|
4319
|
+
_context39.next = 3;
|
|
3781
4320
|
break;
|
|
3782
4321
|
}
|
|
3783
|
-
return
|
|
4322
|
+
return _context39.abrupt("return", {
|
|
3784
4323
|
resources: [],
|
|
3785
4324
|
resourceOccupancies: []
|
|
3786
4325
|
});
|
|
3787
4326
|
case 3:
|
|
3788
4327
|
if (!Array.isArray(params.rawResources)) {
|
|
3789
|
-
|
|
4328
|
+
_context39.next = 5;
|
|
3790
4329
|
break;
|
|
3791
4330
|
}
|
|
3792
|
-
return
|
|
4331
|
+
return _context39.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3793
4332
|
rawResources: params.rawResources,
|
|
3794
4333
|
scheduleList: params.scheduleList,
|
|
3795
4334
|
dateRange: params.dateRange,
|
|
@@ -3797,7 +4336,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3797
4336
|
}));
|
|
3798
4337
|
case 5:
|
|
3799
4338
|
if (!(params.fetchPolicy === 'cache_only')) {
|
|
3800
|
-
|
|
4339
|
+
_context39.next = 10;
|
|
3801
4340
|
break;
|
|
3802
4341
|
}
|
|
3803
4342
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read({
|
|
@@ -3806,22 +4345,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3806
4345
|
dateRange: params.dateRange
|
|
3807
4346
|
});
|
|
3808
4347
|
if (!cachedRawResources) {
|
|
3809
|
-
|
|
4348
|
+
_context39.next = 9;
|
|
3810
4349
|
break;
|
|
3811
4350
|
}
|
|
3812
|
-
return
|
|
4351
|
+
return _context39.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3813
4352
|
rawResources: cachedRawResources,
|
|
3814
4353
|
scheduleList: params.scheduleList,
|
|
3815
4354
|
dateRange: params.dateRange,
|
|
3816
4355
|
fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
|
|
3817
4356
|
}));
|
|
3818
4357
|
case 9:
|
|
3819
|
-
return
|
|
4358
|
+
return _context39.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
|
|
3820
4359
|
resources: [],
|
|
3821
4360
|
resourceOccupancies: []
|
|
3822
4361
|
});
|
|
3823
4362
|
case 10:
|
|
3824
|
-
|
|
4363
|
+
_context39.next = 12;
|
|
3825
4364
|
return this.fetchAndPublishAvailabilityResourcesV2({
|
|
3826
4365
|
timezone: params.timezone,
|
|
3827
4366
|
dateRange: params.dateRange,
|
|
@@ -3829,8 +4368,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3829
4368
|
useCacheOnHit: true
|
|
3830
4369
|
});
|
|
3831
4370
|
case 12:
|
|
3832
|
-
rawResources =
|
|
3833
|
-
return
|
|
4371
|
+
rawResources = _context39.sent;
|
|
4372
|
+
return _context39.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3834
4373
|
rawResources: rawResources,
|
|
3835
4374
|
scheduleList: params.scheduleList,
|
|
3836
4375
|
dateRange: params.dateRange,
|
|
@@ -3838,11 +4377,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3838
4377
|
}));
|
|
3839
4378
|
case 14:
|
|
3840
4379
|
case "end":
|
|
3841
|
-
return
|
|
4380
|
+
return _context39.stop();
|
|
3842
4381
|
}
|
|
3843
|
-
},
|
|
4382
|
+
}, _callee39, this);
|
|
3844
4383
|
}));
|
|
3845
|
-
function loadAvailabilityResources(
|
|
4384
|
+
function loadAvailabilityResources(_x25) {
|
|
3846
4385
|
return _loadAvailabilityResources.apply(this, arguments);
|
|
3847
4386
|
}
|
|
3848
4387
|
return loadAvailabilityResources;
|
|
@@ -3862,7 +4401,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3862
4401
|
var products = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) ? tempOrder.products : [];
|
|
3863
4402
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
3864
4403
|
productLineUids.forEach(function (requestedUid) {
|
|
3865
|
-
var
|
|
4404
|
+
var _ref47, _product$booking_uid2, _product$metadata5;
|
|
3866
4405
|
var product = products.find(function (line) {
|
|
3867
4406
|
return getProductLineUid(line) === String(requestedUid);
|
|
3868
4407
|
});
|
|
@@ -3872,7 +4411,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3872
4411
|
});
|
|
3873
4412
|
}
|
|
3874
4413
|
var productUid = getProductLineUid(product);
|
|
3875
|
-
var linkedBookingUid = String((
|
|
4414
|
+
var linkedBookingUid = String((_ref47 = (_product$booking_uid2 = product.booking_uid) !== null && _product$booking_uid2 !== void 0 ? _product$booking_uid2 : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid) !== null && _ref47 !== void 0 ? _ref47 : '');
|
|
3876
4415
|
var linkedBookings = bookings.filter(function (booking) {
|
|
3877
4416
|
var _booking$product_uid;
|
|
3878
4417
|
return linkedBookingUid && getBookingUid(booking) === linkedBookingUid || productUid && String((_booking$product_uid = booking.product_uid) !== null && _booking$product_uid !== void 0 ? _booking$product_uid : '') === productUid;
|
|
@@ -3915,24 +4454,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3915
4454
|
}, {
|
|
3916
4455
|
key: "collectCartResourceOccupancies",
|
|
3917
4456
|
value: function collectCartResourceOccupancies(tempOrder, exclusions) {
|
|
3918
|
-
var
|
|
4457
|
+
var _this9 = this;
|
|
3919
4458
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
3920
4459
|
return bookings.flatMap(function (booking) {
|
|
3921
|
-
var
|
|
4460
|
+
var _ref48, _booking$product_uid2, _booking$metadata2;
|
|
3922
4461
|
var bookingUid = getBookingUid(booking);
|
|
3923
|
-
var productUid = String((
|
|
4462
|
+
var productUid = String((_ref48 = (_booking$product_uid2 = booking.product_uid) !== null && _booking$product_uid2 !== void 0 ? _booking$product_uid2 : (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid) !== null && _ref48 !== void 0 ? _ref48 : '');
|
|
3924
4463
|
var scheduleEventId = toNumberId(booking.schedule_event_id);
|
|
3925
4464
|
var startAt = booking.start_at || "".concat(booking.start_date || '', " ").concat(booking.start_time || '').trim();
|
|
3926
4465
|
var endAt = booking.end_at || "".concat(booking.end_date || booking.start_date || '', " ").concat(booking.end_time || '').trim();
|
|
3927
4466
|
var resources = Array.isArray(booking.resources) ? booking.resources : [];
|
|
3928
4467
|
return resources.flatMap(function (resource) {
|
|
3929
|
-
var
|
|
3930
|
-
var resourceId = (
|
|
4468
|
+
var _ref49, _resource$resource_id, _ref50, _resource$capacity;
|
|
4469
|
+
var resourceId = (_ref49 = (_resource$resource_id = resource.resource_id) !== null && _resource$resource_id !== void 0 ? _resource$resource_id : resource.relation_id) !== null && _ref49 !== void 0 ? _ref49 : resource.id;
|
|
3931
4470
|
if (resourceId == null || !startAt || !endAt) return [];
|
|
3932
4471
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3933
4472
|
startAt: startAt,
|
|
3934
4473
|
endAt: endAt,
|
|
3935
|
-
fixedOffsetMinutes:
|
|
4474
|
+
fixedOffsetMinutes: _this9.getAvailabilityRuntimeOffsetMinutes(),
|
|
3936
4475
|
rollOverEnd: false
|
|
3937
4476
|
});
|
|
3938
4477
|
if (!range) return [];
|
|
@@ -3940,7 +4479,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3940
4479
|
resourceId: resourceId,
|
|
3941
4480
|
startAt: range.startAt,
|
|
3942
4481
|
endAt: range.endAt,
|
|
3943
|
-
pax: Math.max(1, Number((
|
|
4482
|
+
pax: Math.max(1, Number((_ref50 = (_resource$capacity = resource.capacity) !== null && _resource$capacity !== void 0 ? _resource$capacity : booking.capacity) !== null && _ref50 !== void 0 ? _ref50 : 1) || 1),
|
|
3944
4483
|
source: 'cart',
|
|
3945
4484
|
scheduleEventId: scheduleEventId,
|
|
3946
4485
|
bookingUid: bookingUid || undefined,
|
|
@@ -3950,7 +4489,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3950
4489
|
resource: resource
|
|
3951
4490
|
}
|
|
3952
4491
|
};
|
|
3953
|
-
return
|
|
4492
|
+
return _this9.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
|
|
3954
4493
|
});
|
|
3955
4494
|
});
|
|
3956
4495
|
}
|
|
@@ -4017,16 +4556,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4017
4556
|
}, {
|
|
4018
4557
|
key: "assertContextualQueryFreshness",
|
|
4019
4558
|
value: function assertContextualQueryFreshness(context, request) {
|
|
4020
|
-
var
|
|
4559
|
+
var _this10 = this;
|
|
4021
4560
|
if (request.target === 'time') {
|
|
4022
4561
|
request.candidates.forEach(function (candidate) {
|
|
4023
|
-
|
|
4562
|
+
_this10.assertAvailabilityCandidateFreshness(context, candidate);
|
|
4024
4563
|
});
|
|
4025
4564
|
return;
|
|
4026
4565
|
}
|
|
4027
4566
|
if (request.target === 'resource') {
|
|
4028
4567
|
request.selectedRanges.forEach(function (candidate) {
|
|
4029
|
-
|
|
4568
|
+
_this10.assertAvailabilityCandidateFreshness(context, candidate);
|
|
4030
4569
|
});
|
|
4031
4570
|
}
|
|
4032
4571
|
}
|
|
@@ -4073,18 +4612,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4073
4612
|
}, {
|
|
4074
4613
|
key: "buildAvailabilityProjectionSnapshot",
|
|
4075
4614
|
value: function () {
|
|
4076
|
-
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4077
|
-
var
|
|
4615
|
+
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
4616
|
+
var _this11 = this;
|
|
4078
4617
|
var options,
|
|
4079
4618
|
normalizedPrepareParams,
|
|
4080
4619
|
timezoneLabel,
|
|
4081
4620
|
dateRange,
|
|
4621
|
+
scheduleList,
|
|
4622
|
+
products,
|
|
4623
|
+
useDurationTimeGrid,
|
|
4624
|
+
coverageDateRange,
|
|
4082
4625
|
slotStepMinutes,
|
|
4083
4626
|
businessHours,
|
|
4084
4627
|
mode,
|
|
4085
|
-
scheduleList,
|
|
4086
4628
|
operatingHours,
|
|
4087
|
-
products,
|
|
4088
4629
|
loadedResources,
|
|
4089
4630
|
tempOrder,
|
|
4090
4631
|
exclusions,
|
|
@@ -4095,36 +4636,48 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4095
4636
|
durationCandidateAnchorAt,
|
|
4096
4637
|
orderRevision,
|
|
4097
4638
|
projection,
|
|
4098
|
-
|
|
4099
|
-
return _regeneratorRuntime().wrap(function
|
|
4100
|
-
while (1) switch (
|
|
4639
|
+
_args40 = arguments;
|
|
4640
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4641
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4101
4642
|
case 0:
|
|
4102
|
-
options =
|
|
4643
|
+
options = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {};
|
|
4103
4644
|
normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
4104
4645
|
timezoneLabel = String(normalizedPrepareParams.timezone);
|
|
4105
4646
|
dateRange = normalizedPrepareParams.dateRange;
|
|
4647
|
+
scheduleList = this.getAvailabilityScheduleCatalog();
|
|
4648
|
+
_context40.next = 7;
|
|
4649
|
+
return this.loadAvailabilityProducts({
|
|
4650
|
+
prepare: normalizedPrepareParams,
|
|
4651
|
+
dateRange: dateRange,
|
|
4652
|
+
scheduleList: scheduleList
|
|
4653
|
+
});
|
|
4654
|
+
case 7:
|
|
4655
|
+
products = _context40.sent;
|
|
4656
|
+
// Coverage is physical local time; the caller's date range remains business
|
|
4657
|
+
// dates. Keep yesterday's opening and the last business day's overnight tail.
|
|
4658
|
+
useDurationTimeGrid = this.usesDurationTimeGrid() && products.some(function (product) {
|
|
4659
|
+
return product.kind === 'duration';
|
|
4660
|
+
});
|
|
4661
|
+
coverageDateRange = useDurationTimeGrid ? {
|
|
4662
|
+
startDate: formatLocalDate(addLocalCalendarDays(localDateToScalarStart(parseLocalDate(dateRange.startDate)), -1)),
|
|
4663
|
+
endDate: formatLocalDate(addLocalCalendarDays(localDateToScalarStart(parseLocalDate(dateRange.endDate)), 1))
|
|
4664
|
+
} : dateRange;
|
|
4106
4665
|
slotStepMinutes = normalizedPrepareParams.slotStepMinutes || DEFAULT_AVAILABILITY_SLOT_STEP_MINUTES;
|
|
4107
4666
|
businessHours = normalizedPrepareParams.businessHours || DEFAULT_AVAILABILITY_BUSINESS_HOURS;
|
|
4108
4667
|
mode = normalizedPrepareParams.mode || 'appointment';
|
|
4109
|
-
scheduleList = this.getAvailabilityScheduleCatalog();
|
|
4110
4668
|
operatingHours = this.buildAvailabilityOperatingHoursSnapshot({
|
|
4111
4669
|
prepare: normalizedPrepareParams,
|
|
4112
|
-
dateRange:
|
|
4670
|
+
dateRange: useDurationTimeGrid ? {
|
|
4671
|
+
startDate: coverageDateRange.startDate,
|
|
4672
|
+
endDate: dateRange.endDate
|
|
4673
|
+
} : dateRange,
|
|
4113
4674
|
scheduleList: scheduleList,
|
|
4114
4675
|
businessHours: businessHours
|
|
4115
4676
|
});
|
|
4116
|
-
|
|
4117
|
-
return this.loadAvailabilityProducts({
|
|
4118
|
-
prepare: normalizedPrepareParams,
|
|
4119
|
-
dateRange: dateRange,
|
|
4120
|
-
scheduleList: scheduleList
|
|
4121
|
-
});
|
|
4122
|
-
case 11:
|
|
4123
|
-
products = _context34.sent;
|
|
4124
|
-
_context34.next = 14;
|
|
4677
|
+
_context40.next = 16;
|
|
4125
4678
|
return this.loadAvailabilityResources({
|
|
4126
4679
|
timezone: timezoneLabel,
|
|
4127
|
-
dateRange:
|
|
4680
|
+
dateRange: coverageDateRange,
|
|
4128
4681
|
resourceIds: normalizedPrepareParams.resourceIds,
|
|
4129
4682
|
products: products,
|
|
4130
4683
|
rawResources: normalizedPrepareParams.rawResources,
|
|
@@ -4132,15 +4685,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4132
4685
|
fetchPolicy: options.resourceFetchPolicy || 'default',
|
|
4133
4686
|
fallbackResources: options.fallbackResources
|
|
4134
4687
|
});
|
|
4135
|
-
case
|
|
4136
|
-
loadedResources =
|
|
4688
|
+
case 16:
|
|
4689
|
+
loadedResources = _context40.sent;
|
|
4137
4690
|
tempOrder = this.getTempOrder();
|
|
4138
4691
|
exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
|
|
4139
4692
|
injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
|
|
4140
4693
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
4141
4694
|
startAt: occupancy.startAt,
|
|
4142
4695
|
endAt: occupancy.endAt,
|
|
4143
|
-
fixedOffsetMinutes:
|
|
4696
|
+
fixedOffsetMinutes: _this11.getAvailabilityRuntimeOffsetMinutes(),
|
|
4144
4697
|
rollOverEnd: false
|
|
4145
4698
|
});
|
|
4146
4699
|
if (!range) return [];
|
|
@@ -4150,7 +4703,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4150
4703
|
})];
|
|
4151
4704
|
});
|
|
4152
4705
|
remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
|
|
4153
|
-
return !
|
|
4706
|
+
return !_this11.occupancyIsExcluded(occupancy, exclusions);
|
|
4154
4707
|
});
|
|
4155
4708
|
cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
|
|
4156
4709
|
preparedAt = this.getAvailabilityRuntimeDateTime();
|
|
@@ -4163,7 +4716,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4163
4716
|
resourceOccupancies: [].concat(_toConsumableArray(remoteOccupancies), _toConsumableArray(cartOccupancies)),
|
|
4164
4717
|
mode: mode,
|
|
4165
4718
|
timezone: timezoneLabel,
|
|
4166
|
-
coverage:
|
|
4719
|
+
coverage: coverageDateRange,
|
|
4167
4720
|
slotStepMinutes: slotStepMinutes,
|
|
4168
4721
|
businessHours: businessHours,
|
|
4169
4722
|
operatingHours: operatingHours,
|
|
@@ -4179,18 +4732,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4179
4732
|
prepareParams: normalizedPrepareParams,
|
|
4180
4733
|
durationCandidateAnchorAt: durationCandidateAnchorAt
|
|
4181
4734
|
});
|
|
4182
|
-
return
|
|
4735
|
+
return _context40.abrupt("return", {
|
|
4183
4736
|
projection: projection,
|
|
4184
4737
|
prepareParams: normalizedPrepareParams,
|
|
4185
4738
|
orderRevision: orderRevision
|
|
4186
4739
|
});
|
|
4187
|
-
case
|
|
4740
|
+
case 28:
|
|
4188
4741
|
case "end":
|
|
4189
|
-
return
|
|
4742
|
+
return _context40.stop();
|
|
4190
4743
|
}
|
|
4191
|
-
},
|
|
4744
|
+
}, _callee40, this);
|
|
4192
4745
|
}));
|
|
4193
|
-
function buildAvailabilityProjectionSnapshot(
|
|
4746
|
+
function buildAvailabilityProjectionSnapshot(_x26) {
|
|
4194
4747
|
return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
|
|
4195
4748
|
}
|
|
4196
4749
|
return buildAvailabilityProjectionSnapshot;
|
|
@@ -4198,10 +4751,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4198
4751
|
}, {
|
|
4199
4752
|
key: "getSharedPreparedAvailabilitySnapshot",
|
|
4200
4753
|
value: function () {
|
|
4201
|
-
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4754
|
+
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
4202
4755
|
var lifecycleGeneration, normalizedParams, hasRawInputs, prepareKey, snapshot, existing, promise, _snapshot, current;
|
|
4203
|
-
return _regeneratorRuntime().wrap(function
|
|
4204
|
-
while (1) switch (
|
|
4756
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4757
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4205
4758
|
case 0:
|
|
4206
4759
|
lifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
4207
4760
|
normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
@@ -4220,15 +4773,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4220
4773
|
}
|
|
4221
4774
|
})) : this.buildAvailabilityPrepareKey(normalizedParams);
|
|
4222
4775
|
if (!hasRawInputs) {
|
|
4223
|
-
|
|
4776
|
+
_context41.next = 11;
|
|
4224
4777
|
break;
|
|
4225
4778
|
}
|
|
4226
|
-
|
|
4779
|
+
_context41.next = 7;
|
|
4227
4780
|
return this.buildAvailabilityProjectionSnapshot(normalizedParams);
|
|
4228
4781
|
case 7:
|
|
4229
|
-
snapshot =
|
|
4782
|
+
snapshot = _context41.sent;
|
|
4230
4783
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
4231
|
-
|
|
4784
|
+
_context41.next = 10;
|
|
4232
4785
|
break;
|
|
4233
4786
|
}
|
|
4234
4787
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -4237,7 +4790,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4237
4790
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
4238
4791
|
});
|
|
4239
4792
|
case 10:
|
|
4240
|
-
return
|
|
4793
|
+
return _context41.abrupt("return", {
|
|
4241
4794
|
prepareKey: prepareKey,
|
|
4242
4795
|
snapshot: snapshot
|
|
4243
4796
|
});
|
|
@@ -4251,13 +4804,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4251
4804
|
promise: promise
|
|
4252
4805
|
});
|
|
4253
4806
|
}
|
|
4254
|
-
|
|
4255
|
-
|
|
4807
|
+
_context41.prev = 14;
|
|
4808
|
+
_context41.next = 17;
|
|
4256
4809
|
return promise;
|
|
4257
4810
|
case 17:
|
|
4258
|
-
_snapshot =
|
|
4811
|
+
_snapshot = _context41.sent;
|
|
4259
4812
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
4260
|
-
|
|
4813
|
+
_context41.next = 20;
|
|
4261
4814
|
break;
|
|
4262
4815
|
}
|
|
4263
4816
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -4266,24 +4819,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4266
4819
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
4267
4820
|
});
|
|
4268
4821
|
case 20:
|
|
4269
|
-
return
|
|
4822
|
+
return _context41.abrupt("return", {
|
|
4270
4823
|
prepareKey: prepareKey,
|
|
4271
4824
|
snapshot: _snapshot
|
|
4272
4825
|
});
|
|
4273
4826
|
case 21:
|
|
4274
|
-
|
|
4827
|
+
_context41.prev = 21;
|
|
4275
4828
|
current = this.availabilityPrepareInFlight.get(prepareKey);
|
|
4276
4829
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
4277
4830
|
this.availabilityPrepareInFlight.delete(prepareKey);
|
|
4278
4831
|
}
|
|
4279
|
-
return
|
|
4832
|
+
return _context41.finish(21);
|
|
4280
4833
|
case 25:
|
|
4281
4834
|
case "end":
|
|
4282
|
-
return
|
|
4835
|
+
return _context41.stop();
|
|
4283
4836
|
}
|
|
4284
|
-
},
|
|
4837
|
+
}, _callee41, this, [[14,, 21, 25]]);
|
|
4285
4838
|
}));
|
|
4286
|
-
function getSharedPreparedAvailabilitySnapshot(
|
|
4839
|
+
function getSharedPreparedAvailabilitySnapshot(_x27) {
|
|
4287
4840
|
return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
|
|
4288
4841
|
}
|
|
4289
4842
|
return getSharedPreparedAvailabilitySnapshot;
|
|
@@ -4291,51 +4844,51 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4291
4844
|
}, {
|
|
4292
4845
|
key: "refreshAvailabilityContextProjection",
|
|
4293
4846
|
value: function () {
|
|
4294
|
-
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4295
|
-
var
|
|
4847
|
+
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
4848
|
+
var _this12 = this;
|
|
4296
4849
|
var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
|
|
4297
|
-
return _regeneratorRuntime().wrap(function
|
|
4298
|
-
while (1) switch (
|
|
4850
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4851
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4299
4852
|
case 0:
|
|
4300
4853
|
existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
4301
4854
|
if (!existingInFlight) {
|
|
4302
|
-
|
|
4855
|
+
_context43.next = 5;
|
|
4303
4856
|
break;
|
|
4304
4857
|
}
|
|
4305
|
-
|
|
4858
|
+
_context43.next = 4;
|
|
4306
4859
|
return existingInFlight;
|
|
4307
4860
|
case 4:
|
|
4308
|
-
return
|
|
4861
|
+
return _context43.abrupt("return", _context43.sent);
|
|
4309
4862
|
case 5:
|
|
4310
4863
|
context = this.getAvailabilityContextEntry(params.contextId);
|
|
4311
4864
|
expectedVersion = context.activeVersion;
|
|
4312
4865
|
expectedRefreshNonce = context.refreshNonce;
|
|
4313
4866
|
expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
4314
|
-
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4867
|
+
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
4315
4868
|
var snapshot, currentContext, projectionEntry;
|
|
4316
|
-
return _regeneratorRuntime().wrap(function
|
|
4317
|
-
while (1) switch (
|
|
4869
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4870
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4318
4871
|
case 0:
|
|
4319
|
-
|
|
4320
|
-
return
|
|
4872
|
+
_context42.next = 2;
|
|
4873
|
+
return _this12.buildAvailabilityProjectionSnapshot(_this12.cloneAvailabilityPrepareParams(context.prepareParams), {
|
|
4321
4874
|
durationCandidateAnchorAt: context.durationCandidateAnchorAt
|
|
4322
4875
|
});
|
|
4323
4876
|
case 2:
|
|
4324
|
-
snapshot =
|
|
4325
|
-
currentContext =
|
|
4877
|
+
snapshot = _context42.sent;
|
|
4878
|
+
currentContext = _this12.availabilityContextRegistry.get(params.contextId);
|
|
4326
4879
|
if (currentContext) {
|
|
4327
|
-
|
|
4880
|
+
_context42.next = 6;
|
|
4328
4881
|
break;
|
|
4329
4882
|
}
|
|
4330
|
-
return
|
|
4883
|
+
return _context42.abrupt("return", null);
|
|
4331
4884
|
case 6:
|
|
4332
|
-
if (!(expectedLifecycleGeneration !==
|
|
4333
|
-
|
|
4885
|
+
if (!(expectedLifecycleGeneration !== _this12.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
|
|
4886
|
+
_context42.next = 8;
|
|
4334
4887
|
break;
|
|
4335
4888
|
}
|
|
4336
|
-
return
|
|
4889
|
+
return _context42.abrupt("return", null);
|
|
4337
4890
|
case 8:
|
|
4338
|
-
projectionEntry =
|
|
4891
|
+
projectionEntry = _this12.storeAvailabilityProjectionEntry({
|
|
4339
4892
|
contextId: currentContext.contextId,
|
|
4340
4893
|
prepareParams: snapshot.prepareParams,
|
|
4341
4894
|
prepareKey: currentContext.prepareKey,
|
|
@@ -4343,8 +4896,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4343
4896
|
orderRevision: snapshot.orderRevision,
|
|
4344
4897
|
incrementVersion: true
|
|
4345
4898
|
});
|
|
4346
|
-
|
|
4347
|
-
return
|
|
4899
|
+
_context42.next = 11;
|
|
4900
|
+
return _this12.emitAvailabilityDiagnostic({
|
|
4348
4901
|
action: 'refresh',
|
|
4349
4902
|
contextId: currentContext.contextId,
|
|
4350
4903
|
contextVersion: projectionEntry.contextVersion,
|
|
@@ -4355,33 +4908,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4355
4908
|
reason: params.reason
|
|
4356
4909
|
});
|
|
4357
4910
|
case 11:
|
|
4358
|
-
return
|
|
4911
|
+
return _context42.abrupt("return", projectionEntry);
|
|
4359
4912
|
case 12:
|
|
4360
4913
|
case "end":
|
|
4361
|
-
return
|
|
4914
|
+
return _context42.stop();
|
|
4362
4915
|
}
|
|
4363
|
-
},
|
|
4916
|
+
}, _callee42);
|
|
4364
4917
|
}))();
|
|
4365
4918
|
this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
|
|
4366
|
-
|
|
4367
|
-
|
|
4919
|
+
_context43.prev = 11;
|
|
4920
|
+
_context43.next = 14;
|
|
4368
4921
|
return refreshPromise;
|
|
4369
4922
|
case 14:
|
|
4370
|
-
return
|
|
4923
|
+
return _context43.abrupt("return", _context43.sent);
|
|
4371
4924
|
case 15:
|
|
4372
|
-
|
|
4925
|
+
_context43.prev = 15;
|
|
4373
4926
|
current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
4374
4927
|
if (current === refreshPromise) {
|
|
4375
4928
|
this.availabilityProjectionRefreshInFlight.delete(params.contextId);
|
|
4376
4929
|
}
|
|
4377
|
-
return
|
|
4930
|
+
return _context43.finish(15);
|
|
4378
4931
|
case 19:
|
|
4379
4932
|
case "end":
|
|
4380
|
-
return
|
|
4933
|
+
return _context43.stop();
|
|
4381
4934
|
}
|
|
4382
|
-
},
|
|
4935
|
+
}, _callee43, this, [[11,, 15, 19]]);
|
|
4383
4936
|
}));
|
|
4384
|
-
function refreshAvailabilityContextProjection(
|
|
4937
|
+
function refreshAvailabilityContextProjection(_x28) {
|
|
4385
4938
|
return _refreshAvailabilityContextProjection.apply(this, arguments);
|
|
4386
4939
|
}
|
|
4387
4940
|
return refreshAvailabilityContextProjection;
|
|
@@ -4389,53 +4942,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4389
4942
|
}, {
|
|
4390
4943
|
key: "ensureAvailabilityContextProjection",
|
|
4391
4944
|
value: function () {
|
|
4392
|
-
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4945
|
+
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(contextId, reason) {
|
|
4393
4946
|
var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
|
|
4394
|
-
return _regeneratorRuntime().wrap(function
|
|
4395
|
-
while (1) switch (
|
|
4947
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4948
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4396
4949
|
case 0:
|
|
4397
4950
|
retries = 0;
|
|
4398
4951
|
case 1:
|
|
4399
4952
|
if (!(retries < 3)) {
|
|
4400
|
-
|
|
4953
|
+
_context44.next = 19;
|
|
4401
4954
|
break;
|
|
4402
4955
|
}
|
|
4403
4956
|
context = this.getAvailabilityContextEntry(contextId);
|
|
4404
4957
|
currentOrderRevision = this.getCurrentOrderRevision();
|
|
4405
4958
|
projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
|
|
4406
4959
|
if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
|
|
4407
|
-
|
|
4960
|
+
_context44.next = 7;
|
|
4408
4961
|
break;
|
|
4409
4962
|
}
|
|
4410
|
-
return
|
|
4963
|
+
return _context44.abrupt("return", {
|
|
4411
4964
|
context: context,
|
|
4412
4965
|
projectionEntry: projectionEntry,
|
|
4413
4966
|
refreshed: false
|
|
4414
4967
|
});
|
|
4415
4968
|
case 7:
|
|
4416
|
-
|
|
4969
|
+
_context44.next = 9;
|
|
4417
4970
|
return this.refreshAvailabilityContextProjection({
|
|
4418
4971
|
contextId: contextId,
|
|
4419
4972
|
reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
|
|
4420
4973
|
previousOrderRevision: context.lastKnownOrderRevision
|
|
4421
4974
|
});
|
|
4422
4975
|
case 9:
|
|
4423
|
-
refreshedProjectionEntry =
|
|
4976
|
+
refreshedProjectionEntry = _context44.sent;
|
|
4424
4977
|
if (refreshedProjectionEntry) {
|
|
4425
|
-
|
|
4978
|
+
_context44.next = 13;
|
|
4426
4979
|
break;
|
|
4427
4980
|
}
|
|
4428
4981
|
retries += 1;
|
|
4429
|
-
return
|
|
4982
|
+
return _context44.abrupt("continue", 1);
|
|
4430
4983
|
case 13:
|
|
4431
4984
|
if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4432
|
-
|
|
4985
|
+
_context44.next = 16;
|
|
4433
4986
|
break;
|
|
4434
4987
|
}
|
|
4435
4988
|
retries += 1;
|
|
4436
|
-
return
|
|
4989
|
+
return _context44.abrupt("continue", 1);
|
|
4437
4990
|
case 16:
|
|
4438
|
-
return
|
|
4991
|
+
return _context44.abrupt("return", {
|
|
4439
4992
|
context: this.getAvailabilityContextEntry(contextId),
|
|
4440
4993
|
projectionEntry: refreshedProjectionEntry,
|
|
4441
4994
|
refreshed: true
|
|
@@ -4447,11 +5000,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4447
5000
|
});
|
|
4448
5001
|
case 20:
|
|
4449
5002
|
case "end":
|
|
4450
|
-
return
|
|
5003
|
+
return _context44.stop();
|
|
4451
5004
|
}
|
|
4452
|
-
},
|
|
5005
|
+
}, _callee44, this);
|
|
4453
5006
|
}));
|
|
4454
|
-
function ensureAvailabilityContextProjection(
|
|
5007
|
+
function ensureAvailabilityContextProjection(_x29, _x30) {
|
|
4455
5008
|
return _ensureAvailabilityContextProjection.apply(this, arguments);
|
|
4456
5009
|
}
|
|
4457
5010
|
return ensureAvailabilityContextProjection;
|
|
@@ -4459,18 +5012,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4459
5012
|
}, {
|
|
4460
5013
|
key: "tryAcquireAvailabilityCommitLock",
|
|
4461
5014
|
value: function () {
|
|
4462
|
-
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5015
|
+
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(contextId) {
|
|
4463
5016
|
var _currentContext$activ;
|
|
4464
5017
|
var _waitingContext$activ, waitingContext, currentContext;
|
|
4465
|
-
return _regeneratorRuntime().wrap(function
|
|
4466
|
-
while (1) switch (
|
|
5018
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
5019
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4467
5020
|
case 0:
|
|
4468
5021
|
if (!this.availabilityCommitLocks.has(contextId)) {
|
|
4469
|
-
|
|
5022
|
+
_context45.next = 5;
|
|
4470
5023
|
break;
|
|
4471
5024
|
}
|
|
4472
5025
|
waitingContext = this.availabilityContextRegistry.get(contextId);
|
|
4473
|
-
|
|
5026
|
+
_context45.next = 4;
|
|
4474
5027
|
return this.emitAvailabilityDiagnostic({
|
|
4475
5028
|
action: 'commit_lock_wait',
|
|
4476
5029
|
contextId: contextId,
|
|
@@ -4487,7 +5040,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4487
5040
|
case 5:
|
|
4488
5041
|
this.availabilityCommitLocks.add(contextId);
|
|
4489
5042
|
currentContext = this.availabilityContextRegistry.get(contextId);
|
|
4490
|
-
|
|
5043
|
+
_context45.next = 9;
|
|
4491
5044
|
return this.emitAvailabilityDiagnostic({
|
|
4492
5045
|
action: 'commit_lock_acquired',
|
|
4493
5046
|
contextId: contextId,
|
|
@@ -4499,11 +5052,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4499
5052
|
});
|
|
4500
5053
|
case 9:
|
|
4501
5054
|
case "end":
|
|
4502
|
-
return
|
|
5055
|
+
return _context45.stop();
|
|
4503
5056
|
}
|
|
4504
|
-
},
|
|
5057
|
+
}, _callee45, this);
|
|
4505
5058
|
}));
|
|
4506
|
-
function tryAcquireAvailabilityCommitLock(
|
|
5059
|
+
function tryAcquireAvailabilityCommitLock(_x31) {
|
|
4507
5060
|
return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
|
|
4508
5061
|
}
|
|
4509
5062
|
return tryAcquireAvailabilityCommitLock;
|
|
@@ -4511,15 +5064,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4511
5064
|
}, {
|
|
4512
5065
|
key: "releaseAvailabilityCommitLock",
|
|
4513
5066
|
value: function () {
|
|
4514
|
-
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5067
|
+
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(contextId) {
|
|
4515
5068
|
var _releasedContext$acti;
|
|
4516
5069
|
var releasedContext;
|
|
4517
|
-
return _regeneratorRuntime().wrap(function
|
|
4518
|
-
while (1) switch (
|
|
5070
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
5071
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4519
5072
|
case 0:
|
|
4520
5073
|
this.availabilityCommitLocks.delete(contextId);
|
|
4521
5074
|
releasedContext = this.availabilityContextRegistry.get(contextId);
|
|
4522
|
-
|
|
5075
|
+
_context46.next = 4;
|
|
4523
5076
|
return this.emitAvailabilityDiagnostic({
|
|
4524
5077
|
action: 'commit_lock_released',
|
|
4525
5078
|
contextId: contextId,
|
|
@@ -4531,11 +5084,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4531
5084
|
});
|
|
4532
5085
|
case 4:
|
|
4533
5086
|
case "end":
|
|
4534
|
-
return
|
|
5087
|
+
return _context46.stop();
|
|
4535
5088
|
}
|
|
4536
|
-
},
|
|
5089
|
+
}, _callee46, this);
|
|
4537
5090
|
}));
|
|
4538
|
-
function releaseAvailabilityCommitLock(
|
|
5091
|
+
function releaseAvailabilityCommitLock(_x32) {
|
|
4539
5092
|
return _releaseAvailabilityCommitLock.apply(this, arguments);
|
|
4540
5093
|
}
|
|
4541
5094
|
return releaseAvailabilityCommitLock;
|
|
@@ -4543,20 +5096,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4543
5096
|
}, {
|
|
4544
5097
|
key: "prepareAvailabilityProjection",
|
|
4545
5098
|
value: (function () {
|
|
4546
|
-
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5099
|
+
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4547
5100
|
var paramsWithDefaults, _yield$this$getShared, prepareKey, snapshot, contextId, projectionEntry, context, handle, payload;
|
|
4548
|
-
return _regeneratorRuntime().wrap(function
|
|
4549
|
-
while (1) switch (
|
|
5101
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
5102
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4550
5103
|
case 0:
|
|
4551
5104
|
this.assertAvailabilityPrepareParams(params);
|
|
4552
|
-
|
|
5105
|
+
_context47.next = 3;
|
|
4553
5106
|
return this.resolveAvailabilityPrepareDefaults(params);
|
|
4554
5107
|
case 3:
|
|
4555
|
-
paramsWithDefaults =
|
|
4556
|
-
|
|
5108
|
+
paramsWithDefaults = _context47.sent;
|
|
5109
|
+
_context47.next = 6;
|
|
4557
5110
|
return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
|
|
4558
5111
|
case 6:
|
|
4559
|
-
_yield$this$getShared =
|
|
5112
|
+
_yield$this$getShared = _context47.sent;
|
|
4560
5113
|
prepareKey = _yield$this$getShared.prepareKey;
|
|
4561
5114
|
snapshot = _yield$this$getShared.snapshot;
|
|
4562
5115
|
contextId = this.createAvailabilityContextId();
|
|
@@ -4577,7 +5130,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4577
5130
|
refreshed: false,
|
|
4578
5131
|
reason: 'prepare'
|
|
4579
5132
|
};
|
|
4580
|
-
|
|
5133
|
+
_context47.next = 16;
|
|
4581
5134
|
return this.emitAvailabilityDiagnostic({
|
|
4582
5135
|
action: 'prepare',
|
|
4583
5136
|
contextId: contextId,
|
|
@@ -4588,17 +5141,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4588
5141
|
reason: 'prepare'
|
|
4589
5142
|
});
|
|
4590
5143
|
case 16:
|
|
4591
|
-
|
|
5144
|
+
_context47.next = 18;
|
|
4592
5145
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
|
|
4593
5146
|
case 18:
|
|
4594
|
-
return
|
|
5147
|
+
return _context47.abrupt("return", handle);
|
|
4595
5148
|
case 19:
|
|
4596
5149
|
case "end":
|
|
4597
|
-
return
|
|
5150
|
+
return _context47.stop();
|
|
4598
5151
|
}
|
|
4599
|
-
},
|
|
5152
|
+
}, _callee47, this);
|
|
4600
5153
|
}));
|
|
4601
|
-
function prepareAvailabilityProjection(
|
|
5154
|
+
function prepareAvailabilityProjection(_x33) {
|
|
4602
5155
|
return _prepareAvailabilityProjection.apply(this, arguments);
|
|
4603
5156
|
}
|
|
4604
5157
|
return prepareAvailabilityProjection;
|
|
@@ -4606,54 +5159,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4606
5159
|
}, {
|
|
4607
5160
|
key: "getProductTimeRanges",
|
|
4608
5161
|
value: (function () {
|
|
4609
|
-
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4610
|
-
var _this$otherParams$
|
|
5162
|
+
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(contextId) {
|
|
5163
|
+
var _this$otherParams$pla2,
|
|
4611
5164
|
_this$otherParams26,
|
|
4612
|
-
|
|
5165
|
+
_context$prepareParam,
|
|
5166
|
+
_extractFixedOffsetMi,
|
|
5167
|
+
_this13 = this;
|
|
4613
5168
|
var request,
|
|
4614
5169
|
_yield$this$ensureAva,
|
|
4615
5170
|
context,
|
|
4616
5171
|
projectionEntry,
|
|
4617
5172
|
contextVersion,
|
|
4618
5173
|
isPosAvailabilityRequest,
|
|
5174
|
+
isEditingContext,
|
|
5175
|
+
editingOffset,
|
|
5176
|
+
editingStartAtByProductId,
|
|
5177
|
+
dateRange,
|
|
5178
|
+
editingStarts,
|
|
5179
|
+
businessDate,
|
|
5180
|
+
rememberedStartAtByProductId,
|
|
4619
5181
|
allowOutsideOperatingHoursForRequestedStartTimes,
|
|
4620
|
-
|
|
4621
|
-
return _regeneratorRuntime().wrap(function
|
|
4622
|
-
while (1) switch (
|
|
5182
|
+
_args48 = arguments;
|
|
5183
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
5184
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4623
5185
|
case 0:
|
|
4624
|
-
request =
|
|
4625
|
-
|
|
5186
|
+
request = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {};
|
|
5187
|
+
_context48.next = 3;
|
|
4626
5188
|
return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
|
|
4627
5189
|
case 3:
|
|
4628
|
-
_yield$this$ensureAva =
|
|
5190
|
+
_yield$this$ensureAva = _context48.sent;
|
|
4629
5191
|
context = _yield$this$ensureAva.context;
|
|
4630
5192
|
projectionEntry = _yield$this$ensureAva.projectionEntry;
|
|
4631
5193
|
contextVersion = context.activeVersion;
|
|
4632
|
-
isPosAvailabilityRequest = String((_this$otherParams$
|
|
4633
|
-
|
|
5194
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
|
|
5195
|
+
isEditingContext = Boolean((_context$prepareParam = context.prepareParams.editingProductLineUids) === null || _context$prepareParam === void 0 ? void 0 : _context$prepareParam.length);
|
|
5196
|
+
editingOffset = (_extractFixedOffsetMi = extractFixedOffsetMinutes(projectionEntry.projection.meta.now)) !== null && _extractFixedOffsetMi !== void 0 ? _extractFixedOffsetMi : this.getAvailabilityRuntimeOffsetMinutes(); // This new editing input represents an absolute instant. Normalize it once
|
|
5197
|
+
// to the projection's fixed business clock before the wall-clock planner.
|
|
5198
|
+
editingStartAtByProductId = isEditingContext && request.editingStartAtByProductId ? Object.fromEntries(Object.entries(request.editingStartAtByProductId).map(function (_ref52) {
|
|
5199
|
+
var _ref53 = _slicedToArray(_ref52, 2),
|
|
5200
|
+
productId = _ref53[0],
|
|
5201
|
+
startAt = _ref53[1];
|
|
5202
|
+
try {
|
|
5203
|
+
var _extractFixedOffsetMi2;
|
|
5204
|
+
var scalar = localDateTimeToScalar(parseLocalDateTime(startAt));
|
|
5205
|
+
var inputOffset = (_extractFixedOffsetMi2 = extractFixedOffsetMinutes(startAt)) !== null && _extractFixedOffsetMi2 !== void 0 ? _extractFixedOffsetMi2 : editingOffset;
|
|
5206
|
+
return [productId, formatLocalDateTime(scalar + (editingOffset - inputOffset) * 60000, editingOffset)];
|
|
5207
|
+
} catch (_unused5) {
|
|
5208
|
+
throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑开始时间必须是完整有效日期时间');
|
|
5209
|
+
}
|
|
5210
|
+
})) : undefined;
|
|
5211
|
+
dateRange = request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection); // Older edit drafts carry the real calendar date, not a business-date label.
|
|
5212
|
+
// The explicit absolute start disambiguates the previous day's overnight tail.
|
|
5213
|
+
editingStarts = Object.values(editingStartAtByProductId || {});
|
|
5214
|
+
if (this.usesDurationTimeGrid(projectionEntry.projection) && editingStarts.length === 1 && dateRange.startDate === dateRange.endDate && dateRange.startDate === formatLocalDate(parseLocalDateTime(editingStarts[0]))) {
|
|
5215
|
+
businessDate = getDurationBusinessDate(projectionEntry.projection, editingStarts[0]);
|
|
5216
|
+
dateRange = {
|
|
5217
|
+
startDate: businessDate,
|
|
5218
|
+
endDate: businessDate
|
|
5219
|
+
};
|
|
5220
|
+
}
|
|
5221
|
+
rememberedStartAtByProductId = isPosAvailabilityRequest && !isEditingContext ? request.rememberedStartAtByProductId : undefined;
|
|
5222
|
+
allowOutsideOperatingHoursForRequestedStartTimes = isPosAvailabilityRequest && !rememberedStartAtByProductId && (editingStarts.length > 0 || Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
|
|
4634
5223
|
return Array.isArray(startTimes) && startTimes.length > 0;
|
|
4635
|
-
});
|
|
4636
|
-
return
|
|
5224
|
+
}));
|
|
5225
|
+
return _context48.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread(_objectSpread({}, request), {}, {
|
|
5226
|
+
dateRange: dateRange,
|
|
5227
|
+
editingStartAtByProductId: editingStartAtByProductId,
|
|
5228
|
+
rememberedStartAtByProductId: rememberedStartAtByProductId
|
|
5229
|
+
}, rememberedStartAtByProductId ? {
|
|
5230
|
+
allowOutsideOperatingHoursForRequestedStartTimes: false
|
|
5231
|
+
} : {}), allowOutsideOperatingHoursForRequestedStartTimes ? {
|
|
4637
5232
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
4638
5233
|
} : {}), {
|
|
4639
5234
|
evaluatedAt: this.getAvailabilityRuntimeDateTime(),
|
|
5235
|
+
useDurationTimeGrid: this.usesDurationTimeGrid(projectionEntry.projection),
|
|
5236
|
+
enforceSaleCutoff: Boolean(rememberedStartAtByProductId),
|
|
4640
5237
|
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
4641
5238
|
allowSessionCustomRanges: isPosAvailabilityRequest,
|
|
4642
5239
|
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
4643
5240
|
}).map(function (group) {
|
|
4644
5241
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
4645
5242
|
ranges: group.ranges.map(function (candidate) {
|
|
4646
|
-
return
|
|
5243
|
+
return _this13.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
|
|
4647
5244
|
})
|
|
4648
5245
|
});
|
|
4649
5246
|
}));
|
|
4650
|
-
case
|
|
5247
|
+
case 17:
|
|
4651
5248
|
case "end":
|
|
4652
|
-
return
|
|
5249
|
+
return _context48.stop();
|
|
4653
5250
|
}
|
|
4654
|
-
},
|
|
5251
|
+
}, _callee48, this);
|
|
4655
5252
|
}));
|
|
4656
|
-
function getProductTimeRanges(
|
|
5253
|
+
function getProductTimeRanges(_x34) {
|
|
4657
5254
|
return _getProductTimeRanges.apply(this, arguments);
|
|
4658
5255
|
}
|
|
4659
5256
|
return getProductTimeRanges;
|
|
@@ -4661,22 +5258,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4661
5258
|
}, {
|
|
4662
5259
|
key: "queryBookingAvailability",
|
|
4663
5260
|
value: (function () {
|
|
4664
|
-
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4665
|
-
var _this$otherParams$
|
|
4666
|
-
var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
|
|
4667
|
-
return _regeneratorRuntime().wrap(function
|
|
4668
|
-
while (1) switch (
|
|
5261
|
+
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(contextId, request) {
|
|
5262
|
+
var _this$otherParams$pla3, _this$otherParams27, _context$prepareParam2;
|
|
5263
|
+
var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, queryRequest, result, contextVersion, contextualResult;
|
|
5264
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
5265
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4669
5266
|
case 0:
|
|
4670
|
-
|
|
5267
|
+
_context49.next = 2;
|
|
4671
5268
|
return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4672
5269
|
case 2:
|
|
4673
|
-
_yield$this$ensureAva2 =
|
|
5270
|
+
_yield$this$ensureAva2 = _context49.sent;
|
|
4674
5271
|
context = _yield$this$ensureAva2.context;
|
|
4675
5272
|
projectionEntry = _yield$this$ensureAva2.projectionEntry;
|
|
4676
5273
|
refreshed = _yield$this$ensureAva2.refreshed;
|
|
4677
5274
|
this.assertContextualQueryFreshness(context, request);
|
|
4678
|
-
isPosAvailabilityRequest = String((_this$otherParams$
|
|
4679
|
-
|
|
5275
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla3 = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
|
|
5276
|
+
queryRequest = request.target === 'date' || request.target === 'product' ? _objectSpread(_objectSpread({}, request), {}, {
|
|
5277
|
+
dateRange: request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection)
|
|
5278
|
+
}) : request;
|
|
5279
|
+
result = queryAvailabilityProjection(projectionEntry.projection, queryRequest, {
|
|
5280
|
+
useDurationTimeGrid: this.usesDurationTimeGrid(projectionEntry.projection),
|
|
5281
|
+
enforceSaleCutoff: isPosAvailabilityRequest && !((_context$prepareParam2 = context.prepareParams.editingProductLineUids) !== null && _context$prepareParam2 !== void 0 && _context$prepareParam2.length) && request.selectionIntent === 'remembered',
|
|
4680
5282
|
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
4681
5283
|
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
4682
5284
|
});
|
|
@@ -4706,18 +5308,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4706
5308
|
});
|
|
4707
5309
|
})
|
|
4708
5310
|
}) : result;
|
|
4709
|
-
return
|
|
5311
|
+
return _context49.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
|
|
4710
5312
|
contextId: context.contextId,
|
|
4711
5313
|
contextVersion: contextVersion,
|
|
4712
5314
|
refreshed: refreshed
|
|
4713
5315
|
}));
|
|
4714
|
-
case
|
|
5316
|
+
case 13:
|
|
4715
5317
|
case "end":
|
|
4716
|
-
return
|
|
5318
|
+
return _context49.stop();
|
|
4717
5319
|
}
|
|
4718
|
-
},
|
|
5320
|
+
}, _callee49, this);
|
|
4719
5321
|
}));
|
|
4720
|
-
function queryBookingAvailability(
|
|
5322
|
+
function queryBookingAvailability(_x35, _x36) {
|
|
4721
5323
|
return _queryBookingAvailability.apply(this, arguments);
|
|
4722
5324
|
}
|
|
4723
5325
|
return queryBookingAvailability;
|
|
@@ -4725,7 +5327,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4725
5327
|
}, {
|
|
4726
5328
|
key: "releaseAvailabilityContext",
|
|
4727
5329
|
value: function releaseAvailabilityContext(contextId) {
|
|
4728
|
-
var _this$
|
|
5330
|
+
var _this$getActiveAvaila2;
|
|
4729
5331
|
var context = this.availabilityContextRegistry.get(contextId);
|
|
4730
5332
|
if (!context) return;
|
|
4731
5333
|
this.removeAvailabilityContext(contextId);
|
|
@@ -4733,7 +5335,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4733
5335
|
action: 'release',
|
|
4734
5336
|
contextId: contextId,
|
|
4735
5337
|
contextVersion: context.activeVersion,
|
|
4736
|
-
projection: ((_this$
|
|
5338
|
+
projection: ((_this$getActiveAvaila2 = this.getActiveAvailabilityProjectionEntry(context)) === null || _this$getActiveAvaila2 === void 0 ? void 0 : _this$getActiveAvaila2.projection) || null,
|
|
4737
5339
|
snapshotId: context.lastSnapshotId,
|
|
4738
5340
|
orderRevision: context.lastKnownOrderRevision,
|
|
4739
5341
|
reason: 'explicit_release'
|
|
@@ -4774,82 +5376,160 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4774
5376
|
}, {
|
|
4775
5377
|
key: "findLinkedBooking",
|
|
4776
5378
|
value: function findLinkedBooking(product) {
|
|
4777
|
-
var
|
|
5379
|
+
var _ref54, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
|
|
4778
5380
|
var productUid = getProductLineUid(product);
|
|
4779
|
-
var bookingUid = String((
|
|
5381
|
+
var bookingUid = String((_ref54 = (_product$booking_uid3 = product.booking_uid) !== null && _product$booking_uid3 !== void 0 ? _product$booking_uid3 : (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid) !== null && _ref54 !== void 0 ? _ref54 : '');
|
|
4780
5382
|
return (((_this$getTempOrder3 = this.getTempOrder()) === null || _this$getTempOrder3 === void 0 ? void 0 : _this$getTempOrder3.bookings) || []).find(function (booking) {
|
|
4781
5383
|
var _booking$product_uid3;
|
|
4782
5384
|
return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
|
|
4783
5385
|
});
|
|
4784
5386
|
}
|
|
4785
|
-
|
|
4786
|
-
|
|
5387
|
+
}, {
|
|
5388
|
+
key: "removeBookingProductsOutsideStartDate",
|
|
5389
|
+
value: function () {
|
|
5390
|
+
var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(startDate) {
|
|
5391
|
+
var _this$getTempOrder4,
|
|
5392
|
+
_this$otherParams28,
|
|
5393
|
+
_this14 = this;
|
|
5394
|
+
var products, targetDate, identities;
|
|
5395
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
5396
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
5397
|
+
case 0:
|
|
5398
|
+
products = ((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || [];
|
|
5399
|
+
if (!(((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.enforceSingleBookingStartDate) !== true)) {
|
|
5400
|
+
_context50.next = 3;
|
|
5401
|
+
break;
|
|
5402
|
+
}
|
|
5403
|
+
return _context50.abrupt("return", products);
|
|
5404
|
+
case 3:
|
|
5405
|
+
targetDate = getVisibleCalendarDate(startDate);
|
|
5406
|
+
if (targetDate) {
|
|
5407
|
+
_context50.next = 6;
|
|
5408
|
+
break;
|
|
5409
|
+
}
|
|
5410
|
+
return _context50.abrupt("return", products);
|
|
5411
|
+
case 6:
|
|
5412
|
+
identities = products.flatMap(function (product) {
|
|
5413
|
+
var _product$metadata7;
|
|
5414
|
+
if (!getProductLineUid(product) || (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.product_add_schedule_time) != null) {
|
|
5415
|
+
return [];
|
|
5416
|
+
}
|
|
5417
|
+
var booking = _this14.findLinkedBooking(product);
|
|
5418
|
+
if (!booking || isFulfillmentTimingBooking(booking)) return [];
|
|
5419
|
+
var bookingDate = getVisibleCalendarDate(booking.start_date);
|
|
5420
|
+
return bookingDate && bookingDate !== targetDate ? [buildAvailabilityLineIdentity(product)] : [];
|
|
5421
|
+
});
|
|
5422
|
+
return _context50.abrupt("return", identities.length ? this.removeProductsFromOrder(identities) : products);
|
|
5423
|
+
case 8:
|
|
5424
|
+
case "end":
|
|
5425
|
+
return _context50.stop();
|
|
5426
|
+
}
|
|
5427
|
+
}, _callee50, this);
|
|
5428
|
+
}));
|
|
5429
|
+
function removeBookingProductsOutsideStartDate(_x37) {
|
|
5430
|
+
return _removeBookingProductsOutsideStartDate.apply(this, arguments);
|
|
5431
|
+
}
|
|
5432
|
+
return removeBookingProductsOutsideStartDate;
|
|
5433
|
+
}() /** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
4787
5434
|
}, {
|
|
4788
5435
|
key: "commitAvailabilitySelection",
|
|
4789
5436
|
value: (function () {
|
|
4790
|
-
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4791
|
-
var
|
|
4792
|
-
|
|
4793
|
-
|
|
5437
|
+
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(contextId, params) {
|
|
5438
|
+
var _this$otherParams$pla4,
|
|
5439
|
+
_this$otherParams29,
|
|
5440
|
+
_params$availabilityC,
|
|
5441
|
+
_this$store$order11,
|
|
5442
|
+
_this$store$order11$e,
|
|
5443
|
+
_this15 = this;
|
|
5444
|
+
var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref55, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$otherParams30, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla6, _this$otherParams31, _ref56, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref57, _ref58, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, _params$orderProduct9, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref59, _transformed$product_4, _this$getTempOrder5, _this$getTempOrder6, _params$salesNotes, _params$salesNotes2, _ref60, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
|
|
5445
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
5446
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4794
5447
|
case 0:
|
|
4795
5448
|
normalizedContextId = String(contextId || '').trim();
|
|
4796
5449
|
if (normalizedContextId) {
|
|
4797
|
-
|
|
5450
|
+
_context51.next = 3;
|
|
4798
5451
|
break;
|
|
4799
5452
|
}
|
|
4800
5453
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
|
|
4801
5454
|
candidate: params.candidate
|
|
4802
5455
|
});
|
|
4803
5456
|
case 3:
|
|
4804
|
-
|
|
5457
|
+
isRememberedSelection = params.selectionIntent === 'remembered';
|
|
5458
|
+
if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
|
|
5459
|
+
_context51.next = 6;
|
|
5460
|
+
break;
|
|
5461
|
+
}
|
|
5462
|
+
throw new AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
|
|
5463
|
+
case 6:
|
|
5464
|
+
hasCommitGuard = isRememberedSelection || Boolean(params.availabilityCommitGuard);
|
|
5465
|
+
(_params$availabilityC = params.availabilityCommitGuard) === null || _params$availabilityC === void 0 || _params$availabilityC.call(params);
|
|
5466
|
+
// Stabilize the locally generated sale identity before taking the guard snapshot.
|
|
5467
|
+
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);
|
|
5468
|
+
rememberedOrder = hasCommitGuard ? this.getTempOrder() : null;
|
|
5469
|
+
getRememberedCommitIdentity = function getRememberedCommitIdentity() {
|
|
5470
|
+
var _this15$otherParams$s, _this15$otherParams, _this15$otherParams2, _this15$core, _this15$getTempOrder, _this15$getTempOrder2;
|
|
5471
|
+
return JSON.stringify(stableValue({
|
|
5472
|
+
scope: _this15.getAvailabilityScopeDescriptor(),
|
|
5473
|
+
shopId: (_this15$otherParams$s = (_this15$otherParams = _this15.otherParams) === null || _this15$otherParams === void 0 ? void 0 : _this15$otherParams.shop_id) !== null && _this15$otherParams$s !== void 0 ? _this15$otherParams$s : (_this15$otherParams2 = _this15.otherParams) === null || _this15$otherParams2 === void 0 ? void 0 : _this15$otherParams2.shopId,
|
|
5474
|
+
contextShopId: (_this15$core = _this15.core) === null || _this15$core === void 0 || (_this15$core = _this15$core.context) === null || _this15$core === void 0 ? void 0 : _this15$core.shop_id,
|
|
5475
|
+
orderId: (_this15$getTempOrder = _this15.getTempOrder()) === null || _this15$getTempOrder === void 0 ? void 0 : _this15$getTempOrder.order_id,
|
|
5476
|
+
externalSaleNumber: (_this15$getTempOrder2 = _this15.getTempOrder()) === null || _this15$getTempOrder2 === void 0 ? void 0 : _this15$getTempOrder2.external_sale_number
|
|
5477
|
+
}));
|
|
5478
|
+
};
|
|
5479
|
+
rememberedCommitIdentity = hasCommitGuard ? getRememberedCommitIdentity() : '';
|
|
5480
|
+
availabilityCommitTargetGuard = function availabilityCommitTargetGuard() {
|
|
5481
|
+
return _this15.getTempOrder() === rememberedOrder && getRememberedCommitIdentity() === rememberedCommitIdentity;
|
|
5482
|
+
};
|
|
5483
|
+
guardedCommitPublished = false;
|
|
5484
|
+
_context51.next = 16;
|
|
4805
5485
|
return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
|
|
4806
|
-
case
|
|
4807
|
-
|
|
5486
|
+
case 16:
|
|
5487
|
+
_context51.prev = 16;
|
|
4808
5488
|
bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
|
|
4809
5489
|
if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
|
|
4810
|
-
|
|
5490
|
+
_context51.next = 20;
|
|
4811
5491
|
break;
|
|
4812
5492
|
}
|
|
4813
5493
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
|
|
4814
5494
|
bookingCount: params.bookingCount
|
|
4815
5495
|
});
|
|
4816
|
-
case
|
|
5496
|
+
case 20:
|
|
4817
5497
|
if (!(params.mode === 'edit' && bookingCount !== 1)) {
|
|
4818
|
-
|
|
5498
|
+
_context51.next = 22;
|
|
4819
5499
|
break;
|
|
4820
5500
|
}
|
|
4821
5501
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
|
|
4822
5502
|
bookingCount: bookingCount
|
|
4823
5503
|
});
|
|
4824
|
-
case
|
|
4825
|
-
orderProductQuantity = (
|
|
5504
|
+
case 22:
|
|
5505
|
+
orderProductQuantity = (_ref55 = (_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 && _ref55 !== void 0 ? _ref55 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
|
|
4826
5506
|
if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
|
|
4827
|
-
|
|
5507
|
+
_context51.next = 25;
|
|
4828
5508
|
break;
|
|
4829
5509
|
}
|
|
4830
5510
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
|
|
4831
5511
|
bookingCount: bookingCount,
|
|
4832
5512
|
orderProductQuantity: orderProductQuantity
|
|
4833
5513
|
});
|
|
4834
|
-
case
|
|
5514
|
+
case 25:
|
|
4835
5515
|
partySize = Number(params.partySize);
|
|
4836
5516
|
if (!(!Number.isInteger(partySize) || partySize <= 0)) {
|
|
4837
|
-
|
|
5517
|
+
_context51.next = 28;
|
|
4838
5518
|
break;
|
|
4839
5519
|
}
|
|
4840
5520
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
|
|
4841
5521
|
partySize: params.partySize
|
|
4842
5522
|
});
|
|
4843
|
-
case
|
|
4844
|
-
|
|
5523
|
+
case 28:
|
|
5524
|
+
_context51.next = 30;
|
|
4845
5525
|
return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
4846
|
-
case
|
|
4847
|
-
_yield$this$ensureAva3 =
|
|
5526
|
+
case 30:
|
|
5527
|
+
_yield$this$ensureAva3 = _context51.sent;
|
|
4848
5528
|
context = _yield$this$ensureAva3.context;
|
|
4849
5529
|
projectionEntry = _yield$this$ensureAva3.projectionEntry;
|
|
4850
5530
|
refreshed = _yield$this$ensureAva3.refreshed;
|
|
4851
5531
|
if (!refreshed) {
|
|
4852
|
-
|
|
5532
|
+
_context51.next = 36;
|
|
4853
5533
|
break;
|
|
4854
5534
|
}
|
|
4855
5535
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -4857,14 +5537,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4857
5537
|
currentContextVersion: context.activeVersion,
|
|
4858
5538
|
candidateContextVersion: params.candidate.availabilityContextVersion
|
|
4859
5539
|
});
|
|
4860
|
-
case
|
|
5540
|
+
case 36:
|
|
4861
5541
|
boundEditingUids = context.prepareParams.editingProductLineUids || [];
|
|
4862
5542
|
if (!(params.mode === 'edit')) {
|
|
4863
|
-
|
|
5543
|
+
_context51.next = 42;
|
|
4864
5544
|
break;
|
|
4865
5545
|
}
|
|
4866
5546
|
if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
|
|
4867
|
-
|
|
5547
|
+
_context51.next = 40;
|
|
4868
5548
|
break;
|
|
4869
5549
|
}
|
|
4870
5550
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
|
|
@@ -4872,21 +5552,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4872
5552
|
productLineUid: params.productLineUid,
|
|
4873
5553
|
editingProductLineUids: boundEditingUids
|
|
4874
5554
|
});
|
|
4875
|
-
case
|
|
4876
|
-
|
|
5555
|
+
case 40:
|
|
5556
|
+
_context51.next = 44;
|
|
4877
5557
|
break;
|
|
4878
|
-
case
|
|
5558
|
+
case 42:
|
|
4879
5559
|
if (!(boundEditingUids.length > 0)) {
|
|
4880
|
-
|
|
5560
|
+
_context51.next = 44;
|
|
4881
5561
|
break;
|
|
4882
5562
|
}
|
|
4883
5563
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
|
|
4884
5564
|
contextId: normalizedContextId,
|
|
4885
5565
|
editingProductLineUids: boundEditingUids
|
|
4886
5566
|
});
|
|
4887
|
-
case
|
|
5567
|
+
case 44:
|
|
4888
5568
|
if (!(projectionEntry.contextVersion !== context.activeVersion)) {
|
|
4889
|
-
|
|
5569
|
+
_context51.next = 46;
|
|
4890
5570
|
break;
|
|
4891
5571
|
}
|
|
4892
5572
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -4894,9 +5574,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4894
5574
|
currentContextVersion: context.activeVersion,
|
|
4895
5575
|
projectionContextVersion: projectionEntry.contextVersion
|
|
4896
5576
|
});
|
|
4897
|
-
case
|
|
5577
|
+
case 46:
|
|
4898
5578
|
if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4899
|
-
|
|
5579
|
+
_context51.next = 48;
|
|
4900
5580
|
break;
|
|
4901
5581
|
}
|
|
4902
5582
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
@@ -4905,9 +5585,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4905
5585
|
projectionOrderRevision: projectionEntry.orderRevision,
|
|
4906
5586
|
currentOrderRevision: this.getCurrentOrderRevision()
|
|
4907
5587
|
});
|
|
4908
|
-
case
|
|
5588
|
+
case 48:
|
|
4909
5589
|
if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
|
|
4910
|
-
|
|
5590
|
+
_context51.next = 50;
|
|
4911
5591
|
break;
|
|
4912
5592
|
}
|
|
4913
5593
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
|
|
@@ -4915,35 +5595,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4915
5595
|
candidateContextVersion: params.candidate.availabilityContextVersion,
|
|
4916
5596
|
currentContextVersion: context.activeVersion
|
|
4917
5597
|
});
|
|
4918
|
-
case
|
|
5598
|
+
case 50:
|
|
4919
5599
|
this.assertAvailabilityCandidateFreshness(context, params.candidate);
|
|
4920
5600
|
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;
|
|
4921
5601
|
if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
|
|
4922
|
-
|
|
5602
|
+
_context51.next = 54;
|
|
4923
5603
|
break;
|
|
4924
5604
|
}
|
|
4925
5605
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
|
|
4926
5606
|
orderProductId: orderProductId,
|
|
4927
5607
|
candidateProductId: params.candidate.productId
|
|
4928
5608
|
});
|
|
4929
|
-
case
|
|
5609
|
+
case 54:
|
|
4930
5610
|
if (!(params.mode === 'edit' && !params.productLineUid)) {
|
|
4931
|
-
|
|
5611
|
+
_context51.next = 56;
|
|
4932
5612
|
break;
|
|
4933
5613
|
}
|
|
4934
5614
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
|
|
4935
|
-
case
|
|
5615
|
+
case 56:
|
|
4936
5616
|
editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
|
|
4937
5617
|
if (!(params.mode === 'edit' && !editingLine)) {
|
|
4938
|
-
|
|
5618
|
+
_context51.next = 59;
|
|
4939
5619
|
break;
|
|
4940
5620
|
}
|
|
4941
5621
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
|
|
4942
5622
|
productLineUid: params.productLineUid
|
|
4943
5623
|
});
|
|
4944
|
-
case
|
|
5624
|
+
case 59:
|
|
4945
5625
|
if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
|
|
4946
|
-
|
|
5626
|
+
_context51.next = 61;
|
|
4947
5627
|
break;
|
|
4948
5628
|
}
|
|
4949
5629
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
|
|
@@ -4951,16 +5631,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4951
5631
|
productLineProductId: (_editingLine$product_2 = editingLine.product_id) !== null && _editingLine$product_2 !== void 0 ? _editingLine$product_2 : editingLine.id,
|
|
4952
5632
|
candidateProductId: params.candidate.productId
|
|
4953
5633
|
});
|
|
4954
|
-
case
|
|
5634
|
+
case 61:
|
|
4955
5635
|
if (Array.isArray(params.requirementSelections)) {
|
|
4956
|
-
|
|
5636
|
+
_context51.next = 63;
|
|
4957
5637
|
break;
|
|
4958
5638
|
}
|
|
4959
5639
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
|
|
4960
5640
|
requirementSelections: params.requirementSelections
|
|
4961
5641
|
});
|
|
4962
|
-
case
|
|
5642
|
+
case 63:
|
|
4963
5643
|
baseProjection = projectionEntry.projection;
|
|
5644
|
+
selectedProduct = baseProjection.products.find(function (item) {
|
|
5645
|
+
return sameAvailabilityId(item.id, params.candidate.productId);
|
|
5646
|
+
});
|
|
5647
|
+
if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
|
|
5648
|
+
_context51.next = 67;
|
|
5649
|
+
break;
|
|
5650
|
+
}
|
|
5651
|
+
throw new AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
|
|
5652
|
+
case 67:
|
|
4964
5653
|
commitWriteGuard = {
|
|
4965
5654
|
contextId: normalizedContextId,
|
|
4966
5655
|
expectedVersion: context.activeVersion,
|
|
@@ -4970,11 +5659,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4970
5659
|
};
|
|
4971
5660
|
prepareParams = baseProjection.meta.prepareParams;
|
|
4972
5661
|
if (prepareParams) {
|
|
4973
|
-
|
|
5662
|
+
_context51.next = 71;
|
|
4974
5663
|
break;
|
|
4975
5664
|
}
|
|
4976
5665
|
throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
4977
|
-
case
|
|
5666
|
+
case 71:
|
|
4978
5667
|
fallbackResources = {
|
|
4979
5668
|
resources: cloneDeep(_toConsumableArray(baseProjection.resources || [])),
|
|
4980
5669
|
resourceOccupancies: cloneDeep(_toConsumableArray(baseProjection.resourceOccupancies || []).filter(function (occupancy) {
|
|
@@ -4982,7 +5671,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4982
5671
|
})),
|
|
4983
5672
|
includesInjectedRawOccupancies: true
|
|
4984
5673
|
};
|
|
4985
|
-
|
|
5674
|
+
_context51.next = 74;
|
|
4986
5675
|
return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
|
|
4987
5676
|
editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
|
|
4988
5677
|
}), {
|
|
@@ -4990,20 +5679,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4990
5679
|
fallbackResources: fallbackResources,
|
|
4991
5680
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
4992
5681
|
});
|
|
4993
|
-
case
|
|
4994
|
-
commitSnapshot =
|
|
5682
|
+
case 74:
|
|
5683
|
+
commitSnapshot = _context51.sent;
|
|
4995
5684
|
refreshedProjection = commitSnapshot.projection;
|
|
4996
5685
|
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 : ''))) {
|
|
4997
|
-
|
|
5686
|
+
_context51.next = 81;
|
|
4998
5687
|
break;
|
|
4999
5688
|
}
|
|
5000
|
-
|
|
5689
|
+
_context51.next = 79;
|
|
5001
5690
|
return this.refreshAvailabilityContextProjection({
|
|
5002
5691
|
contextId: normalizedContextId,
|
|
5003
5692
|
reason: 'commit_order_revision_changed',
|
|
5004
5693
|
previousOrderRevision: String((_baseProjection$meta$3 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$3 !== void 0 ? _baseProjection$meta$3 : '')
|
|
5005
5694
|
});
|
|
5006
|
-
case
|
|
5695
|
+
case 79:
|
|
5007
5696
|
latestContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5008
5697
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '最终缓存重校验期间购物车已变化,请重新获取候选', {
|
|
5009
5698
|
contextId: normalizedContextId,
|
|
@@ -5014,24 +5703,34 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5014
5703
|
snapshotId: baseProjection.meta.snapshotId,
|
|
5015
5704
|
refreshedSnapshotId: refreshedProjection.meta.snapshotId
|
|
5016
5705
|
});
|
|
5017
|
-
case
|
|
5706
|
+
case 81:
|
|
5018
5707
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
5019
5708
|
candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
|
|
5020
5709
|
candidateStartTime = getCandidateStartTime(params.candidate);
|
|
5021
|
-
allowPosAvailabilityOverride = String((_this$otherParams$
|
|
5710
|
+
allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection;
|
|
5711
|
+
candidateBusinessDate = params.candidate.businessDate || ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) === 'duration' && this.usesDurationTimeGrid(refreshedProjection) ? getDurationBusinessDate(refreshedProjection, params.candidate.startAt) : params.candidate.startAt.slice(0, 10));
|
|
5022
5712
|
refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
|
|
5023
5713
|
productIds: [params.candidate.productId],
|
|
5024
5714
|
dateRange: {
|
|
5025
|
-
startDate:
|
|
5026
|
-
endDate:
|
|
5715
|
+
startDate: candidateBusinessDate,
|
|
5716
|
+
endDate: candidateBusinessDate
|
|
5027
5717
|
}
|
|
5028
|
-
},
|
|
5718
|
+
}, isRememberedSelection ? _objectSpread({
|
|
5719
|
+
rememberedStartAtByProductId: _defineProperty({}, String(params.candidate.productId), params.candidate.bookingStartAt)
|
|
5720
|
+
}, !(selectedProduct !== null && selectedProduct !== void 0 && selectedProduct.isFlexibleDuration) && candidateDurationMinutes ? {
|
|
5721
|
+
durationMinutesByProductId: _defineProperty({}, String(params.candidate.productId), candidateDurationMinutes)
|
|
5722
|
+
} : {}) : candidateDurationMinutes ? _objectSpread(_objectSpread({
|
|
5029
5723
|
durationMinutesByProductId: _defineProperty({}, String(params.candidate.productId), candidateDurationMinutes)
|
|
5030
|
-
},
|
|
5724
|
+
}, params.mode === 'edit' && (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) === 'duration' ? {
|
|
5725
|
+
editingStartAtByProductId: _defineProperty({}, String(params.candidate.productId), params.candidate.bookingStartAt)
|
|
5726
|
+
} : {}), candidateStartTime ? _objectSpread({
|
|
5031
5727
|
durationStartTimesByProductId: _defineProperty({}, String(params.candidate.productId), [candidateStartTime])
|
|
5032
5728
|
}, allowPosAvailabilityOverride ? {
|
|
5033
5729
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
5034
5730
|
} : {}) : {}) : {}), {
|
|
5731
|
+
evaluatedAt: this.getAvailabilityRuntimeDateTime(),
|
|
5732
|
+
useDurationTimeGrid: this.usesDurationTimeGrid(refreshedProjection),
|
|
5733
|
+
enforceSaleCutoff: isRememberedSelection,
|
|
5035
5734
|
useExactDurationCandidateMinute: allowPosAvailabilityOverride,
|
|
5036
5735
|
allowSessionCustomRanges: allowPosAvailabilityOverride,
|
|
5037
5736
|
allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
|
|
@@ -5042,7 +5741,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5042
5741
|
return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
|
|
5043
5742
|
});
|
|
5044
5743
|
if (refreshedCandidateBase) {
|
|
5045
|
-
|
|
5744
|
+
_context51.next = 90;
|
|
5046
5745
|
break;
|
|
5047
5746
|
}
|
|
5048
5747
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
|
|
@@ -5050,24 +5749,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5050
5749
|
candidate: params.candidate,
|
|
5051
5750
|
refreshedSnapshotId: refreshedProjection.meta.snapshotId
|
|
5052
5751
|
});
|
|
5053
|
-
case
|
|
5752
|
+
case 90:
|
|
5054
5753
|
product = refreshedProjection.products.find(function (item) {
|
|
5055
5754
|
return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
|
|
5056
5755
|
});
|
|
5057
5756
|
if (product) {
|
|
5058
|
-
|
|
5757
|
+
_context51.next = 93;
|
|
5059
5758
|
break;
|
|
5060
5759
|
}
|
|
5061
5760
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
|
|
5062
5761
|
productId: refreshedCandidateBase.productId
|
|
5063
5762
|
});
|
|
5064
|
-
case
|
|
5763
|
+
case 93:
|
|
5065
5764
|
validation = validateAvailabilitySelection(refreshedProjection, {
|
|
5066
5765
|
candidate: refreshedCandidateBase,
|
|
5067
5766
|
requirementSelections: params.requirementSelections,
|
|
5068
5767
|
partySize: partySize,
|
|
5069
5768
|
bookingCount: bookingCount
|
|
5070
5769
|
}, {
|
|
5770
|
+
useDurationTimeGrid: this.usesDurationTimeGrid(refreshedProjection),
|
|
5771
|
+
enforceSaleCutoff: isRememberedSelection,
|
|
5071
5772
|
useExactDurationCandidateMinute: allowPosAvailabilityOverride,
|
|
5072
5773
|
allowExcludedScheduleDateOverride: allowPosAvailabilityOverride
|
|
5073
5774
|
});
|
|
@@ -5092,7 +5793,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5092
5793
|
});
|
|
5093
5794
|
}
|
|
5094
5795
|
if (validation.ok) {
|
|
5095
|
-
|
|
5796
|
+
_context51.next = 98;
|
|
5096
5797
|
break;
|
|
5097
5798
|
}
|
|
5098
5799
|
capacityConflict = validation.conflicts.find(function (conflict) {
|
|
@@ -5102,7 +5803,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5102
5803
|
validation: validation,
|
|
5103
5804
|
refreshedSnapshotId: refreshedProjection.meta.snapshotId
|
|
5104
5805
|
});
|
|
5105
|
-
case
|
|
5806
|
+
case 98:
|
|
5106
5807
|
// Revalidation failure must leave the caller's candidate reusable. Only publish the
|
|
5107
5808
|
// refreshed projection/version after candidate and resource validation has passed;
|
|
5108
5809
|
// otherwise a second Confirm from the still-open modal would incorrectly become stale.
|
|
@@ -5115,7 +5816,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5115
5816
|
incrementVersion: true
|
|
5116
5817
|
});
|
|
5117
5818
|
revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5118
|
-
|
|
5819
|
+
_context51.next = 102;
|
|
5119
5820
|
return this.emitAvailabilityDiagnostic({
|
|
5120
5821
|
action: 'refresh',
|
|
5121
5822
|
contextId: normalizedContextId,
|
|
@@ -5126,7 +5827,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5126
5827
|
previousOrderRevision: baseProjection.meta.orderRevision,
|
|
5127
5828
|
reason: 'commit_cached_occupancy_revalidation'
|
|
5128
5829
|
});
|
|
5129
|
-
case
|
|
5830
|
+
case 102:
|
|
5130
5831
|
commitWriteGuard = {
|
|
5131
5832
|
contextId: normalizedContextId,
|
|
5132
5833
|
expectedVersion: revalidatedContext.activeVersion,
|
|
@@ -5134,17 +5835,41 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5134
5835
|
expectedLifecycleGeneration: this.availabilityLifecycleGeneration,
|
|
5135
5836
|
expectedOrderRevision: revalidationEntry.orderRevision
|
|
5136
5837
|
};
|
|
5137
|
-
refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase);
|
|
5838
|
+
refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase); // Order may await line/runtime setup. Its guarded transaction invokes this
|
|
5839
|
+
// again immediately before publishing, while the live cart is unchanged.
|
|
5840
|
+
availabilityCommitGuard = hasCommitGuard ? function () {
|
|
5841
|
+
var _params$availabilityC2;
|
|
5842
|
+
(_params$availabilityC2 = params.availabilityCommitGuard) === null || _params$availabilityC2 === void 0 || _params$availabilityC2.call(params);
|
|
5843
|
+
_this15.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
5844
|
+
if (!availabilityCommitTargetGuard()) {
|
|
5845
|
+
throw _this15.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '记忆时间加购期间订单或业务已变化');
|
|
5846
|
+
}
|
|
5847
|
+
if (!isRememberedSelection) return;
|
|
5848
|
+
var currentValidation = validateAvailabilitySelection(refreshedProjection, {
|
|
5849
|
+
candidate: refreshedCandidateBase,
|
|
5850
|
+
requirementSelections: params.requirementSelections,
|
|
5851
|
+
partySize: partySize,
|
|
5852
|
+
bookingCount: bookingCount
|
|
5853
|
+
}, {
|
|
5854
|
+
useDurationTimeGrid: true,
|
|
5855
|
+
enforceSaleCutoff: true
|
|
5856
|
+
});
|
|
5857
|
+
if (!currentValidation.ok) {
|
|
5858
|
+
throw new AvailabilityError('REVALIDATION_FAILED', '记忆时间在加购前已不可用,请重新选择', {
|
|
5859
|
+
validation: currentValidation
|
|
5860
|
+
});
|
|
5861
|
+
}
|
|
5862
|
+
} : undefined;
|
|
5138
5863
|
existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
|
|
5139
5864
|
existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
|
|
5140
5865
|
if (!(params.mode === 'edit' && !existingBookingUid)) {
|
|
5141
|
-
|
|
5866
|
+
_context51.next = 109;
|
|
5142
5867
|
break;
|
|
5143
5868
|
}
|
|
5144
5869
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
|
|
5145
5870
|
productLineUid: params.productLineUid
|
|
5146
5871
|
});
|
|
5147
|
-
case
|
|
5872
|
+
case 109:
|
|
5148
5873
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
5149
5874
|
booking = buildBookingFromAvailabilitySelection({
|
|
5150
5875
|
assignments: validation.assignments,
|
|
@@ -5152,21 +5877,54 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5152
5877
|
product: product,
|
|
5153
5878
|
resources: refreshedProjection.resources,
|
|
5154
5879
|
bookingUid: existingBookingUid || undefined,
|
|
5155
|
-
holder: (
|
|
5156
|
-
holderIds: (
|
|
5880
|
+
holder: (_ref56 = (_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 : existingBooking === null || existingBooking === void 0 ? void 0 : existingBooking.holder) !== null && _ref56 !== void 0 ? _ref56 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
|
|
5881
|
+
holderIds: (_ref57 = (_ref58 = (_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 && _ref58 !== void 0 ? _ref58 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta2 = existingBooking.metadata) === null || _existingBooking$meta2 === void 0 ? void 0 : _existingBooking$meta2.holder_id) !== null && _ref57 !== void 0 ? _ref57 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold = existingBooking.holder) === null || _existingBooking$hold === void 0 ? void 0 : _existingBooking$hold.form_record
|
|
5882
|
+
});
|
|
5883
|
+
if (!(isRememberedSelection && (_params$orderProduct9 = params.orderProduct) !== null && _params$orderProduct9 !== void 0 && (_params$orderProduct9 = _params$orderProduct9._extend) !== null && _params$orderProduct9 !== void 0 && _params$orderProduct9.resource)) {
|
|
5884
|
+
_context51.next = 119;
|
|
5885
|
+
break;
|
|
5886
|
+
}
|
|
5887
|
+
// AutoClose 与编辑共用旧资源协议。仅复用其结构,实际资源及每份容量
|
|
5888
|
+
// 必须与本次严格校验结果一致;时间、Holder 和校验元数据仍使用上面的结果。
|
|
5889
|
+
legacyBooking = cacheItemToBookingInput(params.orderProduct);
|
|
5890
|
+
legacyResources = legacyBooking.resources || [];
|
|
5891
|
+
selectedResources = legacyResources.filter(function (resource) {
|
|
5892
|
+
return Number(resource.relation_id) !== 0;
|
|
5157
5893
|
});
|
|
5894
|
+
resourceKeys = function resourceKeys(resources) {
|
|
5895
|
+
return resources.map(function (resource) {
|
|
5896
|
+
return JSON.stringify([String(resource.form_id), String(resource.relation_id), resource.relation_type, Number(resource.capacity)]);
|
|
5897
|
+
}).sort();
|
|
5898
|
+
};
|
|
5899
|
+
if (!(JSON.stringify(resourceKeys(selectedResources)) !== JSON.stringify(resourceKeys(booking.resources)) || legacyResources.some(function (resource) {
|
|
5900
|
+
return Number(resource.relation_id) === 0 && !selectedResources.some(function (selected) {
|
|
5901
|
+
return sameAvailabilityId(selected.form_id, resource.form_id);
|
|
5902
|
+
});
|
|
5903
|
+
}))) {
|
|
5904
|
+
_context51.next = 118;
|
|
5905
|
+
break;
|
|
5906
|
+
}
|
|
5907
|
+
throw new AvailabilityError('REVALIDATION_FAILED', '记忆时间的资源与本次校验结果不一致');
|
|
5908
|
+
case 118:
|
|
5909
|
+
Object.assign(booking, {
|
|
5910
|
+
relation_id: legacyBooking.relation_id,
|
|
5911
|
+
form_id: legacyBooking.form_id,
|
|
5912
|
+
relation_type: legacyBooking.relation_type,
|
|
5913
|
+
resources: cloneDeep(legacyResources)
|
|
5914
|
+
});
|
|
5915
|
+
case 119:
|
|
5158
5916
|
transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
|
|
5159
5917
|
num: bookingCount,
|
|
5160
5918
|
quantity: bookingCount
|
|
5161
5919
|
}), 'unified_booking_sales', product);
|
|
5162
5920
|
if (transformed) {
|
|
5163
|
-
|
|
5921
|
+
_context51.next = 122;
|
|
5164
5922
|
break;
|
|
5165
5923
|
}
|
|
5166
5924
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
|
|
5167
5925
|
orderProduct: params.orderProduct
|
|
5168
5926
|
});
|
|
5169
|
-
case
|
|
5927
|
+
case 122:
|
|
5170
5928
|
transformed.num = bookingCount;
|
|
5171
5929
|
transformed.metadata = _objectSpread(_objectSpread({}, transformed.metadata || {}), {}, {
|
|
5172
5930
|
unified_booking_sales: true,
|
|
@@ -5179,7 +5937,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5179
5937
|
productLineUids = [];
|
|
5180
5938
|
bookingUids = [];
|
|
5181
5939
|
if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
|
|
5182
|
-
|
|
5940
|
+
_context51.next = 143;
|
|
5183
5941
|
break;
|
|
5184
5942
|
}
|
|
5185
5943
|
transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
|
|
@@ -5189,10 +5947,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5189
5947
|
unique_identification_number: params.productLineUid,
|
|
5190
5948
|
booking_uid: existingBookingUid
|
|
5191
5949
|
});
|
|
5192
|
-
|
|
5950
|
+
_context51.next = 135;
|
|
5193
5951
|
return this.updateOrderProduct(_objectSpread(_objectSpread({
|
|
5194
5952
|
product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
|
|
5195
|
-
product_variant_id: (
|
|
5953
|
+
product_variant_id: (_ref59 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref59 !== void 0 ? _ref59 : 0,
|
|
5196
5954
|
unique_identification_number: params.productLineUid,
|
|
5197
5955
|
updates: transformed,
|
|
5198
5956
|
booking: booking
|
|
@@ -5201,26 +5959,38 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5201
5959
|
} : {}), params.allowBookingDiscountReapply !== undefined ? {
|
|
5202
5960
|
allow_booking_discount_reapply: params.allowBookingDiscountReapply
|
|
5203
5961
|
} : {}));
|
|
5204
|
-
case
|
|
5962
|
+
case 135:
|
|
5963
|
+
_context51.next = 137;
|
|
5964
|
+
return this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
5965
|
+
case 137:
|
|
5205
5966
|
productLineUid = params.productLineUid;
|
|
5206
5967
|
bookingUid = existingBookingUid;
|
|
5207
5968
|
productLineUids = [productLineUid];
|
|
5208
5969
|
bookingUids = [bookingUid];
|
|
5209
|
-
|
|
5970
|
+
_context51.next = 160;
|
|
5210
5971
|
break;
|
|
5211
|
-
case
|
|
5212
|
-
beforeProductLineUids = new Set((((_this$
|
|
5972
|
+
case 143:
|
|
5973
|
+
beforeProductLineUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.products) || []).map(function (line) {
|
|
5213
5974
|
return getProductLineUid(line);
|
|
5214
5975
|
}).filter(Boolean));
|
|
5215
|
-
beforeBookingUids = new Set((((_this$
|
|
5976
|
+
beforeBookingUids = new Set((((_this$getTempOrder6 = this.getTempOrder()) === null || _this$getTempOrder6 === void 0 ? void 0 : _this$getTempOrder6.bookings) || []).map(function (item) {
|
|
5216
5977
|
return getBookingUid(item);
|
|
5217
5978
|
}).filter(Boolean));
|
|
5218
|
-
|
|
5219
|
-
|
|
5979
|
+
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5980
|
+
_context51.next = 148;
|
|
5981
|
+
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 ? {
|
|
5220
5982
|
salesNotes: params.salesNotes
|
|
5221
|
-
} :
|
|
5222
|
-
|
|
5223
|
-
|
|
5983
|
+
} : {}), availabilityCommitGuard ? {
|
|
5984
|
+
availabilityCommitGuard: availabilityCommitGuard,
|
|
5985
|
+
availabilityCommitTargetGuard: availabilityCommitTargetGuard
|
|
5986
|
+
} : {}) : undefined);
|
|
5987
|
+
case 148:
|
|
5988
|
+
products = _context51.sent;
|
|
5989
|
+
_context51.next = 151;
|
|
5990
|
+
return this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
5991
|
+
case 151:
|
|
5992
|
+
products = _context51.sent;
|
|
5993
|
+
guardedCommitPublished = hasCommitGuard;
|
|
5224
5994
|
addedLines = products.filter(function (line) {
|
|
5225
5995
|
var _line$product_id, _line$metadata;
|
|
5226
5996
|
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));
|
|
@@ -5228,7 +5998,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5228
5998
|
productLineUids = addedLines.map(function (line) {
|
|
5229
5999
|
return getProductLineUid(line);
|
|
5230
6000
|
}).filter(Boolean);
|
|
5231
|
-
addedBookings = (((
|
|
6001
|
+
addedBookings = (((_ref60 = hasCommitGuard ? rememberedOrder : this.getTempOrder()) === null || _ref60 === void 0 ? void 0 : _ref60.bookings) || []).filter(function (item) {
|
|
5232
6002
|
var _item$metadata;
|
|
5233
6003
|
return ((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.availability_candidate_key) === refreshedCandidate.key && !beforeBookingUids.has(getBookingUid(item));
|
|
5234
6004
|
});
|
|
@@ -5237,19 +6007,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5237
6007
|
}).filter(Boolean);
|
|
5238
6008
|
if (bookingUids.length === 0) {
|
|
5239
6009
|
bookingUids = addedLines.map(function (line) {
|
|
5240
|
-
var
|
|
5241
|
-
return String((
|
|
6010
|
+
var _ref61, _line$booking_uid, _line$metadata2;
|
|
6011
|
+
return String((_ref61 = (_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 && _ref61 !== void 0 ? _ref61 : '');
|
|
5242
6012
|
}).filter(Boolean);
|
|
5243
6013
|
}
|
|
5244
6014
|
productLineUid = productLineUids[productLineUids.length - 1] || '';
|
|
5245
6015
|
bookingUid = bookingUids[bookingUids.length - 1] || '';
|
|
5246
|
-
case
|
|
5247
|
-
|
|
5248
|
-
|
|
6016
|
+
case 160:
|
|
6017
|
+
targetStillCurrent = !hasCommitGuard || availabilityCommitTargetGuard();
|
|
6018
|
+
if (targetStillCurrent) this.invalidateAvailabilityContextsAfterCommit();else this.removeAvailabilityContext(normalizedContextId);
|
|
6019
|
+
nextContext = hasCommitGuard ? this.availabilityContextRegistry.get(normalizedContextId) : this.getAvailabilityContextEntry(normalizedContextId);
|
|
5249
6020
|
result = {
|
|
5250
6021
|
contextId: normalizedContextId,
|
|
5251
|
-
contextVersion: nextContext.activeVersion,
|
|
5252
|
-
tempOrder: this.getTempOrder(),
|
|
6022
|
+
contextVersion: (_nextContext$activeVe = nextContext === null || nextContext === void 0 ? void 0 : nextContext.activeVersion) !== null && _nextContext$activeVe !== void 0 ? _nextContext$activeVe : refreshedCandidate.availabilityContextVersion,
|
|
6023
|
+
tempOrder: hasCommitGuard ? rememberedOrder : this.getTempOrder(),
|
|
5253
6024
|
validation: validation,
|
|
5254
6025
|
candidate: refreshedCandidate,
|
|
5255
6026
|
productLineUid: productLineUid,
|
|
@@ -5257,23 +6028,61 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5257
6028
|
productLineUids: productLineUids,
|
|
5258
6029
|
bookingUids: bookingUids
|
|
5259
6030
|
};
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
6031
|
+
if (!targetStillCurrent) {
|
|
6032
|
+
_context51.next = 178;
|
|
6033
|
+
break;
|
|
6034
|
+
}
|
|
6035
|
+
// A notification failure after publication must not invite a duplicate add.
|
|
6036
|
+
emit = function emit() {
|
|
6037
|
+
return _this15.core.effects.emit("".concat(_this15.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
6038
|
+
};
|
|
6039
|
+
if (!guardedCommitPublished) {
|
|
6040
|
+
_context51.next = 176;
|
|
6041
|
+
break;
|
|
6042
|
+
}
|
|
6043
|
+
_context51.prev = 167;
|
|
6044
|
+
_context51.next = 170;
|
|
6045
|
+
return emit();
|
|
6046
|
+
case 170:
|
|
6047
|
+
_context51.next = 174;
|
|
6048
|
+
break;
|
|
6049
|
+
case 172:
|
|
6050
|
+
_context51.prev = 172;
|
|
6051
|
+
_context51.t0 = _context51["catch"](167);
|
|
6052
|
+
case 174:
|
|
6053
|
+
_context51.next = 178;
|
|
6054
|
+
break;
|
|
6055
|
+
case 176:
|
|
6056
|
+
_context51.next = 178;
|
|
6057
|
+
return emit();
|
|
6058
|
+
case 178:
|
|
6059
|
+
return _context51.abrupt("return", result);
|
|
6060
|
+
case 179:
|
|
6061
|
+
_context51.prev = 179;
|
|
6062
|
+
release = this.releaseAvailabilityCommitLock(normalizedContextId);
|
|
6063
|
+
if (!guardedCommitPublished) {
|
|
6064
|
+
_context51.next = 186;
|
|
6065
|
+
break;
|
|
6066
|
+
}
|
|
6067
|
+
_context51.next = 184;
|
|
6068
|
+
return release.catch(function () {
|
|
6069
|
+
return undefined;
|
|
6070
|
+
});
|
|
6071
|
+
case 184:
|
|
6072
|
+
_context51.next = 188;
|
|
6073
|
+
break;
|
|
6074
|
+
case 186:
|
|
6075
|
+
_context51.next = 188;
|
|
6076
|
+
return release;
|
|
6077
|
+
case 188:
|
|
6078
|
+
return _context51.finish(179);
|
|
6079
|
+
case 189:
|
|
5271
6080
|
case "end":
|
|
5272
|
-
return
|
|
6081
|
+
return _context51.stop();
|
|
5273
6082
|
}
|
|
5274
|
-
},
|
|
6083
|
+
}, _callee51, this, [[16,, 179, 189], [167, 172]]);
|
|
5275
6084
|
}));
|
|
5276
|
-
function commitAvailabilitySelection(
|
|
6085
|
+
function commitAvailabilitySelection(_x38, _x39) {
|
|
5277
6086
|
return _commitAvailabilitySelection.apply(this, arguments);
|
|
5278
6087
|
}
|
|
5279
6088
|
return commitAvailabilitySelection;
|