@pisell/pisellos 2.2.197 → 2.2.199

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 (45) hide show
  1. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +7 -3
  2. package/dist/modules/Cart/utils/cartProduct.js +11 -1
  3. package/dist/modules/Cart/utils/changePrice.js +11 -11
  4. package/dist/modules/Order/index.d.ts +16 -0
  5. package/dist/modules/Order/index.js +1232 -568
  6. package/dist/modules/Order/types.d.ts +1 -0
  7. package/dist/modules/Order/utils.d.ts +33 -2
  8. package/dist/modules/Order/utils.js +112 -55
  9. package/dist/modules/Payment/walletpass.js +14 -7
  10. package/dist/modules/SalesSummary/utils.js +394 -149
  11. package/dist/server/index.d.ts +3 -0
  12. package/dist/server/index.js +294 -190
  13. package/dist/server/modules/order/index.d.ts +8 -0
  14. package/dist/server/modules/order/index.js +536 -317
  15. package/dist/server/modules/order/types.d.ts +2 -0
  16. package/dist/solution/BaseSales/index.js +2 -1
  17. package/dist/solution/BaseSales/types.d.ts +1 -0
  18. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +19 -4
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/dist/solution/ScanOrder/types.d.ts +1 -0
  21. package/dist/solution/ScanOrder/utils.js +26 -9
  22. package/dist/solution/VenueBooking/index.js +2 -1
  23. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -1
  24. package/lib/modules/Cart/utils/cartProduct.js +11 -1
  25. package/lib/modules/Cart/utils/changePrice.js +12 -20
  26. package/lib/modules/Order/index.d.ts +16 -0
  27. package/lib/modules/Order/index.js +525 -18
  28. package/lib/modules/Order/types.d.ts +1 -0
  29. package/lib/modules/Order/utils.d.ts +33 -2
  30. package/lib/modules/Order/utils.js +44 -9
  31. package/lib/modules/Payment/walletpass.js +7 -3
  32. package/lib/modules/SalesSummary/utils.js +256 -46
  33. package/lib/server/index.d.ts +3 -0
  34. package/lib/server/index.js +82 -3
  35. package/lib/server/modules/order/index.d.ts +8 -0
  36. package/lib/server/modules/order/index.js +106 -4
  37. package/lib/server/modules/order/types.d.ts +2 -0
  38. package/lib/solution/BaseSales/index.js +2 -1
  39. package/lib/solution/BaseSales/types.d.ts +1 -0
  40. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +15 -1
  41. package/lib/solution/BookingByStep/index.d.ts +1 -1
  42. package/lib/solution/ScanOrder/types.d.ts +1 -0
  43. package/lib/solution/ScanOrder/utils.js +28 -10
  44. package/lib/solution/VenueBooking/index.js +2 -1
  45. package/package.json +1 -1
@@ -1,6 +1,10 @@
1
1
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
2
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
4
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
9
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
10
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -43,7 +47,7 @@ var ORDER_SQLITE_DEDUPE_MS = 15000;
43
47
  /** silentRefresh 最小间隔,避免 preload 后立即全量重拉 */
44
48
  var ORDER_SILENT_REFRESH_MIN_INTERVAL_MS = 30000;
45
49
  /** 视为「业务侧刚写入」的来源,pubsub 回声可跳过 SQLite */
46
- var ORDER_BUSINESS_WRITE_SOURCES = new Set(['upsertOrdersFromRemote', 'overwriteExistingOrder']);
50
+ var ORDER_BUSINESS_WRITE_SOURCES = new Set(['upsertOrdersFromRemote', 'upsertPendingSyncOrders', 'overwriteExistingOrder']);
47
51
 
48
52
  /**
49
53
  * Order 模块 - 基础框架
@@ -795,6 +799,115 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
795
799
  }
796
800
  return upsertOrdersFromRemote;
797
801
  }()
802
+ /**
803
+ * 将本地待同步订单按 SQLite storage key 合并进 store 并落库。
804
+ * checkout 离线兜底可能没有 order_id,但通常会有 external_sale_number。
805
+ */
806
+ )
807
+ }, {
808
+ key: "upsertPendingSyncOrders",
809
+ value: (function () {
810
+ var _upsertPendingSyncOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(pendingOrders) {
811
+ var _this6 = this;
812
+ 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) {
815
+ case 0:
816
+ if (pendingOrders !== null && pendingOrders !== void 0 && pendingOrders.length) {
817
+ _context9.next = 3;
818
+ break;
819
+ }
820
+ this.logInfo('upsertPendingSyncOrders-订单列表为空', {});
821
+ return _context9.abrupt("return");
822
+ case 3:
823
+ pendingMap = new Map();
824
+ _iterator4 = _createForOfIteratorHelper(pendingOrders);
825
+ _context9.prev = 5;
826
+ _iterator4.s();
827
+ case 7:
828
+ if ((_step4 = _iterator4.n()).done) {
829
+ _context9.next = 15;
830
+ break;
831
+ }
832
+ order = _step4.value;
833
+ storageKey = this.getOrderStorageKey(order);
834
+ if (storageKey) {
835
+ _context9.next = 12;
836
+ break;
837
+ }
838
+ return _context9.abrupt("continue", 13);
839
+ case 12:
840
+ pendingMap.set(storageKey, order);
841
+ case 13:
842
+ _context9.next = 7;
843
+ break;
844
+ case 15:
845
+ _context9.next = 20;
846
+ break;
847
+ case 17:
848
+ _context9.prev = 17;
849
+ _context9.t0 = _context9["catch"](5);
850
+ _iterator4.e(_context9.t0);
851
+ case 20:
852
+ _context9.prev = 20;
853
+ _iterator4.f();
854
+ return _context9.finish(20);
855
+ case 23:
856
+ if (!(pendingMap.size === 0)) {
857
+ _context9.next = 26;
858
+ break;
859
+ }
860
+ this.logError('upsertPendingSyncOrders-订单缺少可落库标识', {
861
+ count: pendingOrders.length
862
+ });
863
+ return _context9.abrupt("return");
864
+ case 26:
865
+ this.logInfo('upsertPendingSyncOrders-开始', {
866
+ count: pendingMap.size
867
+ });
868
+ patchedOrders = _toConsumableArray(pendingMap.values());
869
+ mergeActions = {};
870
+ updatedList = this.store.list.map(function (order) {
871
+ var storageKey = _this6.getOrderStorageKey(order);
872
+ if (!storageKey || !pendingMap.has(storageKey)) return order;
873
+ var pendingOrder = pendingMap.get(storageKey);
874
+ pendingMap.delete(storageKey);
875
+ mergeActions[storageKey] = 'update';
876
+ return pendingOrder;
877
+ });
878
+ _iterator5 = _createForOfIteratorHelper(pendingMap.entries());
879
+ try {
880
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
881
+ _step5$value = _slicedToArray(_step5.value, 2), _storageKey = _step5$value[0], _order = _step5$value[1];
882
+ mergeActions[_storageKey] = 'insert';
883
+ updatedList.push(_order);
884
+ }
885
+ } catch (err) {
886
+ _iterator5.e(err);
887
+ } finally {
888
+ _iterator5.f();
889
+ }
890
+ this.store.list = updatedList;
891
+ this.syncOrdersMap();
892
+ _context9.next = 36;
893
+ return this.patchOrdersInSQLite(patchedOrders, 'upsertPendingSyncOrders', mergeActions);
894
+ case 36:
895
+ this.logInfo('upsertPendingSyncOrders-结束', {
896
+ count: patchedOrders.length,
897
+ storeOrderCountAfter: this.store.list.length
898
+ });
899
+ this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
900
+ case 38:
901
+ case "end":
902
+ return _context9.stop();
903
+ }
904
+ }, _callee9, this, [[5, 17, 20, 23]]);
905
+ }));
906
+ function upsertPendingSyncOrders(_x6) {
907
+ return _upsertPendingSyncOrders.apply(this, arguments);
908
+ }
909
+ return upsertPendingSyncOrders;
910
+ }()
798
911
  /**
799
912
  * 通过 SSE 按自定义 query 拉取订单(支持 select/with 精简字段)
800
913
  */
