@pisell/pisellos 2.2.292 → 2.2.293

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 (173) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +108 -65
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  8. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  9. package/dist/modules/BookingContext/index.d.ts +3 -0
  10. package/dist/modules/BookingContext/index.js +42 -13
  11. package/dist/modules/BookingContext/types.d.ts +4 -4
  12. package/dist/modules/BookingContext/types.js +3 -3
  13. package/dist/modules/OpenData/types.d.ts +1 -0
  14. package/dist/modules/Order/index.d.ts +19 -4
  15. package/dist/modules/Order/index.js +885 -485
  16. package/dist/modules/Order/salesNotes.d.ts +31 -0
  17. package/dist/modules/Order/salesNotes.js +492 -0
  18. package/dist/modules/Order/types.d.ts +93 -5
  19. package/dist/modules/Order/types.js +5 -0
  20. package/dist/modules/Order/utils.d.ts +12 -0
  21. package/dist/modules/Order/utils.js +96 -31
  22. package/dist/modules/Product/types.d.ts +2 -0
  23. package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
  24. package/dist/modules/ProductList/clientDataVariants.js +216 -0
  25. package/dist/modules/ProductList/index.d.ts +18 -3
  26. package/dist/modules/ProductList/index.js +220 -38
  27. package/dist/modules/ProductList/types.d.ts +10 -0
  28. package/dist/modules/Quotation/index.d.ts +22 -0
  29. package/dist/modules/Quotation/index.js +293 -28
  30. package/dist/modules/ResourcePlanner/index.d.ts +0 -22
  31. package/dist/modules/ResourcePlanner/index.js +1 -180
  32. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  33. package/dist/modules/ResourcePlanner/localClock.js +183 -0
  34. package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
  35. package/dist/modules/ResourcePlanner/planner.js +2111 -958
  36. package/dist/modules/ResourcePlanner/types.d.ts +359 -187
  37. package/dist/modules/ResourcePlanner/types.js +33 -1
  38. package/dist/plugins/request.d.ts +1 -0
  39. package/dist/server/index.d.ts +17 -2
  40. package/dist/server/index.js +1134 -932
  41. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  42. package/dist/server/modules/floor-plan/index.js +240 -98
  43. package/dist/server/modules/menu/index.js +48 -23
  44. package/dist/server/modules/order/index.d.ts +17 -7
  45. package/dist/server/modules/order/index.js +419 -207
  46. package/dist/server/modules/products/index.d.ts +10 -4
  47. package/dist/server/modules/products/index.js +177 -84
  48. package/dist/server/modules/resource/index.js +21 -13
  49. package/dist/server/utils/product.d.ts +1 -1
  50. package/dist/server/utils/product.js +186 -22
  51. package/dist/server/utils/small-ticket.d.ts +9 -1
  52. package/dist/server/utils/small-ticket.js +136 -41
  53. package/dist/solution/BaseSales/index.d.ts +26 -3
  54. package/dist/solution/BaseSales/index.js +1384 -905
  55. package/dist/solution/BaseSales/types.d.ts +2 -0
  56. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  57. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +10 -3
  58. package/dist/solution/BaseSales/utils.js +6 -3
  59. package/dist/solution/BookingByStep/index.d.ts +4 -4
  60. package/dist/solution/BookingTicket/index.d.ts +1 -1
  61. package/dist/solution/BookingTicket/index.js +4 -2
  62. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  63. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -3
  64. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  65. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  66. package/dist/solution/RegisterAndLogin/config.js +95 -40
  67. package/dist/solution/RegisterAndLogin/index.js +4 -1
  68. package/dist/solution/ScanOrder/index.d.ts +1 -0
  69. package/dist/solution/ScanOrder/index.js +31 -27
  70. package/dist/solution/ScanOrder/types.d.ts +2 -0
  71. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  72. package/dist/solution/ScanOrder/utils.js +8 -3
  73. package/dist/solution/UnifiedBookingSales/index.d.ts +128 -74
  74. package/dist/solution/UnifiedBookingSales/index.js +3877 -963
  75. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  76. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
  77. package/dist/solution/UnifiedBookingSales/types.d.ts +161 -77
  78. package/dist/solution/UnifiedBookingSales/types.js +4 -9
  79. package/dist/solution/VenueBooking/index.d.ts +3 -0
  80. package/dist/solution/VenueBooking/index.js +549 -497
  81. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  82. package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
  83. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  84. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
  85. package/dist/utils/platform.d.ts +8 -0
  86. package/dist/utils/platform.js +15 -0
  87. package/lib/core/index.d.ts +7 -0
  88. package/lib/core/index.js +20 -2
  89. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  90. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  91. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  93. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  94. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  95. package/lib/modules/BookingContext/index.d.ts +3 -0
  96. package/lib/modules/BookingContext/index.js +35 -8
  97. package/lib/modules/BookingContext/types.d.ts +4 -4
  98. package/lib/modules/BookingContext/types.js +3 -3
  99. package/lib/modules/OpenData/types.d.ts +1 -0
  100. package/lib/modules/Order/index.d.ts +19 -4
  101. package/lib/modules/Order/index.js +325 -28
  102. package/lib/modules/Order/salesNotes.d.ts +31 -0
  103. package/lib/modules/Order/salesNotes.js +382 -0
  104. package/lib/modules/Order/types.d.ts +93 -5
  105. package/lib/modules/Order/types.js +4 -0
  106. package/lib/modules/Order/utils.d.ts +12 -0
  107. package/lib/modules/Order/utils.js +85 -16
  108. package/lib/modules/Product/types.d.ts +2 -0
  109. package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
  110. package/lib/modules/ProductList/clientDataVariants.js +204 -0
  111. package/lib/modules/ProductList/index.d.ts +18 -3
  112. package/lib/modules/ProductList/index.js +137 -8
  113. package/lib/modules/ProductList/types.d.ts +10 -0
  114. package/lib/modules/Quotation/index.d.ts +22 -0
  115. package/lib/modules/Quotation/index.js +158 -11
  116. package/lib/modules/ResourcePlanner/index.d.ts +0 -22
  117. package/lib/modules/ResourcePlanner/index.js +9 -129
  118. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  119. package/lib/modules/ResourcePlanner/localClock.js +205 -0
  120. package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
  121. package/lib/modules/ResourcePlanner/planner.js +1807 -783
  122. package/lib/modules/ResourcePlanner/types.d.ts +359 -187
  123. package/lib/modules/ResourcePlanner/types.js +13 -1
  124. package/lib/plugins/request.d.ts +1 -0
  125. package/lib/server/index.d.ts +17 -2
  126. package/lib/server/index.js +149 -21
  127. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  128. package/lib/server/modules/floor-plan/index.js +60 -7
  129. package/lib/server/modules/menu/index.js +26 -4
  130. package/lib/server/modules/order/index.d.ts +17 -7
  131. package/lib/server/modules/order/index.js +194 -57
  132. package/lib/server/modules/products/index.d.ts +10 -4
  133. package/lib/server/modules/products/index.js +93 -23
  134. package/lib/server/modules/resource/index.js +12 -2
  135. package/lib/server/utils/product.d.ts +1 -1
  136. package/lib/server/utils/product.js +163 -3
  137. package/lib/server/utils/small-ticket.d.ts +9 -1
  138. package/lib/server/utils/small-ticket.js +126 -33
  139. package/lib/solution/BaseSales/index.d.ts +26 -3
  140. package/lib/solution/BaseSales/index.js +396 -70
  141. package/lib/solution/BaseSales/types.d.ts +2 -0
  142. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  143. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +9 -2
  144. package/lib/solution/BaseSales/utils.js +3 -0
  145. package/lib/solution/BookingByStep/index.d.ts +4 -4
  146. package/lib/solution/BookingTicket/index.d.ts +1 -1
  147. package/lib/solution/BookingTicket/index.js +2 -1
  148. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  149. package/lib/solution/BookingTicket/utils/addProductDecision.js +5 -2
  150. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  151. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  152. package/lib/solution/RegisterAndLogin/config.js +49 -8
  153. package/lib/solution/RegisterAndLogin/index.js +4 -1
  154. package/lib/solution/ScanOrder/index.d.ts +1 -0
  155. package/lib/solution/ScanOrder/index.js +5 -1
  156. package/lib/solution/ScanOrder/types.d.ts +2 -0
  157. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  158. package/lib/solution/ScanOrder/utils.js +4 -0
  159. package/lib/solution/UnifiedBookingSales/index.d.ts +128 -74
  160. package/lib/solution/UnifiedBookingSales/index.js +2592 -424
  161. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  162. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +316 -0
  163. package/lib/solution/UnifiedBookingSales/types.d.ts +161 -77
  164. package/lib/solution/UnifiedBookingSales/types.js +4 -6
  165. package/lib/solution/VenueBooking/index.d.ts +3 -0
  166. package/lib/solution/VenueBooking/index.js +33 -9
  167. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  168. package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
  169. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  170. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
  171. package/lib/utils/platform.d.ts +8 -0
  172. package/lib/utils/platform.js +22 -0
  173. package/package.json +1 -1
