@pisell/pisellos 2.3.69 → 2.3.71

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 (44) hide show
  1. package/dist/core/index.d.ts +0 -7
  2. package/dist/core/index.js +65 -109
  3. package/dist/modules/Order/index.d.ts +1 -1
  4. package/dist/modules/Order/types.d.ts +2 -0
  5. package/dist/modules/Order/types.js +1 -0
  6. package/dist/modules/Quotation/index.d.ts +0 -6
  7. package/dist/modules/Quotation/index.js +19 -75
  8. package/dist/plugins/request.d.ts +0 -1
  9. package/dist/server/index.d.ts +2 -8
  10. package/dist/server/index.js +140 -206
  11. package/dist/server/modules/floor-plan/index.d.ts +0 -4
  12. package/dist/server/modules/floor-plan/index.js +98 -240
  13. package/dist/server/modules/menu/index.js +23 -48
  14. package/dist/server/modules/order/index.d.ts +7 -17
  15. package/dist/server/modules/order/index.js +207 -419
  16. package/dist/server/modules/products/index.d.ts +2 -8
  17. package/dist/server/modules/products/index.js +75 -167
  18. package/dist/server/modules/resource/index.js +13 -21
  19. package/dist/solution/BaseSales/index.js +15 -4
  20. package/dist/solution/BookingByStep/index.d.ts +1 -1
  21. package/dist/solution/BookingTicket/index.d.ts +5 -15
  22. package/dist/solution/BookingTicket/index.js +21 -6
  23. package/lib/core/index.d.ts +0 -7
  24. package/lib/core/index.js +2 -20
  25. package/lib/modules/Order/index.d.ts +1 -1
  26. package/lib/modules/Order/types.d.ts +2 -0
  27. package/lib/modules/Quotation/index.d.ts +0 -6
  28. package/lib/modules/Quotation/index.js +5 -49
  29. package/lib/plugins/request.d.ts +0 -1
  30. package/lib/server/index.d.ts +2 -8
  31. package/lib/server/index.js +17 -52
  32. package/lib/server/modules/floor-plan/index.d.ts +0 -4
  33. package/lib/server/modules/floor-plan/index.js +6 -54
  34. package/lib/server/modules/menu/index.js +5 -31
  35. package/lib/server/modules/order/index.d.ts +7 -17
  36. package/lib/server/modules/order/index.js +40 -197
  37. package/lib/server/modules/products/index.d.ts +2 -8
  38. package/lib/server/modules/products/index.js +24 -97
  39. package/lib/server/modules/resource/index.js +2 -7
  40. package/lib/solution/BaseSales/index.js +4 -4
  41. package/lib/solution/BookingByStep/index.d.ts +1 -1
  42. package/lib/solution/BookingTicket/index.d.ts +5 -15
  43. package/lib/solution/BookingTicket/index.js +15 -5
  44. package/package.json +1 -1
@@ -25,7 +25,6 @@ export declare class ProductsModule extends BaseModule implements Module {
25
25
  private quotationBridgeLoadedKey?;
26
26
  private quotationBridgeRefreshPromise?;
27
27
  private quotationBridgeRefreshKey?;
28
- private quotationBridgeUpdatedCallback?;
29
28
  private quotationScheduleCache;
30
29
  private quotationScheduleCacheSource;
31
30
  private quotationScheduleCacheLoaded;
@@ -73,7 +72,6 @@ export declare class ProductsModule extends BaseModule implements Module {
73
72
  scheduleModule?: any;
74
73
  channel?: string;
75
74
  customer_id?: number | string;
76
- onQuotationUpdated?: () => void;
77
75
  }): Promise<void>;
78
76
  /**
79
77
  * 刷新桥接器内的报价单列表。
@@ -183,9 +181,7 @@ export declare class ProductsModule extends BaseModule implements Module {
183
181
  /**
184
182
  * 通过 ProductDataSource SSE 加载完整商品列表
185
183
  */
