@pisell/pisellos 2.3.9 → 2.3.10
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/promotion/index.js +9 -0
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +50 -28
- package/dist/solution/Sales/index.js +2 -1
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +18 -1
- package/lib/solution/Sales/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -180,6 +180,7 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
180
180
|
* const idx = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, freshIdentityKeys)
|
|
181
181
|
*/
|
|
182
182
|
private lookupOrderIndexByIdentityKeys;
|
|
183
|
+
private isRemoteEchoMergeSource;
|
|
183
184
|
/**
|
|
184
185
|
* 将订单的全部身份键登记到索引并指向其在列表中的下标。
|
|
185
186
|
* 合并后订单新增的身份字段(如挂单同步后拿到 order_id)也会被登记。
|
|
@@ -1607,7 +1607,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1607
1607
|
key: "mergeOrdersToStore",
|
|
1608
1608
|
value: (function () {
|
|
1609
1609
|
var _mergeOrdersToStore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(freshOrders, source) {
|
|
1610
|
-
var storeOrderCountBefore, normalizedFreshOrders, _iterator9, _step9, order, id, uniqueFreshOrders, uniqueFreshCount, patchedOrders, mergeActions, updatedList, identityKeyToIndex, index, identityKeys, _iterator10, _step10, key, _iterator11, _step11, fresh, freshIdentityKeys, matchIndex, storageKey, mergeKey, mergedOrder, insertIndex, insertCount, updateCount;
|
|
1610
|
+
var storeOrderCountBefore, normalizedFreshOrders, _iterator9, _step9, order, id, uniqueFreshOrders, uniqueFreshCount, patchedOrders, mergeActions, updatedList, identityKeyToIndex, index, identityKeys, _iterator10, _step10, key, _iterator11, _step11, fresh, freshIdentityKeys, matchIndex, storageKey, mergeKey, existingOrder, _ref2, _existingOrder$order_, _ref3, _external_sale_number, _existingOrder$paymen, _fresh$payment_status, _existingOrder$need_s, _fresh$need_sync, mergedOrder, insertIndex, insertCount, updateCount;
|
|
1611
1611
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1612
1612
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1613
1613
|
case 0:
|
|
@@ -1680,7 +1680,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1680
1680
|
_iterator11.s();
|
|
1681
1681
|
case 33:
|
|
1682
1682
|
if ((_step11 = _iterator11.n()).done) {
|
|
1683
|
-
_context16.next =
|
|
1683
|
+
_context16.next = 57;
|
|
1684
1684
|
break;
|
|
1685
1685
|
}
|
|
1686
1686
|
fresh = _step11.value;
|
|
@@ -1689,38 +1689,55 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1689
1689
|
storageKey = this.getOrderStorageKey(fresh);
|
|
1690
1690
|
mergeKey = storageKey || (fresh.order_id !== undefined && fresh.order_id !== null ? this.getIdKey(fresh.order_id) : '');
|
|
1691
1691
|
if (!(matchIndex >= 0)) {
|
|
1692
|
-
_context16.next =
|
|
1692
|
+
_context16.next = 50;
|
|
1693
1693
|
break;
|
|
1694
1694
|
}
|
|
1695
|
-
|
|
1695
|
+
existingOrder = updatedList[matchIndex];
|
|
1696
|
+
if (!(this.isPendingSyncOrder(existingOrder) && this.isRemoteEchoMergeSource(source))) {
|
|
1697
|
+
_context16.next = 44;
|
|
1698
|
+
break;
|
|
1699
|
+
}
|
|
1700
|
+
this.logInfo('mergeOrdersToStore-跳过 pending 订单远端覆盖', {
|
|
1701
|
+
source: source,
|
|
1702
|
+
order_id: (_ref2 = (_existingOrder$order_ = existingOrder.order_id) !== null && _existingOrder$order_ !== void 0 ? _existingOrder$order_ : fresh.order_id) !== null && _ref2 !== void 0 ? _ref2 : null,
|
|
1703
|
+
external_sale_number: (_ref3 = (_external_sale_number = existingOrder.external_sale_number) !== null && _external_sale_number !== void 0 ? _external_sale_number : fresh.external_sale_number) !== null && _ref3 !== void 0 ? _ref3 : null,
|
|
1704
|
+
local_payment_status: (_existingOrder$paymen = existingOrder.payment_status) !== null && _existingOrder$paymen !== void 0 ? _existingOrder$paymen : null,
|
|
1705
|
+
remote_payment_status: (_fresh$payment_status = fresh.payment_status) !== null && _fresh$payment_status !== void 0 ? _fresh$payment_status : null,
|
|
1706
|
+
local_need_sync: (_existingOrder$need_s = existingOrder.need_sync) !== null && _existingOrder$need_s !== void 0 ? _existingOrder$need_s : null,
|
|
1707
|
+
remote_need_sync: (_fresh$need_sync = fresh.need_sync) !== null && _fresh$need_sync !== void 0 ? _fresh$need_sync : null,
|
|
1708
|
+
reason: 'protect_pending_sync_order_from_remote_echo'
|
|
1709
|
+
});
|
|
1710
|
+
return _context16.abrupt("continue", 55);
|
|
1711
|
+
case 44:
|
|
1712
|
+
mergedOrder = this.mergeOrderRecords(existingOrder, fresh);
|
|
1696
1713
|
updatedList[matchIndex] = mergedOrder;
|
|
1697
1714
|
// 合并后身份字段可能新增(如挂单拿到 order_id),同步登记到索引,
|
|
1698
1715
|
// 供同批后续 fresh 命中同一槽位,避免重复插入
|
|
1699
1716
|
this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, matchIndex);
|
|
1700
1717
|
patchedOrders.push(mergedOrder);
|
|
1701
1718
|
if (mergeKey) mergeActions[mergeKey] = 'update';
|
|
1702
|
-
return _context16.abrupt("continue",
|
|
1703
|
-
case
|
|
1719
|
+
return _context16.abrupt("continue", 55);
|
|
1720
|
+
case 50:
|
|
1704
1721
|
insertIndex = updatedList.length;
|
|
1705
1722
|
updatedList.push(fresh);
|
|
1706
1723
|
this.registerOrderIdentityKeys(identityKeyToIndex, fresh, insertIndex);
|
|
1707
1724
|
patchedOrders.push(fresh);
|
|
1708
1725
|
if (mergeKey) mergeActions[mergeKey] = 'insert';
|
|
1709
|
-
case
|
|
1726
|
+
case 55:
|
|
1710
1727
|
_context16.next = 33;
|
|
1711
1728
|
break;
|
|
1712
|
-
case
|
|
1713
|
-
_context16.next =
|
|
1729
|
+
case 57:
|
|
1730
|
+
_context16.next = 62;
|
|
1714
1731
|
break;
|
|
1715
|
-
case
|
|
1716
|
-
_context16.prev =
|
|
1732
|
+
case 59:
|
|
1733
|
+
_context16.prev = 59;
|
|
1717
1734
|
_context16.t1 = _context16["catch"](31);
|
|
1718
1735
|
_iterator11.e(_context16.t1);
|
|
1719
|
-
case
|
|
1720
|
-
_context16.prev =
|
|
1736
|
+
case 62:
|
|
1737
|
+
_context16.prev = 62;
|
|
1721
1738
|
_iterator11.f();
|
|
1722
|
-
return _context16.finish(
|
|
1723
|
-
case
|
|
1739
|
+
return _context16.finish(62);
|
|
1740
|
+
case 65:
|
|
1724
1741
|
insertCount = Object.values(mergeActions).filter(function (v) {
|
|
1725
1742
|
return v === 'insert';
|
|
1726
1743
|
}).length;
|
|
@@ -1736,22 +1753,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1736
1753
|
// 仅在自检开关开启时做一次兜底校验。
|
|
1737
1754
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, "".concat(source, ".store"));
|
|
1738
1755
|
this.syncOrdersMap();
|
|
1739
|
-
_context16.next =
|
|
1756
|
+
_context16.next = 72;
|
|
1740
1757
|
return this.patchOrdersInSQLite(patchedOrders, source, mergeActions);
|
|
1741
|
-
case
|
|
1758
|
+
case 72:
|
|
1742
1759
|
this.logInfo('mergeOrdersToStore-结束', {
|
|
1743
1760
|
uniqueFreshCount: uniqueFreshCount,
|
|
1744
1761
|
storeOrderCountAfter: this.store.list.length,
|
|
1745
1762
|
insertCount: insertCount,
|
|
1746
1763
|
updateCount: updateCount
|
|
1747
1764
|
});
|
|
1748
|
-
_context16.next =
|
|
1765
|
+
_context16.next = 75;
|
|
1749
1766
|
return this.emitOrdersChanged(patchedOrders, source);
|
|
1750
|
-
case
|
|
1767
|
+
case 75:
|
|
1751
1768
|
case "end":
|
|
1752
1769
|
return _context16.stop();
|
|
1753
1770
|
}
|
|
1754
|
-
}, _callee16, this, [[5, 17, 20, 23], [31,
|
|
1771
|
+
}, _callee16, this, [[5, 17, 20, 23], [31, 59, 62, 65]]);
|
|
1755
1772
|
}));
|
|
1756
1773
|
function mergeOrdersToStore(_x9, _x10) {
|
|
1757
1774
|
return _mergeOrdersToStore.apply(this, arguments);
|
|
@@ -1786,6 +1803,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1786
1803
|
}
|
|
1787
1804
|
return matchIndex;
|
|
1788
1805
|
}
|
|
1806
|
+
}, {
|
|
1807
|
+
key: "isRemoteEchoMergeSource",
|
|
1808
|
+
value: function isRemoteEchoMergeSource(source) {
|
|
1809
|
+
return source === 'pubsub.bodyUpsert' || source === 'pubsub.httpRefresh';
|
|
1810
|
+
}
|
|
1789
1811
|
|
|
1790
1812
|
/**
|
|
1791
1813
|
* 将订单的全部身份键登记到索引并指向其在列表中的下标。
|
|
@@ -2166,22 +2188,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2166
2188
|
} finally {
|
|
2167
2189
|
_iterator20.f();
|
|
2168
2190
|
}
|
|
2169
|
-
return _toConsumableArray(groups.entries()).filter(function (
|
|
2170
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
2171
|
-
group = _ref3[1];
|
|
2172
|
-
return group.length > 1;
|
|
2173
|
-
}).slice(0, 20).map(function (_ref4) {
|
|
2191
|
+
return _toConsumableArray(groups.entries()).filter(function (_ref4) {
|
|
2174
2192
|
var _ref5 = _slicedToArray(_ref4, 2),
|
|
2175
|
-
key = _ref5[0],
|
|
2176
2193
|
group = _ref5[1];
|
|
2194
|
+
return group.length > 1;
|
|
2195
|
+
}).slice(0, 20).map(function (_ref6) {
|
|
2196
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
2197
|
+
key = _ref7[0],
|
|
2198
|
+
group = _ref7[1];
|
|
2177
2199
|
return {
|
|
2178
2200
|
key: key,
|
|
2179
2201
|
count: group.length,
|
|
2180
2202
|
orders: group.map(function (order) {
|
|
2181
|
-
var _order$order_id2,
|
|
2203
|
+
var _order$order_id2, _external_sale_number2, _shop_order_number, _shop_full_order_numb, _order$need_sync;
|
|
2182
2204
|
return {
|
|
2183
2205
|
order_id: (_order$order_id2 = order.order_id) !== null && _order$order_id2 !== void 0 ? _order$order_id2 : null,
|
|
2184
|
-
external_sale_number: (
|
|
2206
|
+
external_sale_number: (_external_sale_number2 = order.external_sale_number) !== null && _external_sale_number2 !== void 0 ? _external_sale_number2 : null,
|
|
2185
2207
|
shop_order_number: (_shop_order_number = order.shop_order_number) !== null && _shop_order_number !== void 0 ? _shop_order_number : null,
|
|
2186
2208
|
shop_full_order_number: (_shop_full_order_numb = order.shop_full_order_number) !== null && _shop_full_order_numb !== void 0 ? _shop_full_order_numb : null,
|
|
2187
2209
|
need_sync: (_order$need_sync = order.need_sync) !== null && _order$need_sync !== void 0 ? _order$need_sync : null
|
|
@@ -896,6 +896,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
896
896
|
completedBookingList = matchedBookingList.filter(function (booking) {
|
|
897
897
|
return _this7.getBookingAppointmentStatus(booking) === 'completed';
|
|
898
898
|
});
|
|
899
|
+
debugger;
|
|
899
900
|
unpaidBookingList = matchedBookingList.filter(function (booking) {
|
|
900
901
|
return _this7.getBookingOrderPaymentStatus(booking) === 'unpaid' || _this7.getBookingOrderPaymentStatus(booking) === 'payment_processing';
|
|
901
902
|
});
|
|
@@ -940,7 +941,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
940
941
|
completedBookings: completedBookings,
|
|
941
942
|
unpaidBookings: unpaidBookings
|
|
942
943
|
}));
|
|
943
|
-
case
|
|
944
|
+
case 29:
|
|
944
945
|
case "end":
|
|
945
946
|
return _context6.stop();
|
|
946
947
|
}
|
|
@@ -180,6 +180,7 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
180
180
|
* const idx = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, freshIdentityKeys)
|
|
181
181
|
*/
|
|
182
182
|
private lookupOrderIndexByIdentityKeys;
|
|
183
|
+
private isRemoteEchoMergeSource;
|
|
183
184
|
/**
|
|
184
185
|
* 将订单的全部身份键登记到索引并指向其在列表中的下标。
|
|
185
186
|
* 合并后订单新增的身份字段(如挂单同步后拿到 order_id)也会被登记。
|
|
@@ -985,7 +985,21 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
985
985
|
const storageKey = this.getOrderStorageKey(fresh);
|
|
986
986
|
const mergeKey = storageKey || (fresh.order_id !== void 0 && fresh.order_id !== null ? this.getIdKey(fresh.order_id) : "");
|
|
987
987
|
if (matchIndex >= 0) {
|
|
988
|
-
const
|
|
988
|
+
const existingOrder = updatedList[matchIndex];
|
|
989
|
+
if (this.isPendingSyncOrder(existingOrder) && this.isRemoteEchoMergeSource(source)) {
|
|
990
|
+
this.logInfo("mergeOrdersToStore-跳过 pending 订单远端覆盖", {
|
|
991
|
+
source,
|
|
992
|
+
order_id: existingOrder.order_id ?? fresh.order_id ?? null,
|
|
993
|
+
external_sale_number: existingOrder.external_sale_number ?? fresh.external_sale_number ?? null,
|
|
994
|
+
local_payment_status: existingOrder.payment_status ?? null,
|
|
995
|
+
remote_payment_status: fresh.payment_status ?? null,
|
|
996
|
+
local_need_sync: existingOrder.need_sync ?? null,
|
|
997
|
+
remote_need_sync: fresh.need_sync ?? null,
|
|
998
|
+
reason: "protect_pending_sync_order_from_remote_echo"
|
|
999
|
+
});
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
const mergedOrder = this.mergeOrderRecords(existingOrder, fresh);
|
|
989
1003
|
updatedList[matchIndex] = mergedOrder;
|
|
990
1004
|
this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, matchIndex);
|
|
991
1005
|
patchedOrders.push(mergedOrder);
|
|
@@ -1036,6 +1050,9 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1036
1050
|
}
|
|
1037
1051
|
return matchIndex;
|
|
1038
1052
|
}
|
|
1053
|
+
isRemoteEchoMergeSource(source) {
|
|
1054
|
+
return source === "pubsub.bodyUpsert" || source === "pubsub.httpRefresh";
|
|
1055
|
+
}
|
|
1039
1056
|
/**
|
|
1040
1057
|
* 将订单的全部身份键登记到索引并指向其在列表中的下标。
|
|
1041
1058
|
* 合并后订单新增的身份字段(如挂单同步后拿到 order_id)也会被登记。
|
|
@@ -631,6 +631,7 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
631
631
|
const completedBookingList = matchedBookingList.filter(
|
|
632
632
|
(booking) => this.getBookingAppointmentStatus(booking) === "completed"
|
|
633
633
|
);
|
|
634
|
+
debugger;
|
|
634
635
|
const unpaidBookingList = matchedBookingList.filter(
|
|
635
636
|
(booking) => this.getBookingOrderPaymentStatus(booking) === "unpaid" || this.getBookingOrderPaymentStatus(booking) === "payment_processing"
|
|
636
637
|
);
|