@pisell/private-materials 6.12.163 → 6.12.165
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 +15 -15
- package/build/lowcode/view.js +15 -15
- package/es/components/bigSale/components/ProductList/index.js +1 -1
- package/es/components/bigSale/dialog.js +5 -4
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +67 -24
- package/es/components/bigSale/templates/Standard/index.js +5 -3
- package/es/components/bigSale/utils/floorResourceSelection.js +106 -0
- package/es/components/bigSale/utils/orderIdentity.js +16 -0
- package/es/components/checkout/plugin.js +1 -1
- package/es/components/pay/toB/components/EFTPOS/index.js +1 -1
- package/es/components/ticketBooking/dialog.js +1 -1
- package/es/components/ticketBooking/hooks/pisellos/useProducts.js +1 -1
- package/es/plus/pisellReservation/utils/reservationTicketBookingHostParams.js +26 -1
- package/es/plus/productSelect/ProductCard/SkuCard/components/CardCom/index.js +23 -2
- package/es/plus/productSelect/ProductCard/SkuCard/components/CardWrapper/index.js +18 -1
- package/es/plus/saleDetail/tmpl/B/components/Pay/index.js +34 -24
- package/es/plus/salesSdk/services/refundPayments.js +1 -0
- package/es/plus/salesSdk/types.d.ts +9 -1
- package/es/pro/skuDetailModal/index.js +1 -1
- package/lib/components/bigSale/components/ProductList/index.js +1 -1
- package/lib/components/bigSale/dialog.js +5 -4
- package/lib/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +67 -24
- package/lib/components/bigSale/templates/Standard/index.js +5 -3
- package/lib/components/bigSale/utils/floorResourceSelection.js +110 -0
- package/lib/components/bigSale/utils/orderIdentity.js +16 -0
- package/lib/components/checkout/plugin.js +1 -1
- package/lib/components/pay/toB/components/EFTPOS/index.js +1 -1
- package/lib/components/ticketBooking/dialog.js +1 -1
- package/lib/components/ticketBooking/hooks/pisellos/useProducts.js +1 -1
- package/lib/plus/pisellReservation/utils/reservationTicketBookingHostParams.js +26 -0
- package/lib/plus/productSelect/ProductCard/SkuCard/components/CardCom/index.js +23 -2
- package/lib/plus/productSelect/ProductCard/SkuCard/components/CardWrapper/index.js +18 -1
- package/lib/plus/saleDetail/tmpl/B/components/Pay/index.js +33 -23
- package/lib/plus/salesSdk/services/refundPayments.js +1 -0
- package/lib/plus/salesSdk/types.d.ts +9 -1
- package/lib/pro/skuDetailModal/index.js +1 -1
- package/package.json +4 -4
|
@@ -7,7 +7,7 @@ import { PiPaymentType } from "../../../../../piPaymentUI/contracts/index.js";
|
|
|
7
7
|
import PiPayment from "../../../../../piPaymentUI/PiPayment.js";
|
|
8
8
|
import { formatLocalizedDateTime } from "../../../../utils.js";
|
|
9
9
|
import { SPI_PAYMENT_CODES } from "../../../../../../components/checkout/constants.js";
|
|
10
|
-
import { getCurrentDeviceNumber } from "../../../../../../components/checkout/utils.js";
|
|
10
|
+
import { getCurrentDeviceNumber, getShopWalletPassId } from "../../../../../../components/checkout/utils.js";
|
|
11
11
|
import { RefundModal } from "../../../../components/RefundModal/index.js";
|
|
12
12
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
13
13
|
import { message } from "antd";
|
|
@@ -360,11 +360,12 @@ function getPayV2RefundMethods() {
|
|
|
360
360
|
iconType: "pisell2-credit-card-02"
|
|
361
361
|
}];
|
|
362
362
|
}
|
|
363
|
-
function buildNormalRefundPayments(selected, editedAmounts) {
|
|
364
|
-
|
|
363
|
+
function buildNormalRefundPayments(selected, editedAmounts, shopWalletPassId) {
|
|
364
|
+
const normalizedShopWalletPassId = String(shopWalletPassId || "").trim();
|
|
365
|
+
return selected.map((transaction) => _objectSpread2({
|
|
365
366
|
id: transaction.payment.orderPaymentId,
|
|
366
367
|
amount: editedAmounts.get(transaction.key) || toDecimal(transaction.refundableAmount).toFixed(2)
|
|
367
|
-
}));
|
|
368
|
+
}, normalizedShopWalletPassId && isCashRefundTransaction(transaction) ? { metadata: { shop_wallet_pass_id: normalizedShopWalletPassId } } : {}));
|
|
368
369
|
}
|
|
369
370
|
function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
370
371
|
var _engineContext$appHel;
|
|
@@ -414,6 +415,14 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
414
415
|
return next;
|
|
415
416
|
});
|
|
416
417
|
}, []);
|
|
418
|
+
const buildNormalRefundPaymentsForSubmit = useCallback(function() {
|
|
419
|
+
var _ref10 = _asyncToGenerator(function* (selected) {
|
|
420
|
+
return buildNormalRefundPayments(selected, editedAmounts, selected.some(isCashRefundTransaction) ? yield getShopWalletPassId(interaction) : null);
|
|
421
|
+
});
|
|
422
|
+
return function(_x) {
|
|
423
|
+
return _ref10.apply(this, arguments);
|
|
424
|
+
};
|
|
425
|
+
}(), [editedAmounts, interaction]);
|
|
417
426
|
const openCashDrawer = useCallback(() => {
|
|
418
427
|
try {
|
|
419
428
|
var _interaction$utils, _interaction$utils$po;
|
|
@@ -447,13 +456,12 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
447
456
|
Toast
|
|
448
457
|
]);
|
|
449
458
|
const submitNormalRefund = useCallback(function() {
|
|
450
|
-
var
|
|
451
|
-
const payments = buildNormalRefundPayments(selected, editedAmounts);
|
|
452
|
-
const submittedRefundAmount = payments.reduce((total, payment) => total.plus(toDecimal(payment.amount)), new Decimal(0));
|
|
459
|
+
var _ref11 = _asyncToGenerator(function* (selected, cancelOrder, note) {
|
|
453
460
|
const shouldOpenCashDrawer = selected.some(isCashRefundTransaction);
|
|
454
461
|
setSubmitting(true);
|
|
455
462
|
try {
|
|
456
|
-
|
|
463
|
+
const payments = yield buildNormalRefundPaymentsForSubmit(selected);
|
|
464
|
+
finishSuccessfulRefund(payments.reduce((total, payment) => total.plus(toDecimal(payment.amount)), new Decimal(0)), (yield context.sales.refundPayments(payments, {
|
|
457
465
|
cancelOrder,
|
|
458
466
|
note
|
|
459
467
|
})).refreshError, shouldOpenCashDrawer);
|
|
@@ -463,17 +471,17 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
463
471
|
setSubmitting(false);
|
|
464
472
|
}
|
|
465
473
|
});
|
|
466
|
-
return function(
|
|
467
|
-
return
|
|
474
|
+
return function(_x2, _x3, _x4) {
|
|
475
|
+
return _ref11.apply(this, arguments);
|
|
468
476
|
};
|
|
469
477
|
}(), [
|
|
478
|
+
buildNormalRefundPaymentsForSubmit,
|
|
470
479
|
context.sales,
|
|
471
|
-
editedAmounts,
|
|
472
480
|
finishSuccessfulRefund,
|
|
473
481
|
getErrorText
|
|
474
482
|
]);
|
|
475
483
|
const submitSpiMx51Refund = useCallback(function() {
|
|
476
|
-
var
|
|
484
|
+
var _ref12 = _asyncToGenerator(function* (transaction, normalTransactions, cancelOrder, note) {
|
|
477
485
|
if (transaction.payment.orderPaymentId === void 0 || transaction.payment.orderPaymentId === null || !transaction.payment.paymentMethod.code) {
|
|
478
486
|
message.error(String(locales.getText("pisell2.sale-detail.refund-modal.eftpos-missing-identity")));
|
|
479
487
|
return;
|
|
@@ -482,13 +490,13 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
482
490
|
const paymentMethodCode = transaction.payment.paymentMethod.code;
|
|
483
491
|
const amount = editedAmounts.get(transaction.key) || toDecimal(transaction.refundableAmount).toFixed(2);
|
|
484
492
|
const refundUuid = createRefundPaymentNumber();
|
|
485
|
-
const normalPayments = buildNormalRefundPayments(normalTransactions, editedAmounts);
|
|
486
|
-
const normalRefundAmount = normalPayments.reduce((total, payment) => total.plus(toDecimal(payment.amount)), new Decimal(0));
|
|
487
493
|
const shouldOpenCashDrawer = normalTransactions.some(isCashRefundTransaction);
|
|
488
494
|
setSubmitting(true);
|
|
489
495
|
let nativeRefundSucceeded = false;
|
|
490
496
|
try {
|
|
491
497
|
var _engineContext$appHel2, _engineContext$appHel3, _engineContext$appHel4, _nativeResult$code, _nativeResult$data, _nativeResult$data2, _transaction$payment$;
|
|
498
|
+
const normalPayments = yield buildNormalRefundPaymentsForSubmit(normalTransactions);
|
|
499
|
+
const normalRefundAmount = normalPayments.reduce((total, payment) => total.plus(toDecimal(payment.amount)), new Decimal(0));
|
|
492
500
|
const mx51Plugin = engineContext === null || engineContext === void 0 || (_engineContext$appHel2 = engineContext.appHelper) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel2 = _engineContext$appHel2.utils) === null || _engineContext$appHel2 === void 0 || (_engineContext$appHel3 = _engineContext$appHel2.getApp) === null || _engineContext$appHel3 === void 0 || (_engineContext$appHel3 = _engineContext$appHel3.call(_engineContext$appHel2)) === null || _engineContext$appHel3 === void 0 || (_engineContext$appHel4 = _engineContext$appHel3.getPlugin) === null || _engineContext$appHel4 === void 0 ? void 0 : _engineContext$appHel4.call(_engineContext$appHel3, "mx51");
|
|
493
501
|
if (typeof (mx51Plugin === null || mx51Plugin === void 0 ? void 0 : mx51Plugin.refund) !== "function") throw new Error(String(locales.getText("pisell2.sale-detail.refund-modal.eftpos-open-failed")));
|
|
494
502
|
const nativeResult = yield mx51Plugin.refund({
|
|
@@ -530,10 +538,11 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
530
538
|
setSubmitting(false);
|
|
531
539
|
}
|
|
532
540
|
});
|
|
533
|
-
return function(
|
|
534
|
-
return
|
|
541
|
+
return function(_x5, _x6, _x7, _x8) {
|
|
542
|
+
return _ref12.apply(this, arguments);
|
|
535
543
|
};
|
|
536
544
|
}(), [
|
|
545
|
+
buildNormalRefundPaymentsForSubmit,
|
|
537
546
|
context.sales,
|
|
538
547
|
editedAmounts,
|
|
539
548
|
engineContext,
|
|
@@ -542,7 +551,7 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
542
551
|
onClose
|
|
543
552
|
]);
|
|
544
553
|
const submitEftposRefund = useCallback(function() {
|
|
545
|
-
var
|
|
554
|
+
var _ref13 = _asyncToGenerator(function* (transaction, normalTransactions, cancelOrder, note) {
|
|
546
555
|
if (!transaction.eftposProvider || !transaction.originalPaymentNumber || !transaction.salesId || transaction.payment.orderPaymentId === void 0 || transaction.payment.orderPaymentId === null || !transaction.payment.paymentMethod.code) {
|
|
547
556
|
message.error(String(locales.getText("pisell2.sale-detail.refund-modal.eftpos-missing-identity")));
|
|
548
557
|
return;
|
|
@@ -551,15 +560,15 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
551
560
|
const orderPaymentId = transaction.payment.orderPaymentId;
|
|
552
561
|
const paymentMethodCode = transaction.payment.paymentMethod.code;
|
|
553
562
|
const amount = editedAmounts.get(transaction.key) || toDecimal(transaction.refundableAmount).toFixed(2);
|
|
554
|
-
const normalPayments = buildNormalRefundPayments(normalTransactions, editedAmounts);
|
|
555
|
-
const normalRefundAmount = normalPayments.reduce((total, payment) => total.plus(toDecimal(payment.amount)), new Decimal(0));
|
|
556
563
|
const shouldOpenCashDrawer = normalTransactions.some(isCashRefundTransaction);
|
|
557
564
|
setSubmitting(true);
|
|
558
565
|
eftposSuccessHandlingRef.current = false;
|
|
559
|
-
const deviceNumber = yield getCurrentDeviceNumber(interaction);
|
|
560
566
|
let opened = false;
|
|
561
567
|
try {
|
|
562
568
|
var _piPaymentRef$current, _context$sales$tempOr3, _context$sales$salesD3;
|
|
569
|
+
const normalPayments = yield buildNormalRefundPaymentsForSubmit(normalTransactions);
|
|
570
|
+
const normalRefundAmount = normalPayments.reduce((total, payment) => total.plus(toDecimal(payment.amount)), new Decimal(0));
|
|
571
|
+
const deviceNumber = yield getCurrentDeviceNumber(interaction);
|
|
563
572
|
opened = Boolean((_piPaymentRef$current = piPaymentRef.current) === null || _piPaymentRef$current === void 0 ? void 0 : _piPaymentRef$current.open({
|
|
564
573
|
provider: transaction.eftposProvider,
|
|
565
574
|
mode: PaymentMode.Refund,
|
|
@@ -628,10 +637,11 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
628
637
|
message.error(String(locales.getText("pisell2.sale-detail.refund-modal.eftpos-open-failed")));
|
|
629
638
|
}
|
|
630
639
|
});
|
|
631
|
-
return function(
|
|
632
|
-
return
|
|
640
|
+
return function(_x9, _x10, _x11, _x12) {
|
|
641
|
+
return _ref13.apply(this, arguments);
|
|
633
642
|
};
|
|
634
643
|
}(), [
|
|
644
|
+
buildNormalRefundPaymentsForSubmit,
|
|
635
645
|
context.sales,
|
|
636
646
|
editedAmounts,
|
|
637
647
|
finishSuccessfulRefund,
|
|
@@ -693,10 +703,10 @@ function PayV2RefundModalConnected({ context, onClose, open }) {
|
|
|
693
703
|
}));
|
|
694
704
|
}
|
|
695
705
|
function Pay({ context }) {
|
|
696
|
-
var
|
|
706
|
+
var _ref14, _context$summary$summ2;
|
|
697
707
|
const paymentMethodNameMap = usePaymentMethodNameMap();
|
|
698
708
|
const tempOrder = context.sales.tempOrder;
|
|
699
|
-
const summary = (
|
|
709
|
+
const summary = (_ref14 = (_context$summary$summ2 = context.summary.summary) !== null && _context$summary$summ2 !== void 0 ? _context$summary$summ2 : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.summary) !== null && _ref14 !== void 0 ? _ref14 : null;
|
|
700
710
|
const symbol = (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.currency_symbol) || "$";
|
|
701
711
|
const payments = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.payments) ? tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.payments : [];
|
|
702
712
|
const overviewItems = [
|
|
@@ -10,6 +10,7 @@ function _refundOrderPayments() {
|
|
|
10
10
|
_refundOrderPayments = _asyncToGenerator(function* (orderId, payments, options = {}) {
|
|
11
11
|
var _options$note$trim, _options$note;
|
|
12
12
|
const payload = _objectSpread2({
|
|
13
|
+
platform: "pos",
|
|
13
14
|
note: (_options$note$trim = (_options$note = options.note) === null || _options$note === void 0 ? void 0 : _options$note.trim()) !== null && _options$note$trim !== void 0 ? _options$note$trim : "",
|
|
14
15
|
content: [],
|
|
15
16
|
is_notice: 0,
|
|
@@ -179,7 +179,8 @@ interface SalesSdkRefundPaymentInput {
|
|
|
179
179
|
product_voucher?: unknown;
|
|
180
180
|
payment_method_name?: string;
|
|
181
181
|
metadata?: {
|
|
182
|
-
|
|
182
|
+
/** 现金退款归属的钱箱 ID。 */shop_wallet_pass_id?: string;
|
|
183
|
+
unique_refund_number?: string;
|
|
183
184
|
manual_marking_flag?: 1;
|
|
184
185
|
};
|
|
185
186
|
}
|
|
@@ -577,6 +578,11 @@ interface UpdateOrderProductParams {
|
|
|
577
578
|
*/
|
|
578
579
|
allow_booking_discount_reapply?: boolean;
|
|
579
580
|
}
|
|
581
|
+
/** Order.updateOrderBooking 入参;仅覆盖 updates 中显式给出的 booking 字段。 */
|
|
582
|
+
interface UpdateOrderBookingParams {
|
|
583
|
+
unique_identification_number: string;
|
|
584
|
+
updates: Record<string, any>;
|
|
585
|
+
}
|
|
580
586
|
/** Order.updateOrderProductQuantity 入参;行定位语义与 updateOrderProduct / removeProductFromOrder 一致 */
|
|
581
587
|
interface UpdateOrderProductQuantityParams extends ScanOrderOrderProductIdentity {
|
|
582
588
|
num: number;
|
|
@@ -944,6 +950,8 @@ interface BookingTicketHandle {
|
|
|
944
950
|
}) => Promise<ScanOrderOrderProduct[]>;
|
|
945
951
|
updateOrderProduct: (params: UpdateOrderProductParams) => Promise<ScanOrderOrderProduct[]>;
|
|
946
952
|
updateOrderProducts?: (paramsList: UpdateOrderProductParams[]) => Promise<ScanOrderOrderProduct[]>;
|
|
953
|
+
/** 按 booking UID 更新预约;OS 会保留未出现在 updates 中的原字段。 */
|
|
954
|
+
updateOrderBooking?: (params: UpdateOrderBookingParams) => Record<string, any>[];
|
|
947
955
|
updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<ScanOrderOrderProduct[]>;
|
|
948
956
|
removeProductFromOrder: (identity: ScanOrderOrderProductIdentity, options?: {
|
|
949
957
|
preserveDisplayPosition?: {
|
|
@@ -11,6 +11,7 @@ import withResponsive from "../../responsive/withResponsive.js";
|
|
|
11
11
|
import noteModal_default from "../../plus/noteModal/index.js";
|
|
12
12
|
import DiscountKeyboard from "../priceKeyboard/components/discountKeyboard/index.js";
|
|
13
13
|
import NumericStepper from "../NumericStepper/index.js";
|
|
14
|
+
import useLogger from "../../hooks/useLogger.js";
|
|
14
15
|
import stock_default from "../../shared/locales/stock.js";
|
|
15
16
|
import { resolveSkuValueCandidates } from "../../plus/skuOptionsSelection/utils/resolveSkuValue.js";
|
|
16
17
|
import SKUOptionsSelection from "../../plus/skuOptionsSelection/index.js";
|
|
@@ -19,7 +20,6 @@ import locales_default$1 from "./flow/locales.js";
|
|
|
19
20
|
import useLocale from "../../hooks/useLocale.js";
|
|
20
21
|
import { canUseLocalProductData, formatSelectedSkuItems, getStockValidationResult, setHiddenStockAlertForToday, shouldShowQuantityStepper } from "./utils.js";
|
|
21
22
|
import useToast$1 from "../../hooks/useToast.js";
|
|
22
|
-
import useLogger from "../../hooks/useLogger.js";
|
|
23
23
|
import SkuDetailLoadingPanel from "./LoadingPanel.js";
|
|
24
24
|
import SkuDetailCollapsibleSection from "./components/CollapsibleSection/index.js";
|
|
25
25
|
import { getProductSkuFromWeighingValue, getWeighedUnitPrice, getWeighingValueFromProductSku, hasPositiveNetWeight, isWeighingProduct, resolveActiveSkuValue } from "./components/weighing/utils.js";
|
|
@@ -3,11 +3,11 @@ const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtim
|
|
|
3
3
|
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
4
4
|
const require_utils = require("../../../booking/info/service2/utils.js");
|
|
5
5
|
const require_useScrollActivity = require("../../../../hooks/useScrollActivity.js");
|
|
6
|
+
const require_useLogger = require("../../../../hooks/useLogger.js");
|
|
6
7
|
const require_useInitLocalesOnce = require("../../../../hooks/useInitLocalesOnce.js");
|
|
7
8
|
const require_index = require("../../../../plus/productSelect/ProductCard/index.js");
|
|
8
9
|
const require_ProductCardV2 = require("../../../../plus/productSelect/ProductCard/ProductCardV2.js");
|
|
9
10
|
const require_useLocale = require("../../../../hooks/useLocale.js");
|
|
10
|
-
const require_useLogger = require("../../../../hooks/useLogger.js");
|
|
11
11
|
const require_List = require("../../../list/List.js");
|
|
12
12
|
const require_utils$1 = require("../../../ticketBooking/components/ProductDisplayAdapter/utils.js");
|
|
13
13
|
const require_showAddToCartToast = require("../../../../plus/salesSdk/components/showAddToCartToast.js");
|
|
@@ -7,6 +7,7 @@ const require_useSalesSdk = require("../../plus/salesSdk/hooks/useSalesSdk.js");
|
|
|
7
7
|
const require_useSalesSdkCart = require("../../plus/salesSdk/hooks/useSalesSdkCart.js");
|
|
8
8
|
const require_SalesSdkProvider = require("../../plus/salesSdk/context/SalesSdkProvider.js");
|
|
9
9
|
const require_seedDineInReservationToCart = require("../../plus/pisellReservation/utils/seedDineInReservationToCart.js");
|
|
10
|
+
const require_orderIdentity = require("./utils/orderIdentity.js");
|
|
10
11
|
const require_index$1 = require("./index.js");
|
|
11
12
|
let dayjs = require("dayjs");
|
|
12
13
|
dayjs = require_runtime.__toESM(dayjs);
|
|
@@ -26,9 +27,7 @@ const MemoizedBigSale = react.default.memo(require_index$1.default);
|
|
|
26
27
|
* isTempOrderBoundToRemoteOrder({ order_id: 'local_order_xxx' }); // false
|
|
27
28
|
*/
|
|
28
29
|
function isTempOrderBoundToRemoteOrder(tempOrder) {
|
|
29
|
-
|
|
30
|
-
if (orderId === void 0 || orderId === null) return false;
|
|
31
|
-
return !String(orderId).startsWith("local_order");
|
|
30
|
+
return require_orderIdentity.isPersistedBigSaleOrderId(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id);
|
|
32
31
|
}
|
|
33
32
|
/**
|
|
34
33
|
* 快照必须是与当前订单匹配的完整原始记录;展示层规范化对象不能直接交给 OS hydrate。
|
|
@@ -328,6 +327,8 @@ function BigSaleDialog(props) {
|
|
|
328
327
|
contentActiveRef.current = contentActive;
|
|
329
328
|
const onVisualStateSettledRef = (0, react.useRef)(onVisualStateSettled);
|
|
330
329
|
onVisualStateSettledRef.current = onVisualStateSettled;
|
|
330
|
+
const resolvedBusinessCode = String(businessCode !== null && businessCode !== void 0 ? businessCode : "").trim() || (mode === "retail" ? "dine_in" : mode);
|
|
331
|
+
const hideSelectFloorMapResourceAction = !(require_orderIdentity.isPersistedBigSaleOrderId(orderId) && resolvedBusinessCode === "dine_in");
|
|
331
332
|
const resolvedFallbackTitle = title || (orderId ? `#${orderId}` : "New Order");
|
|
332
333
|
/** preloaded 实例保持稳定 mount,避免每次 open 销毁 SalesSdkProvider。 */
|
|
333
334
|
const bigSaleInstanceKey = (0, react.useMemo)(() => `${osKey}-${mode}`, [osKey, mode]);
|
|
@@ -518,7 +519,7 @@ function BigSaleDialog(props) {
|
|
|
518
519
|
productLoadParams,
|
|
519
520
|
productCatalogSessionKey,
|
|
520
521
|
productCatalogReady,
|
|
521
|
-
hideSelectFloorMapResourceAction
|
|
522
|
+
hideSelectFloorMapResourceAction,
|
|
522
523
|
rulesHooks,
|
|
523
524
|
otherParams,
|
|
524
525
|
enableTempOrderPersist: false,
|
|
@@ -6,7 +6,10 @@ const require_SalesSdkUIHostsContext = require("../../../plus/salesSdk/context/S
|
|
|
6
6
|
const require_SalesSdkProvider = require("../../../plus/salesSdk/context/SalesSdkProvider.js");
|
|
7
7
|
const require_bookingDetailHostActions = require("../../../plus/pisellReservation/components/bookingDetailModal/bookingDetailHostActions.js");
|
|
8
8
|
const require_usePicoCodingOpenData = require("../../../plus/pisellReservation/hooks/usePicoCodingOpenData.js");
|
|
9
|
+
const require_reservationTicketBookingHostParams = require("../../../plus/pisellReservation/utils/reservationTicketBookingHostParams.js");
|
|
9
10
|
const require_seedDineInReservationToCart = require("../../../plus/pisellReservation/utils/seedDineInReservationToCart.js");
|
|
11
|
+
const require_floorResourceSelection = require("../utils/floorResourceSelection.js");
|
|
12
|
+
const require_orderIdentity = require("../utils/orderIdentity.js");
|
|
10
13
|
let dayjs = require("dayjs");
|
|
11
14
|
dayjs = require_runtime.__toESM(dayjs);
|
|
12
15
|
let react = require("react");
|
|
@@ -70,13 +73,16 @@ function resolveCurrentBookingAt(context) {
|
|
|
70
73
|
* openSelectFloorMapResource();
|
|
71
74
|
*/
|
|
72
75
|
function useSelectFloorMapResourceForBigSale(options) {
|
|
73
|
-
|
|
76
|
+
var _context$sales$bookin5, _context$sales$bookin6, _context$sales$bookin7, _context$sales$tempOr;
|
|
77
|
+
const { context, mode, orderId, businessCode, bookingConfigParams, productLoadParams } = options;
|
|
74
78
|
const engineCtx = require_useEngineContext.default();
|
|
75
79
|
const refreshRoot = (0, react.useContext)(require_SalesSdkProvider.SalesSdkRootRefreshContext);
|
|
76
80
|
const uiHosts = require_SalesSdkUIHostsContext.useSalesSdkUIHosts();
|
|
77
81
|
const reservationBiz = resolveBigSaleReservationBiz(businessCode, mode);
|
|
78
82
|
const { reservationRuleProduct, reservationAssociatedMenuListIds } = require_usePicoCodingOpenData.usePicoCodingOpenData(engineCtx, reservationBiz);
|
|
79
83
|
const hasReservationRuleProduct = Boolean(reservationRuleProduct);
|
|
84
|
+
const hasPersistedCurrentOrder = require_orderIdentity.isPersistedBigSaleOrderId((_context$sales$bookin5 = (_context$sales$bookin6 = context.sales.bookingTicket) === null || _context$sales$bookin6 === void 0 || (_context$sales$bookin7 = _context$sales$bookin6.getTempOrder) === null || _context$sales$bookin7 === void 0 || (_context$sales$bookin7 = _context$sales$bookin7.call(_context$sales$bookin6)) === null || _context$sales$bookin7 === void 0 ? void 0 : _context$sales$bookin7.order_id) !== null && _context$sales$bookin5 !== void 0 ? _context$sales$bookin5 : (_context$sales$tempOr = context.sales.tempOrder) === null || _context$sales$tempOr === void 0 ? void 0 : _context$sales$tempOr.order_id);
|
|
85
|
+
const canSelectFloorMapResource = hasReservationRuleProduct || hasPersistedCurrentOrder;
|
|
80
86
|
const associatedMenuListIds = (0, react.useMemo)(() => {
|
|
81
87
|
const fromProductLoad = normalizeMenuListIdsFromLoadParams(productLoadParams);
|
|
82
88
|
return fromProductLoad.length > 0 ? fromProductLoad : reservationAssociatedMenuListIds;
|
|
@@ -89,10 +95,10 @@ function useSelectFloorMapResourceForBigSale(options) {
|
|
|
89
95
|
*/
|
|
90
96
|
const refreshBigSaleAfterResourceMerge = (0, ahooks.useMemoizedFn)(function() {
|
|
91
97
|
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (loadResources) {
|
|
92
|
-
var _context$sales$
|
|
93
|
-
const liveTempOrder = (_context$sales$
|
|
98
|
+
var _context$sales$bookin8, _context$sales$bookin9, _context$sales$bookin10, _context$sales$bookin11, _context$sales$bookin12;
|
|
99
|
+
const liveTempOrder = (_context$sales$bookin8 = (_context$sales$bookin9 = context.sales.bookingTicket) === null || _context$sales$bookin9 === void 0 || (_context$sales$bookin10 = _context$sales$bookin9.getTempOrder) === null || _context$sales$bookin10 === void 0 ? void 0 : _context$sales$bookin10.call(_context$sales$bookin9)) !== null && _context$sales$bookin8 !== void 0 ? _context$sales$bookin8 : context.sales.tempOrder;
|
|
94
100
|
const bookingIds = require_buildDefaultLoadProductsParams.collectBookingIdsFromTempOrder(liveTempOrder !== null && liveTempOrder !== void 0 ? liveTempOrder : null);
|
|
95
|
-
yield (_context$sales$
|
|
101
|
+
yield (_context$sales$bookin11 = context.sales.bookingTicket) === null || _context$sales$bookin11 === void 0 || (_context$sales$bookin12 = _context$sales$bookin11.initBookingContext) === null || _context$sales$bookin12 === void 0 ? void 0 : _context$sales$bookin12.call(_context$sales$bookin11, require_buildDefaultLoadProductsParams.buildInitBookingContextParams(bookingConfigParams, {
|
|
96
102
|
date: resolveCurrentBookingAt(context),
|
|
97
103
|
bookingIds: bookingIds.length ? bookingIds : void 0,
|
|
98
104
|
loadResources
|
|
@@ -112,8 +118,8 @@ function useSelectFloorMapResourceForBigSale(options) {
|
|
|
112
118
|
*/
|
|
113
119
|
const mergeExistingOrderToBigSale = (0, ahooks.useMemoizedFn)(function() {
|
|
114
120
|
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (orderId) {
|
|
115
|
-
var _context$sales$
|
|
116
|
-
if (!((_context$sales$
|
|
121
|
+
var _context$sales$bookin13;
|
|
122
|
+
if (!((_context$sales$bookin13 = context.sales.bookingTicket) === null || _context$sales$bookin13 === void 0 ? void 0 : _context$sales$bookin13.loadSalesDetail)) throw new Error("[BigSale] loadSalesDetail 不可用");
|
|
117
123
|
yield context.sales.bookingTicket.loadSalesDetail({
|
|
118
124
|
orderId,
|
|
119
125
|
forceRemote: true,
|
|
@@ -133,18 +139,18 @@ function useSelectFloorMapResourceForBigSale(options) {
|
|
|
133
139
|
*/
|
|
134
140
|
const seedEmptyResourceToBigSale = (0, ahooks.useMemoizedFn)(function() {
|
|
135
141
|
var _ref4 = require_asyncToGenerator._asyncToGenerator(function* (selected) {
|
|
136
|
-
var _context$sales$
|
|
142
|
+
var _context$sales$bookin14, _context$sales$bookin15, _context$sales$bookin16, _context$sales$bookin17, _context$sales$bookin18, _context$sales$bookin19, _context$sales$bookin20, _context$sales$bookin21, _context$sales$bookin22, _liveTempOrder$custom;
|
|
137
143
|
if (!context.sales.bookingTicket) throw new Error("[BigSale] bookingTicket 未初始化");
|
|
138
144
|
if (!reservationRuleProduct || typeof reservationRuleProduct !== "object") throw new Error("[BigSale] 缺少桌台关联商品配置");
|
|
139
|
-
if (!context.sales.tempOrder) yield context.sales.createNew();
|
|
145
|
+
if (!((_context$sales$bookin14 = (_context$sales$bookin15 = (_context$sales$bookin16 = context.sales.bookingTicket).getTempOrder) === null || _context$sales$bookin15 === void 0 ? void 0 : _context$sales$bookin15.call(_context$sales$bookin16)) !== null && _context$sales$bookin14 !== void 0 ? _context$sales$bookin14 : context.sales.tempOrder)) yield context.sales.createNew();
|
|
140
146
|
const currentAt = resolveCurrentBookingAt(context);
|
|
141
|
-
const liveTempOrder = (_context$sales$
|
|
147
|
+
const liveTempOrder = (_context$sales$bookin17 = (_context$sales$bookin18 = (_context$sales$bookin19 = context.sales.bookingTicket).getTempOrder) === null || _context$sales$bookin18 === void 0 ? void 0 : _context$sales$bookin18.call(_context$sales$bookin19)) !== null && _context$sales$bookin17 !== void 0 ? _context$sales$bookin17 : context.sales.tempOrder;
|
|
142
148
|
yield require_seedDineInReservationToCart.seedDineInReservationToCart({
|
|
143
149
|
bookingTicket: context.sales.bookingTicket,
|
|
144
150
|
reservationRuleProduct,
|
|
145
|
-
row: selected
|
|
151
|
+
row: require_floorResourceSelection.resolveSelectedReservationRow(selected),
|
|
146
152
|
appointmentStatus: "started",
|
|
147
|
-
bookingConfig: (_context$sales$
|
|
153
|
+
bookingConfig: (_context$sales$bookin20 = (_context$sales$bookin21 = (_context$sales$bookin22 = context.sales.bookingTicket).getBookingConfig) === null || _context$sales$bookin21 === void 0 ? void 0 : _context$sales$bookin21.call(_context$sales$bookin22)) !== null && _context$sales$bookin20 !== void 0 ? _context$sales$bookin20 : null,
|
|
148
154
|
tempOrder: liveTempOrder,
|
|
149
155
|
customerId: (_liveTempOrder$custom = liveTempOrder === null || liveTempOrder === void 0 ? void 0 : liveTempOrder.customer_id) !== null && _liveTempOrder$custom !== void 0 ? _liveTempOrder$custom : void 0,
|
|
150
156
|
date: currentAt.format("YYYY-MM-DD"),
|
|
@@ -156,29 +162,65 @@ function useSelectFloorMapResourceForBigSale(options) {
|
|
|
156
162
|
return _ref4.apply(this, arguments);
|
|
157
163
|
};
|
|
158
164
|
}());
|
|
165
|
+
/** 仅替换已有桌台 booking 的 resources,保留商品行与其余 booking 字段。 */
|
|
166
|
+
const replaceExistingTableResource = (0, ahooks.useMemoizedFn)(function() {
|
|
167
|
+
var _ref6 = require_asyncToGenerator._asyncToGenerator(function* (selected, booking) {
|
|
168
|
+
var _ref5, _booking$metadata$uni, _booking$metadata;
|
|
169
|
+
const bookingTicket = context.sales.bookingTicket;
|
|
170
|
+
if (!bookingTicket || typeof bookingTicket.updateOrderBooking !== "function") throw new Error("[BigSale] updateOrderBooking 不可用");
|
|
171
|
+
const bookingUid = String((_ref5 = (_booking$metadata$uni = (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number) !== null && _booking$metadata$uni !== void 0 ? _booking$metadata$uni : booking.unique_identification_number) !== null && _ref5 !== void 0 ? _ref5 : "").trim();
|
|
172
|
+
if (!bookingUid) throw new Error("[BigSale] 桌台 booking 缺少 UID,无法换桌");
|
|
173
|
+
if (!require_floorResourceSelection.resolveSelectedFloorResourceId(selected)) throw new Error("[BigSale] 所选桌台缺少有效资源 ID");
|
|
174
|
+
const resources = require_reservationTicketBookingHostParams.buildReplacementBookingResourcesFromReservationRow(require_floorResourceSelection.resolveSelectedReservationRow(selected), booking);
|
|
175
|
+
yield bookingTicket.updateOrderBooking({
|
|
176
|
+
unique_identification_number: bookingUid,
|
|
177
|
+
updates: { resources }
|
|
178
|
+
});
|
|
179
|
+
yield refreshBigSaleAfterResourceMerge(true);
|
|
180
|
+
});
|
|
181
|
+
return function(_x4, _x5) {
|
|
182
|
+
return _ref6.apply(this, arguments);
|
|
183
|
+
};
|
|
184
|
+
}());
|
|
159
185
|
/**
|
|
160
|
-
*
|
|
186
|
+
* 处理选择资源弹窗点击结果:已落库订单只新增/替换桌台;新建订单命中已有订单
|
|
187
|
+
* 时 merge,选择空桌时按当前草稿执行新增、同桌不变或异桌替换。
|
|
161
188
|
*
|
|
162
189
|
* @example
|
|
163
190
|
* await handleSelectedFloorMapResource(selected);
|
|
164
191
|
*/
|
|
165
192
|
const handleSelectedFloorMapResource = (0, ahooks.useMemoizedFn)(function() {
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (!
|
|
174
|
-
|
|
193
|
+
var _ref7 = require_asyncToGenerator._asyncToGenerator(function* (selected) {
|
|
194
|
+
var _context$sales$bookin23, _context$sales$bookin24, _context$sales$bookin25, _context$sales$salesD, _context$sales$salesD2, _context$sales$salesD3;
|
|
195
|
+
const liveTempOrder = (_context$sales$bookin23 = (_context$sales$bookin24 = context.sales.bookingTicket) === null || _context$sales$bookin24 === void 0 || (_context$sales$bookin25 = _context$sales$bookin24.getTempOrder) === null || _context$sales$bookin25 === void 0 ? void 0 : _context$sales$bookin25.call(_context$sales$bookin24)) !== null && _context$sales$bookin23 !== void 0 ? _context$sales$bookin23 : context.sales.tempOrder;
|
|
196
|
+
const currentOrderId = liveTempOrder === null || liveTempOrder === void 0 ? void 0 : liveTempOrder.order_id;
|
|
197
|
+
const isPersistedOrder = require_orderIdentity.isPersistedBigSaleOrderId(currentOrderId);
|
|
198
|
+
if (require_orderIdentity.isPersistedBigSaleOrderId(orderId) && String(currentOrderId !== null && currentOrderId !== void 0 ? currentOrderId : "").trim() !== String(orderId).trim()) throw new Error("[BigSale] 当前订单尚未加载完成,请稍后重试");
|
|
199
|
+
const salesDetailOrderId = (_context$sales$salesD = (_context$sales$salesD2 = context.sales.salesDetail) === null || _context$sales$salesD2 === void 0 || (_context$sales$salesD2 = _context$sales$salesD2.header) === null || _context$sales$salesD2 === void 0 ? void 0 : _context$sales$salesD2.order_id) !== null && _context$sales$salesD !== void 0 ? _context$sales$salesD : (_context$sales$salesD3 = context.sales.salesDetail) === null || _context$sales$salesD3 === void 0 ? void 0 : _context$sales$salesD3.order_id;
|
|
200
|
+
if (!liveTempOrder && require_orderIdentity.isPersistedBigSaleOrderId(salesDetailOrderId)) throw new Error("[BigSale] 当前订单尚未加载完成,请稍后重试");
|
|
201
|
+
const selectedOrderId = resolveSelectedResourceOrderId(selected);
|
|
202
|
+
const currentTableBookings = require_floorResourceSelection.resolveCurrentTableBookings(liveTempOrder, reservationRuleProduct);
|
|
203
|
+
const bookingCount = typeof selected.row.bookingCount === "number" && Number.isFinite(selected.row.bookingCount) ? selected.row.bookingCount : 0;
|
|
204
|
+
if (!isPersistedOrder && selectedOrderId == null && bookingCount > 0) console.warn("[BigSale] 当前桌台有订单记录,但未命中可合并订单");
|
|
205
|
+
const result = yield require_floorResourceSelection.applyBigSaleFloorResourceSelection({
|
|
206
|
+
isPersistedOrder,
|
|
207
|
+
selectedOrderId,
|
|
208
|
+
selectedResourceId: require_floorResourceSelection.resolveSelectedFloorResourceId(selected),
|
|
209
|
+
currentTableBookings,
|
|
210
|
+
add: () => seedEmptyResourceToBigSale(selected),
|
|
211
|
+
replace: (booking) => replaceExistingTableResource(selected, booking),
|
|
212
|
+
merge: (orderId) => mergeExistingOrderToBigSale(orderId)
|
|
213
|
+
});
|
|
214
|
+
if (result === "unchanged") antd.message.info("This table is already assigned");
|
|
215
|
+
return result;
|
|
175
216
|
});
|
|
176
|
-
return function(
|
|
177
|
-
return
|
|
217
|
+
return function(_x6) {
|
|
218
|
+
return _ref7.apply(this, arguments);
|
|
178
219
|
};
|
|
179
220
|
}());
|
|
180
221
|
return {
|
|
181
222
|
hasReservationRuleProduct,
|
|
223
|
+
canSelectFloorMapResource,
|
|
182
224
|
openSelectFloorMapResource: (0, ahooks.useMemoizedFn)(() => {
|
|
183
225
|
var _engineCtx$appHelper;
|
|
184
226
|
const action = engineCtx === null || engineCtx === void 0 || (_engineCtx$appHelper = engineCtx.appHelper) === null || _engineCtx$appHelper === void 0 || (_engineCtx$appHelper = _engineCtx$appHelper.utils) === null || _engineCtx$appHelper === void 0 ? void 0 : _engineCtx$appHelper.action;
|
|
@@ -202,7 +244,8 @@ function useSelectFloorMapResourceForBigSale(options) {
|
|
|
202
244
|
at: currentAt
|
|
203
245
|
},
|
|
204
246
|
onClick: (selected) => {
|
|
205
|
-
handleSelectedFloorMapResource(selected).then(() => {
|
|
247
|
+
handleSelectedFloorMapResource(selected).then((result) => {
|
|
248
|
+
if (!require_floorResourceSelection.shouldCloseFloorResourceSelection(result)) return;
|
|
206
249
|
action({
|
|
207
250
|
type: "pisell1.closeSelectFloorMapResource",
|
|
208
251
|
data: {},
|
|
@@ -222,9 +222,10 @@ function StandardBigSaleTemplate({ isActive = true, osKey, productListPreference
|
|
|
222
222
|
]);
|
|
223
223
|
const [productListPreferences, setProductListPreferences] = (0, react.useState)(() => require_productListPreferences.readBigSaleProductListPreferences(productListPreferencesKey, defaultProductListPreferences));
|
|
224
224
|
const [hasProductListPreferencesOverride, setHasProductListPreferencesOverride] = (0, react.useState)(() => Boolean(require_productListPreferences.readStoredBigSaleProductListPreferences(productListPreferencesKey, defaultProductListPreferences)));
|
|
225
|
-
const { openSelectFloorMapResource } = require_useSelectFloorMapResourceForBigSale.useSelectFloorMapResourceForBigSale({
|
|
225
|
+
const { canSelectFloorMapResource, openSelectFloorMapResource } = require_useSelectFloorMapResourceForBigSale.useSelectFloorMapResourceForBigSale({
|
|
226
226
|
context,
|
|
227
227
|
mode,
|
|
228
|
+
orderId,
|
|
228
229
|
businessCode,
|
|
229
230
|
bookingConfigParams,
|
|
230
231
|
productLoadParams
|
|
@@ -235,7 +236,7 @@ function StandardBigSaleTemplate({ isActive = true, osKey, productListPreference
|
|
|
235
236
|
setProductListPreferences(storedPreferences || defaultProductListPreferences);
|
|
236
237
|
setHasProductListPreferencesOverride(Boolean(storedPreferences));
|
|
237
238
|
}, [defaultProductListPreferences, productListPreferencesKey]);
|
|
238
|
-
const shouldInjectFloorResourceAction = !hideSelectFloorMapResourceAction;
|
|
239
|
+
const shouldInjectFloorResourceAction = canSelectFloorMapResource && !hideSelectFloorMapResourceAction;
|
|
239
240
|
const dineInOrderActions = (0, react.useMemo)(() => {
|
|
240
241
|
if (!shouldInjectFloorResourceAction) return void 0;
|
|
241
242
|
return [
|
|
@@ -364,7 +365,8 @@ function StandardBigSaleTemplate({ isActive = true, osKey, productListPreference
|
|
|
364
365
|
defaultProductListPreferences,
|
|
365
366
|
onProductListPreferencesChange: handleProductListPreferencesChange,
|
|
366
367
|
onProductListPreferencesReset: handleProductListPreferencesReset,
|
|
367
|
-
variant
|
|
368
|
+
variant,
|
|
369
|
+
productSelectionTrigger: "click"
|
|
368
370
|
}), /* @__PURE__ */ react.default.createElement(require_index$4.default, {
|
|
369
371
|
variant,
|
|
370
372
|
floatingPanelRef,
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
+
const require_asyncToGenerator = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
3
|
+
//#region src/components/bigSale/utils/floorResourceSelection.ts
|
|
4
|
+
function normalizeIdentity(value) {
|
|
5
|
+
if (value === void 0 || value === null) return null;
|
|
6
|
+
const normalized = String(value).trim();
|
|
7
|
+
return normalized && normalized !== "0" ? normalized : null;
|
|
8
|
+
}
|
|
9
|
+
function resolveBookingResources(booking) {
|
|
10
|
+
return (Array.isArray(booking.resources) ? booking.resources : Array.isArray(booking.event_resources) ? booking.event_resources : []).filter((resource) => Boolean(resource) && typeof resource === "object");
|
|
11
|
+
}
|
|
12
|
+
function resolveProductUid(product) {
|
|
13
|
+
var _product$metadata$uni, _product$metadata;
|
|
14
|
+
return normalizeIdentity((_product$metadata$uni = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product.unique_identification_number);
|
|
15
|
+
}
|
|
16
|
+
function resolveBookingUid(booking) {
|
|
17
|
+
var _booking$metadata$uni, _booking$metadata;
|
|
18
|
+
return normalizeIdentity((_booking$metadata$uni = (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number) !== null && _booking$metadata$uni !== void 0 ? _booking$metadata$uni : booking.unique_identification_number);
|
|
19
|
+
}
|
|
20
|
+
/** 将选择 payload 归一为 seed / 换桌共同消费的桌台行。 */
|
|
21
|
+
function resolveSelectedReservationRow(selected) {
|
|
22
|
+
var _selected$resource$ra, _ref, _selected$resource$re, _selected$resource$fo, _ref2, _selected$resource$co, _ref3, _selected$resource$ma;
|
|
23
|
+
const raw = (_selected$resource$ra = selected.resource.raw) !== null && _selected$resource$ra !== void 0 ? _selected$resource$ra : selected.row;
|
|
24
|
+
const relationId = (_ref = (_selected$resource$re = selected.resource.relation_id) !== null && _selected$resource$re !== void 0 ? _selected$resource$re : selected.resource.id) !== null && _ref !== void 0 ? _ref : raw.id;
|
|
25
|
+
return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, selected.row), raw), {}, {
|
|
26
|
+
id: String(relationId),
|
|
27
|
+
form_id: (_selected$resource$fo = selected.resource.form_id) !== null && _selected$resource$fo !== void 0 ? _selected$resource$fo : raw.form_id,
|
|
28
|
+
code: (_ref2 = (_selected$resource$co = selected.resource.code) !== null && _selected$resource$co !== void 0 ? _selected$resource$co : raw.code) !== null && _ref2 !== void 0 ? _ref2 : String(relationId),
|
|
29
|
+
main_field: (_ref3 = (_selected$resource$ma = selected.resource.main_field) !== null && _selected$resource$ma !== void 0 ? _selected$resource$ma : raw.main_field) !== null && _ref3 !== void 0 ? _ref3 : selected.row.main_field
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/** 选择 payload 中的资源主键,与 booking.resources[].relation_id 对齐。 */
|
|
33
|
+
function resolveSelectedFloorResourceId(selected) {
|
|
34
|
+
var _ref4, _selected$resource$re2;
|
|
35
|
+
return normalizeIdentity((_ref4 = (_selected$resource$re2 = selected.resource.relation_id) !== null && _selected$resource$re2 !== void 0 ? _selected$resource$re2 : selected.resource.id) !== null && _ref4 !== void 0 ? _ref4 : selected.row.id);
|
|
36
|
+
}
|
|
37
|
+
/** 当前 booking 是否已经绑定了本次选中的桌台。 */
|
|
38
|
+
function bookingUsesFloorResource(booking, resourceId) {
|
|
39
|
+
if (!resourceId) return false;
|
|
40
|
+
return resolveBookingResources(booking).some((resource) => normalizeIdentity(resource.relation_id) === resourceId);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 从 tempOrder 找出桌台 booking。
|
|
44
|
+
*
|
|
45
|
+
* 优先使用当前配置的桌台规则商品关联关系;历史数据无法关联时,再退回到带资源的
|
|
46
|
+
* 非 root booking。这样既兼容配置变更后的旧单,也不会把 root booking 当成桌台商品。
|
|
47
|
+
*/
|
|
48
|
+
function resolveCurrentTableBookings(tempOrder, reservationRuleProduct) {
|
|
49
|
+
var _tempOrder$bookings, _reservationRuleProdu, _tempOrder$products;
|
|
50
|
+
if (!tempOrder) return [];
|
|
51
|
+
const nonRootBookings = ((_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 ? _tempOrder$bookings : []).filter((booking) => {
|
|
52
|
+
if (!booking || typeof booking !== "object") return false;
|
|
53
|
+
return Number(booking.parent_id) !== 0;
|
|
54
|
+
});
|
|
55
|
+
const resourceBookings = nonRootBookings.filter((booking) => resolveBookingResources(booking).some((resource) => Boolean(normalizeIdentity(resource.relation_id))));
|
|
56
|
+
const ruleProductId = normalizeIdentity((_reservationRuleProdu = reservationRuleProduct === null || reservationRuleProduct === void 0 ? void 0 : reservationRuleProduct.id) !== null && _reservationRuleProdu !== void 0 ? _reservationRuleProdu : reservationRuleProduct === null || reservationRuleProduct === void 0 ? void 0 : reservationRuleProduct.product_id);
|
|
57
|
+
if (!ruleProductId) return resourceBookings;
|
|
58
|
+
const linkedProductUids = /* @__PURE__ */ new Set();
|
|
59
|
+
const linkedBookingUids = /* @__PURE__ */ new Set();
|
|
60
|
+
for (const product of (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 ? _tempOrder$products : []) {
|
|
61
|
+
var _booking_uid, _product$metadata2;
|
|
62
|
+
if (normalizeIdentity(product.product_id) !== ruleProductId) continue;
|
|
63
|
+
const productUid = resolveProductUid(product);
|
|
64
|
+
if (productUid) linkedProductUids.add(productUid);
|
|
65
|
+
const bookingUid = normalizeIdentity((_booking_uid = product.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_uid);
|
|
66
|
+
if (bookingUid) linkedBookingUids.add(bookingUid);
|
|
67
|
+
}
|
|
68
|
+
const linkedBookings = nonRootBookings.filter((booking) => {
|
|
69
|
+
const productUid = normalizeIdentity(booking.product_uid);
|
|
70
|
+
const bookingUid = resolveBookingUid(booking);
|
|
71
|
+
return Boolean(productUid && linkedProductUids.has(productUid) || bookingUid && linkedBookingUids.has(bookingUid));
|
|
72
|
+
});
|
|
73
|
+
return Array.from(new Set([...linkedBookings, ...resourceBookings]));
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 执行桌台选择分流。已落库订单永远不会进入 merge 回调;新订单命中已有
|
|
77
|
+
* 订单时仍优先 merge,否则对当前草稿已有桌台执行同桌不变或异桌替换。
|
|
78
|
+
*/
|
|
79
|
+
function applyBigSaleFloorResourceSelection(_x) {
|
|
80
|
+
return _applyBigSaleFloorResourceSelection.apply(this, arguments);
|
|
81
|
+
}
|
|
82
|
+
function _applyBigSaleFloorResourceSelection() {
|
|
83
|
+
_applyBigSaleFloorResourceSelection = require_asyncToGenerator._asyncToGenerator(function* (options) {
|
|
84
|
+
const { isPersistedOrder, selectedOrderId, selectedResourceId, currentTableBookings, add, replace, merge } = options;
|
|
85
|
+
if (!isPersistedOrder && selectedOrderId != null) {
|
|
86
|
+
yield merge(selectedOrderId);
|
|
87
|
+
return "merged";
|
|
88
|
+
}
|
|
89
|
+
if (currentTableBookings.length > 1) throw new Error("[BigSale] 当前订单存在多条桌台 booking,无法自动换桌");
|
|
90
|
+
const currentTableBooking = currentTableBookings[0];
|
|
91
|
+
if (!currentTableBooking) {
|
|
92
|
+
yield add();
|
|
93
|
+
return "added";
|
|
94
|
+
}
|
|
95
|
+
if (bookingUsesFloorResource(currentTableBooking, selectedResourceId)) return "unchanged";
|
|
96
|
+
yield replace(currentTableBooking);
|
|
97
|
+
return "replaced";
|
|
98
|
+
});
|
|
99
|
+
return _applyBigSaleFloorResourceSelection.apply(this, arguments);
|
|
100
|
+
}
|
|
101
|
+
/** 只有发生实际写入或合单时才关闭桌台选择弹窗。 */
|
|
102
|
+
function shouldCloseFloorResourceSelection(result) {
|
|
103
|
+
return result !== "unchanged";
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
exports.applyBigSaleFloorResourceSelection = applyBigSaleFloorResourceSelection;
|
|
107
|
+
exports.resolveCurrentTableBookings = resolveCurrentTableBookings;
|
|
108
|
+
exports.resolveSelectedFloorResourceId = resolveSelectedFloorResourceId;
|
|
109
|
+
exports.resolveSelectedReservationRow = resolveSelectedReservationRow;
|
|
110
|
+
exports.shouldCloseFloorResourceSelection = shouldCloseFloorResourceSelection;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/components/bigSale/utils/orderIdentity.ts
|
|
2
|
+
/**
|
|
3
|
+
* 判断订单 ID 是否指向后端已落库订单。
|
|
4
|
+
*
|
|
5
|
+
* `local_order*` / `LOCAL_*` 等本地草稿标识仍属于新建订单流程。
|
|
6
|
+
*/
|
|
7
|
+
function isPersistedBigSaleOrderId(orderId) {
|
|
8
|
+
if (orderId === void 0 || orderId === null) return false;
|
|
9
|
+
if (typeof orderId === "number") return Number.isFinite(orderId) && orderId > 0;
|
|
10
|
+
const normalized = String(orderId).trim();
|
|
11
|
+
if (!normalized || normalized === "0") return false;
|
|
12
|
+
const lower = normalized.toLowerCase();
|
|
13
|
+
return !(lower === "local" || lower.startsWith("local_") || lower.startsWith("local-"));
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.isPersistedBigSaleOrderId = isPersistedBigSaleOrderId;
|
|
@@ -3,8 +3,8 @@ const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.12
|
|
|
3
3
|
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
4
4
|
const require_model = require("../booking/info/model.js");
|
|
5
5
|
const require_useEngineContext = require("../../hooks/useEngineContext.js");
|
|
6
|
-
const require_index = require("../../utils/index.js");
|
|
7
6
|
const require_useLogger = require("../../hooks/useLogger.js");
|
|
7
|
+
const require_index = require("../../utils/index.js");
|
|
8
8
|
const require_payment_modal_utils = require("./payment-modal-utils.js");
|
|
9
9
|
const require_PaymentModal = require("./PaymentModal.js");
|
|
10
10
|
let react = require("react");
|