@pisell/pisellos 2.3.67 → 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.
Files changed (85) hide show
  1. package/dist/core/index.d.ts +0 -7
  2. package/dist/core/index.js +65 -109
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -1
  4. package/dist/model/strategy/adapter/walletPass/utils.js +0 -2
  5. package/dist/modules/BaseModule.d.ts +1 -0
  6. package/dist/modules/BaseModule.js +24 -28
  7. package/dist/modules/Customer/index.d.ts +4 -0
  8. package/dist/modules/Customer/index.js +91 -59
  9. package/dist/modules/Customer/types.d.ts +2 -0
  10. package/dist/modules/Order/index.d.ts +22 -2
  11. package/dist/modules/Order/index.js +313 -142
  12. package/dist/modules/Order/types.d.ts +13 -1
  13. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  14. package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
  15. package/dist/modules/Order/utils.js +0 -1
  16. package/dist/modules/Payment/index.d.ts +4 -0
  17. package/dist/modules/Payment/index.js +14 -4
  18. package/dist/modules/Payment/walletpass.js +52 -18
  19. package/dist/modules/Quotation/index.d.ts +0 -6
  20. package/dist/modules/Quotation/index.js +19 -75
  21. package/dist/modules/Rules/index.js +46 -31
  22. package/dist/plugins/request.d.ts +0 -1
  23. package/dist/server/index.d.ts +2 -8
  24. package/dist/server/index.js +143 -212
  25. package/dist/server/modules/floor-plan/index.d.ts +0 -4
  26. package/dist/server/modules/floor-plan/index.js +98 -240
  27. package/dist/server/modules/menu/index.js +23 -48
  28. package/dist/server/modules/order/index.d.ts +8 -17
  29. package/dist/server/modules/order/index.js +453 -506
  30. package/dist/server/modules/products/index.d.ts +2 -8
  31. package/dist/server/modules/products/index.js +75 -167
  32. package/dist/server/modules/resource/index.js +13 -21
  33. package/dist/server/utils/small-ticket.js +2 -1
  34. package/dist/solution/BaseSales/index.d.ts +3 -1
  35. package/dist/solution/BaseSales/index.js +99 -82
  36. package/dist/solution/BaseSales/utils.js +31 -20
  37. package/dist/solution/BookingTicket/index.d.ts +6 -2
  38. package/dist/solution/BookingTicket/index.js +123 -75
  39. package/dist/solution/ScanOrder/utils.js +31 -20
  40. package/dist/solution/UnifiedBookingSales/index.d.ts +25 -0
  41. package/dist/solution/UnifiedBookingSales/index.js +640 -321
  42. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
  43. package/lib/core/index.d.ts +0 -7
  44. package/lib/core/index.js +2 -20
  45. package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -1
  46. package/lib/model/strategy/adapter/walletPass/utils.js +0 -1
  47. package/lib/modules/BaseModule.d.ts +1 -0
  48. package/lib/modules/BaseModule.js +24 -37
  49. package/lib/modules/Customer/index.d.ts +4 -0
  50. package/lib/modules/Customer/index.js +11 -0
  51. package/lib/modules/Customer/types.d.ts +2 -0
  52. package/lib/modules/Order/index.d.ts +22 -2
  53. package/lib/modules/Order/index.js +212 -54
  54. package/lib/modules/Order/types.d.ts +13 -1
  55. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
  56. package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
  57. package/lib/modules/Order/utils.js +0 -1
  58. package/lib/modules/Payment/index.d.ts +4 -0
  59. package/lib/modules/Payment/index.js +7 -0
  60. package/lib/modules/Payment/walletpass.js +27 -2
  61. package/lib/modules/Quotation/index.d.ts +0 -6
  62. package/lib/modules/Quotation/index.js +5 -49
  63. package/lib/modules/Rules/index.js +17 -1
  64. package/lib/plugins/request.d.ts +0 -1
  65. package/lib/server/index.d.ts +2 -8
  66. package/lib/server/index.js +20 -58
  67. package/lib/server/modules/floor-plan/index.d.ts +0 -4
  68. package/lib/server/modules/floor-plan/index.js +6 -54
  69. package/lib/server/modules/menu/index.js +5 -31
  70. package/lib/server/modules/order/index.d.ts +8 -17
  71. package/lib/server/modules/order/index.js +106 -199
  72. package/lib/server/modules/products/index.d.ts +2 -8
  73. package/lib/server/modules/products/index.js +24 -97
  74. package/lib/server/modules/resource/index.js +2 -7
  75. package/lib/server/utils/small-ticket.js +1 -1
  76. package/lib/solution/BaseSales/index.d.ts +3 -1
  77. package/lib/solution/BaseSales/index.js +29 -16
  78. package/lib/solution/BaseSales/utils.js +29 -18
  79. package/lib/solution/BookingTicket/index.d.ts +6 -2
  80. package/lib/solution/BookingTicket/index.js +53 -14
  81. package/lib/solution/ScanOrder/utils.js +29 -18
  82. package/lib/solution/UnifiedBookingSales/index.d.ts +25 -0
  83. package/lib/solution/UnifiedBookingSales/index.js +188 -0
  84. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
  85. package/package.json +1 -1
