@pisell/private-materials 6.12.160 → 6.12.162
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/preview.js +1 -1
- package/build/lowcode/render/default/view.js +18 -18
- package/build/lowcode/view.js +18 -18
- package/es/components/bigSale/components/ProductList/index.js +30 -19
- package/es/components/bigSale/index.js +3 -3
- package/es/plus/saleDetail/components/CartItems/Editable/index.js +1 -0
- package/es/plus/salesSdk/context/SalesSdkCartContext.js +25 -12
- package/es/plus/salesSdk/context/SalesSdkProvider.js +9 -5
- package/es/plus/salesSdk/hosts/BookingEditHostRenderer.js +12 -7
- package/es/plus/salesSdk/utils/resolvePreviousService.js +28 -0
- package/es/plus/salesSdk/utils/runAddProductFlow.js +8 -4
- package/es/plus/skuOptionsSelection/components/NormalCard/index.js +18 -12
- package/es/plus/skuOptionsSelection/docs/skuOptionsSelection.$tab-dev.md +66 -2
- package/es/plus/skuOptionsSelection/types.d.ts +50 -1
- package/es/plus/skuOptionsSelection/utils/normalizers.js +17 -0
- package/es/plus/skuOptionsSelection/utils/transformOptionGroup.js +17 -7
- package/es/plus/skuOptionsSelection/utils/transformSelectorValueToValue.js +89 -15
- package/es/plus/skuOptionsSelection/utils/transformValueToSelectorValue.js +31 -19
- package/es/pro/Selector/Selector.js +11 -6
- package/es/pro/Selector/hooks/useSelectionController.js +54 -61
- package/es/pro/Selector/locales.js +10 -0
- package/es/pro/Selector/types.d.ts +5 -0
- package/es/pro/skuDetailModal/index.js +4 -4
- package/es/pro/skuDetailModal/types.d.ts +1 -0
- package/lib/components/bigSale/components/ProductList/index.js +30 -19
- package/lib/components/bigSale/index.js +3 -3
- package/lib/plus/saleDetail/components/CartItems/Editable/index.js +1 -0
- package/lib/plus/salesSdk/context/SalesSdkCartContext.js +25 -12
- package/lib/plus/salesSdk/context/SalesSdkProvider.js +9 -5
- package/lib/plus/salesSdk/hosts/BookingEditHostRenderer.js +12 -7
- package/lib/plus/salesSdk/utils/resolvePreviousService.js +30 -0
- package/lib/plus/salesSdk/utils/runAddProductFlow.js +8 -4
- package/lib/plus/skuOptionsSelection/components/NormalCard/index.js +18 -12
- package/lib/plus/skuOptionsSelection/docs/skuOptionsSelection.$tab-dev.md +66 -2
- package/lib/plus/skuOptionsSelection/types.d.ts +50 -1
- package/lib/plus/skuOptionsSelection/utils/normalizers.js +19 -0
- package/lib/plus/skuOptionsSelection/utils/transformOptionGroup.js +17 -7
- package/lib/plus/skuOptionsSelection/utils/transformSelectorValueToValue.js +89 -15
- package/lib/plus/skuOptionsSelection/utils/transformValueToSelectorValue.js +31 -19
- package/lib/pro/Selector/Selector.js +11 -6
- package/lib/pro/Selector/hooks/useSelectionController.js +54 -61
- package/lib/pro/Selector/locales.js +10 -0
- package/lib/pro/Selector/types.d.ts +5 -0
- package/lib/pro/skuDetailModal/index.js +4 -4
- package/lib/pro/skuDetailModal/types.d.ts +1 -0
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@ import useInitLocalesOnce from "../../../../hooks/useInitLocalesOnce.js";
|
|
|
6
6
|
import ProductCard$1 from "../../../../plus/productSelect/ProductCard/index.js";
|
|
7
7
|
import ProductCardV2 from "../../../../plus/productSelect/ProductCard/ProductCardV2.js";
|
|
8
8
|
import useLocale from "../../../../hooks/useLocale.js";
|
|
9
|
+
import useLogger from "../../../../hooks/useLogger.js";
|
|
9
10
|
import List_default from "../../../list/List.js";
|
|
10
11
|
import { generateProductTabs } from "../../../ticketBooking/components/ProductDisplayAdapter/utils.js";
|
|
11
12
|
import { showAddToCartToast } from "../../../../plus/salesSdk/components/showAddToCartToast.js";
|
|
@@ -133,6 +134,7 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
133
134
|
addToCartToastOptions === null || addToCartToastOptions === void 0 ? void 0 : addToCartToastOptions.duration
|
|
134
135
|
]);
|
|
135
136
|
const locale = useLocale();
|
|
137
|
+
const logger = useLogger();
|
|
136
138
|
const { sales, products, cart } = context;
|
|
137
139
|
const { load } = products;
|
|
138
140
|
const [keyword, setKeyword] = useState("");
|
|
@@ -300,17 +302,26 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
300
302
|
* handleSelectProduct(productItem);
|
|
301
303
|
*/
|
|
302
304
|
const handleSelectProduct = useMemoizedFn(function() {
|
|
303
|
-
var
|
|
305
|
+
var _ref5 = _asyncToGenerator(function* (product) {
|
|
304
306
|
var _ref3, _product$id;
|
|
305
307
|
const handlesKioskToastAfterResult = productCardVersion === "v2" && !usesV2ProductCard;
|
|
306
308
|
const productId = String((_ref3 = (_product$id = product === null || product === void 0 ? void 0 : product.id) !== null && _product$id !== void 0 ? _product$id : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref3 !== void 0 ? _ref3 : "");
|
|
307
309
|
const baselineQuantity = phoneCartProductEntries.filter((entry) => resolvePhoneCartProductId(entry.value) === productId).reduce((total, entry) => total + entry.quantity, 0);
|
|
308
310
|
try {
|
|
309
|
-
var _sales$tempOrder3;
|
|
311
|
+
var _sales$tempOrder3, _logger$addLog, _ref4, _sales$tempOrder$orde, _sales$tempOrder4;
|
|
310
312
|
if (!sales.isReady) return;
|
|
311
313
|
if (requiredOrderId !== void 0 && Number((_sales$tempOrder3 = sales.tempOrder) === null || _sales$tempOrder3 === void 0 ? void 0 : _sales$tempOrder3.order_id) !== Number(requiredOrderId)) return;
|
|
312
314
|
const latestProduct = currentProducts.find((currentProduct) => currentProduct.id === product.id);
|
|
313
315
|
latestProduct && _objectSpread2(_objectSpread2({}, product), {}, { cartDetailValue: latestProduct.cartDetailValue });
|
|
316
|
+
logger === null || logger === void 0 || (_logger$addLog = logger.addLog) === null || _logger$addLog === void 0 || _logger$addLog.call(logger, {
|
|
317
|
+
type: "info",
|
|
318
|
+
title: "[BigSaleProductList] 用户点击商品卡片加入购物车",
|
|
319
|
+
metadata: {
|
|
320
|
+
product_id: productId,
|
|
321
|
+
product_title: resolvePhoneProductTitle(product),
|
|
322
|
+
order_id: (_ref4 = (_sales$tempOrder$orde = (_sales$tempOrder4 = sales.tempOrder) === null || _sales$tempOrder4 === void 0 ? void 0 : _sales$tempOrder4.order_id) !== null && _sales$tempOrder$orde !== void 0 ? _sales$tempOrder$orde : requiredOrderId) !== null && _ref4 !== void 0 ? _ref4 : null
|
|
323
|
+
}
|
|
324
|
+
});
|
|
314
325
|
const result = yield cart.addProductWithFlow(product, {
|
|
315
326
|
quantity: 1,
|
|
316
327
|
notShowToast: handlesKioskToastAfterResult
|
|
@@ -322,7 +333,7 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
322
333
|
}
|
|
323
334
|
});
|
|
324
335
|
return function(_x) {
|
|
325
|
-
return
|
|
336
|
+
return _ref5.apply(this, arguments);
|
|
326
337
|
};
|
|
327
338
|
}());
|
|
328
339
|
const phoneCartProductEntries = useMemo(() => {
|
|
@@ -336,8 +347,8 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
336
347
|
const productUid = resolvePhoneCartLineUid(booking === null || booking === void 0 || (_booking$_extend = booking._extend) === null || _booking$_extend === void 0 ? void 0 : _booking$_extend.product);
|
|
337
348
|
if (productUid) bookingProductUids.add(productUid);
|
|
338
349
|
((booking === null || booking === void 0 || (_booking$_extend2 = booking._extend) === null || _booking$_extend2 === void 0 ? void 0 : _booking$_extend2.mergedFrom) || []).forEach((source) => {
|
|
339
|
-
var
|
|
340
|
-
const sourceUid = (
|
|
350
|
+
var _ref6, _source$booking$produ, _source$booking, _source$booking2;
|
|
351
|
+
const sourceUid = (_ref6 = (_source$booking$produ = source === null || source === void 0 || (_source$booking = source.booking) === null || _source$booking === void 0 ? void 0 : _source$booking.product_uid) !== null && _source$booking$produ !== void 0 ? _source$booking$produ : source === null || source === void 0 || (_source$booking2 = source.booking) === null || _source$booking2 === void 0 || (_source$booking2 = _source$booking2.metadata) === null || _source$booking2 === void 0 ? void 0 : _source$booking2.product_uid) !== null && _ref6 !== void 0 ? _ref6 : resolvePhoneCartLineUid(source === null || source === void 0 ? void 0 : source.product);
|
|
341
352
|
if (sourceUid !== void 0 && sourceUid !== null && sourceUid !== "") bookingProductUids.add(String(sourceUid));
|
|
342
353
|
});
|
|
343
354
|
});
|
|
@@ -351,10 +362,10 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
351
362
|
quantity: resolvePhoneCartEntryQuantity(item)
|
|
352
363
|
}));
|
|
353
364
|
displayBookings.forEach((booking) => {
|
|
354
|
-
var _booking$_extend3,
|
|
365
|
+
var _booking$_extend3, _ref7, _booking$_extend$disp, _booking$_extend4, _product$_extend, _product$product_id;
|
|
355
366
|
const product = booking === null || booking === void 0 || (_booking$_extend3 = booking._extend) === null || _booking$_extend3 === void 0 ? void 0 : _booking$_extend3.product;
|
|
356
367
|
if (!product || (product === null || product === void 0 ? void 0 : product._isGiftPromotion)) return;
|
|
357
|
-
const displayQuantity = (
|
|
368
|
+
const displayQuantity = (_ref7 = (_booking$_extend$disp = booking === null || booking === void 0 || (_booking$_extend4 = booking._extend) === null || _booking$_extend4 === void 0 ? void 0 : _booking$_extend4.displayQuantity) !== null && _booking$_extend$disp !== void 0 ? _booking$_extend$disp : product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.displayQuantity) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.num;
|
|
358
369
|
const displayValue = _objectSpread2(_objectSpread2({}, product), {}, {
|
|
359
370
|
product_id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id,
|
|
360
371
|
num: displayQuantity
|
|
@@ -398,9 +409,9 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
398
409
|
show();
|
|
399
410
|
});
|
|
400
411
|
const addPhoneProductWithToast = useMemoizedFn(function() {
|
|
401
|
-
var
|
|
402
|
-
var
|
|
403
|
-
const productId = String((
|
|
412
|
+
var _ref9 = _asyncToGenerator(function* (product, quantity, type = "select", delayUntilModalClosed = false) {
|
|
413
|
+
var _ref8, _product$id2;
|
|
414
|
+
const productId = String((_ref8 = (_product$id2 = product === null || product === void 0 ? void 0 : product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : "");
|
|
404
415
|
const currentQuantity = phoneCartProductEntries.filter((entry) => resolvePhoneCartProductId(entry.value) === productId).reduce((total, entry) => total + entry.quantity, 0);
|
|
405
416
|
const result = yield cart.addProductWithFlow(product, {
|
|
406
417
|
type,
|
|
@@ -411,7 +422,7 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
411
422
|
return result;
|
|
412
423
|
});
|
|
413
424
|
return function(_x2, _x3) {
|
|
414
|
-
return
|
|
425
|
+
return _ref9.apply(this, arguments);
|
|
415
426
|
};
|
|
416
427
|
}());
|
|
417
428
|
/**
|
|
@@ -422,10 +433,10 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
422
433
|
* 这样不会为了“判断商品类型”预先渲染抽屉,同时保留异常商品数据的兜底能力。
|
|
423
434
|
*/
|
|
424
435
|
const addPhoneQuantityProductWithToast = useMemoizedFn(function() {
|
|
425
|
-
var
|
|
426
|
-
var
|
|
436
|
+
var _ref11 = _asyncToGenerator(function* (product, quantity) {
|
|
437
|
+
var _ref10, _product$id3;
|
|
427
438
|
if (!isNormalProductByDurationSchedule(product)) return addPhoneProductWithToast(product, quantity);
|
|
428
|
-
const productId = String((
|
|
439
|
+
const productId = String((_ref10 = (_product$id3 = product === null || product === void 0 ? void 0 : product.id) !== null && _product$id3 !== void 0 ? _product$id3 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : "");
|
|
429
440
|
const result = yield cart.addProduct(product, {
|
|
430
441
|
type: "select",
|
|
431
442
|
quantity
|
|
@@ -437,11 +448,11 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
437
448
|
return addPhoneProductWithToast(product, quantity);
|
|
438
449
|
});
|
|
439
450
|
return function(_x4, _x5) {
|
|
440
|
-
return
|
|
451
|
+
return _ref11.apply(this, arguments);
|
|
441
452
|
};
|
|
442
453
|
}());
|
|
443
454
|
const handlePhoneProductCardChange = useMemoizedFn(function() {
|
|
444
|
-
var
|
|
455
|
+
var _ref12 = _asyncToGenerator(function* (nextValue, _intent, meta) {
|
|
445
456
|
var _product$id4;
|
|
446
457
|
const product = meta === null || meta === void 0 ? void 0 : meta.product;
|
|
447
458
|
if (!product) return;
|
|
@@ -496,7 +507,7 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
496
507
|
}
|
|
497
508
|
});
|
|
498
509
|
return function(_x6, _x7, _x8) {
|
|
499
|
-
return
|
|
510
|
+
return _ref12.apply(this, arguments);
|
|
500
511
|
};
|
|
501
512
|
}());
|
|
502
513
|
const { data: listData, listProps: configuredListProps, skuCardAllConfig } = productListConfig;
|
|
@@ -671,9 +682,9 @@ const BigSaleProductListInner = ({ isActive = true, osKey, productListPreference
|
|
|
671
682
|
setActiveTab([]);
|
|
672
683
|
});
|
|
673
684
|
const handleKioskSearchClose = useMemoizedFn(() => {
|
|
674
|
-
var
|
|
685
|
+
var _ref13, _kioskSearchCategoryT;
|
|
675
686
|
cancelPendingCategoryTransition();
|
|
676
|
-
const categoryTabBeforeSearch = (
|
|
687
|
+
const categoryTabBeforeSearch = (_ref13 = (_kioskSearchCategoryT = kioskSearchCategoryTabRef.current) !== null && _kioskSearchCategoryT !== void 0 ? _kioskSearchCategoryT : lastCategoryTabRef.current) !== null && _ref13 !== void 0 ? _ref13 : defaultActiveTab;
|
|
677
688
|
kioskSearchCategoryTabRef.current = void 0;
|
|
678
689
|
lastCategoryTabRef.current = categoryTabBeforeSearch;
|
|
679
690
|
setKeyword("");
|
|
@@ -47,7 +47,7 @@ const BigSaleHostRuntimeBridge = ({ runtimeRef }) => {
|
|
|
47
47
|
/**
|
|
48
48
|
* BigSale 入口:只创建 SalesSdkProvider 运行环境,UI 由 ResponsiveBigSaleBase 承载。
|
|
49
49
|
*/
|
|
50
|
-
const BigSale = ({ osKey = DEFAULT_OS_KEY, osModuleName, selectionFlowScene, lifecycleOwner, orderId, autoBootstrap, autoRestoreOnInit, restoreOrderAfterPaidCheckout, destroyOnUnmount, businessCode, bookingConfigParams, otherParams, rulesHooks, uiHosts, normalProductDetailConfig, mergeBookingLinesForDisplay, mode = "ticket", variant, tmpl, template, secondaryScreenDisplay, productLoadParams, productDisplayConfig, hideSelectFloorMapResourceAction, productCatalogSessionKey, productCatalogReady, saleDetailTemplate, saleDetailModuleConfig, autoCreate = true, enableTempOrderPersist, enableTempOrderSync = true, isActive = true, preserveProductCatalogOnInactiveCustomerClear, enableGlobalScanListener = false, promotionScanSuccessMessageKey, promotionItemIncreaseMessageKey, className, style, bootstrapSlot, saleDetailHeaderSlot, rightActionBarClose, overlaySlot, onOrderComplete, externalActionRequest, onExternalActionAccepted, onExternalPaymentSettled }) => {
|
|
50
|
+
const BigSale = ({ osKey = DEFAULT_OS_KEY, osModuleName, selectionFlowScene, lifecycleOwner, orderId, autoBootstrap, autoRestoreOnInit, restoreOrderAfterPaidCheckout, destroyOnUnmount, businessCode, bookingConfigParams, autoInitBookingContext, otherParams, rulesHooks, uiHosts, normalProductDetailConfig, mergeBookingLinesForDisplay, mode = "ticket", variant, tmpl, template, secondaryScreenDisplay, productLoadParams, productDisplayConfig, hideSelectFloorMapResourceAction, productCatalogSessionKey, productCatalogReady, saleDetailTemplate, saleDetailModuleConfig, autoCreate = true, enableTempOrderPersist, enableTempOrderSync = true, isActive = true, preserveProductCatalogOnInactiveCustomerClear, enableGlobalScanListener = false, promotionScanSuccessMessageKey, promotionItemIncreaseMessageKey, className, style, bootstrapSlot, saleDetailHeaderSlot, rightActionBarClose, overlaySlot, onOrderComplete, externalActionRequest, onExternalActionAccepted, onExternalPaymentSettled }) => {
|
|
51
51
|
var _context$appHelper, _context$appHelper2, _context$appHelper3, _ref;
|
|
52
52
|
const context = useEngineContext();
|
|
53
53
|
const action = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.action;
|
|
@@ -72,7 +72,7 @@ const BigSale = ({ osKey = DEFAULT_OS_KEY, osModuleName, selectionFlowScene, lif
|
|
|
72
72
|
return resolvedTemplate === "kiosk" ? _objectSpread2(_objectSpread2({}, selectionFlowConfig), {}, {
|
|
73
73
|
initializeFullBookingContext: false,
|
|
74
74
|
variant: "phone",
|
|
75
|
-
selectorColumns:
|
|
75
|
+
selectorColumns: (selectionFlowConfig === null || selectionFlowConfig === void 0 ? void 0 : selectionFlowConfig.presentationPlatform) === "kiosk" ? 2 : 1,
|
|
76
76
|
isShowProductSummary: true,
|
|
77
77
|
isShowCollapsibleSections: true,
|
|
78
78
|
isShowMobileWeighing: true,
|
|
@@ -129,7 +129,7 @@ const BigSale = ({ osKey = DEFAULT_OS_KEY, osModuleName, selectionFlowScene, lif
|
|
|
129
129
|
restoreOrderAfterPaidCheckout,
|
|
130
130
|
businessCode,
|
|
131
131
|
bookingConfigParams,
|
|
132
|
-
autoInitBookingContext
|
|
132
|
+
autoInitBookingContext,
|
|
133
133
|
otherParams,
|
|
134
134
|
shouldMergeProductLines,
|
|
135
135
|
rulesHooks,
|
|
@@ -107,6 +107,7 @@ function useCartLineRowActions({ item, quantityLoading, cardAction, isShowRightA
|
|
|
107
107
|
text: /* @__PURE__ */ React.createElement(PisellNumberSelector, {
|
|
108
108
|
enablePriceAdjust: true,
|
|
109
109
|
min: 1,
|
|
110
|
+
width: "max-content",
|
|
110
111
|
className: "pisell-sale-detail-cart-items__quantity-selector",
|
|
111
112
|
value: getBookingQuantity(item),
|
|
112
113
|
disabled: quantityLoading,
|
|
@@ -28,6 +28,7 @@ import { formatBookingDateTime } from "../utils/bookingDate.js";
|
|
|
28
28
|
import { assignHolderToCartLine } from "../utils/assignHolderToCartLine.js";
|
|
29
29
|
import { resolveLineByProductUid } from "../utils/holderSubmitValidation.js";
|
|
30
30
|
import { removeOrderProductsByIdentities } from "../utils/removeOrderProducts.js";
|
|
31
|
+
import { resolvePreviousService } from "../utils/resolvePreviousService.js";
|
|
31
32
|
import locales_default from "../../../components/ticketBooking/locales.js";
|
|
32
33
|
import { resolveEditCartLineTarget, shouldEditCartLineAsBooking } from "../utils/editCartLine.js";
|
|
33
34
|
import { resolveBookingLineSources, syncBookingLineQuantityByRows } from "../utils/syncBookingLineQuantityByRows.js";
|
|
@@ -793,6 +794,7 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
793
794
|
const customerId = resolveAddFlowCustomerId(liveTempOrder, void 0, 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);
|
|
794
795
|
return {
|
|
795
796
|
bookingConfig: (_bookingTicket$getBoo5 = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getBoo6 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo6 === void 0 ? void 0 : _bookingTicket$getBoo6.call(bookingTicket)) !== null && _bookingTicket$getBoo5 !== void 0 ? _bookingTicket$getBoo5 : null,
|
|
797
|
+
previousService: resolvePreviousService(liveTempOrder),
|
|
796
798
|
customerId,
|
|
797
799
|
tempOrder: liveTempOrder,
|
|
798
800
|
isFranchisee: Boolean(bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getOth = bookingTicket.getOtherParams) === null || _bookingTicket$getOth === void 0 || (_bookingTicket$getOth = _bookingTicket$getOth.call(bookingTicket)) === null || _bookingTicket$getOth === void 0 ? void 0 : _bookingTicket$getOth.isFranchisee),
|
|
@@ -855,7 +857,7 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
855
857
|
});
|
|
856
858
|
const addProductToOrderFromCacheImpl = useMemoizedFn(function() {
|
|
857
859
|
var _ref9 = _asyncToGenerator(function* (item, cacheItem, options) {
|
|
858
|
-
var _flowCtx$date, _ref8, _cacheItemForTransfor, _cacheItemForTransfor2;
|
|
860
|
+
var _flowCtx$date, _flowCtx$bookingConfi, _ref8, _cacheItemForTransfor, _cacheItemForTransfor2;
|
|
859
861
|
if (!bookingTicket) throw new Error("[SalesSdk] Cart: bookingTicket 未初始化");
|
|
860
862
|
if (typeof bookingTicket.transformDetailToProductAndBooking !== "function") throw new Error("[SalesSdk] Cart: bookingTicket.transformDetailToProductAndBooking 不可用");
|
|
861
863
|
const flowCtx = getAddFlowContext();
|
|
@@ -865,7 +867,9 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
865
867
|
cacheItem: cacheItemForTransform,
|
|
866
868
|
options: {
|
|
867
869
|
quantity: options === null || options === void 0 ? void 0 : options.quantity,
|
|
868
|
-
date: (_flowCtx$date = flowCtx.date) !== null && _flowCtx$date !== void 0 ? _flowCtx$date : void 0
|
|
870
|
+
date: (_flowCtx$date = flowCtx.date) !== null && _flowCtx$date !== void 0 ? _flowCtx$date : void 0,
|
|
871
|
+
bookingConfig: (_flowCtx$bookingConfi = flowCtx.bookingConfig) !== null && _flowCtx$bookingConfi !== void 0 ? _flowCtx$bookingConfi : void 0,
|
|
872
|
+
previousService: flowCtx.previousService
|
|
869
873
|
}
|
|
870
874
|
});
|
|
871
875
|
orderLine.note = (_ref8 = (_cacheItemForTransfor = cacheItemForTransform === null || cacheItemForTransform === void 0 || (_cacheItemForTransfor2 = cacheItemForTransform._extend) === null || _cacheItemForTransfor2 === void 0 ? void 0 : _cacheItemForTransfor2.note) !== null && _cacheItemForTransfor !== void 0 ? _cacheItemForTransfor : orderLine.note) !== null && _ref8 !== void 0 ? _ref8 : "";
|
|
@@ -917,7 +921,7 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
917
921
|
*/
|
|
918
922
|
const addProduct = useMemoizedFn(function() {
|
|
919
923
|
var _ref13 = _asyncToGenerator(function* (product, options) {
|
|
920
|
-
var _flowCtx$date2;
|
|
924
|
+
var _flowCtx$date2, _flowCtx$bookingConfi2;
|
|
921
925
|
if (!bookingTicket) throw new Error("[SalesSdk] Cart: bookingTicket 未初始化");
|
|
922
926
|
if (typeof bookingTicket.decideAddProduct !== "function") throw new Error("[SalesSdk] Cart: bookingTicket.decideAddProduct 不可用,请升级 pisellos");
|
|
923
927
|
const flowCtx = getAddFlowContext();
|
|
@@ -966,7 +970,9 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
966
970
|
type: (options === null || options === void 0 ? void 0 : options.type) || "select",
|
|
967
971
|
quantity: options === null || options === void 0 ? void 0 : options.quantity,
|
|
968
972
|
date: (_flowCtx$date2 = flowCtx.date) !== null && _flowCtx$date2 !== void 0 ? _flowCtx$date2 : void 0,
|
|
969
|
-
customerId: flowCtx.customerId
|
|
973
|
+
customerId: flowCtx.customerId,
|
|
974
|
+
bookingConfig: (_flowCtx$bookingConfi2 = flowCtx.bookingConfig) !== null && _flowCtx$bookingConfi2 !== void 0 ? _flowCtx$bookingConfi2 : void 0,
|
|
975
|
+
previousService: flowCtx.previousService
|
|
970
976
|
});
|
|
971
977
|
if (decision.action === "reloadCatalog") {
|
|
972
978
|
yield reloadProductCatalogForStaleSession();
|
|
@@ -986,14 +992,16 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
986
992
|
};
|
|
987
993
|
}
|
|
988
994
|
if (decision.action === "requiresDetail") {
|
|
989
|
-
var _decision$payload, _bookingTicket$buildR, _flowCtx$date4;
|
|
995
|
+
var _decision$payload, _bookingTicket$buildR, _flowCtx$date4, _flowCtx$bookingConfi3;
|
|
990
996
|
return {
|
|
991
997
|
status: "requiresDetail",
|
|
992
998
|
payload: (_decision$payload = decision.payload) !== null && _decision$payload !== void 0 ? _decision$payload : (_bookingTicket$buildR = bookingTicket.buildRequiresDetailPayload) === null || _bookingTicket$buildR === void 0 ? void 0 : _bookingTicket$buildR.call(bookingTicket, product, {
|
|
993
999
|
type: (options === null || options === void 0 ? void 0 : options.type) || "select",
|
|
994
1000
|
quantity: options === null || options === void 0 ? void 0 : options.quantity,
|
|
995
1001
|
date: (_flowCtx$date4 = flowCtx.date) !== null && _flowCtx$date4 !== void 0 ? _flowCtx$date4 : void 0,
|
|
996
|
-
customerId: flowCtx.customerId
|
|
1002
|
+
customerId: flowCtx.customerId,
|
|
1003
|
+
bookingConfig: (_flowCtx$bookingConfi3 = flowCtx.bookingConfig) !== null && _flowCtx$bookingConfi3 !== void 0 ? _flowCtx$bookingConfi3 : void 0,
|
|
1004
|
+
previousService: flowCtx.previousService
|
|
997
1005
|
})
|
|
998
1006
|
};
|
|
999
1007
|
}
|
|
@@ -1019,7 +1027,7 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
1019
1027
|
*/
|
|
1020
1028
|
const confirmDetail = useMemoizedFn(function() {
|
|
1021
1029
|
var _ref15 = _asyncToGenerator(function* (input) {
|
|
1022
|
-
var _flowCtx$date7, _input$options, _input$options3;
|
|
1030
|
+
var _flowCtx$date7, _flowCtx$bookingConfi4, _input$options, _input$options3;
|
|
1023
1031
|
if (!bookingTicket) throw new Error("[SalesSdk] Cart: bookingTicket 未初始化");
|
|
1024
1032
|
if (typeof bookingTicket.transformDetailToProductAndBooking !== "function") throw new Error("[SalesSdk] Cart: bookingTicket.transformDetailToProductAndBooking 不可用");
|
|
1025
1033
|
const confirmQuantity = resolveConfirmDetailQuantity(input);
|
|
@@ -1030,7 +1038,9 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
1030
1038
|
options: {
|
|
1031
1039
|
quantity: confirmQuantity,
|
|
1032
1040
|
date: (_flowCtx$date7 = flowCtx.date) !== null && _flowCtx$date7 !== void 0 ? _flowCtx$date7 : void 0,
|
|
1033
|
-
customerId: flowCtx.customerId
|
|
1041
|
+
customerId: flowCtx.customerId,
|
|
1042
|
+
bookingConfig: (_flowCtx$bookingConfi4 = flowCtx.bookingConfig) !== null && _flowCtx$bookingConfi4 !== void 0 ? _flowCtx$bookingConfi4 : void 0,
|
|
1043
|
+
previousService: flowCtx.previousService
|
|
1034
1044
|
}
|
|
1035
1045
|
});
|
|
1036
1046
|
const catalogItem = input.item;
|
|
@@ -1038,12 +1048,13 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
1038
1048
|
if ((_input$options = input.options) === null || _input$options === void 0 ? void 0 : _input$options.multiDayRange) cacheItem = patchCacheItemDateRange(cacheItem, input.options.multiDayRange);
|
|
1039
1049
|
else cacheItem = applyDefaultMultiDayRangeIfNeeded(cacheItem, catalogItem, flowCtx.date);
|
|
1040
1050
|
if (typeof bookingTicket.decideAfterDetail === "function") {
|
|
1041
|
-
var _flowCtx$date8, _flowCtx$
|
|
1051
|
+
var _flowCtx$date8, _flowCtx$bookingConfi5, _input$options2;
|
|
1042
1052
|
const decision = bookingTicket.decideAfterDetail(cacheItem, {
|
|
1043
1053
|
quantity: confirmQuantity,
|
|
1044
1054
|
customerId: flowCtx.customerId,
|
|
1045
1055
|
date: (_flowCtx$date8 = flowCtx.date) !== null && _flowCtx$date8 !== void 0 ? _flowCtx$date8 : void 0,
|
|
1046
|
-
bookingConfig: (_flowCtx$
|
|
1056
|
+
bookingConfig: (_flowCtx$bookingConfi5 = flowCtx.bookingConfig) !== null && _flowCtx$bookingConfi5 !== void 0 ? _flowCtx$bookingConfi5 : void 0,
|
|
1057
|
+
previousService: flowCtx.previousService
|
|
1047
1058
|
});
|
|
1048
1059
|
if (decision.action === "requiresBookingEdit") {
|
|
1049
1060
|
var _decision$payload5, _ref14, _flowCtx$date9, _decision$payload6, _flowCtx$customerId2, _decision$payload7;
|
|
@@ -1162,13 +1173,15 @@ const SalesSdkCartProvider = ({ children, shouldMergeProductLines, mergeBookingL
|
|
|
1162
1173
|
};
|
|
1163
1174
|
}(),
|
|
1164
1175
|
decideAddProduct: (product, opts) => {
|
|
1165
|
-
var _flowCtx$date11;
|
|
1176
|
+
var _flowCtx$date11, _flowCtx$bookingConfi6;
|
|
1166
1177
|
const ticket = bookingTicketRef.current;
|
|
1167
1178
|
if (!ticket || typeof ticket.decideAddProduct !== "function") return { action: "requiresDetail" };
|
|
1168
1179
|
const flowCtx = getAddFlowContextRef.current();
|
|
1169
1180
|
return ticket.decideAddProduct(product, _objectSpread2(_objectSpread2({}, opts), {}, {
|
|
1170
1181
|
date: (_flowCtx$date11 = flowCtx.date) !== null && _flowCtx$date11 !== void 0 ? _flowCtx$date11 : void 0,
|
|
1171
|
-
customerId: flowCtx.customerId
|
|
1182
|
+
customerId: flowCtx.customerId,
|
|
1183
|
+
bookingConfig: (_flowCtx$bookingConfi6 = flowCtx.bookingConfig) !== null && _flowCtx$bookingConfi6 !== void 0 ? _flowCtx$bookingConfi6 : void 0,
|
|
1184
|
+
previousService: flowCtx.previousService
|
|
1172
1185
|
}));
|
|
1173
1186
|
},
|
|
1174
1187
|
runAddProductFlow: (product, opts) => runFlowRef.current(product, opts),
|
|
@@ -148,7 +148,7 @@ function runAfterNextPaint(task) {
|
|
|
148
148
|
* - 新建态:按 OS persist 开关走 createNew 或 restore → initBookingContext
|
|
149
149
|
* 须位于 SalesSdkSummaryProvider 内,以便 summaryProviderRef 已通过 useImperativeHandle 注入。
|
|
150
150
|
*/
|
|
151
|
-
function SalesSdkBootstrap({
|
|
151
|
+
function SalesSdkBootstrap({ autoRestoreOnInit, autoBootstrap, autoInitBookingContext, orderId, preloadedSalesDetail, initBookingContext, prepareModule, prepareCatalog, catalogKey, lifecycleOwner }) {
|
|
152
152
|
const sales = useContext(SalesSdkContext);
|
|
153
153
|
const cart = useSalesSdkCart();
|
|
154
154
|
useEffect(() => {
|
|
@@ -182,7 +182,7 @@ function SalesSdkBootstrap({ solution, autoRestoreOnInit, autoBootstrap, autoIni
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
if (cancelled || !autoInitBookingContext
|
|
185
|
+
if (cancelled || !autoInitBookingContext) return;
|
|
186
186
|
const bookingIds = collectBookingIdsFromTempOrder((_sales$bookingTicket$2 = (_sales$bookingTicket2 = sales.bookingTicket) === null || _sales$bookingTicket2 === void 0 || (_sales$bookingTicket3 = _sales$bookingTicket2.getTempOrder) === null || _sales$bookingTicket3 === void 0 ? void 0 : _sales$bookingTicket3.call(_sales$bookingTicket2)) !== null && _sales$bookingTicket$2 !== void 0 ? _sales$bookingTicket$2 : null);
|
|
187
187
|
yield initBookingContext(bookingIds.length ? bookingIds : void 0, { loadResources: !(autoBootstrap && orderId) });
|
|
188
188
|
} catch (e) {
|
|
@@ -209,7 +209,6 @@ function SalesSdkBootstrap({ solution, autoRestoreOnInit, autoBootstrap, autoIni
|
|
|
209
209
|
autoRestoreOnInit,
|
|
210
210
|
autoBootstrap,
|
|
211
211
|
autoInitBookingContext,
|
|
212
|
-
solution,
|
|
213
212
|
orderId,
|
|
214
213
|
preloadedSalesDetail,
|
|
215
214
|
initBookingContext,
|
|
@@ -648,7 +647,13 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
648
647
|
*/
|
|
649
648
|
const initBookingContext = useMemoizedFn(function() {
|
|
650
649
|
var _ref2 = _asyncToGenerator(function* (bookingIds, options) {
|
|
651
|
-
if (!
|
|
650
|
+
if (!bookingTicket) return;
|
|
651
|
+
if (String((otherParams === null || otherParams === void 0 ? void 0 : otherParams.platform) || "").trim().toLowerCase() === "h5") {
|
|
652
|
+
var _bookingTicket$loadBo;
|
|
653
|
+
yield (_bookingTicket$loadBo = bookingTicket.loadBookingConfig) === null || _bookingTicket$loadBo === void 0 ? void 0 : _bookingTicket$loadBo.call(bookingTicket, bookingConfigParams);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
if (!bookingTicket.initBookingContext) return;
|
|
652
657
|
yield bookingTicket.initBookingContext(buildInitBookingContextParams(bookingConfigParams, {
|
|
653
658
|
bookingIds,
|
|
654
659
|
loadResources: options === null || options === void 0 ? void 0 : options.loadResources
|
|
@@ -1340,7 +1345,6 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
1340
1345
|
onPromotionScanComplete: handlePromotionScanComplete,
|
|
1341
1346
|
promotionScanSuccessMessageKey: promotionItemIncreaseMessageKey ? void 0 : promotionScanSuccessMessageKey
|
|
1342
1347
|
}), /* @__PURE__ */ React.createElement(SalesSdkBootstrap, {
|
|
1343
|
-
solution,
|
|
1344
1348
|
autoRestoreOnInit,
|
|
1345
1349
|
autoBootstrap,
|
|
1346
1350
|
autoInitBookingContext,
|
|
@@ -5,6 +5,7 @@ import { buildInitBookingContextParams, collectBookingIdsFromTempOrder } from ".
|
|
|
5
5
|
import { buildBookingEditDrawerState, resolveBookingEditCustomerId } from "../bookingEditService/buildBookingEditDrawerState.js";
|
|
6
6
|
import { resolveIsMultiDayProduct } from "../utils/resolveIsMultiDayProduct.js";
|
|
7
7
|
import { isMultiDayQuotationExpanded } from "../utils/multiDayPriceCache.js";
|
|
8
|
+
import { resolvePreviousService } from "../utils/resolvePreviousService.js";
|
|
8
9
|
import { prepareCacheItemForBookingEdit } from "../bookingEditService/prepareCacheItemForBookingEdit.js";
|
|
9
10
|
import { useSalesSdk } from "../hooks/useSalesSdk.js";
|
|
10
11
|
import { useSyncExternalStoreCompat } from "../hooks/useSyncExternalStoreCompat.js";
|
|
@@ -17,11 +18,15 @@ import { locales } from "@pisell/utils";
|
|
|
17
18
|
/**
|
|
18
19
|
* 将 Host payload 的 cacheItem 补齐展示字段并写入 state。
|
|
19
20
|
*/
|
|
20
|
-
function normalizeCacheItemForDrawer(rawItem, bookingTicket, forceOpen) {
|
|
21
|
+
function normalizeCacheItemForDrawer(rawItem, bookingTicket, tempOrder, forceOpen) {
|
|
21
22
|
let item = rawItem;
|
|
22
23
|
if (isMultiDayQuotationExpanded(item)) item = _objectSpread2(_objectSpread2({}, item), {}, { new: 0 });
|
|
23
24
|
if (typeof bookingTicket.getProductExtend === "function") try {
|
|
24
|
-
|
|
25
|
+
var _bookingTicket$getBoo, _bookingTicket$getBoo2;
|
|
26
|
+
item = bookingTicket.getProductExtend(item, {
|
|
27
|
+
bookingConfig: (_bookingTicket$getBoo = (_bookingTicket$getBoo2 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo2 === void 0 ? void 0 : _bookingTicket$getBoo2.call(bookingTicket)) !== null && _bookingTicket$getBoo !== void 0 ? _bookingTicket$getBoo : void 0,
|
|
28
|
+
previousService: resolvePreviousService(tempOrder)
|
|
29
|
+
});
|
|
25
30
|
} catch (e) {
|
|
26
31
|
console.warn("[SalesSdk] getProductExtend 失败,使用原始 cacheItem", e);
|
|
27
32
|
}
|
|
@@ -78,7 +83,7 @@ const BookingEditHostRenderer = () => {
|
|
|
78
83
|
var _ref = _asyncToGenerator(function* () {
|
|
79
84
|
yield ensureBookingContextForDrawer(bookingTicket, payload, tempOrder, bookingConfigParams);
|
|
80
85
|
if (cancelled) return;
|
|
81
|
-
const item = normalizeCacheItemForDrawer(payload.cacheItem, bookingTicket, payload.forceOpen);
|
|
86
|
+
const item = normalizeCacheItemForDrawer(payload.cacheItem, bookingTicket, tempOrder, payload.forceOpen);
|
|
82
87
|
if (item.autoClose && !payload.forceOpen) {
|
|
83
88
|
bridge.complete(item);
|
|
84
89
|
return;
|
|
@@ -90,7 +95,7 @@ const BookingEditHostRenderer = () => {
|
|
|
90
95
|
};
|
|
91
96
|
})()().catch((err) => {
|
|
92
97
|
console.warn("[SalesSdk] openBookingEdit 初始化资源上下文失败", err);
|
|
93
|
-
if (!cancelled) setCacheItem(normalizeCacheItemForDrawer(payload.cacheItem, bookingTicket, payload.forceOpen));
|
|
98
|
+
if (!cancelled) setCacheItem(normalizeCacheItemForDrawer(payload.cacheItem, bookingTicket, tempOrder, payload.forceOpen));
|
|
94
99
|
});
|
|
95
100
|
return () => {
|
|
96
101
|
cancelled = true;
|
|
@@ -176,10 +181,10 @@ const BookingEditHostRenderer = () => {
|
|
|
176
181
|
cacheItem === null || cacheItem === void 0 || (_cacheItem$_data = cacheItem._data) === null || _cacheItem$_data === void 0 || (_cacheItem$_data = _cacheItem$_data.resources) === null || _cacheItem$_data === void 0 ? void 0 : _cacheItem$_data.length
|
|
177
182
|
]);
|
|
178
183
|
const bookingState = useMemo(() => {
|
|
179
|
-
var _bookingTicket$
|
|
184
|
+
var _bookingTicket$getBoo3, _bookingTicket$getBoo4, _ref3, _payload$date2, _bookingTicket$getBoo5, _bookingTicket$getTem3, _bookingTicket$getTem4, _bookingTicket$getOrd, _bookingTicket$getOth;
|
|
180
185
|
if (!cacheItem) return null;
|
|
181
|
-
const bookingConfig = (_bookingTicket$
|
|
182
|
-
const date = (_ref3 = (_payload$date2 = payload === null || payload === void 0 ? void 0 : payload.date) !== null && _payload$date2 !== void 0 ? _payload$date2 : bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$
|
|
186
|
+
const bookingConfig = (_bookingTicket$getBoo3 = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getBoo4 = bookingTicket.getBookingConfig) === null || _bookingTicket$getBoo4 === void 0 ? void 0 : _bookingTicket$getBoo4.call(bookingTicket)) !== null && _bookingTicket$getBoo3 !== void 0 ? _bookingTicket$getBoo3 : null;
|
|
187
|
+
const date = (_ref3 = (_payload$date2 = payload === null || payload === void 0 ? void 0 : payload.date) !== null && _payload$date2 !== void 0 ? _payload$date2 : bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getBoo5 = bookingTicket.getBookingDate) === null || _bookingTicket$getBoo5 === void 0 ? void 0 : _bookingTicket$getBoo5.call(bookingTicket)) !== null && _ref3 !== void 0 ? _ref3 : dayjs().format("YYYY-MM-DD");
|
|
183
188
|
const liveTempOrder = (_bookingTicket$getTem3 = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getTem4 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem4 === void 0 ? void 0 : _bookingTicket$getTem4.call(bookingTicket)) !== null && _bookingTicket$getTem3 !== void 0 ? _bookingTicket$getTem3 : tempOrder;
|
|
184
189
|
return buildBookingEditDrawerState({
|
|
185
190
|
cacheItem,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
//#region src/plus/salesSdk/utils/resolvePreviousService.ts
|
|
3
|
+
/**
|
|
4
|
+
* 取得下一预约计算开始时间时所需的“上一服务”。
|
|
5
|
+
*
|
|
6
|
+
* 对齐 info2:它会过滤自定义/普通商品后,通过 getLastServer 取 service.value[0]。
|
|
7
|
+
* SalesSdk 的 tempOrder.bookings 按加入顺序追加,因此从后向前取最后一条
|
|
8
|
+
* 时间完整的商品预约,转换为 OS BookingCalcContext 所需结构。
|
|
9
|
+
* `parent_id === 0` 是订单级 root booking,不对应商品行,需要跳过;
|
|
10
|
+
* 新建本地预约的 parent_id 可能尚未生成(null/undefined),仍属于有效候选。
|
|
11
|
+
*/
|
|
12
|
+
function resolvePreviousService(tempOrder) {
|
|
13
|
+
const bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
14
|
+
for (let index = bookings.length - 1; index >= 0; index -= 1) {
|
|
15
|
+
const booking = bookings[index];
|
|
16
|
+
if ((booking === null || booking === void 0 ? void 0 : booking.parent_id) != null && Number(booking.parent_id) === 0) continue;
|
|
17
|
+
if (!(booking === null || booking === void 0 ? void 0 : booking.start_date) || !(booking === null || booking === void 0 ? void 0 : booking.start_time) || !(booking === null || booking === void 0 ? void 0 : booking.end_date) || !(booking === null || booking === void 0 ? void 0 : booking.end_time)) continue;
|
|
18
|
+
const startDate = dayjs(`${booking.start_date} ${booking.start_time}`);
|
|
19
|
+
const endDate = dayjs(`${booking.end_date} ${booking.end_time}`);
|
|
20
|
+
if (!startDate.isValid() || !endDate.isValid()) continue;
|
|
21
|
+
return { _extend: {
|
|
22
|
+
startDate,
|
|
23
|
+
endDate
|
|
24
|
+
} };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { resolvePreviousService };
|
|
@@ -152,10 +152,14 @@ function _runAddProductFlow() {
|
|
|
152
152
|
initialHolderIds: (_flowOptions$initialH = flowOptions.initialHolderIds) !== null && _flowOptions$initialH !== void 0 ? _flowOptions$initialH : result.payload.initialHolderIds
|
|
153
153
|
}));
|
|
154
154
|
if (!detailResult) return { status: "cancelled" };
|
|
155
|
-
if (detailResult._committedProducts)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
if (detailResult._committedProducts) {
|
|
156
|
+
var _flowOptions$onBookin2;
|
|
157
|
+
yield (_flowOptions$onBookin2 = flowOptions.onBookingSelectionCommitted) === null || _flowOptions$onBookin2 === void 0 ? void 0 : _flowOptions$onBookin2.call(flowOptions);
|
|
158
|
+
return {
|
|
159
|
+
status: "added",
|
|
160
|
+
products: detailResult._committedProducts
|
|
161
|
+
};
|
|
162
|
+
}
|
|
159
163
|
const catalog = (_result$payload$produ = (_result$payload = result.payload) === null || _result$payload === void 0 ? void 0 : _result$payload.productData) !== null && _result$payload$produ !== void 0 ? _result$payload$produ : product;
|
|
160
164
|
const detailExtend = (_detailResult$detail = detailResult.detail) === null || _detailResult$detail === void 0 ? void 0 : _detailResult$detail._extend;
|
|
161
165
|
const hasFlowSelectedMultiDayRange = resolveIsMultiDayProduct(detailResult.detail, catalog, product) && (detailExtend === null || detailExtend === void 0 ? void 0 : detailExtend.start_date) && (detailExtend === null || detailExtend === void 0 ? void 0 : detailExtend.end_date);
|
|
@@ -6,7 +6,7 @@ import React, { useMemo } from "react";
|
|
|
6
6
|
import Decimal from "decimal.js";
|
|
7
7
|
//#region src/plus/skuOptionsSelection/components/NormalCard/index.tsx
|
|
8
8
|
const NormalCard = (props) => {
|
|
9
|
-
var _props$
|
|
9
|
+
var _props$dataSource2;
|
|
10
10
|
const { _key: uniqueKey, ruleConfig, _original, disabled, selected } = (props === null || props === void 0 ? void 0 : props.dataSource) || {};
|
|
11
11
|
const { cover, title, name, product_subtitle, price, price_type, add_price } = _original || {};
|
|
12
12
|
const symbol = useStore_default((s) => s.symbol);
|
|
@@ -22,20 +22,25 @@ const NormalCard = (props) => {
|
|
|
22
22
|
};
|
|
23
23
|
const renderNumberSelector = () => {
|
|
24
24
|
if (!(props === null || props === void 0 ? void 0 : props.numberSelector) || typeof (props === null || props === void 0 ? void 0 : props.numberSelector) !== "object") return null;
|
|
25
|
-
return React.cloneElement(props === null || props === void 0 ? void 0 : props.numberSelector, { onChange: (v) => {
|
|
26
|
-
var _props$actions;
|
|
25
|
+
return React.cloneElement(props === null || props === void 0 ? void 0 : props.numberSelector, { onChange: (v, meta) => {
|
|
26
|
+
var _props$dataSource, _props$actions;
|
|
27
|
+
const itemMin = Math.max(1, Number((ruleConfig === null || ruleConfig === void 0 ? void 0 : ruleConfig.min) || 0));
|
|
28
|
+
const currentQuantity = Number((props === null || props === void 0 || (_props$dataSource = props.dataSource) === null || _props$dataSource === void 0 ? void 0 : _props$dataSource.quantity) || 0);
|
|
29
|
+
let nextQuantity = v;
|
|
30
|
+
if ((meta === null || meta === void 0 ? void 0 : meta.action) === "increase" && currentQuantity <= 0) nextQuantity = itemMin;
|
|
31
|
+
else if ((meta === null || meta === void 0 ? void 0 : meta.action) === "decrease" && itemMin > 1 && currentQuantity === itemMin && v < itemMin) nextQuantity = 0;
|
|
27
32
|
const _price = add_price !== void 0 && add_price !== null ? add_price : price;
|
|
28
33
|
const priceType = price_type === "markdown" ? -1 : 1;
|
|
29
|
-
const totalPrice = new Decimal(_price).times(new Decimal(
|
|
34
|
+
const totalPrice = new Decimal(_price).times(new Decimal(nextQuantity)).times(priceType).toNumber();
|
|
30
35
|
const newOriginal = _objectSpread2(_objectSpread2({}, _original), {}, {
|
|
31
|
-
quantity:
|
|
32
|
-
num:
|
|
36
|
+
quantity: nextQuantity,
|
|
37
|
+
num: nextQuantity,
|
|
33
38
|
price: _price,
|
|
34
39
|
original_price: _price,
|
|
35
40
|
original_total: _price
|
|
36
41
|
});
|
|
37
42
|
props === null || props === void 0 || (_props$actions = props.actions) === null || _props$actions === void 0 || _props$actions.update(uniqueKey, {
|
|
38
|
-
quantity:
|
|
43
|
+
quantity: nextQuantity,
|
|
39
44
|
data: newOriginal,
|
|
40
45
|
totalPrice
|
|
41
46
|
});
|
|
@@ -62,17 +67,18 @@ const NormalCard = (props) => {
|
|
|
62
67
|
var _props$actions3;
|
|
63
68
|
const _price = add_price !== void 0 && add_price !== null ? add_price : price;
|
|
64
69
|
const priceType = price_type === "markdown" ? -1 : 1;
|
|
70
|
+
const initialQuantity = Math.max(1, Number((ruleConfig === null || ruleConfig === void 0 ? void 0 : ruleConfig.min) || 0));
|
|
65
71
|
const newOriginal = _objectSpread2(_objectSpread2({}, _original), {}, {
|
|
66
|
-
quantity:
|
|
67
|
-
num:
|
|
72
|
+
quantity: initialQuantity,
|
|
73
|
+
num: initialQuantity,
|
|
68
74
|
price: _price,
|
|
69
75
|
original_price: _price,
|
|
70
76
|
original_total: _price
|
|
71
77
|
});
|
|
72
78
|
props === null || props === void 0 || (_props$actions3 = props.actions) === null || _props$actions3 === void 0 || _props$actions3.update(uniqueKey, {
|
|
73
|
-
quantity:
|
|
79
|
+
quantity: initialQuantity,
|
|
74
80
|
data: newOriginal,
|
|
75
|
-
totalPrice: new Decimal(_price).times(priceType).toNumber()
|
|
81
|
+
totalPrice: new Decimal(_price).times(initialQuantity).times(priceType).toNumber()
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
84
|
};
|
|
@@ -99,7 +105,7 @@ const NormalCard = (props) => {
|
|
|
99
105
|
} }))),
|
|
100
106
|
onClick: handleChange,
|
|
101
107
|
skuCardConfig,
|
|
102
|
-
skuDisabled: (props === null || props === void 0 || (_props$
|
|
108
|
+
skuDisabled: (props === null || props === void 0 || (_props$dataSource2 = props.dataSource) === null || _props$dataSource2 === void 0 || (_props$dataSource2 = _props$dataSource2._extra) === null || _props$dataSource2 === void 0 ? void 0 : _props$dataSource2.disabled) === true
|
|
103
109
|
});
|
|
104
110
|
};
|
|
105
111
|
//#endregion
|