@pisell/pisellos 2.2.89 → 2.2.90

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.
@@ -7,11 +7,11 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
7
7
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
8
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
9
9
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
12
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
11
13
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
14
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
14
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
15
15
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
16
16
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
17
17
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -249,7 +249,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
249
249
  duration: "".concat(_duration, "ms"),
250
250
  error: errorMessage
251
251
  });
252
- throw _context2.t0;
252
+ return _context2.abrupt("return", []);
253
253
  case 18:
254
254
  case "end":
255
255
  return _context2.stop();
@@ -267,24 +267,112 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
267
267
  * 缓存的是已经应用了价格的完整商品列表,避免重复转换
268
268
  * @param schedule_date 日期
269
269
  * @param extraContext 额外的上下文数据(可选,由 Server 层传入)
270
+ * @param options 可选参数
271
+ * @param options.changedIds 变更的商品 IDs,非空时仅对这些商品增量执行 prepare 并更新缓存
270
272
  * @returns 应用了价格的商品列表
271
273
  */
272
274
  )
273
275
  }, {
274
276
  key: "getProductsWithPrice",
275
277
  value: (function () {
276
- var _getProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(schedule_date, extraContext) {
277
- var t0, cacheKey, cachedProducts, result;
278
+ var _getProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(schedule_date, extraContext, options) {
279
+ var t0, cacheKey, changedIds, cachedProducts, updatedProducts, updatedMap, mergedCache, _iterator, _step, p, _iterator2, _step2, _p, errorMessage, result;
278
280
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
279
281
  while (1) switch (_context3.prev = _context3.next) {
280
282
  case 0:
281
283
  t0 = performance.now();
282
284
  cacheKey = schedule_date;
285
+ changedIds = options === null || options === void 0 ? void 0 : options.changedIds;
283
286
  if (!this.productsPriceCache.has(cacheKey)) {
284
- _context3.next = 7;
287
+ _context3.next = 33;
288
+ break;
289
+ }
290
+ cachedProducts = this.productsPriceCache.get(cacheKey); // 有变更的商品 → 增量 prepare 后 merge 回缓存
291
+ if (!(changedIds && changedIds.length > 0)) {
292
+ _context3.next = 30;
293
+ break;
294
+ }
295
+ this.logInfo('商品价格缓存命中,增量更新变更商品', {
296
+ cacheKey: cacheKey,
297
+ changedIds: changedIds,
298
+ cachedProductCount: cachedProducts.length
299
+ });
300
+ _context3.prev = 7;
301
+ _context3.next = 10;
302
+ return this.prepareProductsWithPrice(schedule_date, extraContext, {
303
+ productIds: changedIds
304
+ });
305
+ case 10:
306
+ updatedProducts = _context3.sent;
307
+ if (!(updatedProducts.length > 0)) {
308
+ _context3.next = 22;
285
309
  break;
286
310
  }
287
- cachedProducts = this.productsPriceCache.get(cacheKey);
311
+ // merge:用更新结果替换缓存中对应的商品,新增的追加
312
+ updatedMap = new Map(updatedProducts.map(function (p) {
313
+ return [p.id, p];
314
+ }));
315
+ mergedCache = [];
316
+ _iterator = _createForOfIteratorHelper(cachedProducts);
317
+ try {
318
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
319
+ p = _step.value;
320
+ if (updatedMap.has(p.id)) {
321
+ mergedCache.push(updatedMap.get(p.id));
322
+ updatedMap.delete(p.id);
323
+ } else {
324
+ mergedCache.push(p);
325
+ }
326
+ }
327
+ // 剩余的是新增商品(create 场景)
328
+ } catch (err) {
329
+ _iterator.e(err);
330
+ } finally {
331
+ _iterator.f();
332
+ }
333
+ _iterator2 = _createForOfIteratorHelper(updatedMap.values());
334
+ try {
335
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
336
+ _p = _step2.value;
337
+ mergedCache.push(_p);
338
+ }
339
+ } catch (err) {
340
+ _iterator2.e(err);
341
+ } finally {
342
+ _iterator2.f();
343
+ }
344
+ this.productsPriceCache.set(cacheKey, mergedCache);
345
+ this.logInfo('增量更新完成', {
346
+ cacheKey: cacheKey,
347
+ changedCount: updatedProducts.length,
348
+ totalCount: mergedCache.length
349
+ });
350
+ perfMark('getProductsWithPrice(incrementalUpdate)', performance.now() - t0, {
351
+ cacheKey: cacheKey,
352
+ changedCount: changedIds.length,
353
+ count: mergedCache.length
354
+ });
355
+ return _context3.abrupt("return", mergedCache);
356
+ case 22:
357
+ _context3.next = 28;
358
+ break;
359
+ case 24:
360
+ _context3.prev = 24;
361
+ _context3.t0 = _context3["catch"](7);
362
+ errorMessage = _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0);
363
+ this.logError('增量更新失败,返回现有缓存', {
364
+ cacheKey: cacheKey,
365
+ changedIds: changedIds,
366
+ error: errorMessage
367
+ });
368
+ case 28:
369
+ perfMark('getProductsWithPrice(incrementalUpdate)', performance.now() - t0, {
370
+ cacheKey: cacheKey,
371
+ changedCount: changedIds.length,
372
+ count: cachedProducts.length
373
+ });
374
+ return _context3.abrupt("return", cachedProducts);
375
+ case 30:
288
376
  perfMark('getProductsWithPrice(cacheHit)', performance.now() - t0, {
289
377
  cacheKey: cacheKey,
290
378
  count: cachedProducts.length
@@ -294,13 +382,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
294
382
  productCount: cachedProducts.length
295
383
  });
296
384
  return _context3.abrupt("return", cachedProducts);
297
- case 7:
385
+ case 33:
298
386
  this.logInfo('商品价格缓存未命中,准备获取', {
299
387
  cacheKey: cacheKey
300
388
  });
301
- _context3.next = 10;
389
+ _context3.next = 36;
302
390
  return this.prepareProductsWithPrice(schedule_date, extraContext);
303
- case 10:
391
+ case 36:
304
392
  result = _context3.sent;
305
393
  this.productsPriceCache.set(cacheKey, result);
306
394
  this.logInfo('商品价格已缓存', {
@@ -313,13 +401,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
313
401
  count: result.length
314
402
  });
315
403
  return _context3.abrupt("return", result);
316
- case 16:
404
+ case 42:
317
405
  case "end":
318
406
  return _context3.stop();
319
407
  }
320
- }, _callee3, this);
408
+ }, _callee3, this, [[7, 24]]);
321
409
  }));
322
- function getProductsWithPrice(_x4, _x5) {
410
+ function getProductsWithPrice(_x4, _x5, _x6) {
323
411
  return _getProductsWithPrice.apply(this, arguments);
324
412
  }
325
413
  return getProductsWithPrice;
@@ -328,47 +416,62 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
328
416
  * 准备带价格的商品数据(通过格式化器流程处理)
329
417
  * @param schedule_date 日期
330
418
  * @param extraContext 额外的上下文数据(可选)
331
- * @returns 完整处理后的商品列表
419
+ * @param options 可选参数
420
+ * @param options.productIds 指定商品 IDs,仅处理这些商品;不传则处理全量
421
+ * @returns 处理后的商品列表
332
422
  * @private
333
423
  */
334
424
  )
