@pisell/pisellos 2.2.148 → 2.2.149

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 (247) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/strategy/adapter/index.d.ts +2 -0
  4. package/dist/model/strategy/adapter/index.js +3 -1
  5. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  6. package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
  7. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  8. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  9. package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  10. package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
  11. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  12. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  13. package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
  14. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  15. package/dist/modules/Cart/types.d.ts +2 -0
  16. package/dist/modules/Cart/utils/cartProduct.js +22 -1
  17. package/dist/modules/Cart/utils/changePrice.js +6 -0
  18. package/dist/modules/Date/index.d.ts +1 -1
  19. package/dist/modules/Date/index.js +16 -8
  20. package/dist/modules/Date/types.d.ts +3 -1
  21. package/dist/modules/OpenData/index.d.ts +24 -0
  22. package/dist/modules/OpenData/index.js +173 -0
  23. package/dist/modules/OpenData/types.d.ts +73 -0
  24. package/dist/modules/OpenData/types.js +1 -0
  25. package/dist/modules/OpenData/utils.d.ts +2 -0
  26. package/dist/modules/OpenData/utils.js +75 -0
  27. package/dist/modules/Order/index.d.ts +171 -1
  28. package/dist/modules/Order/index.js +2052 -112
  29. package/dist/modules/Order/types.d.ts +441 -20
  30. package/dist/modules/Order/types.js +23 -0
  31. package/dist/modules/Order/utils.d.ts +120 -0
  32. package/dist/modules/Order/utils.js +653 -2
  33. package/dist/modules/Product/utils.js +2 -2
  34. package/dist/modules/ProductList/index.js +2 -1
  35. package/dist/modules/Quotation/index.d.ts +8 -1
  36. package/dist/modules/Quotation/index.js +40 -10
  37. package/dist/modules/Quotation/types.d.ts +5 -0
  38. package/dist/modules/Rules/index.d.ts +3 -1
  39. package/dist/modules/Rules/index.js +136 -50
  40. package/dist/modules/Rules/types.d.ts +6 -0
  41. package/dist/modules/Rules/types.js +8 -0
  42. package/dist/modules/SalesSummary/index.d.ts +70 -0
  43. package/dist/modules/SalesSummary/index.js +175 -0
  44. package/dist/modules/SalesSummary/types.d.ts +64 -0
  45. package/dist/modules/SalesSummary/types.js +1 -0
  46. package/dist/modules/SalesSummary/utils.d.ts +34 -0
  47. package/dist/modules/SalesSummary/utils.js +488 -0
  48. package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
  49. package/dist/modules/ScanOrderLogger/index.js +161 -0
  50. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  51. package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
  52. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  53. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  54. package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
  55. package/dist/modules/ScanOrderLogger/types.js +1 -0
  56. package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
  57. package/dist/modules/Schedule/index.d.ts +4 -13
  58. package/dist/modules/Schedule/index.js +6 -23
  59. package/dist/modules/Schedule/utils.d.ts +1 -1
  60. package/dist/modules/Summary/index.d.ts +3 -0
  61. package/dist/modules/Summary/index.js +134 -15
  62. package/dist/modules/Summary/types.d.ts +7 -0
  63. package/dist/modules/Summary/utils.d.ts +104 -1
  64. package/dist/modules/Summary/utils.js +1116 -13
  65. package/dist/modules/index.d.ts +4 -0
  66. package/dist/modules/index.js +5 -1
  67. package/dist/server/index.d.ts +41 -4
  68. package/dist/server/index.js +900 -405
  69. package/dist/server/modules/order/index.d.ts +10 -2
  70. package/dist/server/modules/order/index.js +246 -193
  71. package/dist/server/modules/products/index.d.ts +26 -0
  72. package/dist/server/modules/products/index.js +618 -338
  73. package/dist/server/modules/products/types.d.ts +5 -1
  74. package/dist/solution/BaseSales/index.d.ts +175 -0
  75. package/dist/solution/BaseSales/index.js +1293 -0
  76. package/dist/solution/BaseSales/types.d.ts +305 -0
  77. package/dist/solution/BaseSales/types.js +38 -0
  78. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
  79. package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
  80. package/dist/solution/BaseSales/utils.d.ts +40 -0
  81. package/dist/solution/BaseSales/utils.js +222 -0
  82. package/dist/solution/BookingByStep/index.d.ts +14 -0
  83. package/dist/solution/BookingByStep/index.js +699 -212
  84. package/dist/solution/BookingByStep/types.d.ts +3 -1
  85. package/dist/solution/BookingByStep/types.js +5 -1
  86. package/dist/solution/BookingByStep/utils/capacity.js +1 -1
  87. package/dist/solution/BookingByStep/utils/resources.js +6 -1
  88. package/dist/solution/BookingTicket/index.d.ts +113 -15
  89. package/dist/solution/BookingTicket/index.js +534 -196
  90. package/dist/solution/BookingTicket/types.d.ts +69 -6
  91. package/dist/solution/BookingTicket/types.js +40 -9
  92. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
  93. package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
  94. package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
  95. package/dist/solution/BookingTicket/utils/cartView.js +84 -0
  96. package/dist/solution/Sales/index.d.ts +1 -0
  97. package/dist/solution/Sales/index.js +1 -0
  98. package/dist/solution/ScanOrder/index.d.ts +146 -0
  99. package/dist/solution/ScanOrder/index.js +3029 -0
  100. package/dist/solution/ScanOrder/types.d.ts +305 -0
  101. package/dist/solution/ScanOrder/types.js +35 -0
  102. package/dist/solution/ScanOrder/utils.d.ts +167 -0
  103. package/dist/solution/ScanOrder/utils.js +768 -0
  104. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  105. package/dist/solution/ShopDiscount/index.js +9 -5
  106. package/dist/solution/ShopDiscount/types.d.ts +4 -0
  107. package/dist/solution/VenueBooking/index.d.ts +197 -0
  108. package/dist/solution/VenueBooking/index.js +3411 -0
  109. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  110. package/dist/solution/VenueBooking/types.d.ts +153 -0
  111. package/dist/solution/VenueBooking/types.js +21 -0
  112. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  113. package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
  114. package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
  115. package/dist/solution/VenueBooking/utils/resource.js +130 -0
  116. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
  117. package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
  118. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  119. package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
  120. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  121. package/dist/solution/VenueBooking/utils.js +1 -0
  122. package/dist/solution/index.d.ts +3 -0
  123. package/dist/solution/index.js +4 -1
  124. package/lib/apis/picoding.d.ts +0 -0
  125. package/lib/apis/picoding.js +0 -0
  126. package/lib/model/strategy/adapter/index.d.ts +2 -0
  127. package/lib/model/strategy/adapter/index.js +6 -0
  128. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
  129. package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
  130. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  131. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  132. package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
  133. package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
  134. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  135. package/lib/model/strategy/adapter/itemRule/index.js +60 -0
  136. package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
  137. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  138. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  139. package/lib/modules/Cart/types.d.ts +2 -0
  140. package/lib/modules/Cart/utils/cartProduct.js +17 -1
  141. package/lib/modules/Cart/utils/changePrice.js +5 -0
  142. package/lib/modules/Date/index.d.ts +1 -1
  143. package/lib/modules/Date/index.js +7 -1
  144. package/lib/modules/Date/types.d.ts +3 -1
  145. package/lib/modules/OpenData/index.d.ts +24 -0
  146. package/lib/modules/OpenData/index.js +119 -0
  147. package/lib/modules/OpenData/types.d.ts +73 -0
  148. package/lib/modules/OpenData/types.js +17 -0
  149. package/lib/modules/OpenData/utils.d.ts +2 -0
  150. package/lib/modules/OpenData/utils.js +111 -0
  151. package/lib/modules/Order/index.d.ts +171 -1
  152. package/lib/modules/Order/index.js +1396 -5
  153. package/lib/modules/Order/types.d.ts +441 -20
  154. package/lib/modules/Order/types.js +1 -0
  155. package/lib/modules/Order/utils.d.ts +120 -0
  156. package/lib/modules/Order/utils.js +562 -2
  157. package/lib/modules/Product/utils.js +2 -2
  158. package/lib/modules/ProductList/index.js +2 -1
  159. package/lib/modules/Quotation/index.d.ts +8 -1
  160. package/lib/modules/Quotation/index.js +33 -4
  161. package/lib/modules/Quotation/types.d.ts +5 -0
  162. package/lib/modules/Rules/index.d.ts +3 -1
  163. package/lib/modules/Rules/index.js +46 -6
  164. package/lib/modules/Rules/types.d.ts +6 -0
  165. package/lib/modules/Rules/types.js +11 -2
  166. package/lib/modules/SalesSummary/index.d.ts +70 -0
  167. package/lib/modules/SalesSummary/index.js +106 -0
  168. package/lib/modules/SalesSummary/types.d.ts +64 -0
  169. package/lib/modules/SalesSummary/types.js +17 -0
  170. package/lib/modules/SalesSummary/utils.d.ts +34 -0
  171. package/lib/modules/SalesSummary/utils.js +430 -0
  172. package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
  173. package/lib/modules/ScanOrderLogger/index.js +135 -0
  174. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  175. package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
  176. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  177. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  178. package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
  179. package/lib/modules/ScanOrderLogger/types.js +17 -0
  180. package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
  181. package/lib/modules/Schedule/index.d.ts +4 -13
  182. package/lib/modules/Schedule/index.js +4 -15
  183. package/lib/modules/Schedule/utils.d.ts +1 -1
  184. package/lib/modules/Summary/index.d.ts +3 -0
  185. package/lib/modules/Summary/index.js +61 -2
  186. package/lib/modules/Summary/types.d.ts +7 -0
  187. package/lib/modules/Summary/utils.d.ts +104 -1
  188. package/lib/modules/Summary/utils.js +659 -8
  189. package/lib/modules/index.d.ts +4 -0
  190. package/lib/modules/index.js +9 -1
  191. package/lib/server/index.d.ts +41 -4
  192. package/lib/server/index.js +272 -10
  193. package/lib/server/modules/order/index.d.ts +10 -2
  194. package/lib/server/modules/order/index.js +26 -1
  195. package/lib/server/modules/products/index.d.ts +26 -0
  196. package/lib/server/modules/products/index.js +174 -22
  197. package/lib/server/modules/products/types.d.ts +5 -1
  198. package/lib/solution/BaseSales/index.d.ts +175 -0
  199. package/lib/solution/BaseSales/index.js +655 -0
  200. package/lib/solution/BaseSales/types.d.ts +305 -0
  201. package/lib/solution/BaseSales/types.js +40 -0
  202. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
  203. package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
  204. package/lib/solution/BaseSales/utils.d.ts +40 -0
  205. package/lib/solution/BaseSales/utils.js +200 -0
  206. package/lib/solution/BookingByStep/index.d.ts +14 -0
  207. package/lib/solution/BookingByStep/index.js +469 -91
  208. package/lib/solution/BookingByStep/types.d.ts +3 -1
  209. package/lib/solution/BookingByStep/types.js +10 -0
  210. package/lib/solution/BookingByStep/utils/capacity.js +1 -1
  211. package/lib/solution/BookingByStep/utils/resources.js +5 -2
  212. package/lib/solution/BookingTicket/index.d.ts +113 -15
  213. package/lib/solution/BookingTicket/index.js +253 -61
  214. package/lib/solution/BookingTicket/types.d.ts +69 -6
  215. package/lib/solution/BookingTicket/types.js +16 -14
  216. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
  217. package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
  218. package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
  219. package/lib/solution/BookingTicket/utils/cartView.js +103 -0
  220. package/lib/solution/Sales/index.d.ts +1 -0
  221. package/lib/solution/ScanOrder/index.d.ts +146 -0
  222. package/lib/solution/ScanOrder/index.js +1820 -0
  223. package/lib/solution/ScanOrder/types.d.ts +305 -0
  224. package/lib/solution/ScanOrder/types.js +36 -0
  225. package/lib/solution/ScanOrder/utils.d.ts +167 -0
  226. package/lib/solution/ScanOrder/utils.js +639 -0
  227. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  228. package/lib/solution/ShopDiscount/index.js +9 -4
  229. package/lib/solution/ShopDiscount/types.d.ts +4 -0
  230. package/lib/solution/VenueBooking/index.d.ts +197 -0
  231. package/lib/solution/VenueBooking/index.js +1892 -0
  232. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  233. package/lib/solution/VenueBooking/types.d.ts +153 -0
  234. package/lib/solution/VenueBooking/types.js +44 -0
  235. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
  236. package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
  237. package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
  238. package/lib/solution/VenueBooking/utils/resource.js +91 -0
  239. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
  240. package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
  241. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  242. package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
  243. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  244. package/lib/solution/VenueBooking/utils.js +69 -0
  245. package/lib/solution/index.d.ts +3 -0
  246. package/lib/solution/index.js +7 -1
  247. package/package.json +1 -1
