@pisell/pisellos 2.2.302 → 2.2.303
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +10 -7
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +41 -5
- package/dist/modules/Discount/types.d.ts +21 -0
- package/dist/modules/OpenData/index.d.ts +15 -2
- package/dist/modules/OpenData/index.js +307 -19
- package/dist/modules/OpenData/types.d.ts +55 -0
- package/dist/modules/OpenData/types.js +7 -1
- package/dist/modules/OpenData/utils.d.ts +21 -1
- package/dist/modules/OpenData/utils.js +138 -0
- package/dist/modules/Order/index.d.ts +50 -7
- package/dist/modules/Order/index.js +1690 -815
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +117 -10
- package/dist/modules/Order/types.js +6 -1
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +5 -1
- package/dist/modules/Order/utils.js +138 -33
- package/dist/modules/Payment/walletpass.js +20 -21
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/ProductList/index.d.ts +2 -1
- package/dist/modules/ProductList/index.js +100 -20
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/modules/Rules/index.d.ts +5 -0
- package/dist/modules/Rules/index.js +30 -14
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/plugins/request.d.ts +2 -1
- package/dist/plugins/request.js +4 -2
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.js +1774 -1285
- package/dist/server/modules/order/types.d.ts +50 -0
- package/dist/server/modules/order/types.js +2 -0
- package/dist/server/utils/small-ticket.d.ts +4 -1
- package/dist/server/utils/small-ticket.js +461 -96
- package/dist/solution/BaseSales/index.d.ts +24 -3
- package/dist/solution/BaseSales/index.js +1484 -873
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +22 -5
- package/dist/solution/BookingTicket/index.js +558 -443
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/Sales/index.d.ts +16 -1
- package/dist/solution/Sales/index.js +338 -63
- package/dist/solution/Sales/types.d.ts +10 -0
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +2 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/dist/solution/UnifiedBookingSales/index.js +874 -527
- package/dist/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +8 -4
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +4 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +34 -2
- package/lib/modules/Discount/types.d.ts +21 -0
- package/lib/modules/OpenData/index.d.ts +15 -2
- package/lib/modules/OpenData/index.js +230 -3
- package/lib/modules/OpenData/types.d.ts +55 -0
- package/lib/modules/OpenData/types.js +9 -1
- package/lib/modules/OpenData/utils.d.ts +21 -1
- package/lib/modules/OpenData/utils.js +126 -0
- package/lib/modules/Order/index.d.ts +50 -7
- package/lib/modules/Order/index.js +704 -64
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +117 -10
- package/lib/modules/Order/types.js +5 -1
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +5 -1
- package/lib/modules/Order/utils.js +127 -21
- package/lib/modules/Payment/walletpass.js +14 -11
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/ProductList/index.d.ts +2 -1
- package/lib/modules/ProductList/index.js +47 -2
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/modules/Rules/index.d.ts +5 -0
- package/lib/modules/Rules/index.js +22 -12
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/plugins/request.d.ts +2 -1
- package/lib/plugins/request.js +3 -2
- package/lib/server/index.d.ts +21 -0
- package/lib/server/index.js +492 -108
- package/lib/server/modules/order/types.d.ts +50 -0
- package/lib/server/modules/order/types.js +1 -0
- package/lib/server/utils/small-ticket.d.ts +4 -1
- package/lib/server/utils/small-ticket.js +427 -72
- package/lib/solution/BaseSales/index.d.ts +24 -3
- package/lib/solution/BaseSales/index.js +433 -30
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +22 -5
- package/lib/solution/BookingTicket/index.js +60 -15
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/Sales/index.d.ts +16 -1
- package/lib/solution/Sales/index.js +168 -1
- package/lib/solution/Sales/types.d.ts +10 -0
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +1 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +20 -6
- package/lib/solution/UnifiedBookingSales/index.js +169 -16
- package/lib/solution/UnifiedBookingSales/types.d.ts +21 -2
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +5 -1
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ import dayjs from 'dayjs';
|
|
|
37
37
|
import { cloneDeep } from 'lodash-es';
|
|
38
38
|
import { OpenDataModule } from "../../modules";
|
|
39
39
|
import { isProductFlexibleDuration } from "../../modules/BookingContext/utils";
|
|
40
|
+
import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from "../../modules/OpenData";
|
|
40
41
|
import { getScheduleStartEndTimePoints } from "../../modules/Schedule/getDateIsInSchedule";
|
|
41
42
|
import { AvailabilityError, createAvailabilityProjection, getProductTimeRanges as getProjectionProductTimeRanges, queryAvailabilityProjection, validateAvailabilitySelection } from "../../modules/ResourcePlanner";
|
|
42
43
|
import { UnifiedBookingSalesHooks } from "./types";
|
|
@@ -44,9 +45,10 @@ import { AvailabilityRemoteOccupancyCache } from "./remoteOccupancyCache";
|
|
|
44
45
|
import { BookingTicket } from "../BookingTicket";
|
|
45
46
|
import { addLocalCalendarDays, captureRuntimeOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, parseLocalDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
|
|
46
47
|
import { isCustomerUserPlatform, normalizeRuntimePlatform } from "../../utils/platform";
|
|
48
|
+
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
47
49
|
export * from "./types";
|
|
48
50
|
export { AvailabilityError } from "../../modules/ResourcePlanner";
|
|
49
|
-
var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability'];
|
|
51
|
+
var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents', 'basic', 'checkout', 'availability'];
|
|
50
52
|
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
51
53
|
function normalizePositiveInteger(value) {
|
|
52
54
|
var normalized = Number(value);
|
|
@@ -77,6 +79,29 @@ function getCandidateStartTime(candidate) {
|
|
|
77
79
|
return undefined;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
82
|
+
function normalizePositiveIntegerList(value) {
|
|
83
|
+
if (!Array.isArray(value)) return [];
|
|
84
|
+
return Array.from(new Set(value.map(function (item) {
|
|
85
|
+
return normalizePositiveInteger(item);
|
|
86
|
+
}).filter(function (item) {
|
|
87
|
+
return item !== undefined;
|
|
88
|
+
})));
|
|
89
|
+
}
|
|
90
|
+
function toConfiguredBoolean(value) {
|
|
91
|
+
if (typeof value === 'boolean') return value;
|
|
92
|
+
if (typeof value === 'number') return value !== 0;
|
|
93
|
+
if (typeof value === 'string') {
|
|
94
|
+
return ['1', 'true', 'yes', 'y', 'on'].includes(value.trim().toLowerCase());
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
function normalizeItemRuleStrategyConfigs(value) {
|
|
99
|
+
if (!Array.isArray(value)) return [];
|
|
100
|
+
return value.filter(function (config) {
|
|
101
|
+
var _metadata;
|
|
102
|
+
return Boolean(config && _typeof(config) === 'object' && ((_metadata = config.metadata) === null || _metadata === void 0 ? void 0 : _metadata.type) === 'item_rule');
|
|
103
|
+
});
|
|
104
|
+
}
|
|
80
105
|
function isRecord(value) {
|
|
81
106
|
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
82
107
|
}
|
|
@@ -1290,9 +1315,6 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1290
1315
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
1291
1316
|
_defineProperty(_assertThisInitialized(_this), "store", {});
|
|
1292
1317
|
_defineProperty(_assertThisInitialized(_this), "unifiedProductCatalog", []);
|
|
1293
|
-
_defineProperty(_assertThisInitialized(_this), "openDataTarget", null);
|
|
1294
|
-
_defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlight", null);
|
|
1295
|
-
_defineProperty(_assertThisInitialized(_this), "loadOpenDataInFlightTarget", null);
|
|
1296
1318
|
_defineProperty(_assertThisInitialized(_this), "availabilityRuntimeOffsetMinutes", null);
|
|
1297
1319
|
_defineProperty(_assertThisInitialized(_this), "availabilityScheduleCatalog", null);
|
|
1298
1320
|
_defineProperty(_assertThisInitialized(_this), "availabilityProjectionSequence", 0);
|
|
@@ -1307,6 +1329,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1307
1329
|
_defineProperty(_assertThisInitialized(_this), "availabilityRemoteResourceQuerySequence", 0);
|
|
1308
1330
|
_defineProperty(_assertThisInitialized(_this), "availabilityRemoteResourceEpoch", 0);
|
|
1309
1331
|
_defineProperty(_assertThisInitialized(_this), "availabilityCommitLocks", new Set());
|
|
1332
|
+
_defineProperty(_assertThisInitialized(_this), "allergyItemRuleEvaluator", new ItemRuleEvaluator());
|
|
1333
|
+
_defineProperty(_assertThisInitialized(_this), "allergyItemRuleConfigs", []);
|
|
1334
|
+
_defineProperty(_assertThisInitialized(_this), "allergyItemRuleConfigsPromise", null);
|
|
1310
1335
|
return _this;
|
|
1311
1336
|
}
|
|
1312
1337
|
_createClass(UnifiedBookingSalesImpl, [{
|
|
@@ -1326,16 +1351,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1326
1351
|
this.openDataTarget = null;
|
|
1327
1352
|
this.availabilityRuntimeOffsetMinutes = captureRuntimeOffsetMinutes();
|
|
1328
1353
|
this.clearAvailabilityRemoteResourceState();
|
|
1329
|
-
|
|
1354
|
+
this.resetAllergyItemRuleState();
|
|
1355
|
+
_context.next = 8;
|
|
1330
1356
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "initialize", this).call(this, core, options);
|
|
1331
|
-
case
|
|
1357
|
+
case 8:
|
|
1332
1358
|
openDataBusinessCode = String((_ref23 = (_this$otherParams$bus = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.businessCode) !== null && _this$otherParams$bus !== void 0 ? _this$otherParams$bus : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.business_code) !== null && _ref23 !== void 0 ? _ref23 : '').trim();
|
|
1333
1359
|
openDataChannel = String((_this$otherParams$cha = (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
|
|
1334
1360
|
if ((_this$otherParams4 = this.otherParams) !== null && _this$otherParams4 !== void 0 && _this$otherParams4.openData && openDataBusinessCode && openDataChannel) {
|
|
1335
1361
|
this.openDataTarget = "".concat(openDataBusinessCode, "+").concat(openDataChannel);
|
|
1336
1362
|
}
|
|
1337
1363
|
this.captureAvailabilityScheduleCatalog();
|
|
1338
|
-
case
|
|
1364
|
+
case 12:
|
|
1339
1365
|
case "end":
|
|
1340
1366
|
return _context.stop();
|
|
1341
1367
|
}
|
|
@@ -1545,13 +1571,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1545
1571
|
key: "setOtherParams",
|
|
1546
1572
|
value: function () {
|
|
1547
1573
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
1574
|
+
var _this$otherParams11, _this$otherParams13;
|
|
1548
1575
|
var _ref32,
|
|
1549
1576
|
_ref32$cover,
|
|
1550
1577
|
cover,
|
|
1551
1578
|
previousScope,
|
|
1579
|
+
previousItemRuleConfig,
|
|
1552
1580
|
explicitlySetsOpenData,
|
|
1553
1581
|
nextScope,
|
|
1554
|
-
_this$
|
|
1582
|
+
_this$otherParams12,
|
|
1555
1583
|
shouldResetAvailabilityState,
|
|
1556
1584
|
_args3 = arguments;
|
|
1557
1585
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -1559,24 +1587,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1559
1587
|
case 0:
|
|
1560
1588
|
_ref32 = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {}, _ref32$cover = _ref32.cover, cover = _ref32$cover === void 0 ? false : _ref32$cover;
|
|
1561
1589
|
previousScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
|
|
1590
|
+
previousItemRuleConfig = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.itemRule;
|
|
1562
1591
|
explicitlySetsOpenData = Object.prototype.hasOwnProperty.call(params, 'openData');
|
|
1563
|
-
_context3.next =
|
|
1592
|
+
_context3.next = 6;
|
|
1564
1593
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "setOtherParams", this).call(this, params, {
|
|
1565
1594
|
cover: cover
|
|
1566
1595
|
});
|
|
1567
|
-
case
|
|
1596
|
+
case 6:
|
|
1568
1597
|
nextScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
|
|
1569
1598
|
if (explicitlySetsOpenData) {
|
|
1570
|
-
this.openDataTarget = (_this$
|
|
1599
|
+
this.openDataTarget = (_this$otherParams12 = this.otherParams) !== null && _this$otherParams12 !== void 0 && _this$otherParams12.openData && nextScope.businessCode && nextScope.channel ? "".concat(nextScope.businessCode, "+").concat(nextScope.channel) : null;
|
|
1571
1600
|
}
|
|
1572
1601
|
shouldResetAvailabilityState = previousScope.cacheId !== nextScope.cacheId || previousScope.businessCode !== nextScope.businessCode || previousScope.channel !== nextScope.channel || previousScope.platform !== nextScope.platform || previousScope.businessTimezone !== nextScope.businessTimezone;
|
|
1573
1602
|
if (!shouldResetAvailabilityState) {
|
|
1574
|
-
_context3.next =
|
|
1603
|
+
_context3.next = 12;
|
|
1575
1604
|
break;
|
|
1576
1605
|
}
|
|
1577
|
-
_context3.next =
|
|
1606
|
+
_context3.next = 12;
|
|
1578
1607
|
return this.resetAvailabilityProjectionState('set_other_params_reset');
|
|
1579
|
-
case
|
|
1608
|
+
case 12:
|
|
1609
|
+
if (shouldResetAvailabilityState || explicitlySetsOpenData || previousItemRuleConfig !== ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.itemRule)) {
|
|
1610
|
+
this.resetAllergyItemRuleState();
|
|
1611
|
+
}
|
|
1612
|
+
case 13:
|
|
1580
1613
|
case "end":
|
|
1581
1614
|
return _context3.stop();
|
|
1582
1615
|
}
|
|
@@ -1599,9 +1632,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1599
1632
|
_context4.next = 4;
|
|
1600
1633
|
return this.resetAvailabilityProjectionState('destroy');
|
|
1601
1634
|
case 4:
|
|
1602
|
-
|
|
1635
|
+
this.resetAllergyItemRuleState();
|
|
1636
|
+
_context4.next = 7;
|
|
1603
1637
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "destroy", this).call(this);
|
|
1604
|
-
case
|
|
1638
|
+
case 7:
|
|
1605
1639
|
case "end":
|
|
1606
1640
|
return _context4.stop();
|
|
1607
1641
|
}
|
|
@@ -1806,8 +1840,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1806
1840
|
}, {
|
|
1807
1841
|
key: "isSessionStoragePersistEnabled",
|
|
1808
1842
|
value: function isSessionStoragePersistEnabled() {
|
|
1809
|
-
var _this$
|
|
1810
|
-
return Boolean(this.cacheId && ((_this$
|
|
1843
|
+
var _this$otherParams14;
|
|
1844
|
+
return Boolean(this.cacheId && ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.enableSessionStoragePersist) === true);
|
|
1811
1845
|
}
|
|
1812
1846
|
}, {
|
|
1813
1847
|
key: "shouldUseSessionStorageForSubModule",
|
|
@@ -1876,10 +1910,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1876
1910
|
}, {
|
|
1877
1911
|
key: "shouldUseCheckoutSyncTask",
|
|
1878
1912
|
value: function shouldUseCheckoutSyncTask() {
|
|
1879
|
-
var _this$
|
|
1880
|
-
var configured = (_this$
|
|
1913
|
+
var _this$otherParams15, _this$otherParams16;
|
|
1914
|
+
var configured = (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.checkoutSyncTaskEnabled;
|
|
1881
1915
|
if (configured === true) return true;
|
|
1882
|
-
var platform = normalizeRuntimePlatform((_this$
|
|
1916
|
+
var platform = normalizeRuntimePlatform((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.platform);
|
|
1883
1917
|
return platform !== 'h5' && platform !== 'kiosk';
|
|
1884
1918
|
}
|
|
1885
1919
|
|
|
@@ -2034,8 +2068,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2034
2068
|
}, {
|
|
2035
2069
|
key: "isAuthenticatedCustomerUserPlatform",
|
|
2036
2070
|
value: function isAuthenticatedCustomerUserPlatform() {
|
|
2037
|
-
var _this$
|
|
2038
|
-
return isCustomerUserPlatform((_this$
|
|
2071
|
+
var _this$otherParams17;
|
|
2072
|
+
return isCustomerUserPlatform((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform);
|
|
2039
2073
|
}
|
|
2040
2074
|
}, {
|
|
2041
2075
|
key: "resolveDiscountOrderIdentity",
|
|
@@ -2132,7 +2166,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2132
2166
|
key: "loadOpenData",
|
|
2133
2167
|
value: (function () {
|
|
2134
2168
|
var _loadOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
2135
|
-
var businessCode, channel, target, cachedData, lastFetchedAt, openData;
|
|
2169
|
+
var businessCode, channel, target, cachedData, lastFetchedAt, request, openData;
|
|
2136
2170
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
2137
2171
|
while (1) switch (_context11.prev = _context11.next) {
|
|
2138
2172
|
case 0:
|
|
@@ -2154,55 +2188,67 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2154
2188
|
cachedData = this.store.openData.getOpenData();
|
|
2155
2189
|
lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
2156
2190
|
if (!(!params.force && this.openDataTarget === target && cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
|
|
2157
|
-
_context11.next =
|
|
2191
|
+
_context11.next = 14;
|
|
2192
|
+
break;
|
|
2193
|
+
}
|
|
2194
|
+
if (!(typeof this.store.openData.ensureInvoiceTemplateSettings === 'function')) {
|
|
2195
|
+
_context11.next = 13;
|
|
2158
2196
|
break;
|
|
2159
2197
|
}
|
|
2198
|
+
_context11.next = 13;
|
|
2199
|
+
return this.store.openData.ensureInvoiceTemplateSettings(target);
|
|
2200
|
+
case 13:
|
|
2160
2201
|
return _context11.abrupt("return", cachedData);
|
|
2161
|
-
case
|
|
2202
|
+
case 14:
|
|
2162
2203
|
if (!this.loadOpenDataInFlight) {
|
|
2163
|
-
_context11.next =
|
|
2204
|
+
_context11.next = 22;
|
|
2164
2205
|
break;
|
|
2165
2206
|
}
|
|
2166
2207
|
if (!(this.loadOpenDataInFlightTarget === target)) {
|
|
2167
|
-
_context11.next =
|
|
2208
|
+
_context11.next = 19;
|
|
2168
2209
|
break;
|
|
2169
2210
|
}
|
|
2170
|
-
_context11.next = 15;
|
|
2171
|
-
return this.loadOpenDataInFlight;
|
|
2172
|
-
case 15:
|
|
2173
|
-
return _context11.abrupt("return", _context11.sent);
|
|
2174
|
-
case 16:
|
|
2175
2211
|
_context11.next = 18;
|
|
2176
2212
|
return this.loadOpenDataInFlight;
|
|
2177
2213
|
case 18:
|
|
2178
|
-
return _context11.abrupt("return",
|
|
2214
|
+
return _context11.abrupt("return", _context11.sent);
|
|
2179
2215
|
case 19:
|
|
2216
|
+
_context11.next = 21;
|
|
2217
|
+
return this.loadOpenDataInFlight;
|
|
2218
|
+
case 21:
|
|
2219
|
+
return _context11.abrupt("return", this.loadOpenData(params));
|
|
2220
|
+
case 22:
|
|
2180
2221
|
this.loadOpenDataInFlightTarget = target;
|
|
2181
|
-
|
|
2222
|
+
request = this.store.openData.fetchOpenData({
|
|
2182
2223
|
scope: 'board',
|
|
2183
2224
|
target: target,
|
|
2184
2225
|
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
2185
2226
|
});
|
|
2186
|
-
|
|
2187
|
-
_context11.
|
|
2188
|
-
|
|
2189
|
-
|
|
2227
|
+
this.loadOpenDataInFlight = request;
|
|
2228
|
+
_context11.prev = 25;
|
|
2229
|
+
_context11.next = 28;
|
|
2230
|
+
return request;
|
|
2231
|
+
case 28:
|
|
2190
2232
|
openData = _context11.sent;
|
|
2191
|
-
this.
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2233
|
+
if (this.loadOpenDataInFlight === request) {
|
|
2234
|
+
this.openDataTarget = target;
|
|
2235
|
+
this.otherParams.openData = openData;
|
|
2236
|
+
this.otherParams.businessCode = businessCode;
|
|
2237
|
+
this.otherParams.channel = channel;
|
|
2238
|
+
}
|
|
2195
2239
|
return _context11.abrupt("return", openData);
|
|
2196
|
-
case
|
|
2197
|
-
_context11.prev =
|
|
2198
|
-
this.loadOpenDataInFlight
|
|
2199
|
-
|
|
2200
|
-
|
|
2240
|
+
case 31:
|
|
2241
|
+
_context11.prev = 31;
|
|
2242
|
+
if (this.loadOpenDataInFlight === request) {
|
|
2243
|
+
this.loadOpenDataInFlight = null;
|
|
2244
|
+
this.loadOpenDataInFlightTarget = null;
|
|
2245
|
+
}
|
|
2246
|
+
return _context11.finish(31);
|
|
2201
2247
|
case 34:
|
|
2202
2248
|
case "end":
|
|
2203
2249
|
return _context11.stop();
|
|
2204
2250
|
}
|
|
2205
|
-
}, _callee11, this, [[
|
|
2251
|
+
}, _callee11, this, [[25,, 31, 34]]);
|
|
2206
2252
|
}));
|
|
2207
2253
|
function loadOpenData(_x7) {
|
|
2208
2254
|
return _loadOpenData.apply(this, arguments);
|
|
@@ -2213,32 +2259,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2213
2259
|
key: "getOpenData",
|
|
2214
2260
|
value: function () {
|
|
2215
2261
|
var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2216
|
-
var _this$
|
|
2217
|
-
var businessCode, channel
|
|
2262
|
+
var _this$otherParams18, _this$otherParams19;
|
|
2263
|
+
var businessCode, channel;
|
|
2218
2264
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2219
2265
|
while (1) switch (_context12.prev = _context12.next) {
|
|
2220
2266
|
case 0:
|
|
2221
|
-
businessCode = String(((_this$
|
|
2222
|
-
channel = String(((_this$
|
|
2267
|
+
businessCode = String(((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.businessCode) || '').trim();
|
|
2268
|
+
channel = String(((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.channel) || '').trim();
|
|
2223
2269
|
if (!(!businessCode || !channel)) {
|
|
2224
2270
|
_context12.next = 4;
|
|
2225
2271
|
break;
|
|
2226
2272
|
}
|
|
2227
2273
|
return _context12.abrupt("return", null);
|
|
2228
2274
|
case 4:
|
|
2229
|
-
target = "".concat(businessCode, "+").concat(channel);
|
|
2230
|
-
cachedData = ((_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData()) || null;
|
|
2231
|
-
if (!(cachedData && this.openDataTarget === target)) {
|
|
2232
|
-
_context12.next = 8;
|
|
2233
|
-
break;
|
|
2234
|
-
}
|
|
2235
|
-
return _context12.abrupt("return", cachedData);
|
|
2236
|
-
case 8:
|
|
2237
2275
|
return _context12.abrupt("return", this.loadOpenData({
|
|
2238
2276
|
businessCode: businessCode,
|
|
2239
2277
|
channel: channel
|
|
2240
2278
|
}));
|
|
2241
|
-
case
|
|
2279
|
+
case 5:
|
|
2242
2280
|
case "end":
|
|
2243
2281
|
return _context12.stop();
|
|
2244
2282
|
}
|
|
@@ -2249,20 +2287,299 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2249
2287
|
}
|
|
2250
2288
|
return getOpenData;
|
|
2251
2289
|
}()
|
|
2290
|
+
}, {
|
|
2291
|
+
key: "resetAllergyItemRuleState",
|
|
2292
|
+
value: function resetAllergyItemRuleState() {
|
|
2293
|
+
this.allergyItemRuleConfigs = [];
|
|
2294
|
+
this.allergyItemRuleConfigsPromise = null;
|
|
2295
|
+
this.allergyItemRuleEvaluator.setStrategyConfigs([]);
|
|
2296
|
+
}
|
|
2297
|
+
}, {
|
|
2298
|
+
key: "fetchAllergyItemRuleConfigs",
|
|
2299
|
+
value: function () {
|
|
2300
|
+
var _fetchAllergyItemRuleConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(strategyModelIds) {
|
|
2301
|
+
var _response$data, response, list;
|
|
2302
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
2303
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2304
|
+
case 0:
|
|
2305
|
+
if (strategyModelIds.length) {
|
|
2306
|
+
_context13.next = 2;
|
|
2307
|
+
break;
|
|
2308
|
+
}
|
|
2309
|
+
return _context13.abrupt("return", []);
|
|
2310
|
+
case 2:
|
|
2311
|
+
_context13.prev = 2;
|
|
2312
|
+
_context13.next = 5;
|
|
2313
|
+
return this.request.get('/promotion', {
|
|
2314
|
+
skip: 1,
|
|
2315
|
+
num: 99,
|
|
2316
|
+
status: 'active',
|
|
2317
|
+
ids: strategyModelIds
|
|
2318
|
+
});
|
|
2319
|
+
case 5:
|
|
2320
|
+
response = _context13.sent;
|
|
2321
|
+
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))) {
|
|
2322
|
+
_context13.next = 8;
|
|
2323
|
+
break;
|
|
2324
|
+
}
|
|
2325
|
+
throw new Error('[UnifiedBookingSales] 商品过敏策略加载失败');
|
|
2326
|
+
case 8:
|
|
2327
|
+
list = response.data.list;
|
|
2328
|
+
return _context13.abrupt("return", normalizeItemRuleStrategyConfigs(list.map(function (item) {
|
|
2329
|
+
return item === null || item === void 0 ? void 0 : item.metadata;
|
|
2330
|
+
})));
|
|
2331
|
+
case 12:
|
|
2332
|
+
_context13.prev = 12;
|
|
2333
|
+
_context13.t0 = _context13["catch"](2);
|
|
2334
|
+
throw _context13.t0;
|
|
2335
|
+
case 15:
|
|
2336
|
+
case "end":
|
|
2337
|
+
return _context13.stop();
|
|
2338
|
+
}
|
|
2339
|
+
}, _callee13, this, [[2, 12]]);
|
|
2340
|
+
}));
|
|
2341
|
+
function fetchAllergyItemRuleConfigs(_x8) {
|
|
2342
|
+
return _fetchAllergyItemRuleConfigs.apply(this, arguments);
|
|
2343
|
+
}
|
|
2344
|
+
return fetchAllergyItemRuleConfigs;
|
|
2345
|
+
}()
|
|
2346
|
+
}, {
|
|
2347
|
+
key: "ensureAllergyItemRuleConfigsLoaded",
|
|
2348
|
+
value: function () {
|
|
2349
|
+
var _ensureAllergyItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
2350
|
+
var _this3 = this;
|
|
2351
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
2352
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2353
|
+
case 0:
|
|
2354
|
+
if (!(this.allergyItemRuleConfigs.length > 0)) {
|
|
2355
|
+
_context15.next = 2;
|
|
2356
|
+
break;
|
|
2357
|
+
}
|
|
2358
|
+
return _context15.abrupt("return", this.allergyItemRuleConfigs);
|
|
2359
|
+
case 2:
|
|
2360
|
+
if (!this.allergyItemRuleConfigsPromise) {
|
|
2361
|
+
_context15.next = 4;
|
|
2362
|
+
break;
|
|
2363
|
+
}
|
|
2364
|
+
return _context15.abrupt("return", this.allergyItemRuleConfigsPromise);
|
|
2365
|
+
case 4:
|
|
2366
|
+
this.allergyItemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
2367
|
+
var _this3$otherParams;
|
|
2368
|
+
var staticConfigs, openData, enabled, strategyModelIds, loaded;
|
|
2369
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2370
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2371
|
+
case 0:
|
|
2372
|
+
staticConfigs = normalizeItemRuleStrategyConfigs((_this3$otherParams = _this3.otherParams) === null || _this3$otherParams === void 0 || (_this3$otherParams = _this3$otherParams.itemRule) === null || _this3$otherParams === void 0 ? void 0 : _this3$otherParams.strategyConfigs);
|
|
2373
|
+
if (!(staticConfigs.length > 0)) {
|
|
2374
|
+
_context14.next = 5;
|
|
2375
|
+
break;
|
|
2376
|
+
}
|
|
2377
|
+
_this3.allergyItemRuleConfigs = staticConfigs;
|
|
2378
|
+
_this3.allergyItemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2379
|
+
return _context14.abrupt("return", staticConfigs);
|
|
2380
|
+
case 5:
|
|
2381
|
+
_context14.next = 7;
|
|
2382
|
+
return _this3.getOpenData();
|
|
2383
|
+
case 7:
|
|
2384
|
+
openData = _context14.sent;
|
|
2385
|
+
enabled = toConfiguredBoolean(openData === null || openData === void 0 ? void 0 : openData['sale.enable_item_rules']);
|
|
2386
|
+
strategyModelIds = normalizePositiveIntegerList(openData === null || openData === void 0 ? void 0 : openData['sale.enabled_item_rules']);
|
|
2387
|
+
if (!(!enabled || !strategyModelIds.length)) {
|
|
2388
|
+
_context14.next = 13;
|
|
2389
|
+
break;
|
|
2390
|
+
}
|
|
2391
|
+
_this3.allergyItemRuleEvaluator.setStrategyConfigs([]);
|
|
2392
|
+
return _context14.abrupt("return", []);
|
|
2393
|
+
case 13:
|
|
2394
|
+
_context14.next = 15;
|
|
2395
|
+
return _this3.fetchAllergyItemRuleConfigs(strategyModelIds);
|
|
2396
|
+
case 15:
|
|
2397
|
+
loaded = _context14.sent;
|
|
2398
|
+
_this3.allergyItemRuleConfigs = loaded;
|
|
2399
|
+
_this3.allergyItemRuleEvaluator.setStrategyConfigs(loaded);
|
|
2400
|
+
return _context14.abrupt("return", loaded);
|
|
2401
|
+
case 19:
|
|
2402
|
+
case "end":
|
|
2403
|
+
return _context14.stop();
|
|
2404
|
+
}
|
|
2405
|
+
}, _callee14);
|
|
2406
|
+
}))();
|
|
2407
|
+
return _context15.abrupt("return", this.allergyItemRuleConfigsPromise);
|
|
2408
|
+
case 6:
|
|
2409
|
+
case "end":
|
|
2410
|
+
return _context15.stop();
|
|
2411
|
+
}
|
|
2412
|
+
}, _callee15, this);
|
|
2413
|
+
}));
|
|
2414
|
+
function ensureAllergyItemRuleConfigsLoaded() {
|
|
2415
|
+
return _ensureAllergyItemRuleConfigsLoaded.apply(this, arguments);
|
|
2416
|
+
}
|
|
2417
|
+
return ensureAllergyItemRuleConfigsLoaded;
|
|
2418
|
+
}()
|
|
2419
|
+
/**
|
|
2420
|
+
* 评估当前渠道与商品是否命中 ALLERGY_CHECK。
|
|
2421
|
+
* 只返回优先级最高 Action 中当前商品 Target 的 dataSource,不跨商品或 Action 合并。
|
|
2422
|
+
*/
|
|
2423
|
+
}, {
|
|
2424
|
+
key: "resolveProductAllergyRequirement",
|
|
2425
|
+
value: (function () {
|
|
2426
|
+
var _resolveProductAllergyRequirement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
2427
|
+
var _this$otherParams20, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref35, _runtimeConfig$servic, _this$otherParams21, _ref36, _ref37, _params$channel, _this$otherParams22, _this$otherParams23, _runtimeConfig$submis;
|
|
2428
|
+
var productId, strategyConfigs, productVariantId, runtimeConfig, runtimePax, cartItems;
|
|
2429
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2430
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2431
|
+
case 0:
|
|
2432
|
+
productId = normalizePositiveInteger(params.productId);
|
|
2433
|
+
if (productId) {
|
|
2434
|
+
_context16.next = 3;
|
|
2435
|
+
break;
|
|
2436
|
+
}
|
|
2437
|
+
return _context16.abrupt("return", null);
|
|
2438
|
+
case 3:
|
|
2439
|
+
_context16.next = 5;
|
|
2440
|
+
return this.ensureAllergyItemRuleConfigsLoaded();
|
|
2441
|
+
case 5:
|
|
2442
|
+
strategyConfigs = _context16.sent;
|
|
2443
|
+
if (strategyConfigs.length) {
|
|
2444
|
+
_context16.next = 8;
|
|
2445
|
+
break;
|
|
2446
|
+
}
|
|
2447
|
+
return _context16.abrupt("return", null);
|
|
2448
|
+
case 8:
|
|
2449
|
+
productVariantId = normalizePositiveInteger(params.productVariantId);
|
|
2450
|
+
runtimeConfig = ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.itemRule) || {};
|
|
2451
|
+
runtimePax = runtimeConfig.pax || {};
|
|
2452
|
+
cartItems = (((_this$getOrderProduct = this.getOrderProducts) === null || _this$getOrderProduct === void 0 ? void 0 : _this$getOrderProduct.call(this)) || []).map(function (item) {
|
|
2453
|
+
var _item$product_id, _item$product_variant, _ref34, _item$num;
|
|
2454
|
+
return {
|
|
2455
|
+
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),
|
|
2456
|
+
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,
|
|
2457
|
+
quantity: Number((_ref34 = (_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 && _ref34 !== void 0 ? _ref34 : 0)
|
|
2458
|
+
};
|
|
2459
|
+
}).filter(function (item) {
|
|
2460
|
+
return Number.isFinite(item.product_id) && item.product_id > 0 && Number.isFinite(item.quantity) && item.quantity > 0;
|
|
2461
|
+
});
|
|
2462
|
+
return _context16.abrupt("return", this.allergyItemRuleEvaluator.getAllergyRequirement({
|
|
2463
|
+
pax: {
|
|
2464
|
+
total: Number((_runtimePax$total = runtimePax.total) !== null && _runtimePax$total !== void 0 ? _runtimePax$total : 0) || 0,
|
|
2465
|
+
adult: Number((_runtimePax$adult = runtimePax.adult) !== null && _runtimePax$adult !== void 0 ? _runtimePax$adult : 0) || 0,
|
|
2466
|
+
child: Number((_runtimePax$child = runtimePax.child) !== null && _runtimePax$child !== void 0 ? _runtimePax$child : 0) || 0
|
|
2467
|
+
},
|
|
2468
|
+
cartItems: cartItems,
|
|
2469
|
+
serviceType: String((_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : ''),
|
|
2470
|
+
channel: String((_ref36 = (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform) !== null && _ref36 !== void 0 ? _ref36 : ''),
|
|
2471
|
+
currentProduct: _objectSpread({
|
|
2472
|
+
product_id: productId
|
|
2473
|
+
}, productVariantId ? {
|
|
2474
|
+
product_variant_id: productVariantId
|
|
2475
|
+
} : {}),
|
|
2476
|
+
submissionIndex: Number((_runtimeConfig$submis = runtimeConfig.submissionIndex) !== null && _runtimeConfig$submis !== void 0 ? _runtimeConfig$submis : 0) || 0,
|
|
2477
|
+
strategyConfigs: strategyConfigs,
|
|
2478
|
+
custom: runtimeConfig.custom
|
|
2479
|
+
}));
|
|
2480
|
+
case 13:
|
|
2481
|
+
case "end":
|
|
2482
|
+
return _context16.stop();
|
|
2483
|
+
}
|
|
2484
|
+
}, _callee16, this);
|
|
2485
|
+
}));
|
|
2486
|
+
function resolveProductAllergyRequirement(_x9) {
|
|
2487
|
+
return _resolveProductAllergyRequirement.apply(this, arguments);
|
|
2488
|
+
}
|
|
2489
|
+
return resolveProductAllergyRequirement;
|
|
2490
|
+
}())
|
|
2491
|
+
}, {
|
|
2492
|
+
key: "clearOpenDataCache",
|
|
2493
|
+
value: function clearOpenDataCache() {
|
|
2494
|
+
this.openDataTarget = null;
|
|
2495
|
+
this.loadOpenDataInFlight = null;
|
|
2496
|
+
this.loadOpenDataInFlightTarget = null;
|
|
2497
|
+
_get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "clearOpenDataCache", this).call(this);
|
|
2498
|
+
}
|
|
2499
|
+
}, {
|
|
2500
|
+
key: "getInvoiceLayoutConfig",
|
|
2501
|
+
value: function () {
|
|
2502
|
+
var _getInvoiceLayoutConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
2503
|
+
var openData;
|
|
2504
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2505
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2506
|
+
case 0:
|
|
2507
|
+
_context17.next = 2;
|
|
2508
|
+
return this.getOpenData();
|
|
2509
|
+
case 2:
|
|
2510
|
+
openData = _context17.sent;
|
|
2511
|
+
if (!(!openData || !this.store.openData)) {
|
|
2512
|
+
_context17.next = 5;
|
|
2513
|
+
break;
|
|
2514
|
+
}
|
|
2515
|
+
return _context17.abrupt("return", getDefaultInvoiceLayoutConfig());
|
|
2516
|
+
case 5:
|
|
2517
|
+
return _context17.abrupt("return", this.store.openData.getInvoiceLayoutConfig());
|
|
2518
|
+
case 6:
|
|
2519
|
+
case "end":
|
|
2520
|
+
return _context17.stop();
|
|
2521
|
+
}
|
|
2522
|
+
}, _callee17, this);
|
|
2523
|
+
}));
|
|
2524
|
+
function getInvoiceLayoutConfig() {
|
|
2525
|
+
return _getInvoiceLayoutConfig.apply(this, arguments);
|
|
2526
|
+
}
|
|
2527
|
+
return getInvoiceLayoutConfig;
|
|
2528
|
+
}()
|
|
2529
|
+
}, {
|
|
2530
|
+
key: "getInvoiceTemplateSettings",
|
|
2531
|
+
value: function () {
|
|
2532
|
+
var _getInvoiceTemplateSettings = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2533
|
+
var openData;
|
|
2534
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2535
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2536
|
+
case 0:
|
|
2537
|
+
_context18.next = 2;
|
|
2538
|
+
return this.getOpenData();
|
|
2539
|
+
case 2:
|
|
2540
|
+
openData = _context18.sent;
|
|
2541
|
+
if (!(!openData || !this.store.openData)) {
|
|
2542
|
+
_context18.next = 5;
|
|
2543
|
+
break;
|
|
2544
|
+
}
|
|
2545
|
+
return _context18.abrupt("return", getDefaultInvoiceTemplateSettings());
|
|
2546
|
+
case 5:
|
|
2547
|
+
return _context18.abrupt("return", this.store.openData.getInvoiceTemplateSettings());
|
|
2548
|
+
case 6:
|
|
2549
|
+
case "end":
|
|
2550
|
+
return _context18.stop();
|
|
2551
|
+
}
|
|
2552
|
+
}, _callee18, this);
|
|
2553
|
+
}));
|
|
2554
|
+
function getInvoiceTemplateSettings() {
|
|
2555
|
+
return _getInvoiceTemplateSettings.apply(this, arguments);
|
|
2556
|
+
}
|
|
2557
|
+
return getInvoiceTemplateSettings;
|
|
2558
|
+
}()
|
|
2559
|
+
}, {
|
|
2560
|
+
key: "isInvoiceOpenDataCacheCurrent",
|
|
2561
|
+
value: function isInvoiceOpenDataCacheCurrent() {
|
|
2562
|
+
var _this$otherParams24, _this$otherParams25;
|
|
2563
|
+
var businessCode = String(((_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.businessCode) || '').trim();
|
|
2564
|
+
var channel = String(((_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.channel) || '').trim();
|
|
2565
|
+
if (!businessCode || !channel) return false;
|
|
2566
|
+
return this.openDataTarget === "".concat(businessCode, "+").concat(channel);
|
|
2567
|
+
}
|
|
2568
|
+
|
|
2252
2569
|
/**
|
|
2253
2570
|
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
2254
2571
|
*/
|
|
2255
2572
|
}, {
|
|
2256
2573
|
key: "getProtocol",
|
|
2257
2574
|
value: (function () {
|
|
2258
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2575
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(policyId) {
|
|
2259
2576
|
var normalizedPolicyId, policyUrl;
|
|
2260
|
-
return _regeneratorRuntime().wrap(function
|
|
2261
|
-
while (1) switch (
|
|
2577
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2578
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2262
2579
|
case 0:
|
|
2263
2580
|
normalizedPolicyId = String(policyId !== null && policyId !== void 0 ? policyId : '').trim();
|
|
2264
2581
|
if (normalizedPolicyId) {
|
|
2265
|
-
|
|
2582
|
+
_context19.next = 3;
|
|
2266
2583
|
break;
|
|
2267
2584
|
}
|
|
2268
2585
|
throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
|
|
@@ -2271,14 +2588,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2271
2588
|
if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
|
|
2272
2589
|
policyUrl = 'policy';
|
|
2273
2590
|
}
|
|
2274
|
-
return
|
|
2591
|
+
return _context19.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
|
|
2275
2592
|
case 6:
|
|
2276
2593
|
case "end":
|
|
2277
|
-
return
|
|
2594
|
+
return _context19.stop();
|
|
2278
2595
|
}
|
|
2279
|
-
},
|
|
2596
|
+
}, _callee19, this);
|
|
2280
2597
|
}));
|
|
2281
|
-
function getProtocol(
|
|
2598
|
+
function getProtocol(_x10) {
|
|
2282
2599
|
return _getProtocol.apply(this, arguments);
|
|
2283
2600
|
}
|
|
2284
2601
|
return getProtocol;
|
|
@@ -2291,27 +2608,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2291
2608
|
}, {
|
|
2292
2609
|
key: "loadProducts",
|
|
2293
2610
|
value: (function () {
|
|
2294
|
-
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2611
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
2295
2612
|
var params,
|
|
2296
2613
|
options,
|
|
2297
2614
|
schedule_date,
|
|
2298
2615
|
schedule_datetime,
|
|
2299
2616
|
result,
|
|
2300
|
-
|
|
2301
|
-
return _regeneratorRuntime().wrap(function
|
|
2302
|
-
while (1) switch (
|
|
2617
|
+
_args20 = arguments;
|
|
2618
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2619
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2303
2620
|
case 0:
|
|
2304
|
-
params =
|
|
2305
|
-
options =
|
|
2621
|
+
params = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {};
|
|
2622
|
+
options = _args20.length > 1 ? _args20[1] : undefined;
|
|
2306
2623
|
if (this.store.products) {
|
|
2307
|
-
|
|
2624
|
+
_context20.next = 4;
|
|
2308
2625
|
break;
|
|
2309
2626
|
}
|
|
2310
2627
|
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
2311
2628
|
case 4:
|
|
2312
2629
|
schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
2313
2630
|
schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
|
|
2314
|
-
|
|
2631
|
+
_context20.next = 8;
|
|
2315
2632
|
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
2316
2633
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
2317
2634
|
with_schedule: 1
|
|
@@ -2321,44 +2638,72 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2321
2638
|
cacheId: this.cacheId
|
|
2322
2639
|
}), options);
|
|
2323
2640
|
case 8:
|
|
2324
|
-
result =
|
|
2641
|
+
result = _context20.sent;
|
|
2325
2642
|
this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
|
|
2326
|
-
|
|
2643
|
+
_context20.next = 12;
|
|
2327
2644
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
|
|
2328
2645
|
case 12:
|
|
2329
|
-
return
|
|
2646
|
+
return _context20.abrupt("return", result);
|
|
2330
2647
|
case 13:
|
|
2331
2648
|
case "end":
|
|
2332
|
-
return
|
|
2649
|
+
return _context20.stop();
|
|
2333
2650
|
}
|
|
2334
|
-
},
|
|
2651
|
+
}, _callee20, this);
|
|
2335
2652
|
}));
|
|
2336
2653
|
function loadProducts() {
|
|
2337
2654
|
return _loadProducts.apply(this, arguments);
|
|
2338
2655
|
}
|
|
2339
2656
|
return loadProducts;
|
|
2340
|
-
}()
|
|
2657
|
+
}())
|
|
2658
|
+
}, {
|
|
2659
|
+
key: "queryProducts",
|
|
2660
|
+
value: function () {
|
|
2661
|
+
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
2662
|
+
var params,
|
|
2663
|
+
_args21 = arguments;
|
|
2664
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2665
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2666
|
+
case 0:
|
|
2667
|
+
params = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
|
|
2668
|
+
if (this.store.products) {
|
|
2669
|
+
_context21.next = 3;
|
|
2670
|
+
break;
|
|
2671
|
+
}
|
|
2672
|
+
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
2673
|
+
case 3:
|
|
2674
|
+
return _context21.abrupt("return", this.store.products.queryProducts(params));
|
|
2675
|
+
case 4:
|
|
2676
|
+
case "end":
|
|
2677
|
+
return _context21.stop();
|
|
2678
|
+
}
|
|
2679
|
+
}, _callee21, this);
|
|
2680
|
+
}));
|
|
2681
|
+
function queryProducts() {
|
|
2682
|
+
return _queryProducts.apply(this, arguments);
|
|
2683
|
+
}
|
|
2684
|
+
return queryProducts;
|
|
2685
|
+
}() /** Date-first entry point. It delegates protocol details and cache ownership to ScheduleModule. */
|
|
2341
2686
|
}, {
|
|
2342
2687
|
key: "loadScheduleAvailableDate",
|
|
2343
2688
|
value: (function () {
|
|
2344
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2345
|
-
return _regeneratorRuntime().wrap(function
|
|
2346
|
-
while (1) switch (
|
|
2689
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2690
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2691
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2347
2692
|
case 0:
|
|
2348
2693
|
if (this.store.schedule) {
|
|
2349
|
-
|
|
2694
|
+
_context22.next = 2;
|
|
2350
2695
|
break;
|
|
2351
2696
|
}
|
|
2352
2697
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
2353
2698
|
case 2:
|
|
2354
|
-
return
|
|
2699
|
+
return _context22.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
|
|
2355
2700
|
case 3:
|
|
2356
2701
|
case "end":
|
|
2357
|
-
return
|
|
2702
|
+
return _context22.stop();
|
|
2358
2703
|
}
|
|
2359
|
-
},
|
|
2704
|
+
}, _callee22, this);
|
|
2360
2705
|
}));
|
|
2361
|
-
function loadScheduleAvailableDate(
|
|
2706
|
+
function loadScheduleAvailableDate(_x11) {
|
|
2362
2707
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
2363
2708
|
}
|
|
2364
2709
|
return loadScheduleAvailableDate;
|
|
@@ -2372,15 +2717,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2372
2717
|
}, {
|
|
2373
2718
|
key: "loadProductsByScheduleDate",
|
|
2374
2719
|
value: (function () {
|
|
2375
|
-
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2720
|
+
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2376
2721
|
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;
|
|
2377
2722
|
var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator, _step, productId, result;
|
|
2378
|
-
return _regeneratorRuntime().wrap(function
|
|
2379
|
-
while (1) switch (
|
|
2723
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2724
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2380
2725
|
case 0:
|
|
2381
2726
|
date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
|
|
2382
2727
|
if (this.store.schedule) {
|
|
2383
|
-
|
|
2728
|
+
_context23.next = 3;
|
|
2384
2729
|
break;
|
|
2385
2730
|
}
|
|
2386
2731
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
@@ -2391,10 +2736,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2391
2736
|
});
|
|
2392
2737
|
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;
|
|
2393
2738
|
if (!(!hasCachedDate && !hasOtherProducts)) {
|
|
2394
|
-
|
|
2739
|
+
_context23.next = 9;
|
|
2395
2740
|
break;
|
|
2396
2741
|
}
|
|
2397
|
-
|
|
2742
|
+
_context23.next = 9;
|
|
2398
2743
|
return this.loadScheduleAvailableDate({
|
|
2399
2744
|
startDate: date,
|
|
2400
2745
|
endDate: date,
|
|
@@ -2414,45 +2759,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2414
2759
|
return !productIdFilter || productIdFilter.has(String(id));
|
|
2415
2760
|
});
|
|
2416
2761
|
if (availableProductIds.length) {
|
|
2417
|
-
|
|
2762
|
+
_context23.next = 17;
|
|
2418
2763
|
break;
|
|
2419
2764
|
}
|
|
2420
2765
|
this.unifiedProductCatalog = [];
|
|
2421
|
-
|
|
2766
|
+
_context23.next = 16;
|
|
2422
2767
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
|
|
2423
2768
|
case 16:
|
|
2424
|
-
return
|
|
2769
|
+
return _context23.abrupt("return", []);
|
|
2425
2770
|
case 17:
|
|
2426
|
-
|
|
2771
|
+
_context23.next = 19;
|
|
2427
2772
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
2428
2773
|
product_ids: availableProductIds,
|
|
2429
2774
|
schedule_date: date
|
|
2430
2775
|
}));
|
|
2431
2776
|
case 19:
|
|
2432
|
-
products =
|
|
2777
|
+
products = _context23.sent;
|
|
2433
2778
|
if (!(products.length || availableProductIds.length <= 1)) {
|
|
2434
|
-
|
|
2779
|
+
_context23.next = 22;
|
|
2435
2780
|
break;
|
|
2436
2781
|
}
|
|
2437
|
-
return
|
|
2782
|
+
return _context23.abrupt("return", products);
|
|
2438
2783
|
case 22:
|
|
2439
2784
|
fallbackProducts = [];
|
|
2440
2785
|
_iterator = _createForOfIteratorHelper(availableProductIds);
|
|
2441
|
-
|
|
2786
|
+
_context23.prev = 24;
|
|
2442
2787
|
_iterator.s();
|
|
2443
2788
|
case 26:
|
|
2444
2789
|
if ((_step = _iterator.n()).done) {
|
|
2445
|
-
|
|
2790
|
+
_context23.next = 34;
|
|
2446
2791
|
break;
|
|
2447
2792
|
}
|
|
2448
2793
|
productId = _step.value;
|
|
2449
|
-
|
|
2794
|
+
_context23.next = 30;
|
|
2450
2795
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
2451
2796
|
product_ids: [productId],
|
|
2452
2797
|
schedule_date: date
|
|
2453
2798
|
}));
|
|
2454
2799
|
case 30:
|
|
2455
|
-
result =
|
|
2800
|
+
result = _context23.sent;
|
|
2456
2801
|
result.forEach(function (product) {
|
|
2457
2802
|
var _id;
|
|
2458
2803
|
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;
|
|
@@ -2464,32 +2809,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2464
2809
|
}
|
|
2465
2810
|
});
|
|
2466
2811
|
case 32:
|
|
2467
|
-
|
|
2812
|
+
_context23.next = 26;
|
|
2468
2813
|
break;
|
|
2469
2814
|
case 34:
|
|
2470
|
-
|
|
2815
|
+
_context23.next = 39;
|
|
2471
2816
|
break;
|
|
2472
2817
|
case 36:
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
_iterator.e(
|
|
2818
|
+
_context23.prev = 36;
|
|
2819
|
+
_context23.t0 = _context23["catch"](24);
|
|
2820
|
+
_iterator.e(_context23.t0);
|
|
2476
2821
|
case 39:
|
|
2477
|
-
|
|
2822
|
+
_context23.prev = 39;
|
|
2478
2823
|
_iterator.f();
|
|
2479
|
-
return
|
|
2824
|
+
return _context23.finish(39);
|
|
2480
2825
|
case 42:
|
|
2481
2826
|
this.unifiedProductCatalog = [].concat(fallbackProducts);
|
|
2482
|
-
|
|
2827
|
+
_context23.next = 45;
|
|
2483
2828
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
|
|
2484
2829
|
case 45:
|
|
2485
|
-
return
|
|
2830
|
+
return _context23.abrupt("return", fallbackProducts);
|
|
2486
2831
|
case 46:
|
|
2487
2832
|
case "end":
|
|
2488
|
-
return
|
|
2833
|
+
return _context23.stop();
|
|
2489
2834
|
}
|
|
2490
|
-
},
|
|
2835
|
+
}, _callee23, this, [[24, 36, 39, 42]]);
|
|
2491
2836
|
}));
|
|
2492
|
-
function loadProductsByScheduleDate(
|
|
2837
|
+
function loadProductsByScheduleDate(_x12) {
|
|
2493
2838
|
return _loadProductsByScheduleDate.apply(this, arguments);
|
|
2494
2839
|
}
|
|
2495
2840
|
return loadProductsByScheduleDate;
|
|
@@ -2542,7 +2887,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2542
2887
|
}, {
|
|
2543
2888
|
key: "applyPlannerDiscounts",
|
|
2544
2889
|
value: (function () {
|
|
2545
|
-
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2890
|
+
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2546
2891
|
var _params$customerId;
|
|
2547
2892
|
var params,
|
|
2548
2893
|
tempOrder,
|
|
@@ -2559,24 +2904,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2559
2904
|
discount,
|
|
2560
2905
|
discountId,
|
|
2561
2906
|
nextTempOrder,
|
|
2562
|
-
|
|
2563
|
-
return _regeneratorRuntime().wrap(function
|
|
2564
|
-
while (1) switch (
|
|
2907
|
+
_args24 = arguments;
|
|
2908
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2909
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2565
2910
|
case 0:
|
|
2566
|
-
params =
|
|
2911
|
+
params = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
|
|
2567
2912
|
tempOrder = this.getTempOrder();
|
|
2568
2913
|
requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
2569
2914
|
parsedCustomerId = Number(requestedCustomerId);
|
|
2570
2915
|
customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
|
|
2571
|
-
|
|
2916
|
+
_context24.next = 7;
|
|
2572
2917
|
return this.getSummary();
|
|
2573
2918
|
case 7:
|
|
2574
|
-
summaryBefore =
|
|
2919
|
+
summaryBefore = _context24.sent;
|
|
2575
2920
|
if (customerId) {
|
|
2576
|
-
|
|
2921
|
+
_context24.next = 10;
|
|
2577
2922
|
break;
|
|
2578
2923
|
}
|
|
2579
|
-
return
|
|
2924
|
+
return _context24.abrupt("return", buildPlannerDiscountResult({
|
|
2580
2925
|
customerId: null,
|
|
2581
2926
|
discountList: this.getDiscountList(),
|
|
2582
2927
|
products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
@@ -2585,7 +2930,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2585
2930
|
status: 'no_customer'
|
|
2586
2931
|
}));
|
|
2587
2932
|
case 10:
|
|
2588
|
-
|
|
2933
|
+
_context24.next = 12;
|
|
2589
2934
|
return this.loadDiscountConfig({
|
|
2590
2935
|
customerId: customerId,
|
|
2591
2936
|
action: 'create'
|
|
@@ -2597,7 +2942,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2597
2942
|
return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
|
|
2598
2943
|
});
|
|
2599
2944
|
if (!preferredDiscount) {
|
|
2600
|
-
|
|
2945
|
+
_context24.next = 40;
|
|
2601
2946
|
break;
|
|
2602
2947
|
}
|
|
2603
2948
|
// A requested card is an explicit UI choice, not a best-effort preference. Clear prior
|
|
@@ -2609,98 +2954,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2609
2954
|
return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
|
|
2610
2955
|
});
|
|
2611
2956
|
_iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
|
|
2612
|
-
|
|
2957
|
+
_context24.prev = 18;
|
|
2613
2958
|
_iterator2.s();
|
|
2614
2959
|
case 20:
|
|
2615
2960
|
if ((_step2 = _iterator2.n()).done) {
|
|
2616
|
-
|
|
2961
|
+
_context24.next = 28;
|
|
2617
2962
|
break;
|
|
2618
2963
|
}
|
|
2619
2964
|
discount = _step2.value;
|
|
2620
2965
|
discountId = Number(resolvePlannerDiscountId(discount));
|
|
2621
2966
|
if (!Number.isFinite(discountId)) {
|
|
2622
|
-
|
|
2967
|
+
_context24.next = 26;
|
|
2623
2968
|
break;
|
|
2624
2969
|
}
|
|
2625
|
-
|
|
2970
|
+
_context24.next = 26;
|
|
2626
2971
|
return this.setDiscountSelected({
|
|
2627
2972
|
discountId: discountId,
|
|
2628
2973
|
isSelected: false
|
|
2629
2974
|
});
|
|
2630
2975
|
case 26:
|
|
2631
|
-
|
|
2976
|
+
_context24.next = 20;
|
|
2632
2977
|
break;
|
|
2633
2978
|
case 28:
|
|
2634
|
-
|
|
2979
|
+
_context24.next = 33;
|
|
2635
2980
|
break;
|
|
2636
2981
|
case 30:
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
_iterator2.e(
|
|
2982
|
+
_context24.prev = 30;
|
|
2983
|
+
_context24.t0 = _context24["catch"](18);
|
|
2984
|
+
_iterator2.e(_context24.t0);
|
|
2640
2985
|
case 33:
|
|
2641
|
-
|
|
2986
|
+
_context24.prev = 33;
|
|
2642
2987
|
_iterator2.f();
|
|
2643
|
-
return
|
|
2988
|
+
return _context24.finish(33);
|
|
2644
2989
|
case 36:
|
|
2645
|
-
|
|
2990
|
+
_context24.next = 38;
|
|
2646
2991
|
return this.setDiscountSelected({
|
|
2647
2992
|
discountId: Number(preferredId),
|
|
2648
2993
|
isSelected: true
|
|
2649
2994
|
});
|
|
2650
2995
|
case 38:
|
|
2651
|
-
|
|
2996
|
+
_context24.next = 49;
|
|
2652
2997
|
break;
|
|
2653
2998
|
case 40:
|
|
2654
2999
|
if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
|
|
2655
|
-
|
|
3000
|
+
_context24.next = 46;
|
|
2656
3001
|
break;
|
|
2657
3002
|
}
|
|
2658
3003
|
if (!(params.applyBestDiscount !== false)) {
|
|
2659
|
-
|
|
3004
|
+
_context24.next = 44;
|
|
2660
3005
|
break;
|
|
2661
3006
|
}
|
|
2662
|
-
|
|
3007
|
+
_context24.next = 44;
|
|
2663
3008
|
return this.bestDiscount();
|
|
2664
3009
|
case 44:
|
|
2665
|
-
|
|
3010
|
+
_context24.next = 49;
|
|
2666
3011
|
break;
|
|
2667
3012
|
case 46:
|
|
2668
3013
|
if (!(params.applyBestDiscount !== false)) {
|
|
2669
|
-
|
|
3014
|
+
_context24.next = 49;
|
|
2670
3015
|
break;
|
|
2671
3016
|
}
|
|
2672
|
-
|
|
3017
|
+
_context24.next = 49;
|
|
2673
3018
|
return this.bestDiscount();
|
|
2674
3019
|
case 49:
|
|
2675
3020
|
nextTempOrder = this.getTempOrder();
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
3021
|
+
_context24.t1 = buildPlannerDiscountResult;
|
|
3022
|
+
_context24.t2 = customerId;
|
|
3023
|
+
_context24.t3 = this.getDiscountList();
|
|
3024
|
+
_context24.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
|
|
3025
|
+
_context24.t5 = summaryBefore;
|
|
3026
|
+
_context24.next = 57;
|
|
2682
3027
|
return this.getSummary();
|
|
2683
3028
|
case 57:
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
customerId:
|
|
2690
|
-
discountList:
|
|
2691
|
-
products:
|
|
2692
|
-
summaryBefore:
|
|
2693
|
-
summaryAfter:
|
|
2694
|
-
status:
|
|
2695
|
-
preferredDiscountId:
|
|
2696
|
-
preferredDiscountFound:
|
|
3029
|
+
_context24.t6 = _context24.sent;
|
|
3030
|
+
_context24.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
|
|
3031
|
+
_context24.t8 = preferredDiscountId;
|
|
3032
|
+
_context24.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
|
|
3033
|
+
_context24.t10 = {
|
|
3034
|
+
customerId: _context24.t2,
|
|
3035
|
+
discountList: _context24.t3,
|
|
3036
|
+
products: _context24.t4,
|
|
3037
|
+
summaryBefore: _context24.t5,
|
|
3038
|
+
summaryAfter: _context24.t6,
|
|
3039
|
+
status: _context24.t7,
|
|
3040
|
+
preferredDiscountId: _context24.t8,
|
|
3041
|
+
preferredDiscountFound: _context24.t9
|
|
2697
3042
|
};
|
|
2698
|
-
return
|
|
3043
|
+
return _context24.abrupt("return", (0, _context24.t1)(_context24.t10));
|
|
2699
3044
|
case 63:
|
|
2700
3045
|
case "end":
|
|
2701
|
-
return
|
|
3046
|
+
return _context24.stop();
|
|
2702
3047
|
}
|
|
2703
|
-
},
|
|
3048
|
+
}, _callee24, this, [[18, 30, 33, 36]]);
|
|
2704
3049
|
}));
|
|
2705
3050
|
function applyPlannerDiscounts() {
|
|
2706
3051
|
return _applyPlannerDiscounts.apply(this, arguments);
|
|
@@ -2710,16 +3055,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2710
3055
|
}, {
|
|
2711
3056
|
key: "buildUnifiedOrderProduct",
|
|
2712
3057
|
value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
|
|
2713
|
-
var
|
|
3058
|
+
var _ref38, _sourceProduct$_exten, _sourceProduct$_exten2, _sourceProduct$metada, _sourceProduct$id, _ref39, _sourceProduct$produc, _ref40, _ref41, _sourceProduct$quanti, _sourceProduct$price, _ref42, _ref43, _sourceProduct$sellin;
|
|
2714
3059
|
var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
|
|
2715
|
-
var quotationShelfId = (
|
|
3060
|
+
var quotationShelfId = (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
|
|
2716
3061
|
var orderProduct = this.transformBaseProductToOrderProduct({
|
|
2717
3062
|
payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
|
|
2718
3063
|
id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
|
|
2719
|
-
product_id: (
|
|
2720
|
-
quantity: (
|
|
3064
|
+
product_id: (_ref39 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref39 !== void 0 ? _ref39 : product === null || product === void 0 ? void 0 : product.id,
|
|
3065
|
+
quantity: (_ref40 = (_ref41 = (_sourceProduct$quanti = sourceProduct.quantity) !== null && _sourceProduct$quanti !== void 0 ? _sourceProduct$quanti : sourceProduct.num) !== null && _ref41 !== void 0 ? _ref41 : product === null || product === void 0 ? void 0 : product.quantity) !== null && _ref40 !== void 0 ? _ref40 : 1,
|
|
2721
3066
|
price: (_sourceProduct$price = sourceProduct.price) !== null && _sourceProduct$price !== void 0 ? _sourceProduct$price : normalizedProductRaw.price,
|
|
2722
|
-
selling_price: (
|
|
3067
|
+
selling_price: (_ref42 = (_ref43 = (_sourceProduct$sellin = sourceProduct.selling_price) !== null && _sourceProduct$sellin !== void 0 ? _sourceProduct$sellin : sourceProduct.price) !== null && _ref43 !== void 0 ? _ref43 : normalizedProductRaw.selling_price) !== null && _ref42 !== void 0 ? _ref42 : normalizedProductRaw.price,
|
|
2723
3068
|
metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
|
|
2724
3069
|
}),
|
|
2725
3070
|
sourceProduct: sourceProduct
|
|
@@ -2738,29 +3083,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2738
3083
|
}, {
|
|
2739
3084
|
key: "removeExistingStagedLines",
|
|
2740
3085
|
value: (function () {
|
|
2741
|
-
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3086
|
+
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(ownershipKey) {
|
|
2742
3087
|
var _this$getTempOrder;
|
|
2743
3088
|
var existingLines;
|
|
2744
|
-
return _regeneratorRuntime().wrap(function
|
|
2745
|
-
while (1) switch (
|
|
3089
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
3090
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2746
3091
|
case 0:
|
|
2747
3092
|
existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
|
|
2748
3093
|
var _product$metadata4;
|
|
2749
3094
|
return (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4[ownershipKey]) === true;
|
|
2750
3095
|
});
|
|
2751
3096
|
if (!(existingLines.length > 0)) {
|
|
2752
|
-
|
|
3097
|
+
_context25.next = 4;
|
|
2753
3098
|
break;
|
|
2754
3099
|
}
|
|
2755
|
-
|
|
3100
|
+
_context25.next = 4;
|
|
2756
3101
|
return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
|
|
2757
3102
|
case 4:
|
|
2758
3103
|
case "end":
|
|
2759
|
-
return
|
|
3104
|
+
return _context25.stop();
|
|
2760
3105
|
}
|
|
2761
|
-
},
|
|
3106
|
+
}, _callee25, this);
|
|
2762
3107
|
}));
|
|
2763
|
-
function removeExistingStagedLines(
|
|
3108
|
+
function removeExistingStagedLines(_x13) {
|
|
2764
3109
|
return _removeExistingStagedLines.apply(this, arguments);
|
|
2765
3110
|
}
|
|
2766
3111
|
return removeExistingStagedLines;
|
|
@@ -2768,25 +3113,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2768
3113
|
}, {
|
|
2769
3114
|
key: "stageProducts",
|
|
2770
3115
|
value: function () {
|
|
2771
|
-
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3116
|
+
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params, ownershipKey) {
|
|
2772
3117
|
var _params$rawProducts;
|
|
2773
3118
|
var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
|
|
2774
|
-
return _regeneratorRuntime().wrap(function
|
|
2775
|
-
while (1) switch (
|
|
3119
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3120
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2776
3121
|
case 0:
|
|
2777
3122
|
productIds = params.productIds || [];
|
|
2778
3123
|
if (productIds.length) {
|
|
2779
|
-
|
|
3124
|
+
_context26.next = 3;
|
|
2780
3125
|
break;
|
|
2781
3126
|
}
|
|
2782
|
-
return
|
|
3127
|
+
return _context26.abrupt("return", this.getTempOrder());
|
|
2783
3128
|
case 3:
|
|
2784
3129
|
if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
|
|
2785
|
-
|
|
3130
|
+
_context26.next = 7;
|
|
2786
3131
|
break;
|
|
2787
3132
|
}
|
|
2788
3133
|
this.unifiedProductCatalog = params.rawProducts;
|
|
2789
|
-
|
|
3134
|
+
_context26.next = 12;
|
|
2790
3135
|
break;
|
|
2791
3136
|
case 7:
|
|
2792
3137
|
existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
|
|
@@ -2797,15 +3142,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2797
3142
|
return !existingIds.has(String(id));
|
|
2798
3143
|
});
|
|
2799
3144
|
if (!(missingIds.length || params.productLoadParams)) {
|
|
2800
|
-
|
|
3145
|
+
_context26.next = 12;
|
|
2801
3146
|
break;
|
|
2802
3147
|
}
|
|
2803
|
-
|
|
3148
|
+
_context26.next = 12;
|
|
2804
3149
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
2805
3150
|
product_ids: productIds.map(Number).filter(Number.isFinite)
|
|
2806
3151
|
}));
|
|
2807
3152
|
case 12:
|
|
2808
|
-
|
|
3153
|
+
_context26.next = 14;
|
|
2809
3154
|
return this.removeExistingStagedLines(ownershipKey);
|
|
2810
3155
|
case 14:
|
|
2811
3156
|
productIdSet = new Set(productIds.map(function (id) {
|
|
@@ -2818,30 +3163,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2818
3163
|
_i = 0, _arr = selectedProducts;
|
|
2819
3164
|
case 17:
|
|
2820
3165
|
if (!(_i < _arr.length)) {
|
|
2821
|
-
|
|
3166
|
+
_context26.next = 26;
|
|
2822
3167
|
break;
|
|
2823
3168
|
}
|
|
2824
3169
|
sourceProduct = _arr[_i];
|
|
2825
3170
|
productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
|
|
2826
3171
|
if (!productInput) {
|
|
2827
|
-
|
|
3172
|
+
_context26.next = 23;
|
|
2828
3173
|
break;
|
|
2829
3174
|
}
|
|
2830
|
-
|
|
3175
|
+
_context26.next = 23;
|
|
2831
3176
|
return this.addProductToOrder(productInput);
|
|
2832
3177
|
case 23:
|
|
2833
3178
|
_i++;
|
|
2834
|
-
|
|
3179
|
+
_context26.next = 17;
|
|
2835
3180
|
break;
|
|
2836
3181
|
case 26:
|
|
2837
|
-
return
|
|
3182
|
+
return _context26.abrupt("return", this.getTempOrder());
|
|
2838
3183
|
case 27:
|
|
2839
3184
|
case "end":
|
|
2840
|
-
return
|
|
3185
|
+
return _context26.stop();
|
|
2841
3186
|
}
|
|
2842
|
-
},
|
|
3187
|
+
}, _callee26, this);
|
|
2843
3188
|
}));
|
|
2844
|
-
function stageProducts(
|
|
3189
|
+
function stageProducts(_x14, _x15) {
|
|
2845
3190
|
return _stageProducts.apply(this, arguments);
|
|
2846
3191
|
}
|
|
2847
3192
|
return stageProducts;
|
|
@@ -2853,18 +3198,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2853
3198
|
}, {
|
|
2854
3199
|
key: "stageRetailProducts",
|
|
2855
3200
|
value: (function () {
|
|
2856
|
-
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2857
|
-
return _regeneratorRuntime().wrap(function
|
|
2858
|
-
while (1) switch (
|
|
3201
|
+
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
3202
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3203
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2859
3204
|
case 0:
|
|
2860
|
-
return
|
|
3205
|
+
return _context27.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
|
|
2861
3206
|
case 1:
|
|
2862
3207
|
case "end":
|
|
2863
|
-
return
|
|
3208
|
+
return _context27.stop();
|
|
2864
3209
|
}
|
|
2865
|
-
},
|
|
3210
|
+
}, _callee27, this);
|
|
2866
3211
|
}));
|
|
2867
|
-
function stageRetailProducts(
|
|
3212
|
+
function stageRetailProducts(_x16) {
|
|
2868
3213
|
return _stageRetailProducts.apply(this, arguments);
|
|
2869
3214
|
}
|
|
2870
3215
|
return stageRetailProducts;
|
|
@@ -2878,20 +3223,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2878
3223
|
}, {
|
|
2879
3224
|
key: "addRetailProduct",
|
|
2880
3225
|
value: (function () {
|
|
2881
|
-
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2882
|
-
var _params$quantity,
|
|
3226
|
+
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
3227
|
+
var _params$quantity, _ref44, _params$productId, _params$product, _params$product2;
|
|
2883
3228
|
var quantity, productId, sourceProduct, products, orderProduct;
|
|
2884
|
-
return _regeneratorRuntime().wrap(function
|
|
2885
|
-
while (1) switch (
|
|
3229
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3230
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2886
3231
|
case 0:
|
|
2887
3232
|
quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
|
|
2888
3233
|
if (!(!Number.isFinite(quantity) || quantity <= 0)) {
|
|
2889
|
-
|
|
3234
|
+
_context28.next = 3;
|
|
2890
3235
|
break;
|
|
2891
3236
|
}
|
|
2892
3237
|
throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
|
|
2893
3238
|
case 3:
|
|
2894
|
-
productId = (
|
|
3239
|
+
productId = (_ref44 = (_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 && _ref44 !== void 0 ? _ref44 : (_params$product2 = params.product) === null || _params$product2 === void 0 ? void 0 : _params$product2.product_id;
|
|
2895
3240
|
sourceProduct = params.product;
|
|
2896
3241
|
if (!sourceProduct && productId !== undefined && productId !== null) {
|
|
2897
3242
|
sourceProduct = this.unifiedProductCatalog.find(function (product) {
|
|
@@ -2900,22 +3245,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2900
3245
|
});
|
|
2901
3246
|
}
|
|
2902
3247
|
if (!(!sourceProduct && productId !== undefined && productId !== null)) {
|
|
2903
|
-
|
|
3248
|
+
_context28.next = 11;
|
|
2904
3249
|
break;
|
|
2905
3250
|
}
|
|
2906
|
-
|
|
3251
|
+
_context28.next = 9;
|
|
2907
3252
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
2908
3253
|
product_ids: [Number(productId)].filter(Number.isFinite)
|
|
2909
3254
|
}));
|
|
2910
3255
|
case 9:
|
|
2911
|
-
products =
|
|
3256
|
+
products = _context28.sent;
|
|
2912
3257
|
sourceProduct = products.find(function (product) {
|
|
2913
3258
|
var _product$id4;
|
|
2914
3259
|
return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
|
|
2915
3260
|
});
|
|
2916
3261
|
case 11:
|
|
2917
3262
|
if (sourceProduct) {
|
|
2918
|
-
|
|
3263
|
+
_context28.next = 13;
|
|
2919
3264
|
break;
|
|
2920
3265
|
}
|
|
2921
3266
|
throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
|
|
@@ -2924,19 +3269,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2924
3269
|
quantity: quantity
|
|
2925
3270
|
}), 'unified_booking_sales_retail');
|
|
2926
3271
|
if (orderProduct) {
|
|
2927
|
-
|
|
3272
|
+
_context28.next = 16;
|
|
2928
3273
|
break;
|
|
2929
3274
|
}
|
|
2930
3275
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
2931
3276
|
case 16:
|
|
2932
|
-
return
|
|
3277
|
+
return _context28.abrupt("return", this.addProductToOrder(orderProduct));
|
|
2933
3278
|
case 17:
|
|
2934
3279
|
case "end":
|
|
2935
|
-
return
|
|
3280
|
+
return _context28.stop();
|
|
2936
3281
|
}
|
|
2937
|
-
},
|
|
3282
|
+
}, _callee28, this);
|
|
2938
3283
|
}));
|
|
2939
|
-
function addRetailProduct(
|
|
3284
|
+
function addRetailProduct(_x17) {
|
|
2940
3285
|
return _addRetailProduct.apply(this, arguments);
|
|
2941
3286
|
}
|
|
2942
3287
|
return addRetailProduct;
|
|
@@ -3036,7 +3381,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3036
3381
|
}, {
|
|
3037
3382
|
key: "buildAvailabilityOperatingHoursSnapshot",
|
|
3038
3383
|
value: function buildAvailabilityOperatingHoursSnapshot(params) {
|
|
3039
|
-
var
|
|
3384
|
+
var _this4 = this;
|
|
3040
3385
|
var descriptor = params.prepare._availabilityOperatingHours || {
|
|
3041
3386
|
source: params.prepare.businessHours ? 'prepare_business_hours' : 'default_business_hours',
|
|
3042
3387
|
scheduleIds: []
|
|
@@ -3046,7 +3391,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3046
3391
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3047
3392
|
startAt: "".concat(date, "T").concat(params.businessHours.startTime, ":00"),
|
|
3048
3393
|
endAt: "".concat(date, "T").concat(params.businessHours.endTime, ":00"),
|
|
3049
|
-
fixedOffsetMinutes:
|
|
3394
|
+
fixedOffsetMinutes: _this4.getAvailabilityRuntimeOffsetMinutes(),
|
|
3050
3395
|
rollOverEnd: true
|
|
3051
3396
|
});
|
|
3052
3397
|
return range ? [{
|
|
@@ -3081,7 +3426,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3081
3426
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3082
3427
|
startAt: slot.start_at,
|
|
3083
3428
|
endAt: slot.end_at,
|
|
3084
|
-
fixedOffsetMinutes:
|
|
3429
|
+
fixedOffsetMinutes: _this4.getAvailabilityRuntimeOffsetMinutes(),
|
|
3085
3430
|
rollOverEnd: true
|
|
3086
3431
|
});
|
|
3087
3432
|
return range ? [{
|
|
@@ -3097,7 +3442,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3097
3442
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3098
3443
|
startAt: slot.start_at,
|
|
3099
3444
|
endAt: slot.end_at,
|
|
3100
|
-
fixedOffsetMinutes:
|
|
3445
|
+
fixedOffsetMinutes: _this4.getAvailabilityRuntimeOffsetMinutes(),
|
|
3101
3446
|
rollOverEnd: true
|
|
3102
3447
|
});
|
|
3103
3448
|
return range ? [{
|
|
@@ -3124,46 +3469,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3124
3469
|
}, {
|
|
3125
3470
|
key: "loadAvailabilityProducts",
|
|
3126
3471
|
value: function () {
|
|
3127
|
-
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3472
|
+
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
3128
3473
|
var _prepare$catalogScope,
|
|
3129
3474
|
_prepare$catalogScope2,
|
|
3130
|
-
|
|
3475
|
+
_this5 = this,
|
|
3131
3476
|
_prepare$resourceIds;
|
|
3132
3477
|
var prepare, dateRange, explicitProductIds, rawProducts, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
|
|
3133
|
-
return _regeneratorRuntime().wrap(function
|
|
3134
|
-
while (1) switch (
|
|
3478
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3479
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3135
3480
|
case 0:
|
|
3136
3481
|
prepare = params.prepare, dateRange = params.dateRange;
|
|
3137
3482
|
explicitProductIds = prepare.productIds || [];
|
|
3138
3483
|
rawProducts = [];
|
|
3139
3484
|
if (!Array.isArray(prepare.rawProducts)) {
|
|
3140
|
-
|
|
3485
|
+
_context29.next = 8;
|
|
3141
3486
|
break;
|
|
3142
3487
|
}
|
|
3143
3488
|
rawProducts = prepare.rawProducts;
|
|
3144
3489
|
this.unifiedProductCatalog = _toConsumableArray(rawProducts);
|
|
3145
|
-
|
|
3490
|
+
_context29.next = 34;
|
|
3146
3491
|
break;
|
|
3147
3492
|
case 8:
|
|
3148
3493
|
if (!(explicitProductIds.length > 0)) {
|
|
3149
|
-
|
|
3494
|
+
_context29.next = 14;
|
|
3150
3495
|
break;
|
|
3151
3496
|
}
|
|
3152
|
-
|
|
3497
|
+
_context29.next = 11;
|
|
3153
3498
|
return this.loadProducts({
|
|
3154
3499
|
product_ids: explicitProductIds,
|
|
3155
3500
|
schedule_date: dateRange.startDate
|
|
3156
3501
|
});
|
|
3157
3502
|
case 11:
|
|
3158
|
-
rawProducts =
|
|
3159
|
-
|
|
3503
|
+
rawProducts = _context29.sent;
|
|
3504
|
+
_context29.next = 34;
|
|
3160
3505
|
break;
|
|
3161
3506
|
case 14:
|
|
3162
3507
|
if (!(((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'schedule')) {
|
|
3163
|
-
|
|
3508
|
+
_context29.next = 30;
|
|
3164
3509
|
break;
|
|
3165
3510
|
}
|
|
3166
|
-
|
|
3511
|
+
_context29.next = 17;
|
|
3167
3512
|
return this.loadScheduleAvailableDate({
|
|
3168
3513
|
startDate: dateRange.startDate,
|
|
3169
3514
|
endDate: dateRange.endDate,
|
|
@@ -3179,44 +3524,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3179
3524
|
});
|
|
3180
3525
|
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)) || [])));
|
|
3181
3526
|
if (!(productIds.length > 0)) {
|
|
3182
|
-
|
|
3527
|
+
_context29.next = 27;
|
|
3183
3528
|
break;
|
|
3184
3529
|
}
|
|
3185
3530
|
assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
|
|
3186
|
-
|
|
3531
|
+
_context29.next = 24;
|
|
3187
3532
|
return this.loadProducts({
|
|
3188
3533
|
product_ids: productIds,
|
|
3189
3534
|
schedule_date: dateRange.startDate
|
|
3190
3535
|
});
|
|
3191
3536
|
case 24:
|
|
3192
|
-
rawProducts =
|
|
3193
|
-
|
|
3537
|
+
rawProducts = _context29.sent;
|
|
3538
|
+
_context29.next = 28;
|
|
3194
3539
|
break;
|
|
3195
3540
|
case 27:
|
|
3196
3541
|
this.unifiedProductCatalog = [];
|
|
3197
3542
|
case 28:
|
|
3198
|
-
|
|
3543
|
+
_context29.next = 34;
|
|
3199
3544
|
break;
|
|
3200
3545
|
case 30:
|
|
3201
3546
|
if (!(((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList')) {
|
|
3202
|
-
|
|
3547
|
+
_context29.next = 34;
|
|
3203
3548
|
break;
|
|
3204
3549
|
}
|
|
3205
|
-
|
|
3550
|
+
_context29.next = 33;
|
|
3206
3551
|
return this.loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
|
|
3207
3552
|
schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
|
|
3208
3553
|
}));
|
|
3209
3554
|
case 33:
|
|
3210
|
-
rawProducts =
|
|
3555
|
+
rawProducts = _context29.sent;
|
|
3211
3556
|
case 34:
|
|
3212
3557
|
normalized = rawProducts.map(function (product) {
|
|
3213
|
-
return normalizeProductForAvailability(product, params.scheduleList,
|
|
3558
|
+
return normalizeProductForAvailability(product, params.scheduleList, _this5.getAvailabilityRuntimeOffsetMinutes());
|
|
3214
3559
|
});
|
|
3215
3560
|
if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
|
|
3216
|
-
|
|
3561
|
+
_context29.next = 37;
|
|
3217
3562
|
break;
|
|
3218
3563
|
}
|
|
3219
|
-
return
|
|
3564
|
+
return _context29.abrupt("return", normalized.filter(function (product) {
|
|
3220
3565
|
var _product$requirementG2;
|
|
3221
3566
|
return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
|
|
3222
3567
|
var _group$resourceIds3;
|
|
@@ -3229,16 +3574,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3229
3574
|
}));
|
|
3230
3575
|
case 37:
|
|
3231
3576
|
productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
|
|
3232
|
-
return
|
|
3577
|
+
return _context29.abrupt("return", productIdSet ? normalized.filter(function (product) {
|
|
3233
3578
|
return productIdSet.has(String(product.id));
|
|
3234
3579
|
}) : normalized);
|
|
3235
3580
|
case 39:
|
|
3236
3581
|
case "end":
|
|
3237
|
-
return
|
|
3582
|
+
return _context29.stop();
|
|
3238
3583
|
}
|
|
3239
|
-
},
|
|
3584
|
+
}, _callee29, this);
|
|
3240
3585
|
}));
|
|
3241
|
-
function loadAvailabilityProducts(
|
|
3586
|
+
function loadAvailabilityProducts(_x18) {
|
|
3242
3587
|
return _loadAvailabilityProducts.apply(this, arguments);
|
|
3243
3588
|
}
|
|
3244
3589
|
return loadAvailabilityProducts;
|
|
@@ -3251,12 +3596,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3251
3596
|
}, {
|
|
3252
3597
|
key: "fetchAvailabilityResourcesV2",
|
|
3253
3598
|
value: (function () {
|
|
3254
|
-
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3599
|
+
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
3255
3600
|
var response, data;
|
|
3256
|
-
return _regeneratorRuntime().wrap(function
|
|
3257
|
-
while (1) switch (
|
|
3601
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3602
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3258
3603
|
case 0:
|
|
3259
|
-
|
|
3604
|
+
_context30.next = 2;
|
|
3260
3605
|
return this.request.get('/schedule/resource/list/v2', {
|
|
3261
3606
|
start_date: params.dateRange.startDate,
|
|
3262
3607
|
end_date: params.dateRange.endDate,
|
|
@@ -3266,28 +3611,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3266
3611
|
useCache: false
|
|
3267
3612
|
});
|
|
3268
3613
|
case 2:
|
|
3269
|
-
response =
|
|
3614
|
+
response = _context30.sent;
|
|
3270
3615
|
data = response === null || response === void 0 ? void 0 : response.data;
|
|
3271
3616
|
if (!Array.isArray(data)) {
|
|
3272
|
-
|
|
3617
|
+
_context30.next = 6;
|
|
3273
3618
|
break;
|
|
3274
3619
|
}
|
|
3275
|
-
return
|
|
3620
|
+
return _context30.abrupt("return", data);
|
|
3276
3621
|
case 6:
|
|
3277
3622
|
if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
|
|
3278
|
-
|
|
3623
|
+
_context30.next = 8;
|
|
3279
3624
|
break;
|
|
3280
3625
|
}
|
|
3281
|
-
return
|
|
3626
|
+
return _context30.abrupt("return", data.list);
|
|
3282
3627
|
case 8:
|
|
3283
|
-
return
|
|
3628
|
+
return _context30.abrupt("return", []);
|
|
3284
3629
|
case 9:
|
|
3285
3630
|
case "end":
|
|
3286
|
-
return
|
|
3631
|
+
return _context30.stop();
|
|
3287
3632
|
}
|
|
3288
|
-
},
|
|
3633
|
+
}, _callee30, this);
|
|
3289
3634
|
}));
|
|
3290
|
-
function fetchAvailabilityResourcesV2(
|
|
3635
|
+
function fetchAvailabilityResourcesV2(_x19) {
|
|
3291
3636
|
return _fetchAvailabilityResourcesV.apply(this, arguments);
|
|
3292
3637
|
}
|
|
3293
3638
|
return fetchAvailabilityResourcesV2;
|
|
@@ -3295,17 +3640,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3295
3640
|
}, {
|
|
3296
3641
|
key: "fetchAndPublishAvailabilityResourcesV2",
|
|
3297
3642
|
value: function () {
|
|
3298
|
-
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3643
|
+
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3299
3644
|
var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
|
|
3300
|
-
return _regeneratorRuntime().wrap(function
|
|
3301
|
-
while (1) switch (
|
|
3645
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3646
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3302
3647
|
case 0:
|
|
3303
3648
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3304
3649
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3305
|
-
|
|
3650
|
+
_context31.next = 3;
|
|
3306
3651
|
break;
|
|
3307
3652
|
}
|
|
3308
|
-
return
|
|
3653
|
+
return _context31.abrupt("return", []);
|
|
3309
3654
|
case 3:
|
|
3310
3655
|
scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
3311
3656
|
cacheParams = {
|
|
@@ -3315,7 +3660,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3315
3660
|
};
|
|
3316
3661
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3317
3662
|
if (!cachedRawResources) {
|
|
3318
|
-
|
|
3663
|
+
_context31.next = 9;
|
|
3319
3664
|
break;
|
|
3320
3665
|
}
|
|
3321
3666
|
if (params.useCacheOnHit) {
|
|
@@ -3327,23 +3672,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3327
3672
|
console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
|
|
3328
3673
|
});
|
|
3329
3674
|
}
|
|
3330
|
-
return
|
|
3675
|
+
return _context31.abrupt("return", cachedRawResources);
|
|
3331
3676
|
case 9:
|
|
3332
|
-
|
|
3677
|
+
_context31.next = 11;
|
|
3333
3678
|
return this.refreshAvailabilityRemoteResourceQuery({
|
|
3334
3679
|
timezone: params.timezone,
|
|
3335
3680
|
dateRange: params.dateRange,
|
|
3336
3681
|
resourceIds: normalizedResourceIds
|
|
3337
3682
|
});
|
|
3338
3683
|
case 11:
|
|
3339
|
-
return
|
|
3684
|
+
return _context31.abrupt("return", _context31.sent);
|
|
3340
3685
|
case 12:
|
|
3341
3686
|
case "end":
|
|
3342
|
-
return
|
|
3687
|
+
return _context31.stop();
|
|
3343
3688
|
}
|
|
3344
|
-
},
|
|
3689
|
+
}, _callee31, this);
|
|
3345
3690
|
}));
|
|
3346
|
-
function fetchAndPublishAvailabilityResourcesV2(
|
|
3691
|
+
function fetchAndPublishAvailabilityResourcesV2(_x20) {
|
|
3347
3692
|
return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
|
|
3348
3693
|
}
|
|
3349
3694
|
return fetchAndPublishAvailabilityResourcesV2;
|
|
@@ -3351,17 +3696,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3351
3696
|
}, {
|
|
3352
3697
|
key: "refreshAvailabilityRemoteResourceQuery",
|
|
3353
3698
|
value: function () {
|
|
3354
|
-
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3699
|
+
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3355
3700
|
var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
|
|
3356
|
-
return _regeneratorRuntime().wrap(function
|
|
3357
|
-
while (1) switch (
|
|
3701
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3702
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3358
3703
|
case 0:
|
|
3359
3704
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3360
3705
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3361
|
-
|
|
3706
|
+
_context32.next = 3;
|
|
3362
3707
|
break;
|
|
3363
3708
|
}
|
|
3364
|
-
return
|
|
3709
|
+
return _context32.abrupt("return", []);
|
|
3365
3710
|
case 3:
|
|
3366
3711
|
queryKey = this.buildAvailabilityRemoteResourceQueryKey({
|
|
3367
3712
|
timezone: params.timezone,
|
|
@@ -3371,13 +3716,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3371
3716
|
epoch = this.availabilityRemoteResourceEpoch;
|
|
3372
3717
|
existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3373
3718
|
if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
|
|
3374
|
-
|
|
3719
|
+
_context32.next = 10;
|
|
3375
3720
|
break;
|
|
3376
3721
|
}
|
|
3377
|
-
|
|
3722
|
+
_context32.next = 9;
|
|
3378
3723
|
return existing.promise;
|
|
3379
3724
|
case 9:
|
|
3380
|
-
return
|
|
3725
|
+
return _context32.abrupt("return", _context32.sent);
|
|
3381
3726
|
case 10:
|
|
3382
3727
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
3383
3728
|
writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
@@ -3389,11 +3734,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3389
3734
|
epoch: epoch,
|
|
3390
3735
|
promise: promise
|
|
3391
3736
|
});
|
|
3392
|
-
|
|
3393
|
-
|
|
3737
|
+
_context32.prev = 14;
|
|
3738
|
+
_context32.next = 17;
|
|
3394
3739
|
return promise;
|
|
3395
3740
|
case 17:
|
|
3396
|
-
rawResources =
|
|
3741
|
+
rawResources = _context32.sent;
|
|
3397
3742
|
if (epoch === this.availabilityRemoteResourceEpoch) {
|
|
3398
3743
|
this.availabilityRemoteOccupancyCache.publish({
|
|
3399
3744
|
scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
|
|
@@ -3404,21 +3749,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3404
3749
|
version: writeVersion
|
|
3405
3750
|
});
|
|
3406
3751
|
}
|
|
3407
|
-
return
|
|
3752
|
+
return _context32.abrupt("return", rawResources);
|
|
3408
3753
|
case 20:
|
|
3409
|
-
|
|
3754
|
+
_context32.prev = 20;
|
|
3410
3755
|
current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3411
3756
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
3412
3757
|
this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
|
|
3413
3758
|
}
|
|
3414
|
-
return
|
|
3759
|
+
return _context32.finish(20);
|
|
3415
3760
|
case 24:
|
|
3416
3761
|
case "end":
|
|
3417
|
-
return
|
|
3762
|
+
return _context32.stop();
|
|
3418
3763
|
}
|
|
3419
|
-
},
|
|
3764
|
+
}, _callee32, this, [[14,, 20, 24]]);
|
|
3420
3765
|
}));
|
|
3421
|
-
function refreshAvailabilityRemoteResourceQuery(
|
|
3766
|
+
function refreshAvailabilityRemoteResourceQuery(_x21) {
|
|
3422
3767
|
return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
|
|
3423
3768
|
}
|
|
3424
3769
|
return refreshAvailabilityRemoteResourceQuery;
|
|
@@ -3426,26 +3771,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3426
3771
|
}, {
|
|
3427
3772
|
key: "loadAvailabilityResources",
|
|
3428
3773
|
value: function () {
|
|
3429
|
-
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3774
|
+
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3430
3775
|
var resourceIds, cachedRawResources, rawResources;
|
|
3431
|
-
return _regeneratorRuntime().wrap(function
|
|
3432
|
-
while (1) switch (
|
|
3776
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3777
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3433
3778
|
case 0:
|
|
3434
3779
|
resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
|
|
3435
3780
|
if (!(resourceIds.length === 0)) {
|
|
3436
|
-
|
|
3781
|
+
_context33.next = 3;
|
|
3437
3782
|
break;
|
|
3438
3783
|
}
|
|
3439
|
-
return
|
|
3784
|
+
return _context33.abrupt("return", {
|
|
3440
3785
|
resources: [],
|
|
3441
3786
|
resourceOccupancies: []
|
|
3442
3787
|
});
|
|
3443
3788
|
case 3:
|
|
3444
3789
|
if (!Array.isArray(params.rawResources)) {
|
|
3445
|
-
|
|
3790
|
+
_context33.next = 5;
|
|
3446
3791
|
break;
|
|
3447
3792
|
}
|
|
3448
|
-
return
|
|
3793
|
+
return _context33.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3449
3794
|
rawResources: params.rawResources,
|
|
3450
3795
|
scheduleList: params.scheduleList,
|
|
3451
3796
|
dateRange: params.dateRange,
|
|
@@ -3453,7 +3798,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3453
3798
|
}));
|
|
3454
3799
|
case 5:
|
|
3455
3800
|
if (!(params.fetchPolicy === 'cache_only')) {
|
|
3456
|
-
|
|
3801
|
+
_context33.next = 10;
|
|
3457
3802
|
break;
|
|
3458
3803
|
}
|
|
3459
3804
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read({
|
|
@@ -3462,22 +3807,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3462
3807
|
dateRange: params.dateRange
|
|
3463
3808
|
});
|
|
3464
3809
|
if (!cachedRawResources) {
|
|
3465
|
-
|
|
3810
|
+
_context33.next = 9;
|
|
3466
3811
|
break;
|
|
3467
3812
|
}
|
|
3468
|
-
return
|
|
3813
|
+
return _context33.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3469
3814
|
rawResources: cachedRawResources,
|
|
3470
3815
|
scheduleList: params.scheduleList,
|
|
3471
3816
|
dateRange: params.dateRange,
|
|
3472
3817
|
fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
|
|
3473
3818
|
}));
|
|
3474
3819
|
case 9:
|
|
3475
|
-
return
|
|
3820
|
+
return _context33.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
|
|
3476
3821
|
resources: [],
|
|
3477
3822
|
resourceOccupancies: []
|
|
3478
3823
|
});
|
|
3479
3824
|
case 10:
|
|
3480
|
-
|
|
3825
|
+
_context33.next = 12;
|
|
3481
3826
|
return this.fetchAndPublishAvailabilityResourcesV2({
|
|
3482
3827
|
timezone: params.timezone,
|
|
3483
3828
|
dateRange: params.dateRange,
|
|
@@ -3485,8 +3830,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3485
3830
|
useCacheOnHit: true
|
|
3486
3831
|
});
|
|
3487
3832
|
case 12:
|
|
3488
|
-
rawResources =
|
|
3489
|
-
return
|
|
3833
|
+
rawResources = _context33.sent;
|
|
3834
|
+
return _context33.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3490
3835
|
rawResources: rawResources,
|
|
3491
3836
|
scheduleList: params.scheduleList,
|
|
3492
3837
|
dateRange: params.dateRange,
|
|
@@ -3494,11 +3839,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3494
3839
|
}));
|
|
3495
3840
|
case 14:
|
|
3496
3841
|
case "end":
|
|
3497
|
-
return
|
|
3842
|
+
return _context33.stop();
|
|
3498
3843
|
}
|
|
3499
|
-
},
|
|
3844
|
+
}, _callee33, this);
|
|
3500
3845
|
}));
|
|
3501
|
-
function loadAvailabilityResources(
|
|
3846
|
+
function loadAvailabilityResources(_x22) {
|
|
3502
3847
|
return _loadAvailabilityResources.apply(this, arguments);
|
|
3503
3848
|
}
|
|
3504
3849
|
return loadAvailabilityResources;
|
|
@@ -3518,7 +3863,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3518
3863
|
var products = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) ? tempOrder.products : [];
|
|
3519
3864
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
3520
3865
|
productLineUids.forEach(function (requestedUid) {
|
|
3521
|
-
var
|
|
3866
|
+
var _ref45, _product$booking_uid2, _product$metadata5;
|
|
3522
3867
|
var product = products.find(function (line) {
|
|
3523
3868
|
return getProductLineUid(line) === String(requestedUid);
|
|
3524
3869
|
});
|
|
@@ -3528,7 +3873,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3528
3873
|
});
|
|
3529
3874
|
}
|
|
3530
3875
|
var productUid = getProductLineUid(product);
|
|
3531
|
-
var linkedBookingUid = String((
|
|
3876
|
+
var linkedBookingUid = String((_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : '');
|
|
3532
3877
|
var linkedBookings = bookings.filter(function (booking) {
|
|
3533
3878
|
var _booking$product_uid;
|
|
3534
3879
|
return linkedBookingUid && getBookingUid(booking) === linkedBookingUid || productUid && String((_booking$product_uid = booking.product_uid) !== null && _booking$product_uid !== void 0 ? _booking$product_uid : '') === productUid;
|
|
@@ -3571,24 +3916,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3571
3916
|
}, {
|
|
3572
3917
|
key: "collectCartResourceOccupancies",
|
|
3573
3918
|
value: function collectCartResourceOccupancies(tempOrder, exclusions) {
|
|
3574
|
-
var
|
|
3919
|
+
var _this6 = this;
|
|
3575
3920
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
3576
3921
|
return bookings.flatMap(function (booking) {
|
|
3577
|
-
var
|
|
3922
|
+
var _ref46, _booking$product_uid2, _booking$metadata2;
|
|
3578
3923
|
var bookingUid = getBookingUid(booking);
|
|
3579
|
-
var productUid = String((
|
|
3924
|
+
var productUid = String((_ref46 = (_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 && _ref46 !== void 0 ? _ref46 : '');
|
|
3580
3925
|
var scheduleEventId = toNumberId(booking.schedule_event_id);
|
|
3581
3926
|
var startAt = booking.start_at || "".concat(booking.start_date || '', " ").concat(booking.start_time || '').trim();
|
|
3582
3927
|
var endAt = booking.end_at || "".concat(booking.end_date || booking.start_date || '', " ").concat(booking.end_time || '').trim();
|
|
3583
3928
|
var resources = Array.isArray(booking.resources) ? booking.resources : [];
|
|
3584
3929
|
return resources.flatMap(function (resource) {
|
|
3585
|
-
var
|
|
3586
|
-
var resourceId = (
|
|
3930
|
+
var _ref47, _resource$resource_id, _ref48, _resource$capacity;
|
|
3931
|
+
var resourceId = (_ref47 = (_resource$resource_id = resource.resource_id) !== null && _resource$resource_id !== void 0 ? _resource$resource_id : resource.relation_id) !== null && _ref47 !== void 0 ? _ref47 : resource.id;
|
|
3587
3932
|
if (resourceId == null || !startAt || !endAt) return [];
|
|
3588
3933
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3589
3934
|
startAt: startAt,
|
|
3590
3935
|
endAt: endAt,
|
|
3591
|
-
fixedOffsetMinutes:
|
|
3936
|
+
fixedOffsetMinutes: _this6.getAvailabilityRuntimeOffsetMinutes(),
|
|
3592
3937
|
rollOverEnd: false
|
|
3593
3938
|
});
|
|
3594
3939
|
if (!range) return [];
|
|
@@ -3596,7 +3941,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3596
3941
|
resourceId: resourceId,
|
|
3597
3942
|
startAt: range.startAt,
|
|
3598
3943
|
endAt: range.endAt,
|
|
3599
|
-
pax: Math.max(1, Number((
|
|
3944
|
+
pax: Math.max(1, Number((_ref48 = (_resource$capacity = resource.capacity) !== null && _resource$capacity !== void 0 ? _resource$capacity : booking.capacity) !== null && _ref48 !== void 0 ? _ref48 : 1) || 1),
|
|
3600
3945
|
source: 'cart',
|
|
3601
3946
|
scheduleEventId: scheduleEventId,
|
|
3602
3947
|
bookingUid: bookingUid || undefined,
|
|
@@ -3606,7 +3951,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3606
3951
|
resource: resource
|
|
3607
3952
|
}
|
|
3608
3953
|
};
|
|
3609
|
-
return
|
|
3954
|
+
return _this6.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
|
|
3610
3955
|
});
|
|
3611
3956
|
});
|
|
3612
3957
|
}
|
|
@@ -3673,16 +4018,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3673
4018
|
}, {
|
|
3674
4019
|
key: "assertContextualQueryFreshness",
|
|
3675
4020
|
value: function assertContextualQueryFreshness(context, request) {
|
|
3676
|
-
var
|
|
4021
|
+
var _this7 = this;
|
|
3677
4022
|
if (request.target === 'time') {
|
|
3678
4023
|
request.candidates.forEach(function (candidate) {
|
|
3679
|
-
|
|
4024
|
+
_this7.assertAvailabilityCandidateFreshness(context, candidate);
|
|
3680
4025
|
});
|
|
3681
4026
|
return;
|
|
3682
4027
|
}
|
|
3683
4028
|
if (request.target === 'resource') {
|
|
3684
4029
|
request.selectedRanges.forEach(function (candidate) {
|
|
3685
|
-
|
|
4030
|
+
_this7.assertAvailabilityCandidateFreshness(context, candidate);
|
|
3686
4031
|
});
|
|
3687
4032
|
}
|
|
3688
4033
|
}
|
|
@@ -3729,8 +4074,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3729
4074
|
}, {
|
|
3730
4075
|
key: "buildAvailabilityProjectionSnapshot",
|
|
3731
4076
|
value: function () {
|
|
3732
|
-
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3733
|
-
var
|
|
4077
|
+
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
4078
|
+
var _this8 = this;
|
|
3734
4079
|
var options,
|
|
3735
4080
|
normalizedPrepareParams,
|
|
3736
4081
|
timezoneLabel,
|
|
@@ -3751,11 +4096,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3751
4096
|
durationCandidateAnchorAt,
|
|
3752
4097
|
orderRevision,
|
|
3753
4098
|
projection,
|
|
3754
|
-
|
|
3755
|
-
return _regeneratorRuntime().wrap(function
|
|
3756
|
-
while (1) switch (
|
|
4099
|
+
_args34 = arguments;
|
|
4100
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
4101
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3757
4102
|
case 0:
|
|
3758
|
-
options =
|
|
4103
|
+
options = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
|
|
3759
4104
|
normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
3760
4105
|
timezoneLabel = String(normalizedPrepareParams.timezone);
|
|
3761
4106
|
dateRange = normalizedPrepareParams.dateRange;
|
|
@@ -3769,15 +4114,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3769
4114
|
scheduleList: scheduleList,
|
|
3770
4115
|
businessHours: businessHours
|
|
3771
4116
|
});
|
|
3772
|
-
|
|
4117
|
+
_context34.next = 11;
|
|
3773
4118
|
return this.loadAvailabilityProducts({
|
|
3774
4119
|
prepare: normalizedPrepareParams,
|
|
3775
4120
|
dateRange: dateRange,
|
|
3776
4121
|
scheduleList: scheduleList
|
|
3777
4122
|
});
|
|
3778
4123
|
case 11:
|
|
3779
|
-
products =
|
|
3780
|
-
|
|
4124
|
+
products = _context34.sent;
|
|
4125
|
+
_context34.next = 14;
|
|
3781
4126
|
return this.loadAvailabilityResources({
|
|
3782
4127
|
timezone: timezoneLabel,
|
|
3783
4128
|
dateRange: dateRange,
|
|
@@ -3789,14 +4134,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3789
4134
|
fallbackResources: options.fallbackResources
|
|
3790
4135
|
});
|
|
3791
4136
|
case 14:
|
|
3792
|
-
loadedResources =
|
|
4137
|
+
loadedResources = _context34.sent;
|
|
3793
4138
|
tempOrder = this.getTempOrder();
|
|
3794
4139
|
exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
|
|
3795
4140
|
injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
|
|
3796
4141
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3797
4142
|
startAt: occupancy.startAt,
|
|
3798
4143
|
endAt: occupancy.endAt,
|
|
3799
|
-
fixedOffsetMinutes:
|
|
4144
|
+
fixedOffsetMinutes: _this8.getAvailabilityRuntimeOffsetMinutes(),
|
|
3800
4145
|
rollOverEnd: false
|
|
3801
4146
|
});
|
|
3802
4147
|
if (!range) return [];
|
|
@@ -3806,7 +4151,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3806
4151
|
})];
|
|
3807
4152
|
});
|
|
3808
4153
|
remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
|
|
3809
|
-
return !
|
|
4154
|
+
return !_this8.occupancyIsExcluded(occupancy, exclusions);
|
|
3810
4155
|
});
|
|
3811
4156
|
cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
|
|
3812
4157
|
preparedAt = this.getAvailabilityRuntimeDateTime();
|
|
@@ -3835,18 +4180,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3835
4180
|
prepareParams: normalizedPrepareParams,
|
|
3836
4181
|
durationCandidateAnchorAt: durationCandidateAnchorAt
|
|
3837
4182
|
});
|
|
3838
|
-
return
|
|
4183
|
+
return _context34.abrupt("return", {
|
|
3839
4184
|
projection: projection,
|
|
3840
4185
|
prepareParams: normalizedPrepareParams,
|
|
3841
4186
|
orderRevision: orderRevision
|
|
3842
4187
|
});
|
|
3843
4188
|
case 26:
|
|
3844
4189
|
case "end":
|
|
3845
|
-
return
|
|
4190
|
+
return _context34.stop();
|
|
3846
4191
|
}
|
|
3847
|
-
},
|
|
4192
|
+
}, _callee34, this);
|
|
3848
4193
|
}));
|
|
3849
|
-
function buildAvailabilityProjectionSnapshot(
|
|
4194
|
+
function buildAvailabilityProjectionSnapshot(_x23) {
|
|
3850
4195
|
return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
|
|
3851
4196
|
}
|
|
3852
4197
|
return buildAvailabilityProjectionSnapshot;
|
|
@@ -3854,10 +4199,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3854
4199
|
}, {
|
|
3855
4200
|
key: "getSharedPreparedAvailabilitySnapshot",
|
|
3856
4201
|
value: function () {
|
|
3857
|
-
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4202
|
+
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3858
4203
|
var lifecycleGeneration, normalizedParams, hasRawInputs, prepareKey, snapshot, existing, promise, _snapshot, current;
|
|
3859
|
-
return _regeneratorRuntime().wrap(function
|
|
3860
|
-
while (1) switch (
|
|
4204
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
4205
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3861
4206
|
case 0:
|
|
3862
4207
|
lifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
3863
4208
|
normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
@@ -3876,15 +4221,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3876
4221
|
}
|
|
3877
4222
|
})) : this.buildAvailabilityPrepareKey(normalizedParams);
|
|
3878
4223
|
if (!hasRawInputs) {
|
|
3879
|
-
|
|
4224
|
+
_context35.next = 11;
|
|
3880
4225
|
break;
|
|
3881
4226
|
}
|
|
3882
|
-
|
|
4227
|
+
_context35.next = 7;
|
|
3883
4228
|
return this.buildAvailabilityProjectionSnapshot(normalizedParams);
|
|
3884
4229
|
case 7:
|
|
3885
|
-
snapshot =
|
|
4230
|
+
snapshot = _context35.sent;
|
|
3886
4231
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
3887
|
-
|
|
4232
|
+
_context35.next = 10;
|
|
3888
4233
|
break;
|
|
3889
4234
|
}
|
|
3890
4235
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -3893,7 +4238,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3893
4238
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
3894
4239
|
});
|
|
3895
4240
|
case 10:
|
|
3896
|
-
return
|
|
4241
|
+
return _context35.abrupt("return", {
|
|
3897
4242
|
prepareKey: prepareKey,
|
|
3898
4243
|
snapshot: snapshot
|
|
3899
4244
|
});
|
|
@@ -3907,13 +4252,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3907
4252
|
promise: promise
|
|
3908
4253
|
});
|
|
3909
4254
|
}
|
|
3910
|
-
|
|
3911
|
-
|
|
4255
|
+
_context35.prev = 14;
|
|
4256
|
+
_context35.next = 17;
|
|
3912
4257
|
return promise;
|
|
3913
4258
|
case 17:
|
|
3914
|
-
_snapshot =
|
|
4259
|
+
_snapshot = _context35.sent;
|
|
3915
4260
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
3916
|
-
|
|
4261
|
+
_context35.next = 20;
|
|
3917
4262
|
break;
|
|
3918
4263
|
}
|
|
3919
4264
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -3922,24 +4267,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3922
4267
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
3923
4268
|
});
|
|
3924
4269
|
case 20:
|
|
3925
|
-
return
|
|
4270
|
+
return _context35.abrupt("return", {
|
|
3926
4271
|
prepareKey: prepareKey,
|
|
3927
4272
|
snapshot: _snapshot
|
|
3928
4273
|
});
|
|
3929
4274
|
case 21:
|
|
3930
|
-
|
|
4275
|
+
_context35.prev = 21;
|
|
3931
4276
|
current = this.availabilityPrepareInFlight.get(prepareKey);
|
|
3932
4277
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
3933
4278
|
this.availabilityPrepareInFlight.delete(prepareKey);
|
|
3934
4279
|
}
|
|
3935
|
-
return
|
|
4280
|
+
return _context35.finish(21);
|
|
3936
4281
|
case 25:
|
|
3937
4282
|
case "end":
|
|
3938
|
-
return
|
|
4283
|
+
return _context35.stop();
|
|
3939
4284
|
}
|
|
3940
|
-
},
|
|
4285
|
+
}, _callee35, this, [[14,, 21, 25]]);
|
|
3941
4286
|
}));
|
|
3942
|
-
function getSharedPreparedAvailabilitySnapshot(
|
|
4287
|
+
function getSharedPreparedAvailabilitySnapshot(_x24) {
|
|
3943
4288
|
return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
|
|
3944
4289
|
}
|
|
3945
4290
|
return getSharedPreparedAvailabilitySnapshot;
|
|
@@ -3947,51 +4292,51 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3947
4292
|
}, {
|
|
3948
4293
|
key: "refreshAvailabilityContextProjection",
|
|
3949
4294
|
value: function () {
|
|
3950
|
-
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3951
|
-
var
|
|
4295
|
+
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
4296
|
+
var _this9 = this;
|
|
3952
4297
|
var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
|
|
3953
|
-
return _regeneratorRuntime().wrap(function
|
|
3954
|
-
while (1) switch (
|
|
4298
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
4299
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3955
4300
|
case 0:
|
|
3956
4301
|
existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
3957
4302
|
if (!existingInFlight) {
|
|
3958
|
-
|
|
4303
|
+
_context37.next = 5;
|
|
3959
4304
|
break;
|
|
3960
4305
|
}
|
|
3961
|
-
|
|
4306
|
+
_context37.next = 4;
|
|
3962
4307
|
return existingInFlight;
|
|
3963
4308
|
case 4:
|
|
3964
|
-
return
|
|
4309
|
+
return _context37.abrupt("return", _context37.sent);
|
|
3965
4310
|
case 5:
|
|
3966
4311
|
context = this.getAvailabilityContextEntry(params.contextId);
|
|
3967
4312
|
expectedVersion = context.activeVersion;
|
|
3968
4313
|
expectedRefreshNonce = context.refreshNonce;
|
|
3969
4314
|
expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
3970
|
-
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4315
|
+
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
3971
4316
|
var snapshot, currentContext, projectionEntry;
|
|
3972
|
-
return _regeneratorRuntime().wrap(function
|
|
3973
|
-
while (1) switch (
|
|
4317
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
4318
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3974
4319
|
case 0:
|
|
3975
|
-
|
|
3976
|
-
return
|
|
4320
|
+
_context36.next = 2;
|
|
4321
|
+
return _this9.buildAvailabilityProjectionSnapshot(_this9.cloneAvailabilityPrepareParams(context.prepareParams), {
|
|
3977
4322
|
durationCandidateAnchorAt: context.durationCandidateAnchorAt
|
|
3978
4323
|
});
|
|
3979
4324
|
case 2:
|
|
3980
|
-
snapshot =
|
|
3981
|
-
currentContext =
|
|
4325
|
+
snapshot = _context36.sent;
|
|
4326
|
+
currentContext = _this9.availabilityContextRegistry.get(params.contextId);
|
|
3982
4327
|
if (currentContext) {
|
|
3983
|
-
|
|
4328
|
+
_context36.next = 6;
|
|
3984
4329
|
break;
|
|
3985
4330
|
}
|
|
3986
|
-
return
|
|
4331
|
+
return _context36.abrupt("return", null);
|
|
3987
4332
|
case 6:
|
|
3988
|
-
if (!(expectedLifecycleGeneration !==
|
|
3989
|
-
|
|
4333
|
+
if (!(expectedLifecycleGeneration !== _this9.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
|
|
4334
|
+
_context36.next = 8;
|
|
3990
4335
|
break;
|
|
3991
4336
|
}
|
|
3992
|
-
return
|
|
4337
|
+
return _context36.abrupt("return", null);
|
|
3993
4338
|
case 8:
|
|
3994
|
-
projectionEntry =
|
|
4339
|
+
projectionEntry = _this9.storeAvailabilityProjectionEntry({
|
|
3995
4340
|
contextId: currentContext.contextId,
|
|
3996
4341
|
prepareParams: snapshot.prepareParams,
|
|
3997
4342
|
prepareKey: currentContext.prepareKey,
|
|
@@ -3999,8 +4344,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3999
4344
|
orderRevision: snapshot.orderRevision,
|
|
4000
4345
|
incrementVersion: true
|
|
4001
4346
|
});
|
|
4002
|
-
|
|
4003
|
-
return
|
|
4347
|
+
_context36.next = 11;
|
|
4348
|
+
return _this9.emitAvailabilityDiagnostic({
|
|
4004
4349
|
action: 'refresh',
|
|
4005
4350
|
contextId: currentContext.contextId,
|
|
4006
4351
|
contextVersion: projectionEntry.contextVersion,
|
|
@@ -4011,33 +4356,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4011
4356
|
reason: params.reason
|
|
4012
4357
|
});
|
|
4013
4358
|
case 11:
|
|
4014
|
-
return
|
|
4359
|
+
return _context36.abrupt("return", projectionEntry);
|
|
4015
4360
|
case 12:
|
|
4016
4361
|
case "end":
|
|
4017
|
-
return
|
|
4362
|
+
return _context36.stop();
|
|
4018
4363
|
}
|
|
4019
|
-
},
|
|
4364
|
+
}, _callee36);
|
|
4020
4365
|
}))();
|
|
4021
4366
|
this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
|
|
4022
|
-
|
|
4023
|
-
|
|
4367
|
+
_context37.prev = 11;
|
|
4368
|
+
_context37.next = 14;
|
|
4024
4369
|
return refreshPromise;
|
|
4025
4370
|
case 14:
|
|
4026
|
-
return
|
|
4371
|
+
return _context37.abrupt("return", _context37.sent);
|
|
4027
4372
|
case 15:
|
|
4028
|
-
|
|
4373
|
+
_context37.prev = 15;
|
|
4029
4374
|
current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
4030
4375
|
if (current === refreshPromise) {
|
|
4031
4376
|
this.availabilityProjectionRefreshInFlight.delete(params.contextId);
|
|
4032
4377
|
}
|
|
4033
|
-
return
|
|
4378
|
+
return _context37.finish(15);
|
|
4034
4379
|
case 19:
|
|
4035
4380
|
case "end":
|
|
4036
|
-
return
|
|
4381
|
+
return _context37.stop();
|
|
4037
4382
|
}
|
|
4038
|
-
},
|
|
4383
|
+
}, _callee37, this, [[11,, 15, 19]]);
|
|
4039
4384
|
}));
|
|
4040
|
-
function refreshAvailabilityContextProjection(
|
|
4385
|
+
function refreshAvailabilityContextProjection(_x25) {
|
|
4041
4386
|
return _refreshAvailabilityContextProjection.apply(this, arguments);
|
|
4042
4387
|
}
|
|
4043
4388
|
return refreshAvailabilityContextProjection;
|
|
@@ -4045,53 +4390,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4045
4390
|
}, {
|
|
4046
4391
|
key: "ensureAvailabilityContextProjection",
|
|
4047
4392
|
value: function () {
|
|
4048
|
-
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4393
|
+
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(contextId, reason) {
|
|
4049
4394
|
var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
|
|
4050
|
-
return _regeneratorRuntime().wrap(function
|
|
4051
|
-
while (1) switch (
|
|
4395
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
4396
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4052
4397
|
case 0:
|
|
4053
4398
|
retries = 0;
|
|
4054
4399
|
case 1:
|
|
4055
4400
|
if (!(retries < 3)) {
|
|
4056
|
-
|
|
4401
|
+
_context38.next = 19;
|
|
4057
4402
|
break;
|
|
4058
4403
|
}
|
|
4059
4404
|
context = this.getAvailabilityContextEntry(contextId);
|
|
4060
4405
|
currentOrderRevision = this.getCurrentOrderRevision();
|
|
4061
4406
|
projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
|
|
4062
4407
|
if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
|
|
4063
|
-
|
|
4408
|
+
_context38.next = 7;
|
|
4064
4409
|
break;
|
|
4065
4410
|
}
|
|
4066
|
-
return
|
|
4411
|
+
return _context38.abrupt("return", {
|
|
4067
4412
|
context: context,
|
|
4068
4413
|
projectionEntry: projectionEntry,
|
|
4069
4414
|
refreshed: false
|
|
4070
4415
|
});
|
|
4071
4416
|
case 7:
|
|
4072
|
-
|
|
4417
|
+
_context38.next = 9;
|
|
4073
4418
|
return this.refreshAvailabilityContextProjection({
|
|
4074
4419
|
contextId: contextId,
|
|
4075
4420
|
reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
|
|
4076
4421
|
previousOrderRevision: context.lastKnownOrderRevision
|
|
4077
4422
|
});
|
|
4078
4423
|
case 9:
|
|
4079
|
-
refreshedProjectionEntry =
|
|
4424
|
+
refreshedProjectionEntry = _context38.sent;
|
|
4080
4425
|
if (refreshedProjectionEntry) {
|
|
4081
|
-
|
|
4426
|
+
_context38.next = 13;
|
|
4082
4427
|
break;
|
|
4083
4428
|
}
|
|
4084
4429
|
retries += 1;
|
|
4085
|
-
return
|
|
4430
|
+
return _context38.abrupt("continue", 1);
|
|
4086
4431
|
case 13:
|
|
4087
4432
|
if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4088
|
-
|
|
4433
|
+
_context38.next = 16;
|
|
4089
4434
|
break;
|
|
4090
4435
|
}
|
|
4091
4436
|
retries += 1;
|
|
4092
|
-
return
|
|
4437
|
+
return _context38.abrupt("continue", 1);
|
|
4093
4438
|
case 16:
|
|
4094
|
-
return
|
|
4439
|
+
return _context38.abrupt("return", {
|
|
4095
4440
|
context: this.getAvailabilityContextEntry(contextId),
|
|
4096
4441
|
projectionEntry: refreshedProjectionEntry,
|
|
4097
4442
|
refreshed: true
|
|
@@ -4103,11 +4448,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4103
4448
|
});
|
|
4104
4449
|
case 20:
|
|
4105
4450
|
case "end":
|
|
4106
|
-
return
|
|
4451
|
+
return _context38.stop();
|
|
4107
4452
|
}
|
|
4108
|
-
},
|
|
4453
|
+
}, _callee38, this);
|
|
4109
4454
|
}));
|
|
4110
|
-
function ensureAvailabilityContextProjection(
|
|
4455
|
+
function ensureAvailabilityContextProjection(_x26, _x27) {
|
|
4111
4456
|
return _ensureAvailabilityContextProjection.apply(this, arguments);
|
|
4112
4457
|
}
|
|
4113
4458
|
return ensureAvailabilityContextProjection;
|
|
@@ -4115,18 +4460,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4115
4460
|
}, {
|
|
4116
4461
|
key: "tryAcquireAvailabilityCommitLock",
|
|
4117
4462
|
value: function () {
|
|
4118
|
-
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4463
|
+
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(contextId) {
|
|
4119
4464
|
var _currentContext$activ;
|
|
4120
4465
|
var _waitingContext$activ, waitingContext, currentContext;
|
|
4121
|
-
return _regeneratorRuntime().wrap(function
|
|
4122
|
-
while (1) switch (
|
|
4466
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4467
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4123
4468
|
case 0:
|
|
4124
4469
|
if (!this.availabilityCommitLocks.has(contextId)) {
|
|
4125
|
-
|
|
4470
|
+
_context39.next = 5;
|
|
4126
4471
|
break;
|
|
4127
4472
|
}
|
|
4128
4473
|
waitingContext = this.availabilityContextRegistry.get(contextId);
|
|
4129
|
-
|
|
4474
|
+
_context39.next = 4;
|
|
4130
4475
|
return this.emitAvailabilityDiagnostic({
|
|
4131
4476
|
action: 'commit_lock_wait',
|
|
4132
4477
|
contextId: contextId,
|
|
@@ -4143,7 +4488,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4143
4488
|
case 5:
|
|
4144
4489
|
this.availabilityCommitLocks.add(contextId);
|
|
4145
4490
|
currentContext = this.availabilityContextRegistry.get(contextId);
|
|
4146
|
-
|
|
4491
|
+
_context39.next = 9;
|
|
4147
4492
|
return this.emitAvailabilityDiagnostic({
|
|
4148
4493
|
action: 'commit_lock_acquired',
|
|
4149
4494
|
contextId: contextId,
|
|
@@ -4155,11 +4500,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4155
4500
|
});
|
|
4156
4501
|
case 9:
|
|
4157
4502
|
case "end":
|
|
4158
|
-
return
|
|
4503
|
+
return _context39.stop();
|
|
4159
4504
|
}
|
|
4160
|
-
},
|
|
4505
|
+
}, _callee39, this);
|
|
4161
4506
|
}));
|
|
4162
|
-
function tryAcquireAvailabilityCommitLock(
|
|
4507
|
+
function tryAcquireAvailabilityCommitLock(_x28) {
|
|
4163
4508
|
return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
|
|
4164
4509
|
}
|
|
4165
4510
|
return tryAcquireAvailabilityCommitLock;
|
|
@@ -4167,15 +4512,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4167
4512
|
}, {
|
|
4168
4513
|
key: "releaseAvailabilityCommitLock",
|
|
4169
4514
|
value: function () {
|
|
4170
|
-
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4515
|
+
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(contextId) {
|
|
4171
4516
|
var _releasedContext$acti;
|
|
4172
4517
|
var releasedContext;
|
|
4173
|
-
return _regeneratorRuntime().wrap(function
|
|
4174
|
-
while (1) switch (
|
|
4518
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4519
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4175
4520
|
case 0:
|
|
4176
4521
|
this.availabilityCommitLocks.delete(contextId);
|
|
4177
4522
|
releasedContext = this.availabilityContextRegistry.get(contextId);
|
|
4178
|
-
|
|
4523
|
+
_context40.next = 4;
|
|
4179
4524
|
return this.emitAvailabilityDiagnostic({
|
|
4180
4525
|
action: 'commit_lock_released',
|
|
4181
4526
|
contextId: contextId,
|
|
@@ -4187,11 +4532,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4187
4532
|
});
|
|
4188
4533
|
case 4:
|
|
4189
4534
|
case "end":
|
|
4190
|
-
return
|
|
4535
|
+
return _context40.stop();
|
|
4191
4536
|
}
|
|
4192
|
-
},
|
|
4537
|
+
}, _callee40, this);
|
|
4193
4538
|
}));
|
|
4194
|
-
function releaseAvailabilityCommitLock(
|
|
4539
|
+
function releaseAvailabilityCommitLock(_x29) {
|
|
4195
4540
|
return _releaseAvailabilityCommitLock.apply(this, arguments);
|
|
4196
4541
|
}
|
|
4197
4542
|
return releaseAvailabilityCommitLock;
|
|
@@ -4199,20 +4544,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4199
4544
|
}, {
|
|
4200
4545
|
key: "prepareAvailabilityProjection",
|
|
4201
4546
|
value: (function () {
|
|
4202
|
-
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4547
|
+
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
4203
4548
|
var paramsWithDefaults, _yield$this$getShared, prepareKey, snapshot, contextId, projectionEntry, context, handle, payload;
|
|
4204
|
-
return _regeneratorRuntime().wrap(function
|
|
4205
|
-
while (1) switch (
|
|
4549
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4550
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4206
4551
|
case 0:
|
|
4207
4552
|
this.assertAvailabilityPrepareParams(params);
|
|
4208
|
-
|
|
4553
|
+
_context41.next = 3;
|
|
4209
4554
|
return this.resolveAvailabilityPrepareDefaults(params);
|
|
4210
4555
|
case 3:
|
|
4211
|
-
paramsWithDefaults =
|
|
4212
|
-
|
|
4556
|
+
paramsWithDefaults = _context41.sent;
|
|
4557
|
+
_context41.next = 6;
|
|
4213
4558
|
return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
|
|
4214
4559
|
case 6:
|
|
4215
|
-
_yield$this$getShared =
|
|
4560
|
+
_yield$this$getShared = _context41.sent;
|
|
4216
4561
|
prepareKey = _yield$this$getShared.prepareKey;
|
|
4217
4562
|
snapshot = _yield$this$getShared.snapshot;
|
|
4218
4563
|
contextId = this.createAvailabilityContextId();
|
|
@@ -4233,7 +4578,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4233
4578
|
refreshed: false,
|
|
4234
4579
|
reason: 'prepare'
|
|
4235
4580
|
};
|
|
4236
|
-
|
|
4581
|
+
_context41.next = 16;
|
|
4237
4582
|
return this.emitAvailabilityDiagnostic({
|
|
4238
4583
|
action: 'prepare',
|
|
4239
4584
|
contextId: contextId,
|
|
@@ -4244,17 +4589,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4244
4589
|
reason: 'prepare'
|
|
4245
4590
|
});
|
|
4246
4591
|
case 16:
|
|
4247
|
-
|
|
4592
|
+
_context41.next = 18;
|
|
4248
4593
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
|
|
4249
4594
|
case 18:
|
|
4250
|
-
return
|
|
4595
|
+
return _context41.abrupt("return", handle);
|
|
4251
4596
|
case 19:
|
|
4252
4597
|
case "end":
|
|
4253
|
-
return
|
|
4598
|
+
return _context41.stop();
|
|
4254
4599
|
}
|
|
4255
|
-
},
|
|
4600
|
+
}, _callee41, this);
|
|
4256
4601
|
}));
|
|
4257
|
-
function prepareAvailabilityProjection(
|
|
4602
|
+
function prepareAvailabilityProjection(_x30) {
|
|
4258
4603
|
return _prepareAvailabilityProjection.apply(this, arguments);
|
|
4259
4604
|
}
|
|
4260
4605
|
return prepareAvailabilityProjection;
|
|
@@ -4262,10 +4607,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4262
4607
|
}, {
|
|
4263
4608
|
key: "getProductTimeRanges",
|
|
4264
4609
|
value: (function () {
|
|
4265
|
-
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4610
|
+
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(contextId) {
|
|
4266
4611
|
var _this$otherParams$pla,
|
|
4267
|
-
_this$
|
|
4268
|
-
|
|
4612
|
+
_this$otherParams26,
|
|
4613
|
+
_this10 = this;
|
|
4269
4614
|
var request,
|
|
4270
4615
|
_yield$this$ensureAva,
|
|
4271
4616
|
context,
|
|
@@ -4273,23 +4618,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4273
4618
|
contextVersion,
|
|
4274
4619
|
isPosAvailabilityRequest,
|
|
4275
4620
|
allowOutsideOperatingHoursForRequestedStartTimes,
|
|
4276
|
-
|
|
4277
|
-
return _regeneratorRuntime().wrap(function
|
|
4278
|
-
while (1) switch (
|
|
4621
|
+
_args42 = arguments;
|
|
4622
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4623
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4279
4624
|
case 0:
|
|
4280
|
-
request =
|
|
4281
|
-
|
|
4625
|
+
request = _args42.length > 1 && _args42[1] !== undefined ? _args42[1] : {};
|
|
4626
|
+
_context42.next = 3;
|
|
4282
4627
|
return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
|
|
4283
4628
|
case 3:
|
|
4284
|
-
_yield$this$ensureAva =
|
|
4629
|
+
_yield$this$ensureAva = _context42.sent;
|
|
4285
4630
|
context = _yield$this$ensureAva.context;
|
|
4286
4631
|
projectionEntry = _yield$this$ensureAva.projectionEntry;
|
|
4287
4632
|
contextVersion = context.activeVersion;
|
|
4288
|
-
isPosAvailabilityRequest = String((_this$otherParams$pla = (_this$
|
|
4633
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos';
|
|
4289
4634
|
allowOutsideOperatingHoursForRequestedStartTimes = isPosAvailabilityRequest && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
|
|
4290
4635
|
return Array.isArray(startTimes) && startTimes.length > 0;
|
|
4291
4636
|
});
|
|
4292
|
-
return
|
|
4637
|
+
return _context42.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
|
|
4293
4638
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
4294
4639
|
} : {}), {
|
|
4295
4640
|
evaluatedAt: this.getAvailabilityRuntimeDateTime(),
|
|
@@ -4299,17 +4644,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4299
4644
|
}).map(function (group) {
|
|
4300
4645
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
4301
4646
|
ranges: group.ranges.map(function (candidate) {
|
|
4302
|
-
return
|
|
4647
|
+
return _this10.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
|
|
4303
4648
|
})
|
|
4304
4649
|
});
|
|
4305
4650
|
}));
|
|
4306
4651
|
case 10:
|
|
4307
4652
|
case "end":
|
|
4308
|
-
return
|
|
4653
|
+
return _context42.stop();
|
|
4309
4654
|
}
|
|
4310
|
-
},
|
|
4655
|
+
}, _callee42, this);
|
|
4311
4656
|
}));
|
|
4312
|
-
function getProductTimeRanges(
|
|
4657
|
+
function getProductTimeRanges(_x31) {
|
|
4313
4658
|
return _getProductTimeRanges.apply(this, arguments);
|
|
4314
4659
|
}
|
|
4315
4660
|
return getProductTimeRanges;
|
|
@@ -4317,21 +4662,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4317
4662
|
}, {
|
|
4318
4663
|
key: "queryBookingAvailability",
|
|
4319
4664
|
value: (function () {
|
|
4320
|
-
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4321
|
-
var _this$otherParams$pla2, _this$
|
|
4665
|
+
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(contextId, request) {
|
|
4666
|
+
var _this$otherParams$pla2, _this$otherParams27;
|
|
4322
4667
|
var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
|
|
4323
|
-
return _regeneratorRuntime().wrap(function
|
|
4324
|
-
while (1) switch (
|
|
4668
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4669
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4325
4670
|
case 0:
|
|
4326
|
-
|
|
4671
|
+
_context43.next = 2;
|
|
4327
4672
|
return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4328
4673
|
case 2:
|
|
4329
|
-
_yield$this$ensureAva2 =
|
|
4674
|
+
_yield$this$ensureAva2 = _context43.sent;
|
|
4330
4675
|
context = _yield$this$ensureAva2.context;
|
|
4331
4676
|
projectionEntry = _yield$this$ensureAva2.projectionEntry;
|
|
4332
4677
|
refreshed = _yield$this$ensureAva2.refreshed;
|
|
4333
4678
|
this.assertContextualQueryFreshness(context, request);
|
|
4334
|
-
isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$
|
|
4679
|
+
isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
|
|
4335
4680
|
result = queryAvailabilityProjection(projectionEntry.projection, request, {
|
|
4336
4681
|
useExactDurationCandidateMinute: isPosAvailabilityRequest,
|
|
4337
4682
|
allowExcludedScheduleDateOverride: isPosAvailabilityRequest
|
|
@@ -4362,18 +4707,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4362
4707
|
});
|
|
4363
4708
|
})
|
|
4364
4709
|
}) : result;
|
|
4365
|
-
return
|
|
4710
|
+
return _context43.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
|
|
4366
4711
|
contextId: context.contextId,
|
|
4367
4712
|
contextVersion: contextVersion,
|
|
4368
4713
|
refreshed: refreshed
|
|
4369
4714
|
}));
|
|
4370
4715
|
case 12:
|
|
4371
4716
|
case "end":
|
|
4372
|
-
return
|
|
4717
|
+
return _context43.stop();
|
|
4373
4718
|
}
|
|
4374
|
-
},
|
|
4719
|
+
}, _callee43, this);
|
|
4375
4720
|
}));
|
|
4376
|
-
function queryBookingAvailability(
|
|
4721
|
+
function queryBookingAvailability(_x32, _x33) {
|
|
4377
4722
|
return _queryBookingAvailability.apply(this, arguments);
|
|
4378
4723
|
}
|
|
4379
4724
|
return queryBookingAvailability;
|
|
@@ -4430,9 +4775,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4430
4775
|
}, {
|
|
4431
4776
|
key: "findLinkedBooking",
|
|
4432
4777
|
value: function findLinkedBooking(product) {
|
|
4433
|
-
var
|
|
4778
|
+
var _ref50, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
|
|
4434
4779
|
var productUid = getProductLineUid(product);
|
|
4435
|
-
var bookingUid = String((
|
|
4780
|
+
var bookingUid = String((_ref50 = (_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 && _ref50 !== void 0 ? _ref50 : '');
|
|
4436
4781
|
return (((_this$getTempOrder3 = this.getTempOrder()) === null || _this$getTempOrder3 === void 0 ? void 0 : _this$getTempOrder3.bookings) || []).find(function (booking) {
|
|
4437
4782
|
var _booking$product_uid3;
|
|
4438
4783
|
return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
|
|
@@ -4443,27 +4788,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4443
4788
|
}, {
|
|
4444
4789
|
key: "commitAvailabilitySelection",
|
|
4445
4790
|
value: (function () {
|
|
4446
|
-
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4447
|
-
var normalizedContextId, _params$bookingCount,
|
|
4448
|
-
return _regeneratorRuntime().wrap(function
|
|
4449
|
-
while (1) switch (
|
|
4791
|
+
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(contextId, params) {
|
|
4792
|
+
var normalizedContextId, _params$bookingCount, _ref51, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams28, _ref52, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref53, _ref54, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref55, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
|
|
4793
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4794
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4450
4795
|
case 0:
|
|
4451
4796
|
normalizedContextId = String(contextId || '').trim();
|
|
4452
4797
|
if (normalizedContextId) {
|
|
4453
|
-
|
|
4798
|
+
_context44.next = 3;
|
|
4454
4799
|
break;
|
|
4455
4800
|
}
|
|
4456
4801
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
|
|
4457
4802
|
candidate: params.candidate
|
|
4458
4803
|
});
|
|
4459
4804
|
case 3:
|
|
4460
|
-
|
|
4805
|
+
_context44.next = 5;
|
|
4461
4806
|
return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
|
|
4462
4807
|
case 5:
|
|
4463
|
-
|
|
4808
|
+
_context44.prev = 5;
|
|
4464
4809
|
bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
|
|
4465
4810
|
if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
|
|
4466
|
-
|
|
4811
|
+
_context44.next = 9;
|
|
4467
4812
|
break;
|
|
4468
4813
|
}
|
|
4469
4814
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
|
|
@@ -4471,16 +4816,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4471
4816
|
});
|
|
4472
4817
|
case 9:
|
|
4473
4818
|
if (!(params.mode === 'edit' && bookingCount !== 1)) {
|
|
4474
|
-
|
|
4819
|
+
_context44.next = 11;
|
|
4475
4820
|
break;
|
|
4476
4821
|
}
|
|
4477
4822
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
|
|
4478
4823
|
bookingCount: bookingCount
|
|
4479
4824
|
});
|
|
4480
4825
|
case 11:
|
|
4481
|
-
orderProductQuantity = (
|
|
4826
|
+
orderProductQuantity = (_ref51 = (_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 && _ref51 !== void 0 ? _ref51 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
|
|
4482
4827
|
if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
|
|
4483
|
-
|
|
4828
|
+
_context44.next = 14;
|
|
4484
4829
|
break;
|
|
4485
4830
|
}
|
|
4486
4831
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
|
|
@@ -4490,22 +4835,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4490
4835
|
case 14:
|
|
4491
4836
|
partySize = Number(params.partySize);
|
|
4492
4837
|
if (!(!Number.isInteger(partySize) || partySize <= 0)) {
|
|
4493
|
-
|
|
4838
|
+
_context44.next = 17;
|
|
4494
4839
|
break;
|
|
4495
4840
|
}
|
|
4496
4841
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
|
|
4497
4842
|
partySize: params.partySize
|
|
4498
4843
|
});
|
|
4499
4844
|
case 17:
|
|
4500
|
-
|
|
4845
|
+
_context44.next = 19;
|
|
4501
4846
|
return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
4502
4847
|
case 19:
|
|
4503
|
-
_yield$this$ensureAva3 =
|
|
4848
|
+
_yield$this$ensureAva3 = _context44.sent;
|
|
4504
4849
|
context = _yield$this$ensureAva3.context;
|
|
4505
4850
|
projectionEntry = _yield$this$ensureAva3.projectionEntry;
|
|
4506
4851
|
refreshed = _yield$this$ensureAva3.refreshed;
|
|
4507
4852
|
if (!refreshed) {
|
|
4508
|
-
|
|
4853
|
+
_context44.next = 25;
|
|
4509
4854
|
break;
|
|
4510
4855
|
}
|
|
4511
4856
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -4516,11 +4861,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4516
4861
|
case 25:
|
|
4517
4862
|
boundEditingUids = context.prepareParams.editingProductLineUids || [];
|
|
4518
4863
|
if (!(params.mode === 'edit')) {
|
|
4519
|
-
|
|
4864
|
+
_context44.next = 31;
|
|
4520
4865
|
break;
|
|
4521
4866
|
}
|
|
4522
4867
|
if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
|
|
4523
|
-
|
|
4868
|
+
_context44.next = 29;
|
|
4524
4869
|
break;
|
|
4525
4870
|
}
|
|
4526
4871
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
|
|
@@ -4529,11 +4874,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4529
4874
|
editingProductLineUids: boundEditingUids
|
|
4530
4875
|
});
|
|
4531
4876
|
case 29:
|
|
4532
|
-
|
|
4877
|
+
_context44.next = 33;
|
|
4533
4878
|
break;
|
|
4534
4879
|
case 31:
|
|
4535
4880
|
if (!(boundEditingUids.length > 0)) {
|
|
4536
|
-
|
|
4881
|
+
_context44.next = 33;
|
|
4537
4882
|
break;
|
|
4538
4883
|
}
|
|
4539
4884
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
|
|
@@ -4542,7 +4887,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4542
4887
|
});
|
|
4543
4888
|
case 33:
|
|
4544
4889
|
if (!(projectionEntry.contextVersion !== context.activeVersion)) {
|
|
4545
|
-
|
|
4890
|
+
_context44.next = 35;
|
|
4546
4891
|
break;
|
|
4547
4892
|
}
|
|
4548
4893
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -4552,7 +4897,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4552
4897
|
});
|
|
4553
4898
|
case 35:
|
|
4554
4899
|
if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4555
|
-
|
|
4900
|
+
_context44.next = 37;
|
|
4556
4901
|
break;
|
|
4557
4902
|
}
|
|
4558
4903
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
@@ -4563,7 +4908,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4563
4908
|
});
|
|
4564
4909
|
case 37:
|
|
4565
4910
|
if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
|
|
4566
|
-
|
|
4911
|
+
_context44.next = 39;
|
|
4567
4912
|
break;
|
|
4568
4913
|
}
|
|
4569
4914
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
|
|
@@ -4575,7 +4920,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4575
4920
|
this.assertAvailabilityCandidateFreshness(context, params.candidate);
|
|
4576
4921
|
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;
|
|
4577
4922
|
if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
|
|
4578
|
-
|
|
4923
|
+
_context44.next = 43;
|
|
4579
4924
|
break;
|
|
4580
4925
|
}
|
|
4581
4926
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
|
|
@@ -4584,14 +4929,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4584
4929
|
});
|
|
4585
4930
|
case 43:
|
|
4586
4931
|
if (!(params.mode === 'edit' && !params.productLineUid)) {
|
|
4587
|
-
|
|
4932
|
+
_context44.next = 45;
|
|
4588
4933
|
break;
|
|
4589
4934
|
}
|
|
4590
4935
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
|
|
4591
4936
|
case 45:
|
|
4592
4937
|
editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
|
|
4593
4938
|
if (!(params.mode === 'edit' && !editingLine)) {
|
|
4594
|
-
|
|
4939
|
+
_context44.next = 48;
|
|
4595
4940
|
break;
|
|
4596
4941
|
}
|
|
4597
4942
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
|
|
@@ -4599,7 +4944,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4599
4944
|
});
|
|
4600
4945
|
case 48:
|
|
4601
4946
|
if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
|
|
4602
|
-
|
|
4947
|
+
_context44.next = 50;
|
|
4603
4948
|
break;
|
|
4604
4949
|
}
|
|
4605
4950
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
|
|
@@ -4609,7 +4954,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4609
4954
|
});
|
|
4610
4955
|
case 50:
|
|
4611
4956
|
if (Array.isArray(params.requirementSelections)) {
|
|
4612
|
-
|
|
4957
|
+
_context44.next = 52;
|
|
4613
4958
|
break;
|
|
4614
4959
|
}
|
|
4615
4960
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
|
|
@@ -4626,7 +4971,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4626
4971
|
};
|
|
4627
4972
|
prepareParams = baseProjection.meta.prepareParams;
|
|
4628
4973
|
if (prepareParams) {
|
|
4629
|
-
|
|
4974
|
+
_context44.next = 57;
|
|
4630
4975
|
break;
|
|
4631
4976
|
}
|
|
4632
4977
|
throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
@@ -4638,7 +4983,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4638
4983
|
})),
|
|
4639
4984
|
includesInjectedRawOccupancies: true
|
|
4640
4985
|
};
|
|
4641
|
-
|
|
4986
|
+
_context44.next = 60;
|
|
4642
4987
|
return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
|
|
4643
4988
|
editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
|
|
4644
4989
|
}), {
|
|
@@ -4647,13 +4992,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4647
4992
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
4648
4993
|
});
|
|
4649
4994
|
case 60:
|
|
4650
|
-
commitSnapshot =
|
|
4995
|
+
commitSnapshot = _context44.sent;
|
|
4651
4996
|
refreshedProjection = commitSnapshot.projection;
|
|
4652
4997
|
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 : ''))) {
|
|
4653
|
-
|
|
4998
|
+
_context44.next = 67;
|
|
4654
4999
|
break;
|
|
4655
5000
|
}
|
|
4656
|
-
|
|
5001
|
+
_context44.next = 65;
|
|
4657
5002
|
return this.refreshAvailabilityContextProjection({
|
|
4658
5003
|
contextId: normalizedContextId,
|
|
4659
5004
|
reason: 'commit_order_revision_changed',
|
|
@@ -4674,7 +5019,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4674
5019
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
4675
5020
|
candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
|
|
4676
5021
|
candidateStartTime = getCandidateStartTime(params.candidate);
|
|
4677
|
-
allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$
|
|
5022
|
+
allowPosAvailabilityOverride = String((_this$otherParams$pla3 = (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
|
|
4678
5023
|
refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
|
|
4679
5024
|
productIds: [params.candidate.productId],
|
|
4680
5025
|
dateRange: {
|
|
@@ -4698,7 +5043,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4698
5043
|
return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
|
|
4699
5044
|
});
|
|
4700
5045
|
if (refreshedCandidateBase) {
|
|
4701
|
-
|
|
5046
|
+
_context44.next = 75;
|
|
4702
5047
|
break;
|
|
4703
5048
|
}
|
|
4704
5049
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
|
|
@@ -4711,7 +5056,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4711
5056
|
return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
|
|
4712
5057
|
});
|
|
4713
5058
|
if (product) {
|
|
4714
|
-
|
|
5059
|
+
_context44.next = 78;
|
|
4715
5060
|
break;
|
|
4716
5061
|
}
|
|
4717
5062
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
|
|
@@ -4748,7 +5093,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4748
5093
|
});
|
|
4749
5094
|
}
|
|
4750
5095
|
if (validation.ok) {
|
|
4751
|
-
|
|
5096
|
+
_context44.next = 83;
|
|
4752
5097
|
break;
|
|
4753
5098
|
}
|
|
4754
5099
|
capacityConflict = validation.conflicts.find(function (conflict) {
|
|
@@ -4771,7 +5116,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4771
5116
|
incrementVersion: true
|
|
4772
5117
|
});
|
|
4773
5118
|
revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
4774
|
-
|
|
5119
|
+
_context44.next = 87;
|
|
4775
5120
|
return this.emitAvailabilityDiagnostic({
|
|
4776
5121
|
action: 'refresh',
|
|
4777
5122
|
contextId: normalizedContextId,
|
|
@@ -4794,7 +5139,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4794
5139
|
existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
|
|
4795
5140
|
existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
|
|
4796
5141
|
if (!(params.mode === 'edit' && !existingBookingUid)) {
|
|
4797
|
-
|
|
5142
|
+
_context44.next = 93;
|
|
4798
5143
|
break;
|
|
4799
5144
|
}
|
|
4800
5145
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
|
|
@@ -4808,15 +5153,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4808
5153
|
product: product,
|
|
4809
5154
|
resources: refreshedProjection.resources,
|
|
4810
5155
|
bookingUid: existingBookingUid || undefined,
|
|
4811
|
-
holder: (
|
|
4812
|
-
holderIds: (
|
|
5156
|
+
holder: (_ref52 = (_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 && _ref52 !== void 0 ? _ref52 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
|
|
5157
|
+
holderIds: (_ref53 = (_ref54 = (_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 && _ref54 !== void 0 ? _ref54 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta2 = existingBooking.metadata) === null || _existingBooking$meta2 === void 0 ? void 0 : _existingBooking$meta2.holder_id) !== null && _ref53 !== void 0 ? _ref53 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold = existingBooking.holder) === null || _existingBooking$hold === void 0 ? void 0 : _existingBooking$hold.form_record
|
|
4813
5158
|
});
|
|
4814
5159
|
transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
|
|
4815
5160
|
num: bookingCount,
|
|
4816
5161
|
quantity: bookingCount
|
|
4817
5162
|
}), 'unified_booking_sales', product);
|
|
4818
5163
|
if (transformed) {
|
|
4819
|
-
|
|
5164
|
+
_context44.next = 98;
|
|
4820
5165
|
break;
|
|
4821
5166
|
}
|
|
4822
5167
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
|
|
@@ -4835,7 +5180,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4835
5180
|
productLineUids = [];
|
|
4836
5181
|
bookingUids = [];
|
|
4837
5182
|
if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
|
|
4838
|
-
|
|
5183
|
+
_context44.next = 117;
|
|
4839
5184
|
break;
|
|
4840
5185
|
}
|
|
4841
5186
|
transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
|
|
@@ -4845,10 +5190,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4845
5190
|
unique_identification_number: params.productLineUid,
|
|
4846
5191
|
booking_uid: existingBookingUid
|
|
4847
5192
|
});
|
|
4848
|
-
|
|
5193
|
+
_context44.next = 111;
|
|
4849
5194
|
return this.updateOrderProduct(_objectSpread(_objectSpread({
|
|
4850
5195
|
product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
|
|
4851
|
-
product_variant_id: (
|
|
5196
|
+
product_variant_id: (_ref55 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref55 !== void 0 ? _ref55 : 0,
|
|
4852
5197
|
unique_identification_number: params.productLineUid,
|
|
4853
5198
|
updates: transformed,
|
|
4854
5199
|
booking: booking
|
|
@@ -4862,7 +5207,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4862
5207
|
bookingUid = existingBookingUid;
|
|
4863
5208
|
productLineUids = [productLineUid];
|
|
4864
5209
|
bookingUids = [bookingUid];
|
|
4865
|
-
|
|
5210
|
+
_context44.next = 129;
|
|
4866
5211
|
break;
|
|
4867
5212
|
case 117:
|
|
4868
5213
|
beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
|
|
@@ -4871,10 +5216,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4871
5216
|
beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
|
|
4872
5217
|
return getBookingUid(item);
|
|
4873
5218
|
}).filter(Boolean));
|
|
4874
|
-
|
|
4875
|
-
return this.addProductToOrder(transformed, booking)
|
|
5219
|
+
_context44.next = 121;
|
|
5220
|
+
return this.addProductToOrder(transformed, booking, (_params$salesNotes = params.salesNotes) !== null && _params$salesNotes !== void 0 && _params$salesNotes.length ? {
|
|
5221
|
+
salesNotes: params.salesNotes
|
|
5222
|
+
} : undefined);
|
|
4876
5223
|
case 121:
|
|
4877
|
-
products =
|
|
5224
|
+
products = _context44.sent;
|
|
4878
5225
|
addedLines = products.filter(function (line) {
|
|
4879
5226
|
var _line$product_id, _line$metadata;
|
|
4880
5227
|
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));
|
|
@@ -4891,8 +5238,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4891
5238
|
}).filter(Boolean);
|
|
4892
5239
|
if (bookingUids.length === 0) {
|
|
4893
5240
|
bookingUids = addedLines.map(function (line) {
|
|
4894
|
-
var
|
|
4895
|
-
return String((
|
|
5241
|
+
var _ref56, _line$booking_uid, _line$metadata2;
|
|
5242
|
+
return String((_ref56 = (_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 && _ref56 !== void 0 ? _ref56 : '');
|
|
4896
5243
|
}).filter(Boolean);
|
|
4897
5244
|
}
|
|
4898
5245
|
productLineUid = productLineUids[productLineUids.length - 1] || '';
|
|
@@ -4911,23 +5258,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4911
5258
|
productLineUids: productLineUids,
|
|
4912
5259
|
bookingUids: bookingUids
|
|
4913
5260
|
};
|
|
4914
|
-
|
|
5261
|
+
_context44.next = 134;
|
|
4915
5262
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
4916
5263
|
case 134:
|
|
4917
|
-
return
|
|
5264
|
+
return _context44.abrupt("return", result);
|
|
4918
5265
|
case 135:
|
|
4919
|
-
|
|
4920
|
-
|
|
5266
|
+
_context44.prev = 135;
|
|
5267
|
+
_context44.next = 138;
|
|
4921
5268
|
return this.releaseAvailabilityCommitLock(normalizedContextId);
|
|
4922
5269
|
case 138:
|
|
4923
|
-
return
|
|
5270
|
+
return _context44.finish(135);
|
|
4924
5271
|
case 139:
|
|
4925
5272
|
case "end":
|
|
4926
|
-
return
|
|
5273
|
+
return _context44.stop();
|
|
4927
5274
|
}
|
|
4928
|
-
},
|
|
5275
|
+
}, _callee44, this, [[5,, 135, 139]]);
|
|
4929
5276
|
}));
|
|
4930
|
-
function commitAvailabilitySelection(
|
|
5277
|
+
function commitAvailabilitySelection(_x34, _x35) {
|
|
4931
5278
|
return _commitAvailabilitySelection.apply(this, arguments);
|
|
4932
5279
|
}
|
|
4933
5280
|
return commitAvailabilitySelection;
|