@pisell/pisellos 0.10.59 → 0.10.60

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 (58) hide show
  1. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  2. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +25 -2
  3. package/dist/modules/Order/holderRelations.d.ts +14 -0
  4. package/dist/modules/Order/holderRelations.js +154 -0
  5. package/dist/modules/Order/index.d.ts +2 -2
  6. package/dist/modules/Order/index.js +92 -47
  7. package/dist/modules/Order/types.d.ts +19 -1
  8. package/dist/modules/Order/types.js +2 -0
  9. package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  10. package/dist/modules/Order/utils/discountProductLineIdentity.js +142 -7
  11. package/dist/modules/Order/utils/orderCollectionIdentity.js +24 -10
  12. package/dist/modules/Order/utils.d.ts +1 -1
  13. package/dist/modules/Order/utils.js +35 -9
  14. package/dist/server/index.js +18 -12
  15. package/dist/server/modules/order/index.d.ts +4 -0
  16. package/dist/server/modules/order/index.js +255 -190
  17. package/dist/server/modules/order/types.d.ts +3 -0
  18. package/dist/shared/receipt/small-ticket.js +17 -0
  19. package/dist/shared/sales/loadSalesOrderSnapshot.js +1 -1
  20. package/dist/solution/BaseSales/index.js +97 -27
  21. package/dist/solution/BaseSales/types.d.ts +2 -1
  22. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  23. package/dist/solution/BaseSales/utils/parseSalesResponse.js +7 -3
  24. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +12 -3
  25. package/dist/solution/BookingByStep/index.d.ts +1 -1
  26. package/dist/solution/BookingTicket/index.d.ts +1 -13
  27. package/dist/solution/BookingTicket/index.js +7 -4
  28. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +6 -2
  29. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  30. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +3 -1
  31. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +16 -1
  32. package/lib/modules/Order/holderRelations.d.ts +14 -0
  33. package/lib/modules/Order/holderRelations.js +98 -0
  34. package/lib/modules/Order/index.d.ts +2 -2
  35. package/lib/modules/Order/index.js +44 -12
  36. package/lib/modules/Order/types.d.ts +19 -1
  37. package/lib/modules/Order/types.js +1 -0
  38. package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +1 -1
  39. package/lib/modules/Order/utils/discountProductLineIdentity.js +51 -2
  40. package/lib/modules/Order/utils/orderCollectionIdentity.js +5 -0
  41. package/lib/modules/Order/utils.d.ts +1 -1
  42. package/lib/modules/Order/utils.js +27 -6
  43. package/lib/server/index.js +6 -0
  44. package/lib/server/modules/order/index.d.ts +4 -0
  45. package/lib/server/modules/order/index.js +46 -4
  46. package/lib/server/modules/order/types.d.ts +3 -0
  47. package/lib/shared/receipt/small-ticket.js +15 -0
  48. package/lib/shared/sales/loadSalesOrderSnapshot.js +1 -1
  49. package/lib/solution/BaseSales/index.js +39 -2
  50. package/lib/solution/BaseSales/types.d.ts +2 -1
  51. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -1
  52. package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -0
  53. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +7 -0
  54. package/lib/solution/BookingByStep/index.d.ts +1 -1
  55. package/lib/solution/BookingTicket/index.d.ts +1 -13
  56. package/lib/solution/BookingTicket/index.js +4 -1
  57. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +7 -1
  58. package/package.json +1 -1
@@ -30,7 +30,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
30
30
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
31
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
32
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
- import { cloneDeep } from 'lodash-es';
33
+ import { cloneDeep, isEqual } from 'lodash-es';
34
34
  import dayjs from 'dayjs';
35
35
  import { BaseModule } from "../../../modules/BaseModule";
36
36
  import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollections } from "../../../modules/Order/utils/orderCollectionIdentity";
@@ -429,6 +429,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
429
429
  var existingRecord = existing;
430
430
  var incomingRecord = incoming;
431
431
  var uidRemaps = [];
432
+ this.applyHolderRelationsSnapshot(reconciled, existing, incoming);
432
433
  for (var _i = 0, _ORDER_AUTHORITATIVE_ = ORDER_AUTHORITATIVE_COLLECTION_FIELDS; _i < _ORDER_AUTHORITATIVE_.length; _i++) {
433
434
  var field = _ORDER_AUTHORITATIVE_[_i];
434
435
  if (!Array.isArray(incomingRecord[field])) continue;
@@ -537,7 +538,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
537
538
  continue;
538
539
  }
539
540
 
540
- // 远端商品成员确实发生增删时必须落库,避免内存已更新但 SQLite 仍被回声窗口跳过。
541
+ // 远端商品成员或 Holder 关系确实变化时必须落库,避免被回声窗口跳过。
541
542
  if (forceWriteStorageKeys.has(storageKey)) {
542
543
  toWrite.push(order);
543
544
  continue;
@@ -1961,17 +1962,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1961
1962
  _iterator12.s();
1962
1963
  case 38:
1963
1964
  if ((_step12 = _iterator12.n()).done) {
1964
- _context15.next = 57;
1965
+ _context15.next = 58;
1965
1966
  break;
1966
1967
  }
1967
1968
  _step12$value = _slicedToArray(_step12.value, 2), _storageKey2 = _step12$value[0], _draftOrder = _step12$value[1];
1968
1969
  matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_draftOrder));
1969
1970
  if (!(matchIndex >= 0)) {
1970
- _context15.next = 51;
1971
+ _context15.next = 52;
1971
1972
  break;
1972
1973
  }
1973
1974
  existingOrder = updatedList[matchIndex];
1974
1975
  reconciledDraftOrder = this.preserveExistingBusinessCodeForDraft(existingOrder, _draftOrder);
1976
+ this.applyHolderRelationsSnapshot(reconciledDraftOrder, existingOrder, _draftOrder);
1975
1977
  mergedOrder = this.mergeOrderRecords(existingOrder, reconciledDraftOrder);
