@pisell/pisellos 2.2.84 → 2.2.85
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.
|
@@ -1485,7 +1485,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1485
1485
|
key: "processProductSyncMessages",
|
|
1486
1486
|
value: (function () {
|
|
1487
1487
|
var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1488
|
-
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, _iterator6, _step6, msg, channelKey, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _msg$
|
|
1488
|
+
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, _iterator6, _step6, msg, channelKey, _msg$change_types, _msg$ids2, _msg$ids, ids, _msg$relation_product, bodyId, _msg$relation_product2, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, freshProducts, sseHandledSet, remainingPriceIds;
|
|
1489
1489
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1490
1490
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1491
1491
|
case 0:
|
|
@@ -1509,13 +1509,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1509
1509
|
_iterator6.s();
|
|
1510
1510
|
case 12:
|
|
1511
1511
|
if ((_step6 = _iterator6.n()).done) {
|
|
1512
|
-
_context18.next =
|
|
1512
|
+
_context18.next = 35;
|
|
1513
1513
|
break;
|
|
1514
1514
|
}
|
|
1515
1515
|
msg = _step6.value;
|
|
1516
1516
|
channelKey = msg._channelKey || msg.module || 'product';
|
|
1517
1517
|
if (!(channelKey === 'product')) {
|
|
1518
|
-
_context18.next =
|
|
1518
|
+
_context18.next = 32;
|
|
1519
1519
|
break;
|
|
1520
1520
|
}
|
|
1521
1521
|
if (!(msg.operation === 'delete' || msg.action === 'delete')) {
|
|
@@ -1523,7 +1523,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1523
1523
|
break;
|
|
1524
1524
|
}
|
|
1525
1525
|
if ((_msg$ids = msg.ids) !== null && _msg$ids !== void 0 && _msg$ids.length) deleteIds.push.apply(deleteIds, _toConsumableArray(msg.ids));else if (msg.id) deleteIds.push(msg.id);
|
|
1526
|
-
return _context18.abrupt("continue",
|
|
1526
|
+
return _context18.abrupt("continue", 33);
|
|
1527
1527
|
case 19:
|
|
1528
1528
|
if (!((_msg$change_types = msg.change_types) !== null && _msg$change_types !== void 0 && _msg$change_types.includes('price'))) {
|
|
1529
1529
|
_context18.next = 24;
|
|
@@ -1532,27 +1532,30 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1532
1532
|
ids = msg.ids || (msg.id ? [msg.id] : []);
|
|
1533
1533
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(ids));
|
|
1534
1534
|
priceRefreshIds.push.apply(priceRefreshIds, _toConsumableArray(ids));
|
|
1535
|
-
return _context18.abrupt("continue",
|
|
1535
|
+
return _context18.abrupt("continue", 33);
|
|
1536
1536
|
case 24:
|
|
1537
1537
|
if (!msg.body) {
|
|
1538
|
-
_context18.next =
|
|
1538
|
+
_context18.next = 29;
|
|
1539
1539
|
break;
|
|
1540
1540
|
}
|
|
1541
1541
|
bodyId = msg.body.id || msg.id;
|
|
1542
1542
|
if (bodyId) bodyUpdates.set(bodyId, msg.body);
|
|
1543
|
-
|
|
1544
|
-
|
|
1543
|
+
if ((_msg$relation_product = msg.relation_product_ids) !== null && _msg$relation_product !== void 0 && _msg$relation_product.length) {
|
|
1544
|
+
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
|
|
1545
|
+
}
|
|
1546
|
+
return _context18.abrupt("continue", 33);
|
|
1547
|
+
case 29:
|
|
1545
1548
|
// 5. 其他情况(有 ids 无 body 无 change_types)→ SSE 拉取
|
|
1546
1549
|
if ((_msg$ids2 = msg.ids) !== null && _msg$ids2 !== void 0 && _msg$ids2.length) {
|
|
1547
1550
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.ids));
|
|
1548
1551
|
} else if (msg.id) {
|
|
1549
1552
|
sseRefreshIds.push(msg.id);
|
|
1550
1553
|
}
|
|
1551
|
-
_context18.next =
|
|
1554
|
+
_context18.next = 33;
|
|
1552
1555
|
break;
|
|
1553
|
-
case
|
|
1556
|
+
case 32:
|
|
1554
1557
|
if (['product_collection', 'product_category', 'product_quotation'].includes(channelKey)) {
|
|
1555
|
-
if ((_msg$
|
|
1558
|
+
if ((_msg$relation_product2 = msg.relation_product_ids) !== null && _msg$relation_product2 !== void 0 && _msg$relation_product2.length) {
|
|
1556
1559
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
|
|
1557
1560
|
if (channelKey === 'product_quotation') {
|
|
1558
1561
|
this.clearPriceCache();
|
|
@@ -1560,73 +1563,73 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1560
1563
|
}
|
|
1561
1564
|
}
|
|
1562
1565
|
}
|
|
1563
|
-
case
|
|
1566
|
+
case 33:
|
|
1564
1567
|
_context18.next = 12;
|
|
1565
1568
|
break;
|
|
1566
|
-
case
|
|
1567
|
-
_context18.next =
|
|
1569
|
+
case 35:
|
|
1570
|
+
_context18.next = 40;
|
|
1568
1571
|
break;
|
|
1569
|
-
case
|
|
1570
|
-
_context18.prev =
|
|
1572
|
+
case 37:
|
|
1573
|
+
_context18.prev = 37;
|
|
1571
1574
|
_context18.t0 = _context18["catch"](10);
|
|
1572
1575
|
_iterator6.e(_context18.t0);
|
|
1573
|
-
case
|
|
1574
|
-
_context18.prev =
|
|
1576
|
+
case 40:
|
|
1577
|
+
_context18.prev = 40;
|
|
1575
1578
|
_iterator6.f();
|
|
1576
|
-
return _context18.finish(
|
|
1577
|
-
case
|
|
1579
|
+
return _context18.finish(40);
|
|
1580
|
+
case 43:
|
|
1578
1581
|
uniqueDeleteIds = _toConsumableArray(new Set(deleteIds));
|
|
1579
1582
|
uniqueSSEIds = _toConsumableArray(new Set(sseRefreshIds));
|
|
1580
1583
|
uniquePriceIds = _toConsumableArray(new Set(priceRefreshIds)); // 1. 处理删除
|
|
1581
1584
|
if (!(uniqueDeleteIds.length > 0)) {
|
|
1582
|
-
_context18.next =
|
|
1585
|
+
_context18.next = 49;
|
|
1583
1586
|
break;
|
|
1584
1587
|
}
|
|
1585
|
-
_context18.next =
|
|
1588
|
+
_context18.next = 49;
|
|
1586
1589
|
return this.removeProductsByIds(uniqueDeleteIds);
|
|
1587
|
-
case
|
|
1590
|
+
case 49:
|
|
1588
1591
|
if (!(bodyUpdates.size > 0)) {
|
|
1589
|
-
_context18.next =
|
|
1592
|
+
_context18.next = 52;
|
|
1590
1593
|
break;
|
|
1591
1594
|
}
|
|
1592
|
-
_context18.next =
|
|
1595
|
+
_context18.next = 52;
|
|
1593
1596
|
return this.applyBodyUpdatesToStore(bodyUpdates);
|
|
1594
|
-
case
|
|
1597
|
+
case 52:
|
|
1595
1598
|
if (!(uniqueSSEIds.length > 0)) {
|
|
1596
|
-
_context18.next =
|
|
1599
|
+
_context18.next = 62;
|
|
1597
1600
|
break;
|
|
1598
1601
|
}
|
|
1599
|
-
_context18.next =
|
|
1602
|
+
_context18.next = 55;
|
|
1600
1603
|
return this.fetchProductsBySSE(uniqueSSEIds);
|
|
1601
|
-
case
|
|
1604
|
+
case 55:
|
|
1602
1605
|
freshProducts = _context18.sent;
|
|
1603
1606
|
if (!(freshProducts.length > 0)) {
|
|
1604
|
-
_context18.next =
|
|
1607
|
+
_context18.next = 61;
|
|
1605
1608
|
break;
|
|
1606
1609
|
}
|
|
1607
|
-
_context18.next =
|
|
1610
|
+
_context18.next = 59;
|
|
1608
1611
|
return this.mergeProductsToStore(freshProducts);
|
|
1609
|
-
case
|
|
1610
|
-
_context18.next =
|
|
1612
|
+
case 59:
|
|
1613
|
+
_context18.next = 61;
|
|
1611
1614
|
return this.updatePriceCacheForProducts(freshProducts);
|
|
1612
|
-
case
|
|
1615
|
+
case 61:
|
|
1613
1616
|
this.logInfo('processProductSyncMessages: SSE 增量更新完成', {
|
|
1614
1617
|
requestedCount: uniqueSSEIds.length,
|
|
1615
1618
|
receivedCount: freshProducts.length
|
|
1616
1619
|
});
|
|
1617
|
-
case
|
|
1620
|
+
case 62:
|
|
1618
1621
|
// 4. 处理报价单价格刷新(排除已被第3步 SSE 处理过的 id,避免重复请求)
|
|
1619
1622
|
sseHandledSet = new Set(uniqueSSEIds);
|
|
1620
1623
|
remainingPriceIds = uniquePriceIds.filter(function (id) {
|
|
1621
1624
|
return !sseHandledSet.has(id);
|
|
1622
1625
|
});
|
|
1623
1626
|
if (!(remainingPriceIds.length > 0)) {
|
|
1624
|
-
_context18.next =
|
|
1627
|
+
_context18.next = 67;
|
|
1625
1628
|
break;
|
|
1626
1629
|
}
|
|
1627
|
-
_context18.next =
|
|
1630
|
+
_context18.next = 67;
|
|
1628
1631
|
return this.updateProductPriceByIds(remainingPriceIds);
|
|
1629
|
-
case
|
|
1632
|
+
case 67:
|
|
1630
1633
|
this.logInfo('processProductSyncMessages: 处理完成', {
|
|
1631
1634
|
deleteCount: uniqueDeleteIds.length,
|
|
1632
1635
|
bodyUpdateCount: bodyUpdates.size,
|
|
@@ -1636,19 +1639,19 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1636
1639
|
|
|
1637
1640
|
// 如果都没有变更,则不触发 onProductsSyncCompleted
|
|
1638
1641
|
if (!(uniqueDeleteIds.length === 0 && bodyUpdates.size === 0 && uniqueSSEIds.length === 0 && uniquePriceIds.length === 0)) {
|
|
1639
|
-
_context18.next =
|
|
1642
|
+
_context18.next = 71;
|
|
1640
1643
|
break;
|
|
1641
1644
|
}
|
|
1642
1645
|
this.logInfo('processProductSyncMessages: 没有变更,不触发 onProductsSyncCompleted');
|
|
1643
1646
|
return _context18.abrupt("return");
|
|
1644
|
-
case
|
|
1645
|
-
_context18.next =
|
|
1647
|
+
case 71:
|
|
1648
|
+
_context18.next = 73;
|
|
1646
1649
|
return this.core.effects.emit(ProductsHooks.onProductsSyncCompleted, null);
|
|
1647
|
-
case
|
|
1650
|
+
case 73:
|
|
1648
1651
|
case "end":
|
|
1649
1652
|
return _context18.stop();
|
|
1650
1653
|
}
|
|
1651
|
-
}, _callee18, this, [[10,
|
|
1654
|
+
}, _callee18, this, [[10, 37, 40, 43]]);
|
|
1652
1655
|
}));
|
|
1653
1656
|
function processProductSyncMessages() {
|
|
1654
1657
|
return _processProductSyncMessages.apply(this, arguments);
|
|
@@ -864,7 +864,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
864
864
|
* 处理完成后 emit onProductsSyncCompleted 通知 Server 层
|
|
865
865
|
*/
|
|
866
866
|
async processProductSyncMessages() {
|
|
867
|
-
var _a, _b, _c, _d;
|
|
867
|
+
var _a, _b, _c, _d, _e;
|
|
868
868
|
const messages = [...this.pendingSyncMessages];
|
|
869
869
|
this.pendingSyncMessages = [];
|
|
870
870
|
if (messages.length === 0)
|
|
@@ -894,15 +894,18 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
|
|
|
894
894
|
const bodyId = msg.body.id || msg.id;
|
|
895
895
|
if (bodyId)
|
|
896
896
|
bodyUpdates.set(bodyId, msg.body);
|
|
897
|
+
if ((_c = msg.relation_product_ids) == null ? void 0 : _c.length) {
|
|
898
|
+
sseRefreshIds.push(...msg.relation_product_ids);
|
|
899
|
+
}
|
|
897
900
|
continue;
|
|
898
901
|
}
|
|
899
|
-
if ((
|
|
902
|
+
if ((_d = msg.ids) == null ? void 0 : _d.length) {
|
|
900
903
|
sseRefreshIds.push(...msg.ids);
|
|
901
904
|
} else if (msg.id) {
|
|
902
905
|
sseRefreshIds.push(msg.id);
|
|
903
906
|
}
|
|
904
907
|
} else if (["product_collection", "product_category", "product_quotation"].includes(channelKey)) {
|
|
905
|
-
if ((
|
|
908
|
+
if ((_e = msg.relation_product_ids) == null ? void 0 : _e.length) {
|
|
906
909
|
sseRefreshIds.push(...msg.relation_product_ids);
|
|
907
910
|
if (channelKey === "product_quotation") {
|
|
908
911
|
this.clearPriceCache();
|