335
425
  }, {
336
426
  key: "prepareProductsWithPrice",
337
427
  value: (function () {
338
- var _prepareProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(schedule_date, extraContext) {
339
- var tTotal, _priceData$length, allProducts, tIds, ids, i, tPrice, priceData, context, tFormat, processedProducts, errorMessage;
428
+ var _prepareProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(schedule_date, extraContext, options) {
429
+ var tTotal, targetIds, isIncremental, _priceData$length, products, ids, idSet, tIds, i, tPrice, priceData, context, tFormat, processedProducts, errorMessage;
340
430
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
341
431
  while (1) switch (_context4.prev = _context4.next) {
342
432
  case 0:
343
433
  tTotal = performance.now();
434
+ targetIds = options === null || options === void 0 ? void 0 : options.productIds;
435
+ isIncremental = targetIds && targetIds.length > 0;
344
436
  this.logInfo('prepareProductsWithPrice 开始处理', {
345
- schedule_date: schedule_date
346
- });
347
- _context4.prev = 2;
348
- // 1. 获取商品列表(内部引用,无拷贝 — formatter 会创建新对象)
349
- allProducts = this.getProductsRef();
350
- this.logInfo('获取到商品列表', {
351
- productCount: allProducts.length
437
+ schedule_date: schedule_date,
438
+ mode: isIncremental ? 'incremental' : 'full',
439
+ targetIdsCount: targetIds === null || targetIds === void 0 ? void 0 : targetIds.length
352
440
  });
441
+ _context4.prev = 4;
442
+ // 1. 获取商品列表:指定 IDs 时从 store 取子集,否则取全量
353
443
 
354
- // 2. 提取 IDs(预分配数组,避免 sort 开销)
355
- tIds = performance.now();
356
- ids = new Array(allProducts.length);
357
- for (i = 0; i < allProducts.length; i++) {
358
- ids[i] = allProducts[i].id;
444
+ if (isIncremental) {
445
+ idSet = new Set(targetIds);
446
+ products = this.getProductsRef().filter(function (p) {
447
+ return idSet.has(p.id);
448
+ });
449
+ ids = products.map(function (p) {
450
+ return p.id;
451
+ });
452
+ } else {
453
+ products = this.getProductsRef();
454
+ tIds = performance.now();
455
+ ids = new Array(products.length);
456
+ for (i = 0; i < products.length; i++) {
457
+ ids[i] = products[i].id;
458
+ }
459
+ perfMark('prepareProducts.extractIds', performance.now() - tIds, {
460
+ count: ids.length
461
+ });
359
462
  }
360
- perfMark('prepareProducts.extractIds', performance.now() - tIds, {
361
- count: ids.length
463
+ this.logInfo('获取到商品列表', {
464
+ productCount: products.length
362
465
  });
363
466
 
364
- // 3. 获取价格数据(网络请求)
467
+ // 2. 获取价格数据(网络请求)
365
468
  tPrice = performance.now();
366
- _context4.next = 12;
469
+ _context4.next = 10;
367
470
  return this.loadProductsPrice({
368
471
  ids: ids,
369
472
  schedule_date: schedule_date
370
473
  });
371
- case 12:
474
+ case 10:
372
475
  priceData = _context4.sent;
373
476
  perfMark('prepareProducts.loadPrice', performance.now() - tPrice, {
374
477
  count: ids.length
@@ -379,47 +482,53 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
379
482
  context = _objectSpread({
380
483
  schedule_date: schedule_date,
381
484
  priceData: priceData
382
- }, extraContext); // 4. 通过格式化器流程处理商品
485
+ }, extraContext); // 3. 通过格式化器流程处理商品
383
486
  tFormat = performance.now();
384
- _context4.next = 19;
385
- return this.applyFormatters(allProducts, context);
386
- case 19:
487
+ _context4.next = 17;
488
+ return this.applyFormatters(products, context);
489
+ case 17:
387
490
  processedProducts = _context4.sent;
388
491
  perfMark('prepareProducts.applyFormatters', performance.now() - tFormat, {
389
- count: allProducts.length,
492
+ count: products.length,
390
493
  formatterCount: this.formatters.length
391
494
  });
392
495
  this.logInfo('prepareProductsWithPrice 处理完成', {
393
- originalProductCount: allProducts.length,
496
+ mode: isIncremental ? 'incremental' : 'full',
497
+ originalProductCount: products.length,
394
498
  processedProductCount: processedProducts.length,
395
499
  formatterCount: this.formatters.length
396
500
  });
397
- _context4.next = 24;
501
+ if (isIncremental) {
502
+ _context4.next = 23;
503
+ break;
504
+ }
505
+ _context4.next = 23;
398
506
  return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
399
- case 24:
507
+ case 23:
400
508
  perfMark('prepareProductsWithPrice', performance.now() - tTotal, {
401
- productCount: allProducts.length,
402
- formatterCount: this.formatters.length
509
+ productCount: products.length,
510
+ formatterCount: this.formatters.length,
511
+ mode: isIncremental ? 'incremental' : 'full'
403
512
  });
404
513
  return _context4.abrupt("return", processedProducts);
405
- case 28:
406
- _context4.prev = 28;
407
- _context4.t0 = _context4["catch"](2);
514
+ case 27:
515
+ _context4.prev = 27;
516
+ _context4.t0 = _context4["catch"](4);
408
517
  errorMessage = _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0);
409
518
  console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context4.t0);
410
519
  this.logError('prepareProductsWithPrice 处理失败', {
411
520
  schedule_date: schedule_date,
412
521
  error: errorMessage
413
522
  });
414
- case 33:
523
+ case 32:
415
524
  return _context4.abrupt("return", []);
416
- case 34:
525
+ case 33:
417
526
  case "end":
418
527
  return _context4.stop();
419
528
  }
420
- }, _callee4, this, [[2, 28]]);
529
+ }, _callee4, this, [[4, 27]]);
421
530
  }));
422
- function prepareProductsWithPrice(_x6, _x7) {
531
+ function prepareProductsWithPrice(_x7, _x8, _x9) {
423
532
  return _prepareProductsWithPrice.apply(this, arguments);
424
533
  }
425
534
  return prepareProductsWithPrice;
@@ -501,7 +610,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
501
610
  }
502
611
  }, _callee5, this, [[9, 17]]);
503
612
  }));
504
- function applyFormatters(_x8, _x9) {
613
+ function applyFormatters(_x10, _x11) {
505
614
  return _applyFormatters.apply(this, arguments);
506
615
  }
507
616
  return applyFormatters;
@@ -755,7 +864,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
755
864
  }
756
865
  }, _callee7, this, [[3, 13]]);
757
866
  }));