@@ -29,7 +29,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
29
29
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
30
30
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
31
31
  import { BaseModule } from "../../../modules/BaseModule";
32
- import { RequestModeENUM } from "../../../plugins";
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
35
 
@@ -70,6 +70,12 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
70
70
  _defineProperty(_assertThisInitialized(_this), "formatters", []);
71
71
  // 是否已注册内置价格格式化器
72
72
  _defineProperty(_assertThisInitialized(_this), "isPriceFormatterRegistered", false);
73
+ // 普通层 QuotationModule 桥接器:本地计算报价单价格,替代 /product/query/price
74
+ _defineProperty(_assertThisInitialized(_this), "quotationPriceBridge", void 0);
75
+ _defineProperty(_assertThisInitialized(_this), "quotationBridgeChannel", void 0);
76
+ _defineProperty(_assertThisInitialized(_this), "quotationBridgeCustomerId", void 0);
77
+ _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshPromise", void 0);
78
+ _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshKey", void 0);
73
79
  // ---- 商品数据同步相关 ----
74
80
  _defineProperty(_assertThisInitialized(_this), "productDataSource", void 0);
75
81
  _defineProperty(_assertThisInitialized(_this), "pendingSyncMessages", []);
@@ -207,41 +213,41 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
207
213
  key: "loadProductsPrice",
208
214
  value: (function () {
209
215
  var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
210
- var _ref$ids, ids, customer_id, schedule_date, startTime, _productsData$data$le, _productsData$data, productsData, duration, _duration, errorMessage;
216
+ var _this2 = this;
217
+ var _ref$ids, ids, schedule_date, schedule_datetime, customer_id, startTime, datetime, idSet, products, priceData, duration, _duration, errorMessage;
211
218
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
212
219
  while (1) switch (_context2.prev = _context2.next) {
213
220
  case 0:
214
- _ref$ids = _ref.ids, ids = _ref$ids === void 0 ? [] : _ref$ids, customer_id = _ref.customer_id, schedule_date = _ref.schedule_date;
221
+ _ref$ids = _ref.ids, ids = _ref$ids === void 0 ? [] : _ref$ids, schedule_date = _ref.schedule_date, schedule_datetime = _ref.schedule_datetime, customer_id = _ref.customer_id;
215
222
  this.logInfo('开始加载商品价格', {
216
223
  productCount: ids.length,
217
224
  schedule_date: schedule_date,
225
+ schedule_datetime: schedule_datetime,
218
226
  customer_id: customer_id
219
227
  });
220
228
  startTime = Date.now();
221
- _context2.prev = 3;
222
- _context2.next = 6;
223
- return this.request.post("/product/query/price", {
224
- ids: ids,
225
- customer_id: customer_id,
226
- schedule_date: schedule_date
227
- }, {
228
- cache: {
229
- mode: RequestModeENUM.REMOTE_LOCAL,
230
- type: "memory"
231
- }
229
+ datetime = schedule_datetime || schedule_date;
230
+ _context2.prev = 4;
231
+ _context2.next = 7;
232
+ return this.ensureQuotationBridgeReady(customer_id);
233
+ case 7:
234
+ idSet = new Set(ids);
235
+ products = this.getProductsRef().filter(function (product) {
236
+ return idSet.has(product.id);
237
+ });
238
+ priceData = products.map(function (product) {
239
+ return _this2.buildPriceDataFromQuotation(product, datetime, customer_id);
232
240
  });
233
- case 6:
234
- productsData = _context2.sent;
235
241
  duration = Date.now() - startTime;
236
242
  this.logInfo('加载商品价格成功', {
237
243
  productCount: ids.length,
238
- priceDataCount: (_productsData$data$le = (_productsData$data = productsData.data) === null || _productsData$data === void 0 ? void 0 : _productsData$data.length) !== null && _productsData$data$le !== void 0 ? _productsData$data$le : 0,
244
+ priceDataCount: priceData.length,
239
245
  duration: "".concat(duration, "ms")
240
246
  });
241
- return _context2.abrupt("return", productsData.data);
242
- case 12:
243
- _context2.prev = 12;
244
- _context2.t0 = _context2["catch"](3);
247
+ return _context2.abrupt("return", priceData);
248
+ case 15:
249
+ _context2.prev = 15;
250
+ _context2.t0 = _context2["catch"](4);
245
251
  _duration = Date.now() - startTime;
246
252
  errorMessage = _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0);
247
253
  this.logError('加载商品价格失败', {
@@ -250,17 +256,265 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
250
256
  error: errorMessage
251
257
  });
252
258
  return _context2.abrupt("return", []);
253
- case 18:
259
+ case 21:
254
260
  case "end":
255
261
  return _context2.stop();
256
262
  }
257
- }, _callee2, this, [[3, 12]]);
263
+ }, _callee2, this, [[4, 15]]);
258
264
  }));
259
265
  function loadProductsPrice(_x3) {
260
266
  return _loadProductsPrice.apply(this, arguments);
261
267
  }
262
268
  return loadProductsPrice;
263
269
  }()
