@pisell/pisellos 2.2.205 → 2.2.206

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 (42) hide show
  1. package/dist/modules/OpenData/index.d.ts +1 -0
  2. package/dist/modules/OpenData/index.js +21 -16
  3. package/dist/modules/Order/index.d.ts +9 -0
  4. package/dist/modules/Order/index.js +230 -145
  5. package/dist/modules/Order/types.d.ts +10 -0
  6. package/dist/modules/Order/utils.js +7 -5
  7. package/dist/server/index.d.ts +136 -0
  8. package/dist/server/index.js +2054 -781
  9. package/dist/server/modules/order/index.d.ts +7 -0
  10. package/dist/server/modules/order/index.js +375 -337
  11. package/dist/server/modules/order/types.d.ts +15 -0
  12. package/dist/server/modules/order/types.js +8 -0
  13. package/dist/server/utils/small-ticket.d.ts +69 -0
  14. package/dist/server/utils/small-ticket.js +528 -0
  15. package/dist/solution/BaseSales/index.d.ts +4 -2
  16. package/dist/solution/BaseSales/index.js +248 -188
  17. package/dist/solution/BookingByStep/index.d.ts +1 -1
  18. package/dist/solution/BookingTicket/index.d.ts +8 -1
  19. package/dist/solution/BookingTicket/index.js +443 -263
  20. package/dist/solution/BookingTicket/types.d.ts +2 -1
  21. package/dist/solution/BookingTicket/types.js +3 -1
  22. package/lib/modules/OpenData/index.d.ts +1 -0
  23. package/lib/modules/OpenData/index.js +6 -4
  24. package/lib/modules/Order/index.d.ts +9 -0
  25. package/lib/modules/Order/index.js +59 -3
  26. package/lib/modules/Order/types.d.ts +10 -0
  27. package/lib/modules/Order/utils.js +4 -3
  28. package/lib/server/index.d.ts +136 -0
  29. package/lib/server/index.js +822 -50
  30. package/lib/server/modules/order/index.d.ts +7 -0
  31. package/lib/server/modules/order/index.js +21 -7
  32. package/lib/server/modules/order/types.d.ts +15 -0
  33. package/lib/server/utils/small-ticket.d.ts +69 -0
  34. package/lib/server/utils/small-ticket.js +555 -0
  35. package/lib/solution/BaseSales/index.d.ts +4 -2
  36. package/lib/solution/BaseSales/index.js +47 -1
  37. package/lib/solution/BookingByStep/index.d.ts +1 -1
  38. package/lib/solution/BookingTicket/index.d.ts +8 -1
  39. package/lib/solution/BookingTicket/index.js +108 -1
  40. package/lib/solution/BookingTicket/types.d.ts +2 -1
  41. package/lib/solution/BookingTicket/types.js +5 -0
  42. package/package.json +1 -1
@@ -80,14 +80,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
80
80
  _defineProperty(_assertThisInitialized(_this), "lastServerFullFetchAtMs", 0);
81
81
  return _this;
82
82
  }
83
+
84
+ /**
85
+ * 广播订单变更事件,兼容全量列表订阅并额外携带本次变更订单。
86
+ *
87
+ * @example
88
+ * await this.emitOrdersChanged([freshOrder], 'pubsub.bodyUpsert')
89
+ */
83
90
  _createClass(OrderModule, [{
91
+ key: "emitOrdersChanged",
92
+ value: (function () {
93
+ var _emitOrdersChanged = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
94
+ var changedOrders,
95
+ source,
96
+ payload,
97
+ _args = arguments;
98
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
99
+ while (1) switch (_context.prev = _context.next) {
100
+ case 0:
101
+ changedOrders = _args.length > 0 && _args[0] !== undefined ? _args[0] : [];
102
+ source = _args.length > 1 ? _args[1] : undefined;
103
+ payload = {
104
+ list: this.store.list,
105
+ changedOrders: changedOrders,
106
+ source: source
107
+ };
108
+ _context.next = 5;
109
+ return this.core.effects.emit(OrderHooks.onOrdersChanged, payload);
110
+ case 5:
111
+ case "end":
112
+ return _context.stop();
113
+ }
114
+ }, _callee, this);
115
+ }));
116
+ function emitOrdersChanged() {
117
+ return _emitOrdersChanged.apply(this, arguments);
118
+ }
119
+ return emitOrdersChanged;
120
+ }())
121
+ }, {
84
122
  key: "initialize",
85
123
  value: function () {
86
- var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
124
+ var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(core, options) {
87
125
  var _options$initialState;
88
126
  var appPlugin, app, _this$store$createdAt, coreData, today, operatingDayBoundary, boundaryTime, boundaryStart, isAfterBoundary, queryStart, queryEnd;
89
- return _regeneratorRuntime().wrap(function _callee$(_context) {
90
- while (1) switch (_context.prev = _context.next) {
127
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
128
+ while (1) switch (_context2.prev = _context2.next) {
91
129
  case 0:
92
130
  this.core = core;
93
131
  this.store = options === null || options === void 0 ? void 0 : options.store;
@@ -135,7 +173,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
135
173
  if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
136
174
  this.store.list = options.initialState.list;
137
175
  this.syncOrdersMap();
138
- this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
176
+ this.emitOrdersChanged([], 'initialState');
139
177
  } else {
140
178
  this.store.list = [];
141
179
  this.store.map = new Map();
@@ -149,9 +187,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
149
187
  });
150
188
  case 10:
151
189
  case "end":
152
- return _context.stop();
190
+ return _context2.stop();
153
191
  }
154
- }, _callee, this);
192
+ }, _callee2, this);
155
193
  }));
156
194
  function initialize(_x, _x2) {
157
195
  return _initialize.apply(this, arguments);
@@ -422,11 +460,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
422
460
  }, {
423
461
  key: "preload",
424
462
  value: function () {
425
- var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
463
+ var _preload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
426
464
  var _this2 = this;
427
465
  var getData;
428
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
429
- while (1) switch (_context3.prev = _context3.next) {
466
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
467
+ while (1) switch (_context4.prev = _context4.next) {
430
468
  case 0:
431
469
  // const hasPulledInCurrentWindow = this.hasPulledOrdersToday()
432
470
  // // 仅当缓存属于当前统计窗口时才直接复用,避免跨天/跨营业日窗口继续使用旧数据
@@ -443,30 +481,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
443
481
  // return
444
482
  // }
445
483
  getData = /*#__PURE__*/function () {
446
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
484
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
447
485
  var orders;
448
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
449
- while (1) switch (_context2.prev = _context2.next) {
486
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
487
+ while (1) switch (_context3.prev = _context3.next) {
450
488
  case 0:
451
- _context2.next = 2;
489
+ _context3.next = 2;
452
490
  return _this2.loadOrdersByServer();
453
491
  case 2:
454
- orders = _context2.sent;
492
+ orders = _context3.sent;
455
493
  if (!(orders.length === 0)) {
456
- _context2.next = 5;
494
+ _context3.next = 5;
457
495
  break;
458
496
  }
459
- return _context2.abrupt("return");
497
+ return _context3.abrupt("return");
460
498
  case 5:
461
499
  _this2.store.list = cloneDeep(orders);
462
500
  _this2.syncOrdersMap();
463
- _this2.core.effects.emit(OrderHooks.onOrdersChanged, _this2.store.list);
501
+ _this2.emitOrdersChanged([], 'preload');
464
502
  _this2.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
465
503
  case 9:
466
504
  case "end":
467
- return _context2.stop();
505
+ return _context3.stop();
468
506
  }
469
- }, _callee2);
507
+ }, _callee3);
470
508
  }));
471
509
  return function getData() {
472
510
  return _ref.apply(this, arguments);
@@ -475,9 +513,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
475
513
  getData();
476
514
  case 2:
477
515
  case "end":
478
- return _context3.stop();
516
+ return _context4.stop();
479
517
  }
480
- }, _callee3);
518
+ }, _callee4);
481
519
  }));
