@pisell/private-materials 6.12.228 → 6.12.230
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +2 -2
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +2 -2
- package/es/components/HDLKiosk/app/manifest.js +16 -1
- package/es/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +2 -2
- package/es/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +15 -31
- package/es/components/HDLKiosk/docs/08-/346/227/240/345/244/264Application/350/277/220/350/241/214/346/227/266/351/207/215/346/236/204/350/256/276/350/256/241.md +1 -1
- package/es/components/HDLKiosk/kernel/application/defineApplication.js +24 -10
- package/es/components/HDLKiosk/kernel/application/defineSlice.js +3 -1
- package/es/components/HDLKiosk/kernel/application/runtime.js +16 -12
- package/es/components/HDLKiosk/kernel/workflow/actor.js +11 -2
- package/es/components/HDLKiosk/locales.js +30 -0
- package/es/components/HDLKiosk/runtime/admissionPolicy.js +2 -2
- package/es/components/HDLKiosk/runtime/application.js +2 -1
- package/es/components/HDLKiosk/runtime/devices/scannerSessionPort.js +2 -1
- package/es/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +36 -8
- package/es/components/HDLKiosk/runtime/operations/writes.js +4 -1
- package/es/components/HDLKiosk/runtime/session/createSession.js +24 -3
- package/es/components/HDLKiosk/slices/catalog/Screen/index.js +4 -8
- package/es/components/HDLKiosk/slices/catalog/slice.js +2 -2
- package/es/components/HDLKiosk/slices/customization/Screen/index.js +24 -20
- package/es/components/HDLKiosk/slices/customization/Screen/index.less +0 -18
- package/es/components/HDLKiosk/slices/identity/Screen/index.js +16 -2
- package/es/components/HDLKiosk/slices/identity/slice.js +2 -0
- package/es/components/HDLKiosk/slices/identity/view.js +9 -6
- package/es/components/HDLKiosk/slices/primaryProductPrompt/slice.js +3 -3
- package/es/components/HDLKiosk/ui/HDLKioskWorkflowView.js +18 -0
- package/es/components/HDLKiosk/ui/controllers/useHDLKioskCustomerController.js +2 -7
- package/es/components/HDLKiosk/utils.js +6 -11
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +1 -0
- package/es/components/bigSale/components/TimeBar/index.js +1 -0
- package/es/components/bigSale/dialog.js +1 -0
- package/es/components/bigSale/hooks/useBigSaleContext.js +1 -0
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +1 -0
- package/es/components/bigSale/index.js +1 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/createHost.js +2 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +6 -2
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +4 -14
- package/es/components/bigSale/templates/HDLKiosk/hooks/useBigSaleHDLKioskAdapter.js +28 -4
- package/es/components/bigSale/templates/HDLKiosk/index.js +1 -1
- package/es/components/bigSale/templates/HDLKiosk/utils/transactionState.js +12 -12
- package/es/components/bigSale/templates/Kiosk/index.js +1 -0
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +1 -0
- package/es/index.js +2 -0
- package/es/plus/multiCurrencySettlement/index.js +1 -1
- package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
- package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
- package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
- package/es/plus/pisellReservation/index.js +17 -0
- package/es/plus/saasDevice/devicePasscodes/model.js +4 -4
- package/es/plus/saleDetail/Base.js +1 -0
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +1 -0
- package/es/plus/saleDetail/components/DetailActions/PrintAction.js +1 -0
- package/es/plus/saleDetail/components/DetailActions/index.js +1 -0
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +1 -0
- package/es/plus/saleDetail/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +1 -0
- package/es/plus/saleDetail/tmpl/B/index.js +1 -0
- package/es/plus/salesSdk/context/SalesSdkProvider.js +20 -1
- package/es/plus/salesSdk/hooks/useSalesSdkTempOrderSync.js +117 -27
- package/es/plus/salesSdk/index.js +53 -0
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/plus/walletPassGallery/components/timelineSection/index.js +4 -4
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +2 -2
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/HDLKiosk/app/manifest.js +16 -1
- package/lib/components/HDLKiosk/docs/00-/346/226/207/344/273/266/345/257/274/350/210/252.md +2 -2
- package/lib/components/HDLKiosk/docs/04-/350/256/276/345/244/207/344/270/216/347/247/260/351/207/215.md +15 -31
- package/lib/components/HDLKiosk/docs/08-/346/227/240/345/244/264Application/350/277/220/350/241/214/346/227/266/351/207/215/346/236/204/350/256/276/350/256/241.md +1 -1
- package/lib/components/HDLKiosk/kernel/application/defineApplication.js +24 -10
- package/lib/components/HDLKiosk/kernel/application/defineSlice.js +3 -0
- package/lib/components/HDLKiosk/kernel/application/runtime.js +16 -12
- package/lib/components/HDLKiosk/kernel/workflow/actor.js +11 -2
- package/lib/components/HDLKiosk/locales.js +30 -0
- package/lib/components/HDLKiosk/runtime/admissionPolicy.js +2 -2
- package/lib/components/HDLKiosk/runtime/application.js +2 -1
- package/lib/components/HDLKiosk/runtime/devices/scannerSessionPort.js +2 -1
- package/lib/components/HDLKiosk/runtime/devices/scannerSessionRouter.js +36 -8
- package/lib/components/HDLKiosk/runtime/operations/writes.js +4 -1
- package/lib/components/HDLKiosk/runtime/session/createSession.js +24 -3
- package/lib/components/HDLKiosk/slices/catalog/Screen/index.js +4 -8
- package/lib/components/HDLKiosk/slices/catalog/slice.js +1 -1
- package/lib/components/HDLKiosk/slices/customization/Screen/index.js +24 -20
- package/lib/components/HDLKiosk/slices/customization/Screen/index.less +0 -18
- package/lib/components/HDLKiosk/slices/identity/Screen/index.js +16 -2
- package/lib/components/HDLKiosk/slices/identity/slice.js +2 -0
- package/lib/components/HDLKiosk/slices/identity/view.js +9 -6
- package/lib/components/HDLKiosk/slices/primaryProductPrompt/slice.js +2 -2
- package/lib/components/HDLKiosk/ui/HDLKioskWorkflowView.js +20 -2
- package/lib/components/HDLKiosk/ui/controllers/useHDLKioskCustomerController.js +2 -7
- package/lib/components/HDLKiosk/utils.js +8 -13
- package/lib/components/bigSale/templates/HDLKiosk/adapter/createHost.js +2 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +6 -2
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +4 -14
- package/lib/components/bigSale/templates/HDLKiosk/hooks/useBigSaleHDLKioskAdapter.js +28 -4
- package/lib/components/bigSale/templates/HDLKiosk/index.js +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/utils/transactionState.js +12 -12
- package/lib/plus/salesSdk/context/SalesSdkProvider.js +20 -1
- package/lib/plus/salesSdk/hooks/useSalesSdkTempOrderSync.js +117 -27
- package/package.json +2 -2
- package/es/private-materials/lowcode/authmodal/meta.d.ts +0 -1
|
@@ -113,7 +113,7 @@ function normalizePayment(context, cartLineCount, amountDue) {
|
|
|
113
113
|
return Object.freeze({ status: "idle" });
|
|
114
114
|
}
|
|
115
115
|
function projectBigSaleTransactionState(context, observationId = 0) {
|
|
116
|
-
var _context$cart$display, _liveOrder$currency_c, _liveOrder$currency_s, _context$
|
|
116
|
+
var _context$cart$display, _liveOrder$currency_c, _liveOrder$currency_s, _context$sales$bookin3, _context$sales$tempOr, _context$sales$tempOr2, _customer$id, _summary$product_quan;
|
|
117
117
|
const rawLines = (_context$cart$display = context.cart.displayLines) !== null && _context$cart$display !== void 0 ? _context$cart$display : context.cart.items;
|
|
118
118
|
const lines = Object.freeze(rawLines.map(projectBigSaleCartLine).filter((line) => line !== null));
|
|
119
119
|
const summary = context.summary.summary;
|
|
@@ -126,19 +126,12 @@ function projectBigSaleTransactionState(context, observationId = 0) {
|
|
|
126
126
|
total: String(summary.total_amount),
|
|
127
127
|
due: amountDue.toFixed(2)
|
|
128
128
|
}) : context.sales.status === "loading" ? Object.freeze({ status: "calculating" }) : Object.freeze({ status: "missing" });
|
|
129
|
-
const customer = context.
|
|
130
|
-
customerId: String(context.customer.selected.id),
|
|
131
|
-
member: ![
|
|
132
|
-
"0",
|
|
133
|
-
"1",
|
|
134
|
-
""
|
|
135
|
-
].includes(String((_context$customer$sel = context.customer.selected.id) !== null && _context$customer$sel !== void 0 ? _context$customer$sel : ""))
|
|
136
|
-
}) : void 0;
|
|
129
|
+
const customer = typeof ((_context$sales$bookin3 = context.sales.bookingTicket) === null || _context$sales$bookin3 === void 0 ? void 0 : _context$sales$bookin3.getOrderCustomerSnapshot) === "function" ? context.sales.bookingTicket.getOrderCustomerSnapshot() : context.customer.selected;
|
|
137
130
|
const fingerprintValue = [
|
|
138
131
|
(_context$sales$tempOr = (_context$sales$tempOr2 = context.sales.tempOrder) === null || _context$sales$tempOr2 === void 0 ? void 0 : _context$sales$tempOr2.order_id) !== null && _context$sales$tempOr !== void 0 ? _context$sales$tempOr : "",
|
|
139
132
|
...lines.map((line) => `${line.lineId}:${line.quantity}`),
|
|
140
133
|
normalizedSummary.status === "ready" ? normalizedSummary.due : "",
|
|
141
|
-
(_customer$
|
|
134
|
+
(_customer$id = customer === null || customer === void 0 ? void 0 : customer.id) !== null && _customer$id !== void 0 ? _customer$id : ""
|
|
142
135
|
].join("|");
|
|
143
136
|
return Object.freeze({
|
|
144
137
|
observationId,
|
|
@@ -163,9 +156,16 @@ function createBigSaleTransactionStateReader(getContext) {
|
|
|
163
156
|
let previousKey = "";
|
|
164
157
|
let previousSnapshot = projectBigSaleTransactionState(getContext(), observationId);
|
|
165
158
|
return () => {
|
|
159
|
+
var _candidate$customer$i, _candidate$customer;
|
|
166
160
|
const candidate = projectBigSaleTransactionState(getContext(), observationId + 1);
|
|
167
|
-
const semanticKey = JSON.stringify(_objectSpread2(_objectSpread2({}, candidate), {}, {
|
|
168
|
-
|
|
161
|
+
const semanticKey = JSON.stringify(_objectSpread2(_objectSpread2({}, candidate), {}, {
|
|
162
|
+
observationId: 0,
|
|
163
|
+
customer: String((_candidate$customer$i = (_candidate$customer = candidate.customer) === null || _candidate$customer === void 0 ? void 0 : _candidate$customer.id) !== null && _candidate$customer$i !== void 0 ? _candidate$customer$i : "")
|
|
164
|
+
}));
|
|
165
|
+
if (semanticKey === previousKey) {
|
|
166
|
+
if (candidate.customer !== previousSnapshot.customer) previousSnapshot = Object.freeze(_objectSpread2(_objectSpread2({}, candidate), {}, { observationId }));
|
|
167
|
+
return previousSnapshot;
|
|
168
|
+
}
|
|
169
169
|
observationId += 1;
|
|
170
170
|
previousKey = semanticKey;
|
|
171
171
|
previousSnapshot = Object.freeze(_objectSpread2(_objectSpread2({}, candidate), {}, { observationId }));
|
|
@@ -10,6 +10,7 @@ import PaymentResultToastV2_default from "../../../checkout/components/PaymentRe
|
|
|
10
10
|
import { freePayApi } from "../../../Sales/Checkout/serve.js";
|
|
11
11
|
import { collectUnassignedHolderLines } from "../../../../plus/salesSdk/utils/holderSubmitValidation.js";
|
|
12
12
|
import { useSalesSdk } from "../../../../plus/salesSdk/hooks/useSalesSdk.js";
|
|
13
|
+
import "../../../../plus/salesSdk/index.js";
|
|
13
14
|
import { usePickSaleDetailContext } from "../../hooks/usePickSaleDetailContext.js";
|
|
14
15
|
import { resolveBigSaleAutoProductListPreferences } from "../../utils/productListPreferences.js";
|
|
15
16
|
import { resolveBigSaleProductDisplayConfig } from "../../hooks/useBigSaleProductListConfig.js";
|
|
@@ -2,6 +2,7 @@ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/
|
|
|
2
2
|
import useEngineContext from "../../hooks/useEngineContext.js";
|
|
3
3
|
import { useSalesSdk } from "../../plus/salesSdk/hooks/useSalesSdk.js";
|
|
4
4
|
import { getTempOrderSyncPayload, shouldApplySharedTempOrderPayload } from "../../plus/salesSdk/tempOrderSync.js";
|
|
5
|
+
import "../../plus/salesSdk/index.js";
|
|
5
6
|
import { useEffect, useRef } from "react";
|
|
6
7
|
import { useMemoizedFn } from "ahooks";
|
|
7
8
|
//#region src/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.tsx
|
package/es/index.js
CHANGED
|
@@ -86,6 +86,7 @@ import { useSalesSdkProducts } from "./plus/salesSdk/hooks/useSalesSdkProducts.j
|
|
|
86
86
|
import SalesSdkDemo from "./plus/salesSdk/demo/index.js";
|
|
87
87
|
import { useSalesSdkDish } from "./plus/salesSdk/hooks/useSalesSdkDish.js";
|
|
88
88
|
import { useSyncOsModule } from "./plus/salesSdk/hooks/useSyncOsModule.js";
|
|
89
|
+
import "./plus/salesSdk/index.js";
|
|
89
90
|
import BigSaleRightActionPanel from "./components/BigSaleRightActionPanel/index.js";
|
|
90
91
|
import ResponsiveWrapper from "./components/list/ResponsiveWrapper.js";
|
|
91
92
|
import { resolveBigSaleSelectionFlowConfig } from "./components/bigSale/selectionFlowConfig.js";
|
|
@@ -139,6 +140,7 @@ import PisellVenueControlPage from "./plus/pisellReservation/PisellVenueControlP
|
|
|
139
140
|
import PisellVenueWallPage from "./plus/pisellReservation/PisellVenueWallPage.js";
|
|
140
141
|
import PisellReservationTablePage from "./plus/pisellReservation/PisellReservationTablePage.js";
|
|
141
142
|
import SelectFloorMapResourceDialog from "./plus/pisellReservation/components/SelectFloorMapResourceDialog.js";
|
|
143
|
+
import "./plus/pisellReservation/index.js";
|
|
142
144
|
import { PisellTopology, PisellTopologyCore } from "./plus/pisellTopology/PisellTopology.js";
|
|
143
145
|
import cupProject_default from "./components/ecocup/cupProject/index.js";
|
|
144
146
|
import CupList from "./components/ecocup/cupList/index.js";
|
|
@@ -280,4 +280,4 @@ function attachSelectedSettlement(item, selectedSettlement) {
|
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
|
-
export { attachSelectedSettlement, buildSettlementPriceRows, createVirtualOnlySkuDisplayProduct, formatSettlementAmount, formatSettlementSelectionTotal, formatTempOrderSettlementAmount, getSettlementKey, getSettlementOptions, hasSettlementOptions, hasSufficientVirtualCurrencyBalance, isVirtualOnlySettlementProduct, isVirtualSettlementTempOrder, resolveConfiguredUnavailableReason, resolveLegalSettlementAddOnUnitPrice, resolveSettlementOptionEntries, resolveVirtualSettlementErrorMessage, showVirtualSettlementErrorToast };
|
|
283
|
+
export { attachSelectedSettlement, buildSettlementPriceRows, createVirtualOnlySkuDisplayProduct, findFirstVirtualCurrencyAsset, formatSettlementAmount, formatSettlementSelectionTotal, formatTempOrderSettlementAmount, getReservedVirtualSettlementAmount, getSettlementKey, getSettlementOptions, hasSettlementOptions, hasSufficientVirtualCurrencyBalance, isVirtualOnlySettlementProduct, isVirtualSettlementTempOrder, resolveConfiguredUnavailableReason, resolveLegalSettlementAddOnUnitPrice, resolveSettlementOptionEntries, resolveVirtualSettlementErrorMessage, showVirtualSettlementErrorToast };
|
|
@@ -259,4 +259,4 @@ function bookingListToReservationTableRows(bookings) {
|
|
|
259
259
|
return rows;
|
|
260
260
|
}
|
|
261
261
|
//#endregion
|
|
262
|
-
export { applyHostResourceShellToBaseRow, bookingListToReservationTableRows, customerBrief, extractResourceRecordIds, filterBookingsByResourceIds, hostBookingUiPatchFromRecord, mergeBookingsForResourceRecord };
|
|
262
|
+
export { applyHostResourceShellToBaseRow, bookingListToReservationTableRows, customerBrief, extractResourceRecordIds, filterBookingsByResourceIds, hostBookingStatusToCardStatus, hostBookingUiPatchFromRecord, mergeBookingsForResourceRecord };
|
|
@@ -78,4 +78,4 @@ function toastFloorPlanLoadError(err) {
|
|
|
78
78
|
PisellToast({ content: err instanceof Error ? err.message : String(err) });
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
|
-
export { PISELL_RESERVATION_FLOOR_PLAN_CODE, ensureShopFloorPlanByCode, saveViewConfigToShopFloorPlan, shopLayoutToSceneElements$1 as shopLayoutToSceneElements, toastFloorPlanLoadError, toastFloorPlanSaveError, unsubscribeShopFloorPlanCodeQuery };
|
|
81
|
+
export { PISELL_RESERVATION_FLOOR_PLAN_CODE, buildDefaultReservationFloorPlanPostBody, ensureShopFloorPlanByCode, putShopFloorPlan, saveViewConfigToShopFloorPlan, shopLayoutToSceneElements$1 as shopLayoutToSceneElements, toastFloorPlanLoadError, toastFloorPlanSaveError, unsubscribeShopFloorPlanCodeQuery };
|
|
@@ -927,4 +927,4 @@ function getReservationDataSourceFormColumns() {
|
|
|
927
927
|
];
|
|
928
928
|
}
|
|
929
929
|
//#endregion
|
|
930
|
-
export { RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND, RESERVATION_BOUND_TABLE_ELEMENT_KIND, applyReservationFloorMapLiveLabels, defaultReservationTableRows, getDefaultReservationFloorMapConfig, getReservationDataSourceFormColumns, getReservationFloorMapShellConfig, mergeFloorMapElementKindCategoriesWithDefaults, mergeFloorMapElementKindsWithDefaults };
|
|
930
|
+
export { RESERVATION_BOUND_ROUND_TABLE_ELEMENT_KIND, RESERVATION_BOUND_TABLE_ELEMENT_KIND, applyReservationFloorMapLiveLabels, defaultReservationSceneElements, defaultReservationTableRows, getDefaultReservationFloorMapConfig, getReservationDataSourceFormColumns, getReservationFloorMapShellConfig, mergeFloorMapElementKindCategoriesWithDefaults, mergeFloorMapElementKindsWithDefaults };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "./serve/formResourcePage.js";
|
|
2
|
+
import "./floorRoomCard/mapRowToFloorRoomCardData.js";
|
|
3
|
+
import "./floorRoomCard/ReservationFloorRoomCard.js";
|
|
4
|
+
import "./floorMap/reservationMock.js";
|
|
5
|
+
import "./floorMap/floorPlanApi.js";
|
|
6
|
+
import "./reservationConstants.js";
|
|
7
|
+
import "./data/bookingToReservationTables.js";
|
|
8
|
+
import "./data/formResourceToReservationTables.js";
|
|
9
|
+
import "./data/salesEmbeddedResourceToTableRows.js";
|
|
10
|
+
import "./floorMap/reservationCards.js";
|
|
11
|
+
import "./PisellReservation.js";
|
|
12
|
+
import "./PisellReservationBookingPage.js";
|
|
13
|
+
import "./PisellVenueControlPage.js";
|
|
14
|
+
import "./PisellVenueWallPage.js";
|
|
15
|
+
import "./PisellReservationTablePage.js";
|
|
16
|
+
import "./components/SelectFloorMapResourceDialog.js";
|
|
17
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import timezone from "dayjs/plugin/timezone";
|
|
4
|
+
import utc from "dayjs/plugin/utc";
|
|
5
5
|
//#region src/plus/saasDevice/devicePasscodes/model.ts
|
|
6
|
-
dayjs.extend(
|
|
7
|
-
dayjs.extend(
|
|
6
|
+
dayjs.extend(utc);
|
|
7
|
+
dayjs.extend(timezone);
|
|
8
8
|
const INITIAL_DEVICE_PASSCODE_STATE = {
|
|
9
9
|
deviceIds: [],
|
|
10
10
|
devicesById: {}
|
|
@@ -11,6 +11,7 @@ import { useSalesSdkCart } from "../salesSdk/hooks/useSalesSdkCart.js";
|
|
|
11
11
|
import { useSalesSdkCustomer } from "../salesSdk/hooks/useSalesSdkCustomer.js";
|
|
12
12
|
import { useSalesSdkBookingContext } from "../salesSdk/context/SalesSdkBookingContext.js";
|
|
13
13
|
import { useSalesSdkSummary } from "../salesSdk/hooks/useSalesSdkSummary.js";
|
|
14
|
+
import "../salesSdk/index.js";
|
|
14
15
|
import locales_default from "./locales.js";
|
|
15
16
|
import locales_default$1 from "./components/LineItem/locales.js";
|
|
16
17
|
import { SaleOrderActionBoundary } from "./actions/index.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
2
|
import useEngineContext from "../../../../../hooks/useEngineContext.js";
|
|
3
3
|
import { useSalesSdkBookingContext } from "../../../../salesSdk/context/SalesSdkBookingContext.js";
|
|
4
|
+
import "../../../../salesSdk/index.js";
|
|
4
5
|
import { useMemo } from "react";
|
|
5
6
|
import { useMemoizedFn } from "ahooks";
|
|
6
7
|
//#region src/plus/saleDetail/components/Client/hooks/useClientSelectorProps.ts
|
|
@@ -4,6 +4,7 @@ import { _objectWithoutProperties } from "../../../../_virtual/_@oxc-project_run
|
|
|
4
4
|
import useEngineContext from "../../../../hooks/useEngineContext.js";
|
|
5
5
|
import useLogger from "../../../../hooks/useLogger.js";
|
|
6
6
|
import { useSalesSdk } from "../../../salesSdk/hooks/useSalesSdk.js";
|
|
7
|
+
import "../../../salesSdk/index.js";
|
|
7
8
|
import { invokeLocalReceiptPrint, resolveLocalReceiptPrintModule, resolveSaleDetailOrderIdFromSales } from "./utils.js";
|
|
8
9
|
import { getRemotePrintActions, getWristbandList } from "../../serve.js";
|
|
9
10
|
import { EBizPrintType } from "./types.js";
|
|
@@ -9,6 +9,7 @@ import { useSalesSdk } from "../../../salesSdk/hooks/useSalesSdk.js";
|
|
|
9
9
|
import { useSalesSdkCart } from "../../../salesSdk/hooks/useSalesSdkCart.js";
|
|
10
10
|
import { useSalesSdkGlobalScanActivity } from "../../../salesSdk/context/SalesSdkGlobalScanActivityContext.js";
|
|
11
11
|
import { useSalesSdkSummary } from "../../../salesSdk/hooks/useSalesSdkSummary.js";
|
|
12
|
+
import "../../../salesSdk/index.js";
|
|
12
13
|
import { resolveSaleDetailTempOrder } from "../../utils.js";
|
|
13
14
|
import { getNumericAmount, getSalesHostModule, resolveSaleDetailOrderIdFromSales, resolveSaleDetailOrderIdFromSalesResult, shouldCloseDialogAfterCheckout, updateLocalOrder } from "./utils.js";
|
|
14
15
|
import { deriveSaleOrderSubmitState } from "../../actions/state.js";
|
|
@@ -5,6 +5,7 @@ import { isAppliedPaymentRecord } from "../../../salesSdk/utils/paymentStatus.js
|
|
|
5
5
|
import { useSalesSdk } from "../../../salesSdk/hooks/useSalesSdk.js";
|
|
6
6
|
import { useSalesSdkCart } from "../../../salesSdk/hooks/useSalesSdkCart.js";
|
|
7
7
|
import { useSalesSdkSummary } from "../../../salesSdk/hooks/useSalesSdkSummary.js";
|
|
8
|
+
import "../../../salesSdk/index.js";
|
|
8
9
|
import { resolveSaleDetailTempOrder } from "../../utils.js";
|
|
9
10
|
import React, { memo, useMemo } from "react";
|
|
10
11
|
import { formatAmount, locales } from "@pisell/utils";
|
|
@@ -4,6 +4,7 @@ import { useSalesSdk } from "../salesSdk/hooks/useSalesSdk.js";
|
|
|
4
4
|
import { SalesSdkProvider } from "../salesSdk/context/SalesSdkProvider.js";
|
|
5
5
|
import { SalesSdkDishProvider } from "../salesSdk/context/SalesSdkDishContext.js";
|
|
6
6
|
import { SalesSdkBookingContextProvider } from "../salesSdk/context/SalesSdkBookingContext.js";
|
|
7
|
+
import "../salesSdk/index.js";
|
|
7
8
|
import Base_default from "./Base.js";
|
|
8
9
|
import { resolveSaleDetailOsProps } from "./osProps.js";
|
|
9
10
|
import React, { forwardRef, useImperativeHandle } from "react";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import useStableInstanceId from "../../../../../../hooks/useStableInstanceId.js";
|
|
2
2
|
import { useSalesSdkDish } from "../../../../../salesSdk/hooks/useSalesSdkDish.js";
|
|
3
3
|
import { useCurrentSalesSdkDish } from "../../../../../salesSdk/hooks/useCurrentSalesSdkDish.js";
|
|
4
|
+
import "../../../../../salesSdk/index.js";
|
|
4
5
|
import { SaleDetailStatusOverview } from "../shared/StatusOverview.js";
|
|
5
6
|
import { DishGroupView } from "./DishGroupView.js";
|
|
6
7
|
import dayjs from "dayjs";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
2
|
import useEngineContext from "../../../../hooks/useEngineContext.js";
|
|
3
3
|
import { useCurrentSalesSdkDish } from "../../../salesSdk/hooks/useCurrentSalesSdkDish.js";
|
|
4
|
+
import "../../../salesSdk/index.js";
|
|
4
5
|
import { getInternalNotesByScheduleEvent } from "../../serve.js";
|
|
5
6
|
import { TEMPLATE_B_PAY_ACTIONS, TEMPLATE_B_SUMMARY_ACTIONS } from "../../components/DetailActions/configs/index.js";
|
|
6
7
|
import { DetailActions } from "../../components/DetailActions/index.js";
|
|
@@ -163,7 +163,7 @@ function runAfterNextPaint(task) {
|
|
|
163
163
|
* - 新建态:按 OS persist 开关走 createNew 或 restore → initBookingContext
|
|
164
164
|
* 须位于 SalesSdkSummaryProvider 内,以便 summaryProviderRef 已通过 useImperativeHandle 注入。
|
|
165
165
|
*/
|
|
166
|
-
function SalesSdkBootstrap({ autoRestoreOnInit, autoBootstrap, autoInitBookingContext, orderId, preloadedSalesDetail, initBookingContext, prepareModule, prepareCatalog, catalogKey, lifecycleOwner }) {
|
|
166
|
+
function SalesSdkBootstrap({ bootstrapKey, onSettled, autoRestoreOnInit, autoBootstrap, autoInitBookingContext, orderId, preloadedSalesDetail, initBookingContext, prepareModule, prepareCatalog, catalogKey, lifecycleOwner }) {
|
|
167
167
|
const sales = useContext(SalesSdkContext);
|
|
168
168
|
const cart = useSalesSdkCart();
|
|
169
169
|
useEffect(() => {
|
|
@@ -202,6 +202,8 @@ function SalesSdkBootstrap({ autoRestoreOnInit, autoBootstrap, autoInitBookingCo
|
|
|
202
202
|
yield initBookingContext(bookingIds.length ? bookingIds : void 0, { loadResources: !(autoBootstrap && orderId) });
|
|
203
203
|
} catch (e) {
|
|
204
204
|
if (!cancelled) console.warn("[SalesSdk] bootstrap 失败", e);
|
|
205
|
+
} finally {
|
|
206
|
+
if (!cancelled) onSettled(bootstrapKey);
|
|
205
207
|
}
|
|
206
208
|
});
|
|
207
209
|
return function runBootstrap() {
|
|
@@ -215,6 +217,8 @@ function SalesSdkBootstrap({ autoRestoreOnInit, autoBootstrap, autoInitBookingCo
|
|
|
215
217
|
cancelBootstrapStart === null || cancelBootstrapStart === void 0 || cancelBootstrapStart();
|
|
216
218
|
};
|
|
217
219
|
}, [
|
|
220
|
+
bootstrapKey,
|
|
221
|
+
onSettled,
|
|
218
222
|
sales === null || sales === void 0 ? void 0 : sales.bookingTicket,
|
|
219
223
|
sales === null || sales === void 0 ? void 0 : sales.osKey,
|
|
220
224
|
sales === null || sales === void 0 ? void 0 : sales.createNew,
|
|
@@ -383,6 +387,18 @@ const SalesSdkProvider = ({ osKey, enableMultiCurrencySettlement = false, soluti
|
|
|
383
387
|
moduleOtherParams.channel,
|
|
384
388
|
productLoadChannel
|
|
385
389
|
]);
|
|
390
|
+
const bootstrapKey = useMemo(() => Symbol("sales-sdk-bootstrap"), [
|
|
391
|
+
bookingTicket,
|
|
392
|
+
osKey,
|
|
393
|
+
catalogKey,
|
|
394
|
+
lifecycleOwner,
|
|
395
|
+
autoBootstrap,
|
|
396
|
+
autoRestoreOnInit,
|
|
397
|
+
autoInitBookingContext,
|
|
398
|
+
orderId,
|
|
399
|
+
preloadedSalesDetail
|
|
400
|
+
]);
|
|
401
|
+
const [settledBootstrapKey, setSettledBootstrapKey] = useState(null);
|
|
386
402
|
const moduleParamsSyncRef = useRef(null);
|
|
387
403
|
const syncModuleOtherParams = useMemoizedFn(_asyncToGenerator(function* () {
|
|
388
404
|
var _moduleParamsSyncRef$;
|
|
@@ -483,6 +499,7 @@ const SalesSdkProvider = ({ osKey, enableMultiCurrencySettlement = false, soluti
|
|
|
483
499
|
});
|
|
484
500
|
const { publishTempOrder } = useSalesSdkTempOrderSync({
|
|
485
501
|
enabled: enableTempOrderSync,
|
|
502
|
+
ready: !(lifecycleOwner === "provider" && (autoRestoreOnInit || Boolean(autoBootstrap && orderId)) && settledBootstrapKey !== bootstrapKey),
|
|
486
503
|
isActive,
|
|
487
504
|
osKey: (osKey === null || osKey === void 0 || (_osKey$replace = osKey.replace) === null || _osKey$replace === void 0 ? void 0 : _osKey$replace.call(osKey, "bookingTicket-", "")) || osKey,
|
|
488
505
|
bookingTicket,
|
|
@@ -1509,6 +1526,8 @@ const SalesSdkProvider = ({ osKey, enableMultiCurrencySettlement = false, soluti
|
|
|
1509
1526
|
onPromotionScanComplete: handlePromotionScanComplete,
|
|
1510
1527
|
promotionScanSuccessMessageKey: promotionItemIncreaseMessageKey ? void 0 : promotionScanSuccessMessageKey
|
|
1511
1528
|
}), /* @__PURE__ */ React.createElement(SalesSdkBootstrap, {
|
|
1529
|
+
bootstrapKey,
|
|
1530
|
+
onSettled: setSettledBootstrapKey,
|
|
1512
1531
|
autoRestoreOnInit,
|
|
1513
1532
|
autoBootstrap,
|
|
1514
1533
|
autoInitBookingContext,
|
|
@@ -47,7 +47,7 @@ function isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, snapshot) {
|
|
|
47
47
|
* 两端都可发布本地变更、接收同 osKey 快照;页面激活时向更早激活的对端补拉。
|
|
48
48
|
* 远端快照应用期间禁止再次发布,避免 replaceTempOrder 触发 refresh 后形成回环。
|
|
49
49
|
*/
|
|
50
|
-
function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTicket, refreshRootSnapshot }) {
|
|
50
|
+
function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKey, bookingTicket, refreshRootSnapshot }) {
|
|
51
51
|
var _context$appHelper, _context$appHelper$ge, _app$getPlugin, _unifiedCommunication;
|
|
52
52
|
const context = useEngineContext();
|
|
53
53
|
const app = context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 || (_context$appHelper$ge = _context$appHelper.getApp) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper);
|
|
@@ -60,17 +60,24 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
60
60
|
const sourceIdRef = useRef(createSourceId());
|
|
61
61
|
const revisionRef = useRef(0);
|
|
62
62
|
const activeSinceRef = useRef(0);
|
|
63
|
+
const pendingActiveSinceRef = useRef(null);
|
|
63
64
|
const isActiveRef = useRef(isActive);
|
|
65
|
+
const readyRef = useRef(ready);
|
|
64
66
|
const remoteApplyingRef = useRef(false);
|
|
65
67
|
const activationKeyRef = useRef(null);
|
|
66
68
|
const activationEpochRef = useRef(0);
|
|
67
69
|
const pendingRequestIdsRef = useRef(/* @__PURE__ */ new Set());
|
|
70
|
+
const deferredRequestsRef = useRef(/* @__PURE__ */ new Map());
|
|
71
|
+
const deferredPayloadsRef = useRef(/* @__PURE__ */ new Map());
|
|
72
|
+
const needsBootstrapRecoveryRef = useRef(!ready);
|
|
73
|
+
const bootstrapRecoveryRequestRef = useRef(null);
|
|
68
74
|
const lastRevisionBySourceRef = useRef(/* @__PURE__ */ new Map());
|
|
69
75
|
const lastTimestampBySourceRef = useRef(/* @__PURE__ */ new Map());
|
|
70
76
|
const latestOfferedRevisionBySourceRef = useRef(/* @__PURE__ */ new Map());
|
|
71
77
|
const applyQueueRef = useRef(Promise.resolve());
|
|
72
78
|
const lastAppliedRemoteOriginRef = useRef(null);
|
|
73
79
|
isActiveRef.current = isActive;
|
|
80
|
+
readyRef.current = ready;
|
|
74
81
|
const getPeerTarget = useMemoizedFn((role) => resolveTempOrderSyncPeerTarget(role, endpoints));
|
|
75
82
|
/** 在触发发布时一次性深拷贝订单与折扣上下文,避免防抖期间 OS 原地修改造成版本错配。 */
|
|
76
83
|
const captureRuntimeSnapshot = useMemoizedFn((tempOrder, causalOrigin) => {
|
|
@@ -100,7 +107,7 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
100
107
|
});
|
|
101
108
|
const sendTempOrderSnapshot = useMemoizedFn(function() {
|
|
102
109
|
var _ref = _asyncToGenerator(function* (snapshot, options = {}) {
|
|
103
|
-
if (!enabled || !screenRole || !isActiveRef.current) return;
|
|
110
|
+
if (!enabled || !ready || !screenRole || !isActiveRef.current) return;
|
|
104
111
|
if (remoteApplyingRef.current && !options.responseToRequestId) return;
|
|
105
112
|
if (options.incrementRevision !== false) revisionRef.current += 1;
|
|
106
113
|
try {
|
|
@@ -151,15 +158,23 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
151
158
|
});
|
|
152
159
|
const publishTempOrder = useMemoizedFn((tempOrder, options = {}) => {
|
|
153
160
|
var _lastAppliedRemoteOri;
|
|
154
|
-
if (!enabled || !screenRole || !isActiveRef.current || remoteApplyingRef.current) return;
|
|
161
|
+
if (!enabled || !ready || !screenRole || !isActiveRef.current || remoteApplyingRef.current) return;
|
|
155
162
|
const causalOrigin = options.preserveRemoteOrigin ? (_lastAppliedRemoteOri = lastAppliedRemoteOriginRef.current) !== null && _lastAppliedRemoteOri !== void 0 ? _lastAppliedRemoteOri : void 0 : void 0;
|
|
156
|
-
if (!options.preserveRemoteOrigin)
|
|
163
|
+
if (!options.preserveRemoteOrigin) {
|
|
164
|
+
lastAppliedRemoteOriginRef.current = null;
|
|
165
|
+
needsBootstrapRecoveryRef.current = false;
|
|
166
|
+
bootstrapRecoveryRequestRef.current = null;
|
|
167
|
+
}
|
|
157
168
|
debouncedPublish(captureRuntimeSnapshot(tempOrder, causalOrigin));
|
|
158
169
|
});
|
|
159
170
|
const requestPeerSnapshot = useMemoizedFn(_asyncToGenerator(function* () {
|
|
160
|
-
if (!enabled || !screenRole || !bookingTicket || !isActiveRef.current) return;
|
|
171
|
+
if (!enabled || !ready || !screenRole || !bookingTicket || !isActiveRef.current) return;
|
|
161
172
|
const requestId = createRequestId();
|
|
162
173
|
pendingRequestIdsRef.current.add(requestId);
|
|
174
|
+
if (needsBootstrapRecoveryRef.current) bootstrapRecoveryRequestRef.current = {
|
|
175
|
+
requestId,
|
|
176
|
+
localRevision: revisionRef.current
|
|
177
|
+
};
|
|
163
178
|
try {
|
|
164
179
|
var _unifiedCommunication4, _unifiedCommunication5;
|
|
165
180
|
yield unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication4 = unifiedCommunication.sdk) === null || _unifiedCommunication4 === void 0 || (_unifiedCommunication5 = _unifiedCommunication4.publishData) === null || _unifiedCommunication5 === void 0 ? void 0 : _unifiedCommunication5.call(_unifiedCommunication4, {
|
|
@@ -180,19 +195,24 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
180
195
|
console.warn("[SalesSdk] 请求对端 tempOrder 快照失败", error);
|
|
181
196
|
}
|
|
182
197
|
}));
|
|
198
|
+
const isBootstrapRecoveryResponse = useMemoizedFn((payload) => {
|
|
199
|
+
const recovery = bootstrapRecoveryRequestRef.current;
|
|
200
|
+
return Boolean(recovery && payload.responseToRequestId === recovery.requestId && pendingRequestIdsRef.current.has(recovery.requestId) && revisionRef.current === recovery.localRevision);
|
|
201
|
+
});
|
|
183
202
|
const shouldAcceptPayload = useMemoizedFn((payload) => {
|
|
184
203
|
var _lastTimestampBySourc;
|
|
185
204
|
const sourceKey = getPayloadSourceKey(payload);
|
|
186
205
|
const revision = getPayloadRevision(payload);
|
|
187
206
|
if (revision !== null) {
|
|
188
207
|
var _lastRevisionBySource, _latestOfferedRevisio;
|
|
189
|
-
|
|
208
|
+
const lastRevision = (_lastRevisionBySource = lastRevisionBySourceRef.current.get(sourceKey)) !== null && _lastRevisionBySource !== void 0 ? _lastRevisionBySource : -1;
|
|
209
|
+
if (revision < lastRevision || revision === lastRevision && !isBootstrapRecoveryResponse(payload)) return false;
|
|
190
210
|
if (revision < ((_latestOfferedRevisio = latestOfferedRevisionBySourceRef.current.get(sourceKey)) !== null && _latestOfferedRevisio !== void 0 ? _latestOfferedRevisio : -1)) return false;
|
|
191
211
|
latestOfferedRevisionBySourceRef.current.set(sourceKey, revision);
|
|
192
212
|
return true;
|
|
193
213
|
}
|
|
194
214
|
const lastTimestamp = (_lastTimestampBySourc = lastTimestampBySourceRef.current.get(sourceKey)) !== null && _lastTimestampBySourc !== void 0 ? _lastTimestampBySourc : 0;
|
|
195
|
-
return payload.timestamp > lastTimestamp;
|
|
215
|
+
return payload.timestamp > lastTimestamp || payload.timestamp === lastTimestamp && isBootstrapRecoveryResponse(payload);
|
|
196
216
|
});
|
|
197
217
|
const applyPayload = useMemoizedFn((payload) => {
|
|
198
218
|
const requestId = payload.responseToRequestId;
|
|
@@ -202,13 +222,16 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
202
222
|
}
|
|
203
223
|
const activationEpoch = activationEpochRef.current;
|
|
204
224
|
applyQueueRef.current = applyQueueRef.current.then(_asyncToGenerator(function* () {
|
|
205
|
-
|
|
225
|
+
const isCurrentActivation = () => readyRef.current && isActiveRef.current && activationEpochRef.current === activationEpoch && activationKeyRef.current === `${screenRole}:${payload.osKey}`;
|
|
226
|
+
if (!isCurrentActivation()) return;
|
|
206
227
|
const sourceKey = getPayloadSourceKey(payload);
|
|
207
228
|
const revision = getPayloadRevision(payload);
|
|
208
229
|
const isRequestedResponse = Boolean(requestId && pendingRequestIdsRef.current.has(requestId));
|
|
230
|
+
const isRecoveryResponse = isBootstrapRecoveryResponse(payload);
|
|
209
231
|
if (revision !== null) {
|
|
210
232
|
var _lastRevisionBySource2, _latestOfferedRevisio2;
|
|
211
|
-
|
|
233
|
+
const lastApplied = (_lastRevisionBySource2 = lastRevisionBySourceRef.current.get(sourceKey)) !== null && _lastRevisionBySource2 !== void 0 ? _lastRevisionBySource2 : -1;
|
|
234
|
+
if (revision < lastApplied || revision === lastApplied && !isRecoveryResponse) {
|
|
212
235
|
if (requestId) pendingRequestIdsRef.current.delete(requestId);
|
|
213
236
|
return;
|
|
214
237
|
}
|
|
@@ -219,12 +242,12 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
219
242
|
} else {
|
|
220
243
|
var _lastTimestampBySourc2;
|
|
221
244
|
const lastAppliedTimestamp = (_lastTimestampBySourc2 = lastTimestampBySourceRef.current.get(sourceKey)) !== null && _lastTimestampBySourc2 !== void 0 ? _lastTimestampBySourc2 : 0;
|
|
222
|
-
if (payload.timestamp
|
|
245
|
+
if (payload.timestamp < lastAppliedTimestamp || payload.timestamp === lastAppliedTimestamp && !isRecoveryResponse) {
|
|
223
246
|
if (requestId) pendingRequestIdsRef.current.delete(requestId);
|
|
224
247
|
return;
|
|
225
248
|
}
|
|
226
249
|
}
|
|
227
|
-
if (payload.originSourceId === sourceIdRef.current && Number.isSafeInteger(payload.originRevision) && payload.originRevision <= revisionRef.current) {
|
|
250
|
+
if (payload.originSourceId === sourceIdRef.current && Number.isSafeInteger(payload.originRevision) && payload.originRevision <= revisionRef.current && !isRecoveryResponse) {
|
|
228
251
|
lastAppliedRemoteOriginRef.current = null;
|
|
229
252
|
if (requestId) pendingRequestIdsRef.current.delete(requestId);
|
|
230
253
|
if (revision !== null) lastRevisionBySourceRef.current.set(sourceKey, revision);
|
|
@@ -243,6 +266,7 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
243
266
|
try {
|
|
244
267
|
var _bookingTicket$getWal;
|
|
245
268
|
if (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.replaceDiscountStoreLists) yield bookingTicket.replaceDiscountStoreLists(resolvePayloadDiscountState(payload));
|
|
269
|
+
if (!isCurrentActivation()) return;
|
|
246
270
|
if (payload.tempOrder) {
|
|
247
271
|
if (!(bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.replaceTempOrder)) {
|
|
248
272
|
console.warn("[SalesSdk] 当前 BookingTicket 不支持 replaceTempOrder,已跳过双屏同步");
|
|
@@ -253,12 +277,17 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
253
277
|
var _bookingTicket$restor;
|
|
254
278
|
yield bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$restor = bookingTicket.restoreOrder) === null || _bookingTicket$restor === void 0 ? void 0 : _bookingTicket$restor.call(bookingTicket);
|
|
255
279
|
}
|
|
280
|
+
if (!isCurrentActivation()) return;
|
|
256
281
|
if (payload.walletAssetsSnapshot && (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.importWalletAssetsSnapshot)) yield bookingTicket.importWalletAssetsSnapshot(cloneDeep(payload.walletAssetsSnapshot));
|
|
282
|
+
if (!isCurrentActivation()) return;
|
|
257
283
|
const importedWalletSnapshotIsAligned = payload.walletAssetsSnapshot ? isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, payload.walletAssetsSnapshot) : false;
|
|
258
284
|
const currentWalletState = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getWal = bookingTicket.getWalletAssetsState) === null || _bookingTicket$getWal === void 0 ? void 0 : _bookingTicket$getWal.call(bookingTicket);
|
|
259
285
|
const hasWalletRuntimeState = Boolean(currentWalletState && (currentWalletState.items.length > 0 || currentWalletState.selectedIds.length > 0 || currentWalletState.committedIds.length > 0));
|
|
260
286
|
if (payload.tempOrder && (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.refreshWalletAssets) && hasWalletRuntimeState && !importedWalletSnapshotIsAligned) yield bookingTicket.refreshWalletAssets({ preserveSelection: true });
|
|
287
|
+
if (!isCurrentActivation()) return;
|
|
261
288
|
refreshRootSnapshot();
|
|
289
|
+
needsBootstrapRecoveryRef.current = false;
|
|
290
|
+
bootstrapRecoveryRequestRef.current = null;
|
|
262
291
|
if (isRequestedResponse) pendingRequestIdsRef.current.delete(requestId);
|
|
263
292
|
if (revision !== null) lastRevisionBySourceRef.current.set(sourceKey, revision);
|
|
264
293
|
else lastTimestampBySourceRef.current.set(sourceKey, payload.timestamp);
|
|
@@ -272,6 +301,32 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
272
301
|
console.warn("[SalesSdk] tempOrder 同步队列失败", error);
|
|
273
302
|
});
|
|
274
303
|
});
|
|
304
|
+
const respondToSnapshotRequest = useMemoizedFn((request) => {
|
|
305
|
+
if (!enabled || !screenRole || !bookingTicket || !isActiveRef.current) return;
|
|
306
|
+
if (request.sourceId === sourceIdRef.current) return;
|
|
307
|
+
if (request.osKey !== void 0 && request.osKey !== osKey) return;
|
|
308
|
+
if (!ready || activationKeyRef.current !== `${screenRole}:${osKey}`) {
|
|
309
|
+
deferredRequestsRef.current.set(request.requestId, request);
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (!shouldRespondToTempOrderSyncRequest(request, {
|
|
313
|
+
ownRole: screenRole,
|
|
314
|
+
ownActiveSince: activeSinceRef.current
|
|
315
|
+
})) return;
|
|
316
|
+
const queue = applyQueueRef.current;
|
|
317
|
+
const activationEpoch = activationEpochRef.current;
|
|
318
|
+
queue.then(() => {
|
|
319
|
+
var _bookingTicket$getTem, _bookingTicket$getTem2, _lastAppliedRemoteOri2;
|
|
320
|
+
if (queue !== applyQueueRef.current || activationEpoch !== activationEpochRef.current || !readyRef.current || !isActiveRef.current) {
|
|
321
|
+
respondToSnapshotRequest(request);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
sendTempOrderSnapshot(captureRuntimeSnapshot((_bookingTicket$getTem = (_bookingTicket$getTem2 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem2 === void 0 ? void 0 : _bookingTicket$getTem2.call(bookingTicket)) !== null && _bookingTicket$getTem !== void 0 ? _bookingTicket$getTem : null, (_lastAppliedRemoteOri2 = lastAppliedRemoteOriginRef.current) !== null && _lastAppliedRemoteOri2 !== void 0 ? _lastAppliedRemoteOri2 : void 0), {
|
|
325
|
+
incrementRevision: false,
|
|
326
|
+
responseToRequestId: request.requestId
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
});
|
|
275
330
|
useEffect(() => {
|
|
276
331
|
var _unifiedCommunication6, _unifiedCommunication7;
|
|
277
332
|
if (!enabled || !screenRole || !bookingTicket) return;
|
|
@@ -279,17 +334,7 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
279
334
|
if (!isActiveRef.current) return;
|
|
280
335
|
const request = getTempOrderSyncRequestPayload(event);
|
|
281
336
|
if (request) {
|
|
282
|
-
|
|
283
|
-
if (request.sourceId === sourceIdRef.current) return;
|
|
284
|
-
if (request.osKey !== void 0 && request.osKey !== osKey) return;
|
|
285
|
-
if (!shouldRespondToTempOrderSyncRequest(request, {
|
|
286
|
-
ownRole: screenRole,
|
|
287
|
-
ownActiveSince: activeSinceRef.current
|
|
288
|
-
})) return;
|
|
289
|
-
sendTempOrderSnapshot(captureRuntimeSnapshot((_bookingTicket$getTem = (_bookingTicket$getTem2 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem2 === void 0 ? void 0 : _bookingTicket$getTem2.call(bookingTicket)) !== null && _bookingTicket$getTem !== void 0 ? _bookingTicket$getTem : null), {
|
|
290
|
-
incrementRevision: false,
|
|
291
|
-
responseToRequestId: request.requestId
|
|
292
|
-
});
|
|
337
|
+
respondToSnapshotRequest(request);
|
|
293
338
|
return;
|
|
294
339
|
}
|
|
295
340
|
const payload = getTempOrderSyncPayload(event);
|
|
@@ -298,6 +343,17 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
298
343
|
if (payload.sourceId === sourceIdRef.current) return;
|
|
299
344
|
if (payload.isActive === false) return;
|
|
300
345
|
if (payload.sourceRole === screenRole) return;
|
|
346
|
+
if (!readyRef.current) {
|
|
347
|
+
if (payload.responseToRequestId) return;
|
|
348
|
+
const sourceKey = getPayloadSourceKey(payload);
|
|
349
|
+
const previous = deferredPayloadsRef.current.get(sourceKey);
|
|
350
|
+
const revision = getPayloadRevision(payload);
|
|
351
|
+
const previousRevision = previous ? getPayloadRevision(previous) : null;
|
|
352
|
+
if (previous && (revision !== null && previousRevision !== null ? revision < previousRevision || revision === previousRevision && payload.timestamp <= previous.timestamp : payload.timestamp <= previous.timestamp)) return;
|
|
353
|
+
deferredPayloadsRef.current.delete(sourceKey);
|
|
354
|
+
deferredPayloadsRef.current.set(sourceKey, payload);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
301
357
|
applyPayload(payload);
|
|
302
358
|
};
|
|
303
359
|
const listenerHandle = unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication6 = unifiedCommunication.sdk) === null || _unifiedCommunication6 === void 0 || (_unifiedCommunication7 = _unifiedCommunication6.onMessage) === null || _unifiedCommunication7 === void 0 ? void 0 : _unifiedCommunication7.call(_unifiedCommunication6, handleMessage);
|
|
@@ -317,17 +373,30 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
317
373
|
bookingTicket,
|
|
318
374
|
osKey,
|
|
319
375
|
applyPayload,
|
|
320
|
-
|
|
321
|
-
sendTempOrderSnapshot,
|
|
376
|
+
respondToSnapshotRequest,
|
|
322
377
|
unifiedCommunication
|
|
323
378
|
]);
|
|
324
379
|
useEffect(() => {
|
|
325
|
-
|
|
380
|
+
var _pendingActiveSinceRe2;
|
|
381
|
+
if (!ready) {
|
|
382
|
+
needsBootstrapRecoveryRef.current = true;
|
|
383
|
+
lastAppliedRemoteOriginRef.current = null;
|
|
384
|
+
}
|
|
385
|
+
if (!enabled || !screenRole || !bookingTicket || !isActive || !ready) {
|
|
326
386
|
if (activationKeyRef.current !== null) {
|
|
327
387
|
activationEpochRef.current += 1;
|
|
328
388
|
activationKeyRef.current = null;
|
|
329
389
|
}
|
|
330
390
|
pendingRequestIdsRef.current.clear();
|
|
391
|
+
bootstrapRecoveryRequestRef.current = null;
|
|
392
|
+
if (!enabled || !screenRole || !bookingTicket || !isActive) {
|
|
393
|
+
deferredRequestsRef.current.clear();
|
|
394
|
+
deferredPayloadsRef.current.clear();
|
|
395
|
+
pendingActiveSinceRef.current = null;
|
|
396
|
+
} else {
|
|
397
|
+
var _pendingActiveSinceRe;
|
|
398
|
+
(_pendingActiveSinceRe = pendingActiveSinceRef.current) !== null && _pendingActiveSinceRe !== void 0 || (pendingActiveSinceRef.current = Date.now());
|
|
399
|
+
}
|
|
331
400
|
cancelDebouncedPublish();
|
|
332
401
|
return;
|
|
333
402
|
}
|
|
@@ -336,21 +405,42 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
336
405
|
activationEpochRef.current += 1;
|
|
337
406
|
pendingRequestIdsRef.current.clear();
|
|
338
407
|
activationKeyRef.current = activationKey;
|
|
339
|
-
activeSinceRef.current = Date.now();
|
|
340
|
-
|
|
408
|
+
activeSinceRef.current = (_pendingActiveSinceRe2 = pendingActiveSinceRef.current) !== null && _pendingActiveSinceRe2 !== void 0 ? _pendingActiveSinceRe2 : Date.now();
|
|
409
|
+
pendingActiveSinceRef.current = null;
|
|
410
|
+
const activationEpoch = activationEpochRef.current;
|
|
411
|
+
const resumeSync = () => {
|
|
412
|
+
if (!readyRef.current || !isActiveRef.current || activationEpochRef.current !== activationEpoch) return;
|
|
413
|
+
requestPeerSnapshot();
|
|
414
|
+
const deferredRequests = [...deferredRequestsRef.current.values()];
|
|
415
|
+
deferredRequestsRef.current.clear();
|
|
416
|
+
deferredRequests.forEach(respondToSnapshotRequest);
|
|
417
|
+
};
|
|
418
|
+
const deferredPayloads = [...deferredPayloadsRef.current.values()];
|
|
419
|
+
deferredPayloadsRef.current.clear();
|
|
420
|
+
if (deferredPayloads.length) {
|
|
421
|
+
deferredPayloads.forEach(applyPayload);
|
|
422
|
+
applyQueueRef.current.then(resumeSync);
|
|
423
|
+
} else resumeSync();
|
|
341
424
|
}, [
|
|
342
425
|
enabled,
|
|
426
|
+
ready,
|
|
343
427
|
screenRole,
|
|
344
428
|
bookingTicket,
|
|
345
429
|
isActive,
|
|
346
430
|
osKey,
|
|
347
431
|
requestPeerSnapshot,
|
|
432
|
+
respondToSnapshotRequest,
|
|
433
|
+
applyPayload,
|
|
348
434
|
cancelDebouncedPublish
|
|
349
435
|
]);
|
|
350
436
|
useEffect(() => () => {
|
|
351
437
|
activationEpochRef.current += 1;
|
|
352
438
|
activationKeyRef.current = null;
|
|
353
439
|
pendingRequestIdsRef.current.clear();
|
|
440
|
+
bootstrapRecoveryRequestRef.current = null;
|
|
441
|
+
deferredRequestsRef.current.clear();
|
|
442
|
+
deferredPayloadsRef.current.clear();
|
|
443
|
+
pendingActiveSinceRef.current = null;
|
|
354
444
|
cancelDebouncedPublish();
|
|
355
445
|
}, [cancelDebouncedPublish]);
|
|
356
446
|
return {
|