270
+ /**
271
+ * 设置报价单价格桥接器。
272
+ * Server 层负责传入完整 schedule 模块,Products 只负责把报价单计算结果转成价格响应形状。
273
+ */
274
+ )
275
+ }, {
276
+ key: "setupQuotationPriceBridge",
277
+ value: (function () {
278
+ var _setupQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
279
+ var _this$otherParams;
280
+ var channel, quotation, _params$scheduleModul, _params$scheduleModul2, scheduleList, scheduleMap;
281
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
282
+ while (1) switch (_context3.prev = _context3.next) {
283
+ case 0:
284
+ if (this.core) {
285
+ _context3.next = 3;
286
+ break;
287
+ }
288
+ this.logWarning('setupQuotationPriceBridge: core 尚未初始化');
289
+ return _context3.abrupt("return");
290
+ case 3:
291
+ channel = params.channel || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel);
292
+ this.quotationBridgeChannel = channel;
293
+ if (this.quotationPriceBridge) {
294
+ _context3.next = 10;
295
+ break;
296
+ }
297
+ quotation = new ClientQuotationModule("".concat(this.name, "_quotation_price_bridge"));
298
+ _context3.next = 9;
299
+ return quotation.initialize(this.core, {});
300
+ case 9:
301
+ this.quotationPriceBridge = quotation;
302
+ case 10:
303
+ if (params.scheduleModule) {
304
+ scheduleList = ((_params$scheduleModul = (_params$scheduleModul2 = params.scheduleModule).getScheduleList) === null || _params$scheduleModul === void 0 ? void 0 : _params$scheduleModul.call(_params$scheduleModul2)) || [];
305
+ scheduleMap = new Map(scheduleList.map(function (schedule) {
306
+ return [schedule.id, schedule];
307
+ }));
308
+ this.quotationPriceBridge.setScheduleResolver(function (id) {
309
+ var _params$scheduleModul3, _params$scheduleModul4;
310
+ if (scheduleMap.has(id)) return scheduleMap.get(id);
311
+ var schedules = ((_params$scheduleModul3 = (_params$scheduleModul4 = params.scheduleModule).getScheduleByIds) === null || _params$scheduleModul3 === void 0 ? void 0 : _params$scheduleModul3.call(_params$scheduleModul4, [id])) || [];
312
+ return schedules[0];
313
+ });
314
+ }
315
+ _context3.next = 13;
316
+ return this.refreshQuotationPriceBridge({
317
+ customer_id: params.customer_id
318
+ });
319
+ case 13:
320
+ case "end":
321
+ return _context3.stop();
322
+ }
323
+ }, _callee3, this);
324
+ }));
325
+ function setupQuotationPriceBridge(_x4) {
326
+ return _setupQuotationPriceBridge.apply(this, arguments);
327
+ }
328
+ return setupQuotationPriceBridge;
329
+ }()
330
+ /**
331
+ * 刷新桥接器内的报价单列表。
332
+ */
333
+ )
334
+ }, {
335
+ key: "refreshQuotationPriceBridge",
336
+ value: (function () {
337
+ var _refreshQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
338
+ var _this3 = this;
339
+ var customerId, refreshKey;
340
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
341
+ while (1) switch (_context4.prev = _context4.next) {
342
+ case 0:
343
+ if (this.quotationPriceBridge) {
344
+ _context4.next = 2;
345
+ break;
346
+ }
347
+ return _context4.abrupt("return");
348
+ case 2:
349
+ customerId = params && 'customer_id' in params ? params.customer_id : this.quotationBridgeCustomerId;
350
+ refreshKey = this.getQuotationBridgeScopeKey(customerId);
351
+ if (!(this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey)) {
352
+ _context4.next = 8;
353
+ break;
354
+ }
355
+ _context4.next = 7;
356
+ return this.quotationBridgeRefreshPromise;
357
+ case 7:
358
+ return _context4.abrupt("return");
359
+ case 8:
360
+ if (!this.quotationBridgeRefreshPromise) {
361
+ _context4.next = 11;
362
+ break;
363
+ }
364
+ _context4.next = 11;
365
+ return this.quotationBridgeRefreshPromise;
366
+ case 11:
367
+ this.quotationBridgeRefreshKey = refreshKey;
368
+ this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
369
+ channel: this.quotationBridgeChannel,
370
+ customer_id: customerId
371
+ }).then(function () {
372
+ _this3.quotationBridgeCustomerId = customerId;
373
+ }).finally(function () {
374
+ _this3.quotationBridgeRefreshPromise = undefined;
375
+ _this3.quotationBridgeRefreshKey = undefined;
376
+ });
377
+ _context4.next = 15;
378
+ return this.quotationBridgeRefreshPromise;
379
+ case 15:
380
+ case "end":
381
+ return _context4.stop();
382
+ }
383
+ }, _callee4, this);
384
+ }));
385
+ function refreshQuotationPriceBridge(_x5) {
386
+ return _refreshQuotationPriceBridge.apply(this, arguments);
387
+ }
388
+ return refreshQuotationPriceBridge;
389
+ }())
390
+ }, {
391
+ key: "ensureQuotationBridgeReady",
392
+ value: function () {
393
+ var _ensureQuotationBridgeReady = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(customerId) {
394
+ var _this$otherParams2;
395
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
396
+ while (1) switch (_context5.prev = _context5.next) {
397
+ case 0:
398
+ if (this.quotationPriceBridge) {
399
+ _context5.next = 4;
400
+ break;
401
+ }
402
+ _context5.next = 3;
403
+ return this.setupQuotationPriceBridge({
404
+ channel: (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel,
405
+ customer_id: customerId
406
+ });
407
+ case 3:
408
+ return _context5.abrupt("return");
409
+ case 4:
410
+ if (!this.quotationBridgeRefreshPromise) {
411
+ _context5.next = 7;
412
+ break;
413
+ }
414
+ _context5.next = 7;
415
+ return this.quotationBridgeRefreshPromise;
416
+ case 7:
417
+ if (!(this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId))) {
418
+ _context5.next = 10;
419
+ break;
420
+ }
421
+ _context5.next = 10;
422
+ return this.refreshQuotationPriceBridge({
423
+ customer_id: customerId
424
+ });
425
+ case 10:
426
+ case "end":
427
+ return _context5.stop();
428
+ }
429
+ }, _callee5, this);
430
+ }));
431
+ function ensureQuotationBridgeReady(_x6) {
432
+ return _ensureQuotationBridgeReady.apply(this, arguments);
433
+ }
434
+ return ensureQuotationBridgeReady;
435
+ }()
436
+ }, {
437
+ key: "getQuotationBridgeScopeKey",
438
+ value: function getQuotationBridgeScopeKey(customerId) {
439
+ return "".concat(this.quotationBridgeChannel || '', ":").concat(customerId !== null && customerId !== void 0 ? customerId : '');
440
+ }
441
+ }, {
442
+ key: "buildPriceDataFromQuotation",
443
+ value: function buildPriceDataFromQuotation(product, datetime, customerId) {
444
+ var _this$quotationPriceB, _ref2, _product$base_price;
445
+ var quotedPrice = (_this$quotationPriceB = this.quotationPriceBridge) === null || _this$quotationPriceB === void 0 ? void 0 : _this$quotationPriceB.getPriceForProduct({
446
+ productId: product.id,
447
+ datetime: datetime,
448
+ customer_id: customerId
449
+ });
450
+ var productPrice = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : product.price;
451
+ return {
452
+ id: product.id,
453
+ price: String(productPrice !== null && productPrice !== void 0 ? productPrice : 0),
454
+ base_price: String((_ref2 = (_product$base_price = product.base_price) !== null && _product$base_price !== void 0 ? _product$base_price : product.price) !== null && _ref2 !== void 0 ? _ref2 : 0),
455
+ variant: this.buildVariantPriceData(product, datetime, customerId),
456
+ bundle_group: this.buildBundleGroupPriceData(product, datetime, customerId)
457
+ };
458
+ }
459
+ }, {
460
+ key: "buildVariantPriceData",
461
+ value: function buildVariantPriceData(product, datetime, customerId) {
462
+ var _this4 = this;
463
+ if (!Array.isArray(product.variant)) return [];
464
+ return product.variant.map(function (variant) {
465
+ var _this4$quotationPrice, _ref3, _ref4, _ref5, _ref6, _ref7, _variant$base_price, _variant$product_id;
466
+ var quotedPrice = (_this4$quotationPrice = _this4.quotationPriceBridge) === null || _this4$quotationPrice === void 0 ? void 0 : _this4$quotationPrice.getPriceForProduct({
467
+ productId: product.id,
468
+ variantId: Number(variant.id),
469
+ datetime: datetime,
470
+ customer_id: customerId
471
+ });
472
+ var price = (_ref3 = (_ref4 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : variant.price) !== null && _ref4 !== void 0 ? _ref4 : product.price) !== null && _ref3 !== void 0 ? _ref3 : 0;
473
+ var basePrice = (_ref5 = (_ref6 = (_ref7 = (_variant$base_price = variant.base_price) !== null && _variant$base_price !== void 0 ? _variant$base_price : variant.price) !== null && _ref7 !== void 0 ? _ref7 : product.base_price) !== null && _ref6 !== void 0 ? _ref6 : product.price) !== null && _ref5 !== void 0 ? _ref5 : 0;
474
+ return {
475
+ id: Number(variant.id),
476
+ product_id: Number((_variant$product_id = variant.product_id) !== null && _variant$product_id !== void 0 ? _variant$product_id : product.id),
477
+ base_price: Number(basePrice),
478
+ price: Number(price)
479
+ };
480
+ });
481
+ }
482
+ }, {
483
+ key: "buildBundleGroupPriceData",
484
+ value: function buildBundleGroupPriceData(product, datetime, customerId) {
485
+ var _this5 = this;
486
+ if (!Array.isArray(product.bundle_group)) return [];
487
+ return product.bundle_group.map(function (group) {
488
+ return {
489
+ id: Number(group.id),
490
+ bundle_item: (group.bundle_item || []).map(function (item) {
491
+ var _this5$quotationPrice, _ref8, _ref9, _item$base_price, _item$product_id, _item$group_id;
492
+ var bundleProductId = Number(item.bundle_product_id);
493
+ var bundleVariantId = Number(item.bundle_variant_id || 0);
494
+ var quotedPrice = (_this5$quotationPrice = _this5.quotationPriceBridge) === null || _this5$quotationPrice === void 0 ? void 0 : _this5$quotationPrice.getPriceForProduct({
495
+ productId: bundleProductId,
496
+ variantId: bundleVariantId,
497
+ datetime: datetime,
498
+ customer_id: customerId
499
+ });
500
+ var price = (_ref8 = quotedPrice !== null && quotedPrice !== void 0 ? quotedPrice : item.price) !== null && _ref8 !== void 0 ? _ref8 : 0;
501
+ var basePrice = (_ref9 = (_item$base_price = item.base_price) !== null && _item$base_price !== void 0 ? _item$base_price : item.price) !== null && _ref9 !== void 0 ? _ref9 : 0;
502
+ return {
503
+ id: Number(item.id),
504
+ product_id: Number((_item$product_id = item.product_id) !== null && _item$product_id !== void 0 ? _item$product_id : product.id),
505
+ group_id: Number((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group.id),
506
+ bundle_product_id: bundleProductId,
507
+ bundle_variant_id: bundleVariantId,
508
+ price: Number(price),
509
+ base_price: basePrice,
510
+ price_type: item.price_type,
511
+ price_type_ext: item.price_type_ext
512
+ };
513
+ })
514
+ };
515
+ });
516
+ }
517
+
264
518
  /**
265
519
  * 获取应用了价格的商品列表(带缓存)
266
520
  * 使用日期作为缓存 key,同一天的商品价格会被缓存
@@ -271,25 +525,24 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
271
525
  * @param options.changedIds 变更的商品 IDs,非空时仅对这些商品增量执行 prepare 并更新缓存
272
526
  * @returns 应用了价格的商品列表
273
527
  */
274
- )
275
528
  }, {
276
529
  key: "getProductsWithPrice",
277
530
  value: (function () {
278
- var _getProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(schedule_date, extraContext, options) {
531
+ var _getProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(schedule_date, extraContext, options) {
279
532
  var t0, cacheKey, changedIds, cachedProducts, updatedProducts, updatedMap, mergedCache, _iterator, _step, p, _iterator2, _step2, _p, errorMessage, result;
280
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
281
- while (1) switch (_context3.prev = _context3.next) {
533
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
534
+ while (1) switch (_context6.prev = _context6.next) {
282
535
  case 0:
283
536
  t0 = performance.now();
284
- cacheKey = schedule_date;
537
+ cacheKey = this.getProductsPriceCacheKey(schedule_date, extraContext);
285
538
  changedIds = options === null || options === void 0 ? void 0 : options.changedIds;
286
539
  if (!this.productsPriceCache.has(cacheKey)) {
287
- _context3.next = 33;
540
+ _context6.next = 33;
288
541
  break;
289
542
  }
290
543
  cachedProducts = this.productsPriceCache.get(cacheKey); // 有变更的商品 → 增量 prepare 后 merge 回缓存
291
544
  if (!(changedIds && changedIds.length > 0)) {
292
- _context3.next = 30;
545
+ _context6.next = 30;
293
546
  break;
294
547
  }
295
548
  this.logInfo('商品价格缓存命中,增量更新变更商品', {
@@ -297,15 +550,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
297
550
  changedIds: changedIds,
298
551
  cachedProductCount: cachedProducts.length
299
552
  });
300
- _context3.prev = 7;
301
- _context3.next = 10;
553
+ _context6.prev = 7;
554
+ _context6.next = 10;
302
555
  return this.prepareProductsWithPrice(schedule_date, extraContext, {
303
556
  productIds: changedIds
304
557
  });
305
558
  case 10:
306
- updatedProducts = _context3.sent;
559
+ updatedProducts = _context6.sent;
307
560
  if (!(updatedProducts.length > 0)) {
308
- _context3.next = 22;
561
+ _context6.next = 22;
309
562
  break;
310
563
  }
311
564
  // merge:用更新结果替换缓存中对应的商品,新增的追加
@@ -352,14 +605,14 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
352
605
  changedCount: changedIds.length,
353
606
  count: mergedCache.length
354
607
  });
355
- return _context3.abrupt("return", mergedCache);
608
+ return _context6.abrupt("return", mergedCache);
356
609
  case 22:
357
- _context3.next = 28;
610
+ _context6.next = 28;
358
611
  break;
359
612
  case 24:
360
- _context3.prev = 24;
361
- _context3.t0 = _context3["catch"](7);
362
- errorMessage = _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0);
613
+ _context6.prev = 24;
614
+ _context6.t0 = _context6["catch"](7);
615
+ errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
363
616
  this.logError('增量更新失败,返回现有缓存', {
364
617
  cacheKey: cacheKey,
365
618
  changedIds: changedIds,
@@ -371,7 +624,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
371
624
  changedCount: changedIds.length,
372
625
  count: cachedProducts.length
373
626
  });
374
- return _context3.abrupt("return", cachedProducts);
627
+ return _context6.abrupt("return", cachedProducts);
375
628
  case 30:
376
629
  perfMark('getProductsWithPrice(cacheHit)', performance.now() - t0, {
377
630
  cacheKey: cacheKey,
@@ -381,15 +634,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
381
634
  cacheKey: cacheKey,
382
635
  productCount: cachedProducts.length
383
636
  });
384
- return _context3.abrupt("return", cachedProducts);
637
+ return _context6.abrupt("return", cachedProducts);
385
638
  case 33:
386
639
  this.logInfo('商品价格缓存未命中,准备获取', {
387
640
  cacheKey: cacheKey
388
641
  });
389
- _context3.next = 36;
642
+ _context6.next = 36;
390
643
  return this.prepareProductsWithPrice(schedule_date, extraContext);
391
644
  case 36:
392
- result = _context3.sent;
645
+ result = _context6.sent;
393
646
  this.productsPriceCache.set(cacheKey, result);
394
647
  this.logInfo('商品价格已缓存', {
395
648
  cacheKey: cacheKey,
@@ -400,14 +653,14 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
400
653
  cacheKey: cacheKey,
401
654
  count: result.length
402
655
  });
403
- return _context3.abrupt("return", result);
656
+ return _context6.abrupt("return", result);
404
657
  case 42:
405
658
  case "end":
406
- return _context3.stop();
659
+ return _context6.stop();
407
660
  }
408
- }, _callee3, this, [[7, 24]]);
661
+ }, _callee6, this, [[7, 24]]);
409
662
  }));