186
- loadProductsByServer(options?: {
187
- trigger?: string;
188
- }): Promise<any>;
184
+ loadProductsByServer(): Promise<any>;
189
185
  /**
190
186
  * 纯请求方法:通过 HTTP 接口获取商品列表(无副作用,不触发事件、不写 IndexDB)
191
187
  * @param params 查询参数
@@ -335,9 +331,7 @@ export declare class ProductsModule extends BaseModule implements Module {
335
331
  * 拿到完整数据后一次性替换 store,清除价格缓存,触发 onProductsSyncCompleted
336
332
  * @returns 刷新后的商品列表
337
333
  */
338
- silentRefresh(options?: {
339
- trigger?: string;
340
- }): Promise<ProductData[]>;
334
+ silentRefresh(): Promise<ProductData[]>;
341
335
  /**
342
336
  * 销毁同步资源(取消 pubsub 订阅、清除定时器)
343
337
  */
@@ -78,7 +78,6 @@ 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);
82
81
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCache", new Map());
83
82
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheSource", null);
84
83
  _defineProperty(_assertThisInitialized(_this), "quotationScheduleCacheLoaded", false);
@@ -291,9 +290,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
291
290
  value: (function () {
292
291
  var _setupQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
293
292
  var _this$otherParams,
294
- _this3 = this,
295
- _this$quotationPriceB,
296
- _this$quotationPriceB2;
293
+ _this3 = this;
297
294
  var channel, quotation;
298
295
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
299
296
  while (1) switch (_context3.prev = _context3.next) {
@@ -354,20 +351,11 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
354
351
  return schedules[0];
355
352
  });
356
353
  }
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;
354
+ _context3.next = 13;
367
355
  return this.refreshQuotationPriceBridge({
368
356
  customer_id: params.customer_id
369
357
  });
370
- case 15:
358
+ case 13:
371
359
  case "end":
372
360
  return _context3.stop();
373
361
  }
@@ -1214,8 +1202,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1214
1202
  key: "clearPriceCache",
1215
1203
  value: function clearPriceCache() {
1216
1204
  this.productsPriceCache.clear();
1217
- this.quotationScheduleCache.clear();
1218
- this.quotationScheduleCacheLoaded = false;
1219
1205
  console.log('[ProductsModule] 🗑️ 商品价格缓存已清空');
1220
1206
  }
1221
1207
 
@@ -1226,76 +1212,62 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1226
1212
  key: "loadProductsByServer",