482
520
  function preload() {
483
521
  return _preload.apply(this, arguments);
@@ -504,50 +542,50 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
504
542
  }, {
505
543
  key: "getLocalOrderByLookup",
506
544
  value: function () {
507
- var _getLocalOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(lookup) {
545
+ var _getLocalOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(lookup) {
508
546
  var _this3 = this;
509
547
  var key, memoryOrderById, memoryOrder, orders, localOrder;
510
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
511
- while (1) switch (_context4.prev = _context4.next) {
548
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
549
+ while (1) switch (_context5.prev = _context5.next) {
512
550
  case 0:
513
551
  key = this.getIdKey(lookup);
514
552
  memoryOrderById = this.store.map.get(key);
515
553
  if (!memoryOrderById) {
516
- _context4.next = 4;
554
+ _context5.next = 4;
517
555
  break;
518
556
  }
519
- return _context4.abrupt("return", memoryOrderById);
557
+ return _context5.abrupt("return", memoryOrderById);
520
558
  case 4:
521
559
  memoryOrder = this.store.list.find(function (order) {
522
560
  return _this3.isOrderLookupMatch(order, key);
523
561
  });
524
562
  if (!memoryOrder) {
525
- _context4.next = 7;
563
+ _context5.next = 7;
526
564
  break;
527
565
  }
528
- return _context4.abrupt("return", memoryOrder);
566
+ return _context5.abrupt("return", memoryOrder);
529
567
  case 7:
530
- _context4.next = 9;
568
+ _context5.next = 9;
531
569
  return this.loadOrdersFromSQLite();
532
570
  case 9:
533
- orders = _context4.sent;
571
+ orders = _context5.sent;
534
572
  localOrder = orders.find(function (order) {
535
573
  return _this3.isOrderLookupMatch(order, key);
536
574
  });
537
575
  if (localOrder) {
538
- _context4.next = 13;
576
+ _context5.next = 13;
539
577
  break;
540
578
  }
541
- return _context4.abrupt("return", null);
579
+ return _context5.abrupt("return", null);
542
580
  case 13:
543
581
  this.store.list = orders;
544
582
  this.syncOrdersMap();
545
- return _context4.abrupt("return", localOrder);
583
+ return _context5.abrupt("return", localOrder);
546
584
  case 16:
547
585
  case "end":
548
- return _context4.stop();
586
+ return _context5.stop();
549
587
  }
550
- }, _callee4, this);
588
+ }, _callee5, this);
551
589
  }));
552
590
  function getLocalOrderByLookup(_x3) {
553
591
  return _getLocalOrderByLookup.apply(this, arguments);
@@ -557,11 +595,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
557
595
  }, {
558
596
  key: "loadOrdersByServer",
559
597
  value: function () {
560
- var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
598
+ var _loadOrdersByServer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
561
599
  var _this$store;
562
600
  var orderList, data;
563
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
564
- while (1) switch (_context5.prev = _context5.next) {
601
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
602
+ while (1) switch (_context6.prev = _context6.next) {
565
603
  case 0:
566
604
  orderList = [];
567
605
  this.logInfo('loadOrdersByServer-开始', {
@@ -569,47 +607,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
569
607
  query: ((_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store.createdAtQuery) || null
570
608
  });
571
609
  if (!this.orderDataSource) {
572
- _context5.next = 17;
610
+ _context6.next = 17;
573
611
  break;
574
612
  }
575
- _context5.prev = 3;
576
- _context5.next = 6;
613
+ _context6.prev = 3;
614
+ _context6.next = 6;
577
615
  return this.orderDataSource.run({
578
616
  sse: {
579
617
  query: this.store.createdAtQuery
580
618
  }
581
619
  });
582
620
  case 6:
583
- data = _context5.sent;
621
+ data = _context6.sent;
584
622
  orderList = data || [];
585
623
  this.logInfo('loadOrdersByServer-SSE拉取成功', {
586
624
  count: orderList.length
587
625
  });
588
626
  this.markOrderPulledAtNow();
589
627
  this.lastServerFullFetchAtMs = Date.now();
590
- _context5.next = 17;
628
+ _context6.next = 17;
591
629
  break;
592
630
  case 13:
593
- _context5.prev = 13;
594
- _context5.t0 = _context5["catch"](3);
631
+ _context6.prev = 13;
632
+ _context6.t0 = _context6["catch"](3);
595
633
  orderList = [];
596
634
  this.logInfo('loadOrdersByServer-SSE拉取失败,回退为空数组');
597
635
  case 17:
598
- _context5.next = 19;
636
+ _context6.next = 19;
599
637
  return this.replaceOrdersSnapshotInSQLite(orderList, 'loadOrdersByServer');
600
638
  case 19:
601
639
  this.logInfo('loadOrdersByServer-结束', {
602
640
  count: orderList.length
603
641
  });
604
- _context5.next = 22;
642
+ _context6.next = 22;
605
643
  return this.core.effects.emit(OrderHooks.onOrdersLoaded, orderList);
606
644
  case 22:
607
- return _context5.abrupt("return", orderList);
645
+ return _context6.abrupt("return", orderList);
608
646
  case 23:
609
647
  case "end":
610
- return _context5.stop();
648
+ return _context6.stop();
611
649
  }
612
- }, _callee5, this, [[3, 13]]);
650
+ }, _callee6, this, [[3, 13]]);
613
651
  }));
614
652
  function loadOrdersByServer() {
615
653
  return _loadOrdersByServer.apply(this, arguments);
@@ -624,59 +662,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
624
662
  }, {
625
663
  key: "silentRefresh",
626
664
  value: (function () {
627
- var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
665
+ var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
628
666
  var startTime, elapsedSinceFullFetch, orders, errorMessage;
629
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
630
- while (1) switch (_context6.prev = _context6.next) {
667
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
668
+ while (1) switch (_context7.prev = _context7.next) {
631
669
  case 0:
632
670
  startTime = Date.now();
633
671
  elapsedSinceFullFetch = Date.now() - this.lastServerFullFetchAtMs;
634
672
  if (!(this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < ORDER_SILENT_REFRESH_MIN_INTERVAL_MS)) {
635
- _context6.next = 4;
673
+ _context7.next = 4;
636
674
  break;
637
675
  }
638
- return _context6.abrupt("return", this.store.list);
676
+ return _context7.abrupt("return", this.store.list);
639
677
  case 4:
640
678
  this.logInfo('silentRefresh 开始');
641
- _context6.prev = 5;
642
- _context6.next = 8;
679
+ _context7.prev = 5;
680
+ _context7.next = 8;
643
681
  return this.loadOrdersByServer();
644
682
  case 8:
645
- orders = _context6.sent;
683
+ orders = _context7.sent;
646
684
  if (!(orders.length > 0)) {
647
- _context6.next = 18;
685
+ _context7.next = 18;
648
686
  break;
649
687
  }
650
688
  this.store.list = cloneDeep(orders);
651
689
  this.syncOrdersMap();
652
- this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
653
- _context6.next = 15;
690
+ this.emitOrdersChanged([], 'silentRefresh');
691
+ _context7.next = 15;
654
692
  return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
655
693
  case 15:
656
694
  this.logInfo('silentRefresh 完成', {
657
695
  orderCount: orders.length,
658
696
  duration: "".concat(Date.now() - startTime, "ms")
659
697
  });
660
- _context6.next = 19;
698
+ _context7.next = 19;
661
699
  break;
662
700
  case 18:
663
701
  this.logInfo('silentRefresh: 服务器未返回数据');
664
702
  case 19:
665
- return _context6.abrupt("return", this.store.list);
703
+ return _context7.abrupt("return", this.store.list);
666
704
  case 22:
667
- _context6.prev = 22;
668
- _context6.t0 = _context6["catch"](5);
669
- errorMessage = _context6.t0 instanceof Error ? _context6.t0.message : String(_context6.t0);
705
+ _context7.prev = 22;
706
+ _context7.t0 = _context7["catch"](5);
707
+ errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
670
708
  this.logError('silentRefresh 失败', {
671
709
  duration: "".concat(Date.now() - startTime, "ms"),
672
710
  error: errorMessage
673
711
  });
674
- return _context6.abrupt("return", this.store.list);
712
+ return _context7.abrupt("return", this.store.list);
675
713
  case 27:
676
714
  case "end":
677
- return _context6.stop();
715
+ return _context7.stop();
678
716
  }
679
- }, _callee6, this, [[5, 22]]);
717
+ }, _callee7, this, [[5, 22]]);
680
718
  }));