410
- function getProductsWithPrice(_x4, _x5, _x6) {
663
+ function getProductsWithPrice(_x7, _x8, _x9) {
411
664
  return _getProductsWithPrice.apply(this, arguments);
412
665
  }
413
666
  return getProductsWithPrice;
@@ -425,10 +678,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
425
678
  }, {
426
679
  key: "prepareProductsWithPrice",
427
680
  value: (function () {
428
- var _prepareProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(schedule_date, extraContext, options) {
681
+ var _prepareProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schedule_date, extraContext, options) {
429
682
  var tTotal, targetIds, isIncremental, _priceData$length, _this$core, products, ids, idSet, tIds, i, tPrice, priceData, context, tFormat, processedProducts, errorMessage;
430
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
431
- while (1) switch (_context4.prev = _context4.next) {
683
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
684
+ while (1) switch (_context7.prev = _context7.next) {
432
685
  case 0:
433
686
  tTotal = performance.now();
434
687
  targetIds = options === null || options === void 0 ? void 0 : options.productIds;
@@ -438,7 +691,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
438
691
  mode: isIncremental ? 'incremental' : 'full',
439
692
  targetIdsCount: targetIds === null || targetIds === void 0 ? void 0 : targetIds.length
440
693
  });
441
- _context4.prev = 4;
694
+ _context7.prev = 4;
442
695
  // 1. 获取商品列表:指定 IDs 时从 store 取子集,否则取全量
443
696
 
444
697
  if (isIncremental) {
@@ -466,13 +719,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
466
719
 
467
720
  // 2. 获取价格数据(网络请求)
468
721
  tPrice = performance.now();
469
- _context4.next = 10;
722
+ _context7.next = 10;
470
723
  return this.loadProductsPrice({
471
724
  ids: ids,
472
- schedule_date: schedule_date
725
+ schedule_date: schedule_date,
726
+ schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
727
+ customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id
473
728
  });
474
729
  case 10:
475
- priceData = _context4.sent;
730
+ priceData = _context7.sent;
476
731
  perfMark('prepareProducts.loadPrice', performance.now() - tPrice, {
477
732
  count: ids.length
478
733
  });
@@ -481,14 +736,16 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
481
736
  });
482
737
  context = _objectSpread({
483
738
  schedule_date: schedule_date,
739
+ schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
740
+ customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id,
484
741
  priceData: priceData,
485
742
  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
486
743
  }, extraContext); // 3. 通过格式化器流程处理商品
487
744
  tFormat = performance.now();
488
- _context4.next = 17;
745
+ _context7.next = 17;
489
746
  return this.applyFormatters(products, context);
490
747
  case 17:
491
- processedProducts = _context4.sent;
748
+ processedProducts = _context7.sent;
492
749
  perfMark('prepareProducts.applyFormatters', performance.now() - tFormat, {
493
750
  count: products.length,
494
751
  formatterCount: this.formatters.length
@@ -500,10 +757,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
500
757
  formatterCount: this.formatters.length
501
758
  });
502
759
  if (isIncremental) {
503
- _context4.next = 23;
760
+ _context7.next = 23;
504
761
  break;
505
762
  }
506
- _context4.next = 23;
763
+ _context7.next = 23;
507
764
  return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
508
765
  case 23:
509
766
  perfMark('prepareProductsWithPrice', performance.now() - tTotal, {
@@ -511,29 +768,37 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
511
768
  formatterCount: this.formatters.length,
512
769
  mode: isIncremental ? 'incremental' : 'full'
513
770
  });
514
- return _context4.abrupt("return", processedProducts);
771
+ return _context7.abrupt("return", processedProducts);
515
772
  case 27:
516
- _context4.prev = 27;
517
- _context4.t0 = _context4["catch"](4);
518
- errorMessage = _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0);
519
- console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context4.t0);
773
+ _context7.prev = 27;
774
+ _context7.t0 = _context7["catch"](4);
775
+ errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
776
+ console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context7.t0);
520
777
  this.logError('prepareProductsWithPrice 处理失败', {
521
778
  schedule_date: schedule_date,
522
779
  error: errorMessage
523
780
  });
524
781
  case 32:
525
- return _context4.abrupt("return", []);
782
+ return _context7.abrupt("return", []);
526
783
  case 33:
527
784
  case "end":
528
- return _context4.stop();
785
+ return _context7.stop();
529
786
  }
530
- }, _callee4, this, [[4, 27]]);
787
+ }, _callee7, this, [[4, 27]]);
531
788
  }));
532
- function prepareProductsWithPrice(_x7, _x8, _x9) {
789
+ function prepareProductsWithPrice(_x10, _x11, _x12) {
533
790
  return _prepareProductsWithPrice.apply(this, arguments);
534
791
  }
535
792
  return prepareProductsWithPrice;
536
- }()
793
+ }())
794
+ }, {
795
+ key: "getProductsPriceCacheKey",
796
+ value: function getProductsPriceCacheKey(schedule_date, extraContext) {
797
+ var _extraContext$custome;
798
+ var datetime = (extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime) || schedule_date;
799
+ return "".concat(datetime, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '');
800
+ }
801
+
537
802
  /**
538
803
  * 应用所有已注册的格式化器
539
804
  * @param products 商品列表
@@ -541,25 +806,24 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
541
806
  * @returns 格式化后的商品列表
542
807
  * @private
543
808
  */
544
- )
545
809
  }, {
546
810
  key: "applyFormatters",
547
811
  value: (function () {
548
- var _applyFormatters = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(products, context) {
812
+ var _applyFormatters = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(products, context) {
549
813
  var result, i, formatter, tF, errorMessage;
550
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
551
- while (1) switch (_context5.prev = _context5.next) {
814
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
815
+ while (1) switch (_context8.prev = _context8.next) {
552
816
  case 0:
553
817
  result = products;
554
818
  if (!(this.formatters.length === 0)) {
555
- _context5.next = 5;
819
+ _context8.next = 5;
556
820
  break;
557
821
  }
558
822
  console.warn('[ProductsModule] ⚠️ 没有注册任何格式化器');
559
823
  this.logWarning('没有注册任何格式化器', {
560
824
  productCount: products.length
561
825
  });
562
- return _context5.abrupt("return", result);
826
+ return _context8.abrupt("return", result);
563
827
  case 5:
564
828
  this.logInfo('开始应用格式化器', {
565
829
  productCount: products.length,
@@ -568,28 +832,28 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
568
832
  i = 0;
569
833
  case 7:
570
834
  if (!(i < this.formatters.length)) {
571
- _context5.next = 25;
835
+ _context8.next = 25;
572
836
  break;
573
837
  }
574
838
  formatter = this.formatters[i];
575
- _context5.prev = 9;
839
+ _context8.prev = 9;
576
840
  tF = performance.now();
577
- _context5.next = 13;
841
+ _context8.next = 13;
578
842
  return formatter(result, context);
579
843
  case 13:
580
- result = _context5.sent;
844
+ result = _context8.sent;
581
845
  perfMark("applyFormatters[".concat(i, "]"), performance.now() - tF, {
582
846
  index: i,
583
847
  total: this.formatters.length,
584
848
  productCount: result.length
585
849
  });
586
- _context5.next = 22;
850
+ _context8.next = 22;
587
851
  break;
588
852
  case 17:
589
- _context5.prev = 17;
590
- _context5.t0 = _context5["catch"](9);
591
- errorMessage = _context5.t0 instanceof Error ? _context5.t0.message : String(_context5.t0);
592
- console.error("[ProductsModule] \u274C \u683C\u5F0F\u5316\u5668 ".concat(i + 1, " \u6267\u884C\u5931\u8D25:"), _context5.t0);
853
+ _context8.prev = 17;
854
+ _context8.t0 = _context8["catch"](9);
855
+ errorMessage = _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0);
856
+ console.error("[ProductsModule] \u274C \u683C\u5F0F\u5316\u5668 ".concat(i + 1, " \u6267\u884C\u5931\u8D25:"), _context8.t0);
593
857
  this.logError("\u683C\u5F0F\u5316\u5668 ".concat(i + 1, " \u6267\u884C\u5931\u8D25"), {
594
858
  formatterIndex: i + 1,
595
859
  totalFormatters: this.formatters.length,
@@ -597,21 +861,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
597
861
  });
598
862
  case 22:
599
863
  i++;
600
- _context5.next = 7;
864
+ _context8.next = 7;
601
865
  break;
602
866
  case 25:
603
867
  this.logInfo('所有格式化器已应用', {
604
868
  formatterCount: this.formatters.length,
605
869
  resultProductCount: result.length
606
870
  });
607
- return _context5.abrupt("return", result);
871
+ return _context8.abrupt("return", result);
608
872
  case 27:
609
873
  case "end":
610
- return _context5.stop();
874
+ return _context8.stop();
611
875
  }
612
- }, _callee5, this, [[9, 17]]);
876
+ }, _callee8, this, [[9, 17]]);
613
877
  }));
614
- function applyFormatters(_x10, _x11) {
878
+ function applyFormatters(_x13, _x14) {
615
879
  return _applyFormatters.apply(this, arguments);
616
880
  }
617
881
  return applyFormatters;
@@ -737,28 +1001,28 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
737
1001
  }, {
738
1002
  key: "loadProductsByServer",
739
1003
  value: (function () {
740
- var _loadProductsByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
1004
+ var _loadProductsByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
741
1005
  var t0, tSSE, productList, list, duration, errorMessage;
742
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
743
- while (1) switch (_context6.prev = _context6.next) {
1006
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1007
+ while (1) switch (_context9.prev = _context9.next) {
744
1008
  case 0:
745
1009
  if (this.productDataSource) {
746
- _context6.next = 3;
1010
+ _context9.next = 3;
747
1011
  break;
748
1012
  }
749
1013
  this.logWarning('loadProductsByServer: ProductDataSource 不可用');
750
- return _context6.abrupt("return", []);
1014
+ return _context9.abrupt("return", []);
751
1015
  case 3:
752
1016
  this.logInfo('开始通过 DataSource SSE 加载商品列表');
753
1017
  t0 = performance.now();
754
- _context6.prev = 5;
1018
+ _context9.prev = 5;
755
1019
  tSSE = performance.now();
756
- _context6.next = 9;
1020
+ _context9.next = 9;
757
1021
  return this.productDataSource.run({
758
1022
  sse: {}
759
1023
  });
760
1024
  case 9:
761
- productList = _context6.sent;
1025
+ productList = _context9.sent;
762
1026
  list = productList || [];
763
1027
  perfMark('loadProductsByServer.SSE', performance.now() - tSSE, {
764
1028
  count: list.length
@@ -767,32 +1031,32 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
767
1031
  productCount: list.length,
768
1032
  duration: "".concat(Math.round(performance.now() - t0), "ms")
769
1033
  });
770
- _context6.next = 15;
1034
+ _context9.next = 15;
771
1035
  return this.saveProductsToIndexDB(list);
772
1036
  case 15:
773
- _context6.next = 17;
1037
+ _context9.next = 17;
774
1038
  return this.core.effects.emit(ProductsHooks.onProductsLoaded, list);
775
1039
  case 17:
776
1040
  perfMark('loadProductsByServer', performance.now() - t0, {
777
1041
  count: list.length
778
1042
  });
779
- return _context6.abrupt("return", list);
1043
+ return _context9.abrupt("return", list);
780
1044
  case 21:
781
- _context6.prev = 21;
782
- _context6.t0 = _context6["catch"](5);
1045
+ _context9.prev = 21;
1046
+ _context9.t0 = _context9["catch"](5);
783
1047
  duration = Math.round(performance.now() - t0);
784
- errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
785
- console.error('[Products] 加载商品数据失败:', _context6.t0);
1048
+ errorMessage = _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0);
1049
+ console.error('[Products] 加载商品数据失败:', _context9.t0);
786
1050
  this.logError('通过 DataSource SSE 加载商品列表失败', {
787
1051
  duration: "".concat(duration, "ms"),
788
1052
  error: errorMessage
789
1053
  });
790
- return _context6.abrupt("return", []);
1054
+ return _context9.abrupt("return", []);
791
1055
  case 28:
792
1056
  case "end":
793
- return _context6.stop();
1057
+ return _context9.stop();
794
1058
  }
795
- }, _callee6, this, [[5, 21]]);
1059
+ }, _callee9, this, [[5, 21]]);
796
1060
  }));