758
- function fetchProductsByHttp(_x10) {
867
+ function fetchProductsByHttp(_x12) {
759
868
  return _fetchProductsByHttp.apply(this, arguments);
760
869
  }
761
870
  return fetchProductsByHttp;
@@ -795,7 +904,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
795
904
  }
796
905
  }, _callee8, this);
797
906
  }));
798
- function loadProductsByServerHttp(_x11) {
907
+ function loadProductsByServerHttp(_x13) {
799
908
  return _loadProductsByServerHttp.apply(this, arguments);
800
909
  }
801
910
  return loadProductsByServerHttp;
@@ -860,7 +969,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
860
969
  }
861
970
  }, _callee10, this);
862
971
  }));
863
- function getProductById(_x12) {
972
+ function getProductById(_x14) {
864
973
  return _getProductById.apply(this, arguments);
865
974
  }
866
975
  return getProductById;
@@ -874,7 +983,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
874
983
  key: "removeProductsByIds",
875
984
  value: (function () {
876
985
  var _removeProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ids) {
877
- var idSet, _iterator, _step, _id, _iterator2, _step2, id, errorMessage, _iterator3, _step3, _step3$value, dateKey, cachedProducts;
986
+ var idSet, _iterator3, _step3, _id, _iterator4, _step4, id, errorMessage, _iterator5, _step5, _step5$value, dateKey, cachedProducts;
878
987
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
879
988
  while (1) switch (_context11.prev = _context11.next) {
880
989
  case 0:
@@ -886,31 +995,31 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
886
995
  this.store.list = this.store.list.filter(function (p) {
887
996
  return !idSet.has(p.id);
888
997
  });
889
- _iterator = _createForOfIteratorHelper(ids);
998
+ _iterator3 = _createForOfIteratorHelper(ids);
890
999
  try {
891
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
892
- _id = _step.value;
1000
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1001
+ _id = _step3.value;
893
1002
  this.store.map.delete(_id);
894
1003
  }
895
1004
  } catch (err) {
896
- _iterator.e(err);
1005
+ _iterator3.e(err);
897
1006
  } finally {
898
- _iterator.f();
1007
+ _iterator3.f();
899
1008
  }
900
1009
  if (!this.dbManager) {
901
1010
  _context11.next = 30;
902
1011
  break;
903
1012
  }
904
1013
  _context11.prev = 6;
905
- _iterator2 = _createForOfIteratorHelper(ids);
1014
+ _iterator4 = _createForOfIteratorHelper(ids);
906
1015
  _context11.prev = 8;
907
- _iterator2.s();
1016
+ _iterator4.s();
908
1017
  case 10:
909
- if ((_step2 = _iterator2.n()).done) {
1018
+ if ((_step4 = _iterator4.n()).done) {
910
1019
  _context11.next = 16;
911
1020
  break;
912
1021
  }
913
- id = _step2.value;
1022
+ id = _step4.value;
914
1023
  _context11.next = 14;
915
1024
  return this.dbManager.delete(INDEXDB_STORE_NAME, id);
916
1025
  case 14:
@@ -922,10 +1031,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
922
1031
  case 18:
923
1032
  _context11.prev = 18;
924
1033
  _context11.t0 = _context11["catch"](8);
925
- _iterator2.e(_context11.t0);
1034
+ _iterator4.e(_context11.t0);
926
1035
  case 21:
927
1036
  _context11.prev = 21;
928
- _iterator2.f();
1037
+ _iterator4.f();
929
1038
  return _context11.finish(21);
930
1039
  case 24:
931
1040
  _context11.next = 30;
@@ -939,18 +1048,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
939
1048
  error: errorMessage
940
1049
  });
941
1050
  case 30:
942
- _iterator3 = _createForOfIteratorHelper(this.productsPriceCache.entries());
1051
+ _iterator5 = _createForOfIteratorHelper(this.productsPriceCache.entries());
943
1052
  try {
944
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
945
- _step3$value = _slicedToArray(_step3.value, 2), dateKey = _step3$value[0], cachedProducts = _step3$value[1];
1053
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1054
+ _step5$value = _slicedToArray(_step5.value, 2), dateKey = _step5$value[0], cachedProducts = _step5$value[1];
946
1055
  this.productsPriceCache.set(dateKey, cachedProducts.filter(function (p) {
947
1056
  return !idSet.has(p.id);
948
1057
  }));
949
1058
  }
950
1059
  } catch (err) {
951
- _iterator3.e(err);
1060
+ _iterator5.e(err);
952
1061
  } finally {
953
- _iterator3.f();
1062
+ _iterator5.f();
954
1063
  }
955
1064
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
956
1065
  this.logInfo('removeProductsByIds 完成', {
@@ -962,7 +1071,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
962
1071
  }
963
1072
  }, _callee11, this, [[6, 26], [8, 18, 21, 24]]);
964
1073
  }));
965
- function removeProductsByIds(_x13) {
1074
+ function removeProductsByIds(_x15) {
966
1075
  return _removeProductsByIds.apply(this, arguments);
967
1076
  }
968
1077
  return removeProductsByIds;
@@ -1012,33 +1121,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1012
1121
  }
1013
1122
  return refreshProducts;
1014
1123
  }()
1015
- /**
1016
- * 指定商品的报价单价格变更时,清除价格缓存
1017
- * 后续查询会走完整的 formatter 管道重建缓存
1018
- */
1019
- )
1020
- }, {
1021
- key: "updateProductPriceByIds",
1022
- value: (function () {
1023
- var _updateProductPriceByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(ids) {
1024
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1025
- while (1) switch (_context13.prev = _context13.next) {
1026
- case 0:
1027
- this.logInfo('updateProductPriceByIds: 清除价格缓存', {
1028
- ids: ids
1029
- });
1030
- this.clearPriceCache();
1031
- case 2:
1032
- case "end":
1033
- return _context13.stop();
1034
- }
1035
- }, _callee13, this);
1036
- }));
1037
- function updateProductPriceByIds(_x14) {
1038
- return _updateProductPriceByIds.apply(this, arguments);
1039
- }
1040
- return updateProductPriceByIds;
1041
- }()
1042
1124
  /**
1043
1125
  * 清空缓存
1044
1126
  */
