@pisell/pisellos 2.2.261 → 2.2.263

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 (134) hide show
  1. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  2. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  3. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  4. package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
  5. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  6. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  7. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  8. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  9. package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  10. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  11. package/dist/model/strategy/adapter/index.d.ts +4 -0
  12. package/dist/model/strategy/adapter/index.js +5 -1
  13. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  14. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  15. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  16. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  17. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  18. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  19. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  20. package/dist/model/strategy/adapter/promotion/index.js +1 -1
  21. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  22. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  23. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -10
  24. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
  25. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  26. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +32 -1
  27. package/dist/modules/Discount/index.d.ts +5 -2
  28. package/dist/modules/Discount/index.js +30 -7
  29. package/dist/modules/Discount/types.d.ts +4 -0
  30. package/dist/modules/Order/index.d.ts +14 -2
  31. package/dist/modules/Order/index.js +1035 -736
  32. package/dist/modules/Order/types.d.ts +16 -0
  33. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  34. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  35. package/dist/modules/Order/utils.d.ts +4 -3
  36. package/dist/modules/Order/utils.js +54 -61
  37. package/dist/modules/Product/types.d.ts +22 -0
  38. package/dist/modules/ProductList/index.d.ts +1 -1
  39. package/dist/modules/ProductList/index.js +4 -2
  40. package/dist/modules/ProductList/types.d.ts +2 -0
  41. package/dist/modules/Rules/index.d.ts +2 -9
  42. package/dist/modules/Rules/index.js +69 -43
  43. package/dist/modules/Rules/types.d.ts +10 -1
  44. package/dist/server/index.d.ts +55 -0
  45. package/dist/server/index.js +1173 -753
  46. package/dist/server/modules/order/index.d.ts +10 -4
  47. package/dist/server/modules/order/index.js +404 -399
  48. package/dist/server/modules/order/types.d.ts +4 -0
  49. package/dist/server/modules/products/index.d.ts +31 -8
  50. package/dist/server/modules/products/index.js +549 -390
  51. package/dist/server/modules/products/types.d.ts +18 -0
  52. package/dist/solution/BaseSales/index.d.ts +21 -1
  53. package/dist/solution/BaseSales/index.js +1136 -789
  54. package/dist/solution/BaseSales/types.d.ts +6 -1
  55. package/dist/solution/BaseSales/types.js +1 -1
  56. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  57. package/dist/solution/BaseSales/utils/cartPromotion.js +48 -81
  58. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  59. package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
  60. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -1
  61. package/dist/solution/BookingByStep/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.d.ts +1 -1
  63. package/dist/solution/BookingTicket/index.js +59 -25
  64. package/dist/solution/BookingTicket/types.d.ts +2 -0
  65. package/dist/solution/ScanOrder/index.js +20 -31
  66. package/dist/solution/ShopDiscount/index.js +15 -14
  67. package/dist/solution/VenueBooking/index.js +19 -30
  68. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  69. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  70. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  71. package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
  72. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  73. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  74. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  75. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  76. package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
  77. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  78. package/lib/model/strategy/adapter/index.d.ts +4 -0
  79. package/lib/model/strategy/adapter/index.js +13 -2
  80. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  81. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  82. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  83. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  84. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  85. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  86. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  87. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  88. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  89. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  90. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -0
  91. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -0
  92. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -1
  93. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +23 -2
  94. package/lib/modules/Discount/index.d.ts +5 -2
  95. package/lib/modules/Discount/index.js +23 -3
  96. package/lib/modules/Discount/types.d.ts +4 -0
  97. package/lib/modules/Order/index.d.ts +14 -2
  98. package/lib/modules/Order/index.js +326 -60
  99. package/lib/modules/Order/types.d.ts +16 -0
  100. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  101. package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
  102. package/lib/modules/Order/utils.d.ts +4 -3
  103. package/lib/modules/Order/utils.js +22 -23
  104. package/lib/modules/Product/types.d.ts +22 -0
  105. package/lib/modules/ProductList/index.d.ts +1 -1
  106. package/lib/modules/ProductList/index.js +4 -2
  107. package/lib/modules/ProductList/types.d.ts +2 -0
  108. package/lib/modules/Rules/index.d.ts +2 -9
  109. package/lib/modules/Rules/index.js +61 -29
  110. package/lib/modules/Rules/types.d.ts +10 -1
  111. package/lib/server/index.d.ts +55 -0
  112. package/lib/server/index.js +332 -34
  113. package/lib/server/modules/order/index.d.ts +10 -4
  114. package/lib/server/modules/order/index.js +198 -139
  115. package/lib/server/modules/order/types.d.ts +4 -0
  116. package/lib/server/modules/products/index.d.ts +31 -8
  117. package/lib/server/modules/products/index.js +134 -35
  118. package/lib/server/modules/products/types.d.ts +18 -0
  119. package/lib/solution/BaseSales/index.d.ts +21 -1
  120. package/lib/solution/BaseSales/index.js +313 -72
  121. package/lib/solution/BaseSales/types.d.ts +6 -1
  122. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  123. package/lib/solution/BaseSales/utils/cartPromotion.js +29 -60
  124. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
  125. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
  126. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -0
  127. package/lib/solution/BookingByStep/index.d.ts +1 -1
  128. package/lib/solution/BookingTicket/index.d.ts +1 -1
  129. package/lib/solution/BookingTicket/index.js +33 -8
  130. package/lib/solution/BookingTicket/types.d.ts +2 -0
  131. package/lib/solution/ScanOrder/index.js +0 -8
  132. package/lib/solution/ShopDiscount/index.js +2 -1
  133. package/lib/solution/VenueBooking/index.js +0 -8
  134. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
3
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
9
4
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
12
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
@@ -32,7 +32,6 @@ import { BaseModule } from "../../../modules/BaseModule";
32
32
  import { QuotationModule as ClientQuotationModule } from "../../../modules/Quotation";
33
33
  import { ProductsHooks } from "./types";
34
34
  import { applyDetailValueToProducts, applyPriceDataToProducts, applyI18nToProducts, perfMark } from "../../utils/product";
35
-
36
35
  /**
37
36
  * IndexDB 存储名称
38
37
  */
@@ -69,8 +68,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
69
68
  // 最多缓存7天
70
69
  // 商品格式化器列表
71
70
  _defineProperty(_assertThisInitialized(_this), "formatters", []);
72
- // 是否已注册内置价格格式化器
73
- _defineProperty(_assertThisInitialized(_this), "isPriceFormatterRegistered", false);
71
+ // 是否已注册内置商品格式化器
72
+ _defineProperty(_assertThisInitialized(_this), "isBuiltinFormatterRegistered", false);
73
+ // 旧报价单格式化器默认关闭,仅显式开启时作为兼容兜底注册
74
+ _defineProperty(_assertThisInitialized(_this), "isLegacyPriceFormatterEnabled", false);
74
75
  // 普通层 QuotationModule 桥接器:本地计算报价单价格,替代 /product/query/price
75
76
  _defineProperty(_assertThisInitialized(_this), "quotationPriceBridge", void 0);
76
77
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeChannel", void 0);
@@ -90,6 +91,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
90
91
  _defineProperty(_assertThisInitialized(_this), "lastPreloadCompletedAtMs", 0);
91
92
  /** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
92
93
  _defineProperty(_assertThisInitialized(_this), "productIndexDBSaveQueue", Promise.resolve());
94
+ /** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
95
+ _defineProperty(_assertThisInitialized(_this), "lastScheduleTimePoints", []);
93
96
  return _this;
94
97
  }
95
98
  _createClass(ProductsModule, [{
@@ -128,8 +131,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
128
131
  }
129
132
  }
130
133
 
131
- // 注册内置的价格格式化器(作为第一个格式化器)
132
- this.registerBuiltinPriceFormatter();
134
+ // 注册内置商品格式化器;智能定价默认替代报价单价格逻辑
135
+ this.registerBuiltinProductFormatters();
133
136
 
134
137
  // 初始化 ProductDataSource 实例
135
138
  this.initProductDataSource();
@@ -743,7 +746,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
743
746
  key: "prepareProductsWithPrice",
744
747
  value: (function () {
745
748
  var _prepareProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schedule_date, extraContext, options) {
746
- var tTotal, targetIds, isIncremental, _priceData$length, _this$core, products, ids, tIds, i, tPrice, priceData, context, tFormat, processedProducts, errorMessage;
749
+ var tTotal, targetIds, isIncremental, _this$core, _this$core2, products, ids, tIds, i, priceData, _priceData$length, _priceData, tPrice, context, tFormat, processedProducts, errorMessage;
747
750
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
748
751
  while (1) switch (_context7.prev = _context7.next) {
749
752
  case 0:
@@ -778,34 +781,44 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
778
781
  productCount: products.length
779
782
  });
780
783
 
781
- // 2. 获取价格数据(网络请求)
784
+ // 2. 仅在 legacy 报价单 formatter 启用时加载报价单价格;默认由智能定价覆盖商品价格。
785
+ priceData = [];
786
+ if (!this.isLegacyPriceFormatterEnabled) {
787
+ _context7.next = 15;
788
+ break;
789
+ }
782
790
  tPrice = performance.now();
783
- _context7.next = 10;
791
+ _context7.next = 12;
784
792
  return this.loadProductsPrice({
785
793
  ids: ids,
786
794
  schedule_date: schedule_date,
787
795
  schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
788
796
  customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id
789
797
  });
790
- case 10:
798
+ case 12:
791
799
  priceData = _context7.sent;
792
800
  perfMark('prepareProducts.loadPrice', performance.now() - tPrice, {
793
801
  count: ids.length
794
802
  });
795
803
  this.logInfo('获取商品报价单价格成功', {
796
- priceDataCount: (_priceData$length = priceData === null || priceData === void 0 ? void 0 : priceData.length) !== null && _priceData$length !== void 0 ? _priceData$length : 0
804
+ priceDataCount: (_priceData$length = (_priceData = priceData) === null || _priceData === void 0 ? void 0 : _priceData.length) !== null && _priceData$length !== void 0 ? _priceData$length : 0
797
805
  });
806
+ case 15:
798
807
  context = _objectSpread({
799
808
  schedule_date: schedule_date,
800
809
  schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
801
810
  customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id,
802
811
  priceData: priceData,
803
- locale: (_this$core = this.core) === null || _this$core === void 0 || (_this$core = _this$core.context) === null || _this$core === void 0 ? void 0 : _this$core.locale
812
+ locale: (_this$core = this.core) === null || _this$core === void 0 || (_this$core = _this$core.context) === null || _this$core === void 0 ? void 0 : _this$core.locale,
813
+ dataVariantEvaluator: (extraContext === null || extraContext === void 0 ? void 0 : extraContext.dataVariantEvaluator) || ((_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.context) === null || _this$core2 === void 0 ? void 0 : _this$core2.dataVariantEvaluator),
814
+ menuList: (extraContext === null || extraContext === void 0 ? void 0 : extraContext.menuList) || [],
815
+ scheduleList: (extraContext === null || extraContext === void 0 ? void 0 : extraContext.scheduleList) || [],
816
+ strategy_context: extraContext === null || extraContext === void 0 ? void 0 : extraContext.strategy_context
804
817
  }, extraContext); // 3. 通过格式化器流程处理商品
805
818
  tFormat = performance.now();
806
- _context7.next = 17;
819
+ _context7.next = 19;
807
820
  return this.applyFormatters(products, context);
808
- case 17:
821
+ case 19:
809
822
  processedProducts = _context7.sent;
810
823
  perfMark('prepareProducts.applyFormatters', performance.now() - tFormat, {
811
824
  count: products.length,
@@ -818,20 +831,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
818
831
  formatterCount: this.formatters.length
819
832
  });
820
833
  if (isIncremental) {
821
- _context7.next = 23;
834
+ _context7.next = 25;
822
835
  break;
823
836
  }
824
- _context7.next = 23;
837
+ _context7.next = 25;
825
838
  return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
826
- case 23:
839
+ case 25:
827
840
  perfMark('prepareProductsWithPrice', performance.now() - tTotal, {
828
841
  productCount: products.length,
829
842
  formatterCount: this.formatters.length,
830
843
  mode: isIncremental ? 'incremental' : 'full'
831
844
  });
832
845
  return _context7.abrupt("return", processedProducts);
833
- case 27:
834
- _context7.prev = 27;
846
+ case 29:
847
+ _context7.prev = 29;
835
848
  _context7.t0 = _context7["catch"](4);
836
849
  errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
837
850
  console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context7.t0);
@@ -839,13 +852,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
839
852
  schedule_date: schedule_date,
840
853
  error: errorMessage
841
854
  });
842
- case 32:
855
+ case 34:
843
856
  return _context7.abrupt("return", []);
844
- case 33:
857
+ case 35:
845
858
  case "end":
846
859
  return _context7.stop();
847
860
  }
848
- }, _callee7, this, [[4, 27]]);
861
+ }, _callee7, this, [[4, 29]]);
849
862
  }));
850
863
  function prepareProductsWithPrice(_x10, _x11, _x12) {
851
864
  return _prepareProductsWithPrice.apply(this, arguments);
@@ -858,7 +871,27 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
858
871
  var _extraContext$custome;
859
872
  var datetime = (extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime) || schedule_date;
860
873
  var productScope = productIds ? ":products:".concat(productIds.join(',')) : '';
861
- return "".concat(datetime, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '').concat(productScope);
874
+ var strategyScope = this.stringifyStable((extraContext === null || extraContext === void 0 ? void 0 : extraContext.strategy_context) || {});
875
+ 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);
876
+ }
877
+
878
+ /**
879
+ * 稳定序列化策略上下文,避免对象 key 顺序不同导致缓存 key 抖动。
880
+ */
881
+ }, {
882
+ key: "stringifyStable",
883
+ value: function stringifyStable(value) {
884
+ var _this7 = this;
885
+ if (value == null) return '';
886
+ if (Array.isArray(value)) return "[".concat(value.map(function (item) {
887
+ return _this7.stringifyStable(item);
888
+ }).join(','), "]");
889
+ if (_typeof(value) === 'object') {
890
+ return "{".concat(Object.keys(value).sort().map(function (key) {
891
+ return "".concat(key, ":").concat(_this7.stringifyStable(value[key]));
892
+ }).join(','), "}");
893
+ }
894
+ return String(value);
862
895
  }
863
896
  }, {
864
897
  key: "normalizeProductIds",
@@ -1004,26 +1037,56 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1004
1037
  return applyFormatters;
1005
1038
  }()
