@pisell/pisellos 2.2.94 → 2.2.95

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 (39) hide show
  1. package/dist/core/index.d.ts +1 -0
  2. package/dist/core/index.js +7 -0
  3. package/dist/modules/Customer/index.d.ts +1 -0
  4. package/dist/modules/Customer/index.js +28 -12
  5. package/dist/modules/Order/index.d.ts +1 -1
  6. package/dist/server/index.d.ts +6 -1
  7. package/dist/server/index.js +40 -17
  8. package/dist/server/modules/order/types.d.ts +1 -1
  9. package/dist/server/modules/order/utils/filterBookings.js +1 -1
  10. package/dist/server/modules/products/index.d.ts +19 -24
  11. package/dist/server/modules/products/index.js +429 -600
  12. package/dist/server/modules/products/types.d.ts +1 -0
  13. package/dist/server/utils/product.d.ts +4 -0
  14. package/dist/server/utils/product.js +34 -0
  15. package/dist/solution/BookingByStep/index.d.ts +1 -1
  16. package/dist/solution/Sales/index.d.ts +1 -1
  17. package/dist/solution/Sales/index.js +72 -20
  18. package/dist/solution/Sales/types.d.ts +5 -4
  19. package/dist/types/index.d.ts +2 -0
  20. package/lib/core/index.d.ts +1 -0
  21. package/lib/core/index.js +4 -0
  22. package/lib/modules/Customer/index.d.ts +1 -0
  23. package/lib/modules/Customer/index.js +21 -6
  24. package/lib/modules/Order/index.d.ts +1 -1
  25. package/lib/server/index.d.ts +6 -1
  26. package/lib/server/index.js +33 -13
  27. package/lib/server/modules/order/types.d.ts +1 -1
  28. package/lib/server/modules/order/utils/filterBookings.js +1 -1
  29. package/lib/server/modules/products/index.d.ts +19 -24
  30. package/lib/server/modules/products/index.js +151 -150
  31. package/lib/server/modules/products/types.d.ts +1 -0
  32. package/lib/server/utils/product.d.ts +4 -0
  33. package/lib/server/utils/product.js +27 -0
  34. package/lib/solution/BookingByStep/index.d.ts +1 -1
  35. package/lib/solution/Sales/index.d.ts +1 -1
  36. package/lib/solution/Sales/index.js +67 -12
  37. package/lib/solution/Sales/types.d.ts +5 -4
  38. package/lib/types/index.d.ts +2 -0
  39. package/package.json +1 -1
@@ -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); }); }; }
@@ -31,7 +31,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
31
31
  import { BaseModule } from "../../../modules/BaseModule";
32
32
  import { RequestModeENUM } from "../../../plugins";
33
33
  import { ProductsHooks } from "./types";
34
- import { applyDetailValueToProducts, applyPriceDataToProducts, perfMark } from "../../utils/product";
34
+ import { applyDetailValueToProducts, applyPriceDataToProducts, applyI18nToProducts, perfMark } from "../../utils/product";
35
35
 
