@pisell/pisellos 2.3.85 → 2.3.86
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.
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +251 -215
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +19 -4
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +23 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +14 -0
- package/package.json +1 -1
|
@@ -20,6 +20,8 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
20
20
|
private storage;
|
|
21
21
|
private orderSQLiteSaveQueue; /** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
22
22
|
private recentSqliteWriteByStorageKey;
|
|
23
|
+
/** 最近一次清理过期 SQLite 去重记录的时间,避免每次写入都遍历 Map */
|
|
24
|
+
private lastRecentSqliteWriteCleanupAtMs;
|
|
23
25
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
24
26
|
private lastServerFullFetchAtMs;
|
|
25
27
|
constructor(name?: string, version?: string);
|
|
@@ -58,6 +60,12 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
58
60
|
*/
|
|
59
61
|
private mergeAuthoritativeOrderCollection;
|
|
60
62
|
private reconcileOverwriteOrderCollections;
|
|
63
|
+
/**
|
|
64
|
+
* 惰性清理已经超过去重窗口的 SQLite 写入记录。
|
|
65
|
+
*
|
|
66
|
+
* 清理频率与去重窗口一致,既限制 Map 长期增长,也不会移除仍参与去重的记录。
|
|
67
|
+
*/
|
|
68
|
+
private cleanupExpiredRecentSqliteWrites;
|
|
61
69
|
/**
|
|
62
70
|
* 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
|
|
63
71
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
-
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."); }
|
|
4
|
-
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; } }
|
|
5
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
7
3
|
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."); }
|
|
8
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
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."); }
|
|
8
|
+
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; } }
|
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -91,6 +91,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
91
91
|
_defineProperty(_assertThisInitialized(_this), "orderSQLiteSaveQueue", Promise.resolve());
|
|
92
92
|
/** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
93
93
|
_defineProperty(_assertThisInitialized(_this), "recentSqliteWriteByStorageKey", new Map());
|
|
94
|
+
/** 最近一次清理过期 SQLite 去重记录的时间,避免每次写入都遍历 Map */
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "lastRecentSqliteWriteCleanupAtMs", 0);
|
|
94
96
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
95
97
|
_defineProperty(_assertThisInitialized(_this), "lastServerFullFetchAtMs", 0);
|
|
96
98
|
return _this;
|
|
@@ -434,6 +436,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
434
436
|
return this.normalizeOrderCollectionsForIngress(applyOrderCollectionUidRemaps(reconciled, uidRemaps), 'overwriteExistingOrder.reconciled');
|
|
435
437
|
}
|
|
436
438
|
|
|
439
|
+
/**
|
|
440
|
+
* 惰性清理已经超过去重窗口的 SQLite 写入记录。
|
|
441
|
+
*
|
|
442
|
+
* 清理频率与去重窗口一致,既限制 Map 长期增长,也不会移除仍参与去重的记录。
|
|
443
|
+
*/
|
|
444
|
+
}, {
|
|
445
|
+
key: "cleanupExpiredRecentSqliteWrites",
|
|
446
|
+
value: function cleanupExpiredRecentSqliteWrites(now) {
|
|
447
|
+
var elapsedSinceCleanup = now - this.lastRecentSqliteWriteCleanupAtMs;
|
|
448
|
+
if (this.lastRecentSqliteWriteCleanupAtMs > 0 && elapsedSinceCleanup >= 0 && elapsedSinceCleanup < ORDER_SQLITE_DEDUPE_MS) {
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
var _iterator3 = _createForOfIteratorHelper(this.recentSqliteWriteByStorageKey),
|
|
452
|
+
_step3;
|
|
453
|
+
try {
|
|
454
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
455
|
+
var _step3$value = _slicedToArray(_step3.value, 2),
|
|
456
|
+
storageKey = _step3$value[0],
|
|
457
|
+
recentWrite = _step3$value[1];
|
|
458
|
+
if (now - recentWrite.ts >= ORDER_SQLITE_DEDUPE_MS) {
|
|
459
|
+
this.recentSqliteWriteByStorageKey.delete(storageKey);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
} catch (err) {
|
|
463
|
+
_iterator3.e(err);
|
|
464
|
+
} finally {
|
|
465
|
+
_iterator3.f();
|
|
466
|
+
}
|
|
467
|
+
this.lastRecentSqliteWriteCleanupAtMs = now;
|
|
468
|
+
}
|
|
469
|
+
|
|
437
470
|
/**
|
|
438
471
|
* 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
|
|
439
472
|
*
|
|
@@ -444,11 +477,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
444
477
|
key: "recordRecentSqliteWrite",
|
|
445
478
|
value: function recordRecentSqliteWrite(source, orders) {
|
|
446
479
|
var now = Date.now();
|
|
447
|
-
|
|
448
|
-
|
|
480
|
+
this.cleanupExpiredRecentSqliteWrites(now);
|
|
481
|
+
var _iterator4 = _createForOfIteratorHelper(orders),
|
|
482
|
+
_step4;
|
|
449
483
|
try {
|
|
450
|
-
for (
|
|
451
|
-
var order =
|
|
484
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
485
|
+
var order = _step4.value;
|
|
452
486
|
var storageKey = this.getOrderStorageKey(order);
|
|
453
487
|
if (!storageKey) continue;
|
|
454
488
|
this.recentSqliteWriteByStorageKey.set(storageKey, {
|
|
@@ -457,9 +491,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
457
491
|
});
|
|
458
492
|
}
|
|
459
493
|
} catch (err) {
|
|
460
|
-
|
|
494
|
+
_iterator4.e(err);
|
|
461
495
|
} finally {
|
|
462
|
-
|
|
496
|
+
_iterator4.f();
|
|
463
497
|
}
|
|
464
498
|
}
|
|
465
499
|
|
|
@@ -483,11 +517,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
483
517
|
var now = Date.now();
|
|
484
518
|
var toWrite = [];
|
|
485
519
|
var skipped = [];
|
|
486
|
-
var
|
|
487
|
-
|
|
520
|
+
var _iterator5 = _createForOfIteratorHelper(orders),
|
|
521
|
+
_step5;
|
|
488
522
|
try {
|
|
489
|
-
for (
|
|
490
|
-
var order =
|
|
523
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
524
|
+
var order = _step5.value;
|
|
491
525
|
var storageKey = this.getOrderStorageKey(order);
|
|
492
526
|
if (!storageKey) {
|
|
493
527
|
toWrite.push(order);
|
|
@@ -522,9 +556,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
522
556
|
toWrite.push(order);
|
|
523
557
|
}
|
|
524
558
|
} catch (err) {
|
|
525
|
-
|
|
559
|
+
_iterator5.e(err);
|
|
526
560
|
} finally {
|
|
527
|
-
|
|
561
|
+
_iterator5.f();
|
|
528
562
|
}
|
|
529
563
|
return {
|
|
530
564
|
toWrite: toWrite,
|
|
@@ -544,11 +578,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
544
578
|
var now = Date.now();
|
|
545
579
|
var toFetch = [];
|
|
546
580
|
var skipped = [];
|
|
547
|
-
var
|
|
548
|
-
|
|
581
|
+
var _iterator6 = _createForOfIteratorHelper(ids),
|
|
582
|
+
_step6;
|
|
549
583
|
try {
|
|
550
|
-
for (
|
|
551
|
-
var id =
|
|
584
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
585
|
+
var id = _step6.value;
|
|
552
586
|
var existing = this.getOrderByOrderId(id);
|
|
553
587
|
if (!existing) {
|
|
554
588
|
toFetch.push(id);
|
|
@@ -567,9 +601,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
567
601
|
toFetch.push(id);
|
|
568
602
|
}
|
|
569
603
|
} catch (err) {
|
|
570
|
-
|
|
604
|
+
_iterator6.e(err);
|
|
571
605
|
} finally {
|
|
572
|
-
|
|
606
|
+
_iterator6.f();
|
|
573
607
|
}
|
|
574
608
|
return {
|
|
575
609
|
toFetch: toFetch,
|
|
@@ -1581,8 +1615,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1581
1615
|
var options,
|
|
1582
1616
|
pendingMap,
|
|
1583
1617
|
memoryPendingMap,
|
|
1584
|
-
|
|
1585
|
-
|
|
1618
|
+
_iterator7,
|
|
1619
|
+
_step7,
|
|
1586
1620
|
order,
|
|
1587
1621
|
normalizedOrder,
|
|
1588
1622
|
pendingOrder,
|
|
@@ -1591,12 +1625,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1591
1625
|
updatedList,
|
|
1592
1626
|
identityKeyToIndex,
|
|
1593
1627
|
index,
|
|
1594
|
-
_iterator7,
|
|
1595
|
-
_step7,
|
|
1596
|
-
key,
|
|
1597
1628
|
_iterator8,
|
|
1598
1629
|
_step8,
|
|
1599
|
-
|
|
1630
|
+
key,
|
|
1631
|
+
_iterator9,
|
|
1632
|
+
_step9,
|
|
1633
|
+
_step9$value,
|
|
1600
1634
|
_storageKey,
|
|
1601
1635
|
_pendingOrder,
|
|
1602
1636
|
matchIndex,
|
|
@@ -1621,15 +1655,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1621
1655
|
case 4:
|
|
1622
1656
|
pendingMap = new Map();
|
|
1623
1657
|
memoryPendingMap = new Map();
|
|
1624
|
-
|
|
1658
|
+
_iterator7 = _createForOfIteratorHelper(pendingOrders);
|
|
1625
1659
|
_context13.prev = 7;
|
|
1626
|
-
|
|
1660
|
+
_iterator7.s();
|
|
1627
1661
|
case 9:
|
|
1628
|
-
if ((
|
|
1662
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1629
1663
|
_context13.next = 20;
|
|
1630
1664
|
break;
|
|
1631
1665
|
}
|
|
1632
|
-
order =
|
|
1666
|
+
order = _step7.value;
|
|
1633
1667
|
normalizedOrder = this.normalizeOrderCollectionsForIngress(order, 'upsertPendingSyncOrders.incoming');
|
|
1634
1668
|
pendingOrder = _objectSpread(_objectSpread({}, normalizedOrder), {}, {
|
|
1635
1669
|
need_sync: 1,
|
|
@@ -1653,10 +1687,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1653
1687
|
case 22:
|
|
1654
1688
|
_context13.prev = 22;
|
|
1655
1689
|
_context13.t0 = _context13["catch"](7);
|
|
1656
|
-
|
|
1690
|
+
_iterator7.e(_context13.t0);
|
|
1657
1691
|
case 25:
|
|
1658
1692
|
_context13.prev = 25;
|
|
1659
|
-
|
|
1693
|
+
_iterator7.f();
|
|
1660
1694
|
return _context13.finish(25);
|
|
1661
1695
|
case 28:
|
|
1662
1696
|
if (!(pendingMap.size === 0)) {
|
|
@@ -1678,28 +1712,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1678
1712
|
// 从 O(n) 线性扫描降为 O(1),整体复杂度由 O(n^2) 降为 O(n + m)。
|
|
1679
1713
|
identityKeyToIndex = new Map();
|
|
1680
1714
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
1681
|
-
|
|
1715
|
+
_iterator8 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
1682
1716
|
try {
|
|
1683
|
-
for (
|
|
1684
|
-
key =
|
|
1717
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1718
|
+
key = _step8.value;
|
|
1685
1719
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
1686
1720
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
1687
1721
|
}
|
|
1688
1722
|
} catch (err) {
|
|
1689
|
-
|
|
1723
|
+
_iterator8.e(err);
|
|
1690
1724
|
} finally {
|
|
1691
|
-
|
|
1725
|
+
_iterator8.f();
|
|
1692
1726
|
}
|
|
1693
1727
|
}
|
|
1694
|
-
|
|
1728
|
+
_iterator9 = _createForOfIteratorHelper(memoryPendingMap.entries());
|
|
1695
1729
|
_context13.prev = 37;
|
|
1696
|
-
|
|
1730
|
+
_iterator9.s();
|
|
1697
1731
|
case 39:
|
|
1698
|
-
if ((
|
|
1732
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
1699
1733
|
_context13.next = 58;
|
|
1700
1734
|
break;
|
|
1701
1735
|
}
|
|
1702
|
-
|
|
1736
|
+
_step9$value = _slicedToArray(_step9.value, 2), _storageKey = _step9$value[0], _pendingOrder = _step9$value[1];
|
|
1703
1737
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_pendingOrder));
|
|
1704
1738
|
if (!(matchIndex >= 0)) {
|
|
1705
1739
|
_context13.next = 52;
|
|
@@ -1734,10 +1768,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1734
1768
|
case 60:
|
|
1735
1769
|
_context13.prev = 60;
|
|
1736
1770
|
_context13.t1 = _context13["catch"](37);
|
|
1737
|
-
|
|
1771
|
+
_iterator9.e(_context13.t1);
|
|
1738
1772
|
case 63:
|
|
1739
1773
|
_context13.prev = 63;
|
|
1740
|
-
|
|
1774
|
+
_iterator9.f();
|
|
1741
1775
|
return _context13.finish(63);
|
|
1742
1776
|
case 66:
|
|
1743
1777
|
patchedOrders = _toConsumableArray(pendingMap.values()); // 增量索引已保证 store 去重不变量,无需再对全表做 O(n^2) 压缩;仅自检开关开启时兜底。
|
|
@@ -1784,7 +1818,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1784
1818
|
value: (function () {
|
|
1785
1819
|
var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(draftOrders) {
|
|
1786
1820
|
var _this11 = this;
|
|
1787
|
-
var draftMap, memoryDraftMap,
|
|
1821
|
+
var draftMap, memoryDraftMap, _iterator10, _step10, order, draftOrder, storageKey, memoryDraftOrder, mergeActions, updatedList, identityKeyToIndex, index, _iterator11, _step11, key, _iterator12, _step12, _step12$value, _storageKey2, _draftOrder, matchIndex, existingOrder, reconciledDraftOrder, mergedOrder, nextOrder, insertIndex, patchedOrders, previousList, removedLegacyMemoryDraft;
|
|
1788
1822
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1789
1823
|
while (1) switch (_context14.prev = _context14.next) {
|
|
1790
1824
|
case 0:
|
|
@@ -1797,15 +1831,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1797
1831
|
case 3:
|
|
1798
1832
|
draftMap = new Map();
|
|
1799
1833
|
memoryDraftMap = new Map();
|
|
1800
|
-
|
|
1834
|
+
_iterator10 = _createForOfIteratorHelper(draftOrders);
|
|
1801
1835
|
_context14.prev = 6;
|
|
1802
|
-
|
|
1836
|
+
_iterator10.s();
|
|
1803
1837
|
case 8:
|
|
1804
|
-
if ((
|
|
1838
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
1805
1839
|
_context14.next = 19;
|
|
1806
1840
|
break;
|
|
1807
1841
|
}
|
|
1808
|
-
order =
|
|
1842
|
+
order = _step10.value;
|
|
1809
1843
|
draftOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
1810
1844
|
need_sync: 0,
|
|
1811
1845
|
is_draft_order: 1
|
|
@@ -1831,10 +1865,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1831
1865
|
case 21:
|
|
1832
1866
|
_context14.prev = 21;
|
|
1833
1867
|
_context14.t0 = _context14["catch"](6);
|
|
1834
|
-
|
|
1868
|
+
_iterator10.e(_context14.t0);
|
|
1835
1869
|
case 24:
|
|
1836
1870
|
_context14.prev = 24;
|
|
1837
|
-
|
|
1871
|
+
_iterator10.f();
|
|
1838
1872
|
return _context14.finish(24);
|
|
1839
1873
|
case 27:
|
|
1840
1874
|
if (!(draftMap.size === 0)) {
|
|
@@ -1857,27 +1891,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1857
1891
|
});
|
|
1858
1892
|
identityKeyToIndex = new Map();
|
|
1859
1893
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
1860
|
-
|
|
1894
|
+
_iterator11 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[index]));
|
|
1861
1895
|
try {
|
|
1862
|
-
for (
|
|
1863
|
-
key =
|
|
1896
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1897
|
+
key = _step11.value;
|
|
1864
1898
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
1865
1899
|
}
|
|
1866
1900
|
} catch (err) {
|
|
1867
|
-
|
|
1901
|
+
_iterator11.e(err);
|
|
1868
1902
|
} finally {
|
|
1869
|
-
|
|
1903
|
+
_iterator11.f();
|
|
1870
1904
|
}
|
|
1871
1905
|
}
|
|
1872
|
-
|
|
1906
|
+
_iterator12 = _createForOfIteratorHelper(memoryDraftMap.entries());
|
|
1873
1907
|
_context14.prev = 36;
|
|
1874
|
-
|
|
1908
|
+
_iterator12.s();
|
|
1875
1909
|
case 38:
|
|
1876
|
-
if ((
|
|
1910
|
+
if ((_step12 = _iterator12.n()).done) {
|
|
1877
1911
|
_context14.next = 57;
|
|
1878
1912
|
break;
|
|
1879
1913
|
}
|
|
1880
|
-
|
|
1914
|
+
_step12$value = _slicedToArray(_step12.value, 2), _storageKey2 = _step12$value[0], _draftOrder = _step12$value[1];
|
|
1881
1915
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_draftOrder));
|
|
1882
1916
|
if (!(matchIndex >= 0)) {
|
|
1883
1917
|
_context14.next = 51;
|
|
@@ -1910,10 +1944,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1910
1944
|
case 59:
|
|
1911
1945
|
_context14.prev = 59;
|
|
1912
1946
|
_context14.t1 = _context14["catch"](36);
|
|
1913
|
-
|
|
1947
|
+
_iterator12.e(_context14.t1);
|
|
1914
1948
|
case 62:
|
|
1915
1949
|
_context14.prev = 62;
|
|
1916
|
-
|
|
1950
|
+
_iterator12.f();
|
|
1917
1951
|
return _context14.finish(62);
|
|
1918
1952
|
case 65:
|
|
1919
1953
|
patchedOrders = _toConsumableArray(draftMap.values());
|
|
@@ -2025,6 +2059,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2025
2059
|
}
|
|
2026
2060
|
this.isProcessingSyncBatch = false;
|
|
2027
2061
|
this.pendingSyncMessages = [];
|
|
2062
|
+
this.recentSqliteWriteByStorageKey.clear();
|
|
2063
|
+
this.lastRecentSqliteWriteCleanupAtMs = 0;
|
|
2028
2064
|
if ((_this$orderDataSource = this.orderDataSource) !== null && _this$orderDataSource !== void 0 && _this$orderDataSource.destroy) this.orderDataSource.destroy();
|
|
2029
2065
|
_get(_getPrototypeOf(OrderModule.prototype), "destroy", this).call(this);
|
|
2030
2066
|
}
|
|
@@ -2036,19 +2072,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2036
2072
|
return _this12.shouldKeepOrderInMemory(order);
|
|
2037
2073
|
});
|
|
2038
2074
|
this.store.map.clear();
|
|
2039
|
-
var
|
|
2040
|
-
|
|
2075
|
+
var _iterator13 = _createForOfIteratorHelper(this.store.list),
|
|
2076
|
+
_step13;
|
|
2041
2077
|
try {
|
|
2042
|
-
for (
|
|
2043
|
-
var order =
|
|
2078
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2079
|
+
var order = _step13.value;
|
|
2044
2080
|
var primaryIdentity = this.getOrderMapKey(order);
|
|
2045
2081
|
if (!primaryIdentity) continue;
|
|
2046
2082
|
this.store.map.set(primaryIdentity, order);
|
|
2047
2083
|
}
|
|
2048
2084
|
} catch (err) {
|
|
2049
|
-
|
|
2085
|
+
_iterator13.e(err);
|
|
2050
2086
|
} finally {
|
|
2051
|
-
|
|
2087
|
+
_iterator13.f();
|
|
2052
2088
|
}
|
|
2053
2089
|
}
|
|
2054
2090
|
}, {
|
|
@@ -2129,17 +2165,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2129
2165
|
key: "getOrderIdentityKeys",
|
|
2130
2166
|
value: function getOrderIdentityKeys(order) {
|
|
2131
2167
|
var keys = [];
|
|
2132
|
-
var
|
|
2133
|
-
|
|
2168
|
+
var _iterator14 = _createForOfIteratorHelper(this.getOrderIdentityEntries(order)),
|
|
2169
|
+
_step14;
|
|
2134
2170
|
try {
|
|
2135
|
-
for (
|
|
2136
|
-
var entry =
|
|
2171
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
2172
|
+
var entry = _step14.value;
|
|
2137
2173
|
if (!keys.includes(entry.key)) keys.push(entry.key);
|
|
2138
2174
|
}
|
|
2139
2175
|
} catch (err) {
|
|
2140
|
-
|
|
2176
|
+
_iterator14.e(err);
|
|
2141
2177
|
} finally {
|
|
2142
|
-
|
|
2178
|
+
_iterator14.f();
|
|
2143
2179
|
}
|
|
2144
2180
|
return keys;
|
|
2145
2181
|
}
|
|
@@ -2467,7 +2503,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2467
2503
|
value: (function () {
|
|
2468
2504
|
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(freshOrders, source) {
|
|
2469
2505
|
var _this17 = this;
|
|
2470
|
-
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity,
|
|
2506
|
+
var storeOrderCountBefore, normalizedFreshOrders, incomingProductsHaveStableIdentity, _iterator15, _step15, order, id, rawProducts, _incomingProductsHave, allProductsHaveStableIdentity, orderIdKey, uniqueFreshOrders, uniqueFreshCount, patchedOrders, remoteProductMembershipChanges, forceWriteStorageKeys, storageKeyMigrations, mergeActions, existingProductsHaveStableIdentity, updatedList, identityKeyToIndex, index, identityKeys, _iterator16, _step16, key, _iterator17, _step17, fresh, freshIdentityKeys, matchIndex, storageKey, mergeKey, existingOrder, previousStorageKey, _ref, _existingOrder$order_, _ref2, _external_sale_number2, _existingOrder$paymen, _fresh$payment_status, _existingOrder$need_s, _fresh$need_sync, _ref3, _existingOrder$order_2, _ref4, _external_sale_number3, _existingOrder$is_dra, _fresh$is_draft_order, mergedOrder, freshOrderId, incomingProductsAreStable, membershipChange, mergedProductsHaveStableIdentity, adjustedMatchIndex, duplicateIndexes, _iterator18, _step18, _key2, _duplicateIndex, _iterator19, _step19, duplicateIndex, _index, _iterator20, _step20, _key, nextStorageKey, _ref5, _ref6, _mergedOrder$order_id, mergedStorageKey, insertIndex, insertCount, updateCount;
|
|
2471
2507
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2472
2508
|
while (1) switch (_context19.prev = _context19.next) {
|
|
2473
2509
|
case 0:
|
|
@@ -2480,15 +2516,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2480
2516
|
this.logDuplicateOrders("".concat(source, ".beforeMerge"), this.store.list);
|
|
2481
2517
|
normalizedFreshOrders = [];
|
|
2482
2518
|
incomingProductsHaveStableIdentity = new Map();
|
|
2483
|
-
|
|
2519
|
+
_iterator15 = _createForOfIteratorHelper(freshOrders);
|
|
2484
2520
|
_context19.prev = 6;
|
|
2485
|
-
|
|
2521
|
+
_iterator15.s();
|
|
2486
2522
|
case 8:
|
|
2487
|
-
if ((
|
|
2523
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
2488
2524
|
_context19.next = 18;
|
|
2489
2525
|
break;
|
|
2490
2526
|
}
|
|
2491
|
-
order =
|
|
2527
|
+
order = _step15.value;
|
|
2492
2528
|
id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
2493
2529
|
if (!(id === undefined || id === null)) {
|
|
2494
2530
|
_context19.next = 13;
|
|
@@ -2512,10 +2548,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2512
2548
|
case 20:
|
|
2513
2549
|
_context19.prev = 20;
|
|
2514
2550
|
_context19.t0 = _context19["catch"](6);
|
|
2515
|
-
|
|
2551
|
+
_iterator15.e(_context19.t0);
|
|
2516
2552
|
case 23:
|
|
2517
2553
|
_context19.prev = 23;
|
|
2518
|
-
|
|
2554
|
+
_iterator15.f();
|
|
2519
2555
|
return _context19.finish(23);
|
|
2520
2556
|
case 26:
|
|
2521
2557
|
// 先对本批新单做去重(批内规模 m 很小),保证每条 fresh 身份唯一
|
|
@@ -2537,28 +2573,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2537
2573
|
identityKeyToIndex = new Map();
|
|
2538
2574
|
for (index = 0; index < updatedList.length; index += 1) {
|
|
2539
2575
|
identityKeys = this.getOrderIdentityMatchKeys(updatedList[index]);
|
|
2540
|
-
|
|
2576
|
+
_iterator16 = _createForOfIteratorHelper(identityKeys);
|
|
2541
2577
|
try {
|
|
2542
|
-
for (
|
|
2543
|
-
key =
|
|
2578
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
2579
|
+
key = _step16.value;
|
|
2544
2580
|
// 同一 key 命中多张时保留最靠前的下标,与原 findIndex「取首个匹配」一致
|
|
2545
2581
|
if (!identityKeyToIndex.has(key)) identityKeyToIndex.set(key, index);
|
|
2546
2582
|
}
|
|
2547
2583
|
} catch (err) {
|
|
2548
|
-
|
|
2584
|
+
_iterator16.e(err);
|
|
2549
2585
|
} finally {
|
|
2550
|
-
|
|
2586
|
+
_iterator16.f();
|
|
2551
2587
|
}
|
|
2552
2588
|
}
|
|
2553
|
-
|
|
2589
|
+
_iterator17 = _createForOfIteratorHelper(uniqueFreshOrders);
|
|
2554
2590
|
_context19.prev = 38;
|
|
2555
|
-
|
|
2591
|
+
_iterator17.s();
|
|
2556
2592
|
case 40:
|
|
2557
|
-
if ((
|
|
2593
|
+
if ((_step17 = _iterator17.n()).done) {
|
|
2558
2594
|
_context19.next = 100;
|
|
2559
2595
|
break;
|
|
2560
2596
|
}
|
|
2561
|
-
fresh =
|
|
2597
|
+
fresh = _step17.value;
|
|
2562
2598
|
freshIdentityKeys = this.getOrderIdentityMatchKeys(fresh);
|
|
2563
2599
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, freshIdentityKeys);
|
|
2564
2600
|
storageKey = this.getOrderStorageKey(fresh);
|
|
@@ -2609,15 +2645,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2609
2645
|
mergedProductsHaveStableIdentity = existingProductsHaveStableIdentity[matchIndex] !== false && incomingProductsAreStable;
|
|
2610
2646
|
adjustedMatchIndex = matchIndex;
|
|
2611
2647
|
duplicateIndexes = new Set();
|
|
2612
|
-
|
|
2648
|
+
_iterator18 = _createForOfIteratorHelper(freshIdentityKeys);
|
|
2613
2649
|
_context19.prev = 64;
|
|
2614
|
-
|
|
2650
|
+
_iterator18.s();
|
|
2615
2651
|
case 66:
|
|
2616
|
-
if ((
|
|
2652
|
+
if ((_step18 = _iterator18.n()).done) {
|
|
2617
2653
|
_context19.next = 74;
|
|
2618
2654
|
break;
|
|
2619
2655
|
}
|
|
2620
|
-
_key2 =
|
|
2656
|
+
_key2 = _step18.value;
|
|
2621
2657
|
_duplicateIndex = identityKeyToIndex.get(_key2);
|
|
2622
2658
|
if (!(_duplicateIndex === undefined || _duplicateIndex === matchIndex)) {
|
|
2623
2659
|
_context19.next = 71;
|
|
@@ -2635,19 +2671,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2635
2671
|
case 76:
|
|
2636
2672
|
_context19.prev = 76;
|
|
2637
2673
|
_context19.t1 = _context19["catch"](64);
|
|
2638
|
-
|
|
2674
|
+
_iterator18.e(_context19.t1);
|
|
2639
2675
|
case 79:
|
|
2640
2676
|
_context19.prev = 79;
|
|
2641
|
-
|
|
2677
|
+
_iterator18.f();
|
|
2642
2678
|
return _context19.finish(79);
|
|
2643
2679
|
case 82:
|
|
2644
2680
|
if (duplicateIndexes.size > 0) {
|
|
2645
|
-
|
|
2681
|
+
_iterator19 = _createForOfIteratorHelper(_toConsumableArray(duplicateIndexes).sort(function (left, right) {
|
|
2646
2682
|
return right - left;
|
|
2647
2683
|
}));
|
|
2648
2684
|
try {
|
|
2649
|
-
for (
|
|
2650
|
-
duplicateIndex =
|
|
2685
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
2686
|
+
duplicateIndex = _step19.value;
|
|
2651
2687
|
mergedOrder = this.mergeOrderRecords(mergedOrder, updatedList[duplicateIndex]);
|
|
2652
2688
|
mergedProductsHaveStableIdentity = mergedProductsHaveStableIdentity && existingProductsHaveStableIdentity[duplicateIndex] !== false;
|
|
2653
2689
|
updatedList.splice(duplicateIndex, 1);
|
|
@@ -2655,22 +2691,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2655
2691
|
if (duplicateIndex < adjustedMatchIndex) adjustedMatchIndex -= 1;
|
|
2656
2692
|
}
|
|
2657
2693
|
} catch (err) {
|
|
2658
|
-
|
|
2694
|
+
_iterator19.e(err);
|
|
2659
2695
|
} finally {
|
|
2660
|
-
|
|
2696
|
+
_iterator19.f();
|
|
2661
2697
|
}
|
|
2662
2698
|
identityKeyToIndex.clear();
|
|
2663
2699
|
for (_index = 0; _index < updatedList.length; _index += 1) {
|
|
2664
|
-
|
|
2700
|
+
_iterator20 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(updatedList[_index]));
|
|
2665
2701
|
try {
|
|
2666
|
-
for (
|
|
2667
|
-
_key =
|
|
2702
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
2703
|
+
_key = _step20.value;
|
|
2668
2704
|
if (!identityKeyToIndex.has(_key)) identityKeyToIndex.set(_key, _index);
|
|
2669
2705
|
}
|
|
2670
2706
|
} catch (err) {
|
|
2671
|
-
|
|
2707
|
+
_iterator20.e(err);
|
|
2672
2708
|
} finally {
|
|
2673
|
-
|
|
2709
|
+
_iterator20.f();
|
|
2674
2710
|
}
|
|
2675
2711
|
}
|
|
2676
2712
|
}
|
|
@@ -2711,10 +2747,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2711
2747
|
case 102:
|
|
2712
2748
|
_context19.prev = 102;
|
|
2713
2749
|
_context19.t2 = _context19["catch"](38);
|
|
2714
|
-
|
|
2750
|
+
_iterator17.e(_context19.t2);
|
|
2715
2751
|
case 105:
|
|
2716
2752
|
_context19.prev = 105;
|
|
2717
|
-
|
|
2753
|
+
_iterator17.f();
|
|
2718
2754
|
return _context19.finish(105);
|
|
2719
2755
|
case 108:
|
|
2720
2756
|
insertCount = Object.values(mergeActions).filter(function (v) {
|
|
@@ -2771,19 +2807,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2771
2807
|
key: "lookupOrderIndexByIdentityKeys",
|
|
2772
2808
|
value: function lookupOrderIndexByIdentityKeys(identityKeyToIndex, identityKeys) {
|
|
2773
2809
|
var matchIndex = -1;
|
|
2774
|
-
var
|
|
2775
|
-
|
|
2810
|
+
var _iterator21 = _createForOfIteratorHelper(identityKeys),
|
|
2811
|
+
_step21;
|
|
2776
2812
|
try {
|
|
2777
|
-
for (
|
|
2778
|
-
var key =
|
|
2813
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
2814
|
+
var key = _step21.value;
|
|
2779
2815
|
var index = identityKeyToIndex.get(key);
|
|
2780
2816
|
if (index === undefined) continue;
|
|
2781
2817
|
if (matchIndex < 0 || index < matchIndex) matchIndex = index;
|
|
2782
2818
|
}
|
|
2783
2819
|
} catch (err) {
|
|
2784
|
-
|
|
2820
|
+
_iterator21.e(err);
|
|
2785
2821
|
} finally {
|
|
2786
|
-
|
|
2822
|
+
_iterator21.f();
|
|
2787
2823
|
}
|
|
2788
2824
|
return matchIndex;
|
|
2789
2825
|
}
|
|
@@ -2843,11 +2879,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2843
2879
|
return index;
|
|
2844
2880
|
}));
|
|
2845
2881
|
var removedProductKeys = [];
|
|
2846
|
-
var
|
|
2847
|
-
|
|
2882
|
+
var _iterator22 = _createForOfIteratorHelper(previousProducts),
|
|
2883
|
+
_step22;
|
|
2848
2884
|
try {
|
|
2849
2885
|
var _loop2 = function _loop2() {
|
|
2850
|
-
var previousProduct =
|
|
2886
|
+
var previousProduct = _step22.value;
|
|
2851
2887
|
var matchedIndex = currentProducts.findIndex(function (currentProduct, index) {
|
|
2852
2888
|
return unmatchedCurrentIndexes.has(index) && _this18.isSameProductMembershipItem(previousProduct, currentProduct);
|
|
2853
2889
|
});
|
|
@@ -2858,13 +2894,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2858
2894
|
var productKey = _this18.getProductMembershipKey(previousProduct);
|
|
2859
2895
|
if (productKey) removedProductKeys.push(productKey);
|
|
2860
2896
|
};
|
|
2861
|
-
for (
|
|
2897
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
2862
2898
|
if (_loop2()) continue;
|
|
2863
2899
|
}
|
|
2864
2900
|
} catch (err) {
|
|
2865
|
-
|
|
2901
|
+
_iterator22.e(err);
|
|
2866
2902
|
} finally {
|
|
2867
|
-
|
|
2903
|
+
_iterator22.f();
|
|
2868
2904
|
}
|
|
2869
2905
|
var addedProductKeys = _toConsumableArray(unmatchedCurrentIndexes).map(function (index) {
|
|
2870
2906
|
return _this18.getProductMembershipKey(currentProducts[index]);
|
|
@@ -2895,17 +2931,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2895
2931
|
key: "registerOrderIdentityKeys",
|
|
2896
2932
|
value: function registerOrderIdentityKeys(identityKeyToIndex, order, index) {
|
|
2897
2933
|
var identityKeys = this.getOrderIdentityMatchKeys(order);
|
|
2898
|
-
var
|
|
2899
|
-
|
|
2934
|
+
var _iterator23 = _createForOfIteratorHelper(identityKeys),
|
|
2935
|
+
_step23;
|
|
2900
2936
|
try {
|
|
2901
|
-
for (
|
|
2902
|
-
var key =
|
|
2937
|
+
for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {
|
|
2938
|
+
var key = _step23.value;
|
|
2903
2939
|
identityKeyToIndex.set(key, index);
|
|
2904
2940
|
}
|
|
2905
2941
|
} catch (err) {
|
|
2906
|
-
|
|
2942
|
+
_iterator23.e(err);
|
|
2907
2943
|
} finally {
|
|
2908
|
-
|
|
2944
|
+
_iterator23.f();
|
|
2909
2945
|
}
|
|
2910
2946
|
}
|
|
2911
2947
|
|
|
@@ -2960,17 +2996,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2960
2996
|
key: "uniqueOrderIds",
|
|
2961
2997
|
value: function uniqueOrderIds(ids) {
|
|
2962
2998
|
var idMap = new Map();
|
|
2963
|
-
var
|
|
2964
|
-
|
|
2999
|
+
var _iterator24 = _createForOfIteratorHelper(ids),
|
|
3000
|
+
_step24;
|
|
2965
3001
|
try {
|
|
2966
|
-
for (
|
|
2967
|
-
var id =
|
|
3002
|
+
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
3003
|
+
var id = _step24.value;
|
|
2968
3004
|
idMap.set(this.getIdKey(id), id);
|
|
2969
3005
|
}
|
|
2970
3006
|
} catch (err) {
|
|
2971
|
-
|
|
3007
|
+
_iterator24.e(err);
|
|
2972
3008
|
} finally {
|
|
2973
|
-
|
|
3009
|
+
_iterator24.f();
|
|
2974
3010
|
}
|
|
2975
3011
|
return _toConsumableArray(idMap.values());
|
|
2976
3012
|
}
|
|
@@ -3091,58 +3127,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3091
3127
|
if (secondaryList.length === 0) return preferredList;
|
|
3092
3128
|
if (preferredList.length === 0) return secondaryList;
|
|
3093
3129
|
var seenKeys = new Set();
|
|
3094
|
-
var
|
|
3095
|
-
|
|
3130
|
+
var _iterator25 = _createForOfIteratorHelper(preferredList),
|
|
3131
|
+
_step25;
|
|
3096
3132
|
try {
|
|
3097
|
-
for (
|
|
3098
|
-
var item =
|
|
3133
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
3134
|
+
var item = _step25.value;
|
|
3099
3135
|
var keys = this.getProductIdentityKeys(item);
|
|
3100
|
-
var
|
|
3101
|
-
|
|
3136
|
+
var _iterator27 = _createForOfIteratorHelper(keys),
|
|
3137
|
+
_step27;
|
|
3102
3138
|
try {
|
|
3103
|
-
for (
|
|
3104
|
-
var key =
|
|
3139
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
3140
|
+
var key = _step27.value;
|
|
3105
3141
|
seenKeys.add(key);
|
|
3106
3142
|
}
|
|
3107
3143
|
} catch (err) {
|
|
3108
|
-
|
|
3144
|
+
_iterator27.e(err);
|
|
3109
3145
|
} finally {
|
|
3110
|
-
|
|
3146
|
+
_iterator27.f();
|
|
3111
3147
|
}
|
|
3112
3148
|
}
|
|
3113
3149
|
} catch (err) {
|
|
3114
|
-
|
|
3150
|
+
_iterator25.e(err);
|
|
3115
3151
|
} finally {
|
|
3116
|
-
|
|
3152
|
+
_iterator25.f();
|
|
3117
3153
|
}
|
|
3118
3154
|
var result = _toConsumableArray(preferredList);
|
|
3119
|
-
var
|
|
3120
|
-
|
|
3155
|
+
var _iterator26 = _createForOfIteratorHelper(secondaryList),
|
|
3156
|
+
_step26;
|
|
3121
3157
|
try {
|
|
3122
|
-
for (
|
|
3123
|
-
var _item =
|
|
3158
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
3159
|
+
var _item = _step26.value;
|
|
3124
3160
|
var _keys = this.getProductIdentityKeys(_item);
|
|
3125
3161
|
if (_keys.length === 0 || _keys.some(function (key) {
|
|
3126
3162
|
return seenKeys.has(key);
|
|
3127
3163
|
})) continue;
|
|
3128
|
-
var
|
|
3129
|
-
|
|
3164
|
+
var _iterator28 = _createForOfIteratorHelper(_keys),
|
|
3165
|
+
_step28;
|
|
3130
3166
|
try {
|
|
3131
|
-
for (
|
|
3132
|
-
var _key3 =
|
|
3167
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
3168
|
+
var _key3 = _step28.value;
|
|
3133
3169
|
seenKeys.add(_key3);
|
|
3134
3170
|
}
|
|
3135
3171
|
} catch (err) {
|
|
3136
|
-
|
|
3172
|
+
_iterator28.e(err);
|
|
3137
3173
|
} finally {
|
|
3138
|
-
|
|
3174
|
+
_iterator28.f();
|
|
3139
3175
|
}
|
|
3140
3176
|
result.push(cloneDeep(_item));
|
|
3141
3177
|
}
|
|
3142
3178
|
} catch (err) {
|
|
3143
|
-
|
|
3179
|
+
_iterator26.e(err);
|
|
3144
3180
|
} finally {
|
|
3145
|
-
|
|
3181
|
+
_iterator26.f();
|
|
3146
3182
|
}
|
|
3147
3183
|
return result;
|
|
3148
3184
|
}
|
|
@@ -3252,30 +3288,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3252
3288
|
key: "summarizeDuplicateOrders",
|
|
3253
3289
|
value: function summarizeDuplicateOrders(orders) {
|
|
3254
3290
|
var groups = new Map();
|
|
3255
|
-
var
|
|
3256
|
-
|
|
3291
|
+
var _iterator29 = _createForOfIteratorHelper(orders),
|
|
3292
|
+
_step29;
|
|
3257
3293
|
try {
|
|
3258
|
-
for (
|
|
3259
|
-
var order =
|
|
3260
|
-
var
|
|
3261
|
-
|
|
3294
|
+
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
3295
|
+
var order = _step29.value;
|
|
3296
|
+
var _iterator30 = _createForOfIteratorHelper(this.getOrderIdentityMatchKeys(order)),
|
|
3297
|
+
_step30;
|
|
3262
3298
|
try {
|
|
3263
|
-
for (
|
|
3264
|
-
var key =
|
|
3299
|
+
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
3300
|
+
var key = _step30.value;
|
|
3265
3301
|
var group = groups.get(key) || [];
|
|
3266
3302
|
group.push(order);
|
|
3267
3303
|
groups.set(key, group);
|
|
3268
3304
|
}
|
|
3269
3305
|
} catch (err) {
|
|
3270
|
-
|
|
3306
|
+
_iterator30.e(err);
|
|
3271
3307
|
} finally {
|
|
3272
|
-
|
|
3308
|
+
_iterator30.f();
|
|
3273
3309
|
}
|
|
3274
3310
|
}
|
|
3275
3311
|
} catch (err) {
|
|
3276
|
-
|
|
3312
|
+
_iterator29.e(err);
|
|
3277
3313
|
} finally {
|
|
3278
|
-
|
|
3314
|
+
_iterator29.f();
|
|
3279
3315
|
}
|
|
3280
3316
|
return _toConsumableArray(groups.entries()).filter(function (_ref9) {
|
|
3281
3317
|
var _ref10 = _slicedToArray(_ref9, 2),
|
|
@@ -3318,11 +3354,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3318
3354
|
value: function compactOrderListByIdentity(orders, source) {
|
|
3319
3355
|
var list = [];
|
|
3320
3356
|
var removedCount = 0;
|
|
3321
|
-
var
|
|
3322
|
-
|
|
3357
|
+
var _iterator31 = _createForOfIteratorHelper(orders),
|
|
3358
|
+
_step31;
|
|
3323
3359
|
try {
|
|
3324
|
-
for (
|
|
3325
|
-
var order =
|
|
3360
|
+
for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
|
|
3361
|
+
var order = _step31.value;
|
|
3326
3362
|
var normalizedOrder = this.normalizeOrderCollectionsForIngress(order, "".concat(source, ".order"));
|
|
3327
3363
|
var matchIndex = this.findOrderIndexByIdentity(list, normalizedOrder);
|
|
3328
3364
|
if (matchIndex < 0) {
|
|
@@ -3333,9 +3369,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3333
3369
|
removedCount += 1;
|
|
3334
3370
|
}
|
|
3335
3371
|
} catch (err) {
|
|
3336
|
-
|
|
3372
|
+
_iterator31.e(err);
|
|
3337
3373
|
} finally {
|
|
3338
|
-
|
|
3374
|
+
_iterator31.f();
|
|
3339
3375
|
}
|
|
3340
3376
|
if (removedCount > 0) {
|
|
3341
3377
|
this.logWarning('订单列表重复项已压缩', {
|
|
@@ -3576,11 +3612,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3576
3612
|
var merged = remoteOrders.map(function (order) {
|
|
3577
3613
|
return _this22.normalizeRemoteSyncedOrder(order);
|
|
3578
3614
|
});
|
|
3579
|
-
var
|
|
3580
|
-
|
|
3615
|
+
var _iterator32 = _createForOfIteratorHelper(existingOrders),
|
|
3616
|
+
_step32;
|
|
3581
3617
|
try {
|
|
3582
|
-
for (
|
|
3583
|
-
var rawOrder =
|
|
3618
|
+
for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
|
|
3619
|
+
var rawOrder = _step32.value;
|
|
3584
3620
|
var order = this.normalizeOrderCollectionsForIngress(rawOrder, 'mergeRemoteSnapshotWithPendingOrders.existingSQLite');
|
|
3585
3621
|
if (!this.shouldProtectLocalOrderFromRemoteSnapshot(order)) continue;
|
|
3586
3622
|
var matchIndex = this.findOrderIndexByIdentity(merged, order);
|
|
@@ -3596,9 +3632,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3596
3632
|
merged.push(order);
|
|
3597
3633
|
}
|
|
3598
3634
|
} catch (err) {
|
|
3599
|
-
|
|
3635
|
+
_iterator32.e(err);
|
|
3600
3636
|
} finally {
|
|
3601
|
-
|
|
3637
|
+
_iterator32.f();
|
|
3602
3638
|
}
|
|
3603
3639
|
return this.compactOrderListByIdentity(merged, 'mergeRemoteSnapshotWithPendingOrders').list;
|
|
3604
3640
|
}
|
|
@@ -3660,8 +3696,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3660
3696
|
compactedToWrite,
|
|
3661
3697
|
writtenStorageKeys,
|
|
3662
3698
|
storageKeyMigrations,
|
|
3663
|
-
|
|
3664
|
-
|
|
3699
|
+
_iterator33,
|
|
3700
|
+
_step33,
|
|
3665
3701
|
migration,
|
|
3666
3702
|
_args23 = arguments;
|
|
3667
3703
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
@@ -3724,15 +3760,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3724
3760
|
return _this23.getOrderStorageKey(order);
|
|
3725
3761
|
}).filter(Boolean));
|
|
3726
3762
|
storageKeyMigrations = new Map();
|
|
3727
|
-
|
|
3763
|
+
_iterator33 = _createForOfIteratorHelper(options.storageKeyMigrations || []);
|
|
3728
3764
|
_context23.prev = 22;
|
|
3729
|
-
|
|
3765
|
+
_iterator33.s();
|
|
3730
3766
|
case 24:
|
|
3731
|
-
if ((
|
|
3767
|
+
if ((_step33 = _iterator33.n()).done) {
|
|
3732
3768
|
_context23.next = 33;
|
|
3733
3769
|
break;
|
|
3734
3770
|
}
|
|
3735
|
-
migration =
|
|
3771
|
+
migration = _step33.value;
|
|
3736
3772
|
if (writtenStorageKeys.has(migration.to)) {
|
|
3737
3773
|
_context23.next = 28;
|
|
3738
3774
|
break;
|
|
@@ -3755,16 +3791,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3755
3791
|
case 35:
|
|
3756
3792
|
_context23.prev = 35;
|
|
3757
3793
|
_context23.t0 = _context23["catch"](22);
|
|
3758
|
-
|
|
3794
|
+
_iterator33.e(_context23.t0);
|
|
3759
3795
|
case 38:
|
|
3760
3796
|
_context23.prev = 38;
|
|
3761
|
-
|
|
3797
|
+
_iterator33.f();
|
|
3762
3798
|
return _context23.finish(38);
|
|
3763
3799
|
case 41:
|
|
3764
3800
|
_context23.prev = 41;
|
|
3765
3801
|
_context23.next = 44;
|
|
3766
3802
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
3767
|
-
var writeMethod,
|
|
3803
|
+
var writeMethod, _iterator34, _step34, order, _iterator35, _step35, migration, _iterator36, _step36, _orderRecord$ORDER_ST, _order, orderRecord;
|
|
3768
3804
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
3769
3805
|
while (1) switch (_context22.prev = _context22.next) {
|
|
3770
3806
|
case 0:
|
|
@@ -3801,15 +3837,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3801
3837
|
break;
|
|
3802
3838
|
}
|
|
3803
3839
|
writeMethod = 'update';
|
|
3804
|
-
|
|
3840
|
+
_iterator34 = _createForOfIteratorHelper(compactedToWrite);
|
|
3805
3841
|
_context22.prev = 17;
|
|
3806
|
-
|
|
3842
|
+
_iterator34.s();
|
|
3807
3843
|
case 19:
|
|
3808
|
-
if ((
|
|
3844
|
+
if ((_step34 = _iterator34.n()).done) {
|
|
3809
3845
|
_context22.next = 25;
|
|
3810
3846
|
break;
|
|
3811
3847
|
}
|
|
3812
|
-
order =
|
|
3848
|
+
order = _step34.value;
|
|
3813
3849
|
_context22.next = 23;
|
|
3814
3850
|
return _this23.dbManager.update(INDEXDB_STORE_NAME, order);
|
|
3815
3851
|
case 23:
|
|
@@ -3821,10 +3857,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3821
3857
|
case 27:
|
|
3822
3858
|
_context22.prev = 27;
|
|
3823
3859
|
_context22.t0 = _context22["catch"](17);
|
|
3824
|
-
|
|
3860
|
+
_iterator34.e(_context22.t0);
|
|
3825
3861
|
case 30:
|
|
3826
3862
|
_context22.prev = 30;
|
|
3827
|
-
|
|
3863
|
+
_iterator34.f();
|
|
3828
3864
|
return _context22.finish(30);
|
|
3829
3865
|
case 33:
|
|
3830
3866
|
_context22.next = 37;
|
|
@@ -3841,29 +3877,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3841
3877
|
_context22.next = 84;
|
|
3842
3878
|
break;
|
|
3843
3879
|
}
|
|
3844
|
-
|
|
3880
|
+
_iterator35 = _createForOfIteratorHelper(storageKeyMigrations.values());
|
|
3845
3881
|
_context22.prev = 40;
|
|
3846
|
-
|
|
3882
|
+
_iterator35.s();
|
|
3847
3883
|
case 42:
|
|
3848
|
-
if ((
|
|
3884
|
+
if ((_step35 = _iterator35.n()).done) {
|
|
3849
3885
|
_context22.next = 76;
|
|
3850
3886
|
break;
|
|
3851
3887
|
}
|
|
3852
|
-
migration =
|
|
3888
|
+
migration = _step35.value;
|
|
3853
3889
|
_context22.prev = 44;
|
|
3854
3890
|
_context22.next = 47;
|
|
3855
3891
|
return _this23.dbManager.delete(INDEXDB_STORE_NAME, migration.from);
|
|
3856
3892
|
case 47:
|
|
3857
3893
|
_this23.recentSqliteWriteByStorageKey.delete(migration.from);
|
|
3858
|
-
|
|
3894
|
+
_iterator36 = _createForOfIteratorHelper(orders);
|
|
3859
3895
|
_context22.prev = 49;
|
|
3860
|
-
|
|
3896
|
+
_iterator36.s();
|
|
3861
3897
|
case 51:
|
|
3862
|
-
if ((
|
|
3898
|
+
if ((_step36 = _iterator36.n()).done) {
|
|
3863
3899
|
_context22.next = 61;
|
|
3864
3900
|
break;
|
|
3865
3901
|
}
|
|
3866
|
-
_order =
|
|
3902
|
+
_order = _step36.value;
|
|
3867
3903
|
if (!(_this23.getOrderStorageKey(_order) !== migration.to)) {
|
|
3868
3904
|
_context22.next = 55;
|
|
3869
3905
|
break;
|
|
@@ -3887,10 +3923,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3887
3923
|
case 63:
|
|
3888
3924
|
_context22.prev = 63;
|
|
3889
3925
|
_context22.t1 = _context22["catch"](49);
|
|
3890
|
-
|
|
3926
|
+
_iterator36.e(_context22.t1);
|
|
3891
3927
|
case 66:
|
|
3892
3928
|
_context22.prev = 66;
|
|
3893
|
-
|
|
3929
|
+
_iterator36.f();
|
|
3894
3930
|
return _context22.finish(66);
|
|
3895
3931
|
case 69:
|
|
3896
3932
|
_context22.next = 74;
|
|
@@ -3914,10 +3950,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3914
3950
|
case 78:
|
|
3915
3951
|
_context22.prev = 78;
|
|
3916
3952
|
_context22.t3 = _context22["catch"](40);
|
|
3917
|
-
|
|
3953
|
+
_iterator35.e(_context22.t3);
|
|
3918
3954
|
case 81:
|
|
3919
3955
|
_context22.prev = 81;
|
|
3920
|
-
|
|
3956
|
+
_iterator35.f();
|
|
3921
3957
|
return _context22.finish(81);
|
|
3922
3958
|
case 84:
|
|
3923
3959
|
_this23.logInfo('patchOrdersInSQLite-完成', {
|
|
@@ -4137,7 +4173,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4137
4173
|
_context27.prev = 6;
|
|
4138
4174
|
_context27.next = 9;
|
|
4139
4175
|
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
4140
|
-
var existingOrders, protectedLocalOrders,
|
|
4176
|
+
var existingOrders, protectedLocalOrders, _iterator37, _step37, rawCurrentOrder, currentOrder, protectedIndex, currentNeedsProtection, orderListSnapshot;
|
|
4141
4177
|
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
4142
4178
|
while (1) switch (_context26.prev = _context26.next) {
|
|
4143
4179
|
case 0:
|
|
@@ -4160,15 +4196,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4160
4196
|
}).filter(function (order) {
|
|
4161
4197
|
return _this25.shouldProtectLocalOrderFromRemoteSnapshot(order);
|
|
4162
4198
|
});
|
|
4163
|
-
|
|
4199
|
+
_iterator37 = _createForOfIteratorHelper(existingOrders || []);
|
|
4164
4200
|
_context26.prev = 10;
|
|
4165
|
-
|
|
4201
|
+
_iterator37.s();
|
|
4166
4202
|
case 12:
|
|
4167
|
-
if ((
|
|
4203
|
+
if ((_step37 = _iterator37.n()).done) {
|
|
4168
4204
|
_context26.next = 23;
|
|
4169
4205
|
break;
|
|
4170
4206
|
}
|
|
4171
|
-
rawCurrentOrder =
|
|
4207
|
+
rawCurrentOrder = _step37.value;
|
|
4172
4208
|
currentOrder = _this25.normalizeOrderCollectionsForIngress(rawCurrentOrder, "".concat(source, ".currentSQLite"));
|
|
4173
4209
|
protectedIndex = _this25.findOrderIndexByIdentity(protectedLocalOrders, currentOrder);
|
|
4174
4210
|
currentNeedsProtection = _this25.shouldProtectLocalOrderFromRemoteSnapshot(currentOrder);
|
|
@@ -4193,10 +4229,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4193
4229
|
case 25:
|
|
4194
4230
|
_context26.prev = 25;
|
|
4195
4231
|
_context26.t1 = _context26["catch"](10);
|
|
4196
|
-
|
|
4232
|
+
_iterator37.e(_context26.t1);
|
|
4197
4233
|
case 28:
|
|
4198
4234
|
_context26.prev = 28;
|
|
4199
|
-
|
|
4235
|
+
_iterator37.f();
|
|
4200
4236
|
return _context26.finish(28);
|
|
4201
4237
|
case 31:
|
|
4202
4238
|
orderListSnapshot = _this25.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, protectedLocalOrders);
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 1 |
|
|
329
|
+
weekNum: 0 | 1 | 5 | 2 | 3 | 4 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -1068,6 +1068,7 @@ var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cuto
|
|
|
1068
1068
|
// as missing_resource at group level. Structural validation below still
|
|
1069
1069
|
// rejects a genuinely missing selection.
|
|
1070
1070
|
'missing_resource']);
|
|
1071
|
+
var POS_NO_RESOURCE_ID = 0;
|
|
1071
1072
|
function matchesForcedSelectionGroup(selection, group) {
|
|
1072
1073
|
var hasGroupId = typeof selection.requirementGroupId === 'string' && selection.requirementGroupId.trim().length > 0;
|
|
1073
1074
|
var hasFormId = selection.formId !== undefined && selection.formId !== null;
|
|
@@ -1153,7 +1154,21 @@ function buildPosForcedAvailabilityAssignments(params) {
|
|
|
1153
1154
|
return;
|
|
1154
1155
|
}
|
|
1155
1156
|
selectedResourceIds.forEach(function (resourceId) {
|
|
1156
|
-
var _group$resourceIds2, _group$
|
|
1157
|
+
var _group$resourceIds2, _group$formId2, _candidate$primarySch7, _candidate$primarySch8;
|
|
1158
|
+
if (sameAvailabilityId(resourceId, POS_NO_RESOURCE_ID)) {
|
|
1159
|
+
var _group$formId, _candidate$primarySch5, _candidate$primarySch6;
|
|
1160
|
+
assignments.push({
|
|
1161
|
+
productId: product.id,
|
|
1162
|
+
resourceId: POS_NO_RESOURCE_ID,
|
|
1163
|
+
formId: (_group$formId = group.formId) !== null && _group$formId !== void 0 ? _group$formId : selection.formId,
|
|
1164
|
+
startAt: candidate.bookingStartAt || candidate.startAt,
|
|
1165
|
+
endAt: candidate.bookingEndAt || candidate.endAt,
|
|
1166
|
+
capacityRequired: Math.max(1, partySize),
|
|
1167
|
+
scheduleId: (_candidate$primarySch5 = candidate.primaryScheduleRef) === null || _candidate$primarySch5 === void 0 ? void 0 : _candidate$primarySch5.scheduleId,
|
|
1168
|
+
timeSlotId: (_candidate$primarySch6 = candidate.primaryScheduleRef) === null || _candidate$primarySch6 === void 0 ? void 0 : _candidate$primarySch6.timeSlotId
|
|
1169
|
+
});
|
|
1170
|
+
return;
|
|
1171
|
+
}
|
|
1157
1172
|
var resource = resources.find(function (item) {
|
|
1158
1173
|
return sameAvailabilityId(item.id, resourceId);
|
|
1159
1174
|
});
|
|
@@ -1171,12 +1186,12 @@ function buildPosForcedAvailabilityAssignments(params) {
|
|
|
1171
1186
|
assignments.push({
|
|
1172
1187
|
productId: product.id,
|
|
1173
1188
|
resourceId: resourceId,
|
|
1174
|
-
formId: (_group$
|
|
1189
|
+
formId: (_group$formId2 = group.formId) !== null && _group$formId2 !== void 0 ? _group$formId2 : resource.formId,
|
|
1175
1190
|
startAt: candidate.bookingStartAt || candidate.startAt,
|
|
1176
1191
|
endAt: candidate.bookingEndAt || candidate.endAt,
|
|
1177
1192
|
capacityRequired: Math.max(1, partySize),
|
|
1178
|
-
scheduleId: (_candidate$
|
|
1179
|
-
timeSlotId: (_candidate$
|
|
1193
|
+
scheduleId: (_candidate$primarySch7 = candidate.primaryScheduleRef) === null || _candidate$primarySch7 === void 0 ? void 0 : _candidate$primarySch7.scheduleId,
|
|
1194
|
+
timeSlotId: (_candidate$primarySch8 = candidate.primaryScheduleRef) === null || _candidate$primarySch8 === void 0 ? void 0 : _candidate$primarySch8.timeSlotId
|
|
1180
1195
|
});
|
|
1181
1196
|
});
|
|
1182
1197
|
});
|
|
@@ -20,6 +20,8 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
20
20
|
private storage;
|
|
21
21
|
private orderSQLiteSaveQueue; /** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
22
22
|
private recentSqliteWriteByStorageKey;
|
|
23
|
+
/** 最近一次清理过期 SQLite 去重记录的时间,避免每次写入都遍历 Map */
|
|
24
|
+
private lastRecentSqliteWriteCleanupAtMs;
|
|
23
25
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
24
26
|
private lastServerFullFetchAtMs;
|
|
25
27
|
constructor(name?: string, version?: string);
|
|
@@ -58,6 +60,12 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
58
60
|
*/
|
|
59
61
|
private mergeAuthoritativeOrderCollection;
|
|
60
62
|
private reconcileOverwriteOrderCollections;
|
|
63
|
+
/**
|
|
64
|
+
* 惰性清理已经超过去重窗口的 SQLite 写入记录。
|
|
65
|
+
*
|
|
66
|
+
* 清理频率与去重窗口一致,既限制 Map 长期增长,也不会移除仍参与去重的记录。
|
|
67
|
+
*/
|
|
68
|
+
private cleanupExpiredRecentSqliteWrites;
|
|
61
69
|
/**
|
|
62
70
|
* 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
|
|
63
71
|
*
|
|
@@ -57,6 +57,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
57
57
|
storage;
|
|
58
58
|
orderSQLiteSaveQueue = Promise.resolve(); /** 按 storageKey 记录最近一次 SQLite 写入来源与时间,用于去重 */
|
|
59
59
|
recentSqliteWriteByStorageKey = new Map();
|
|
60
|
+
/** 最近一次清理过期 SQLite 去重记录的时间,避免每次写入都遍历 Map */
|
|
61
|
+
lastRecentSqliteWriteCleanupAtMs = 0;
|
|
60
62
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
61
63
|
lastServerFullFetchAtMs = 0;
|
|
62
64
|
constructor(name, version) {
|
|
@@ -292,6 +294,24 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
292
294
|
return this.normalizeOrderCollectionsForIngress((0, _orderCollectionIdentity.applyOrderCollectionUidRemaps)(reconciled, uidRemaps), 'overwriteExistingOrder.reconciled');
|
|
293
295
|
}
|
|
294
296
|
|
|
297
|
+
/**
|
|
298
|
+
* 惰性清理已经超过去重窗口的 SQLite 写入记录。
|
|
299
|
+
*
|
|
300
|
+
* 清理频率与去重窗口一致,既限制 Map 长期增长,也不会移除仍参与去重的记录。
|
|
301
|
+
*/
|
|
302
|
+
cleanupExpiredRecentSqliteWrites(now) {
|
|
303
|
+
const elapsedSinceCleanup = now - this.lastRecentSqliteWriteCleanupAtMs;
|
|
304
|
+
if (this.lastRecentSqliteWriteCleanupAtMs > 0 && elapsedSinceCleanup >= 0 && elapsedSinceCleanup < ORDER_SQLITE_DEDUPE_MS) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
for (const [storageKey, recentWrite] of this.recentSqliteWriteByStorageKey) {
|
|
308
|
+
if (now - recentWrite.ts >= ORDER_SQLITE_DEDUPE_MS) {
|
|
309
|
+
this.recentSqliteWriteByStorageKey.delete(storageKey);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
this.lastRecentSqliteWriteCleanupAtMs = now;
|
|
313
|
+
}
|
|
314
|
+
|
|
295
315
|
/**
|
|
296
316
|
* 记录订单最近一次 SQLite 写入,供 pubsub 回声去重使用。
|
|
297
317
|
*
|
|
@@ -300,6 +320,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
300
320
|
*/
|
|
301
321
|
recordRecentSqliteWrite(source, orders) {
|
|
302
322
|
const now = Date.now();
|
|
323
|
+
this.cleanupExpiredRecentSqliteWrites(now);
|
|
303
324
|
for (const order of orders) {
|
|
304
325
|
const storageKey = this.getOrderStorageKey(order);
|
|
305
326
|
if (!storageKey) continue;
|
|
@@ -1264,6 +1285,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
1264
1285
|
}
|
|
1265
1286
|
this.isProcessingSyncBatch = false;
|
|
1266
1287
|
this.pendingSyncMessages = [];
|
|
1288
|
+
this.recentSqliteWriteByStorageKey.clear();
|
|
1289
|
+
this.lastRecentSqliteWriteCleanupAtMs = 0;
|
|
1267
1290
|
if (this.orderDataSource?.destroy) this.orderDataSource.destroy();
|
|
1268
1291
|
super.destroy();
|
|
1269
1292
|
}
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 | 1 |
|
|
329
|
+
weekNum: 0 | 1 | 5 | 2 | 3 | 4 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -986,6 +986,7 @@ const POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cu
|
|
|
986
986
|
// as missing_resource at group level. Structural validation below still
|
|
987
987
|
// rejects a genuinely missing selection.
|
|
988
988
|
'missing_resource']);
|
|
989
|
+
const POS_NO_RESOURCE_ID = 0;
|
|
989
990
|
function matchesForcedSelectionGroup(selection, group) {
|
|
990
991
|
const hasGroupId = typeof selection.requirementGroupId === 'string' && selection.requirementGroupId.trim().length > 0;
|
|
991
992
|
const hasFormId = selection.formId !== undefined && selection.formId !== null;
|
|
@@ -1066,6 +1067,19 @@ function buildPosForcedAvailabilityAssignments(params) {
|
|
|
1066
1067
|
return;
|
|
1067
1068
|
}
|
|
1068
1069
|
selectedResourceIds.forEach(resourceId => {
|
|
1070
|
+
if (sameAvailabilityId(resourceId, POS_NO_RESOURCE_ID)) {
|
|
1071
|
+
assignments.push({
|
|
1072
|
+
productId: product.id,
|
|
1073
|
+
resourceId: POS_NO_RESOURCE_ID,
|
|
1074
|
+
formId: group.formId ?? selection.formId,
|
|
1075
|
+
startAt: candidate.bookingStartAt || candidate.startAt,
|
|
1076
|
+
endAt: candidate.bookingEndAt || candidate.endAt,
|
|
1077
|
+
capacityRequired: Math.max(1, partySize),
|
|
1078
|
+
scheduleId: candidate.primaryScheduleRef?.scheduleId,
|
|
1079
|
+
timeSlotId: candidate.primaryScheduleRef?.timeSlotId
|
|
1080
|
+
});
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1069
1083
|
const resource = resources.find(item => sameAvailabilityId(item.id, resourceId));
|
|
1070
1084
|
const belongsToGroup = Boolean(resource && !(group.formId !== undefined && resource.formId !== undefined && !sameAvailabilityId(group.formId, resource.formId)) && !(group.resourceIds?.length && !group.resourceIds.some(id => sameAvailabilityId(id, resourceId))));
|
|
1071
1085
|
if (!resource || !belongsToGroup) {
|