@pisell/pisellos 2.2.151 → 2.2.152

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.
@@ -384,6 +384,66 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
384
384
  }
385
385
  return loadOrdersByServer;
386
386
  }()
387
+ /**
388
+ * 静默全量刷新:后台重新拉取全量 SSE 订单数据并更新本地
389
+ * 拿到完整数据后一次性替换 store,触发订单变更与同步完成事件
390
+ * @returns 刷新后的订单列表
391
+ */
392
+ }, {
393
+ key: "silentRefresh",
394
+ value: (function () {
395
+ var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
396
+ var startTime, orders, errorMessage;
397
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
398
+ while (1) switch (_context6.prev = _context6.next) {
399
+ case 0:
400
+ startTime = Date.now();
401
+ this.logInfo('silentRefresh 开始');
402
+ _context6.prev = 2;
403
+ _context6.next = 5;
404
+ return this.loadOrdersByServer();
405
+ case 5:
406
+ orders = _context6.sent;
407
+ if (!(orders.length > 0)) {
408
+ _context6.next = 15;
409
+ break;
410
+ }
411
+ this.store.list = cloneDeep(orders);
412
+ this.syncOrdersMap();
413
+ this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
414
+ _context6.next = 12;
415
+ return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
416
+ case 12:
417
+ this.logInfo('silentRefresh 完成', {
418
+ orderCount: orders.length,
419
+ duration: "".concat(Date.now() - startTime, "ms")
420
+ });
421
+ _context6.next = 16;
422
+ break;
423
+ case 15:
424
+ this.logInfo('silentRefresh: 服务器未返回数据');
425
+ case 16:
426
+ return _context6.abrupt("return", this.store.list);
427
+ case 19:
428
+ _context6.prev = 19;
429
+ _context6.t0 = _context6["catch"](2);
430
+ errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
431
+ this.logError('silentRefresh 失败', {
432
+ duration: "".concat(Date.now() - startTime, "ms"),
433
+ error: errorMessage
434
+ });
435
+ return _context6.abrupt("return", this.store.list);
436
+ case 24:
437
+ case "end":
438
+ return _context6.stop();
439
+ }
440
+ }, _callee6, this, [[2, 19]]);
441
+ }));
442
+ function silentRefresh() {
443
+ return _silentRefresh.apply(this, arguments);
444
+ }
445
+ return silentRefresh;
446
+ }())
387
447
  }, {
388
448
  key: "getOrdersByResourceId",
389
449
  value: function getOrdersByResourceId(resourceId) {
@@ -403,31 +463,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
403
463
  }, {
404
464
  key: "overwriteExistingOrder",
405
465
  value: (function () {
406
- var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(fresh) {
466
+ var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(fresh) {
407
467
  var _this5 = this;
408
468
  var orderId, key;
409
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
410
- while (1) switch (_context6.prev = _context6.next) {
469
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
470
+ while (1) switch (_context7.prev = _context7.next) {
411
471
  case 0:
412
472
  orderId = fresh === null || fresh === void 0 ? void 0 : fresh.order_id;
413
473
  if (!(orderId === undefined || orderId === null)) {
414
- _context6.next = 4;
474
+ _context7.next = 4;
415
475
  break;
416
476
  }
417
477
  this.logError('overwriteExistingOrder-入参缺少 order_id');
418
- return _context6.abrupt("return", {
478
+ return _context7.abrupt("return", {
419
479
  overwritten: false
420
480
  });
421
481
  case 4:
422
482
  key = this.getIdKey(orderId);
423
483
  if (this.store.map.has(key)) {
424
- _context6.next = 8;
484
+ _context7.next = 8;
425
485
  break;
426
486
  }
427
487
  this.logInfo('overwriteExistingOrder-本地不存在该订单,跳过', {
428
488
  orderId: orderId
429
489
  });
430
- return _context6.abrupt("return", {
490
+ return _context7.abrupt("return", {
431
491
  overwritten: false
432
492
  });
433
493
  case 8:
@@ -441,24 +501,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
441
501
  return _this5.getIdKey(id) === key ? fresh : order;
442
502
  });
443
503
  this.syncOrdersMap();
444
- _context6.next = 13;
504
+ _context7.next = 13;
445
505
  return this.saveOrdersToSQLite(this.store.list);
446
506
  case 13:
447
507
  this.logInfo('overwriteExistingOrder-结束', {
448
508
  orderId: orderId,
449
509
  storeOrderCountAfter: this.store.list.length
450
510
  });
451
- _context6.next = 16;
511
+ _context7.next = 16;
452
512
  return this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
453
513
  case 16:
454
- return _context6.abrupt("return", {
514
+ return _context7.abrupt("return", {
455
515
  overwritten: true
456
516
  });
457
517
  case 17:
458
518
  case "end":
459
- return _context6.stop();
519
+ return _context7.stop();
460
520
  }
461
- }, _callee6, this);
521
+ }, _callee7, this);
462
522
  }));
463
523
  function overwriteExistingOrder(_x4) {
464
524
  return _overwriteExistingOrder.apply(this, arguments);
@@ -473,27 +533,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
473
533
  }, {
474
534
  key: "upsertOrdersFromRemote",
475
535
  value: (function () {
476
- var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(freshOrders) {
477
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
478
- while (1) switch (_context7.prev = _context7.next) {
536
+ var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(freshOrders) {
537
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
538
+ while (1) switch (_context8.prev = _context8.next) {
479
539
  case 0:
480
540
  if (freshOrders !== null && freshOrders !== void 0 && freshOrders.length) {
481
- _context7.next = 3;
541
+ _context8.next = 3;
482
542
  break;
483
543
  }
484
544
  this.logInfo('upsertOrdersFromRemote-订单列表为空', {});
485
- return _context7.abrupt("return");
545
+ return _context8.abrupt("return");
486
546
  case 3:
487
547
  this.logInfo('upsertOrdersFromRemote-开始', {
488
548
  count: freshOrders.length
489
549
  });
490
- _context7.next = 6;
550
+ _context8.next = 6;
491
551
  return this.mergeOrdersToStore(freshOrders);
492
552
  case 6:
493
553
  case "end":
494
- return _context7.stop();
554
+ return _context8.stop();
495
555
  }
496
- }, _callee7, this);
556
+ }, _callee8, this);
497
557
  }));
498
558
  function upsertOrdersFromRemote(_x5) {
499
559
  return _upsertOrdersFromRemote.apply(this, arguments);
@@ -507,42 +567,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
507
567
  }, {
508
568
  key: "fetchOrdersBySSE",
509
569
  value: (function () {
510
- var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
570
+ var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
511
571
  var query,
512
572
  data,
513
- _args8 = arguments;
514
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
515
- while (1) switch (_context8.prev = _context8.next) {
573
+ _args9 = arguments;
574
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
575
+ while (1) switch (_context9.prev = _context9.next) {
516
576
  case 0:
517
- query = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
577
+ query = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
518
578
  if (this.orderDataSource) {
519
- _context8.next = 3;
579
+ _context9.next = 3;
520
580
  break;
521
581
  }
522
- return _context8.abrupt("return", []);
582
+ return _context9.abrupt("return", []);
523
583
  case 3:
524
- _context8.prev = 3;
525
- _context8.next = 6;
584
+ _context9.prev = 3;
585
+ _context9.next = 6;
526
586
  return this.orderDataSource.run({
527
587
  sse: {
528
588
  query: query
529
589
  }
530
590
  });
531
591
  case 6:
532
- data = _context8.sent;
533
- return _context8.abrupt("return", data || []);
592
+ data = _context9.sent;
593
+ return _context9.abrupt("return", data || []);
534
594
  case 10:
535
- _context8.prev = 10;
536
- _context8.t0 = _context8["catch"](3);
595
+ _context9.prev = 10;
596
+ _context9.t0 = _context9["catch"](3);
537
597
  this.logError('fetchOrdersBySSE-失败', {
538
- error: _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0)
598
+ error: _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0)
539
599
  });
540
- return _context8.abrupt("return", []);
600
+ return _context9.abrupt("return", []);
541
601
  case 14:
542
602
  case "end":
543
- return _context8.stop();
603
+ return _context9.stop();
544
604
  }
545
- }, _callee8, this, [[3, 10]]);
605
+ }, _callee9, this, [[3, 10]]);
546
606
  }));