681
719
  function silentRefresh() {
682
720
  return _silentRefresh.apply(this, arguments);
@@ -702,31 +740,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
702
740
  }, {
703
741
  key: "overwriteExistingOrder",
704
742
  value: (function () {
705
- var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(fresh) {
743
+ var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(fresh) {
706
744
  var _this5 = this;
707
745
  var orderId, key;
708
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
709
- while (1) switch (_context7.prev = _context7.next) {
746
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
747
+ while (1) switch (_context8.prev = _context8.next) {
710
748
  case 0:
711
749
  orderId = fresh === null || fresh === void 0 ? void 0 : fresh.order_id;
712
750
  if (!(orderId === undefined || orderId === null)) {
713
- _context7.next = 4;
751
+ _context8.next = 4;
714
752
  break;
715
753
  }
716
754
  this.logError('overwriteExistingOrder-入参缺少 order_id');
717
- return _context7.abrupt("return", {
755
+ return _context8.abrupt("return", {
718
756
  overwritten: false
719
757
  });
720
758
  case 4:
721
759
  key = this.getIdKey(orderId);
722
760
  if (this.store.map.has(key)) {
723
- _context7.next = 8;
761
+ _context8.next = 8;
724
762
  break;
725
763
  }
726
764
  this.logInfo('overwriteExistingOrder-本地不存在该订单,跳过', {
727
765
  orderId: orderId
728
766
  });
729
- return _context7.abrupt("return", {
767
+ return _context8.abrupt("return", {
730
768
  overwritten: false
731
769
  });
732
770
  case 8:
@@ -740,24 +778,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
740
778
  return _this5.getIdKey(id) === key ? fresh : order;
741
779
  });
742
780
  this.syncOrdersMap();
743
- _context7.next = 13;
781
+ _context8.next = 13;
744
782
  return this.updateOrderInSQLite(fresh, 'overwriteExistingOrder');
745
783
  case 13:
746
784
  this.logInfo('overwriteExistingOrder-结束', {
747
785
  orderId: orderId,
748
786
  storeOrderCountAfter: this.store.list.length
749
787
  });
750
- _context7.next = 16;
751
- return this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
788
+ _context8.next = 16;
789
+ return this.emitOrdersChanged([fresh], 'overwriteExistingOrder');
752
790
  case 16:
753
- return _context7.abrupt("return", {
791
+ return _context8.abrupt("return", {
754
792
  overwritten: true
755
793
  });
756
794
  case 17:
757
795
  case "end":
758
- return _context7.stop();
796
+ return _context8.stop();
759
797
  }
760
- }, _callee7, this);
798
+ }, _callee8, this);
761
799
  }));
762
800
  function overwriteExistingOrder(_x4) {
763
801
  return _overwriteExistingOrder.apply(this, arguments);
@@ -772,27 +810,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
772
810
  }, {
773
811
  key: "upsertOrdersFromRemote",
774
812
  value: (function () {
775
- var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(freshOrders) {
776
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
777
- while (1) switch (_context8.prev = _context8.next) {
813
+ var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(freshOrders) {
814
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
815
+ while (1) switch (_context9.prev = _context9.next) {
778
816
  case 0:
779
817
  if (freshOrders !== null && freshOrders !== void 0 && freshOrders.length) {
780
- _context8.next = 3;
818
+ _context9.next = 3;
781
819
  break;
782
820
  }
783
821
  this.logInfo('upsertOrdersFromRemote-订单列表为空', {});
784
- return _context8.abrupt("return");
822
+ return _context9.abrupt("return");
785
823
  case 3:
786
824
  this.logInfo('upsertOrdersFromRemote-开始', {
787
825
  count: freshOrders.length
788
826
  });
789
- _context8.next = 6;
827
+ _context9.next = 6;
790
828
  return this.mergeOrdersToStore(freshOrders, 'upsertOrdersFromRemote');
791
829
  case 6:
792
830
  case "end":
793
- return _context8.stop();
831
+ return _context9.stop();
794
832
  }
795
- }, _callee8, this);
833
+ }, _callee9, this);
796
834
  }));
797
835
  function upsertOrdersFromRemote(_x5) {
798
836
  return _upsertOrdersFromRemote.apply(this, arguments);
@@ -807,60 +845,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
807
845
  }, {
808
846
  key: "upsertPendingSyncOrders",
809
847
  value: (function () {
810
- var _upsertPendingSyncOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(pendingOrders) {
848
+ var _upsertPendingSyncOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(pendingOrders) {
811
849
  var _this6 = this;
812
850
  var pendingMap, _iterator4, _step4, order, storageKey, patchedOrders, mergeActions, updatedList, _iterator5, _step5, _step5$value, _storageKey, _order;
813
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
814
- while (1) switch (_context9.prev = _context9.next) {
851
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
852
+ while (1) switch (_context10.prev = _context10.next) {
815
853
  case 0:
816
854
  if (pendingOrders !== null && pendingOrders !== void 0 && pendingOrders.length) {
817
- _context9.next = 3;
855
+ _context10.next = 3;
818
856
  break;
819
857
  }
820
858
  this.logInfo('upsertPendingSyncOrders-订单列表为空', {});
821
- return _context9.abrupt("return");
859
+ return _context10.abrupt("return");
822
860
  case 3:
823
861
  pendingMap = new Map();
824
862
  _iterator4 = _createForOfIteratorHelper(pendingOrders);
825
- _context9.prev = 5;
863
+ _context10.prev = 5;
826
864
  _iterator4.s();
827
865
  case 7:
828
866
  if ((_step4 = _iterator4.n()).done) {
829
- _context9.next = 15;
867
+ _context10.next = 15;
830
868
  break;
831
869
  }
832
870
  order = _step4.value;
833
871
  storageKey = this.getOrderStorageKey(order);
834
872
  if (storageKey) {
835
- _context9.next = 12;
873
+ _context10.next = 12;
836
874
  break;
837
875
  }
838
- return _context9.abrupt("continue", 13);
876
+ return _context10.abrupt("continue", 13);
839
877
  case 12:
840
878
  pendingMap.set(storageKey, order);
841
879
  case 13:
842
- _context9.next = 7;
880
+ _context10.next = 7;
843
881
  break;
844
882
  case 15:
845
- _context9.next = 20;
883
+ _context10.next = 20;
846
884
  break;
847
885
  case 17:
848
- _context9.prev = 17;
849
- _context9.t0 = _context9["catch"](5);
850
- _iterator4.e(_context9.t0);
886
+ _context10.prev = 17;
887
+ _context10.t0 = _context10["catch"](5);
888
+ _iterator4.e(_context10.t0);
851
889
  case 20:
852
- _context9.prev = 20;
890
+ _context10.prev = 20;
853
891
  _iterator4.f();
854
- return _context9.finish(20);
892
+ return _context10.finish(20);
855
893
  case 23:
856
894
  if (!(pendingMap.size === 0)) {
857
- _context9.next = 26;
895
+ _context10.next = 26;
858
896
  break;
859
897
  }
860
898
  this.logError('upsertPendingSyncOrders-订单缺少可落库标识', {
861
899
  count: pendingOrders.length
862
900
  });
863
- return _context9.abrupt("return");
901
+ return _context10.abrupt("return");
864
902
  case 26:
865
903
  this.logInfo('upsertPendingSyncOrders-开始', {
866
904
  count: pendingMap.size
@@ -889,19 +927,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
889
927
  }
890
928
  this.store.list = updatedList;
891
929
  this.syncOrdersMap();
892
- _context9.next = 36;
930
+ _context10.next = 36;
893
931
  return this.patchOrdersInSQLite(patchedOrders, 'upsertPendingSyncOrders', mergeActions);
894
932
  case 36:
895
933
  this.logInfo('upsertPendingSyncOrders-结束', {
896
934
  count: patchedOrders.length,
897
935
  storeOrderCountAfter: this.store.list.length
898
936
  });
899
- this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
937
+ this.emitOrdersChanged(patchedOrders, 'upsertPendingSyncOrders');
900
938
  case 38:
901
939
  case "end":
902
- return _context9.stop();
940
+ return _context10.stop();
903
941
  }
904
- }, _callee9, this, [[5, 17, 20, 23]]);
942
+ }, _callee10, this, [[5, 17, 20, 23]]);
905
943
  }));
906
944
  function upsertPendingSyncOrders(_x6) {
907
945
  return _upsertPendingSyncOrders.apply(this, arguments);
@@ -915,42 +953,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
915
953
  }, {
916
954
  key: "fetchOrdersBySSE",
917
955
  value: (function () {
918
- var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
956
+ var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
919
957
  var query,
920
958
  data,
921
- _args10 = arguments;
922
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
923
- while (1) switch (_context10.prev = _context10.next) {
959
+ _args11 = arguments;
960
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
961
+ while (1) switch (_context11.prev = _context11.next) {
924
962
  case 0:
925
- query = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
963
+ query = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
926
964
  if (this.orderDataSource) {
927
- _context10.next = 3;
965
+ _context11.next = 3;
928
966
  break;
929
967
  }
930
- return _context10.abrupt("return", []);
968
+ return _context11.abrupt("return", []);
931
969
  case 3:
932
- _context10.prev = 3;
933
- _context10.next = 6;
970
+ _context11.prev = 3;
971
+ _context11.next = 6;
934
972
  return this.orderDataSource.run({
935
973
  sse: {
936
974
  query: query
937
975
  }
938
976
  });
939
977
  case 6:
940
- data = _context10.sent;
941
- return _context10.abrupt("return", data || []);
978
+ data = _context11.sent;
979
+ return _context11.abrupt("return", data || []);
942
980
  case 10:
943
- _context10.prev = 10;
944
- _context10.t0 = _context10["catch"](3);
981
+ _context11.prev = 10;
982
+ _context11.t0 = _context11["catch"](3);
945
983
  this.logError('fetchOrdersBySSE-失败', {
946
- error: _context10.t0 instanceof Error ? _context10.t0.message : String(_context10.t0)
984
+ error: _context11.t0 instanceof Error ? _context11.t0.message : String(_context11.t0)
947
985
  });
948
- return _context10.abrupt("return", []);
986
+ return _context11.abrupt("return", []);
949
987
  case 14:
950
988
  case "end":
951
- return _context10.stop();
989
+ return _context11.stop();
952
990
  }
953
- }, _callee10, this, [[3, 10]]);
991
+ }, _callee11, this, [[3, 10]]);
954
992
  }));