1006
1039
  /**
1007
- * 注册内置的价格格式化器
1008
- * 这个格式化器负责将价格数据应用到商品上
1040
+ * 注册内置商品格式化器。
1041
+ *
1042
+ * 智能定价默认替代报价单逻辑;报价单 formatter 仅在 enableLegacyPriceFormatter=true 时启用。
1009
1043
  * @private
1010
1044
  */
1011
1045
  )
1012
1046
  }, {
1013
- key: "registerBuiltinPriceFormatter",
1014
- value: function registerBuiltinPriceFormatter() {
1015
- if (this.isPriceFormatterRegistered) {
1016
- console.warn('[ProductsModule] 内置价格格式化器已注册,跳过');
1047
+ key: "registerBuiltinProductFormatters",
1048
+ value: function registerBuiltinProductFormatters() {
1049
+ var _this8 = this;
1050
+ if (this.isBuiltinFormatterRegistered) {
1051
+ console.warn('[ProductsModule] 内置商品格式化器已注册,跳过');
1017
1052
  return;
1018
1053
  }
1054
+ this.isLegacyPriceFormatterEnabled = this.shouldEnableLegacyPriceFormatter();
1055
+ var dataVariantFormatter = function dataVariantFormatter(products, context) {
1056
+ var _this8$core, _strategyContext$busi;
1057
+ var evaluator = context.dataVariantEvaluator || ((_this8$core = _this8.core) === null || _this8$core === void 0 || (_this8$core = _this8$core.context) === null || _this8$core === void 0 ? void 0 : _this8$core.dataVariantEvaluator);
1058
+ if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
1059
+ _this8.lastScheduleTimePoints = [];
1060
+ _this8.logWarning('智能定价评估器未注入,跳过 DataVariant 格式化', {
1061
+ productCount: products.length
1062
+ });
1063
+ return products;
1064
+ }
1065
+ var strategyContext = context.strategy_context || {};
1066
+ var businessData = {
1067
+ products: products,
1068
+ scheduleDateTime: context.schedule_datetime || context.schedule_date,
1069
+ scheduleList: context.scheduleList || [],
1070
+ menuList: context.menuList || [],
1071
+ customerId: context.customer_id,
1072
+ channel: strategyContext.channel,
1073
+ orderType: strategyContext.orderType || strategyContext.order_type,
1074
+ businessCode: (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : strategyContext.businessCode,
1075
+ availableWalletIds: strategyContext.available_wallet_ids,
1076
+ custom: strategyContext
1077
+ };
1078
+ var result = evaluator.resolveProducts(businessData);
1079
+ _this8.lastScheduleTimePoints = Array.isArray(result === null || result === void 0 ? void 0 : result.scheduleTimePoints) ? _toConsumableArray(result.scheduleTimePoints) : [];
1080
+ return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
1081
+ };
1019
1082
 
1020
- // 创建价格格式化器
1021
- var priceFormatter = function priceFormatter(products, context) {
1083
+ // 创建 legacy 报价单格式化器
1084
+ var legacyPriceFormatter = function legacyPriceFormatter(products, context) {
1022
1085
  if (!context.priceData || context.priceData.length === 0) {
1023
- console.log('[ProductsModule] 💰 没有价格数据,跳过价格应用');
1086
+ console.log('[ProductsModule] 💰 没有价格数据,跳过 legacy 报价单价格应用');
1024
1087
  return products;
1025
1088
  }
1026
- console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528\u4EF7\u683C\u6570\u636E\u5230 ".concat(products.length, " \u4E2A\u5546\u54C1"));
1089
+ console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528 legacy \u62A5\u4EF7\u5355\u4EF7\u683C\u5230 ".concat(products.length, " \u4E2A\u5546\u54C1"));
1027
1090
  return applyPriceDataToProducts(products, context.priceData);
1028
1091
  };
1029
1092
  var i18nFormatter = function i18nFormatter(products, context) {
@@ -1032,18 +1095,41 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1032
1095
  var detailValueFormatter = function detailValueFormatter(products, context) {
1033
1096
  return applyDetailValueToProducts(products, context);
1034
1097
  };
1035
-
1036
- // 将价格格式化器注册为第一个格式化器
1037
- this.formatters.unshift(priceFormatter);
1098
+ if (this.isLegacyPriceFormatterEnabled) {
1099
+ this.formatters.push(legacyPriceFormatter);
1100
+ }
1101
+ this.formatters.push(dataVariantFormatter);
1038
1102
  this.formatters.push(i18nFormatter);
1039
1103
  this.formatters.push(detailValueFormatter);
1040
- this.isPriceFormatterRegistered = true;
1041
- console.log('[ProductsModule] ✅ 内置价格格式化器已注册(第 1 个)');
1104
+ this.isBuiltinFormatterRegistered = true;
1105
+ console.log('[ProductsModule] ✅ 内置商品格式化器已注册(智能定价优先)');
1106
+ }
1107
+
1108
+ /**
1109
+ * 是否启用旧报价单价格 formatter。
1110
+ *
1111
+ * 默认关闭,避免报价单逻辑覆盖智能定价结果。
1112
+ */
1113
+ }, {
1114
+ key: "shouldEnableLegacyPriceFormatter",
1115
+ value: function shouldEnableLegacyPriceFormatter() {
1116
+ var _this$otherParams3, _this$core3;
1117
+ 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;
1118
+ }
1119
+
1120
+ /**
1121
+ * 返回最近一次 prepareProductsWithPrice / DataVariant 评估提取的变价时间点(HH:mm)。
1122
+ * 供 OS Server 商品 query 订阅定时刷新使用。
1123
+ */
1124
+ }, {
1125
+ key: "getLastScheduleTimePoints",
1126
+ value: function getLastScheduleTimePoints() {
1127
+ return _toConsumableArray(this.lastScheduleTimePoints);
1042
1128
  }
1043
1129
 
1044
1130
  /**
1045
1131
  * 注册商品格式化器
1046
- * 格式化器会按注册顺序依次执行(内置价格格式化器始终是第一个)
1132
+ * 格式化器会按注册顺序依次执行;legacy 启用时先兜底报价,再由智能定价覆盖。
1047
1133
  * @param formatter 格式化函数
1048
1134
  * @param prepend 是否插入到队列开头(默认 false,追加到末尾)
1049
1135
  * @example
@@ -1061,8 +1147,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1061
1147
  value: function registerFormatter(formatter) {
1062
1148
  var prepend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1063
1149
  if (prepend) {
1064
- // 插入到价格格式化器之后(索引 1 的位置)
1065
- var insertIndex = this.isPriceFormatterRegistered ? 1 : 0;
1150
+ // 插入到内置智能定价格式化器之后;legacy 报价单启用时需跳过它。
1151
+ var insertIndex = this.isBuiltinFormatterRegistered ? this.isLegacyPriceFormatterEnabled ? 2 : 1 : 0;
1066
1152
  this.formatters.splice(insertIndex, 0, formatter);
1067
1153
  console.log("[ProductsModule] \uD83D\uDCCC \u5DF2\u5728\u4F4D\u7F6E ".concat(insertIndex + 1, " \u63D2\u5165\u683C\u5F0F\u5316\u5668\uFF0C\u5F53\u524D\u5171 ").concat(this.formatters.length, " \u4E2A"));
1068
1154
  } else {
@@ -1073,20 +1159,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1073
1159
  }
1074
1160
 
1075
1161
  /**
1076
- * 清空所有格式化器(包括内置价格格式化器)
1077
- * @param keepBuiltin 是否保留内置价格格式化器(默认 true)
1162
+ * 清空所有格式化器(包括内置智能定价格式化器)
1163
+ * @param keepBuiltin 是否保留内置智能定价格式化器(默认 true)
1078
1164
  */
1079
1165
  }, {
1080
1166
  key: "clearFormatters",
1081
1167
  value: function clearFormatters() {
1082
1168
  var keepBuiltin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1083
- if (keepBuiltin && this.isPriceFormatterRegistered) {
1084
- // 只保留第一个格式化器(内置价格格式化器)
1085
- this.formatters = [this.formatters[0]];
1086
- console.log('[ProductsModule] 🧹 已清空自定义格式化器,保留内置价格格式化器');
1169
+ if (keepBuiltin && this.isBuiltinFormatterRegistered) {
1170
+ // 保留 legacy 兜底(如果启用)和智能定价格式化器。
1171
+ var builtinCount = this.isLegacyPriceFormatterEnabled ? 2 : 1;
1172
+ this.formatters = this.formatters.slice(0, builtinCount);
1173
+ console.log('[ProductsModule] 🧹 已清空自定义格式化器,保留内置智能定价格式化器');
1087
1174
  } else {
1088
1175
  this.formatters = [];
1089
- this.isPriceFormatterRegistered = false;
1176
+ this.isBuiltinFormatterRegistered = false;
1090
1177
  console.log('[ProductsModule] 🧹 已清空所有格式化器');
1091
1178
  }
1092
1179
  }
@@ -1197,7 +1284,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1197
1284
  key: "fetchProductsByHttp",
1198
1285
  value: (function () {
1199
1286
  var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1200
- var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$otherParams3, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
1287
+ 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;
1201
1288
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1202
1289
  while (1) switch (_context10.prev = _context10.next) {
1203
1290
  case 0:
@@ -1215,7 +1302,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1215
1302
  open_bundle: 1,
1216
1303
  exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
1217
1304
  force_ignore_cache_flag: 1,
1218
- with: ['category', 'collection', 'resourceRelation', 'bundleGroup.bundleItem', 'optionGroup.optionItem', 'variantGroup.variantItem'],
1305
+ with: ['category', 'collection', 'resourceRelation', 'bundleGroup.bundleItem', 'optionGroup.optionItem', 'variantGroup.variantItem', 'dataVariants'],
1219
1306
  open_deposit: 1,
1220
1307
  is_append_product_description: 1,
1221
1308
  with_count: ['bundleGroup', 'optionGroup'],
@@ -1227,7 +1314,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1227
1314
  ids: product_ids,
1228
1315
  collection: collection,
1229
1316
  front_end_cache_id: cacheId,
1230
- application_code: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel
1317
+ application_code: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.channel
1231
1318
  }, {
1232
1319
  cache: undefined
1233
1320
  });
@@ -1332,6 +1419,74 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1332
1419
  }
1333
1420
  return getProducts;
1334
1421
  }()
1422
+ /**
1423
+ * 批量获取商品轻量快照,供订单详情等响应补齐展示协议字段。
1424
+ */
1425
+ )
1426
+ }, {
1427
+ key: "getProductSnapshotsByIds",
1428
+ value: (function () {
1429
+ var _getProductSnapshotsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(ids) {
1430
+ var snapshots, seen, _iterator6, _step6, id, product;
1431
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1432
+ while (1) switch (_context13.prev = _context13.next) {
1433
+ case 0:
1434
+ snapshots = {};
1435
+ seen = new Set();
1436
+ _iterator6 = _createForOfIteratorHelper(ids);
1437
+ _context13.prev = 3;
1438
+ _iterator6.s();
1439
+ case 5:
1440
+ if ((_step6 = _iterator6.n()).done) {
1441
+ _context13.next = 16;
1442
+ break;
1443
+ }
1444
+ id = _step6.value;
1445
+ if (!(!Number.isFinite(id) || seen.has(id))) {
1446
+ _context13.next = 9;
1447
+ break;
1448
+ }
1449
+ return _context13.abrupt("continue", 14);
1450
+ case 9:
1451
+ seen.add(id);
1452
+ product = this.store.map.get(id);
1453
+ if (product) {
1454
+ _context13.next = 13;
1455
+ break;
1456
+ }
1457
+ return _context13.abrupt("continue", 14);
1458
+ case 13:
1459
+ snapshots[String(id)] = {
1460
+ cover: product.cover,
1461
+ holder_config: product.holder_config
1462
+ };
1463
+ case 14:
1464
+ _context13.next = 5;
1465
+ break;
1466
+ case 16:
1467
+ _context13.next = 21;
1468
+ break;
1469
+ case 18:
1470
+ _context13.prev = 18;
1471
+ _context13.t0 = _context13["catch"](3);
1472
+ _iterator6.e(_context13.t0);
1473
+ case 21:
1474
+ _context13.prev = 21;
1475
+ _iterator6.f();
1476
+ return _context13.finish(21);
1477
+ case 24:
1478
+ return _context13.abrupt("return", snapshots);
1479
+ case 25:
1480
+ case "end":
1481
+ return _context13.stop();
1482
+ }
1483
+ }, _callee13, this, [[3, 18, 21, 24]]);
1484
+ }));
1485
+ function getProductSnapshotsByIds(_x17) {
1486
+ return _getProductSnapshotsByIds.apply(this, arguments);
1487
+ }
1488
+ return getProductSnapshotsByIds;
1489
+ }()
1335
1490
  /**
1336
1491
  * 内部获取商品列表的直接引用(无拷贝)
1337
1492
  * 仅供内部 formatter 流程使用,因为 formatter 会创建新对象
@@ -1350,18 +1505,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1350
1505
  key: "getProductsRefByIds",
1351
1506
  value: function getProductsRefByIds(ids) {
1352
1507
  var products = [];
1353
- var _iterator6 = _createForOfIteratorHelper(ids),
1354
- _step6;
1508
+ var _iterator7 = _createForOfIteratorHelper(ids),
1509
+ _step7;
1355
1510
  try {
1356
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1357
- var id = _step6.value;
1511
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1512
+ var id = _step7.value;
1358
1513
  var product = this.store.map.get(id);
1359
1514
  if (product) products.push(product);
1360
1515
  }
1361
1516
  } catch (err) {
1362
- _iterator6.e(err);
1517
+ _iterator7.e(err);
1363
1518
  } finally {
1364
- _iterator6.f();
1519
+ _iterator7.f();
1365
1520
  }
1366
1521
  return products;
1367
1522
  }
@@ -1373,20 +1528,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1373
1528
  }, {
1374
1529
  key: "getProductById",
1375
1530
  value: (function () {
1376
- var _getProductById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id) {
1531
+ var _getProductById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(id) {
1377
1532
  var product;
1378
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1379
- while (1) switch (_context13.prev = _context13.next) {
1533
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1534
+ while (1) switch (_context14.prev = _context14.next) {
1380
1535
  case 0:
1381
1536
  product = this.store.map.get(id);
1382
- return _context13.abrupt("return", product ? structuredClone(product) : undefined);
1537
+ return _context14.abrupt("return", product ? structuredClone(product) : undefined);
1383
1538
  case 2:
1384
1539
  case "end":
1385
- return _context13.stop();
1540
+ return _context14.stop();
1386
1541
  }
1387
- }, _callee13, this);
1542
+ }, _callee14, this);
1388
1543
  }));
1389
- function getProductById(_x17) {
1544
+ function getProductById(_x18) {
1390
1545
  return _getProductById.apply(this, arguments);
1391
1546
  }
1392
1547
  return getProductById;
@@ -1399,10 +1554,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1399
1554
  }, {
1400
1555
  key: "removeProductsByIds",
1401
1556
  value: (function () {
1402
- var _removeProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(ids) {
1403
- var idSet, _iterator7, _step7, _id, _iterator8, _step8, id, errorMessage, _iterator9, _step9, _step9$value, dateKey, cachedProducts;
1404
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1405
- while (1) switch (_context14.prev = _context14.next) {
1557
+ var _removeProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(ids) {
1558
+ var idSet, _iterator8, _step8, _id, _iterator9, _step9, id, errorMessage, _iterator10, _step10, _step10$value, dateKey, cachedProducts;
1559
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1560
+ while (1) switch (_context15.prev = _context15.next) {
1406
1561
  case 0:
1407
1562
  idSet = new Set(ids);
1408
1563
  this.logInfo('removeProductsByIds', {
@@ -1412,71 +1567,71 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1412
1567
  this.store.list = this.store.list.filter(function (p) {
1413
1568
  return !idSet.has(p.id);
1414
1569
  });
1415
- _iterator7 = _createForOfIteratorHelper(ids);
1570
+ _iterator8 = _createForOfIteratorHelper(ids);
1416
1571
  try {
1417
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1418
- _id = _step7.value;
1572
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1573
+ _id = _step8.value;
1419
1574
  this.store.map.delete(_id);
1420
1575
  }
1421
1576
  } catch (err) {
1422
- _iterator7.e(err);
1577
+ _iterator8.e(err);
1423
1578
  } finally {
1424
- _iterator7.f();
1579
+ _iterator8.f();
1425
1580
  }
1426
1581
  if (!this.dbManager) {
1427
- _context14.next = 30;
1582
+ _context15.next = 30;
1428
1583
  break;
1429
1584
  }
1430
- _context14.prev = 6;
1431
- _iterator8 = _createForOfIteratorHelper(ids);
1432
- _context14.prev = 8;
1433
- _iterator8.s();
1585
+ _context15.prev = 6;
1586
+ _iterator9 = _createForOfIteratorHelper(ids);
1587
+ _context15.prev = 8;
1588
+ _iterator9.s();
1434
1589
  case 10:
1435
- if ((_step8 = _iterator8.n()).done) {
1436
- _context14.next = 16;
1590
+ if ((_step9 = _iterator9.n()).done) {
1591
+ _context15.next = 16;
1437
1592
  break;
1438
1593
  }
1439
- id = _step8.value;
1440
- _context14.next = 14;
1594
+ id = _step9.value;
1595
+ _context15.next = 14;
1441
1596
  return this.dbManager.delete(INDEXDB_STORE_NAME, id);
1442
1597
  case 14:
1443
- _context14.next = 10;
1598
+ _context15.next = 10;
1444
1599
  break;
1445
1600
  case 16:
1446
- _context14.next = 21;
1601
+ _context15.next = 21;
1447
1602
  break;
1448
1603
  case 18:
1449
- _context14.prev = 18;
1450
- _context14.t0 = _context14["catch"](8);
1451
- _iterator8.e(_context14.t0);
1604
+ _context15.prev = 18;
1605
+ _context15.t0 = _context15["catch"](8);
1606
+ _iterator9.e(_context15.t0);
1452
1607
  case 21:
1453
- _context14.prev = 21;
1454
- _iterator8.f();
1455
- return _context14.finish(21);
1608
+ _context15.prev = 21;
1609
+ _iterator9.f();
1610
+ return _context15.finish(21);
1456
1611
  case 24:
1457
- _context14.next = 30;
1612
+ _context15.next = 30;
1458
1613
  break;
1459
1614
  case 26:
1460
- _context14.prev = 26;
1461
- _context14.t1 = _context14["catch"](6);
1462
- errorMessage = _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1);
1615
+ _context15.prev = 26;
1616
+ _context15.t1 = _context15["catch"](6);
1617
+ errorMessage = _context15.t1 instanceof Error ? _context15.t1.message : String(_context15.t1);
1463
1618
  this.logError('removeProductsByIds: IndexDB 删除失败', {
1464
1619
  ids: ids,
1465
1620
  error: errorMessage
1466
1621
  });
1467
1622
  case 30:
1468
- _iterator9 = _createForOfIteratorHelper(this.productsPriceCache.entries());
1623
+ _iterator10 = _createForOfIteratorHelper(this.productsPriceCache.entries());
1469
1624
  try {
1470
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1471
- _step9$value = _slicedToArray(_step9.value, 2), dateKey = _step9$value[0], cachedProducts = _step9$value[1];
1625
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1626
+ _step10$value = _slicedToArray(_step10.value, 2), dateKey = _step10$value[0], cachedProducts = _step10$value[1];
1472
1627
  this.productsPriceCache.set(dateKey, cachedProducts.filter(function (p) {
1473
1628
  return !idSet.has(p.id);
1474
1629
  }));
1475
1630
  }
1476
1631
  } catch (err) {
1477
- _iterator9.e(err);
1632
+ _iterator10.e(err);
1478
1633
  } finally {
1479
- _iterator9.f();
1634
+ _iterator10.f();
1480
1635
  }
1481
1636
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1482
1637
  this.logInfo('removeProductsByIds 完成', {
@@ -1484,11 +1639,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1484
1639
  });
1485
1640
  case 34:
1486
1641
  case "end":
1487
- return _context14.stop();
1642
+ return _context15.stop();
1488
1643
  }
1489
- }, _callee14, this, [[6, 26], [8, 18, 21, 24]]);
1644
+ }, _callee15, this, [[6, 26], [8, 18, 21, 24]]);
1490
1645
  }));
1491
- function removeProductsByIds(_x18) {
1646
+ function removeProductsByIds(_x19) {
1492
1647
  return _removeProductsByIds.apply(this, arguments);
1493
1648
  }
1494
1649
  return removeProductsByIds;
@@ -1501,17 +1656,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1501
1656
  }, {
1502
1657
  key: "refreshProducts",
1503
1658
  value: (function () {
1504
- var _refreshProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1659
+ var _refreshProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1505
1660
  var tTotal, products;
1506
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1507
- while (1) switch (_context15.prev = _context15.next) {
1661
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1662
+ while (1) switch (_context16.prev = _context16.next) {
1508
1663
  case 0:
1509
1664
  tTotal = performance.now();
1510
1665
  this.logInfo('refreshProducts 开始');
1511
- _context15.next = 4;
1666
+ _context16.next = 4;
1512
1667
  return this.loadProductsByServer();
1513
1668
  case 4:
1514
- products = _context15.sent;
1669
+ products = _context16.sent;
1515
1670
  if (products && products.length > 0) {
1516
1671
  // 服务器返回的数据已经是全新的,无需 cloneDeep
1517
1672
  this.store.list = products;
@@ -1526,12 +1681,12 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1526
1681
  perfMark('refreshProducts', performance.now() - tTotal, {
1527
1682
  count: this.store.list.length
1528
1683
  });
1529
- return _context15.abrupt("return", this.store.list);
1684
+ return _context16.abrupt("return", this.store.list);
1530
1685
  case 8:
1531
1686
  case "end":
1532
- return _context15.stop();
1687
+ return _context16.stop();
1533
1688
  }
1534
- }, _callee15, this);
1689
+ }, _callee16, this);
1535
1690
  }));
1536
1691
  function refreshProducts() {
1537
1692
  return _refreshProducts.apply(this, arguments);
@@ -1545,10 +1700,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1545
1700
  }, {
1546
1701
  key: "clear",
1547
1702
  value: (function () {
1548
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1703
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1549
1704
  var errorMessage;
1550
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1551
- while (1) switch (_context16.prev = _context16.next) {
1705
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1706
+ while (1) switch (_context17.prev = _context17.next) {
1552
1707
  case 0:
1553
1708
  this.logInfo('开始清空缓存', {
1554
1709
  currentProductCount: this.store.list.length,
@@ -1559,22 +1714,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1559
1714
 
1560
1715
  // 同时清空 IndexDB 中的所有数据(包括商品和元数据)
1561
1716
  if (!this.dbManager) {
1562
- _context16.next = 16;
1717
+ _context17.next = 16;
1563
1718
  break;
1564
1719
  }
1565
- _context16.prev = 4;
1566
- _context16.next = 7;
1720
+ _context17.prev = 4;
1721
+ _context17.next = 7;
1567
1722
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1568
1723
  case 7:
1569
1724
  console.log('[Products] IndexDB 缓存已清空');
1570
1725
  this.logInfo('IndexDB 缓存已清空');
1571
- _context16.next = 16;
1726
+ _context17.next = 16;
1572
1727
  break;
1573
1728
  case 11:
1574
- _context16.prev = 11;
1575
- _context16.t0 = _context16["catch"](4);
1576
- errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1577
- console.error('[Products] 清空 IndexDB 缓存失败:', _context16.t0);
1729
+ _context17.prev = 11;
1730
+ _context17.t0 = _context17["catch"](4);
1731
+ errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1732
+ console.error('[Products] 清空 IndexDB 缓存失败:', _context17.t0);
1578
1733
  this.logError('清空 IndexDB 缓存失败', {
1579
1734
  error: errorMessage
1580
1735
  });
@@ -1583,9 +1738,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1583
1738
  this.logInfo('缓存清空完成');
1584
1739
  case 18:
1585
1740
  case "end":
1586
- return _context16.stop();
1741
+ return _context17.stop();
1587
1742
  }
1588
- }, _callee16, this, [[4, 11]]);
1743
+ }, _callee17, this, [[4, 11]]);
1589
1744
  }));
1590
1745
  function clear() {
1591
1746
  return _clear.apply(this, arguments);
@@ -1600,45 +1755,45 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1600
1755
  }, {
1601
1756
  key: "loadProductsFromIndexDB",
1602
1757
  value: (function () {
1603
- var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1758
+ var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1604
1759
  var _products$length, _products$length2, t0, products, errorMessage;
1605
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1606
- while (1) switch (_context17.prev = _context17.next) {
1760
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1761
+ while (1) switch (_context18.prev = _context18.next) {
1607
1762
  case 0:
1608
1763
  if (this.dbManager) {
1609
- _context17.next = 3;
1764
+ _context18.next = 3;
1610
1765
  break;
1611
1766
  }
1612
1767
  this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
1613
- return _context17.abrupt("return", []);
1768
+ return _context18.abrupt("return", []);
1614
1769
  case 3:
1615
- _context17.prev = 3;
1770
+ _context18.prev = 3;
1616
1771
  t0 = performance.now();
1617
- _context17.next = 7;
1772
+ _context18.next = 7;
1618
1773
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1619
1774
  case 7:
1620
- products = _context17.sent;
1775
+ products = _context18.sent;
1621
1776
  perfMark('loadProductsFromIndexDB', performance.now() - t0, {
1622
1777
  count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
1623
1778
  });
1624
1779
  this.logInfo('从 IndexDB 加载商品数据', {
1625
1780
  productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
1626
1781
  });
1627
- return _context17.abrupt("return", products || []);
1782
+ return _context18.abrupt("return", products || []);
1628
1783
  case 13:
1629
- _context17.prev = 13;
1630
- _context17.t0 = _context17["catch"](3);
1631
- errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1632
- console.error('[Products] 从 IndexDB 读取数据失败:', _context17.t0);
1784
+ _context18.prev = 13;
1785
+ _context18.t0 = _context18["catch"](3);
1786
+ errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1787
+ console.error('[Products] 从 IndexDB 读取数据失败:', _context18.t0);
1633
1788
  this.logError('从 IndexDB 读取数据失败', {
1634
1789
  error: errorMessage
1635
1790
  });
1636
- return _context17.abrupt("return", []);
1791
+ return _context18.abrupt("return", []);
1637
1792
  case 19:
1638
1793
  case "end":
1639
- return _context17.stop();
1794
+ return _context18.stop();
1640
1795
  }
1641
- }, _callee17, this, [[3, 13]]);
1796
+ }, _callee18, this, [[3, 13]]);
1642
1797
  }));
1643
1798
  function loadProductsFromIndexDB() {
1644
1799
  return _loadProductsFromIndexDB.apply(this, arguments);
@@ -1657,10 +1812,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1657
1812
  }, {
1658
1813
  key: "runInProductIndexDBSaveQueue",
1659
1814
  value: (function () {
1660
- var _runInProductIndexDBSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(task) {
1815
+ var _runInProductIndexDBSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(task) {
1661
1816
  var queuedTask;
1662
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1663
- while (1) switch (_context18.prev = _context18.next) {
1817
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1818
+ while (1) switch (_context19.prev = _context19.next) {
1664
1819
  case 0:
1665
1820
  queuedTask = this.productIndexDBSaveQueue.then(task, task);
1666
1821
  this.productIndexDBSaveQueue = queuedTask.then(function () {
@@ -1668,14 +1823,14 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1668
1823
  }, function () {
1669
1824
  return undefined;
1670
1825
  });
1671
- return _context18.abrupt("return", queuedTask);
1826
+ return _context19.abrupt("return", queuedTask);
1672
1827
  case 3:
1673
1828
  case "end":
1674
- return _context18.stop();
1829
+ return _context19.stop();
1675
1830
  }
1676
- }, _callee18, this);
1831
+ }, _callee19, this);
1677
1832
  }));
1678
- function runInProductIndexDBSaveQueue(_x19) {
1833
+ function runInProductIndexDBSaveQueue(_x20) {
1679
1834
  return _runInProductIndexDBSaveQueue.apply(this, arguments);
1680
1835
  }
1681
1836
  return runInProductIndexDBSaveQueue;
@@ -1690,61 +1845,61 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1690
1845
  }, {
1691
1846
  key: "replaceProductsSnapshotInIndexDB",
1692
1847
  value: (function () {
1693
- var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(products, source) {
1694
- var _this7 = this;
1848
+ var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(products, source) {
1849
+ var _this9 = this;
1695
1850
  var errorMessage;
1696
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1697
- while (1) switch (_context20.prev = _context20.next) {
1851
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1852
+ while (1) switch (_context21.prev = _context21.next) {
1698
1853
  case 0:
1699
1854
  if (this.dbManager) {
1700
- _context20.next = 3;
1855
+ _context21.next = 3;
1701
1856
  break;
1702
1857
  }
1703
1858
  this.logWarning('replaceProductsSnapshotInIndexDB: dbManager 不可用');
1704
- return _context20.abrupt("return");
1859
+ return _context21.abrupt("return");
1705
1860
  case 3:
1706
- _context20.prev = 3;
1707
- _context20.next = 6;
1708
- return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1861
+ _context21.prev = 3;
1862
+ _context21.next = 6;
1863
+ return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1709
1864
  var t0;
1710
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1711
- while (1) switch (_context19.prev = _context19.next) {
1865
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1866
+ while (1) switch (_context20.prev = _context20.next) {
1712
1867
  case 0:
1713
- _this7.logInfo('replaceProductsSnapshotInIndexDB 开始', {
1868
+ _this9.logInfo('replaceProductsSnapshotInIndexDB 开始', {
1714
1869
  source: source,
1715
1870
  productCount: products.length
1716
1871
  });
1717
1872
  t0 = performance.now();
1718
- _context19.next = 4;
1719
- return _this7.dbManager.clear(INDEXDB_STORE_NAME);
1873
+ _context20.next = 4;
1874
+ return _this9.dbManager.clear(INDEXDB_STORE_NAME);
1720
1875
  case 4:
1721
1876
  if (!(products.length > 0)) {
1722
- _context19.next = 7;
1877
+ _context20.next = 7;
1723
1878
  break;
1724
1879
  }
1725
- _context19.next = 7;
1726
- return _this7.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
1880
+ _context20.next = 7;
1881
+ return _this9.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
1727
1882
  case 7:
1728
1883
  perfMark('replaceProductsSnapshotInIndexDB', performance.now() - t0, {
1729
1884
  count: products.length
1730
1885
  });
1731
- _this7.logInfo('replaceProductsSnapshotInIndexDB 完成', {
1886
+ _this9.logInfo('replaceProductsSnapshotInIndexDB 完成', {
1732
1887
  source: source,
1733
1888
  productCount: products.length
1734
1889
  });
1735
1890
  case 9:
1736
1891
  case "end":
1737
- return _context19.stop();
1892
+ return _context20.stop();
1738
1893
  }
1739
- }, _callee19);
1894
+ }, _callee20);
1740
1895
  })));
1741
1896
  case 6:
1742
- _context20.next = 12;
1897
+ _context21.next = 12;
1743
1898
  break;
1744
1899
  case 8:
1745
- _context20.prev = 8;
1746
- _context20.t0 = _context20["catch"](3);
1747
- errorMessage = _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0);
1900
+ _context21.prev = 8;
1901
+ _context21.t0 = _context21["catch"](3);
1902
+ errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1748
1903
  this.logError('全量保存商品到 IndexDB 失败', {
1749
1904
  source: source,
1750
1905
  productCount: products.length,
@@ -1752,11 +1907,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1752
1907
  });
1753
1908
  case 12:
1754
1909
  case "end":
1755
- return _context20.stop();
1910
+ return _context21.stop();
1756
1911
  }
1757
- }, _callee20, this, [[3, 8]]);
1912
+ }, _callee21, this, [[3, 8]]);
1758
1913
  }));
1759
- function replaceProductsSnapshotInIndexDB(_x20, _x21) {
1914
+ function replaceProductsSnapshotInIndexDB(_x21, _x22) {
1760
1915
  return _replaceProductsSnapshotInIndexDB.apply(this, arguments);
1761
1916
  }
1762
1917
  return replaceProductsSnapshotInIndexDB;
@@ -1771,103 +1926,103 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1771
1926
  }, {
1772
1927
  key: "patchProductsInIndexDB",
1773
1928
  value: (function () {
1774
- var _patchProductsInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(products, source) {
1775
- var _this8 = this;
1929
+ var _patchProductsInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(products, source) {
1930
+ var _this10 = this;
1776
1931
  var mergeActions,
1777
1932
  validProducts,
1778
1933
  errorMessage,
1779
- _args22 = arguments;
1780
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1781
- while (1) switch (_context22.prev = _context22.next) {
1934
+ _args23 = arguments;
1935
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1936
+ while (1) switch (_context23.prev = _context23.next) {
1782
1937
  case 0:
1783
- mergeActions = _args22.length > 2 && _args22[2] !== undefined ? _args22[2] : {};
1938
+ mergeActions = _args23.length > 2 && _args23[2] !== undefined ? _args23[2] : {};
1784
1939
  if (!(!this.dbManager || products.length === 0)) {
1785
- _context22.next = 3;
1940
+ _context23.next = 3;
1786
1941
  break;
1787
1942
  }
1788
- return _context22.abrupt("return");
1943
+ return _context23.abrupt("return");
1789
1944
  case 3:
1790
1945
  validProducts = products.filter(function (p) {
1791
1946
  return (p === null || p === void 0 ? void 0 : p.id) !== undefined && (p === null || p === void 0 ? void 0 : p.id) !== null;
1792
1947
  });
1793
1948
  if (!(validProducts.length === 0)) {
1794
- _context22.next = 6;
1949
+ _context23.next = 6;
1795
1950
  break;
1796
1951
  }
1797
- return _context22.abrupt("return");
1952
+ return _context23.abrupt("return");
1798
1953
  case 6:
1799
- _context22.prev = 6;
1800
- _context22.next = 9;
1801
- return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1802
- var t0, _iterator10, _step10, product;
1803
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1804
- while (1) switch (_context21.prev = _context21.next) {
1954
+ _context23.prev = 6;
1955
+ _context23.next = 9;
1956
+ return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1957
+ var t0, _iterator11, _step11, product;
1958
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1959
+ while (1) switch (_context22.prev = _context22.next) {
1805
1960
  case 0:
1806
- _this8.logInfo('patchProductsInIndexDB 开始', {
1961
+ _this10.logInfo('patchProductsInIndexDB 开始', {
1807
1962
  source: source,
1808
1963
  count: validProducts.length
1809
1964
  });
1810
1965
  t0 = performance.now();
1811
- if (!(typeof _this8.dbManager.bulkUpdate === 'function')) {
1812
- _context21.next = 7;
1966
+ if (!(typeof _this10.dbManager.bulkUpdate === 'function')) {
1967
+ _context22.next = 7;
1813
1968
  break;
1814
1969
  }
1815
- _context21.next = 5;
1816
- return _this8.dbManager.bulkUpdate(INDEXDB_STORE_NAME, validProducts);
1970
+ _context22.next = 5;
1971
+ return _this10.dbManager.bulkUpdate(INDEXDB_STORE_NAME, validProducts);
1817
1972
  case 5:
1818
- _context21.next = 25;
1973
+ _context22.next = 25;
1819
1974
  break;
1820
1975
  case 7:
1821
- if (!(typeof _this8.dbManager.update === 'function')) {
1822
- _context21.next = 25;
1976
+ if (!(typeof _this10.dbManager.update === 'function')) {
1977
+ _context22.next = 25;
1823
1978
  break;
1824
1979
  }
1825
- _iterator10 = _createForOfIteratorHelper(validProducts);
1826
- _context21.prev = 9;
1827
- _iterator10.s();
1980
+ _iterator11 = _createForOfIteratorHelper(validProducts);
1981
+ _context22.prev = 9;
1982
+ _iterator11.s();
1828
1983
  case 11:
1829
- if ((_step10 = _iterator10.n()).done) {
1830
- _context21.next = 17;
1984
+ if ((_step11 = _iterator11.n()).done) {
1985
+ _context22.next = 17;
1831
1986
  break;
1832
1987
  }
1833
- product = _step10.value;
1834
- _context21.next = 15;
1835
- return _this8.dbManager.update(INDEXDB_STORE_NAME, product);
1988
+ product = _step11.value;
1989
+ _context22.next = 15;
1990
+ return _this10.dbManager.update(INDEXDB_STORE_NAME, product);
1836
1991
  case 15:
1837
- _context21.next = 11;
1992
+ _context22.next = 11;
1838
1993
  break;
1839
1994
  case 17:
1840
- _context21.next = 22;
1995
+ _context22.next = 22;
1841
1996
  break;
1842
1997
  case 19:
1843
- _context21.prev = 19;
1844
- _context21.t0 = _context21["catch"](9);
1845
- _iterator10.e(_context21.t0);
1998
+ _context22.prev = 19;
1999
+ _context22.t0 = _context22["catch"](9);
2000
+ _iterator11.e(_context22.t0);
1846
2001
  case 22:
1847
- _context21.prev = 22;
1848
- _iterator10.f();
1849
- return _context21.finish(22);
2002
+ _context22.prev = 22;
2003
+ _iterator11.f();
2004
+ return _context22.finish(22);
1850
2005
  case 25:
1851
2006
  perfMark('patchProductsInIndexDB', performance.now() - t0, {
1852
2007
  count: validProducts.length
1853
2008
  });
1854
- _this8.logInfo('patchProductsInIndexDB 完成', {
2009
+ _this10.logInfo('patchProductsInIndexDB 完成', {
1855
2010
  source: source,
1856
2011
  count: validProducts.length
1857
2012
  });
1858
2013
  case 27:
1859
2014
  case "end":
1860
- return _context21.stop();
2015
+ return _context22.stop();
1861
2016
  }
1862
- }, _callee21, null, [[9, 19, 22, 25]]);
2017
+ }, _callee22, null, [[9, 19, 22, 25]]);
1863
2018
  })));
1864
2019
  case 9:
1865
- _context22.next = 15;
2020
+ _context23.next = 15;
1866
2021
  break;
1867
2022
  case 11:
1868
- _context22.prev = 11;
1869
- _context22.t0 = _context22["catch"](6);
1870
- errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
2023
+ _context23.prev = 11;
2024
+ _context23.t0 = _context23["catch"](6);
2025
+ errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0);
1871
2026
  this.logError('增量保存商品到 IndexDB 失败', {
1872
2027
  source: source,
1873
2028
  error: errorMessage,
@@ -1875,11 +2030,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1875
2030
  });
1876
2031
  case 15:
1877
2032
  case "end":
1878
- return _context22.stop();
2033
+ return _context23.stop();
1879
2034
  }
1880
- }, _callee22, this, [[6, 11]]);
2035
+ }, _callee23, this, [[6, 11]]);
1881
2036
  }));
1882
- function patchProductsInIndexDB(_x22, _x23) {
2037
+ function patchProductsInIndexDB(_x23, _x24) {
1883
2038
  return _patchProductsInIndexDB.apply(this, arguments);
1884
2039
  }
1885
2040
  return patchProductsInIndexDB;
@@ -1895,17 +2050,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1895
2050
  value: function syncProductsMap() {
1896
2051
  var t0 = performance.now();
1897
2052
  this.store.map.clear();
1898
- var _iterator11 = _createForOfIteratorHelper(this.store.list),
1899
- _step11;
2053
+ var _iterator12 = _createForOfIteratorHelper(this.store.list),
2054
+ _step12;
1900
2055
  try {
1901
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1902
- var product = _step11.value;
2056
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
2057
+ var product = _step12.value;
1903
2058
  this.store.map.set(product.id, product);
1904
2059
  }
1905
2060
  } catch (err) {
1906
- _iterator11.e(err);
2061
+ _iterator12.e(err);
1907
2062
  } finally {
1908
- _iterator11.f();
2063
+ _iterator12.f();
1909
2064
  }
1910
2065
  perfMark('syncProductsMap', performance.now() - t0, {
1911
2066
  count: this.store.map.size
@@ -1919,26 +2074,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1919
2074
  }, {
1920
2075
  key: "preload",
1921
2076
  value: (function () {
1922
- var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2077
+ var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1923
2078
  var _products$length3;
1924
2079
  var tTotal, _cachedData$length, tIndexDB, cachedData, tSync, errorMessage, tServer, products, _tSync;
1925
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1926
- while (1) switch (_context23.prev = _context23.next) {
2080
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2081
+ while (1) switch (_context24.prev = _context24.next) {
1927
2082
  case 0:
1928
2083
  console.log('[Products] 开始预加载数据...');
1929
2084
  tTotal = performance.now();
1930
2085
  this.logInfo('开始预加载数据');
1931
- _context23.prev = 3;
2086
+ _context24.prev = 3;
1932
2087
  tIndexDB = performance.now();
1933
- _context23.next = 7;
2088
+ _context24.next = 7;
1934
2089
  return this.loadProductsFromIndexDB();
1935
2090
  case 7:
1936
- cachedData = _context23.sent;
2091
+ cachedData = _context24.sent;
1937
2092
  perfMark('preload.loadFromIndexDB', performance.now() - tIndexDB, {
1938
2093
  count: (_cachedData$length = cachedData === null || cachedData === void 0 ? void 0 : cachedData.length) !== null && _cachedData$length !== void 0 ? _cachedData$length : 0
1939
2094
  });
1940
2095
  if (!(cachedData && cachedData.length > 0)) {
1941
- _context23.next = 20;
2096
+ _context24.next = 20;
1942
2097
  break;
1943
2098
  }
1944
2099
  console.log("[Products] \u4ECE IndexDB \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u4E2A\u5546\u54C1"));
@@ -1960,26 +2115,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1960
2115
  source: 'IndexDB'
1961
2116
  });
1962
2117
  this.lastPreloadCompletedAtMs = Date.now();
1963
- return _context23.abrupt("return");
2118
+ return _context24.abrupt("return");
1964
2119
  case 20:
1965
2120
  console.log('[Products] IndexDB 中没有缓存数据,从服务器加载...');
1966
2121
  this.logInfo('IndexDB 中没有缓存数据,准备从服务器加载');
1967
- _context23.next = 29;
2122
+ _context24.next = 29;
1968
2123
  break;
1969
2124
  case 24:
1970
- _context23.prev = 24;
1971
- _context23.t0 = _context23["catch"](3);
1972
- errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0);
1973
- console.warn('[Products] 从 IndexDB 加载数据失败:', _context23.t0);
2125
+ _context24.prev = 24;
2126
+ _context24.t0 = _context24["catch"](3);
2127
+ errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
2128
+ console.warn('[Products] 从 IndexDB 加载数据失败:', _context24.t0);
1974
2129
  this.logWarning('从 IndexDB 加载数据失败,准备从服务器加载', {
1975
2130
  error: errorMessage
1976
2131
  });
1977
2132
  case 29:
1978
2133
  tServer = performance.now();
1979
- _context23.next = 32;
2134
+ _context24.next = 32;
1980
2135
  return this.loadProductsByServer();
1981
2136
  case 32:
1982
- products = _context23.sent;
2137
+ products = _context24.sent;
1983
2138
  perfMark('preload.loadFromServer', performance.now() - tServer, {
1984
2139
  count: (_products$length3 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length3 !== void 0 ? _products$length3 : 0
1985
2140
  });
@@ -2012,9 +2167,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2012
2167
  }
2013
2168
  case 35:
2014
2169
  case "end":
2015
- return _context23.stop();
2170
+ return _context24.stop();
2016
2171
  }
2017
- }, _callee23, this, [[3, 24]]);
2172
+ }, _callee24, this, [[3, 24]]);
2018
2173
  }));
2019
2174
  function preload() {
2020
2175
  return _preload.apply(this, arguments);
@@ -2049,7 +2204,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2049
2204
  }, {
2050
2205
  key: "setupProductSync",
2051
2206
  value: function setupProductSync() {
2052
- var _this9 = this;
2207
+ var _this11 = this;
2053
2208
  if (!this.productDataSource) {
2054
2209
  this.logWarning('setupProductSync: ProductDataSource 不可用,跳过同步初始化');
2055
2210
  return;
@@ -2059,20 +2214,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2059
2214
  var data = (message === null || message === void 0 ? void 0 : message.data) || message;
2060
2215
  if (!data) return;
2061
2216
  console.log("[ProductsModule] \u6536\u5230\u540C\u6B65\u6D88\u606F [".concat(channelKey, "]:"), data);
2062
- _this9.logInfo('收到同步消息', {
2217
+ _this11.logInfo('收到同步消息', {
2063
2218
  channelKey: channelKey,
2064
2219
  action: data.action,
2065
2220
  id: data.id,
2066
2221
  action_filed: data.action_filed
2067
2222
  });
2068
- _this9.pendingSyncMessages.push(_objectSpread(_objectSpread({}, data), {}, {
2223
+ _this11.pendingSyncMessages.push(_objectSpread(_objectSpread({}, data), {}, {
2069
2224
  _channelKey: channelKey
2070
2225
  }));
2071
- if (_this9.syncTimer) {
2072
- clearTimeout(_this9.syncTimer);
2226
+ if (_this11.syncTimer) {
2227
+ clearTimeout(_this11.syncTimer);
2073
2228
  }
2074
- _this9.syncTimer = setTimeout(function () {
2075
- _this9.processProductSyncMessages();
2229
+ _this11.syncTimer = setTimeout(function () {
2230
+ _this11.processProductSyncMessages();
2076
2231
  }, PRODUCT_SYNC_DEBOUNCE_MS);
2077
2232
  };
2078
2233
  };
@@ -2090,7 +2245,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2090
2245
  }
2091
2246
  }
2092
2247
  }).catch(function (err) {
2093
- _this9.logError('setupProductSync: DataSource run 出错', {
2248
+ _this11.logError('setupProductSync: DataSource run 出错', {
2094
2249
  error: err instanceof Error ? err.message : String(err)
2095
2250
  });
2096
2251
  });
@@ -2118,18 +2273,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2118
2273
  }, {
2119
2274
  key: "processProductSyncMessages",
2120
2275
  value: (function () {
2121
- var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2122
- var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator12, _step12, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, patchProductMap, patchMergeActions, storeMutated, bodyResult, _iterator13, _step13, product, freshProducts, mergeResult, _iterator14, _step14, _product, patchProducts, allChangedIds, hasChanges, errorMessage;
2123
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2124
- while (1) switch (_context24.prev = _context24.next) {
2276
+ var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2277
+ var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator13, _step13, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, _msg$product_ids, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, patchProductMap, patchMergeActions, storeMutated, bodyResult, _iterator14, _step14, product, freshProducts, mergeResult, _iterator15, _step15, _product, patchProducts, allChangedIds, hasChanges, errorMessage;
2278
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2279
+ while (1) switch (_context25.prev = _context25.next) {
2125
2280
  case 0:
2126
2281
  messages = _toConsumableArray(this.pendingSyncMessages);
2127
2282
  this.pendingSyncMessages = [];
2128
2283
  if (!(messages.length === 0)) {
2129
- _context24.next = 4;
2284
+ _context25.next = 4;
2130
2285
  break;
2131
2286
  }
2132
- return _context24.abrupt("return");
2287
+ return _context25.abrupt("return");
2133
2288
  case 4:
2134
2289
  this.logInfo('processProductSyncMessages: 开始处理', {
2135
2290
  count: messages.length
@@ -2139,18 +2294,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2139
2294
  sseRefreshIds = [];
2140
2295
  priceRefreshIds = [];
2141
2296
  shouldClearPriceCache = false;
2142
- _iterator12 = _createForOfIteratorHelper(messages);
2143
- _context24.prev = 11;
2144
- _iterator12.s();
2297
+ _iterator13 = _createForOfIteratorHelper(messages);
2298
+ _context25.prev = 11;
2299
+ _iterator13.s();
2145
2300
  case 13:
2146
- if ((_step12 = _iterator12.n()).done) {
2147
- _context24.next = 36;
2301
+ if ((_step13 = _iterator13.n()).done) {
2302
+ _context25.next = 36;
2148
2303
  break;
2149
2304
  }
2150
- msg = _step12.value;
2305
+ msg = _step13.value;
2151
2306
  channelKey = msg._channelKey || msg.module || 'product';
2152
2307
  if (!(channelKey === 'product')) {
2153
- _context24.next = 33;
2308
+ _context25.next = 33;
2154
2309
  break;
2155
2310
  }
2156
2311
  if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
@@ -2158,14 +2313,14 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2158
2313
  }
2159
2314
  // 1. 删除场景:operation === 'delete' 或 action === 'delete'
2160
2315
  if (!(msg.operation === 'delete' || msg.action === 'delete')) {
2161
- _context24.next = 21;
2316
+ _context25.next = 21;
2162
2317
  break;
2163
2318
  }
2164
2319
  if ((_msg$ids = msg.ids) !== null && _msg$ids !== void 0 && _msg$ids.length) deleteIds.push.apply(deleteIds, _toConsumableArray(msg.ids));else if (msg.id) deleteIds.push(msg.id);
2165
- return _context24.abrupt("continue", 34);
2320
+ return _context25.abrupt("continue", 34);
2166
2321
  case 21:
2167
2322
  if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
2168
- _context24.next = 26;
2323
+ _context25.next = 26;
2169
2324
  break;
2170
2325
  }
2171
2326
  ids = msg.ids || (msg.id ? [msg.id] : []);
@@ -2174,15 +2329,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2174
2329
  bodyId = msg.body.id;
2175
2330
  if (bodyId) bodyUpdates.set(bodyId, msg.body);
2176
2331
  }
2177
- return _context24.abrupt("continue", 34);
2332
+ return _context25.abrupt("continue", 34);
2178
2333
  case 26:
2179
2334
  if (!msg.body) {
2180
- _context24.next = 30;
2335
+ _context25.next = 30;
2181
2336
  break;
2182
2337
  }
2183
2338
  _bodyId = msg.body.id || msg.id;
2184
2339
  if (_bodyId) bodyUpdates.set(_bodyId, msg.body);
2185
- return _context24.abrupt("continue", 34);
2340
+ return _context25.abrupt("continue", 34);
2186
2341
  case 30:
2187
2342
  // 4. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
2188
2343
  if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
@@ -2190,7 +2345,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2190
2345
  } else if (msg.id) {
2191
2346
  sseRefreshIds.push(msg.id);
2192
2347
  }
2193
- _context24.next = 34;
2348
+ _context25.next = 34;
2194
2349
  break;
2195
2350
  case 33:
2196
2351
  if (channelKey === 'product_quotation') {
@@ -2203,30 +2358,34 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2203
2358
  if ((_msg$relation_product3 = msg.relation_product_ids) !== null && _msg$relation_product3 !== void 0 && _msg$relation_product3.length) {
2204
2359
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
2205
2360
  }
2361
+ } else if (['product_data_variant'].includes(channelKey)) {
2362
+ if ((_msg$product_ids = msg.product_ids) !== null && _msg$product_ids !== void 0 && _msg$product_ids.length) {
2363
+ sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.product_ids));
2364
+ }
2206
2365
  }
2207
2366
  case 34:
2208
- _context24.next = 13;
2367
+ _context25.next = 13;
2209
2368
  break;
2210
2369
  case 36:
2211
- _context24.next = 41;
2370
+ _context25.next = 41;
2212
2371
  break;
2213
2372
  case 38:
2214
- _context24.prev = 38;
2215
- _context24.t0 = _context24["catch"](11);
2216
- _iterator12.e(_context24.t0);
2373
+ _context25.prev = 38;
2374
+ _context25.t0 = _context25["catch"](11);
2375
+ _iterator13.e(_context25.t0);
2217
2376
  case 41:
2218
- _context24.prev = 41;
2219
- _iterator12.f();
2220
- return _context24.finish(41);
2377
+ _context25.prev = 41;
2378
+ _iterator13.f();
2379
+ return _context25.finish(41);
2221
2380
  case 44:
2222
2381
  uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
2223
2382
  uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds));
2224
2383
  uniquePriceIds = _toConsumableArray(new Set(priceRefreshIds)); // 1. 处理删除
2225
2384
  if (!(uniqueDeleteIds.length > 0)) {
2226
- _context24.next = 50;
2385
+ _context25.next = 50;
2227
2386
  break;
2228
2387
  }
2229
- _context24.next = 50;
2388
+ _context25.next = 50;
2230
2389
  return this.removeProductsByIds(uniqueDeleteIds);
2231
2390
  case 50:
2232
2391
  /** 本批次待 patch 的商品(按 id 去重,SSE 覆盖 body) */
@@ -2234,62 +2393,62 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2234
2393
  patchMergeActions = {};
2235
2394
  storeMutated = uniqueDeleteIds.length > 0; // 2. 处理 body 直接覆盖(仅内存,IndexDB 批次末统一 patch)
2236
2395
  if (!(bodyUpdates.size > 0)) {
2237
- _context24.next = 60;
2396
+ _context25.next = 60;
2238
2397
  break;
2239
2398
  }
2240
- _context24.next = 56;
2399
+ _context25.next = 56;
2241
2400
  return this.applyBodyUpdatesToStore(bodyUpdates, {
2242
2401
  skipIndexDB: true,
2243
2402
  skipEmit: true
2244
2403
  });
2245
2404
  case 56:
2246
- bodyResult = _context24.sent;
2247
- _iterator13 = _createForOfIteratorHelper(bodyResult.changedProducts);
2405
+ bodyResult = _context25.sent;
2406
+ _iterator14 = _createForOfIteratorHelper(bodyResult.changedProducts);
2248
2407
  try {
2249
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2250
- product = _step13.value;
2408
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
2409
+ product = _step14.value;
2251
2410
  patchProductMap.set(product.id, product);
2252
2411
  patchMergeActions[product.id] = bodyResult.mergeActions[product.id];
2253
2412
  }
2254
2413
  } catch (err) {
2255
- _iterator13.e(err);
2414
+ _iterator14.e(err);
2256
2415
  } finally {
2257
- _iterator13.f();
2416
+ _iterator14.f();
2258
2417
  }