@@ -1046,10 +1128,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1046
1128
  }, {
1047
1129
  key: "clear",
1048
1130
  value: (function () {
1049
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1131
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1050
1132
  var errorMessage;
1051
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1052
- while (1) switch (_context14.prev = _context14.next) {
1133
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1134
+ while (1) switch (_context13.prev = _context13.next) {
1053
1135
  case 0:
1054
1136
  this.logInfo('开始清空缓存', {
1055
1137
  currentProductCount: this.store.list.length,
@@ -1060,22 +1142,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1060
1142
 
1061
1143
  // 同时清空 IndexDB 中的所有数据(包括商品和元数据)
1062
1144
  if (!this.dbManager) {
1063
- _context14.next = 16;
1145
+ _context13.next = 16;
1064
1146
  break;
1065
1147
  }
1066
- _context14.prev = 4;
1067
- _context14.next = 7;
1148
+ _context13.prev = 4;
1149
+ _context13.next = 7;
1068
1150
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1069
1151
  case 7:
1070
1152
  console.log('[Products] IndexDB 缓存已清空');
1071
1153
  this.logInfo('IndexDB 缓存已清空');
1072
- _context14.next = 16;
1154
+ _context13.next = 16;
1073
1155
  break;
1074
1156
  case 11:
1075
- _context14.prev = 11;
1076
- _context14.t0 = _context14["catch"](4);
1077
- errorMessage = _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0);
1078
- console.error('[Products] 清空 IndexDB 缓存失败:', _context14.t0);
1157
+ _context13.prev = 11;
1158
+ _context13.t0 = _context13["catch"](4);
1159
+ errorMessage = _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0);
1160
+ console.error('[Products] 清空 IndexDB 缓存失败:', _context13.t0);
1079
1161
  this.logError('清空 IndexDB 缓存失败', {
1080
1162
  error: errorMessage
1081
1163
  });
@@ -1084,9 +1166,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1084
1166
  this.logInfo('缓存清空完成');
1085
1167
  case 18:
1086
1168
  case "end":
1087
- return _context14.stop();
1169
+ return _context13.stop();
1088
1170
  }
1089
- }, _callee14, this, [[4, 11]]);
1171
+ }, _callee13, this, [[4, 11]]);
1090
1172
  }));
1091
1173
  function clear() {
1092
1174
  return _clear.apply(this, arguments);
@@ -1101,45 +1183,45 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1101
1183
  }, {
1102
1184
  key: "loadProductsFromIndexDB",
1103
1185
  value: (function () {
1104
- var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1186
+ var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1105
1187
  var _products$length, _products$length2, t0, products, errorMessage;
1106
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1107
- while (1) switch (_context15.prev = _context15.next) {
1188
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1189
+ while (1) switch (_context14.prev = _context14.next) {
1108
1190
  case 0:
1109
1191
  if (this.dbManager) {
1110
- _context15.next = 3;
1192
+ _context14.next = 3;
1111
1193
  break;
1112
1194
  }
1113
1195
  this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
1114
- return _context15.abrupt("return", []);
1196
+ return _context14.abrupt("return", []);
1115
1197
  case 3:
1116
- _context15.prev = 3;
1198
+ _context14.prev = 3;
1117
1199
  t0 = performance.now();
1118
- _context15.next = 7;
1200
+ _context14.next = 7;
1119
1201
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1120
1202
  case 7:
1121
- products = _context15.sent;
1203
+ products = _context14.sent;
1122
1204
  perfMark('loadProductsFromIndexDB', performance.now() - t0, {
1123
1205
  count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
1124
1206
  });
1125
1207
  this.logInfo('从 IndexDB 加载商品数据', {
1126
1208
  productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
1127
1209
  });
1128
- return _context15.abrupt("return", products || []);
1210
+ return _context14.abrupt("return", products || []);
1129
1211
  case 13:
1130
- _context15.prev = 13;
1131
- _context15.t0 = _context15["catch"](3);
1132
- errorMessage = _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0);
1133
- console.error('[Products] 从 IndexDB 读取数据失败:', _context15.t0);
1212
+ _context14.prev = 13;
1213
+ _context14.t0 = _context14["catch"](3);
1214
+ errorMessage = _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0);
1215
+ console.error('[Products] 从 IndexDB 读取数据失败:', _context14.t0);
1134
1216
  this.logError('从 IndexDB 读取数据失败', {
1135
1217
  error: errorMessage
1136
1218
  });
1137
- return _context15.abrupt("return", []);
1219
+ return _context14.abrupt("return", []);
1138
1220
  case 19:
1139
1221
  case "end":
1140
- return _context15.stop();
1222
+ return _context14.stop();
1141
1223
  }
1142
- }, _callee15, this, [[3, 13]]);
1224
+ }, _callee14, this, [[3, 13]]);
1143
1225
  }));
1144
1226
  function loadProductsFromIndexDB() {
1145
1227
  return _loadProductsFromIndexDB.apply(this, arguments);
@@ -1154,27 +1236,27 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1154
1236
  }, {
1155
1237
  key: "saveProductsToIndexDB",
1156
1238
  value: (function () {
1157
- var _saveProductsToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(products) {
1239
+ var _saveProductsToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(products) {
1158
1240
  var t0, errorMessage;
1159
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1160
- while (1) switch (_context16.prev = _context16.next) {
1241
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1242
+ while (1) switch (_context15.prev = _context15.next) {
1161
1243
  case 0:
1162
1244
  if (this.dbManager) {
1163
- _context16.next = 3;
1245
+ _context15.next = 3;
1164
1246
  break;
1165
1247
  }
1166
1248
  this.logWarning('saveProductsToIndexDB: dbManager 不可用');
1167
- return _context16.abrupt("return");
1249
+ return _context15.abrupt("return");
1168
1250
  case 3:
1169
1251
  this.logInfo('开始保存商品数据到 IndexDB', {
1170
1252
  productCount: products.length
1171
1253
  });
1172
- _context16.prev = 4;
1254
+ _context15.prev = 4;
1173
1255
  t0 = performance.now();
1174
- _context16.next = 8;
1256
+ _context15.next = 8;
1175
1257
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1176
1258
  case 8:
1177
- _context16.next = 10;
1259
+ _context15.next = 10;
1178
1260
  return this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
1179
1261
  case 10:
1180
1262
  perfMark('saveProductsToIndexDB', performance.now() - t0, {
@@ -1184,24 +1266,24 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1184
1266
  this.logInfo('商品数据已保存到 IndexDB', {
1185
1267
  productCount: products.length
1186
1268
  });
1187
- _context16.next = 20;
1269
+ _context15.next = 20;
1188
1270
  break;
1189
1271
  case 15:
1190
- _context16.prev = 15;
1191
- _context16.t0 = _context16["catch"](4);
1192
- errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1193
- console.error('[Products] 保存数据到 IndexDB 失败:', _context16.t0);
1272
+ _context15.prev = 15;
1273
+ _context15.t0 = _context15["catch"](4);
1274
+ errorMessage = _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0);
1275
+ console.error('[Products] 保存数据到 IndexDB 失败:', _context15.t0);
1194
1276
  this.logError('保存数据到 IndexDB 失败', {
1195
1277
  productCount: products.length,
1196
1278
  error: errorMessage
1197
1279
  });
1198
1280
  case 20:
1199
1281
  case "end":
1200
- return _context16.stop();
1282
+ return _context15.stop();
1201
1283
  }
1202
- }, _callee16, this, [[4, 15]]);
1284
+ }, _callee15, this, [[4, 15]]);
1203
1285
  }));