955
993
  function fetchOrdersBySSE() {
956
994
  return _fetchOrdersBySSE.apply(this, arguments);
@@ -1132,41 +1170,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1132
1170
  }, {
1133
1171
  key: "flushOrderSyncMessagesByThrottle",
1134
1172
  value: (function () {
1135
- var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1136
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1137
- while (1) switch (_context11.prev = _context11.next) {
1173
+ var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1174
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1175
+ while (1) switch (_context12.prev = _context12.next) {
1138
1176
  case 0:
1139
1177
  if (!this.isProcessingSyncBatch) {
1140
- _context11.next = 2;
1178
+ _context12.next = 2;
1141
1179
  break;
1142
1180
  }
1143
- return _context11.abrupt("return");
1181
+ return _context12.abrupt("return");
1144
1182
  case 2:
1145
1183
  if (!(this.pendingSyncMessages.length === 0)) {
1146
- _context11.next = 5;
1184
+ _context12.next = 5;
1147
1185
  break;
1148
1186
  }
1149
1187
  this.isIdlePhase = true;
1150
- return _context11.abrupt("return");
1188
+ return _context12.abrupt("return");
1151
1189
  case 5:
1152
1190
  this.isProcessingSyncBatch = true;
1153
- _context11.prev = 6;
1154
- _context11.next = 9;
1191
+ _context12.prev = 6;
1192
+ _context12.next = 9;
1155
1193
  return this.processOrderSyncMessages();
1156
1194
  case 9:
1157
- _context11.prev = 9;
1195
+ _context12.prev = 9;
1158
1196
  this.isProcessingSyncBatch = false;
1159
1197
  if (this.pendingSyncMessages.length > 0) {
1160
1198
  this.scheduleOrderSyncThrottle();
1161
1199
  } else {
1162
1200
  this.isIdlePhase = true;
1163
1201
  }
1164
- return _context11.finish(9);
1202
+ return _context12.finish(9);
1165
1203
  case 13:
1166
1204
  case "end":
1167
- return _context11.stop();
1205
+ return _context12.stop();
1168
1206
  }
1169
- }, _callee11, this, [[6,, 9, 13]]);
1207
+ }, _callee12, this, [[6,, 9, 13]]);
1170
1208
  }));
1171
1209
  function flushOrderSyncMessagesByThrottle() {
1172
1210
  return _flushOrderSyncMessagesByThrottle.apply(this, arguments);
@@ -1188,19 +1226,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1188
1226
  }, {
1189
1227
  key: "processOrderSyncMessages",
1190
1228
  value: (function () {
1191
- var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1229
+ var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
1192
1230
  var _this10 = this;
1193
1231
  var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, uniqueRefreshIds, upsertList, _this$filterRedundant, toFetch, skipped, freshOrders, batchProcessEndAt;
1194
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1195
- while (1) switch (_context12.prev = _context12.next) {
1232
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1233
+ while (1) switch (_context13.prev = _context13.next) {
1196
1234
  case 0:
1197
1235
  messages = _toConsumableArray(this.pendingSyncMessages);
1198
1236
  this.pendingSyncMessages = [];
1199
1237
  if (!(messages.length === 0)) {
1200
- _context12.next = 4;
1238
+ _context13.next = 4;
1201
1239
  break;
1202
1240
  }
1203
- return _context12.abrupt("return");
1241
+ return _context13.abrupt("return");
1204
1242
  case 4:
1205
1243
  batchProcessStartAt = Date.now();
1206
1244
  earliestReceivedAt = Math.min.apply(Math, _toConsumableArray(messages.map(function (m) {
@@ -1234,41 +1272,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1234
1272
  refreshIdCount: uniqueRefreshIds.length
1235
1273
  });
1236
1274
  if (!(upsertList.length > 0)) {
1237
- _context12.next = 16;
1275
+ _context13.next = 16;
1238
1276
  break;
1239
1277
  }
1240
- _context12.next = 16;
1278
+ _context13.next = 16;
1241
1279
  return this.mergeOrdersToStore(upsertList, 'pubsub.bodyUpsert');
1242
1280
  case 16:
1243
1281
  if (!(uniqueRefreshIds.length > 0)) {
1244
- _context12.next = 28;
1282
+ _context13.next = 28;
1245
1283
  break;
1246
1284
  }
1247
1285
  _this$filterRedundant = this.filterRedundantHttpRefreshIds(uniqueRefreshIds), toFetch = _this$filterRedundant.toFetch, skipped = _this$filterRedundant.skipped;
1248
1286
  if (skipped.length > 0) {}
1249
1287
  if (!(toFetch.length > 0)) {
1250
- _context12.next = 28;
1288
+ _context13.next = 28;
1251
1289
  break;
1252
1290
  }
1253
- _context12.next = 22;
1291
+ _context13.next = 22;
1254
1292
  return this.fetchOrdersByHttp(toFetch);
1255
1293
  case 22:
1256
- freshOrders = _context12.sent;
1294
+ freshOrders = _context13.sent;
1257
1295
  if (!(freshOrders.length > 0)) {
1258
- _context12.next = 28;
1296
+ _context13.next = 28;
1259
1297
  break;
1260
1298
  }
1261
- _context12.next = 26;
1299
+ _context13.next = 26;
1262
1300
  return this.mergeOrdersToStore(freshOrders, 'pubsub.httpRefresh');
1263
1301
  case 26:
1264
- _context12.next = 28;
1302
+ _context13.next = 28;
1265
1303
  break;
1266
1304
  case 28:
1267
1305
  if (!(upsertList.length === 0 && uniqueRefreshIds.length === 0)) {
1268
- _context12.next = 30;
1306
+ _context13.next = 30;
1269
1307
  break;
1270
1308
  }
1271
- return _context12.abrupt("return");
1309
+ return _context13.abrupt("return");
1272
1310
  case 30:
1273
1311
  batchProcessEndAt = Date.now();
1274
1312
  this.logInfo('processOrderSyncMessages-结束', {
@@ -1277,13 +1315,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1277
1315
  batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt,
1278
1316
  totalFromPubsubToProcessedMs: batchProcessEndAt - earliestReceivedAt
1279
1317
  });
1280
- _context12.next = 34;
1318
+ _context13.next = 34;
1281
1319
  return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
1282
1320
  case 34:
1283
1321
  case "end":
1284
- return _context12.stop();
1322
+ return _context13.stop();
1285
1323
  }
1286
- }, _callee12, this);
1324
+ }, _callee13, this);
1287
1325
  }));
