@pisell/pisellos 2.3.66 → 2.3.67

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 (53) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +109 -65
  3. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  4. package/dist/model/strategy/adapter/walletPass/evaluator.js +1 -0
  5. package/dist/model/strategy/adapter/walletPass/utils.js +2 -0
  6. package/dist/modules/Customer/index.d.ts +0 -4
  7. package/dist/modules/Customer/index.js +59 -91
  8. package/dist/modules/Customer/types.d.ts +0 -2
  9. package/dist/modules/Payment/walletpass.js +11 -31
  10. package/dist/modules/Quotation/index.d.ts +6 -0
  11. package/dist/modules/Quotation/index.js +75 -19
  12. package/dist/plugins/request.d.ts +1 -0
  13. package/dist/server/index.d.ts +8 -2
  14. package/dist/server/index.js +212 -143
  15. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  16. package/dist/server/modules/floor-plan/index.js +240 -98
  17. package/dist/server/modules/menu/index.js +48 -23
  18. package/dist/server/modules/order/index.d.ts +17 -8
  19. package/dist/server/modules/order/index.js +506 -453
  20. package/dist/server/modules/products/index.d.ts +8 -2
  21. package/dist/server/modules/products/index.js +167 -75
  22. package/dist/server/modules/resource/index.js +21 -13
  23. package/dist/server/utils/small-ticket.js +1 -2
  24. package/dist/solution/BookingByStep/index.d.ts +1 -1
  25. package/dist/solution/BookingTicket/index.d.ts +0 -2
  26. package/dist/solution/BookingTicket/index.js +10 -34
  27. package/lib/core/index.d.ts +7 -0
  28. package/lib/core/index.js +20 -2
  29. package/lib/model/strategy/adapter/promotion/index.js +0 -51
  30. package/lib/model/strategy/adapter/walletPass/evaluator.js +1 -0
  31. package/lib/model/strategy/adapter/walletPass/utils.js +1 -0
  32. package/lib/modules/Customer/index.d.ts +0 -4
  33. package/lib/modules/Customer/index.js +0 -11
  34. package/lib/modules/Customer/types.d.ts +0 -2
  35. package/lib/modules/Payment/walletpass.js +2 -15
  36. package/lib/modules/Quotation/index.d.ts +6 -0
  37. package/lib/modules/Quotation/index.js +49 -5
  38. package/lib/plugins/request.d.ts +1 -0
  39. package/lib/server/index.d.ts +8 -2
  40. package/lib/server/index.js +58 -20
  41. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  42. package/lib/server/modules/floor-plan/index.js +54 -6
  43. package/lib/server/modules/menu/index.js +31 -5
  44. package/lib/server/modules/order/index.d.ts +17 -8
  45. package/lib/server/modules/order/index.js +199 -106
  46. package/lib/server/modules/products/index.d.ts +8 -2
  47. package/lib/server/modules/products/index.js +97 -24
  48. package/lib/server/modules/resource/index.js +7 -2
  49. package/lib/server/utils/small-ticket.js +1 -1
  50. package/lib/solution/BookingByStep/index.d.ts +1 -1
  51. package/lib/solution/BookingTicket/index.d.ts +0 -2
  52. package/lib/solution/BookingTicket/index.js +2 -18
  53. package/package.json +1 -1
@@ -25,6 +25,7 @@ export declare class ProductsModule extends BaseModule implements Module {
25
25
  private quotationBridgeLoadedKey?;
26
26
  private quotationBridgeRefreshPromise?;
27
27
  private quotationBridgeRefreshKey?;
28
+ private quotationBridgeUpdatedCallback?;
28
29
  private quotationScheduleCache;
29
30
  private quotationScheduleCacheSource;
30
31
  private quotationScheduleCacheLoaded;
@@ -72,6 +73,7 @@ export declare class ProductsModule extends BaseModule implements Module {
72
73
  scheduleModule?: any;
73
74
  channel?: string;
74
75
  customer_id?: number | string;
76
+ onQuotationUpdated?: () => void;
75
77
  }): Promise<void>;