1204
- function saveProductsToIndexDB(_x15) {
1286
+ function saveProductsToIndexDB(_x16) {
1205
1287
  return _saveProductsToIndexDB.apply(this, arguments);
1206
1288
  }
1207
1289
  return saveProductsToIndexDB;
@@ -1217,17 +1299,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1217
1299
  value: function syncProductsMap() {
1218
1300
  var t0 = performance.now();
1219
1301
  this.store.map.clear();
1220
- var _iterator4 = _createForOfIteratorHelper(this.store.list),
1221
- _step4;
1302
+ var _iterator6 = _createForOfIteratorHelper(this.store.list),
1303
+ _step6;
1222
1304
  try {
1223
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1224
- var product = _step4.value;
1305
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1306
+ var product = _step6.value;
1225
1307
  this.store.map.set(product.id, product);
1226
1308
  }
1227
1309
  } catch (err) {
1228
- _iterator4.e(err);
1310
+ _iterator6.e(err);
1229
1311
  } finally {
1230
- _iterator4.f();
1312
+ _iterator6.f();
1231
1313
  }
1232
1314
  perfMark('syncProductsMap', performance.now() - t0, {
1233
1315
  count: this.store.map.size
@@ -1241,26 +1323,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1241
1323
  }, {
1242
1324
  key: "preload",
1243
1325
  value: (function () {
1244
- var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1326
+ var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1245
1327
  var _products$length3;
1246
1328
  var tTotal, _cachedData$length, tIndexDB, cachedData, tSync, errorMessage, tServer, products, _tSync;
1247
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1248
- while (1) switch (_context17.prev = _context17.next) {
1329
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1330
+ while (1) switch (_context16.prev = _context16.next) {
1249
1331
  case 0:
1250
1332
  console.log('[Products] 开始预加载数据...');
1251
1333
  tTotal = performance.now();
1252
1334
  this.logInfo('开始预加载数据');
1253
- _context17.prev = 3;
1335
+ _context16.prev = 3;
1254
1336
  tIndexDB = performance.now();
1255
- _context17.next = 7;
1337
+ _context16.next = 7;
1256
1338
  return this.loadProductsFromIndexDB();
1257
1339
  case 7:
1258
- cachedData = _context17.sent;
1340
+ cachedData = _context16.sent;
1259
1341
  perfMark('preload.loadFromIndexDB', performance.now() - tIndexDB, {
1260
1342
  count: (_cachedData$length = cachedData === null || cachedData === void 0 ? void 0 : cachedData.length) !== null && _cachedData$length !== void 0 ? _cachedData$length : 0
1261
1343
  });
1262
1344
  if (!(cachedData && cachedData.length > 0)) {
1263
- _context17.next = 19;
1345
+ _context16.next = 19;
1264
1346
  break;
1265
1347
  }
1266
1348
  console.log("[Products] \u4ECE IndexDB \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u4E2A\u5546\u54C1"));
@@ -1281,26 +1363,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1281
1363
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
1282
1364
  source: 'IndexDB'
1283
1365
  });
1284
- return _context17.abrupt("return");
1366
+ return _context16.abrupt("return");
1285
1367
  case 19:
1286
1368
  console.log('[Products] IndexDB 中没有缓存数据,从服务器加载...');
1287
1369
  this.logInfo('IndexDB 中没有缓存数据,准备从服务器加载');
1288
- _context17.next = 28;
1370
+ _context16.next = 28;
1289
1371
  break;
1290
1372
  case 23:
1291
- _context17.prev = 23;
1292
- _context17.t0 = _context17["catch"](3);
1293
- errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1294
- console.warn('[Products] 从 IndexDB 加载数据失败:', _context17.t0);
1373
+ _context16.prev = 23;
1374
+ _context16.t0 = _context16["catch"](3);
1375
+ errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1376
+ console.warn('[Products] 从 IndexDB 加载数据失败:', _context16.t0);
1295
1377
  this.logWarning('从 IndexDB 加载数据失败,准备从服务器加载', {
1296
1378
  error: errorMessage
1297
1379
  });
1298
1380
  case 28:
1299
1381
  tServer = performance.now();
1300
- _context17.next = 31;
1382
+ _context16.next = 31;
1301
1383
  return this.loadProductsByServer();
1302
1384
  case 31:
1303
- products = _context17.sent;
1385
+ products = _context16.sent;
1304
1386
  perfMark('preload.loadFromServer', performance.now() - tServer, {
1305
1387
  count: (_products$length3 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length3 !== void 0 ? _products$length3 : 0
1306
1388
  });
@@ -1332,9 +1414,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1332
1414
  }
1333
1415
  case 34:
1334
1416
  case "end":
1335
- return _context17.stop();
1417
+ return _context16.stop();
1336
1418
  }
1337
- }, _callee17, this, [[3, 23]]);
1419
+ }, _callee16, this, [[3, 23]]);
1338
1420
  }));