@@ -802,42 +915,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
802
915
  }, {
803
916
  key: "fetchOrdersBySSE",
804
917
  value: (function () {
805
- var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
918
+ var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
806
919
  var query,
807
920
  data,
808
- _args9 = arguments;
809
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
810
- while (1) switch (_context9.prev = _context9.next) {
921
+ _args10 = arguments;
922
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
923
+ while (1) switch (_context10.prev = _context10.next) {
811
924
  case 0:
812
- query = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
925
+ query = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
813
926
  if (this.orderDataSource) {
814
- _context9.next = 3;
927
+ _context10.next = 3;
815
928
  break;
816
929
  }
817
- return _context9.abrupt("return", []);
930
+ return _context10.abrupt("return", []);
818
931
  case 3:
819
- _context9.prev = 3;
820
- _context9.next = 6;
932
+ _context10.prev = 3;
933
+ _context10.next = 6;
821
934
  return this.orderDataSource.run({
822
935
  sse: {
823
936
  query: query
824
937
  }
825
938
  });
826
939
  case 6:
827
- data = _context9.sent;
828
- return _context9.abrupt("return", data || []);
940
+ data = _context10.sent;
941
+ return _context10.abrupt("return", data || []);
829
942
  case 10:
830
- _context9.prev = 10;
831
- _context9.t0 = _context9["catch"](3);
943
+ _context10.prev = 10;
944
+ _context10.t0 = _context10["catch"](3);
832
945
  this.logError('fetchOrdersBySSE-失败', {
833
- error: _context9.t0 instanceof Error ? _context9.t0.message : String(_context9.t0)
946
+ error: _context10.t0 instanceof Error ? _context10.t0.message : String(_context10.t0)
834
947
  });
835
- return _context9.abrupt("return", []);
948
+ return _context10.abrupt("return", []);
836
949
  case 14:
837
950
  case "end":
838
- return _context9.stop();
951
+ return _context10.stop();
839
952
  }
840
- }, _callee9, this, [[3, 10]]);
953
+ }, _callee10, this, [[3, 10]]);
841
954
  }));
842
955
  function fetchOrdersBySSE() {
843
956
  return _fetchOrdersBySSE.apply(this, arguments);
@@ -865,44 +978,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
865
978
  }, {
866
979
  key: "syncOrdersMap",
867
980
  value: function syncOrdersMap() {
868
- var _this6 = this;
981
+ var _this7 = this;
869
982
  this.store.map.clear();
870
983
  this.resourceIdIndex.clear();
871
- var _iterator4 = _createForOfIteratorHelper(this.store.list),
872
- _step4;
984
+ var _iterator6 = _createForOfIteratorHelper(this.store.list),
985
+ _step6;
873
986
  try {
874
987
  var _loop = function _loop() {
875
- var order = _step4.value;
988
+ var order = _step6.value;
876
989
  var id = order.order_id;
877
990
  if (id === undefined || id === null) return 1; // continue
878
- _this6.store.map.set(_this6.getIdKey(id), order);
879
- var resourceIds = _this6.extractResourceIds(order);
880
- var _iterator5 = _createForOfIteratorHelper(resourceIds),
881
- _step5;
991
+ _this7.store.map.set(_this7.getIdKey(id), order);
992
+ var resourceIds = _this7.extractResourceIds(order);
993
+ var _iterator7 = _createForOfIteratorHelper(resourceIds),
994
+ _step7;
882
995
  try {
883
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
884
- var resourceId = _step5.value;
996
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
997
+ var resourceId = _step7.value;
885
998
  var key = String(resourceId);
886
- var existing = _this6.resourceIdIndex.get(key) || [];
999
+ var existing = _this7.resourceIdIndex.get(key) || [];
887
1000
  if (existing.some(function (eid) {
888
- return _this6.getIdKey(eid) === _this6.getIdKey(id);
1001
+ return _this7.getIdKey(eid) === _this7.getIdKey(id);
889
1002
  })) continue;
890
1003
  existing.push(id);
891
- _this6.resourceIdIndex.set(key, existing);
1004
+ _this7.resourceIdIndex.set(key, existing);
892
1005
  }
893
1006
  } catch (err) {
894
- _iterator5.e(err);
1007
+ _iterator7.e(err);
895
1008
  } finally {
896
- _iterator5.f();
1009
+ _iterator7.f();
897
1010
  }
898
1011
  };
899
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1012
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
900
1013
  if (_loop()) continue;
901
1014
  }
902
1015
  } catch (err) {
903
- _iterator4.e(err);
1016
+ _iterator6.e(err);
904
1017
  } finally {
905
- _iterator4.f();
1018
+ _iterator6.f();
906
1019
  }
907
1020
  }
