@pisell/private-materials 6.12.182 → 6.12.183
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/plus/salesSdk/context/SalesSdkProvider.js +20 -13
- package/es/plus/salesSdk/docs.md +3 -2
- package/es/plus/salesSdk/hooks/useSalesSdkTempOrderSync.js +22 -1
- package/lib/plus/salesSdk/context/SalesSdkProvider.js +20 -13
- package/lib/plus/salesSdk/docs.md +3 -2
- package/lib/plus/salesSdk/hooks/useSalesSdkTempOrderSync.js +22 -1
- package/package.json +4 -4
|
@@ -451,10 +451,11 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
451
451
|
* 内部 refresh:所有改 OS 的入口在动作完成后调一次,把 tempOrder / salesDetail 同步到顶层 state。
|
|
452
452
|
* 子 Provider 通过 `SalesSdkRootRefreshContext` 拿到此函数。
|
|
453
453
|
*/
|
|
454
|
-
const refreshRootSnapshot = useMemoizedFn(() => {
|
|
454
|
+
const refreshRootSnapshot = useMemoizedFn((publishOptions) => {
|
|
455
455
|
const nextSnapshot = readRootSnapshot(bookingTicket);
|
|
456
456
|
setRootSnapshot(nextSnapshot);
|
|
457
|
-
publishTempOrderRef.current(nextSnapshot.tempOrder);
|
|
457
|
+
if (publishOptions) publishTempOrderRef.current(nextSnapshot.tempOrder, publishOptions);
|
|
458
|
+
else publishTempOrderRef.current(nextSnapshot.tempOrder);
|
|
458
459
|
});
|
|
459
460
|
/**
|
|
460
461
|
* 编辑弹窗切换 orderId 时:同一订单保留顶层 React 快照供热打开直接展示;
|
|
@@ -569,7 +570,7 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
569
570
|
useEffect(() => {
|
|
570
571
|
if (!bookingTicket) return;
|
|
571
572
|
const off = bookingTicket.effectsOn("onDiscountApplied", () => {
|
|
572
|
-
refreshRootSnapshot();
|
|
573
|
+
refreshRootSnapshot({ preserveRemoteOrigin: true });
|
|
573
574
|
});
|
|
574
575
|
return () => {
|
|
575
576
|
try {
|
|
@@ -582,16 +583,21 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
582
583
|
if (!bookingTicket) return;
|
|
583
584
|
const orderModule = (_bookingTicket$store = bookingTicket.store) === null || _bookingTicket$store === void 0 ? void 0 : _bookingTicket$store.order;
|
|
584
585
|
if (!orderModule || typeof orderModule.effectsOn !== "function") return;
|
|
585
|
-
let
|
|
586
|
+
let walletRefreshTimer = null;
|
|
586
587
|
const off = orderModule.effectsOn("onPromotionApplied", () => {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
588
|
+
refreshRootSnapshot();
|
|
589
|
+
if (typeof bookingTicket.refreshWalletAssets !== "function") return;
|
|
590
|
+
if (walletRefreshTimer !== null) clearTimeout(walletRefreshTimer);
|
|
591
|
+
walletRefreshTimer = setTimeout(() => {
|
|
592
|
+
var _bookingTicket$refres;
|
|
593
|
+
walletRefreshTimer = null;
|
|
594
|
+
(_bookingTicket$refres = bookingTicket.refreshWalletAssets) === null || _bookingTicket$refres === void 0 || _bookingTicket$refres.call(bookingTicket, { preserveSelection: true }).catch((error) => {
|
|
595
|
+
console.warn("[SalesSdk] 商品变化后 Wallet 重验失败", error);
|
|
596
|
+
});
|
|
597
|
+
}, 120);
|
|
592
598
|
});
|
|
593
599
|
return () => {
|
|
594
|
-
if (
|
|
600
|
+
if (walletRefreshTimer !== null) clearTimeout(walletRefreshTimer);
|
|
595
601
|
try {
|
|
596
602
|
off();
|
|
597
603
|
} catch (_unused4) {}
|
|
@@ -628,17 +634,18 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
628
634
|
var _bookingTicket$getTem4, _bookingTicket$getTem5;
|
|
629
635
|
if (!bookingTicket) return;
|
|
630
636
|
walletOrderAffectingSignatureRef.current = resolveWalletOrderAffectingSignature((_bookingTicket$getTem4 = (_bookingTicket$getTem5 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem5 === void 0 ? void 0 : _bookingTicket$getTem5.call(bookingTicket)) !== null && _bookingTicket$getTem4 !== void 0 ? _bookingTicket$getTem4 : null);
|
|
631
|
-
const off = bookingTicket.effectsOn("onWalletAssetsStateChanged", () => {
|
|
637
|
+
const off = bookingTicket.effectsOn("onWalletAssetsStateChanged", (eventPayload) => {
|
|
632
638
|
var _bookingTicket$getTem6, _bookingTicket$getTem7, _summaryProviderRef$c;
|
|
633
639
|
const tempOrder = (_bookingTicket$getTem6 = (_bookingTicket$getTem7 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem7 === void 0 ? void 0 : _bookingTicket$getTem7.call(bookingTicket)) !== null && _bookingTicket$getTem6 !== void 0 ? _bookingTicket$getTem6 : null;
|
|
634
640
|
const nextSignature = resolveWalletOrderAffectingSignature(tempOrder);
|
|
635
641
|
if (nextSignature === walletOrderAffectingSignatureRef.current) {
|
|
636
|
-
publishTempOrderRef.current(tempOrder, { preserveRemoteOrigin: true });
|
|
642
|
+
if ((eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.changeSource) === "derived") publishTempOrderRef.current(tempOrder, { preserveRemoteOrigin: true });
|
|
643
|
+
else publishTempOrderRef.current(tempOrder);
|
|
637
644
|
checkPromotionItemCountIncrease();
|
|
638
645
|
return;
|
|
639
646
|
}
|
|
640
647
|
walletOrderAffectingSignatureRef.current = nextSignature;
|
|
641
|
-
refreshRootSnapshot();
|
|
648
|
+
refreshRootSnapshot((eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.changeSource) === "derived" ? { preserveRemoteOrigin: true } : void 0);
|
|
642
649
|
(_summaryProviderRef$c = summaryProviderRef.current) === null || _summaryProviderRef$c === void 0 || _summaryProviderRef$c.refreshSummary().catch((error) => {
|
|
643
650
|
console.warn("[SalesSdk] wallet summary 刷新失败", error);
|
|
644
651
|
}).finally(() => {
|
package/es/plus/salesSdk/docs.md
CHANGED
|
@@ -791,14 +791,15 @@ SalesSdk giftSelectResolver (bridge) ─┘ │
|
|
|
791
791
|
├─ 评估器:算价 + 拆分 + gifts
|
|
792
792
|
├─ giftActions: toAdd / toReduce / toRemove
|
|
793
793
|
├─ 写回 tempOrder.products(含 _promotion / _giftInfo)
|
|
794
|
-
|
|
794
|
+
├─ applyDiscount + recalculateSummary + persist
|
|
795
|
+
└─ emit `order:onPromotionApplied`(稳定态)
|
|
795
796
|
│
|
|
796
797
|
SalesSdkCartContext ◀──────────────────────── unfulfilledPromotions / lastGiftActions
|
|
797
798
|
SalesSdkProductContext.products ◀─ appendPromotionTagsForProducts(products, evaluator)
|
|
798
799
|
```
|
|
799
800
|
|
|
800
801
|
- 评估与赠品落地的 **唯一真源** 是 OS `OrderModule`;SDK 不再算价或维护 `toAdd/toReduce`。
|
|
801
|
-
- 写路径(`addProductToOrder` / `updateOrderProduct(Quantity)` / `removeProductFromOrder` / `clearOrderCartLines` / `setOrderCustomer
|
|
802
|
+
- 写路径(`addProductToOrder` / `updateOrderProduct(Quantity)` / `removeProductFromOrder` / `clearOrderCartLines` / `setOrderCustomer`)统一先完成促销评估,再执行 `applyDiscount() → recalculateSummary() → persist`,最后发布 `onPromotionApplied`;订阅方读取到的是可直接同步的稳定态。
|
|
802
803
|
- 多选项赠品由 SDK Host 弹窗(`GiftSelectHostRenderer`)让用户选择,OS 同步 `await` 结果后落 cart。
|
|
803
804
|
|
|
804
805
|
### 9.2 evaluator 注入(host 透明)
|
|
@@ -27,6 +27,21 @@ function resolvePayloadDiscountState(payload) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
+
* Wallet 快照只能应用到生成它时对应的订单应付金额。
|
|
31
|
+
* 商品 revision 先于 Wallet 异步重算完成时,拒绝传播旧计算结果。
|
|
32
|
+
* 缺少任一金额(兼容旧 OS/测试桩)时保持原有导入行为。
|
|
33
|
+
*/
|
|
34
|
+
function isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, snapshot) {
|
|
35
|
+
var _bookingTicket$getOrd, _snapshot$calculation;
|
|
36
|
+
const rawCurrentAmount = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getOrd = bookingTicket.getOrderAmountSnapshot) === null || _bookingTicket$getOrd === void 0 || (_bookingTicket$getOrd = _bookingTicket$getOrd.call(bookingTicket)) === null || _bookingTicket$getOrd === void 0 ? void 0 : _bookingTicket$getOrd.amountGap;
|
|
37
|
+
const rawSnapshotAmount = (_snapshot$calculation = snapshot.calculationContext) === null || _snapshot$calculation === void 0 ? void 0 : _snapshot$calculation.orderTotalAmount;
|
|
38
|
+
if (rawCurrentAmount === void 0 || rawCurrentAmount === null || rawCurrentAmount === "" || rawSnapshotAmount === void 0 || rawSnapshotAmount === null) return true;
|
|
39
|
+
const currentAmount = Number(rawCurrentAmount);
|
|
40
|
+
const snapshotAmount = Number(rawSnapshotAmount);
|
|
41
|
+
if (!Number.isFinite(currentAmount) || !Number.isFinite(snapshotAmount)) return true;
|
|
42
|
+
return Math.abs(currentAmount - snapshotAmount) < .005;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
30
45
|
* SalesSdk tempOrder 对等双屏同步。
|
|
31
46
|
*
|
|
32
47
|
* 两端都可发布本地变更、接收同 osKey 快照;页面激活时向更早激活的对端补拉。
|
|
@@ -76,7 +91,8 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
76
91
|
console.warn("[SalesSdk] 读取折扣运行态失败,仅同步 tempOrder", error);
|
|
77
92
|
}
|
|
78
93
|
if (typeof bookingTicket.exportWalletAssetsSnapshot === "function") try {
|
|
79
|
-
|
|
94
|
+
const walletAssetsSnapshot = bookingTicket.exportWalletAssetsSnapshot();
|
|
95
|
+
if (isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, walletAssetsSnapshot)) snapshot.walletAssetsSnapshot = walletAssetsSnapshot;
|
|
80
96
|
} catch (error) {
|
|
81
97
|
console.warn("[SalesSdk] 读取 Wallet 运行态失败,仅同步订单", error);
|
|
82
98
|
}
|
|
@@ -225,6 +241,7 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
225
241
|
revision
|
|
226
242
|
} : null;
|
|
227
243
|
try {
|
|
244
|
+
var _bookingTicket$getWal;
|
|
228
245
|
if (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.replaceDiscountStoreLists) yield bookingTicket.replaceDiscountStoreLists(resolvePayloadDiscountState(payload));
|
|
229
246
|
if (payload.tempOrder) {
|
|
230
247
|
if (!(bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.replaceTempOrder)) {
|
|
@@ -237,6 +254,10 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
237
254
|
yield bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$restor = bookingTicket.restoreOrder) === null || _bookingTicket$restor === void 0 ? void 0 : _bookingTicket$restor.call(bookingTicket);
|
|
238
255
|
}
|
|
239
256
|
if (payload.walletAssetsSnapshot && (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.importWalletAssetsSnapshot)) yield bookingTicket.importWalletAssetsSnapshot(cloneDeep(payload.walletAssetsSnapshot));
|
|
257
|
+
const importedWalletSnapshotIsAligned = payload.walletAssetsSnapshot ? isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, payload.walletAssetsSnapshot) : false;
|
|
258
|
+
const currentWalletState = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getWal = bookingTicket.getWalletAssetsState) === null || _bookingTicket$getWal === void 0 ? void 0 : _bookingTicket$getWal.call(bookingTicket);
|
|
259
|
+
const hasWalletRuntimeState = Boolean(currentWalletState && (currentWalletState.items.length > 0 || currentWalletState.selectedIds.length > 0 || currentWalletState.committedIds.length > 0));
|
|
260
|
+
if (payload.tempOrder && (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.refreshWalletAssets) && hasWalletRuntimeState && !importedWalletSnapshotIsAligned) yield bookingTicket.refreshWalletAssets({ preserveSelection: true });
|
|
240
261
|
refreshRootSnapshot();
|
|
241
262
|
if (isRequestedResponse) pendingRequestIdsRef.current.delete(requestId);
|
|
242
263
|
if (revision !== null) lastRevisionBySourceRef.current.set(sourceKey, revision);
|
|
@@ -454,10 +454,11 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
454
454
|
* 内部 refresh:所有改 OS 的入口在动作完成后调一次,把 tempOrder / salesDetail 同步到顶层 state。
|
|
455
455
|
* 子 Provider 通过 `SalesSdkRootRefreshContext` 拿到此函数。
|
|
456
456
|
*/
|
|
457
|
-
const refreshRootSnapshot = (0, ahooks.useMemoizedFn)(() => {
|
|
457
|
+
const refreshRootSnapshot = (0, ahooks.useMemoizedFn)((publishOptions) => {
|
|
458
458
|
const nextSnapshot = readRootSnapshot(bookingTicket);
|
|
459
459
|
setRootSnapshot(nextSnapshot);
|
|
460
|
-
publishTempOrderRef.current(nextSnapshot.tempOrder);
|
|
460
|
+
if (publishOptions) publishTempOrderRef.current(nextSnapshot.tempOrder, publishOptions);
|
|
461
|
+
else publishTempOrderRef.current(nextSnapshot.tempOrder);
|
|
461
462
|
});
|
|
462
463
|
/**
|
|
463
464
|
* 编辑弹窗切换 orderId 时:同一订单保留顶层 React 快照供热打开直接展示;
|
|
@@ -572,7 +573,7 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
572
573
|
(0, react.useEffect)(() => {
|
|
573
574
|
if (!bookingTicket) return;
|
|
574
575
|
const off = bookingTicket.effectsOn("onDiscountApplied", () => {
|
|
575
|
-
refreshRootSnapshot();
|
|
576
|
+
refreshRootSnapshot({ preserveRemoteOrigin: true });
|
|
576
577
|
});
|
|
577
578
|
return () => {
|
|
578
579
|
try {
|
|
@@ -585,16 +586,21 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
585
586
|
if (!bookingTicket) return;
|
|
586
587
|
const orderModule = (_bookingTicket$store = bookingTicket.store) === null || _bookingTicket$store === void 0 ? void 0 : _bookingTicket$store.order;
|
|
587
588
|
if (!orderModule || typeof orderModule.effectsOn !== "function") return;
|
|
588
|
-
let
|
|
589
|
+
let walletRefreshTimer = null;
|
|
589
590
|
const off = orderModule.effectsOn("onPromotionApplied", () => {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
refreshRootSnapshot();
|
|
592
|
+
if (typeof bookingTicket.refreshWalletAssets !== "function") return;
|
|
593
|
+
if (walletRefreshTimer !== null) clearTimeout(walletRefreshTimer);
|
|
594
|
+
walletRefreshTimer = setTimeout(() => {
|
|
595
|
+
var _bookingTicket$refres;
|
|
596
|
+
walletRefreshTimer = null;
|
|
597
|
+
(_bookingTicket$refres = bookingTicket.refreshWalletAssets) === null || _bookingTicket$refres === void 0 || _bookingTicket$refres.call(bookingTicket, { preserveSelection: true }).catch((error) => {
|
|
598
|
+
console.warn("[SalesSdk] 商品变化后 Wallet 重验失败", error);
|
|
599
|
+
});
|
|
600
|
+
}, 120);
|
|
595
601
|
});
|
|
596
602
|
return () => {
|
|
597
|
-
if (
|
|
603
|
+
if (walletRefreshTimer !== null) clearTimeout(walletRefreshTimer);
|
|
598
604
|
try {
|
|
599
605
|
off();
|
|
600
606
|
} catch (_unused4) {}
|
|
@@ -631,17 +637,18 @@ const SalesSdkProvider = ({ osKey, solution = "bookingTicket", moduleAccess = "e
|
|
|
631
637
|
var _bookingTicket$getTem4, _bookingTicket$getTem5;
|
|
632
638
|
if (!bookingTicket) return;
|
|
633
639
|
walletOrderAffectingSignatureRef.current = resolveWalletOrderAffectingSignature((_bookingTicket$getTem4 = (_bookingTicket$getTem5 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem5 === void 0 ? void 0 : _bookingTicket$getTem5.call(bookingTicket)) !== null && _bookingTicket$getTem4 !== void 0 ? _bookingTicket$getTem4 : null);
|
|
634
|
-
const off = bookingTicket.effectsOn("onWalletAssetsStateChanged", () => {
|
|
640
|
+
const off = bookingTicket.effectsOn("onWalletAssetsStateChanged", (eventPayload) => {
|
|
635
641
|
var _bookingTicket$getTem6, _bookingTicket$getTem7, _summaryProviderRef$c;
|
|
636
642
|
const tempOrder = (_bookingTicket$getTem6 = (_bookingTicket$getTem7 = bookingTicket.getTempOrder) === null || _bookingTicket$getTem7 === void 0 ? void 0 : _bookingTicket$getTem7.call(bookingTicket)) !== null && _bookingTicket$getTem6 !== void 0 ? _bookingTicket$getTem6 : null;
|
|
637
643
|
const nextSignature = resolveWalletOrderAffectingSignature(tempOrder);
|
|
638
644
|
if (nextSignature === walletOrderAffectingSignatureRef.current) {
|
|
639
|
-
publishTempOrderRef.current(tempOrder, { preserveRemoteOrigin: true });
|
|
645
|
+
if ((eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.changeSource) === "derived") publishTempOrderRef.current(tempOrder, { preserveRemoteOrigin: true });
|
|
646
|
+
else publishTempOrderRef.current(tempOrder);
|
|
640
647
|
checkPromotionItemCountIncrease();
|
|
641
648
|
return;
|
|
642
649
|
}
|
|
643
650
|
walletOrderAffectingSignatureRef.current = nextSignature;
|
|
644
|
-
refreshRootSnapshot();
|
|
651
|
+
refreshRootSnapshot((eventPayload === null || eventPayload === void 0 ? void 0 : eventPayload.changeSource) === "derived" ? { preserveRemoteOrigin: true } : void 0);
|
|
645
652
|
(_summaryProviderRef$c = summaryProviderRef.current) === null || _summaryProviderRef$c === void 0 || _summaryProviderRef$c.refreshSummary().catch((error) => {
|
|
646
653
|
console.warn("[SalesSdk] wallet summary 刷新失败", error);
|
|
647
654
|
}).finally(() => {
|
|
@@ -791,14 +791,15 @@ SalesSdk giftSelectResolver (bridge) ─┘ │
|
|
|
791
791
|
├─ 评估器:算价 + 拆分 + gifts
|
|
792
792
|
├─ giftActions: toAdd / toReduce / toRemove
|
|
793
793
|
├─ 写回 tempOrder.products(含 _promotion / _giftInfo)
|
|
794
|
-
|
|
794
|
+
├─ applyDiscount + recalculateSummary + persist
|
|
795
|
+
└─ emit `order:onPromotionApplied`(稳定态)
|
|
795
796
|
│
|
|
796
797
|
SalesSdkCartContext ◀──────────────────────── unfulfilledPromotions / lastGiftActions
|
|
797
798
|
SalesSdkProductContext.products ◀─ appendPromotionTagsForProducts(products, evaluator)
|
|
798
799
|
```
|
|
799
800
|
|
|
800
801
|
- 评估与赠品落地的 **唯一真源** 是 OS `OrderModule`;SDK 不再算价或维护 `toAdd/toReduce`。
|
|
801
|
-
- 写路径(`addProductToOrder` / `updateOrderProduct(Quantity)` / `removeProductFromOrder` / `clearOrderCartLines` / `setOrderCustomer
|
|
802
|
+
- 写路径(`addProductToOrder` / `updateOrderProduct(Quantity)` / `removeProductFromOrder` / `clearOrderCartLines` / `setOrderCustomer`)统一先完成促销评估,再执行 `applyDiscount() → recalculateSummary() → persist`,最后发布 `onPromotionApplied`;订阅方读取到的是可直接同步的稳定态。
|
|
802
803
|
- 多选项赠品由 SDK Host 弹窗(`GiftSelectHostRenderer`)让用户选择,OS 同步 `await` 结果后落 cart。
|
|
803
804
|
|
|
804
805
|
### 9.2 evaluator 注入(host 透明)
|
|
@@ -28,6 +28,21 @@ function resolvePayloadDiscountState(payload) {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
+
* Wallet 快照只能应用到生成它时对应的订单应付金额。
|
|
32
|
+
* 商品 revision 先于 Wallet 异步重算完成时,拒绝传播旧计算结果。
|
|
33
|
+
* 缺少任一金额(兼容旧 OS/测试桩)时保持原有导入行为。
|
|
34
|
+
*/
|
|
35
|
+
function isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, snapshot) {
|
|
36
|
+
var _bookingTicket$getOrd, _snapshot$calculation;
|
|
37
|
+
const rawCurrentAmount = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getOrd = bookingTicket.getOrderAmountSnapshot) === null || _bookingTicket$getOrd === void 0 || (_bookingTicket$getOrd = _bookingTicket$getOrd.call(bookingTicket)) === null || _bookingTicket$getOrd === void 0 ? void 0 : _bookingTicket$getOrd.amountGap;
|
|
38
|
+
const rawSnapshotAmount = (_snapshot$calculation = snapshot.calculationContext) === null || _snapshot$calculation === void 0 ? void 0 : _snapshot$calculation.orderTotalAmount;
|
|
39
|
+
if (rawCurrentAmount === void 0 || rawCurrentAmount === null || rawCurrentAmount === "" || rawSnapshotAmount === void 0 || rawSnapshotAmount === null) return true;
|
|
40
|
+
const currentAmount = Number(rawCurrentAmount);
|
|
41
|
+
const snapshotAmount = Number(rawSnapshotAmount);
|
|
42
|
+
if (!Number.isFinite(currentAmount) || !Number.isFinite(snapshotAmount)) return true;
|
|
43
|
+
return Math.abs(currentAmount - snapshotAmount) < .005;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
31
46
|
* SalesSdk tempOrder 对等双屏同步。
|
|
32
47
|
*
|
|
33
48
|
* 两端都可发布本地变更、接收同 osKey 快照;页面激活时向更早激活的对端补拉。
|
|
@@ -77,7 +92,8 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
77
92
|
console.warn("[SalesSdk] 读取折扣运行态失败,仅同步 tempOrder", error);
|
|
78
93
|
}
|
|
79
94
|
if (typeof bookingTicket.exportWalletAssetsSnapshot === "function") try {
|
|
80
|
-
|
|
95
|
+
const walletAssetsSnapshot = bookingTicket.exportWalletAssetsSnapshot();
|
|
96
|
+
if (isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, walletAssetsSnapshot)) snapshot.walletAssetsSnapshot = walletAssetsSnapshot;
|
|
81
97
|
} catch (error) {
|
|
82
98
|
console.warn("[SalesSdk] 读取 Wallet 运行态失败,仅同步订单", error);
|
|
83
99
|
}
|
|
@@ -226,6 +242,7 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
226
242
|
revision
|
|
227
243
|
} : null;
|
|
228
244
|
try {
|
|
245
|
+
var _bookingTicket$getWal;
|
|
229
246
|
if (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.replaceDiscountStoreLists) yield bookingTicket.replaceDiscountStoreLists(resolvePayloadDiscountState(payload));
|
|
230
247
|
if (payload.tempOrder) {
|
|
231
248
|
if (!(bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.replaceTempOrder)) {
|
|
@@ -238,6 +255,10 @@ function useSalesSdkTempOrderSync({ enabled, isActive = true, osKey, bookingTick
|
|
|
238
255
|
yield bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$restor = bookingTicket.restoreOrder) === null || _bookingTicket$restor === void 0 ? void 0 : _bookingTicket$restor.call(bookingTicket);
|
|
239
256
|
}
|
|
240
257
|
if (payload.walletAssetsSnapshot && (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.importWalletAssetsSnapshot)) yield bookingTicket.importWalletAssetsSnapshot((0, lodash.cloneDeep)(payload.walletAssetsSnapshot));
|
|
258
|
+
const importedWalletSnapshotIsAligned = payload.walletAssetsSnapshot ? isWalletSnapshotAlignedWithCurrentOrder(bookingTicket, payload.walletAssetsSnapshot) : false;
|
|
259
|
+
const currentWalletState = bookingTicket === null || bookingTicket === void 0 || (_bookingTicket$getWal = bookingTicket.getWalletAssetsState) === null || _bookingTicket$getWal === void 0 ? void 0 : _bookingTicket$getWal.call(bookingTicket);
|
|
260
|
+
const hasWalletRuntimeState = Boolean(currentWalletState && (currentWalletState.items.length > 0 || currentWalletState.selectedIds.length > 0 || currentWalletState.committedIds.length > 0));
|
|
261
|
+
if (payload.tempOrder && (bookingTicket === null || bookingTicket === void 0 ? void 0 : bookingTicket.refreshWalletAssets) && hasWalletRuntimeState && !importedWalletSnapshotIsAligned) yield bookingTicket.refreshWalletAssets({ preserveSelection: true });
|
|
241
262
|
refreshRootSnapshot();
|
|
242
263
|
if (isRequestedResponse) pendingRequestIdsRef.current.delete(requestId);
|
|
243
264
|
if (revision !== null) lastRevisionBySourceRef.current.set(sourceKey, revision);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.12.
|
|
3
|
+
"version": "6.12.183",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"styled-components": "^6.0.0-rc.3",
|
|
71
71
|
"use-sync-external-store": "^1.6.0",
|
|
72
72
|
"@pisell/pi-payment-sdk": "0.0.3",
|
|
73
|
-
"@pisell/icon": "0.0.11",
|
|
74
|
-
"@pisell/date-picker": "3.0.10",
|
|
75
73
|
"@pisell/utils": "3.0.4",
|
|
76
|
-
"@pisell/materials": "6.12.52"
|
|
74
|
+
"@pisell/materials": "6.12.52",
|
|
75
|
+
"@pisell/date-picker": "3.0.10",
|
|
76
|
+
"@pisell/icon": "0.0.11"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"react": "^18.0.0",
|