1227
1213
  value: (function () {
1228
1214
  var _loadProductsByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1229
- var options,
1230
- trigger,
1231
- t0,
1232
- tSSE,
1233
- productList,
1234
- list,
1235
- duration,
1236
- errorMessage,
1237
- _args9 = arguments;
1215
+ var t0, tSSE, productList, list, duration, errorMessage;
1238
1216
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1239
1217
  while (1) switch (_context9.prev = _context9.next) {
1240
1218
  case 0:
1241
- options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
1242
1219
  if (this.productDataSource) {
1243
- _context9.next = 4;
1220
+ _context9.next = 3;
1244
1221
  break;
1245
1222
  }
1246
1223
  this.logWarning('loadProductsByServer: ProductDataSource 不可用');
1247
1224
  return _context9.abrupt("return", []);
1248
- case 4:
1249
- trigger = options.trigger || 'unknown';
1250
- this.logInfo('开始通过 DataSource SSE 加载商品列表', {
1251
- trigger: trigger
1252
- });
1225
+ case 3:
1226
+ this.logInfo('开始通过 DataSource SSE 加载商品列表');
1253
1227
  t0 = performance.now();
1254
- _context9.prev = 7;
1228
+ _context9.prev = 5;
1255
1229
  tSSE = performance.now();
1256
- _context9.next = 11;
1230
+ _context9.next = 9;
1257
1231
  return this.productDataSource.run({
1258
1232
  sse: {}
1259
1233
  });
1260
- case 11:
1234
+ case 9:
1261
1235
  productList = _context9.sent;
1262
1236
  list = productList || [];
1263
1237
  perfMark('loadProductsByServer.SSE', performance.now() - tSSE, {
1264
1238
  count: list.length
1265
1239
  });
1266
1240
  this.logInfo('通过 DataSource SSE 加载商品列表成功', {
1267
- trigger: trigger,
1268
1241
  productCount: list.length,
1269
1242
  duration: "".concat(Math.round(performance.now() - t0), "ms")
1270
1243
  });
1271
- _context9.next = 17;
1244
+ _context9.next = 15;
1272
1245
  return this.replaceProductsSnapshotInIndexDB(list, 'loadProductsByServer');
1273
- case 17:
1246
+ case 15:
1274
1247
  this.lastServerFullFetchAtMs = Date.now();
1275
- _context9.next = 20;
1248
+ _context9.next = 18;
1276
1249
  return this.core.effects.emit(ProductsHooks.onProductsLoaded, list);
1277
- case 20:
1250
+ case 18:
1278
1251
  perfMark('loadProductsByServer', performance.now() - t0, {
1279
1252
  count: list.length
1280
1253
  });
1281
1254
  return _context9.abrupt("return", list);
1282
- case 24:
1283
- _context9.prev = 24;
1284
- _context9.t0 = _context9["catch"](7);
1255
+ case 22:
1256
+ _context9.prev = 22;
1257
+ _context9.t0 = _context9["catch"](5);
1285
1258
  duration = Math.round(performance.now() - t0);
1286
1259
  errorMessage = _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0);
1287
1260
  console.error('[Products] 加载商品数据失败:', _context9.t0);
1288
1261
  this.logError('通过 DataSource SSE 加载商品列表失败', {
1289
- trigger: trigger,
1290
1262
  duration: "".concat(duration, "ms"),
1291
1263
  error: errorMessage
1292
1264
  });
1293
1265
  return _context9.abrupt("return", []);
1294
- case 31:
1266
+ case 29:
1295
1267
  case "end":
1296
1268
  return _context9.stop();
1297
1269
  }
1298
- }, _callee9, this, [[7, 24]]);
1270
+ }, _callee9, this, [[5, 22]]);
1299
1271
  }));
1300
1272
  function loadProductsByServer() {
1301
1273
  return _loadProductsByServer.apply(this, arguments);
@@ -1692,9 +1664,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1692
1664
  tTotal = performance.now();
1693
1665
  this.logInfo('refreshProducts 开始');
1694
1666
  _context16.next = 4;
1695
- return this.loadProductsByServer({
1696
- trigger: 'product_sync'
1697
- });
1667
+ return this.loadProductsByServer();
1698
1668
  case 4:
1699
1669
  products = _context16.sent;
1700
1670
  if (products && products.length > 0) {
@@ -1786,7 +1756,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1786
1756
  key: "loadProductsFromIndexDB",
1787
1757
  value: (function () {
1788
1758
  var _loadProductsFromIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1789
- var startedAt, _products$length, _products$length2, products, durationMs, errorMessage;
1759
+ var _products$length, _products$length2, t0, products, errorMessage;
1790
1760
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1791
1761
  while (1) switch (_context18.prev = _context18.next) {
1792
1762
  case 0:
@@ -1797,36 +1767,33 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1797
1767
  this.logWarning('loadProductsFromIndexDB: dbManager 不可用');
1798
1768
  return _context18.abrupt("return", []);
1799
1769
  case 3:
1800
- startedAt = performance.now();
1801
- _context18.prev = 4;
1770
+ _context18.prev = 3;
1771
+ t0 = performance.now();
1802
1772
  _context18.next = 7;
1803
1773
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1804
1774
  case 7:
1805
1775
  products = _context18.sent;
1806
- durationMs = +(performance.now() - startedAt).toFixed(2);
1807
- perfMark('loadProductsFromIndexDB', durationMs, {
1776
+ perfMark('loadProductsFromIndexDB', performance.now() - t0, {
1808
1777
  count: (_products$length = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length !== void 0 ? _products$length : 0
1809
1778
  });
1810
1779
  this.logInfo('从 IndexDB 加载商品数据', {
1811
- productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0,
1812
- durationMs: durationMs
1780
+ productCount: (_products$length2 = products === null || products === void 0 ? void 0 : products.length) !== null && _products$length2 !== void 0 ? _products$length2 : 0
1813
1781
  });
1814
1782
  return _context18.abrupt("return", products || []);
1815
- case 14:
1816
- _context18.prev = 14;
1817
- _context18.t0 = _context18["catch"](4);
1783
+ case 13:
1784
+ _context18.prev = 13;
1785
+ _context18.t0 = _context18["catch"](3);
1818
1786
  errorMessage = _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0);
1819
1787
  console.error('[Products] 从 IndexDB 读取数据失败:', _context18.t0);
1820
1788
  this.logError('从 IndexDB 读取数据失败', {
1821
- durationMs: +(performance.now() - startedAt).toFixed(2),
1822
1789
  error: errorMessage
1823
1790
  });
1824
1791
  return _context18.abrupt("return", []);
1825
- case 20:
1792
+ case 19:
1826
1793
  case "end":
1827
1794
  return _context18.stop();
1828
1795
  }
1829
- }, _callee18, this, [[4, 14]]);
1796
+ }, _callee18, this, [[3, 13]]);
1830
1797
  }));