908
1021
  }, {
@@ -957,7 +1070,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
957
1070
  }, {
958
1071
  key: "setupOrderSync",
959
1072
  value: function setupOrderSync() {
960
- var _this7 = this;
1073
+ var _this8 = this;
961
1074
  if (!this.orderDataSource) return;
962
1075
  this.orderDataSource.run({
963
1076
  pubsub: {
@@ -965,21 +1078,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
965
1078
  var _message$id, _message$order_id, _message$type;
966
1079
  console.log('orderDataSource', res);
967
1080
  var pubsubReceivedAt = Date.now();
968
- var message = _this7.normalizeOrderSyncMessage(res);
1081
+ var message = _this8.normalizeOrderSyncMessage(res);
969
1082
  if (!message) return;
970
1083
  message._pubsubReceivedAt = pubsubReceivedAt;
971
- _this7.pendingSyncMessages.push(message);
972
- var throttleMs = _this7.getOrderSyncThrottleMs();
973
- var routeInfo = _this7.resolveSyncMessageRoute(message);
974
- _this7.logInfo('orderSync-收到消息并入队', {
1084
+ _this8.pendingSyncMessages.push(message);
1085
+ var throttleMs = _this8.getOrderSyncThrottleMs();
1086
+ var routeInfo = _this8.resolveSyncMessageRoute(message);
1087
+ _this8.logInfo('orderSync-收到消息并入队', {
975
1088
  id: (_message$id = message.id) !== null && _message$id !== void 0 ? _message$id : null,
976
1089
  order_id: (_message$order_id = message.order_id) !== null && _message$order_id !== void 0 ? _message$order_id : null,
977
1090
  type: (_message$type = message.type) !== null && _message$type !== void 0 ? _message$type : null,
978
- pendingCount: _this7.pendingSyncMessages.length,
1091
+ pendingCount: _this8.pendingSyncMessages.length,
979
1092
  throttleMs: throttleMs,
980
1093
  pubsubReceivedAt: new Date(pubsubReceivedAt).toISOString()
981
1094
  });
982
- _this7.scheduleOrderSyncThrottle();
1095
+ _this8.scheduleOrderSyncThrottle();
983
1096
  }
984
1097
  }
985
1098
  }).catch(function () {
@@ -996,7 +1109,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
996
1109
  }, {
997
1110
  key: "scheduleOrderSyncThrottle",
998
1111
  value: function scheduleOrderSyncThrottle() {
999
- var _this8 = this;
1112
+ var _this9 = this;
1000
1113
  if (this.isProcessingSyncBatch) return;
1001
1114
  if (this.isIdlePhase) {
1002
1115
  this.isIdlePhase = false;
@@ -1007,8 +1120,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1007
1120
  if (this.syncTimer) return;
1008
1121
  var throttleMs = this.getOrderSyncThrottleMs();
1009
1122
  this.syncTimer = setTimeout(function () {
1010
- _this8.syncTimer = undefined;
1011
- void _this8.flushOrderSyncMessagesByThrottle();
1123
+ _this9.syncTimer = undefined;
1124
+ void _this9.flushOrderSyncMessagesByThrottle();
1012
1125
  }, throttleMs);
1013
1126
  }
1014
1127
 
@@ -1019,41 +1132,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1019
1132
  }, {
1020
1133
  key: "flushOrderSyncMessagesByThrottle",
1021
1134
  value: (function () {
1022
- var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1023
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1024
- while (1) switch (_context10.prev = _context10.next) {
1135
+ var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1136
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1137
+ while (1) switch (_context11.prev = _context11.next) {
1025
1138
  case 0:
1026
1139
  if (!this.isProcessingSyncBatch) {
1027
- _context10.next = 2;
1140
+ _context11.next = 2;
1028
1141
  break;
1029
1142
  }
1030
- return _context10.abrupt("return");
1143
+ return _context11.abrupt("return");
1031
1144
  case 2:
1032
1145
  if (!(this.pendingSyncMessages.length === 0)) {
1033
- _context10.next = 5;
1146
+ _context11.next = 5;
1034
1147
  break;
1035
1148
  }
1036
1149
  this.isIdlePhase = true;
1037
- return _context10.abrupt("return");
1150
+ return _context11.abrupt("return");
1038
1151
  case 5:
1039
1152
  this.isProcessingSyncBatch = true;
1040
- _context10.prev = 6;
1041
- _context10.next = 9;
1153
+ _context11.prev = 6;
1154
+ _context11.next = 9;
1042
1155
  return this.processOrderSyncMessages();
1043
1156
  case 9:
1044
- _context10.prev = 9;
1157
+ _context11.prev = 9;
1045
1158
  this.isProcessingSyncBatch = false;
1046
1159
  if (this.pendingSyncMessages.length > 0) {
1047
1160
  this.scheduleOrderSyncThrottle();
1048
1161
  } else {
1049
1162
  this.isIdlePhase = true;
1050
1163
  }
1051
- return _context10.finish(9);
1164
+ return _context11.finish(9);
1052
1165
  case 13:
1053
1166
  case "end":
1054
- return _context10.stop();
1167
+ return _context11.stop();
1055
1168
  }
1056
- }, _callee10, this, [[6,, 9, 13]]);
1169
+ }, _callee11, this, [[6,, 9, 13]]);
1057
1170
  }));
1058
1171
  function flushOrderSyncMessagesByThrottle() {
1059
1172
  return _flushOrderSyncMessagesByThrottle.apply(this, arguments);
@@ -1075,19 +1188,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1075
1188
  }, {
1076
1189
  key: "processOrderSyncMessages",
1077
1190
  value: (function () {
1078
- var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1079
- var _this9 = this;
1191
+ var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
1192
+ var _this10 = this;
1080
1193
  var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, uniqueRefreshIds, upsertList, _this$filterRedundant, toFetch, skipped, freshOrders, batchProcessEndAt;
1081
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1082
- while (1) switch (_context11.prev = _context11.next) {
1194
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1195
+ while (1) switch (_context12.prev = _context12.next) {
1083
1196
  case 0:
1084
1197
  messages = _toConsumableArray(this.pendingSyncMessages);
1085
1198
  this.pendingSyncMessages = [];
1086
1199
  if (!(messages.length === 0)) {
1087
- _context11.next = 4;
1200
+ _context12.next = 4;
1088
1201
  break;
1089
1202
  }
1090
- return _context11.abrupt("return");
1203
+ return _context12.abrupt("return");
1091
1204
  case 4:
1092
1205
  batchProcessStartAt = Date.now();
1093
1206
  earliestReceivedAt = Math.min.apply(Math, _toConsumableArray(messages.map(function (m) {
@@ -1103,13 +1216,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1103
1216
  upsertOrders = new Map();
1104
1217
  refreshIds = [];
1105
1218
  messages.forEach(function (msg, msgIndex) {
1106
- var routeInfo = _this9.resolveSyncMessageRoute(msg);
1219
+ var routeInfo = _this10.resolveSyncMessageRoute(msg);
1107
1220
  var hasBatchIds = routeInfo.hasBatchIds;
1108
1221
  var singleId = routeInfo.singleId;
1109
1222
  var hasSingleId = routeInfo.hasSingleId;
1110
- var normalizedBody = _this9.normalizeOrderSyncPayload(msg.body || msg.data);
1223
+ var normalizedBody = _this10.normalizeOrderSyncPayload(msg.body || msg.data);
1111
1224
  if (routeInfo.route === 'bodyUpsert' && normalizedBody) {
1112
- upsertOrders.set(_this9.getIdKey(normalizedBody.order_id), normalizedBody);
1225
+ upsertOrders.set(_this10.getIdKey(normalizedBody.order_id), normalizedBody);
1113
1226
  return;
1114
1227
  }
1115
1228
  if (hasBatchIds) refreshIds.push.apply(refreshIds, _toConsumableArray(routeInfo.batchIds));else if (routeInfo.route === 'httpRefresh.singleId' && singleId !== null) refreshIds.push(singleId);else if (routeInfo.route === 'httpRefresh.relationIds') refreshIds.push.apply(refreshIds, _toConsumableArray(routeInfo.batchIds));
@@ -1121,41 +1234,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1121
1234
  refreshIdCount: uniqueRefreshIds.length
1122
1235
  });
1123
1236
  if (!(upsertList.length > 0)) {
1124
- _context11.next = 16;
1237
+ _context12.next = 16;
1125
1238
  break;
1126
1239
  }
1127
- _context11.next = 16;
1240
+ _context12.next = 16;
1128
1241
  return this.mergeOrdersToStore(upsertList, 'pubsub.bodyUpsert');
1129
1242
  case 16:
1130
1243
  if (!(uniqueRefreshIds.length > 0)) {
1131
- _context11.next = 28;
1244
+ _context12.next = 28;
1132
1245
  break;
1133
1246
  }
1134
1247
  _this$filterRedundant = this.filterRedundantHttpRefreshIds(uniqueRefreshIds), toFetch = _this$filterRedundant.toFetch, skipped = _this$filterRedundant.skipped;
1135
1248
  if (skipped.length > 0) {}
1136
1249
  if (!(toFetch.length > 0)) {
1137
- _context11.next = 28;
1250
+ _context12.next = 28;
1138
1251
  break;
1139
1252
  }
1140
- _context11.next = 22;
1253
+ _context12.next = 22;
1141
1254
  return this.fetchOrdersByHttp(toFetch);
1142
1255
  case 22:
1143
- freshOrders = _context11.sent;
1256
+ freshOrders = _context12.sent;
1144
1257
  if (!(freshOrders.length > 0)) {
1145
- _context11.next = 28;
1258
+ _context12.next = 28;
1146
1259
  break;
1147
1260
  }
1148
- _context11.next = 26;
1261
+ _context12.next = 26;
1149
1262
  return this.mergeOrdersToStore(freshOrders, 'pubsub.httpRefresh');
1150
1263
  case 26:
1151
- _context11.next = 28;
1264
+ _context12.next = 28;
1152
1265
  break;
1153
1266
  case 28:
1154
1267
  if (!(upsertList.length === 0 && uniqueRefreshIds.length === 0)) {
1155
- _context11.next = 30;
1268
+ _context12.next = 30;
1156
1269
  break;
1157
1270
  }
1158
- return _context11.abrupt("return");
1271
+ return _context12.abrupt("return");
1159
1272
  case 30:
1160
1273
  batchProcessEndAt = Date.now();
1161
1274
  this.logInfo('processOrderSyncMessages-结束', {
@@ -1164,13 +1277,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1164
1277
  batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt,
1165
1278
  totalFromPubsubToProcessedMs: batchProcessEndAt - earliestReceivedAt
1166
1279
  });
1167
- _context11.next = 34;
1280
+ _context12.next = 34;
1168
1281
  return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
1169
1282
  case 34:
1170
1283
  case "end":
1171
- return _context11.stop();
1284
+ return _context12.stop();
1172
1285
  }
1173
- }, _callee11, this);
1286
+ }, _callee12, this);
1174
1287
  }));
1175
1288
  function processOrderSyncMessages() {
1176
1289
  return _processOrderSyncMessages.apply(this, arguments);
@@ -1191,29 +1304,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1191
1304
  }, {
1192
1305
  key: "fetchOrdersByHttp",
1193
1306
  value: (function () {
1194
- var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(ids) {
1307
+ var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(ids) {
1195
1308
  var _orderList, orderList;
1196
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1197
- while (1) switch (_context12.prev = _context12.next) {
1309
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1310
+ while (1) switch (_context13.prev = _context13.next) {
1198
1311
  case 0:
1199
1312
  if (!(!this.orderDataSource || ids.length === 0)) {
1200
- _context12.next = 2;
1313
+ _context13.next = 2;
1201
1314
  break;
1202
1315
  }
1203
- return _context12.abrupt("return", []);
1316
+ return _context13.abrupt("return", []);
1204
1317
  case 2:
1205
- _context12.prev = 2;
1318
+ _context13.prev = 2;
1206
1319
  if (!(typeof this.orderDataSource.fetchOrdersByIds === 'function')) {
1207
- _context12.next = 8;
1320
+ _context13.next = 8;
1208
1321
  break;
1209
1322
  }
1210
- _context12.next = 6;
1323
+ _context13.next = 6;
1211
1324
  return this.orderDataSource.fetchOrdersByIds(ids);
1212
1325
  case 6:
1213
- _orderList = _context12.sent;
1214
- return _context12.abrupt("return", _orderList || []);
1326
+ _orderList = _context13.sent;
1327
+ return _context13.abrupt("return", _orderList || []);
1215
1328
  case 8:
1216
- _context12.next = 10;
1329
+ _context13.next = 10;
1217
1330
  return this.orderDataSource.run({
1218
1331
  http: {
1219
1332
  query: {
@@ -1222,19 +1335,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1222
1335
  }
1223
1336
  });
1224
1337
  case 10:
1225
- orderList = _context12.sent;
1226
- return _context12.abrupt("return", orderList || []);
1338
+ orderList = _context13.sent;
1339
+ return _context13.abrupt("return", orderList || []);
1227
1340
  case 14:
1228
- _context12.prev = 14;
1229
- _context12.t0 = _context12["catch"](2);
1230
- return _context12.abrupt("return", []);
1341
+ _context13.prev = 14;
1342
+ _context13.t0 = _context13["catch"](2);
1343
+ return _context13.abrupt("return", []);
1231
1344
  case 17:
1232
1345
  case "end":
1233
- return _context12.stop();
1346
+ return _context13.stop();
1234
1347
  }
1235
- }, _callee12, this, [[2, 14]]);
1348
+ }, _callee13, this, [[2, 14]]);
1236
1349
  }));
1237
- function fetchOrdersByHttp(_x6) {
1350
+ function fetchOrdersByHttp(_x7) {
1238
1351
  return _fetchOrdersByHttp.apply(this, arguments);
1239
1352
  }
1240
1353
  return fetchOrdersByHttp;
@@ -1246,76 +1359,122 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1246
1359
  }, {
1247
1360
  key: "mergeOrdersToStore",
1248
1361
  value: (function () {
1249
- var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(freshOrders, source) {
1250
- var _this10 = this;
1251
- var freshMap, _iterator6, _step6, order, id, uniqueFreshCount, patchedOrders, mergeActions, updatedList, _iterator7, _step7, _order, _id, insertCount, updateCount;
1252
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1253
- while (1) switch (_context13.prev = _context13.next) {
1362
+ var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(freshOrders, source) {
1363
+ var _this11 = this;
1364
+ 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) {
1254
1367
  case 0:
1255
1368
  this.logInfo('mergeOrdersToStore-开始', {
1256
1369
  freshOrderCount: freshOrders.length,
1257
1370
  storeOrderCountBefore: this.store.list.length
1258
1371
  });
1259
1372
  freshMap = new Map();
1260
- _iterator6 = _createForOfIteratorHelper(freshOrders);
1261
- _context13.prev = 3;
1262
- _iterator6.s();
1373
+ _iterator8 = _createForOfIteratorHelper(freshOrders);
1374
+ _context14.prev = 3;
1375
+ _iterator8.s();
1263
1376
  case 5:
1264
- if ((_step6 = _iterator6.n()).done) {
1265
- _context13.next = 13;
1377
+ if ((_step8 = _iterator8.n()).done) {
1378
+ _context14.next = 13;
1266
1379
  break;
1267
1380
  }
1268
- order = _step6.value;
1381
+ order = _step8.value;
1269
1382
  id = order === null || order === void 0 ? void 0 : order.order_id;
1270
1383
  if (!(id === undefined || id === null)) {
1271
- _context13.next = 10;
1384
+ _context14.next = 10;
1272
1385
  break;
1273
1386
  }
1274
- return _context13.abrupt("continue", 11);
1387
+ return _context14.abrupt("continue", 11);
1275
1388
  case 10:
1276
- freshMap.set(this.getIdKey(id), order);
1389
+ freshMap.set(this.getIdKey(id), this.normalizeRemoteSyncedOrder(order));
1277
1390
  case 11:
1278
- _context13.next = 5;
1391
+ _context14.next = 5;
1279
1392
  break;
1280
1393
  case 13:
1281
- _context13.next = 18;
1394
+ _context14.next = 18;
1282
1395
  break;
1283
1396
  case 15:
1284
- _context13.prev = 15;
1285
- _context13.t0 = _context13["catch"](3);
1286
- _iterator6.e(_context13.t0);
1397
+ _context14.prev = 15;
1398
+ _context14.t0 = _context14["catch"](3);
1399
+ _iterator8.e(_context14.t0);
1287
1400
  case 18:
1288
- _context13.prev = 18;
1289
- _iterator6.f();
1290
- return _context13.finish(18);
1401
+ _context14.prev = 18;
1402
+ _iterator8.f();
1403
+ return _context14.finish(18);
1291
1404
  case 21:
1405
+ freshStorageKeyMap = new Map();
1406
+ _iterator9 = _createForOfIteratorHelper(freshMap.values());
1407
+ _context14.prev = 23;
1408
+ _iterator9.s();
1409
+ case 25:
1410
+ if ((_step9 = _iterator9.n()).done) {
1411
+ _context14.next = 33;
1412
+ break;
1413
+ }
1414
+ _order2 = _step9.value;
1415
+ storageKey = this.getOrderStorageKey(_order2);
1416
+ if (storageKey) {
1417
+ _context14.next = 30;
1418
+ break;
1419
+ }
1420
+ return _context14.abrupt("continue", 31);
1421
+ case 30:
1422
+ freshStorageKeyMap.set(storageKey, _order2);
1423
+ case 31:
1424
+ _context14.next = 25;
1425
+ break;
1426
+ case 33:
1427
+ _context14.next = 38;
1428
+ break;
1429
+ case 35:
1430
+ _context14.prev = 35;
1431
+ _context14.t1 = _context14["catch"](23);
1432
+ _iterator9.e(_context14.t1);
1433
+ case 38:
1434
+ _context14.prev = 38;
1435
+ _iterator9.f();
1436
+ return _context14.finish(38);
1437
+ case 41:
1292
1438
  uniqueFreshCount = freshMap.size;
1293
1439
  patchedOrders = _toConsumableArray(freshMap.values());
1294
1440
  mergeActions = {};
1295
1441
  updatedList = this.store.list.map(function (order) {
1442
+ var storageKey = _this11.getOrderStorageKey(order);
1443
+ if (storageKey && freshStorageKeyMap.has(storageKey)) {
1444
+ var _fresh = freshStorageKeyMap.get(storageKey);
1445
+ freshStorageKeyMap.delete(storageKey);
1446
+ var freshId = _fresh.order_id;
1447
+ if (freshId !== undefined && freshId !== null) {
1448
+ freshMap.delete(_this11.getIdKey(freshId));
1449
+ mergeActions[_this11.getIdKey(freshId)] = 'update';
1450
+ } else {
1451
+ mergeActions[storageKey] = 'update';
1452
+ }
1453
+ return _fresh;
1454
+ }
1296
1455
  var id = order.order_id;
1297
1456
  if (id === undefined || id === null) return order;
1298
- var key = _this10.getIdKey(id);
1457
+ var key = _this11.getIdKey(id);
1299
1458
  if (!freshMap.has(key)) return order;
1300
1459
  var fresh = freshMap.get(key);
1301
1460
  freshMap.delete(key);
1302
1461
  mergeActions[key] = 'update';
1303
1462
  return fresh;
1304
1463
  });
1305
- _iterator7 = _createForOfIteratorHelper(freshMap.values());
1464
+ _iterator10 = _createForOfIteratorHelper(freshMap.values());
1306
1465
  try {
1307
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
1308
- _order = _step7.value;
1309
- _id = _order.order_id;
1466
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1467
+ _order3 = _step10.value;
1468
+ _id = _order3.order_id;
1310
1469
  if (_id !== undefined && _id !== null) {
1311
1470
  mergeActions[this.getIdKey(_id)] = 'insert';
1312
1471
  }
1313
- updatedList.push(_order);
1472
+ updatedList.push(_order3);
1314
1473
  }
1315
1474
  } catch (err) {
1316
- _iterator7.e(err);
1475
+ _iterator10.e(err);
1317
1476
  } finally {
1318
- _iterator7.f();
1477
+ _iterator10.f();
1319
1478
  }
1320
1479
  insertCount = Object.values(mergeActions).filter(function (v) {
1321
1480
  return v === 'insert';
@@ -1325,21 +1484,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1325
1484
  }).length;
1326
1485
  this.store.list = updatedList;
1327
1486
  this.syncOrdersMap();
1328
- _context13.next = 33;
1487
+ _context14.next = 53;
1329
1488
  return this.patchOrdersInSQLite(patchedOrders, source, mergeActions);
1330
- case 33:
1489
+ case 53:
1331
1490
  this.logInfo('mergeOrdersToStore-结束', {
1332
1491
  uniqueFreshCount: uniqueFreshCount,
1333
1492
  storeOrderCountAfter: this.store.list.length
1334
1493
  });
1335
1494
  this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
1336
- case 35:
1495
+ case 55:
1337
1496
  case "end":
1338
- return _context13.stop();
1497
+ return _context14.stop();
1339
1498
  }
1340
- }, _callee13, this, [[3, 15, 18, 21]]);
1499
+ }, _callee14, this, [[3, 15, 18, 21], [23, 35, 38, 41]]);
1341
1500
  }));
1342
- function mergeOrdersToStore(_x7, _x8) {
1501
+ function mergeOrdersToStore(_x8, _x9) {
1343
1502
  return _mergeOrdersToStore.apply(this, arguments);
1344
1503
  }
1345
1504
  return mergeOrdersToStore;
@@ -1376,17 +1535,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1376
1535
  key: "uniqueOrderIds",
1377
1536
  value: function uniqueOrderIds(ids) {
1378
1537
  var idMap = new Map();
1379
- var _iterator8 = _createForOfIteratorHelper(ids),
1380
- _step8;
1538
+ var _iterator11 = _createForOfIteratorHelper(ids),
1539
+ _step11;
1381
1540
  try {
1382
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
1383
- var id = _step8.value;
1541
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
1542
+ var id = _step11.value;
1384
1543
  idMap.set(this.getIdKey(id), id);
1385
1544
  }
1386
1545
  } catch (err) {
1387
- _iterator8.e(err);
1546
+ _iterator11.e(err);
1388
1547
  } finally {
1389
- _iterator8.f();
1548
+ _iterator11.f();
1390
1549
  }
1391
1550
  return _toConsumableArray(idMap.values());
1392
1551
  }
@@ -1398,12 +1557,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1398
1557
  }, {
1399
1558
  key: "isOrderLookupMatch",
1400
1559
  value: function isOrderLookupMatch(order, lookupKey) {
1401
- var _this11 = this;
1560
+ var _this12 = this;
1402
1561
  if (!order || !lookupKey) return false;
1403
1562
  var candidates = [order.order_id, order.external_sale_number, order.order_number, order.shop_order_number, order.shop_full_order_number];
1404
1563
  return candidates.some(function (value) {
1405
1564
  if (value === undefined || value === null || value === '') return false;
1406
- return _this11.getIdKey(value) === lookupKey;
1565
+ return _this12.getIdKey(value) === lookupKey;
1407
1566
  });
1408
1567
  }
1409
1568
 
@@ -1508,38 +1667,80 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1508
1667
  }, {
1509
1668
  key: "loadOrdersFromSQLite",
1510
1669
  value: function () {
1511
- var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1670
+ var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1512
1671
  var orders;
1513
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1514
- while (1) switch (_context14.prev = _context14.next) {
1672
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1673
+ while (1) switch (_context15.prev = _context15.next) {
1515
1674
  case 0:
1516
1675
  if (this.dbManager) {
1517
- _context14.next = 2;
1676
+ _context15.next = 2;
1518
1677
  break;
1519
1678
  }
1520
- return _context14.abrupt("return", []);
1679
+ return _context15.abrupt("return", []);
1521
1680
  case 2:
1522
- _context14.prev = 2;
1523
- _context14.next = 5;
1681
+ _context15.prev = 2;
1682
+ _context15.next = 5;
1524
1683
  return this.dbManager.getAll(INDEXDB_STORE_NAME);
1525
1684
  case 5:
1526
- orders = _context14.sent;
1527
- return _context14.abrupt("return", orders || []);
1685
+ orders = _context15.sent;
1686
+ return _context15.abrupt("return", orders || []);
1528
1687
  case 9:
1529
- _context14.prev = 9;
1530
- _context14.t0 = _context14["catch"](2);
1531
- return _context14.abrupt("return", []);
1688
+ _context15.prev = 9;
1689
+ _context15.t0 = _context15["catch"](2);
1690
+ return _context15.abrupt("return", []);
1532
1691
  case 12:
1533
1692
  case "end":
1534
- return _context14.stop();
1693
+ return _context15.stop();
1535
1694
  }
1536
- }, _callee14, this, [[2, 9]]);
1695
+ }, _callee15, this, [[2, 9]]);
1537
1696
  }));
