@pisell/private-materials 6.12.169 → 6.12.170
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 +10 -10
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +10 -10
- package/es/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/es/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/es/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/es/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/es/components/HDLKiosk/index.js +10 -2
- package/es/components/HDLKiosk/index.less +7 -2
- package/es/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/es/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/es/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/es/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/es/components/bigSale/components/BookingFloatingPanel/useBookingPanelController.js +0 -1
- package/es/components/bigSale/components/TimeBar/index.js +0 -1
- package/es/components/bigSale/dialog.js +0 -1
- package/es/components/bigSale/hooks/useBigSaleContext.js +0 -1
- package/es/components/bigSale/hooks/useSelectFloorMapResourceForBigSale.js +0 -1
- package/es/components/bigSale/index.js +0 -1
- package/es/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/createHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/es/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +187 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +160 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +124 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +2 -2
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +41 -0
- package/es/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/es/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +122 -0
- package/es/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/es/components/bigSale/templates/HDLKiosk/index.js +40 -146
- package/es/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +15 -59
- package/es/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/es/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/es/components/bigSale/templates/Kiosk/index.js +0 -1
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +0 -1
- package/es/index.js +0 -2
- 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/saleDetail/Base.js +0 -1
- package/es/plus/saleDetail/components/Client/hooks/useClientSelectorProps.js +0 -1
- package/es/plus/saleDetail/components/DetailActions/index.js +0 -1
- package/es/plus/saleDetail/components/SummaryFinancialSections/index.js +0 -1
- package/es/plus/saleDetail/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/components/Dish/index.js +0 -1
- package/es/plus/saleDetail/tmpl/B/index.js +0 -1
- package/es/plus/salesSdk/utils/addProductWithFlowDebounced.js +1 -1
- package/es/plus/salesSdk/utils/bookingDate.js +1 -1
- package/es/plus/salesSdk/utils/customerAuthGate.js +1 -1
- package/es/plus/salesSdk/utils/enrichCartLineHolderDisplay.js +1 -1
- package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
- package/es/pro/Login2.0/AuthModal.d.ts +1 -1
- package/es/pro/Login2.0/index.d.ts +1 -2
- package/es/pro/Login2.0/shared/types.d.ts +1 -1
- package/lib/components/HDLKiosk/components/common/HDLKioskSkuOptionsSelection/index.less +1 -1
- package/lib/components/HDLKiosk/components/overlays/HDLKioskModal/index.less +1 -1
- package/lib/components/HDLKiosk/components/shell/HDLKioskBottomBarHost/index.js +4 -1
- package/lib/components/HDLKiosk/docs/02-Host/351/200/202/351/205/215/344/270/216/344/270/232/345/212/241/346/225/260/346/215/256.md +20 -19
- package/lib/components/HDLKiosk/index.js +10 -2
- package/lib/components/HDLKiosk/index.less +7 -2
- package/lib/components/HDLKiosk/slices/identity/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/slices/payment/Screen/index.less +1 -1
- package/lib/components/HDLKiosk/ui/HDLKioskWorkflowView.js +26 -1
- package/lib/components/HDLKiosk/ui/collaborationStatus.js +11 -0
- package/lib/components/bigSale/templates/HDLKiosk/README.md +43 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/createHost.js +9 -9
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js} +10 -38
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{fulfillment.js → host/fulfillmentWriter.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{telemetry.js → host/telemetry.js} +1 -1
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/cart.js +189 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.js +162 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{customizationProduct.js → sales/customizationProduct.js} +4 -4
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/fulfillment.js +31 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/identity.js +57 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/index.js +18 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/payment.js +123 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/session.js +71 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales/weightedOperations.js +126 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/{weightedProduct.js → sales/weightedProduct.js} +3 -3
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskAdapter.js +42 -0
- package/lib/components/bigSale/templates/HDLKiosk/adapter/useBigSaleHDLKioskHost.js +7 -7
- package/lib/components/bigSale/templates/HDLKiosk/cart/useBigSaleHDLKioskCart.js +124 -0
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → hooks}/useHDLKioskEntryPreparationToast.js +2 -1
- package/lib/components/bigSale/templates/HDLKiosk/index.js +41 -147
- package/lib/components/bigSale/templates/HDLKiosk/{adapter/scaleTrigger.js → runtime/BigSaleScaleRuntimeOwner.js} +14 -59
- package/lib/components/bigSale/templates/HDLKiosk/{adapter → runtime}/HDLKioskPaymentRuntime.js +2 -2
- package/lib/components/bigSale/templates/HDLKiosk/runtime/scaleBridge.js +44 -0
- package/package.json +3 -3
- package/es/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -710
- package/es/plus/pisellReservation/index.js +0 -17
- package/es/plus/salesSdk/index.js +0 -52
- package/lib/components/bigSale/templates/HDLKiosk/adapter/sales.js +0 -712
|
@@ -14,6 +14,7 @@ const require_index$6 = require("../components/common/BlockingNotice/index.js");
|
|
|
14
14
|
const require_utils = require("../utils.js");
|
|
15
15
|
const require_ScreenRenderer = require("./ScreenRenderer.js");
|
|
16
16
|
const require_snapshots = require("./snapshots.js");
|
|
17
|
+
const require_collaborationStatus = require("./collaborationStatus.js");
|
|
17
18
|
let react = require("react");
|
|
18
19
|
react = require_runtime.__toESM(react);
|
|
19
20
|
let _pisell_utils = require("@pisell/utils");
|
|
@@ -55,7 +56,7 @@ function HDLKioskWorkflowBlockingSurface({ snapshot, title, description, referen
|
|
|
55
56
|
* 它把运行时控制器投影为 Screen/Dialog 所需的 props;具体页面不直接接触
|
|
56
57
|
* Host、Workflow Actor 或会话计时器。
|
|
57
58
|
*/
|
|
58
|
-
function HDLKioskWorkflowView({ session, host, sales, config, isActive, returning, returnError, renderIdentityAuth, renderCartContent, cartOverlayActions, returnToEntry }) {
|
|
59
|
+
function HDLKioskWorkflowView({ session, host, sales, config, isActive, returning, returnError, renderIdentityAuth, renderCartContent, cartOverlayActions, onCollaborationStatusChange, returnToEntry }) {
|
|
59
60
|
var _session$definition$n2, _customer$error, _activeNode$presentat;
|
|
60
61
|
const snapshot = require_snapshots.useWorkflowSnapshot(session.actor);
|
|
61
62
|
const navigationSequence = (0, react.useRef)(0);
|
|
@@ -67,6 +68,29 @@ function HDLKioskWorkflowView({ session, host, sales, config, isActive, returnin
|
|
|
67
68
|
});
|
|
68
69
|
const screenDataNode = (_session$definition$n2 = session.definition.nodes[snapshot.surface.pageStepId]) !== null && _session$definition$n2 !== void 0 ? _session$definition$n2 : activeNode;
|
|
69
70
|
const paymentSafeForReset = sales.payment.status === "idle" || sales.payment.status === "failed";
|
|
71
|
+
const screenCollaborationStatus = require_collaborationStatus.resolveHDLKioskCollaborationStatus(screenDataNode.surfaceId);
|
|
72
|
+
const currentCollaborationStatus = (0, react.useRef)("home");
|
|
73
|
+
const statusBeforeCartOpen = (0, react.useRef)("home");
|
|
74
|
+
const cartOpenRef = (0, react.useRef)(false);
|
|
75
|
+
const publishCollaborationStatus = (0, react.useCallback)((status) => {
|
|
76
|
+
if (isActive) onCollaborationStatusChange === null || onCollaborationStatusChange === void 0 || onCollaborationStatusChange(status);
|
|
77
|
+
}, [isActive, onCollaborationStatusChange]);
|
|
78
|
+
const handleCartOpenChange = (0, react.useCallback)((open) => {
|
|
79
|
+
if (open) {
|
|
80
|
+
if (!cartOpenRef.current) statusBeforeCartOpen.current = currentCollaborationStatus.current;
|
|
81
|
+
cartOpenRef.current = true;
|
|
82
|
+
publishCollaborationStatus("cart");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (!cartOpenRef.current) return;
|
|
86
|
+
cartOpenRef.current = false;
|
|
87
|
+
publishCollaborationStatus(statusBeforeCartOpen.current);
|
|
88
|
+
}, [publishCollaborationStatus]);
|
|
89
|
+
(0, react.useEffect)(() => {
|
|
90
|
+
if (!screenCollaborationStatus) return;
|
|
91
|
+
currentCollaborationStatus.current = screenCollaborationStatus;
|
|
92
|
+
if (!cartOpenRef.current) publishCollaborationStatus(screenCollaborationStatus);
|
|
93
|
+
}, [publishCollaborationStatus, screenCollaborationStatus]);
|
|
70
94
|
const { endOrderConfirmationOpen, resetSession, requestEndOrder, cancelEndOrder, confirmEndOrder } = require_useHDLKioskExitController.useHDLKioskExitController({
|
|
71
95
|
session,
|
|
72
96
|
snapshot,
|
|
@@ -160,6 +184,7 @@ function HDLKioskWorkflowView({ session, host, sales, config, isActive, returnin
|
|
|
160
184
|
memberAction,
|
|
161
185
|
variant: screenDataNode.surfaceId === "identity" ? "identityGate" : "default"
|
|
162
186
|
}, /* @__PURE__ */ react.default.createElement(require_index$5.HDLKioskBottomBarHost, {
|
|
187
|
+
onCartOpenChange: handleCartOpenChange,
|
|
163
188
|
mode: ((_activeNode$presentat = activeNode.presentation) === null || _activeNode$presentat === void 0 ? void 0 : _activeNode$presentat.mode) === "modal" || endOrderConfirmationOpen || memberLoginOpen ? "masked" : "visible",
|
|
164
189
|
fallback: endOrderBottomBar,
|
|
165
190
|
cartOverlayActions,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/components/HDLKiosk/ui/collaborationStatus.ts
|
|
2
|
+
/** 把当前可见 Screen 映射为主屏协同预览状态;购物车由 Shell 临时覆盖。 */
|
|
3
|
+
function resolveHDLKioskCollaborationStatus(screenId) {
|
|
4
|
+
if (screenId === "entry") return "home";
|
|
5
|
+
if (screenId === "identity") return "identity";
|
|
6
|
+
if (screenId === "customization" || screenId === "catalog") return "selling";
|
|
7
|
+
if (screenId === "fulfillment") return "fulfillment";
|
|
8
|
+
if (screenId === "checkout") return "checkout";
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.resolveHDLKioskCollaborationStatus = resolveHDLKioskCollaborationStatus;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# BigSale HDLKiosk integration
|
|
2
|
+
|
|
3
|
+
This directory is the compatibility boundary between BigSale/SalesSDK and the
|
|
4
|
+
independent `components/HDLKiosk` material.
|
|
5
|
+
|
|
6
|
+
## Structure
|
|
7
|
+
|
|
8
|
+
- `index.tsx`: outer composition only; renders device owners, HDLKiosk and the
|
|
9
|
+
embedded payment runtime.
|
|
10
|
+
- `adapter/useBigSaleHDLKioskAdapter.ts`: owns late React capabilities and the
|
|
11
|
+
stable Host assembly (payment controller, authenticated customer, scale and
|
|
12
|
+
fulfillment).
|
|
13
|
+
- `adapter/useBigSaleHDLKioskHost.ts`: bridges changing React Context into one
|
|
14
|
+
stable Host and publishes semantic Projection changes.
|
|
15
|
+
- `adapter/createHost.ts`: pure Host composition factory.
|
|
16
|
+
- `adapter/host/`: pure Host support: capabilities, Projection, telemetry and
|
|
17
|
+
the fulfillment writer.
|
|
18
|
+
- `adapter/devices/`: raw BigSale device sources converted to HDLKiosk ports.
|
|
19
|
+
- `adapter/sales/index.ts`: composition-only Sales Port entry.
|
|
20
|
+
- `adapter/sales/`: capability modules for session, catalog, identity,
|
|
21
|
+
fulfillment, cart, weighted products and payment.
|
|
22
|
+
- `runtime/scaleBridge.ts`: owns one Scale Snapshot runtime and one standard
|
|
23
|
+
device-event stream.
|
|
24
|
+
- `runtime/BigSaleScaleRuntimeOwner.tsx`: the only React owner of the native
|
|
25
|
+
scale Hook; publishes exclusively through ScaleBridge.
|
|
26
|
+
- `runtime/HDLKioskPaymentRuntime.tsx`: React-owned payment runtime.
|
|
27
|
+
- `hooks/`: template-level React effects that are not Host adapters.
|
|
28
|
+
- `cart/`: SaleDetail-based cart overlay presentation.
|
|
29
|
+
- `auth/`: BigSale login/register integration.
|
|
30
|
+
|
|
31
|
+
## Boundary rules
|
|
32
|
+
|
|
33
|
+
1. Raw BigSale, SalesSDK and OS objects stop in this directory.
|
|
34
|
+
2. HDLKiosk Core receives only contracts from `components/HDLKiosk/app`.
|
|
35
|
+
3. Reads use Projection snapshots; writes use explicit Host operations.
|
|
36
|
+
4. A stable Host must pair `getSnapshot` with semantic `subscribe`
|
|
37
|
+
notifications. Updating a ref without publishing is not a valid store.
|
|
38
|
+
5. React-owned capabilities are assembled in `useBigSaleHDLKioskAdapter`; do
|
|
39
|
+
not add new controller refs to `index.tsx`.
|
|
40
|
+
6. Add capability-specific code to `adapter/sales/` rather than growing the
|
|
41
|
+
Sales Port composition file with unrelated concerns.
|
|
42
|
+
7. Keep tests beside their capability. Shared BigSale test data belongs in
|
|
43
|
+
`adapter/testing/`, not in a new aggregate adapter suite.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const require_capabilities = require("./capabilities.js");
|
|
2
|
-
const
|
|
3
|
-
const require_projection = require("./projection.js");
|
|
4
|
-
const
|
|
5
|
-
const require_telemetry = require("./telemetry.js");
|
|
1
|
+
const require_capabilities = require("./host/capabilities.js");
|
|
2
|
+
const require_devicePort = require("./devices/devicePort.js");
|
|
3
|
+
const require_projection = require("./host/projection.js");
|
|
4
|
+
const require_index = require("./sales/index.js");
|
|
5
|
+
const require_telemetry = require("./host/telemetry.js");
|
|
6
6
|
//#region src/components/bigSale/templates/HDLKiosk/adapter/createHost.ts
|
|
7
7
|
function createBigSaleHDLKioskHost({ getContext, executeScan, hasScanExecutionSource, devices, writeFulfillment, getWriteFulfillment, getAuthenticatedCustomer, allowSimulatedFulfillment, subscribeProjection, getPickupReferenceMode, getPaymentController }) {
|
|
8
|
-
const
|
|
8
|
+
const resolveScaleEventSource = () => (devices === null || devices === void 0 ? void 0 : devices.getSubscribeScaleEvents) ? devices.getSubscribeScaleEvents() : devices === null || devices === void 0 ? void 0 : devices.subscribeScaleEvents;
|
|
9
9
|
const getSnapshot = require_projection.createBigSaleProjectionReader(getContext, getPickupReferenceMode);
|
|
10
10
|
const telemetry = require_telemetry.createBigSaleTelemetryPort();
|
|
11
11
|
let compatibilityFallbackSequence = 0;
|
|
12
12
|
return {
|
|
13
|
-
sales:
|
|
13
|
+
sales: require_index.createBigSaleSalesPort({
|
|
14
14
|
getContext,
|
|
15
15
|
getSnapshot,
|
|
16
16
|
executeScan,
|
|
@@ -33,11 +33,11 @@ function createBigSaleHDLKioskHost({ getContext, executeScan, hasScanExecutionSo
|
|
|
33
33
|
subscribeProjection,
|
|
34
34
|
getPaymentController
|
|
35
35
|
}),
|
|
36
|
-
devices:
|
|
36
|
+
devices: require_devicePort.createBigSaleDevicePort(devices),
|
|
37
37
|
telemetry,
|
|
38
38
|
get capabilities() {
|
|
39
39
|
return require_capabilities.resolveBigSaleHDLKioskCapabilities(getContext(), {
|
|
40
|
-
hasScaleWeightChangeSource: typeof
|
|
40
|
+
hasScaleWeightChangeSource: typeof resolveScaleEventSource() === "function",
|
|
41
41
|
hasScanExecutionSource: (hasScanExecutionSource === null || hasScanExecutionSource === void 0 ? void 0 : hasScanExecutionSource()) === true
|
|
42
42
|
});
|
|
43
43
|
}
|
package/lib/components/bigSale/templates/HDLKiosk/adapter/{devices.js → devices/devicePort.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/components/bigSale/templates/HDLKiosk/adapter/devices.ts
|
|
1
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/devices/devicePort.ts
|
|
2
2
|
const SCAN_RESULT_EVENT = "nativeScanResult";
|
|
3
3
|
const FALLBACK_DEDUPE_WINDOW_MS = 350;
|
|
4
4
|
function fingerprint(value) {
|
|
@@ -13,7 +13,7 @@ function fingerprint(value) {
|
|
|
13
13
|
* BigSale/PisellOS 原始扫码协议只停留在本文件。缺少宿主 eventId 时使用
|
|
14
14
|
* 非明文 fingerprint + 短窗口合成降级 ID;capability 会保持 stableEventId=false。
|
|
15
15
|
*/
|
|
16
|
-
function createBigSaleDevicePort({ getPubsub, getAcquireScanFocus,
|
|
16
|
+
function createBigSaleDevicePort({ getPubsub, getAcquireScanFocus, subscribeScaleEvents, getSubscribeScaleEvents, now = Date.now } = {}) {
|
|
17
17
|
const listeners = /* @__PURE__ */ new Map();
|
|
18
18
|
let stopScanner;
|
|
19
19
|
let stopScale;
|
|
@@ -82,44 +82,16 @@ function createBigSaleDevicePort({ getPubsub, getAcquireScanFocus, subscribeWeig
|
|
|
82
82
|
} catch (_unused5) {}
|
|
83
83
|
};
|
|
84
84
|
const connectScale = () => {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const cleanup = currentSubscribeWeightChange((payload) => {
|
|
91
|
-
var _payload$occurredAt, _payload$eventId;
|
|
92
|
-
const occurredAt = (_payload$occurredAt = payload.occurredAt) !== null && _payload$occurredAt !== void 0 ? _payload$occurredAt : now();
|
|
93
|
-
eventSequence += 1;
|
|
94
|
-
emit("scale", {
|
|
95
|
-
type: "weightChanged",
|
|
96
|
-
eventId: (_payload$eventId = payload.eventId) !== null && _payload$eventId !== void 0 ? _payload$eventId : `big-sale-scale:${occurredAt}:${eventSequence}`,
|
|
97
|
-
weight: payload.weight,
|
|
98
|
-
occurredAt
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
if (typeof cleanup === "function") cleanups.push(cleanup);
|
|
102
|
-
} catch (_unused6) {}
|
|
103
|
-
if (currentSubscribeScaleConnection) try {
|
|
104
|
-
const cleanup = currentSubscribeScaleConnection((payload) => {
|
|
105
|
-
var _payload$occurredAt2;
|
|
106
|
-
emit("scale", {
|
|
107
|
-
type: "connectionChanged",
|
|
108
|
-
device: "scale",
|
|
109
|
-
connected: payload.connected,
|
|
110
|
-
state: payload.state,
|
|
111
|
-
occurredAt: (_payload$occurredAt2 = payload.occurredAt) !== null && _payload$occurredAt2 !== void 0 ? _payload$occurredAt2 : now()
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
if (typeof cleanup === "function") cleanups.push(cleanup);
|
|
115
|
-
} catch (_unused7) {}
|
|
116
|
-
stopScale = () => {
|
|
117
|
-
cleanups.forEach((cleanup) => {
|
|
85
|
+
const currentSubscribe = getSubscribeScaleEvents ? getSubscribeScaleEvents() : subscribeScaleEvents;
|
|
86
|
+
if (stopScale || !currentSubscribe) return;
|
|
87
|
+
try {
|
|
88
|
+
const cleanup = currentSubscribe((event) => emit("scale", event));
|
|
89
|
+
stopScale = () => {
|
|
118
90
|
try {
|
|
119
91
|
cleanup();
|
|
120
|
-
} catch (
|
|
121
|
-
}
|
|
122
|
-
}
|
|
92
|
+
} catch (_unused6) {}
|
|
93
|
+
};
|
|
94
|
+
} catch (_unused7) {}
|
|
123
95
|
};
|
|
124
96
|
const syncConnections = () => {
|
|
125
97
|
const scannerNeeded = Array.from(listeners.values()).some((sources) => sources.has("scanner"));
|
package/lib/components/bigSale/templates/HDLKiosk/adapter/{capabilities.js → host/capabilities.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/components/bigSale/templates/HDLKiosk/adapter/capabilities.ts
|
|
1
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/host/capabilities.ts
|
|
2
2
|
function resolveBigSaleHDLKioskCapabilities(context, options = {}) {
|
|
3
3
|
var _bookingTicket$store;
|
|
4
4
|
const bookingTicket = context.sales.bookingTicket;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_asyncToGenerator = require("
|
|
2
|
-
const require_normalize = require("
|
|
3
|
-
//#region src/components/bigSale/templates/HDLKiosk/adapter/
|
|
1
|
+
const require_asyncToGenerator = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
const require_normalize = require("../normalize.js");
|
|
3
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/host/fulfillmentWriter.ts
|
|
4
4
|
function createHDLKioskFulfillmentWriter(runtime) {
|
|
5
5
|
if (typeof (runtime === null || runtime === void 0 ? void 0 : runtime.setPickupReferenceMode) !== "function" || typeof (runtime === null || runtime === void 0 ? void 0 : runtime.setServiceType) !== "function") return;
|
|
6
6
|
const setPickupReferenceMode = runtime.setPickupReferenceMode.bind(runtime);
|
package/lib/components/bigSale/templates/HDLKiosk/adapter/{projection.js → host/projection.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const require_runtime = require("
|
|
2
|
-
const require_objectSpread2 = require("
|
|
3
|
-
const require_resolveSkuValue = require("
|
|
1
|
+
const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_objectSpread2 = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
+
const require_resolveSkuValue = require("../../../../../../plus/skuOptionsSelection/utils/resolveSkuValue.js");
|
|
4
4
|
let decimal_js = require("decimal.js");
|
|
5
5
|
decimal_js = require_runtime.__toESM(decimal_js);
|
|
6
|
-
//#region src/components/bigSale/templates/HDLKiosk/adapter/projection.ts
|
|
6
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/host/projection.ts
|
|
7
7
|
/**
|
|
8
8
|
* 文件角色:把 BigSale/SalesSDK 当前状态投影成 HDLKiosk 只读业务快照。
|
|
9
9
|
* 运行机制:归一化订单行、称重数量、Summary、Customer、Payment 和 fingerprint,
|
|
@@ -0,0 +1,189 @@
|
|
|
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
|
+
const require_normalize = require("../normalize.js");
|
|
4
|
+
const require_projection = require("../host/projection.js");
|
|
5
|
+
const require_catalog = require("./catalog.js");
|
|
6
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/cart.ts
|
|
7
|
+
function cancelled(reason) {
|
|
8
|
+
return {
|
|
9
|
+
status: "cancelled",
|
|
10
|
+
reason
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function findCartLine(context, lineId) {
|
|
14
|
+
var _context$cart$display;
|
|
15
|
+
return ((_context$cart$display = context.cart.displayLines) !== null && _context$cart$display !== void 0 ? _context$cart$display : context.cart.items).find((line) => require_projection.resolveBigSaleLineId(line) === lineId);
|
|
16
|
+
}
|
|
17
|
+
function projectConfirmedMutationLine(product) {
|
|
18
|
+
var _projectBigSaleCartLi;
|
|
19
|
+
return product ? (_projectBigSaleCartLi = require_projection.projectBigSaleCartLine(product)) !== null && _projectBigSaleCartLi !== void 0 ? _projectBigSaleCartLi : void 0 : void 0;
|
|
20
|
+
}
|
|
21
|
+
function projectConfirmedCartLineById(products, lineId) {
|
|
22
|
+
return projectConfirmedMutationLine(products.find((candidate) => require_projection.resolveBigSaleLineId(candidate) === lineId));
|
|
23
|
+
}
|
|
24
|
+
function createBigSaleCartOperations({ getContext, getSnapshot, executeScan }) {
|
|
25
|
+
return {
|
|
26
|
+
consumeBarcode: function() {
|
|
27
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (code, signal) {
|
|
28
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
29
|
+
if (!code.trim()) return require_normalize.failed("barcodeEmpty", "back");
|
|
30
|
+
try {
|
|
31
|
+
var _scanResult$meta$coun, _scanResult$meta;
|
|
32
|
+
const execution = yield executeScan(code);
|
|
33
|
+
if (signal.aborted) return require_normalize.unknown("barcodeAbortedAfterDispatch");
|
|
34
|
+
const scanResult = execution.scanResult;
|
|
35
|
+
if (!scanResult) return require_normalize.failed("barcodeUnavailable", "staff");
|
|
36
|
+
if (scanResult.status === "cancelled") return {
|
|
37
|
+
status: "cancelled",
|
|
38
|
+
reason: scanResult.reason
|
|
39
|
+
};
|
|
40
|
+
if (scanResult.status === "failed") return require_normalize.failed("barcodeNotResolved", "retry");
|
|
41
|
+
return {
|
|
42
|
+
status: "succeeded",
|
|
43
|
+
data: {
|
|
44
|
+
code: scanResult.status === "pending" ? "requiresSelection" : "added",
|
|
45
|
+
cartChangeConfirmed: scanResult.status === "success" && Number((_scanResult$meta$coun = (_scanResult$meta = scanResult.meta) === null || _scanResult$meta === void 0 ? void 0 : _scanResult$meta.count) !== null && _scanResult$meta$coun !== void 0 ? _scanResult$meta$coun : 0) > 0
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return require_normalize.partialFailure("barcodeDispatchFailed", error);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return function consumeBarcode(_x, _x2) {
|
|
53
|
+
return _ref.apply(this, arguments);
|
|
54
|
+
};
|
|
55
|
+
}(),
|
|
56
|
+
addProduct: function() {
|
|
57
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (input, signal) {
|
|
58
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
59
|
+
const productId = Number(input.productId);
|
|
60
|
+
const quantity = Number(input.quantity);
|
|
61
|
+
if (!Number.isFinite(productId) || !Number.isFinite(quantity) || quantity <= 0) return require_normalize.failed("productInputInvalid", "back");
|
|
62
|
+
try {
|
|
63
|
+
const context = getContext();
|
|
64
|
+
const product = require_catalog.findCatalogProduct(context, String(productId));
|
|
65
|
+
if (!product) return require_normalize.failed("productNotFound", "back");
|
|
66
|
+
const result = yield context.cart.addProductWithFlow(product, {
|
|
67
|
+
quantity,
|
|
68
|
+
notShowToast: true
|
|
69
|
+
});
|
|
70
|
+
if (signal.aborted) return require_normalize.unknown("addProductAbortedAfterDispatch");
|
|
71
|
+
if (result.status === "cancelled") return cancelled("userCancelled");
|
|
72
|
+
if (result.status !== "added") return require_normalize.failed("productRequiresUnsupportedSelection", "back");
|
|
73
|
+
const confirmedLine = projectConfirmedMutationLine([...Array.isArray(result.products) ? result.products : []].reverse().find((candidate) => {
|
|
74
|
+
var _candidate$product_id;
|
|
75
|
+
return String((_candidate$product_id = candidate.product_id) !== null && _candidate$product_id !== void 0 ? _candidate$product_id : "") === input.productId;
|
|
76
|
+
}));
|
|
77
|
+
return {
|
|
78
|
+
status: "succeeded",
|
|
79
|
+
data: confirmedLine ? {
|
|
80
|
+
affectedLineId: confirmedLine.lineId,
|
|
81
|
+
confirmedLine
|
|
82
|
+
} : {}
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return require_normalize.partialFailure("addProductFailed", error);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return function addProduct(_x3, _x4) {
|
|
89
|
+
return _ref2.apply(this, arguments);
|
|
90
|
+
};
|
|
91
|
+
}(),
|
|
92
|
+
updateQuantity: function() {
|
|
93
|
+
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (input, signal) {
|
|
94
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
95
|
+
const quantity = Number(input.quantity);
|
|
96
|
+
if (!Number.isFinite(quantity) || quantity <= 0) return require_normalize.failed("quantityInvalid", "back");
|
|
97
|
+
const context = getContext();
|
|
98
|
+
const line = findCartLine(context, input.lineId);
|
|
99
|
+
if (!line) return require_normalize.failed("cartLineNotFound", "back");
|
|
100
|
+
try {
|
|
101
|
+
const updatedProducts = yield context.cart.updateItemQuantity(line, quantity);
|
|
102
|
+
if (signal.aborted) return require_normalize.unknown("updateQuantityAbortedAfterDispatch");
|
|
103
|
+
const confirmedLine = projectConfirmedCartLineById(Array.isArray(updatedProducts) ? updatedProducts : [], input.lineId);
|
|
104
|
+
return {
|
|
105
|
+
status: "succeeded",
|
|
106
|
+
data: require_objectSpread2._objectSpread2({ affectedLineId: input.lineId }, confirmedLine ? { confirmedLine } : {})
|
|
107
|
+
};
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return require_normalize.partialFailure("updateQuantityFailed", error);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return function updateQuantity(_x5, _x6) {
|
|
113
|
+
return _ref3.apply(this, arguments);
|
|
114
|
+
};
|
|
115
|
+
}(),
|
|
116
|
+
removeLine: function() {
|
|
117
|
+
var _ref4 = require_asyncToGenerator._asyncToGenerator(function* (input, signal) {
|
|
118
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
119
|
+
const context = getContext();
|
|
120
|
+
const line = findCartLine(context, input.lineId);
|
|
121
|
+
if (!line) return require_normalize.failed("cartLineNotFound", "back");
|
|
122
|
+
try {
|
|
123
|
+
const remainingProducts = yield context.cart.removeItem(line);
|
|
124
|
+
if (signal.aborted) return require_normalize.unknown("removeLineAbortedAfterDispatch");
|
|
125
|
+
return {
|
|
126
|
+
status: "succeeded",
|
|
127
|
+
data: require_objectSpread2._objectSpread2({ affectedLineId: input.lineId }, Array.isArray(remainingProducts) && !remainingProducts.some((candidate) => require_projection.resolveBigSaleLineId(candidate) === input.lineId) ? { removedLineId: input.lineId } : {})
|
|
128
|
+
};
|
|
129
|
+
} catch (error) {
|
|
130
|
+
return require_normalize.partialFailure("removeLineFailed", error);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return function removeLine(_x7, _x8) {
|
|
134
|
+
return _ref4.apply(this, arguments);
|
|
135
|
+
};
|
|
136
|
+
}(),
|
|
137
|
+
waitForCartConsistency: function() {
|
|
138
|
+
var _ref5 = require_asyncToGenerator._asyncToGenerator(function* (signal) {
|
|
139
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
140
|
+
try {
|
|
141
|
+
yield getContext().cart.waitForCartConsistency();
|
|
142
|
+
if (signal.aborted) return require_normalize.unknown("consistencyAbortedAfterWait");
|
|
143
|
+
return {
|
|
144
|
+
status: "succeeded",
|
|
145
|
+
data: { observationId: getSnapshot().observationId }
|
|
146
|
+
};
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return require_normalize.failed("cartConsistencyFailed", "retry", error);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return function waitForCartConsistency(_x9) {
|
|
152
|
+
return _ref5.apply(this, arguments);
|
|
153
|
+
};
|
|
154
|
+
}(),
|
|
155
|
+
recalculateSummary: function() {
|
|
156
|
+
var _ref6 = require_asyncToGenerator._asyncToGenerator(function* (signal) {
|
|
157
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
158
|
+
try {
|
|
159
|
+
var _getContext$sales$tem, _getContext$sales$tem2, _getContext$sales$tem3, _getContext$sales$tem4;
|
|
160
|
+
const summary = yield getContext().cart.recalcSummary();
|
|
161
|
+
if (signal.aborted) return require_normalize.unknown("summaryAbortedAfterDispatch");
|
|
162
|
+
if (!summary) return require_normalize.failed("summaryMissing", "retry");
|
|
163
|
+
return {
|
|
164
|
+
status: "succeeded",
|
|
165
|
+
data: {
|
|
166
|
+
observationId: getSnapshot().observationId,
|
|
167
|
+
confirmedSummary: {
|
|
168
|
+
status: "ready",
|
|
169
|
+
currency: String((_getContext$sales$tem = (_getContext$sales$tem2 = getContext().sales.tempOrder) === null || _getContext$sales$tem2 === void 0 ? void 0 : _getContext$sales$tem2.currency_code) !== null && _getContext$sales$tem !== void 0 ? _getContext$sales$tem : ""),
|
|
170
|
+
currencySymbol: String((_getContext$sales$tem3 = (_getContext$sales$tem4 = getContext().sales.tempOrder) === null || _getContext$sales$tem4 === void 0 ? void 0 : _getContext$sales$tem4.currency_symbol) !== null && _getContext$sales$tem3 !== void 0 ? _getContext$sales$tem3 : ""),
|
|
171
|
+
total: String(summary.total_amount),
|
|
172
|
+
due: String(summary.expect_amount)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
return require_normalize.failed("summaryRecalculationFailed", "retry", error);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return function recalculateSummary(_x10) {
|
|
181
|
+
return _ref6.apply(this, arguments);
|
|
182
|
+
};
|
|
183
|
+
}()
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
exports.createBigSaleCartOperations = createBigSaleCartOperations;
|
|
188
|
+
exports.findCartLine = findCartLine;
|
|
189
|
+
exports.projectConfirmedMutationLine = projectConfirmedMutationLine;
|
|
@@ -0,0 +1,162 @@
|
|
|
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
|
+
const require_pricePresentation = require("../../../../../../plus/productSelect/pricing/pricePresentation.js");
|
|
4
|
+
const require_normalize = require("../normalize.js");
|
|
5
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/catalog.ts
|
|
6
|
+
function findCatalogProduct(context, productId) {
|
|
7
|
+
return context.products.products.find((product) => String(product.id) === productId);
|
|
8
|
+
}
|
|
9
|
+
function resolveProductQuery(context) {
|
|
10
|
+
var _bookingTicket$store;
|
|
11
|
+
if (typeof context.products.queryProducts === "function") return function() {
|
|
12
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (params) {
|
|
13
|
+
return (yield context.products.queryProducts.call(context.products, params)) || [];
|
|
14
|
+
});
|
|
15
|
+
return function(_x) {
|
|
16
|
+
return _ref.apply(this, arguments);
|
|
17
|
+
};
|
|
18
|
+
}();
|
|
19
|
+
const bookingTicket = context.sales.bookingTicket;
|
|
20
|
+
if (typeof (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.queryProducts) === "function") return function() {
|
|
21
|
+
var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (params) {
|
|
22
|
+
return (yield bookingTicket.queryProducts(params)) || [];
|
|
23
|
+
});
|
|
24
|
+
return function(_x2) {
|
|
25
|
+
return _ref2.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
}();
|
|
28
|
+
const productListStore = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$store = bookingTicket.store) === null || _bookingTicket$store === void 0 ? void 0 : _bookingTicket$store.products;
|
|
29
|
+
if (typeof (productListStore === null || productListStore === void 0 ? void 0 : productListStore.queryProducts) === "function") return function() {
|
|
30
|
+
var _ref3 = require_asyncToGenerator._asyncToGenerator(function* (params) {
|
|
31
|
+
return (yield productListStore.queryProducts.call(productListStore, params)) || [];
|
|
32
|
+
});
|
|
33
|
+
return function(_x3) {
|
|
34
|
+
return _ref3.apply(this, arguments);
|
|
35
|
+
};
|
|
36
|
+
}();
|
|
37
|
+
}
|
|
38
|
+
function queryPrimaryProduct(_x4, _x5, _x6) {
|
|
39
|
+
return _queryPrimaryProduct.apply(this, arguments);
|
|
40
|
+
}
|
|
41
|
+
function _queryPrimaryProduct() {
|
|
42
|
+
_queryPrimaryProduct = require_asyncToGenerator._asyncToGenerator(function* (context, productId, signal) {
|
|
43
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
44
|
+
const queryProducts = resolveProductQuery(context);
|
|
45
|
+
if (!queryProducts) return require_normalize.failed("primaryProductQueryUnavailable", "staff");
|
|
46
|
+
try {
|
|
47
|
+
let products = yield queryProducts({ includeIds: [productId] });
|
|
48
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
49
|
+
let product = products.find((candidate) => String(candidate.id) === productId);
|
|
50
|
+
const numericProductId = Number(productId);
|
|
51
|
+
if (!product && Number.isSafeInteger(numericProductId) && numericProductId > 0 && typeof context.products.findByIds === "function") {
|
|
52
|
+
yield context.products.findByIds([numericProductId], {
|
|
53
|
+
loadMissing: true,
|
|
54
|
+
refreshCatalog: false
|
|
55
|
+
});
|
|
56
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
57
|
+
products = yield queryProducts({ includeIds: [productId] });
|
|
58
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
59
|
+
product = products.find((candidate) => String(candidate.id) === productId);
|
|
60
|
+
}
|
|
61
|
+
return product ? {
|
|
62
|
+
status: "succeeded",
|
|
63
|
+
data: product
|
|
64
|
+
} : require_normalize.failed("primaryProductNotFound", "staff");
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return require_normalize.partialFailure("primaryProductQueryFailed", error);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return _queryPrimaryProduct.apply(this, arguments);
|
|
70
|
+
}
|
|
71
|
+
function readProductName(product) {
|
|
72
|
+
const rawName = product.title;
|
|
73
|
+
if (typeof rawName === "string") return rawName || void 0;
|
|
74
|
+
if (!rawName || typeof rawName !== "object") return void 0;
|
|
75
|
+
return Object.values(rawName).find((value) => typeof value === "string" && value.length > 0);
|
|
76
|
+
}
|
|
77
|
+
function readLocalizedText(value) {
|
|
78
|
+
if (typeof value === "string") return value || void 0;
|
|
79
|
+
if (!value || typeof value !== "object") return void 0;
|
|
80
|
+
return Object.values(value).find((item) => typeof item === "string" && item.length > 0);
|
|
81
|
+
}
|
|
82
|
+
function projectProductCategories(product) {
|
|
83
|
+
const directCategories = Array.isArray(product.category) ? product.category : [];
|
|
84
|
+
const categories = /* @__PURE__ */ new Map();
|
|
85
|
+
const visit = (category, direct) => {
|
|
86
|
+
var _category$name, _ref4, _category$parent_id;
|
|
87
|
+
if (!category || category.id === void 0 || category.id === null) return;
|
|
88
|
+
const parent = category.parent_category;
|
|
89
|
+
visit(parent, false);
|
|
90
|
+
const categoryId = String(category.id);
|
|
91
|
+
const name = readLocalizedText((_category$name = category.name) !== null && _category$name !== void 0 ? _category$name : category.title);
|
|
92
|
+
if (!name) return;
|
|
93
|
+
const parentId = (_ref4 = (_category$parent_id = category.parent_id) !== null && _category$parent_id !== void 0 ? _category$parent_id : parent === null || parent === void 0 ? void 0 : parent.id) !== null && _ref4 !== void 0 ? _ref4 : void 0;
|
|
94
|
+
const previous = categories.get(categoryId);
|
|
95
|
+
categories.set(categoryId, Object.freeze({
|
|
96
|
+
categoryId,
|
|
97
|
+
name,
|
|
98
|
+
parentId: parentId === void 0 || parentId === null || parentId === 0 ? void 0 : String(parentId),
|
|
99
|
+
sort: Number.isFinite(Number(category.sort)) ? Number(category.sort) : void 0,
|
|
100
|
+
direct: direct || (previous === null || previous === void 0 ? void 0 : previous.direct) === true
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
directCategories.forEach((category) => visit(category, true));
|
|
104
|
+
return Object.freeze(Array.from(categories.values()));
|
|
105
|
+
}
|
|
106
|
+
function projectCatalogProduct(product, currency, currencySymbol) {
|
|
107
|
+
var _ref5, _ref6, _product$price, _product$variants, _product$variants2;
|
|
108
|
+
const name = readProductName(product);
|
|
109
|
+
if (!name) return void 0;
|
|
110
|
+
const rawPrice = (_ref5 = (_ref6 = (_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : product.selling_price) !== null && _ref6 !== void 0 ? _ref6 : (_product$variants = product.variants) === null || _product$variants === void 0 || (_product$variants = _product$variants[0]) === null || _product$variants === void 0 ? void 0 : _product$variants.selling_price) !== null && _ref5 !== void 0 ? _ref5 : (_product$variants2 = product.variants) === null || _product$variants2 === void 0 || (_product$variants2 = _product$variants2[0]) === null || _product$variants2 === void 0 ? void 0 : _product$variants2.price;
|
|
111
|
+
const pricePresentation = require_pricePresentation.resolveProductPricePresentation(product, rawPrice === void 0 || rawPrice === null ? void 0 : { price: rawPrice });
|
|
112
|
+
const categories = projectProductCategories(product);
|
|
113
|
+
return Object.freeze(require_objectSpread2._objectSpread2({
|
|
114
|
+
productId: String(product.id),
|
|
115
|
+
name,
|
|
116
|
+
imageUrl: product.cover || void 0,
|
|
117
|
+
currency: currency || void 0,
|
|
118
|
+
currencySymbol: currencySymbol || void 0,
|
|
119
|
+
pricePresentation: pricePresentation ? Object.freeze({
|
|
120
|
+
amount: String(pricePresentation.amount),
|
|
121
|
+
originalAmount: pricePresentation.originalAmount === void 0 ? void 0 : String(pricePresentation.originalAmount),
|
|
122
|
+
qualifier: pricePresentation.qualifier,
|
|
123
|
+
unit: pricePresentation.unit,
|
|
124
|
+
precision: pricePresentation.precision
|
|
125
|
+
}) : void 0,
|
|
126
|
+
available: product.status !== "disabled" && product.status !== "sold_out" && product.is_sold_out !== true
|
|
127
|
+
}, categories.length ? { categories } : {}));
|
|
128
|
+
}
|
|
129
|
+
function createBigSaleCatalogOperations({ getContext }) {
|
|
130
|
+
return {
|
|
131
|
+
getCatalogSnapshot: () => {
|
|
132
|
+
var _context$sales$tempOr, _context$sales$tempOr2, _context$sales$tempOr3, _context$sales$tempOr4;
|
|
133
|
+
const context = getContext();
|
|
134
|
+
const currency = String((_context$sales$tempOr = (_context$sales$tempOr2 = context.sales.tempOrder) === null || _context$sales$tempOr2 === void 0 ? void 0 : _context$sales$tempOr2.currency_code) !== null && _context$sales$tempOr !== void 0 ? _context$sales$tempOr : "");
|
|
135
|
+
const currencySymbol = String((_context$sales$tempOr3 = (_context$sales$tempOr4 = context.sales.tempOrder) === null || _context$sales$tempOr4 === void 0 ? void 0 : _context$sales$tempOr4.currency_symbol) !== null && _context$sales$tempOr3 !== void 0 ? _context$sales$tempOr3 : "");
|
|
136
|
+
const products = context.products.products.map((product) => projectCatalogProduct(product, currency, currencySymbol)).filter((product) => product !== void 0);
|
|
137
|
+
return Object.freeze({
|
|
138
|
+
status: context.products.error ? "error" : context.products.loading || context.sales.catalogState === "pending" ? "loading" : "ready",
|
|
139
|
+
products: Object.freeze(products)
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
loadPrimaryProduct: function() {
|
|
143
|
+
var _ref7 = require_asyncToGenerator._asyncToGenerator(function* (rawProductId, signal) {
|
|
144
|
+
if (signal.aborted) return { status: "cancelled" };
|
|
145
|
+
const productId = Number(rawProductId);
|
|
146
|
+
if (!Number.isFinite(productId)) return require_normalize.failed("primaryProductIdInvalid", "staff");
|
|
147
|
+
try {
|
|
148
|
+
return yield queryPrimaryProduct(getContext(), String(productId), signal);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
return require_normalize.partialFailure("primaryProductLoadFailed", error);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return function loadPrimaryProduct(_x7, _x8) {
|
|
154
|
+
return _ref7.apply(this, arguments);
|
|
155
|
+
};
|
|
156
|
+
}()
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
exports.createBigSaleCatalogOperations = createBigSaleCatalogOperations;
|
|
161
|
+
exports.findCatalogProduct = findCatalogProduct;
|
|
162
|
+
exports.queryPrimaryProduct = queryPrimaryProduct;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_runtime = require("
|
|
2
|
-
const require_objectSpread2 = require("
|
|
3
|
-
const require_validateSkuValue = require("
|
|
1
|
+
const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_objectSpread2 = require("../../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
+
const require_validateSkuValue = require("../../../../../../plus/skuOptionsSelection/utils/validateSkuValue.js");
|
|
4
4
|
const require_weightedProduct = require("./weightedProduct.js");
|
|
5
5
|
let decimal_js = require("decimal.js");
|
|
6
6
|
decimal_js = require_runtime.__toESM(decimal_js);
|
|
7
|
-
//#region src/components/bigSale/templates/HDLKiosk/adapter/customizationProduct.ts
|
|
7
|
+
//#region src/components/bigSale/templates/HDLKiosk/adapter/sales/customizationProduct.ts
|
|
8
8
|
/**
|
|
9
9
|
* 文件角色:将 HDLKiosk 选中结果写入 OS 标准称重商品。
|
|
10
10
|
* 运行机制:提交时按 SKUOptionsSelection 的标准 ProductData 约束校验 SkuValue,并将
|