1339
1421
  function preload() {
1340
1422
  return _preload.apply(this, arguments);
@@ -1422,30 +1504,34 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1422
1504
  *
1423
1505
  * product 模块:
1424
1506
  * - operation === 'delete' → 本地删除
1425
- * - change_types 包含 price → SSE 增量拉取
1507
+ * - change_types 包含 price → 仅收集变更 IDs(不拉商品数据)
1426
1508
  * - 有 body → body 完整数据直接覆盖本地
1509
+ * - 其他 → SSE 增量拉取
1427
1510
  *
1428
- * product_collection / product_category / product_quotation
1511
+ * product_collection / product_category:
1429
1512
  * - 按 relation_product_ids SSE 拉取受影响商品
1430
1513
  *
1431
- * 处理完成后清除价格缓存并 emit onProductsSyncCompleted,
1432
- * Server 层监听该事件后重新查询,走完整的 formatter 管道重建缓存
1514
+ * product_quotation:
1515
+ * - 报价单变更影响范围大,直接清除价格缓存走全量重建
1516
+ *
1517
+ * 处理完成后 emit onProductsSyncCompleted(携带 changedIds),
1518
+ * Server 层监听该事件后对变更商品增量执行 prepareProductsWithPrice 并更新缓存
1433
1519
  */
1434
1520
  }, {
1435
1521
  key: "processProductSyncMessages",
1436
1522
  value: (function () {
1437
- var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1438
- var messages, deleteIds, bodyUpdates, sseRefreshIds, _iterator5, _step5, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _msg$relation_product2, uniqueDeleteIds, uniqueSSEIds, freshProducts;
1439
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1440
- while (1) switch (_context18.prev = _context18.next) {
1523
+ var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1524
+ var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator7, _step7, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, allChangedIds, hasChanges;
1525
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1526
+ while (1) switch (_context17.prev = _context17.next) {
1441
1527
  case 0:
1442
1528
  messages = _toConsumableArray(this.pendingSyncMessages);
1443
1529
  this.pendingSyncMessages = [];
1444
1530
  if (!(messages.length === 0)) {
1445
- _context18.next = 4;
1531
+ _context17.next = 4;
1446
1532
  break;
1447
1533
  }
1448
- return _context18.abrupt("return");
1534
+ return _context17.abrupt("return");
1449
1535
  case 4:
1450
1536
  this.logInfo('processProductSyncMessages: 开始处理', {
1451
1537
  count: messages.length
@@ -1453,18 +1539,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1453
1539
  deleteIds = [];
1454
1540
  bodyUpdates = new Map();
1455
1541
  sseRefreshIds = [];
1456
- _iterator5 = _createForOfIteratorHelper(messages);
1457
- _context18.prev = 9;
1458
- _iterator5.s();
1459
- case 11:
1460
- if ((_step5 = _iterator5.n()).done) {
1461
- _context18.next = 33;
1542
+ priceRefreshIds = [];
1543
+ shouldClearPriceCache = false;
1544
+ _iterator7 = _createForOfIteratorHelper(messages);
1545
+ _context17.prev = 11;
1546
+ _iterator7.s();
1547
+ case 13:
1548
+ if ((_step7 = _iterator7.n()).done) {
1549
+ _context17.next = 35;
1462
1550
  break;
1463
1551
  }
1464
- msg = _step5.value;
1552
+ msg = _step7.value;
1465
1553
  channelKey = msg._channelKey || msg.module || 'product';
1466
1554
  if (!(channelKey === 'product')) {
1467
- _context18.next = 30;
1555
+ _context17.next = 32;
1468
1556
  break;
1469
1557
  }
1470
1558
  if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
@@ -1472,116 +1560,131 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1472
1560
  }
1473
1561
  // 1. 删除场景:operation === 'delete' 或 action === 'delete'
1474
1562
  if (!(msg.operation === 'delete' || msg.action === 'delete')) {
1475
- _context18.next = 19;
1563
+ _context17.next = 21;
1476
1564
  break;
1477
1565
  }
1478
1566
  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);
1479
- return _context18.abrupt("continue", 31);
1480
- case 19:
1567
+ return _context17.abrupt("continue", 33);
1568
+ case 21:
1481
1569
  if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
1482
- _context18.next = 23;
1570
+ _context17.next = 25;
1483
1571
  break;
1484
1572
  }
1485
1573
  ids = msg.ids || (msg.id ? [msg.id] : []);
1486
- sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(ids));
1487
- return _context18.abrupt("continue", 31);
1488
- case 23:
1574
+ priceRefreshIds.push.apply(priceRefreshIds, _toConsumableArray(ids));
1575
+ return _context17.abrupt("continue", 33);
1576
+ case 25:
1489
1577
  if (!msg.body) {
1490
- _context18.next = 27;
1578
+ _context17.next = 29;
1491
1579
  break;
1492
1580
  }
1493
1581
  bodyId = msg.body.id || msg.id;
1494
1582
  if (bodyId) bodyUpdates.set(bodyId, msg.body);
1495
- return _context18.abrupt("continue", 31);
1496
- case 27:
1497
- // 5. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
1583
+ return _context17.abrupt("continue", 33);
1584
+ case 29:
1585
+ // 4. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
1498
1586
  if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
1499
1587
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.ids));
1500
1588
  } else if (msg.id) {
1501
1589
  sseRefreshIds.push(msg.id);
1502
1590
  }
1503
- _context18.next = 31;
1591
+ _context17.next = 33;
1504
1592
  break;
1505
- case 30:
1506
- if (['product_collection', 'product_category', 'product_quotation'].includes(channelKey)) {
1593
+ case 32:
1594
+ if (channelKey === 'product_quotation') {
1595
+ // 报价单变更影响范围大,标记清除全量价格缓存
1596
+ shouldClearPriceCache = true;
1507
1597
  if ((_msg$relation_product2 = msg.relation_product_ids) !== null && _msg$relation_product2 !== void 0 && _msg$relation_product2.length) {
1508
1598
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1509
1599
  }
1600
+ } else if (['product_collection', 'product_category'].includes(channelKey)) {
1601
+ if ((_msg$relation_product3 = msg.relation_product_ids) !== null && _msg$relation_product3 !== void 0 && _msg$relation_product3.length) {
1602
+ sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1603
+ }
1510
1604
  }
1511
- case 31:
1512
- _context18.next = 11;
1513
- break;
1514
1605
  case 33:
1515
- _context18.next = 38;
1606
+ _context17.next = 13;
1516
1607
  break;
1517
1608
  case 35:
1518
- _context18.prev = 35;
1519
- _context18.t0 = _context18["catch"](9);
1520
- _iterator5.e(_context18.t0);
1521
- case 38:
1522
- _context18.prev = 38;
1523
- _iterator5.f();
1524
- return _context18.finish(38);
1525
- case 41:
1609
+ _context17.next = 40;
1610
+ break;
1611
+ case 37:
1612
+ _context17.prev = 37;
1613
+ _context17.t0 = _context17["catch"](11);
1614
+ _iterator7.e(_context17.t0);
1615
+ case 40:
1616
+ _context17.prev = 40;
1617
+ _iterator7.f();
1618
+ return _context17.finish(40);
1619
+ case 43:
1526
1620
  uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
1527
- uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds)); // 1. 处理删除
1621
+ uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds));
1622
+ uniquePriceIds = _toConsumableArray(new Set(priceRefreshIds)); // 1. 处理删除
1528
1623
  if (!(uniqueDeleteIds.length > 0)) {
1529
- _context18.next = 46;
1624
+ _context17.next = 49;
1530
1625
  break;
1531
1626
  }
1532
- _context18.next = 46;
1627
+ _context17.next = 49;
1533
1628
  return this.removeProductsByIds(uniqueDeleteIds);
1534
- case 46:
1629
+ case 49:
1535
1630
  if (!(bodyUpdates.size > 0)) {
1536
- _context18.next = 49;
1631
+ _context17.next = 52;
1537
1632
  break;
1538
1633
  }
1539
- _context18.next = 49;
1634
+ _context17.next = 52;
1540
1635
  return this.applyBodyUpdatesToStore(bodyUpdates);
1541
- case 49:
1636
+ case 52:
1542
1637
  if (!(uniqueSSEIds.length > 0)) {
1543
- _context18.next = 57;
1638
+ _context17.next = 60;
1544
1639
  break;
1545
1640
  }
1546
- _context18.next = 52;
1641
+ _context17.next = 55;
1547
1642
  return this.fetchProductsBySSE(uniqueSSEIds);
1548
- case 52:
1549
- freshProducts = _context18.sent;
1643
+ case 55:
1644
+ freshProducts = _context17.sent;
1550
1645
  if (!(freshProducts.length > 0)) {
1551
- _context18.next = 56;
1646
+ _context17.next = 59;
1552
1647
  break;
1553
1648
  }
1554
- _context18.next = 56;
1649
+ _context17.next = 59;
1555
1650
  return this.mergeProductsToStore(freshProducts);
1556
- case 56:
1651
+ case 59:
1557
1652
  this.logInfo('processProductSyncMessages: SSE 增量更新完成', {
1558
1653
  requestedCount: uniqueSSEIds.length,
1559
1654
  receivedCount: freshProducts.length
1560
1655
  });