36
36
  /**
37
37
  * IndexDB 存储名称
@@ -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, _this$core, 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
@@ -378,48 +481,55 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
378
481
  });
379
482
  context = _objectSpread({
380
483
  schedule_date: schedule_date,
381
- priceData: priceData
382
- }, extraContext); // 4. 通过格式化器流程处理商品
484
+ priceData: priceData,
485
+ 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
+ }, extraContext); // 3. 通过格式化器流程处理商品
383
487
  tFormat = performance.now();
384
- _context4.next = 19;
385
- return this.applyFormatters(allProducts, context);
386
- case 19:
488
+ _context4.next = 17;
489
+ return this.applyFormatters(products, context);
490
+ case 17:
387
491
  processedProducts = _context4.sent;
388
492
  perfMark('prepareProducts.applyFormatters', performance.now() - tFormat, {
389
- count: allProducts.length,
493
+ count: products.length,
390
494
  formatterCount: this.formatters.length
391
495
  });
392
496
  this.logInfo('prepareProductsWithPrice 处理完成', {
393
- originalProductCount: allProducts.length,
497
+ mode: isIncremental ? 'incremental' : 'full',
498
+ originalProductCount: products.length,
394
499
  processedProductCount: processedProducts.length,
395
500
  formatterCount: this.formatters.length
396
501
  });
397
- _context4.next = 24;
502
+ if (isIncremental) {
503
+ _context4.next = 23;
504
+ break;
505
+ }
506
+ _context4.next = 23;
398
507
  return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
399
- case 24:
508
+ case 23:
400
509
  perfMark('prepareProductsWithPrice', performance.now() - tTotal, {
401
- productCount: allProducts.length,
402
- formatterCount: this.formatters.length
510
+ productCount: products.length,
511
+ formatterCount: this.formatters.length,
512
+ mode: isIncremental ? 'incremental' : 'full'
403
513
  });
404
514
  return _context4.abrupt("return", processedProducts);
405
- case 28:
406
- _context4.prev = 28;
407
- _context4.t0 = _context4["catch"](2);
515
+ case 27:
516
+ _context4.prev = 27;
517
+ _context4.t0 = _context4["catch"](4);
408
518
  errorMessage = _context4.t0 instanceof Error ? _context4.t0.message : String(_context4.t0);
409
519
  console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context4.t0);
410
520
  this.logError('prepareProductsWithPrice 处理失败', {
411
521
  schedule_date: schedule_date,
412
522
  error: errorMessage
413
523
  });
414
- case 33:
524
+ case 32:
415
525
  return _context4.abrupt("return", []);
416
- case 34:
526
+ case 33:
417
527
  case "end":
418
528
  return _context4.stop();
419
529
  }
420
- }, _callee4, this, [[2, 28]]);
530
+ }, _callee4, this, [[4, 27]]);
421
531
  }));
422
- function prepareProductsWithPrice(_x6, _x7) {
532
+ function prepareProductsWithPrice(_x7, _x8, _x9) {
423
533
  return _prepareProductsWithPrice.apply(this, arguments);
424
534
  }
425
535
  return prepareProductsWithPrice;
@@ -501,7 +611,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
501
611
  }
502
612
  }, _callee5, this, [[9, 17]]);
503
613
  }));
504
- function applyFormatters(_x8, _x9) {
614
+ function applyFormatters(_x10, _x11) {
505
615
  return _applyFormatters.apply(this, arguments);
506
616
  }
507
617
  return applyFormatters;
@@ -529,12 +639,16 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
529
639
  console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528\u4EF7\u683C\u6570\u636E\u5230 ".concat(products.length, " \u4E2A\u5546\u54C1"));
530
640
  return applyPriceDataToProducts(products, context.priceData);
531
641
  };
642
+ var i18nFormatter = function i18nFormatter(products, context) {
643
+ return applyI18nToProducts(products, context.locale);
644
+ };
532
645
  var detailValueFormatter = function detailValueFormatter(products, context) {
533
646
  return applyDetailValueToProducts(products, context);
534
647
  };
535
648
 
536
649
  // 将价格格式化器注册为第一个格式化器
537
650
  this.formatters.unshift(priceFormatter);
651
+ this.formatters.push(i18nFormatter);
538
652
  this.formatters.push(detailValueFormatter);
539
653
  this.isPriceFormatterRegistered = true;
540
654
  console.log('[ProductsModule] ✅ 内置价格格式化器已注册(第 1 个)');
@@ -755,7 +869,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
755
869
  }
756
870
  }, _callee7, this, [[3, 13]]);
757
871
  }));
758
- function fetchProductsByHttp(_x10) {
872
+ function fetchProductsByHttp(_x12) {
759
873
  return _fetchProductsByHttp.apply(this, arguments);
760
874
  }
761
875
  return fetchProductsByHttp;
@@ -795,7 +909,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
795
909
  }
796
910
  }, _callee8, this);
797
911
  }));
798
- function loadProductsByServerHttp(_x11) {
912
+ function loadProductsByServerHttp(_x13) {
799
913
  return _loadProductsByServerHttp.apply(this, arguments);
800
914
  }
801
915
  return loadProductsByServerHttp;
@@ -860,7 +974,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
860
974
  }
861
975
  }, _callee10, this);
862
976
  }));
863
- function getProductById(_x12) {
977
+ function getProductById(_x14) {
864
978
  return _getProductById.apply(this, arguments);
865
979
  }
866
980
  return getProductById;
@@ -874,7 +988,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
874
988
  key: "removeProductsByIds",
875
989
  value: (function () {
876
990
  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;
991
+ var idSet, _iterator3, _step3, _id, _iterator4, _step4, id, errorMessage, _iterator5, _step5, _step5$value, dateKey, cachedProducts;
878
992
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
879
993
  while (1) switch (_context11.prev = _context11.next) {
880
994
  case 0:
@@ -886,31 +1000,31 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
886
1000
  this.store.list = this.store.list.filter(function (p) {
887
1001
  return !idSet.has(p.id);
888
1002
  });
889
- _iterator = _createForOfIteratorHelper(ids);
1003
+ _iterator3 = _createForOfIteratorHelper(ids);
890
1004
  try {
891
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
892
- _id = _step.value;
1005
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1006
+ _id = _step3.value;
893
1007
  this.store.map.delete(_id);
894
1008
  }
895
1009
  } catch (err) {
896
- _iterator.e(err);
1010
+ _iterator3.e(err);
897
1011
  } finally {
898
- _iterator.f();
1012
+ _iterator3.f();
899
1013
  }
900
1014
  if (!this.dbManager) {
901
1015
  _context11.next = 30;
902
1016
  break;
903
1017
  }
904
1018
  _context11.prev = 6;
905
- _iterator2 = _createForOfIteratorHelper(ids);
1019
+ _iterator4 = _createForOfIteratorHelper(ids);
906
1020
  _context11.prev = 8;
907
- _iterator2.s();
1021
+ _iterator4.s();
908
1022
  case 10:
909
- if ((_step2 = _iterator2.n()).done) {
1023
+ if ((_step4 = _iterator4.n()).done) {
910
1024
  _context11.next = 16;
911
1025
  break;
912
1026
  }
913
- id = _step2.value;
1027
+ id = _step4.value;
914
1028
  _context11.next = 14;
915
1029
  return this.dbManager.delete(INDEXDB_STORE_NAME, id);
916
1030
  case 14:
@@ -922,10 +1036,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
922
1036
  case 18:
923
1037
  _context11.prev = 18;
924
1038
  _context11.t0 = _context11["catch"](8);
925
- _iterator2.e(_context11.t0);
1039
+ _iterator4.e(_context11.t0);
926
1040
  case 21:
927
1041
  _context11.prev = 21;
928
- _iterator2.f();
1042
+ _iterator4.f();
929
1043
  return _context11.finish(21);
930
1044
  case 24:
931
1045
  _context11.next = 30;
@@ -939,18 +1053,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
939
1053
  error: errorMessage
940
1054
  });
941
1055
  case 30:
942
- _iterator3 = _createForOfIteratorHelper(this.productsPriceCache.entries());
1056
+ _iterator5 = _createForOfIteratorHelper(this.productsPriceCache.entries());
943
1057
  try {
944
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
945
- _step3$value = _slicedToArray(_step3.value, 2), dateKey = _step3$value[0], cachedProducts = _step3$value[1];
1058
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1059
+ _step5$value = _slicedToArray(_step5.value, 2), dateKey = _step5$value[0], cachedProducts = _step5$value[1];
946
1060
  this.productsPriceCache.set(dateKey, cachedProducts.filter(function (p) {
947
1061
  return !idSet.has(p.id);
948
1062
  }));
949
1063
  }
950
1064
  } catch (err) {
951
- _iterator3.e(err);
1065
+ _iterator5.e(err);
952
1066
  } finally {
953
- _iterator3.f();
1067
+ _iterator5.f();
954
1068
  }
955
1069
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
956
1070
  this.logInfo('removeProductsByIds 完成', {
@@ -962,7 +1076,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
962
1076
  }
963
1077
  }, _callee11, this, [[6, 26], [8, 18, 21, 24]]);
964
1078
  }));
965
- function removeProductsByIds(_x13) {
1079
+ function removeProductsByIds(_x15) {
966
1080
  return _removeProductsByIds.apply(this, arguments);
967
1081
  }
968
1082
  return removeProductsByIds;
@@ -1012,83 +1126,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1012
1126
  }
1013
1127
  return refreshProducts;
1014
1128
  }()
1015
- /**
1016
- * 局部更新指定商品的报价单价格
1017
- * 遍历所有已缓存的日期,为目标商品重新获取价格并覆盖到缓存中
1018
- */
1019
- )
1020
- }, {
1021
- key: "updateProductPriceByIds",
1022
- value: (function () {
1023
- var _updateProductPriceByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(ids) {
1024
- var _iterator4, _step4, _step4$value, dateKey, cachedProducts, priceData, updatedProducts, errorMessage;
1025
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1026
- while (1) switch (_context13.prev = _context13.next) {
1027
- case 0:
1028
- this.logInfo('updateProductPriceByIds', {
1029
- ids: ids
1030
- });
1031
- _iterator4 = _createForOfIteratorHelper(this.productsPriceCache.entries());
1032
- _context13.prev = 2;
1033
- _iterator4.s();
1034
- case 4:
1035
- if ((_step4 = _iterator4.n()).done) {
1036
- _context13.next = 19;
1037
- break;
1038
- }
1039
- _step4$value = _slicedToArray(_step4.value, 2), dateKey = _step4$value[0], cachedProducts = _step4$value[1];
1040
- _context13.prev = 6;
1041
- _context13.next = 9;
1042
- return this.loadProductsPrice({
1043
- ids: ids,
1044
- schedule_date: dateKey
1045
- });
1046
- case 9:
1047
- priceData = _context13.sent;
1048
- if (priceData && priceData.length > 0) {
1049
- updatedProducts = applyPriceDataToProducts(cachedProducts, priceData);
1050
- this.productsPriceCache.set(dateKey, updatedProducts);
1051
- this.logInfo('updateProductPriceByIds: 缓存已更新', {
1052
- dateKey: dateKey,
1053
- priceDataCount: priceData.length
1054
- });
1055
- }
1056
- _context13.next = 17;
1057
- break;
1058
- case 13:
1059
- _context13.prev = 13;
1060
- _context13.t0 = _context13["catch"](6);
1061
- errorMessage = _context13.t0 instanceof Error ? _context13.t0.message : String(_context13.t0);
1062
- this.logError('updateProductPriceByIds: 失败', {
1063
- dateKey: dateKey,
1064
- ids: ids,
1065
- error: errorMessage
1066
- });
1067
- case 17:
1068
- _context13.next = 4;
1069
- break;
1070
- case 19:
1071
- _context13.next = 24;
1072
- break;
1073
- case 21:
1074
- _context13.prev = 21;
1075
- _context13.t1 = _context13["catch"](2);
1076
- _iterator4.e(_context13.t1);
1077
- case 24:
1078
- _context13.prev = 24;
1079
- _iterator4.f();
1080
- return _context13.finish(24);
1081
- case 27:
1082
- case "end":
1083
- return _context13.stop();
1084
- }
1085
- }, _callee13, this, [[2, 21, 24, 27], [6, 13]]);
1086
- }));
1087
- function updateProductPriceByIds(_x14) {
1088
- return _updateProductPriceByIds.apply(this, arguments);
1089
- }
1090
- return updateProductPriceByIds;
1091
- }()
1092
1129
  /**
1093
1130
  * 清空缓存
1094
1131
  */