76
78
  /**
77
79
  * 刷新桥接器内的报价单列表。
@@ -181,7 +183,9 @@ export declare class ProductsModule extends BaseModule implements Module {
181
183
  /**
182
184
  * 通过 ProductDataSource SSE 加载完整商品列表
183
185
  */
184
- loadProductsByServer(): Promise<any>;
186
+ loadProductsByServer(options?: {
187
+ trigger?: string;
188
+ }): Promise<any>;
185
189
  /**
186
190
  * 纯请求方法:通过 HTTP 接口获取商品列表(无副作用,不触发事件、不写 IndexDB)
187
191
  * @param params 查询参数
@@ -331,7 +335,9 @@ export declare class ProductsModule extends BaseModule implements Module {
331
335
  * 拿到完整数据后一次性替换 store,清除价格缓存,触发 onProductsSyncCompleted
332
336
  * @returns 刷新后的商品列表
333
337
  */
334
- silentRefresh(): Promise<ProductData[]>;
338
+ silentRefresh(options?: {
339
+ trigger?: string;
340
+ }): Promise<ProductData[]>;
335
341
  /**
336
342
  * 销毁同步资源(取消 pubsub 订阅、清除定时器)
337
343
  */
@@ -78,6 +78,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
78
78
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeLoadedKey", '');
79
79
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshPromise", void 0);
80
80
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshKey", void 0);
81
+ _defineProperty(_assertThisInitialized(_this), "quotationBridgeUpdatedCallback", void 0);
81
82
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCache", new Map());
82
83
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheSource", null);
83
84
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheLoaded", false);
@@ -290,7 +291,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
290
291
  value: (function () {
291
292
  var _setupQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
292
293
  var _this$otherParams,
293
- _this3 = this;
294
+ _this3 = this,
295
+ _this$quotationPriceB,
296
+ _this$quotationPriceB2;
294
297
  var channel, quotation;
295
298
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
296
299
  while (1) switch (_context3.prev = _context3.next) {
@@ -351,11 +354,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
351
354
  return schedules[0];
352
355
  });
353
356
  }
354
- _context3.next = 13;
357
+ if (params.onQuotationUpdated) {
358
+ this.quotationBridgeUpdatedCallback = params.onQuotationUpdated;
359
+ }
360
+ (_this$quotationPriceB = (_this$quotationPriceB2 = this.quotationPriceBridge).setQuotationListUpdatedListener) === null || _this$quotationPriceB === void 0 || _this$quotationPriceB.call(_this$quotationPriceB2, function () {
361
+ var _this3$quotationBridg;
362
+ _this3.quotationBridgeLoadedKey = _this3.getQuotationBridgeScopeKey();
363
+ _this3.clearPriceCache();
364
+ (_this3$quotationBridg = _this3.quotationBridgeUpdatedCallback) === null || _this3$quotationBridg === void 0 || _this3$quotationBridg.call(_this3);
365
+ });
366
+ _context3.next = 15;
355
367
  return this.refreshQuotationPriceBridge({
356
368
  customer_id: params.customer_id
357
369
  });
358
- case 13:
370
+ case 15:
359
371
  case "end":
360
372
  return _context3.stop();
361
373
  }
@@ -1202,6 +1214,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1202
1214
  key: "clearPriceCache",
1203
1215
  value: function clearPriceCache() {
1204
1216
  this.productsPriceCache.clear();
1217
+ this.quotationScheduleCache.clear();
1218
+ this.quotationScheduleCacheLoaded = false;
1205
1219
  console.log('[ProductsModule] 🗑️ 商品价格缓存已清空');
1206
1220
  }
1207
1221
 
@@ -1212,62 +1226,76 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1212
1226
  key: "loadProductsByServer",