@@ -25,6 +25,7 @@ export declare class ProductsModule extends BaseModule implements Module {
25
25
  private quotationBridgeLoadedKey?;
26
26
  private quotationBridgeRefreshPromise?;
27
27
  private quotationBridgeRefreshKey?;
28
+ private quotationBridgeUpdatedCallback?;
28
29
  private quotationScheduleCache;
29
30
  private quotationScheduleCacheSource;
30
31
  private quotationScheduleCacheLoaded;
@@ -72,6 +73,7 @@ export declare class ProductsModule extends BaseModule implements Module {
72
73
  scheduleModule?: any;
73
74
  channel?: string;
74
75
  customer_id?: number | string;
76
+ onQuotationUpdated?: () => void;
75
77
  }): Promise<void>;
76
78
  /**
77
79
  * 刷新桥接器内的报价单列表。
@@ -87,8 +89,8 @@ export declare class ProductsModule extends BaseModule implements Module {
87
89
  private buildBundleGroupPriceData;
88
90
  /**
89
91
  * 获取应用了价格的商品列表(带缓存)
90
- * 使用日期作为缓存 key,同一天的商品价格会被缓存
91
- * 缓存的是已经应用了价格的完整商品列表,避免重复转换
92
+ * 使用时间、客户、策略、商品范围和语言作为缓存 key
93
+ * 缓存的是已经应用了价格与多语言的完整商品列表,避免重复转换
92
94
  * @param schedule_date 日期
93
95
  * @param extraContext 额外的上下文数据(可选,由 Server 层传入)
94
96
  * @param options 可选参数
@@ -181,7 +183,9 @@ export declare class ProductsModule extends BaseModule implements Module {
181
183
  /**
182
184
  * 通过 ProductDataSource SSE 加载完整商品列表
183
185
  */