797
1061
  function loadProductsByServer() {
798
1062
  return _loadProductsByServer.apply(this, arguments);
@@ -808,12 +1072,12 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
808
1072
  }, {
809
1073
  key: "fetchProductsByHttp",
810
1074
  value: (function () {
811
- var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
812
- var _ref2, _ref2$category_ids, category_ids, _ref2$product_ids, product_ids, _ref2$collection, collection, customer_id, cacheId, startTime, _this$otherParams, _productsData$data2, productsData, productList, duration, _duration2, errorMessage;
813
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
814
- while (1) switch (_context7.prev = _context7.next) {
1075
+ var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
1076
+ var _ref10, _ref10$category_ids, category_ids, _ref10$product_ids, product_ids, _ref10$collection, collection, customer_id, cacheId, startTime, _this$otherParams3, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
1077
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1078
+ while (1) switch (_context10.prev = _context10.next) {
815
1079
  case 0:
816
- _ref2 = params || {}, _ref2$category_ids = _ref2.category_ids, category_ids = _ref2$category_ids === void 0 ? [] : _ref2$category_ids, _ref2$product_ids = _ref2.product_ids, product_ids = _ref2$product_ids === void 0 ? [] : _ref2$product_ids, _ref2$collection = _ref2.collection, collection = _ref2$collection === void 0 ? [] : _ref2$collection, customer_id = _ref2.customer_id, cacheId = _ref2.cacheId;
1080
+ _ref10 = params || {}, _ref10$category_ids = _ref10.category_ids, category_ids = _ref10$category_ids === void 0 ? [] : _ref10$category_ids, _ref10$product_ids = _ref10.product_ids, product_ids = _ref10$product_ids === void 0 ? [] : _ref10$product_ids, _ref10$collection = _ref10.collection, collection = _ref10$collection === void 0 ? [] : _ref10$collection, customer_id = _ref10.customer_id, cacheId = _ref10.cacheId;
817
1081
  this.logInfo('fetchProductsByHttp: 开始请求', {
818
1082
  categoryIdsCount: category_ids.length,
819
1083
  productIdsCount: product_ids.length,
@@ -821,8 +1085,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
821
1085
  customer_id: customer_id
822
1086
  });
823
1087
  startTime = Date.now();
824
- _context7.prev = 3;
825
- _context7.next = 6;
1088
+ _context10.prev = 3;
1089
+ _context10.next = 6;
826
1090
  return this.request.post("/product/query", {
827
1091
  open_bundle: 1,
828
1092
  exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
@@ -839,37 +1103,37 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
839
1103
  ids: product_ids,
840
1104
  collection: collection,
841
1105
  front_end_cache_id: cacheId,
842
- application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel
1106
+ application_code: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel
843
1107
  }, {
844
1108
  cache: undefined
845
1109
  });
846
1110
  case 6:
847
- productsData = _context7.sent;
848
- productList = (productsData === null || productsData === void 0 || (_productsData$data2 = productsData.data) === null || _productsData$data2 === void 0 ? void 0 : _productsData$data2.list) || [];
1111
+ productsData = _context10.sent;
1112
+ productList = (productsData === null || productsData === void 0 || (_productsData$data = productsData.data) === null || _productsData$data === void 0 ? void 0 : _productsData$data.list) || [];
849
1113
  duration = Date.now() - startTime;
850
1114
  this.logInfo('fetchProductsByHttp: 请求成功', {
851
1115
  productCount: productList.length,
852
1116
  duration: "".concat(duration, "ms")
853
1117
  });
854
- return _context7.abrupt("return", productList);
1118
+ return _context10.abrupt("return", productList);
855
1119
  case 13:
856
- _context7.prev = 13;
857
- _context7.t0 = _context7["catch"](3);
1120
+ _context10.prev = 13;
1121
+ _context10.t0 = _context10["catch"](3);
858
1122
  _duration2 = Date.now() - startTime;
859
- errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
860
- console.error('[Products] fetchProductsByHttp 失败:', _context7.t0);
1123
+ errorMessage = _context10.t0 instanceof Error ? _context10.t0.message : String(_context10.t0);
1124
+ console.error('[Products] fetchProductsByHttp 失败:', _context10.t0);
861
1125
  this.logError('fetchProductsByHttp: 请求失败', {
862
1126
  duration: "".concat(_duration2, "ms"),
863
1127
  error: errorMessage
864
1128
  });
865
- return _context7.abrupt("return", []);
1129
+ return _context10.abrupt("return", []);
866
1130
  case 20:
867
1131
  case "end":
868
- return _context7.stop();
1132
+ return _context10.stop();
869
1133
  }
870
- }, _callee7, this, [[3, 13]]);
1134
+ }, _callee10, this, [[3, 13]]);
871
1135
  }));
872
- function fetchProductsByHttp(_x12) {
1136
+ function fetchProductsByHttp(_x15) {
873
1137
  return _fetchProductsByHttp.apply(this, arguments);
874
1138
  }
875
1139
  return fetchProductsByHttp;
@@ -883,33 +1147,33 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
883
1147
  }, {
884
1148
  key: "loadProductsByServerHttp",
885
1149
  value: (function () {
886
- var _loadProductsByServerHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
1150
+ var _loadProductsByServerHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
887
1151
  var productList;
888
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
889
- while (1) switch (_context8.prev = _context8.next) {
1152
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1153
+ while (1) switch (_context11.prev = _context11.next) {
890
1154
  case 0:
891
- _context8.next = 2;
1155
+ _context11.next = 2;
892
1156
  return this.fetchProductsByHttp(params);
893
1157
  case 2:
894
- productList = _context8.sent;
1158
+ productList = _context11.sent;
895
1159
  if (!(productList.length > 0)) {
896
- _context8.next = 8;
1160
+ _context11.next = 8;
897
1161
  break;
898
1162
  }
899
- _context8.next = 6;
1163
+ _context11.next = 6;
900
1164
  return this.saveProductsToIndexDB(productList);
901
1165
  case 6:
902
- _context8.next = 8;
1166
+ _context11.next = 8;
903
1167
  return this.core.effects.emit(ProductsHooks.onProductsLoaded, productList);
904
1168
  case 8:
905
- return _context8.abrupt("return", productList);
1169
+ return _context11.abrupt("return", productList);
906
1170
  case 9:
907
1171
  case "end":
908
- return _context8.stop();
1172
+ return _context11.stop();
909
1173
  }
910
- }, _callee8, this);
1174
+ }, _callee11, this);
911
1175
  }));
912
- function loadProductsByServerHttp(_x13) {
1176
+ function loadProductsByServerHttp(_x16) {
913
1177
  return _loadProductsByServerHttp.apply(this, arguments);
914
1178
  }
915
1179
  return loadProductsByServerHttp;
@@ -921,22 +1185,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
921
1185
  }, {
922
1186
  key: "getProducts",
923
1187
  value: (function () {
924
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1188
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
925
1189
  var t0, result;
926
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
927
- while (1) switch (_context9.prev = _context9.next) {
1190
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1191
+ while (1) switch (_context12.prev = _context12.next) {
928
1192
  case 0:
929
1193
  t0 = performance.now();
930
1194
  result = structuredClone(this.store.list);
931
1195
  perfMark('ProductsModule.getProducts(structuredClone)', performance.now() - t0, {
932
1196
  count: result.length
933
1197
  });
934
- return _context9.abrupt("return", result);
1198
+ return _context12.abrupt("return", result);
935
1199
  case 4:
936
1200
  case "end":
937
- return _context9.stop();
1201
+ return _context12.stop();
938
1202
  }
939
- }, _callee9, this);
1203
+ }, _callee12, this);
940
1204
  }));
941
1205
  function getProducts() {
942
1206
  return _getProducts.apply(this, arguments);
@@ -961,20 +1225,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
961
1225
  }, {
962
1226
  key: "getProductById",
963
1227
  value: (function () {
964
- var _getProductById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(id) {
1228
+ var _getProductById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id) {
965
1229
  var product;
966
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
967
- while (1) switch (_context10.prev = _context10.next) {
1230
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1231
+ while (1) switch (_context13.prev = _context13.next) {
968
1232
  case 0:
969
1233
  product = this.store.map.get(id);
970
- return _context10.abrupt("return", product ? structuredClone(product) : undefined);
1234
+ return _context13.abrupt("return", product ? structuredClone(product) : undefined);
971
1235
  case 2:
972
1236
  case "end":
973
- return _context10.stop();
1237
+ return _context13.stop();
974
1238
  }
975
- }, _callee10, this);
1239
+ }, _callee13, this);
976
1240
  }));
977
- function getProductById(_x14) {
1241
+ function getProductById(_x17) {
978
1242
  return _getProductById.apply(this, arguments);
979
1243
  }
980
1244
  return getProductById;
@@ -987,10 +1251,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
987
1251
  }, {
988
1252
  key: "removeProductsByIds",
989
1253
  value: (function () {
990
- var _removeProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ids) {
1254
+ var _removeProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(ids) {
991
1255
  var idSet, _iterator3, _step3, _id, _iterator4, _step4, id, errorMessage, _iterator5, _step5, _step5$value, dateKey, cachedProducts;
992
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
993
- while (1) switch (_context11.prev = _context11.next) {
1256
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1257
+ while (1) switch (_context14.prev = _context14.next) {
994
1258
  case 0:
995
1259
  idSet = new Set(ids);
996
1260
  this.logInfo('removeProductsByIds', {
@@ -1012,42 +1276,42 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1012
1276
  _iterator3.f();
1013
1277
  }
1014
1278
  if (!this.dbManager) {
1015
- _context11.next = 30;
1279
+ _context14.next = 30;
1016
1280
  break;
1017
1281
  }
1018
- _context11.prev = 6;
1282
+ _context14.prev = 6;
1019
1283
  _iterator4 = _createForOfIteratorHelper(ids);
1020
- _context11.prev = 8;
1284
+ _context14.prev = 8;
1021
1285
  _iterator4.s();
1022
1286
  case 10:
1023
1287
  if ((_step4 = _iterator4.n()).done) {
1024
- _context11.next = 16;
1288
+ _context14.next = 16;
1025
1289
  break;
1026
1290
  }
1027
1291
  id = _step4.value;
1028
- _context11.next = 14;
1292
+ _context14.next = 14;
1029
1293
  return this.dbManager.delete(INDEXDB_STORE_NAME, id);
1030
1294
  case 14:
1031
- _context11.next = 10;
1295
+ _context14.next = 10;
1032
1296
  break;
1033
1297
  case 16:
1034
- _context11.next = 21;
1298
+ _context14.next = 21;
1035
1299
  break;
1036
1300
  case 18:
1037
- _context11.prev = 18;
1038
- _context11.t0 = _context11["catch"](8);
1039
- _iterator4.e(_context11.t0);
1301
+ _context14.prev = 18;
1302
+ _context14.t0 = _context14["catch"](8);
1303
+ _iterator4.e(_context14.t0);
1040
1304
  case 21:
1041
- _context11.prev = 21;
1305
+ _context14.prev = 21;
1042
1306
  _iterator4.f();
1043
- return _context11.finish(21);
1307
+ return _context14.finish(21);
1044
1308
  case 24:
1045
- _context11.next = 30;
1309
+ _context14.next = 30;
1046
1310
  break;
1047
1311
  case 26:
1048
- _context11.prev = 26;
1049
- _context11.t1 = _context11["catch"](6);
1050
- errorMessage = _context11.t1 instanceof Error ? _context11.t1.message : String(_context11.t1);
1312
+ _context14.prev = 26;
1313
+ _context14.t1 = _context14["catch"](6);
1314
+ errorMessage = _context14.t1 instanceof Error ? _context14.t1.message : String(_context14.t1);
1051
1315
  this.logError('removeProductsByIds: IndexDB 删除失败', {
1052
1316
  ids: ids,
1053
1317
  error: errorMessage
@@ -1072,11 +1336,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1072
1336
  });
1073
1337
  case 34:
1074
1338
  case "end":
1075
- return _context11.stop();
1339
+ return _context14.stop();
1076
1340
  }
1077
- }, _callee11, this, [[6, 26], [8, 18, 21, 24]]);
1341
+ }, _callee14, this, [[6, 26], [8, 18, 21, 24]]);
1078
1342
  }));