@@ -1096,10 +1133,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1096
1133
  }, {
1097
1134
  key: "clear",
1098
1135
  value: (function () {
1099
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1136
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1100
1137
  var errorMessage;
1101
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1102
- while (1) switch (_context14.prev = _context14.next) {
1138
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1139
+ while (1) switch (_context13.prev = _context13.next) {
1103
1140
  case 0:
1104
1141
  this.logInfo('开始清空缓存', {
1105
1142
  currentProductCount: this.store.list.length,
@@ -1110,22 +1147,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1110
1147
 
1111
1148
  // 同时清空 IndexDB 中的所有数据(包括商品和元数据)
1112
1149
  if (!this.dbManager) {
1113
- _context14.next = 16;
1150
+ _context13.next = 16;
1114
1151
  break;
1115
1152
  }
1116
- _context14.prev = 4;
1117
- _context14.next = 7;
1153
+ _context13.prev = 4;
1154
+ _context13.next = 7;
1118
1155
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1119
1156
  case 7:
1120
1157
  console.log('[Products] IndexDB 缓存已清空');
1121
1158
  this.logInfo('IndexDB 缓存已清空');
1122
- _context14.next = 16;
1159
+ _context13.next = 16;
1123
1160
  break;
1124
1161
  case 11:
1125
- _context14.prev = 11;
1126
- _context14.t0 = _context14["catch"](4);
1127
- errorMessage = _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0);
1128
- console.error('[Products] 清空 IndexDB 缓存失败:', _context14.t0);
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);
1129
1166
  this.logError('清空 IndexDB 缓存失败', {
1130
1167
  error: errorMessage
1131
1168
  });
@@ -1134,9 +1171,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1134
1171
  this.logInfo('缓存清空完成');
1135
1172
  case 18:
1136
1173
  case "end":
1137
- return _context14.stop();
1174
+ return _context13.stop();
1138
1175
  }
1139
- }, _callee14, this, [[4, 11]]);
1176
+ }, _callee13, this, [[4, 11]]);
1140
1177
  }));
1141
1178
  function clear() {
1142
1179
  return _clear.apply(this, arguments);
@@ -1151,45 +1188,45 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1151
1188
  }, {
1152
1189
  key: "loadProductsFromIndexDB",
1153
1190
  value: (function () {
1154
- var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1191
+ var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1155
1192
  var _products$length, _products$length2, t0, products, errorMessage;
1156
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1157
- while (1) switch (_context15.prev = _context15.next) {
1193
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1194
+ while (1) switch (_context14.prev = _context14.next) {
1158
1195
  case 0:
1159
1196
  if (this.dbManager) {
1160
- _context15.next = 3;
1197
+ _context14.next = 3;
1161
1198
  break;
1162
1199
  }
1163
1200
  this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
1164
- return _context15.abrupt("return", []);
1201
+ return _context14.abrupt("return", []);
1165
1202
  case 3:
1166
- _context15.prev = 3;
1203
+ _context14.prev = 3;
1167
1204
  t0 = performance.now();
1168
- _context15.next = 7;
1205
+ _context14.next = 7;
1169
1206
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1170
1207
  case 7:
1171
- products = _context15.sent;
1208
+ products = _context14.sent;
1172
1209
  perfMark('loadProductsFromIndexDB', performance.now() - t0, {
1173
1210
  count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
1174
1211
  });
1175
1212
  this.logInfo('从 IndexDB 加载商品数据', {
1176
1213
  productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
1177
1214
  });
1178
- return _context15.abrupt("return", products || []);
1215
+ return _context14.abrupt("return", products || []);
1179
1216
  case 13:
1180
- _context15.prev = 13;
1181
- _context15.t0 = _context15["catch"](3);
1182
- errorMessage = _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0);
1183
- console.error('[Products] 从 IndexDB 读取数据失败:', _context15.t0);
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);
1184
1221
  this.logError('从 IndexDB 读取数据失败', {
1185
1222
  error: errorMessage
1186
1223
  });
1187
- return _context15.abrupt("return", []);
1224
+ return _context14.abrupt("return", []);
1188
1225
  case 19:
1189
1226
  case "end":
1190
- return _context15.stop();
1227
+ return _context14.stop();
1191
1228
  }
1192
- }, _callee15, this, [[3, 13]]);
1229
+ }, _callee14, this, [[3, 13]]);
1193
1230
  }));
1194
1231
  function loadProductsFromIndexDB() {
1195
1232
  return _loadProductsFromIndexDB.apply(this, arguments);
@@ -1204,28 +1241,28 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1204
1241
  }, {
1205
1242
  key: "saveProductsToIndexDB",
1206
1243
  value: (function () {
1207
- var _saveProductsToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(products) {
1244
+ var _saveProductsToIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(products) {
1208
1245
  var t0, errorMessage;
1209
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1210
- while (1) switch (_context16.prev = _context16.next) {
1246
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1247
+ while (1) switch (_context15.prev = _context15.next) {
1211
1248
  case 0:
1212
1249
  if (this.dbManager) {
1213
- _context16.next = 3;
1250
+ _context15.next = 3;
1214
1251
  break;
1215
1252
  }
1216
1253
  this.logWarning('saveProductsToIndexDB: dbManager 不可用');
1217
- return _context16.abrupt("return");
1254
+ return _context15.abrupt("return");
1218
1255
  case 3:
1219
1256
  this.logInfo('开始保存商品数据到 IndexDB', {
1220
1257
  productCount: products.length
1221
1258
  });
1222
- _context16.prev = 4;
1259
+ _context15.prev = 4;
1223
1260
  t0 = performance.now();
1224
- _context16.next = 8;
1261
+ _context15.next = 8;
1225
1262
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1226
1263
  case 8:
1227
- _context16.next = 10;
1228
- return this.dbManager.bulkAdd(INDEXDB_STORE_NAME, products);
1264
+ _context15.next = 10;
1265
+ return this.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
1229
1266
  case 10:
1230
1267
  perfMark('saveProductsToIndexDB', performance.now() - t0, {
1231
1268
  count: products.length
@@ -1234,24 +1271,24 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1234
1271
  this.logInfo('商品数据已保存到 IndexDB', {
1235
1272
  productCount: products.length
1236
1273
  });
1237
- _context16.next = 20;
1274
+ _context15.next = 20;
1238
1275
  break;
1239
1276
  case 15:
1240
- _context16.prev = 15;
1241
- _context16.t0 = _context16["catch"](4);
1242
- errorMessage = _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0);
1243
- console.error('[Products] 保存数据到 IndexDB 失败:', _context16.t0);
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);
1244
1281
  this.logError('保存数据到 IndexDB 失败', {
1245
1282
  productCount: products.length,
1246
1283
  error: errorMessage
1247
1284
  });
1248
1285
  case 20:
1249
1286
  case "end":
1250
- return _context16.stop();
1287
+ return _context15.stop();
1251
1288
  }
1252
- }, _callee16, this, [[4, 15]]);
1289
+ }, _callee15, this, [[4, 15]]);
1253
1290
  }));