1213
1227
  value: (function () {
1214
1228
  var _loadProductsByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1215
- var t0, tSSE, productList, list, duration, errorMessage;
1229
+ var options,
1230
+ trigger,
1231
+ t0,
1232
+ tSSE,
1233
+ productList,
1234
+ list,
1235
+ duration,
1236
+ errorMessage,
1237
+ _args9 = arguments;
1216
1238
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1217
1239
  while (1) switch (_context9.prev = _context9.next) {
1218
1240
  case 0:
1241
+ options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
1219
1242
  if (this.productDataSource) {
1220
- _context9.next = 3;
1243
+ _context9.next = 4;
1221
1244
  break;
1222
1245
  }
1223
1246
  this.logWarning('loadProductsByServer: ProductDataSource 不可用');
1224
1247
  return _context9.abrupt("return", []);
1225
- case 3:
1226
- this.logInfo('开始通过 DataSource SSE 加载商品列表');
1248
+ case 4:
1249
+ trigger = options.trigger || 'unknown';
1250
+ this.logInfo('开始通过 DataSource SSE 加载商品列表', {
1251
+ trigger: trigger
1252
+ });
1227
1253
  t0 = performance.now();
1228
- _context9.prev = 5;
1254
+ _context9.prev = 7;
1229
1255
  tSSE = performance.now();
1230
- _context9.next = 9;
1256
+ _context9.next = 11;
1231
1257
  return this.productDataSource.run({
1232
1258
  sse: {}
1233
1259
  });
1234
- case 9:
1260
+ case 11:
1235
1261
  productList = _context9.sent;
1236
1262
  list = productList || [];
1237
1263
  perfMark('loadProductsByServer.SSE', performance.now() - tSSE, {
1238
1264
  count: list.length
1239
1265
  });
1240
1266
  this.logInfo('通过 DataSource SSE 加载商品列表成功', {
1267
+ trigger: trigger,
1241
1268
  productCount: list.length,
1242
1269
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1243
1270
  });
1244
- _context9.next = 15;
1271
+ _context9.next = 17;
1245
1272
  return this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer');
1246
- case 15:
1273
+ case 17:
1247
1274
  this.lastServerFullFetchAtMs = Date.now();
1248
- _context9.next = 18;
1275
+ _context9.next = 20;
1249
1276
  return this.core.effects.emit(ProductsHooks.onProductsLoaded, list);
1250
- case 18:
1277
+ case 20:
1251
1278
  perfMark('loadProductsByServer', performance.now() - t0, {
1252
1279
  count: list.length
1253
1280
  });
1254
1281
  return _context9.abrupt("return", list);
1255
- case 22:
1256
- _context9.prev = 22;
1257
- _context9.t0 = _context9["catch"](5);
1282
+ case 24:
1283
+ _context9.prev = 24;
1284
+ _context9.t0 = _context9["catch"](7);
1258
1285
  duration = Math.round(performance.now() - t0);
1259
1286
  errorMessage = _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0);
1260
1287
  console.error('[Products] 加载商品数据失败:', _context9.t0);
1261
1288
  this.logError('通过 DataSource SSE 加载商品列表失败', {
1289
+ trigger: trigger,
1262
1290
  duration: "".concat(duration, "ms"),
1263
1291
  error: errorMessage
1264
1292
  });
1265
1293
  return _context9.abrupt("return", []);
1266
- case 29:
1294
+ case 31:
1267
1295
  case "end":
1268
1296
  return _context9.stop();
1269
1297
  }
1270
- }, _callee9, this, [[5, 22]]);
1298
+ }, _callee9, this, [[7, 24]]);
1271
1299
  }));