1976
1978
  nextOrder = _objectSpread(_objectSpread({}, mergedOrder), {}, {
1977
1979
  need_sync: 0,
@@ -1982,46 +1984,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1982
1984
  draftMap.set(_storageKey2, reconciledDraftOrder);
1983
1985
  this.registerOrderIdentityKeys(identityKeyToIndex, nextOrder, matchIndex);
1984
1986
  mergeActions[_storageKey2] = 'update';
1985
- return _context15.abrupt("continue", 55);
1986
- case 51:
1987
+ return _context15.abrupt("continue", 56);
1988
+ case 52:
1987
1989
  insertIndex = updatedList.length;
1988
1990
  updatedList.push(_draftOrder);
1989
1991
  this.registerOrderIdentityKeys(identityKeyToIndex, _draftOrder, insertIndex);
1990
1992
  mergeActions[_storageKey2] = 'insert';
1991
- case 55:
1993
+ case 56:
1992
1994
  _context15.next = 38;
1993
1995
  break;
1994
- case 57:
1995
- _context15.next = 62;
1996
+ case 58:
1997
+ _context15.next = 63;
1996
1998
  break;
1997
- case 59:
1998
- _context15.prev = 59;
1999
+ case 60:
2000
+ _context15.prev = 60;
1999
2001
  _context15.t1 = _context15["catch"](36);
2000
2002
  _iterator12.e(_context15.t1);
2001
- case 62:
2002
- _context15.prev = 62;
2003
+ case 63:
2004
+ _context15.prev = 63;
2003
2005
  _iterator12.f();
2004
- return _context15.finish(62);
2005
- case 65:
2006
+ return _context15.finish(63);
2007
+ case 66:
2006
2008
  patchedOrders = _toConsumableArray(draftMap.values());
2007
2009
  previousList = this.store.list;
2008
2010
  this.store.list = this.runOrderStoreSelfCheck(updatedList, 'upsertLocalDraftOrders.store');
2009
2011
  this.syncOrdersMap();
2010
- _context15.prev = 69;
2011
- _context15.next = 72;
2012
+ _context15.prev = 70;
2013
+ _context15.next = 73;
2012
2014
  return this.patchOrdersInSQLite(patchedOrders, 'upsertLocalDraftOrders', mergeActions, {
2013
2015
  throwOnError: true
2014
2016
  });
2015
- case 72:
2016
- _context15.next = 79;
2017
+ case 73:
2018
+ _context15.next = 80;
2017
2019
  break;
2018
- case 74:
2019
- _context15.prev = 74;
2020
- _context15.t2 = _context15["catch"](69);
2020
+ case 75:
2021
+ _context15.prev = 75;
2022
+ _context15.t2 = _context15["catch"](70);
2021
2023
  this.store.list = previousList;
2022
2024
  this.syncOrdersMap();
2023
2025
  throw _context15.t2;
2024
- case 79:
2026
+ case 80:
2025
2027
  this.logInfo('upsertLocalDraftOrders-结束', {
2026
2028
  count: patchedOrders.length,
2027
2029
  storeOrderCountAfter: this.store.list.length
@@ -2030,18 +2032,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2030
2032
  return !_this11.shouldKeepOrderInMemory(order);
2031
2033
  });
2032
2034
  if (!(memoryDraftMap.size > 0 || removedLegacyMemoryDraft)) {
2033
- _context15.next = 84;
2035
+ _context15.next = 85;
2034
2036
  break;
2035
2037
  }
2036
- _context15.next = 84;
2038
+ _context15.next = 85;
2037
2039
  return this.emitOrdersChanged(patchedOrders.filter(function (order) {
2038
2040
  return _this11.shouldKeepOrderInMemory(order);
2039
2041
  }), 'upsertLocalDraftOrders');
2040
- case 84:
2042
+ case 85:
2041
2043
  case "end":
2042
2044
  return _context15.stop();
2043
2045
  }
2044
- }, _callee15, this, [[6, 21, 24, 27], [36, 59, 62, 65], [69, 74]]);
2046
+ }, _callee15, this, [[6, 21, 24, 27], [36, 60, 63, 66], [70, 75]]);
2045
2047
  }));
2046
2048
  function upsertLocalDraftOrders(_x11) {
2047
2049
  return _upsertLocalDraftOrders.apply(this, arguments);
@@ -2417,7 +2419,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2417
2419
  var hasSingleId = routeInfo.hasSingleId;
2418
2420
  var normalizedBody = _this16.normalizeOrderSyncPayload(msg.body || msg.data);
2419
2421
  if (routeInfo.route === 'bodyUpsert' && normalizedBody) {
2420
- upsertOrders.set(_this16.getIdKey(normalizedBody.order_id), normalizedBody);
2422
+ var orderKey = _this16.getIdKey(normalizedBody.order_id);
2423
+ var previousBody = upsertOrders.get(orderKey);
2424
+ if (previousBody) _this16.applyHolderRelationsSnapshot(normalizedBody, previousBody, normalizedBody);
2425
+ upsertOrders.set(orderKey, normalizedBody);
2421
2426
  return;
2422
2427
  }
2423
2428
  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));
@@ -2644,7 +2649,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2644
2649
  _iterator17.s();
2645
2650
  case 40:
2646
2651
  if ((_step17 = _iterator17.n()).done) {
2647
- _context20.next = 100;
2652
+ _context20.next = 101;
2648
2653
  break;
2649
2654
  }
2650
2655
  fresh = _step17.value;
@@ -2653,7 +2658,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2653
2658
  storageKey = this.getOrderStorageKey(fresh);
2654
2659
  mergeKey = storageKey || (fresh.order_id !== undefined && fresh.order_id !== null ? this.getIdKey(fresh.order_id) : '');
2655
2660
  if (!(matchIndex >= 0)) {
2656
- _context20.next = 92;
2661
+ _context20.next = 93;
2657
2662
  break;
2658
2663
  }
2659
2664
  existingOrder = updatedList[matchIndex];
@@ -2672,7 +2677,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2672
2677
  remote_need_sync: (_fresh$need_sync = fresh.need_sync) !== null && _fresh$need_sync !== void 0 ? _fresh$need_sync : null,
2673
2678
  reason: 'protect_pending_sync_order_from_remote_echo'
2674
2679
  });
2675
- return _context20.abrupt("continue", 98);
2680
+ return _context20.abrupt("continue", 99);
2676
2681
  case 52:
2677
2682
  if (!(this.isDraftOrder(existingOrder) && this.shouldProtectDraftOrderFromIncoming(source))) {
2678
2683
  _context20.next = 55;
@@ -2686,7 +2691,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2686
2691
  remote_is_draft_order: (_fresh$is_draft_order = fresh.is_draft_order) !== null && _fresh$is_draft_order !== void 0 ? _fresh$is_draft_order : null,
2687
2692
  reason: 'protect_draft_order_from_remote_echo'
2688
2693
  });
2689
- return _context20.abrupt("continue", 98);
2694
+ return _context20.abrupt("continue", 99);
2690
2695
  case 55:
2691
2696
  mergedOrder = this.mergeOrderRecords(existingOrder, fresh);
2692
2697
  freshOrderId = fresh.order_id;
@@ -2778,34 +2783,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2778
2783
  mergedStorageKey = this.getOrderStorageKey(mergedOrder);
2779
2784
  if (mergedStorageKey) forceWriteStorageKeys.add(mergedStorageKey);
2780
2785
  }
