@pisell/pisellos 0.10.6 → 0.10.8
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/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Order/index.d.ts +14 -6
- package/dist/modules/Order/index.js +373 -246
- package/dist/modules/Order/types.d.ts +26 -3
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
- package/dist/modules/Rules/index.js +125 -52
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +810 -729
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +9 -2
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/solution/BaseSales/index.d.ts +15 -5
- package/dist/solution/BaseSales/index.js +211 -159
- package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +13 -1
- package/dist/solution/BookingTicket/index.js +19 -22
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +16 -4
- package/dist/solution/UnifiedBookingSales/index.js +113 -48
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Order/index.d.ts +14 -6
- package/lib/modules/Order/index.js +192 -52
- package/lib/modules/Order/types.d.ts +26 -3
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
- package/lib/modules/Rules/index.js +100 -20
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +6 -0
- package/lib/server/index.js +51 -0
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +9 -3
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/solution/BaseSales/index.d.ts +15 -5
- package/lib/solution/BaseSales/index.js +64 -16
- package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +13 -1
- package/lib/solution/BookingTicket/index.js +6 -9
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +16 -4
- package/lib/solution/UnifiedBookingSales/index.js +80 -26
- package/package.json +1 -1
|
@@ -357,33 +357,44 @@ function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
|
|
|
357
357
|
return productList;
|
|
358
358
|
}
|
|
359
359
|
function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
360
|
+
const normalizeOptions = (options) => {
|
|
361
|
+
const optionArr = Array.isArray(options) ? options : [];
|
|
362
|
+
return optionArr.map((item) => ({
|
|
363
|
+
option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
|
|
364
|
+
option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
|
|
365
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
366
|
+
price: String((item == null ? void 0 : item.add_price) ?? (item == null ? void 0 : item.price) ?? "")
|
|
367
|
+
})).sort((p, q) => {
|
|
368
|
+
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
369
|
+
return p.option_group_item_id - q.option_group_item_id;
|
|
370
|
+
}
|
|
371
|
+
if (p.option_group_id !== q.option_group_id) {
|
|
372
|
+
return p.option_group_id - q.option_group_id;
|
|
373
|
+
}
|
|
374
|
+
if (p.num !== q.num)
|
|
375
|
+
return p.num - q.num;
|
|
376
|
+
return p.price.localeCompare(q.price);
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
const normalizedOpts = normalizeOptions(productOptionItem);
|
|
376
380
|
const bundleArr = Array.isArray(productBundle) ? productBundle : [];
|
|
377
381
|
const normalizedBundles = bundleArr.map((item) => ({
|
|
378
382
|
bundle_id: Number((item == null ? void 0 : item.bundle_id) ?? (item == null ? void 0 : item.id) ?? 0) || 0,
|
|
379
383
|
product_id: Number(item == null ? void 0 : item.product_id) || 0,
|
|
380
|
-
|
|
384
|
+
product_variant_id: Number((item == null ? void 0 : item.bundle_variant_id) ?? (item == null ? void 0 : item.product_variant_id)) || 0,
|
|
385
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
386
|
+
option: normalizeOptions(item == null ? void 0 : item.option)
|
|
381
387
|
})).sort((p, q) => {
|
|
382
388
|
if (p.bundle_id !== q.bundle_id)
|
|
383
389
|
return p.bundle_id - q.bundle_id;
|
|
384
390
|
if (p.product_id !== q.product_id)
|
|
385
391
|
return p.product_id - q.product_id;
|
|
386
|
-
|
|
392
|
+
if (p.product_variant_id !== q.product_variant_id) {
|
|
393
|
+
return p.product_variant_id - q.product_variant_id;
|
|
394
|
+
}
|
|
395
|
+
if (p.num !== q.num)
|
|
396
|
+
return p.num - q.num;
|
|
397
|
+
return JSON.stringify(p.option).localeCompare(JSON.stringify(q.option));
|
|
387
398
|
});
|
|
388
399
|
return JSON.stringify([normalizedOpts, normalizedBundles]);
|
|
389
400
|
}
|
|
@@ -63,8 +63,24 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
63
63
|
private openDataTarget;
|
|
64
64
|
private loadOpenDataInFlight;
|
|
65
65
|
private loadOpenDataInFlightTarget;
|
|
66
|
+
protected getSubmitOrderSalesChannel(): string;
|
|
66
67
|
protected isSessionStoragePersistEnabled(): boolean;
|
|
67
68
|
protected shouldUseSessionStorageForSubModule(moduleName?: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* 读取与当前 cacheId 同分桶的 Solution 会话状态。
|
|
71
|
+
* 该状态独立于 otherParams,适合页面皮肤保存短生命周期 UI 状态。
|
|
72
|
+
*/
|
|
73
|
+
getSessionStateValue<T = unknown>(key: string): T | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* 写入与当前 cacheId 同分桶的 Solution 会话状态。
|
|
76
|
+
* value 为 undefined 时删除该 key;存储失败不阻断业务流程。
|
|
77
|
+
*/
|
|
78
|
+
setSessionStateValue(key: string, value: unknown): void;
|
|
79
|
+
/**
|
|
80
|
+
* 清除当前 cacheId 的可恢复订单快照,同时保留 Solution UI sessionState。
|
|
81
|
+
* 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
|
|
82
|
+
*/
|
|
83
|
+
clearSessionStorageOrderSnapshot(): void;
|
|
68
84
|
/**
|
|
69
85
|
* Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
|
|
70
86
|
* 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
|
|
@@ -111,10 +127,6 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
111
127
|
* Read-only compatibility view for salesSdk skins. It reconnects a booking to its product but
|
|
112
128
|
* must not be used to mutate tempOrder; all writes go through BaseSales / planner APIs.
|
|
113
129
|
*/
|
|
114
|
-
getCart(): {
|
|
115
|
-
items: any[];
|
|
116
|
-
bookings: any[];
|
|
117
|
-
};
|
|
118
130
|
/**
|
|
119
131
|
* Loads the current customer's product coupons and discount cards after planner lines exist,
|
|
120
132
|
* then optionally lets the existing Rules engine select the best valid combination. This is a
|
|
@@ -49,6 +49,9 @@ var import_BookingTicket = require("../BookingTicket");
|
|
|
49
49
|
__reExport(UnifiedBookingSales_exports, require("./types"), module.exports);
|
|
50
50
|
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
51
51
|
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
52
|
+
function isRecord(value) {
|
|
53
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
54
|
+
}
|
|
52
55
|
function pickLocalizedText(value) {
|
|
53
56
|
if (!value)
|
|
54
57
|
return void 0;
|
|
@@ -469,6 +472,11 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
469
472
|
this.loadOpenDataInFlight = null;
|
|
470
473
|
this.loadOpenDataInFlightTarget = null;
|
|
471
474
|
}
|
|
475
|
+
getSubmitOrderSalesChannel() {
|
|
476
|
+
var _a;
|
|
477
|
+
const channel = String(((_a = this.otherParams) == null ? void 0 : _a.channel) ?? "").trim();
|
|
478
|
+
return channel || super.getSubmitOrderSalesChannel();
|
|
479
|
+
}
|
|
472
480
|
isSessionStoragePersistEnabled() {
|
|
473
481
|
var _a;
|
|
474
482
|
return Boolean(
|
|
@@ -478,6 +486,51 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
478
486
|
shouldUseSessionStorageForSubModule(moduleName) {
|
|
479
487
|
return this.isSessionStoragePersistEnabled() && moduleName === "order";
|
|
480
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* 读取与当前 cacheId 同分桶的 Solution 会话状态。
|
|
491
|
+
* 该状态独立于 otherParams,适合页面皮肤保存短生命周期 UI 状态。
|
|
492
|
+
*/
|
|
493
|
+
getSessionStateValue(key) {
|
|
494
|
+
if (!key || !this.isSessionStoragePersistEnabled())
|
|
495
|
+
return void 0;
|
|
496
|
+
const cacheData = this.readSessionCacheData();
|
|
497
|
+
const solutionCache = cacheData == null ? void 0 : cacheData[this.name];
|
|
498
|
+
if (!isRecord(solutionCache) || !isRecord(solutionCache.sessionState)) {
|
|
499
|
+
return void 0;
|
|
500
|
+
}
|
|
501
|
+
return solutionCache.sessionState[key];
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* 写入与当前 cacheId 同分桶的 Solution 会话状态。
|
|
505
|
+
* value 为 undefined 时删除该 key;存储失败不阻断业务流程。
|
|
506
|
+
*/
|
|
507
|
+
setSessionStateValue(key, value) {
|
|
508
|
+
if (!key || !this.isSessionStoragePersistEnabled())
|
|
509
|
+
return;
|
|
510
|
+
const cacheData = this.readSessionCacheData();
|
|
511
|
+
const solutionCache = cacheData == null ? void 0 : cacheData[this.name];
|
|
512
|
+
const currentSessionState = isRecord(solutionCache) && isRecord(solutionCache.sessionState) ? solutionCache.sessionState : {};
|
|
513
|
+
const nextSessionState = { ...currentSessionState };
|
|
514
|
+
if (value === void 0) {
|
|
515
|
+
delete nextSessionState[key];
|
|
516
|
+
} else {
|
|
517
|
+
nextSessionState[key] = value;
|
|
518
|
+
}
|
|
519
|
+
this.checkSaveCache({
|
|
520
|
+
cacheId: this.cacheId,
|
|
521
|
+
fatherModule: this.name,
|
|
522
|
+
store: { sessionState: nextSessionState },
|
|
523
|
+
cacheKey: ["sessionState"]
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* 清除当前 cacheId 的可恢复订单快照,同时保留 Solution UI sessionState。
|
|
528
|
+
* 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
|
|
529
|
+
*/
|
|
530
|
+
clearSessionStorageOrderSnapshot() {
|
|
531
|
+
var _a, _b;
|
|
532
|
+
(_b = (_a = this.store.order) == null ? void 0 : _a.clearSessionStoragePersistedTempOrder) == null ? void 0 : _b.call(_a);
|
|
533
|
+
}
|
|
481
534
|
/**
|
|
482
535
|
* Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
|
|
483
536
|
* 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
|
|
@@ -761,32 +814,33 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
761
814
|
* Read-only compatibility view for salesSdk skins. It reconnects a booking to its product but
|
|
762
815
|
* must not be used to mutate tempOrder; all writes go through BaseSales / planner APIs.
|
|
763
816
|
*/
|
|
764
|
-
getCart() {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
817
|
+
// getCart(): BookingTicketCartView {
|
|
818
|
+
// const tempOrder = this.getTempOrder();
|
|
819
|
+
// const salesDetail = this.getSalesOrder();
|
|
820
|
+
// const items = tempOrder?.products || [];
|
|
821
|
+
// const bookings = salesDetail?.bookings || tempOrder?.bookings || [];
|
|
822
|
+
// return {
|
|
823
|
+
// items,
|
|
824
|
+
// bookings: bookings.map((booking: any) => {
|
|
825
|
+
// const productUid = booking?.product_uid;
|
|
826
|
+
// const product = productUid
|
|
827
|
+
// ? items.find((item: any) => {
|
|
828
|
+
// const uid = item?.metadata?.unique_identification_number || item?.unique_identification_number;
|
|
829
|
+
// return String(uid || '') === String(productUid);
|
|
830
|
+
// }) || null
|
|
831
|
+
// : null;
|
|
832
|
+
// return {
|
|
833
|
+
// ...booking,
|
|
834
|
+
// _extend: {
|
|
835
|
+
// ...(booking?._extend || {}),
|
|
836
|
+
// product,
|
|
837
|
+
// addTimeProduct: [],
|
|
838
|
+
// canAddTime: false,
|
|
839
|
+
// },
|
|
840
|
+
// };
|
|
841
|
+
// }),
|
|
842
|
+
// };
|
|
843
|
+
// }
|
|
790
844
|
/**
|
|
791
845
|
* Loads the current customer's product coupons and discount cards after planner lines exist,
|
|
792
846
|
* then optionally lets the existing Rules engine select the best valid combination. This is a
|