@pisell/pisellos 2.3.94 → 2.3.95
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/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 +9 -0
- package/dist/modules/Order/index.d.ts +18 -3
- package/dist/modules/Order/index.js +885 -485
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +91 -5
- package/dist/modules/Order/types.js +5 -0
- package/dist/modules/Order/utils.d.ts +12 -0
- package/dist/modules/Order/utils.js +75 -26
- 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/server/index.d.ts +6 -0
- package/dist/server/index.js +43 -3
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +894 -706
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- 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/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 +15 -2
- package/dist/solution/UnifiedBookingSales/index.js +751 -483
- package/dist/solution/UnifiedBookingSales/types.d.ts +14 -1
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +8 -4
- 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/modules/Order/index.d.ts +18 -3
- package/lib/modules/Order/index.js +325 -28
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +91 -5
- package/lib/modules/Order/types.js +4 -0
- package/lib/modules/Order/utils.d.ts +12 -0
- package/lib/modules/Order/utils.js +68 -16
- 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/server/index.d.ts +6 -0
- package/lib/server/index.js +37 -3
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +105 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- 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/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 +15 -2
- package/lib/solution/UnifiedBookingSales/index.js +125 -1
- package/lib/solution/UnifiedBookingSales/types.d.ts +14 -1
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +5 -1
- package/package.json +1 -1
|
@@ -43,6 +43,7 @@ import { AvailabilityRemoteOccupancyCache } from "./remoteOccupancyCache";
|
|
|
43
43
|
import { BookingTicket } from "../BookingTicket";
|
|
44
44
|
import { addLocalCalendarDays, captureRuntimeOffsetMinutes, formatLocalDate, formatLocalDateTime, formatLocalTime, localDateTimeToScalar, localDateToScalar, localDateToScalarStart, parseLocalDate, parseLocalDateTime } from "../../modules/ResourcePlanner/localClock";
|
|
45
45
|
import { isCustomerUserPlatform } from "../../utils/platform";
|
|
46
|
+
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
46
47
|
export * from "./types";
|
|
47
48
|
export { AvailabilityError } from "../../modules/ResourcePlanner";
|
|
48
49
|
var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability'];
|
|
@@ -76,6 +77,29 @@ function getCandidateStartTime(candidate) {
|
|
|
76
77
|
return undefined;
|
|
77
78
|
}
|
|
78
79
|
}
|
|
80
|
+
function normalizePositiveIntegerList(value) {
|
|
81
|
+
if (!Array.isArray(value)) return [];
|
|
82
|
+
return Array.from(new Set(value.map(function (item) {
|
|
83
|
+
return normalizePositiveInteger(item);
|
|
84
|
+
}).filter(function (item) {
|
|
85
|
+
return item !== undefined;
|
|
86
|
+
})));
|
|
87
|
+
}
|
|
88
|
+
function toConfiguredBoolean(value) {
|
|
89
|
+
if (typeof value === 'boolean') return value;
|
|
90
|
+
if (typeof value === 'number') return value !== 0;
|
|
91
|
+
if (typeof value === 'string') {
|
|
92
|
+
return ['1', 'true', 'yes', 'y', 'on'].includes(value.trim().toLowerCase());
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
function normalizeItemRuleStrategyConfigs(value) {
|
|
97
|
+
if (!Array.isArray(value)) return [];
|
|
98
|
+
return value.filter(function (config) {
|
|
99
|
+
var _metadata;
|
|
100
|
+
return Boolean(config && _typeof(config) === 'object' && ((_metadata = config.metadata) === null || _metadata === void 0 ? void 0 : _metadata.type) === 'item_rule');
|
|
101
|
+
});
|
|
102
|
+
}
|
|
79
103
|
function isRecord(value) {
|
|
80
104
|
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
81
105
|
}
|
|
@@ -1265,6 +1289,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1265
1289
|
_defineProperty(_assertThisInitialized(_this), "availabilityRemoteResourceQuerySequence", 0);
|
|
1266
1290
|
_defineProperty(_assertThisInitialized(_this), "availabilityRemoteResourceEpoch", 0);
|
|
1267
1291
|
_defineProperty(_assertThisInitialized(_this), "availabilityCommitLocks", new Set());
|
|
1292
|
+
_defineProperty(_assertThisInitialized(_this), "allergyItemRuleEvaluator", new ItemRuleEvaluator());
|
|
1293
|
+
_defineProperty(_assertThisInitialized(_this), "allergyItemRuleConfigs", []);
|
|
1294
|
+
_defineProperty(_assertThisInitialized(_this), "allergyItemRuleConfigsPromise", null);
|
|
1268
1295
|
return _this;
|
|
1269
1296
|
}
|
|
1270
1297
|
_createClass(UnifiedBookingSalesImpl, [{
|
|
@@ -1284,16 +1311,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1284
1311
|
this.openDataTarget = null;
|
|
1285
1312
|
this.availabilityRuntimeOffsetMinutes = captureRuntimeOffsetMinutes();
|
|
1286
1313
|
this.clearAvailabilityRemoteResourceState();
|
|
1287
|
-
|
|
1314
|
+
this.resetAllergyItemRuleState();
|
|
1315
|
+
_context.next = 8;
|
|
1288
1316
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "initialize", this).call(this, core, options);
|
|
1289
|
-
case
|
|
1317
|
+
case 8:
|
|
1290
1318
|
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();
|
|
1291
1319
|
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();
|
|
1292
1320
|
if ((_this$otherParams4 = this.otherParams) !== null && _this$otherParams4 !== void 0 && _this$otherParams4.openData && openDataBusinessCode && openDataChannel) {
|
|
1293
1321
|
this.openDataTarget = "".concat(openDataBusinessCode, "+").concat(openDataChannel);
|
|
1294
1322
|
}
|
|
1295
1323
|
this.captureAvailabilityScheduleCatalog();
|
|
1296
|
-
case
|
|
1324
|
+
case 12:
|
|
1297
1325
|
case "end":
|
|
1298
1326
|
return _context.stop();
|
|
1299
1327
|
}
|
|
@@ -1503,13 +1531,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1503
1531
|
key: "setOtherParams",
|
|
1504
1532
|
value: function () {
|
|
1505
1533
|
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
1534
|
+
var _this$otherParams11, _this$otherParams13;
|
|
1506
1535
|
var _ref32,
|
|
1507
1536
|
_ref32$cover,
|
|
1508
1537
|
cover,
|
|
1509
1538
|
previousScope,
|
|
1539
|
+
previousItemRuleConfig,
|
|
1510
1540
|
explicitlySetsOpenData,
|
|
1511
1541
|
nextScope,
|
|
1512
|
-
_this$
|
|
1542
|
+
_this$otherParams12,
|
|
1513
1543
|
shouldResetAvailabilityState,
|
|
1514
1544
|
_args3 = arguments;
|
|
1515
1545
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -1517,24 +1547,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1517
1547
|
case 0:
|
|
1518
1548
|
_ref32 = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {}, _ref32$cover = _ref32.cover, cover = _ref32$cover === void 0 ? false : _ref32$cover;
|
|
1519
1549
|
previousScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
|
|
1550
|
+
previousItemRuleConfig = (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.itemRule;
|
|
1520
1551
|
explicitlySetsOpenData = Object.prototype.hasOwnProperty.call(params, 'openData');
|
|
1521
|
-
_context3.next =
|
|
1552
|
+
_context3.next = 6;
|
|
1522
1553
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "setOtherParams", this).call(this, params, {
|
|
1523
1554
|
cover: cover
|
|
1524
1555
|
});
|
|
1525
|
-
case
|
|
1556
|
+
case 6:
|
|
1526
1557
|
nextScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
|
|
1527
1558
|
if (explicitlySetsOpenData) {
|
|
1528
|
-
this.openDataTarget = (_this$
|
|
1559
|
+
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;
|
|
1529
1560
|
}
|
|
1530
1561
|
shouldResetAvailabilityState = previousScope.cacheId !== nextScope.cacheId || previousScope.businessCode !== nextScope.businessCode || previousScope.channel !== nextScope.channel || previousScope.platform !== nextScope.platform || previousScope.businessTimezone !== nextScope.businessTimezone;
|
|
1531
1562
|
if (!shouldResetAvailabilityState) {
|
|
1532
|
-
_context3.next =
|
|
1563
|
+
_context3.next = 12;
|
|
1533
1564
|
break;
|
|
1534
1565
|
}
|
|
1535
|
-
_context3.next =
|
|
1566
|
+
_context3.next = 12;
|
|
1536
1567
|
return this.resetAvailabilityProjectionState('set_other_params_reset');
|
|
1537
|
-
case
|
|
1568
|
+
case 12:
|
|
1569
|
+
if (shouldResetAvailabilityState || explicitlySetsOpenData || previousItemRuleConfig !== ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.itemRule)) {
|
|
1570
|
+
this.resetAllergyItemRuleState();
|
|
1571
|
+
}
|
|
1572
|
+
case 13:
|
|
1538
1573
|
case "end":
|
|
1539
1574
|
return _context3.stop();
|
|
1540
1575
|
}
|
|
@@ -1557,9 +1592,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1557
1592
|
_context4.next = 4;
|
|
1558
1593
|
return this.resetAvailabilityProjectionState('destroy');
|
|
1559
1594
|
case 4:
|
|
1560
|
-
|
|
1595
|
+
this.resetAllergyItemRuleState();
|
|
1596
|
+
_context4.next = 7;
|
|
1561
1597
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "destroy", this).call(this);
|
|
1562
|
-
case
|
|
1598
|
+
case 7:
|
|
1563
1599
|
case "end":
|
|
1564
1600
|
return _context4.stop();
|
|
1565
1601
|
}
|
|
@@ -1764,8 +1800,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1764
1800
|
}, {
|
|
1765
1801
|
key: "isSessionStoragePersistEnabled",
|
|
1766
1802
|
value: function isSessionStoragePersistEnabled() {
|
|
1767
|
-
var _this$
|
|
1768
|
-
return Boolean(this.cacheId && ((_this$
|
|
1803
|
+
var _this$otherParams14;
|
|
1804
|
+
return Boolean(this.cacheId && ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.enableSessionStoragePersist) === true);
|
|
1769
1805
|
}
|
|
1770
1806
|
}, {
|
|
1771
1807
|
key: "shouldUseSessionStorageForSubModule",
|
|
@@ -1834,8 +1870,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1834
1870
|
}, {
|
|
1835
1871
|
key: "shouldUseCheckoutSyncTask",
|
|
1836
1872
|
value: function shouldUseCheckoutSyncTask() {
|
|
1837
|
-
var _this$
|
|
1838
|
-
var configured = (_this$
|
|
1873
|
+
var _this$otherParams15;
|
|
1874
|
+
var configured = (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.checkoutSyncTaskEnabled;
|
|
1839
1875
|
return typeof configured === 'boolean' ? configured : false;
|
|
1840
1876
|
}
|
|
1841
1877
|
|
|
@@ -1990,8 +2026,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1990
2026
|
}, {
|
|
1991
2027
|
key: "isAuthenticatedCustomerUserPlatform",
|
|
1992
2028
|
value: function isAuthenticatedCustomerUserPlatform() {
|
|
1993
|
-
var _this$
|
|
1994
|
-
return isCustomerUserPlatform((_this$
|
|
2029
|
+
var _this$otherParams16;
|
|
2030
|
+
return isCustomerUserPlatform((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.platform);
|
|
1995
2031
|
}
|
|
1996
2032
|
}, {
|
|
1997
2033
|
key: "resolveDiscountOrderIdentity",
|
|
@@ -2169,13 +2205,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2169
2205
|
key: "getOpenData",
|
|
2170
2206
|
value: function () {
|
|
2171
2207
|
var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
2172
|
-
var _this$
|
|
2208
|
+
var _this$otherParams17, _this$otherParams18, _this$store$openData;
|
|
2173
2209
|
var businessCode, channel, target, cachedData;
|
|
2174
2210
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
2175
2211
|
while (1) switch (_context12.prev = _context12.next) {
|
|
2176
2212
|
case 0:
|
|
2177
|
-
businessCode = String(((_this$
|
|
2178
|
-
channel = String(((_this$
|
|
2213
|
+
businessCode = String(((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.businessCode) || '').trim();
|
|
2214
|
+
channel = String(((_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.channel) || '').trim();
|
|
2179
2215
|
if (!(!businessCode || !channel)) {
|
|
2180
2216
|
_context12.next = 4;
|
|
2181
2217
|
break;
|
|
@@ -2205,20 +2241,222 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2205
2241
|
}
|
|
2206
2242
|
return getOpenData;
|
|
2207
2243
|
}()
|
|
2244
|
+
}, {
|
|
2245
|
+
key: "resetAllergyItemRuleState",
|
|
2246
|
+
value: function resetAllergyItemRuleState() {
|
|
2247
|
+
this.allergyItemRuleConfigs = [];
|
|
2248
|
+
this.allergyItemRuleConfigsPromise = null;
|
|
2249
|
+
this.allergyItemRuleEvaluator.setStrategyConfigs([]);
|
|
2250
|
+
}
|
|
2251
|
+
}, {
|
|
2252
|
+
key: "fetchAllergyItemRuleConfigs",
|
|
2253
|
+
value: function () {
|
|
2254
|
+
var _fetchAllergyItemRuleConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(strategyModelIds) {
|
|
2255
|
+
var _response$data, response, list;
|
|
2256
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
2257
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2258
|
+
case 0:
|
|
2259
|
+
if (strategyModelIds.length) {
|
|
2260
|
+
_context13.next = 2;
|
|
2261
|
+
break;
|
|
2262
|
+
}
|
|
2263
|
+
return _context13.abrupt("return", []);
|
|
2264
|
+
case 2:
|
|
2265
|
+
_context13.prev = 2;
|
|
2266
|
+
_context13.next = 5;
|
|
2267
|
+
return this.request.get('/promotion', {
|
|
2268
|
+
skip: 1,
|
|
2269
|
+
num: 99,
|
|
2270
|
+
status: 'active',
|
|
2271
|
+
ids: strategyModelIds
|
|
2272
|
+
});
|
|
2273
|
+
case 5:
|
|
2274
|
+
response = _context13.sent;
|
|
2275
|
+
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))) {
|
|
2276
|
+
_context13.next = 8;
|
|
2277
|
+
break;
|
|
2278
|
+
}
|
|
2279
|
+
throw new Error('[UnifiedBookingSales] 商品过敏策略加载失败');
|
|
2280
|
+
case 8:
|
|
2281
|
+
list = response.data.list;
|
|
2282
|
+
return _context13.abrupt("return", normalizeItemRuleStrategyConfigs(list.map(function (item) {
|
|
2283
|
+
return item === null || item === void 0 ? void 0 : item.metadata;
|
|
2284
|
+
})));
|
|
2285
|
+
case 12:
|
|
2286
|
+
_context13.prev = 12;
|
|
2287
|
+
_context13.t0 = _context13["catch"](2);
|
|
2288
|
+
throw _context13.t0;
|
|
2289
|
+
case 15:
|
|
2290
|
+
case "end":
|
|
2291
|
+
return _context13.stop();
|
|
2292
|
+
}
|
|
2293
|
+
}, _callee13, this, [[2, 12]]);
|
|
2294
|
+
}));
|
|
2295
|
+
function fetchAllergyItemRuleConfigs(_x8) {
|
|
2296
|
+
return _fetchAllergyItemRuleConfigs.apply(this, arguments);
|
|
2297
|
+
}
|
|
2298
|
+
return fetchAllergyItemRuleConfigs;
|
|
2299
|
+
}()
|
|
2300
|
+
}, {
|
|
2301
|
+
key: "ensureAllergyItemRuleConfigsLoaded",
|
|
2302
|
+
value: function () {
|
|
2303
|
+
var _ensureAllergyItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
2304
|
+
var _this3 = this;
|
|
2305
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
2306
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2307
|
+
case 0:
|
|
2308
|
+
if (!(this.allergyItemRuleConfigs.length > 0)) {
|
|
2309
|
+
_context15.next = 2;
|
|
2310
|
+
break;
|
|
2311
|
+
}
|
|
2312
|
+
return _context15.abrupt("return", this.allergyItemRuleConfigs);
|
|
2313
|
+
case 2:
|
|
2314
|
+
if (!this.allergyItemRuleConfigsPromise) {
|
|
2315
|
+
_context15.next = 4;
|
|
2316
|
+
break;
|
|
2317
|
+
}
|
|
2318
|
+
return _context15.abrupt("return", this.allergyItemRuleConfigsPromise);
|
|
2319
|
+
case 4:
|
|
2320
|
+
this.allergyItemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
2321
|
+
var _this3$otherParams;
|
|
2322
|
+
var staticConfigs, openData, enabled, strategyModelIds, loaded;
|
|
2323
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
2324
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2325
|
+
case 0:
|
|
2326
|
+
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);
|
|
2327
|
+
if (!(staticConfigs.length > 0)) {
|
|
2328
|
+
_context14.next = 5;
|
|
2329
|
+
break;
|
|
2330
|
+
}
|
|
2331
|
+
_this3.allergyItemRuleConfigs = staticConfigs;
|
|
2332
|
+
_this3.allergyItemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2333
|
+
return _context14.abrupt("return", staticConfigs);
|
|
2334
|
+
case 5:
|
|
2335
|
+
_context14.next = 7;
|
|
2336
|
+
return _this3.getOpenData();
|
|
2337
|
+
case 7:
|
|
2338
|
+
openData = _context14.sent;
|
|
2339
|
+
enabled = toConfiguredBoolean(openData === null || openData === void 0 ? void 0 : openData['sale.enable_item_rules']);
|
|
2340
|
+
strategyModelIds = normalizePositiveIntegerList(openData === null || openData === void 0 ? void 0 : openData['sale.enabled_item_rules']);
|
|
2341
|
+
if (!(!enabled || !strategyModelIds.length)) {
|
|
2342
|
+
_context14.next = 13;
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
_this3.allergyItemRuleEvaluator.setStrategyConfigs([]);
|
|
2346
|
+
return _context14.abrupt("return", []);
|
|
2347
|
+
case 13:
|
|
2348
|
+
_context14.next = 15;
|
|
2349
|
+
return _this3.fetchAllergyItemRuleConfigs(strategyModelIds);
|
|
2350
|
+
case 15:
|
|
2351
|
+
loaded = _context14.sent;
|
|
2352
|
+
_this3.allergyItemRuleConfigs = loaded;
|
|
2353
|
+
_this3.allergyItemRuleEvaluator.setStrategyConfigs(loaded);
|
|
2354
|
+
return _context14.abrupt("return", loaded);
|
|
2355
|
+
case 19:
|
|
2356
|
+
case "end":
|
|
2357
|
+
return _context14.stop();
|
|
2358
|
+
}
|
|
2359
|
+
}, _callee14);
|
|
2360
|
+
}))();
|
|
2361
|
+
return _context15.abrupt("return", this.allergyItemRuleConfigsPromise);
|
|
2362
|
+
case 6:
|
|
2363
|
+
case "end":
|
|
2364
|
+
return _context15.stop();
|
|
2365
|
+
}
|
|
2366
|
+
}, _callee15, this);
|
|
2367
|
+
}));
|
|
2368
|
+
function ensureAllergyItemRuleConfigsLoaded() {
|
|
2369
|
+
return _ensureAllergyItemRuleConfigsLoaded.apply(this, arguments);
|
|
2370
|
+
}
|
|
2371
|
+
return ensureAllergyItemRuleConfigsLoaded;
|
|
2372
|
+
}()
|
|
2373
|
+
/**
|
|
2374
|
+
* 评估当前渠道与商品是否命中 ALLERGY_CHECK。
|
|
2375
|
+
* 只返回优先级最高 Action 中当前商品 Target 的 dataSource,不跨商品或 Action 合并。
|
|
2376
|
+
*/
|
|
2377
|
+
}, {
|
|
2378
|
+
key: "resolveProductAllergyRequirement",
|
|
2379
|
+
value: (function () {
|
|
2380
|
+
var _resolveProductAllergyRequirement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
2381
|
+
var _this$otherParams19, _this$getOrderProduct, _runtimePax$total, _runtimePax$adult, _runtimePax$child, _ref35, _runtimeConfig$servic, _this$otherParams20, _ref36, _ref37, _params$channel, _this$otherParams21, _this$otherParams22, _runtimeConfig$submis;
|
|
2382
|
+
var productId, strategyConfigs, productVariantId, runtimeConfig, runtimePax, cartItems;
|
|
2383
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2384
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2385
|
+
case 0:
|
|
2386
|
+
productId = normalizePositiveInteger(params.productId);
|
|
2387
|
+
if (productId) {
|
|
2388
|
+
_context16.next = 3;
|
|
2389
|
+
break;
|
|
2390
|
+
}
|
|
2391
|
+
return _context16.abrupt("return", null);
|
|
2392
|
+
case 3:
|
|
2393
|
+
_context16.next = 5;
|
|
2394
|
+
return this.ensureAllergyItemRuleConfigsLoaded();
|
|
2395
|
+
case 5:
|
|
2396
|
+
strategyConfigs = _context16.sent;
|
|
2397
|
+
if (strategyConfigs.length) {
|
|
2398
|
+
_context16.next = 8;
|
|
2399
|
+
break;
|
|
2400
|
+
}
|
|
2401
|
+
return _context16.abrupt("return", null);
|
|
2402
|
+
case 8:
|
|
2403
|
+
productVariantId = normalizePositiveInteger(params.productVariantId);
|
|
2404
|
+
runtimeConfig = ((_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.itemRule) || {};
|
|
2405
|
+
runtimePax = runtimeConfig.pax || {};
|
|
2406
|
+
cartItems = (((_this$getOrderProduct = this.getOrderProducts) === null || _this$getOrderProduct === void 0 ? void 0 : _this$getOrderProduct.call(this)) || []).map(function (item) {
|
|
2407
|
+
var _item$product_id, _item$product_variant, _ref34, _item$num;
|
|
2408
|
+
return {
|
|
2409
|
+
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),
|
|
2410
|
+
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,
|
|
2411
|
+
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)
|
|
2412
|
+
};
|
|
2413
|
+
}).filter(function (item) {
|
|
2414
|
+
return Number.isFinite(item.product_id) && item.product_id > 0 && Number.isFinite(item.quantity) && item.quantity > 0;
|
|
2415
|
+
});
|
|
2416
|
+
return _context16.abrupt("return", this.allergyItemRuleEvaluator.getAllergyRequirement({
|
|
2417
|
+
pax: {
|
|
2418
|
+
total: Number((_runtimePax$total = runtimePax.total) !== null && _runtimePax$total !== void 0 ? _runtimePax$total : 0) || 0,
|
|
2419
|
+
adult: Number((_runtimePax$adult = runtimePax.adult) !== null && _runtimePax$adult !== void 0 ? _runtimePax$adult : 0) || 0,
|
|
2420
|
+
child: Number((_runtimePax$child = runtimePax.child) !== null && _runtimePax$child !== void 0 ? _runtimePax$child : 0) || 0
|
|
2421
|
+
},
|
|
2422
|
+
cartItems: cartItems,
|
|
2423
|
+
serviceType: String((_ref35 = (_runtimeConfig$servic = runtimeConfig.serviceType) !== null && _runtimeConfig$servic !== void 0 ? _runtimeConfig$servic : (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.serviceType) !== null && _ref35 !== void 0 ? _ref35 : ''),
|
|
2424
|
+
channel: String((_ref36 = (_ref37 = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.channel) !== null && _ref37 !== void 0 ? _ref37 : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.platform) !== null && _ref36 !== void 0 ? _ref36 : ''),
|
|
2425
|
+
currentProduct: _objectSpread({
|
|
2426
|
+
product_id: productId
|
|
2427
|
+
}, productVariantId ? {
|
|
2428
|
+
product_variant_id: productVariantId
|
|
2429
|
+
} : {}),
|
|
2430
|
+
submissionIndex: Number((_runtimeConfig$submis = runtimeConfig.submissionIndex) !== null && _runtimeConfig$submis !== void 0 ? _runtimeConfig$submis : 0) || 0,
|
|
2431
|
+
strategyConfigs: strategyConfigs,
|
|
2432
|
+
custom: runtimeConfig.custom
|
|
2433
|
+
}));
|
|
2434
|
+
case 13:
|
|
2435
|
+
case "end":
|
|
2436
|
+
return _context16.stop();
|
|
2437
|
+
}
|
|
2438
|
+
}, _callee16, this);
|
|
2439
|
+
}));
|
|
2440
|
+
function resolveProductAllergyRequirement(_x9) {
|
|
2441
|
+
return _resolveProductAllergyRequirement.apply(this, arguments);
|
|
2442
|
+
}
|
|
2443
|
+
return resolveProductAllergyRequirement;
|
|
2444
|
+
}()
|
|
2208
2445
|
/**
|
|
2209
2446
|
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
2210
2447
|
*/
|
|
2448
|
+
)
|
|
2211
2449
|
}, {
|
|
2212
2450
|
key: "getProtocol",
|
|
2213
2451
|
value: (function () {
|
|
2214
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2452
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(policyId) {
|
|
2215
2453
|
var normalizedPolicyId, policyUrl;
|
|
2216
|
-
return _regeneratorRuntime().wrap(function
|
|
2217
|
-
while (1) switch (
|
|
2454
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2455
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2218
2456
|
case 0:
|
|
2219
2457
|
normalizedPolicyId = String(policyId !== null && policyId !== void 0 ? policyId : '').trim();
|
|
2220
2458
|
if (normalizedPolicyId) {
|
|
2221
|
-
|
|
2459
|
+
_context17.next = 3;
|
|
2222
2460
|
break;
|
|
2223
2461
|
}
|
|
2224
2462
|
throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
|
|
@@ -2227,14 +2465,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2227
2465
|
if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
|
|
2228
2466
|
policyUrl = 'policy';
|
|
2229
2467
|
}
|
|
2230
|
-
return
|
|
2468
|
+
return _context17.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
|
|
2231
2469
|
case 6:
|
|
2232
2470
|
case "end":
|
|
2233
|
-
return
|
|
2471
|
+
return _context17.stop();
|
|
2234
2472
|
}
|
|
2235
|
-
},
|
|
2473
|
+
}, _callee17, this);
|
|
2236
2474
|
}));
|
|
2237
|
-
function getProtocol(
|
|
2475
|
+
function getProtocol(_x10) {
|
|
2238
2476
|
return _getProtocol.apply(this, arguments);
|
|
2239
2477
|
}
|
|
2240
2478
|
return getProtocol;
|
|
@@ -2247,27 +2485,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2247
2485
|
}, {
|
|
2248
2486
|
key: "loadProducts",
|
|
2249
2487
|
value: (function () {
|
|
2250
|
-
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2488
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2251
2489
|
var params,
|
|
2252
2490
|
options,
|
|
2253
2491
|
schedule_date,
|
|
2254
2492
|
schedule_datetime,
|
|
2255
2493
|
result,
|
|
2256
|
-
|
|
2257
|
-
return _regeneratorRuntime().wrap(function
|
|
2258
|
-
while (1) switch (
|
|
2494
|
+
_args18 = arguments;
|
|
2495
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2496
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2259
2497
|
case 0:
|
|
2260
|
-
params =
|
|
2261
|
-
options =
|
|
2498
|
+
params = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
|
|
2499
|
+
options = _args18.length > 1 ? _args18[1] : undefined;
|
|
2262
2500
|
if (this.store.products) {
|
|
2263
|
-
|
|
2501
|
+
_context18.next = 4;
|
|
2264
2502
|
break;
|
|
2265
2503
|
}
|
|
2266
2504
|
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
2267
2505
|
case 4:
|
|
2268
2506
|
schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
2269
2507
|
schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
|
|
2270
|
-
|
|
2508
|
+
_context18.next = 8;
|
|
2271
2509
|
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
2272
2510
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
2273
2511
|
with_schedule: 1
|
|
@@ -2277,44 +2515,72 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2277
2515
|
cacheId: this.cacheId
|
|
2278
2516
|
}), options);
|
|
2279
2517
|
case 8:
|
|
2280
|
-
result =
|
|
2518
|
+
result = _context18.sent;
|
|
2281
2519
|
this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
|
|
2282
|
-
|
|
2520
|
+
_context18.next = 12;
|
|
2283
2521
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
|
|
2284
2522
|
case 12:
|
|
2285
|
-
return
|
|
2523
|
+
return _context18.abrupt("return", result);
|
|
2286
2524
|
case 13:
|
|
2287
2525
|
case "end":
|
|
2288
|
-
return
|
|
2526
|
+
return _context18.stop();
|
|
2289
2527
|
}
|
|
2290
|
-
},
|
|
2528
|
+
}, _callee18, this);
|
|
2291
2529
|
}));
|
|
2292
2530
|
function loadProducts() {
|
|
2293
2531
|
return _loadProducts.apply(this, arguments);
|
|
2294
2532
|
}
|
|
2295
2533
|
return loadProducts;
|
|
2296
|
-
}()
|
|
2534
|
+
}())
|
|
2535
|
+
}, {
|
|
2536
|
+
key: "queryProducts",
|
|
2537
|
+
value: function () {
|
|
2538
|
+
var _queryProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
2539
|
+
var params,
|
|
2540
|
+
_args19 = arguments;
|
|
2541
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2542
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2543
|
+
case 0:
|
|
2544
|
+
params = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {};
|
|
2545
|
+
if (this.store.products) {
|
|
2546
|
+
_context19.next = 3;
|
|
2547
|
+
break;
|
|
2548
|
+
}
|
|
2549
|
+
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
2550
|
+
case 3:
|
|
2551
|
+
return _context19.abrupt("return", this.store.products.queryProducts(params));
|
|
2552
|
+
case 4:
|
|
2553
|
+
case "end":
|
|
2554
|
+
return _context19.stop();
|
|
2555
|
+
}
|
|
2556
|
+
}, _callee19, this);
|
|
2557
|
+
}));
|
|
2558
|
+
function queryProducts() {
|
|
2559
|
+
return _queryProducts.apply(this, arguments);
|
|
2560
|
+
}
|
|
2561
|
+
return queryProducts;
|
|
2562
|
+
}() /** Date-first entry point. It delegates protocol details and cache ownership to ScheduleModule. */
|
|
2297
2563
|
}, {
|
|
2298
2564
|
key: "loadScheduleAvailableDate",
|
|
2299
2565
|
value: (function () {
|
|
2300
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2301
|
-
return _regeneratorRuntime().wrap(function
|
|
2302
|
-
while (1) switch (
|
|
2566
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
2567
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2568
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2303
2569
|
case 0:
|
|
2304
2570
|
if (this.store.schedule) {
|
|
2305
|
-
|
|
2571
|
+
_context20.next = 2;
|
|
2306
2572
|
break;
|
|
2307
2573
|
}
|
|
2308
2574
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
2309
2575
|
case 2:
|
|
2310
|
-
return
|
|
2576
|
+
return _context20.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
|
|
2311
2577
|
case 3:
|
|
2312
2578
|
case "end":
|
|
2313
|
-
return
|
|
2579
|
+
return _context20.stop();
|
|
2314
2580
|
}
|
|
2315
|
-
},
|
|
2581
|
+
}, _callee20, this);
|
|
2316
2582
|
}));
|
|
2317
|
-
function loadScheduleAvailableDate(
|
|
2583
|
+
function loadScheduleAvailableDate(_x11) {
|
|
2318
2584
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
2319
2585
|
}
|
|
2320
2586
|
return loadScheduleAvailableDate;
|
|
@@ -2328,15 +2594,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2328
2594
|
}, {
|
|
2329
2595
|
key: "loadProductsByScheduleDate",
|
|
2330
2596
|
value: (function () {
|
|
2331
|
-
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2597
|
+
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
2332
2598
|
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;
|
|
2333
2599
|
var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator, _step, productId, result;
|
|
2334
|
-
return _regeneratorRuntime().wrap(function
|
|
2335
|
-
while (1) switch (
|
|
2600
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2601
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
2336
2602
|
case 0:
|
|
2337
2603
|
date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
|
|
2338
2604
|
if (this.store.schedule) {
|
|
2339
|
-
|
|
2605
|
+
_context21.next = 3;
|
|
2340
2606
|
break;
|
|
2341
2607
|
}
|
|
2342
2608
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
@@ -2347,10 +2613,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2347
2613
|
});
|
|
2348
2614
|
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;
|
|
2349
2615
|
if (!(!hasCachedDate && !hasOtherProducts)) {
|
|
2350
|
-
|
|
2616
|
+
_context21.next = 9;
|
|
2351
2617
|
break;
|
|
2352
2618
|
}
|
|
2353
|
-
|
|
2619
|
+
_context21.next = 9;
|
|
2354
2620
|
return this.loadScheduleAvailableDate({
|
|
2355
2621
|
startDate: date,
|
|
2356
2622
|
endDate: date,
|
|
@@ -2370,45 +2636,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2370
2636
|
return !productIdFilter || productIdFilter.has(String(id));
|
|
2371
2637
|
});
|
|
2372
2638
|
if (availableProductIds.length) {
|
|
2373
|
-
|
|
2639
|
+
_context21.next = 17;
|
|
2374
2640
|
break;
|
|
2375
2641
|
}
|
|
2376
2642
|
this.unifiedProductCatalog = [];
|
|
2377
|
-
|
|
2643
|
+
_context21.next = 16;
|
|
2378
2644
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
|
|
2379
2645
|
case 16:
|
|
2380
|
-
return
|
|
2646
|
+
return _context21.abrupt("return", []);
|
|
2381
2647
|
case 17:
|
|
2382
|
-
|
|
2648
|
+
_context21.next = 19;
|
|
2383
2649
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
2384
2650
|
product_ids: availableProductIds,
|
|
2385
2651
|
schedule_date: date
|
|
2386
2652
|
}));
|
|
2387
2653
|
case 19:
|
|
2388
|
-
products =
|
|
2654
|
+
products = _context21.sent;
|
|
2389
2655
|
if (!(products.length || availableProductIds.length <= 1)) {
|
|
2390
|
-
|
|
2656
|
+
_context21.next = 22;
|
|
2391
2657
|
break;
|
|
2392
2658
|
}
|
|
2393
|
-
return
|
|
2659
|
+
return _context21.abrupt("return", products);
|
|
2394
2660
|
case 22:
|
|
2395
2661
|
fallbackProducts = [];
|
|
2396
2662
|
_iterator = _createForOfIteratorHelper(availableProductIds);
|
|
2397
|
-
|
|
2663
|
+
_context21.prev = 24;
|
|
2398
2664
|
_iterator.s();
|
|
2399
2665
|
case 26:
|
|
2400
2666
|
if ((_step = _iterator.n()).done) {
|
|
2401
|
-
|
|
2667
|
+
_context21.next = 34;
|
|
2402
2668
|
break;
|
|
2403
2669
|
}
|
|
2404
2670
|
productId = _step.value;
|
|
2405
|
-
|
|
2671
|
+
_context21.next = 30;
|
|
2406
2672
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
2407
2673
|
product_ids: [productId],
|
|
2408
2674
|
schedule_date: date
|
|
2409
2675
|
}));
|
|
2410
2676
|
case 30:
|
|
2411
|
-
result =
|
|
2677
|
+
result = _context21.sent;
|
|
2412
2678
|
result.forEach(function (product) {
|
|
2413
2679
|
var _id;
|
|
2414
2680
|
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;
|
|
@@ -2420,32 +2686,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2420
2686
|
}
|
|
2421
2687
|
});
|
|
2422
2688
|
case 32:
|
|
2423
|
-
|
|
2689
|
+
_context21.next = 26;
|
|
2424
2690
|
break;
|
|
2425
2691
|
case 34:
|
|
2426
|
-
|
|
2692
|
+
_context21.next = 39;
|
|
2427
2693
|
break;
|
|
2428
2694
|
case 36:
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
_iterator.e(
|
|
2695
|
+
_context21.prev = 36;
|
|
2696
|
+
_context21.t0 = _context21["catch"](24);
|
|
2697
|
+
_iterator.e(_context21.t0);
|
|
2432
2698
|
case 39:
|
|
2433
|
-
|
|
2699
|
+
_context21.prev = 39;
|
|
2434
2700
|
_iterator.f();
|
|
2435
|
-
return
|
|
2701
|
+
return _context21.finish(39);
|
|
2436
2702
|
case 42:
|
|
2437
2703
|
this.unifiedProductCatalog = [].concat(fallbackProducts);
|
|
2438
|
-
|
|
2704
|
+
_context21.next = 45;
|
|
2439
2705
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
|
|
2440
2706
|
case 45:
|
|
2441
|
-
return
|
|
2707
|
+
return _context21.abrupt("return", fallbackProducts);
|
|
2442
2708
|
case 46:
|
|
2443
2709
|
case "end":
|
|
2444
|
-
return
|
|
2710
|
+
return _context21.stop();
|
|
2445
2711
|
}
|
|
2446
|
-
},
|
|
2712
|
+
}, _callee21, this, [[24, 36, 39, 42]]);
|
|
2447
2713
|
}));
|
|
2448
|
-
function loadProductsByScheduleDate(
|
|
2714
|
+
function loadProductsByScheduleDate(_x12) {
|
|
2449
2715
|
return _loadProductsByScheduleDate.apply(this, arguments);
|
|
2450
2716
|
}
|
|
2451
2717
|
return loadProductsByScheduleDate;
|
|
@@ -2498,7 +2764,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2498
2764
|
}, {
|
|
2499
2765
|
key: "applyPlannerDiscounts",
|
|
2500
2766
|
value: (function () {
|
|
2501
|
-
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2767
|
+
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
2502
2768
|
var _params$customerId;
|
|
2503
2769
|
var params,
|
|
2504
2770
|
tempOrder,
|
|
@@ -2515,24 +2781,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2515
2781
|
discount,
|
|
2516
2782
|
discountId,
|
|
2517
2783
|
nextTempOrder,
|
|
2518
|
-
|
|
2519
|
-
return _regeneratorRuntime().wrap(function
|
|
2520
|
-
while (1) switch (
|
|
2784
|
+
_args22 = arguments;
|
|
2785
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2786
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
2521
2787
|
case 0:
|
|
2522
|
-
params =
|
|
2788
|
+
params = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
2523
2789
|
tempOrder = this.getTempOrder();
|
|
2524
2790
|
requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
2525
2791
|
parsedCustomerId = Number(requestedCustomerId);
|
|
2526
2792
|
customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
|
|
2527
|
-
|
|
2793
|
+
_context22.next = 7;
|
|
2528
2794
|
return this.getSummary();
|
|
2529
2795
|
case 7:
|
|
2530
|
-
summaryBefore =
|
|
2796
|
+
summaryBefore = _context22.sent;
|
|
2531
2797
|
if (customerId) {
|
|
2532
|
-
|
|
2798
|
+
_context22.next = 10;
|
|
2533
2799
|
break;
|
|
2534
2800
|
}
|
|
2535
|
-
return
|
|
2801
|
+
return _context22.abrupt("return", buildPlannerDiscountResult({
|
|
2536
2802
|
customerId: null,
|
|
2537
2803
|
discountList: this.getDiscountList(),
|
|
2538
2804
|
products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
@@ -2541,7 +2807,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2541
2807
|
status: 'no_customer'
|
|
2542
2808
|
}));
|
|
2543
2809
|
case 10:
|
|
2544
|
-
|
|
2810
|
+
_context22.next = 12;
|
|
2545
2811
|
return this.loadDiscountConfig({
|
|
2546
2812
|
customerId: customerId,
|
|
2547
2813
|
action: 'create'
|
|
@@ -2553,7 +2819,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2553
2819
|
return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
|
|
2554
2820
|
});
|
|
2555
2821
|
if (!preferredDiscount) {
|
|
2556
|
-
|
|
2822
|
+
_context22.next = 40;
|
|
2557
2823
|
break;
|
|
2558
2824
|
}
|
|
2559
2825
|
// A requested card is an explicit UI choice, not a best-effort preference. Clear prior
|
|
@@ -2565,98 +2831,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2565
2831
|
return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
|
|
2566
2832
|
});
|
|
2567
2833
|
_iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
|
|
2568
|
-
|
|
2834
|
+
_context22.prev = 18;
|
|
2569
2835
|
_iterator2.s();
|
|
2570
2836
|
case 20:
|
|
2571
2837
|
if ((_step2 = _iterator2.n()).done) {
|
|
2572
|
-
|
|
2838
|
+
_context22.next = 28;
|
|
2573
2839
|
break;
|
|
2574
2840
|
}
|
|
2575
2841
|
discount = _step2.value;
|
|
2576
2842
|
discountId = Number(resolvePlannerDiscountId(discount));
|
|
2577
2843
|
if (!Number.isFinite(discountId)) {
|
|
2578
|
-
|
|
2844
|
+
_context22.next = 26;
|
|
2579
2845
|
break;
|
|
2580
2846
|
}
|
|
2581
|
-
|
|
2847
|
+
_context22.next = 26;
|
|
2582
2848
|
return this.setDiscountSelected({
|
|
2583
2849
|
discountId: discountId,
|
|
2584
2850
|
isSelected: false
|
|
2585
2851
|
});
|
|
2586
2852
|
case 26:
|
|
2587
|
-
|
|
2853
|
+
_context22.next = 20;
|
|
2588
2854
|
break;
|
|
2589
2855
|
case 28:
|
|
2590
|
-
|
|
2856
|
+
_context22.next = 33;
|
|
2591
2857
|
break;
|
|
2592
2858
|
case 30:
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
_iterator2.e(
|
|
2859
|
+
_context22.prev = 30;
|
|
2860
|
+
_context22.t0 = _context22["catch"](18);
|
|
2861
|
+
_iterator2.e(_context22.t0);
|
|
2596
2862
|
case 33:
|
|
2597
|
-
|
|
2863
|
+
_context22.prev = 33;
|
|
2598
2864
|
_iterator2.f();
|
|
2599
|
-
return
|
|
2865
|
+
return _context22.finish(33);
|
|
2600
2866
|
case 36:
|
|
2601
|
-
|
|
2867
|
+
_context22.next = 38;
|
|
2602
2868
|
return this.setDiscountSelected({
|
|
2603
2869
|
discountId: Number(preferredId),
|
|
2604
2870
|
isSelected: true
|
|
2605
2871
|
});
|
|
2606
2872
|
case 38:
|
|
2607
|
-
|
|
2873
|
+
_context22.next = 49;
|
|
2608
2874
|
break;
|
|
2609
2875
|
case 40:
|
|
2610
2876
|
if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
|
|
2611
|
-
|
|
2877
|
+
_context22.next = 46;
|
|
2612
2878
|
break;
|
|
2613
2879
|
}
|
|
2614
2880
|
if (!(params.applyBestDiscount !== false)) {
|
|
2615
|
-
|
|
2881
|
+
_context22.next = 44;
|
|
2616
2882
|
break;
|
|
2617
2883
|
}
|
|
2618
|
-
|
|
2884
|
+
_context22.next = 44;
|
|
2619
2885
|
return this.bestDiscount();
|
|
2620
2886
|
case 44:
|
|
2621
|
-
|
|
2887
|
+
_context22.next = 49;
|
|
2622
2888
|
break;
|
|
2623
2889
|
case 46:
|
|
2624
2890
|
if (!(params.applyBestDiscount !== false)) {
|
|
2625
|
-
|
|
2891
|
+
_context22.next = 49;
|
|
2626
2892
|
break;
|
|
2627
2893
|
}
|
|
2628
|
-
|
|
2894
|
+
_context22.next = 49;
|
|
2629
2895
|
return this.bestDiscount();
|
|
2630
2896
|
case 49:
|
|
2631
2897
|
nextTempOrder = this.getTempOrder();
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2898
|
+
_context22.t1 = buildPlannerDiscountResult;
|
|
2899
|
+
_context22.t2 = customerId;
|
|
2900
|
+
_context22.t3 = this.getDiscountList();
|
|
2901
|
+
_context22.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
|
|
2902
|
+
_context22.t5 = summaryBefore;
|
|
2903
|
+
_context22.next = 57;
|
|
2638
2904
|
return this.getSummary();
|
|
2639
2905
|
case 57:
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
customerId:
|
|
2646
|
-
discountList:
|
|
2647
|
-
products:
|
|
2648
|
-
summaryBefore:
|
|
2649
|
-
summaryAfter:
|
|
2650
|
-
status:
|
|
2651
|
-
preferredDiscountId:
|
|
2652
|
-
preferredDiscountFound:
|
|
2906
|
+
_context22.t6 = _context22.sent;
|
|
2907
|
+
_context22.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
|
|
2908
|
+
_context22.t8 = preferredDiscountId;
|
|
2909
|
+
_context22.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
|
|
2910
|
+
_context22.t10 = {
|
|
2911
|
+
customerId: _context22.t2,
|
|
2912
|
+
discountList: _context22.t3,
|
|
2913
|
+
products: _context22.t4,
|
|
2914
|
+
summaryBefore: _context22.t5,
|
|
2915
|
+
summaryAfter: _context22.t6,
|
|
2916
|
+
status: _context22.t7,
|
|
2917
|
+
preferredDiscountId: _context22.t8,
|
|
2918
|
+
preferredDiscountFound: _context22.t9
|
|
2653
2919
|
};
|
|
2654
|
-
return
|
|
2920
|
+
return _context22.abrupt("return", (0, _context22.t1)(_context22.t10));
|
|
2655
2921
|
case 63:
|
|
2656
2922
|
case "end":
|
|
2657
|
-
return
|
|
2923
|
+
return _context22.stop();
|
|
2658
2924
|
}
|
|
2659
|
-
},
|
|
2925
|
+
}, _callee22, this, [[18, 30, 33, 36]]);
|
|
2660
2926
|
}));
|
|
2661
2927
|
function applyPlannerDiscounts() {
|
|
2662
2928
|
return _applyPlannerDiscounts.apply(this, arguments);
|
|
@@ -2666,16 +2932,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2666
2932
|
}, {
|
|
2667
2933
|
key: "buildUnifiedOrderProduct",
|
|
2668
2934
|
value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
|
|
2669
|
-
var
|
|
2935
|
+
var _ref38, _sourceProduct$_exten, _sourceProduct$_exten2, _sourceProduct$metada, _sourceProduct$id, _ref39, _sourceProduct$produc, _ref40, _ref41, _sourceProduct$quanti, _sourceProduct$price, _ref42, _ref43, _sourceProduct$sellin;
|
|
2670
2936
|
var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
|
|
2671
|
-
var quotationShelfId = (
|
|
2937
|
+
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;
|
|
2672
2938
|
var orderProduct = this.transformBaseProductToOrderProduct({
|
|
2673
2939
|
payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
|
|
2674
2940
|
id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
|
|
2675
|
-
product_id: (
|
|
2676
|
-
quantity: (
|
|
2941
|
+
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,
|
|
2942
|
+
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,
|
|
2677
2943
|
price: (_sourceProduct$price = sourceProduct.price) !== null && _sourceProduct$price !== void 0 ? _sourceProduct$price : normalizedProductRaw.price,
|
|
2678
|
-
selling_price: (
|
|
2944
|
+
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,
|
|
2679
2945
|
metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
|
|
2680
2946
|
}),
|
|
2681
2947
|
sourceProduct: sourceProduct
|
|
@@ -2694,29 +2960,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2694
2960
|
}, {
|
|
2695
2961
|
key: "removeExistingStagedLines",
|
|
2696
2962
|
value: (function () {
|
|
2697
|
-
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2963
|
+
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(ownershipKey) {
|
|
2698
2964
|
var _this$getTempOrder;
|
|
2699
2965
|
var existingLines;
|
|
2700
|
-
return _regeneratorRuntime().wrap(function
|
|
2701
|
-
while (1) switch (
|
|
2966
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2967
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2702
2968
|
case 0:
|
|
2703
2969
|
existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
|
|
2704
2970
|
var _product$metadata4;
|
|
2705
2971
|
return (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4[ownershipKey]) === true;
|
|
2706
2972
|
});
|
|
2707
2973
|
if (!(existingLines.length > 0)) {
|
|
2708
|
-
|
|
2974
|
+
_context23.next = 4;
|
|
2709
2975
|
break;
|
|
2710
2976
|
}
|
|
2711
|
-
|
|
2977
|
+
_context23.next = 4;
|
|
2712
2978
|
return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
|
|
2713
2979
|
case 4:
|
|
2714
2980
|
case "end":
|
|
2715
|
-
return
|
|
2981
|
+
return _context23.stop();
|
|
2716
2982
|
}
|
|
2717
|
-
},
|
|
2983
|
+
}, _callee23, this);
|
|
2718
2984
|
}));
|
|
2719
|
-
function removeExistingStagedLines(
|
|
2985
|
+
function removeExistingStagedLines(_x13) {
|
|
2720
2986
|
return _removeExistingStagedLines.apply(this, arguments);
|
|
2721
2987
|
}
|
|
2722
2988
|
return removeExistingStagedLines;
|
|
@@ -2724,25 +2990,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2724
2990
|
}, {
|
|
2725
2991
|
key: "stageProducts",
|
|
2726
2992
|
value: function () {
|
|
2727
|
-
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2993
|
+
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params, ownershipKey) {
|
|
2728
2994
|
var _params$rawProducts;
|
|
2729
2995
|
var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
|
|
2730
|
-
return _regeneratorRuntime().wrap(function
|
|
2731
|
-
while (1) switch (
|
|
2996
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2997
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2732
2998
|
case 0:
|
|
2733
2999
|
productIds = params.productIds || [];
|
|
2734
3000
|
if (productIds.length) {
|
|
2735
|
-
|
|
3001
|
+
_context24.next = 3;
|
|
2736
3002
|
break;
|
|
2737
3003
|
}
|
|
2738
|
-
return
|
|
3004
|
+
return _context24.abrupt("return", this.getTempOrder());
|
|
2739
3005
|
case 3:
|
|
2740
3006
|
if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
|
|
2741
|
-
|
|
3007
|
+
_context24.next = 7;
|
|
2742
3008
|
break;
|
|
2743
3009
|
}
|
|
2744
3010
|
this.unifiedProductCatalog = params.rawProducts;
|
|
2745
|
-
|
|
3011
|
+
_context24.next = 12;
|
|
2746
3012
|
break;
|
|
2747
3013
|
case 7:
|
|
2748
3014
|
existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
|
|
@@ -2753,15 +3019,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2753
3019
|
return !existingIds.has(String(id));
|
|
2754
3020
|
});
|
|
2755
3021
|
if (!(missingIds.length || params.productLoadParams)) {
|
|
2756
|
-
|
|
3022
|
+
_context24.next = 12;
|
|
2757
3023
|
break;
|
|
2758
3024
|
}
|
|
2759
|
-
|
|
3025
|
+
_context24.next = 12;
|
|
2760
3026
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
2761
3027
|
product_ids: productIds.map(Number).filter(Number.isFinite)
|
|
2762
3028
|
}));
|
|
2763
3029
|
case 12:
|
|
2764
|
-
|
|
3030
|
+
_context24.next = 14;
|
|
2765
3031
|
return this.removeExistingStagedLines(ownershipKey);
|
|
2766
3032
|
case 14:
|
|
2767
3033
|
productIdSet = new Set(productIds.map(function (id) {
|
|
@@ -2774,30 +3040,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2774
3040
|
_i = 0, _arr = selectedProducts;
|
|
2775
3041
|
case 17:
|
|
2776
3042
|
if (!(_i < _arr.length)) {
|
|
2777
|
-
|
|
3043
|
+
_context24.next = 26;
|
|
2778
3044
|
break;
|
|
2779
3045
|
}
|
|
2780
3046
|
sourceProduct = _arr[_i];
|
|
2781
3047
|
productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
|
|
2782
3048
|
if (!productInput) {
|
|
2783
|
-
|
|
3049
|
+
_context24.next = 23;
|
|
2784
3050
|
break;
|
|
2785
3051
|
}
|
|
2786
|
-
|
|
3052
|
+
_context24.next = 23;
|
|
2787
3053
|
return this.addProductToOrder(productInput);
|
|
2788
3054
|
case 23:
|
|
2789
3055
|
_i++;
|
|
2790
|
-
|
|
3056
|
+
_context24.next = 17;
|
|
2791
3057
|
break;
|
|
2792
3058
|
case 26:
|
|
2793
|
-
return
|
|
3059
|
+
return _context24.abrupt("return", this.getTempOrder());
|
|
2794
3060
|
case 27:
|
|
2795
3061
|
case "end":
|
|
2796
|
-
return
|
|
3062
|
+
return _context24.stop();
|
|
2797
3063
|
}
|
|
2798
|
-
},
|
|
3064
|
+
}, _callee24, this);
|
|
2799
3065
|
}));
|
|
2800
|
-
function stageProducts(
|
|
3066
|
+
function stageProducts(_x14, _x15) {
|
|
2801
3067
|
return _stageProducts.apply(this, arguments);
|
|
2802
3068
|
}
|
|
2803
3069
|
return stageProducts;
|
|
@@ -2809,18 +3075,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2809
3075
|
}, {
|
|
2810
3076
|
key: "stageRetailProducts",
|
|
2811
3077
|
value: (function () {
|
|
2812
|
-
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2813
|
-
return _regeneratorRuntime().wrap(function
|
|
2814
|
-
while (1) switch (
|
|
3078
|
+
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
3079
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
3080
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2815
3081
|
case 0:
|
|
2816
|
-
return
|
|
3082
|
+
return _context25.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
|
|
2817
3083
|
case 1:
|
|
2818
3084
|
case "end":
|
|
2819
|
-
return
|
|
3085
|
+
return _context25.stop();
|
|
2820
3086
|
}
|
|
2821
|
-
},
|
|
3087
|
+
}, _callee25, this);
|
|
2822
3088
|
}));
|
|
2823
|
-
function stageRetailProducts(
|
|
3089
|
+
function stageRetailProducts(_x16) {
|
|
2824
3090
|
return _stageRetailProducts.apply(this, arguments);
|
|
2825
3091
|
}
|
|
2826
3092
|
return stageRetailProducts;
|
|
@@ -2834,20 +3100,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2834
3100
|
}, {
|
|
2835
3101
|
key: "addRetailProduct",
|
|
2836
3102
|
value: (function () {
|
|
2837
|
-
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2838
|
-
var _params$quantity,
|
|
3103
|
+
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
3104
|
+
var _params$quantity, _ref44, _params$productId, _params$product, _params$product2;
|
|
2839
3105
|
var quantity, productId, sourceProduct, products, orderProduct;
|
|
2840
|
-
return _regeneratorRuntime().wrap(function
|
|
2841
|
-
while (1) switch (
|
|
3106
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
3107
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2842
3108
|
case 0:
|
|
2843
3109
|
quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
|
|
2844
3110
|
if (!(!Number.isFinite(quantity) || quantity <= 0)) {
|
|
2845
|
-
|
|
3111
|
+
_context26.next = 3;
|
|
2846
3112
|
break;
|
|
2847
3113
|
}
|
|
2848
3114
|
throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
|
|
2849
3115
|
case 3:
|
|
2850
|
-
productId = (
|
|
3116
|
+
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;
|
|
2851
3117
|
sourceProduct = params.product;
|
|
2852
3118
|
if (!sourceProduct && productId !== undefined && productId !== null) {
|
|
2853
3119
|
sourceProduct = this.unifiedProductCatalog.find(function (product) {
|
|
@@ -2856,22 +3122,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2856
3122
|
});
|
|
2857
3123
|
}
|
|
2858
3124
|
if (!(!sourceProduct && productId !== undefined && productId !== null)) {
|
|
2859
|
-
|
|
3125
|
+
_context26.next = 11;
|
|
2860
3126
|
break;
|
|
2861
3127
|
}
|
|
2862
|
-
|
|
3128
|
+
_context26.next = 9;
|
|
2863
3129
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
2864
3130
|
product_ids: [Number(productId)].filter(Number.isFinite)
|
|
2865
3131
|
}));
|
|
2866
3132
|
case 9:
|
|
2867
|
-
products =
|
|
3133
|
+
products = _context26.sent;
|
|
2868
3134
|
sourceProduct = products.find(function (product) {
|
|
2869
3135
|
var _product$id4;
|
|
2870
3136
|
return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
|
|
2871
3137
|
});
|
|
2872
3138
|
case 11:
|
|
2873
3139
|
if (sourceProduct) {
|
|
2874
|
-
|
|
3140
|
+
_context26.next = 13;
|
|
2875
3141
|
break;
|
|
2876
3142
|
}
|
|
2877
3143
|
throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
|
|
@@ -2880,19 +3146,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2880
3146
|
quantity: quantity
|
|
2881
3147
|
}), 'unified_booking_sales_retail');
|
|
2882
3148
|
if (orderProduct) {
|
|
2883
|
-
|
|
3149
|
+
_context26.next = 16;
|
|
2884
3150
|
break;
|
|
2885
3151
|
}
|
|
2886
3152
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
2887
3153
|
case 16:
|
|
2888
|
-
return
|
|
3154
|
+
return _context26.abrupt("return", this.addProductToOrder(orderProduct));
|
|
2889
3155
|
case 17:
|
|
2890
3156
|
case "end":
|
|
2891
|
-
return
|
|
3157
|
+
return _context26.stop();
|
|
2892
3158
|
}
|
|
2893
|
-
},
|
|
3159
|
+
}, _callee26, this);
|
|
2894
3160
|
}));
|
|
2895
|
-
function addRetailProduct(
|
|
3161
|
+
function addRetailProduct(_x17) {
|
|
2896
3162
|
return _addRetailProduct.apply(this, arguments);
|
|
2897
3163
|
}
|
|
2898
3164
|
return addRetailProduct;
|
|
@@ -2992,7 +3258,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2992
3258
|
}, {
|
|
2993
3259
|
key: "buildAvailabilityOperatingHoursSnapshot",
|
|
2994
3260
|
value: function buildAvailabilityOperatingHoursSnapshot(params) {
|
|
2995
|
-
var
|
|
3261
|
+
var _this4 = this;
|
|
2996
3262
|
var descriptor = params.prepare._availabilityOperatingHours || {
|
|
2997
3263
|
source: params.prepare.businessHours ? 'prepare_business_hours' : 'default_business_hours',
|
|
2998
3264
|
scheduleIds: []
|
|
@@ -3002,7 +3268,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3002
3268
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3003
3269
|
startAt: "".concat(date, "T").concat(params.businessHours.startTime, ":00"),
|
|
3004
3270
|
endAt: "".concat(date, "T").concat(params.businessHours.endTime, ":00"),
|
|
3005
|
-
fixedOffsetMinutes:
|
|
3271
|
+
fixedOffsetMinutes: _this4.getAvailabilityRuntimeOffsetMinutes(),
|
|
3006
3272
|
rollOverEnd: true
|
|
3007
3273
|
});
|
|
3008
3274
|
return range ? [{
|
|
@@ -3037,7 +3303,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3037
3303
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3038
3304
|
startAt: slot.start_at,
|
|
3039
3305
|
endAt: slot.end_at,
|
|
3040
|
-
fixedOffsetMinutes:
|
|
3306
|
+
fixedOffsetMinutes: _this4.getAvailabilityRuntimeOffsetMinutes(),
|
|
3041
3307
|
rollOverEnd: true
|
|
3042
3308
|
});
|
|
3043
3309
|
return range ? [{
|
|
@@ -3057,46 +3323,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3057
3323
|
}, {
|
|
3058
3324
|
key: "loadAvailabilityProducts",
|
|
3059
3325
|
value: function () {
|
|
3060
|
-
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3326
|
+
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
3061
3327
|
var _prepare$catalogScope,
|
|
3062
3328
|
_prepare$catalogScope2,
|
|
3063
|
-
|
|
3329
|
+
_this5 = this,
|
|
3064
3330
|
_prepare$resourceIds;
|
|
3065
3331
|
var prepare, dateRange, explicitProductIds, rawProducts, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
|
|
3066
|
-
return _regeneratorRuntime().wrap(function
|
|
3067
|
-
while (1) switch (
|
|
3332
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
3333
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3068
3334
|
case 0:
|
|
3069
3335
|
prepare = params.prepare, dateRange = params.dateRange;
|
|
3070
3336
|
explicitProductIds = prepare.productIds || [];
|
|
3071
3337
|
rawProducts = [];
|
|
3072
3338
|
if (!Array.isArray(prepare.rawProducts)) {
|
|
3073
|
-
|
|
3339
|
+
_context27.next = 8;
|
|
3074
3340
|
break;
|
|
3075
3341
|
}
|
|
3076
3342
|
rawProducts = prepare.rawProducts;
|
|
3077
3343
|
this.unifiedProductCatalog = _toConsumableArray(rawProducts);
|
|
3078
|
-
|
|
3344
|
+
_context27.next = 34;
|
|
3079
3345
|
break;
|
|
3080
3346
|
case 8:
|
|
3081
3347
|
if (!(explicitProductIds.length > 0)) {
|
|
3082
|
-
|
|
3348
|
+
_context27.next = 14;
|
|
3083
3349
|
break;
|
|
3084
3350
|
}
|
|
3085
|
-
|
|
3351
|
+
_context27.next = 11;
|
|
3086
3352
|
return this.loadProducts({
|
|
3087
3353
|
product_ids: explicitProductIds,
|
|
3088
3354
|
schedule_date: dateRange.startDate
|
|
3089
3355
|
});
|
|
3090
3356
|
case 11:
|
|
3091
|
-
rawProducts =
|
|
3092
|
-
|
|
3357
|
+
rawProducts = _context27.sent;
|
|
3358
|
+
_context27.next = 34;
|
|
3093
3359
|
break;
|
|
3094
3360
|
case 14:
|
|
3095
3361
|
if (!(((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'schedule')) {
|
|
3096
|
-
|
|
3362
|
+
_context27.next = 30;
|
|
3097
3363
|
break;
|
|
3098
3364
|
}
|
|
3099
|
-
|
|
3365
|
+
_context27.next = 17;
|
|
3100
3366
|
return this.loadScheduleAvailableDate({
|
|
3101
3367
|
startDate: dateRange.startDate,
|
|
3102
3368
|
endDate: dateRange.endDate,
|
|
@@ -3112,44 +3378,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3112
3378
|
});
|
|
3113
3379
|
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)) || [])));
|
|
3114
3380
|
if (!(productIds.length > 0)) {
|
|
3115
|
-
|
|
3381
|
+
_context27.next = 27;
|
|
3116
3382
|
break;
|
|
3117
3383
|
}
|
|
3118
3384
|
assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
|
|
3119
|
-
|
|
3385
|
+
_context27.next = 24;
|
|
3120
3386
|
return this.loadProducts({
|
|
3121
3387
|
product_ids: productIds,
|
|
3122
3388
|
schedule_date: dateRange.startDate
|
|
3123
3389
|
});
|
|
3124
3390
|
case 24:
|
|
3125
|
-
rawProducts =
|
|
3126
|
-
|
|
3391
|
+
rawProducts = _context27.sent;
|
|
3392
|
+
_context27.next = 28;
|
|
3127
3393
|
break;
|
|
3128
3394
|
case 27:
|
|
3129
3395
|
this.unifiedProductCatalog = [];
|
|
3130
3396
|
case 28:
|
|
3131
|
-
|
|
3397
|
+
_context27.next = 34;
|
|
3132
3398
|
break;
|
|
3133
3399
|
case 30:
|
|
3134
3400
|
if (!(((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList')) {
|
|
3135
|
-
|
|
3401
|
+
_context27.next = 34;
|
|
3136
3402
|
break;
|
|
3137
3403
|
}
|
|
3138
|
-
|
|
3404
|
+
_context27.next = 33;
|
|
3139
3405
|
return this.loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
|
|
3140
3406
|
schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
|
|
3141
3407
|
}));
|
|
3142
3408
|
case 33:
|
|
3143
|
-
rawProducts =
|
|
3409
|
+
rawProducts = _context27.sent;
|
|
3144
3410
|
case 34:
|
|
3145
3411
|
normalized = rawProducts.map(function (product) {
|
|
3146
|
-
return normalizeProductForAvailability(product, params.scheduleList,
|
|
3412
|
+
return normalizeProductForAvailability(product, params.scheduleList, _this5.getAvailabilityRuntimeOffsetMinutes());
|
|
3147
3413
|
});
|
|
3148
3414
|
if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
|
|
3149
|
-
|
|
3415
|
+
_context27.next = 37;
|
|
3150
3416
|
break;
|
|
3151
3417
|
}
|
|
3152
|
-
return
|
|
3418
|
+
return _context27.abrupt("return", normalized.filter(function (product) {
|
|
3153
3419
|
var _product$requirementG2;
|
|
3154
3420
|
return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
|
|
3155
3421
|
var _group$resourceIds3;
|
|
@@ -3162,16 +3428,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3162
3428
|
}));
|
|
3163
3429
|
case 37:
|
|
3164
3430
|
productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
|
|
3165
|
-
return
|
|
3431
|
+
return _context27.abrupt("return", productIdSet ? normalized.filter(function (product) {
|
|
3166
3432
|
return productIdSet.has(String(product.id));
|
|
3167
3433
|
}) : normalized);
|
|
3168
3434
|
case 39:
|
|
3169
3435
|
case "end":
|
|
3170
|
-
return
|
|
3436
|
+
return _context27.stop();
|
|
3171
3437
|
}
|
|
3172
|
-
},
|
|
3438
|
+
}, _callee27, this);
|
|
3173
3439
|
}));
|
|
3174
|
-
function loadAvailabilityProducts(
|
|
3440
|
+
function loadAvailabilityProducts(_x18) {
|
|
3175
3441
|
return _loadAvailabilityProducts.apply(this, arguments);
|
|
3176
3442
|
}
|
|
3177
3443
|
return loadAvailabilityProducts;
|
|
@@ -3184,12 +3450,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3184
3450
|
}, {
|
|
3185
3451
|
key: "fetchAvailabilityResourcesV2",
|
|
3186
3452
|
value: (function () {
|
|
3187
|
-
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3453
|
+
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
3188
3454
|
var response, data;
|
|
3189
|
-
return _regeneratorRuntime().wrap(function
|
|
3190
|
-
while (1) switch (
|
|
3455
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3456
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3191
3457
|
case 0:
|
|
3192
|
-
|
|
3458
|
+
_context28.next = 2;
|
|
3193
3459
|
return this.request.get('/schedule/resource/list/v2', {
|
|
3194
3460
|
start_date: params.dateRange.startDate,
|
|
3195
3461
|
end_date: params.dateRange.endDate,
|
|
@@ -3199,28 +3465,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3199
3465
|
useCache: false
|
|
3200
3466
|
});
|
|
3201
3467
|
case 2:
|
|
3202
|
-
response =
|
|
3468
|
+
response = _context28.sent;
|
|
3203
3469
|
data = response === null || response === void 0 ? void 0 : response.data;
|
|
3204
3470
|
if (!Array.isArray(data)) {
|
|
3205
|
-
|
|
3471
|
+
_context28.next = 6;
|
|
3206
3472
|
break;
|
|
3207
3473
|
}
|
|
3208
|
-
return
|
|
3474
|
+
return _context28.abrupt("return", data);
|
|
3209
3475
|
case 6:
|
|
3210
3476
|
if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
|
|
3211
|
-
|
|
3477
|
+
_context28.next = 8;
|
|
3212
3478
|
break;
|
|
3213
3479
|
}
|
|
3214
|
-
return
|
|
3480
|
+
return _context28.abrupt("return", data.list);
|
|
3215
3481
|
case 8:
|
|
3216
|
-
return
|
|
3482
|
+
return _context28.abrupt("return", []);
|
|
3217
3483
|
case 9:
|
|
3218
3484
|
case "end":
|
|
3219
|
-
return
|
|
3485
|
+
return _context28.stop();
|
|
3220
3486
|
}
|
|
3221
|
-
},
|
|
3487
|
+
}, _callee28, this);
|
|
3222
3488
|
}));
|
|
3223
|
-
function fetchAvailabilityResourcesV2(
|
|
3489
|
+
function fetchAvailabilityResourcesV2(_x19) {
|
|
3224
3490
|
return _fetchAvailabilityResourcesV.apply(this, arguments);
|
|
3225
3491
|
}
|
|
3226
3492
|
return fetchAvailabilityResourcesV2;
|
|
@@ -3228,17 +3494,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3228
3494
|
}, {
|
|
3229
3495
|
key: "fetchAndPublishAvailabilityResourcesV2",
|
|
3230
3496
|
value: function () {
|
|
3231
|
-
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3497
|
+
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
3232
3498
|
var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
|
|
3233
|
-
return _regeneratorRuntime().wrap(function
|
|
3234
|
-
while (1) switch (
|
|
3499
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3500
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3235
3501
|
case 0:
|
|
3236
3502
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3237
3503
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3238
|
-
|
|
3504
|
+
_context29.next = 3;
|
|
3239
3505
|
break;
|
|
3240
3506
|
}
|
|
3241
|
-
return
|
|
3507
|
+
return _context29.abrupt("return", []);
|
|
3242
3508
|
case 3:
|
|
3243
3509
|
scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
3244
3510
|
cacheParams = {
|
|
@@ -3248,7 +3514,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3248
3514
|
};
|
|
3249
3515
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3250
3516
|
if (!cachedRawResources) {
|
|
3251
|
-
|
|
3517
|
+
_context29.next = 9;
|
|
3252
3518
|
break;
|
|
3253
3519
|
}
|
|
3254
3520
|
if (params.useCacheOnHit) {
|
|
@@ -3260,23 +3526,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3260
3526
|
console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
|
|
3261
3527
|
});
|
|
3262
3528
|
}
|
|
3263
|
-
return
|
|
3529
|
+
return _context29.abrupt("return", cachedRawResources);
|
|
3264
3530
|
case 9:
|
|
3265
|
-
|
|
3531
|
+
_context29.next = 11;
|
|
3266
3532
|
return this.refreshAvailabilityRemoteResourceQuery({
|
|
3267
3533
|
timezone: params.timezone,
|
|
3268
3534
|
dateRange: params.dateRange,
|
|
3269
3535
|
resourceIds: normalizedResourceIds
|
|
3270
3536
|
});
|
|
3271
3537
|
case 11:
|
|
3272
|
-
return
|
|
3538
|
+
return _context29.abrupt("return", _context29.sent);
|
|
3273
3539
|
case 12:
|
|
3274
3540
|
case "end":
|
|
3275
|
-
return
|
|
3541
|
+
return _context29.stop();
|
|
3276
3542
|
}
|
|
3277
|
-
},
|
|
3543
|
+
}, _callee29, this);
|
|
3278
3544
|
}));
|
|
3279
|
-
function fetchAndPublishAvailabilityResourcesV2(
|
|
3545
|
+
function fetchAndPublishAvailabilityResourcesV2(_x20) {
|
|
3280
3546
|
return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
|
|
3281
3547
|
}
|
|
3282
3548
|
return fetchAndPublishAvailabilityResourcesV2;
|
|
@@ -3284,17 +3550,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3284
3550
|
}, {
|
|
3285
3551
|
key: "refreshAvailabilityRemoteResourceQuery",
|
|
3286
3552
|
value: function () {
|
|
3287
|
-
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3553
|
+
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
3288
3554
|
var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
|
|
3289
|
-
return _regeneratorRuntime().wrap(function
|
|
3290
|
-
while (1) switch (
|
|
3555
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3556
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3291
3557
|
case 0:
|
|
3292
3558
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3293
3559
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3294
|
-
|
|
3560
|
+
_context30.next = 3;
|
|
3295
3561
|
break;
|
|
3296
3562
|
}
|
|
3297
|
-
return
|
|
3563
|
+
return _context30.abrupt("return", []);
|
|
3298
3564
|
case 3:
|
|
3299
3565
|
queryKey = this.buildAvailabilityRemoteResourceQueryKey({
|
|
3300
3566
|
timezone: params.timezone,
|
|
@@ -3304,13 +3570,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3304
3570
|
epoch = this.availabilityRemoteResourceEpoch;
|
|
3305
3571
|
existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3306
3572
|
if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
|
|
3307
|
-
|
|
3573
|
+
_context30.next = 10;
|
|
3308
3574
|
break;
|
|
3309
3575
|
}
|
|
3310
|
-
|
|
3576
|
+
_context30.next = 9;
|
|
3311
3577
|
return existing.promise;
|
|
3312
3578
|
case 9:
|
|
3313
|
-
return
|
|
3579
|
+
return _context30.abrupt("return", _context30.sent);
|
|
3314
3580
|
case 10:
|
|
3315
3581
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
3316
3582
|
writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
@@ -3322,11 +3588,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3322
3588
|
epoch: epoch,
|
|
3323
3589
|
promise: promise
|
|
3324
3590
|
});
|
|
3325
|
-
|
|
3326
|
-
|
|
3591
|
+
_context30.prev = 14;
|
|
3592
|
+
_context30.next = 17;
|
|
3327
3593
|
return promise;
|
|
3328
3594
|
case 17:
|
|
3329
|
-
rawResources =
|
|
3595
|
+
rawResources = _context30.sent;
|
|
3330
3596
|
if (epoch === this.availabilityRemoteResourceEpoch) {
|
|
3331
3597
|
this.availabilityRemoteOccupancyCache.publish({
|
|
3332
3598
|
scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
|
|
@@ -3337,21 +3603,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3337
3603
|
version: writeVersion
|
|
3338
3604
|
});
|
|
3339
3605
|
}
|
|
3340
|
-
return
|
|
3606
|
+
return _context30.abrupt("return", rawResources);
|
|
3341
3607
|
case 20:
|
|
3342
|
-
|
|
3608
|
+
_context30.prev = 20;
|
|
3343
3609
|
current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3344
3610
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
3345
3611
|
this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
|
|
3346
3612
|
}
|
|
3347
|
-
return
|
|
3613
|
+
return _context30.finish(20);
|
|
3348
3614
|
case 24:
|
|
3349
3615
|
case "end":
|
|
3350
|
-
return
|
|
3616
|
+
return _context30.stop();
|
|
3351
3617
|
}
|
|
3352
|
-
},
|
|
3618
|
+
}, _callee30, this, [[14,, 20, 24]]);
|
|
3353
3619
|
}));
|
|
3354
|
-
function refreshAvailabilityRemoteResourceQuery(
|
|
3620
|
+
function refreshAvailabilityRemoteResourceQuery(_x21) {
|
|
3355
3621
|
return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
|
|
3356
3622
|
}
|
|
3357
3623
|
return refreshAvailabilityRemoteResourceQuery;
|
|
@@ -3359,26 +3625,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3359
3625
|
}, {
|
|
3360
3626
|
key: "loadAvailabilityResources",
|
|
3361
3627
|
value: function () {
|
|
3362
|
-
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3628
|
+
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
3363
3629
|
var resourceIds, cachedRawResources, rawResources;
|
|
3364
|
-
return _regeneratorRuntime().wrap(function
|
|
3365
|
-
while (1) switch (
|
|
3630
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3631
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3366
3632
|
case 0:
|
|
3367
3633
|
resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
|
|
3368
3634
|
if (!(resourceIds.length === 0)) {
|
|
3369
|
-
|
|
3635
|
+
_context31.next = 3;
|
|
3370
3636
|
break;
|
|
3371
3637
|
}
|
|
3372
|
-
return
|
|
3638
|
+
return _context31.abrupt("return", {
|
|
3373
3639
|
resources: [],
|
|
3374
3640
|
resourceOccupancies: []
|
|
3375
3641
|
});
|
|
3376
3642
|
case 3:
|
|
3377
3643
|
if (!Array.isArray(params.rawResources)) {
|
|
3378
|
-
|
|
3644
|
+
_context31.next = 5;
|
|
3379
3645
|
break;
|
|
3380
3646
|
}
|
|
3381
|
-
return
|
|
3647
|
+
return _context31.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3382
3648
|
rawResources: params.rawResources,
|
|
3383
3649
|
scheduleList: params.scheduleList,
|
|
3384
3650
|
dateRange: params.dateRange,
|
|
@@ -3386,7 +3652,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3386
3652
|
}));
|
|
3387
3653
|
case 5:
|
|
3388
3654
|
if (!(params.fetchPolicy === 'cache_only')) {
|
|
3389
|
-
|
|
3655
|
+
_context31.next = 10;
|
|
3390
3656
|
break;
|
|
3391
3657
|
}
|
|
3392
3658
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read({
|
|
@@ -3395,22 +3661,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3395
3661
|
dateRange: params.dateRange
|
|
3396
3662
|
});
|
|
3397
3663
|
if (!cachedRawResources) {
|
|
3398
|
-
|
|
3664
|
+
_context31.next = 9;
|
|
3399
3665
|
break;
|
|
3400
3666
|
}
|
|
3401
|
-
return
|
|
3667
|
+
return _context31.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3402
3668
|
rawResources: cachedRawResources,
|
|
3403
3669
|
scheduleList: params.scheduleList,
|
|
3404
3670
|
dateRange: params.dateRange,
|
|
3405
3671
|
fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
|
|
3406
3672
|
}));
|
|
3407
3673
|
case 9:
|
|
3408
|
-
return
|
|
3674
|
+
return _context31.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
|
|
3409
3675
|
resources: [],
|
|
3410
3676
|
resourceOccupancies: []
|
|
3411
3677
|
});
|
|
3412
3678
|
case 10:
|
|
3413
|
-
|
|
3679
|
+
_context31.next = 12;
|
|
3414
3680
|
return this.fetchAndPublishAvailabilityResourcesV2({
|
|
3415
3681
|
timezone: params.timezone,
|
|
3416
3682
|
dateRange: params.dateRange,
|
|
@@ -3418,8 +3684,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3418
3684
|
useCacheOnHit: true
|
|
3419
3685
|
});
|
|
3420
3686
|
case 12:
|
|
3421
|
-
rawResources =
|
|
3422
|
-
return
|
|
3687
|
+
rawResources = _context31.sent;
|
|
3688
|
+
return _context31.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
3423
3689
|
rawResources: rawResources,
|
|
3424
3690
|
scheduleList: params.scheduleList,
|
|
3425
3691
|
dateRange: params.dateRange,
|
|
@@ -3427,11 +3693,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3427
3693
|
}));
|
|
3428
3694
|
case 14:
|
|
3429
3695
|
case "end":
|
|
3430
|
-
return
|
|
3696
|
+
return _context31.stop();
|
|
3431
3697
|
}
|
|
3432
|
-
},
|
|
3698
|
+
}, _callee31, this);
|
|
3433
3699
|
}));
|
|
3434
|
-
function loadAvailabilityResources(
|
|
3700
|
+
function loadAvailabilityResources(_x22) {
|
|
3435
3701
|
return _loadAvailabilityResources.apply(this, arguments);
|
|
3436
3702
|
}
|
|
3437
3703
|
return loadAvailabilityResources;
|
|
@@ -3451,7 +3717,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3451
3717
|
var products = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) ? tempOrder.products : [];
|
|
3452
3718
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
3453
3719
|
productLineUids.forEach(function (requestedUid) {
|
|
3454
|
-
var
|
|
3720
|
+
var _ref45, _product$booking_uid2, _product$metadata5;
|
|
3455
3721
|
var product = products.find(function (line) {
|
|
3456
3722
|
return getProductLineUid(line) === String(requestedUid);
|
|
3457
3723
|
});
|
|
@@ -3461,7 +3727,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3461
3727
|
});
|
|
3462
3728
|
}
|
|
3463
3729
|
var productUid = getProductLineUid(product);
|
|
3464
|
-
var linkedBookingUid = String((
|
|
3730
|
+
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 : '');
|
|
3465
3731
|
var linkedBookings = bookings.filter(function (booking) {
|
|
3466
3732
|
var _booking$product_uid;
|
|
3467
3733
|
return linkedBookingUid && getBookingUid(booking) === linkedBookingUid || productUid && String((_booking$product_uid = booking.product_uid) !== null && _booking$product_uid !== void 0 ? _booking$product_uid : '') === productUid;
|
|
@@ -3504,24 +3770,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3504
3770
|
}, {
|
|
3505
3771
|
key: "collectCartResourceOccupancies",
|
|
3506
3772
|
value: function collectCartResourceOccupancies(tempOrder, exclusions) {
|
|
3507
|
-
var
|
|
3773
|
+
var _this6 = this;
|
|
3508
3774
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
3509
3775
|
return bookings.flatMap(function (booking) {
|
|
3510
|
-
var
|
|
3776
|
+
var _ref46, _booking$product_uid2, _booking$metadata2;
|
|
3511
3777
|
var bookingUid = getBookingUid(booking);
|
|
3512
|
-
var productUid = String((
|
|
3778
|
+
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 : '');
|
|
3513
3779
|
var scheduleEventId = toNumberId(booking.schedule_event_id);
|
|
3514
3780
|
var startAt = booking.start_at || "".concat(booking.start_date || '', " ").concat(booking.start_time || '').trim();
|
|
3515
3781
|
var endAt = booking.end_at || "".concat(booking.end_date || booking.start_date || '', " ").concat(booking.end_time || '').trim();
|
|
3516
3782
|
var resources = Array.isArray(booking.resources) ? booking.resources : [];
|
|
3517
3783
|
return resources.flatMap(function (resource) {
|
|
3518
|
-
var
|
|
3519
|
-
var resourceId = (
|
|
3784
|
+
var _ref47, _resource$resource_id, _ref48, _resource$capacity;
|
|
3785
|
+
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;
|
|
3520
3786
|
if (resourceId == null || !startAt || !endAt) return [];
|
|
3521
3787
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3522
3788
|
startAt: startAt,
|
|
3523
3789
|
endAt: endAt,
|
|
3524
|
-
fixedOffsetMinutes:
|
|
3790
|
+
fixedOffsetMinutes: _this6.getAvailabilityRuntimeOffsetMinutes(),
|
|
3525
3791
|
rollOverEnd: false
|
|
3526
3792
|
});
|
|
3527
3793
|
if (!range) return [];
|
|
@@ -3529,7 +3795,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3529
3795
|
resourceId: resourceId,
|
|
3530
3796
|
startAt: range.startAt,
|
|
3531
3797
|
endAt: range.endAt,
|
|
3532
|
-
pax: Math.max(1, Number((
|
|
3798
|
+
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),
|
|
3533
3799
|
source: 'cart',
|
|
3534
3800
|
scheduleEventId: scheduleEventId,
|
|
3535
3801
|
bookingUid: bookingUid || undefined,
|
|
@@ -3539,7 +3805,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3539
3805
|
resource: resource
|
|
3540
3806
|
}
|
|
3541
3807
|
};
|
|
3542
|
-
return
|
|
3808
|
+
return _this6.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
|
|
3543
3809
|
});
|
|
3544
3810
|
});
|
|
3545
3811
|
}
|
|
@@ -3606,16 +3872,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3606
3872
|
}, {
|
|
3607
3873
|
key: "assertContextualQueryFreshness",
|
|
3608
3874
|
value: function assertContextualQueryFreshness(context, request) {
|
|
3609
|
-
var
|
|
3875
|
+
var _this7 = this;
|
|
3610
3876
|
if (request.target === 'time') {
|
|
3611
3877
|
request.candidates.forEach(function (candidate) {
|
|
3612
|
-
|
|
3878
|
+
_this7.assertAvailabilityCandidateFreshness(context, candidate);
|
|
3613
3879
|
});
|
|
3614
3880
|
return;
|
|
3615
3881
|
}
|
|
3616
3882
|
if (request.target === 'resource') {
|
|
3617
3883
|
request.selectedRanges.forEach(function (candidate) {
|
|
3618
|
-
|
|
3884
|
+
_this7.assertAvailabilityCandidateFreshness(context, candidate);
|
|
3619
3885
|
});
|
|
3620
3886
|
}
|
|
3621
3887
|
}
|
|
@@ -3662,8 +3928,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3662
3928
|
}, {
|
|
3663
3929
|
key: "buildAvailabilityProjectionSnapshot",
|
|
3664
3930
|
value: function () {
|
|
3665
|
-
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3666
|
-
var
|
|
3931
|
+
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3932
|
+
var _this8 = this;
|
|
3667
3933
|
var options,
|
|
3668
3934
|
normalizedPrepareParams,
|
|
3669
3935
|
timezoneLabel,
|
|
@@ -3684,11 +3950,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3684
3950
|
durationCandidateAnchorAt,
|
|
3685
3951
|
orderRevision,
|
|
3686
3952
|
projection,
|
|
3687
|
-
|
|
3688
|
-
return _regeneratorRuntime().wrap(function
|
|
3689
|
-
while (1) switch (
|
|
3953
|
+
_args32 = arguments;
|
|
3954
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3955
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3690
3956
|
case 0:
|
|
3691
|
-
options =
|
|
3957
|
+
options = _args32.length > 1 && _args32[1] !== undefined ? _args32[1] : {};
|
|
3692
3958
|
normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
3693
3959
|
timezoneLabel = String(normalizedPrepareParams.timezone);
|
|
3694
3960
|
dateRange = normalizedPrepareParams.dateRange;
|
|
@@ -3702,15 +3968,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3702
3968
|
scheduleList: scheduleList,
|
|
3703
3969
|
businessHours: businessHours
|
|
3704
3970
|
});
|
|
3705
|
-
|
|
3971
|
+
_context32.next = 11;
|
|
3706
3972
|
return this.loadAvailabilityProducts({
|
|
3707
3973
|
prepare: normalizedPrepareParams,
|
|
3708
3974
|
dateRange: dateRange,
|
|
3709
3975
|
scheduleList: scheduleList
|
|
3710
3976
|
});
|
|
3711
3977
|
case 11:
|
|
3712
|
-
products =
|
|
3713
|
-
|
|
3978
|
+
products = _context32.sent;
|
|
3979
|
+
_context32.next = 14;
|
|
3714
3980
|
return this.loadAvailabilityResources({
|
|
3715
3981
|
timezone: timezoneLabel,
|
|
3716
3982
|
dateRange: dateRange,
|
|
@@ -3722,14 +3988,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3722
3988
|
fallbackResources: options.fallbackResources
|
|
3723
3989
|
});
|
|
3724
3990
|
case 14:
|
|
3725
|
-
loadedResources =
|
|
3991
|
+
loadedResources = _context32.sent;
|
|
3726
3992
|
tempOrder = this.getTempOrder();
|
|
3727
3993
|
exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
|
|
3728
3994
|
injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
|
|
3729
3995
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3730
3996
|
startAt: occupancy.startAt,
|
|
3731
3997
|
endAt: occupancy.endAt,
|
|
3732
|
-
fixedOffsetMinutes:
|
|
3998
|
+
fixedOffsetMinutes: _this8.getAvailabilityRuntimeOffsetMinutes(),
|
|
3733
3999
|
rollOverEnd: false
|
|
3734
4000
|
});
|
|
3735
4001
|
if (!range) return [];
|
|
@@ -3739,7 +4005,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3739
4005
|
})];
|
|
3740
4006
|
});
|
|
3741
4007
|
remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
|
|
3742
|
-
return !
|
|
4008
|
+
return !_this8.occupancyIsExcluded(occupancy, exclusions);
|
|
3743
4009
|
});
|
|
3744
4010
|
cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
|
|
3745
4011
|
preparedAt = this.getAvailabilityRuntimeDateTime();
|
|
@@ -3768,18 +4034,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3768
4034
|
prepareParams: normalizedPrepareParams,
|
|
3769
4035
|
durationCandidateAnchorAt: durationCandidateAnchorAt
|
|
3770
4036
|
});
|
|
3771
|
-
return
|
|
4037
|
+
return _context32.abrupt("return", {
|
|
3772
4038
|
projection: projection,
|
|
3773
4039
|
prepareParams: normalizedPrepareParams,
|
|
3774
4040
|
orderRevision: orderRevision
|
|
3775
4041
|
});
|
|
3776
4042
|
case 26:
|
|
3777
4043
|
case "end":
|
|
3778
|
-
return
|
|
4044
|
+
return _context32.stop();
|
|
3779
4045
|
}
|
|
3780
|
-
},
|
|
4046
|
+
}, _callee32, this);
|
|
3781
4047
|
}));
|
|
3782
|
-
function buildAvailabilityProjectionSnapshot(
|
|
4048
|
+
function buildAvailabilityProjectionSnapshot(_x23) {
|
|
3783
4049
|
return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
|
|
3784
4050
|
}
|
|
3785
4051
|
return buildAvailabilityProjectionSnapshot;
|
|
@@ -3787,10 +4053,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3787
4053
|
}, {
|
|
3788
4054
|
key: "getSharedPreparedAvailabilitySnapshot",
|
|
3789
4055
|
value: function () {
|
|
3790
|
-
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4056
|
+
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3791
4057
|
var lifecycleGeneration, normalizedParams, hasRawInputs, prepareKey, snapshot, existing, promise, _snapshot, current;
|
|
3792
|
-
return _regeneratorRuntime().wrap(function
|
|
3793
|
-
while (1) switch (
|
|
4058
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
4059
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3794
4060
|
case 0:
|
|
3795
4061
|
lifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
3796
4062
|
normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
@@ -3809,15 +4075,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3809
4075
|
}
|
|
3810
4076
|
})) : this.buildAvailabilityPrepareKey(normalizedParams);
|
|
3811
4077
|
if (!hasRawInputs) {
|
|
3812
|
-
|
|
4078
|
+
_context33.next = 11;
|
|
3813
4079
|
break;
|
|
3814
4080
|
}
|
|
3815
|
-
|
|
4081
|
+
_context33.next = 7;
|
|
3816
4082
|
return this.buildAvailabilityProjectionSnapshot(normalizedParams);
|
|
3817
4083
|
case 7:
|
|
3818
|
-
snapshot =
|
|
4084
|
+
snapshot = _context33.sent;
|
|
3819
4085
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
3820
|
-
|
|
4086
|
+
_context33.next = 10;
|
|
3821
4087
|
break;
|
|
3822
4088
|
}
|
|
3823
4089
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -3826,7 +4092,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3826
4092
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
3827
4093
|
});
|
|
3828
4094
|
case 10:
|
|
3829
|
-
return
|
|
4095
|
+
return _context33.abrupt("return", {
|
|
3830
4096
|
prepareKey: prepareKey,
|
|
3831
4097
|
snapshot: snapshot
|
|
3832
4098
|
});
|
|
@@ -3840,13 +4106,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3840
4106
|
promise: promise
|
|
3841
4107
|
});
|
|
3842
4108
|
}
|
|
3843
|
-
|
|
3844
|
-
|
|
4109
|
+
_context33.prev = 14;
|
|
4110
|
+
_context33.next = 17;
|
|
3845
4111
|
return promise;
|
|
3846
4112
|
case 17:
|
|
3847
|
-
_snapshot =
|
|
4113
|
+
_snapshot = _context33.sent;
|
|
3848
4114
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
3849
|
-
|
|
4115
|
+
_context33.next = 20;
|
|
3850
4116
|
break;
|
|
3851
4117
|
}
|
|
3852
4118
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -3855,24 +4121,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3855
4121
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
3856
4122
|
});
|
|
3857
4123
|
case 20:
|
|
3858
|
-
return
|
|
4124
|
+
return _context33.abrupt("return", {
|
|
3859
4125
|
prepareKey: prepareKey,
|
|
3860
4126
|
snapshot: _snapshot
|
|
3861
4127
|
});
|
|
3862
4128
|
case 21:
|
|
3863
|
-
|
|
4129
|
+
_context33.prev = 21;
|
|
3864
4130
|
current = this.availabilityPrepareInFlight.get(prepareKey);
|
|
3865
4131
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
3866
4132
|
this.availabilityPrepareInFlight.delete(prepareKey);
|
|
3867
4133
|
}
|
|
3868
|
-
return
|
|
4134
|
+
return _context33.finish(21);
|
|
3869
4135
|
case 25:
|
|
3870
4136
|
case "end":
|
|
3871
|
-
return
|
|
4137
|
+
return _context33.stop();
|
|
3872
4138
|
}
|
|
3873
|
-
},
|
|
4139
|
+
}, _callee33, this, [[14,, 21, 25]]);
|
|
3874
4140
|
}));
|
|
3875
|
-
function getSharedPreparedAvailabilitySnapshot(
|
|
4141
|
+
function getSharedPreparedAvailabilitySnapshot(_x24) {
|
|
3876
4142
|
return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
|
|
3877
4143
|
}
|
|
3878
4144
|
return getSharedPreparedAvailabilitySnapshot;
|
|
@@ -3880,51 +4146,51 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3880
4146
|
}, {
|
|
3881
4147
|
key: "refreshAvailabilityContextProjection",
|
|
3882
4148
|
value: function () {
|
|
3883
|
-
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3884
|
-
var
|
|
4149
|
+
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
4150
|
+
var _this9 = this;
|
|
3885
4151
|
var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
|
|
3886
|
-
return _regeneratorRuntime().wrap(function
|
|
3887
|
-
while (1) switch (
|
|
4152
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
4153
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3888
4154
|
case 0:
|
|
3889
4155
|
existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
3890
4156
|
if (!existingInFlight) {
|
|
3891
|
-
|
|
4157
|
+
_context35.next = 5;
|
|
3892
4158
|
break;
|
|
3893
4159
|
}
|
|
3894
|
-
|
|
4160
|
+
_context35.next = 4;
|
|
3895
4161
|
return existingInFlight;
|
|
3896
4162
|
case 4:
|
|
3897
|
-
return
|
|
4163
|
+
return _context35.abrupt("return", _context35.sent);
|
|
3898
4164
|
case 5:
|
|
3899
4165
|
context = this.getAvailabilityContextEntry(params.contextId);
|
|
3900
4166
|
expectedVersion = context.activeVersion;
|
|
3901
4167
|
expectedRefreshNonce = context.refreshNonce;
|
|
3902
4168
|
expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
3903
|
-
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4169
|
+
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
3904
4170
|
var snapshot, currentContext, projectionEntry;
|
|
3905
|
-
return _regeneratorRuntime().wrap(function
|
|
3906
|
-
while (1) switch (
|
|
4171
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
4172
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3907
4173
|
case 0:
|
|
3908
|
-
|
|
3909
|
-
return
|
|
4174
|
+
_context34.next = 2;
|
|
4175
|
+
return _this9.buildAvailabilityProjectionSnapshot(_this9.cloneAvailabilityPrepareParams(context.prepareParams), {
|
|
3910
4176
|
durationCandidateAnchorAt: context.durationCandidateAnchorAt
|
|
3911
4177
|
});
|
|
3912
4178
|
case 2:
|
|
3913
|
-
snapshot =
|
|
3914
|
-
currentContext =
|
|
4179
|
+
snapshot = _context34.sent;
|
|
4180
|
+
currentContext = _this9.availabilityContextRegistry.get(params.contextId);
|
|
3915
4181
|
if (currentContext) {
|
|
3916
|
-
|
|
4182
|
+
_context34.next = 6;
|
|
3917
4183
|
break;
|
|
3918
4184
|
}
|
|
3919
|
-
return
|
|
4185
|
+
return _context34.abrupt("return", null);
|
|
3920
4186
|
case 6:
|
|
3921
|
-
if (!(expectedLifecycleGeneration !==
|
|
3922
|
-
|
|
4187
|
+
if (!(expectedLifecycleGeneration !== _this9.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
|
|
4188
|
+
_context34.next = 8;
|
|
3923
4189
|
break;
|
|
3924
4190
|
}
|
|
3925
|
-
return
|
|
4191
|
+
return _context34.abrupt("return", null);
|
|
3926
4192
|
case 8:
|
|
3927
|
-
projectionEntry =
|
|
4193
|
+
projectionEntry = _this9.storeAvailabilityProjectionEntry({
|
|
3928
4194
|
contextId: currentContext.contextId,
|
|
3929
4195
|
prepareParams: snapshot.prepareParams,
|
|
3930
4196
|
prepareKey: currentContext.prepareKey,
|
|
@@ -3932,8 +4198,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3932
4198
|
orderRevision: snapshot.orderRevision,
|
|
3933
4199
|
incrementVersion: true
|
|
3934
4200
|
});
|
|
3935
|
-
|
|
3936
|
-
return
|
|
4201
|
+
_context34.next = 11;
|
|
4202
|
+
return _this9.emitAvailabilityDiagnostic({
|
|
3937
4203
|
action: 'refresh',
|
|
3938
4204
|
contextId: currentContext.contextId,
|
|
3939
4205
|
contextVersion: projectionEntry.contextVersion,
|
|
@@ -3944,33 +4210,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3944
4210
|
reason: params.reason
|
|
3945
4211
|
});
|
|
3946
4212
|
case 11:
|
|
3947
|
-
return
|
|
4213
|
+
return _context34.abrupt("return", projectionEntry);
|
|
3948
4214
|
case 12:
|
|
3949
4215
|
case "end":
|
|
3950
|
-
return
|
|
4216
|
+
return _context34.stop();
|
|
3951
4217
|
}
|
|
3952
|
-
},
|
|
4218
|
+
}, _callee34);
|
|
3953
4219
|
}))();
|
|
3954
4220
|
this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
|
|
3955
|
-
|
|
3956
|
-
|
|
4221
|
+
_context35.prev = 11;
|
|
4222
|
+
_context35.next = 14;
|
|
3957
4223
|
return refreshPromise;
|
|
3958
4224
|
case 14:
|
|
3959
|
-
return
|
|
4225
|
+
return _context35.abrupt("return", _context35.sent);
|
|
3960
4226
|
case 15:
|
|
3961
|
-
|
|
4227
|
+
_context35.prev = 15;
|
|
3962
4228
|
current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
3963
4229
|
if (current === refreshPromise) {
|
|
3964
4230
|
this.availabilityProjectionRefreshInFlight.delete(params.contextId);
|
|
3965
4231
|
}
|
|
3966
|
-
return
|
|
4232
|
+
return _context35.finish(15);
|
|
3967
4233
|
case 19:
|
|
3968
4234
|
case "end":
|
|
3969
|
-
return
|
|
4235
|
+
return _context35.stop();
|
|
3970
4236
|
}
|
|
3971
|
-
},
|
|
4237
|
+
}, _callee35, this, [[11,, 15, 19]]);
|
|
3972
4238
|
}));
|
|
3973
|
-
function refreshAvailabilityContextProjection(
|
|
4239
|
+
function refreshAvailabilityContextProjection(_x25) {
|
|
3974
4240
|
return _refreshAvailabilityContextProjection.apply(this, arguments);
|
|
3975
4241
|
}
|
|
3976
4242
|
return refreshAvailabilityContextProjection;
|
|
@@ -3978,53 +4244,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3978
4244
|
}, {
|
|
3979
4245
|
key: "ensureAvailabilityContextProjection",
|
|
3980
4246
|
value: function () {
|
|
3981
|
-
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4247
|
+
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(contextId, reason) {
|
|
3982
4248
|
var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
|
|
3983
|
-
return _regeneratorRuntime().wrap(function
|
|
3984
|
-
while (1) switch (
|
|
4249
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
4250
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3985
4251
|
case 0:
|
|
3986
4252
|
retries = 0;
|
|
3987
4253
|
case 1:
|
|
3988
4254
|
if (!(retries < 3)) {
|
|
3989
|
-
|
|
4255
|
+
_context36.next = 19;
|
|
3990
4256
|
break;
|
|
3991
4257
|
}
|
|
3992
4258
|
context = this.getAvailabilityContextEntry(contextId);
|
|
3993
4259
|
currentOrderRevision = this.getCurrentOrderRevision();
|
|
3994
4260
|
projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
|
|
3995
4261
|
if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
|
|
3996
|
-
|
|
4262
|
+
_context36.next = 7;
|
|
3997
4263
|
break;
|
|
3998
4264
|
}
|
|
3999
|
-
return
|
|
4265
|
+
return _context36.abrupt("return", {
|
|
4000
4266
|
context: context,
|
|
4001
4267
|
projectionEntry: projectionEntry,
|
|
4002
4268
|
refreshed: false
|
|
4003
4269
|
});
|
|
4004
4270
|
case 7:
|
|
4005
|
-
|
|
4271
|
+
_context36.next = 9;
|
|
4006
4272
|
return this.refreshAvailabilityContextProjection({
|
|
4007
4273
|
contextId: contextId,
|
|
4008
4274
|
reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
|
|
4009
4275
|
previousOrderRevision: context.lastKnownOrderRevision
|
|
4010
4276
|
});
|
|
4011
4277
|
case 9:
|
|
4012
|
-
refreshedProjectionEntry =
|
|
4278
|
+
refreshedProjectionEntry = _context36.sent;
|
|
4013
4279
|
if (refreshedProjectionEntry) {
|
|
4014
|
-
|
|
4280
|
+
_context36.next = 13;
|
|
4015
4281
|
break;
|
|
4016
4282
|
}
|
|
4017
4283
|
retries += 1;
|
|
4018
|
-
return
|
|
4284
|
+
return _context36.abrupt("continue", 1);
|
|
4019
4285
|
case 13:
|
|
4020
4286
|
if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4021
|
-
|
|
4287
|
+
_context36.next = 16;
|
|
4022
4288
|
break;
|
|
4023
4289
|
}
|
|
4024
4290
|
retries += 1;
|
|
4025
|
-
return
|
|
4291
|
+
return _context36.abrupt("continue", 1);
|
|
4026
4292
|
case 16:
|
|
4027
|
-
return
|
|
4293
|
+
return _context36.abrupt("return", {
|
|
4028
4294
|
context: this.getAvailabilityContextEntry(contextId),
|
|
4029
4295
|
projectionEntry: refreshedProjectionEntry,
|
|
4030
4296
|
refreshed: true
|
|
@@ -4036,11 +4302,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4036
4302
|
});
|
|
4037
4303
|
case 20:
|
|
4038
4304
|
case "end":
|
|
4039
|
-
return
|
|
4305
|
+
return _context36.stop();
|
|
4040
4306
|
}
|
|
4041
|
-
},
|
|
4307
|
+
}, _callee36, this);
|
|
4042
4308
|
}));
|
|
4043
|
-
function ensureAvailabilityContextProjection(
|
|
4309
|
+
function ensureAvailabilityContextProjection(_x26, _x27) {
|
|
4044
4310
|
return _ensureAvailabilityContextProjection.apply(this, arguments);
|
|
4045
4311
|
}
|
|
4046
4312
|
return ensureAvailabilityContextProjection;
|
|
@@ -4048,18 +4314,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4048
4314
|
}, {
|
|
4049
4315
|
key: "tryAcquireAvailabilityCommitLock",
|
|
4050
4316
|
value: function () {
|
|
4051
|
-
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4317
|
+
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId) {
|
|
4052
4318
|
var _currentContext$activ;
|
|
4053
4319
|
var _waitingContext$activ, waitingContext, currentContext;
|
|
4054
|
-
return _regeneratorRuntime().wrap(function
|
|
4055
|
-
while (1) switch (
|
|
4320
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
4321
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4056
4322
|
case 0:
|
|
4057
4323
|
if (!this.availabilityCommitLocks.has(contextId)) {
|
|
4058
|
-
|
|
4324
|
+
_context37.next = 5;
|
|
4059
4325
|
break;
|
|
4060
4326
|
}
|
|
4061
4327
|
waitingContext = this.availabilityContextRegistry.get(contextId);
|
|
4062
|
-
|
|
4328
|
+
_context37.next = 4;
|
|
4063
4329
|
return this.emitAvailabilityDiagnostic({
|
|
4064
4330
|
action: 'commit_lock_wait',
|
|
4065
4331
|
contextId: contextId,
|
|
@@ -4076,7 +4342,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4076
4342
|
case 5:
|
|
4077
4343
|
this.availabilityCommitLocks.add(contextId);
|
|
4078
4344
|
currentContext = this.availabilityContextRegistry.get(contextId);
|
|
4079
|
-
|
|
4345
|
+
_context37.next = 9;
|
|
4080
4346
|
return this.emitAvailabilityDiagnostic({
|
|
4081
4347
|
action: 'commit_lock_acquired',
|
|
4082
4348
|
contextId: contextId,
|
|
@@ -4088,11 +4354,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4088
4354
|
});
|
|
4089
4355
|
case 9:
|
|
4090
4356
|
case "end":
|
|
4091
|
-
return
|
|
4357
|
+
return _context37.stop();
|
|
4092
4358
|
}
|
|
4093
|
-
},
|
|
4359
|
+
}, _callee37, this);
|
|
4094
4360
|
}));
|
|
4095
|
-
function tryAcquireAvailabilityCommitLock(
|
|
4361
|
+
function tryAcquireAvailabilityCommitLock(_x28) {
|
|
4096
4362
|
return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
|
|
4097
4363
|
}
|
|
4098
4364
|
return tryAcquireAvailabilityCommitLock;
|
|
@@ -4100,15 +4366,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4100
4366
|
}, {
|
|
4101
4367
|
key: "releaseAvailabilityCommitLock",
|
|
4102
4368
|
value: function () {
|
|
4103
|
-
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4369
|
+
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(contextId) {
|
|
4104
4370
|
var _releasedContext$acti;
|
|
4105
4371
|
var releasedContext;
|
|
4106
|
-
return _regeneratorRuntime().wrap(function
|
|
4107
|
-
while (1) switch (
|
|
4372
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
4373
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4108
4374
|
case 0:
|
|
4109
4375
|
this.availabilityCommitLocks.delete(contextId);
|
|
4110
4376
|
releasedContext = this.availabilityContextRegistry.get(contextId);
|
|
4111
|
-
|
|
4377
|
+
_context38.next = 4;
|
|
4112
4378
|
return this.emitAvailabilityDiagnostic({
|
|
4113
4379
|
action: 'commit_lock_released',
|
|
4114
4380
|
contextId: contextId,
|
|
@@ -4120,11 +4386,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4120
4386
|
});
|
|
4121
4387
|
case 4:
|
|
4122
4388
|
case "end":
|
|
4123
|
-
return
|
|
4389
|
+
return _context38.stop();
|
|
4124
4390
|
}
|
|
4125
|
-
},
|
|
4391
|
+
}, _callee38, this);
|
|
4126
4392
|
}));
|
|
4127
|
-
function releaseAvailabilityCommitLock(
|
|
4393
|
+
function releaseAvailabilityCommitLock(_x29) {
|
|
4128
4394
|
return _releaseAvailabilityCommitLock.apply(this, arguments);
|
|
4129
4395
|
}
|
|
4130
4396
|
return releaseAvailabilityCommitLock;
|
|
@@ -4132,20 +4398,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4132
4398
|
}, {
|
|
4133
4399
|
key: "prepareAvailabilityProjection",
|
|
4134
4400
|
value: (function () {
|
|
4135
|
-
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4401
|
+
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
4136
4402
|
var paramsWithDefaults, _yield$this$getShared, prepareKey, snapshot, contextId, projectionEntry, context, handle, payload;
|
|
4137
|
-
return _regeneratorRuntime().wrap(function
|
|
4138
|
-
while (1) switch (
|
|
4403
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4404
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4139
4405
|
case 0:
|
|
4140
4406
|
this.assertAvailabilityPrepareParams(params);
|
|
4141
|
-
|
|
4407
|
+
_context39.next = 3;
|
|
4142
4408
|
return this.resolveAvailabilityPrepareDefaults(params);
|
|
4143
4409
|
case 3:
|
|
4144
|
-
paramsWithDefaults =
|
|
4145
|
-
|
|
4410
|
+
paramsWithDefaults = _context39.sent;
|
|
4411
|
+
_context39.next = 6;
|
|
4146
4412
|
return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
|
|
4147
4413
|
case 6:
|
|
4148
|
-
_yield$this$getShared =
|
|
4414
|
+
_yield$this$getShared = _context39.sent;
|
|
4149
4415
|
prepareKey = _yield$this$getShared.prepareKey;
|
|
4150
4416
|
snapshot = _yield$this$getShared.snapshot;
|
|
4151
4417
|
contextId = this.createAvailabilityContextId();
|
|
@@ -4166,7 +4432,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4166
4432
|
refreshed: false,
|
|
4167
4433
|
reason: 'prepare'
|
|
4168
4434
|
};
|
|
4169
|
-
|
|
4435
|
+
_context39.next = 16;
|
|
4170
4436
|
return this.emitAvailabilityDiagnostic({
|
|
4171
4437
|
action: 'prepare',
|
|
4172
4438
|
contextId: contextId,
|
|
@@ -4177,17 +4443,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4177
4443
|
reason: 'prepare'
|
|
4178
4444
|
});
|
|
4179
4445
|
case 16:
|
|
4180
|
-
|
|
4446
|
+
_context39.next = 18;
|
|
4181
4447
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
|
|
4182
4448
|
case 18:
|
|
4183
|
-
return
|
|
4449
|
+
return _context39.abrupt("return", handle);
|
|
4184
4450
|
case 19:
|
|
4185
4451
|
case "end":
|
|
4186
|
-
return
|
|
4452
|
+
return _context39.stop();
|
|
4187
4453
|
}
|
|
4188
|
-
},
|
|
4454
|
+
}, _callee39, this);
|
|
4189
4455
|
}));
|
|
4190
|
-
function prepareAvailabilityProjection(
|
|
4456
|
+
function prepareAvailabilityProjection(_x30) {
|
|
4191
4457
|
return _prepareAvailabilityProjection.apply(this, arguments);
|
|
4192
4458
|
}
|
|
4193
4459
|
return prepareAvailabilityProjection;
|
|
@@ -4195,47 +4461,47 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4195
4461
|
}, {
|
|
4196
4462
|
key: "getProductTimeRanges",
|
|
4197
4463
|
value: (function () {
|
|
4198
|
-
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4464
|
+
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(contextId) {
|
|
4199
4465
|
var _this$otherParams$pla,
|
|
4200
|
-
_this$
|
|
4201
|
-
|
|
4466
|
+
_this$otherParams23,
|
|
4467
|
+
_this10 = this;
|
|
4202
4468
|
var request,
|
|
4203
4469
|
_yield$this$ensureAva,
|
|
4204
4470
|
context,
|
|
4205
4471
|
projectionEntry,
|
|
4206
4472
|
contextVersion,
|
|
4207
4473
|
allowOutsideOperatingHoursForRequestedStartTimes,
|
|
4208
|
-
|
|
4209
|
-
return _regeneratorRuntime().wrap(function
|
|
4210
|
-
while (1) switch (
|
|
4474
|
+
_args40 = arguments;
|
|
4475
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4476
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4211
4477
|
case 0:
|
|
4212
|
-
request =
|
|
4213
|
-
|
|
4478
|
+
request = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {};
|
|
4479
|
+
_context40.next = 3;
|
|
4214
4480
|
return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
|
|
4215
4481
|
case 3:
|
|
4216
|
-
_yield$this$ensureAva =
|
|
4482
|
+
_yield$this$ensureAva = _context40.sent;
|
|
4217
4483
|
context = _yield$this$ensureAva.context;
|
|
4218
4484
|
projectionEntry = _yield$this$ensureAva.projectionEntry;
|
|
4219
4485
|
contextVersion = context.activeVersion;
|
|
4220
|
-
allowOutsideOperatingHoursForRequestedStartTimes = String((_this$otherParams$pla = (_this$
|
|
4486
|
+
allowOutsideOperatingHoursForRequestedStartTimes = String((_this$otherParams$pla = (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos' && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
|
|
4221
4487
|
return Array.isArray(startTimes) && startTimes.length > 0;
|
|
4222
4488
|
});
|
|
4223
|
-
return
|
|
4489
|
+
return _context40.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
|
|
4224
4490
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
4225
4491
|
} : {})).map(function (group) {
|
|
4226
4492
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
4227
4493
|
ranges: group.ranges.map(function (candidate) {
|
|
4228
|
-
return
|
|
4494
|
+
return _this10.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
|
|
4229
4495
|
})
|
|
4230
4496
|
});
|
|
4231
4497
|
}));
|
|
4232
4498
|
case 9:
|
|
4233
4499
|
case "end":
|
|
4234
|
-
return
|
|
4500
|
+
return _context40.stop();
|
|
4235
4501
|
}
|
|
4236
|
-
},
|
|
4502
|
+
}, _callee40, this);
|
|
4237
4503
|
}));
|
|
4238
|
-
function getProductTimeRanges(
|
|
4504
|
+
function getProductTimeRanges(_x31) {
|
|
4239
4505
|
return _getProductTimeRanges.apply(this, arguments);
|
|
4240
4506
|
}
|
|
4241
4507
|
return getProductTimeRanges;
|
|
@@ -4243,15 +4509,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4243
4509
|
}, {
|
|
4244
4510
|
key: "queryBookingAvailability",
|
|
4245
4511
|
value: (function () {
|
|
4246
|
-
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4512
|
+
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(contextId, request) {
|
|
4247
4513
|
var _yield$this$ensureAva2, context, projectionEntry, refreshed, result, contextVersion, contextualResult;
|
|
4248
|
-
return _regeneratorRuntime().wrap(function
|
|
4249
|
-
while (1) switch (
|
|
4514
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4515
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4250
4516
|
case 0:
|
|
4251
|
-
|
|
4517
|
+
_context41.next = 2;
|
|
4252
4518
|
return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4253
4519
|
case 2:
|
|
4254
|
-
_yield$this$ensureAva2 =
|
|
4520
|
+
_yield$this$ensureAva2 = _context41.sent;
|
|
4255
4521
|
context = _yield$this$ensureAva2.context;
|
|
4256
4522
|
projectionEntry = _yield$this$ensureAva2.projectionEntry;
|
|
4257
4523
|
refreshed = _yield$this$ensureAva2.refreshed;
|
|
@@ -4283,18 +4549,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4283
4549
|
});
|
|
4284
4550
|
})
|
|
4285
4551
|
}) : result;
|
|
4286
|
-
return
|
|
4552
|
+
return _context41.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
|
|
4287
4553
|
contextId: context.contextId,
|
|
4288
4554
|
contextVersion: contextVersion,
|
|
4289
4555
|
refreshed: refreshed
|
|
4290
4556
|
}));
|
|
4291
4557
|
case 11:
|
|
4292
4558
|
case "end":
|
|
4293
|
-
return
|
|
4559
|
+
return _context41.stop();
|
|
4294
4560
|
}
|
|
4295
|
-
},
|
|
4561
|
+
}, _callee41, this);
|
|
4296
4562
|
}));
|
|
4297
|
-
function queryBookingAvailability(
|
|
4563
|
+
function queryBookingAvailability(_x32, _x33) {
|
|
4298
4564
|
return _queryBookingAvailability.apply(this, arguments);
|
|
4299
4565
|
}
|
|
4300
4566
|
return queryBookingAvailability;
|
|
@@ -4351,9 +4617,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4351
4617
|
}, {
|
|
4352
4618
|
key: "findLinkedBooking",
|
|
4353
4619
|
value: function findLinkedBooking(product) {
|
|
4354
|
-
var
|
|
4620
|
+
var _ref50, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
|
|
4355
4621
|
var productUid = getProductLineUid(product);
|
|
4356
|
-
var bookingUid = String((
|
|
4622
|
+
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 : '');
|
|
4357
4623
|
return (((_this$getTempOrder3 = this.getTempOrder()) === null || _this$getTempOrder3 === void 0 ? void 0 : _this$getTempOrder3.bookings) || []).find(function (booking) {
|
|
4358
4624
|
var _booking$product_uid3;
|
|
4359
4625
|
return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
|
|
@@ -4364,27 +4630,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4364
4630
|
}, {
|
|
4365
4631
|
key: "commitAvailabilitySelection",
|
|
4366
4632
|
value: (function () {
|
|
4367
|
-
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4368
|
-
var normalizedContextId, _params$bookingCount,
|
|
4369
|
-
return _regeneratorRuntime().wrap(function
|
|
4370
|
-
while (1) switch (
|
|
4633
|
+
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(contextId, params) {
|
|
4634
|
+
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$pla2, _this$otherParams24, _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;
|
|
4635
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4636
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4371
4637
|
case 0:
|
|
4372
4638
|
normalizedContextId = String(contextId || '').trim();
|
|
4373
4639
|
if (normalizedContextId) {
|
|
4374
|
-
|
|
4640
|
+
_context42.next = 3;
|
|
4375
4641
|
break;
|
|
4376
4642
|
}
|
|
4377
4643
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
|
|
4378
4644
|
candidate: params.candidate
|
|
4379
4645
|
});
|
|
4380
4646
|
case 3:
|
|
4381
|
-
|
|
4647
|
+
_context42.next = 5;
|
|
4382
4648
|
return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
|
|
4383
4649
|
case 5:
|
|
4384
|
-
|
|
4650
|
+
_context42.prev = 5;
|
|
4385
4651
|
bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
|
|
4386
4652
|
if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
|
|
4387
|
-
|
|
4653
|
+
_context42.next = 9;
|
|
4388
4654
|
break;
|
|
4389
4655
|
}
|
|
4390
4656
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
|
|
@@ -4392,16 +4658,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4392
4658
|
});
|
|
4393
4659
|
case 9:
|
|
4394
4660
|
if (!(params.mode === 'edit' && bookingCount !== 1)) {
|
|
4395
|
-
|
|
4661
|
+
_context42.next = 11;
|
|
4396
4662
|
break;
|
|
4397
4663
|
}
|
|
4398
4664
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
|
|
4399
4665
|
bookingCount: bookingCount
|
|
4400
4666
|
});
|
|
4401
4667
|
case 11:
|
|
4402
|
-
orderProductQuantity = (
|
|
4668
|
+
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;
|
|
4403
4669
|
if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
|
|
4404
|
-
|
|
4670
|
+
_context42.next = 14;
|
|
4405
4671
|
break;
|
|
4406
4672
|
}
|
|
4407
4673
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
|
|
@@ -4411,22 +4677,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4411
4677
|
case 14:
|
|
4412
4678
|
partySize = Number(params.partySize);
|
|
4413
4679
|
if (!(!Number.isInteger(partySize) || partySize <= 0)) {
|
|
4414
|
-
|
|
4680
|
+
_context42.next = 17;
|
|
4415
4681
|
break;
|
|
4416
4682
|
}
|
|
4417
4683
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
|
|
4418
4684
|
partySize: params.partySize
|
|
4419
4685
|
});
|
|
4420
4686
|
case 17:
|
|
4421
|
-
|
|
4687
|
+
_context42.next = 19;
|
|
4422
4688
|
return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
4423
4689
|
case 19:
|
|
4424
|
-
_yield$this$ensureAva3 =
|
|
4690
|
+
_yield$this$ensureAva3 = _context42.sent;
|
|
4425
4691
|
context = _yield$this$ensureAva3.context;
|
|
4426
4692
|
projectionEntry = _yield$this$ensureAva3.projectionEntry;
|
|
4427
4693
|
refreshed = _yield$this$ensureAva3.refreshed;
|
|
4428
4694
|
if (!refreshed) {
|
|
4429
|
-
|
|
4695
|
+
_context42.next = 25;
|
|
4430
4696
|
break;
|
|
4431
4697
|
}
|
|
4432
4698
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -4437,11 +4703,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4437
4703
|
case 25:
|
|
4438
4704
|
boundEditingUids = context.prepareParams.editingProductLineUids || [];
|
|
4439
4705
|
if (!(params.mode === 'edit')) {
|
|
4440
|
-
|
|
4706
|
+
_context42.next = 31;
|
|
4441
4707
|
break;
|
|
4442
4708
|
}
|
|
4443
4709
|
if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
|
|
4444
|
-
|
|
4710
|
+
_context42.next = 29;
|
|
4445
4711
|
break;
|
|
4446
4712
|
}
|
|
4447
4713
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
|
|
@@ -4450,11 +4716,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4450
4716
|
editingProductLineUids: boundEditingUids
|
|
4451
4717
|
});
|
|
4452
4718
|
case 29:
|
|
4453
|
-
|
|
4719
|
+
_context42.next = 33;
|
|
4454
4720
|
break;
|
|
4455
4721
|
case 31:
|
|
4456
4722
|
if (!(boundEditingUids.length > 0)) {
|
|
4457
|
-
|
|
4723
|
+
_context42.next = 33;
|
|
4458
4724
|
break;
|
|
4459
4725
|
}
|
|
4460
4726
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
|
|
@@ -4463,7 +4729,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4463
4729
|
});
|
|
4464
4730
|
case 33:
|
|
4465
4731
|
if (!(projectionEntry.contextVersion !== context.activeVersion)) {
|
|
4466
|
-
|
|
4732
|
+
_context42.next = 35;
|
|
4467
4733
|
break;
|
|
4468
4734
|
}
|
|
4469
4735
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -4473,7 +4739,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4473
4739
|
});
|
|
4474
4740
|
case 35:
|
|
4475
4741
|
if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4476
|
-
|
|
4742
|
+
_context42.next = 37;
|
|
4477
4743
|
break;
|
|
4478
4744
|
}
|
|
4479
4745
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
@@ -4484,7 +4750,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4484
4750
|
});
|
|
4485
4751
|
case 37:
|
|
4486
4752
|
if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
|
|
4487
|
-
|
|
4753
|
+
_context42.next = 39;
|
|
4488
4754
|
break;
|
|
4489
4755
|
}
|
|
4490
4756
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
|
|
@@ -4496,7 +4762,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4496
4762
|
this.assertAvailabilityCandidateFreshness(context, params.candidate);
|
|
4497
4763
|
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;
|
|
4498
4764
|
if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
|
|
4499
|
-
|
|
4765
|
+
_context42.next = 43;
|
|
4500
4766
|
break;
|
|
4501
4767
|
}
|
|
4502
4768
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
|
|
@@ -4505,14 +4771,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4505
4771
|
});
|
|
4506
4772
|
case 43:
|
|
4507
4773
|
if (!(params.mode === 'edit' && !params.productLineUid)) {
|
|
4508
|
-
|
|
4774
|
+
_context42.next = 45;
|
|
4509
4775
|
break;
|
|
4510
4776
|
}
|
|
4511
4777
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
|
|
4512
4778
|
case 45:
|
|
4513
4779
|
editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
|
|
4514
4780
|
if (!(params.mode === 'edit' && !editingLine)) {
|
|
4515
|
-
|
|
4781
|
+
_context42.next = 48;
|
|
4516
4782
|
break;
|
|
4517
4783
|
}
|
|
4518
4784
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
|
|
@@ -4520,7 +4786,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4520
4786
|
});
|
|
4521
4787
|
case 48:
|
|
4522
4788
|
if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
|
|
4523
|
-
|
|
4789
|
+
_context42.next = 50;
|
|
4524
4790
|
break;
|
|
4525
4791
|
}
|
|
4526
4792
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
|
|
@@ -4530,7 +4796,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4530
4796
|
});
|
|
4531
4797
|
case 50:
|
|
4532
4798
|
if (Array.isArray(params.requirementSelections)) {
|
|
4533
|
-
|
|
4799
|
+
_context42.next = 52;
|
|
4534
4800
|
break;
|
|
4535
4801
|
}
|
|
4536
4802
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
|
|
@@ -4547,7 +4813,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4547
4813
|
};
|
|
4548
4814
|
prepareParams = baseProjection.meta.prepareParams;
|
|
4549
4815
|
if (prepareParams) {
|
|
4550
|
-
|
|
4816
|
+
_context42.next = 57;
|
|
4551
4817
|
break;
|
|
4552
4818
|
}
|
|
4553
4819
|
throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
@@ -4559,7 +4825,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4559
4825
|
})),
|
|
4560
4826
|
includesInjectedRawOccupancies: true
|
|
4561
4827
|
};
|
|
4562
|
-
|
|
4828
|
+
_context42.next = 60;
|
|
4563
4829
|
return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
|
|
4564
4830
|
editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
|
|
4565
4831
|
}), {
|
|
@@ -4568,13 +4834,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4568
4834
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
4569
4835
|
});
|
|
4570
4836
|
case 60:
|
|
4571
|
-
commitSnapshot =
|
|
4837
|
+
commitSnapshot = _context42.sent;
|
|
4572
4838
|
refreshedProjection = commitSnapshot.projection;
|
|
4573
4839
|
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 : ''))) {
|
|
4574
|
-
|
|
4840
|
+
_context42.next = 67;
|
|
4575
4841
|
break;
|
|
4576
4842
|
}
|
|
4577
|
-
|
|
4843
|
+
_context42.next = 65;
|
|
4578
4844
|
return this.refreshAvailabilityContextProjection({
|
|
4579
4845
|
contextId: normalizedContextId,
|
|
4580
4846
|
reason: 'commit_order_revision_changed',
|
|
@@ -4595,7 +4861,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4595
4861
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
4596
4862
|
candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
|
|
4597
4863
|
candidateStartTime = getCandidateStartTime(params.candidate);
|
|
4598
|
-
allowPosAvailabilityOverride = String((_this$otherParams$pla2 = (_this$
|
|
4864
|
+
allowPosAvailabilityOverride = String((_this$otherParams$pla2 = (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
|
|
4599
4865
|
refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
|
|
4600
4866
|
productIds: [params.candidate.productId],
|
|
4601
4867
|
dateRange: {
|
|
@@ -4615,7 +4881,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4615
4881
|
return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
|
|
4616
4882
|
});
|
|
4617
4883
|
if (refreshedCandidateBase) {
|
|
4618
|
-
|
|
4884
|
+
_context42.next = 75;
|
|
4619
4885
|
break;
|
|
4620
4886
|
}
|
|
4621
4887
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
|
|
@@ -4628,7 +4894,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4628
4894
|
return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
|
|
4629
4895
|
});
|
|
4630
4896
|
if (product) {
|
|
4631
|
-
|
|
4897
|
+
_context42.next = 78;
|
|
4632
4898
|
break;
|
|
4633
4899
|
}
|
|
4634
4900
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
|
|
@@ -4662,7 +4928,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4662
4928
|
});
|
|
4663
4929
|
}
|
|
4664
4930
|
if (validation.ok) {
|
|
4665
|
-
|
|
4931
|
+
_context42.next = 83;
|
|
4666
4932
|
break;
|
|
4667
4933
|
}
|
|
4668
4934
|
capacityConflict = validation.conflicts.find(function (conflict) {
|
|
@@ -4685,7 +4951,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4685
4951
|
incrementVersion: true
|
|
4686
4952
|
});
|
|
4687
4953
|
revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
4688
|
-
|
|
4954
|
+
_context42.next = 87;
|
|
4689
4955
|
return this.emitAvailabilityDiagnostic({
|
|
4690
4956
|
action: 'refresh',
|
|
4691
4957
|
contextId: normalizedContextId,
|
|
@@ -4708,7 +4974,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4708
4974
|
existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
|
|
4709
4975
|
existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
|
|
4710
4976
|
if (!(params.mode === 'edit' && !existingBookingUid)) {
|
|
4711
|
-
|
|
4977
|
+
_context42.next = 93;
|
|
4712
4978
|
break;
|
|
4713
4979
|
}
|
|
4714
4980
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
|
|
@@ -4722,15 +4988,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4722
4988
|
product: product,
|
|
4723
4989
|
resources: refreshedProjection.resources,
|
|
4724
4990
|
bookingUid: existingBookingUid || undefined,
|
|
4725
|
-
holder: (
|
|
4726
|
-
holderIds: (
|
|
4991
|
+
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,
|
|
4992
|
+
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
|
|
4727
4993
|
});
|
|
4728
4994
|
transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
|
|
4729
4995
|
num: bookingCount,
|
|
4730
4996
|
quantity: bookingCount
|
|
4731
4997
|
}), 'unified_booking_sales', product);
|
|
4732
4998
|
if (transformed) {
|
|
4733
|
-
|
|
4999
|
+
_context42.next = 98;
|
|
4734
5000
|
break;
|
|
4735
5001
|
}
|
|
4736
5002
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
|
|
@@ -4749,7 +5015,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4749
5015
|
productLineUids = [];
|
|
4750
5016
|
bookingUids = [];
|
|
4751
5017
|
if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
|
|
4752
|
-
|
|
5018
|
+
_context42.next = 117;
|
|
4753
5019
|
break;
|
|
4754
5020
|
}
|
|
4755
5021
|
transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
|
|
@@ -4759,10 +5025,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4759
5025
|
unique_identification_number: params.productLineUid,
|
|
4760
5026
|
booking_uid: existingBookingUid
|
|
4761
5027
|
});
|
|
4762
|
-
|
|
5028
|
+
_context42.next = 111;
|
|
4763
5029
|
return this.updateOrderProduct(_objectSpread(_objectSpread({
|
|
4764
5030
|
product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
|
|
4765
|
-
product_variant_id: (
|
|
5031
|
+
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,
|
|
4766
5032
|
unique_identification_number: params.productLineUid,
|
|
4767
5033
|
updates: transformed,
|
|
4768
5034
|
booking: booking
|
|
@@ -4776,7 +5042,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4776
5042
|
bookingUid = existingBookingUid;
|
|
4777
5043
|
productLineUids = [productLineUid];
|
|
4778
5044
|
bookingUids = [bookingUid];
|
|
4779
|
-
|
|
5045
|
+
_context42.next = 129;
|
|
4780
5046
|
break;
|
|
4781
5047
|
case 117:
|
|
4782
5048
|
beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
|
|
@@ -4785,10 +5051,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4785
5051
|
beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
|
|
4786
5052
|
return getBookingUid(item);
|
|
4787
5053
|
}).filter(Boolean));
|
|
4788
|
-
|
|
4789
|
-
return this.addProductToOrder(transformed, booking)
|
|
5054
|
+
_context42.next = 121;
|
|
5055
|
+
return this.addProductToOrder(transformed, booking, (_params$salesNotes = params.salesNotes) !== null && _params$salesNotes !== void 0 && _params$salesNotes.length ? {
|
|
5056
|
+
salesNotes: params.salesNotes
|
|
5057
|
+
} : undefined);
|
|
4790
5058
|
case 121:
|
|
4791
|
-
products =
|
|
5059
|
+
products = _context42.sent;
|
|
4792
5060
|
addedLines = products.filter(function (line) {
|
|
4793
5061
|
var _line$product_id, _line$metadata;
|
|
4794
5062
|
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));
|
|
@@ -4805,8 +5073,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4805
5073
|
}).filter(Boolean);
|
|
4806
5074
|
if (bookingUids.length === 0) {
|
|
4807
5075
|
bookingUids = addedLines.map(function (line) {
|
|
4808
|
-
var
|
|
4809
|
-
return String((
|
|
5076
|
+
var _ref56, _line$booking_uid, _line$metadata2;
|
|
5077
|
+
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 : '');
|
|
4810
5078
|
}).filter(Boolean);
|
|
4811
5079
|
}
|
|
4812
5080
|
productLineUid = productLineUids[productLineUids.length - 1] || '';
|
|
@@ -4825,23 +5093,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4825
5093
|
productLineUids: productLineUids,
|
|
4826
5094
|
bookingUids: bookingUids
|
|
4827
5095
|
};
|
|
4828
|
-
|
|
5096
|
+
_context42.next = 134;
|
|
4829
5097
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
4830
5098
|
case 134:
|
|
4831
|
-
return
|
|
5099
|
+
return _context42.abrupt("return", result);
|
|
4832
5100
|
case 135:
|
|
4833
|
-
|
|
4834
|
-
|
|
5101
|
+
_context42.prev = 135;
|
|
5102
|
+
_context42.next = 138;
|
|
4835
5103
|
return this.releaseAvailabilityCommitLock(normalizedContextId);
|
|
4836
5104
|
case 138:
|
|
4837
|
-
return
|
|
5105
|
+
return _context42.finish(135);
|
|
4838
5106
|
case 139:
|
|
4839
5107
|
case "end":
|
|
4840
|
-
return
|
|
5108
|
+
return _context42.stop();
|
|
4841
5109
|
}
|
|
4842
|
-
},
|
|
5110
|
+
}, _callee42, this, [[5,, 135, 139]]);
|
|
4843
5111
|
}));
|
|
4844
|
-
function commitAvailabilitySelection(
|
|
5112
|
+
function commitAvailabilitySelection(_x34, _x35) {
|
|
4845
5113
|
return _commitAvailabilitySelection.apply(this, arguments);
|
|
4846
5114
|
}
|
|
4847
5115
|
return commitAvailabilitySelection;
|