@pisell/private-materials 6.12.367 → 6.12.368
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +12 -12
- package/build/lowcode/view.js +12 -12
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.d.ts +1 -0
- package/es/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +51 -36
- package/es/components/sharedSecondaryBigSale/index.js +28 -4
- package/es/plus/invoice/ReceiptRenderer.js +11 -10
- package/es/plus/saasDevice/devicePasscodes/model.js +4 -4
- package/es/plus/salesSdk/context/SalesSdkProvider.js +7 -1
- package/es/plus/salesSdk/hooks/useSalesSdkTempOrderSync.js +44 -4
- package/es/plus/salesSdk/tempOrderSync.d.ts +1 -0
- package/es/plus/salesSdk/tempOrderSync.js +12 -1
- package/es/plus/walletPassGallery/components/timelineSection/index.js +4 -4
- package/lib/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.d.ts +1 -0
- package/lib/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.js +49 -33
- package/lib/components/sharedSecondaryBigSale/index.js +26 -2
- package/lib/plus/invoice/ReceiptRenderer.js +11 -10
- package/lib/plus/salesSdk/context/SalesSdkProvider.js +7 -1
- package/lib/plus/salesSdk/hooks/useSalesSdkTempOrderSync.js +43 -3
- package/lib/plus/salesSdk/tempOrderSync.d.ts +1 -0
- package/lib/plus/salesSdk/tempOrderSync.js +12 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1,65 +1,50 @@
|
|
|
1
1
|
import useEngineContext from "../../hooks/useEngineContext.js";
|
|
2
2
|
import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
3
|
import { useSalesSdk } from "../../plus/salesSdk/hooks/useSalesSdk.js";
|
|
4
|
-
import { getTempOrderSyncPayload, shouldApplySharedTempOrderPayload } from "../../plus/salesSdk/tempOrderSync.js";
|
|
4
|
+
import { TEMP_ORDER_SYNC_REQUEST_MESSAGE_TYPE, getTempOrderSyncPayload, shouldApplySharedTempOrderPayload } from "../../plus/salesSdk/tempOrderSync.js";
|
|
5
5
|
import "../../plus/salesSdk/index.js";
|
|
6
|
-
import { useEffect, useRef } from "react";
|
|
7
|
-
import { useMemoizedFn } from "ahooks";
|
|
6
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
7
|
//#region src/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.tsx
|
|
9
8
|
function createRequestId() {
|
|
10
9
|
return `shared-secondary-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* 在销售 Provider 外接收快照,先确定业务上下文,再创建只读销售实例。
|
|
14
13
|
*/
|
|
15
|
-
function
|
|
14
|
+
function useSharedSecondaryBigSaleSnapshot() {
|
|
16
15
|
var _context$appHelper, _context$appHelper$ge, _app$getPlugin, _unifiedCommunication;
|
|
17
16
|
const context = useEngineContext();
|
|
18
17
|
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);
|
|
19
18
|
const unifiedCommunication = app === null || app === void 0 || (_app$getPlugin = app.getPlugin) === null || _app$getPlugin === void 0 ? void 0 : _app$getPlugin.call(app, "unifiedCommunication");
|
|
20
19
|
const { runtime } = (unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication = unifiedCommunication.useRuntime) === null || _unifiedCommunication === void 0 ? void 0 : _unifiedCommunication.call(unifiedCommunication)) || {};
|
|
21
20
|
const isSecondaryScreen = (runtime === null || runtime === void 0 ? void 0 : runtime.role) === "secondary-screen";
|
|
22
|
-
const sales = useSalesSdk();
|
|
23
21
|
const latestTimestampRef = useRef(0);
|
|
24
|
-
const
|
|
25
|
-
const applyPayload = useMemoizedFn((payload) => {
|
|
26
|
-
if (!shouldApplySharedTempOrderPayload(payload, latestTimestampRef.current)) return;
|
|
27
|
-
latestTimestampRef.current = payload.timestamp;
|
|
28
|
-
applyQueueRef.current = applyQueueRef.current.then(_asyncToGenerator(function* () {
|
|
29
|
-
var _sales$bookingTicket2;
|
|
30
|
-
if (payload.timestamp < latestTimestampRef.current) return;
|
|
31
|
-
if (payload.tempOrder) {
|
|
32
|
-
var _sales$bookingTicket;
|
|
33
|
-
if (!((_sales$bookingTicket = sales.bookingTicket) === null || _sales$bookingTicket === void 0 ? void 0 : _sales$bookingTicket.replaceTempOrder)) {
|
|
34
|
-
console.warn("[SharedSecondaryBigSale] 当前 BookingTicket 不支持 replaceTempOrder");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
yield sales.bookingTicket.replaceTempOrder(payload.tempOrder);
|
|
38
|
-
} else yield sales.clearCartAndReset();
|
|
39
|
-
if (payload.walletAssetsSnapshot && ((_sales$bookingTicket2 = sales.bookingTicket) === null || _sales$bookingTicket2 === void 0 ? void 0 : _sales$bookingTicket2.importWalletAssetsSnapshot)) yield sales.bookingTicket.importWalletAssetsSnapshot(payload.walletAssetsSnapshot);
|
|
40
|
-
})).catch((error) => {
|
|
41
|
-
console.warn("[SharedSecondaryBigSale] 应用副屏订单快照失败", error);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
22
|
+
const [snapshot, setSnapshot] = useState(null);
|
|
44
23
|
useEffect(() => {
|
|
45
24
|
var _unifiedCommunication2, _unifiedCommunication3, _unifiedCommunication4, _unifiedCommunication5;
|
|
46
|
-
if (!isSecondaryScreen
|
|
25
|
+
if (!isSecondaryScreen) return;
|
|
26
|
+
let cancelled = false;
|
|
47
27
|
const handleMessage = (event) => {
|
|
48
28
|
const payload = getTempOrderSyncPayload(event);
|
|
49
|
-
if (!payload) return;
|
|
50
|
-
|
|
29
|
+
if (cancelled || !payload || payload.sourceRole === "secondary-screen") return;
|
|
30
|
+
if (!shouldApplySharedTempOrderPayload(payload, latestTimestampRef.current)) return;
|
|
31
|
+
latestTimestampRef.current = payload.timestamp;
|
|
32
|
+
setSnapshot(payload);
|
|
51
33
|
};
|
|
52
34
|
const listenerHandle = unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication2 = unifiedCommunication.sdk) === null || _unifiedCommunication2 === void 0 || (_unifiedCommunication3 = _unifiedCommunication2.onMessage) === null || _unifiedCommunication3 === void 0 ? void 0 : _unifiedCommunication3.call(_unifiedCommunication2, handleMessage);
|
|
53
|
-
unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication4 = unifiedCommunication.sdk) === null || _unifiedCommunication4 === void 0 || (_unifiedCommunication5 = _unifiedCommunication4.publishData) === null || _unifiedCommunication5 === void 0
|
|
35
|
+
Promise.resolve(unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication4 = unifiedCommunication.sdk) === null || _unifiedCommunication4 === void 0 || (_unifiedCommunication5 = _unifiedCommunication4.publishData) === null || _unifiedCommunication5 === void 0 ? void 0 : _unifiedCommunication5.call(_unifiedCommunication4, {
|
|
54
36
|
target: { type: "main" },
|
|
55
37
|
data: {
|
|
56
|
-
type:
|
|
38
|
+
type: TEMP_ORDER_SYNC_REQUEST_MESSAGE_TYPE,
|
|
57
39
|
requestId: createRequestId(),
|
|
58
40
|
timestamp: Date.now()
|
|
59
41
|
},
|
|
60
42
|
meta: {}
|
|
43
|
+
})).catch((error) => {
|
|
44
|
+
console.warn("[SharedSecondaryBigSale] 请求主屏订单快照失败", error);
|
|
61
45
|
});
|
|
62
46
|
return () => {
|
|
47
|
+
cancelled = true;
|
|
63
48
|
if (listenerHandle && typeof listenerHandle.then === "function") listenerHandle.then((handle) => {
|
|
64
49
|
var _handle$remove;
|
|
65
50
|
return handle === null || handle === void 0 || (_handle$remove = handle.remove) === null || _handle$remove === void 0 ? void 0 : _handle$remove.call(handle);
|
|
@@ -69,13 +54,43 @@ function SharedSecondaryBigSaleReceiver() {
|
|
|
69
54
|
listenerHandle === null || listenerHandle === void 0 || (_remove = listenerHandle.remove) === null || _remove === void 0 || _remove.call(listenerHandle);
|
|
70
55
|
}
|
|
71
56
|
};
|
|
57
|
+
}, [isSecondaryScreen, unifiedCommunication]);
|
|
58
|
+
return snapshot;
|
|
59
|
+
}
|
|
60
|
+
/** 配置就绪后将同一业务实例的订单快照串行应用,不等待只读实例变为 ready。 */
|
|
61
|
+
function SharedSecondaryBigSaleReceiver({ payload }) {
|
|
62
|
+
const sales = useSalesSdk();
|
|
63
|
+
const bookingTicket = sales.bookingTicket;
|
|
64
|
+
const clearCartAndReset = sales.clearCartAndReset;
|
|
65
|
+
const settingsPending = sales.salesSettingsSource === "picoding" && !sales.salesSettings;
|
|
66
|
+
const applyQueueRef = useRef(Promise.resolve());
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!bookingTicket || settingsPending) return;
|
|
69
|
+
let cancelled = false;
|
|
70
|
+
applyQueueRef.current = applyQueueRef.current.then(_asyncToGenerator(function* () {
|
|
71
|
+
if (cancelled) return;
|
|
72
|
+
if (payload.tempOrder) {
|
|
73
|
+
if (!bookingTicket.replaceTempOrder) {
|
|
74
|
+
console.warn("[SharedSecondaryBigSale] 当前销售实例不支持 replaceTempOrder");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
yield bookingTicket.replaceTempOrder(payload.tempOrder);
|
|
78
|
+
} else yield clearCartAndReset();
|
|
79
|
+
if (cancelled) return;
|
|
80
|
+
if (payload.walletAssetsSnapshot && bookingTicket.importWalletAssetsSnapshot) yield bookingTicket.importWalletAssetsSnapshot(payload.walletAssetsSnapshot);
|
|
81
|
+
})).catch((error) => {
|
|
82
|
+
console.warn("[SharedSecondaryBigSale] 应用副屏订单快照失败", error);
|
|
83
|
+
});
|
|
84
|
+
return () => {
|
|
85
|
+
cancelled = true;
|
|
86
|
+
};
|
|
72
87
|
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
bookingTicket,
|
|
89
|
+
clearCartAndReset,
|
|
90
|
+
payload,
|
|
91
|
+
settingsPending
|
|
77
92
|
]);
|
|
78
93
|
return null;
|
|
79
94
|
}
|
|
80
95
|
//#endregion
|
|
81
|
-
export { SharedSecondaryBigSaleReceiver };
|
|
96
|
+
export { SharedSecondaryBigSaleReceiver, useSharedSecondaryBigSaleSnapshot };
|
|
@@ -1,14 +1,38 @@
|
|
|
1
|
+
import useEngineContext from "../../hooks/useEngineContext.js";
|
|
2
|
+
import { resolveTempOrderSyncSalesContext } from "../../plus/salesSdk/tempOrderSync.js";
|
|
1
3
|
import BigSale from "../bigSale/index.js";
|
|
2
|
-
import { SharedSecondaryBigSaleReceiver } from "./SharedSecondaryBigSaleReceiver.js";
|
|
3
|
-
import React from "react";
|
|
4
|
+
import { SharedSecondaryBigSaleReceiver, useSharedSecondaryBigSaleSnapshot } from "./SharedSecondaryBigSaleReceiver.js";
|
|
5
|
+
import React, { useMemo } from "react";
|
|
4
6
|
//#region src/components/sharedSecondaryBigSale/index.tsx
|
|
5
7
|
const DEFAULT_OS_KEY = "shared-secondary-big-sale";
|
|
8
|
+
let nextScopeId = 0;
|
|
6
9
|
/**
|
|
7
10
|
* 多个主屏销售实例共用的只读副屏;订单内容和布局继续复用 BigSale。
|
|
8
11
|
*/
|
|
9
12
|
function SharedSecondaryBigSale({ osKey = DEFAULT_OS_KEY, saleDetailModuleConfig, secondaryScreenDisplay, className, style }) {
|
|
10
|
-
|
|
13
|
+
var _context$appHelper, _context$appHelper$ge;
|
|
14
|
+
const payload = useSharedSecondaryBigSaleSnapshot();
|
|
15
|
+
const context = useEngineContext();
|
|
16
|
+
const salesContext = payload ? resolveTempOrderSyncSalesContext(payload) : void 0;
|
|
17
|
+
const businessCode = salesContext === null || salesContext === void 0 ? void 0 : salesContext.businessCode;
|
|
18
|
+
const localChannel = 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.getData) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper, "channel");
|
|
19
|
+
const channel = (salesContext === null || salesContext === void 0 ? void 0 : salesContext.channel) || (typeof localChannel === "string" && localChannel.trim() ? localChannel.trim() : "cds");
|
|
20
|
+
const scopeId = useMemo(() => ++nextScopeId, [
|
|
11
21
|
osKey,
|
|
22
|
+
businessCode,
|
|
23
|
+
channel
|
|
24
|
+
]);
|
|
25
|
+
const otherParams = useMemo(() => ({ channel }), [channel]);
|
|
26
|
+
if (!payload || !businessCode) return /* @__PURE__ */ React.createElement("div", {
|
|
27
|
+
className,
|
|
28
|
+
style,
|
|
29
|
+
"aria-busy": "true"
|
|
30
|
+
});
|
|
31
|
+
return /* @__PURE__ */ React.createElement(BigSale, {
|
|
32
|
+
key: scopeId,
|
|
33
|
+
osKey: `${osKey}-${encodeURIComponent(channel)}-${scopeId}`,
|
|
34
|
+
businessCode,
|
|
35
|
+
otherParams,
|
|
12
36
|
mode: "ticket",
|
|
13
37
|
template: "secondaryScreen",
|
|
14
38
|
saleDetailTemplate: "A",
|
|
@@ -20,7 +44,7 @@ function SharedSecondaryBigSale({ osKey = DEFAULT_OS_KEY, saleDetailModuleConfig
|
|
|
20
44
|
saleDetailModuleConfig,
|
|
21
45
|
className,
|
|
22
46
|
style,
|
|
23
|
-
bootstrapSlot: /* @__PURE__ */ React.createElement(SharedSecondaryBigSaleReceiver,
|
|
47
|
+
bootstrapSlot: /* @__PURE__ */ React.createElement(SharedSecondaryBigSaleReceiver, { payload })
|
|
24
48
|
});
|
|
25
49
|
}
|
|
26
50
|
//#endregion
|
|
@@ -285,8 +285,9 @@ function bookingHeadersAreVisible(config) {
|
|
|
285
285
|
return isInvoiceFieldVisible(config, "booking");
|
|
286
286
|
}
|
|
287
287
|
const renderBrand = ({ config, receipt }) => {
|
|
288
|
-
var _receipt$secondary2, _receipt$secondary3;
|
|
288
|
+
var _receipt$secondary2, _receipt$secondary3, _receipt$secondary4;
|
|
289
289
|
const base = receipt.baseData;
|
|
290
|
+
const isJapaneseEnglish = receipt.locale.toLowerCase().startsWith("ja") && ((_receipt$secondary2 = receipt.secondary) === null || _receipt$secondary2 === void 0 ? void 0 : _receipt$secondary2.locale.toLowerCase().startsWith("en"));
|
|
290
291
|
const show = (field) => isInvoiceFieldVisible(config, field);
|
|
291
292
|
const logo = show("logo") && receipt.brandLogo;
|
|
292
293
|
const name = show("store_name") && base.shop_name;
|
|
@@ -298,7 +299,7 @@ const renderBrand = ({ config, receipt }) => {
|
|
|
298
299
|
return /* @__PURE__ */ React.createElement("section", { className: `${PREFIX}__receipt-brand` }, logo ? /* @__PURE__ */ React.createElement("img", {
|
|
299
300
|
alt: "",
|
|
300
301
|
src: receipt.brandLogo
|
|
301
|
-
}) : null, name ? /* @__PURE__ */ React.createElement("h2", null, bilingualText(base.shop_name, (_receipt$
|
|
302
|
+
}) : null, name ? /* @__PURE__ */ React.createElement("h2", null, bilingualText(base.shop_name, (_receipt$secondary3 = receipt.secondary) === null || _receipt$secondary3 === void 0 ? void 0 : _receipt$secondary3.baseData.shop_name)) : null, taxNumber ? /* @__PURE__ */ React.createElement("div", null, receipt.taxNumberLabel ? `${receipt.taxNumberLabel}: ` : "", base.shop_tax_number) : null, address ? /* @__PURE__ */ React.createElement("div", null, bilingualText(base.shop_address, (_receipt$secondary4 = receipt.secondary) === null || _receipt$secondary4 === void 0 ? void 0 : _receipt$secondary4.baseData.shop_address)) : null, phone ? /* @__PURE__ */ React.createElement("div", null, base.shop_phone) : null, title ? /* @__PURE__ */ React.createElement("strong", { className: `${PREFIX}__receipt-bill-title` }, isJapaneseEnglish ? label(receipt.billTitle, "en") : receiptLabel(receipt, receipt.billTitle)) : null);
|
|
302
303
|
};
|
|
303
304
|
/** Stable row keys survive translation; localized labels are never selectors. */
|
|
304
305
|
function visibleSemanticRows(rows, config, fields) {
|
|
@@ -326,8 +327,8 @@ const renderOrder = ({ config, receipt }) => {
|
|
|
326
327
|
}) : null);
|
|
327
328
|
};
|
|
328
329
|
const renderCustom = ({ config, receipt }) => {
|
|
329
|
-
var _receipt$
|
|
330
|
-
return renderCustomModule(config, receipt.locale, (_receipt$
|
|
330
|
+
var _receipt$secondary5;
|
|
331
|
+
return renderCustomModule(config, receipt.locale, (_receipt$secondary5 = receipt.secondary) === null || _receipt$secondary5 === void 0 ? void 0 : _receipt$secondary5.locale);
|
|
331
332
|
};
|
|
332
333
|
const MODULE_RENDERERS = {
|
|
333
334
|
reference: ({ receipt }) => receipt.reference ? /* @__PURE__ */ React.createElement("section", { className: `${PREFIX}__receipt-reference` }, /* @__PURE__ */ React.createElement("span", null, receiptLabel(receipt, "Reference")), /* @__PURE__ */ React.createElement("strong", null, receipt.reference)) : null,
|
|
@@ -346,8 +347,8 @@ const MODULE_RENDERERS = {
|
|
|
346
347
|
line_groups: ({ config, receipt }) => {
|
|
347
348
|
const showBookingHeaders = bookingHeadersAreVisible(config);
|
|
348
349
|
const lineGroups = showBookingHeaders ? receipt.lineGroups.filter((group) => {
|
|
349
|
-
var _receipt$
|
|
350
|
-
return group.products.length || lineGroupMetaRows(group, receipt.locale, (_receipt$
|
|
350
|
+
var _receipt$secondary6;
|
|
351
|
+
return group.products.length || lineGroupMetaRows(group, receipt.locale, (_receipt$secondary6 = receipt.secondary) === null || _receipt$secondary6 === void 0 ? void 0 : _receipt$secondary6.locale).length;
|
|
351
352
|
}) : receipt.products.length ? [{
|
|
352
353
|
key: "all-items",
|
|
353
354
|
products: receipt.products,
|
|
@@ -358,12 +359,12 @@ const MODULE_RENDERERS = {
|
|
|
358
359
|
locale: receipt.locale,
|
|
359
360
|
rows: tableRows
|
|
360
361
|
}), lineGroups.map((group) => {
|
|
361
|
-
var _receipt$
|
|
362
|
+
var _receipt$secondary7;
|
|
362
363
|
return /* @__PURE__ */ React.createElement(LineGroup, {
|
|
363
364
|
group,
|
|
364
365
|
key: group.key,
|
|
365
366
|
locale: receipt.locale,
|
|
366
|
-
secondaryLocale: (_receipt$
|
|
367
|
+
secondaryLocale: (_receipt$secondary7 = receipt.secondary) === null || _receipt$secondary7 === void 0 ? void 0 : _receipt$secondary7.locale,
|
|
367
368
|
config
|
|
368
369
|
});
|
|
369
370
|
})) : null;
|
|
@@ -399,8 +400,8 @@ const MODULE_RENDERERS = {
|
|
|
399
400
|
locale: receipt.locale
|
|
400
401
|
})) : null,
|
|
401
402
|
total_savings: ({ config, receipt }) => {
|
|
402
|
-
var _receipt$
|
|
403
|
-
return receipt.totalSavings ? /* @__PURE__ */ React.createElement("section", null, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__receipt-savings` }, /* @__PURE__ */ React.createElement("strong", null, receiptLabel(receipt, "Total Savings")), /* @__PURE__ */ React.createElement("strong", null, receipt.totalSavings)), isInvoiceFieldVisible(config, "description") && receipt.totalSavingsDescription ? /* @__PURE__ */ React.createElement("p", { className: `${PREFIX}__receipt-savings-description` }, bilingualText(receipt.totalSavingsDescription, (_receipt$
|
|
403
|
+
var _receipt$secondary8;
|
|
404
|
+
return receipt.totalSavings ? /* @__PURE__ */ React.createElement("section", null, /* @__PURE__ */ React.createElement("div", { className: `${PREFIX}__receipt-savings` }, /* @__PURE__ */ React.createElement("strong", null, receiptLabel(receipt, "Total Savings")), /* @__PURE__ */ React.createElement("strong", null, receipt.totalSavings)), isInvoiceFieldVisible(config, "description") && receipt.totalSavingsDescription ? /* @__PURE__ */ React.createElement("p", { className: `${PREFIX}__receipt-savings-description` }, bilingualText(receipt.totalSavingsDescription, (_receipt$secondary8 = receipt.secondary) === null || _receipt$secondary8 === void 0 ? void 0 : _receipt$secondary8.totalSavingsDescription)) : null) : null;
|
|
404
405
|
},
|
|
405
406
|
custom_3: renderCustom,
|
|
406
407
|
barcode: ({ receipt }) => receipt.barcodeValue ? /* @__PURE__ */ React.createElement("section", { className: `${PREFIX}__receipt-barcode` }, /* @__PURE__ */ React.createElement(QRCode, {
|
|
@@ -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 timezonePlugin from "dayjs/plugin/timezone";
|
|
4
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
5
5
|
//#region src/plus/saasDevice/devicePasscodes/model.ts
|
|
6
|
-
dayjs.extend(
|
|
7
|
-
dayjs.extend(
|
|
6
|
+
dayjs.extend(utcPlugin);
|
|
7
|
+
dayjs.extend(timezonePlugin);
|
|
8
8
|
const INITIAL_DEVICE_PASSCODE_STATE = {
|
|
9
9
|
deviceIds: [],
|
|
10
10
|
devicesById: {}
|
|
@@ -563,11 +563,17 @@ const SalesSdkProvider = ({ osKey, enableMultiCurrencySettlement = false, soluti
|
|
|
563
563
|
snapshotPreserved: false
|
|
564
564
|
};
|
|
565
565
|
});
|
|
566
|
+
const isOrderBootstrapPending = lifecycleOwner === "provider" && (autoRestoreOnInit || Boolean(autoBootstrap && orderId)) && settledBootstrapKey !== bootstrapKey;
|
|
567
|
+
const syncBusinessCode = businessCode || moduleOtherParams.businessCode || (otherParams === null || otherParams === void 0 ? void 0 : otherParams.business_code);
|
|
566
568
|
const { publishTempOrder } = useSalesSdkTempOrderSync({
|
|
567
569
|
enabled: enableTempOrderSync,
|
|
568
|
-
ready: !
|
|
570
|
+
ready: !isOrderBootstrapPending,
|
|
569
571
|
isActive,
|
|
570
572
|
osKey: (osKey === null || osKey === void 0 || (_osKey$replace = osKey.replace) === null || _osKey$replace === void 0 ? void 0 : _osKey$replace.call(osKey, "bookingTicket-", "")) || osKey,
|
|
573
|
+
salesContext: typeof syncBusinessCode === "string" && syncBusinessCode.trim() ? {
|
|
574
|
+
businessCode: syncBusinessCode,
|
|
575
|
+
channel: productLoadChannel
|
|
576
|
+
} : void 0,
|
|
571
577
|
bookingTicket,
|
|
572
578
|
refreshRootSnapshot
|
|
573
579
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useEngineContext from "../../../hooks/useEngineContext.js";
|
|
2
2
|
import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
3
|
-
import { TEMP_ORDER_SYNC_MESSAGE_TYPE, TEMP_ORDER_SYNC_REQUEST_MESSAGE_TYPE, cloneTempOrderSyncSnapshot, getTempOrderSyncPayload, getTempOrderSyncRequestPayload, resolveTempOrderSyncPeerTarget, resolveTempOrderSyncScreenRole, shouldRespondToTempOrderSyncRequest } from "../tempOrderSync.js";
|
|
3
|
+
import { TEMP_ORDER_SYNC_MESSAGE_TYPE, TEMP_ORDER_SYNC_REQUEST_MESSAGE_TYPE, cloneTempOrderSyncSnapshot, getTempOrderSyncPayload, getTempOrderSyncRequestPayload, resolveTempOrderSyncPeerTarget, resolveTempOrderSyncSalesContext, resolveTempOrderSyncScreenRole, shouldRespondToTempOrderSyncRequest } from "../tempOrderSync.js";
|
|
4
4
|
import { useEffect, useRef } from "react";
|
|
5
5
|
import { cloneDeep } from "lodash";
|
|
6
6
|
import { useDebounceFn, useMemoizedFn } from "ahooks";
|
|
@@ -17,6 +17,13 @@ function getPayloadRevision(payload) {
|
|
|
17
17
|
function getPayloadSourceKey(payload) {
|
|
18
18
|
return `${payload.osKey}:${payload.sourceId}`;
|
|
19
19
|
}
|
|
20
|
+
function getSalesContextKey(salesContext) {
|
|
21
|
+
return JSON.stringify([salesContext === null || salesContext === void 0 ? void 0 : salesContext.businessCode, salesContext === null || salesContext === void 0 ? void 0 : salesContext.channel]);
|
|
22
|
+
}
|
|
23
|
+
function isSalesContextAlignedWithOrder(tempOrder, salesContext) {
|
|
24
|
+
const orderBusinessCode = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.business_code;
|
|
25
|
+
return !salesContext || typeof orderBusinessCode !== "string" || !orderBusinessCode.trim() || orderBusinessCode === salesContext.businessCode;
|
|
26
|
+
}
|
|
20
27
|
function resolvePayloadDiscountState(payload) {
|
|
21
28
|
var _payload$tempOrder;
|
|
22
29
|
if (payload.discountState) return cloneDeep(payload.discountState);
|
|
@@ -50,7 +57,7 @@ function isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, snapshot) {
|
|
|
50
57
|
* 两端都可发布本地变更、接收同 osKey 快照;页面激活时向更早激活的对端补拉。
|
|
51
58
|
* 远端快照应用期间禁止再次发布,避免 replaceTempOrder 触发 refresh 后形成回环。
|
|
52
59
|
*/
|
|
53
|
-
function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKey, bookingTicket, refreshRootSnapshot }) {
|
|
60
|
+
function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKey, salesContext, bookingTicket, refreshRootSnapshot }) {
|
|
54
61
|
var _context$appHelper, _context$appHelper$ge, _app$getPlugin, _unifiedCommunication;
|
|
55
62
|
const context = useEngineContext();
|
|
56
63
|
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);
|
|
@@ -79,13 +86,19 @@ function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKe
|
|
|
79
86
|
const latestOfferedRevisionBySourceRef = useRef(/* @__PURE__ */ new Map());
|
|
80
87
|
const applyQueueRef = useRef(Promise.resolve());
|
|
81
88
|
const lastAppliedRemoteOriginRef = useRef(null);
|
|
89
|
+
const salesContextKey = getSalesContextKey(salesContext);
|
|
90
|
+
const previousSalesContextKeyRef = useRef(salesContextKey);
|
|
82
91
|
isActiveRef.current = isActive;
|
|
83
92
|
readyRef.current = ready;
|
|
84
93
|
const getPeerTarget = useMemoizedFn((role) => resolveTempOrderSyncPeerTarget(role, endpoints));
|
|
85
|
-
/**
|
|
94
|
+
/** 发布时一起拷贝订单、业务与折扣上下文,避免防抖期间 OS 原地修改造成版本错配。 */
|
|
86
95
|
const captureRuntimeSnapshot = useMemoizedFn((tempOrder, causalOrigin) => {
|
|
87
96
|
const snapshot = {
|
|
88
97
|
tempOrder,
|
|
98
|
+
salesContext: resolveTempOrderSyncSalesContext({
|
|
99
|
+
tempOrder,
|
|
100
|
+
salesContext
|
|
101
|
+
}),
|
|
89
102
|
causalOrigin
|
|
90
103
|
};
|
|
91
104
|
if (!bookingTicket) return cloneTempOrderSyncSnapshot(snapshot);
|
|
@@ -112,6 +125,12 @@ function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKe
|
|
|
112
125
|
var _ref = _asyncToGenerator(function* (snapshot, options = {}) {
|
|
113
126
|
if (!enabled || !ready || !screenRole || !isActiveRef.current) return;
|
|
114
127
|
if (remoteApplyingRef.current && !options.responseToRequestId) return;
|
|
128
|
+
if (!isSalesContextAlignedWithOrder(snapshot.tempOrder, snapshot.salesContext)) return;
|
|
129
|
+
const currentSalesContext = resolveTempOrderSyncSalesContext({
|
|
130
|
+
tempOrder: snapshot.tempOrder,
|
|
131
|
+
salesContext
|
|
132
|
+
});
|
|
133
|
+
if (getSalesContextKey(snapshot.salesContext) !== getSalesContextKey(currentSalesContext)) return;
|
|
115
134
|
if (options.incrementRevision !== false) revisionRef.current += 1;
|
|
116
135
|
try {
|
|
117
136
|
var _snapshot$causalOrigi, _unifiedCommunication2, _unifiedCommunication3;
|
|
@@ -134,6 +153,7 @@ function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKe
|
|
|
134
153
|
timestamp: Date.now(),
|
|
135
154
|
isActive: true,
|
|
136
155
|
tempOrder: snapshot.tempOrder,
|
|
156
|
+
salesContext: snapshot.salesContext,
|
|
137
157
|
discountState: snapshot.discountState,
|
|
138
158
|
walletAssetsSnapshot: snapshot.walletAssetsSnapshot
|
|
139
159
|
},
|
|
@@ -161,7 +181,7 @@ function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKe
|
|
|
161
181
|
});
|
|
162
182
|
const publishTempOrder = useMemoizedFn((tempOrder, options = {}) => {
|
|
163
183
|
var _lastAppliedRemoteOri;
|
|
164
|
-
if (!enabled || !ready || !screenRole || !isActiveRef.current || remoteApplyingRef.current) return;
|
|
184
|
+
if (!enabled || !ready || !screenRole || !isActiveRef.current || remoteApplyingRef.current || !isSalesContextAlignedWithOrder(tempOrder, salesContext)) return;
|
|
165
185
|
const causalOrigin = options.preserveRemoteOrigin ? (_lastAppliedRemoteOri = lastAppliedRemoteOriginRef.current) !== null && _lastAppliedRemoteOri !== void 0 ? _lastAppliedRemoteOri : void 0 : void 0;
|
|
166
186
|
if (!options.preserveRemoteOrigin) {
|
|
167
187
|
lastAppliedRemoteOriginRef.current = null;
|
|
@@ -476,6 +496,26 @@ function useSalesSdkTempOrderSync({ enabled, ready = true, isActive = true, osKe
|
|
|
476
496
|
applyPayload,
|
|
477
497
|
cancelDebouncedPublish
|
|
478
498
|
]);
|
|
499
|
+
useEffect(() => {
|
|
500
|
+
var _bookingTicket$getTem5, _bookingTicket$getTem6;
|
|
501
|
+
if (previousSalesContextKeyRef.current === salesContextKey) return;
|
|
502
|
+
cancelDebouncedPublish();
|
|
503
|
+
if (!enabled || !ready || !isActive || screenRole !== "main" || !salesContext || !bookingTicket || remoteApplyingRef.current) return;
|
|
504
|
+
const tempOrder = (_bookingTicket$getTem5 = (_bookingTicket$getTem6 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem6 === void 0 ? void 0 : _bookingTicket$getTem6.call(bookingTicket)) !== null && _bookingTicket$getTem5 !== void 0 ? _bookingTicket$getTem5 : null;
|
|
505
|
+
if (!isSalesContextAlignedWithOrder(tempOrder, salesContext)) return;
|
|
506
|
+
previousSalesContextKeyRef.current = salesContextKey;
|
|
507
|
+
publishTempOrder(tempOrder);
|
|
508
|
+
}, [
|
|
509
|
+
salesContextKey,
|
|
510
|
+
bookingTicket,
|
|
511
|
+
enabled,
|
|
512
|
+
ready,
|
|
513
|
+
isActive,
|
|
514
|
+
osKey,
|
|
515
|
+
screenRole,
|
|
516
|
+
publishTempOrder,
|
|
517
|
+
cancelDebouncedPublish
|
|
518
|
+
]);
|
|
479
519
|
useEffect(() => () => {
|
|
480
520
|
activationEpochRef.current += 1;
|
|
481
521
|
activationKeyRef.current = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -20,6 +20,16 @@ function getMessageData(event) {
|
|
|
20
20
|
function isRecord(value) {
|
|
21
21
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
22
22
|
}
|
|
23
|
+
function isSalesContext(value) {
|
|
24
|
+
return isRecord(value) && typeof value.businessCode === "string" && value.businessCode.trim().length > 0 && (value.channel === void 0 || typeof value.channel === "string" && value.channel.trim().length > 0);
|
|
25
|
+
}
|
|
26
|
+
/** 旧发送端只有订单字段;它无法证明销售渠道,因此不推测 channel。 */
|
|
27
|
+
function resolveTempOrderSyncSalesContext(payload) {
|
|
28
|
+
var _payload$tempOrder;
|
|
29
|
+
if (payload.salesContext) return payload.salesContext;
|
|
30
|
+
const businessCode = (_payload$tempOrder = payload.tempOrder) === null || _payload$tempOrder === void 0 ? void 0 : _payload$tempOrder.business_code;
|
|
31
|
+
return typeof businessCode === "string" && businessCode.trim() ? { businessCode } : void 0;
|
|
32
|
+
}
|
|
23
33
|
function isWalletAssetsSnapshot(value) {
|
|
24
34
|
if (!isRecord(value) || !isRecord(value.state)) return false;
|
|
25
35
|
const state = value.state;
|
|
@@ -41,6 +51,7 @@ function getTempOrderSyncPayload(event) {
|
|
|
41
51
|
if (payload.activeSince !== void 0 && !Number.isFinite(payload.activeSince)) return null;
|
|
42
52
|
if (!Object.prototype.hasOwnProperty.call(payload, "tempOrder")) return null;
|
|
43
53
|
if (payload.tempOrder !== null && (typeof payload.tempOrder !== "object" || Array.isArray(payload.tempOrder))) return null;
|
|
54
|
+
if (payload.salesContext !== void 0 && !isSalesContext(payload.salesContext)) return null;
|
|
44
55
|
if (payload.discountState !== void 0) {
|
|
45
56
|
if (!payload.discountState || typeof payload.discountState !== "object" || Array.isArray(payload.discountState) || !Array.isArray(payload.discountState.discountList) || !Array.isArray(payload.discountState.originalDiscountList)) return null;
|
|
46
57
|
}
|
|
@@ -86,4 +97,4 @@ function shouldApplySharedTempOrderPayload(payload, latestTimestamp) {
|
|
|
86
97
|
return payload.isActive === true && payload.timestamp > latestTimestamp;
|
|
87
98
|
}
|
|
88
99
|
//#endregion
|
|
89
|
-
export { TEMP_ORDER_SYNC_MESSAGE_TYPE, TEMP_ORDER_SYNC_REQUEST_MESSAGE_TYPE, cloneTempOrderSyncSnapshot, getTempOrderSyncPayload, getTempOrderSyncRequestPayload, resolveTempOrderSyncPeerTarget, resolveTempOrderSyncScreenRole, shouldApplySharedTempOrderPayload, shouldRespondToTempOrderSyncRequest };
|
|
100
|
+
export { TEMP_ORDER_SYNC_MESSAGE_TYPE, TEMP_ORDER_SYNC_REQUEST_MESSAGE_TYPE, cloneTempOrderSyncSnapshot, getTempOrderSyncPayload, getTempOrderSyncRequestPayload, resolveTempOrderSyncPeerTarget, resolveTempOrderSyncSalesContext, resolveTempOrderSyncScreenRole, shouldApplySharedTempOrderPayload, shouldRespondToTempOrderSyncRequest };
|
|
@@ -6,12 +6,12 @@ import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
6
6
|
import { locales } from "@pisell/utils";
|
|
7
7
|
import { Button, PisellEmpty, PisellModal, PisellStatisticList, Skeleton, Timeline, usePisellConfig } from "@pisell/materials";
|
|
8
8
|
import { useRequest } from "ahooks";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
9
|
+
import timezonePlugin from "dayjs/plugin/timezone";
|
|
10
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
11
11
|
import "./index.less";
|
|
12
12
|
//#region src/plus/walletPassGallery/components/timelineSection/index.tsx
|
|
13
|
-
dayjs.extend(
|
|
14
|
-
dayjs.extend(
|
|
13
|
+
dayjs.extend(timezonePlugin);
|
|
14
|
+
dayjs.extend(utcPlugin);
|
|
15
15
|
const stateTimeUnix = 1723255863;
|
|
16
16
|
const POLL_INTERVAL = 2e3;
|
|
17
17
|
const POLL_MAX_TIMES = 5;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -4,62 +4,47 @@ const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0
|
|
|
4
4
|
const require_useSalesSdk = require("../../plus/salesSdk/hooks/useSalesSdk.js");
|
|
5
5
|
const require_tempOrderSync = require("../../plus/salesSdk/tempOrderSync.js");
|
|
6
6
|
let react = require("react");
|
|
7
|
-
let ahooks = require("ahooks");
|
|
8
7
|
//#region src/components/sharedSecondaryBigSale/SharedSecondaryBigSaleReceiver.tsx
|
|
9
8
|
function createRequestId() {
|
|
10
9
|
return `shared-secondary-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* 在销售 Provider 外接收快照,先确定业务上下文,再创建只读销售实例。
|
|
14
13
|
*/
|
|
15
|
-
function
|
|
14
|
+
function useSharedSecondaryBigSaleSnapshot() {
|
|
16
15
|
var _context$appHelper, _context$appHelper$ge, _app$getPlugin, _unifiedCommunication;
|
|
17
16
|
const context = require_useEngineContext.default();
|
|
18
17
|
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);
|
|
19
18
|
const unifiedCommunication = app === null || app === void 0 || (_app$getPlugin = app.getPlugin) === null || _app$getPlugin === void 0 ? void 0 : _app$getPlugin.call(app, "unifiedCommunication");
|
|
20
19
|
const { runtime } = (unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication = unifiedCommunication.useRuntime) === null || _unifiedCommunication === void 0 ? void 0 : _unifiedCommunication.call(unifiedCommunication)) || {};
|
|
21
20
|
const isSecondaryScreen = (runtime === null || runtime === void 0 ? void 0 : runtime.role) === "secondary-screen";
|
|
22
|
-
const sales = require_useSalesSdk.useSalesSdk();
|
|
23
21
|
const latestTimestampRef = (0, react.useRef)(0);
|
|
24
|
-
const
|
|
25
|
-
const applyPayload = (0, ahooks.useMemoizedFn)((payload) => {
|
|
26
|
-
if (!require_tempOrderSync.shouldApplySharedTempOrderPayload(payload, latestTimestampRef.current)) return;
|
|
27
|
-
latestTimestampRef.current = payload.timestamp;
|
|
28
|
-
applyQueueRef.current = applyQueueRef.current.then(require_asyncToGenerator._asyncToGenerator(function* () {
|
|
29
|
-
var _sales$bookingTicket2;
|
|
30
|
-
if (payload.timestamp < latestTimestampRef.current) return;
|
|
31
|
-
if (payload.tempOrder) {
|
|
32
|
-
var _sales$bookingTicket;
|
|
33
|
-
if (!((_sales$bookingTicket = sales.bookingTicket) === null || _sales$bookingTicket === void 0 ? void 0 : _sales$bookingTicket.replaceTempOrder)) {
|
|
34
|
-
console.warn("[SharedSecondaryBigSale] 当前 BookingTicket 不支持 replaceTempOrder");
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
yield sales.bookingTicket.replaceTempOrder(payload.tempOrder);
|
|
38
|
-
} else yield sales.clearCartAndReset();
|
|
39
|
-
if (payload.walletAssetsSnapshot && ((_sales$bookingTicket2 = sales.bookingTicket) === null || _sales$bookingTicket2 === void 0 ? void 0 : _sales$bookingTicket2.importWalletAssetsSnapshot)) yield sales.bookingTicket.importWalletAssetsSnapshot(payload.walletAssetsSnapshot);
|
|
40
|
-
})).catch((error) => {
|
|
41
|
-
console.warn("[SharedSecondaryBigSale] 应用副屏订单快照失败", error);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
22
|
+
const [snapshot, setSnapshot] = (0, react.useState)(null);
|
|
44
23
|
(0, react.useEffect)(() => {
|
|
45
24
|
var _unifiedCommunication2, _unifiedCommunication3, _unifiedCommunication4, _unifiedCommunication5;
|
|
46
|
-
if (!isSecondaryScreen
|
|
25
|
+
if (!isSecondaryScreen) return;
|
|
26
|
+
let cancelled = false;
|
|
47
27
|
const handleMessage = (event) => {
|
|
48
28
|
const payload = require_tempOrderSync.getTempOrderSyncPayload(event);
|
|
49
|
-
if (!payload) return;
|
|
50
|
-
|
|
29
|
+
if (cancelled || !payload || payload.sourceRole === "secondary-screen") return;
|
|
30
|
+
if (!require_tempOrderSync.shouldApplySharedTempOrderPayload(payload, latestTimestampRef.current)) return;
|
|
31
|
+
latestTimestampRef.current = payload.timestamp;
|
|
32
|
+
setSnapshot(payload);
|
|
51
33
|
};
|
|
52
34
|
const listenerHandle = unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication2 = unifiedCommunication.sdk) === null || _unifiedCommunication2 === void 0 || (_unifiedCommunication3 = _unifiedCommunication2.onMessage) === null || _unifiedCommunication3 === void 0 ? void 0 : _unifiedCommunication3.call(_unifiedCommunication2, handleMessage);
|
|
53
|
-
unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication4 = unifiedCommunication.sdk) === null || _unifiedCommunication4 === void 0 || (_unifiedCommunication5 = _unifiedCommunication4.publishData) === null || _unifiedCommunication5 === void 0
|
|
35
|
+
Promise.resolve(unifiedCommunication === null || unifiedCommunication === void 0 || (_unifiedCommunication4 = unifiedCommunication.sdk) === null || _unifiedCommunication4 === void 0 || (_unifiedCommunication5 = _unifiedCommunication4.publishData) === null || _unifiedCommunication5 === void 0 ? void 0 : _unifiedCommunication5.call(_unifiedCommunication4, {
|
|
54
36
|
target: { type: "main" },
|
|
55
37
|
data: {
|
|
56
|
-
type:
|
|
38
|
+
type: require_tempOrderSync.TEMP_ORDER_SYNC_REQUEST_MESSAGE_TYPE,
|
|
57
39
|
requestId: createRequestId(),
|
|
58
40
|
timestamp: Date.now()
|
|
59
41
|
},
|
|
60
42
|
meta: {}
|
|
43
|
+
})).catch((error) => {
|
|
44
|
+
console.warn("[SharedSecondaryBigSale] 请求主屏订单快照失败", error);
|
|
61
45
|
});
|
|
62
46
|
return () => {
|
|
47
|
+
cancelled = true;
|
|
63
48
|
if (listenerHandle && typeof listenerHandle.then === "function") listenerHandle.then((handle) => {
|
|
64
49
|
var _handle$remove;
|
|
65
50
|
return handle === null || handle === void 0 || (_handle$remove = handle.remove) === null || _handle$remove === void 0 ? void 0 : _handle$remove.call(handle);
|
|
@@ -69,13 +54,44 @@ function SharedSecondaryBigSaleReceiver() {
|
|
|
69
54
|
listenerHandle === null || listenerHandle === void 0 || (_remove = listenerHandle.remove) === null || _remove === void 0 || _remove.call(listenerHandle);
|
|
70
55
|
}
|
|
71
56
|
};
|
|
57
|
+
}, [isSecondaryScreen, unifiedCommunication]);
|
|
58
|
+
return snapshot;
|
|
59
|
+
}
|
|
60
|
+
/** 配置就绪后将同一业务实例的订单快照串行应用,不等待只读实例变为 ready。 */
|
|
61
|
+
function SharedSecondaryBigSaleReceiver({ payload }) {
|
|
62
|
+
const sales = require_useSalesSdk.useSalesSdk();
|
|
63
|
+
const bookingTicket = sales.bookingTicket;
|
|
64
|
+
const clearCartAndReset = sales.clearCartAndReset;
|
|
65
|
+
const settingsPending = sales.salesSettingsSource === "picoding" && !sales.salesSettings;
|
|
66
|
+
const applyQueueRef = (0, react.useRef)(Promise.resolve());
|
|
67
|
+
(0, react.useEffect)(() => {
|
|
68
|
+
if (!bookingTicket || settingsPending) return;
|
|
69
|
+
let cancelled = false;
|
|
70
|
+
applyQueueRef.current = applyQueueRef.current.then(require_asyncToGenerator._asyncToGenerator(function* () {
|
|
71
|
+
if (cancelled) return;
|
|
72
|
+
if (payload.tempOrder) {
|
|
73
|
+
if (!bookingTicket.replaceTempOrder) {
|
|
74
|
+
console.warn("[SharedSecondaryBigSale] 当前销售实例不支持 replaceTempOrder");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
yield bookingTicket.replaceTempOrder(payload.tempOrder);
|
|
78
|
+
} else yield clearCartAndReset();
|
|
79
|
+
if (cancelled) return;
|
|
80
|
+
if (payload.walletAssetsSnapshot && bookingTicket.importWalletAssetsSnapshot) yield bookingTicket.importWalletAssetsSnapshot(payload.walletAssetsSnapshot);
|
|
81
|
+
})).catch((error) => {
|
|
82
|
+
console.warn("[SharedSecondaryBigSale] 应用副屏订单快照失败", error);
|
|
83
|
+
});
|
|
84
|
+
return () => {
|
|
85
|
+
cancelled = true;
|
|
86
|
+
};
|
|
72
87
|
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
88
|
+
bookingTicket,
|
|
89
|
+
clearCartAndReset,
|
|
90
|
+
payload,
|
|
91
|
+
settingsPending
|
|
77
92
|
]);
|
|
78
93
|
return null;
|
|
79
94
|
}
|
|
80
95
|
//#endregion
|
|
81
96
|
exports.SharedSecondaryBigSaleReceiver = SharedSecondaryBigSaleReceiver;
|
|
97
|
+
exports.useSharedSecondaryBigSaleSnapshot = useSharedSecondaryBigSaleSnapshot;
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_useEngineContext = require("../../hooks/useEngineContext.js");
|
|
3
|
+
const require_tempOrderSync = require("../../plus/salesSdk/tempOrderSync.js");
|
|
2
4
|
const require_index = require("../bigSale/index.js");
|
|
3
5
|
const require_SharedSecondaryBigSaleReceiver = require("./SharedSecondaryBigSaleReceiver.js");
|
|
4
6
|
let react = require("react");
|
|
5
7
|
react = require_runtime.__toESM(react);
|
|
6
8
|
//#region src/components/sharedSecondaryBigSale/index.tsx
|
|
7
9
|
const DEFAULT_OS_KEY = "shared-secondary-big-sale";
|
|
10
|
+
let nextScopeId = 0;
|
|
8
11
|
/**
|
|
9
12
|
* 多个主屏销售实例共用的只读副屏;订单内容和布局继续复用 BigSale。
|
|
10
13
|
*/
|
|
11
14
|
function SharedSecondaryBigSale({ osKey = DEFAULT_OS_KEY, saleDetailModuleConfig, secondaryScreenDisplay, className, style }) {
|
|
12
|
-
|
|
15
|
+
var _context$appHelper, _context$appHelper$ge;
|
|
16
|
+
const payload = require_SharedSecondaryBigSaleReceiver.useSharedSecondaryBigSaleSnapshot();
|
|
17
|
+
const context = require_useEngineContext.default();
|
|
18
|
+
const salesContext = payload ? require_tempOrderSync.resolveTempOrderSyncSalesContext(payload) : void 0;
|
|
19
|
+
const businessCode = salesContext === null || salesContext === void 0 ? void 0 : salesContext.businessCode;
|
|
20
|
+
const localChannel = 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.getData) === null || _context$appHelper$ge === void 0 ? void 0 : _context$appHelper$ge.call(_context$appHelper, "channel");
|
|
21
|
+
const channel = (salesContext === null || salesContext === void 0 ? void 0 : salesContext.channel) || (typeof localChannel === "string" && localChannel.trim() ? localChannel.trim() : "cds");
|
|
22
|
+
const scopeId = (0, react.useMemo)(() => ++nextScopeId, [
|
|
13
23
|
osKey,
|
|
24
|
+
businessCode,
|
|
25
|
+
channel
|
|
26
|
+
]);
|
|
27
|
+
const otherParams = (0, react.useMemo)(() => ({ channel }), [channel]);
|
|
28
|
+
if (!payload || !businessCode) return /* @__PURE__ */ react.default.createElement("div", {
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
"aria-busy": "true"
|
|
32
|
+
});
|
|
33
|
+
return /* @__PURE__ */ react.default.createElement(require_index.default, {
|
|
34
|
+
key: scopeId,
|
|
35
|
+
osKey: `${osKey}-${encodeURIComponent(channel)}-${scopeId}`,
|
|
36
|
+
businessCode,
|
|
37
|
+
otherParams,
|
|
14
38
|
mode: "ticket",
|
|
15
39
|
template: "secondaryScreen",
|
|
16
40
|
saleDetailTemplate: "A",
|
|
@@ -22,7 +46,7 @@ function SharedSecondaryBigSale({ osKey = DEFAULT_OS_KEY, saleDetailModuleConfig
|
|
|
22
46
|
saleDetailModuleConfig,
|
|
23
47
|
className,
|
|
24
48
|
style,
|
|
25
|
-
bootstrapSlot: /* @__PURE__ */ react.default.createElement(require_SharedSecondaryBigSaleReceiver.SharedSecondaryBigSaleReceiver,
|
|
49
|
+
bootstrapSlot: /* @__PURE__ */ react.default.createElement(require_SharedSecondaryBigSaleReceiver.SharedSecondaryBigSaleReceiver, { payload })
|
|
26
50
|
});
|
|
27
51
|
}
|
|
28
52
|
//#endregion
|