@@ -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;
@@ -12,15 +12,8 @@ declare class PisellOSCore implements PisellCore {
12
12
  context: BusinessContext;
13
13
  server: any;
14
14
  serverOptions?: ServerOptions;
15
- private serverModulePromise?;
16
15
  constructor(options?: PisellOSOptions);
17
16
  private initialize;
18
- /**
19
- * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
20
- * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
21
- */
22
- preloadServerModule(): Promise<void>;
23
- private loadServerModule;
24
17
  /**
25
18
  * 初始化 Server(公开方法,需要外部显式调用并等待)
26
19
  * Server 配置从构造函数传入的 options.server 中获取
package/lib/core/index.js CHANGED
@@ -36,6 +36,7 @@ module.exports = __toCommonJS(core_exports);
36
36
  var import_createStore = require("../store/createStore");
37
37
  var import_effects = require("../effects");
38
38
  var PisellOSCore = class {
39
+ // 保存 Server 配置
39
40
  constructor(options) {
40
41
  this.plugins = /* @__PURE__ */ new Map();
41
42
  this.modules = /* @__PURE__ */ new Map();
@@ -49,7 +50,6 @@ var PisellOSCore = class {
49
50
  this.serverOptions = options.server;
50
51
  }
51
52
  this.initialize(options);
52
- console.log("constructor123456");
53
53
  }