1272
1300
  function loadProductsByServer() {
1273
1301
  return _loadProductsByServer.apply(this, arguments);
@@ -1664,7 +1692,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1664
1692
  tTotal = performance.now();
1665
1693
  this.logInfo('refreshProducts 开始');
1666
1694
  _context16.next = 4;
1667
- return this.loadProductsByServer();
1695
+ return this.loadProductsByServer({
1696
+ trigger: 'product_sync'
1697
+ });
1668
1698
  case 4:
1669
1699
  products = _context16.sent;
1670
1700
  if (products && products.length > 0) {
@@ -1756,7 +1786,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1756
1786
  key: "loadProductsFromIndexDB",
1757
1787
  value: (function () {
1758
1788
  var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1759
- var _products$length, _products$length2, t0, products, errorMessage;
1789
+ var startedAt, _products$length, _products$length2, products, durationMs, errorMessage;
1760
1790
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1761
1791
  while (1) switch (_context18.prev = _context18.next) {
1762
1792
  case 0:
@@ -1767,33 +1797,36 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1767
1797
  this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
1768
1798
  return _context18.abrupt("return", []);
1769
1799
  case 3:
1770
- _context18.prev = 3;
1771
- t0 = performance.now();
1800
+ startedAt = performance.now();
1801
+ _context18.prev = 4;
1772
1802
  _context18.next = 7;
1773
1803
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1774
1804
  case 7:
1775
1805
  products = _context18.sent;
1776
- perfMark('loadProductsFromIndexDB', performance.now() - t0, {
1806
+ durationMs = +(performance.now() - startedAt).toFixed(2);
1807
+ perfMark('loadProductsFromIndexDB', durationMs, {
1777
1808
  count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
1778
1809
  });
1779
1810
  this.logInfo('从 IndexDB 加载商品数据', {
1780
- productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
1811
+ productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0,
1812
+ durationMs: durationMs
1781
1813
  });
1782
1814
  return _context18.abrupt("return", products || []);
1783
- case 13:
1784
- _context18.prev = 13;
1785
- _context18.t0 = _context18["catch"](3);
1815
+ case 14:
1816
+ _context18.prev = 14;
1817
+ _context18.t0 = _context18["catch"](4);
1786
1818
  errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1787
1819
  console.error('[Products] 从 IndexDB 读取数据失败:', _context18.t0);
1788
1820
  this.logError('从 IndexDB 读取数据失败', {
1821
+ durationMs: +(performance.now() - startedAt).toFixed(2),
1789
1822
  error: errorMessage
1790
1823
  });
1791
1824
  return _context18.abrupt("return", []);
1792
- case 19:
1825
+ case 20:
1793
1826
  case "end":
1794
1827
  return _context18.stop();
1795
1828
  }
1796
- }, _callee18, this, [[3, 13]]);
1829
+ }, _callee18, this, [[4, 14]]);
1797
1830
  }));
1798
1831
  function loadProductsFromIndexDB() {
1799
1832
  return _loadProductsFromIndexDB.apply(this, arguments);
@@ -1847,7 +1880,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1847
1880
  value: (function () {
1848
1881
  var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(products, source) {
1849
1882
  var _this9 = this;
1850
- var errorMessage;
1883
+ var enqueuedAt, queueWaitMs, clearDurationMs, writeDurationMs, errorMessage;
1851
1884
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1852
1885
  while (1) switch (_context21.prev = _context21.next) {
1853
1886
  case 0:
@@ -1858,58 +1891,86 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1858
1891
  this.logWarning('replaceProductsSnapshotInIndexDB: dbManager 不可用');
1859
1892
  return _context21.abrupt("return");
1860
1893
  case 3:
1861
- _context21.prev = 3;
1862
- _context21.next = 6;
1894
+ enqueuedAt = performance.now();
1895
+ queueWaitMs = 0;
1896
+ clearDurationMs = 0;
1897
+ writeDurationMs = 0;
1898
+ _context21.prev = 7;
1899
+ _context21.next = 10;
1863
1900
  return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1864
- var t0;
1901
+ var operationStartedAt, clearStartedAt, writeStartedAt, executeDurationMs;
1865
1902
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1866
1903
  while (1) switch (_context20.prev = _context20.next) {
1867
1904
  case 0:
1905
+ operationStartedAt = performance.now();
1906
+ queueWaitMs = +(operationStartedAt - enqueuedAt).toFixed(2);
1868
1907
  _this9.logInfo('replaceProductsSnapshotInIndexDB 开始', {
1869
1908
  source: source,
1870
- productCount: products.length
1909
+ productCount: products.length,
1910
+ queueWaitMs: queueWaitMs
1871
1911
  });
1872
- t0 = performance.now();
1873
- _context20.next = 4;
1912
+ clearStartedAt = performance.now();
1913
+ _context20.prev = 4;
1914
+ _context20.next = 7;
1874
1915
  return _this9.dbManager.clear(INDEXDB_STORE_NAME);
1875
- case 4:
1916
+ case 7:
1917
+ _context20.prev = 7;
1918
+ clearDurationMs = +(performance.now() - clearStartedAt).toFixed(2);
1919
+ return _context20.finish(7);
1920
+ case 10:
1876
1921
  if (!(products.length > 0)) {
1877
- _context20.next = 7;
1922
+ _context20.next = 18;
1878
1923
  break;
1879
1924
  }
1880
- _context20.next = 7;
1925
+ writeStartedAt = performance.now();
1926
+ _context20.prev = 12;
1927
+ _context20.next = 15;
1881
1928
  return _this9.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
1882
- case 7:
1883
- perfMark('replaceProductsSnapshotInIndexDB', performance.now() - t0, {
1929
+ case 15:
1930
+ _context20.prev = 15;
1931
+ writeDurationMs = +(performance.now() - writeStartedAt).toFixed(2);
1932
+ return _context20.finish(15);
1933
+ case 18:
1934
+ executeDurationMs = +(performance.now() - operationStartedAt).toFixed(2);
1935
+ perfMark('replaceProductsSnapshotInIndexDB', executeDurationMs, {
1884
1936
  count: products.length
1885
1937
  });
1886
1938
  _this9.logInfo('replaceProductsSnapshotInIndexDB 完成', {
1887
1939
  source: source,
1888
- productCount: products.length
1940
+ productCount: products.length,
1941
+ queueWaitMs: queueWaitMs,
1942
+ clearDurationMs: clearDurationMs,
1943
+ writeDurationMs: writeDurationMs,
1944
+ executeDurationMs: executeDurationMs,
1945
+ totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2)
1889
1946
  });
1890
- case 9:
1947
+ case 21:
1891
1948
  case "end":
1892
1949
  return _context20.stop();
1893
1950
  }
1894
- }, _callee20);
1951
+ }, _callee20, null, [[4,, 7, 10], [12,, 15, 18]]);
1895
1952
  })));
