@pisell/pisellos 2.2.190 → 2.2.191

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 (67) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  3. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -7
  4. package/dist/modules/Cart/utils/cartProduct.js +13 -2
  5. package/dist/modules/Order/index.d.ts +1 -3
  6. package/dist/modules/Order/index.js +69 -95
  7. package/dist/modules/Order/types.d.ts +9 -6
  8. package/dist/modules/Order/utils.d.ts +9 -2
  9. package/dist/modules/Order/utils.js +36 -13
  10. package/dist/modules/SalesSummary/types.d.ts +3 -1
  11. package/dist/modules/SalesSummary/utils.js +7 -3
  12. package/dist/server/modules/order/index.d.ts +126 -6
  13. package/dist/server/modules/order/index.js +1204 -285
  14. package/dist/server/modules/order/types.d.ts +0 -2
  15. package/dist/server/modules/products/index.d.ts +90 -6
  16. package/dist/server/modules/products/index.js +1017 -361
  17. package/dist/solution/BaseSales/index.js +13 -7
  18. package/dist/solution/BaseSales/types.d.ts +8 -5
  19. package/dist/solution/BaseSales/types.js +2 -3
  20. package/dist/solution/BaseSales/utils/cartPromotion.js +7 -7
  21. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  22. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +16 -13
  23. package/dist/solution/BaseSales/utils.d.ts +1 -1
  24. package/dist/solution/BaseSales/utils.js +22 -19
  25. package/dist/solution/BookingByStep/index.d.ts +1 -1
  26. package/dist/solution/BookingTicket/index.d.ts +1 -1
  27. package/dist/solution/ScanOrder/index.js +7 -5
  28. package/dist/solution/ScanOrder/types.d.ts +8 -5
  29. package/dist/solution/ScanOrder/types.js +2 -3
  30. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  31. package/dist/solution/ScanOrder/utils.js +26 -23
  32. package/dist/solution/VenueBooking/index.js +5 -3
  33. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  34. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  35. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +2 -1
  36. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  37. package/lib/modules/Cart/utils/cartProduct.js +9 -2
  38. package/lib/modules/Order/index.d.ts +1 -3
  39. package/lib/modules/Order/index.js +45 -58
  40. package/lib/modules/Order/types.d.ts +9 -6
  41. package/lib/modules/Order/utils.d.ts +9 -2
  42. package/lib/modules/Order/utils.js +41 -10
  43. package/lib/modules/SalesSummary/types.d.ts +3 -1
  44. package/lib/modules/SalesSummary/utils.js +5 -3
  45. package/lib/server/modules/order/index.d.ts +126 -6
  46. package/lib/server/modules/order/index.js +722 -42
  47. package/lib/server/modules/order/types.d.ts +0 -2
  48. package/lib/server/modules/products/index.d.ts +90 -6
  49. package/lib/server/modules/products/index.js +492 -30
  50. package/lib/solution/BaseSales/index.js +14 -5
  51. package/lib/solution/BaseSales/types.d.ts +8 -5
  52. package/lib/solution/BaseSales/utils/cartPromotion.js +6 -6
  53. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
  54. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +21 -14
  55. package/lib/solution/BaseSales/utils.d.ts +1 -1
  56. package/lib/solution/BaseSales/utils.js +11 -7
  57. package/lib/solution/BookingByStep/index.d.ts +1 -1
  58. package/lib/solution/BookingTicket/index.d.ts +1 -1
  59. package/lib/solution/ScanOrder/index.js +4 -4
  60. package/lib/solution/ScanOrder/types.d.ts +8 -5
  61. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  62. package/lib/solution/ScanOrder/utils.js +12 -8
  63. package/lib/solution/VenueBooking/index.js +2 -2
  64. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  65. package/package.json +1 -1
  66. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  67. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -94,8 +94,6 @@ export interface OrderProductLineItem {
94
94
  num: number;
95
95
  /** 多规格 ID。来源:Detail.product_variant_id */
96
96
  product_variant_id?: number;
97
- /** 选项配置 */
98
- product_option_item?: unknown[];
99
97
  /**
100
98
  * 销售单价(交易快照,仅输出)。
101
99
  * 来源:Detail.selling_price
@@ -3,6 +3,36 @@ import { BaseModule } from '../../../modules/BaseModule';
3
3
  import { ProductData } from '../../../modules/Product/types';
4
4
  import type { RouteDefinition } from '../../types';
5
5
  import { ProductIdScope, ProductFormatter, ProductFormatterContext } from './types';
6
+ /** 商品模块流程调试日志条目 */
7
+ interface ProductFlowLogEntry {
8
+ ts: string;
9
+ step: string;
10
+ metadata?: Record<string, unknown>;
11
+ }
12
+ /** 单个商品 IndexDB 写入记录 */
13
+ interface ProductWriteStatEntry {
14
+ ts: string;
15
+ writeSeq: number;
16
+ source: string;
17
+ writeMethod: string;
18
+ productId: number;
19
+ mergeAction?: 'insert' | 'update' | 'snapshot' | 'delete';
20
+ }
21
+ declare global {
22
+ interface Window {
23
+ __productModuleFlowLogs?: ProductFlowLogEntry[];
24
+ __productModuleWriteStats?: Record<string, ProductWriteStatEntry[]>;
25
+ clearProductModuleFlowLogs?: () => void;
26
+ exportProductModuleFlowLogs?: () => string;
27
+ exportProductModuleWriteStats?: () => string;
28
+ summarizeProductModuleWrites?: (topN?: number) => Array<{
29
+ productId: number;
30
+ writeCount: number;
31
+ sources: string[];
32
+ lastWriteAt: string;
33
+ }>;
34
+ }
35
+ }
6
36
  /**
7
37
  * Products 模块 - 用于获取和管理完整的商品详细数据
8
38
  * 相比 ProductList 模块,Products 会获取所有详细信息并缓存
@@ -27,6 +57,14 @@ export declare class ProductsModule extends BaseModule implements Module {
27
57
  private productDataSource;
28
58
  private pendingSyncMessages;
29
59
  private syncTimer?;
60
+ /** IndexDB 写入序号,便于日志关联 */
61
+ private productFlowWriteSeq;
62
+ /** 最近一次 SSE 全量拉取完成时间 */
63
+ private lastServerFullFetchAtMs;
64
+ /** 最近一次 preload 完成时间(含 IndexDB 命中) */
65
+ private lastPreloadCompletedAtMs;
66
+ /** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
67
+ private productIndexDBSaveQueue;
30
68
  constructor(name?: string, version?: string);
31
69
  initialize(core: PisellCore, options: any): Promise<void>;
32
70
  /**
@@ -47,6 +85,30 @@ export declare class ProductsModule extends BaseModule implements Module {
47
85
  * @param metadata 日志元数据
48
86
  */
49
87
  private logError;
88
+ /**
89
+ * 初始化 window 上的商品流程调试日志。
90
+ *
91
+ * @example
92
+ * window.clearProductModuleFlowLogs()
93
+ * copy(window.exportProductModuleFlowLogs?.() || '[]')
94
+ */
95
+ private initProductFlowLogs;
96
+ /**
97
+ * 写入 window 商品流程调试日志。
98
+ *
99
+ * @example
100
+ * this.pushProductFlowLog('mergeProductsToStore.start', { count: 3 })
101
+ */
102
+ private pushProductFlowLog;
103
+ /** 当前内存 store 快照,供流程日志使用 */
104
+ private getProductStoreSnapshot;
105
+ /**
106
+ * 记录 IndexDB 写入统计(按 productId 聚合)。
107
+ *
108
+ * @example
109
+ * this.trackProductWrite('pubsub.mergeProductsToStore', 'clear+bulkUpdate', products, { 1: 'update' })
110
+ */
111
+ private trackProductWrite;
50
112
  /**
51
113
  * 加载商品价格(原始方法,不带缓存)
52
114
  * @private
@@ -209,10 +271,28 @@ export declare class ProductsModule extends BaseModule implements Module {
209
271
  */
210
272
  private loadProductsFromIndexDB;
211
273
  /**
212
- * 保存商品数据到 IndexDB(平铺存储)
213
- * @private
274
+ * 串行执行商品 IndexDB 写入,避免快照替换与增量 patch 并发交错。
275
+ *
276
+ * @example
277
+ * await this.runInProductIndexDBSaveQueue(async () => {
278
+ * await this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products)
279
+ * })
280
+ */
281
+ private runInProductIndexDBSaveQueue;
282
+ /**
283
+ * 全量快照写入 IndexDB:clear + bulkUpdate,仅用于 SSE/HTTP 全量拉取。
284
+ *
285
+ * @example
286
+ * await this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer')
214
287
  */
215
- private saveProductsToIndexDB;
288
+ private replaceProductsSnapshotInIndexDB;
289
+ /**
290
+ * 增量 upsert 商品到 IndexDB,不清空表;用于 pubsub 批次合并后的变更商品。
291
+ *
292
+ * @example
293
+ * await this.patchProductsInIndexDB(changedProducts, 'pubsub.processProductSyncMessages', mergeActions)
294
+ */
295
+ private patchProductsInIndexDB;
216
296
  /**
217
297
  * 同步更新商品 Map 缓存
218
298
  * 将 list 中的商品同步到 map,以 id 为 key
@@ -262,14 +342,17 @@ export declare class ProductsModule extends BaseModule implements Module {
262
342
  /**
263
343
  * 将 body 完整数据直接覆盖到本地 store(不调用报价单接口)
264
344
  * 已存在的 → 直接替换;不存在的 → 追加
265
- * 同时更新 Map 缓存、IndexDB,触发 onProductsChanged
266
- * 价格缓存由 processProductSyncMessages 末尾统一清除
345
+ *
346
+ * @example
347
+ * await this.applyBodyUpdatesToStore(bodyUpdates, { skipIndexDB: true })
267
348
  */
268
349
  private applyBodyUpdatesToStore;
269
350
  /**
270
351
  * 将增量拉取的商品合并到 store
271
352
  * 已存在的 → 替换;新的 → 追加
272
- * 同时更新 store.map、IndexDB,触发 onProductsChanged
353
+ *
354
+ * @example
355
+ * await this.mergeProductsToStore(freshProducts, { skipIndexDB: true })
273
356
  */
274
357
  private mergeProductsToStore;
275
358
  /**
@@ -288,3 +371,4 @@ export declare class ProductsModule extends BaseModule implements Module {
288
371
  */
289
372
  getRoutes(): RouteDefinition[];
290
373
  }
374
+ export {};