54
54
  initialize(options) {
55
55
  if (options == null ? void 0 : options.plugins) {
@@ -64,24 +64,6 @@ var PisellOSCore = class {
64
64
  }
65
65
  this.log("[PisellOS] 核心初始化完成");
66
66
  }
67
- /**
68
- * 仅预加载 Server 模块代码,不创建实例、不注册模块、不请求业务数据。
69
- * 导入失败会清空 Promise,正式 initializeServer 时仍可重新尝试。
70
- */
71
- async preloadServerModule() {
72
- if (this.server || !this.serverOptions)
73
- return;
74
- await this.loadServerModule();
75
- }
76
- loadServerModule() {
77
- if (!this.serverModulePromise) {
78
- this.serverModulePromise = import("../server").catch((error) => {
79
- this.serverModulePromise = void 0;
80
- throw error;
81
- });
82
- }
83
- return this.serverModulePromise;
84
- }
85
67
  /**
86
68
  * 初始化 Server(公开方法,需要外部显式调用并等待)
87
69
  * Server 配置从构造函数传入的 options.server 中获取
@@ -96,7 +78,7 @@ var PisellOSCore = class {
96
78
  return;
97
79
  }
98
80
  try {
99
- const ServerModule = await this.loadServerModule();
81
+ const ServerModule = await import("../server");
100
82
  const Server = ServerModule.default;
101
83
  this.server = new Server(this);
102
84
  this.log("Server 实例已创建");
@@ -415,7 +415,6 @@ var WalletPassEvaluator = class {
415
415
  * 计算适用商品的总金额和数量
416
416
  */
417
417
  calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee) {
418
- console.log(products, "products1234");
419
418
  let total = 0;
420
419
  let count = 0;
421
420
  if (applicableProductIds !== null && applicableProductIds.length === 0) {
@@ -166,7 +166,6 @@ var getApplicableProducts = (voucher, productsData) => {
166
166
  return productsData.filter((p) => applicableProductIds.includes(p.product_id));
167
167
  };
168
168
  function processVouchers(applicableVouchers, orderTotalAmount, products) {
169
- console.log(products, "products123");
170
169
  const productsCopy = expandProductsWithBundleItems(products, true);
171
170
  let remainingOrderAmount = new import_decimal.default(orderTotalAmount);
172
171
  const getItemPassUsage = (usageMap, walletPassProductId, lineKey) => {
@@ -8,6 +8,7 @@ export declare class BaseModule {
8
8
  protected core: PisellCore;
9
9
  constructor(name?: string, version?: string);
10
10
  destroy(): void;
11
+ private isRecord;
11
12
  checkSaveCache({ cacheId, fatherModule, store, cacheKey, }: {
12
13
  cacheId: string | undefined;
13
14
  fatherModule: string | undefined;
@@ -34,6 +34,9 @@ var BaseModule = class {
34
34
  this.core.effects.offByModuleDestroy(this.name);
35
35
  this.core.unregisterModule(this);
36
36
  }
37
+ isRecord(value) {
38
+ return !!value && typeof value === "object" && !Array.isArray(value);
39
+ }
37
40
  // 提供统一的缓存 module 里的数据的方法
38
41
  checkSaveCache({
39
42
  cacheId,
@@ -41,45 +44,29 @@ var BaseModule = class {
41
44
  store,
42
45
  cacheKey
43
46
  }) {
44
- const window = this.core.getPlugin("window");
45
- if (cacheId) {
47
+ if (!cacheId)
48
+ return;
49
+ try {
50
+ const window = this.core.getPlugin("window");
51
+ const sessionStorage = window == null ? void 0 : window.sessionStorage;
52
+ if (!sessionStorage)
53
+ return;
54
+ const storageKey = fatherModule || cacheId;
55
+ const rawCacheData = sessionStorage.getItem(storageKey);
56
+ const parsedCacheData = rawCacheData ? JSON.parse(rawCacheData) : {};
57
+ if (!this.isRecord(parsedCacheData))
58
+ return;
59
+ const cacheBucket = fatherModule ? this.isRecord(parsedCacheData[cacheId]) ? parsedCacheData[cacheId] : {} : parsedCacheData;
60
+ const moduleBucket = this.isRecord(cacheBucket[this.name]) ? cacheBucket[this.name] : {};
61
+ cacheKey.forEach((key) => {
62
+ moduleBucket[key] = store == null ? void 0 : store[key];
63
+ });
64
+ cacheBucket[this.name] = moduleBucket;
46
65
  if (fatherModule) {
47
- const currentCacheData = window.sessionStorage.getItem(fatherModule);
48
- let currentCacheDataObj = JSON.parse(currentCacheData || "{}");
49
- if (!currentCacheData || !currentCacheDataObj[cacheId]) {
50
- currentCacheDataObj = {
51
- [cacheId]: {
52
- [this.name]: {}
53
- }
54
- };
55
- }
56
- if (!currentCacheDataObj[cacheId][this.name]) {
57
- currentCacheDataObj[cacheId][this.name] = {};
58
- }
59
- cacheKey.forEach((key) => {
60
- currentCacheDataObj[cacheId][this.name][key] = store == null ? void 0 : store[key];
61
- });
62
- window.sessionStorage.setItem(
63
- fatherModule,
64
- JSON.stringify(currentCacheDataObj)
65
- );
66
- } else {
67
- let currentCacheData = window.sessionStorage.getItem(cacheId);
68
- let currentCacheDataObj = JSON.parse(currentCacheData || "{}");
69
- if (!currentCacheDataObj) {
70
- currentCacheDataObj = {};
71
- }
72
- if (!currentCacheDataObj[this.name]) {
73
- currentCacheDataObj[this.name] = {};
74
- }
75
- cacheKey.forEach((key) => {
76
- currentCacheDataObj[this.name][key] = store[key];
77
- });
78
- window.sessionStorage.setItem(
79
- cacheId,
80
- JSON.stringify(currentCacheDataObj)
81
- );
66
+ parsedCacheData[cacheId] = cacheBucket;
82
67
  }
68
+ sessionStorage.setItem(storageKey, JSON.stringify(parsedCacheData));
69
+ } catch {
83
70
  }
84
71
  }
85
72
  effectsOn(eventType, callback) {
@@ -44,6 +44,10 @@ export declare class CustomerModule extends BaseModule implements Module, Custom
44
44
  * 用于按 ID 补齐客户等内部查询,避免把临时的 num/searchParams 污染到滚动列表。
45
45
  */
46
46
  queryCustomerList(params?: ShopGetCustomerListParams): Promise<ICustomerListResponse>;
47
+ /**
48
+ * 查询单个客户详情,不写入 customerList / pagination 状态。
49
+ */
50
+ queryCustomerDetail(id: string | number): Promise<ShopCustomer | null>;
47
51
  /**
48
52
  * 获取客户列表
49
53
  * @param params 查询参数
@@ -201,6 +201,17 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
201
201
  pageSize
202
202
  };
203
203
  }
204
+ /**
205
+ * 查询单个客户详情,不写入 customerList / pagination 状态。
206
+ */
207
+ async queryCustomerDetail(id) {
208
+ var _a;
209
+ const result = await this.request.get(`/customer/info/${id}`, {
210
+ with_trashed: 1
211
+ });
212
+ const customer = ((_a = result == null ? void 0 : result.data) == null ? void 0 : _a.customer) || (result == null ? void 0 : result.data) || (result == null ? void 0 : result.customer) || null;
213
+ return customer && typeof customer === "object" ? customer : null;
214
+ }
204
215
  /**
205
216
  * 获取客户列表
206
217
  * @param params 查询参数
@@ -112,6 +112,8 @@ export interface CustomerModuleAPI {
112
112
  getCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
113
113
  /** 查询客户列表但不更新列表分页状态 */
114
114
  queryCustomerList: (params?: ShopGetCustomerListParams) => Promise<ICustomerListResponse>;
115
+ /** 查询单个客户详情但不修改客户列表状态 */
116
+ queryCustomerDetail: (id: string | number) => Promise<ShopCustomer | null>;
115
117
  /** 设置客户列表 */
116
118
  setCustomerList: (customers: ShopCustomer[], total?: number) => void;
117
119
  /** 设置当前选择的客户 */
@@ -16,6 +16,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
16
16
  private window;
17
17
  private appPlugin;
18
18
  private cacheId;
19
+ private fatherModule;
20
+ private openCache;
21
+ private sessionStoragePersistEnabled;
22
+ private sessionStorageRestoreRecord;
19
23
  private salesSummaryModuleName;
20
24
  private rulesHooksOverride?;
21
25
  private moduleHooksOverride?;
@@ -46,6 +50,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
46
50
  static populateSavedAmounts(productList: Array<Record<string, any>>, discountList: Array<Record<string, any>>): void;
47
51
  private applyProductDiscountPrices;
48
52
  constructor(name?: string, version?: string);
53
+ private syncSessionStorageOptions;
49
54
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
50
55
  destroy(): Promise<void>;
51
56
  /**
@@ -137,7 +142,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
137
142
  }): void;
138
143
  /**
139
144
  * 控制 IndexedDB 草稿(saveDraft)是否写入。
140
- * localStorage tempOrder 持久化已废弃,此方法仅影响 saveDraft。
145
+ * 此开关仅影响 saveDraft;可选 sessionStorage 会话恢复由
146
+ * enableSessionStoragePersist 独立控制。
141
147
  *
142
148
  * @example
143
149
  * order.setEnableTempOrderPersist(false); // BigSale 弹窗:跳过 ~1s 的 dbUpdate
@@ -145,8 +151,19 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
145
151
  setEnableTempOrderPersist(enabled: boolean): void;
146
152
  /** 是否允许 saveDraft 写入 IndexedDB 草稿。 */
147
153
  isTempOrderPersistEnabled(): boolean;
148
- /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
154
+ /**
155
+ * 在 UnifiedBookingSales 显式开启会话恢复时,将完整 tempOrder 写入
156
+ * sessionStorage 的 cacheId 分桶。写入失败由 BaseModule 静默降级。
157
+ */
149
158
  persistTempOrder(): void;
159
+ /**
160
+ * 终止当前模块实例的 sessionStorage 订单恢复会话。
161
+ *
162
+ * 支付跳转等终态场景需要同时删除当前 cacheId 的 tempOrder 快照,并关闭
163
+ * 本实例后续异步任务的再次写入;新模块实例初始化时会按 otherParams 重新启用。
164
+ */
165
+ clearSessionStoragePersistedTempOrder(): void;
166
+ consumeSessionStorageRestore(): Record<string, any> | null;
150
167
  notifyTempOrderChanged(): void;
151
168
  private createDefaultTempOrderInstance;
152
169
  private createExternalSaleNumber;
@@ -178,6 +195,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
178
195
  orderExpectedAmount: string;
179
196
  };
180
197
  private calculateDepositPaidAmount;
198
+ private hasPaidNormalPayment;
181
199
  private resolveNextOrderPaymentType;
182
200
  private getPaymentNumberAppData;
183
201
  private getPaymentNumberDevicePrefixSync;
@@ -227,6 +245,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
227
245
  private sanitizeOrderProductForTempOrder;
228
246
  private sanitizeTempOrderProducts;
229
247
  private ensureExtend;
248
+ private repairDuplicateProductLineIdentities;
230
249
  private captureProductRuntime;
231
250
  private createLinkedProductAndBooking;
232
251
  /**
@@ -543,6 +562,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
543
562
  */
544
563
  hydrateTempOrderFromRecord(record: Record<string, any>, options?: {
545
564
  recalcOnHydrate?: boolean;
565
+ source?: 'salesDetail' | 'sessionStorage';
546
566
  }): Promise<OrderTempOrder>;
547
567
  /**
548
568
  * 兼容后端详情将 holder 放在 metadata.holder 的历史形态,统一补到运行时展示路径。