@pisell/pisellos 0.10.3 → 0.10.4

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.
@@ -447,6 +447,15 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
447
447
  this.loadOpenDataInFlight = null;
448
448
  this.loadOpenDataInFlightTarget = null;
449
449
  }
450
+ isSessionStoragePersistEnabled() {
451
+ var _a;
452
+ return Boolean(
453
+ this.cacheId && ((_a = this.otherParams) == null ? void 0 : _a.enableSessionStoragePersist) === true
454
+ );
455
+ }
456
+ shouldUseSessionStorageForSubModule(moduleName) {
457
+ return this.isSessionStoragePersistEnabled() && moduleName === "order";
458
+ }
450
459
  /**
451
460
  * Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
452
461
  * 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
@@ -472,6 +481,35 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
472
481
  }
473
482
  return super.createSubModule(moduleName);
474
483
  }
484
+ async addNewOrder() {
485
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
486
+ const sessionRecord = this.isSessionStoragePersistEnabled() ? (_b = (_a = this.store.order) == null ? void 0 : _a.consumeSessionStorageRestore) == null ? void 0 : _b.call(_a) : null;
487
+ if (!sessionRecord)
488
+ return super.addNewOrder();
489
+ await this.loadSalesDetail({
490
+ preloadedSalesDetail: sessionRecord,
491
+ hydrateSource: "sessionStorage"
492
+ });
493
+ const tempOrder = await super.addNewOrder();
494
+ (_c = this.store.order) == null ? void 0 : _c.persistTempOrder();
495
+ const customerId = Number(
496
+ tempOrder.customer_id || ((_d = tempOrder.customer) == null ? void 0 : _d.id) || ((_f = (_e = tempOrder._extend) == null ? void 0 : _e.customerSnapshot) == null ? void 0 : _f.id) || ((_h = (_g = tempOrder._extend) == null ? void 0 : _g.customerSnapshot) == null ? void 0 : _h.customer_id) || 0
497
+ );
498
+ if (customerId > 1) {
499
+ try {
500
+ await this.loadDiscountConfig({
501
+ customerId,
502
+ action: tempOrder.order_id ? "edit" : "create"
503
+ });
504
+ } catch (error) {
505
+ console.warn(
506
+ "[UnifiedBookingSales] Failed to refresh discounts after session restore",
507
+ error
508
+ );
509
+ }
510
+ }
511
+ return ((_i = this.store.order) == null ? void 0 : _i.getTempOrder()) || tempOrder;
512
+ }
475
513
  /**
476
514
  * Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
477
515
  * 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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.10.3",
4
+ "version": "0.10.4",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",