1538
1697
  function loadOrdersFromSQLite() {
1539
1698
  return _loadOrdersFromSQLite.apply(this, arguments);
1540
1699
  }
1541
1700
  return loadOrdersFromSQLite;
1542
1701
  }()
1702
+ }, {
1703
+ key: "isPendingSyncOrder",
1704
+ value: function isPendingSyncOrder(order) {
1705
+ return Number(order === null || order === void 0 ? void 0 : order.need_sync) === 1;
1706
+ }
1707
+ }, {
1708
+ key: "normalizeRemoteSyncedOrder",
1709
+ value: function normalizeRemoteSyncedOrder(order) {
1710
+ if (this.isPendingSyncOrder(order)) return order;
1711
+ return _objectSpread(_objectSpread({}, order), {}, {
1712
+ need_sync: 0
1713
+ });
1714
+ }
1715
+ }, {
1716
+ key: "mergeRemoteSnapshotWithPendingOrders",
1717
+ value: function mergeRemoteSnapshotWithPendingOrders(remoteOrders, existingOrders) {
1718
+ var _this13 = this;
1719
+ var merged = remoteOrders.map(function (order) {
1720
+ return _this13.normalizeRemoteSyncedOrder(order);
1721
+ });
1722
+ var remoteStorageKeys = new Set(merged.map(function (order) {
1723
+ return _this13.getOrderStorageKey(order);
1724
+ }).filter(Boolean));
1725
+ var _iterator12 = _createForOfIteratorHelper(existingOrders),
1726
+ _step12;
1727
+ try {
1728
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
1729
+ var order = _step12.value;
1730
+ if (!this.isPendingSyncOrder(order)) continue;
1731
+ var storageKey = this.getOrderStorageKey(order);
1732
+ if (!storageKey || remoteStorageKeys.has(storageKey)) continue;
1733
+ merged.push(order);
1734
+ remoteStorageKeys.add(storageKey);
1735
+ }
1736
+ } catch (err) {
1737
+ _iterator12.e(err);
1738
+ } finally {
1739
+ _iterator12.f();
1740
+ }
1741
+ return merged;
1742
+ }
1743
+
1543
1744
  /**
1544
1745
  * 串行执行订单 SQLite 写入任务,避免快照替换与增量 upsert 并发交错。
1545
1746
  *
@@ -1551,10 +1752,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1551
1752
  }, {
1552
1753
  key: "runInOrderSQLiteSaveQueue",
1553
1754
  value: (function () {
1554
- var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(task) {
1755
+ var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(task) {
1555
1756
  var queuedTask;
1556
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1557
- while (1) switch (_context15.prev = _context15.next) {
1757
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1758
+ while (1) switch (_context16.prev = _context16.next) {
1558
1759
  case 0:
1559
1760
  queuedTask = this.orderSQLiteSaveQueue.then(task, task);
1560
1761
  this.orderSQLiteSaveQueue = queuedTask.then(function () {
@@ -1562,14 +1763,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1562
1763
  }, function () {
1563
1764
  return undefined;
1564
1765
  });
1565
- return _context15.abrupt("return", queuedTask);
1766
+ return _context16.abrupt("return", queuedTask);
1566
1767
  case 3:
1567
1768
  case "end":
1568
- return _context15.stop();
1769
+ return _context16.stop();
1569
1770
  }
1570
- }, _callee15, this);
1771
+ }, _callee16, this);
1571
1772
  }));
1572
- function runInOrderSQLiteSaveQueue(_x9) {
1773
+ function runInOrderSQLiteSaveQueue(_x10) {
1573
1774
  return _runInOrderSQLiteSaveQueue.apply(this, arguments);
1574
1775
  }
1575
1776
  return runInOrderSQLiteSaveQueue;
@@ -1584,108 +1785,108 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1584
1785
  }, {
1585
1786
  key: "patchOrdersInSQLite",
1586
1787
  value: (function () {
1587
- var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orders, source) {
1588
- var _this12 = this;
1788
+ var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orders, source) {
1789
+ var _this14 = this;
1589
1790
  var mergeActions,
1590
1791
  ordersSnapshot,
1591
1792
  _this$filterRedundant2,
1592
1793
  toWrite,
1593
1794
  skipped,
1594
- _args17 = arguments;
1595
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1596
- while (1) switch (_context17.prev = _context17.next) {
1795
+ _args18 = arguments;
1796
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1797
+ while (1) switch (_context18.prev = _context18.next) {
1597
1798
  case 0:
1598
- mergeActions = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : {};
1799
+ mergeActions = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
1599
1800
  if (!(!this.dbManager || orders.length === 0)) {
1600
- _context17.next = 3;
1801
+ _context18.next = 3;
1601
1802
  break;
1602
1803
  }
1603
- return _context17.abrupt("return");
1804
+ return _context18.abrupt("return");
1604
1805
  case 3:
1605
1806
  ordersSnapshot = cloneDeep(orders).filter(function (order) {
1606
- return _this12.getOrderStorageKey(order);
1807
+ return _this14.getOrderStorageKey(order);
1607
1808
  });
1608
1809
  if (!(ordersSnapshot.length === 0)) {
1609
- _context17.next = 6;
1810
+ _context18.next = 6;
1610
1811
  break;
1611
1812
  }
1612
- return _context17.abrupt("return");
1813
+ return _context18.abrupt("return");
1613
1814
  case 6:
1614
1815
  _this$filterRedundant2 = this.filterRedundantPatchOrders(source, ordersSnapshot, mergeActions), toWrite = _this$filterRedundant2.toWrite, skipped = _this$filterRedundant2.skipped;
1615
1816
  if (!(toWrite.length === 0)) {
1616
- _context17.next = 9;
1817
+ _context18.next = 9;
1617
1818
  break;
1618
1819
  }
1619
- return _context17.abrupt("return");
1820
+ return _context18.abrupt("return");
1620
1821
  case 9:
1621
- _context17.prev = 9;
1622
- _context17.next = 12;
1623
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1624
- var writeMethod, _iterator9, _step9, order;
1625
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1626
- while (1) switch (_context16.prev = _context16.next) {
1822
+ _context18.prev = 9;
1823
+ _context18.next = 12;
1824
+ return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1825
+ var writeMethod, _iterator13, _step13, order;
1826
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1827
+ while (1) switch (_context17.prev = _context17.next) {
1627
1828
  case 0:
1628
1829
  writeMethod = 'none';
1629
- _this12.logInfo('patchOrdersInSQLite-开始', {
1830
+ _this14.logInfo('patchOrdersInSQLite-开始', {
1630
1831
  source: source,
1631
1832
  count: toWrite.length,
1632
1833
  dedupedCount: skipped.length
1633
1834
  });
1634
- if (!(typeof _this12.dbManager.bulkUpdate === 'function')) {
1635
- _context16.next = 8;
1835
+ if (!(typeof _this14.dbManager.bulkUpdate === 'function')) {
1836
+ _context17.next = 8;
1636
1837
  break;
1637
1838
  }
1638
1839
  writeMethod = 'bulkUpdate';
1639
- _context16.next = 6;
1640
- return _this12.dbManager.bulkUpdate(INDEXDB_STORE_NAME, toWrite);
1840
+ _context17.next = 6;
1841
+ return _this14.dbManager.bulkUpdate(INDEXDB_STORE_NAME, toWrite);
1641
1842
  case 6:
1642
- _context16.next = 33;
1843
+ _context17.next = 33;
1643
1844
  break;
1644
1845
  case 8:
1645
- if (!(typeof _this12.dbManager.bulkAdd === 'function')) {
1646
- _context16.next = 14;
1846
+ if (!(typeof _this14.dbManager.bulkAdd === 'function')) {
1847
+ _context17.next = 14;
1647
1848
  break;
1648
1849
  }
1649
1850
  writeMethod = 'bulkAdd';
1650
- _context16.next = 12;
1651
- return _this12.dbManager.bulkAdd(INDEXDB_STORE_NAME, toWrite);
1851
+ _context17.next = 12;
1852
+ return _this14.dbManager.bulkAdd(INDEXDB_STORE_NAME, toWrite);
1652
1853
  case 12:
1653
- _context16.next = 33;
1854
+ _context17.next = 33;
1654
1855
  break;
1655
1856
  case 14:
1656
- if (!(typeof _this12.dbManager.update === 'function')) {
1657
- _context16.next = 33;
1857
+ if (!(typeof _this14.dbManager.update === 'function')) {
1858
+ _context17.next = 33;
1658
1859
  break;
1659
1860
  }
1660
1861
  writeMethod = 'update';
1661
- _iterator9 = _createForOfIteratorHelper(toWrite);
1662
- _context16.prev = 17;
1663
- _iterator9.s();
1862
+ _iterator13 = _createForOfIteratorHelper(toWrite);
1863
+ _context17.prev = 17;
1864
+ _iterator13.s();
1664
1865
  case 19:
1665
- if ((_step9 = _iterator9.n()).done) {
1666
- _context16.next = 25;
1866
+ if ((_step13 = _iterator13.n()).done) {
1867
+ _context17.next = 25;
1667
1868
  break;
1668
1869
  }
1669
- order = _step9.value;
1670
- _context16.next = 23;
1671
- return _this12.dbManager.update(INDEXDB_STORE_NAME, order);
1870
+ order = _step13.value;
1871
+ _context17.next = 23;
1872
+ return _this14.dbManager.update(INDEXDB_STORE_NAME, order);
1672
1873
  case 23:
1673
- _context16.next = 19;
1874
+ _context17.next = 19;
1674
1875
  break;
1675
1876
  case 25:
1676
- _context16.next = 30;
1877
+ _context17.next = 30;
1677
1878
  break;
1678
1879
  case 27:
1679
- _context16.prev = 27;
1680
- _context16.t0 = _context16["catch"](17);
1681
- _iterator9.e(_context16.t0);
1880
+ _context17.prev = 27;
1881
+ _context17.t0 = _context17["catch"](17);
1882
+ _iterator13.e(_context17.t0);
1682
1883
  case 30:
1683
- _context16.prev = 30;
1684
- _iterator9.f();
1685
- return _context16.finish(30);
1884
+ _context17.prev = 30;
1885
+ _iterator13.f();
1886
+ return _context17.finish(30);
1686
1887
  case 33:
1687
- _this12.recordRecentSqliteWrite(source, toWrite);
1688
- _this12.logInfo('patchOrdersInSQLite-完成', {
1888
+ _this14.recordRecentSqliteWrite(source, toWrite);
1889
+ _this14.logInfo('patchOrdersInSQLite-完成', {
1689
1890
  source: source,
1690
1891
  count: toWrite.length,
1691
1892
  writeMethod: writeMethod,
@@ -1693,27 +1894,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1693
1894
  });
1694
1895
  case 35:
1695
1896
  case "end":
1696
- return _context16.stop();
1897
+ return _context17.stop();
1697
1898
  }
1698
- }, _callee16, null, [[17, 27, 30, 33]]);
1899
+ }, _callee17, null, [[17, 27, 30, 33]]);
1699
1900
  })));
1700
1901
  case 12:
1701
- _context17.next = 17;
1902
+ _context18.next = 17;
1702
1903
  break;
1703
1904
  case 14:
1704
- _context17.prev = 14;
1705
- _context17.t0 = _context17["catch"](9);
1905
+ _context18.prev = 14;
1906
+ _context18.t0 = _context18["catch"](9);
1706
1907
  this.logError('增量保存订单到 SQLite 失败', {
1707
- error: _context17.t0 instanceof Error ? _context17.t0.message : String(_context17.t0),
1908
+ error: _context18.t0 instanceof Error ? _context18.t0.message : String(_context18.t0),
1708
1909
  orderCount: ordersSnapshot.length
1709
1910
  });
1710
1911
  case 17:
1711
1912
  case "end":
1712
- return _context17.stop();
1913
+ return _context18.stop();
1713
1914
  }
1714
- }, _callee17, this, [[9, 14]]);
1915
+ }, _callee18, this, [[9, 14]]);
1715
1916
  }));
1716
- function patchOrdersInSQLite(_x10, _x11) {
1917
+ function patchOrdersInSQLite(_x11, _x12) {
1717
1918
  return _patchOrdersInSQLite.apply(this, arguments);
1718
1919
  }
1719
1920
  return patchOrdersInSQLite;
@@ -1728,92 +1929,92 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1728
1929
  }, {
1729
1930
  key: "updateOrderInSQLite",
1730
1931
  value: (function () {
1731
- var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(order, source) {
1732
- var _this13 = this;
1932
+ var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(order, source) {
1933
+ var _this15 = this;
1733
1934
  var orderSnapshot, _orderSnapshot$order_3;
1734
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1735
- while (1) switch (_context19.prev = _context19.next) {
1935
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1936
+ while (1) switch (_context20.prev = _context20.next) {
1736
1937
  case 0:
1737
1938
  if (!(!this.dbManager || !this.getOrderStorageKey(order))) {
1738
- _context19.next = 2;
1939
+ _context20.next = 2;
1739
1940
  break;
1740
1941
  }
1741
- return _context19.abrupt("return");
1942
+ return _context20.abrupt("return");
1742
1943
  case 2:
1743
1944
  orderSnapshot = cloneDeep(order);
1744
- _context19.prev = 3;
1745
- _context19.next = 6;
1746
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1945
+ _context20.prev = 3;
1946
+ _context20.next = 6;
1947
+ return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1747
1948
  var _orderSnapshot$order_, _orderSnapshot$order_2;
1748
1949
  var writeMethod;
1749
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1750
- while (1) switch (_context18.prev = _context18.next) {
1950
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1951
+ while (1) switch (_context19.prev = _context19.next) {
1751
1952
  case 0:
1752
1953
  writeMethod = 'none';
1753
- _this13.logInfo('updateOrderInSQLite-开始', {
1954
+ _this15.logInfo('updateOrderInSQLite-开始', {
1754
1955
  source: source,
1755
1956
  orderId: (_orderSnapshot$order_ = orderSnapshot.order_id) !== null && _orderSnapshot$order_ !== void 0 ? _orderSnapshot$order_ : null,
1756
- storageKey: _this13.getOrderStorageKey(orderSnapshot)
1957
+ storageKey: _this15.getOrderStorageKey(orderSnapshot)
1757
1958
  });
1758
- if (!(typeof _this13.dbManager.update === 'function')) {
1759
- _context18.next = 8;
1959
+ if (!(typeof _this15.dbManager.update === 'function')) {
1960
+ _context19.next = 8;
1760
1961
  break;
1761
1962
  }
1762
1963
  writeMethod = 'update';
1763
- _context18.next = 6;
1764
- return _this13.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
1964
+ _context19.next = 6;
1965
+ return _this15.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
1765
1966
  case 6:
1766
- _context18.next = 18;
1967
+ _context19.next = 18;
1767
1968
  break;
1768
1969
  case 8:
1769
- if (!(typeof _this13.dbManager.bulkUpdate === 'function')) {
1770
- _context18.next = 14;
1970
+ if (!(typeof _this15.dbManager.bulkUpdate === 'function')) {
1971
+ _context19.next = 14;
1771
1972
  break;
1772
1973
  }
1773
1974
  writeMethod = 'bulkUpdate';
1774
- _context18.next = 12;
1775
- return _this13.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
1975
+ _context19.next = 12;
1976
+ return _this15.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
1776
1977
  case 12:
1777
- _context18.next = 18;
1978
+ _context19.next = 18;
1778
1979
  break;
1779
1980
  case 14:
1780
- if (!(typeof _this13.dbManager.bulkAdd === 'function')) {
1781
- _context18.next = 18;
1981
+ if (!(typeof _this15.dbManager.bulkAdd === 'function')) {
1982
+ _context19.next = 18;
1782
1983
  break;
1783
1984
  }
1784
1985
  writeMethod = 'bulkAdd';
1785
- _context18.next = 18;
1786
- return _this13.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
1986
+ _context19.next = 18;
1987
+ return _this15.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
1787
1988
  case 18:
1788
- _this13.recordRecentSqliteWrite(source, [orderSnapshot]);
1789
- _this13.logInfo('updateOrderInSQLite-完成', {
1989
+ _this15.recordRecentSqliteWrite(source, [orderSnapshot]);
1990
+ _this15.logInfo('updateOrderInSQLite-完成', {
1790
1991
  source: source,
1791
1992
  orderId: (_orderSnapshot$order_2 = orderSnapshot.order_id) !== null && _orderSnapshot$order_2 !== void 0 ? _orderSnapshot$order_2 : null,
1792
1993
  writeMethod: writeMethod
1793
1994
  });
1794
1995
  case 20:
1795
1996
  case "end":
1796
- return _context18.stop();
1997
+ return _context19.stop();
1797
1998
  }
1798
- }, _callee18);
1999
+ }, _callee19);
1799
2000
  })));
1800
2001
  case 6:
1801
- _context19.next = 11;
2002
+ _context20.next = 11;
1802
2003
  break;
1803
2004
  case 8:
1804
- _context19.prev = 8;
1805
- _context19.t0 = _context19["catch"](3);
2005
+ _context20.prev = 8;
2006
+ _context20.t0 = _context20["catch"](3);
1806
2007
  this.logError('单条保存订单到 SQLite 失败', {
1807
- error: _context19.t0 instanceof Error ? _context19.t0.message : String(_context19.t0),
2008
+ error: _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0),
1808
2009
  orderId: (_orderSnapshot$order_3 = orderSnapshot.order_id) !== null && _orderSnapshot$order_3 !== void 0 ? _orderSnapshot$order_3 : null
1809
2010
  });
1810
2011
  case 11:
1811
2012
  case "end":
1812
- return _context19.stop();
2013
+ return _context20.stop();
1813
2014
  }
1814
- }, _callee19, this, [[3, 8]]);
2015
+ }, _callee20, this, [[3, 8]]);
1815
2016
  }));
1816
- function updateOrderInSQLite(_x12, _x13) {
2017
+ function updateOrderInSQLite(_x13, _x14) {
1817
2018
  return _updateOrderInSQLite.apply(this, arguments);
1818
2019
  }
1819
2020
  return updateOrderInSQLite;
@@ -1828,72 +2029,90 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1828
2029
  }, {
1829
2030
  key: "replaceOrdersSnapshotInSQLite",
1830
2031
  value: (function () {
1831
- var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderList, source) {
1832
- var _this14 = this;
1833
- var orderListSnapshot;
1834
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1835
- while (1) switch (_context21.prev = _context21.next) {
2032
+ var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(orderList, source) {
2033
+ var _this16 = this;
2034
+ var remoteSnapshot;
2035
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2036
+ while (1) switch (_context22.prev = _context22.next) {
1836
2037
  case 0:
1837
2038
  if (this.dbManager) {
1838
- _context21.next = 2;
2039
+ _context22.next = 2;
1839
2040
  break;
1840
2041
  }
1841
- return _context21.abrupt("return");
2042
+ return _context22.abrupt("return");
1842
2043
  case 2:
1843
- orderListSnapshot = cloneDeep(orderList);
1844
- _context21.prev = 3;
1845
- _context21.next = 6;
1846
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1847
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1848
- while (1) switch (_context20.prev = _context20.next) {
2044
+ remoteSnapshot = cloneDeep(orderList);
2045
+ _context22.prev = 3;
2046
+ _context22.next = 6;
2047
+ return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
2048
+ var existingOrders, orderListSnapshot;
2049
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2050
+ while (1) switch (_context21.prev = _context21.next) {
1849
2051
  case 0:
1850
- _this14.logInfo('replaceOrdersSnapshotInSQLite-开始', {
2052
+ if (!(typeof _this16.dbManager.getAll === 'function')) {
2053
+ _context21.next = 6;
2054
+ break;
2055
+ }
2056
+ _context21.next = 3;
2057
+ return _this16.dbManager.getAll(INDEXDB_STORE_NAME);
2058
+ case 3:
2059
+ _context21.t0 = _context21.sent;
2060
+ _context21.next = 7;
2061
+ break;
2062
+ case 6:
2063
+ _context21.t0 = [];
2064
+ case 7:
2065
+ existingOrders = _context21.t0;
2066
+ orderListSnapshot = _this16.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, existingOrders || []);
2067
+ _this16.logInfo('replaceOrdersSnapshotInSQLite-开始', {
1851
2068
  source: source,
1852
- count: orderListSnapshot.length
2069
+ count: orderListSnapshot.length,
2070
+ remoteCount: remoteSnapshot.length,
2071
+ preservedPendingCount: orderListSnapshot.length - remoteSnapshot.length
1853
2072
  });
1854
- _context20.next = 3;
1855
- return _this14.dbManager.clear(INDEXDB_STORE_NAME);
1856
- case 3:
1857
- _this14.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
2073
+ _context21.next = 12;
2074
+ return _this16.dbManager.clear(INDEXDB_STORE_NAME);
2075
+ case 12:
2076
+ _this16.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
1858
2077
  count: orderListSnapshot.length
1859
2078
  });
1860
2079
  if (!(orderListSnapshot.length === 0)) {
1861
- _context20.next = 6;
2080
+ _context21.next = 15;
1862
2081
  break;
1863
2082
  }
1864
- return _context20.abrupt("return");
1865
- case 6:
1866
- _context20.next = 8;
1867
- return _this14.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderListSnapshot);
1868
- case 8:
1869
- _this14.recordRecentSqliteWrite(source, orderListSnapshot);
1870
- _this14.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
2083
+ return _context21.abrupt("return");
2084
+ case 15:
2085
+ _context21.next = 17;
2086
+ return _this16.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderListSnapshot);
2087
+ case 17:
2088
+ _this16.recordRecentSqliteWrite(source, orderListSnapshot);
2089
+ _this16.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
1871
2090
  source: source,
1872
2091
  count: orderListSnapshot.length
1873
2092
  });
1874
- case 10:
2093
+ case 19:
1875
2094
  case "end":
1876
- return _context20.stop();
2095
+ return _context21.stop();
1877
2096
  }
1878
- }, _callee20);
2097
+ }, _callee21);
1879
2098
  })));
1880
2099
  case 6:
1881
- _context21.next = 11;
2100
+ _context22.next = 11;
1882
2101
  break;
1883
2102
  case 8:
1884
- _context21.prev = 8;
1885
- _context21.t0 = _context21["catch"](3);
2103
+ _context22.prev = 8;
2104
+ _context22.t0 = _context22["catch"](3);
1886
2105
  this.logError('全量保存订单到 SQLite 失败', {
1887
- error: _context21.t0 instanceof Error ? _context21.t0.message : String(_context21.t0),
1888
- orderList: orderListSnapshot.length
2106
+ error: _context22.t0 instanceof Error ? _context22.t0.message : String(_context22.t0),
2107
+ orderList: remoteSnapshot.length
1889
2108
  });
1890
2109
  case 11:
1891
2110
  case "end":
1892
- return _context21.stop();
2111
+ return _context22.stop();
1893
2112
  }
1894
- }, _callee21, this, [[3, 8]]);
2113
+ }, _callee22, this, [[3, 8]]);
1895
2114
  }));
1896
- function replaceOrdersSnapshotInSQLite(_x14, _x15) {
2115
+ function replaceOrdersSnapshotInSQLite(_x15, _x16) {
1897
2116
  return _replaceOrdersSnapshotInSQLite.apply(this, arguments);
1898
2117
  }
1899
2118
  return replaceOrdersSnapshotInSQLite;
@@ -1908,39 +2127,39 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1908
2127
  }, {
1909
2128
  key: "clear",
1910
2129
  value: (function () {
1911
- var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1912
- var _this15 = this;
1913
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1914
- while (1) switch (_context23.prev = _context23.next) {
2130
+ var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2131
+ var _this17 = this;
2132
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2133
+ while (1) switch (_context24.prev = _context24.next) {
1915
2134
  case 0:
1916
2135
  this.store.list = [];
1917
2136
  this.store.map = new Map();
1918
2137
  this.resourceIdIndex.clear();
1919
2138
  if (!this.dbManager) {
1920
- _context23.next = 6;
2139
+ _context24.next = 6;
1921
2140
  break;
1922
2141
  }
1923
- _context23.next = 6;
1924
- return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1925
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1926
- while (1) switch (_context22.prev = _context22.next) {
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) {
1927
2146
  case 0:
1928
- _context22.next = 2;
1929
- return _this15.dbManager.clear(INDEXDB_STORE_NAME);
2147
+ _context23.next = 2;
2148
+ return _this17.dbManager.clear(INDEXDB_STORE_NAME);
1930
2149
  case 2:
1931
2150
  case "end":
1932
- return _context22.stop();
2151
+ return _context23.stop();
1933
2152
  }
1934
- }, _callee22);
2153
+ }, _callee23);
1935
2154
  })));
1936
2155
  case 6:
1937
2156
  this.setStorageItem(ORDER_LAST_FULL_FETCH_AT_STORAGE_KEY, '');
1938
2157
  this.core.effects.emit(OrderHooks.onOrdersChanged, this.store.list);
1939
2158
  case 8:
1940
2159
  case "end":
1941
- return _context23.stop();
2160
+ return _context24.stop();
1942
2161
  }
1943
- }, _callee23, this);
2162
+ }, _callee24, this);
1944
2163
  }));
1945
2164
  function clear() {
1946
2165
  return _clear.apply(this, arguments);