1831
1798
  function loadProductsFromIndexDB() {
1832
1799
  return _loadProductsFromIndexDB.apply(this, arguments);
@@ -1880,7 +1847,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1880
1847
  value: (function () {
1881
1848
  var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(products, source) {
1882
1849
  var _this9 = this;
1883
- var enqueuedAt, queueWaitMs, clearDurationMs, writeDurationMs, errorMessage;
1850
+ var errorMessage;
1884
1851
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1885
1852
  while (1) switch (_context21.prev = _context21.next) {
1886
1853
  case 0:
@@ -1891,86 +1858,58 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
1891
1858
  this.logWarning('replaceProductsSnapshotInIndexDB: dbManager 不可用');
1892
1859
  return _context21.abrupt("return");
1893
1860
  case 3:
1894
- enqueuedAt = performance.now();
1895
- queueWaitMs = 0;
1896
- clearDurationMs = 0;
1897
- writeDurationMs = 0;
1898
- _context21.prev = 7;
1899
- _context21.next = 10;
1861
+ _context21.prev = 3;
1862
+ _context21.next = 6;
1900
1863
  return this.runInProductIndexDBSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1901
- var operationStartedAt, clearStartedAt, writeStartedAt, executeDurationMs;
1864
+ var t0;
1902
1865
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1903
1866
  while (1) switch (_context20.prev = _context20.next) {
1904
1867
  case 0:
1905
- operationStartedAt = performance.now();
1906
- queueWaitMs = +(operationStartedAt - enqueuedAt).toFixed(2);
1907
1868
  _this9.logInfo('replaceProductsSnapshotInIndexDB 开始', {
1908
1869
  source: source,
1909
- productCount: products.length,
1910
- queueWaitMs: queueWaitMs
1870
+ productCount: products.length
1911
1871
  });
1912
- clearStartedAt = performance.now();
1913
- _context20.prev = 4;
1914
- _context20.next = 7;
1872
+ t0 = performance.now();
1873
+ _context20.next = 4;
1915
1874
  return _this9.dbManager.clear(INDEXDB_STORE_NAME);
1916
- case 7:
1917
- _context20.prev = 7;
1918
- clearDurationMs = +(performance.now() - clearStartedAt).toFixed(2);
1919
- return _context20.finish(7);
1920
- case 10:
1875
+ case 4:
1921
1876
  if (!(products.length > 0)) {
1922
- _context20.next = 18;
1877
+ _context20.next = 7;
1923
1878
  break;
1924
1879
  }
1925
- writeStartedAt = performance.now();
1926
- _context20.prev = 12;
1927
- _context20.next = 15;
1880
+ _context20.next = 7;
1928
1881
  return _this9.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
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, {
1882
+ case 7:
1883
+ perfMark('replaceProductsSnapshotInIndexDB', performance.now() - t0, {
1936
1884
  count: products.length
1937
1885
  });
1938
1886
  _this9.logInfo('replaceProductsSnapshotInIndexDB 完成', {
1939
1887
  source: source,
1940
- productCount: products.length,
1941
- queueWaitMs: queueWaitMs,
1942
- clearDurationMs: clearDurationMs,
1943
- writeDurationMs: writeDurationMs,
1944
- executeDurationMs: executeDurationMs,
1945
- totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2)
1888
+ productCount: products.length
1946
1889
  });
1947
- case 21:
1890
+ case 9:
1948
1891
  case "end":
1949
1892
  return _context20.stop();
1950
1893
  }
1951
- }, _callee20, null, [[4,, 7, 10], [12,, 15, 18]]);
1894
+ }, _callee20);
1952
1895
  })));