1561
- case 57:
1656
+ case 60:
1657
+ // 收集所有非 delete 的变更 IDs(body + SSE + price),用于增量更新价格缓存
1658
+ allChangedIds = _toConsumableArray(new Set([].concat(_toConsumableArray(Array.from(bodyUpdates.keys())), _toConsumableArray(uniqueSSEIds), _toConsumableArray(uniquePriceIds))));
1562
1659
  this.logInfo('processProductSyncMessages: 处理完成', {
1563
1660
  deleteCount: uniqueDeleteIds.length,
1564
1661
  bodyUpdateCount: bodyUpdates.size,
1565
- sseRefreshCount: uniqueSSEIds.length
1566
- });
1567
-
1568
- // 如果都没有变更,则不触发 onProductsSyncCompleted
1569
- if (!(uniqueDeleteIds.length === 0 && bodyUpdates.size === 0 && uniqueSSEIds.length === 0)) {
1570
- _context18.next = 61;
1662
+ sseRefreshCount: uniqueSSEIds.length,
1663
+ priceRefreshCount: uniquePriceIds.length,
1664
+ allChangedIdsCount: allChangedIds.length,
1665
+ shouldClearPriceCache: shouldClearPriceCache
1666
+ });
1667
+ hasChanges = uniqueDeleteIds.length > 0 || allChangedIds.length > 0 || shouldClearPriceCache;
1668
+ if (hasChanges) {
1669
+ _context17.next = 66;
1571
1670
  break;
1572
1671
  }
1573
1672
  this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
1574
- return _context18.abrupt("return");
1575
- case 61:
1576
- // 清除价格缓存,让后续查询走完整的 formatter 管道重建(含 detailValueFormatter)
1577
- this.clearPriceCache();
1578
- _context18.next = 64;
1579
- return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
1580
- case 64:
1673
+ return _context17.abrupt("return");
1674
+ case 66:
1675
+ // 报价单变更 清除全量价格缓存,后续走全量重建
1676
+ if (shouldClearPriceCache) {
1677
+ this.clearPriceCache();
1678
+ }
1679
+ _context17.next = 69;
1680
+ return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, {
1681
+ changedIds: allChangedIds
1682
+ });
1683
+ case 69:
1581
1684
  case "end":
1582
- return _context18.stop();
1685
+ return _context17.stop();
1583
1686
  }
1584
- }, _callee18, this, [[9, 35, 38, 41]]);
1687
+ }, _callee17, this, [[11, 37, 40, 43]]);
1585
1688
  }));
1586
1689
  function processProductSyncMessages() {
1587
1690
  return _processProductSyncMessages.apply(this, arguments);
@@ -1596,25 +1699,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1596
1699
  }, {
1597
1700
  key: "fetchProductsBySSE",
1598
1701
  value: (function () {
1599
- var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(ids) {
1702
+ var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
1600
1703
  var t0, productList, list, errorMessage;
1601
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1602
- while (1) switch (_context19.prev = _context19.next) {
1704
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1705
+ while (1) switch (_context18.prev = _context18.next) {
1603
1706
  case 0:
1604
1707
  if (this.productDataSource) {
1605
- _context19.next = 3;
1708
+ _context18.next = 3;
1606
1709
  break;
1607
1710
  }
1608
1711
  this.logWarning('fetchProductsBySSE: ProductDataSource 不可用');
1609
- return _context19.abrupt("return", []);
1712
+ return _context18.abrupt("return", []);
1610
1713
  case 3:
1611
1714
  this.logInfo('fetchProductsBySSE: 开始', {
1612
1715
  ids: ids,
1613
1716
  count: ids.length
1614
1717
  });
1615
1718
  t0 = performance.now();
1616
- _context19.prev = 5;
1617
- _context19.next = 8;
1719
+ _context18.prev = 5;
1720
+ _context18.next = 8;
1618
1721
  return this.productDataSource.run({
1619
1722
  sse: {
1620
1723
  query: {
@@ -1624,7 +1727,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1624
1727
  }
1625
1728
  });
1626
1729
  case 8:
1627
- productList = _context19.sent;
1730
+ productList = _context18.sent;
1628
1731
  list = productList || [];
1629
1732
  perfMark('fetchProductsBySSE', performance.now() - t0, {
1630
1733
  count: list.length
@@ -1634,23 +1737,23 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1634
1737
  receivedCount: list.length,
1635
1738
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1636
1739
  });
1637
- return _context19.abrupt("return", list);
1740
+ return _context18.abrupt("return", list);
1638
1741
  case 15:
1639
- _context19.prev = 15;
1640
- _context19.t0 = _context19["catch"](5);
1641
- errorMessage = _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0);
1742
+ _context18.prev = 15;
1743
+ _context18.t0 = _context18["catch"](5);
1744
+ errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1642
1745
  this.logError('fetchProductsBySSE: 失败', {
1643
1746
  ids: ids,
1644
1747
  error: errorMessage
1645
1748
  });
1646
- return _context19.abrupt("return", []);
1749
+ return _context18.abrupt("return", []);
1647
1750
  case 20:
1648
1751
  case "end":
1649
- return _context19.stop();
1752
+ return _context18.stop();
1650
1753
  }
1651
- }, _callee19, this, [[5, 15]]);
1754
+ }, _callee18, this, [[5, 15]]);
1652
1755
  }));
1653
- function fetchProductsBySSE(_x16) {
1756
+ function fetchProductsBySSE(_x17) {
1654
1757
  return _fetchProductsBySSE.apply(this, arguments);
1655
1758
  }
1656
1759
  return fetchProductsBySSE;
@@ -1665,10 +1768,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1665
1768
  }, {
1666
1769
  key: "applyBodyUpdatesToStore",
1667
1770
  value: (function () {
1668
- var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(bodyUpdates) {
1669
- var updatedCount, newCount, appliedIds, _iterator6, _step6, _step6$value, id, body;
1670
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1671
- while (1) switch (_context20.prev = _context20.next) {
1771
+ var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(bodyUpdates) {
1772
+ var updatedCount, newCount, appliedIds, _iterator8, _step8, _step8$value, id, body;
1773
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1774
+ while (1) switch (_context19.prev = _context19.next) {
1672
1775
  case 0:
1673
1776
  this.logInfo('applyBodyUpdatesToStore: 开始', {
1674
1777
  count: bodyUpdates.size
@@ -1684,22 +1787,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1684
1787
  }
1685
1788
  return p;
1686
1789
  });
1687
- _iterator6 = _createForOfIteratorHelper(bodyUpdates);
1790
+ _iterator8 = _createForOfIteratorHelper(bodyUpdates);
1688
1791
  try {
1689
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1690
- _step6$value = _slicedToArray(_step6.value, 2), id = _step6$value[0], body = _step6$value[1];
1792
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1793
+ _step8$value = _slicedToArray(_step8.value, 2), id = _step8$value[0], body = _step8$value[1];
1691
1794
  if (!appliedIds.has(id)) {
1692
1795
  this.store.list.push(body);
1693
1796
  newCount++;
1694
1797
  }
1695
1798
  }
1696
1799
  } catch (err) {
1697
- _iterator6.e(err);
1800
+ _iterator8.e(err);
1698
1801
  } finally {
1699
- _iterator6.f();
1802
+ _iterator8.f();
1700
1803
  }
1701
1804
  this.syncProductsMap();
1702
- _context20.next = 10;
1805
+ _context19.next = 10;
1703
1806
  return this.saveProductsToIndexDB(this.store.list);
1704
1807
  case 10:
1705
1808
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
@@ -1710,11 +1813,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1710
1813
  });
1711
1814
  case 12:
1712
1815
  case "end":
1713
- return _context20.stop();
1816
+ return _context19.stop();
1714
1817
  }
1715
- }, _callee20, this);
1818
+ }, _callee19, this);
1716
1819
  }));