1896
- case 6:
1897
- _context21.next = 12;
1953
+ case 10:
1954
+ _context21.next = 16;
1898
1955
  break;
1899
- case 8:
1900
- _context21.prev = 8;
1901
- _context21.t0 = _context21["catch"](3);
1956
+ case 12:
1957
+ _context21.prev = 12;
1958
+ _context21.t0 = _context21["catch"](7);
1902
1959
  errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1903
1960
  this.logError('全量保存商品到 IndexDB 失败', {
1904
1961
  source: source,
1905
1962
  productCount: products.length,
1963
+ queueWaitMs: queueWaitMs,
1964
+ clearDurationMs: clearDurationMs,
1965
+ writeDurationMs: writeDurationMs,
1966
+ totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2),
1906
1967
  error: errorMessage
1907
1968
  });
1908
- case 12:
1969
+ case 16:
1909
1970
  case "end":
1910
1971
  return _context21.stop();
1911
1972
  }
1912
- }, _callee21, this, [[3, 8]]);
1973
+ }, _callee21, this, [[7, 12]]);
1913
1974
  }));
1914
1975
  function replaceProductsSnapshotInIndexDB(_x21, _x22) {
1915
1976
  return _replaceProductsSnapshotInIndexDB.apply(this, arguments);
@@ -2110,6 +2171,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2110
2171
  source: 'IndexDB'
2111
2172
  });