2259
2418
  storeMutated = true;
2260
2419
  case 60:
2261
2420
  // 3. 处理 SSE 增量拉取(仅内存,IndexDB 批次末统一 patch)
2262
2421
  freshProducts = [];
2263
2422
  if (!(uniqueSSEIds.length > 0)) {
2264
- _context24.next = 73;
2423
+ _context25.next = 73;
2265
2424
  break;
2266
2425
  }
2267
- _context24.next = 64;
2426
+ _context25.next = 64;
2268
2427
  return this.fetchProductsBySSE(uniqueSSEIds);
2269
2428
  case 64:
2270
- freshProducts = _context24.sent;
2429
+ freshProducts = _context25.sent;
2271
2430
  if (!(freshProducts.length > 0)) {
2272
- _context24.next = 72;
2431
+ _context25.next = 72;
2273
2432
  break;
2274
2433
  }
2275
- _context24.next = 68;
2434
+ _context25.next = 68;
2276
2435
  return this.mergeProductsToStore(freshProducts, {
2277
2436
  skipIndexDB: true,
2278
2437
  skipEmit: true
2279
2438
  });
2280
2439
  case 68:
2281
- mergeResult = _context24.sent;
2282
- _iterator14 = _createForOfIteratorHelper(mergeResult.changedProducts);
2440
+ mergeResult = _context25.sent;
2441
+ _iterator15 = _createForOfIteratorHelper(mergeResult.changedProducts);
2283
2442
  try {
2284
- for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
2285
- _product = _step14.value;
2443
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
2444
+ _product = _step15.value;
2286
2445
  patchProductMap.set(_product.id, _product);
2287
2446
  patchMergeActions[_product.id] = mergeResult.mergeActions[_product.id];
2288
2447
  }