1254
- function saveProductsToIndexDB(_x15) {
1291
+ function saveProductsToIndexDB(_x16) {
1255
1292
  return _saveProductsToIndexDB.apply(this, arguments);
1256
1293
  }
1257
1294
  return saveProductsToIndexDB;
@@ -1267,17 +1304,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1267
1304
  value: function syncProductsMap() {
1268
1305
  var t0 = performance.now();
1269
1306
  this.store.map.clear();
1270
- var _iterator5 = _createForOfIteratorHelper(this.store.list),
1271
- _step5;
1307
+ var _iterator6 = _createForOfIteratorHelper(this.store.list),
1308
+ _step6;
1272
1309
  try {
1273
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1274
- var product = _step5.value;
1310
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1311
+ var product = _step6.value;
1275
1312
  this.store.map.set(product.id, product);
1276
1313
  }
1277
1314
  } catch (err) {
1278
- _iterator5.e(err);
1315
+ _iterator6.e(err);
1279
1316
  } finally {
1280
- _iterator5.f();
1317
+ _iterator6.f();
1281
1318
  }
1282
1319
  perfMark('syncProductsMap', performance.now() - t0, {
1283
1320
  count: this.store.map.size
@@ -1291,26 +1328,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1291
1328
  }, {
1292
1329
  key: "preload",
1293
1330
  value: (function () {
1294
- var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1331
+ var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1295
1332
  var _products$length3;
1296
1333
  var tTotal, _cachedData$length, tIndexDB, cachedData, tSync, errorMessage, tServer, products, _tSync;
1297
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1298
- while (1) switch (_context17.prev = _context17.next) {
1334
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1335
+ while (1) switch (_context16.prev = _context16.next) {
1299
1336
  case 0:
1300
1337
  console.log('[Products] 开始预加载数据...');
1301
1338
  tTotal = performance.now();
1302
1339
  this.logInfo('开始预加载数据');
1303
- _context17.prev = 3;
1340
+ _context16.prev = 3;
1304
1341
  tIndexDB = performance.now();
1305
- _context17.next = 7;
1342
+ _context16.next = 7;
1306
1343
  return this.loadProductsFromIndexDB();
1307
1344
  case 7:
1308
- cachedData = _context17.sent;
1345
+ cachedData = _context16.sent;
1309
1346
  perfMark('preload.loadFromIndexDB', performance.now() - tIndexDB, {
1310
1347
  count: (_cachedData$length = cachedData === null || cachedData === void 0 ? void 0 : cachedData.length) !== null && _cachedData$length !== void 0 ? _cachedData$length : 0
1311
1348
  });
1312
1349
  if (!(cachedData && cachedData.length > 0)) {
1313
- _context17.next = 19;
1350
+ _context16.next = 19;
1314
1351
  break;
1315
1352
  }
1316
1353
  console.log("[Products] \u4ECE IndexDB \u52A0\u8F7D\u4E86 ".concat(cachedData.length, " \u4E2A\u5546\u54C1"));
@@ -1331,26 +1368,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1331
1368
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
1332
1369
  source: 'IndexDB'
1333
1370
  });
1334
- return _context17.abrupt("return");
1371
+ return _context16.abrupt("return");
1335
1372
  case 19:
1336
1373
  console.log('[Products] IndexDB 中没有缓存数据,从服务器加载...');
1337
1374
  this.logInfo('IndexDB 中没有缓存数据,准备从服务器加载');
1338
- _context17.next = 28;
1375
+ _context16.next = 28;
1339
1376
  break;
1340
1377
  case 23:
1341
- _context17.prev = 23;
1342
- _context17.t0 = _context17["catch"](3);
1343
- errorMessage = _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0);
1344
- console.warn('[Products] 从 IndexDB 加载数据失败:', _context17.t0);
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);
1345
1382
  this.logWarning('从 IndexDB 加载数据失败,准备从服务器加载', {
1346
1383
  error: errorMessage
1347
1384
  });
1348
1385
  case 28:
1349
1386
  tServer = performance.now();
1350
- _context17.next = 31;
1387
+ _context16.next = 31;
1351
1388
  return this.loadProductsByServer();
1352
1389
  case 31:
1353
- products = _context17.sent;
1390
+ products = _context16.sent;
1354
1391
  perfMark('preload.loadFromServer', performance.now() - tServer, {
1355
1392
  count: (_products$length3 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length3 !== void 0 ? _products$length3 : 0
1356
1393
  });
@@ -1382,9 +1419,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1382
1419
  }
1383
1420
  case 34:
1384
1421
  case "end":
1385
- return _context17.stop();
1422
+ return _context16.stop();
1386
1423
  }
1387
- }, _callee17, this, [[3, 23]]);
1424
+ }, _callee16, this, [[3, 23]]);
1388
1425
  }));
1389
1426
  function preload() {
1390
1427
  return _preload.apply(this, arguments);
@@ -1472,31 +1509,34 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1472
1509
  *
1473
1510
  * product 模块:
1474
1511
  * - operation === 'delete' → 本地删除
1475
- * - body(无 price change_types) body 完整数据直接覆盖本地
1476
- * - change_types 包含 price SSE 增量拉取 + 刷新报价单价格缓存
1477
- * - change_types stock → 跳过(暂不响应)
1512
+ * - change_types 包含 price → 仅收集变更 IDs(不拉商品数据)
1513
+ * - bodybody 完整数据直接覆盖本地
1514
+ * - 其他 SSE 增量拉取
1478
1515
  *
1479
- * product_collection / product_category / product_quotation
1516
+ * product_collection / product_category:
1480
1517
  * - 按 relation_product_ids SSE 拉取受影响商品
1481
- * - product_quotation 额外刷新报价单价格缓存
1482
1518
  *
1483
- * 处理完成后 emit onProductsSyncCompleted 通知 Server 层
1519
+ * product_quotation:
1520
+ * - 报价单变更影响范围大,直接清除价格缓存走全量重建
1521
+ *
1522
+ * 处理完成后 emit onProductsSyncCompleted(携带 changedIds),
1523
+ * Server 层监听该事件后对变更商品增量执行 prepareProductsWithPrice 并更新缓存
1484
1524
  */
1485
1525
  }, {
1486
1526
  key: "processProductSyncMessages",
1487
1527
  value: (function () {
1488
- var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1489
- var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, _iterator6, _step6, msg, channelKey, _msg$change_types, _msg$change_types2, _msg$ids2, _msg$ids, ids, bodyId, _msg$relation_product, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, sseHandledSet, remainingPriceIds;
1490
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1491
- while (1) switch (_context18.prev = _context18.next) {
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) {
1492
1532
  case 0:
1493
1533
  messages = _toConsumableArray(this.pendingSyncMessages);
1494
1534
  this.pendingSyncMessages = [];
1495
1535
  if (!(messages.length === 0)) {
1496
- _context18.next = 4;
1536
+ _context17.next = 4;
1497
1537
  break;
1498
1538
  }
1499
- return _context18.abrupt("return");
1539
+ return _context17.abrupt("return");
1500
1540
  case 4:
1501
1541
  this.logInfo('processProductSyncMessages: 开始处理', {
1502
1542
  count: messages.length
@@ -1505,162 +1545,155 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1505
1545
  bodyUpdates = new Map();
1506
1546
  sseRefreshIds = [];
1507
1547
  priceRefreshIds = [];
1508
- _iterator6 = _createForOfIteratorHelper(messages);
1509
- _context18.prev = 10;
1510
- _iterator6.s();
1511
- case 12:
1512
- if ((_step6 = _iterator6.n()).done) {
1513
- _context18.next = 37;
1548
+ shouldClearPriceCache = false;
1549
+ _iterator7 = _createForOfIteratorHelper(messages);
1550
+ _context17.prev = 11;
1551
+ _iterator7.s();
1552
+ case 13:
1553
+ if ((_step7 = _iterator7.n()).done) {
1554
+ _context17.next = 36;
1514
1555
  break;
1515
1556
  }
1516
- msg = _step6.value;
1557
+ msg = _step7.value;
1517
1558
  channelKey = msg._channelKey || msg.module || 'product';
1518
1559
  if (!(channelKey === 'product')) {
1519
- _context18.next = 34;
1560
+ _context17.next = 33;
1520
1561
  break;
1521
1562
  }
1563
+ if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
1564
+ sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1565
+ }
1566
+ // 1. 删除场景:operation === 'delete' 或 action === 'delete'
1522
1567
  if (!(msg.operation === 'delete' || msg.action === 'delete')) {
1523
- _context18.next = 19;
1568
+ _context17.next = 21;
1524
1569
  break;
1525
1570
  }
1526
1571
  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);
1527
- return _context18.abrupt("continue", 35);
1528
- case 19:
1529
- if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.length && msg.change_types.every(function (t) {
1530
- return t === 'stock';
1531
- }))) {
1532
- _context18.next = 22;
1533
- break;
1534
- }
1535
- this.logInfo('跳过仅库存变更', {
1536
- ids: msg.ids
1537
- });
1538
- return _context18.abrupt("continue", 35);
1539
- case 22:
1540
- if (!((_msg$change_types2 = msg.change_types) !== null && _msg$change_types2 !== void 0 && _msg$change_types2.includes('price'))) {
1541
- _context18.next = 27;
1572
+ return _context17.abrupt("continue", 34);
1573
+ case 21:
1574
+ if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
1575
+ _context17.next = 26;
1542
1576
  break;
1543
1577
  }
1544
1578
  ids = msg.ids || (msg.id ? [msg.id] : []);
1545
- sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(ids));
1546
1579
  priceRefreshIds.push.apply(priceRefreshIds, _toConsumableArray(ids));
1547
- return _context18.abrupt("continue", 35);
1548
- case 27:
1580
+ if (msg.body) {
1581
+ bodyId = msg.body.id;
1582
+ if (bodyId) bodyUpdates.set(bodyId, msg.body);
1583
+ }
1584
+ return _context17.abrupt("continue", 34);
1585
+ case 26:
1549
1586
  if (!msg.body) {
1550
- _context18.next = 31;
1587
+ _context17.next = 30;
1551
1588
  break;
1552
1589
  }
1553
- bodyId = msg.body.id || msg.id;
1554
- if (bodyId) bodyUpdates.set(bodyId, msg.body);
1555
- return _context18.abrupt("continue", 35);
1556
- case 31:
1557
- // 5. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
1590
+ _bodyId = msg.body.id || msg.id;
1591
+ if (_bodyId) bodyUpdates.set(_bodyId, msg.body);
1592
+ return _context17.abrupt("continue", 34);
1593
+ case 30:
1594
+ // 4. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
1558
1595
  if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
1559
1596
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.ids));
1560
1597
  } else if (msg.id) {
1561
1598
  sseRefreshIds.push(msg.id);
1562
1599
  }