547
607
  function fetchOrdersBySSE() {
548
608
  return _fetchOrdersBySSE.apply(this, arguments);
@@ -723,41 +783,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
723
783
  }, {
724
784
  key: "flushOrderSyncMessagesByThrottle",
725
785
  value: (function () {
726
- var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
727
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
728
- while (1) switch (_context9.prev = _context9.next) {
786
+ var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
787
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
788
+ while (1) switch (_context10.prev = _context10.next) {
729
789
  case 0:
730
790
  if (!this.isProcessingSyncBatch) {
731
- _context9.next = 2;
791
+ _context10.next = 2;
732
792
  break;
733
793
  }
734
- return _context9.abrupt("return");
794
+ return _context10.abrupt("return");
735
795
  case 2:
736
796
  if (!(this.pendingSyncMessages.length === 0)) {
737
- _context9.next = 5;
797
+ _context10.next = 5;
738
798
  break;
739
799
  }
740
800
  this.isIdlePhase = true;
741
- return _context9.abrupt("return");
801
+ return _context10.abrupt("return");
742
802
  case 5:
743
803
  this.isProcessingSyncBatch = true;
744
- _context9.prev = 6;
745
- _context9.next = 9;
804
+ _context10.prev = 6;
805
+ _context10.next = 9;
746
806
  return this.processOrderSyncMessages();
747
807
  case 9:
748
- _context9.prev = 9;
808
+ _context10.prev = 9;
749
809
  this.isProcessingSyncBatch = false;
750
810
  if (this.pendingSyncMessages.length > 0) {
751
811
  this.scheduleOrderSyncThrottle();
752
812
  } else {
753
813
  this.isIdlePhase = true;
754
814
  }
755
- return _context9.finish(9);
815
+ return _context10.finish(9);
756
816
  case 13:
757
817
  case "end":
758
- return _context9.stop();
818
+ return _context10.stop();
759
819
  }
760
- }, _callee9, this, [[6,, 9, 13]]);
820
+ }, _callee10, this, [[6,, 9, 13]]);
761
821
  }));