2289
2448
  } catch (err) {
2290
- _iterator14.e(err);
2449
+ _iterator15.e(err);
2291
2450
  } finally {
2292
- _iterator14.f();
2451
+ _iterator15.f();
2293
2452
  }
2294
2453
  storeMutated = true;
2295
2454
  case 72:
@@ -2300,10 +2459,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2300
2459
  case 73:
2301
2460
  patchProducts = _toConsumableArray(patchProductMap.values());
2302
2461
  if (!(patchProducts.length > 0)) {
2303
- _context24.next = 77;
2462
+ _context25.next = 77;
2304
2463
  break;
2305
2464
  }
2306
- _context24.next = 77;
2465
+ _context25.next = 77;
2307
2466
  return this.patchProductsInIndexDB(patchProducts, 'pubsub.processProductSyncMessages', patchMergeActions);
2308
2467
  case 77:
2309
2468
  if (storeMutated) {
@@ -2322,41 +2481,41 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2322
2481
  });
2323
2482
  hasChanges = uniqueDeleteIds.length > 0 || allChangedIds.length > 0 || shouldClearPriceCache;
2324
2483
  if (hasChanges) {
2325
- _context24.next = 84;
2484
+ _context25.next = 84;
2326
2485
  break;
2327
2486
  }
2328
2487
  this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