1288
1326
  function processOrderSyncMessages() {
1289
1327
  return _processOrderSyncMessages.apply(this, arguments);
@@ -1304,29 +1342,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1304
1342
  }, {
1305
1343
  key: "fetchOrdersByHttp",
1306
1344
  value: (function () {
1307
- var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(ids) {
1345
+ var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(ids) {
1308
1346
  var _orderList, orderList;
1309
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1310
- while (1) switch (_context13.prev = _context13.next) {
1347
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1348
+ while (1) switch (_context14.prev = _context14.next) {
1311
1349
  case 0:
1312
1350
  if (!(!this.orderDataSource || ids.length === 0)) {
1313
- _context13.next = 2;
1351
+ _context14.next = 2;
1314
1352
  break;
1315
1353
  }
1316
- return _context13.abrupt("return", []);
1354
+ return _context14.abrupt("return", []);
1317
1355
  case 2:
1318
- _context13.prev = 2;
1356
+ _context14.prev = 2;
1319
1357
  if (!(typeof this.orderDataSource.fetchOrdersByIds === 'function')) {
1320
- _context13.next = 8;
1358
+ _context14.next = 8;
1321
1359
  break;
1322
1360
  }
1323
- _context13.next = 6;
1361
+ _context14.next = 6;
1324
1362
  return this.orderDataSource.fetchOrdersByIds(ids);
1325
1363
  case 6:
1326
- _orderList = _context13.sent;
1327
- return _context13.abrupt("return", _orderList || []);
1364
+ _orderList = _context14.sent;
1365
+ return _context14.abrupt("return", _orderList || []);
1328
1366
  case 8:
1329
- _context13.next = 10;
1367
+ _context14.next = 10;
1330
1368
  return this.orderDataSource.run({
1331
1369
  http: {
1332
1370
  query: {
@@ -1335,17 +1373,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1335
1373
  }
1336
1374
  });
1337
1375
  case 10:
1338
- orderList = _context13.sent;
1339
- return _context13.abrupt("return", orderList || []);
1376
+ orderList = _context14.sent;
1377
+ return _context14.abrupt("return", orderList || []);
1340
1378
  case 14:
1341
- _context13.prev = 14;
1342
- _context13.t0 = _context13["catch"](2);
1343
- return _context13.abrupt("return", []);
1379
+ _context14.prev = 14;
1380
+ _context14.t0 = _context14["catch"](2);
1381
+ return _context14.abrupt("return", []);
1344
1382
  case 17:
1345
1383
  case "end":
1346
- return _context13.stop();
1384
+ return _context14.stop();
1347
1385
  }
1348
- }, _callee13, this, [[2, 14]]);
1386
+ }, _callee14, this, [[2, 14]]);
1349
1387
  }));
1350
1388
  function fetchOrdersByHttp(_x7) {
1351
1389
  return _fetchOrdersByHttp.apply(this, arguments);
@@ -1359,11 +1397,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1359
1397
  }, {
1360
1398
  key: "mergeOrdersToStore",
1361
1399
  value: (function () {
1362
- var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(freshOrders, source) {
1400
+ var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(freshOrders, source) {
1363
1401
  var _this11 = this;
1364
1402
  var freshMap, _iterator8, _step8, order, id, freshStorageKeyMap, _iterator9, _step9, _order2, storageKey, uniqueFreshCount, patchedOrders, mergeActions, updatedList, _iterator10, _step10, _order3, _id, insertCount, updateCount;
1365
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1366
- while (1) switch (_context14.prev = _context14.next) {
1403
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1404
+ while (1) switch (_context15.prev = _context15.next) {
1367
1405
  case 0:
1368
1406
  this.logInfo('mergeOrdersToStore-开始', {
1369
1407
  freshOrderCount: freshOrders.length,
@@ -1371,69 +1409,69 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1371
1409
  });
1372
1410
  freshMap = new Map();
1373
1411
  _iterator8 = _createForOfIteratorHelper(freshOrders);
1374
- _context14.prev = 3;
1412
+ _context15.prev = 3;
1375
1413
  _iterator8.s();
1376
1414
  case 5:
1377
1415
  if ((_step8 = _iterator8.n()).done) {
1378
- _context14.next = 13;
1416
+ _context15.next = 13;
1379
1417
  break;
1380
1418
  }
1381
1419
  order = _step8.value;
1382
1420
  id = order === null || order === void 0 ? void 0 : order.order_id;
1383
1421
  if (!(id === undefined || id === null)) {
1384
- _context14.next = 10;
1422
+ _context15.next = 10;
1385
1423
  break;
1386
1424
  }
1387
- return _context14.abrupt("continue", 11);
1425
+ return _context15.abrupt("continue", 11);
1388
1426
  case 10:
1389
1427
  freshMap.set(this.getIdKey(id), this.normalizeRemoteSyncedOrder(order));
1390
1428
  case 11:
1391
- _context14.next = 5;
1429
+ _context15.next = 5;
1392
1430
  break;
1393
1431
  case 13:
1394
- _context14.next = 18;
1432
+ _context15.next = 18;
1395
1433
  break;
1396
1434
  case 15:
1397
- _context14.prev = 15;
1398
- _context14.t0 = _context14["catch"](3);
1399
- _iterator8.e(_context14.t0);
1435
+ _context15.prev = 15;
1436
+ _context15.t0 = _context15["catch"](3);
1437
+ _iterator8.e(_context15.t0);
1400
1438
  case 18:
1401
- _context14.prev = 18;
1439
+ _context15.prev = 18;
1402
1440
  _iterator8.f();
1403
- return _context14.finish(18);
1441
+ return _context15.finish(18);
1404
1442
  case 21:
1405
1443
  freshStorageKeyMap = new Map();
1406
1444
  _iterator9 = _createForOfIteratorHelper(freshMap.values());
1407
- _context14.prev = 23;
1445
+ _context15.prev = 23;
1408
1446
  _iterator9.s();
1409
1447
  case 25:
1410
1448
  if ((_step9 = _iterator9.n()).done) {
1411
- _context14.next = 33;
1449
+ _context15.next = 33;
1412
1450
  break;
1413
1451
  }
1414
1452
  _order2 = _step9.value;
1415
1453
  storageKey = this.getOrderStorageKey(_order2);
1416
1454
  if (storageKey) {
1417
- _context14.next = 30;
1455
+ _context15.next = 30;
1418
1456
  break;
1419
1457
  }
1420
- return _context14.abrupt("continue", 31);
1458
+ return _context15.abrupt("continue", 31);
1421
1459
  case 30:
1422
1460
  freshStorageKeyMap.set(storageKey, _order2);
1423
1461
  case 31:
1424
- _context14.next = 25;
1462
+ _context15.next = 25;
1425
1463
  break;
1426
1464
  case 33:
1427
- _context14.next = 38;
1465
+ _context15.next = 38;
1428
1466
  break;
1429
1467
  case 35:
1430
- _context14.prev = 35;
1431
- _context14.t1 = _context14["catch"](23);
1432
- _iterator9.e(_context14.t1);
1468
+ _context15.prev = 35;
1469
+ _context15.t1 = _context15["catch"](23);
1470
+ _iterator9.e(_context15.t1);
1433
1471
  case 38:
1434
- _context14.prev = 38;
1472
+ _context15.prev = 38;
1435
1473
  _iterator9.f();
1436
- return _context14.finish(38);
1474
+ return _context15.finish(38);
1437
1475
  case 41:
1438
1476
  uniqueFreshCount = freshMap.size;
1439
1477
  patchedOrders = _toConsumableArray(freshMap.values());
@@ -1484,19 +1522,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1484
1522
  }).length;
1485
1523
  this.store.list = updatedList;
1486
1524
  this.syncOrdersMap();
1487
- _context14.next = 53;
1525
+ _context15.next = 53;
1488
1526
  return this.patchOrdersInSQLite(patchedOrders, source, mergeActions);
1489
1527
  case 53:
1490
1528
  this.logInfo('mergeOrdersToStore-结束', {
1491
1529
  uniqueFreshCount: uniqueFreshCount,
1492
1530
  storeOrderCountAfter: this.store.list.length
1493
1531
  });
1494
- this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
1532
+ this.emitOrdersChanged(patchedOrders, source);
1495
1533
  case 55:
1496
1534
  case "end":
1497
- return _context14.stop();
1535
+ return _context15.stop();
1498
1536
  }
1499
- }, _callee14, this, [[3, 15, 18, 21], [23, 35, 38, 41]]);
1537
+ }, _callee15, this, [[3, 15, 18, 21], [23, 35, 38, 41]]);
1500
1538
  }));
