@pisell/pisellos 2.2.192 → 2.2.194
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/model/strategy/adapter/walletPass/utils.js +7 -4
- package/dist/modules/Order/index.d.ts +12 -9
- package/dist/modules/Order/index.js +503 -580
- package/dist/modules/Order/types.d.ts +5 -5
- package/dist/modules/Order/utils/manualProductDiscount.js +1 -1
- package/dist/modules/Order/utils.js +3 -3
- package/dist/modules/Payment/utils.js +2 -1
- package/dist/modules/SalesSummary/index.d.ts +0 -25
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +2 -25
- package/dist/modules/SalesSummary/utils.js +529 -160
- package/dist/server/index.d.ts +8 -1
- package/dist/server/index.js +653 -466
- package/dist/server/modules/order/index.d.ts +3 -2
- package/dist/server/modules/order/index.js +68 -52
- package/dist/server/modules/products/index.js +4 -4
- package/dist/solution/BaseSales/index.d.ts +2 -1
- package/dist/solution/BaseSales/index.js +116 -122
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -1
- package/dist/solution/ScanOrder/index.js +3 -1
- package/lib/model/strategy/adapter/walletPass/utils.js +3 -2
- package/lib/modules/Order/index.d.ts +12 -9
- package/lib/modules/Order/index.js +124 -120
- package/lib/modules/Order/types.d.ts +5 -5
- package/lib/modules/Order/utils/manualProductDiscount.js +1 -1
- package/lib/modules/Order/utils.js +4 -4
- package/lib/modules/Payment/utils.js +2 -1
- package/lib/modules/SalesSummary/index.d.ts +0 -25
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +2 -25
- package/lib/modules/SalesSummary/utils.js +420 -92
- package/lib/server/index.d.ts +8 -1
- package/lib/server/index.js +145 -26
- package/lib/server/modules/order/index.d.ts +3 -2
- package/lib/server/modules/order/index.js +25 -15
- package/lib/server/modules/products/index.js +0 -4
- package/lib/solution/BaseSales/index.d.ts +2 -1
- package/lib/solution/BaseSales/index.js +53 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +0 -1
- package/lib/solution/ScanOrder/index.js +3 -1
- package/package.json +1 -1
|
@@ -69,9 +69,9 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
69
69
|
preload(): Promise<void>;
|
|
70
70
|
getOrders(): OrderData[];
|
|
71
71
|
getOrderById(id: OrderId): OrderData | undefined;
|
|
72
|
-
/** 按 order_id
|
|
72
|
+
/** 按 order_id 查询内存订单。 */
|
|
73
73
|
getOrderByOrderId(orderId: OrderId): OrderData | undefined;
|
|
74
|
-
|
|
74
|
+
getLocalOrderByLookup(lookup: OrderId): Promise<OrderData | null>;
|
|
75
75
|
loadOrdersByServer(): Promise<OrderData[]>;
|
|
76
76
|
/**
|
|
77
77
|
* 静默全量刷新:后台重新拉取全量 SSE 订单数据并更新本地
|
|
@@ -152,6 +152,7 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
152
152
|
private normalizeOrderSyncPayload;
|
|
153
153
|
private uniqueOrderIds;
|
|
154
154
|
private getIdKey;
|
|
155
|
+
private isOrderLookupMatch;
|
|
155
156
|
/**
|
|
156
157
|
* 解析订单 SQLite 主键,规则与宿主 OrderDataSource.getOrderStorageKey 一致。
|
|
157
158
|
*
|
|
@@ -491,59 +491,64 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
491
491
|
return this.store.map.get(this.getIdKey(id));
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
-
/** 按 order_id
|
|
494
|
+
/** 按 order_id 查询内存订单。 */
|
|
495
495
|
}, {
|
|
496
496
|
key: "getOrderByOrderId",
|
|
497
497
|
value: function getOrderByOrderId(orderId) {
|
|
498
498
|
return this.store.map.get(this.getIdKey(orderId));
|
|
499
499
|
}
|
|
500
500
|
}, {
|
|
501
|
-
key: "
|
|
501
|
+
key: "getLocalOrderByLookup",
|
|
502
502
|
value: function () {
|
|
503
|
-
var
|
|
503
|
+
var _getLocalOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(lookup) {
|
|
504
504
|
var _this3 = this;
|
|
505
|
-
var key, memoryOrder, orders, localOrder;
|
|
505
|
+
var key, memoryOrderById, memoryOrder, orders, localOrder;
|
|
506
506
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
507
507
|
while (1) switch (_context4.prev = _context4.next) {
|
|
508
508
|
case 0:
|
|
509
|
-
key = this.getIdKey(
|
|
510
|
-
|
|
511
|
-
if (!
|
|
509
|
+
key = this.getIdKey(lookup);
|
|
510
|
+
memoryOrderById = this.store.map.get(key);
|
|
511
|
+
if (!memoryOrderById) {
|
|
512
512
|
_context4.next = 4;
|
|
513
513
|
break;
|
|
514
514
|
}
|
|
515
|
-
return _context4.abrupt("return",
|
|
515
|
+
return _context4.abrupt("return", memoryOrderById);
|
|
516
516
|
case 4:
|
|
517
|
-
|
|
517
|
+
memoryOrder = this.store.list.find(function (order) {
|
|
518
|
+
return _this3.isOrderLookupMatch(order, key);
|
|
519
|
+
});
|
|
520
|
+
if (!memoryOrder) {
|
|
521
|
+
_context4.next = 7;
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
return _context4.abrupt("return", memoryOrder);
|
|
525
|
+
case 7:
|
|
526
|
+
_context4.next = 9;
|
|
518
527
|
return this.loadOrdersFromSQLite();
|
|
519
|
-
case
|
|
528
|
+
case 9:
|
|
520
529
|
orders = _context4.sent;
|
|
521
530
|
localOrder = orders.find(function (order) {
|
|
522
|
-
|
|
523
|
-
if (shopOrderNumber && _this3.getIdKey(shopOrderNumber) === key) return true;
|
|
524
|
-
var id = order === null || order === void 0 ? void 0 : order.order_id;
|
|
525
|
-
if (id === undefined || id === null) return false;
|
|
526
|
-
return _this3.getIdKey(id) === key;
|
|
531
|
+
return _this3.isOrderLookupMatch(order, key);
|
|
527
532
|
});
|
|
528
533
|
if (localOrder) {
|
|
529
|
-
_context4.next =
|
|
534
|
+
_context4.next = 13;
|
|
530
535
|
break;
|
|
531
536
|
}
|
|
532
537
|
return _context4.abrupt("return", null);
|
|
533
|
-
case
|
|
538
|
+
case 13:
|
|
534
539
|
this.store.list = orders;
|
|
535
540
|
this.syncOrdersMap();
|
|
536
541
|
return _context4.abrupt("return", localOrder);
|
|
537
|
-
case
|
|
542
|
+
case 16:
|
|
538
543
|
case "end":
|
|
539
544
|
return _context4.stop();
|
|
540
545
|
}
|
|
541
546
|
}, _callee4, this);
|
|
542
547
|
}));
|
|
543
|
-
function
|
|
544
|
-
return
|
|
548
|
+
function getLocalOrderByLookup(_x3) {
|
|
549
|
+
return _getLocalOrderByLookup.apply(this, arguments);
|
|
545
550
|
}
|
|
546
|
-
return
|
|
551
|
+
return getLocalOrderByLookup;
|
|
547
552
|
}()
|
|
548
553
|
}, {
|
|
549
554
|
key: "loadOrdersByServer",
|
|
@@ -1390,6 +1395,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1390
1395
|
value: function getIdKey(id) {
|
|
1391
1396
|
return String(id);
|
|
1392
1397
|
}
|
|
1398
|
+
}, {
|
|
1399
|
+
key: "isOrderLookupMatch",
|
|
1400
|
+
value: function isOrderLookupMatch(order, lookupKey) {
|
|
1401
|
+
var _this11 = this;
|
|
1402
|
+
if (!order || !lookupKey) return false;
|
|
1403
|
+
var candidates = [order.order_id, order.external_sale_number, order.order_number, order.shop_order_number, order.shop_full_order_number];
|
|
1404
|
+
return candidates.some(function (value) {
|
|
1405
|
+
if (value === undefined || value === null || value === '') return false;
|
|
1406
|
+
return _this11.getIdKey(value) === lookupKey;
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1393
1409
|
|
|
1394
1410
|
/**
|
|
1395
1411
|
* 解析订单 SQLite 主键,规则与宿主 OrderDataSource.getOrderStorageKey 一致。
|
|
@@ -1569,7 +1585,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1569
1585
|
key: "patchOrdersInSQLite",
|
|
1570
1586
|
value: (function () {
|
|
1571
1587
|
var _patchOrdersInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orders, source) {
|
|
1572
|
-
var
|
|
1588
|
+
var _this12 = this;
|
|
1573
1589
|
var mergeActions,
|
|
1574
1590
|
ordersSnapshot,
|
|
1575
1591
|
_this$filterRedundant2,
|
|
@@ -1587,7 +1603,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1587
1603
|
return _context17.abrupt("return");
|
|
1588
1604
|
case 3:
|
|
1589
1605
|
ordersSnapshot = cloneDeep(orders).filter(function (order) {
|
|
1590
|
-
return
|
|
1606
|
+
return _this12.getOrderStorageKey(order);
|
|
1591
1607
|
});
|
|
1592
1608
|
if (!(ordersSnapshot.length === 0)) {
|
|
1593
1609
|
_context17.next = 6;
|
|
@@ -1610,34 +1626,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1610
1626
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1611
1627
|
case 0:
|
|
1612
1628
|
writeMethod = 'none';
|
|
1613
|
-
|
|
1629
|
+
_this12.logInfo('patchOrdersInSQLite-开始', {
|
|
1614
1630
|
source: source,
|
|
1615
1631
|
count: toWrite.length,
|
|
1616
1632
|
dedupedCount: skipped.length
|
|
1617
1633
|
});
|
|
1618
|
-
if (!(typeof
|
|
1634
|
+
if (!(typeof _this12.dbManager.bulkUpdate === 'function')) {
|
|
1619
1635
|
_context16.next = 8;
|
|
1620
1636
|
break;
|
|
1621
1637
|
}
|
|
1622
1638
|
writeMethod = 'bulkUpdate';
|
|
1623
1639
|
_context16.next = 6;
|
|
1624
|
-
return
|
|
1640
|
+
return _this12.dbManager.bulkUpdate(INDEXDB_STORE_NAME, toWrite);
|
|
1625
1641
|
case 6:
|
|
1626
1642
|
_context16.next = 33;
|
|
1627
1643
|
break;
|
|
1628
1644
|
case 8:
|
|
1629
|
-
if (!(typeof
|
|
1645
|
+
if (!(typeof _this12.dbManager.bulkAdd === 'function')) {
|
|
1630
1646
|
_context16.next = 14;
|
|
1631
1647
|
break;
|
|
1632
1648
|
}
|
|
1633
1649
|
writeMethod = 'bulkAdd';
|
|
1634
1650
|
_context16.next = 12;
|
|
1635
|
-
return
|
|
1651
|
+
return _this12.dbManager.bulkAdd(INDEXDB_STORE_NAME, toWrite);
|
|
1636
1652
|
case 12:
|
|
1637
1653
|
_context16.next = 33;
|
|
1638
1654
|
break;
|
|
1639
1655
|
case 14:
|
|
1640
|
-
if (!(typeof
|
|
1656
|
+
if (!(typeof _this12.dbManager.update === 'function')) {
|
|
1641
1657
|
_context16.next = 33;
|
|
1642
1658
|
break;
|
|
1643
1659
|
}
|
|
@@ -1652,7 +1668,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1652
1668
|
}
|
|
1653
1669
|
order = _step9.value;
|
|
1654
1670
|
_context16.next = 23;
|
|
1655
|
-
return
|
|
1671
|
+
return _this12.dbManager.update(INDEXDB_STORE_NAME, order);
|
|
1656
1672
|
case 23:
|
|
1657
1673
|
_context16.next = 19;
|
|
1658
1674
|
break;
|
|
@@ -1668,8 +1684,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1668
1684
|
_iterator9.f();
|
|
1669
1685
|
return _context16.finish(30);
|
|
1670
1686
|
case 33:
|
|
1671
|
-
|
|
1672
|
-
|
|
1687
|
+
_this12.recordRecentSqliteWrite(source, toWrite);
|
|
1688
|
+
_this12.logInfo('patchOrdersInSQLite-完成', {
|
|
1673
1689
|
source: source,
|
|
1674
1690
|
count: toWrite.length,
|
|
1675
1691
|
writeMethod: writeMethod,
|
|
@@ -1713,7 +1729,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1713
1729
|
key: "updateOrderInSQLite",
|
|
1714
1730
|
value: (function () {
|
|
1715
1731
|
var _updateOrderInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(order, source) {
|
|
1716
|
-
var
|
|
1732
|
+
var _this13 = this;
|
|
1717
1733
|
var orderSnapshot, _orderSnapshot$order_3;
|
|
1718
1734
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1719
1735
|
while (1) switch (_context19.prev = _context19.next) {
|
|
@@ -1734,43 +1750,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1734
1750
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1735
1751
|
case 0:
|
|
1736
1752
|
writeMethod = 'none';
|
|
1737
|
-
|
|
1753
|
+
_this13.logInfo('updateOrderInSQLite-开始', {
|
|
1738
1754
|
source: source,
|
|
1739
1755
|
orderId: (_orderSnapshot$order_ = orderSnapshot.order_id) !== null && _orderSnapshot$order_ !== void 0 ? _orderSnapshot$order_ : null,
|
|
1740
|
-
storageKey:
|
|
1756
|
+
storageKey: _this13.getOrderStorageKey(orderSnapshot)
|
|
1741
1757
|
});
|
|
1742
|
-
if (!(typeof
|
|
1758
|
+
if (!(typeof _this13.dbManager.update === 'function')) {
|
|
1743
1759
|
_context18.next = 8;
|
|
1744
1760
|
break;
|
|
1745
1761
|
}
|
|
1746
1762
|
writeMethod = 'update';
|
|
1747
1763
|
_context18.next = 6;
|
|
1748
|
-
return
|
|
1764
|
+
return _this13.dbManager.update(INDEXDB_STORE_NAME, orderSnapshot);
|
|
1749
1765
|
case 6:
|
|
1750
1766
|
_context18.next = 18;
|
|
1751
1767
|
break;
|
|
1752
1768
|
case 8:
|
|
1753
|
-
if (!(typeof
|
|
1769
|
+
if (!(typeof _this13.dbManager.bulkUpdate === 'function')) {
|
|
1754
1770
|
_context18.next = 14;
|
|
1755
1771
|
break;
|
|
1756
1772
|
}
|
|
1757
1773
|
writeMethod = 'bulkUpdate';
|
|
1758
1774
|
_context18.next = 12;
|
|
1759
|
-
return
|
|
1775
|
+
return _this13.dbManager.bulkUpdate(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
1760
1776
|
case 12:
|
|
1761
1777
|
_context18.next = 18;
|
|
1762
1778
|
break;
|
|
1763
1779
|
case 14:
|
|
1764
|
-
if (!(typeof
|
|
1780
|
+
if (!(typeof _this13.dbManager.bulkAdd === 'function')) {
|
|
1765
1781
|
_context18.next = 18;
|
|
1766
1782
|
break;
|
|
1767
1783
|
}
|
|
1768
1784
|
writeMethod = 'bulkAdd';
|
|
1769
1785
|
_context18.next = 18;
|
|
1770
|
-
return
|
|
1786
|
+
return _this13.dbManager.bulkAdd(INDEXDB_STORE_NAME, [orderSnapshot]);
|
|
1771
1787
|
case 18:
|
|
1772
|
-
|
|
1773
|
-
|
|
1788
|
+
_this13.recordRecentSqliteWrite(source, [orderSnapshot]);
|
|
1789
|
+
_this13.logInfo('updateOrderInSQLite-完成', {
|
|
1774
1790
|
source: source,
|
|
1775
1791
|
orderId: (_orderSnapshot$order_2 = orderSnapshot.order_id) !== null && _orderSnapshot$order_2 !== void 0 ? _orderSnapshot$order_2 : null,
|
|
1776
1792
|
writeMethod: writeMethod
|
|
@@ -1813,7 +1829,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1813
1829
|
key: "replaceOrdersSnapshotInSQLite",
|
|
1814
1830
|
value: (function () {
|
|
1815
1831
|
var _replaceOrdersSnapshotInSQLite = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderList, source) {
|
|
1816
|
-
var
|
|
1832
|
+
var _this14 = this;
|
|
1817
1833
|
var orderListSnapshot;
|
|
1818
1834
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1819
1835
|
while (1) switch (_context21.prev = _context21.next) {
|
|
@@ -1831,14 +1847,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1831
1847
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1832
1848
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1833
1849
|
case 0:
|
|
1834
|
-
|
|
1850
|
+
_this14.logInfo('replaceOrdersSnapshotInSQLite-开始', {
|
|
1835
1851
|
source: source,
|
|
1836
1852
|
count: orderListSnapshot.length
|
|
1837
1853
|
});
|
|
1838
1854
|
_context20.next = 3;
|
|
1839
|
-
return
|
|
1855
|
+
return _this14.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1840
1856
|
case 3:
|
|
1841
|
-
|
|
1857
|
+
_this14.logInfo('replaceOrdersSnapshotInSQLite-clear完成', {
|
|
1842
1858
|
count: orderListSnapshot.length
|
|
1843
1859
|
});
|
|
1844
1860
|
if (!(orderListSnapshot.length === 0)) {
|
|
@@ -1848,10 +1864,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1848
1864
|
return _context20.abrupt("return");
|
|
1849
1865
|
case 6:
|
|
1850
1866
|
_context20.next = 8;
|
|
1851
|
-
return
|
|
1867
|
+
return _this14.dbManager.bulkAdd(INDEXDB_STORE_NAME, orderListSnapshot);
|
|
1852
1868
|
case 8:
|
|
1853
|
-
|
|
1854
|
-
|
|
1869
|
+
_this14.recordRecentSqliteWrite(source, orderListSnapshot);
|
|
1870
|
+
_this14.logInfo('replaceOrdersSnapshotInSQLite-bulkAdd完成', {
|
|
1855
1871
|
source: source,
|
|
1856
1872
|
count: orderListSnapshot.length
|
|
1857
1873
|
});
|
|
@@ -1893,7 +1909,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1893
1909
|
key: "clear",
|
|
1894
1910
|
value: (function () {
|
|
1895
1911
|
var _clear = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1896
|
-
var
|
|
1912
|
+
var _this15 = this;
|
|
1897
1913
|
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1898
1914
|
while (1) switch (_context23.prev = _context23.next) {
|
|
1899
1915
|
case 0:
|
|
@@ -1910,7 +1926,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1910
1926
|
while (1) switch (_context22.prev = _context22.next) {
|
|
1911
1927
|
case 0:
|
|
1912
1928
|
_context22.next = 2;
|
|
1913
|
-
return
|
|
1929
|
+
return _this15.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1914
1930
|
case 2:
|
|
1915
1931
|
case "end":
|
|
1916
1932
|
return _context22.stop();
|
|
@@ -2048,10 +2048,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2048
2048
|
this.productDataSource.run({
|
|
2049
2049
|
pubsub: {
|
|
2050
2050
|
callback: function callback(res) {
|
|
2051
|
-
console.log('sse_products_callback', res)
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
});
|
|
2051
|
+
// console.log('sse_products_callback', res)
|
|
2052
|
+
// this.logInfo('sse_products_callback: 收到同步消息', {
|
|
2053
|
+
// data: res?.data,
|
|
2054
|
+
// });
|
|
2055
2055
|
if (!(res !== null && res !== void 0 && res.data)) return;
|
|
2056
2056
|
var data = res.data;
|
|
2057
2057
|
var channelKey = data.module || 'product';
|
|
@@ -89,7 +89,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
89
89
|
destroy(): Promise<void>;
|
|
90
90
|
/**
|
|
91
91
|
* 加载销售订单到统一 tempOrder 工作区。
|
|
92
|
-
*
|
|
92
|
+
* 统一通过 OrderModule 的 sales detail lookup 加载订单详情。
|
|
93
93
|
*
|
|
94
94
|
* 子类可在 `super.loadSalesDetail` 之后基于返回的 `sales` 做业务侧装配
|
|
95
95
|
* (比如把 `sales.customer` 写入 CustomerModule、emit 业务 hook 等)。
|
|
@@ -140,6 +140,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
140
140
|
private getHistoricalProductDiscountList;
|
|
141
141
|
private isPersistedOrderProduct;
|
|
142
142
|
private mergeHistoricalDiscountList;
|
|
143
|
+
private shouldSkipAutoApplyFetchedDiscountsInEditMode;
|
|
143
144
|
private mergeCurrentDiscountSelectionState;
|
|
144
145
|
loadDiscountConfig(params?: {
|
|
145
146
|
customerId?: number;
|