762
822
  function flushOrderSyncMessagesByThrottle() {
763
823
  return _flushOrderSyncMessagesByThrottle.apply(this, arguments);
@@ -779,18 +839,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
779
839
  }, {
780
840
  key: "processOrderSyncMessages",
781
841
  value: (function () {
782
- var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
842
+ var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
783
843
  var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, _iterator3, _step3, _msg$id, _msg$relation_order_i, msg, hasBatchIds, singleId, hasSingleId, rawBody, normalizedBody, uniqueRefreshIds, upsertList, freshOrders, batchProcessEndAt;
784
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
785
- while (1) switch (_context10.prev = _context10.next) {
844
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
845
+ while (1) switch (_context11.prev = _context11.next) {
786
846
  case 0:
787
847
  messages = _toConsumableArray(this.pendingSyncMessages);
788
848
  this.pendingSyncMessages = [];
789
849
  if (!(messages.length === 0)) {
790
- _context10.next = 4;
850
+ _context11.next = 4;
791
851
  break;
792
852
  }
793
- return _context10.abrupt("return");
853
+ return _context11.abrupt("return");
794
854
  case 4:
795
855
  batchProcessStartAt = Date.now();
796
856
  earliestReceivedAt = Math.min.apply(Math, _toConsumableArray(messages.map(function (m) {
@@ -806,11 +866,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
806
866
  upsertOrders = new Map();
807
867
  refreshIds = [];
808
868
  _iterator3 = _createForOfIteratorHelper(messages);
809
- _context10.prev = 10;
869
+ _context11.prev = 10;
810
870
  _iterator3.s();
811
871
  case 12:
812
872
  if ((_step3 = _iterator3.n()).done) {
813
- _context10.next = 25;
873
+ _context11.next = 25;
814
874
  break;
815
875
  }
816
876
  msg = _step3.value;
@@ -820,27 +880,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
820
880
  rawBody = msg.body || msg.data;
821
881
  normalizedBody = this.normalizeOrderSyncPayload(rawBody);
822
882
  if (!(hasSingleId && normalizedBody)) {
823
- _context10.next = 22;
883
+ _context11.next = 22;
824
884
  break;
825
885
  }
826
886
  upsertOrders.set(this.getIdKey(normalizedBody.order_id), normalizedBody);
827
- return _context10.abrupt("continue", 23);
887
+ return _context11.abrupt("continue", 23);
828
888
  case 22:
829
889
  if (hasBatchIds) refreshIds.push.apply(refreshIds, _toConsumableArray(msg.ids));else if (hasSingleId) refreshIds.push(singleId);else if ((_msg$relation_order_i = msg.relation_order_ids) !== null && _msg$relation_order_i !== void 0 && _msg$relation_order_i.length) refreshIds.push.apply(refreshIds, _toConsumableArray(msg.relation_order_ids));
830
890
  case 23:
831
- _context10.next = 12;
891
+ _context11.next = 12;
832
892
  break;
833
893
  case 25:
834
- _context10.next = 30;
894
+ _context11.next = 30;
835
895
  break;
836
896
  case 27:
837
- _context10.prev = 27;
838
- _context10.t0 = _context10["catch"](10);
839
- _iterator3.e(_context10.t0);
897
+ _context11.prev = 27;
898
+ _context11.t0 = _context11["catch"](10);
899
+ _iterator3.e(_context11.t0);
840
900
  case 30:
841
- _context10.prev = 30;
901
+ _context11.prev = 30;
842
902
  _iterator3.f();
843
- return _context10.finish(30);
903
+ return _context11.finish(30);
844
904
  case 33:
845
905
  uniqueRefreshIds = this.uniqueOrderIds(refreshIds);
846
906
  upsertList = _toConsumableArray(upsertOrders.values());
@@ -849,32 +909,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
849
909
  refreshIdCount: uniqueRefreshIds.length
850
910
  });
851
911
  if (!(upsertList.length > 0)) {
852
- _context10.next = 39;
912
+ _context11.next = 39;
853
913
  break;
854
914
  }
855
- _context10.next = 39;
915
+ _context11.next = 39;
856
916
  return this.mergeOrdersToStore(upsertList);
857
917
  case 39:
858
918
  if (!(uniqueRefreshIds.length > 0)) {
859
- _context10.next = 46;
919
+ _context11.next = 46;
860
920
  break;
861
921
  }
862
- _context10.next = 42;
922
+ _context11.next = 42;
863
923
  return this.fetchOrdersByHttp(uniqueRefreshIds);
864
924
  case 42:
865
- freshOrders = _context10.sent;
925
+ freshOrders = _context11.sent;
866
926
  if (!(freshOrders.length > 0)) {
867
- _context10.next = 46;
927
+ _context11.next = 46;
868
928
  break;
869
929
  }
870
- _context10.next = 46;
930
+ _context11.next = 46;
871
931
  return this.mergeOrdersToStore(freshOrders);
872
932
  case 46:
873
933
  if (!(upsertList.length === 0 && uniqueRefreshIds.length === 0)) {
874
- _context10.next = 48;
934
+ _context11.next = 48;
875
935
  break;
876
936
  }
877
- return _context10.abrupt("return");
937
+ return _context11.abrupt("return");
878
938
  case 48:
879
939
  batchProcessEndAt = Date.now();
880
940
  this.logInfo('processOrderSyncMessages-结束', {
@@ -883,13 +943,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
883
943
  batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt,
884
944
  totalFromPubsubToProcessedMs: batchProcessEndAt - earliestReceivedAt
885
945
  });
886
- _context10.next = 52;
946
+ _context11.next = 52;
887
947
  return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
888
948
  case 52:
889
949
  case "end":
890
- return _context10.stop();
950
+ return _context11.stop();
891
951
  }
892
- }, _callee10, this, [[10, 27, 30, 33]]);
952
+ }, _callee11, this, [[10, 27, 30, 33]]);
893
953
  }));