2329
- return _context24.abrupt("return");
2488
+ return _context25.abrupt("return");
2330
2489
  case 84:
2331
2490
  if (!shouldClearPriceCache) {
2332
- _context24.next = 95;
2491
+ _context25.next = 95;
2333
2492
  break;
2334
2493
  }
2335
- _context24.prev = 85;
2336
- _context24.next = 88;
2494
+ _context25.prev = 85;
2495
+ _context25.next = 88;
2337
2496
  return this.refreshQuotationPriceBridge();
2338
2497
  case 88:
2339
- _context24.next = 94;
2498
+ _context25.next = 94;
2340
2499
  break;
2341
2500
  case 90:
2342
- _context24.prev = 90;
2343
- _context24.t1 = _context24["catch"](85);
2344
- errorMessage = _context24.t1 instanceof Error ? _context24.t1.message : String(_context24.t1);
2501
+ _context25.prev = 90;
2502
+ _context25.t1 = _context25["catch"](85);
2503
+ errorMessage = _context25.t1 instanceof Error ? _context25.t1.message : String(_context25.t1);
2345
2504
  this.logError('报价单桥接刷新失败,将继续清理价格缓存', {
2346
2505
  error: errorMessage
2347
2506
  });
2348
2507
  case 94:
2349
2508
  this.clearPriceCache();