1563
- _context18.next = 35;
1600
+ _context17.next = 34;
1564
1601
  break;
1565
- case 34:
1566
- if (['product_collection', 'product_category', 'product_quotation'].includes(channelKey)) {
1567
- if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
1602
+ case 33:
1603
+ if (channelKey === 'product_quotation') {
1604
+ // 报价单变更影响范围大,标记清除全量价格缓存
1605
+ shouldClearPriceCache = true;
1606
+ if ((_msg$relation_product2 = msg.relation_product_ids) !== null && _msg$relation_product2 !== void 0 && _msg$relation_product2.length) {
1607
+ sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1608
+ }
1609
+ } else if (['product_collection', 'product_category'].includes(channelKey)) {
1610
+ if ((_msg$relation_product3 = msg.relation_product_ids) !== null && _msg$relation_product3 !== void 0 && _msg$relation_product3.length) {
1568
1611
  sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
1569
- if (channelKey === 'product_quotation') {
1570
- this.clearPriceCache();
1571
- priceRefreshIds.push.apply(priceRefreshIds, _toConsumableArray(msg.relation_product_ids));
1572
- }
1573
1612
  }
1574
1613
  }
1575
- case 35:
1576
- _context18.next = 12;
1614
+ case 34:
1615
+ _context17.next = 13;
1577
1616
  break;
1578
- case 37:
1579
- _context18.next = 42;
1617
+ case 36:
1618
+ _context17.next = 41;
1580
1619
  break;
1581
- case 39:
1582
- _context18.prev = 39;
1583
- _context18.t0 = _context18["catch"](10);
1584
- _iterator6.e(_context18.t0);
1585
- case 42:
1586
- _context18.prev = 42;
1587
- _iterator6.f();
1588
- return _context18.finish(42);
1589
- case 45:
1620
+ case 38:
1621
+ _context17.prev = 38;
1622
+ _context17.t0 = _context17["catch"](11);
1623
+ _iterator7.e(_context17.t0);
1624
+ case 41:
1625
+ _context17.prev = 41;
1626
+ _iterator7.f();
1627
+ return _context17.finish(41);
1628
+ case 44:
1590
1629
  uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
1591
1630
  uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds));
1592
1631
  uniquePriceIds = _toConsumableArray(new Set(priceRefreshIds)); // 1. 处理删除
1593
1632
  if (!(uniqueDeleteIds.length > 0)) {
1594
- _context18.next = 51;
1633
+ _context17.next = 50;
1595
1634
  break;
1596
1635
  }
1597
- _context18.next = 51;
1636
+ _context17.next = 50;
1598
1637
  return this.removeProductsByIds(uniqueDeleteIds);
1599
- case 51:
1638
+ case 50:
1600
1639
  if (!(bodyUpdates.size > 0)) {
1601
- _context18.next = 54;
1640
+ _context17.next = 53;
1602
1641
  break;
1603
1642
  }
1604
- _context18.next = 54;
1643
+ _context17.next = 53;
1605
1644
  return this.applyBodyUpdatesToStore(bodyUpdates);
1606
- case 54:
1645
+ case 53:
1607
1646
  if (!(uniqueSSEIds.length > 0)) {
1608
- _context18.next = 64;
1647
+ _context17.next = 61;
1609
1648
  break;
1610
1649
  }
1611
- _context18.next = 57;
1650
+ _context17.next = 56;
1612
1651
  return this.fetchProductsBySSE(uniqueSSEIds);
1613
- case 57:
1614
- freshProducts = _context18.sent;
1652
+ case 56:
1653
+ freshProducts = _context17.sent;
1615
1654
  if (!(freshProducts.length > 0)) {
1616
- _context18.next = 63;
1655
+ _context17.next = 60;
1617
1656
  break;
1618
1657
  }
1619
- _context18.next = 61;
1658
+ _context17.next = 60;
1620
1659
  return this.mergeProductsToStore(freshProducts);