894
954
  function processOrderSyncMessages() {
895
955
  return _processOrderSyncMessages.apply(this, arguments);
@@ -910,29 +970,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
910
970
  }, {
911
971
  key: "fetchOrdersByHttp",
912
972
  value: (function () {
913
- var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ids) {
973
+ var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(ids) {
914
974
  var _orderList, orderList;
915
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
916
- while (1) switch (_context11.prev = _context11.next) {
975
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
976
+ while (1) switch (_context12.prev = _context12.next) {
917
977
  case 0:
918
978
  if (!(!this.orderDataSource || ids.length === 0)) {
919
- _context11.next = 2;
979
+ _context12.next = 2;
920
980
  break;
921
981
  }
922
- return _context11.abrupt("return", []);
982
+ return _context12.abrupt("return", []);
923
983
  case 2:
924
- _context11.prev = 2;
984
+ _context12.prev = 2;
925
985
  if (!(typeof this.orderDataSource.fetchOrdersByIds === 'function')) {
926
- _context11.next = 8;
986
+ _context12.next = 8;
927
987
  break;
928
988
  }
929
- _context11.next = 6;
989
+ _context12.next = 6;
930
990
  return this.orderDataSource.fetchOrdersByIds(ids);
931
991
  case 6:
932
- _orderList = _context11.sent;
933
- return _context11.abrupt("return", _orderList || []);
992
+ _orderList = _context12.sent;
993
+ return _context12.abrupt("return", _orderList || []);
934
994
  case 8:
935
- _context11.next = 10;
995
+ _context12.next = 10;
936
996
  return this.orderDataSource.run({
937
997
  http: {
938
998
  query: {
@@ -941,17 +1001,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
941
1001
  }
942
1002
  });
943
1003
  case 10:
944
- orderList = _context11.sent;
945
- return _context11.abrupt("return", orderList || []);
1004
+ orderList = _context12.sent;
1005
+ return _context12.abrupt("return", orderList || []);
946
1006
  case 14:
947
- _context11.prev = 14;
948
- _context11.t0 = _context11["catch"](2);
949
- return _context11.abrupt("return", []);
1007
+ _context12.prev = 14;
1008
+ _context12.t0 = _context12["catch"](2);
1009
+ return _context12.abrupt("return", []);
950
1010
  case 17:
951
1011
  case "end":
952
- return _context11.stop();
1012
+ return _context12.stop();
953
1013
  }
954
- }, _callee11, this, [[2, 14]]);
1014
+ }, _callee12, this, [[2, 14]]);
955
1015
  }));