2786
+ if (nextStorageKey && !isEqual(existingOrder.holder_relations, mergedOrder.holder_relations)) {
2787
+ forceWriteStorageKeys.add(nextStorageKey);
2788
+ }
2781
2789
  // 合并后身份字段可能新增(如挂单拿到 order_id),同步登记到索引,
2782
2790
  // 供同批后续 fresh 命中同一槽位,避免重复插入
2783
2791
  this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, adjustedMatchIndex);
2784
2792
  patchedOrders.push(mergedOrder);
2785
2793
  if (mergeKey) mergeActions[mergeKey] = 'update';
2786
- return _context20.abrupt("continue", 98);
2787
- case 92:
2794
+ return _context20.abrupt("continue", 99);
2795
+ case 93:
2788
2796
  insertIndex = updatedList.length;
2789
2797
  updatedList.push(fresh);
2790
2798
  existingProductsHaveStableIdentity.push(fresh.order_id !== undefined && fresh.order_id !== null && incomingProductsHaveStableIdentity.get(this.getIdKey(fresh.order_id)) !== false);
2791
2799
  this.registerOrderIdentityKeys(identityKeyToIndex, fresh, insertIndex);
2792
2800
  patchedOrders.push(fresh);
2793
2801
  if (mergeKey) mergeActions[mergeKey] = 'insert';
2794
- case 98:
2802
+ case 99:
2795
2803
  _context20.next = 40;
2796
2804
  break;
2797
- case 100:
2798
- _context20.next = 105;
2805
+ case 101:
2806
+ _context20.next = 106;
2799
2807
  break;
2800
- case 102:
2801
- _context20.prev = 102;
2808
+ case 103:
2809
+ _context20.prev = 103;
2802
2810
  _context20.t2 = _context20["catch"](38);
2803
2811
  _iterator17.e(_context20.t2);
2804
- case 105:
2805
- _context20.prev = 105;
2812
+ case 106:
2813
+ _context20.prev = 106;
2806
2814
  _iterator17.f();
2807
- return _context20.finish(105);
2808
- case 108:
2815
+ return _context20.finish(106);
2816
+ case 109:
2809
2817
  insertCount = Object.values(mergeActions).filter(function (v) {
2810
2818
  return v === 'insert';
2811
2819
  }).length;
@@ -2821,27 +2829,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
2821
2829
  // 仅在自检开关开启时做一次兜底校验。
2822
2830
  this.store.list = this.runOrderStoreSelfCheck(updatedList, "".concat(source, ".store"));
2823
2831
  this.syncOrdersMap();
2824
- _context20.next = 115;
2832
+ _context20.next = 116;
2825
2833
  return this.patchOrdersInSQLite(patchedOrders, source, mergeActions, {
2826
2834
  storageKeyMigrations: storageKeyMigrations
2827
2835
  }, forceWriteStorageKeys);
2828
- case 115:
2836
+ case 116:
2829
2837
  this.logInfo('mergeOrdersToStore-结束', {
2830
2838
  uniqueFreshCount: uniqueFreshCount,
2831
2839
  storeOrderCountAfter: this.store.list.length,
2832
2840
  insertCount: insertCount,
2833
2841
  updateCount: updateCount
2834
2842
  });
2835
- _context20.next = 118;
2843
+ _context20.next = 119;
2836
2844
  return this.emitRemoteProductMembershipChanges(remoteProductMembershipChanges);
2837
- case 118:
2838
- _context20.next = 120;
2845
+ case 119:
2846
+ _context20.next = 121;
2839
2847
  return this.emitOrdersChanged(patchedOrders, source);
2840
- case 120:
2848
+ case 121:
2841
2849
  case "end":
2842
2850
  return _context20.stop();
2843
2851
  }
2844
- }, _callee20, this, [[6, 20, 23, 26], [38, 102, 105, 108], [64, 76, 79, 82]]);
2852
+ }, _callee20, this, [[6, 20, 23, 26], [38, 103, 106, 109], [64, 76, 79, 82]]);
2845
2853
  }));
2846
2854
  function mergeOrdersToStore(_x13, _x14) {
2847
2855
  return _mergeOrdersToStore.apply(this, arguments);
@@ -3270,6 +3278,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3270
3278
  });
3271
3279
  });
3272
3280
  }