1953
- case 10:
1954
- _context21.next = 16;
1896
+ case 6:
1897
+ _context21.next = 12;
1955
1898
  break;
1956
- case 12:
1957
- _context21.prev = 12;
1958
- _context21.t0 = _context21["catch"](7);
1899
+ case 8:
1900
+ _context21.prev = 8;
1901
+ _context21.t0 = _context21["catch"](3);
1959
1902
  errorMessage = _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0);
1960
1903
  this.logError('全量保存商品到 IndexDB 失败', {
1961
1904
  source: source,
1962
1905
  productCount: products.length,
1963
- queueWaitMs: queueWaitMs,
1964
- clearDurationMs: clearDurationMs,
1965
- writeDurationMs: writeDurationMs,
1966
- totalDurationMs: +(performance.now() - enqueuedAt).toFixed(2),
1967
1906
  error: errorMessage
1968
1907
  });
1969
- case 16:
1908
+ case 12:
1970
1909
  case "end":
1971
1910
  return _context21.stop();
1972
1911
  }
1973
- }, _callee21, this, [[7, 12]]);
1912
+ }, _callee21, this, [[3, 8]]);
1974
1913
  }));
1975
1914
  function replaceProductsSnapshotInIndexDB(_x21, _x22) {
1976
1915
  return _replaceProductsSnapshotInIndexDB.apply(this, arguments);
@@ -2171,7 +2110,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2171
2110
  source: 'IndexDB'
2172
2111
  });