1079
- function removeProductsByIds(_x15) {
1343
+ function removeProductsByIds(_x18) {
1080
1344
  return _removeProductsByIds.apply(this, arguments);
1081
1345
  }
1082
1346
  return removeProductsByIds;
@@ -1089,17 +1353,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1089
1353
  }, {
1090
1354
  key: "refreshProducts",
1091
1355
  value: (function () {
1092
- var _refreshProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1356
+ var _refreshProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1093
1357
  var tTotal, products;
1094
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1095
- while (1) switch (_context12.prev = _context12.next) {
1358
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1359
+ while (1) switch (_context15.prev = _context15.next) {
1096
1360
  case 0:
1097
1361
  tTotal = performance.now();
1098
1362
  this.logInfo('refreshProducts 开始');
1099
- _context12.next = 4;
1363
+ _context15.next = 4;
1100
1364
  return this.loadProductsByServer();
1101
1365
  case 4:
1102
- products = _context12.sent;
1366
+ products = _context15.sent;
1103
1367
  if (products && products.length > 0) {
1104
1368
  // 服务器返回的数据已经是全新的,无需 cloneDeep
1105
1369
  this.store.list = products;
@@ -1114,12 +1378,12 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1114
1378
  perfMark('refreshProducts', performance.now() - tTotal, {
1115
1379
  count: this.store.list.length
1116
1380
  });
1117
- return _context12.abrupt("return", this.store.list);
1381
+ return _context15.abrupt("return", this.store.list);
1118
1382
  case 8:
1119
1383
  case "end":
1120
- return _context12.stop();
1384
+ return _context15.stop();
1121
1385
  }
1122
- }, _callee12, this);
1386
+ }, _callee15, this);
1123
1387
  }));
1124
1388
  function refreshProducts() {
1125
1389
  return _refreshProducts.apply(this, arguments);
@@ -1133,10 +1397,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1133
1397
  }, {
1134
1398
  key: "clear",
1135
1399
  value: (function () {
1136
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1400
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1137
1401
  var errorMessage;
1138
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1139
- while (1) switch (_context13.prev = _context13.next) {
1402
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1403
+ while (1) switch (_context16.prev = _context16.next) {
1140
1404
  case 0:
1141
1405
  this.logInfo('开始清空缓存', {
1142
1406
  currentProductCount: this.store.list.length,
@@ -1147,22 +1411,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1147
1411
 
1148
1412
  // 同时清空 IndexDB 中的所有数据(包括商品和元数据)
1149
1413
  if (!this.dbManager) {
1150
- _context13.next = 16;
1414
+ _context16.next = 16;
1151
1415
  break;
1152
1416
  }
1153
- _context13.prev = 4;
1154
- _context13.next = 7;
1417
+ _context16.prev = 4;
1418
+ _context16.next = 7;
1155
1419
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1156
1420
  case 7:
1157
1421
  console.log('[Products] IndexDB 缓存已清空');
1158
1422
  this.logInfo('IndexDB 缓存已清空');
1159
- _context13.next = 16;
1423
+ _context16.next = 16;
1160
1424
  break;
1161
1425
  case 11:
1162
- _context13.prev = 11;
1163
- _context13.t0 = _context13["catch"](4);
1164
- errorMessage = _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0);
1165
- console.error('[Products] 清空 IndexDB 缓存失败:', _context13.t0);
1426
+ _context16.prev = 11;
1427
+ _context16.t0 = _context16["catch"](4);
1428
+ errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1429
+ console.error('[Products] 清空 IndexDB 缓存失败:', _context16.t0);
1166
1430
  this.logError('清空 IndexDB 缓存失败', {
1167
1431
  error: errorMessage
1168
1432
  });
@@ -1171,9 +1435,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1171
1435
  this.logInfo('缓存清空完成');
1172
1436
  case 18:
1173
1437
  case "end":
1174
- return _context13.stop();
1438
+ return _context16.stop();
1175
1439
  }
1176
- }, _callee13, this, [[4, 11]]);
1440
+ }, _callee16, this, [[4, 11]]);
1177
1441
  }));
1178
1442
  function clear() {
1179
1443
  return _clear.apply(this, arguments);
@@ -1188,45 +1452,45 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1188
1452
  }, {
1189
1453
  key: "loadProductsFromIndexDB",
1190
1454
  value: (function () {
1191
- var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1455
+ var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1192
1456
  var _products$length, _products$length2, t0, products, errorMessage;
1193
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1194
- while (1) switch (_context14.prev = _context14.next) {
1457
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1458
+ while (1) switch (_context17.prev = _context17.next) {
1195
1459
  case 0:
1196
1460
  if (this.dbManager) {
1197
- _context14.next = 3;
1461
+ _context17.next = 3;
1198
1462
  break;
1199
1463
  }
1200
1464
  this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
1201
- return _context14.abrupt("return", []);
1465
+ return _context17.abrupt("return", []);
1202
1466
  case 3:
1203
- _context14.prev = 3;
1467
+ _context17.prev = 3;
1204
1468
  t0 = performance.now();
1205
- _context14.next = 7;
1469
+ _context17.next = 7;
1206
1470
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1207
1471
  case 7:
1208
- products = _context14.sent;
1472
+ products = _context17.sent;
1209
1473
  perfMark('loadProductsFromIndexDB', performance.now() - t0, {
1210
1474
  count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
1211
1475
  });
1212
1476
  this.logInfo('从 IndexDB 加载商品数据', {
1213
1477
  productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
1214
1478
  });
1215
- return _context14.abrupt("return", products || []);
1479
+ return _context17.abrupt("return", products || []);
1216
1480
  case 13:
1217
- _context14.prev = 13;
1218
- _context14.t0 = _context14["catch"](3);
1219
- errorMessage = _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0);
1220
- console.error('[Products] 从 IndexDB 读取数据失败:', _context14.t0);
1481
+ _context17.prev = 13;
1482
+ _context17.t0 = _context17["catch"](3);
1483
+ errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1484
+ console.error('[Products] 从 IndexDB 读取数据失败:', _context17.t0);
1221
1485
  this.logError('从 IndexDB 读取数据失败', {
1222
1486
  error: errorMessage
1223
1487
  });
1224
- return _context14.abrupt("return", []);
1488
+ return _context17.abrupt("return", []);
1225
1489
  case 19:
1226
1490
  case "end":
1227
- return _context14.stop();
1491
+ return _context17.stop();
1228
1492
  }
1229
- }, _callee14, this, [[3, 13]]);
1493
+ }, _callee17, this, [[3, 13]]);
1230
1494
  }));
1231
1495
  function loadProductsFromIndexDB() {
1232
1496
  return _loadProductsFromIndexDB.apply(this, arguments);
@@ -1241,27 +1505,27 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1241
1505
  }, {
1242
1506
  key: "saveProductsToIndexDB",
1243
1507
  value: (function () {
1244
- var _saveProductsToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(products) {
1508
+ var _saveProductsToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(products) {
1245
1509
  var t0, errorMessage;
1246
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1247
- while (1) switch (_context15.prev = _context15.next) {
1510
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1511
+ while (1) switch (_context18.prev = _context18.next) {
1248
1512
  case 0:
1249
1513
  if (this.dbManager) {
1250
- _context15.next = 3;
1514
+ _context18.next = 3;
1251
1515
  break;
1252
1516
  }
1253
1517
  this.logWarning('saveProductsToIndexDB: dbManager 不可用');
1254
- return _context15.abrupt("return");
1518
+ return _context18.abrupt("return");
1255
1519
  case 3:
1256
1520
  this.logInfo('开始保存商品数据到 IndexDB', {
1257
1521
  productCount: products.length
1258
1522
  });
1259
- _context15.prev = 4;
1523
+ _context18.prev = 4;
1260
1524
  t0 = performance.now();
1261
- _context15.next = 8;
1525
+ _context18.next = 8;
1262
1526
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1263
1527
  case 8:
1264
- _context15.next = 10;
1528
+ _context18.next = 10;
1265
1529
  return this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
1266
1530
  case 10:
1267
1531
  perfMark('saveProductsToIndexDB', performance.now() - t0, {
@@ -1271,24 +1535,24 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1271
1535
  this.logInfo('商品数据已保存到 IndexDB', {
1272
1536
  productCount: products.length
1273
1537
  });
1274
- _context15.next = 20;
1538
+ _context18.next = 20;
1275
1539
  break;
1276
1540
  case 15:
1277
- _context15.prev = 15;
1278
- _context15.t0 = _context15["catch"](4);
1279
- errorMessage = _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0);
1280
- console.error('[Products] 保存数据到 IndexDB 失败:', _context15.t0);
1541
+ _context18.prev = 15;
1542
+ _context18.t0 = _context18["catch"](4);
1543
+ errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1544
+ console.error('[Products] 保存数据到 IndexDB 失败:', _context18.t0);
1281
1545
  this.logError('保存数据到 IndexDB 失败', {
1282
1546
  productCount: products.length,
1283
1547
  error: errorMessage
1284
1548
  });
1285
1549
  case 20:
1286
1550
  case "end":
1287
- return _context15.stop();
1551
+ return _context18.stop();
1288
1552
  }
1289
- }, _callee15, this, [[4, 15]]);
1553
+ }, _callee18, this, [[4, 15]]);
1290
1554
  }));