184
- loadProductsByServer(): Promise<any>;
186
+ loadProductsByServer(options?: {
187
+ trigger?: string;
188
+ }): Promise<any>;
185
189
  /**
186
190
  * 纯请求方法:通过 HTTP 接口获取商品列表(无副作用,不触发事件、不写 IndexDB)
187
191
  * @param params 查询参数
@@ -331,7 +335,9 @@ export declare class ProductsModule extends BaseModule implements Module {
331
335
  * 拿到完整数据后一次性替换 store,清除价格缓存,触发 onProductsSyncCompleted
332
336
  * @returns 刷新后的商品列表
333
337
  */
334
- silentRefresh(): Promise<ProductData[]>;
338
+ silentRefresh(options?: {
339
+ trigger?: string;
340
+ }): Promise<ProductData[]>;
335
341
  /**
336
342
  * 销毁同步资源(取消 pubsub 订阅、清除定时器)
337
343
  */
@@ -61,7 +61,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
61
61
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
62
62
  // LoggerManager 实例
63
63
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
64
- // 商品价格缓存:Map<日期, 应用了价格的商品列表>
64
+ // 商品格式化缓存:Map<查询上下文 key, 已应用价格与多语言的商品列表>
65
65
  _defineProperty(_assertThisInitialized(_this), "productsPriceCache", new Map());
66
66
  // 缓存配置
67
67
  _defineProperty(_assertThisInitialized(_this), "CACHE_MAX_DAYS", 7);
@@ -78,6 +78,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
78
78
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeLoadedKey", '');
79
79
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshPromise", void 0);
80
80
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshKey", void 0);
81
+ _defineProperty(_assertThisInitialized(_this), "quotationBridgeUpdatedCallback", void 0);
81
82
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCache", new Map());
82
83
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheSource", null);
83
84
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheLoaded", false);
@@ -288,7 +289,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
288
289
  value: (function () {
289
290
  var _setupQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
290
291
  var _this$otherParams,
291
- _this3 = this;
292
+ _this3 = this,
293
+ _this$quotationPriceB,
294
+ _this$quotationPriceB2;
292
295
  var channel, quotation;
293
296
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
294
297
  while (1) switch (_context3.prev = _context3.next) {
@@ -349,11 +352,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
349
352
  return schedules[0];
350
353
  });
351
354
  }
352
- _context3.next = 13;
355
+ if (params.onQuotationUpdated) {
356
+ this.quotationBridgeUpdatedCallback = params.onQuotationUpdated;
357
+ }
358
+ (_this$quotationPriceB = (_this$quotationPriceB2 = this.quotationPriceBridge).setQuotationListUpdatedListener) === null || _this$quotationPriceB === void 0 || _this$quotationPriceB.call(_this$quotationPriceB2, function () {
359
+ var _this3$quotationBridg;
360
+ _this3.quotationBridgeLoadedKey = _this3.getQuotationBridgeScopeKey();
361
+ _this3.clearPriceCache();
362
+ (_this3$quotationBridg = _this3.quotationBridgeUpdatedCallback) === null || _this3$quotationBridg === void 0 || _this3$quotationBridg.call(_this3);
363
+ });
364
+ _context3.next = 15;
353
365
  return this.refreshQuotationPriceBridge({
354
366
  customer_id: params.customer_id
355
367
  });
356
- case 13:
368
+ case 15:
357
369
  case "end":
358
370
  return _context3.stop();
359
371
  }
@@ -573,8 +585,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
573
585
 