2173
2112
  this.logInfo('预加载完成(从 IndexDB)', {
2174
- trigger: 'preload',
2175
2113
  productCount: cachedData.length,
2176
2114
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
2177
2115
  source: 'IndexDB'
@@ -2194,9 +2132,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2194
2132
  case 29:
2195
2133
  tServer = performance.now();
2196
2134
  _context24.next = 32;
2197
- return this.loadProductsByServer({
2198
- trigger: 'preload'
2199
- });
2135
+ return this.loadProductsByServer();
2200
2136
  case 32:
2201
2137
  products = _context24.sent;
2202
2138
  perfMark('preload.loadFromServer', performance.now() - tServer, {
@@ -2216,7 +2152,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2216
2152
  source: 'Server'
2217
2153
  });
2218
2154
  this.logInfo('预加载完成(从服务器)', {
2219
- trigger: 'preload',
2220
2155
  productCount: products.length,
2221
2156
  duration: "".concat(Math.round(performance.now() - tTotal), "ms"),
2222
2157
  source: 'Server'
@@ -2841,91 +2776,64 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
2841
2776
  key: "silentRefresh",
2842
2777
  value: (function () {
2843
2778
  var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2844
- var options,
2845
- t0,
2846
- now,
2847
- trigger,
2848
- elapsedSincePreloadMs,
2849
- elapsedSinceFullFetchMs,
2850
- products,
2851
- errorMessage,
2852
- _args29 = arguments;
2779
+ var t0, now, elapsedSincePreload, elapsedSinceFullFetch, products, errorMessage;
2853
2780
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2854
2781
  while (1) switch (_context29.prev = _context29.next) {
2855
2782
  case 0:
2856
- options = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
2857
2783
  t0 = performance.now();
2858
2784
  now = Date.now();
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;
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;
2864
2789
  break;
2865
2790
  }
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
- });
2874
2791
  return _context29.abrupt("return", this.store.list);
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:
2792
+ case 6:
2793
+ this.logInfo('silentRefresh 开始');
2794
+ _context29.prev = 7;
2795
+ _context29.next = 10;
2796
+ return this.loadProductsByServer();
2797
+ case 10:
2888
2798
  products = _context29.sent;
2889
2799
  if (!(products && products.length > 0)) {
2890
- _context29.next = 24;
2800
+ _context29.next = 21;
2891
2801
  break;
2892
2802
  }
2893
2803
  this.store.list = products;
2894
2804
  this.syncProductsMap();
2895
2805
  this.clearPriceCache();
2896
2806
  this.core.effects.emit(ProductsHooks.onProductsChanged, this.store.list);
2897
- _context29.next = 21;
2807
+ _context29.next = 18;
2898
2808
  return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
2899
- case 21:
2809
+ case 18:
2900
2810
  this.logInfo('silentRefresh 完成', {
2901
- trigger: trigger,
2902
2811
  productCount: products.length,
2903
2812
  duration: "".concat(Math.round(performance.now() - t0), "ms")
2904
2813
  });
2905
- _context29.next = 25;
2814
+ _context29.next = 22;
2906
2815
  break;
2907
- case 24:
2816
+ case 21:
2908
2817
  this.logWarning('silentRefresh: 服务器未返回数据');
2909
- case 25:
2818
+ case 22:
2910
2819
  perfMark('silentRefresh', performance.now() - t0, {
2911
2820
  count: this.store.list.length
2912
2821
  });
2913
2822
  return _context29.abrupt("return", this.store.list);
2914
- case 29:
2915
- _context29.prev = 29;
2916
- _context29.t0 = _context29["catch"](10);
2823
+ case 26:
2824
+ _context29.prev = 26;
2825
+ _context29.t0 = _context29["catch"](7);
2917
2826
  errorMessage = _context29.t0 instanceof Error ? _context29.t0.message : String(_context29.t0);
2918
2827
  this.logError('silentRefresh 失败', {
2919
- trigger: trigger,
2920
2828
  duration: "".concat(Math.round(performance.now() - t0), "ms"),
2921
2829
  error: errorMessage
2922
2830
  });
2923
2831
  return _context29.abrupt("return", this.store.list);
2924
- case 34:
2832
+ case 31:
2925
2833
  case "end":
2926
2834
  return _context29.stop();
2927
2835
  }
2928
- }, _callee29, this, [[10, 29]]);
2836
+ }, _callee29, this, [[7, 26]]);
2929
2837
  }));
2930
2838
  function silentRefresh() {
2931
2839
  return _silentRefresh.apply(this, arguments);
@@ -149,49 +149,41 @@ 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.loadResourcesFromSQLite();
152
+ return this.setupResourceSync();
153
153
  case 2:
154
+ _context2.next = 4;
155
+ return this.loadResourcesFromSQLite();
156
+ case 4:
154
157
  cachedResources = _context2.sent;
155
158
  if (!(cachedResources.length > 0)) {
156
- _context2.next = 10;
159
+ _context2.next = 12;
157
160
  break;
158
161
  }
159
162
  this.store.list = cloneDeep(cachedResources).map(function (item) {
160
163
  return _this3.normalizeResource(item);
161
164
  });
162
165
  this.syncResourcesMap();
163
- _context2.next = 8;
166
+ _context2.next = 10;
164
167
  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");
172
168
  case 10:
173
- _context2.next = 12;
174
- return this.setupResourceSync();
169
+ _context2.next = 20;
170
+ break;
175
171
  case 12:
176
- if (!(this.store.list.length === 0)) {
177
- _context2.next = 21;
178
- break;
179
- }
180
- _context2.next = 15;
172
+ _context2.next = 14;
181
173
  return this.loadResourcesByServer();
182
- case 15:
174
+ case 14:
183
175
  resources = _context2.sent;
184
176
  if (!(resources.length > 0)) {
185
- _context2.next = 21;
177
+ _context2.next = 20;
186
178
  break;
187
179
  }
188
180
  this.store.list = cloneDeep(resources).map(function (item) {
189
181
  return _this3.normalizeResource(item);
190
182
  });
191
183
  this.syncResourcesMap();
192
- _context2.next = 21;
184
+ _context2.next = 20;
193
185
  return this.safeEmit(ResourceHooks.onResourcesChanged, this.store.list);
194
- case 21:
186
+ case 20:
195
187
  case "end":
196
188
  return _context2.stop();
197
189
  }