956
1016
  function fetchOrdersByHttp(_x6) {
957
1017
  return _fetchOrdersByHttp.apply(this, arguments);
@@ -965,11 +1025,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
965
1025
  }, {
966
1026
  key: "mergeOrdersToStore",
967
1027
  value: (function () {
968
- var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(freshOrders) {
1028
+ var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(freshOrders) {
969
1029
  var _this9 = this;
970
1030
  var freshMap, _iterator4, _step4, order, id, uniqueFreshCount, updatedList, _iterator5, _step5, _order;
971
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
972
- while (1) switch (_context12.prev = _context12.next) {
1031
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1032
+ while (1) switch (_context13.prev = _context13.next) {
973
1033
  case 0:
974
1034
  this.logInfo('mergeOrdersToStore-开始', {
975
1035
  freshOrderCount: freshOrders.length,
@@ -977,36 +1037,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
977
1037
  });
978
1038
  freshMap = new Map();
979
1039
  _iterator4 = _createForOfIteratorHelper(freshOrders);
980
- _context12.prev = 3;
1040
+ _context13.prev = 3;
981
1041
  _iterator4.s();
982
1042
  case 5:
983
1043
  if ((_step4 = _iterator4.n()).done) {
984
- _context12.next = 13;
1044
+ _context13.next = 13;
985
1045
  break;
986
1046
  }
987
1047
  order = _step4.value;
988
1048
  id = order === null || order === void 0 ? void 0 : order.order_id;
989
1049
  if (!(id === undefined || id === null)) {
990
- _context12.next = 10;
1050
+ _context13.next = 10;
991
1051
  break;
992
1052
  }
993
- return _context12.abrupt("continue", 11);
1053
+ return _context13.abrupt("continue", 11);
994
1054
  case 10:
995
1055
  freshMap.set(this.getIdKey(id), order);
996
1056
  case 11:
997
- _context12.next = 5;
1057
+ _context13.next = 5;
998
1058
  break;
999
1059
  case 13:
1000
- _context12.next = 18;
1060
+ _context13.next = 18;
1001
1061
  break;
1002
1062
  case 15:
1003
- _context12.prev = 15;
1004
- _context12.t0 = _context12["catch"](3);
1005
- _iterator4.e(_context12.t0);
1063
+ _context13.prev = 15;
1064
+ _context13.t0 = _context13["catch"](3);
1065
+ _iterator4.e(_context13.t0);
1006
1066
  case 18:
1007
- _context12.prev = 18;
1067
+ _context13.prev = 18;
1008
1068
  _iterator4.f();
1009
- return _context12.finish(18);
1069
+ return _context13.finish(18);
1010
1070
  case 21:
1011
1071
  uniqueFreshCount = freshMap.size;
1012
1072
  updatedList = this.store.list.map(function (order) {
@@ -1031,7 +1091,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1031
1091
  }
1032
1092
  this.store.list = updatedList;
1033
1093
  this.syncOrdersMap();
1034
- _context12.next = 29;
1094
+ _context13.next = 29;
1035
1095
  return this.saveOrdersToSQLite(this.store.list);
1036
1096
  case 29:
1037
1097
  this.logInfo('mergeOrdersToStore-结束', {
@@ -1041,9 +1101,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1041
1101
  this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
1042
1102
  case 31:
1043
1103
  case "end":
1044
- return _context12.stop();
1104
+ return _context13.stop();
1045
1105
  }
1046
- }, _callee12, this, [[3, 15, 18, 21]]);
1106
+ }, _callee13, this, [[3, 15, 18, 21]]);
1047
1107
  }));
1048
1108
  function mergeOrdersToStore(_x7) {
1049
1109
  return _mergeOrdersToStore.apply(this, arguments);
@@ -1182,32 +1242,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1182
1242
  }, {
1183
1243
  key: "loadOrdersFromSQLite",
1184
1244
  value: function () {
1185
- var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1245
+ var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1186
1246
  var orders;
1187
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1188
- while (1) switch (_context13.prev = _context13.next) {
1247
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1248
+ while (1) switch (_context14.prev = _context14.next) {
1189
1249
  case 0:
1190
1250
  if (this.dbManager) {
1191
- _context13.next = 2;
1251
+ _context14.next = 2;
1192
1252
  break;
1193
1253
  }
1194
- return _context13.abrupt("return", []);
1254
+ return _context14.abrupt("return", []);
1195
1255
  case 2:
1196
- _context13.prev = 2;
1197
- _context13.next = 5;
1256
+ _context14.prev = 2;
1257
+ _context14.next = 5;
1198
1258
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1199
1259
  case 5:
1200
- orders = _context13.sent;
1201
- return _context13.abrupt("return", orders || []);
1260
+ orders = _context14.sent;
1261
+ return _context14.abrupt("return", orders || []);
1202
1262
  case 9:
1203
- _context13.prev = 9;
1204
- _context13.t0 = _context13["catch"](2);
1205
- return _context13.abrupt("return", []);
1263
+ _context14.prev = 9;
1264
+ _context14.t0 = _context14["catch"](2);
1265
+ return _context14.abrupt("return", []);
1206
1266
  case 12:
1207
1267
  case "end":
1208
- return _context13.stop();
1268
+ return _context14.stop();
1209
1269
  }
1210
- }, _callee13, this, [[2, 9]]);
1270
+ }, _callee14, this, [[2, 9]]);
1211
1271
  }));