2350
2509
  case 95:
2351
- _context24.next = 97;
2510
+ _context25.next = 97;
2352
2511
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, {
2353
2512
  changedIds: allChangedIds
2354
2513
  });
2355
2514
  case 97:
2356
2515
  case "end":
2357
- return _context24.stop();
2516
+ return _context25.stop();
2358
2517
  }
2359
- }, _callee24, this, [[11, 38, 41, 44], [85, 90]]);
2518
+ }, _callee25, this, [[11, 38, 41, 44], [85, 90]]);
2360
2519
  }));
2361
2520
  function processProductSyncMessages() {
2362
2521
  return _processProductSyncMessages.apply(this, arguments);
@@ -2371,25 +2530,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2371
2530
  }, {
2372
2531
  key: "fetchProductsBySSE",
2373
2532
  value: (function () {
2374
- var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(ids) {
2533
+ var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(ids) {
2375
2534
  var t0, productList, list, errorMessage;
2376
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2377
- while (1) switch (_context25.prev = _context25.next) {
2535
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2536
+ while (1) switch (_context26.prev = _context26.next) {
2378
2537
  case 0:
2379
2538
  if (this.productDataSource) {
2380
- _context25.next = 3;
2539
+ _context26.next = 3;
2381
2540
  break;
2382
2541
  }
2383
2542
  this.logWarning('fetchProductsBySSE: ProductDataSource 不可用');
2384
- return _context25.abrupt("return", []);
2543
+ return _context26.abrupt("return", []);
2385
2544
  case 3:
2386
2545
  this.logInfo('fetchProductsBySSE: 开始', {
2387
2546
  ids: ids,
2388
2547
  count: ids.length
2389
2548
  });
2390
2549
  t0 = performance.now();
2391
- _context25.prev = 5;
2392
- _context25.next = 8;
2550
+ _context26.prev = 5;
2551
+ _context26.next = 8;
2393
2552
  return this.productDataSource.run({
2394
2553
  sse: {
2395
2554
  query: {
@@ -2399,7 +2558,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2399
2558
  }
2400
2559
  });
2401
2560
  case 8:
2402
- productList = _context25.sent;
2561
+ productList = _context26.sent;
2403
2562
  list = productList || [];
2404
2563
  perfMark('fetchProductsBySSE', performance.now() - t0, {
2405
2564
  count: list.length
@@ -2409,23 +2568,23 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2409
2568
  receivedCount: list.length,
2410
2569
  duration: "".concat(Math.round(performance.now() - t0), "ms")
2411
2570
  });
2412
- return _context25.abrupt("return", list);
2571
+ return _context26.abrupt("return", list);
2413
2572
  case 15:
2414
- _context25.prev = 15;
2415
- _context25.t0 = _context25["catch"](5);
2416
- errorMessage = _context25.t0 instanceof Error ? _context25.t0.message : String(_context25.t0);
2573
+ _context26.prev = 15;
2574
+ _context26.t0 = _context26["catch"](5);
2575
+ errorMessage = _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0);
2417
2576
  this.logError('fetchProductsBySSE: 失败', {
2418
2577
  ids: ids,
2419
2578
  error: errorMessage
2420
2579
  });
2421
- return _context25.abrupt("return", []);
2580
+ return _context26.abrupt("return", []);
2422
2581
  case 20:
2423
2582
  case "end":
2424
- return _context25.stop();
2583
+ return _context26.stop();
2425
2584
  }
2426
- }, _callee25, this, [[5, 15]]);
2585
+ }, _callee26, this, [[5, 15]]);
2427
2586
  }));