1717
- function applyBodyUpdatesToStore(_x17) {
1820
+ function applyBodyUpdatesToStore(_x18) {
1718
1821
  return _applyBodyUpdatesToStore.apply(this, arguments);
1719
1822
  }
1720
1823
  return applyBodyUpdatesToStore;
@@ -1728,22 +1831,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1728
1831
  }, {
1729
1832
  key: "mergeProductsToStore",
1730
1833
  value: (function () {
1731
- var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(freshProducts) {
1732
- var freshMap, _iterator7, _step7, p, updatedList, newCount, _iterator8, _step8, _p, updatedCount;
1733
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1734
- while (1) switch (_context21.prev = _context21.next) {
1834
+ var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(freshProducts) {
1835
+ var freshMap, _iterator9, _step9, p, updatedList, newCount, _iterator10, _step10, _p2, updatedCount;
1836
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1837
+ while (1) switch (_context20.prev = _context20.next) {
1735
1838
  case 0:
1736
1839
  freshMap = new Map();
1737
- _iterator7 = _createForOfIteratorHelper(freshProducts);
1840
+ _iterator9 = _createForOfIteratorHelper(freshProducts);
1738
1841
  try {
1739
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1740
- p = _step7.value;
1842
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1843
+ p = _step9.value;
1741
1844
  freshMap.set(p.id, p);
1742
1845
  }
1743
1846
  } catch (err) {
1744
- _iterator7.e(err);
1847
+ _iterator9.e(err);
1745
1848
  } finally {
1746
- _iterator7.f();
1849
+ _iterator9.f();
1747
1850
  }
1748
1851
  updatedList = this.store.list.map(function (p) {
1749
1852
  if (freshMap.has(p.id)) {
@@ -1754,21 +1857,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1754
1857
  return p;
1755
1858
  }); // freshMap 中剩余的是新商品(create 场景)
1756
1859
  newCount = freshMap.size;
1757
- _iterator8 = _createForOfIteratorHelper(freshMap.values());
1860
+ _iterator10 = _createForOfIteratorHelper(freshMap.values());
1758
1861
  try {
1759
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1760
- _p = _step8.value;
1761
- updatedList.push(_p);
1862
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1863
+ _p2 = _step10.value;
1864
+ updatedList.push(_p2);
1762
1865
  }
1763
1866
  } catch (err) {
1764
- _iterator8.e(err);
1867
+ _iterator10.e(err);
1765
1868
  } finally {
1766
- _iterator8.f();
1869
+ _iterator10.f();
1767
1870
  }
1768
1871
  updatedCount = freshProducts.length - newCount;
1769
1872
  this.store.list = updatedList;
1770
1873
  this.syncProductsMap();
1771
- _context21.next = 12;
1874
+ _context20.next = 12;
1772
1875
  return this.saveProductsToIndexDB(this.store.list);
1773
1876
  case 12:
1774
1877
  this.logInfo('mergeProductsToStore: 合并完成', {
@@ -1779,11 +1882,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1779
1882
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1780
1883
  case 14:
1781
1884
  case "end":
1782
- return _context21.stop();
1885
+ return _context20.stop();
1783
1886
  }
1784
- }, _callee21, this);
1887
+ }, _callee20, this);
1785
1888
  }));
1786
- function mergeProductsToStore(_x18) {
1889
+ function mergeProductsToStore(_x19) {
1787
1890
  return _mergeProductsToStore.apply(this, arguments);
1788
1891
  }
1789
1892
  return mergeProductsToStore;
@@ -1797,34 +1900,34 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1797
1900
  }, {
1798
1901
  key: "silentRefresh",
1799
1902
  value: (function () {
1800
- var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1903
+ var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1801
1904
  var t0, products, errorMessage;
1802
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1803
- while (1) switch (_context22.prev = _context22.next) {
1905
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1906
+ while (1) switch (_context21.prev = _context21.next) {
1804
1907
  case 0:
1805
1908
  t0 = performance.now();
1806
1909
  this.logInfo('silentRefresh 开始');
1807
- _context22.prev = 2;
1808
- _context22.next = 5;
1910
+ _context21.prev = 2;
1911
+ _context21.next = 5;
1809
1912
  return this.loadProductsByServer();
1810
1913
  case 5:
1811
- products = _context22.sent;
1914
+ products = _context21.sent;
1812
1915
  if (!(products && products.length > 0)) {
1813
- _context22.next = 16;
1916
+ _context21.next = 16;
1814
1917
  break;
1815
1918
  }
1816
1919
  this.store.list = products;
1817
1920
  this.syncProductsMap();
1818
1921
  this.clearPriceCache();
1819
1922
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1820
- _context22.next = 13;
1923
+ _context21.next = 13;
1821
1924
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
1822
1925
  case 13:
1823
1926
  this.logInfo('silentRefresh 完成', {
1824
1927
  productCount: products.length,
1825
1928
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1826
1929
  });
1827
- _context22.next = 17;
1930
+ _context21.next = 17;
1828
1931
  break;
1829
1932
  case 16:
1830
1933
  this.logWarning('silentRefresh: 服务器未返回数据');
@@ -1832,21 +1935,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1832
1935
  perfMark('silentRefresh', performance.now() - t0, {
1833
1936
  count: this.store.list.length
1834
1937
  });
1835
- return _context22.abrupt("return", this.store.list);
1938
+ return _context21.abrupt("return", this.store.list);
1836
1939
  case 21:
1837
- _context22.prev = 21;
1838
- _context22.t0 = _context22["catch"](2);
1839
- errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
1940
+ _context21.prev = 21;
1941
+ _context21.t0 = _context21["catch"](2);
1942
+ errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1840
1943
  this.logError('silentRefresh 失败', {
1841
1944
  duration: "".concat(Math.round(performance.now() - t0), "ms"),
1842
1945
  error: errorMessage
1843
1946
  });
1844
- return _context22.abrupt("return", this.store.list);
1947
+ return _context21.abrupt("return", this.store.list);
1845
1948
  case 26:
1846
1949
  case "end":
1847
- return _context22.stop();
1950
+ return _context21.stop();
1848
1951
  }
1849
- }, _callee22, this, [[2, 21]]);
1952
+ }, _callee21, this, [[2, 21]]);
1850
1953
  }));
1851
1954
  function silentRefresh() {
1852
1955
  return _silentRefresh.apply(this, arguments);