574
586
  /**
575
587
  * 获取应用了价格的商品列表(带缓存)
576
- * 使用日期作为缓存 key,同一天的商品价格会被缓存
577
- * 缓存的是已经应用了价格的完整商品列表,避免重复转换
588
+ * 使用时间、客户、策略、商品范围和语言作为缓存 key
589
+ * 缓存的是已经应用了价格与多语言的完整商品列表,避免重复转换
578
590
  * @param schedule_date 日期
579
591
  * @param extraContext 额外的上下文数据(可选,由 Server 层传入)
580
592
  * @param options 可选参数
@@ -865,11 +877,12 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
865
877
  }, {
866
878
  key: "getProductsPriceCacheKey",
867
879
  value: function getProductsPriceCacheKey(schedule_date, extraContext, productIds) {
868
- var _extraContext$custome;
880
+ var _ref13, _extraContext$locale, _this$core3, _extraContext$custome;
869
881
  var datetime = (extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime) || schedule_date;
882
+ var locale = (_ref13 = (_extraContext$locale = extraContext === null || extraContext === void 0 ? void 0 : extraContext.locale) !== null && _extraContext$locale !== void 0 ? _extraContext$locale : (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.locale) !== null && _ref13 !== void 0 ? _ref13 : '';
870
883
  var productScope = productIds ? ":products:".concat(productIds.join(',')) : '';
871
884
  var strategyScope = this.stringifyStable((extraContext === null || extraContext === void 0 ? void 0 : extraContext.strategy_context) || {});
872
- return "".concat(datetime, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '', ":strategy:").concat(strategyScope).concat(productScope);
885
+ return "".concat(datetime, ":locale:").concat(locale, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '') + ":strategy:".concat(strategyScope).concat(productScope);
873
886
  }
874
887
 
875
888
  /**
@@ -1107,8 +1120,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1107
1120
  }, {
1108
1121
  key: "shouldEnableLegacyPriceFormatter",
1109
1122
  value: function shouldEnableLegacyPriceFormatter() {
1110
- var _this$otherParams3, _this$core3;
1111
- return ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.enableLegacyPriceFormatter) === true || ((_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.enableLegacyPriceFormatter) === true;
1123
+ var _this$otherParams3, _this$core4;
1124
+ return ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.enableLegacyPriceFormatter) === true || ((_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.enableLegacyPriceFormatter) === true;
1112
1125
  }
1113
1126
 
1114
1127
  /**
@@ -1191,6 +1204,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1191
1204
  key: "clearPriceCache",
1192
1205
  value: function clearPriceCache() {
1193
1206
  this.productsPriceCache.clear();
1207
+ this.quotationScheduleCache.clear();
1208
+ this.quotationScheduleCacheLoaded = false;
1194
1209
  }
1195
1210
 
1196
1211
  /**
@@ -1200,62 +1215,76 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1200
1215
  key: "loadProductsByServer",
1201
1216
  value: (function () {
1202
1217
  var _loadProductsByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1203
- var t0, tSSE, productList, list, duration, errorMessage;
1218
+ var options,
1219
+ trigger,
1220
+ t0,
1221
+ tSSE,
1222
+ productList,
1223
+ list,
1224
+ duration,
1225
+ errorMessage,
1226
+ _args9 = arguments;
1204
1227
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1205
1228
  while (1) switch (_context9.prev = _context9.next) {
1206
1229
  case 0:
1230
+ options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
1207
1231
  if (this.productDataSource) {
1208
- _context9.next = 3;
1232
+ _context9.next = 4;
1209
1233
  break;
1210
1234
  }
1211
1235
  this.logWarning('loadProductsByServer: ProductDataSource 不可用');
1212
1236
  return _context9.abrupt("return", []);
1213
- case 3:
1214
- this.logInfo('开始通过 DataSource SSE 加载商品列表');
1237
+ case 4:
1238
+ trigger = options.trigger || 'unknown';
1239
+ this.logInfo('开始通过 DataSource SSE 加载商品列表', {
1240
+ trigger: trigger
1241
+ });
1215
1242
  t0 = performance.now();
1216
- _context9.prev = 5;
1243
+ _context9.prev = 7;
1217
1244
  tSSE = performance.now();
1218
- _context9.next = 9;
1245
+ _context9.next = 11;
1219
1246
  return this.productDataSource.run({
1220
1247
  sse: {}
1221
1248
  });
1222
- case 9:
1249
+ case 11:
1223
1250
  productList = _context9.sent;
1224
1251
  list = productList || [];
1225
1252
  perfMark('loadProductsByServer.SSE', performance.now() - tSSE, {
1226
1253
  count: list.length
1227
1254
  });
1228
1255
  this.logInfo('通过 DataSource SSE 加载商品列表成功', {
1256
+ trigger: trigger,
1229
1257
  productCount: list.length,
1230
1258
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1231
1259
  });
1232
- _context9.next = 15;
1260
+ _context9.next = 17;
1233
1261
  return this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer');
1234
- case 15:
1262
+ case 17:
1235
1263
  this.lastServerFullFetchAtMs = Date.now();
1236
- _context9.next = 18;
1264
+ _context9.next = 20;
1237
1265
  return this.core.effects.emit(ProductsHooks.onProductsLoaded, list);
1238
- case 18:
1266
+ case 20:
1239
1267
  perfMark('loadProductsByServer', performance.now() - t0, {
1240
1268
  count: list.length
1241
1269
  });
1242
1270
  return _context9.abrupt("return", list);
1243
- case 22:
1244
- _context9.prev = 22;
1245
- _context9.t0 = _context9["catch"](5);
1271
+ case 24:
1272
+ _context9.prev = 24;
1273
+ _context9.t0 = _context9["catch"](7);
1246
1274
  duration = Math.round(performance.now() - t0);
1247
1275
  errorMessage = _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0);
1248
1276
  console.error('[Products] 加载商品数据失败:', _context9.t0);
1249
1277
  this.logError('通过 DataSource SSE 加载商品列表失败', {
1278
+ trigger: trigger,
1250
1279
  duration: "".concat(duration, "ms"),
1251
1280
  error: errorMessage
1252
1281
  });
1253
1282
  return _context9.abrupt("return", []);
1254
- case 29:
1283
+ case 31:
1255
1284
  case "end":
1256
1285
  return _context9.stop();
1257
1286
  }
1258
- }, _callee9, this, [[5, 22]]);
1287
+ }, _callee9, this, [[7, 24]]);
1259
1288
  }));
1260
1289
  function loadProductsByServer() {
1261
1290
  return _loadProductsByServer.apply(this, arguments);
@@ -1272,11 +1301,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1272
1301
  key: "fetchProductsByHttp",
1273
1302
  value: (function () {
1274
1303
  var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1275
- var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$otherParams4, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
1304
+ var _ref14, _ref14$category_ids, category_ids, _ref14$product_ids, product_ids, _ref14$collection, collection, customer_id, cacheId, startTime, _this$otherParams4, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
1276
1305
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1277
1306
  while (1) switch (_context10.prev = _context10.next) {
1278
1307
  case 0:
1279
- _ref13 = params || {}, _ref13$category_ids = _ref13.category_ids, category_ids = _ref13$category_ids === void 0 ? [] : _ref13$category_ids, _ref13$product_ids = _ref13.product_ids, product_ids = _ref13$product_ids === void 0 ? [] : _ref13$product_ids, _ref13$collection = _ref13.collection, collection = _ref13$collection === void 0 ? [] : _ref13$collection, customer_id = _ref13.customer_id, cacheId = _ref13.cacheId;
1308
+ _ref14 = params || {}, _ref14$category_ids = _ref14.category_ids, category_ids = _ref14$category_ids === void 0 ? [] : _ref14$category_ids, _ref14$product_ids = _ref14.product_ids, product_ids = _ref14$product_ids === void 0 ? [] : _ref14$product_ids, _ref14$collection = _ref14.collection, collection = _ref14$collection === void 0 ? [] : _ref14$collection, customer_id = _ref14.customer_id, cacheId = _ref14.cacheId;
1280
1309
  this.logInfo('fetchProductsByHttp: 开始请求', {
1281
1310
  categoryIdsCount: category_ids.length,
1282
1311
  productIdsCount: product_ids.length,
@@ -1652,7 +1681,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1652
1681
  tTotal = performance.now();
1653
1682
  this.logInfo('refreshProducts 开始');
1654
1683
  _context16.next = 4;
1655
- return this.loadProductsByServer();
1684
+ return this.loadProductsByServer({
1685
+ trigger: 'product_sync'
1686
+ });
1656
1687
  case 4:
1657
1688
  products = _context16.sent;
1658
1689
  if (products && products.length > 0) {
@@ -1742,7 +1773,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1742
1773
  key: "loadProductsFromIndexDB",
1743
1774
  value: (function () {
1744
1775
  var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1745
- var _products$length, _products$length2, t0, products, errorMessage;
1776
+ var startedAt, _products$length, _products$length2, products, durationMs, errorMessage;
1746
1777
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1747
1778
  while (1) switch (_context18.prev = _context18.next) {
1748
1779
  case 0:
@@ -1753,33 +1784,36 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1753
1784
  this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
1754
1785
  return _context18.abrupt("return", []);
1755
1786
  case 3:
1756
- _context18.prev = 3;
1757
- t0 = performance.now();
1787
+ startedAt = performance.now();
1788
+ _context18.prev = 4;
1758
1789
  _context18.next = 7;
1759
1790
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1760
1791
  case 7:
1761
1792
  products = _context18.sent;
1762
- perfMark('loadProductsFromIndexDB', performance.now() - t0, {
1793
+ durationMs = +(performance.now() - startedAt).toFixed(2);
1794
+ perfMark('loadProductsFromIndexDB', durationMs, {
1763
1795
  count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
1764
1796
  });
1765
1797
  this.logInfo('从 IndexDB 加载商品数据', {
1766
- productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
1798
+ productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0,
1799
+ durationMs: durationMs
1767
1800
  });
1768
1801
  return _context18.abrupt("return", products || []);
1769
- case 13:
1770
- _context18.prev = 13;
1771
- _context18.t0 = _context18["catch"](3);
1802
+ case 14:
1803
+ _context18.prev = 14;
1804
+ _context18.t0 = _context18["catch"](4);
1772
1805
  errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1773
1806
  console.error('[Products] 从 IndexDB 读取数据失败:', _context18.t0);
1774
1807
  this.logError('从 IndexDB 读取数据失败', {
1808
+ durationMs: +(performance.now() - startedAt).toFixed(2),
1775
1809
  error: errorMessage
1776
1810
  });
1777
1811
  return _context18.abrupt("return", []);
1778
- case 19:
1812
+ case 20:
1779
1813
  case "end":
1780
1814
  return _context18.stop();
1781
1815
  }
1782
- }, _callee18, this, [[3, 13]]);
1816
+ }, _callee18, this, [[4, 14]]);
1783
1817
  }));
1784
1818
  function loadProductsFromIndexDB() {
1785
1819
  return _loadProductsFromIndexDB.apply(this, arguments);
@@ -1833,7 +1867,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1833
1867
  value: (function () {
1834
1868
  var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(products, source) {
1835
1869
  var _this9 = this;
1836
- var errorMessage;
1870
+ var enqueuedAt, queueWaitMs, clearDurationMs, writeDurationMs, errorMessage;
1837
1871
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1838
1872
  while (1) switch (_context21.prev = _context21.next) {
1839
1873
  case 0:
@@ -1844,58 +1878,86 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1844
1878
  this.logWarning('replaceProductsSnapshotInIndexDB: dbManager 不可用');
1845
1879
  return _context21.abrupt("return");
1846
1880
  case 3:
1847
- _context21.prev = 3;
1848
- _context21.next = 6;
1881
+ enqueuedAt = performance.now();
1882
+ queueWaitMs = 0;
1883
+ clearDurationMs = 0;
1884
+ writeDurationMs = 0;
1885
+ _context21.prev = 7;
1886
+ _context21.next = 10;
1849
1887
  return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1850
- var t0;
1888
+ var operationStartedAt, clearStartedAt, writeStartedAt, executeDurationMs;
1851
1889
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1852
1890
  while (1) switch (_context20.prev = _context20.next) {
1853
1891
  case 0:
1892
+ operationStartedAt = performance.now();
1893
+ queueWaitMs = +(operationStartedAt - enqueuedAt).toFixed(2);
1854
1894
  _this9.logInfo('replaceProductsSnapshotInIndexDB 开始', {
1855
1895
  source: source,
1856
- productCount: products.length
1896
+ productCount: products.length,
1897
+ queueWaitMs: queueWaitMs
1857
1898
  });
1858
- t0 = performance.now();
1859
- _context20.next = 4;
1899
+ clearStartedAt = performance.now();
1900
+ _context20.prev = 4;
1901
+ _context20.next = 7;
1860
1902
  return _this9.dbManager.clear(INDEXDB_STORE_NAME);
1861
- case 4:
1903
+ case 7:
1904
+ _context20.prev = 7;
1905
+ clearDurationMs = +(performance.now() - clearStartedAt).toFixed(2);
1906
+ return _context20.finish(7);
1907
+ case 10:
1862
1908
  if (!(products.length > 0)) {
1863
- _context20.next = 7;
1909
+ _context20.next = 18;
1864
1910
  break;
1865
1911
  }
1866
- _context20.next = 7;
1912
+ writeStartedAt = performance.now();
1913
+ _context20.prev = 12;
1914
+ _context20.next = 15;
1867
1915
  return _this9.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
1868
- case 7:
1869
- perfMark('replaceProductsSnapshotInIndexDB', performance.now() - t0, {
1916
+ case 15:
1917
+ _context20.prev = 15;
1918
+ writeDurationMs = +(performance.now() - writeStartedAt).toFixed(2);
1919
+ return _context20.finish(15);
1920
+ case 18:
1921
+ executeDurationMs = +(performance.now() - operationStartedAt).toFixed(2);
1922
+ perfMark('replaceProductsSnapshotInIndexDB', executeDurationMs, {
1870
1923
  count: products.length
1871
1924
  });
1872
1925
  _this9.logInfo('replaceProductsSnapshotInIndexDB 完成', {
1873
1926
  source: source,
1874
- productCount: products.length
1927
+ productCount: products.length,
1928
+ queueWaitMs: queueWaitMs,
1929
+ clearDurationMs: clearDurationMs,
1930
+ writeDurationMs: writeDurationMs,
1931
+ executeDurationMs: executeDurationMs,
1932
+ totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2)
1875
1933
  });
1876
- case 9:
1934
+ case 21:
1877
1935
  case "end":
1878
1936
  return _context20.stop();
1879
1937
  }
1880
- }, _callee20);
1938
+ }, _callee20, null, [[4,, 7, 10], [12,, 15, 18]]);
1881
1939
  })));
1882
- case 6:
1883
- _context21.next = 12;
1940
+ case 10:
1941
+ _context21.next = 16;
1884
1942
  break;
1885
- case 8:
1886
- _context21.prev = 8;
1887
- _context21.t0 = _context21["catch"](3);
1943
+ case 12:
1944
+ _context21.prev = 12;
1945
+ _context21.t0 = _context21["catch"](7);
1888
1946
  errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1889
1947
  this.logError('全量保存商品到 IndexDB 失败', {
1890
1948
  source: source,
1891
1949
  productCount: products.length,
1950
+ queueWaitMs: queueWaitMs,
1951
+ clearDurationMs: clearDurationMs,
1952
+ writeDurationMs: writeDurationMs,
1953
+ totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2),
1892
1954
  error: errorMessage
1893
1955
  });
1894
- case 12:
1956
+ case 16:
1895
1957
  case "end":
1896
1958
  return _context21.stop();
1897
1959
  }
1898
- }, _callee21, this, [[3, 8]]);
1960
+ }, _callee21, this, [[7, 12]]);
1899
1961
  }));
1900
1962
  function replaceProductsSnapshotInIndexDB(_x21, _x22) {
1901
1963
  return _replaceProductsSnapshotInIndexDB.apply(this, arguments);
@@ -2094,6 +2156,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2094
2156
  source: 'IndexDB'
2095
2157
  });
2096
2158
  this.logInfo('预加载完成(从 IndexDB)', {
2159
+ trigger: 'preload',
2097
2160
  productCount: cachedData.length,
2098
2161
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
2099
2162
  source: 'IndexDB'
@@ -2115,7 +2178,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2115
2178
  case 26:
2116
2179
  tServer = performance.now();
2117
2180
  _context24.next = 29;
2118
- return this.loadProductsByServer();
2181
+ return this.loadProductsByServer({
2182
+ trigger: 'preload'
2183
+ });
2119
2184
  case 29:
2120
2185
  products = _context24.sent;
2121
2186
  perfMark('preload.loadFromServer', performance.now() - tServer, {
@@ -2135,6 +2200,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2135
2200
  source: 'Server'
2136
2201
  });
2137
2202
  this.logInfo('预加载完成(从服务器)', {
2203
+ trigger: 'preload',
2138
2204
  productCount: products.length,
2139
2205
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
2140
2206
  source: 'Server'
@@ -2758,64 +2824,91 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2758
2824
  key: "silentRefresh",
2759
2825
  value: (function () {
2760
2826
  var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2761
- var t0, now, elapsedSincePreload, elapsedSinceFullFetch, products, errorMessage;
2827
+ var options,
2828
+ t0,
2829
+ now,
2830
+ trigger,
2831
+ elapsedSincePreloadMs,
2832
+ elapsedSinceFullFetchMs,
2833
+ products,
2834
+ errorMessage,
2835
+ _args29 = arguments;
2762
2836
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2763
2837
  while (1) switch (_context29.prev = _context29.next) {
2764
2838
  case 0:
2839
+ options = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
2765
2840
  t0 = performance.now();
2766
2841
  now = Date.now();
2767
- elapsedSincePreload = now - this.lastPreloadCompletedAtMs;
2768
- elapsedSinceFullFetch = now - this.lastServerFullFetchAtMs;
2769
- if (!(this.lastPreloadCompletedAtMs > 0 && elapsedSincePreload < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS)) {
2770
- _context29.next = 6;
2842
+ trigger = options.trigger || 'background';
2843
+ elapsedSincePreloadMs = now - this.lastPreloadCompletedAtMs;
2844
+ elapsedSinceFullFetchMs = now - this.lastServerFullFetchAtMs;
2845
+ if (!(this.lastPreloadCompletedAtMs > 0 && elapsedSincePreloadMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS)) {
2846
+ _context29.next = 9;
2771
2847
  break;
2772
2848
  }
2849
+ this.logInfo('silentRefresh 跳过全量 SSE', {
2850
+ trigger: trigger,
2851
+ reason: 'within_min_interval',
2852
+ minIntervalMs: PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS,
2853
+ elapsedSincePreloadMs: elapsedSincePreloadMs,
2854
+ elapsedSinceFullFetchMs: elapsedSinceFullFetchMs,
2855
+ productCount: this.store.list.length
2856
+ });
2773
2857
  return _context29.abrupt("return", this.store.list);
2774
- case 6:
2775
- this.logInfo('silentRefresh 开始');
2776
- _context29.prev = 7;
2777
- _context29.next = 10;
2778
- return this.loadProductsByServer();
2779
- case 10:
2858
+ case 9:
2859
+ this.logInfo('silentRefresh 开始', {
2860
+ trigger: trigger,
2861
+ elapsedSincePreloadMs: elapsedSincePreloadMs,
2862
+ elapsedSinceFullFetchMs: elapsedSinceFullFetchMs,
2863
+ productCount: this.store.list.length
2864
+ });
2865
+ _context29.prev = 10;
2866
+ _context29.next = 13;
2867
+ return this.loadProductsByServer({
2868
+ trigger: trigger
2869
+ });
2870
+ case 13:
2780
2871
  products = _context29.sent;
2781
2872
  if (!(products && products.length > 0)) {
2782
- _context29.next = 21;
2873
+ _context29.next = 24;
2783
2874
  break;
2784
2875
  }
2785
2876
  this.store.list = products;
2786
2877
  this.syncProductsMap();
2787
2878
  this.clearPriceCache();
2788
2879
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
2789
- _context29.next = 18;
2880
+ _context29.next = 21;
2790
2881
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
2791
- case 18:
2882
+ case 21:
2792
2883
  this.logInfo('silentRefresh 完成', {
2884
+ trigger: trigger,
2793
2885
  productCount: products.length,
2794
2886
  duration: "".concat(Math.round(performance.now() - t0), "ms")
2795
2887
  });
2796
- _context29.next = 22;
2888
+ _context29.next = 25;
2797
2889
  break;
2798
- case 21:
2890
+ case 24:
2799
2891
  this.logWarning('silentRefresh: 服务器未返回数据');
2800
- case 22:
2892
+ case 25:
2801
2893
  perfMark('silentRefresh', performance.now() - t0, {
2802
2894
  count: this.store.list.length
2803
2895
  });
2804
2896
  return _context29.abrupt("return", this.store.list);
2805
- case 26:
2806
- _context29.prev = 26;
2807
- _context29.t0 = _context29["catch"](7);
2897
+ case 29:
2898
+ _context29.prev = 29;
2899
+ _context29.t0 = _context29["catch"](10);
2808
2900
  errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
2809
2901
  this.logError('silentRefresh 失败', {
2902
+ trigger: trigger,
2810
2903
  duration: "".concat(Math.round(performance.now() - t0), "ms"),
2811
2904
  error: errorMessage
2812
2905
  });
2813
2906
  return _context29.abrupt("return", this.store.list);
2814
- case 31:
2907
+ case 34:
2815
2908
  case "end":
2816
2909
  return _context29.stop();
2817
2910
  }
2818
- }, _callee29, this, [[7, 26]]);
2911
+ }, _callee29, this, [[10, 29]]);
2819
2912
  }));
2820
2913
  function silentRefresh() {
2821
2914
  return _silentRefresh.apply(this, arguments);
@@ -149,41 +149,49 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
149
149
  while (1) switch (_context2.prev = _context2.next) {
150
150
  case 0:
151
151
  _context2.next = 2;
152
- return this.setupResourceSync();
153
- case 2:
154
- _context2.next = 4;
155
152
  return this.loadResourcesFromSQLite();
156
- case 4:
153
+ case 2:
157
154
  cachedResources = _context2.sent;
158
155
  if (!(cachedResources.length > 0)) {
159
- _context2.next = 12;
156
+ _context2.next = 10;
160
157
  break;
161
158
  }
162
159
  this.store.list = cloneDeep(cachedResources).map(function (item) {
163
160
  return _this3.normalizeResource(item);
164
161
  });
165
162
  this.syncResourcesMap();
166
- _context2.next = 10;
163
+ _context2.next = 8;
167
164
  return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
165
+ case 8:
166
+ // 二次启动优先使用 SQLite。pubsub 注册及远端校准继续在后台执行,
167
+ // setupResourceSync 完成后会合并最新数据并回写 SQLite。
168
+ void this.setupResourceSync().catch(function (error) {
169
+ _this3.logError('后台初始化资源同步失败', error);
170
+ });
171
+ return _context2.abrupt("return");
168
172
  case 10:
169
- _context2.next = 20;
170
- break;
173
+ _context2.next = 12;
174
+ return this.setupResourceSync();
171
175
  case 12:
172
- _context2.next = 14;
176
+ if (!(this.store.list.length === 0)) {
177
+ _context2.next = 21;
178
+ break;
179
+ }
180
+ _context2.next = 15;
173
181
  return this.loadResourcesByServer();
174
- case 14:
182
+ case 15:
175
183
  resources = _context2.sent;
176
184
  if (!(resources.length > 0)) {
177
- _context2.next = 20;
185
+ _context2.next = 21;
178
186
  break;
179
187
  }
180
188
  this.store.list = cloneDeep(resources).map(function (item) {
181
189
  return _this3.normalizeResource(item);
182
190
  });
183
191
  this.syncResourcesMap();
184
- _context2.next = 20;
192
+ _context2.next = 21;
185
193
  return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
186
- case 20:
194
+ case 21:
187
195
  case "end":
188
196
  return _context2.stop();
189
197
  }
@@ -11,7 +11,7 @@ export declare function perfMark(label: string, durationMs: number, meta?: Recor
11
11
  export declare function applyPriceDataToProducts(products: ProductData[], priceData: LoadProductsPriceData[]): ProductData[];
12
12
  export declare const getIsSessionProduct: (product: ProductData) => boolean;
13
13
  /**
14
- * 根据 locale 将商品的 i18n 字段覆盖到对应原始字段
14
+ * 根据 locale 格式化商品、分类、规格及套餐文案,缺少对应语言时回退 original。
15
15
  */
16
16
  export declare function applyI18nToProducts(products: ProductData[], locale?: string): ProductData[];
17
17
  /**