1291
- function saveProductsToIndexDB(_x16) {
1555
+ function saveProductsToIndexDB(_x19) {
1292
1556
  return _saveProductsToIndexDB.apply(this, arguments);
1293
1557
  }
1294
1558
  return saveProductsToIndexDB;
@@ -1328,26 +1592,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1328
1592
  }, {
1329
1593
  key: "preload",
1330
1594
  value: (function () {
1331
- var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1595
+ var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1332
1596
  var _products$length3;
1333
1597
  var tTotal, _cachedData$length, tIndexDB, cachedData, tSync, errorMessage, tServer, products, _tSync;
1334
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1335
- while (1) switch (_context16.prev = _context16.next) {
1598
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1599
+ while (1) switch (_context19.prev = _context19.next) {
1336
1600
  case 0:
1337
1601
  console.log('[Products] 开始预加载数据...');
1338
1602
  tTotal = performance.now();
1339
1603
  this.logInfo('开始预加载数据');
1340
- _context16.prev = 3;
1604
+ _context19.prev = 3;
1341
1605
  tIndexDB = performance.now();
1342
- _context16.next = 7;
1606
+ _context19.next = 7;
1343
1607
  return this.loadProductsFromIndexDB();
1344
1608
  case 7:
1345
- cachedData = _context16.sent;
1609
+ cachedData = _context19.sent;
1346
1610
  perfMark('preload.loadFromIndexDB', performance.now() - tIndexDB, {
1347
1611
  count: (_cachedData$length = cachedData === null || cachedData === void 0 ? void 0 : cachedData.length) !== null && _cachedData$length !== void 0 ? _cachedData$length : 0
1348
1612
  });
1349
1613
  if (!(cachedData && cachedData.length > 0)) {
1350
- _context16.next = 19;
1614
+ _context19.next = 19;
1351
1615
  break;
1352
1616
  }
1353
1617
  console.log("[Products] \u4ECE IndexDB \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u4E2A\u5546\u54C1"));
@@ -1368,26 +1632,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1368
1632
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
1369
1633
  source: 'IndexDB'
1370
1634
  });
1371
- return _context16.abrupt("return");
1635
+ return _context19.abrupt("return");
1372
1636
  case 19:
1373
1637
  console.log('[Products] IndexDB 中没有缓存数据,从服务器加载...');
1374
1638
  this.logInfo('IndexDB 中没有缓存数据,准备从服务器加载');
1375
- _context16.next = 28;
1639
+ _context19.next = 28;
1376
1640
  break;
1377
1641
  case 23:
1378
- _context16.prev = 23;
1379
- _context16.t0 = _context16["catch"](3);
1380
- errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1381
- console.warn('[Products] 从 IndexDB 加载数据失败:', _context16.t0);
1642
+ _context19.prev = 23;
1643
+ _context19.t0 = _context19["catch"](3);
1644
+ errorMessage = _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0);
1645
+ console.warn('[Products] 从 IndexDB 加载数据失败:', _context19.t0);
1382
1646
  this.logWarning('从 IndexDB 加载数据失败,准备从服务器加载', {
1383
1647
  error: errorMessage
1384
1648
  });
1385
1649
  case 28:
1386
1650
  tServer = performance.now();
1387
- _context16.next = 31;
1651
+ _context19.next = 31;
1388
1652
  return this.loadProductsByServer();
1389
1653
  case 31:
1390
- products = _context16.sent;
1654
+ products = _context19.sent;
1391
1655
  perfMark('preload.loadFromServer', performance.now() - tServer, {
1392
1656
  count: (_products$length3 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length3 !== void 0 ? _products$length3 : 0
1393
1657
  });
@@ -1419,9 +1683,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1419
1683
  }
1420
1684
  case 34:
1421
1685
  case "end":
1422
- return _context16.stop();
1686
+ return _context19.stop();
1423
1687
  }
1424
- }, _callee16, this, [[3, 23]]);
1688
+ }, _callee19, this, [[3, 23]]);
1425
1689
  }));
1426
1690
  function preload() {
1427
1691
  return _preload.apply(this, arguments);
@@ -1456,7 +1720,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1456
1720
  }, {
1457
1721
  key: "setupProductSync",
1458
1722
  value: function setupProductSync() {
1459
- var _this2 = this;
1723
+ var _this6 = this;
1460
1724
  if (!this.productDataSource) {
1461
1725
  this.logWarning('setupProductSync: ProductDataSource 不可用,跳过同步初始化');
1462
1726
  return;
@@ -1466,20 +1730,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1466
1730
  var data = (message === null || message === void 0 ? void 0 : message.data) || message;
1467
1731
  if (!data) return;
1468
1732
  console.log("[ProductsModule] \u6536\u5230\u540C\u6B65\u6D88\u606F [".concat(channelKey, "]:"), data);
1469
- _this2.logInfo('收到同步消息', {
1733
+ _this6.logInfo('收到同步消息', {
1470
1734
  channelKey: channelKey,
1471
1735
  action: data.action,
1472
1736
  id: data.id,
1473
1737
  action_filed: data.action_filed
1474
1738
  });
1475
- _this2.pendingSyncMessages.push(_objectSpread(_objectSpread({}, data), {}, {
1739
+ _this6.pendingSyncMessages.push(_objectSpread(_objectSpread({}, data), {}, {
1476
1740
  _channelKey: channelKey
1477
1741
  }));
1478
- if (_this2.syncTimer) {
1479
- clearTimeout(_this2.syncTimer);
1742
+ if (_this6.syncTimer) {
1743
+ clearTimeout(_this6.syncTimer);
1480
1744
  }
1481
- _this2.syncTimer = setTimeout(function () {
1482
- _this2.processProductSyncMessages();
1745
+ _this6.syncTimer = setTimeout(function () {
1746
+ _this6.processProductSyncMessages();
1483
1747
  }, PRODUCT_SYNC_DEBOUNCE_MS);
1484
1748
  };
1485
1749
  };
@@ -1487,7 +1751,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1487
1751
  pubsub: {
1488
1752
  callback: function callback(res) {
1489
1753
  console.log('sse_products_callback', res);
1490
- _this2.logInfo('sse_products_callback: 收到同步消息', {
1754
+ _this6.logInfo('sse_products_callback: 收到同步消息', {
1491
1755
  data: res === null || res === void 0 ? void 0 : res.data
1492
1756
  });
1493
1757
  if (!(res !== null && res !== void 0 && res.data)) return;
@@ -1497,7 +1761,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1497
1761
  }
1498
1762
  }
1499
1763
  }).catch(function (err) {
1500
- _this2.logError('setupProductSync: DataSource run 出错', {
1764
+ _this6.logError('setupProductSync: DataSource run 出错', {
1501
1765
  error: err instanceof Error ? err.message : String(err)
1502
1766
  });
1503
1767
  });
@@ -1525,18 +1789,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1525
1789
  }, {
1526
1790
  key: "processProductSyncMessages",
1527
1791
  value: (function () {
1528
- var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1529
- var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator7, _step7, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges;
1530
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1531
- while (1) switch (_context17.prev = _context17.next) {
1792
+ var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1793
+ var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator7, _step7, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges, errorMessage;
1794
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1795
+ while (1) switch (_context20.prev = _context20.next) {
1532
1796
  case 0:
1533
1797
  messages = _toConsumableArray(this.pendingSyncMessages);
1534
1798
  this.pendingSyncMessages = [];
1535
1799
  if (!(messages.length === 0)) {
1536
- _context17.next = 4;
1800
+ _context20.next = 4;
1537
1801
  break;
1538
1802
  }
1539
- return _context17.abrupt("return");
1803
+ return _context20.abrupt("return");
1540
1804
  case 4:
1541
1805
  this.logInfo('processProductSyncMessages: 开始处理', {
1542
1806
  count: messages.length
@@ -1547,17 +1811,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1547
1811
  priceRefreshIds = [];
1548
1812
  shouldClearPriceCache = false;
1549
1813
  _iterator7 = _createForOfIteratorHelper(messages);
1550
- _context17.prev = 11;
1814
+ _context20.prev = 11;
1551
1815
  _iterator7.s();
1552
1816
  case 13:
1553
1817
  if ((_step7 = _iterator7.n()).done) {
1554
- _context17.next = 36;
1818
+ _context20.next = 36;
1555
1819
  break;
1556
1820
  }
1557
1821
  msg = _step7.value;
1558
1822
  channelKey = msg._channelKey || msg.module || 'product';
1559
1823
  if (!(channelKey === 'product')) {
1560
- _context17.next = 33;
1824
+ _context20.next = 33;
1561
1825
  break;
1562
1826
  }
1563
1827
  if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
@@ -1565,14 +1829,14 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1565
1829
  }
1566
1830
  // 1. 删除场景:operation === 'delete' 或 action === 'delete'
1567
1831
  if (!(msg.operation === 'delete' || msg.action === 'delete')) {
1568
- _context17.next = 21;
1832
+ _context20.next = 21;
1569
1833
  break;
1570
1834
  }
1571
1835
  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);
1572
- return _context17.abrupt("continue", 34);
1836
+ return _context20.abrupt("continue", 34);
1573
1837
  case 21:
1574
1838
  if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
1575
- _context17.next = 26;
1839
+ _context20.next = 26;
1576
1840
  break;
1577
1841
  }
1578
1842
  ids = msg.ids || (msg.id ? [msg.id] : []);
@@ -1581,15 +1845,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1581
1845
  bodyId = msg.body.id;
1582
1846
  if (bodyId) bodyUpdates.set(bodyId, msg.body);
1583
1847
  }
1584
- return _context17.abrupt("continue", 34);
1848
+ return _context20.abrupt("continue", 34);
1585
1849
  case 26:
1586
1850
  if (!msg.body) {
1587
- _context17.next = 30;
1851
+ _context20.next = 30;
1588
1852
  break;
1589
1853
  }
1590
1854
  _bodyId = msg.body.id || msg.id;
1591
1855
  if (_bodyId) bodyUpdates.set(_bodyId, msg.body);
1592
- return _context17.abrupt("continue", 34);
1856
+ return _context20.abrupt("continue", 34);
1593
1857
  case 30:
1594
1858
  // 4. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
1595
1859
  if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
@@ -1597,7 +1861,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1597
1861
  } else if (msg.id) {
1598
1862
  sseRefreshIds.push(msg.id);
1599
1863
  }
1600
- _context17.next = 34;
1864
+ _context20.next = 34;
1601
1865
  break;
1602
1866
  case 33:
1603
1867
  if (channelKey === 'product_quotation') {
@@ -1612,50 +1876,50 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1612
1876
  }
1613
1877
  }
1614
1878
  case 34:
1615
- _context17.next = 13;
1879
+ _context20.next = 13;
1616
1880
  break;
1617
1881
  case 36:
1618
- _context17.next = 41;
1882
+ _context20.next = 41;
1619
1883
  break;
1620
1884
  case 38:
1621
- _context17.prev = 38;
1622
- _context17.t0 = _context17["catch"](11);
1623
- _iterator7.e(_context17.t0);
1885
+ _context20.prev = 38;
1886
+ _context20.t0 = _context20["catch"](11);
1887
+ _iterator7.e(_context20.t0);
1624
1888
  case 41:
1625
- _context17.prev = 41;
1889
+ _context20.prev = 41;
1626
1890
  _iterator7.f();
1627
- return _context17.finish(41);
1891
+ return _context20.finish(41);
1628
1892
  case 44:
1629
1893
  uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
1630
1894
  uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds));
1631
1895
  uniquePriceIds = _toConsumableArray(new Set(priceRefreshIds)); // 1. 处理删除
1632
1896
  if (!(uniqueDeleteIds.length > 0)) {
1633
- _context17.next = 50;
1897
+ _context20.next = 50;
1634
1898
  break;
1635
1899
  }
1636
- _context17.next = 50;
1900
+ _context20.next = 50;
1637
1901
  return this.removeProductsByIds(uniqueDeleteIds);
1638
1902
  case 50:
1639
1903
  if (!(bodyUpdates.size > 0)) {
1640
- _context17.next = 53;
1904
+ _context20.next = 53;
1641
1905
  break;
1642
1906
  }
1643
- _context17.next = 53;
1907
+ _context20.next = 53;
1644
1908
  return this.applyBodyUpdatesToStore(bodyUpdates);
1645
1909
  case 53:
1646
1910
  if (!(uniqueSSEIds.length > 0)) {
1647
- _context17.next = 61;
1911
+ _context20.next = 61;
1648
1912
  break;
1649
1913
  }
1650
- _context17.next = 56;
1914
+ _context20.next = 56;
1651
1915
  return this.fetchProductsBySSE(uniqueSSEIds);
1652
1916
  case 56:
1653
- freshProducts = _context17.sent;
1917
+ freshProducts = _context20.sent;
1654
1918
  if (!(freshProducts.length > 0)) {
1655
- _context17.next = 60;
1919
+ _context20.next = 60;
1656
1920
  break;
1657
1921
  }
1658
- _context17.next = 60;
1922
+ _context20.next = 60;
1659
1923
  return this.mergeProductsToStore(freshProducts);
1660
1924
  case 60:
1661
1925
  this.logInfo('processProductSyncMessages: SSE 增量更新完成123', {
@@ -1675,25 +1939,41 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1675
1939
  });
1676
1940
  hasChanges = uniqueDeleteIds.length > 0 || allChangedIds.length > 0 || shouldClearPriceCache;
1677
1941
  if (hasChanges) {
1678
- _context17.next = 67;
1942
+ _context20.next = 67;
1679
1943
  break;
1680
1944
  }
1681
1945
  this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
1682
- return _context17.abrupt("return");
1946
+ return _context20.abrupt("return");
1683
1947
  case 67:
1684
- // 报价单变更 → 清除全量价格缓存,后续走全量重建
1685
- if (shouldClearPriceCache) {
1686
- this.clearPriceCache();
1948
+ if (!shouldClearPriceCache) {
1949
+ _context20.next = 78;
1950
+ break;
1687
1951
  }
1688
- _context17.next = 70;
1952
+ _context20.prev = 68;
1953
+ _context20.next = 71;
1954
+ return this.refreshQuotationPriceBridge();
1955
+ case 71:
1956
+ _context20.next = 77;
1957
+ break;
1958
+ case 73:
1959
+ _context20.prev = 73;
1960
+ _context20.t1 = _context20["catch"](68);
1961
+ errorMessage = _context20.t1 instanceof Error ? _context20.t1.message : String(_context20.t1);
1962
+ this.logError('报价单桥接刷新失败,将继续清理价格缓存', {
1963
+ error: errorMessage
1964
+ });
1965
+ case 77:
1966
+ this.clearPriceCache();
1967
+ case 78:
1968
+ _context20.next = 80;
1689
1969
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, {
1690
1970
  changedIds: allChangedIds
1691
1971
  });
1692
- case 70:
1972
+ case 80:
1693
1973
  case "end":
1694
- return _context17.stop();
1974
+ return _context20.stop();
1695
1975
  }
1696
- }, _callee17, this, [[11, 38, 41, 44]]);
1976
+ }, _callee20, this, [[11, 38, 41, 44], [68, 73]]);
1697
1977
  }));
1698
1978
  function processProductSyncMessages() {
1699
1979
  return _processProductSyncMessages.apply(this, arguments);
@@ -1708,25 +1988,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1708
1988
  }, {
1709
1989
  key: "fetchProductsBySSE",
1710
1990
  value: (function () {
1711
- var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
1991
+ var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(ids) {
1712
1992
  var t0, productList, list, errorMessage;
1713
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1714
- while (1) switch (_context18.prev = _context18.next) {
1993
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1994
+ while (1) switch (_context21.prev = _context21.next) {
1715
1995
  case 0:
1716
1996
  if (this.productDataSource) {
1717
- _context18.next = 3;
1997
+ _context21.next = 3;
1718
1998
  break;
1719
1999
  }
1720
2000
  this.logWarning('fetchProductsBySSE: ProductDataSource 不可用');
1721
- return _context18.abrupt("return", []);
2001
+ return _context21.abrupt("return", []);
1722
2002
  case 3:
1723
2003
  this.logInfo('fetchProductsBySSE: 开始', {
1724
2004
  ids: ids,
1725
2005
  count: ids.length
1726
2006
  });
1727
2007
  t0 = performance.now();
1728
- _context18.prev = 5;
1729
- _context18.next = 8;
2008
+ _context21.prev = 5;
2009
+ _context21.next = 8;
1730
2010
  return this.productDataSource.run({
1731
2011
  sse: {
1732
2012
  query: {
@@ -1736,7 +2016,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1736
2016
  }
1737
2017
  });
1738
2018
  case 8:
1739
- productList = _context18.sent;
2019
+ productList = _context21.sent;
1740
2020
  list = productList || [];
1741
2021
  perfMark('fetchProductsBySSE', performance.now() - t0, {
1742
2022
  count: list.length
@@ -1746,23 +2026,23 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1746
2026
  receivedCount: list.length,
1747
2027
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1748
2028
  });
1749
- return _context18.abrupt("return", list);
2029
+ return _context21.abrupt("return", list);
1750
2030
  case 15:
1751
- _context18.prev = 15;
1752
- _context18.t0 = _context18["catch"](5);
1753
- errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
2031
+ _context21.prev = 15;
2032
+ _context21.t0 = _context21["catch"](5);
2033
+ errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1754
2034
  this.logError('fetchProductsBySSE: 失败', {
1755
2035
  ids: ids,
1756
2036
  error: errorMessage
1757
2037
  });
1758
- return _context18.abrupt("return", []);
2038
+ return _context21.abrupt("return", []);
1759
2039
  case 20:
1760
2040
  case "end":
1761
- return _context18.stop();
2041
+ return _context21.stop();
1762
2042
  }
1763
- }, _callee18, this, [[5, 15]]);
2043
+ }, _callee21, this, [[5, 15]]);
1764
2044
  }));
