@pisell/pisellos 2.3.66 → 2.3.68
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 +0 -9
- package/dist/modules/BaseModule.d.ts +1 -0
- package/dist/modules/BaseModule.js +24 -28
- package/dist/modules/Order/index.d.ts +22 -2
- package/dist/modules/Order/index.js +313 -142
- package/dist/modules/Order/types.d.ts +13 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
- package/dist/modules/Order/utils.js +0 -1
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +14 -4
- package/dist/modules/Payment/walletpass.js +21 -7
- package/dist/modules/Rules/index.js +46 -31
- package/dist/solution/BaseSales/index.d.ts +3 -1
- package/dist/solution/BaseSales/index.js +99 -82
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -2
- package/dist/solution/BookingTicket/index.js +89 -65
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/dist/solution/UnifiedBookingSales/index.js +640 -321
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BaseModule.d.ts +1 -0
- package/lib/modules/BaseModule.js +24 -37
- package/lib/modules/Order/index.d.ts +22 -2
- package/lib/modules/Order/index.js +212 -54
- package/lib/modules/Order/types.d.ts +13 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
- package/lib/modules/Order/utils.js +0 -1
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +7 -0
- package/lib/modules/Payment/walletpass.js +12 -0
- package/lib/modules/Rules/index.js +17 -1
- package/lib/solution/BaseSales/index.d.ts +3 -1
- package/lib/solution/BaseSales/index.js +29 -16
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -2
- package/lib/solution/BookingTicket/index.js +35 -12
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/lib/solution/UnifiedBookingSales/index.js +188 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -141,6 +144,28 @@ function toNumberId(value) {
|
|
|
141
144
|
const parsed = Number(value);
|
|
142
145
|
return Number.isFinite(parsed) ? parsed : String(value);
|
|
143
146
|
}
|
|
147
|
+
function toCustomerId(value) {
|
|
148
|
+
const parsed = Number(value);
|
|
149
|
+
return Number.isFinite(parsed) && parsed > 1 ? parsed : null;
|
|
150
|
+
}
|
|
151
|
+
function resolveTempOrderCustomerId(tempOrder) {
|
|
152
|
+
var _a, _b, _c, _d, _e;
|
|
153
|
+
return toCustomerId(
|
|
154
|
+
(tempOrder == null ? void 0 : tempOrder.customer_id) || ((_a = tempOrder == null ? void 0 : tempOrder.customer) == null ? void 0 : _a.id) || ((_c = (_b = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _b.customerSnapshot) == null ? void 0 : _c.id) || ((_e = (_d = tempOrder == null ? void 0 : tempOrder._extend) == null ? void 0 : _d.customerSnapshot) == null ? void 0 : _e.customer_id)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
function isLocalOrderId(orderId) {
|
|
158
|
+
return typeof orderId === "string" && orderId.startsWith("local_order");
|
|
159
|
+
}
|
|
160
|
+
function isCustomerBoundDiscount(discount) {
|
|
161
|
+
const type = (discount == null ? void 0 : discount.type) ?? (discount == null ? void 0 : discount.tag);
|
|
162
|
+
return type === "good_pass" || type === "discount_card" || type === "product_discount_card";
|
|
163
|
+
}
|
|
164
|
+
function filterCustomerBoundDiscounts(discountList) {
|
|
165
|
+
if (!Array.isArray(discountList))
|
|
166
|
+
return [];
|
|
167
|
+
return discountList.filter((discount) => !isCustomerBoundDiscount(discount));
|
|
168
|
+
}
|
|
144
169
|
function resolveProductKind(product) {
|
|
145
170
|
var _a, _b, _c;
|
|
146
171
|
if (product.duration)
|
|
@@ -447,6 +472,65 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
447
472
|
this.loadOpenDataInFlight = null;
|
|
448
473
|
this.loadOpenDataInFlightTarget = null;
|
|
449
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
|
+
}
|
|
480
|
+
isSessionStoragePersistEnabled() {
|
|
481
|
+
var _a;
|
|
482
|
+
return Boolean(
|
|
483
|
+
this.cacheId && ((_a = this.otherParams) == null ? void 0 : _a.enableSessionStoragePersist) === true
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
shouldUseSessionStorageForSubModule(moduleName) {
|
|
487
|
+
return this.isSessionStoragePersistEnabled() && moduleName === "order";
|
|
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
|
+
}
|
|
450
534
|
/**
|
|
451
535
|
* Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
|
|
452
536
|
* 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
|
|
@@ -472,6 +556,110 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
472
556
|
}
|
|
473
557
|
return super.createSubModule(moduleName);
|
|
474
558
|
}
|
|
559
|
+
async addNewOrder() {
|
|
560
|
+
var _a, _b, _c, _d;
|
|
561
|
+
const sessionRecord = this.isSessionStoragePersistEnabled() ? (_b = (_a = this.store.order) == null ? void 0 : _a.consumeSessionStorageRestore) == null ? void 0 : _b.call(_a) : null;
|
|
562
|
+
if (sessionRecord) {
|
|
563
|
+
await this.loadSalesDetail({
|
|
564
|
+
preloadedSalesDetail: sessionRecord,
|
|
565
|
+
hydrateSource: "sessionStorage"
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
const tempOrder = await super.addNewOrder();
|
|
569
|
+
if (sessionRecord) {
|
|
570
|
+
(_c = this.store.order) == null ? void 0 : _c.persistTempOrder();
|
|
571
|
+
}
|
|
572
|
+
if (this.isAuthenticatedCustomerUserPlatform()) {
|
|
573
|
+
try {
|
|
574
|
+
const didSyncAuthenticatedCustomer = await this.syncAuthenticatedOrderCustomer();
|
|
575
|
+
if (!didSyncAuthenticatedCustomer && sessionRecord) {
|
|
576
|
+
await this.refreshLegacySessionCustomerDiscounts(tempOrder);
|
|
577
|
+
}
|
|
578
|
+
} catch (error) {
|
|
579
|
+
console.warn(
|
|
580
|
+
"[UnifiedBookingSales] Failed to sync authenticated order customer after addNewOrder",
|
|
581
|
+
error
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
} else if (sessionRecord) {
|
|
585
|
+
try {
|
|
586
|
+
await this.refreshLegacySessionCustomerDiscounts(tempOrder);
|
|
587
|
+
} catch (error) {
|
|
588
|
+
console.warn(
|
|
589
|
+
"[UnifiedBookingSales] Failed to refresh cached customer discounts after addNewOrder",
|
|
590
|
+
error
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return ((_d = this.store.order) == null ? void 0 : _d.getTempOrder()) || tempOrder;
|
|
595
|
+
}
|
|
596
|
+
async syncAuthenticatedOrderCustomer() {
|
|
597
|
+
var _a, _b, _c, _d, _e, _f;
|
|
598
|
+
if (!this.isAuthenticatedCustomerUserPlatform())
|
|
599
|
+
return false;
|
|
600
|
+
const authenticatedCustomer = (_d = (_c = (_b = (_a = this.core) == null ? void 0 : _a.getPlugin) == null ? void 0 : _b.call(_a, "user")) == null ? void 0 : _c.get) == null ? void 0 : _d.call(_c);
|
|
601
|
+
const authenticatedCustomerId = toCustomerId(authenticatedCustomer == null ? void 0 : authenticatedCustomer.id);
|
|
602
|
+
if (!authenticatedCustomerId)
|
|
603
|
+
return false;
|
|
604
|
+
const tempOrder = this.getTempOrder();
|
|
605
|
+
const cachedCustomerId = resolveTempOrderCustomerId(tempOrder);
|
|
606
|
+
if (cachedCustomerId !== null && cachedCustomerId !== authenticatedCustomerId) {
|
|
607
|
+
await this.resetCachedCustomerDiscountState();
|
|
608
|
+
}
|
|
609
|
+
(_f = (_e = this.store.customer) == null ? void 0 : _e.setSelectedCustomer) == null ? void 0 : _f.call(_e, authenticatedCustomer);
|
|
610
|
+
this.setOrderCustomer(authenticatedCustomer);
|
|
611
|
+
await Promise.all([
|
|
612
|
+
this.refreshDiscountConfigAfterOrderCustomerChange(authenticatedCustomerId),
|
|
613
|
+
this.waitForOrderCustomerPromotionRefresh()
|
|
614
|
+
]);
|
|
615
|
+
return true;
|
|
616
|
+
}
|
|
617
|
+
isAuthenticatedCustomerUserPlatform() {
|
|
618
|
+
var _a;
|
|
619
|
+
const platform = String(((_a = this.otherParams) == null ? void 0 : _a.platform) || "").toLowerCase();
|
|
620
|
+
return platform === "pc" || platform === "h5";
|
|
621
|
+
}
|
|
622
|
+
resolveDiscountOrderIdentity(tempOrder) {
|
|
623
|
+
var _a, _b, _c;
|
|
624
|
+
return (tempOrder == null ? void 0 : tempOrder.order_id) || ((_c = (_b = (_a = this.store.order) == null ? void 0 : _a.getOrderIdentity) == null ? void 0 : _b.call(_a)) == null ? void 0 : _c.orderId) || null;
|
|
625
|
+
}
|
|
626
|
+
resolveDiscountAction(orderId) {
|
|
627
|
+
if (!orderId || isLocalOrderId(orderId))
|
|
628
|
+
return "create";
|
|
629
|
+
return "edit";
|
|
630
|
+
}
|
|
631
|
+
async resetCachedCustomerDiscountState() {
|
|
632
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
633
|
+
(_b = (_a = this.store.order) == null ? void 0 : _a.clearOrderCustomer) == null ? void 0 : _b.call(_a);
|
|
634
|
+
(_d = (_c = this.store.customer) == null ? void 0 : _c.setSelectedCustomer) == null ? void 0 : _d.call(_c, null);
|
|
635
|
+
this.discountConfigCacheKey = null;
|
|
636
|
+
this.hasManualDiscountSelection = false;
|
|
637
|
+
const orderStore = ((_e = this.store.order) == null ? void 0 : _e.store) || {};
|
|
638
|
+
const discountModule = orderStore.discount;
|
|
639
|
+
const filteredOriginalDiscounts = filterCustomerBoundDiscounts(
|
|
640
|
+
((_f = discountModule == null ? void 0 : discountModule.getOriginalDiscountList) == null ? void 0 : _f.call(discountModule)) || []
|
|
641
|
+
);
|
|
642
|
+
const filteredCurrentDiscounts = filterCustomerBoundDiscounts(
|
|
643
|
+
((_g = discountModule == null ? void 0 : discountModule.getDiscountList) == null ? void 0 : _g.call(discountModule)) || []
|
|
644
|
+
);
|
|
645
|
+
await ((_h = discountModule == null ? void 0 : discountModule.setOriginalDiscountList) == null ? void 0 : _h.call(discountModule, filteredOriginalDiscounts));
|
|
646
|
+
await ((_i = discountModule == null ? void 0 : discountModule.setDiscountList) == null ? void 0 : _i.call(discountModule, filteredCurrentDiscounts));
|
|
647
|
+
(_k = (_j = this.store.order) == null ? void 0 : _j.applyDiscount) == null ? void 0 : _k.call(_j);
|
|
648
|
+
await ((_m = (_l = this.store.order) == null ? void 0 : _l.recalculateSummary) == null ? void 0 : _m.call(_l, { createIfMissing: true }));
|
|
649
|
+
(_o = (_n = this.store.order) == null ? void 0 : _n.persistTempOrder) == null ? void 0 : _o.call(_n);
|
|
650
|
+
}
|
|
651
|
+
async refreshLegacySessionCustomerDiscounts(tempOrder) {
|
|
652
|
+
const customerId = resolveTempOrderCustomerId(tempOrder);
|
|
653
|
+
if (!customerId)
|
|
654
|
+
return void 0;
|
|
655
|
+
const loadDiscountConfig = super.loadDiscountConfig.bind(this);
|
|
656
|
+
return await loadDiscountConfig({
|
|
657
|
+
customerId,
|
|
658
|
+
action: this.resolveDiscountAction(
|
|
659
|
+
this.resolveDiscountOrderIdentity(tempOrder)
|
|
660
|
+
)
|
|
661
|
+
});
|
|
662
|
+
}
|
|
475
663
|
/**
|
|
476
664
|
* Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
|
|
477
665
|
* business/channel target so a reused solution instance cannot leak another entry's menus.
|
|
@@ -11,6 +11,13 @@ export declare enum UnifiedBookingSalesHooks {
|
|
|
11
11
|
export interface UnifiedBookingSalesState extends BookingTicketState {
|
|
12
12
|
resourcePlanner: ResourcePlannerModule;
|
|
13
13
|
}
|
|
14
|
+
export interface UnifiedBookingSalesOtherParams extends Record<string, any> {
|
|
15
|
+
/**
|
|
16
|
+
* Persist the active order workspace in sessionStorage, partitioned by cacheId.
|
|
17
|
+
* Disabled by default and ignored when cacheId is missing.
|
|
18
|
+
*/
|
|
19
|
+
enableSessionStoragePersist?: boolean;
|
|
20
|
+
}
|
|
14
21
|
/** Explicit OpenData target used by page-level UnifiedBookingSales skins. */
|
|
15
22
|
export interface UnifiedBookingSalesLoadOpenDataParams {
|
|
16
23
|
businessCode: string;
|