2428
- function fetchProductsBySSE(_x24) {
2587
+ function fetchProductsBySSE(_x25) {
2429
2588
  return _fetchProductsBySSE.apply(this, arguments);
2430
2589
  }
2431
2590
  return fetchProductsBySSE;
@@ -2441,10 +2600,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2441
2600
  }, {
2442
2601
  key: "applyBodyUpdatesToStore",
2443
2602
  value: (function () {
2444
- var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(bodyUpdates, options) {
2445
- var changedProductIds, updatedCount, newCount, appliedIds, mergeActions, changedProducts, _iterator15, _step15, _step15$value, id, body;
2446
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2447
- while (1) switch (_context26.prev = _context26.next) {
2603
+ var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(bodyUpdates, options) {
2604
+ var changedProductIds, updatedCount, newCount, appliedIds, mergeActions, changedProducts, _iterator16, _step16, _step16$value, id, body;
2605
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2606
+ while (1) switch (_context27.prev = _context27.next) {
2448
2607
  case 0:
2449
2608
  changedProductIds = _toConsumableArray(bodyUpdates.keys());
2450
2609
  this.logInfo('applyBodyUpdatesToStore: 开始', {
@@ -2466,10 +2625,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2466
2625
  }
2467
2626
  return p;
2468
2627
  });
2469
- _iterator15 = _createForOfIteratorHelper(bodyUpdates);
2628
+ _iterator16 = _createForOfIteratorHelper(bodyUpdates);
2470
2629
  try {
2471
- for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
2472
- _step15$value = _slicedToArray(_step15.value, 2), id = _step15$value[0], body = _step15$value[1];
2630
+ for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
2631
+ _step16$value = _slicedToArray(_step16.value, 2), id = _step16$value[0], body = _step16$value[1];
2473
2632
  if (!appliedIds.has(id)) {
2474
2633
  this.store.list.push(body);
2475
2634
  newCount++;
@@ -2478,16 +2637,16 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2478
2637
  }
2479
2638
  }
2480
2639
  } catch (err) {
2481
- _iterator15.e(err);
2640
+ _iterator16.e(err);
2482
2641
  } finally {
2483
- _iterator15.f();
2642
+ _iterator16.f();
2484
2643
  }
2485
2644
  this.syncProductsMap();
2486
2645
  if (options !== null && options !== void 0 && options.skipIndexDB) {
2487
- _context26.next = 14;
2646
+ _context27.next = 14;
2488
2647
  break;
2489
2648
  }
2490
- _context26.next = 14;
2649
+ _context27.next = 14;
2491
2650
  return this.patchProductsInIndexDB(changedProducts, 'pubsub.bodyUpdate', mergeActions);
2492
2651
  case 14:
2493
2652
  if (!(options !== null && options !== void 0 && options.skipEmit)) {
@@ -2498,7 +2657,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2498
2657
  newCount: newCount,
2499
2658
  totalCount: this.store.list.length
2500
2659
  });
2501
- return _context26.abrupt("return", {
2660
+ return _context27.abrupt("return", {
2502
2661
  changedProducts: changedProducts,
2503
2662
  mergeActions: mergeActions,
2504
2663
  updatedCount: updatedCount,
@@ -2506,11 +2665,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2506
2665
  });
2507
2666
  case 17:
2508
2667
  case "end":
2509
- return _context26.stop();
2668
+ return _context27.stop();
2510
2669
  }
2511
- }, _callee26, this);
2670
+ }, _callee27, this);
2512
2671
  }));