1765
- function fetchProductsBySSE(_x17) {
2045
+ function fetchProductsBySSE(_x20) {
1766
2046
  return _fetchProductsBySSE.apply(this, arguments);
1767
2047
  }
1768
2048
  return fetchProductsBySSE;
@@ -1777,10 +2057,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1777
2057
  }, {
1778
2058
  key: "applyBodyUpdatesToStore",
1779
2059
  value: (function () {
1780
- var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(bodyUpdates) {
2060
+ var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(bodyUpdates) {
1781
2061
  var updatedCount, newCount, appliedIds, _iterator8, _step8, _step8$value, id, body;
1782
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1783
- while (1) switch (_context19.prev = _context19.next) {
2062
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2063
+ while (1) switch (_context22.prev = _context22.next) {
1784
2064
  case 0:
1785
2065
  this.logInfo('applyBodyUpdatesToStore: 开始', {
1786
2066
  count: bodyUpdates.size
@@ -1811,7 +2091,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1811
2091
  _iterator8.f();
1812
2092
  }
1813
2093
  this.syncProductsMap();
1814
- _context19.next = 10;
2094
+ _context22.next = 10;
1815
2095
  return this.saveProductsToIndexDB(this.store.list);
1816
2096
  case 10:
1817
2097
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
@@ -1822,11 +2102,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1822
2102
  });
1823
2103
  case 12:
1824
2104
  case "end":
1825
- return _context19.stop();
2105
+ return _context22.stop();
1826
2106
  }
1827
- }, _callee19, this);
2107
+ }, _callee22, this);
1828
2108
  }));
1829
- function applyBodyUpdatesToStore(_x18) {
2109
+ function applyBodyUpdatesToStore(_x21) {
1830
2110
  return _applyBodyUpdatesToStore.apply(this, arguments);
1831
2111
  }
1832
2112
  return applyBodyUpdatesToStore;
@@ -1840,10 +2120,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1840
2120
  }, {
1841
2121
  key: "mergeProductsToStore",
1842
2122
  value: (function () {
1843
- var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(freshProducts) {
2123
+ var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(freshProducts) {
1844
2124
  var freshMap, _iterator9, _step9, p, updatedList, newCount, _iterator10, _step10, _p2, updatedCount;
1845
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1846
- while (1) switch (_context20.prev = _context20.next) {
2125
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2126
+ while (1) switch (_context23.prev = _context23.next) {
1847
2127
  case 0:
1848
2128
  freshMap = new Map();
1849
2129
  _iterator9 = _createForOfIteratorHelper(freshProducts);
@@ -1880,7 +2160,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1880
2160
  updatedCount = freshProducts.length - newCount;
1881
2161
  this.store.list = updatedList;
1882
2162
  this.syncProductsMap();
1883
- _context20.next = 12;
2163
+ _context23.next = 12;
1884
2164
  return this.saveProductsToIndexDB(this.store.list);
1885
2165
  case 12:
1886
2166
  this.logInfo('mergeProductsToStore: 合并完成', {
@@ -1891,11 +2171,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1891
2171
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1892
2172
  case 14:
1893
2173
  case "end":
1894
- return _context20.stop();
2174
+ return _context23.stop();
1895
2175
  }
1896
- }, _callee20, this);
2176
+ }, _callee23, this);
1897
2177
  }));
1898
- function mergeProductsToStore(_x19) {
2178
+ function mergeProductsToStore(_x22) {
1899
2179
  return _mergeProductsToStore.apply(this, arguments);
1900
2180
  }
1901
2181
  return mergeProductsToStore;
@@ -1909,34 +2189,34 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1909
2189
  }, {
1910
2190
  key: "silentRefresh",
1911
2191
  value: (function () {
1912
- var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2192
+ var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1913
2193
  var t0, products, errorMessage;
1914
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1915
- while (1) switch (_context21.prev = _context21.next) {
2194
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2195
+ while (1) switch (_context24.prev = _context24.next) {
1916
2196
  case 0:
1917
2197
  t0 = performance.now();
1918
2198
  this.logInfo('silentRefresh 开始');
1919
- _context21.prev = 2;
1920
- _context21.next = 5;
2199
+ _context24.prev = 2;
2200
+ _context24.next = 5;
1921
2201
  return this.loadProductsByServer();
1922
2202
  case 5:
1923
- products = _context21.sent;
2203
+ products = _context24.sent;
1924
2204
  if (!(products && products.length > 0)) {
1925
- _context21.next = 16;
2205
+ _context24.next = 16;
1926
2206
  break;
1927
2207
  }
1928
2208
  this.store.list = products;
1929
2209
  this.syncProductsMap();
1930
2210
  this.clearPriceCache();
1931
2211
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1932
- _context21.next = 13;
2212
+ _context24.next = 13;
1933
2213
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
1934
2214
  case 13:
1935
2215
  this.logInfo('silentRefresh 完成', {
1936
2216
  productCount: products.length,
1937
2217
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1938
2218
  });
1939
- _context21.next = 17;
2219
+ _context24.next = 17;
1940
2220
  break;
1941
2221
  case 16:
1942
2222
  this.logWarning('silentRefresh: 服务器未返回数据');
@@ -1944,21 +2224,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1944
2224
  perfMark('silentRefresh', performance.now() - t0, {
1945
2225
  count: this.store.list.length
1946
2226
  });
1947
- return _context21.abrupt("return", this.store.list);
2227
+ return _context24.abrupt("return", this.store.list);
1948
2228
  case 21:
1949
- _context21.prev = 21;
1950
- _context21.t0 = _context21["catch"](2);
1951
- errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
2229
+ _context24.prev = 21;
2230
+ _context24.t0 = _context24["catch"](2);
2231
+ errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
1952
2232
  this.logError('silentRefresh 失败', {
1953
2233
  duration: "".concat(Math.round(performance.now() - t0), "ms"),
1954
2234
  error: errorMessage
1955
2235
  });
1956
- return _context21.abrupt("return", this.store.list);
2236
+ return _context24.abrupt("return", this.store.list);
1957
2237
  case 26:
1958
2238
  case "end":
1959
- return _context21.stop();
2239
+ return _context24.stop();
1960
2240
  }
1961
- }, _callee21, this, [[2, 21]]);
2241
+ }, _callee24, this, [[2, 21]]);
1962
2242
  }));
1963
2243
  function silentRefresh() {
1964
2244
  return _silentRefresh.apply(this, arguments);