1621
- case 61:
1622
- _context18.next = 63;
1623
- return this.updatePriceCacheForProducts(freshProducts);
1624
- case 63:
1625
- this.logInfo('processProductSyncMessages: SSE 增量更新完成', {
1660
+ case 60:
1661
+ this.logInfo('processProductSyncMessages: SSE 增量更新完成123', {
1626
1662
  requestedCount: uniqueSSEIds.length,
1627
1663
  receivedCount: freshProducts.length
1628
1664
  });
1629
- case 64:
1630
- // 4. 处理报价单价格刷新(排除已被第3步 SSE 处理过的 id,避免重复请求)
1631
- sseHandledSet = new Set(uniqueSSEIds);
1632
- remainingPriceIds = uniquePriceIds.filter(function (id) {
1633
- return !sseHandledSet.has(id);
1634
- });
1635
- if (!(remainingPriceIds.length > 0)) {
1636
- _context18.next = 69;
1637
- break;
1638
- }
1639
- _context18.next = 69;
1640
- return this.updateProductPriceByIds(remainingPriceIds);
1641
- case 69:
1642
- this.logInfo('processProductSyncMessages: 处理完成', {
1665
+ case 61:
1666
+ // 收集所有非 delete 的变更 IDs(body + SSE + price),用于增量更新价格缓存
1667
+ allChangedIds = _toConsumableArray(new Set([].concat(_toConsumableArray(Array.from(bodyUpdates.keys())), _toConsumableArray(uniqueSSEIds), _toConsumableArray(uniquePriceIds))));
1668
+ this.logInfo('processProductSyncMessages: 处理完成123', {
1643
1669
  deleteCount: uniqueDeleteIds.length,
1644
1670
  bodyUpdateCount: bodyUpdates.size,
1645
1671
  sseRefreshCount: uniqueSSEIds.length,
1646
- priceRefreshCount: uniquePriceIds.length
1672
+ priceRefreshCount: uniquePriceIds.length,
1673
+ allChangedIdsCount: allChangedIds.length,
1674
+ shouldClearPriceCache: shouldClearPriceCache
1647
1675
  });
1648
-
1649
- // 如果都没有变更,则不触发 onProductsSyncCompleted
1650
- if (!(uniqueDeleteIds.length === 0 && bodyUpdates.size === 0 && uniqueSSEIds.length === 0 && uniquePriceIds.length === 0)) {
1651
- _context18.next = 73;
1676
+ hasChanges = uniqueDeleteIds.length > 0 || allChangedIds.length > 0 || shouldClearPriceCache;
1677
+ if (hasChanges) {
1678
+ _context17.next = 67;
1652
1679
  break;
1653
1680
  }
1654
1681
  this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
1655
- return _context18.abrupt("return");
1656
- case 73:
1657
- _context18.next = 75;
1658
- return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
1659
- case 75:
1682
+ return _context17.abrupt("return");
1683
+ case 67:
1684
+ // 报价单变更 → 清除全量价格缓存,后续走全量重建
1685
+ if (shouldClearPriceCache) {
1686
+ this.clearPriceCache();
1687
+ }
1688
+ _context17.next = 70;
1689
+ return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, {
1690
+ changedIds: allChangedIds
1691
+ });
1692
+ case 70:
1660
1693
  case "end":
1661
- return _context18.stop();
1694
+ return _context17.stop();
1662
1695
  }
1663
- }, _callee18, this, [[10, 39, 42, 45]]);
1696
+ }, _callee17, this, [[11, 38, 41, 44]]);
1664
1697
  }));
1665
1698
  function processProductSyncMessages() {
1666
1699
  return _processProductSyncMessages.apply(this, arguments);
@@ -1675,25 +1708,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1675
1708
  }, {
1676
1709
  key: "fetchProductsBySSE",
1677
1710
  value: (function () {
1678
- var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(ids) {
1711
+ var _fetchProductsBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ids) {
1679
1712
  var t0, productList, list, errorMessage;
1680
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1681
- while (1) switch (_context19.prev = _context19.next) {
1713
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1714
+ while (1) switch (_context18.prev = _context18.next) {
1682
1715
  case 0:
1683
1716
  if (this.productDataSource) {
1684
- _context19.next = 3;
1717
+ _context18.next = 3;
1685
1718
  break;
1686
1719
  }
1687
1720
  this.logWarning('fetchProductsBySSE: ProductDataSource 不可用');
1688
- return _context19.abrupt("return", []);
1721
+ return _context18.abrupt("return", []);
1689
1722
  case 3:
1690
1723
  this.logInfo('fetchProductsBySSE: 开始', {
1691
1724
  ids: ids,
1692
1725
  count: ids.length
1693
1726
  });
1694
1727
  t0 = performance.now();
1695
- _context19.prev = 5;
1696
- _context19.next = 8;
1728
+ _context18.prev = 5;
1729
+ _context18.next = 8;
1697
1730
  return this.productDataSource.run({
1698
1731
  sse: {
1699
1732
  query: {
@@ -1703,7 +1736,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1703
1736
  }
1704
1737
  });
1705
1738
  case 8:
1706
- productList = _context19.sent;
1739
+ productList = _context18.sent;
1707
1740
  list = productList || [];
1708
1741
  perfMark('fetchProductsBySSE', performance.now() - t0, {
1709
1742
  count: list.length
@@ -1713,23 +1746,23 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1713
1746
  receivedCount: list.length,
1714
1747
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1715
1748
  });
1716
- return _context19.abrupt("return", list);
1749
+ return _context18.abrupt("return", list);
1717
1750
  case 15:
1718
- _context19.prev = 15;
1719
- _context19.t0 = _context19["catch"](5);
1720
- errorMessage = _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0);
1751
+ _context18.prev = 15;
1752
+ _context18.t0 = _context18["catch"](5);
1753
+ errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1721
1754
  this.logError('fetchProductsBySSE: 失败', {
1722
1755
  ids: ids,
1723
1756
  error: errorMessage
1724
1757
  });
1725
- return _context19.abrupt("return", []);
1758
+ return _context18.abrupt("return", []);
1726
1759
  case 20:
1727
1760
  case "end":
1728
- return _context19.stop();
1761
+ return _context18.stop();
1729
1762
  }
1730
- }, _callee19, this, [[5, 15]]);
1763
+ }, _callee18, this, [[5, 15]]);
1731
1764
  }));
1732
- function fetchProductsBySSE(_x16) {
1765
+ function fetchProductsBySSE(_x17) {
1733
1766
  return _fetchProductsBySSE.apply(this, arguments);
1734
1767
  }
1735
1768
  return fetchProductsBySSE;
@@ -1737,16 +1770,17 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1737
1770
  /**
1738
1771
  * 将 body 完整数据直接覆盖到本地 store(不调用报价单接口)
1739
1772
  * 已存在的 → 直接替换;不存在的 → 追加
1740
- * 同时更新 Map 缓存、IndexDB,清空价格缓存,触发 onProductsChanged
1773
+ * 同时更新 Map 缓存、IndexDB,触发 onProductsChanged
1774
+ * 价格缓存由 processProductSyncMessages 末尾统一清除
1741
1775
  */
1742
1776
  )
1743
1777
  }, {
1744
1778
  key: "applyBodyUpdatesToStore",
1745
1779
  value: (function () {
1746
- var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(bodyUpdates) {
1747
- var updatedCount, newCount, appliedIds, _iterator7, _step7, _step7$value, id, body;
1748
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1749
- while (1) switch (_context20.prev = _context20.next) {
1780
+ var _applyBodyUpdatesToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(bodyUpdates) {
1781
+ 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) {
1750
1784
  case 0:
1751
1785
  this.logInfo('applyBodyUpdatesToStore: 开始', {
1752
1786
  count: bodyUpdates.size
@@ -1762,40 +1796,37 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1762
1796
  }
1763
1797
  return p;
1764
1798
  });
1765
- _iterator7 = _createForOfIteratorHelper(bodyUpdates);
1799
+ _iterator8 = _createForOfIteratorHelper(bodyUpdates);
1766
1800
  try {
1767
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1768
- _step7$value = _slicedToArray(_step7.value, 2), id = _step7$value[0], body = _step7$value[1];
1801
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1802
+ _step8$value = _slicedToArray(_step8.value, 2), id = _step8$value[0], body = _step8$value[1];
1769
1803
  if (!appliedIds.has(id)) {
1770
1804
  this.store.list.push(body);
1771
1805
  newCount++;
1772
1806
  }
1773
1807
  }
1774
1808
  } catch (err) {
1775
- _iterator7.e(err);
1809
+ _iterator8.e(err);
1776
1810
  } finally {
1777
- _iterator7.f();
1811
+ _iterator8.f();
1778
1812
  }
1779
1813
  this.syncProductsMap();
1780
- _context20.next = 10;
1814
+ _context19.next = 10;
1781
1815
  return this.saveProductsToIndexDB(this.store.list);
1782
1816
  case 10:
1783
- _context20.next = 12;
1784
- return this.updatePriceCacheForProducts(_toConsumableArray(bodyUpdates.values()));
1785
- case 12:
1786
1817
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1787
1818
  this.logInfo('applyBodyUpdatesToStore: 完成', {
1788
1819
  updatedCount: updatedCount,
1789
1820
  newCount: newCount,
1790
1821
  totalCount: this.store.list.length
1791
1822
  });
1792
- case 14:
1823
+ case 12:
1793
1824
  case "end":
1794
- return _context20.stop();
1825
+ return _context19.stop();
1795
1826
  }
1796
- }, _callee20, this);
1827
+ }, _callee19, this);
1797
1828
  }));
