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