@pisell/private-materials 6.12.197 → 6.12.198
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +18 -18
- package/build/lowcode/view.js +18 -18
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +1 -0
- package/es/components/bigSale/components/TimeBar/index.js +1 -0
- package/es/components/bigSale/dialog.js +1 -0
- package/es/components/bigSale/hooks/useBigSaleContext.js +1 -0
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +1 -0
- package/es/components/bigSale/hooks/useSyncBigSaleCartToCds.js +46 -17
- package/es/components/bigSale/index.js +1 -0
- package/es/components/bigSale/templates/Kiosk/index.js +1 -0
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.js +5 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/index.js +9 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/components/SelectDate/index.js +3 -1
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/index.d.ts +5 -0
- package/es/components/eventBooking/components/bookingAvailabilityCalendar/index.js +2 -1
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +1 -0
- package/es/index.js +2 -0
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/data/reservationDataUtils.js +2 -8
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/pisellReservation/index.js +17 -0
- package/es/plus/pisellSaleSummaryDetail/index.js +2 -1
- package/es/plus/saleDetail/Base.js +1 -0
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +1 -0
- package/es/plus/saleDetail/components/DetailActions/index.js +1 -0
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +7 -3
- package/es/plus/saleDetail/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/components/Pay/index.js +2 -1
- package/es/plus/saleDetail/tmpl/B/index.js +1 -0
- package/es/plus/saleDetail/utils/paymentStatus.js +15 -0
- package/es/plus/salesSdk/index.js +52 -0
- package/es/plus/salesSdk/normalProductDetail/NormalProductDetailHostRenderer.js +105 -45
- package/es/plus/salesSdk/normalProductDetail/availabilityContextRouting.js +29 -0
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +2 -1
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/es/pro/skuDetailModal/flow/modules/date/availabilityWindow.js +71 -0
- package/es/pro/skuDetailModal/flow/modules/date/index.js +24 -9
- package/es/pro/skuDetailModal/flow/modules/time/index.js +36 -17
- package/es/pro/skuDetailModal/flow/modules/time/posCustomTime.js +10 -24
- package/es/pro/skuDetailModal/flow/posAutoResolution.js +3 -1
- package/es/pro/skuDetailModal/flow/registry.d.ts +2 -2
- package/es/pro/skuDetailModal/flow/types.d.ts +8 -0
- package/es/pro/skuDetailModal/index.js +50 -12
- package/lib/components/bigSale/hooks/useSyncBigSaleCartToCds.js +46 -17
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/CalenDateWeek/index.js +5 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/CalendarDate/index.js +9 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/components/SelectDate/index.js +3 -1
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/index.d.ts +5 -0
- package/lib/components/eventBooking/components/bookingAvailabilityCalendar/index.js +2 -1
- package/lib/plus/pisellReservation/data/reservationDataUtils.js +2 -8
- package/lib/plus/pisellSaleSummaryDetail/index.js +2 -1
- package/lib/plus/saleDetail/components/SummaryFinancialSections/index.js +6 -3
- package/lib/plus/saleDetail/tmpl/B/components/Pay/index.js +2 -1
- package/lib/plus/saleDetail/utils/paymentStatus.js +15 -0
- package/lib/plus/salesSdk/normalProductDetail/NormalProductDetailHostRenderer.js +105 -45
- package/lib/plus/salesSdk/normalProductDetail/availabilityContextRouting.js +32 -0
- package/lib/pro/skuDetailModal/flow/modules/date/availabilityWindow.js +74 -0
- package/lib/pro/skuDetailModal/flow/modules/date/index.js +24 -9
- package/lib/pro/skuDetailModal/flow/modules/time/index.js +39 -20
- package/lib/pro/skuDetailModal/flow/modules/time/posCustomTime.js +11 -24
- package/lib/pro/skuDetailModal/flow/posAutoResolution.js +4 -0
- package/lib/pro/skuDetailModal/flow/registry.d.ts +2 -2
- package/lib/pro/skuDetailModal/flow/types.d.ts +8 -0
- package/lib/pro/skuDetailModal/index.js +49 -11
- package/package.json +2 -2
- package/es/private-materials/lowcode/authmodal/meta.d.ts +0 -1
|
@@ -20,6 +20,7 @@ import { prepareNormalProductEditCacheItem, transformNormalProductCreateConfirm
|
|
|
20
20
|
import { assertBookingEditQuantityUnchanged, buildAvailabilityCommitParams, normalizeAvailabilityOrderProductForCommit, resolveBookingCommitCount, resolveBookingEditRepriceFlags } from "./resolveBookingCommitCount.js";
|
|
21
21
|
import { buildInitialBookingSelectionPriceSnapshot, buildInitialBookingSelectionProductData, createBookingSelectionPriceService, resolveConfiguredBookingSelectionPricingDuration } from "./bookingSelectionPrice.js";
|
|
22
22
|
import { buildBookingSelectionCacheItem } from "./buildBookingSelectionCacheItem.js";
|
|
23
|
+
import { availabilityDateRangeContains, resolveAvailabilityRequestContextId } from "./availabilityContextRouting.js";
|
|
23
24
|
import dayjs from "dayjs";
|
|
24
25
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
25
26
|
import { locales } from "@pisell/utils";
|
|
@@ -115,11 +116,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
115
116
|
tempOrderRef.current = tempOrder;
|
|
116
117
|
const handledDismissRevisionRef = useRef(dismissRevision);
|
|
117
118
|
const availabilityContextIdRef = useRef(null);
|
|
119
|
+
const availabilityContextsRef = useRef(/* @__PURE__ */ new Map());
|
|
118
120
|
const releaseAvailabilityContext = useMemoizedFn(() => {
|
|
119
|
-
const
|
|
120
|
-
if (!contextId) return;
|
|
121
|
+
const contextIds = Array.from(availabilityContextsRef.current.keys());
|
|
121
122
|
availabilityContextIdRef.current = null;
|
|
122
|
-
|
|
123
|
+
availabilityContextsRef.current.clear();
|
|
124
|
+
contextIds.forEach((contextId) => {
|
|
125
|
+
salesModule.releaseAvailabilityContext(contextId);
|
|
126
|
+
});
|
|
123
127
|
});
|
|
124
128
|
const commitAvailabilitySelection = useMemoizedFn(function() {
|
|
125
129
|
var _ref2 = _asyncToGenerator(function* (orderProduct, selection, commit) {
|
|
@@ -214,7 +218,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
214
218
|
activePendingRef.current = null;
|
|
215
219
|
};
|
|
216
220
|
(function() {
|
|
217
|
-
var
|
|
221
|
+
var _ref19 = _asyncToGenerator(function* () {
|
|
218
222
|
var _bookingTicket$getBoo3, _bookingTicket$getBoo4;
|
|
219
223
|
const payload = capturedPending.payload;
|
|
220
224
|
const deferHolderUntilSubmit = payload.mode === "create" ? payload.requiresDetailPayload.deferHolderUntilSubmit === true : payload.mode === "booking-create" ? payload.requiresBookingEditPayload.deferHolderUntilSubmit === true : false;
|
|
@@ -250,12 +254,25 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
250
254
|
const prepareAvailability = (productId, date, editingProductLineUids) => {
|
|
251
255
|
const numericProductId = Number(productId);
|
|
252
256
|
if (!Number.isFinite(numericProductId)) throw new Error("预约商品缺少有效 product id。");
|
|
257
|
+
const initialScheduleDate = dayjs(date).format("YYYY-MM-DD");
|
|
258
|
+
const initialDateRange = {
|
|
259
|
+
startDate: initialScheduleDate,
|
|
260
|
+
endDate: dayjs(initialScheduleDate).add(31, "day").format("YYYY-MM-DD")
|
|
261
|
+
};
|
|
253
262
|
let availabilityReady;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
263
|
+
let dateAvailabilityContextId = null;
|
|
264
|
+
let latestDateRangeRequestId = 0;
|
|
265
|
+
const dateRangePrepareTasks = /* @__PURE__ */ new Map();
|
|
266
|
+
const getRegisteredContexts = () => Array.from(availabilityContextsRef.current.values());
|
|
267
|
+
const prepareDateRange = (dateRange) => {
|
|
268
|
+
const coveringContext = [...getRegisteredContexts()].reverse().find((item) => availabilityDateRangeContains(item.dateRange, dateRange));
|
|
269
|
+
if (coveringContext) return Promise.resolve(coveringContext.contextId);
|
|
270
|
+
const rangeKey = `${dateRange.startDate}:${dateRange.endDate}`;
|
|
271
|
+
const pendingRange = dateRangePrepareTasks.get(rangeKey);
|
|
272
|
+
if (pendingRange) return pendingRange;
|
|
273
|
+
const task = _asyncToGenerator(function* () {
|
|
257
274
|
var _getProductCatalog;
|
|
258
|
-
const scheduleDate =
|
|
275
|
+
const scheduleDate = dateRange.startDate;
|
|
259
276
|
const availabilityProduct = yield salesModule.queryProductDetail({
|
|
260
277
|
product_id: numericProductId,
|
|
261
278
|
schedule_date: scheduleDate,
|
|
@@ -269,35 +286,78 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
269
286
|
catalogWithAvailabilityProduct.push(availabilityProduct);
|
|
270
287
|
const prepared = yield salesModule.prepareAvailabilityProjection(_objectSpread2({
|
|
271
288
|
productIds: [numericProductId],
|
|
289
|
+
dateRange,
|
|
272
290
|
rawProducts: catalogWithAvailabilityProduct
|
|
273
291
|
}, (editingProductLineUids === null || editingProductLineUids === void 0 ? void 0 : editingProductLineUids.length) ? { editingProductLineUids } : {}));
|
|
274
292
|
if (!isCurrentPending()) {
|
|
275
293
|
salesModule.releaseAvailabilityContext(prepared.contextId);
|
|
276
294
|
throw new Error("预约商品选择已取消。");
|
|
277
295
|
}
|
|
278
|
-
|
|
296
|
+
availabilityContextsRef.current.set(prepared.contextId, {
|
|
297
|
+
contextId: prepared.contextId,
|
|
298
|
+
dateRange
|
|
299
|
+
});
|
|
279
300
|
return prepared.contextId;
|
|
280
301
|
})();
|
|
302
|
+
dateRangePrepareTasks.set(rangeKey, task);
|
|
303
|
+
task.finally(() => {
|
|
304
|
+
if (dateRangePrepareTasks.get(rangeKey) === task) dateRangePrepareTasks.delete(rangeKey);
|
|
305
|
+
}).catch(() => void 0);
|
|
306
|
+
return task;
|
|
307
|
+
};
|
|
308
|
+
const getAvailabilityReady = () => {
|
|
309
|
+
if (availabilityReady) return availabilityReady;
|
|
310
|
+
availabilityReady = prepareDateRange(initialDateRange).then((contextId) => {
|
|
311
|
+
dateAvailabilityContextId = contextId;
|
|
312
|
+
availabilityContextIdRef.current = contextId;
|
|
313
|
+
return contextId;
|
|
314
|
+
});
|
|
281
315
|
availabilityReady.catch((error) => {
|
|
282
316
|
if (isCurrentPending()) console.warn("[SalesSdk] Availability context 初始化失败", error);
|
|
283
317
|
});
|
|
284
318
|
return availabilityReady;
|
|
285
319
|
};
|
|
320
|
+
const ensureDateRange = function() {
|
|
321
|
+
var _ref4 = _asyncToGenerator(function* (dateRange) {
|
|
322
|
+
yield getAvailabilityReady();
|
|
323
|
+
const requestId = ++latestDateRangeRequestId;
|
|
324
|
+
const contextId = yield prepareDateRange(dateRange);
|
|
325
|
+
if (!isCurrentPending()) throw new Error("预约商品选择已取消。");
|
|
326
|
+
if (requestId === latestDateRangeRequestId) dateAvailabilityContextId = contextId;
|
|
327
|
+
});
|
|
328
|
+
return function ensureDateRange(_x6) {
|
|
329
|
+
return _ref4.apply(this, arguments);
|
|
330
|
+
};
|
|
331
|
+
}();
|
|
332
|
+
const resolveContextId = function() {
|
|
333
|
+
var _ref5 = _asyncToGenerator(function* (request, target) {
|
|
334
|
+
const initialContextId = yield getAvailabilityReady();
|
|
335
|
+
if (target === "date") return dateAvailabilityContextId || initialContextId;
|
|
336
|
+
const contextId = resolveAvailabilityRequestContextId(getRegisteredContexts(), request, dateAvailabilityContextId || initialContextId) || initialContextId;
|
|
337
|
+
availabilityContextIdRef.current = contextId;
|
|
338
|
+
return contextId;
|
|
339
|
+
});
|
|
340
|
+
return function resolveContextId(_x7, _x8) {
|
|
341
|
+
return _ref5.apply(this, arguments);
|
|
342
|
+
};
|
|
343
|
+
}();
|
|
286
344
|
let availabilityQuerySequence = 0;
|
|
287
345
|
selectionFlowServices = _objectSpread2(_objectSpread2({}, selectionFlowServices), {}, { availability: {
|
|
288
346
|
contextId: `pending:${numericProductId}`,
|
|
289
347
|
productId,
|
|
290
348
|
partySize: 1,
|
|
349
|
+
ensureDateRange,
|
|
291
350
|
getProductTimeRanges: function() {
|
|
292
|
-
var
|
|
293
|
-
|
|
351
|
+
var _ref6 = _asyncToGenerator(function* (_contextId, request) {
|
|
352
|
+
const contextId = yield resolveContextId(request);
|
|
353
|
+
return salesModule.getProductTimeRanges(contextId, request);
|
|
294
354
|
});
|
|
295
|
-
return function getProductTimeRanges(
|
|
296
|
-
return
|
|
355
|
+
return function getProductTimeRanges(_x9, _x10) {
|
|
356
|
+
return _ref6.apply(this, arguments);
|
|
297
357
|
};
|
|
298
358
|
}(),
|
|
299
359
|
queryBookingAvailability: function() {
|
|
300
|
-
var
|
|
360
|
+
var _ref7 = _asyncToGenerator(function* (_contextId, request) {
|
|
301
361
|
availabilityQuerySequence += 1;
|
|
302
362
|
const callId = `${numericProductId}-${availabilityQuerySequence}`;
|
|
303
363
|
console.info("[SelectionFlowAvailability][queryBookingAvailability][input]", {
|
|
@@ -306,7 +366,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
306
366
|
request
|
|
307
367
|
});
|
|
308
368
|
try {
|
|
309
|
-
const contextId = yield
|
|
369
|
+
const contextId = yield resolveContextId(request, request.target);
|
|
310
370
|
const result = yield salesModule.queryBookingAvailability(contextId, request);
|
|
311
371
|
console.info("[SelectionFlowAvailability][queryBookingAvailability][output]", {
|
|
312
372
|
callId,
|
|
@@ -325,14 +385,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
325
385
|
throw error;
|
|
326
386
|
}
|
|
327
387
|
});
|
|
328
|
-
return function queryBookingAvailability(
|
|
329
|
-
return
|
|
388
|
+
return function queryBookingAvailability(_x11, _x12) {
|
|
389
|
+
return _ref7.apply(this, arguments);
|
|
330
390
|
};
|
|
331
391
|
}()
|
|
332
392
|
} });
|
|
333
393
|
};
|
|
334
394
|
const refreshHolderContextFromHydratedProduct = function() {
|
|
335
|
-
var
|
|
395
|
+
var _ref8 = _asyncToGenerator(function* ({ productData }) {
|
|
336
396
|
holderSource = productData;
|
|
337
397
|
if (deferHolderUntilSubmit) holderOptions = getHolderOptionsForSource(productData);
|
|
338
398
|
else try {
|
|
@@ -362,14 +422,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
362
422
|
holderSource: productData
|
|
363
423
|
});
|
|
364
424
|
});
|
|
365
|
-
return function refreshHolderContextFromHydratedProduct(
|
|
366
|
-
return
|
|
425
|
+
return function refreshHolderContextFromHydratedProduct(_x13) {
|
|
426
|
+
return _ref8.apply(this, arguments);
|
|
367
427
|
};
|
|
368
428
|
}();
|
|
369
429
|
if (payload.mode === "create") {
|
|
370
|
-
var
|
|
430
|
+
var _ref9, _detailPayload$produc;
|
|
371
431
|
const detailPayload = payload.requiresDetailPayload;
|
|
372
|
-
const item = normalizeCatalogProduct((
|
|
432
|
+
const item = normalizeCatalogProduct((_ref9 = (_detailPayload$produc = detailPayload.productData) !== null && _detailPayload$produc !== void 0 ? _detailPayload$produc : detailPayload.item) !== null && _ref9 !== void 0 ? _ref9 : {});
|
|
373
433
|
const detailProductData = _objectSpread2(_objectSpread2({}, item), {}, { is_eject: detailPayload.isEject });
|
|
374
434
|
const productId = resolveCatalogProductId(item);
|
|
375
435
|
const rawDate = detailPayload.date;
|
|
@@ -381,26 +441,26 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
381
441
|
const liveTempOrder = (_bookingTicket$getTem = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getTem2 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem2 === void 0 ? void 0 : _bookingTicket$getTem2.call(bookingTicket)) !== null && _bookingTicket$getTem !== void 0 ? _bookingTicket$getTem : tempOrderRef.current;
|
|
382
442
|
if (usesUnifiedBookingSales) {
|
|
383
443
|
if (!bookingConfig && typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.initBookingContext) === "function") {
|
|
384
|
-
var
|
|
444
|
+
var _ref10, _result$bookingConfig, _bookingTicket$getBoo5;
|
|
385
445
|
const bookingIds = collectBookingIdsFromTempOrder(liveTempOrder);
|
|
386
446
|
const result = yield bookingTicket.initBookingContext(buildInitBookingContextParams(bookingConfigParams, {
|
|
387
447
|
date: dayjs(date),
|
|
388
448
|
bookingIds: bookingIds.length ? bookingIds : void 0,
|
|
389
449
|
loadResources: initializeFullBookingContext
|
|
390
450
|
}));
|
|
391
|
-
bookingConfig = (
|
|
451
|
+
bookingConfig = (_ref10 = (_result$bookingConfig = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig !== void 0 ? _result$bookingConfig : (_bookingTicket$getBoo5 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo5 === void 0 ? void 0 : _bookingTicket$getBoo5.call(bookingTicket)) !== null && _ref10 !== void 0 ? _ref10 : null;
|
|
392
452
|
}
|
|
393
453
|
} else if (typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.initBookingContext) !== "function") {
|
|
394
454
|
if (!bookingConfig) throw new Error("当前 SalesSdk 运行时不支持初始化 BookingContext。");
|
|
395
455
|
} else {
|
|
396
|
-
var
|
|
456
|
+
var _ref11, _result$bookingConfig2, _bookingTicket$getBoo6;
|
|
397
457
|
const bookingIds = collectBookingIdsFromTempOrder(liveTempOrder);
|
|
398
458
|
const result = yield bookingTicket.initBookingContext(buildInitBookingContextParams(bookingConfigParams, {
|
|
399
459
|
date: dayjs(date),
|
|
400
460
|
bookingIds: bookingIds.length ? bookingIds : void 0,
|
|
401
461
|
loadResources: true
|
|
402
462
|
}));
|
|
403
|
-
bookingConfig = (
|
|
463
|
+
bookingConfig = (_ref11 = (_result$bookingConfig2 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig2 !== void 0 ? _result$bookingConfig2 : (_bookingTicket$getBoo6 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo6 === void 0 ? void 0 : _bookingTicket$getBoo6.call(bookingTicket)) !== null && _ref11 !== void 0 ? _ref11 : null;
|
|
404
464
|
}
|
|
405
465
|
if (!usesUnifiedBookingSales && !bookingConfig) throw new Error("BookingContext 初始化完成后仍缺少 bookingConfig。");
|
|
406
466
|
const customerId = resolveBookingEditCustomerId(liveTempOrder, detailPayload.customerId, bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getOrd2 = bookingTicket.getOrderCustomerSnapshot) === null || _bookingTicket$getOrd2 === void 0 || (_bookingTicket$getOrd2 = _bookingTicket$getOrd2.call(bookingTicket)) === null || _bookingTicket$getOrd2 === void 0 ? void 0 : _bookingTicket$getOrd2.id);
|
|
@@ -452,14 +512,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
452
512
|
return true;
|
|
453
513
|
} } : {}), {}, { skuDetailConfig });
|
|
454
514
|
} else if (payload.mode === "booking-create" || payload.mode === "booking-edit") {
|
|
455
|
-
var
|
|
515
|
+
var _ref12, _ref13, _ref14, _ref15, _bookingPayload$date, _bookingPayload$cache, _bookingTicket$getTem3, _bookingTicket$getTem4, _bookingTicket$getOrd3, _ref17, _bookingTicket$getRes3, _bookingTicket$getRes4, _initialCacheItem$_da, _ref18, _bookingPayload$catal, _initialCacheItem$_ex, _bookingTicket$getOth3, _initialCacheItem$_ex2;
|
|
456
516
|
const isBookingEdit = payload.mode === "booking-edit";
|
|
457
517
|
const bookingPayload = isBookingEdit ? payload.bookingEditPayload : payload.requiresBookingEditPayload;
|
|
458
518
|
selectionFlowServices = _objectSpread2(_objectSpread2({}, selectionFlowServices), {}, {
|
|
459
519
|
selectionFlowMode: isBookingEdit ? "edit" : "create",
|
|
460
520
|
deferAvailabilityCommit: Boolean(isBookingEdit && bookingPayload.deferCommit)
|
|
461
521
|
});
|
|
462
|
-
const item = normalizeCatalogProduct((
|
|
522
|
+
const item = normalizeCatalogProduct((_ref12 = (_ref13 = (_ref14 = (_ref15 = isBookingEdit ? bookingPayload.catalogProduct : null) !== null && _ref15 !== void 0 ? _ref15 : bookingPayload.catalogProduct) !== null && _ref14 !== void 0 ? _ref14 : bookingPayload.sourceProduct) !== null && _ref13 !== void 0 ? _ref13 : bookingPayload.cacheItem) !== null && _ref12 !== void 0 ? _ref12 : {});
|
|
463
523
|
const skuDetailConfig = mergeSkuDetailConfig(item === null || item === void 0 ? void 0 : item.skuDetailConfig, defaultSkuDetailConfig);
|
|
464
524
|
if (!(Array.isArray(skuDetailConfig.steps) || typeof skuDetailConfig.resolveSteps === "function") || getUnsupportedBookingFlowReason(item) && !isMultiDayProduct(item) || !bookingTicket) {
|
|
465
525
|
completeCaptured({ mode: "booking-fallback" });
|
|
@@ -475,13 +535,13 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
475
535
|
const liveTempOrder = (_bookingTicket$getTem3 = (_bookingTicket$getTem4 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem4 === void 0 ? void 0 : _bookingTicket$getTem4.call(bookingTicket)) !== null && _bookingTicket$getTem3 !== void 0 ? _bookingTicket$getTem3 : tempOrderRef.current;
|
|
476
536
|
const bookingIds = collectBookingIdsFromTempOrder(liveTempOrder);
|
|
477
537
|
if (typeof bookingTicket.initBookingContext === "function") {
|
|
478
|
-
var
|
|
538
|
+
var _ref16, _result$bookingConfig3, _bookingTicket$getBoo7;
|
|
479
539
|
const result = yield bookingTicket.initBookingContext(buildInitBookingContextParams(bookingConfigParams, {
|
|
480
540
|
date: dayjs(date),
|
|
481
541
|
bookingIds: bookingIds.length ? bookingIds : void 0,
|
|
482
542
|
loadResources: !usesUnifiedBookingSales || initializeFullBookingContext
|
|
483
543
|
}));
|
|
484
|
-
bookingConfig = (
|
|
544
|
+
bookingConfig = (_ref16 = (_result$bookingConfig3 = result === null || result === void 0 ? void 0 : result.bookingConfig) !== null && _result$bookingConfig3 !== void 0 ? _result$bookingConfig3 : (_bookingTicket$getBoo7 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo7 === void 0 ? void 0 : _bookingTicket$getBoo7.call(bookingTicket)) !== null && _ref16 !== void 0 ? _ref16 : null;
|
|
485
545
|
}
|
|
486
546
|
if (!usesUnifiedBookingSales && !bookingConfig) throw new Error("预约 Selection Flow 初始化后仍缺少 bookingConfig。");
|
|
487
547
|
let initialCacheItem = bookingPayload.cacheItem;
|
|
@@ -493,10 +553,10 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
493
553
|
initialCacheItem = prepareCacheItemForBookingEdit(initialCacheItem);
|
|
494
554
|
if (isBookingEdit && bookingPayload.orderProduct) initialCacheItem = _objectSpread2(_objectSpread2({}, initialCacheItem), {}, { discount_list: Array.isArray(bookingPayload.orderProduct.discount_list) ? [...bookingPayload.orderProduct.discount_list] : [] });
|
|
495
555
|
const customerId = resolveBookingEditCustomerId(liveTempOrder, bookingPayload.customerId, (_bookingTicket$getOrd3 = bookingTicket.getOrderCustomerSnapshot) === null || _bookingTicket$getOrd3 === void 0 || (_bookingTicket$getOrd3 = _bookingTicket$getOrd3.call(bookingTicket)) === null || _bookingTicket$getOrd3 === void 0 ? void 0 : _bookingTicket$getOrd3.id);
|
|
496
|
-
const resourcesOrigin = (
|
|
556
|
+
const resourcesOrigin = (_ref17 = (_bookingTicket$getRes3 = (_bookingTicket$getRes4 = bookingTicket.getResourcesOrigin) === null || _bookingTicket$getRes4 === void 0 ? void 0 : _bookingTicket$getRes4.call(bookingTicket)) !== null && _bookingTicket$getRes3 !== void 0 ? _bookingTicket$getRes3 : initialCacheItem === null || initialCacheItem === void 0 || (_initialCacheItem$_da = initialCacheItem._data) === null || _initialCacheItem$_da === void 0 ? void 0 : _initialCacheItem$_da.resourcesOrigin) !== null && _ref17 !== void 0 ? _ref17 : [];
|
|
497
557
|
initialCacheItem = _objectSpread2(_objectSpread2({}, initialCacheItem), {}, { _data: _objectSpread2(_objectSpread2({}, (initialCacheItem === null || initialCacheItem === void 0 ? void 0 : initialCacheItem._data) || {}), {}, { resourcesOrigin }) });
|
|
498
558
|
bookingInitialCacheItem = initialCacheItem;
|
|
499
|
-
holderSource = (
|
|
559
|
+
holderSource = (_ref18 = (_bookingPayload$catal = bookingPayload.catalogProduct) !== null && _bookingPayload$catal !== void 0 ? _bookingPayload$catal : bookingPayload.sourceProduct) !== null && _ref18 !== void 0 ? _ref18 : initialCacheItem;
|
|
500
560
|
if (usesUnifiedBookingSales) holderOptions = getHolderOptionsForSource(holderSource);
|
|
501
561
|
else try {
|
|
502
562
|
holderOptions = yield ensureHolderOptionsForSource(holderSource);
|
|
@@ -582,7 +642,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
582
642
|
});
|
|
583
643
|
});
|
|
584
644
|
return function prepareOpen() {
|
|
585
|
-
return
|
|
645
|
+
return _ref19.apply(this, arguments);
|
|
586
646
|
};
|
|
587
647
|
})()().catch((error) => {
|
|
588
648
|
if (!isCurrentPending()) return;
|
|
@@ -632,7 +692,7 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
632
692
|
showHostError
|
|
633
693
|
]);
|
|
634
694
|
const handleConfirm = useMemoizedFn(function() {
|
|
635
|
-
var
|
|
695
|
+
var _ref30 = _asyncToGenerator(function* (data) {
|
|
636
696
|
const activePending = activePendingRef.current;
|
|
637
697
|
if (!activePending || bridge.getSnapshot() !== activePending) return false;
|
|
638
698
|
const completeActive = (result) => {
|
|
@@ -643,9 +703,9 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
643
703
|
return true;
|
|
644
704
|
};
|
|
645
705
|
if (activePending.payload.mode === "create") {
|
|
646
|
-
var
|
|
706
|
+
var _ref20, _detailPayload$produc2;
|
|
647
707
|
const detailPayload = activePending.payload.requiresDetailPayload;
|
|
648
|
-
const item = normalizeCatalogProduct((
|
|
708
|
+
const item = normalizeCatalogProduct((_ref20 = (_detailPayload$produc2 = detailPayload.productData) !== null && _detailPayload$produc2 !== void 0 ? _detailPayload$produc2 : detailPayload.item) !== null && _ref20 !== void 0 ? _ref20 : {});
|
|
649
709
|
const productId = resolveCatalogProductId(item);
|
|
650
710
|
if (!productId) {
|
|
651
711
|
console.warn("[SalesSdk] openNormalProductDetail: 商品缺少有效 id/product_id");
|
|
@@ -659,13 +719,13 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
659
719
|
let detailResult = transformNormalProductCreateConfirm(productId, data);
|
|
660
720
|
const holderIds = (_detailResult$detail = detailResult.detail) === null || _detailResult$detail === void 0 || (_detailResult$detail = _detailResult$detail._extend) === null || _detailResult$detail === void 0 ? void 0 : _detailResult$detail.holder_id;
|
|
661
721
|
if (Array.isArray(holderIds) && holderIds.length > 0 && activeBookingState) {
|
|
662
|
-
var _activeBookingState$b, _activeBookingState$c,
|
|
722
|
+
var _activeBookingState$b, _activeBookingState$c, _ref21, _ref22, _ref23;
|
|
663
723
|
detailResult = _objectSpread2(_objectSpread2({}, detailResult), {}, { detail: applyHolderToCacheItem(detailResult.detail, holderIds, {
|
|
664
724
|
bookingConfig: (_activeBookingState$b = activeBookingState.bookingConfig) !== null && _activeBookingState$b !== void 0 ? _activeBookingState$b : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingConfig,
|
|
665
725
|
customerId: (_activeBookingState$c = activeBookingState.client) === null || _activeBookingState$c === void 0 || (_activeBookingState$c = _activeBookingState$c.value) === null || _activeBookingState$c === void 0 ? void 0 : _activeBookingState$c.id,
|
|
666
726
|
isFranchisee: activeBookingState.isFranchisee,
|
|
667
727
|
holderOptions: activeHolderOptions,
|
|
668
|
-
productSource: (
|
|
728
|
+
productSource: (_ref21 = (_ref22 = (_ref23 = data !== null && data !== void 0 ? data : detailResult.detail) !== null && _ref23 !== void 0 ? _ref23 : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref22 !== void 0 ? _ref22 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref21 !== void 0 ? _ref21 : item
|
|
669
729
|
}) });
|
|
670
730
|
}
|
|
671
731
|
const allergyPreparation = yield prepareAllergyBeforeCommit({
|
|
@@ -696,11 +756,11 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
696
756
|
const isBookingEdit = activePending.payload.mode === "booking-edit";
|
|
697
757
|
const bookingPayload = isBookingEdit ? activePending.payload.bookingEditPayload : activePending.payload.requiresBookingEditPayload;
|
|
698
758
|
try {
|
|
699
|
-
var _hydratedContext$book2,
|
|
759
|
+
var _hydratedContext$book2, _ref24, _hydratedContext$hold2, _bookingState$booking, _bookingState$client, _ref25, _ref26, _ref27, _ref28, _cacheItem$_extend3;
|
|
700
760
|
if (isBookingEdit && !bookingPayload.deferCommit) assertBookingEditQuantityUnchanged(data);
|
|
701
761
|
const hydratedContext = (hydratedHolderContext === null || hydratedHolderContext === void 0 ? void 0 : hydratedHolderContext.pending) === activePending ? hydratedHolderContext : null;
|
|
702
762
|
const bookingState = (_hydratedContext$book2 = hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.bookingState) !== null && _hydratedContext$book2 !== void 0 ? _hydratedContext$book2 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingState;
|
|
703
|
-
const holderOptions = (
|
|
763
|
+
const holderOptions = (_ref24 = (_hydratedContext$hold2 = hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderOptions) !== null && _hydratedContext$hold2 !== void 0 ? _hydratedContext$hold2 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderOptions) !== null && _ref24 !== void 0 ? _ref24 : [];
|
|
704
764
|
const cacheItem = buildBookingSelectionCacheItem(data, {
|
|
705
765
|
bookingConfig: (_bookingState$booking = bookingState === null || bookingState === void 0 ? void 0 : bookingState.bookingConfig) !== null && _bookingState$booking !== void 0 ? _bookingState$booking : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.bookingConfig,
|
|
706
766
|
customerId: bookingState === null || bookingState === void 0 || (_bookingState$client = bookingState.client) === null || _bookingState$client === void 0 || (_bookingState$client = _bookingState$client.value) === null || _bookingState$client === void 0 ? void 0 : _bookingState$client.id,
|
|
@@ -708,14 +768,14 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
708
768
|
isPriceIncludeTax: data === null || data === void 0 ? void 0 : data.is_price_include_tax,
|
|
709
769
|
holderOptions,
|
|
710
770
|
initialCacheItem: preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.initialCacheItem,
|
|
711
|
-
productSource: (
|
|
771
|
+
productSource: (_ref25 = (_ref26 = (_ref27 = (_ref28 = data !== null && data !== void 0 ? data : hydratedContext === null || hydratedContext === void 0 ? void 0 : hydratedContext.holderSource) !== null && _ref28 !== void 0 ? _ref28 : preparedOpen === null || preparedOpen === void 0 ? void 0 : preparedOpen.holderSource) !== null && _ref27 !== void 0 ? _ref27 : bookingPayload.catalogProduct) !== null && _ref26 !== void 0 ? _ref26 : bookingPayload.sourceProduct) !== null && _ref25 !== void 0 ? _ref25 : bookingPayload.cacheItem
|
|
712
772
|
});
|
|
713
773
|
cacheItem._holderOptionsSnapshot = holderOptions;
|
|
714
774
|
let allergyNoteDraft;
|
|
715
775
|
if (!isBookingEdit) {
|
|
716
|
-
var
|
|
776
|
+
var _ref29, _bookingPayload$catal2;
|
|
717
777
|
const allergyPreparation = yield prepareAllergyBeforeCommit({
|
|
718
|
-
product: _objectSpread2(_objectSpread2({}, (
|
|
778
|
+
product: _objectSpread2(_objectSpread2({}, (_ref29 = (_bookingPayload$catal2 = bookingPayload.catalogProduct) !== null && _bookingPayload$catal2 !== void 0 ? _bookingPayload$catal2 : bookingPayload.sourceProduct) !== null && _ref29 !== void 0 ? _ref29 : {}), cacheItem),
|
|
719
779
|
flowId: bookingPayload._allergyFlowId
|
|
720
780
|
});
|
|
721
781
|
if (!allergyPreparation.allowed) return false;
|
|
@@ -769,8 +829,8 @@ const NormalProductDetailHostRenderer = ({ defaultSkuDetailConfig }) => {
|
|
|
769
829
|
return false;
|
|
770
830
|
}
|
|
771
831
|
});
|
|
772
|
-
return function(
|
|
773
|
-
return
|
|
832
|
+
return function(_x14) {
|
|
833
|
+
return _ref30.apply(this, arguments);
|
|
774
834
|
};
|
|
775
835
|
}());
|
|
776
836
|
const handleClose = useMemoizedFn(() => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
//#region src/plus/salesSdk/normalProductDetail/availabilityContextRouting.ts
|
|
3
|
+
const normalizeDate = (value) => {
|
|
4
|
+
if (value == null || value === "") return void 0;
|
|
5
|
+
const parsed = dayjs(value);
|
|
6
|
+
return parsed.isValid() ? parsed.format("YYYY-MM-DD") : void 0;
|
|
7
|
+
};
|
|
8
|
+
const availabilityDateRangeContains = (coverage, requested) => !dayjs(requested.startDate).isBefore(dayjs(coverage.startDate), "day") && !dayjs(requested.endDate).isAfter(dayjs(coverage.endDate), "day");
|
|
9
|
+
const resolveAvailabilityRequestContextId = (contexts, request, preferredContextId) => {
|
|
10
|
+
var _rangeCandidates$find, _rawDateRange$endDate, _contexts;
|
|
11
|
+
const candidateContextId = (_rangeCandidates$find = [...Array.isArray(request.candidates) ? request.candidates : [], ...Array.isArray(request.selectedRanges) ? request.selectedRanges : []].find((item) => typeof (item === null || item === void 0 ? void 0 : item.availabilityContextId) === "string")) === null || _rangeCandidates$find === void 0 ? void 0 : _rangeCandidates$find.availabilityContextId;
|
|
12
|
+
if (candidateContextId && contexts.some((item) => item.contextId === candidateContextId)) return candidateContextId;
|
|
13
|
+
const rawDateRange = request.dateRange;
|
|
14
|
+
const startDate = normalizeDate(rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.startDate);
|
|
15
|
+
const endDate = normalizeDate((_rawDateRange$endDate = rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.endDate) !== null && _rawDateRange$endDate !== void 0 ? _rawDateRange$endDate : rawDateRange === null || rawDateRange === void 0 ? void 0 : rawDateRange.startDate);
|
|
16
|
+
if (startDate && endDate) {
|
|
17
|
+
var _reverse$find;
|
|
18
|
+
const requestedRange = {
|
|
19
|
+
startDate,
|
|
20
|
+
endDate
|
|
21
|
+
};
|
|
22
|
+
const preferred = contexts.find((item) => item.contextId === preferredContextId && availabilityDateRangeContains(item.dateRange, requestedRange));
|
|
23
|
+
if (preferred) return preferred.contextId;
|
|
24
|
+
return (_reverse$find = [...contexts].reverse().find((item) => availabilityDateRangeContains(item.dateRange, requestedRange))) === null || _reverse$find === void 0 ? void 0 : _reverse$find.contextId;
|
|
25
|
+
}
|
|
26
|
+
return contexts.some((item) => item.contextId === preferredContextId) ? preferredContextId || void 0 : (_contexts = contexts[contexts.length - 1]) === null || _contexts === void 0 ? void 0 : _contexts.contextId;
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { availabilityDateRangeContains, resolveAvailabilityRequestContextId };
|
|
@@ -31,4 +31,4 @@ function subscribeBookingDateChange(bookingTicket, callback) {
|
|
|
31
31
|
return typeof off === "function" ? off : () => {};
|
|
32
32
|
}
|
|
33
33
|
//#endregion
|
|
34
|
-
export { formatBookingDateTime, subscribeBookingDateChange };
|
|
34
|
+
export { BOOKING_CONTEXT_DATE_EVENT, formatBookingDateTime, subscribeBookingDateChange };
|
|
@@ -59,4 +59,4 @@ function normalizeCustomerAuthCustomer(value) {
|
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
//#endregion
|
|
62
|
-
export { isValidOrderCustomerId, normalizeCustomerAuthCustomer, resolveCustomerAuthCurrentCustomerId, shouldPromptCustomerAuthForProduct };
|
|
62
|
+
export { isHolderRequiredProduct, isValidOrderCustomerId, normalizeCustomerAuthCustomer, resolveCustomerAuthCurrentCustomerId, shouldPromptCustomerAuthForProduct };
|
|
@@ -71,4 +71,4 @@ function buildHolderListRequestKey(params) {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
//#endregion
|
|
74
|
-
export { buildHolderListRequestKey, buildHolderListRequestParams, enrichCartBookingHolderDisplay, resolveHolderDisplayConfig };
|
|
74
|
+
export { buildHolderListRequestKey, buildHolderListRequestParams, enrichCartBookingHolderDisplay, pickHolderIdFromBooking, resolveHolderDisplayConfig };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuthMethodType, EmailAuthConfig, EmailRegistrationVerification, LoginFormData, OAuthConfig, PhoneAuthConfig, RegisterFormData, UIConfig, VerificationMethod } from "./shared/types.js";
|
|
1
2
|
import { Login2, Login2Config, Login2Events, Login2Props } from "./Login2.js";
|
|
2
3
|
import { Register2, Register2Config, Register2Events, Register2Props } from "./Register2.js";
|
|
3
|
-
import { AuthModal
|
|
4
|
+
import { AuthModal } from "./AuthModal.js";
|
|
@@ -226,4 +226,4 @@ interface RegisterFormData {
|
|
|
226
226
|
verification_token?: string;
|
|
227
227
|
}
|
|
228
228
|
//#endregion
|
|
229
|
-
export { AuthMethodType, EmailAuthConfig, LegalTermsConfig, LoginFormData, LoginMethodItem, OAuthConfig, PhoneAuthConfig, RegisterFormData, RegistrationMethodItem, UIConfig };
|
|
229
|
+
export { AuthMethodType, EmailAuthConfig, EmailRegistrationVerification, LegalTermsConfig, LoginFormData, LoginMethodItem, OAuthConfig, PhoneAuthConfig, RegisterFormData, RegistrationMethodItem, UIConfig, VerificationMethod };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
//#region src/pro/skuDetailModal/flow/modules/date/availabilityWindow.ts
|
|
3
|
+
const AVAILABILITY_RANGE_EDGE_DAYS = 7;
|
|
4
|
+
const AVAILABILITY_RANGE_PRELOAD_DAYS = 28;
|
|
5
|
+
const MAX_AVAILABILITY_RANGE_DAYS = 90;
|
|
6
|
+
const normalizeRange = (range) => {
|
|
7
|
+
const start = dayjs(range.startDate);
|
|
8
|
+
const end = dayjs(range.endDate);
|
|
9
|
+
if (!start.isValid() || !end.isValid()) return null;
|
|
10
|
+
return start.isAfter(end, "day") ? {
|
|
11
|
+
startDate: end.format("YYYY-MM-DD"),
|
|
12
|
+
endDate: start.format("YYYY-MM-DD")
|
|
13
|
+
} : {
|
|
14
|
+
startDate: start.format("YYYY-MM-DD"),
|
|
15
|
+
endDate: end.format("YYYY-MM-DD")
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const resolveAvailabilityDatesCoverage = (dates) => {
|
|
19
|
+
const normalizedDates = (dates || []).map((item) => dayjs(item === null || item === void 0 ? void 0 : item.date)).filter((date) => date.isValid()).sort((left, right) => left.valueOf() - right.valueOf());
|
|
20
|
+
if (normalizedDates.length === 0) return null;
|
|
21
|
+
return {
|
|
22
|
+
startDate: normalizedDates[0].format("YYYY-MM-DD"),
|
|
23
|
+
endDate: normalizedDates[normalizedDates.length - 1].format("YYYY-MM-DD")
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const inclusiveDays = (range) => dayjs(range.endDate).diff(dayjs(range.startDate), "day") + 1;
|
|
27
|
+
/**
|
|
28
|
+
* 日历只在接近当前缓存边缘时向外扩展。能与现有覆盖合并且不超过 UBS
|
|
29
|
+
* 90 天上限时优先扩展;跨度更大时围绕用户正在查看的范围移动窗口。
|
|
30
|
+
*/
|
|
31
|
+
const resolveSlidingAvailabilityDateRange = (params) => {
|
|
32
|
+
const visibleRange = normalizeRange(params.visibleRange);
|
|
33
|
+
const coverage = resolveAvailabilityDatesCoverage(params.availabilityDates);
|
|
34
|
+
if (!visibleRange || !coverage) return null;
|
|
35
|
+
const visibleStart = dayjs(visibleRange.startDate);
|
|
36
|
+
const visibleEnd = dayjs(visibleRange.endDate);
|
|
37
|
+
const coverageStart = dayjs(coverage.startDate);
|
|
38
|
+
const coverageEnd = dayjs(coverage.endDate);
|
|
39
|
+
const beforeStart = visibleStart.isBefore(coverageStart, "day");
|
|
40
|
+
const nearEnd = visibleEnd.isAfter(coverageEnd.subtract(AVAILABILITY_RANGE_EDGE_DAYS, "day"), "day");
|
|
41
|
+
if (!beforeStart && !nearEnd) return null;
|
|
42
|
+
const browsingForward = !beforeStart;
|
|
43
|
+
const requestedStart = browsingForward ? coverageStart : visibleStart.subtract(AVAILABILITY_RANGE_PRELOAD_DAYS, "day");
|
|
44
|
+
const requestedEnd = browsingForward ? visibleEnd.add(AVAILABILITY_RANGE_PRELOAD_DAYS, "day") : coverageEnd;
|
|
45
|
+
const mergedRange = normalizeRange({
|
|
46
|
+
startDate: requestedStart.format("YYYY-MM-DD"),
|
|
47
|
+
endDate: requestedEnd.format("YYYY-MM-DD")
|
|
48
|
+
});
|
|
49
|
+
if (inclusiveDays(mergedRange) <= MAX_AVAILABILITY_RANGE_DAYS) return mergedRange;
|
|
50
|
+
if (browsingForward) {
|
|
51
|
+
const endDate = requestedEnd;
|
|
52
|
+
return {
|
|
53
|
+
startDate: endDate.subtract(MAX_AVAILABILITY_RANGE_DAYS - 1, "day").format("YYYY-MM-DD"),
|
|
54
|
+
endDate: endDate.format("YYYY-MM-DD")
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const startDate = requestedStart;
|
|
58
|
+
return {
|
|
59
|
+
startDate: startDate.format("YYYY-MM-DD"),
|
|
60
|
+
endDate: startDate.add(MAX_AVAILABILITY_RANGE_DAYS - 1, "day").format("YYYY-MM-DD")
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const mergeAvailabilityDates = (previousDates, nextDates) => {
|
|
64
|
+
const byDate = /* @__PURE__ */ new Map();
|
|
65
|
+
[...previousDates || [], ...nextDates].forEach((item) => {
|
|
66
|
+
if (typeof (item === null || item === void 0 ? void 0 : item.date) === "string" && dayjs(item.date).isValid()) byDate.set(item.date, item);
|
|
67
|
+
});
|
|
68
|
+
return Array.from(byDate.values()).sort((left, right) => dayjs(left.date).valueOf() - dayjs(right.date).valueOf());
|
|
69
|
+
};
|
|
70
|
+
//#endregion
|
|
71
|
+
export { mergeAvailabilityDates, resolveSlidingAvailabilityDateRange };
|