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