@pisell/pisellos 2.2.305 → 2.2.307
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 +506 -453
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/Sales/index.d.ts +2 -0
- package/dist/solution/Sales/index.js +15 -1
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +19 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/Sales/index.d.ts +2 -0
- package/lib/solution/Sales/index.js +10 -1
- package/package.json +1 -1
|
@@ -95,6 +95,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
95
95
|
_defineProperty(_assertThisInitialized(_this), "lastRecentSqliteWriteCleanupAtMs", 0);
|
|
96
96
|
/** 最近一次 SSE 全量拉取完成时间 */
|
|
97
97
|
_defineProperty(_assertThisInitialized(_this), "lastServerFullFetchAtMs", 0);
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "businessDayRefreshPromise", null);
|
|
98
99
|
return _this;
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -1256,31 +1257,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1256
1257
|
}
|
|
1257
1258
|
return loadOrdersByServer;
|
|
1258
1259
|
}()
|
|
1260
|
+
/**
|
|
1261
|
+
* 供展示屏按需补齐当前营业日的订单快照;成功标记复用全量拉取落库逻辑。
|
|
1262
|
+
* 拉取或落库失败时不记录已刷新,下一次调用仍可重试。
|
|
1263
|
+
*/
|
|
1264
|
+
}, {
|
|
1265
|
+
key: "refreshOrdersForCurrentBusinessDay",
|
|
1266
|
+
value: (function () {
|
|
1267
|
+
var _refreshOrdersForCurrentBusinessDay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
1268
|
+
var options,
|
|
1269
|
+
refreshPromise,
|
|
1270
|
+
_args9 = arguments;
|
|
1271
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1272
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
1273
|
+
case 0:
|
|
1274
|
+
options = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
|
1275
|
+
if (!this.businessDayRefreshPromise) {
|
|
1276
|
+
_context9.next = 3;
|
|
1277
|
+
break;
|
|
1278
|
+
}
|
|
1279
|
+
return _context9.abrupt("return", this.businessDayRefreshPromise);
|
|
1280
|
+
case 3:
|
|
1281
|
+
if (!(!this.orderDataSource || !this.getCurrentShopId() || this.hasPulledOrdersToday())) {
|
|
1282
|
+
_context9.next = 5;
|
|
1283
|
+
break;
|
|
1284
|
+
}
|
|
1285
|
+
return _context9.abrupt("return");
|
|
1286
|
+
case 5:
|
|
1287
|
+
refreshPromise = this.silentRefresh({
|
|
1288
|
+
trigger: options.trigger || 'business_day_rollover'
|
|
1289
|
+
}).then(function () {
|
|
1290
|
+
return undefined;
|
|
1291
|
+
});
|
|
1292
|
+
this.businessDayRefreshPromise = refreshPromise;
|
|
1293
|
+
_context9.prev = 7;
|
|
1294
|
+
_context9.next = 10;
|
|
1295
|
+
return refreshPromise;
|
|
1296
|
+
case 10:
|
|
1297
|
+
_context9.prev = 10;
|
|
1298
|
+
this.businessDayRefreshPromise = null;
|
|
1299
|
+
return _context9.finish(10);
|
|
1300
|
+
case 13:
|
|
1301
|
+
case "end":
|
|
1302
|
+
return _context9.stop();
|
|
1303
|
+
}
|
|
1304
|
+
}, _callee9, this, [[7,, 10, 13]]);
|
|
1305
|
+
}));
|
|
1306
|
+
function refreshOrdersForCurrentBusinessDay() {
|
|
1307
|
+
return _refreshOrdersForCurrentBusinessDay.apply(this, arguments);
|
|
1308
|
+
}
|
|
1309
|
+
return refreshOrdersForCurrentBusinessDay;
|
|
1310
|
+
}()
|
|
1259
1311
|
/**
|
|
1260
1312
|
* 静默全量刷新:后台重新拉取全量 SSE 订单数据并更新本地
|
|
1261
1313
|
* 拿到完整数据后一次性替换 store,触发订单变更与同步完成事件
|
|
1262
1314
|
* @returns 刷新后的订单列表
|
|
1263
1315
|
*/
|
|
1316
|
+
)
|
|
1264
1317
|
}, {
|
|
1265
1318
|
key: "silentRefresh",
|
|
1266
1319
|
value: (function () {
|
|
1267
|
-
var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1320
|
+
var _silentRefresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
1268
1321
|
var options,
|
|
1269
1322
|
startTime,
|
|
1270
1323
|
trigger,
|
|
1271
1324
|
elapsedSinceFullFetch,
|
|
1272
1325
|
orders,
|
|
1273
1326
|
errorMessage,
|
|
1274
|
-
|
|
1275
|
-
return _regeneratorRuntime().wrap(function
|
|
1276
|
-
while (1) switch (
|
|
1327
|
+
_args10 = arguments;
|
|
1328
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1329
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1277
1330
|
case 0:
|
|
1278
|
-
options =
|
|
1331
|
+
options = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
|
|
1279
1332
|
startTime = Date.now();
|
|
1280
1333
|
trigger = options.trigger || 'background';
|
|
1281
1334
|
elapsedSinceFullFetch = Date.now() - this.lastServerFullFetchAtMs;
|
|
1282
1335
|
if (!(this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetch < ORDER_SILENT_REFRESH_MIN_INTERVAL_MS)) {
|
|
1283
|
-
|
|
1336
|
+
_context10.next = 7;
|
|
1284
1337
|
break;
|
|
1285
1338
|
}
|
|
1286
1339
|
this.logInfo('silentRefresh 跳过全量 SSE', {
|
|
@@ -1290,28 +1343,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1290
1343
|
elapsedSinceFullFetchMs: elapsedSinceFullFetch,
|
|
1291
1344
|
orderCount: this.store.list.length
|
|
1292
1345
|
});
|
|
1293
|
-
return
|
|
1346
|
+
return _context10.abrupt("return", this.store.list);
|
|
1294
1347
|
case 7:
|
|
1295
1348
|
this.logInfo('silentRefresh 开始', {
|
|
1296
1349
|
trigger: trigger,
|
|
1297
1350
|
elapsedSinceFullFetchMs: elapsedSinceFullFetch,
|
|
1298
1351
|
orderCount: this.store.list.length
|
|
1299
1352
|
});
|
|
1300
|
-
|
|
1353
|
+
_context10.prev = 8;
|
|
1301
1354
|
// 刷新前,需要更新当前营业日边界(store.createdAtQuery)
|
|
1302
1355
|
this.updateCreateStore();
|
|
1303
|
-
|
|
1356
|
+
_context10.next = 12;
|
|
1304
1357
|
return this.loadOrdersByServer({
|
|
1305
1358
|
trigger: trigger
|
|
1306
1359
|
});
|
|
1307
1360
|
case 12:
|
|
1308
|
-
orders =
|
|
1361
|
+
orders = _context10.sent;
|
|
1309
1362
|
this.store.list = cloneDeep(orders);
|
|
1310
1363
|
this.syncOrdersMap();
|
|
1311
|
-
|
|
1364
|
+
_context10.next = 17;
|
|
1312
1365
|
return this.emitOrdersChanged([], 'silentRefresh');
|
|
1313
1366
|
case 17:
|
|
1314
|
-
|
|
1367
|
+
_context10.next = 19;
|
|
1315
1368
|
return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
1316
1369
|
case 19:
|
|
1317
1370
|
this.logInfo('silentRefresh 完成', {
|
|
@@ -1319,22 +1372,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1319
1372
|
orderCount: orders.length,
|
|
1320
1373
|
duration: "".concat(Date.now() - startTime, "ms")
|
|
1321
1374
|
});
|
|
1322
|
-
return
|
|
1375
|
+
return _context10.abrupt("return", this.store.list);
|
|
1323
1376
|
case 23:
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
errorMessage =
|
|
1377
|
+
_context10.prev = 23;
|
|
1378
|
+
_context10.t0 = _context10["catch"](8);
|
|
1379
|
+
errorMessage = _context10.t0 instanceof Error ? _context10.t0.message : String(_context10.t0);
|
|
1327
1380
|
this.logError('silentRefresh 失败', {
|
|
1328
1381
|
trigger: trigger,
|
|
1329
1382
|
duration: "".concat(Date.now() - startTime, "ms"),
|
|
1330
1383
|
error: errorMessage
|
|
1331
1384
|
});
|
|
1332
|
-
return
|
|
1385
|
+
return _context10.abrupt("return", this.store.list);
|
|
1333
1386
|
case 28:
|
|
1334
1387
|
case "end":
|
|
1335
|
-
return
|
|
1388
|
+
return _context10.stop();
|
|
1336
1389
|
}
|
|
1337
|
-
},
|
|
1390
|
+
}, _callee10, this, [[8, 23]]);
|
|
1338
1391
|
}));
|
|
1339
1392
|
function silentRefresh() {
|
|
1340
1393
|
return _silentRefresh.apply(this, arguments);
|
|
@@ -1420,31 +1473,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1420
1473
|
}, {
|
|
1421
1474
|
key: "overwriteExistingOrder",
|
|
1422
1475
|
value: (function () {
|
|
1423
|
-
var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1476
|
+
var _overwriteExistingOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(fresh) {
|
|
1424
1477
|
var _this8 = this;
|
|
1425
1478
|
var orderId, key, normalizedFresh, existingOrder, reconciledFresh;
|
|
1426
|
-
return _regeneratorRuntime().wrap(function
|
|
1427
|
-
while (1) switch (
|
|
1479
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1480
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1428
1481
|
case 0:
|
|
1429
1482
|
orderId = fresh === null || fresh === void 0 ? void 0 : fresh.order_id;
|
|
1430
1483
|
if (!(orderId === undefined || orderId === null)) {
|
|
1431
|
-
|
|
1484
|
+
_context11.next = 4;
|
|
1432
1485
|
break;
|
|
1433
1486
|
}
|
|
1434
1487
|
this.logError('overwriteExistingOrder-入参缺少 order_id');
|
|
1435
|
-
return
|
|
1488
|
+
return _context11.abrupt("return", {
|
|
1436
1489
|
overwritten: false
|
|
1437
1490
|
});
|
|
1438
1491
|
case 4:
|
|
1439
1492
|
key = this.getIdKey(orderId);
|
|
1440
1493
|
if (this.store.map.has(key)) {
|
|
1441
|
-
|
|
1494
|
+
_context11.next = 8;
|
|
1442
1495
|
break;
|
|
1443
1496
|
}
|
|
1444
1497
|
this.logInfo('overwriteExistingOrder-本地不存在该订单,跳过', {
|
|
1445
1498
|
orderId: orderId
|
|
1446
1499
|
});
|
|
1447
|
-
return
|
|
1500
|
+
return _context11.abrupt("return", {
|
|
1448
1501
|
overwritten: false
|
|
1449
1502
|
});
|
|
1450
1503
|
case 8:
|
|
@@ -1463,24 +1516,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1463
1516
|
return _this8.getIdKey(id) === key ? reconciledFresh : _this8.normalizeOrderForMemoryList(order, 'overwriteExistingOrder.existingMemory');
|
|
1464
1517
|
});
|
|
1465
1518
|
this.syncOrdersMap();
|
|
1466
|
-
|
|
1519
|
+
_context11.next = 16;
|
|
1467
1520
|
return this.updateOrderInSQLite(reconciledFresh, 'overwriteExistingOrder');
|
|
1468
1521
|
case 16:
|
|
1469
1522
|
this.logInfo('overwriteExistingOrder-结束', {
|
|
1470
1523
|
orderId: orderId,
|
|
1471
1524
|
storeOrderCountAfter: this.store.list.length
|
|
1472
1525
|
});
|
|
1473
|
-
|
|
1526
|
+
_context11.next = 19;
|
|
1474
1527
|
return this.emitOrdersChanged([reconciledFresh], 'overwriteExistingOrder');
|
|
1475
1528
|
case 19:
|
|
1476
|
-
return
|
|
1529
|
+
return _context11.abrupt("return", {
|
|
1477
1530
|
overwritten: true
|
|
1478
1531
|
});
|
|
1479
1532
|
case 20:
|
|
1480
1533
|
case "end":
|
|
1481
|
-
return
|
|
1534
|
+
return _context11.stop();
|
|
1482
1535
|
}
|
|
1483
|
-
},
|
|
1536
|
+
}, _callee11, this);
|
|
1484
1537
|
}));
|
|
1485
1538
|
function overwriteExistingOrder(_x7) {
|
|
1486
1539
|
return _overwriteExistingOrder.apply(this, arguments);
|
|
@@ -1495,33 +1548,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1495
1548
|
}, {
|
|
1496
1549
|
key: "upsertOrdersFromRemote",
|
|
1497
1550
|
value: (function () {
|
|
1498
|
-
var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1551
|
+
var _upsertOrdersFromRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(freshOrders) {
|
|
1499
1552
|
var source,
|
|
1500
|
-
|
|
1501
|
-
return _regeneratorRuntime().wrap(function
|
|
1502
|
-
while (1) switch (
|
|
1553
|
+
_args12 = arguments;
|
|
1554
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1555
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1503
1556
|
case 0:
|
|
1504
|
-
source =
|
|
1557
|
+
source = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : 'upsertOrdersFromRemote';
|
|
1505
1558
|
if (freshOrders !== null && freshOrders !== void 0 && freshOrders.length) {
|
|
1506
|
-
|
|
1559
|
+
_context12.next = 4;
|
|
1507
1560
|
break;
|
|
1508
1561
|
}
|
|
1509
1562
|
this.logInfo('upsertOrdersFromRemote-订单列表为空', {
|
|
1510
1563
|
source: source
|
|
1511
1564
|
});
|
|
1512
|
-
return
|
|
1565
|
+
return _context12.abrupt("return");
|
|
1513
1566
|
case 4:
|
|
1514
1567
|
this.logInfo('upsertOrdersFromRemote-开始', {
|
|
1515
1568
|
count: freshOrders.length,
|
|
1516
1569
|
source: source
|
|
1517
1570
|
});
|
|
1518
|
-
|
|
1571
|
+
_context12.next = 7;
|
|
1519
1572
|
return this.mergeOrdersToStore(freshOrders, source);
|
|
1520
1573
|
case 7:
|
|
1521
1574
|
case "end":
|
|
1522
|
-
return
|
|
1575
|
+
return _context12.stop();
|
|
1523
1576
|
}
|
|
1524
|
-
},
|
|
1577
|
+
}, _callee12, this);
|
|
1525
1578
|
}));
|
|
1526
1579
|
function upsertOrdersFromRemote(_x8) {
|
|
1527
1580
|
return _upsertOrdersFromRemote.apply(this, arguments);
|
|
@@ -1531,21 +1584,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1531
1584
|
}, {
|
|
1532
1585
|
key: "markOrderSyncedByExternalSaleNumber",
|
|
1533
1586
|
value: function () {
|
|
1534
|
-
var _markOrderSyncedByExternalSaleNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1587
|
+
var _markOrderSyncedByExternalSaleNumber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
|
|
1535
1588
|
var _this9 = this,
|
|
1536
1589
|
_existing$external_sa,
|
|
1537
1590
|
_nextOrder$order_id;
|
|
1538
1591
|
var externalSaleNumber, key, targetIndex, existing, nextOrder, storageKey;
|
|
1539
|
-
return _regeneratorRuntime().wrap(function
|
|
1540
|
-
while (1) switch (
|
|
1592
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1593
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1541
1594
|
case 0:
|
|
1542
1595
|
externalSaleNumber = params.externalSaleNumber;
|
|
1543
1596
|
if (!(externalSaleNumber === undefined || externalSaleNumber === null || externalSaleNumber === '')) {
|
|
1544
|
-
|
|
1597
|
+
_context13.next = 4;
|
|
1545
1598
|
break;
|
|
1546
1599
|
}
|
|
1547
1600
|
this.logError('markOrderSyncedByExternalSaleNumber-缺少 external_sale_number');
|
|
1548
|
-
return
|
|
1601
|
+
return _context13.abrupt("return", {
|
|
1549
1602
|
updated: false
|
|
1550
1603
|
});
|
|
1551
1604
|
case 4:
|
|
@@ -1556,13 +1609,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1556
1609
|
return _this9.getIdKey(value) === key;
|
|
1557
1610
|
});
|
|
1558
1611
|
if (!(targetIndex < 0)) {
|
|
1559
|
-
|
|
1612
|
+
_context13.next = 9;
|
|
1560
1613
|
break;
|
|
1561
1614
|
}
|
|
1562
1615
|
this.logInfo('markOrderSyncedByExternalSaleNumber-本地订单不存在,跳过', {
|
|
1563
1616
|
external_sale_number: externalSaleNumber
|
|
1564
1617
|
});
|
|
1565
|
-
return
|
|
1618
|
+
return _context13.abrupt("return", {
|
|
1566
1619
|
updated: false
|
|
1567
1620
|
});
|
|
1568
1621
|
case 9:
|
|
@@ -1578,25 +1631,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1578
1631
|
return nextOrder;
|
|
1579
1632
|
});
|
|
1580
1633
|
this.syncOrdersMap();
|
|
1581
|
-
|
|
1634
|
+
_context13.next = 16;
|
|
1582
1635
|
return this.patchOrdersInSQLite([nextOrder], 'markOrderSyncedByExternalSaleNumber', _defineProperty({}, storageKey, 'update'));
|
|
1583
1636
|
case 16:
|
|
1584
1637
|
this.logInfo('markOrderSyncedByExternalSaleNumber-完成', {
|
|
1585
1638
|
external_sale_number: externalSaleNumber,
|
|
1586
1639
|
order_id: (_nextOrder$order_id = nextOrder.order_id) !== null && _nextOrder$order_id !== void 0 ? _nextOrder$order_id : null
|
|
1587
1640
|
});
|
|
1588
|
-
|
|
1641
|
+
_context13.next = 19;
|
|
1589
1642
|
return this.emitOrdersChanged([nextOrder], 'markOrderSyncedByExternalSaleNumber');
|
|
1590
1643
|
case 19:
|
|
1591
|
-
return
|
|
1644
|
+
return _context13.abrupt("return", {
|
|
1592
1645
|
updated: true,
|
|
1593
1646
|
order: nextOrder
|
|
1594
1647
|
});
|
|
1595
1648
|
case 20:
|
|
1596
1649
|
case "end":
|
|
1597
|
-
return
|
|
1650
|
+
return _context13.stop();
|
|
1598
1651
|
}
|
|
1599
|
-
},
|
|
1652
|
+
}, _callee13, this);
|
|
1600
1653
|
}));
|
|
1601
1654
|
function markOrderSyncedByExternalSaleNumber(_x9) {
|
|
1602
1655
|
return _markOrderSyncedByExternalSaleNumber.apply(this, arguments);
|
|
@@ -1610,7 +1663,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1610
1663
|
}, {
|
|
1611
1664
|
key: "upsertPendingSyncOrders",
|
|
1612
1665
|
value: (function () {
|
|
1613
|
-
var _upsertPendingSyncOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1666
|
+
var _upsertPendingSyncOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(pendingOrders) {
|
|
1614
1667
|
var _this10 = this;
|
|
1615
1668
|
var options,
|
|
1616
1669
|
pendingMap,
|
|
@@ -1641,26 +1694,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1641
1694
|
insertIndex,
|
|
1642
1695
|
patchedOrders,
|
|
1643
1696
|
previousList,
|
|
1644
|
-
|
|
1645
|
-
return _regeneratorRuntime().wrap(function
|
|
1646
|
-
while (1) switch (
|
|
1697
|
+
_args14 = arguments;
|
|
1698
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1699
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1647
1700
|
case 0:
|
|
1648
|
-
options =
|
|
1701
|
+
options = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : {};
|
|
1649
1702
|
if (pendingOrders !== null && pendingOrders !== void 0 && pendingOrders.length) {
|
|
1650
|
-
|
|
1703
|
+
_context14.next = 4;
|
|
1651
1704
|
break;
|
|
1652
1705
|
}
|
|
1653
1706
|
this.logInfo('upsertPendingSyncOrders-订单列表为空', {});
|
|
1654
|
-
return
|
|
1707
|
+
return _context14.abrupt("return");
|
|
1655
1708
|
case 4:
|
|
1656
1709
|
pendingMap = new Map();
|
|
1657
1710
|
memoryPendingMap = new Map();
|
|
1658
1711
|
_iterator7 = _createForOfIteratorHelper(pendingOrders);
|
|
1659
|
-
|
|
1712
|
+
_context14.prev = 7;
|
|
1660
1713
|
_iterator7.s();
|
|
1661
1714
|
case 9:
|
|
1662
1715
|
if ((_step7 = _iterator7.n()).done) {
|
|
1663
|
-
|
|
1716
|
+
_context14.next = 20;
|
|
1664
1717
|
break;
|
|
1665
1718
|
}
|
|
1666
1719
|
order = _step7.value;
|
|
@@ -1671,36 +1724,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1671
1724
|
});
|
|
1672
1725
|
storageKey = this.getOrderStorageKey(pendingOrder);
|
|
1673
1726
|
if (storageKey) {
|
|
1674
|
-
|
|
1727
|
+
_context14.next = 16;
|
|
1675
1728
|
break;
|
|
1676
1729
|
}
|
|
1677
|
-
return
|
|
1730
|
+
return _context14.abrupt("continue", 18);
|
|
1678
1731
|
case 16:
|
|
1679
1732
|
pendingMap.set(storageKey, pendingOrder);
|
|
1680
1733
|
memoryPendingMap.set(storageKey, this.normalizeOrderForMemoryList(pendingOrder, 'upsertPendingSyncOrders.memory'));
|
|
1681
1734
|
case 18:
|
|
1682
|
-
|
|
1735
|
+
_context14.next = 9;
|
|
1683
1736
|
break;
|
|
1684
1737
|
case 20:
|
|
1685
|
-
|
|
1738
|
+
_context14.next = 25;
|
|
1686
1739
|
break;
|
|
1687
1740
|
case 22:
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
_iterator7.e(
|
|
1741
|
+
_context14.prev = 22;
|
|
1742
|
+
_context14.t0 = _context14["catch"](7);
|
|
1743
|
+
_iterator7.e(_context14.t0);
|
|
1691
1744
|
case 25:
|
|
1692
|
-
|
|
1745
|
+
_context14.prev = 25;
|
|
1693
1746
|
_iterator7.f();
|
|
1694
|
-
return
|
|
1747
|
+
return _context14.finish(25);
|
|
1695
1748
|
case 28:
|
|
1696
1749
|
if (!(pendingMap.size === 0)) {
|
|
1697
|
-
|
|
1750
|
+
_context14.next = 31;
|
|
1698
1751
|
break;
|
|
1699
1752
|
}
|
|
1700
1753
|
this.logError('upsertPendingSyncOrders-订单缺少可落库标识', {
|
|
1701
1754
|
count: pendingOrders.length
|
|
1702
1755
|
});
|
|
1703
|
-
return
|
|
1756
|
+
return _context14.abrupt("return");
|
|
1704
1757
|
case 31:
|
|
1705
1758
|
this.logInfo('upsertPendingSyncOrders-开始', {
|
|
1706
1759
|
count: pendingMap.size
|
|
@@ -1726,17 +1779,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1726
1779
|
}
|
|
1727
1780
|
}
|
|
1728
1781
|
_iterator9 = _createForOfIteratorHelper(memoryPendingMap.entries());
|
|
1729
|
-
|
|
1782
|
+
_context14.prev = 37;
|
|
1730
1783
|
_iterator9.s();
|
|
1731
1784
|
case 39:
|
|
1732
1785
|
if ((_step9 = _iterator9.n()).done) {
|
|
1733
|
-
|
|
1786
|
+
_context14.next = 58;
|
|
1734
1787
|
break;
|
|
1735
1788
|
}
|
|
1736
1789
|
_step9$value = _slicedToArray(_step9.value, 2), _storageKey = _step9$value[0], _pendingOrder = _step9$value[1];
|
|
1737
1790
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_pendingOrder));
|
|
1738
1791
|
if (!(matchIndex >= 0)) {
|
|
1739
|
-
|
|
1792
|
+
_context14.next = 52;
|
|
1740
1793
|
break;
|
|
1741
1794
|
}
|
|
1742
1795
|
existingOrder = updatedList[matchIndex];
|
|
@@ -1753,55 +1806,55 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1753
1806
|
// 合并后身份字段可能新增(如挂单拿到 order_id),同步登记,供同批后续 pending 命中同一槽位
|
|
1754
1807
|
this.registerOrderIdentityKeys(identityKeyToIndex, nextOrder, matchIndex);
|
|
1755
1808
|
mergeActions[_storageKey] = 'update';
|
|
1756
|
-
return
|
|
1809
|
+
return _context14.abrupt("continue", 56);
|
|
1757
1810
|
case 52:
|
|
1758
1811
|
insertIndex = updatedList.length;
|
|
1759
1812
|
updatedList.push(_pendingOrder);
|
|
1760
1813
|
this.registerOrderIdentityKeys(identityKeyToIndex, _pendingOrder, insertIndex);
|
|
1761
1814
|
mergeActions[_storageKey] = 'insert';
|
|
1762
1815
|
case 56:
|
|
1763
|
-
|
|
1816
|
+
_context14.next = 39;
|
|
1764
1817
|
break;
|
|
1765
1818
|
case 58:
|
|
1766
|
-
|
|
1819
|
+
_context14.next = 63;
|
|
1767
1820
|
break;
|
|
1768
1821
|
case 60:
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
_iterator9.e(
|
|
1822
|
+
_context14.prev = 60;
|
|
1823
|
+
_context14.t1 = _context14["catch"](37);
|
|
1824
|
+
_iterator9.e(_context14.t1);
|
|
1772
1825
|
case 63:
|
|
1773
|
-
|
|
1826
|
+
_context14.prev = 63;
|
|
1774
1827
|
_iterator9.f();
|
|
1775
|
-
return
|
|
1828
|
+
return _context14.finish(63);
|
|
1776
1829
|
case 66:
|
|
1777
1830
|
patchedOrders = _toConsumableArray(pendingMap.values()); // 增量索引已保证 store 去重不变量,无需再对全表做 O(n^2) 压缩;仅自检开关开启时兜底。
|
|
1778
1831
|
previousList = this.store.list;
|
|
1779
1832
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, 'upsertPendingSyncOrders.store');
|
|
1780
1833
|
this.syncOrdersMap();
|
|
1781
|
-
|
|
1782
|
-
|
|
1834
|
+
_context14.prev = 70;
|
|
1835
|
+
_context14.next = 73;
|
|
1783
1836
|
return this.patchOrdersInSQLite(patchedOrders, 'upsertPendingSyncOrders', mergeActions, options);
|
|
1784
1837
|
case 73:
|
|
1785
|
-
|
|
1838
|
+
_context14.next = 80;
|
|
1786
1839
|
break;
|
|
1787
1840
|
case 75:
|
|
1788
|
-
|
|
1789
|
-
|
|
1841
|
+
_context14.prev = 75;
|
|
1842
|
+
_context14.t2 = _context14["catch"](70);
|
|
1790
1843
|
this.store.list = previousList;
|
|
1791
1844
|
this.syncOrdersMap();
|
|
1792
|
-
throw
|
|
1845
|
+
throw _context14.t2;
|
|
1793
1846
|
case 80:
|
|
1794
1847
|
this.logInfo('upsertPendingSyncOrders-结束', {
|
|
1795
1848
|
count: patchedOrders.length,
|
|
1796
1849
|
storeOrderCountAfter: this.store.list.length
|
|
1797
1850
|
});
|
|
1798
|
-
|
|
1851
|
+
_context14.next = 83;
|
|
1799
1852
|
return this.emitOrdersChanged(patchedOrders, 'upsertPendingSyncOrders');
|
|
1800
1853
|
case 83:
|
|
1801
1854
|
case "end":
|
|
1802
|
-
return
|
|
1855
|
+
return _context14.stop();
|
|
1803
1856
|
}
|
|
1804
|
-
},
|
|
1857
|
+
}, _callee14, this, [[7, 22, 25, 28], [37, 60, 63, 66], [70, 75]]);
|
|
1805
1858
|
}));
|
|
1806
1859
|
function upsertPendingSyncOrders(_x10) {
|
|
1807
1860
|
return _upsertPendingSyncOrders.apply(this, arguments);
|
|
@@ -1816,27 +1869,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1816
1869
|
}, {
|
|
1817
1870
|
key: "upsertLocalDraftOrders",
|
|
1818
1871
|
value: (function () {
|
|
1819
|
-
var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1872
|
+
var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(draftOrders) {
|
|
1820
1873
|
var _this11 = this;
|
|
1821
1874
|
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;
|
|
1822
|
-
return _regeneratorRuntime().wrap(function
|
|
1823
|
-
while (1) switch (
|
|
1875
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1876
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1824
1877
|
case 0:
|
|
1825
1878
|
if (draftOrders !== null && draftOrders !== void 0 && draftOrders.length) {
|
|
1826
|
-
|
|
1879
|
+
_context15.next = 3;
|
|
1827
1880
|
break;
|
|
1828
1881
|
}
|
|
1829
1882
|
this.logInfo('upsertLocalDraftOrders-订单列表为空', {});
|
|
1830
|
-
return
|
|
1883
|
+
return _context15.abrupt("return");
|
|
1831
1884
|
case 3:
|
|
1832
1885
|
draftMap = new Map();
|
|
1833
1886
|
memoryDraftMap = new Map();
|
|
1834
1887
|
_iterator10 = _createForOfIteratorHelper(draftOrders);
|
|
1835
|
-
|
|
1888
|
+
_context15.prev = 6;
|
|
1836
1889
|
_iterator10.s();
|
|
1837
1890
|
case 8:
|
|
1838
1891
|
if ((_step10 = _iterator10.n()).done) {
|
|
1839
|
-
|
|
1892
|
+
_context15.next = 19;
|
|
1840
1893
|
break;
|
|
1841
1894
|
}
|
|
1842
1895
|
order = _step10.value;
|
|
@@ -1846,10 +1899,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1846
1899
|
});
|
|
1847
1900
|
storageKey = this.getOrderStorageKey(draftOrder);
|
|
1848
1901
|
if (storageKey) {
|
|
1849
|
-
|
|
1902
|
+
_context15.next = 14;
|
|
1850
1903
|
break;
|
|
1851
1904
|
}
|
|
1852
|
-
return
|
|
1905
|
+
return _context15.abrupt("continue", 17);
|
|
1853
1906
|
case 14:
|
|
1854
1907
|
draftMap.set(storageKey, draftOrder);
|
|
1855
1908
|
memoryDraftOrder = this.normalizeOrderForMemoryList(draftOrder);
|
|
@@ -1857,28 +1910,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1857
1910
|
memoryDraftMap.set(storageKey, memoryDraftOrder);
|
|
1858
1911
|
}
|
|
1859
1912
|
case 17:
|
|
1860
|
-
|
|
1913
|
+
_context15.next = 8;
|
|
1861
1914
|
break;
|
|
1862
1915
|
case 19:
|
|
1863
|
-
|
|
1916
|
+
_context15.next = 24;
|
|
1864
1917
|
break;
|
|
1865
1918
|
case 21:
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
_iterator10.e(
|
|
1919
|
+
_context15.prev = 21;
|
|
1920
|
+
_context15.t0 = _context15["catch"](6);
|
|
1921
|
+
_iterator10.e(_context15.t0);
|
|
1869
1922
|
case 24:
|
|
1870
|
-
|
|
1923
|
+
_context15.prev = 24;
|
|
1871
1924
|
_iterator10.f();
|
|
1872
|
-
return
|
|
1925
|
+
return _context15.finish(24);
|
|
1873
1926
|
case 27:
|
|
1874
1927
|
if (!(draftMap.size === 0)) {
|
|
1875
|
-
|
|
1928
|
+
_context15.next = 30;
|
|
1876
1929
|
break;
|
|
1877
1930
|
}
|
|
1878
1931
|
this.logError('upsertLocalDraftOrders-订单缺少可落库标识', {
|
|
1879
1932
|
count: draftOrders.length
|
|
1880
1933
|
});
|
|
1881
|
-
return
|
|
1934
|
+
return _context15.abrupt("return");
|
|
1882
1935
|
case 30:
|
|
1883
1936
|
this.logInfo('upsertLocalDraftOrders-开始', {
|
|
1884
1937
|
count: draftMap.size,
|
|
@@ -1904,17 +1957,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1904
1957
|
}
|
|
1905
1958
|
}
|
|
1906
1959
|
_iterator12 = _createForOfIteratorHelper(memoryDraftMap.entries());
|
|
1907
|
-
|
|
1960
|
+
_context15.prev = 36;
|
|
1908
1961
|
_iterator12.s();
|
|
1909
1962
|
case 38:
|
|
1910
1963
|
if ((_step12 = _iterator12.n()).done) {
|
|
1911
|
-
|
|
1964
|
+
_context15.next = 57;
|
|
1912
1965
|
break;
|
|
1913
1966
|
}
|
|
1914
1967
|
_step12$value = _slicedToArray(_step12.value, 2), _storageKey2 = _step12$value[0], _draftOrder = _step12$value[1];
|
|
1915
1968
|
matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_draftOrder));
|
|
1916
1969
|
if (!(matchIndex >= 0)) {
|
|
1917
|
-
|
|
1970
|
+
_context15.next = 51;
|
|
1918
1971
|
break;
|
|
1919
1972
|
}
|
|
1920
1973
|
existingOrder = updatedList[matchIndex];
|
|
@@ -1929,45 +1982,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
1982
|
draftMap.set(_storageKey2, reconciledDraftOrder);
|
|
1930
1983
|
this.registerOrderIdentityKeys(identityKeyToIndex, nextOrder, matchIndex);
|
|
1931
1984
|
mergeActions[_storageKey2] = 'update';
|
|
1932
|
-
return
|
|
1985
|
+
return _context15.abrupt("continue", 55);
|
|
1933
1986
|
case 51:
|
|
1934
1987
|
insertIndex = updatedList.length;
|
|
1935
1988
|
updatedList.push(_draftOrder);
|
|
1936
1989
|
this.registerOrderIdentityKeys(identityKeyToIndex, _draftOrder, insertIndex);
|
|
1937
1990
|
mergeActions[_storageKey2] = 'insert';
|
|
1938
1991
|
case 55:
|
|
1939
|
-
|
|
1992
|
+
_context15.next = 38;
|
|
1940
1993
|
break;
|
|
1941
1994
|
case 57:
|
|
1942
|
-
|
|
1995
|
+
_context15.next = 62;
|
|
1943
1996
|
break;
|
|
1944
1997
|
case 59:
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
_iterator12.e(
|
|
1998
|
+
_context15.prev = 59;
|
|
1999
|
+
_context15.t1 = _context15["catch"](36);
|
|
2000
|
+
_iterator12.e(_context15.t1);
|
|
1948
2001
|
case 62:
|
|
1949
|
-
|
|
2002
|
+
_context15.prev = 62;
|
|
1950
2003
|
_iterator12.f();
|
|
1951
|
-
return
|
|
2004
|
+
return _context15.finish(62);
|
|
1952
2005
|
case 65:
|
|
1953
2006
|
patchedOrders = _toConsumableArray(draftMap.values());
|
|
1954
2007
|
previousList = this.store.list;
|
|
1955
2008
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, 'upsertLocalDraftOrders.store');
|
|
1956
2009
|
this.syncOrdersMap();
|
|
1957
|
-
|
|
1958
|
-
|
|
2010
|
+
_context15.prev = 69;
|
|
2011
|
+
_context15.next = 72;
|
|
1959
2012
|
return this.patchOrdersInSQLite(patchedOrders, 'upsertLocalDraftOrders', mergeActions, {
|
|
1960
2013
|
throwOnError: true
|
|
1961
2014
|
});
|
|
1962
2015
|
case 72:
|
|
1963
|
-
|
|
2016
|
+
_context15.next = 79;
|
|
1964
2017
|
break;
|
|
1965
2018
|
case 74:
|
|
1966
|
-
|
|
1967
|
-
|
|
2019
|
+
_context15.prev = 74;
|
|
2020
|
+
_context15.t2 = _context15["catch"](69);
|
|
1968
2021
|
this.store.list = previousList;
|
|
1969
2022
|
this.syncOrdersMap();
|
|
1970
|
-
throw
|
|
2023
|
+
throw _context15.t2;
|
|
1971
2024
|
case 79:
|
|
1972
2025
|
this.logInfo('upsertLocalDraftOrders-结束', {
|
|
1973
2026
|
count: patchedOrders.length,
|
|
@@ -1977,18 +2030,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1977
2030
|
return !_this11.shouldKeepOrderInMemory(order);
|
|
1978
2031
|
});
|
|
1979
2032
|
if (!(memoryDraftMap.size > 0 || removedLegacyMemoryDraft)) {
|
|
1980
|
-
|
|
2033
|
+
_context15.next = 84;
|
|
1981
2034
|
break;
|
|
1982
2035
|
}
|
|
1983
|
-
|
|
2036
|
+
_context15.next = 84;
|
|
1984
2037
|
return this.emitOrdersChanged(patchedOrders.filter(function (order) {
|
|
1985
2038
|
return _this11.shouldKeepOrderInMemory(order);
|
|
1986
2039
|
}), 'upsertLocalDraftOrders');
|
|
1987
2040
|
case 84:
|
|
1988
2041
|
case "end":
|
|
1989
|
-
return
|
|
2042
|
+
return _context15.stop();
|
|
1990
2043
|
}
|
|
1991
|
-
},
|
|
2044
|
+
}, _callee15, this, [[6, 21, 24, 27], [36, 59, 62, 65], [69, 74]]);
|
|
1992
2045
|
}));
|
|
1993
2046
|
function upsertLocalDraftOrders(_x11) {
|
|
1994
2047
|
return _upsertLocalDraftOrders.apply(this, arguments);
|
|
@@ -2002,42 +2055,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2002
2055
|
}, {
|
|
2003
2056
|
key: "fetchOrdersBySSE",
|
|
2004
2057
|
value: (function () {
|
|
2005
|
-
var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2058
|
+
var _fetchOrdersBySSE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
2006
2059
|
var query,
|
|
2007
2060
|
data,
|
|
2008
|
-
|
|
2009
|
-
return _regeneratorRuntime().wrap(function
|
|
2010
|
-
while (1) switch (
|
|
2061
|
+
_args16 = arguments;
|
|
2062
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
2063
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
2011
2064
|
case 0:
|
|
2012
|
-
query =
|
|
2065
|
+
query = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {};
|
|
2013
2066
|
if (this.orderDataSource) {
|
|
2014
|
-
|
|
2067
|
+
_context16.next = 3;
|
|
2015
2068
|
break;
|
|
2016
2069
|
}
|
|
2017
|
-
return
|
|
2070
|
+
return _context16.abrupt("return", []);
|
|
2018
2071
|
case 3:
|
|
2019
|
-
|
|
2020
|
-
|
|
2072
|
+
_context16.prev = 3;
|
|
2073
|
+
_context16.next = 6;
|
|
2021
2074
|
return this.orderDataSource.run({
|
|
2022
2075
|
sse: {
|
|
2023
2076
|
query: query
|
|
2024
2077
|
}
|
|
2025
2078
|
});
|
|
2026
2079
|
case 6:
|
|
2027
|
-
data =
|
|
2028
|
-
return
|
|
2080
|
+
data = _context16.sent;
|
|
2081
|
+
return _context16.abrupt("return", data || []);
|
|
2029
2082
|
case 10:
|
|
2030
|
-
|
|
2031
|
-
|
|
2083
|
+
_context16.prev = 10;
|
|
2084
|
+
_context16.t0 = _context16["catch"](3);
|
|
2032
2085
|
this.logError('fetchOrdersBySSE-失败', {
|
|
2033
|
-
error:
|
|
2086
|
+
error: _context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0)
|
|
2034
2087
|
});
|
|
2035
|
-
return
|
|
2088
|
+
return _context16.abrupt("return", []);
|
|
2036
2089
|
case 14:
|
|
2037
2090
|
case "end":
|
|
2038
|
-
return
|
|
2091
|
+
return _context16.stop();
|
|
2039
2092
|
}
|
|
2040
|
-
},
|
|
2093
|
+
}, _callee16, this, [[3, 10]]);
|
|
2041
2094
|
}));
|
|
2042
2095
|
function fetchOrdersBySSE() {
|
|
2043
2096
|
return _fetchOrdersBySSE.apply(this, arguments);
|
|
@@ -2274,41 +2327,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2274
2327
|
}, {
|
|
2275
2328
|
key: "flushOrderSyncMessagesByThrottle",
|
|
2276
2329
|
value: (function () {
|
|
2277
|
-
var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2278
|
-
return _regeneratorRuntime().wrap(function
|
|
2279
|
-
while (1) switch (
|
|
2330
|
+
var _flushOrderSyncMessagesByThrottle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
2331
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
2332
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
2280
2333
|
case 0:
|
|
2281
2334
|
if (!this.isProcessingSyncBatch) {
|
|
2282
|
-
|
|
2335
|
+
_context17.next = 2;
|
|
2283
2336
|
break;
|
|
2284
2337
|
}
|
|
2285
|
-
return
|
|
2338
|
+
return _context17.abrupt("return");
|
|
2286
2339
|
case 2:
|
|
2287
2340
|
if (!(this.pendingSyncMessages.length === 0)) {
|
|
2288
|
-
|
|
2341
|
+
_context17.next = 5;
|
|
2289
2342
|
break;
|
|
2290
2343
|
}
|
|
2291
2344
|
this.isIdlePhase = true;
|
|
2292
|
-
return
|
|
2345
|
+
return _context17.abrupt("return");
|
|
2293
2346
|
case 5:
|
|
2294
2347
|
this.isProcessingSyncBatch = true;
|
|
2295
|
-
|
|
2296
|
-
|
|
2348
|
+
_context17.prev = 6;
|
|
2349
|
+
_context17.next = 9;
|
|
2297
2350
|
return this.processOrderSyncMessages();
|
|
2298
2351
|
case 9:
|
|
2299
|
-
|
|
2352
|
+
_context17.prev = 9;
|
|
2300
2353
|
this.isProcessingSyncBatch = false;
|
|
2301
2354
|
if (this.pendingSyncMessages.length > 0) {
|
|
2302
2355
|
this.scheduleOrderSyncThrottle();
|
|
2303
2356
|
} else {
|
|
2304
2357
|
this.isIdlePhase = true;
|
|
2305
2358
|
}
|
|
2306
|
-
return
|
|
2359
|
+
return _context17.finish(9);
|
|
2307
2360
|
case 13:
|
|
2308
2361
|
case "end":
|
|
2309
|
-
return
|
|
2362
|
+
return _context17.stop();
|
|
2310
2363
|
}
|
|
2311
|
-
},
|
|
2364
|
+
}, _callee17, this, [[6,, 9, 13]]);
|
|
2312
2365
|
}));
|
|
2313
2366
|
function flushOrderSyncMessagesByThrottle() {
|
|
2314
2367
|
return _flushOrderSyncMessagesByThrottle.apply(this, arguments);
|
|
@@ -2330,19 +2383,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2330
2383
|
}, {
|
|
2331
2384
|
key: "processOrderSyncMessages",
|
|
2332
2385
|
value: (function () {
|
|
2333
|
-
var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2386
|
+
var _processOrderSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
2334
2387
|
var _this16 = this;
|
|
2335
2388
|
var messages, batchProcessStartAt, earliestReceivedAt, upsertOrders, refreshIds, uniqueRefreshIds, upsertList, _this$filterRedundant, toFetch, skipped, freshOrders, batchProcessEndAt;
|
|
2336
|
-
return _regeneratorRuntime().wrap(function
|
|
2337
|
-
while (1) switch (
|
|
2389
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
2390
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
2338
2391
|
case 0:
|
|
2339
2392
|
messages = _toConsumableArray(this.pendingSyncMessages);
|
|
2340
2393
|
this.pendingSyncMessages = [];
|
|
2341
2394
|
if (!(messages.length === 0)) {
|
|
2342
|
-
|
|
2395
|
+
_context18.next = 4;
|
|
2343
2396
|
break;
|
|
2344
2397
|
}
|
|
2345
|
-
return
|
|
2398
|
+
return _context18.abrupt("return");
|
|
2346
2399
|
case 4:
|
|
2347
2400
|
batchProcessStartAt = Date.now();
|
|
2348
2401
|
earliestReceivedAt = Math.min.apply(Math, _toConsumableArray(messages.map(function (m) {
|
|
@@ -2376,41 +2429,41 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2376
2429
|
refreshIdCount: uniqueRefreshIds.length
|
|
2377
2430
|
});
|
|
2378
2431
|
if (!(upsertList.length > 0)) {
|
|
2379
|
-
|
|
2432
|
+
_context18.next = 16;
|
|
2380
2433
|
break;
|
|
2381
2434
|
}
|
|
2382
|
-
|
|
2435
|
+
_context18.next = 16;
|
|
2383
2436
|
return this.mergeOrdersToStore(upsertList, 'pubsub.bodyUpsert');
|
|
2384
2437
|
case 16:
|
|
2385
2438
|
if (!(uniqueRefreshIds.length > 0)) {
|
|
2386
|
-
|
|
2439
|
+
_context18.next = 28;
|
|
2387
2440
|
break;
|
|
2388
2441
|
}
|
|
2389
2442
|
_this$filterRedundant = this.filterRedundantHttpRefreshIds(uniqueRefreshIds), toFetch = _this$filterRedundant.toFetch, skipped = _this$filterRedundant.skipped;
|
|
2390
2443
|
if (skipped.length > 0) {}
|
|
2391
2444
|
if (!(toFetch.length > 0)) {
|
|
2392
|
-
|
|
2445
|
+
_context18.next = 28;
|
|
2393
2446
|
break;
|
|
2394
2447
|
}
|
|
2395
|
-
|
|
2448
|
+
_context18.next = 22;
|
|
2396
2449
|
return this.fetchOrdersByHttp(toFetch);
|
|
2397
2450
|
case 22:
|
|
2398
|
-
freshOrders =
|
|
2451
|
+
freshOrders = _context18.sent;
|
|
2399
2452
|
if (!(freshOrders.length > 0)) {
|
|
2400
|
-
|
|
2453
|
+
_context18.next = 28;
|
|
2401
2454
|
break;
|
|
2402
2455
|
}
|
|
2403
|
-
|
|
2456
|
+
_context18.next = 26;
|
|
2404
2457
|
return this.mergeOrdersToStore(freshOrders, 'pubsub.httpRefresh');
|
|
2405
2458
|
case 26:
|
|
2406
|
-
|
|
2459
|
+
_context18.next = 28;
|
|
2407
2460
|
break;
|
|
2408
2461
|
case 28:
|
|
2409
2462
|
if (!(upsertList.length === 0 && uniqueRefreshIds.length === 0)) {
|
|
2410
|
-
|
|
2463
|
+
_context18.next = 30;
|
|
2411
2464
|
break;
|
|
2412
2465
|
}
|
|
2413
|
-
return
|
|
2466
|
+
return _context18.abrupt("return");
|
|
2414
2467
|
case 30:
|
|
2415
2468
|
batchProcessEndAt = Date.now();
|
|
2416
2469
|
this.logInfo('processOrderSyncMessages-结束', {
|
|
@@ -2419,13 +2472,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2419
2472
|
batchProcessDurationMs: batchProcessEndAt - batchProcessStartAt,
|
|
2420
2473
|
totalFromPubsubToProcessedMs: batchProcessEndAt - earliestReceivedAt
|
|
2421
2474
|
});
|
|
2422
|
-
|
|
2475
|
+
_context18.next = 34;
|
|
2423
2476
|
return this.core.effects.emit(OrderHooks.onOrdersSyncCompleted, null);
|
|
2424
2477
|
case 34:
|
|
2425
2478
|
case "end":
|
|
2426
|
-
return
|
|
2479
|
+
return _context18.stop();
|
|
2427
2480
|
}
|
|
2428
|
-
},
|
|
2481
|
+
}, _callee18, this);
|
|
2429
2482
|
}));
|
|
2430
2483
|
function processOrderSyncMessages() {
|
|
2431
2484
|
return _processOrderSyncMessages.apply(this, arguments);
|
|
@@ -2446,29 +2499,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2446
2499
|
}, {
|
|
2447
2500
|
key: "fetchOrdersByHttp",
|
|
2448
2501
|
value: (function () {
|
|
2449
|
-
var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2502
|
+
var _fetchOrdersByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(ids) {
|
|
2450
2503
|
var _orderList, orderList;
|
|
2451
|
-
return _regeneratorRuntime().wrap(function
|
|
2452
|
-
while (1) switch (
|
|
2504
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
2505
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
2453
2506
|
case 0:
|
|
2454
2507
|
if (!(!this.orderDataSource || ids.length === 0)) {
|
|
2455
|
-
|
|
2508
|
+
_context19.next = 2;
|
|
2456
2509
|
break;
|
|
2457
2510
|
}
|
|
2458
|
-
return
|
|
2511
|
+
return _context19.abrupt("return", []);
|
|
2459
2512
|
case 2:
|
|
2460
|
-
|
|
2513
|
+
_context19.prev = 2;
|
|
2461
2514
|
if (!(typeof this.orderDataSource.fetchOrdersByIds === 'function')) {
|
|
2462
|
-
|
|
2515
|
+
_context19.next = 8;
|
|
2463
2516
|
break;
|
|
2464
2517
|
}
|
|
2465
|
-
|
|
2518
|
+
_context19.next = 6;
|
|
2466
2519
|
return this.orderDataSource.fetchOrdersByIds(ids);
|
|
2467
2520
|
case 6:
|
|
2468
|
-
_orderList =
|
|
2469
|
-
return
|
|
2521
|
+
_orderList = _context19.sent;
|
|
2522
|
+
return _context19.abrupt("return", _orderList || []);
|
|
2470
2523
|
case 8:
|
|
2471
|
-
|
|
2524
|
+
_context19.next = 10;
|
|
2472
2525
|
return this.orderDataSource.run({
|
|
2473
2526
|
http: {
|
|
2474
2527
|
query: {
|
|
@@ -2477,17 +2530,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2477
2530
|
}
|
|
2478
2531
|
});
|
|
2479
2532
|
case 10:
|
|
2480
|
-
orderList =
|
|
2481
|
-
return
|
|
2533
|
+
orderList = _context19.sent;
|
|
2534
|
+
return _context19.abrupt("return", orderList || []);
|
|
2482
2535
|
case 14:
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
return
|
|
2536
|
+
_context19.prev = 14;
|
|
2537
|
+
_context19.t0 = _context19["catch"](2);
|
|
2538
|
+
return _context19.abrupt("return", []);
|
|
2486
2539
|
case 17:
|
|
2487
2540
|
case "end":
|
|
2488
|
-
return
|
|
2541
|
+
return _context19.stop();
|
|
2489
2542
|
}
|
|
2490
|
-
},
|
|
2543
|
+
}, _callee19, this, [[2, 14]]);
|
|
2491
2544
|
}));
|
|
2492
2545
|
function fetchOrdersByHttp(_x12) {
|
|
2493
2546
|
return _fetchOrdersByHttp.apply(this, arguments);
|
|
@@ -2501,11 +2554,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2501
2554
|
}, {
|
|
2502
2555
|
key: "mergeOrdersToStore",
|
|
2503
2556
|
value: (function () {
|
|
2504
|
-
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2557
|
+
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(freshOrders, source) {
|
|
2505
2558
|
var _this17 = this;
|
|
2506
2559
|
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;
|
|
2507
|
-
return _regeneratorRuntime().wrap(function
|
|
2508
|
-
while (1) switch (
|
|
2560
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2561
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
2509
2562
|
case 0:
|
|
2510
2563
|
storeOrderCountBefore = this.store.list.length;
|
|
2511
2564
|
this.logInfo('mergeOrdersToStore-开始', {
|
|
@@ -2517,20 +2570,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2517
2570
|
normalizedFreshOrders = [];
|
|
2518
2571
|
incomingProductsHaveStableIdentity = new Map();
|
|
2519
2572
|
_iterator15 = _createForOfIteratorHelper(freshOrders);
|
|
2520
|
-
|
|
2573
|
+
_context20.prev = 6;
|
|
2521
2574
|
_iterator15.s();
|
|
2522
2575
|
case 8:
|
|
2523
2576
|
if ((_step15 = _iterator15.n()).done) {
|
|
2524
|
-
|
|
2577
|
+
_context20.next = 18;
|
|
2525
2578
|
break;
|
|
2526
2579
|
}
|
|
2527
2580
|
order = _step15.value;
|
|
2528
2581
|
id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
2529
2582
|
if (!(id === undefined || id === null)) {
|
|
2530
|
-
|
|
2583
|
+
_context20.next = 13;
|
|
2531
2584
|
break;
|
|
2532
2585
|
}
|
|
2533
|
-
return
|
|
2586
|
+
return _context20.abrupt("continue", 16);
|
|
2534
2587
|
case 13:
|
|
2535
2588
|
rawProducts = order.products;
|
|
2536
2589
|
if (Array.isArray(rawProducts)) {
|
|
@@ -2540,19 +2593,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2540
2593
|
}
|
|
2541
2594
|
normalizedFreshOrders.push(this.normalizeRemoteSyncedOrder(order));
|
|
2542
2595
|
case 16:
|
|
2543
|
-
|
|
2596
|
+
_context20.next = 8;
|
|
2544
2597
|
break;
|
|
2545
2598
|
case 18:
|
|
2546
|
-
|
|
2599
|
+
_context20.next = 23;
|
|
2547
2600
|
break;
|
|
2548
2601
|
case 20:
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
_iterator15.e(
|
|
2602
|
+
_context20.prev = 20;
|
|
2603
|
+
_context20.t0 = _context20["catch"](6);
|
|
2604
|
+
_iterator15.e(_context20.t0);
|
|
2552
2605
|
case 23:
|
|
2553
|
-
|
|
2606
|
+
_context20.prev = 23;
|
|
2554
2607
|
_iterator15.f();
|
|
2555
|
-
return
|
|
2608
|
+
return _context20.finish(23);
|
|
2556
2609
|
case 26:
|
|
2557
2610
|
// 先对本批新单做去重(批内规模 m 很小),保证每条 fresh 身份唯一
|
|
2558
2611
|
uniqueFreshOrders = this.compactOrderListByIdentity(normalizedFreshOrders, "".concat(source, ".incoming")).list;
|
|
@@ -2587,11 +2640,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2587
2640
|
}
|
|
2588
2641
|
}
|
|
2589
2642
|
_iterator17 = _createForOfIteratorHelper(uniqueFreshOrders);
|
|
2590
|
-
|
|
2643
|
+
_context20.prev = 38;
|
|
2591
2644
|
_iterator17.s();
|
|
2592
2645
|
case 40:
|
|
2593
2646
|
if ((_step17 = _iterator17.n()).done) {
|
|
2594
|
-
|
|
2647
|
+
_context20.next = 100;
|
|
2595
2648
|
break;
|
|
2596
2649
|
}
|
|
2597
2650
|
fresh = _step17.value;
|
|
@@ -2600,13 +2653,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2600
2653
|
storageKey = this.getOrderStorageKey(fresh);
|
|
2601
2654
|
mergeKey = storageKey || (fresh.order_id !== undefined && fresh.order_id !== null ? this.getIdKey(fresh.order_id) : '');
|
|
2602
2655
|
if (!(matchIndex >= 0)) {
|
|
2603
|
-
|
|
2656
|
+
_context20.next = 92;
|
|
2604
2657
|
break;
|
|
2605
2658
|
}
|
|
2606
2659
|
existingOrder = updatedList[matchIndex];
|
|
2607
2660
|
previousStorageKey = this.getPersistedOrderStorageKey(existingOrder);
|
|
2608
2661
|
if (!(this.isPendingSyncOrder(existingOrder) && this.isRemoteEchoMergeSource(source))) {
|
|
2609
|
-
|
|
2662
|
+
_context20.next = 52;
|
|
2610
2663
|
break;
|
|
2611
2664
|
}
|
|
2612
2665
|
this.logInfo('mergeOrdersToStore-跳过 pending 订单远端覆盖', {
|
|
@@ -2619,10 +2672,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2619
2672
|
remote_need_sync: (_fresh$need_sync = fresh.need_sync) !== null && _fresh$need_sync !== void 0 ? _fresh$need_sync : null,
|
|
2620
2673
|
reason: 'protect_pending_sync_order_from_remote_echo'
|
|
2621
2674
|
});
|
|
2622
|
-
return
|
|
2675
|
+
return _context20.abrupt("continue", 98);
|
|
2623
2676
|
case 52:
|
|
2624
2677
|
if (!(this.isDraftOrder(existingOrder) && this.shouldProtectDraftOrderFromIncoming(source))) {
|
|
2625
|
-
|
|
2678
|
+
_context20.next = 55;
|
|
2626
2679
|
break;
|
|
2627
2680
|
}
|
|
2628
2681
|
this.logInfo('mergeOrdersToStore-跳过 draft 订单远端覆盖', {
|
|
@@ -2633,7 +2686,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2633
2686
|
remote_is_draft_order: (_fresh$is_draft_order = fresh.is_draft_order) !== null && _fresh$is_draft_order !== void 0 ? _fresh$is_draft_order : null,
|
|
2634
2687
|
reason: 'protect_draft_order_from_remote_echo'
|
|
2635
2688
|
});
|
|
2636
|
-
return
|
|
2689
|
+
return _context20.abrupt("continue", 98);
|
|
2637
2690
|
case 55:
|
|
2638
2691
|
mergedOrder = this.mergeOrderRecords(existingOrder, fresh);
|
|
2639
2692
|
freshOrderId = fresh.order_id;
|
|
@@ -2646,36 +2699,36 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2646
2699
|
adjustedMatchIndex = matchIndex;
|
|
2647
2700
|
duplicateIndexes = new Set();
|
|
2648
2701
|
_iterator18 = _createForOfIteratorHelper(freshIdentityKeys);
|
|
2649
|
-
|
|
2702
|
+
_context20.prev = 64;
|
|
2650
2703
|
_iterator18.s();
|
|
2651
2704
|
case 66:
|
|
2652
2705
|
if ((_step18 = _iterator18.n()).done) {
|
|
2653
|
-
|
|
2706
|
+
_context20.next = 74;
|
|
2654
2707
|
break;
|
|
2655
2708
|
}
|
|
2656
2709
|
_key2 = _step18.value;
|
|
2657
2710
|
_duplicateIndex = identityKeyToIndex.get(_key2);
|
|
2658
2711
|
if (!(_duplicateIndex === undefined || _duplicateIndex === matchIndex)) {
|
|
2659
|
-
|
|
2712
|
+
_context20.next = 71;
|
|
2660
2713
|
break;
|
|
2661
2714
|
}
|
|
2662
|
-
return
|
|
2715
|
+
return _context20.abrupt("continue", 72);
|
|
2663
2716
|
case 71:
|
|
2664
2717
|
duplicateIndexes.add(_duplicateIndex);
|
|
2665
2718
|
case 72:
|
|
2666
|
-
|
|
2719
|
+
_context20.next = 66;
|
|
2667
2720
|
break;
|
|
2668
2721
|
case 74:
|
|
2669
|
-
|
|
2722
|
+
_context20.next = 79;
|
|
2670
2723
|
break;
|
|
2671
2724
|
case 76:
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
_iterator18.e(
|
|
2725
|
+
_context20.prev = 76;
|
|
2726
|
+
_context20.t1 = _context20["catch"](64);
|
|
2727
|
+
_iterator18.e(_context20.t1);
|
|
2675
2728
|
case 79:
|
|
2676
|
-
|
|
2729
|
+
_context20.prev = 79;
|
|
2677
2730
|
_iterator18.f();
|
|
2678
|
-
return
|
|
2731
|
+
return _context20.finish(79);
|
|
2679
2732
|
case 82:
|
|
2680
2733
|
if (duplicateIndexes.size > 0) {
|
|
2681
2734
|
_iterator19 = _createForOfIteratorHelper(_toConsumableArray(duplicateIndexes).sort(function (left, right) {
|
|
@@ -2730,7 +2783,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2730
2783
|
this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, adjustedMatchIndex);
|
|
2731
2784
|
patchedOrders.push(mergedOrder);
|
|
2732
2785
|
if (mergeKey) mergeActions[mergeKey] = 'update';
|
|
2733
|
-
return
|
|
2786
|
+
return _context20.abrupt("continue", 98);
|
|
2734
2787
|
case 92:
|
|
2735
2788
|
insertIndex = updatedList.length;
|
|
2736
2789
|
updatedList.push(fresh);
|
|
@@ -2739,19 +2792,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2739
2792
|
patchedOrders.push(fresh);
|
|
2740
2793
|
if (mergeKey) mergeActions[mergeKey] = 'insert';
|
|
2741
2794
|
case 98:
|
|
2742
|
-
|
|
2795
|
+
_context20.next = 40;
|
|
2743
2796
|
break;
|
|
2744
2797
|
case 100:
|
|
2745
|
-
|
|
2798
|
+
_context20.next = 105;
|
|
2746
2799
|
break;
|
|
2747
2800
|
case 102:
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
_iterator17.e(
|
|
2801
|
+
_context20.prev = 102;
|
|
2802
|
+
_context20.t2 = _context20["catch"](38);
|
|
2803
|
+
_iterator17.e(_context20.t2);
|
|
2751
2804
|
case 105:
|
|
2752
|
-
|
|
2805
|
+
_context20.prev = 105;
|
|
2753
2806
|
_iterator17.f();
|
|
2754
|
-
return
|
|
2807
|
+
return _context20.finish(105);
|
|
2755
2808
|
case 108:
|
|
2756
2809
|
insertCount = Object.values(mergeActions).filter(function (v) {
|
|
2757
2810
|
return v === 'insert';
|
|
@@ -2768,7 +2821,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2768
2821
|
// 仅在自检开关开启时做一次兜底校验。
|
|
2769
2822
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, "".concat(source, ".store"));
|
|
2770
2823
|
this.syncOrdersMap();
|
|
2771
|
-
|
|
2824
|
+
_context20.next = 115;
|
|
2772
2825
|
return this.patchOrdersInSQLite(patchedOrders, source, mergeActions, {
|
|
2773
2826
|
storageKeyMigrations: storageKeyMigrations
|
|
2774
2827
|
}, forceWriteStorageKeys);
|
|
@@ -2779,16 +2832,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2779
2832
|
insertCount: insertCount,
|
|
2780
2833
|
updateCount: updateCount
|
|
2781
2834
|
});
|
|
2782
|
-
|
|
2835
|
+
_context20.next = 118;
|
|
2783
2836
|
return this.emitRemoteProductMembershipChanges(remoteProductMembershipChanges);
|
|
2784
2837
|
case 118:
|
|
2785
|
-
|
|
2838
|
+
_context20.next = 120;
|
|
2786
2839
|
return this.emitOrdersChanged(patchedOrders, source);
|
|
2787
2840
|
case 120:
|
|
2788
2841
|
case "end":
|
|
2789
|
-
return
|
|
2842
|
+
return _context20.stop();
|
|
2790
2843
|
}
|
|
2791
|
-
},
|
|
2844
|
+
}, _callee20, this, [[6, 20, 23, 26], [38, 102, 105, 108], [64, 76, 79, 82]]);
|
|
2792
2845
|
}));
|
|
2793
2846
|
function mergeOrdersToStore(_x13, _x14) {
|
|
2794
2847
|
return _mergeOrdersToStore.apply(this, arguments);
|
|
@@ -3503,7 +3556,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3503
3556
|
}, {
|
|
3504
3557
|
key: "loadOrdersFromSQLite",
|
|
3505
3558
|
value: function () {
|
|
3506
|
-
var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3559
|
+
var _loadOrdersFromSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
3507
3560
|
var _this21 = this;
|
|
3508
3561
|
var options,
|
|
3509
3562
|
_options$onTiming,
|
|
@@ -3514,24 +3567,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3514
3567
|
normalizeStartedAt,
|
|
3515
3568
|
normalizedOrders,
|
|
3516
3569
|
sqliteNormalizeMs,
|
|
3517
|
-
|
|
3518
|
-
return _regeneratorRuntime().wrap(function
|
|
3519
|
-
while (1) switch (
|
|
3570
|
+
_args21 = arguments;
|
|
3571
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
3572
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3520
3573
|
case 0:
|
|
3521
|
-
options =
|
|
3574
|
+
options = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
|
|
3522
3575
|
if (this.dbManager) {
|
|
3523
|
-
|
|
3576
|
+
_context21.next = 3;
|
|
3524
3577
|
break;
|
|
3525
3578
|
}
|
|
3526
|
-
return
|
|
3579
|
+
return _context21.abrupt("return", []);
|
|
3527
3580
|
case 3:
|
|
3528
|
-
|
|
3581
|
+
_context21.prev = 3;
|
|
3529
3582
|
loadStartedAt = performance.now();
|
|
3530
3583
|
rawReadStartedAt = performance.now();
|
|
3531
|
-
|
|
3584
|
+
_context21.next = 8;
|
|
3532
3585
|
return this.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
3533
3586
|
case 8:
|
|
3534
|
-
orders =
|
|
3587
|
+
orders = _context21.sent;
|
|
3535
3588
|
sqliteRawReadMs = +(performance.now() - rawReadStartedAt).toFixed(2);
|
|
3536
3589
|
normalizeStartedAt = performance.now();
|
|
3537
3590
|
normalizedOrders = (orders || []).map(function (order) {
|
|
@@ -3543,22 +3596,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3543
3596
|
sqliteNormalizeMs: sqliteNormalizeMs,
|
|
3544
3597
|
sqliteLoadTotalMs: +(performance.now() - loadStartedAt).toFixed(2)
|
|
3545
3598
|
});
|
|
3546
|
-
return
|
|
3599
|
+
return _context21.abrupt("return", normalizedOrders);
|
|
3547
3600
|
case 17:
|
|
3548
|
-
|
|
3549
|
-
|
|
3601
|
+
_context21.prev = 17;
|
|
3602
|
+
_context21.t0 = _context21["catch"](3);
|
|
3550
3603
|
if (!options.throwOnError) {
|
|
3551
|
-
|
|
3604
|
+
_context21.next = 21;
|
|
3552
3605
|
break;
|
|
3553
3606
|
}
|
|
3554
|
-
throw
|
|
3607
|
+
throw _context21.t0;
|
|
3555
3608
|
case 21:
|
|
3556
|
-
return
|
|
3609
|
+
return _context21.abrupt("return", []);
|
|
3557
3610
|
case 22:
|
|
3558
3611
|
case "end":
|
|
3559
|
-
return
|
|
3612
|
+
return _context21.stop();
|
|
3560
3613
|
}
|
|
3561
|
-
},
|
|
3614
|
+
}, _callee21, this, [[3, 17]]);
|
|
3562
3615
|
}));
|
|
3563
3616
|
function loadOrdersFromSQLite() {
|
|
3564
3617
|
return _loadOrdersFromSQLite.apply(this, arguments);
|
|
@@ -3650,10 +3703,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3650
3703
|
}, {
|
|
3651
3704
|
key: "runInOrderSQLiteSaveQueue",
|
|
3652
3705
|
value: (function () {
|
|
3653
|
-
var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3706
|
+
var _runInOrderSQLiteSaveQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(task) {
|
|
3654
3707
|
var queuedTask;
|
|
3655
|
-
return _regeneratorRuntime().wrap(function
|
|
3656
|
-
while (1) switch (
|
|
3708
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
3709
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3657
3710
|
case 0:
|
|
3658
3711
|
queuedTask = this.orderSQLiteSaveQueue.then(task, task);
|
|
3659
3712
|
this.orderSQLiteSaveQueue = queuedTask.then(function () {
|
|
@@ -3661,12 +3714,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3661
3714
|
}, function () {
|
|
3662
3715
|
return undefined;
|
|
3663
3716
|
});
|
|
3664
|
-
return
|
|
3717
|
+
return _context22.abrupt("return", queuedTask);
|
|
3665
3718
|
case 3:
|
|
3666
3719
|
case "end":
|
|
3667
|
-
return
|
|
3720
|
+
return _context22.stop();
|
|
3668
3721
|
}
|
|
3669
|
-
},
|
|
3722
|
+
}, _callee22, this);
|
|
3670
3723
|
}));
|
|
3671
3724
|
function runInOrderSQLiteSaveQueue(_x15) {
|
|
3672
3725
|
return _runInOrderSQLiteSaveQueue.apply(this, arguments);
|
|
@@ -3683,7 +3736,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3683
3736
|
}, {
|
|
3684
3737
|
key: "patchOrdersInSQLite",
|
|
3685
3738
|
value: (function () {
|
|
3686
|
-
var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3739
|
+
var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(orders, source) {
|
|
3687
3740
|
var _this23 = this;
|
|
3688
3741
|
var mergeActions,
|
|
3689
3742
|
options,
|
|
@@ -3699,30 +3752,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3699
3752
|
_iterator33,
|
|
3700
3753
|
_step33,
|
|
3701
3754
|
migration,
|
|
3702
|
-
|
|
3703
|
-
return _regeneratorRuntime().wrap(function
|
|
3704
|
-
while (1) switch (
|
|
3755
|
+
_args24 = arguments;
|
|
3756
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
3757
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3705
3758
|
case 0:
|
|
3706
|
-
mergeActions =
|
|
3707
|
-
options =
|
|
3708
|
-
forceWriteStorageKeys =
|
|
3759
|
+
mergeActions = _args24.length > 2 && _args24[2] !== undefined ? _args24[2] : {};
|
|
3760
|
+
options = _args24.length > 3 && _args24[3] !== undefined ? _args24[3] : {};
|
|
3761
|
+
forceWriteStorageKeys = _args24.length > 4 && _args24[4] !== undefined ? _args24[4] : new Set();
|
|
3709
3762
|
if (!(orders.length === 0)) {
|
|
3710
|
-
|
|
3763
|
+
_context24.next = 5;
|
|
3711
3764
|
break;
|
|
3712
3765
|
}
|
|
3713
|
-
return
|
|
3766
|
+
return _context24.abrupt("return");
|
|
3714
3767
|
case 5:
|
|
3715
3768
|
if (this.dbManager) {
|
|
3716
|
-
|
|
3769
|
+
_context24.next = 9;
|
|
3717
3770
|
break;
|
|
3718
3771
|
}
|
|
3719
3772
|
if (!options.throwOnError) {
|
|
3720
|
-
|
|
3773
|
+
_context24.next = 8;
|
|
3721
3774
|
break;
|
|
3722
3775
|
}
|
|
3723
3776
|
throw new Error('订单 SQLite 数据库未初始化');
|
|
3724
3777
|
case 8:
|
|
3725
|
-
return
|
|
3778
|
+
return _context24.abrupt("return");
|
|
3726
3779
|
case 9:
|
|
3727
3780
|
migrationTargetStorageKeys = new Set((options.storageKeyMigrations || []).map(function (migration) {
|
|
3728
3781
|
return migration.to;
|
|
@@ -3737,72 +3790,72 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3737
3790
|
return _this23.getOrderStorageKey(order);
|
|
3738
3791
|
});
|
|
3739
3792
|
if (!(ordersSnapshot.length === 0)) {
|
|
3740
|
-
|
|
3793
|
+
_context24.next = 13;
|
|
3741
3794
|
break;
|
|
3742
3795
|
}
|
|
3743
|
-
return
|
|
3796
|
+
return _context24.abrupt("return");
|
|
3744
3797
|
case 13:
|
|
3745
3798
|
_this$filterRedundant2 = this.filterRedundantPatchOrders(source, ordersSnapshot, mergeActions, forceWriteStorageKeys), toWrite = _this$filterRedundant2.toWrite, skipped = _this$filterRedundant2.skipped;
|
|
3746
3799
|
if (!(toWrite.length === 0)) {
|
|
3747
|
-
|
|
3800
|
+
_context24.next = 16;
|
|
3748
3801
|
break;
|
|
3749
3802
|
}
|
|
3750
|
-
return
|
|
3803
|
+
return _context24.abrupt("return");
|
|
3751
3804
|
case 16:
|
|
3752
3805
|
compactedToWrite = this.compactOrderListByIdentity(toWrite, "".concat(source, ".sqlitePatch")).list;
|
|
3753
3806
|
if (!(compactedToWrite.length === 0)) {
|
|
3754
|
-
|
|
3807
|
+
_context24.next = 19;
|
|
3755
3808
|
break;
|
|
3756
3809
|
}
|
|
3757
|
-
return
|
|
3810
|
+
return _context24.abrupt("return");
|
|
3758
3811
|
case 19:
|
|
3759
3812
|
writtenStorageKeys = new Set(compactedToWrite.map(function (order) {
|
|
3760
3813
|
return _this23.getOrderStorageKey(order);
|
|
3761
3814
|
}).filter(Boolean));
|
|
3762
3815
|
storageKeyMigrations = new Map();
|
|
3763
3816
|
_iterator33 = _createForOfIteratorHelper(options.storageKeyMigrations || []);
|
|
3764
|
-
|
|
3817
|
+
_context24.prev = 22;
|
|
3765
3818
|
_iterator33.s();
|
|
3766
3819
|
case 24:
|
|
3767
3820
|
if ((_step33 = _iterator33.n()).done) {
|
|
3768
|
-
|
|
3821
|
+
_context24.next = 33;
|
|
3769
3822
|
break;
|
|
3770
3823
|
}
|
|
3771
3824
|
migration = _step33.value;
|
|
3772
3825
|
if (writtenStorageKeys.has(migration.to)) {
|
|
3773
|
-
|
|
3826
|
+
_context24.next = 28;
|
|
3774
3827
|
break;
|
|
3775
3828
|
}
|
|
3776
|
-
return
|
|
3829
|
+
return _context24.abrupt("continue", 31);
|
|
3777
3830
|
case 28:
|
|
3778
3831
|
if (!writtenStorageKeys.has(migration.from)) {
|
|
3779
|
-
|
|
3832
|
+
_context24.next = 30;
|
|
3780
3833
|
break;
|
|
3781
3834
|
}
|
|
3782
|
-
return
|
|
3835
|
+
return _context24.abrupt("continue", 31);
|
|
3783
3836
|
case 30:
|
|
3784
3837
|
storageKeyMigrations.set(migration.from, migration);
|
|
3785
3838
|
case 31:
|
|
3786
|
-
|
|
3839
|
+
_context24.next = 24;
|
|
3787
3840
|
break;
|
|
3788
3841
|
case 33:
|
|
3789
|
-
|
|
3842
|
+
_context24.next = 38;
|
|
3790
3843
|
break;
|
|
3791
3844
|
case 35:
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
_iterator33.e(
|
|
3845
|
+
_context24.prev = 35;
|
|
3846
|
+
_context24.t0 = _context24["catch"](22);
|
|
3847
|
+
_iterator33.e(_context24.t0);
|
|
3795
3848
|
case 38:
|
|
3796
|
-
|
|
3849
|
+
_context24.prev = 38;
|
|
3797
3850
|
_iterator33.f();
|
|
3798
|
-
return
|
|
3851
|
+
return _context24.finish(38);
|
|
3799
3852
|
case 41:
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3853
|
+
_context24.prev = 41;
|
|
3854
|
+
_context24.next = 44;
|
|
3855
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
3803
3856
|
var writeMethod, _iterator34, _step34, order, _iterator35, _step35, migration, _iterator36, _step36, _orderRecord$ORDER_ST, _order, orderRecord;
|
|
3804
|
-
return _regeneratorRuntime().wrap(function
|
|
3805
|
-
while (1) switch (
|
|
3857
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
3858
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3806
3859
|
case 0:
|
|
3807
3860
|
writeMethod = 'none';
|
|
3808
3861
|
_this23.logInfo('patchOrdersInSQLite-开始', {
|
|
@@ -3811,150 +3864,150 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3811
3864
|
dedupedCount: skipped.length
|
|
3812
3865
|
});
|
|
3813
3866
|
if (!(typeof _this23.dbManager.bulkUpdate === 'function')) {
|
|
3814
|
-
|
|
3867
|
+
_context23.next = 8;
|
|
3815
3868
|
break;
|
|
3816
3869
|
}
|
|
3817
3870
|
writeMethod = 'bulkUpdate';
|
|
3818
|
-
|
|
3871
|
+
_context23.next = 6;
|
|
3819
3872
|
return _this23.dbManager.bulkUpdate(INDEXDB_STORE_NAME, compactedToWrite);
|
|
3820
3873
|
case 6:
|
|
3821
|
-
|
|
3874
|
+
_context23.next = 37;
|
|
3822
3875
|
break;
|
|
3823
3876
|
case 8:
|
|
3824
3877
|
if (!(typeof _this23.dbManager.bulkAdd === 'function')) {
|
|
3825
|
-
|
|
3878
|
+
_context23.next = 14;
|
|
3826
3879
|
break;
|
|
3827
3880
|
}
|
|
3828
3881
|
writeMethod = 'bulkAdd';
|
|
3829
|
-
|
|
3882
|
+
_context23.next = 12;
|
|
3830
3883
|
return _this23.dbManager.bulkAdd(INDEXDB_STORE_NAME, compactedToWrite);
|
|
3831
3884
|
case 12:
|
|
3832
|
-
|
|
3885
|
+
_context23.next = 37;
|
|
3833
3886
|
break;
|
|
3834
3887
|
case 14:
|
|
3835
3888
|
if (!(typeof _this23.dbManager.update === 'function')) {
|
|
3836
|
-
|
|
3889
|
+
_context23.next = 35;
|
|
3837
3890
|
break;
|
|
3838
3891
|
}
|
|
3839
3892
|
writeMethod = 'update';
|
|
3840
3893
|
_iterator34 = _createForOfIteratorHelper(compactedToWrite);
|
|
3841
|
-
|
|
3894
|
+
_context23.prev = 17;
|
|
3842
3895
|
_iterator34.s();
|
|
3843
3896
|
case 19:
|
|
3844
3897
|
if ((_step34 = _iterator34.n()).done) {
|
|
3845
|
-
|
|
3898
|
+
_context23.next = 25;
|
|
3846
3899
|
break;
|
|
3847
3900
|
}
|
|
3848
3901
|
order = _step34.value;
|
|
3849
|
-
|
|
3902
|
+
_context23.next = 23;
|
|
3850
3903
|
return _this23.dbManager.update(INDEXDB_STORE_NAME, order);
|
|
3851
3904
|
case 23:
|
|
3852
|
-
|
|
3905
|
+
_context23.next = 19;
|
|
3853
3906
|
break;
|
|
3854
3907
|
case 25:
|
|
3855
|
-
|
|
3908
|
+
_context23.next = 30;
|
|
3856
3909
|
break;
|
|
3857
3910
|
case 27:
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
_iterator34.e(
|
|
3911
|
+
_context23.prev = 27;
|
|
3912
|
+
_context23.t0 = _context23["catch"](17);
|
|
3913
|
+
_iterator34.e(_context23.t0);
|
|
3861
3914
|
case 30:
|
|
3862
|
-
|
|
3915
|
+
_context23.prev = 30;
|
|
3863
3916
|
_iterator34.f();
|
|
3864
|
-
return
|
|
3917
|
+
return _context23.finish(30);
|
|
3865
3918
|
case 33:
|
|
3866
|
-
|
|
3919
|
+
_context23.next = 37;
|
|
3867
3920
|
break;
|
|
3868
3921
|
case 35:
|
|
3869
3922
|
if (!options.throwOnError) {
|
|
3870
|
-
|
|
3923
|
+
_context23.next = 37;
|
|
3871
3924
|
break;
|
|
3872
3925
|
}
|
|
3873
3926
|
throw new Error('订单 SQLite 数据库不支持写入');
|
|
3874
3927
|
case 37:
|
|
3875
3928
|
_this23.recordRecentSqliteWrite(source, compactedToWrite);
|
|
3876
3929
|
if (!(writeMethod !== 'none')) {
|
|
3877
|
-
|
|
3930
|
+
_context23.next = 84;
|
|
3878
3931
|
break;
|
|
3879
3932
|
}
|
|
3880
3933
|
_iterator35 = _createForOfIteratorHelper(storageKeyMigrations.values());
|
|
3881
|
-
|
|
3934
|
+
_context23.prev = 40;
|
|
3882
3935
|
_iterator35.s();
|
|
3883
3936
|
case 42:
|
|
3884
3937
|
if ((_step35 = _iterator35.n()).done) {
|
|
3885
|
-
|
|
3938
|
+
_context23.next = 76;
|
|
3886
3939
|
break;
|
|
3887
3940
|
}
|
|
3888
3941
|
migration = _step35.value;
|
|
3889
|
-
|
|
3890
|
-
|
|
3942
|
+
_context23.prev = 44;
|
|
3943
|
+
_context23.next = 47;
|
|
3891
3944
|
return _this23.dbManager.delete(INDEXDB_STORE_NAME, migration.from);
|
|
3892
3945
|
case 47:
|
|
3893
3946
|
_this23.recentSqliteWriteByStorageKey.delete(migration.from);
|
|
3894
3947
|
_iterator36 = _createForOfIteratorHelper(orders);
|
|
3895
|
-
|
|
3948
|
+
_context23.prev = 49;
|
|
3896
3949
|
_iterator36.s();
|
|
3897
3950
|
case 51:
|
|
3898
3951
|
if ((_step36 = _iterator36.n()).done) {
|
|
3899
|
-
|
|
3952
|
+
_context23.next = 61;
|
|
3900
3953
|
break;
|
|
3901
3954
|
}
|
|
3902
3955
|
_order = _step36.value;
|
|
3903
3956
|
if (!(_this23.getOrderStorageKey(_order) !== migration.to)) {
|
|
3904
|
-
|
|
3957
|
+
_context23.next = 55;
|
|
3905
3958
|
break;
|
|
3906
3959
|
}
|
|
3907
|
-
return
|
|
3960
|
+
return _context23.abrupt("continue", 59);
|
|
3908
3961
|
case 55:
|
|
3909
3962
|
orderRecord = _order;
|
|
3910
3963
|
if (!(String((_orderRecord$ORDER_ST = orderRecord[ORDER_STORAGE_KEY_FIELD]) !== null && _orderRecord$ORDER_ST !== void 0 ? _orderRecord$ORDER_ST : '') !== migration.from)) {
|
|
3911
|
-
|
|
3964
|
+
_context23.next = 58;
|
|
3912
3965
|
break;
|
|
3913
3966
|
}
|
|
3914
|
-
return
|
|
3967
|
+
return _context23.abrupt("continue", 59);
|
|
3915
3968
|
case 58:
|
|
3916
3969
|
orderRecord[ORDER_STORAGE_KEY_FIELD] = migration.to;
|
|
3917
3970
|
case 59:
|
|
3918
|
-
|
|
3971
|
+
_context23.next = 51;
|
|
3919
3972
|
break;
|
|
3920
3973
|
case 61:
|
|
3921
|
-
|
|
3974
|
+
_context23.next = 66;
|
|
3922
3975
|
break;
|
|
3923
3976
|
case 63:
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
_iterator36.e(
|
|
3977
|
+
_context23.prev = 63;
|
|
3978
|
+
_context23.t1 = _context23["catch"](49);
|
|
3979
|
+
_iterator36.e(_context23.t1);
|
|
3927
3980
|
case 66:
|
|
3928
|
-
|
|
3981
|
+
_context23.prev = 66;
|
|
3929
3982
|
_iterator36.f();
|
|
3930
|
-
return
|
|
3983
|
+
return _context23.finish(66);
|
|
3931
3984
|
case 69:
|
|
3932
|
-
|
|
3985
|
+
_context23.next = 74;
|
|
3933
3986
|
break;
|
|
3934
3987
|
case 71:
|
|
3935
|
-
|
|
3936
|
-
|
|
3988
|
+
_context23.prev = 71;
|
|
3989
|
+
_context23.t2 = _context23["catch"](44);
|
|
3937
3990
|
_this23.logError('删除订单旧 SQLite storage key 失败', {
|
|
3938
3991
|
source: source,
|
|
3939
3992
|
order_id: migration.orderId,
|
|
3940
3993
|
oldStorageKey: migration.from,
|
|
3941
3994
|
newStorageKey: migration.to,
|
|
3942
|
-
error:
|
|
3995
|
+
error: _context23.t2 instanceof Error ? _context23.t2.message : String(_context23.t2)
|
|
3943
3996
|
});
|
|
3944
3997
|
case 74:
|
|
3945
|
-
|
|
3998
|
+
_context23.next = 42;
|
|
3946
3999
|
break;
|
|
3947
4000
|
case 76:
|
|
3948
|
-
|
|
4001
|
+
_context23.next = 81;
|
|
3949
4002
|
break;
|
|
3950
4003
|
case 78:
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
_iterator35.e(
|
|
4004
|
+
_context23.prev = 78;
|
|
4005
|
+
_context23.t3 = _context23["catch"](40);
|
|
4006
|
+
_iterator35.e(_context23.t3);
|
|
3954
4007
|
case 81:
|
|
3955
|
-
|
|
4008
|
+
_context23.prev = 81;
|
|
3956
4009
|
_iterator35.f();
|
|
3957
|
-
return
|
|
4010
|
+
return _context23.finish(81);
|
|
3958
4011
|
case 84:
|
|
3959
4012
|
_this23.logInfo('patchOrdersInSQLite-完成', {
|
|
3960
4013
|
source: source,
|
|
@@ -3964,30 +4017,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3964
4017
|
});
|
|
3965
4018
|
case 85:
|
|
3966
4019
|
case "end":
|
|
3967
|
-
return
|
|
4020
|
+
return _context23.stop();
|
|
3968
4021
|
}
|
|
3969
|
-
},
|
|
4022
|
+
}, _callee23, null, [[17, 27, 30, 33], [40, 78, 81, 84], [44, 71], [49, 63, 66, 69]]);
|
|
3970
4023
|
})));
|
|
3971
4024
|
case 44:
|
|
3972
|
-
|
|
4025
|
+
_context24.next = 51;
|
|
3973
4026
|
break;
|
|
3974
4027
|
case 46:
|
|
3975
|
-
|
|
3976
|
-
|
|
4028
|
+
_context24.prev = 46;
|
|
4029
|
+
_context24.t1 = _context24["catch"](41);
|
|
3977
4030
|
this.logError('增量保存订单到 SQLite 失败', {
|
|
3978
|
-
error:
|
|
4031
|
+
error: _context24.t1 instanceof Error ? _context24.t1.message : String(_context24.t1),
|
|
3979
4032
|
orderCount: ordersSnapshot.length
|
|
3980
4033
|
});
|
|
3981
4034
|
if (!options.throwOnError) {
|
|
3982
|
-
|
|
4035
|
+
_context24.next = 51;
|
|
3983
4036
|
break;
|
|
3984
4037
|
}
|
|
3985
|
-
throw
|
|
4038
|
+
throw _context24.t1;
|
|
3986
4039
|
case 51:
|
|
3987
4040
|
case "end":
|
|
3988
|
-
return
|
|
4041
|
+
return _context24.stop();
|
|
3989
4042
|
}
|
|
3990
|
-
},
|
|
4043
|
+
}, _callee24, this, [[22, 35, 38, 41], [41, 46]]);
|
|
3991
4044
|
}));
|
|
3992
4045
|
function patchOrdersInSQLite(_x16, _x17) {
|
|
3993
4046
|
return _patchOrdersInSQLite.apply(this, arguments);
|
|
@@ -4004,48 +4057,48 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4004
4057
|
}, {
|
|
4005
4058
|
key: "updateOrderInSQLite",
|
|
4006
4059
|
value: (function () {
|
|
4007
|
-
var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4060
|
+
var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(order, source) {
|
|
4008
4061
|
var _this24 = this;
|
|
4009
4062
|
var options,
|
|
4010
4063
|
orderSnapshot,
|
|
4011
4064
|
_orderSnapshot$order_3,
|
|
4012
|
-
|
|
4013
|
-
return _regeneratorRuntime().wrap(function
|
|
4014
|
-
while (1) switch (
|
|
4065
|
+
_args26 = arguments;
|
|
4066
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
4067
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4015
4068
|
case 0:
|
|
4016
|
-
options =
|
|
4069
|
+
options = _args26.length > 2 && _args26[2] !== undefined ? _args26[2] : {};
|
|
4017
4070
|
if (this.getOrderStorageKey(order)) {
|
|
4018
|
-
|
|
4071
|
+
_context26.next = 5;
|
|
4019
4072
|
break;
|
|
4020
4073
|
}
|
|
4021
4074
|
if (!options.throwOnError) {
|
|
4022
|
-
|
|
4075
|
+
_context26.next = 4;
|
|
4023
4076
|
break;
|
|
4024
4077
|
}
|
|
4025
4078
|
throw new Error('订单缺少可用的 SQLite 存储主键');
|
|
4026
4079
|
case 4:
|
|
4027
|
-
return
|
|
4080
|
+
return _context26.abrupt("return");
|
|
4028
4081
|
case 5:
|
|
4029
4082
|
if (this.dbManager) {
|
|
4030
|
-
|
|
4083
|
+
_context26.next = 9;
|
|
4031
4084
|
break;
|
|
4032
4085
|
}
|
|
4033
4086
|
if (!options.throwOnError) {
|
|
4034
|
-
|
|
4087
|
+
_context26.next = 8;
|
|
4035
4088
|
break;
|
|
4036
4089
|
}
|
|
4037
4090
|
throw new Error('订单 SQLite 数据库未初始化');
|
|
4038
4091
|
case 8:
|
|
4039
|
-
return
|
|
4092
|
+
return _context26.abrupt("return");
|
|
4040
4093
|
case 9:
|
|
4041
4094
|
orderSnapshot = this.normalizeOrderCollectionsForIngress(cloneDeep(order), "".concat(source, ".sqliteIngress"));
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4095
|
+
_context26.prev = 10;
|
|
4096
|
+
_context26.next = 13;
|
|
4097
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
4045
4098
|
var _orderSnapshot$order_, _orderSnapshot$order_2;
|
|
4046
4099
|
var writeMethod;
|
|
4047
|
-
return _regeneratorRuntime().wrap(function
|
|
4048
|
-
while (1) switch (
|
|
4100
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
4101
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4049
4102
|
case 0:
|
|
4050
4103
|
writeMethod = 'none';
|
|
4051
4104
|
_this24.logInfo('updateOrderInSQLite-开始', {
|
|
@@ -4054,40 +4107,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4054
4107
|
storageKey: _this24.getOrderStorageKey(orderSnapshot)
|
|
4055
4108
|
});
|
|
4056
4109
|
if (!(typeof _this24.dbManager.update === 'function')) {
|
|
4057
|
-
|
|
4110
|
+
_context25.next = 8;
|
|
4058
4111
|
break;
|
|
4059
4112
|
}
|
|
4060
4113
|
writeMethod = 'update';
|
|
4061
|
-
|
|
4114
|
+
_context25.next = 6;
|
|
4062
4115
|
return _this24.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
|
|
4063
4116
|
case 6:
|
|
4064
|
-
|
|
4117
|
+
_context25.next = 22;
|
|
4065
4118
|
break;
|
|
4066
4119
|
case 8:
|
|
4067
4120
|
if (!(typeof _this24.dbManager.bulkUpdate === 'function')) {
|
|
4068
|
-
|
|
4121
|
+
_context25.next = 14;
|
|
4069
4122
|
break;
|
|
4070
4123
|
}
|
|
4071
4124
|
writeMethod = 'bulkUpdate';
|
|
4072
|
-
|
|
4125
|
+
_context25.next = 12;
|
|
4073
4126
|
return _this24.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
4074
4127
|
case 12:
|
|
4075
|
-
|
|
4128
|
+
_context25.next = 22;
|
|
4076
4129
|
break;
|
|
4077
4130
|
case 14:
|
|
4078
4131
|
if (!(typeof _this24.dbManager.bulkAdd === 'function')) {
|
|
4079
|
-
|
|
4132
|
+
_context25.next = 20;
|
|
4080
4133
|
break;
|
|
4081
4134
|
}
|
|
4082
4135
|
writeMethod = 'bulkAdd';
|
|
4083
|
-
|
|
4136
|
+
_context25.next = 18;
|
|
4084
4137
|
return _this24.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
4085
4138
|
case 18:
|
|
4086
|
-
|
|
4139
|
+
_context25.next = 22;
|
|
4087
4140
|
break;
|
|
4088
4141
|
case 20:
|
|
4089
4142
|
if (!options.throwOnError) {
|
|
4090
|
-
|
|
4143
|
+
_context25.next = 22;
|
|
4091
4144
|
break;
|
|
4092
4145
|
}
|
|
4093
4146
|
throw new Error('订单 SQLite 数据库不支持写入');
|
|
@@ -4100,30 +4153,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4100
4153
|
});
|
|
4101
4154
|
case 24:
|
|
4102
4155
|
case "end":
|
|
4103
|
-
return
|
|
4156
|
+
return _context25.stop();
|
|
4104
4157
|
}
|
|
4105
|
-
},
|
|
4158
|
+
}, _callee25);
|
|
4106
4159
|
})));
|
|
4107
4160
|
case 13:
|
|
4108
|
-
|
|
4161
|
+
_context26.next = 20;
|
|
4109
4162
|
break;
|
|
4110
4163
|
case 15:
|
|
4111
|
-
|
|
4112
|
-
|
|
4164
|
+
_context26.prev = 15;
|
|
4165
|
+
_context26.t0 = _context26["catch"](10);
|
|
4113
4166
|
this.logError('单条保存订单到 SQLite 失败', {
|
|
4114
|
-
error:
|
|
4167
|
+
error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0),
|
|
4115
4168
|
orderId: (_orderSnapshot$order_3 = orderSnapshot.order_id) !== null && _orderSnapshot$order_3 !== void 0 ? _orderSnapshot$order_3 : null
|
|
4116
4169
|
});
|
|
4117
4170
|
if (!options.throwOnError) {
|
|
4118
|
-
|
|
4171
|
+
_context26.next = 20;
|
|
4119
4172
|
break;
|
|
4120
4173
|
}
|
|
4121
|
-
throw
|
|
4174
|
+
throw _context26.t0;
|
|
4122
4175
|
case 20:
|
|
4123
4176
|
case "end":
|
|
4124
|
-
return
|
|
4177
|
+
return _context26.stop();
|
|
4125
4178
|
}
|
|
4126
|
-
},
|
|
4179
|
+
}, _callee26, this, [[10, 15]]);
|
|
4127
4180
|
}));
|
|
4128
4181
|
function updateOrderInSQLite(_x18, _x19) {
|
|
4129
4182
|
return _updateOrderInSQLite.apply(this, arguments);
|
|
@@ -4141,22 +4194,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4141
4194
|
}, {
|
|
4142
4195
|
key: "replaceOrdersSnapshotInSQLite",
|
|
4143
4196
|
value: (function () {
|
|
4144
|
-
var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4197
|
+
var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(orderList, source) {
|
|
4145
4198
|
var _this25 = this;
|
|
4146
4199
|
var protectedOrdersBeforeRemoteFetch,
|
|
4147
4200
|
remoteSnapshot,
|
|
4148
4201
|
mergedSnapshot,
|
|
4149
4202
|
persisted,
|
|
4150
|
-
|
|
4151
|
-
return _regeneratorRuntime().wrap(function
|
|
4152
|
-
while (1) switch (
|
|
4203
|
+
_args28 = arguments;
|
|
4204
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
4205
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4153
4206
|
case 0:
|
|
4154
|
-
protectedOrdersBeforeRemoteFetch =
|
|
4207
|
+
protectedOrdersBeforeRemoteFetch = _args28.length > 2 && _args28[2] !== undefined ? _args28[2] : [];
|
|
4155
4208
|
if (this.dbManager) {
|
|
4156
|
-
|
|
4209
|
+
_context28.next = 3;
|
|
4157
4210
|
break;
|
|
4158
4211
|
}
|
|
4159
|
-
return
|
|
4212
|
+
return _context28.abrupt("return", {
|
|
4160
4213
|
orders: this.compactOrderListByIdentity(orderList.map(function (order) {
|
|
4161
4214
|
return _this25.normalizeRemoteSyncedOrder(order);
|
|
4162
4215
|
}), "".concat(source, ".snapshotNoDb")).list,
|
|
@@ -4170,38 +4223,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4170
4223
|
return _this25.normalizeRemoteSyncedOrder(order);
|
|
4171
4224
|
}), "".concat(source, ".remoteSnapshot")).list;
|
|
4172
4225
|
persisted = false;
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4226
|
+
_context28.prev = 6;
|
|
4227
|
+
_context28.next = 9;
|
|
4228
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
4176
4229
|
var existingOrders, protectedLocalOrders, _iterator37, _step37, rawCurrentOrder, currentOrder, protectedIndex, currentNeedsProtection, orderListSnapshot;
|
|
4177
|
-
return _regeneratorRuntime().wrap(function
|
|
4178
|
-
while (1) switch (
|
|
4230
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
4231
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4179
4232
|
case 0:
|
|
4180
4233
|
if (!(typeof _this25.dbManager.getAll === 'function')) {
|
|
4181
|
-
|
|
4234
|
+
_context27.next = 6;
|
|
4182
4235
|
break;
|
|
4183
4236
|
}
|
|
4184
|
-
|
|
4237
|
+
_context27.next = 3;
|
|
4185
4238
|
return _this25.dbManager.getAll(INDEXDB_STORE_NAME);
|
|
4186
4239
|
case 3:
|
|
4187
|
-
|
|
4188
|
-
|
|
4240
|
+
_context27.t0 = _context27.sent;
|
|
4241
|
+
_context27.next = 7;
|
|
4189
4242
|
break;
|
|
4190
4243
|
case 6:
|
|
4191
|
-
|
|
4244
|
+
_context27.t0 = [];
|
|
4192
4245
|
case 7:
|
|
4193
|
-
existingOrders =
|
|
4246
|
+
existingOrders = _context27.t0;
|
|
4194
4247
|
protectedLocalOrders = protectedOrdersBeforeRemoteFetch.map(function (order) {
|
|
4195
4248
|
return _this25.normalizeOrderCollectionsForIngress(order, "".concat(source, ".protectedBeforeRemoteFetch"));
|
|
4196
4249
|
}).filter(function (order) {
|
|
4197
4250
|
return _this25.shouldProtectLocalOrderFromRemoteSnapshot(order);
|
|
4198
4251
|
});
|
|
4199
4252
|
_iterator37 = _createForOfIteratorHelper(existingOrders || []);
|
|
4200
|
-
|
|
4253
|
+
_context27.prev = 10;
|
|
4201
4254
|
_iterator37.s();
|
|
4202
4255
|
case 12:
|
|
4203
4256
|
if ((_step37 = _iterator37.n()).done) {
|
|
4204
|
-
|
|
4257
|
+
_context27.next = 23;
|
|
4205
4258
|
break;
|
|
4206
4259
|
}
|
|
4207
4260
|
rawCurrentOrder = _step37.value;
|
|
@@ -4209,7 +4262,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4209
4262
|
protectedIndex = _this25.findOrderIndexByIdentity(protectedLocalOrders, currentOrder);
|
|
4210
4263
|
currentNeedsProtection = _this25.shouldProtectLocalOrderFromRemoteSnapshot(currentOrder);
|
|
4211
4264
|
if (!(protectedIndex >= 0)) {
|
|
4212
|
-
|
|
4265
|
+
_context27.next = 20;
|
|
4213
4266
|
break;
|
|
4214
4267
|
}
|
|
4215
4268
|
if (currentNeedsProtection) {
|
|
@@ -4217,23 +4270,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4217
4270
|
} else {
|
|
4218
4271
|
protectedLocalOrders.splice(protectedIndex, 1);
|
|
4219
4272
|
}
|
|
4220
|
-
return
|
|
4273
|
+
return _context27.abrupt("continue", 21);
|
|
4221
4274
|
case 20:
|
|
4222
4275
|
if (currentNeedsProtection) protectedLocalOrders.push(currentOrder);
|
|
4223
4276
|
case 21:
|
|
4224
|
-
|
|
4277
|
+
_context27.next = 12;
|
|
4225
4278
|
break;
|
|
4226
4279
|
case 23:
|
|
4227
|
-
|
|
4280
|
+
_context27.next = 28;
|
|
4228
4281
|
break;
|
|
4229
4282
|
case 25:
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
_iterator37.e(
|
|
4283
|
+
_context27.prev = 25;
|
|
4284
|
+
_context27.t1 = _context27["catch"](10);
|
|
4285
|
+
_iterator37.e(_context27.t1);
|
|
4233
4286
|
case 28:
|
|
4234
|
-
|
|
4287
|
+
_context27.prev = 28;
|
|
4235
4288
|
_iterator37.f();
|
|
4236
|
-
return
|
|
4289
|
+
return _context27.finish(28);
|
|
4237
4290
|
case 31:
|
|
4238
4291
|
orderListSnapshot = _this25.mergeRemoteSnapshotWithPendingOrders(remoteSnapshot, protectedLocalOrders);
|
|
4239
4292
|
mergedSnapshot = _this25.compactOrderListByIdentity(orderListSnapshot, "".concat(source, ".sqliteSnapshot")).list;
|
|
@@ -4258,19 +4311,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4258
4311
|
});
|
|
4259
4312
|
})
|
|
4260
4313
|
});
|
|
4261
|
-
|
|
4314
|
+
_context27.next = 36;
|
|
4262
4315
|
return _this25.dbManager.clear(INDEXDB_STORE_NAME);
|
|
4263
4316
|
case 36:
|
|
4264
4317
|
_this25.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
|
|
4265
4318
|
count: mergedSnapshot.length
|
|
4266
4319
|
});
|
|
4267
4320
|
if (!(mergedSnapshot.length === 0)) {
|
|
4268
|
-
|
|
4321
|
+
_context27.next = 39;
|
|
4269
4322
|
break;
|
|
4270
4323
|
}
|
|
4271
|
-
return
|
|
4324
|
+
return _context27.abrupt("return");
|
|
4272
4325
|
case 39:
|
|
4273
|
-
|
|
4326
|
+
_context27.next = 41;
|
|
4274
4327
|
return _this25.dbManager.bulkAdd(INDEXDB_STORE_NAME, mergedSnapshot);
|
|
4275
4328
|
case 41:
|
|
4276
4329
|
_this25.recordRecentSqliteWrite(source, mergedSnapshot);
|
|
@@ -4280,31 +4333,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4280
4333
|
});
|
|
4281
4334
|
case 43:
|
|
4282
4335
|
case "end":
|
|
4283
|
-
return
|
|
4336
|
+
return _context27.stop();
|
|
4284
4337
|
}
|
|
4285
|
-
},
|
|
4338
|
+
}, _callee27, null, [[10, 25, 28, 31]]);
|
|
4286
4339
|
})));
|
|
4287
4340
|
case 9:
|
|
4288
4341
|
persisted = true;
|
|
4289
|
-
|
|
4342
|
+
_context28.next = 15;
|
|
4290
4343
|
break;
|
|
4291
4344
|
case 12:
|
|
4292
|
-
|
|
4293
|
-
|
|
4345
|
+
_context28.prev = 12;
|
|
4346
|
+
_context28.t0 = _context28["catch"](6);
|
|
4294
4347
|
this.logError('全量保存订单到 SQLite 失败', {
|
|
4295
|
-
error:
|
|
4348
|
+
error: _context28.t0 instanceof Error ? _context28.t0.message : String(_context28.t0),
|
|
4296
4349
|
orderList: remoteSnapshot.length
|
|
4297
4350
|
});
|
|
4298
4351
|
case 15:
|
|
4299
|
-
return
|
|
4352
|
+
return _context28.abrupt("return", {
|
|
4300
4353
|
orders: mergedSnapshot,
|
|
4301
4354
|
persisted: persisted
|
|
4302
4355
|
});
|
|
4303
4356
|
case 16:
|
|
4304
4357
|
case "end":
|
|
4305
|
-
return
|
|
4358
|
+
return _context28.stop();
|
|
4306
4359
|
}
|
|
4307
|
-
},
|
|
4360
|
+
}, _callee28, this, [[6, 12]]);
|
|
4308
4361
|
}));
|
|
4309
4362
|
function replaceOrdersSnapshotInSQLite(_x20, _x21) {
|
|
4310
4363
|
return _replaceOrdersSnapshotInSQLite.apply(this, arguments);
|
|
@@ -4321,38 +4374,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4321
4374
|
}, {
|
|
4322
4375
|
key: "clear",
|
|
4323
4376
|
value: (function () {
|
|
4324
|
-
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4377
|
+
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
4325
4378
|
var _this26 = this;
|
|
4326
|
-
return _regeneratorRuntime().wrap(function
|
|
4327
|
-
while (1) switch (
|
|
4379
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
4380
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4328
4381
|
case 0:
|
|
4329
4382
|
this.store.list = [];
|
|
4330
4383
|
this.store.map = new Map();
|
|
4331
4384
|
if (!this.dbManager) {
|
|
4332
|
-
|
|
4385
|
+
_context30.next = 5;
|
|
4333
4386
|
break;
|
|
4334
4387
|
}
|
|
4335
|
-
|
|
4336
|
-
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4337
|
-
return _regeneratorRuntime().wrap(function
|
|
4338
|
-
while (1) switch (
|
|
4388
|
+
_context30.next = 5;
|
|
4389
|
+
return this.runInOrderSQLiteSaveQueue( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
4390
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
4391
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4339
4392
|
case 0:
|
|
4340
|
-
|
|
4393
|
+
_context29.next = 2;
|
|
4341
4394
|
return _this26.dbManager.clear(INDEXDB_STORE_NAME);
|
|
4342
4395
|
case 2:
|
|
4343
4396
|
case "end":
|
|
4344
|
-
return
|
|
4397
|
+
return _context29.stop();
|
|
4345
4398
|
}
|
|
4346
|
-
},
|
|
4399
|
+
}, _callee29);
|
|
4347
4400
|
})));
|
|
4348
4401
|
case 5:
|
|
4349
4402
|
this.clearOrderSnapshotMarker();
|
|
4350
4403
|
this.emitOrdersChanged([], 'clear');
|
|
4351
4404
|
case 7:
|
|
4352
4405
|
case "end":
|
|
4353
|
-
return
|
|
4406
|
+
return _context30.stop();
|
|
4354
4407
|
}
|
|
4355
|
-
},
|
|
4408
|
+
}, _callee30, this);
|
|
4356
4409
|
}));
|
|
4357
4410
|
function clear() {
|
|
4358
4411
|
return _clear.apply(this, arguments);
|