1212
1272
  function loadOrdersFromSQLite() {
1213
1273
  return _loadOrdersFromSQLite.apply(this, arguments);
@@ -1217,53 +1277,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1217
1277
  }, {
1218
1278
  key: "saveOrdersToSQLite",
1219
1279
  value: function () {
1220
- var _saveOrdersToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderList) {
1221
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1222
- while (1) switch (_context14.prev = _context14.next) {
1280
+ var _saveOrdersToSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderList) {
1281
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1282
+ while (1) switch (_context15.prev = _context15.next) {
1223
1283
  case 0:
1224
1284
  if (this.dbManager) {
1225
- _context14.next = 2;
1285
+ _context15.next = 2;
1226
1286
  break;
1227
1287
  }
1228
- return _context14.abrupt("return");
1288
+ return _context15.abrupt("return");
1229
1289
  case 2:
1230
- _context14.prev = 2;
1290
+ _context15.prev = 2;
1231
1291
  this.logInfo('saveOrdersToSQLite-开始', {
1232
1292
  count: orderList.length
1233
1293
  });
1234
- _context14.next = 6;
1294
+ _context15.next = 6;
1235
1295
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1236
1296
  case 6:
1237
1297
  this.logInfo('saveOrdersToSQLite-clear完成', {
1238
1298
  count: orderList.length
1239
1299
  });
1240
1300
  if (!(orderList.length === 0)) {
1241
- _context14.next = 9;
1301
+ _context15.next = 9;
1242
1302
  break;
1243
1303
  }
1244
- return _context14.abrupt("return");
1304
+ return _context15.abrupt("return");
1245
1305
  case 9:
1246
- _context14.next = 11;
1306
+ _context15.next = 11;
1247
1307
  return this.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderList);
1248
1308
  case 11:
1249
1309
  this.logInfo('saveOrdersToSQLite-bulkAdd完成', {
1250
1310
  count: orderList.length
1251
1311
  });
1252
- _context14.next = 17;
1312
+ _context15.next = 17;
1253
1313
  break;
1254
1314
  case 14:
1255
- _context14.prev = 14;
1256
- _context14.t0 = _context14["catch"](2);
1315
+ _context15.prev = 14;
1316
+ _context15.t0 = _context15["catch"](2);
1257
1317
  // SQLite 异常,避免影响主流程
1258
1318
  this.logError('保存订单到 SQLite 失败', {
1259
- error: _context14.t0 instanceof Error ? _context14.t0.message : String(_context14.t0),
1319
+ error: _context15.t0 instanceof Error ? _context15.t0.message : String(_context15.t0),
1260
1320
  orderList: orderList.length
1261
1321
  });
1262
1322
  case 17:
1263
1323
  case "end":
1264
- return _context14.stop();
1324
+ return _context15.stop();
1265
1325
  }
1266
- }, _callee14, this, [[2, 14]]);
1326
+ }, _callee15, this, [[2, 14]]);
1267
1327
  }));