1798
- function applyBodyUpdatesToStore(_x17) {
1829
+ function applyBodyUpdatesToStore(_x18) {
1799
1830
  return _applyBodyUpdatesToStore.apply(this, arguments);
1800
1831
  }
1801
1832
  return applyBodyUpdatesToStore;
@@ -1809,22 +1840,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1809
1840
  }, {
1810
1841
  key: "mergeProductsToStore",
1811
1842
  value: (function () {
1812
- var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(freshProducts) {
1813
- var freshMap, _iterator8, _step8, p, updatedList, newCount, _iterator9, _step9, _p, updatedCount;
1814
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1815
- while (1) switch (_context21.prev = _context21.next) {
1843
+ var _mergeProductsToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(freshProducts) {
1844
+ 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) {
1816
1847
  case 0:
1817
1848
  freshMap = new Map();
1818
- _iterator8 = _createForOfIteratorHelper(freshProducts);
1849
+ _iterator9 = _createForOfIteratorHelper(freshProducts);
1819
1850
  try {
1820
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1821
- p = _step8.value;
1851
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1852
+ p = _step9.value;
1822
1853
  freshMap.set(p.id, p);
1823
1854
  }
1824
1855
  } catch (err) {
1825
- _iterator8.e(err);
1856
+ _iterator9.e(err);
1826
1857
  } finally {
1827
- _iterator8.f();
1858
+ _iterator9.f();
1828
1859
  }
1829
1860
  updatedList = this.store.list.map(function (p) {
1830
1861
  if (freshMap.has(p.id)) {
@@ -1835,21 +1866,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1835
1866
  return p;
1836
1867
  }); // freshMap 中剩余的是新商品(create 场景)
1837
1868
  newCount = freshMap.size;
1838
- _iterator9 = _createForOfIteratorHelper(freshMap.values());
1869
+ _iterator10 = _createForOfIteratorHelper(freshMap.values());
1839
1870
  try {
1840
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
1841
- _p = _step9.value;
1842
- updatedList.push(_p);
1871
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1872
+ _p2 = _step10.value;
1873
+ updatedList.push(_p2);
1843
1874
  }
1844
1875
  } catch (err) {
1845
- _iterator9.e(err);
1876
+ _iterator10.e(err);
1846
1877
  } finally {
1847
- _iterator9.f();
1878
+ _iterator10.f();
1848
1879
  }
1849
1880
  updatedCount = freshProducts.length - newCount;
1850
1881
  this.store.list = updatedList;
1851
1882
  this.syncProductsMap();
1852
- _context21.next = 12;
1883
+ _context20.next = 12;
1853
1884
  return this.saveProductsToIndexDB(this.store.list);
1854
1885
  case 12:
1855
1886
  this.logInfo('mergeProductsToStore: 合并完成', {
@@ -1860,217 +1891,15 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1860
1891
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
1861
1892
  case 14:
1862
1893
  case "end":
1863
- return _context21.stop();
1894
+ return _context20.stop();
1864
1895
  }
1865
- }, _callee21, this);
1896
+ }, _callee20, this);
1866
1897
  }));
1867
- function mergeProductsToStore(_x18) {
1898
+ function mergeProductsToStore(_x19) {
1868
1899
  return _mergeProductsToStore.apply(this, arguments);
1869
1900
  }
1870
1901
  return mergeProductsToStore;
1871
1902
  }()