2112
2173
  this.logInfo('预加载完成(从 IndexDB)', {
2174
+ trigger: 'preload',
2113
2175
  productCount: cachedData.length,
2114
2176
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
2115
2177
  source: 'IndexDB'
@@ -2132,7 +2194,9 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2132
2194
  case 29:
2133
2195
  tServer = performance.now();
2134
2196
  _context24.next = 32;
2135
- return this.loadProductsByServer();
2197
+ return this.loadProductsByServer({
2198
+ trigger: 'preload'
2199
+ });
2136
2200
  case 32:
2137
2201
  products = _context24.sent;
2138
2202
  perfMark('preload.loadFromServer', performance.now() - tServer, {
@@ -2152,6 +2216,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2152
2216
  source: 'Server'
2153
2217
  });
2154
2218
  this.logInfo('预加载完成(从服务器)', {
2219
+ trigger: 'preload',
2155
2220
  productCount: products.length,
2156
2221
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
2157
2222
  source: 'Server'
@@ -2776,64 +2841,91 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2776
2841
  key: "silentRefresh",
2777
2842
  value: (function () {
2778
2843
  var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2779
- var t0, now, elapsedSincePreload, elapsedSinceFullFetch, products, errorMessage;
2844
+ var options,
2845
+ t0,
2846
+ now,
2847
+ trigger,
2848
+ elapsedSincePreloadMs,
2849
+ elapsedSinceFullFetchMs,
2850
+ products,
2851
+ errorMessage,
2852
+ _args29 = arguments;
2780
2853
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2781
2854
  while (1) switch (_context29.prev = _context29.next) {
2782
2855
  case 0:
2856
+ options = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
2783
2857
  t0 = performance.now();
2784
2858
  now = Date.now();
2785
- elapsedSincePreload = now - this.lastPreloadCompletedAtMs;
2786
- elapsedSinceFullFetch = now - this.lastServerFullFetchAtMs;
2787
- if (!(this.lastPreloadCompletedAtMs > 0 && elapsedSincePreload < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS)) {
2788
- _context29.next = 6;
2859
+ trigger = options.trigger || 'background';
2860
+ elapsedSincePreloadMs = now - this.lastPreloadCompletedAtMs;
2861
+ elapsedSinceFullFetchMs = now - this.lastServerFullFetchAtMs;
2862
+ if (!(this.lastPreloadCompletedAtMs > 0 && elapsedSincePreloadMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS)) {
2863
+ _context29.next = 9;
2789
2864
  break;
2790
2865
  }
2866
+ this.logInfo('silentRefresh 跳过全量 SSE', {
2867
+ trigger: trigger,
2868
+ reason: 'within_min_interval',
2869
+ minIntervalMs: PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS,
2870
+ elapsedSincePreloadMs: elapsedSincePreloadMs,
2871
+ elapsedSinceFullFetchMs: elapsedSinceFullFetchMs,
2872
+ productCount: this.store.list.length
2873
+ });
2791
2874
  return _context29.abrupt("return", this.store.list);
2792
- case 6:
2793
- this.logInfo('silentRefresh 开始');
2794
- _context29.prev = 7;
2795
- _context29.next = 10;
2796
- return this.loadProductsByServer();
2797
- case 10:
2875
+ case 9:
2876
+ this.logInfo('silentRefresh 开始', {
2877
+ trigger: trigger,
2878
+ elapsedSincePreloadMs: elapsedSincePreloadMs,
2879
+ elapsedSinceFullFetchMs: elapsedSinceFullFetchMs,
2880
+ productCount: this.store.list.length
2881
+ });
2882
+ _context29.prev = 10;
2883
+ _context29.next = 13;
2884
+ return this.loadProductsByServer({
2885
+ trigger: trigger
2886
+ });
2887
+ case 13:
2798
2888
  products = _context29.sent;
2799
2889
  if (!(products && products.length > 0)) {
2800
- _context29.next = 21;
2890
+ _context29.next = 24;
2801
2891
  break;
2802
2892
  }
2803
2893
  this.store.list = products;
2804
2894
  this.syncProductsMap();
2805
2895
  this.clearPriceCache();
2806
2896
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
2807
- _context29.next = 18;
2897
+ _context29.next = 21;
2808
2898
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
2809
- case 18:
2899
+ case 21:
2810
2900
  this.logInfo('silentRefresh 完成', {
2901
+ trigger: trigger,
2811
2902
  productCount: products.length,
2812
2903
  duration: "".concat(Math.round(performance.now() - t0), "ms")
2813
2904
  });
2814
- _context29.next = 22;
2905
+ _context29.next = 25;
2815
2906
  break;
2816
- case 21:
2907
+ case 24:
2817
2908
  this.logWarning('silentRefresh: 服务器未返回数据');
2818
- case 22:
2909
+ case 25:
2819
2910
  perfMark('silentRefresh', performance.now() - t0, {
2820
2911
  count: this.store.list.length
2821
2912
  });
2822
2913
  return _context29.abrupt("return", this.store.list);
2823
- case 26:
2824
- _context29.prev = 26;
2825
- _context29.t0 = _context29["catch"](7);
2914
+ case 29:
2915
+ _context29.prev = 29;
2916
+ _context29.t0 = _context29["catch"](10);
2826
2917
  errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
2827
2918
  this.logError('silentRefresh 失败', {
2919
+ trigger: trigger,
2828
2920
  duration: "".concat(Math.round(performance.now() - t0), "ms"),
2829
2921
  error: errorMessage
2830
2922
  });
2831
2923
  return _context29.abrupt("return", this.store.list);
2832
- case 31:
2924
+ case 34:
2833
2925
  case "end":
2834
2926
  return _context29.stop();
2835
2927
  }
2836
- }, _callee29, this, [[7, 26]]);
2928
+ }, _callee29, this, [[10, 29]]);
2837
2929
  }));