@@ -2126,12 +2126,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2126
2126
  return !_this12.isPersistedOrderProduct(product);
2127
2127
  });
2128
2128
  if (hasDraftProduct) return false;
2129
- var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
2130
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2129
+
2130
+ // 编辑详情 hydrate 时,商品行上的历史券卡会被还原为 isEditMode=true、
2131
+ // isSelected=true 的只读记录。它们表示“该折扣已在原订单结算”,不是用户在
2132
+ // 当前编辑会话中新做的选择,不能据此放行刚从 prepare/config 拉回来的折扣。
2133
+ // 否则后续 Rules.calcDiscount 会把没有 isManualSelect 标记的可用 runtime 卡
2134
+ // 当作自动候选,再次写入 tempOrder。这里只识别非 isEditMode 的 runtime 状态;
2135
+ // 新建单、编辑态新增商品以及用户本次明确选择/取消折扣的原有流程保持不变。
2136
+ var hasRuntimeDiscountSelection = params.currentDiscountList.some(function (discount) {
2137
+ return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2131
2138
  });
2132
- if (hasSelectedDiscount) return false;
2139
+ if (hasRuntimeDiscountSelection) return false;
2140
+
2141
+ // nextDiscountList 已经合并了历史只读折扣与本次获取的 runtime 折扣,
2142
+ // 因此这里同样必须排除 isEditMode;只有 runtime 条目已有明确选择状态时,
2143
+ // 才允许继续进入折扣重算。
2133
2144
  return !params.nextDiscountList.some(function (discount) {
2134
- return discount.isSelected || discount.isEditMode || discount.isManualSelect;
2145
+ return !discount.isEditMode && (discount.isSelected || discount.isManualSelect);
2135
2146
  });
2136
2147
  }
2137
2148
  }, {
@@ -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 | 2 | 1 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 1 | 5 | 2 | 4 | 3 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -3,7 +3,7 @@ import { BookingTicketCartView, BookingTicketProductCatalogView, BookingTicketSt
3
3
  import type { ProductData } from '../../modules';
4
4
  import type { OpenDataConfig } from '../../modules/OpenData';
5
5
  import { type BookingContextConfig, type BookingContextDateInput, type BookingContextResource, type BookingContextResourceMap, type BookingContextState, type InitBookingContextParams, type LoadBookingConfigParams, type LoadBookingResourcesParams, type ResourceError, type BookingCalcContext } from '../../modules/BookingContext';
6
- import type { OrderCustomerView } from '../../modules/Order/types';
6
+ import type { OrderCustomerView, OrderCustomerChangePayload } from '../../modules/Order/types';
7
7
  import { BaseSalesImpl } from '../BaseSales';
8
8
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
9
9
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
@@ -260,7 +260,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
260
260
  * 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
261
261
  * 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
262
262
  */
263
- setOrderCustomer(customer: ICustomer | null): void;
263
+ setOrderCustomer(customer: ICustomer | null, options?: {
264
+ source?: OrderCustomerChangePayload['source'];
265
+ }): void;
264
266
  /**
265
267
  * 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
266
268
  */
@@ -451,19 +453,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
451
453
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
452
454
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
453
455
  */
454
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
455
- action: "reloadCatalog";
456
- } | {
457
- action: "add";
458
- cacheItem: any;
459
- } | {
460
- action: "requiresDetail";
461
- payload: AddProductRequiresDetailPayload;
462
- } | {
463
- action: "requiresBookingEdit";
464
- cacheItem: any;
465
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
466
- };
456
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
467
457
  /** 规格弹窗 callback 后的第二段决策。 */
468
458
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
469
459
  /**