2513
- function applyBodyUpdatesToStore(_x25, _x26) {
2672
+ function applyBodyUpdatesToStore(_x26, _x27) {
2514
2673
  return _applyBodyUpdatesToStore.apply(this, arguments);
2515
2674
  }
2516
2675
  return applyBodyUpdatesToStore;
@@ -2526,22 +2685,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2526
2685
  }, {
2527
2686
  key: "mergeProductsToStore",
2528
2687
  value: (function () {
2529
- var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(freshProducts, options) {
2530
- var freshMap, _iterator16, _step16, p, mergeActions, changedProducts, updatedList, newCount, _iterator17, _step17, _p2, updatedCount, changedProductIds;
2531
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2532
- while (1) switch (_context27.prev = _context27.next) {
2688
+ var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(freshProducts, options) {
2689
+ var freshMap, _iterator17, _step17, p, mergeActions, changedProducts, updatedList, newCount, _iterator18, _step18, _p2, updatedCount, changedProductIds;
2690
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2691
+ while (1) switch (_context28.prev = _context28.next) {
2533
2692
  case 0:
2534
2693
  freshMap = new Map();
2535
- _iterator16 = _createForOfIteratorHelper(freshProducts);
2694
+ _iterator17 = _createForOfIteratorHelper(freshProducts);
2536
2695
  try {
2537
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
2538
- p = _step16.value;
2696
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
2697
+ p = _step17.value;
2539
2698
  freshMap.set(p.id, p);
2540
2699
  }
2541
2700
  } catch (err) {
2542
- _iterator16.e(err);
2701
+ _iterator17.e(err);
2543
2702
  } finally {
2544
- _iterator16.f();
2703
+ _iterator17.f();
2545
2704
  }
2546
2705
  mergeActions = {};
2547
2706
  changedProducts = [];
@@ -2556,18 +2715,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2556
2715
  return p;
2557
2716
  }); // freshMap 中剩余的是新商品(create 场景)
2558
2717
  newCount = freshMap.size;
2559
- _iterator17 = _createForOfIteratorHelper(freshMap.values());
2718
+ _iterator18 = _createForOfIteratorHelper(freshMap.values());
2560
2719
  try {
2561
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
2562
- _p2 = _step17.value;
2720
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
2721
+ _p2 = _step18.value;
2563
2722
  updatedList.push(_p2);
2564
2723
  mergeActions[_p2.id] = 'insert';
2565
2724
  changedProducts.push(_p2);
2566
2725
  }
2567
2726
  } catch (err) {
2568
- _iterator17.e(err);
2727
+ _iterator18.e(err);
2569
2728
  } finally {
2570
- _iterator17.f();
2729
+ _iterator18.f();
2571
2730
  }
2572
2731
  updatedCount = freshProducts.length - newCount;
2573
2732
  changedProductIds = freshProducts.map(function (p) {
@@ -2576,10 +2735,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2576
2735
  this.store.list = updatedList;
2577
2736
  this.syncProductsMap();
2578
2737
  if (options !== null && options !== void 0 && options.skipIndexDB) {
2579
- _context27.next = 16;
2738
+ _context28.next = 16;
2580
2739
  break;
2581
2740
  }
2582
- _context27.next = 16;
2741
+ _context28.next = 16;
2583
2742
  return this.patchProductsInIndexDB(changedProducts, 'pubsub.mergeProductsToStore', mergeActions);
2584
2743
  case 16:
2585
2744
  if (!(options !== null && options !== void 0 && options.skipEmit)) {
@@ -2590,7 +2749,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2590
2749
  newCount: newCount,
2591
2750
  totalCount: this.store.list.length
2592
2751
  });
2593
- return _context27.abrupt("return", {
2752
+ return _context28.abrupt("return", {
2594
2753
  changedProducts: changedProducts,
2595
2754
  mergeActions: mergeActions,
2596
2755
  updatedCount: updatedCount,
@@ -2598,11 +2757,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2598
2757
  });
2599
2758
  case 19:
2600
2759
  case "end":
2601
- return _context27.stop();
2760
+ return _context28.stop();
2602
2761
  }
2603
- }, _callee27, this);
2762
+ }, _callee28, this);
2604
2763
  }));
2605
- function mergeProductsToStore(_x27, _x28) {
2764
+ function mergeProductsToStore(_x28, _x29) {
2606
2765
  return _mergeProductsToStore.apply(this, arguments);
2607
2766
  }
2608
2767
  return mergeProductsToStore;
@@ -2616,43 +2775,43 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2616
2775
  }, {
2617
2776
  key: "silentRefresh",
2618
2777
  value: (function () {
2619
- var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2778
+ var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2620
2779
  var t0, now, elapsedSincePreload, elapsedSinceFullFetch, products, errorMessage;
2621
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2622
- while (1) switch (_context28.prev = _context28.next) {
2780
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2781
+ while (1) switch (_context29.prev = _context29.next) {
2623
2782
  case 0:
2624
2783
  t0 = performance.now();
2625
2784
  now = Date.now();
2626
2785
  elapsedSincePreload = now - this.lastPreloadCompletedAtMs;
2627
2786
  elapsedSinceFullFetch = now - this.lastServerFullFetchAtMs;
2628
2787
  if (!(this.lastPreloadCompletedAtMs > 0 && elapsedSincePreload < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS)) {
2629
- _context28.next = 6;
2788
+ _context29.next = 6;
2630
2789
  break;
2631
2790
  }
2632
- return _context28.abrupt("return", this.store.list);
2791
+ return _context29.abrupt("return", this.store.list);
2633
2792
  case 6:
2634
2793
  this.logInfo('silentRefresh 开始');
2635
- _context28.prev = 7;
2636
- _context28.next = 10;
2794
+ _context29.prev = 7;
2795
+ _context29.next = 10;
2637
2796
  return this.loadProductsByServer();
2638
2797
  case 10:
2639
- products = _context28.sent;
2798
+ products = _context29.sent;
2640
2799
  if (!(products && products.length > 0)) {
2641
- _context28.next = 21;
2800
+ _context29.next = 21;
2642
2801
  break;
2643
2802
  }
2644
2803
  this.store.list = products;
2645
2804
  this.syncProductsMap();
2646
2805
  this.clearPriceCache();
2647
2806
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
2648
- _context28.next = 18;
2807
+ _context29.next = 18;
2649
2808
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
2650
2809
  case 18:
2651
2810
  this.logInfo('silentRefresh 完成', {
2652
2811
  productCount: products.length,
2653
2812
  duration: "".concat(Math.round(performance.now() - t0), "ms")
2654
2813
  });
2655
- _context28.next = 22;
2814
+ _context29.next = 22;
2656
2815
  break;
2657
2816
  case 21:
2658
2817
  this.logWarning('silentRefresh: 服务器未返回数据');
@@ -2660,21 +2819,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2660
2819
  perfMark('silentRefresh', performance.now() - t0, {
2661
2820
  count: this.store.list.length
2662
2821
  });
2663
- return _context28.abrupt("return", this.store.list);
2822
+ return _context29.abrupt("return", this.store.list);
2664
2823
  case 26:
2665
- _context28.prev = 26;
2666
- _context28.t0 = _context28["catch"](7);
2667
- errorMessage = _context28.t0 instanceof Error ? _context28.t0.message : String(_context28.t0);
2824
+ _context29.prev = 26;
2825
+ _context29.t0 = _context29["catch"](7);
2826
+ errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
2668
2827
  this.logError('silentRefresh 失败', {
2669
2828
  duration: "".concat(Math.round(performance.now() - t0), "ms"),
2670
2829
  error: errorMessage
2671
2830
  });
2672
- return _context28.abrupt("return", this.store.list);
2831
+ return _context29.abrupt("return", this.store.list);
2673
2832
  case 31:
2674
2833
  case "end":
2675
- return _context28.stop();
2834
+ return _context29.stop();
2676
2835
  }
2677
- }, _callee28, this, [[7, 26]]);
2836
+ }, _callee29, this, [[7, 26]]);
2678
2837
  }));
2679
2838
  function silentRefresh() {
2680
2839
  return _silentRefresh.apply(this, arguments);