1872
- /**
1873
- * 增量更新价格缓存中变更的商品
1874
- * 对每个已缓存的日期 key:替换/追加最新商品数据,重新拉取这些 ID 的价格并应用
1875
- */
1876
- )
1877
- }, {
1878
- key: "updatePriceCacheForProducts",
1879
- value: (function () {
1880
- var _updatePriceCacheForProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(freshProducts) {
1881
- var freshIds, freshMap, _iterator10, _step10, p, _iterator11, _step11, _step11$value, dateKey, cachedProducts, updatedList, existingIds, _iterator12, _step12, _p2, priceData, result, errorMessage;
1882
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1883
- while (1) switch (_context22.prev = _context22.next) {
1884
- case 0:
1885
- if (!(this.productsPriceCache.size === 0)) {
1886
- _context22.next = 2;
1887
- break;
1888
- }
1889
- return _context22.abrupt("return");
1890
- case 2:
1891
- freshIds = freshProducts.map(function (p) {
1892
- return p.id;
1893
- });
1894
- freshMap = new Map();
1895
- _iterator10 = _createForOfIteratorHelper(freshProducts);
1896
- try {
1897
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1898
- p = _step10.value;
1899
- freshMap.set(p.id, p);
1900
- }
1901
- } catch (err) {
1902
- _iterator10.e(err);
1903
- } finally {
1904
- _iterator10.f();
1905
- }
1906
- this.logInfo('updatePriceCacheForProducts: 开始', {
1907
- freshIds: freshIds,
1908
- cachedDateCount: this.productsPriceCache.size
1909
- });
1910
- _iterator11 = _createForOfIteratorHelper(this.productsPriceCache.entries());
1911
- _context22.prev = 8;
1912
- _iterator11.s();
1913
- case 10:
1914
- if ((_step11 = _iterator11.n()).done) {
1915
- _context22.next = 31;
1916
- break;
1917
- }
1918
- _step11$value = _slicedToArray(_step11.value, 2), dateKey = _step11$value[0], cachedProducts = _step11$value[1];
1919
- _context22.prev = 12;
1920
- // 1. 替换已有商品 / 收集新增商品
1921
- updatedList = cachedProducts.map(function (p) {
1922
- var fresh = freshMap.get(p.id);
1923
- return fresh ? _objectSpread({}, fresh) : p;
1924
- }); // 追加新增商品(缓存中不存在的 ID)
1925
- existingIds = new Set(cachedProducts.map(function (p) {
1926
- return p.id;
1927
- }));
1928
- _iterator12 = _createForOfIteratorHelper(freshProducts);
1929
- try {
1930
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
1931
- _p2 = _step12.value;
1932
- if (!existingIds.has(_p2.id)) {
1933
- updatedList.push(_objectSpread({}, _p2));
1934
- }
1935
- }
1936
-
1937
- // 2. 拉取这些 ID 的最新价格并应用
1938
- } catch (err) {
1939
- _iterator12.e(err);
1940
- } finally {
1941
- _iterator12.f();
1942
- }
1943
- _context22.next = 19;
1944
- return this.loadProductsPrice({
1945
- ids: freshIds,
1946
- schedule_date: dateKey
1947
- });
1948
- case 19:
1949
- priceData = _context22.sent;
1950
- result = priceData && priceData.length > 0 ? applyPriceDataToProducts(updatedList, priceData) : updatedList;
1951
- this.productsPriceCache.set(dateKey, result);
1952
- this.logInfo('updatePriceCacheForProducts: 日期缓存已更新', {
1953
- dateKey: dateKey,
1954
- updatedIds: freshIds
1955
- });
1956
- _context22.next = 29;
1957
- break;
1958
- case 25:
1959
- _context22.prev = 25;
1960
- _context22.t0 = _context22["catch"](12);
1961
- errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0);
1962
- this.logError('updatePriceCacheForProducts: 失败', {
1963
- dateKey: dateKey,
1964
- error: errorMessage
1965
- });
1966
- case 29:
1967
- _context22.next = 10;
1968
- break;
1969
- case 31:
1970
- _context22.next = 36;
1971
- break;
1972
- case 33:
1973
- _context22.prev = 33;
1974
- _context22.t1 = _context22["catch"](8);
1975
- _iterator11.e(_context22.t1);
1976
- case 36:
1977
- _context22.prev = 36;
1978
- _iterator11.f();
1979
- return _context22.finish(36);
1980
- case 39:
1981
- case "end":
1982
- return _context22.stop();
1983
- }
1984
- }, _callee22, this, [[8, 33, 36, 39], [12, 25]]);
1985
- }));
1986
- function updatePriceCacheForProducts(_x19) {
1987
- return _updatePriceCacheForProducts.apply(this, arguments);
1988
- }
1989
- return updatePriceCacheForProducts;
1990
- }()
1991
- /**
1992
- * 全量重新拉取报价单价格并重建价格缓存
1993
- * 遍历当前已缓存的所有日期 key,对每个日期重新调用 loadProductsPrice
1994
- */
1995
- )
1996
- }, {
1997
- key: "refreshAllPriceCache",
1998
- value: (function () {
1999
- var _refreshAllPriceCache = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2000
- var allProducts, ids, dateKeys, _i, _dateKeys, dateKey, priceData, updatedProducts, errorMessage;
2001
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2002
- while (1) switch (_context23.prev = _context23.next) {
2003
- case 0:
2004
- allProducts = this.getProductsRef();
2005
- if (!(allProducts.length === 0)) {
2006
- _context23.next = 3;
2007
- break;
2008
- }
2009
- return _context23.abrupt("return");
2010
- case 3:
2011
- ids = allProducts.map(function (p) {
2012
- return p.id;
2013
- }); // 先快照当前已缓存的日期 key,再清空缓存
2014
- dateKeys = Array.from(this.productsPriceCache.keys());
2015
- this.clearPriceCache();
2016
- if (!(dateKeys.length === 0)) {
2017
- _context23.next = 9;
2018
- break;
2019
- }
2020
- this.logInfo('refreshAllPriceCache: 无已缓存日期,跳过');
2021
- return _context23.abrupt("return");
2022
- case 9:
2023
- this.logInfo('refreshAllPriceCache: 开始重新拉取', {
2024
- dateKeys: dateKeys,
2025
- productCount: ids.length
2026
- });
2027
- _i = 0, _dateKeys = dateKeys;
2028
- case 11:
2029
- if (!(_i < _dateKeys.length)) {
2030
- _context23.next = 28;
2031
- break;
2032
- }
2033
- dateKey = _dateKeys[_i];
2034
- _context23.prev = 13;
2035
- _context23.next = 16;
2036
- return this.loadProductsPrice({
2037
- ids: ids,
2038
- schedule_date: dateKey
2039
- });
2040
- case 16:
2041
- priceData = _context23.sent;
2042
- if (priceData && priceData.length > 0) {
2043
- updatedProducts = applyPriceDataToProducts(allProducts, priceData);
2044
- this.productsPriceCache.set(dateKey, updatedProducts);
2045
- }
2046
- this.logInfo('refreshAllPriceCache: 日期缓存已更新', {
2047
- dateKey: dateKey
2048
- });
2049
- _context23.next = 25;
2050
- break;
2051
- case 21:
2052
- _context23.prev = 21;
2053
- _context23.t0 = _context23["catch"](13);
2054
- errorMessage = _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0);
2055
- this.logError('refreshAllPriceCache: 失败', {
2056
- dateKey: dateKey,
2057
- error: errorMessage
2058
- });
2059
- case 25:
2060
- _i++;
2061
- _context23.next = 11;
2062
- break;
2063
- case 28:
2064
- case "end":
2065
- return _context23.stop();
2066
- }
2067
- }, _callee23, this, [[13, 21]]);
2068
- }));
2069
- function refreshAllPriceCache() {
2070
- return _refreshAllPriceCache.apply(this, arguments);
2071
- }
2072
- return refreshAllPriceCache;
2073
- }()
2074
1903
  /**
2075
1904
  * 静默全量刷新:后台重新拉取全量 SSE 数据并更新本地
2076
1905
  * 拿到完整数据后一次性替换 store,清除价格缓存,触发 onProductsSyncCompleted
@@ -2080,34 +1909,34 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2080
1909
  }, {
2081
1910
  key: "silentRefresh",
2082
1911
  value: (function () {
2083
- var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1912
+ var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2084
1913
  var t0, products, errorMessage;
2085
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2086
- while (1) switch (_context24.prev = _context24.next) {
1914
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1915
+ while (1) switch (_context21.prev = _context21.next) {
2087
1916
  case 0:
2088
1917
  t0 = performance.now();
2089
1918
  this.logInfo('silentRefresh 开始');
2090
- _context24.prev = 2;
2091
- _context24.next = 5;
1919
+ _context21.prev = 2;
1920
+ _context21.next = 5;
2092
1921
  return this.loadProductsByServer();
2093
1922
  case 5:
2094
- products = _context24.sent;
1923
+ products = _context21.sent;
2095
1924
  if (!(products && products.length > 0)) {
2096
- _context24.next = 16;
1925
+ _context21.next = 16;
2097
1926
  break;
2098
1927
  }
2099
1928
  this.store.list = products;
2100
1929
  this.syncProductsMap();
2101
1930
  this.clearPriceCache();
2102
1931
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
2103
- _context24.next = 13;
1932
+ _context21.next = 13;
2104
1933
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
2105
1934
  case 13:
2106
1935
  this.logInfo('silentRefresh 完成', {
2107
1936
  productCount: products.length,
2108
1937
  duration: "".concat(Math.round(performance.now() - t0), "ms")
2109
1938
  });
2110
- _context24.next = 17;
1939
+ _context21.next = 17;
2111
1940
  break;
2112
1941
  case 16:
2113
1942
  this.logWarning('silentRefresh: 服务器未返回数据');
@@ -2115,21 +1944,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2115
1944
  perfMark('silentRefresh', performance.now() - t0, {
2116
1945
  count: this.store.list.length
2117
1946
  });
2118
- return _context24.abrupt("return", this.store.list);
1947
+ return _context21.abrupt("return", this.store.list);
2119
1948
  case 21:
2120
- _context24.prev = 21;
2121
- _context24.t0 = _context24["catch"](2);
2122
- errorMessage = _context24.t0 instanceof Error ? _context24.t0.message : String(_context24.t0);
1949
+ _context21.prev = 21;
1950
+ _context21.t0 = _context21["catch"](2);
1951
+ errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
2123
1952
  this.logError('silentRefresh 失败', {
2124
1953
  duration: "".concat(Math.round(performance.now() - t0), "ms"),
2125
1954
  error: errorMessage
2126
1955
  });
2127
- return _context24.abrupt("return", this.store.list);
1956
+ return _context21.abrupt("return", this.store.list);
2128
1957
  case 26:
2129
1958
  case "end":
2130
- return _context24.stop();
1959
+ return _context21.stop();
2131
1960
  }
2132
- }, _callee24, this, [[2, 21]]);
1961
+ }, _callee21, this, [[2, 21]]);
2133
1962
  }));
2134
1963
  function silentRefresh() {
2135
1964
  return _silentRefresh.apply(this, arguments);