2838
2930
  function silentRefresh() {
2839
2931
  return _silentRefresh.apply(this, arguments);
@@ -149,41 +149,49 @@ export var ResourceModule = /*#__PURE__*/function (_BaseModule) {
149
149
  while (1) switch (_context2.prev = _context2.next) {
150
150
  case 0:
151
151
  _context2.next = 2;
152
- return this.setupResourceSync();
153
- case 2:
154
- _context2.next = 4;
155
152
  return this.loadResourcesFromSQLite();
156
- case 4:
153
+ case 2:
157
154
  cachedResources = _context2.sent;
158
155
  if (!(cachedResources.length > 0)) {
159
- _context2.next = 12;
156
+ _context2.next = 10;
160
157
  break;
161
158
  }
162
159
  this.store.list = cloneDeep(cachedResources).map(function (item) {
163
160
  return _this3.normalizeResource(item);
164
161
  });
165
162
  this.syncResourcesMap();
166
- _context2.next = 10;
163
+ _context2.next = 8;
167
164
  return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
165
+ case 8:
166
+ // 二次启动优先使用 SQLite。pubsub 注册及远端校准继续在后台执行,
167
+ // setupResourceSync 完成后会合并最新数据并回写 SQLite。
168
+ void this.setupResourceSync().catch(function (error) {
169
+ _this3.logError('后台初始化资源同步失败', error);
170
+ });
171
+ return _context2.abrupt("return");
168
172
  case 10:
169
- _context2.next = 20;
170
- break;
173
+ _context2.next = 12;
174
+ return this.setupResourceSync();
171
175
  case 12:
172
- _context2.next = 14;
176
+ if (!(this.store.list.length === 0)) {
177
+ _context2.next = 21;
178
+ break;
179
+ }
180
+ _context2.next = 15;
173
181
  return this.loadResourcesByServer();
174
- case 14:
182
+ case 15:
175
183
  resources = _context2.sent;
176
184
  if (!(resources.length > 0)) {
177
- _context2.next = 20;
185
+ _context2.next = 21;
178
186
  break;
179
187
  }
180
188
  this.store.list = cloneDeep(resources).map(function (item) {
181
189
  return _this3.normalizeResource(item);
182
190
  });
183
191
  this.syncResourcesMap();
184
- _context2.next = 20;
192
+ _context2.next = 21;
185
193
  return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
186
- case 20:
194
+ case 21:
187
195
  case "end":
188
196
  return _context2.stop();
189
197
  }
@@ -619,8 +619,7 @@ function formatBundlePrice(bundle, currencySymbol) {
619
619
  var _ref33, _ref34, _bundle$bundle_sellin;
620
620
  var value = (_ref33 = (_ref34 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref34 !== void 0 ? _ref34 : bundle.price) !== null && _ref33 !== void 0 ? _ref33 : 0;
621
621
  var amount = new Decimal(toMoneyNumber(value));
622
- // 套餐价格协议:只有 markdown 是减价;加价与商品原价都保持正数。
623
- var isNegative = bundle.price_type === 'markdown';
622
+ var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
624
623
  if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
625
624
  return formatMoney(amount, currencySymbol);
626
625
  }
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -63,8 +63,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
63
63
  scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
64
64
  private hydrateOrderCustomerFromScanDiscounts;
65
65
  private getDiscountCustomerId;
66
- resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
67
- /** 兼容既有优惠码扫码逻辑。 */
68
66
  private resolveCustomerByDiscountCustomerId;
69
67
  private findCustomerById;
70
68
  private normalizeCustomer;