1268
1328
  function saveOrdersToSQLite(_x8) {
1269
1329
  return _saveOrdersToSQLite.apply(this, arguments);
@@ -1273,27 +1333,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1273
1333
  }, {
1274
1334
  key: "clear",
1275
1335
  value: function () {
1276
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1277
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1278
- while (1) switch (_context15.prev = _context15.next) {
1336
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1337
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1338
+ while (1) switch (_context16.prev = _context16.next) {
1279
1339
  case 0:
1280
1340
  this.store.list = [];
1281
1341
  this.store.map = new Map();
1282
1342
  this.resourceIdIndex.clear();
1283
1343
  if (!this.dbManager) {
1284
- _context15.next = 6;
1344
+ _context16.next = 6;
1285
1345
  break;
1286
1346
  }
1287
- _context15.next = 6;
1347
+ _context16.next = 6;
1288
1348
  return this.dbManager.clear(INDEXDB_STORE_NAME);
1289
1349
  case 6:
1290
1350
  this.setStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY, '');
1291
1351
  this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
1292
1352
  case 8:
1293
1353
  case "end":
1294
- return _context15.stop();
1354
+ return _context16.stop();
1295
1355
  }
1296
- }, _callee15, this);
1356
+ }, _callee16, this);
1297
1357
  }));
1298
1358
  function clear() {
1299
1359
  return _clear.apply(this, arguments);