3281
+
3282
+ /** 关系数组是完整快照,不能拼接或按商品子项生成 UID;扩展字段整体保留。 */
3283
+ }, {
3284
+ key: "applyHolderRelationsSnapshot",
3285
+ value: function applyHolderRelationsSnapshot(target, existing, incoming) {
3286
+ if (Array.isArray(incoming.holder_relations)) {
3287
+ target.holder_relations = cloneDeep(incoming.holder_relations);
3288
+ } else if (Array.isArray(existing.holder_relations)) {
3289
+ target.holder_relations = cloneDeep(existing.holder_relations);
3290
+ } else {
3291
+ delete target.holder_relations;
3292
+ }
3293
+ }
3294
+
3295
+ /** 全量拉取缺少关系字段时,仍保留同一订单已有的关系快照。 */
3296
+ }, {
3297
+ key: "preserveOmittedHolderRelations",
3298
+ value: function preserveOmittedHolderRelations(incomingOrders, existingOrders) {
3299
+ var _this21 = this;
3300
+ var existingByIdentity = new Map();
3301
+ var _iterator29 = _createForOfIteratorHelper(existingOrders),
3302
+ _step29;
3303
+ try {
3304
+ for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
3305
+ var order = _step29.value;
3306
+ if (!Array.isArray(order.holder_relations)) continue;
3307
+ var _iterator30 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
3308
+ _step30;
3309
+ try {
3310
+ for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
3311
+ var key = _step30.value;
3312
+ existingByIdentity.set(key, order);
3313
+ }
3314
+ } catch (err) {
3315
+ _iterator30.e(err);
3316
+ } finally {
3317
+ _iterator30.f();
3318
+ }
3319
+ }
3320
+ } catch (err) {
3321
+ _iterator29.e(err);
3322
+ } finally {
3323
+ _iterator29.f();
3324
+ }
3325
+ return incomingOrders.map(function (order) {
3326
+ if (Array.isArray(order.holder_relations)) return order;
3327
+ var existingOrder = _this21.getOrderIdentityMatchKeys(order).map(function (key) {
3328
+ return existingByIdentity.get(key);
3329
+ }).find(Boolean);
3330
+ if (!existingOrder) return order;
3331
+ var nextOrder = _objectSpread({}, order);
3332
+ _this21.applyHolderRelationsSnapshot(nextOrder, existingOrder, order);
3333
+ return nextOrder;
3334
+ });
3335
+ }
3273
3336
  }, {
3274
3337
  key: "mergeOrderRecords",
3275
3338
  value: function mergeOrderRecords(existing, incoming) {
@@ -3307,6 +3370,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3307
3370
  if (Object.prototype.hasOwnProperty.call(incomingRecord, 'order_meta_list')) {
3308
3371
  mergedRecord.order_meta_list = cloneDeep(incomingRecord.order_meta_list);
3309
3372
  }
3373
+ this.applyHolderRelationsSnapshot(merged, existing, incoming);
3310
3374
 
3311
3375
  // 子项数组遵循完整快照语义:incoming 自有且为数组(包括 [])时权威替换;
3312
3376
  // 字段缺席或不是数组时视为稀疏 patch,继续保留 existing。
@@ -3347,30 +3411,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3347
3411
  key: "summarizeDuplicateOrders",
3348
3412
  value: function summarizeDuplicateOrders(orders) {
3349
3413
  var groups = new Map();
3350
- var _iterator29 = _createForOfIteratorHelper(orders),
3351
- _step29;
3414
+ var _iterator31 = _createForOfIteratorHelper(orders),
3415
+ _step31;
3352
3416
  try {
3353
- for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
3354
- var order = _step29.value;
3355
- var _iterator30 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
3356
- _step30;
3417
+ for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
3418
+ var order = _step31.value;
3419
+ var _iterator32 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
3420
+ _step32;
3357
3421
  try {
3358
- for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
3359
- var key = _step30.value;
3422
+ for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
3423
+ var key = _step32.value;
3360
3424
  var group = groups.get(key) || [];
3361
3425
  group.push(order);
3362
3426
  groups.set(key, group);
3363
3427
  }
3364
3428
  } catch (err) {
3365
- _iterator30.e(err);
3429
+ _iterator32.e(err);
3366
3430
  } finally {
3367
- _iterator30.f();
3431
+ _iterator32.f();
3368
3432
  }
3369
3433
  }
3370
3434
  } catch (err) {
3371
- _iterator29.e(err);
3435
+ _iterator31.e(err);
3372
3436
  } finally {
3373
- _iterator29.f();
3437
+ _iterator31.f();
3374
3438
  }
3375
3439
  return _toConsumableArray(groups.entries()).filter(function (_ref9) {
3376
3440
  var _ref10 = _slicedToArray(_ref9, 2),
@@ -3413,11 +3477,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3413
3477
  value: function compactOrderListByIdentity(orders, source) {
3414
3478
  var list = [];
3415
3479
  var removedCount = 0;
3416
- var _iterator31 = _createForOfIteratorHelper(orders),
3417
- _step31;
3480
+ var _iterator33 = _createForOfIteratorHelper(orders),
3481
+ _step33;
3418
3482
  try {
3419
- for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
3420
- var order = _step31.value;
3483
+ for (_iterator33.s(); !(_step33 = _iterator33.n()).done;) {
3484
+ var order = _step33.value;
3421
3485
  var normalizedOrder = this.normalizeOrderCollectionsForIngress(order, "".concat(source, ".order"));
3422
3486
  var matchIndex = this.findOrderIndexByIdentity(list, normalizedOrder);
3423
3487
  if (matchIndex < 0) {
@@ -3428,9 +3492,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3428
3492
  removedCount += 1;
3429
3493
  }
3430
3494
  } catch (err) {
3431
- _iterator31.e(err);
3495
+ _iterator33.e(err);
3432
3496
  } finally {
3433
- _iterator31.f();
3497
+ _iterator33.f();
3434
3498
  }
3435
3499
  if (removedCount > 0) {
3436
3500
  this.logWarning('订单列表重复项已压缩', {
@@ -3563,7 +3627,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3563
3627
  key: "loadOrdersFromSQLite",
3564
3628
  value: function () {
3565
3629
  var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
3566
- var _this21 = this;
3630
+ var _this22 = this;
3567
3631
  var options,
3568
3632
  _options$onTiming,
3569
3633
  loadStartedAt,
@@ -3594,7 +3658,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3594
3658
  sqliteRawReadMs = +(performance.now() - rawReadStartedAt).toFixed(2);
3595
3659
  normalizeStartedAt = performance.now();
3596
3660
  normalizedOrders = (orders || []).map(function (order) {
3597
- return _this21.normalizeOrderCollectionsForIngress(order, 'loadOrdersFromSQLite');
3661
+ return _this22.normalizeOrderCollectionsForIngress(order, 'loadOrdersFromSQLite');
3598
3662
  });
3599
3663
  sqliteNormalizeMs = +(performance.now() - normalizeStartedAt).toFixed(2);
3600
3664
  (_options$onTiming = options.onTiming) === null || _options$onTiming === void 0 || _options$onTiming.call(options, {
@@ -3667,15 +3731,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3667
3731
  }, {
3668
3732
  key: "mergeRemoteSnapshotWithPendingOrders",
3669
3733
  value: function mergeRemoteSnapshotWithPendingOrders(remoteOrders, existingOrders) {
3670
- var _this22 = this;
3734
+ var _this23 = this;
3671
3735
  var merged = remoteOrders.map(function (order) {
3672
- return _this22.normalizeRemoteSyncedOrder(order);
3736
+ return _this23.normalizeRemoteSyncedOrder(order);
3673
3737
  });
3674
- var _iterator32 = _createForOfIteratorHelper(existingOrders),
3675
- _step32;
3738
+ var _iterator34 = _createForOfIteratorHelper(existingOrders),
3739
+ _step34;
3676
3740
  try {
3677
- for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
3678
- var rawOrder = _step32.value;
3741
+ for (_iterator34.s(); !(_step34 = _iterator34.n()).done;) {
3742
+ var rawOrder = _step34.value;
3679
3743
  var order = this.normalizeOrderCollectionsForIngress(rawOrder, 'mergeRemoteSnapshotWithPendingOrders.existingSQLite');
3680
3744
  if (!this.shouldProtectLocalOrderFromRemoteSnapshot(order)) continue;
3681
3745
  var matchIndex = this.findOrderIndexByIdentity(merged, order);
@@ -3691,9 +3755,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3691
3755
  merged.push(order);
3692
3756
  }
3693
3757
  } catch (err) {
3694
- _iterator32.e(err);
3758
+ _iterator34.e(err);
3695
3759
  } finally {
3696
- _iterator32.f();
3760
+ _iterator34.f();
3697
3761
  }
3698
3762
  return this.compactOrderListByIdentity(merged, 'mergeRemoteSnapshotWithPendingOrders').list;
3699
3763
  }
@@ -3743,7 +3807,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3743
3807
  key: "patchOrdersInSQLite",
3744
3808
  value: (function () {
3745
3809
  var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(orders, source) {
3746
- var _this23 = this;
3810
+ var _this24 = this;
3747
3811
  var mergeActions,
3748
3812
  options,
3749
3813
  forceWriteStorageKeys,
@@ -3755,8 +3819,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3755
3819
  compactedToWrite,
3756
3820
  writtenStorageKeys,
3757
3821
  storageKeyMigrations,
3758
- _iterator33,
3759
- _step33,
3822
+ _iterator35,
3823
+ _step35,
3760
3824
  migration,
3761
3825
  _args24 = arguments;
3762
3826
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
@@ -3787,13 +3851,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3787
3851
  return migration.to;
3788
3852
  }));
3789
3853
  ordersSnapshot = cloneDeep(orders).map(function (order) {
3790
- return _this23.normalizeOrderCollectionsForIngress(order, "".concat(source, ".sqliteIngress"));
3854
+ return _this24.normalizeOrderCollectionsForIngress(order, "".concat(source, ".sqliteIngress"));
3791
3855
  }).map(function (order) {
3792
- var storageKey = _this23.getOrderStorageKey(order);
3856
+ var storageKey = _this24.getOrderStorageKey(order);
3793
3857
  if (!storageKey || !migrationTargetStorageKeys.has(storageKey)) return order;
3794
3858
  return _objectSpread(_objectSpread({}, order), {}, _defineProperty({}, ORDER_STORAGE_KEY_FIELD, storageKey));
3795
3859
  }).filter(function (order) {
3796
- return _this23.getOrderStorageKey(order);
3860
+ return _this24.getOrderStorageKey(order);
3797
3861
  });
3798
3862
  if (!(ordersSnapshot.length === 0)) {
3799
3863
  _context24.next = 13;
@@ -3816,18 +3880,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3816
3880
  return _context24.abrupt("return");
3817
3881
  case 19:
3818
3882
  writtenStorageKeys = new Set(compactedToWrite.map(function (order) {
3819
- return _this23.getOrderStorageKey(order);
3883
+ return _this24.getOrderStorageKey(order);
3820
3884
  }).filter(Boolean));
3821
3885
  storageKeyMigrations = new Map();
3822
- _iterator33 = _createForOfIteratorHelper(options.storageKeyMigrations || []);
3886
+ _iterator35 = _createForOfIteratorHelper(options.storageKeyMigrations || []);
3823
3887
  _context24.prev = 22;
3824
- _iterator33.s();
3888
+ _iterator35.s();
3825
3889
  case 24:
3826
- if ((_step33 = _iterator33.n()).done) {
3890
+ if ((_step35 = _iterator35.n()).done) {
3827
3891
  _context24.next = 33;
3828
3892
  break;
3829
3893
  }
3830
- migration = _step33.value;
3894
+ migration = _step35.value;
3831
3895
  if (writtenStorageKeys.has(migration.to)) {
3832
3896
  _context24.next = 28;
3833
3897
  break;
@@ -3850,63 +3914,63 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3850
3914
  case 35:
3851
3915
  _context24.prev = 35;
3852
3916
  _context24.t0 = _context24["catch"](22);
3853
- _iterator33.e(_context24.t0);
3917
+ _iterator35.e(_context24.t0);
3854
3918
  case 38:
3855
3919
  _context24.prev = 38;
3856
- _iterator33.f();
3920
+ _iterator35.f();
3857
3921
  return _context24.finish(38);
3858
3922
  case 41:
3859
3923
  _context24.prev = 41;
3860
3924
  _context24.next = 44;
3861
3925
  return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
3862
- var writeMethod, _iterator34, _step34, order, _iterator35, _step35, migration, _iterator36, _step36, _orderRecord$ORDER_ST, _order, orderRecord;
3926
+ var writeMethod, _iterator36, _step36, order, _iterator37, _step37, migration, _iterator38, _step38, _orderRecord$ORDER_ST, _order, orderRecord;
3863
3927
  return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3864
3928
  while (1) switch (_context23.prev = _context23.next) {
3865
3929
  case 0:
3866
3930
  writeMethod = 'none';
3867
- _this23.logInfo('patchOrdersInSQLite-开始', {
3931
+ _this24.logInfo('patchOrdersInSQLite-开始', {
3868
3932
  source: source,
3869
3933
  count: compactedToWrite.length,
3870
3934
  dedupedCount: skipped.length
3871
3935
  });
3872
- if (!(typeof _this23.dbManager.bulkUpdate === 'function')) {
3936
+ if (!(typeof _this24.dbManager.bulkUpdate === 'function')) {
3873
3937
  _context23.next = 8;
3874
3938
  break;
3875
3939
  }
3876
3940
  writeMethod = 'bulkUpdate';
3877
3941
  _context23.next = 6;
3878
- return _this23.dbManager.bulkUpdate(INDEXDB_STORE_NAME, compactedToWrite);
3942
+ return _this24.dbManager.bulkUpdate(INDEXDB_STORE_NAME, compactedToWrite);
3879
3943
  case 6:
3880
3944
  _context23.next = 37;
3881
3945
  break;
3882
3946
  case 8:
3883
- if (!(typeof _this23.dbManager.bulkAdd === 'function')) {
3947
+ if (!(typeof _this24.dbManager.bulkAdd === 'function')) {
3884
3948
  _context23.next = 14;
3885
3949
  break;
3886
3950
  }
3887
3951
  writeMethod = 'bulkAdd';
3888
3952
  _context23.next = 12;
3889
- return _this23.dbManager.bulkAdd(INDEXDB_STORE_NAME, compactedToWrite);
3953
+ return _this24.dbManager.bulkAdd(INDEXDB_STORE_NAME, compactedToWrite);
3890
3954
  case 12:
3891
3955
  _context23.next = 37;
3892
3956
  break;
3893
3957
  case 14:
3894
- if (!(typeof _this23.dbManager.update === 'function')) {
3958
+ if (!(typeof _this24.dbManager.update === 'function')) {
3895
3959
  _context23.next = 35;
3896
3960
  break;
3897
3961
  }
3898
3962
  writeMethod = 'update';
3899
- _iterator34 = _createForOfIteratorHelper(compactedToWrite);
3963
+ _iterator36 = _createForOfIteratorHelper(compactedToWrite);
3900
3964
  _context23.prev = 17;
3901
- _iterator34.s();
3965
+ _iterator36.s();
3902
3966
  case 19:
3903
- if ((_step34 = _iterator34.n()).done) {
3967
+ if ((_step36 = _iterator36.n()).done) {
3904
3968
  _context23.next = 25;
3905
3969
  break;
3906
3970
  }
3907
- order = _step34.value;
3971
+ order = _step36.value;
3908
3972
  _context23.next = 23;
3909
- return _this23.dbManager.update(INDEXDB_STORE_NAME, order);
3973
+ return _this24.dbManager.update(INDEXDB_STORE_NAME, order);
3910
3974
  case 23:
3911
3975
  _context23.next = 19;
3912
3976
  break;
@@ -3916,10 +3980,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3916
3980
  case 27:
3917
3981
  _context23.prev = 27;
3918
3982
  _context23.t0 = _context23["catch"](17);
3919
- _iterator34.e(_context23.t0);
3983
+ _iterator36.e(_context23.t0);
3920
3984
  case 30:
3921
3985
  _context23.prev = 30;
3922
- _iterator34.f();
3986
+ _iterator36.f();
3923
3987
  return _context23.finish(30);
3924
3988
  case 33:
3925
3989
  _context23.next = 37;
@@ -3931,35 +3995,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3931
3995
  }
3932
3996
  throw new Error('订单 SQLite 数据库不支持写入');
3933
3997
  case 37:
3934
- _this23.recordRecentSqliteWrite(source, compactedToWrite);
3998
+ _this24.recordRecentSqliteWrite(source, compactedToWrite);
3935
3999
  if (!(writeMethod !== 'none')) {
3936
4000
  _context23.next = 84;
3937
4001
  break;
3938
4002
  }
3939
- _iterator35 = _createForOfIteratorHelper(storageKeyMigrations.values());
4003
+ _iterator37 = _createForOfIteratorHelper(storageKeyMigrations.values());
3940
4004
  _context23.prev = 40;
3941
- _iterator35.s();
4005
+ _iterator37.s();
3942
4006
  case 42:
3943
- if ((_step35 = _iterator35.n()).done) {
4007
+ if ((_step37 = _iterator37.n()).done) {
3944
4008
  _context23.next = 76;
3945
4009
  break;
3946
4010
  }
3947
- migration = _step35.value;
4011
+ migration = _step37.value;
3948
4012
  _context23.prev = 44;
3949
4013
  _context23.next = 47;
3950
- return _this23.dbManager.delete(INDEXDB_STORE_NAME, migration.from);
4014
+ return _this24.dbManager.delete(INDEXDB_STORE_NAME, migration.from);
3951
4015
  case 47:
3952
- _this23.recentSqliteWriteByStorageKey.delete(migration.from);
3953
- _iterator36 = _createForOfIteratorHelper(orders);
4016
+ _this24.recentSqliteWriteByStorageKey.delete(migration.from);
4017
+ _iterator38 = _createForOfIteratorHelper(orders);
3954
4018
  _context23.prev = 49;
3955
- _iterator36.s();
4019
+ _iterator38.s();
3956
4020
  case 51:
3957
- if ((_step36 = _iterator36.n()).done) {
4021
+ if ((_step38 = _iterator38.n()).done) {
3958
4022
  _context23.next = 61;
3959
4023
  break;
3960
4024
  }
3961
- _order = _step36.value;
3962
- if (!(_this23.getOrderStorageKey(_order) !== migration.to)) {
4025
+ _order = _step38.value;
4026
+ if (!(_this24.getOrderStorageKey(_order) !== migration.to)) {
3963
4027
  _context23.next = 55;
3964
4028
  break;
3965
4029
  }
@@ -3982,10 +4046,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3982
4046
  case 63:
3983
4047
  _context23.prev = 63;
3984
4048
  _context23.t1 = _context23["catch"](49);
3985
- _iterator36.e(_context23.t1);
4049
+ _iterator38.e(_context23.t1);
3986
4050
  case 66:
3987
4051
  _context23.prev = 66;
3988
- _iterator36.f();
4052
+ _iterator38.f();
3989
4053
  return _context23.finish(66);
3990
4054
  case 69:
3991
4055
  _context23.next = 74;
@@ -3993,7 +4057,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3993
4057
  case 71:
3994
4058
  _context23.prev = 71;
3995
4059
  _context23.t2 = _context23["catch"](44);
3996
- _this23.logError('删除订单旧 SQLite storage key 失败', {
4060
+ _this24.logError('删除订单旧 SQLite storage key 失败', {
3997
4061
  source: source,
3998
4062
  order_id: migration.orderId,
3999
4063
  oldStorageKey: migration.from,
@@ -4009,13 +4073,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4009
4073
  case 78:
4010
4074
  _context23.prev = 78;
4011
4075
  _context23.t3 = _context23["catch"](40);
4012
- _iterator35.e(_context23.t3);
4076
+ _iterator37.e(_context23.t3);
4013
4077
  case 81:
4014
4078
  _context23.prev = 81;
4015
- _iterator35.f();
4079
+ _iterator37.f();
4016
4080
  return _context23.finish(81);
4017
4081
  case 84:
4018
- _this23.logInfo('patchOrdersInSQLite-完成', {
4082
+ _this24.logInfo('patchOrdersInSQLite-完成', {
4019
4083
  source: source,
4020
4084
  count: compactedToWrite.length,
4021
4085
  writeMethod: writeMethod,
@@ -4064,7 +4128,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4064
4128
  key: "updateOrderInSQLite",
4065
4129
  value: (function () {
4066
4130
  var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order, source) {
4067
- var _this24 = this;
4131
+ var _this25 = this;
4068
4132
  var options,
4069
4133
  orderSnapshot,
4070
4134
  _orderSnapshot$order_3,
@@ -4107,40 +4171,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4107
4171
  while (1) switch (_context25.prev = _context25.next) {
4108
4172
  case 0:
4109
4173
  writeMethod = 'none';
4110
- _this24.logInfo('updateOrderInSQLite-开始', {
4174
+ _this25.logInfo('updateOrderInSQLite-开始', {
4111
4175
  source: source,
4112
4176
  orderId: (_orderSnapshot$order_ = orderSnapshot.order_id) !== null && _orderSnapshot$order_ !== void 0 ? _orderSnapshot$order_ : null,
4113
- storageKey: _this24.getOrderStorageKey(orderSnapshot)
4177
+ storageKey: _this25.getOrderStorageKey(orderSnapshot)
4114
4178
  });
4115
- if (!(typeof _this24.dbManager.update === 'function')) {
4179
+ if (!(typeof _this25.dbManager.update === 'function')) {
4116
4180
  _context25.next = 8;
4117
4181
  break;
4118
4182
  }
4119
4183
  writeMethod = 'update';
4120
4184
  _context25.next = 6;
4121
- return _this24.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
4185
+ return _this25.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
4122
4186
  case 6:
4123
4187
  _context25.next = 22;
4124
4188
  break;
4125
4189
  case 8:
4126
- if (!(typeof _this24.dbManager.bulkUpdate === 'function')) {
4190
+ if (!(typeof _this25.dbManager.bulkUpdate === 'function')) {
4127
4191
  _context25.next = 14;
4128
4192
  break;
4129
4193
  }
4130
4194
  writeMethod = 'bulkUpdate';
4131
4195
  _context25.next = 12;
4132
- return _this24.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
4196
+ return _this25.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
4133
4197
  case 12:
4134
4198
  _context25.next = 22;
4135
4199
  break;
4136
4200
  case 14:
4137
- if (!(typeof _this24.dbManager.bulkAdd === 'function')) {
4201
+ if (!(typeof _this25.dbManager.bulkAdd === 'function')) {
4138
4202
  _context25.next = 20;
4139
4203
  break;
4140
4204
  }
4141
4205
  writeMethod = 'bulkAdd';
4142
4206
  _context25.next = 18;
4143
- return _this24.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
4207
+ return _this25.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
4144
4208
  case 18:
4145
4209
  _context25.next = 22;
4146
4210
  break;
@@ -4151,8 +4215,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4151
4215
  }
4152
4216
  throw new Error('订单 SQLite 数据库不支持写入');
4153
4217
  case 22:
4154
- _this24.recordRecentSqliteWrite(source, [orderSnapshot]);
4155
- _this24.logInfo('updateOrderInSQLite-完成', {
4218
+ _this25.recordRecentSqliteWrite(source, [orderSnapshot]);
4219
+ _this25.logInfo('updateOrderInSQLite-完成', {
4156
4220
  source: source,
4157
4221
  orderId: (_orderSnapshot$order_2 = orderSnapshot.order_id) !== null && _orderSnapshot$order_2 !== void 0 ? _orderSnapshot$order_2 : null,
4158
4222
  writeMethod: writeMethod
@@ -4201,7 +4265,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4201
4265
  key: "replaceOrdersSnapshotInSQLite",
4202
4266
  value: (function () {
4203
4267
  var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(orderList, source) {
4204
- var _this25 = this;
4268
+ var _this26 = this;
4205
4269
  var protectedOrdersBeforeRemoteFetch,
4206
4270
  remoteSnapshot,
4207
4271
  mergedSnapshot,
@@ -4216,32 +4280,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4216
4280
  break;
4217
4281
  }
4218
4282
  return _context28.abrupt("return", {
4219
- orders: this.compactOrderListByIdentity(orderList.map(function (order) {
4220
- return _this25.normalizeRemoteSyncedOrder(order);
4283
+ orders: this.compactOrderListByIdentity(this.preserveOmittedHolderRelations(orderList, this.store.list).map(function (order) {
4284
+ return _this26.normalizeRemoteSyncedOrder(order);
4221
4285
  }), "".concat(source, ".snapshotNoDb")).list,
4222
4286
  persisted: false
4223
4287
  });
4224
4288
  case 3:
4225
4289
  remoteSnapshot = cloneDeep(orderList).map(function (order) {
4226
- return _this25.normalizeOrderCollectionsForIngress(order, "".concat(source, ".remoteIngress"));
4290
+ return _this26.normalizeOrderCollectionsForIngress(order, "".concat(source, ".remoteIngress"));
4227
4291
  });
4228
4292
  mergedSnapshot = this.compactOrderListByIdentity(remoteSnapshot.map(function (order) {
4229
- return _this25.normalizeRemoteSyncedOrder(order);
4293
+ return _this26.normalizeRemoteSyncedOrder(order);
4230
4294
  }), "".concat(source, ".remoteSnapshot")).list;
4231
4295
  persisted = false;
4232
4296
  _context28.prev = 6;
4233
4297
  _context28.next = 9;
4234
4298
  return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
4235
- var existingOrders, protectedLocalOrders, _iterator37, _step37, rawCurrentOrder, currentOrder, protectedIndex, currentNeedsProtection, orderListSnapshot;
4299
+ var existingOrders, remoteSnapshotWithHolderRelations, protectedLocalOrders, _iterator39, _step39, rawCurrentOrder, currentOrder, protectedIndex, currentNeedsProtection, orderListSnapshot;
4236
4300
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
4237
4301
  while (1) switch (_context27.prev = _context27.next) {
4238
4302
  case 0:
4239
- if (!(typeof _this25.dbManager.getAll === 'function')) {
4303
+ if (!(typeof _this26.dbManager.getAll === 'function')) {
4240
4304
  _context27.next = 6;
4241
4305
  break;
4242
4306
  }
4243
4307
  _context27.next = 3;
4244
- return _this25.dbManager.getAll(INDEXDB_STORE_NAME);
4308
+ return _this26.dbManager.getAll(INDEXDB_STORE_NAME);
4245
4309
  case 3:
4246
4310
  _context27.t0 = _context27.sent;
4247
4311
  _context27.next = 7;
@@ -4250,25 +4314,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4250
4314
  _context27.t0 = [];
4251
4315
  case 7:
4252
4316
  existingOrders = _context27.t0;
4317
+ remoteSnapshotWithHolderRelations = _this26.preserveOmittedHolderRelations(remoteSnapshot, [].concat(_toConsumableArray(protectedOrdersBeforeRemoteFetch), _toConsumableArray(existingOrders || [])));
4253
4318
  protectedLocalOrders = protectedOrdersBeforeRemoteFetch.map(function (order) {
4254
- return _this25.normalizeOrderCollectionsForIngress(order, "".concat(source, ".protectedBeforeRemoteFetch"));
4319
+ return _this26.normalizeOrderCollectionsForIngress(order, "".concat(source, ".protectedBeforeRemoteFetch"));
4255
4320
  }).filter(function (order) {
4256
- return _this25.shouldProtectLocalOrderFromRemoteSnapshot(order);
4321
+ return _this26.shouldProtectLocalOrderFromRemoteSnapshot(order);
4257
4322
  });
4258
- _iterator37 = _createForOfIteratorHelper(existingOrders || []);
4259
- _context27.prev = 10;
4260
- _iterator37.s();
4261
- case 12:
4262
- if ((_step37 = _iterator37.n()).done) {
4263
- _context27.next = 23;
4323
+ _iterator39 = _createForOfIteratorHelper(existingOrders || []);
4324
+ _context27.prev = 11;
4325
+ _iterator39.s();
4326
+ case 13:
4327
+ if ((_step39 = _iterator39.n()).done) {
4328
+ _context27.next = 24;
4264
4329
  break;
4265
4330
  }
4266
- rawCurrentOrder = _step37.value;
4267
- currentOrder = _this25.normalizeOrderCollectionsForIngress(rawCurrentOrder, "".concat(source, ".currentSQLite"));
4268
- protectedIndex = _this25.findOrderIndexByIdentity(protectedLocalOrders, currentOrder);
4269
- currentNeedsProtection = _this25.shouldProtectLocalOrderFromRemoteSnapshot(currentOrder);
4331
+ rawCurrentOrder = _step39.value;
4332
+ currentOrder = _this26.normalizeOrderCollectionsForIngress(rawCurrentOrder, "".concat(source, ".currentSQLite"));
4333
+ protectedIndex = _this26.findOrderIndexByIdentity(protectedLocalOrders, currentOrder);
4334
+ currentNeedsProtection = _this26.shouldProtectLocalOrderFromRemoteSnapshot(currentOrder);
4270
4335
  if (!(protectedIndex >= 0)) {
4271
- _context27.next = 20;
4336
+ _context27.next = 21;
4272
4337
  break;
4273
4338
  }
4274
4339
  if (currentNeedsProtection) {
@@ -4276,27 +4341,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4276
4341
  } else {
4277
4342
  protectedLocalOrders.splice(protectedIndex, 1);
4278
4343
  }
4279
- return _context27.abrupt("continue", 21);
4280
- case 20:
4281
- if (currentNeedsProtection) protectedLocalOrders.push(currentOrder);
4344
+ return _context27.abrupt("continue", 22);
4282
4345
  case 21:
4283
- _context27.next = 12;
4346
+ if (currentNeedsProtection) protectedLocalOrders.push(currentOrder);
4347
+ case 22:
4348
+ _context27.next = 13;
4284
4349
  break;
4285
- case 23:
4286
- _context27.next = 28;
4350
+ case 24:
4351
+ _context27.next = 29;
4287
4352
  break;
4288
- case 25:
4289
- _context27.prev = 25;
4290
- _context27.t1 = _context27["catch"](10);
4291
- _iterator37.e(_context27.t1);
4292
- case 28:
4293
- _context27.prev = 28;
4294
- _iterator37.f();
4295
- return _context27.finish(28);
4296
- case 31:
4297
- orderListSnapshot = _this25.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, protectedLocalOrders);
4298
- mergedSnapshot = _this25.compactOrderListByIdentity(orderListSnapshot, "".concat(source, ".sqliteSnapshot")).list;
4299
- _this25.logInfo('replaceOrdersSnapshotInSQLite-开始', {
4353
+ case 26:
4354
+ _context27.prev = 26;
4355
+ _context27.t1 = _context27["catch"](11);
4356
+ _iterator39.e(_context27.t1);
4357
+ case 29:
4358
+ _context27.prev = 29;
4359
+ _iterator39.f();
4360
+ return _context27.finish(29);
4361
+ case 32:
4362
+ orderListSnapshot = _this26.mergeRemoteSnapshotWithPendingOrders(remoteSnapshotWithHolderRelations, protectedLocalOrders);
4363
+ mergedSnapshot = _this26.compactOrderListByIdentity(orderListSnapshot, "".concat(source, ".sqliteSnapshot")).list;
4364
+ _this26.logInfo('replaceOrdersSnapshotInSQLite-开始', {
4300
4365
  source: source,
4301
4366
  count: mergedSnapshot.length,
4302
4367
  remoteCount: remoteSnapshot.length,
@@ -4304,10 +4369,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4304
4369
  protectedLocalOrderCount: protectedLocalOrders.length,
4305
4370
  preservedLocalUnsyncedCount: mergedSnapshot.length - remoteSnapshot.length,
4306
4371
  protectedPendingPaymentCount: protectedLocalOrders.reduce(function (count, order) {
4307
- return count + _this25.getIdentifiedPendingPayments(order).length;
4372
+ return count + _this26.getIdentifiedPendingPayments(order).length;
4308
4373
  }, 0),
4309
4374
  protectedPendingPaymentIdentities: protectedLocalOrders.flatMap(function (order) {
4310
- return _this25.getIdentifiedPendingPayments(order).map(function (payment) {
4375
+ return _this26.getIdentifiedPendingPayments(order).map(function (payment) {
4311
4376
  var _order$order_id5, _external_sale_number5;
4312
4377
  return {
4313
4378
  order_id: (_order$order_id5 = order.order_id) !== null && _order$order_id5 !== void 0 ? _order$order_id5 : null,
@@ -4317,31 +4382,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4317
4382
  });
4318
4383
  })
4319
4384
  });
4320
- _context27.next = 36;
4321
- return _this25.dbManager.clear(INDEXDB_STORE_NAME);
4322
- case 36:
4323
- _this25.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
4385
+ _context27.next = 37;
4386
+ return _this26.dbManager.clear(INDEXDB_STORE_NAME);
4387
+ case 37:
4388
+ _this26.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
4324
4389
  count: mergedSnapshot.length
4325
4390
  });
4326
4391
  if (!(mergedSnapshot.length === 0)) {
4327
- _context27.next = 39;
4392
+ _context27.next = 40;
4328
4393
  break;
4329
4394
  }
4330
4395
  return _context27.abrupt("return");
4331
- case 39:
4332
- _context27.next = 41;
4333
- return _this25.dbManager.bulkAdd(INDEXDB_STORE_NAME, mergedSnapshot);
4334
- case 41:
4335
- _this25.recordRecentSqliteWrite(source, mergedSnapshot);
4336
- _this25.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
4396
+ case 40:
4397
+ _context27.next = 42;
4398
+ return _this26.dbManager.bulkAdd(INDEXDB_STORE_NAME, mergedSnapshot);
4399
+ case 42:
4400
+ _this26.recordRecentSqliteWrite(source, mergedSnapshot);
4401
+ _this26.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
4337
4402
  source: source,
4338
4403
  count: mergedSnapshot.length
4339
4404
  });
4340
- case 43:
4405
+ case 44:
4341
4406
  case "end":
4342
4407
  return _context27.stop();
4343
4408
  }
4344
- }, _callee27, null, [[10, 25, 28, 31]]);
4409
+ }, _callee27, null, [[11, 26, 29, 32]]);
4345
4410
  })));
4346
4411
  case 9:
4347
4412
  persisted = true;
@@ -4381,7 +4446,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4381
4446
  key: "clear",
4382
4447
  value: (function () {
4383
4448
  var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
4384
- var _this26 = this;
4449
+ var _this27 = this;
4385
4450
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
4386
4451
  while (1) switch (_context30.prev = _context30.next) {
4387
4452
  case 0:
@@ -4397,7 +4462,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4397
4462
  while (1) switch (_context29.prev = _context29.next) {
4398
4463
  case 0:
4399
4464
  _context29.next = 2;
4400
- return _this26.dbManager.clear(INDEXDB_STORE_NAME);
4465
+ return _this27.dbManager.clear(INDEXDB_STORE_NAME);
4401
4466
  case 2:
4402
4467
  case "end":
4403
4468
  return _context29.stop();