1501
1539
  function mergeOrdersToStore(_x8, _x9) {
1502
1540
  return _mergeOrdersToStore.apply(this, arguments);
@@ -1667,32 +1705,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1667
1705
  }, {
1668
1706
  key: "loadOrdersFromSQLite",
1669
1707
  value: function () {
1670
- var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1708
+ var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1671
1709
  var orders;
1672
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1673
- while (1) switch (_context15.prev = _context15.next) {
1710
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1711
+ while (1) switch (_context16.prev = _context16.next) {
1674
1712
  case 0:
1675
1713
  if (this.dbManager) {
1676
- _context15.next = 2;
1714
+ _context16.next = 2;
1677
1715
  break;
1678
1716
  }
1679
- return _context15.abrupt("return", []);
1717
+ return _context16.abrupt("return", []);
1680
1718
  case 2:
1681
- _context15.prev = 2;
1682
- _context15.next = 5;
1719
+ _context16.prev = 2;
1720
+ _context16.next = 5;
1683
1721
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1684
1722
  case 5:
1685
- orders = _context15.sent;
1686
- return _context15.abrupt("return", orders || []);
1723
+ orders = _context16.sent;
1724
+ return _context16.abrupt("return", orders || []);
1687
1725
  case 9:
1688
- _context15.prev = 9;
1689
- _context15.t0 = _context15["catch"](2);
1690
- return _context15.abrupt("return", []);
1726
+ _context16.prev = 9;
1727
+ _context16.t0 = _context16["catch"](2);
1728
+ return _context16.abrupt("return", []);
1691
1729
  case 12:
1692
1730
  case "end":
1693
- return _context15.stop();
1731
+ return _context16.stop();
1694
1732
  }
1695
- }, _callee15, this, [[2, 9]]);
1733
+ }, _callee16, this, [[2, 9]]);
1696
1734
  }));
1697
1735
  function loadOrdersFromSQLite() {
1698
1736
  return _loadOrdersFromSQLite.apply(this, arguments);
@@ -1752,10 +1790,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1752
1790
  }, {
1753
1791
  key: "runInOrderSQLiteSaveQueue",
1754
1792
  value: (function () {
1755
- var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(task) {
1793
+ var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(task) {
1756
1794
  var queuedTask;
1757
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1758
- while (1) switch (_context16.prev = _context16.next) {
1795
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1796
+ while (1) switch (_context17.prev = _context17.next) {
1759
1797
  case 0:
1760
1798
  queuedTask = this.orderSQLiteSaveQueue.then(task, task);
1761
1799
  this.orderSQLiteSaveQueue = queuedTask.then(function () {
@@ -1763,12 +1801,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1763
1801
  }, function () {
1764
1802
  return undefined;
1765
1803
  });
1766
- return _context16.abrupt("return", queuedTask);
1804
+ return _context17.abrupt("return", queuedTask);
1767
1805
  case 3:
1768
1806
  case "end":
1769
- return _context16.stop();
1807
+ return _context17.stop();
1770
1808
  }
1771
- }, _callee16, this);
1809
+ }, _callee17, this);
1772
1810
  }));
1773
1811
  function runInOrderSQLiteSaveQueue(_x10) {
1774
1812
  return _runInOrderSQLiteSaveQueue.apply(this, arguments);
@@ -1785,46 +1823,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1785
1823
  }, {
1786
1824
  key: "patchOrdersInSQLite",
1787
1825
  value: (function () {
1788
- var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orders, source) {
1826
+ var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orders, source) {
1789
1827
  var _this14 = this;
1790
1828
  var mergeActions,
1791
1829
  ordersSnapshot,
1792
1830
  _this$filterRedundant2,
1793
1831
  toWrite,
1794
1832
  skipped,
1795
- _args18 = arguments;
1796
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1797
- while (1) switch (_context18.prev = _context18.next) {
1833
+ _args19 = arguments;
1834
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1835
+ while (1) switch (_context19.prev = _context19.next) {
1798
1836
  case 0:
1799
- mergeActions = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
1837
+ mergeActions = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
1800
1838
  if (!(!this.dbManager || orders.length === 0)) {
1801
- _context18.next = 3;
1839
+ _context19.next = 3;
1802
1840
  break;
1803
1841
  }
1804
- return _context18.abrupt("return");
1842
+ return _context19.abrupt("return");
1805
1843
  case 3:
1806
1844
  ordersSnapshot = cloneDeep(orders).filter(function (order) {
1807
1845
  return _this14.getOrderStorageKey(order);
1808
1846
  });
1809
1847
  if (!(ordersSnapshot.length === 0)) {
1810
- _context18.next = 6;
1848
+ _context19.next = 6;
1811
1849
  break;
1812
1850
  }
1813
- return _context18.abrupt("return");
1851
+ return _context19.abrupt("return");
1814
1852
  case 6:
1815
1853
  _this$filterRedundant2 = this.filterRedundantPatchOrders(source, ordersSnapshot, mergeActions), toWrite = _this$filterRedundant2.toWrite, skipped = _this$filterRedundant2.skipped;
1816
1854
  if (!(toWrite.length === 0)) {
1817
- _context18.next = 9;
1855
+ _context19.next = 9;
1818
1856
  break;
1819
1857
  }
1820
- return _context18.abrupt("return");
1858
+ return _context19.abrupt("return");
1821
1859
  case 9:
1822
- _context18.prev = 9;
1823
- _context18.next = 12;
1824
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1860
+ _context19.prev = 9;
1861
+ _context19.next = 12;
1862
+ return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1825
1863
  var writeMethod, _iterator13, _step13, order;
1826
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1827
- while (1) switch (_context17.prev = _context17.next) {
1864
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1865
+ while (1) switch (_context18.prev = _context18.next) {
1828
1866
  case 0:
1829
1867
  writeMethod = 'none';
1830
1868
  _this14.logInfo('patchOrdersInSQLite-开始', {
@@ -1833,57 +1871,57 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1833
1871
  dedupedCount: skipped.length
1834
1872
  });
1835
1873
  if (!(typeof _this14.dbManager.bulkUpdate === 'function')) {
1836
- _context17.next = 8;
1874
+ _context18.next = 8;
1837
1875
  break;
1838
1876
  }
1839
1877
  writeMethod = 'bulkUpdate';
1840
- _context17.next = 6;
1878
+ _context18.next = 6;
1841
1879
  return _this14.dbManager.bulkUpdate(INDEXDB_STORE_NAME, toWrite);
1842
1880
  case 6:
1843
- _context17.next = 33;
1881
+ _context18.next = 33;
1844
1882
  break;
1845
1883
  case 8:
1846
1884
  if (!(typeof _this14.dbManager.bulkAdd === 'function')) {
1847
- _context17.next = 14;
1885
+ _context18.next = 14;
1848
1886
  break;
1849
1887
  }
1850
1888
  writeMethod = 'bulkAdd';
1851
- _context17.next = 12;
1889
+ _context18.next = 12;
1852
1890
  return _this14.dbManager.bulkAdd(INDEXDB_STORE_NAME, toWrite);
1853
1891
  case 12:
1854
- _context17.next = 33;
1892
+ _context18.next = 33;
1855
1893
  break;
1856
1894
  case 14:
1857
1895
  if (!(typeof _this14.dbManager.update === 'function')) {
1858
- _context17.next = 33;
1896
+ _context18.next = 33;
1859
1897
  break;
1860
1898
  }
1861
1899
  writeMethod = 'update';
1862
1900
  _iterator13 = _createForOfIteratorHelper(toWrite);
1863
- _context17.prev = 17;
1901
+ _context18.prev = 17;
1864
1902
  _iterator13.s();
1865
1903
  case 19:
1866
1904
  if ((_step13 = _iterator13.n()).done) {
1867
- _context17.next = 25;
1905
+ _context18.next = 25;
1868
1906
  break;
1869
1907
  }
1870
1908
  order = _step13.value;
1871
- _context17.next = 23;
1909
+ _context18.next = 23;
1872
1910
  return _this14.dbManager.update(INDEXDB_STORE_NAME, order);
1873
1911
  case 23:
1874
- _context17.next = 19;
1912
+ _context18.next = 19;
1875
1913
  break;
1876
1914
  case 25:
1877
- _context17.next = 30;
1915
+ _context18.next = 30;
1878
1916
  break;
1879
1917
  case 27:
1880
- _context17.prev = 27;
1881
- _context17.t0 = _context17["catch"](17);
1882
- _iterator13.e(_context17.t0);
1918
+ _context18.prev = 27;
1919
+ _context18.t0 = _context18["catch"](17);
1920
+ _iterator13.e(_context18.t0);
1883
1921
  case 30:
1884
- _context17.prev = 30;
1922
+ _context18.prev = 30;
1885
1923
  _iterator13.f();
1886
- return _context17.finish(30);
1924
+ return _context18.finish(30);
1887
1925
  case 33:
1888
1926
  _this14.recordRecentSqliteWrite(source, toWrite);
1889
1927
  _this14.logInfo('patchOrdersInSQLite-完成', {
@@ -1894,25 +1932,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1894
1932
  });
1895
1933
  case 35:
1896
1934
  case "end":
1897
- return _context17.stop();
1935
+ return _context18.stop();
1898
1936
  }
1899
- }, _callee17, null, [[17, 27, 30, 33]]);
1937
+ }, _callee18, null, [[17, 27, 30, 33]]);
1900
1938
  })));
1901
1939
  case 12:
1902
- _context18.next = 17;
1940
+ _context19.next = 17;
1903
1941
  break;
1904
1942
  case 14:
1905
- _context18.prev = 14;
1906
- _context18.t0 = _context18["catch"](9);
1943
+ _context19.prev = 14;
1944
+ _context19.t0 = _context19["catch"](9);
1907
1945
  this.logError('增量保存订单到 SQLite 失败', {
1908
- error: _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0),
1946
+ error: _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0),
1909
1947
  orderCount: ordersSnapshot.length
1910
1948
  });
1911
1949
  case 17:
1912
1950
  case "end":
1913
- return _context18.stop();
1951
+ return _context19.stop();
1914
1952
  }
1915
- }, _callee18, this, [[9, 14]]);
1953
+ }, _callee19, this, [[9, 14]]);
1916
1954
  }));
1917
1955
  function patchOrdersInSQLite(_x11, _x12) {
1918
1956
  return _patchOrdersInSQLite.apply(this, arguments);
@@ -1929,26 +1967,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1929
1967
  }, {
1930
1968
  key: "updateOrderInSQLite",
1931
1969
  value: (function () {
1932
- var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(order, source) {
1970
+ var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(order, source) {
1933
1971
  var _this15 = this;
1934
1972
  var orderSnapshot, _orderSnapshot$order_3;
1935
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1936
- while (1) switch (_context20.prev = _context20.next) {
1973
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1974
+ while (1) switch (_context21.prev = _context21.next) {
1937
1975
  case 0:
1938
1976
  if (!(!this.dbManager || !this.getOrderStorageKey(order))) {
1939
- _context20.next = 2;
1977
+ _context21.next = 2;
1940
1978
  break;
1941
1979
  }
1942
- return _context20.abrupt("return");
1980
+ return _context21.abrupt("return");
1943
1981
  case 2:
1944
1982
  orderSnapshot = cloneDeep(order);
1945
- _context20.prev = 3;
1946
- _context20.next = 6;
1947
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1983
+ _context21.prev = 3;
1984
+ _context21.next = 6;
1985
+ return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1948
1986
  var _orderSnapshot$order_, _orderSnapshot$order_2;
1949
1987
  var writeMethod;
1950
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1951
- while (1) switch (_context19.prev = _context19.next) {
1988
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1989
+ while (1) switch (_context20.prev = _context20.next) {
1952
1990
  case 0:
1953
1991
  writeMethod = 'none';
1954
1992
  _this15.logInfo('updateOrderInSQLite-开始', {
@@ -1957,33 +1995,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1957
1995
  storageKey: _this15.getOrderStorageKey(orderSnapshot)
1958
1996
  });
1959
1997
  if (!(typeof _this15.dbManager.update === 'function')) {
1960
- _context19.next = 8;
1998
+ _context20.next = 8;
1961
1999
  break;
1962
2000
  }
1963
2001
  writeMethod = 'update';
1964
- _context19.next = 6;
2002
+ _context20.next = 6;
1965
2003
  return _this15.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
1966
2004
  case 6:
1967
- _context19.next = 18;
2005
+ _context20.next = 18;
1968
2006
  break;
1969
2007
  case 8:
1970
2008
  if (!(typeof _this15.dbManager.bulkUpdate === 'function')) {
1971
- _context19.next = 14;
2009
+ _context20.next = 14;
1972
2010
  break;
1973
2011
  }
1974
2012
  writeMethod = 'bulkUpdate';
1975
- _context19.next = 12;
2013
+ _context20.next = 12;
1976
2014
  return _this15.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
1977
2015
  case 12:
1978
- _context19.next = 18;
2016
+ _context20.next = 18;
1979
2017
  break;
1980
2018
  case 14:
1981
2019
  if (!(typeof _this15.dbManager.bulkAdd === 'function')) {
1982
- _context19.next = 18;
2020
+ _context20.next = 18;
1983
2021
  break;
1984
2022
  }
1985
2023
  writeMethod = 'bulkAdd';
1986
- _context19.next = 18;
2024
+ _context20.next = 18;
1987
2025
  return _this15.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
1988
2026
  case 18:
1989
2027
  _this15.recordRecentSqliteWrite(source, [orderSnapshot]);
@@ -1994,25 +2032,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1994
2032
  });
1995
2033
  case 20:
1996
2034
  case "end":
1997
- return _context19.stop();
2035
+ return _context20.stop();
1998
2036
  }
1999
- }, _callee19);
2037
+ }, _callee20);
2000
2038
  })));
2001
2039
  case 6:
2002
- _context20.next = 11;
2040
+ _context21.next = 11;
2003
2041
  break;
2004
2042
  case 8:
2005
- _context20.prev = 8;
2006
- _context20.t0 = _context20["catch"](3);
2043
+ _context21.prev = 8;
2044
+ _context21.t0 = _context21["catch"](3);
2007
2045
  this.logError('单条保存订单到 SQLite 失败', {
2008
- error: _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0),
2046
+ error: _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0),
2009
2047
  orderId: (_orderSnapshot$order_3 = orderSnapshot.order_id) !== null && _orderSnapshot$order_3 !== void 0 ? _orderSnapshot$order_3 : null
2010
2048
  });
2011
2049
  case 11:
2012
2050
  case "end":
2013
- return _context20.stop();
2051
+ return _context21.stop();
2014
2052
  }
2015
- }, _callee20, this, [[3, 8]]);
2053
+ }, _callee21, this, [[3, 8]]);
2016
2054
  }));
2017
2055
  function updateOrderInSQLite(_x13, _x14) {
2018
2056
  return _updateOrderInSQLite.apply(this, arguments);
@@ -2029,40 +2067,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2029
2067
  }, {
2030
2068
  key: "replaceOrdersSnapshotInSQLite",
2031
2069
  value: (function () {
2032
- var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(orderList, source) {
2070
+ var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(orderList, source) {
2033
2071
  var _this16 = this;
2034
2072
  var remoteSnapshot;
2035
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2036
- while (1) switch (_context22.prev = _context22.next) {
2073
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2074
+ while (1) switch (_context23.prev = _context23.next) {
2037
2075
  case 0:
2038
2076
  if (this.dbManager) {
2039
- _context22.next = 2;
2077
+ _context23.next = 2;
2040
2078
  break;
2041
2079
  }
2042
- return _context22.abrupt("return");
2080
+ return _context23.abrupt("return");
2043
2081
  case 2:
2044
2082
  remoteSnapshot = cloneDeep(orderList);
2045
- _context22.prev = 3;
2046
- _context22.next = 6;
2047
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2083
+ _context23.prev = 3;
2084
+ _context23.next = 6;
2085
+ return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2048
2086
  var existingOrders, orderListSnapshot;
2049
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2050
- while (1) switch (_context21.prev = _context21.next) {
2087
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2088
+ while (1) switch (_context22.prev = _context22.next) {
2051
2089
  case 0:
2052
2090
  if (!(typeof _this16.dbManager.getAll === 'function')) {
2053
- _context21.next = 6;
2091
+ _context22.next = 6;
2054
2092
  break;
2055
2093
  }
2056
- _context21.next = 3;
2094
+ _context22.next = 3;
2057
2095
  return _this16.dbManager.getAll(INDEXDB_STORE_NAME);
2058
2096
  case 3:
2059
- _context21.t0 = _context21.sent;
2060
- _context21.next = 7;
2097
+ _context22.t0 = _context22.sent;
2098
+ _context22.next = 7;
2061
2099
  break;
2062
2100
  case 6:
2063
- _context21.t0 = [];
2101
+ _context22.t0 = [];
2064
2102
  case 7:
2065
- existingOrders = _context21.t0;
2103
+ existingOrders = _context22.t0;
2066
2104
  orderListSnapshot = _this16.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, existingOrders || []);
2067
2105
  _this16.logInfo('replaceOrdersSnapshotInSQLite-开始', {
2068
2106
  source: source,
@@ -2070,19 +2108,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2070
2108
  remoteCount: remoteSnapshot.length,
2071
2109
  preservedPendingCount: orderListSnapshot.length - remoteSnapshot.length
2072
2110
  });
2073
- _context21.next = 12;
2111
+ _context22.next = 12;
2074
2112
  return _this16.dbManager.clear(INDEXDB_STORE_NAME);
2075
2113
  case 12:
2076
2114
  _this16.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
2077
2115
  count: orderListSnapshot.length
2078
2116
  });
2079
2117
  if (!(orderListSnapshot.length === 0)) {
2080
- _context21.next = 15;
2118
+ _context22.next = 15;
2081
2119
  break;
2082
2120
  }
2083
- return _context21.abrupt("return");
2121
+ return _context22.abrupt("return");
2084
2122
  case 15:
2085
- _context21.next = 17;
2123
+ _context22.next = 17;
2086
2124
  return _this16.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderListSnapshot);
2087
2125
  case 17:
2088
2126
  _this16.recordRecentSqliteWrite(source, orderListSnapshot);
@@ -2092,25 +2130,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2092
2130
  });
2093
2131
  case 19:
2094
2132
  case "end":
2095
- return _context21.stop();
2133
+ return _context22.stop();
2096
2134
  }
2097
- }, _callee21);
2135
+ }, _callee22);
2098
2136
  })));
2099
2137
  case 6:
2100
- _context22.next = 11;
2138
+ _context23.next = 11;
2101
2139
  break;
2102
2140
  case 8:
2103
- _context22.prev = 8;
2104
- _context22.t0 = _context22["catch"](3);
2141
+ _context23.prev = 8;
2142
+ _context23.t0 = _context23["catch"](3);
2105
2143
  this.logError('全量保存订单到 SQLite 失败', {
2106
- error: _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0),
2144
+ error: _context23.t0 instanceof Error ? _context23.t0.message : String(_context23.t0),
2107
2145
  orderList: remoteSnapshot.length
2108
2146
  });
2109
2147
  case 11:
2110
2148
  case "end":
2111
- return _context22.stop();
2149
+ return _context23.stop();
2112
2150
  }
2113
- }, _callee22, this, [[3, 8]]);
2151
+ }, _callee23, this, [[3, 8]]);
2114
2152
  }));
2115
2153
  function replaceOrdersSnapshotInSQLite(_x15, _x16) {
2116
2154
  return _replaceOrdersSnapshotInSQLite.apply(this, arguments);
@@ -2127,39 +2165,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2127
2165
  }, {
2128
2166
  key: "clear",
2129
2167
  value: (function () {
2130
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2168
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2131
2169
  var _this17 = this;
2132
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2133
- while (1) switch (_context24.prev = _context24.next) {
2170
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2171
+ while (1) switch (_context25.prev = _context25.next) {
2134
2172
  case 0:
2135
2173
  this.store.list = [];
2136
2174
  this.store.map = new Map();
2137
2175
  this.resourceIdIndex.clear();
2138
2176
  if (!this.dbManager) {
2139
- _context24.next = 6;
2177
+ _context25.next = 6;
2140
2178
  break;
2141
2179
  }
2142
- _context24.next = 6;
2143
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2144
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2145
- while (1) switch (_context23.prev = _context23.next) {
2180
+ _context25.next = 6;
2181
+ return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2182
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2183
+ while (1) switch (_context24.prev = _context24.next) {
2146
2184
  case 0:
2147
- _context23.next = 2;
2185
+ _context24.next = 2;
2148
2186
  return _this17.dbManager.clear(INDEXDB_STORE_NAME);
2149
2187
  case 2:
2150
2188
  case "end":
2151
- return _context23.stop();
2189
+ return _context24.stop();
2152
2190
  }
2153
- }, _callee23);
2191
+ }, _callee24);
2154
2192
  })));
2155
2193
  case 6:
2156
2194
  this.setStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY, '');
2157
- this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
2195
+ this.emitOrdersChanged([], 'clear');
2158
2196
  case 8:
2159
2197
  case "end":
2160
- return _context24.stop();
2198
+ return _context25.stop();
2161
2199
  }
2162
- }, _callee24, this);
2200
+ }, _callee25, this);
2163
2201
  }));
2164
2202
  function clear() {
2165
2203
  return _clear.apply(this, arguments);