@pisell/pisellos 2.2.260 → 2.2.261
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/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +17 -13
- package/dist/modules/Order/index.d.ts +33 -2
- package/dist/modules/Order/index.js +615 -288
- package/dist/modules/Order/types.d.ts +20 -2
- package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +116 -29
- package/dist/modules/Product/types.d.ts +0 -22
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -4
- package/dist/modules/ProductList/types.d.ts +0 -2
- package/dist/modules/Rules/index.d.ts +4 -3
- package/dist/modules/Rules/index.js +42 -17
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +2 -1
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/server/index.d.ts +3 -50
- package/dist/server/index.js +1075 -1040
- package/dist/server/modules/order/index.d.ts +22 -3
- package/dist/server/modules/order/index.js +398 -316
- package/dist/server/modules/products/index.d.ts +7 -26
- package/dist/server/modules/products/index.js +76 -166
- package/dist/server/modules/products/types.d.ts +0 -14
- package/dist/solution/BaseSales/index.d.ts +22 -2
- package/dist/solution/BaseSales/index.js +995 -701
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +74 -29
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +9 -1
- package/dist/solution/BookingTicket/index.js +153 -6
- package/dist/solution/BookingTicket/types.d.ts +0 -2
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.js +30 -19
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +2 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.d.ts +33 -2
- package/lib/modules/Order/index.js +402 -64
- package/lib/modules/Order/types.d.ts +20 -2
- package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
- package/lib/modules/Order/utils/bundleDiscountHydration.js +139 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +90 -3
- package/lib/modules/Product/types.d.ts +0 -22
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -4
- package/lib/modules/ProductList/types.d.ts +0 -2
- package/lib/modules/Rules/index.d.ts +4 -3
- package/lib/modules/Rules/index.js +27 -7
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +2 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/server/index.d.ts +3 -50
- package/lib/server/index.js +244 -215
- package/lib/server/modules/order/index.d.ts +22 -3
- package/lib/server/modules/order/index.js +103 -53
- package/lib/server/modules/products/index.d.ts +7 -26
- package/lib/server/modules/products/index.js +35 -113
- package/lib/server/modules/products/types.d.ts +0 -14
- package/lib/solution/BaseSales/index.d.ts +22 -2
- package/lib/solution/BaseSales/index.js +246 -60
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +59 -16
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +9 -1
- package/lib/solution/BookingTicket/index.js +101 -0
- package/lib/solution/BookingTicket/types.d.ts +0 -2
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -152
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -755
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -282
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -49
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -139
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -87
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -564
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -295
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -146
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
|
@@ -18,8 +18,7 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
18
18
|
private productsPriceCache;
|
|
19
19
|
private readonly CACHE_MAX_DAYS;
|
|
20
20
|
private formatters;
|
|
21
|
-
private
|
|
22
|
-
private isLegacyPriceFormatterEnabled;
|
|
21
|
+
private isPriceFormatterRegistered;
|
|
23
22
|
private quotationPriceBridge?;
|
|
24
23
|
private quotationBridgeChannel?;
|
|
25
24
|
private quotationBridgeLoadedKey?;
|
|
@@ -37,8 +36,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
37
36
|
private lastPreloadCompletedAtMs;
|
|
38
37
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
39
38
|
private productIndexDBSaveQueue;
|
|
40
|
-
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
41
|
-
private lastScheduleTimePoints;
|
|
42
39
|
constructor(name?: string, version?: string);
|
|
43
40
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
44
41
|
/**
|
|
@@ -111,10 +108,6 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
111
108
|
*/
|
|
112
109
|
private prepareProductsWithPrice;
|
|
113
110
|
private getProductsPriceCacheKey;
|
|
114
|
-
/**
|
|
115
|
-
* 稳定序列化策略上下文,避免对象 key 顺序不同导致缓存 key 抖动。
|
|
116
|
-
*/
|
|
117
|
-
private stringifyStable;
|
|
118
111
|
private normalizeProductIds;
|
|
119
112
|
/**
|
|
120
113
|
* 按轻量范围返回商品 ID,不做 structuredClone。
|
|
@@ -129,26 +122,14 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
129
122
|
*/
|
|
130
123
|
private applyFormatters;
|
|
131
124
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* 智能定价默认替代报价单逻辑;报价单 formatter 仅在 enableLegacyPriceFormatter=true 时启用。
|
|
125
|
+
* 注册内置的价格格式化器
|
|
126
|
+
* 这个格式化器负责将价格数据应用到商品上
|
|
135
127
|
* @private
|
|
136
128
|
*/
|
|
137
|
-
private
|
|
138
|
-
/**
|
|
139
|
-
* 是否启用旧报价单价格 formatter。
|
|
140
|
-
*
|
|
141
|
-
* 默认关闭,避免报价单逻辑覆盖智能定价结果。
|
|
142
|
-
*/
|
|
143
|
-
private shouldEnableLegacyPriceFormatter;
|
|
144
|
-
/**
|
|
145
|
-
* 返回最近一次 prepareProductsWithPrice / DataVariant 评估提取的变价时间点(HH:mm)。
|
|
146
|
-
* 供 OS Server 商品 query 订阅定时刷新使用。
|
|
147
|
-
*/
|
|
148
|
-
getLastScheduleTimePoints(): string[];
|
|
129
|
+
private registerBuiltinPriceFormatter;
|
|
149
130
|
/**
|
|
150
131
|
* 注册商品格式化器
|
|
151
|
-
*
|
|
132
|
+
* 格式化器会按注册顺序依次执行(内置价格格式化器始终是第一个)
|
|
152
133
|
* @param formatter 格式化函数
|
|
153
134
|
* @param prepend 是否插入到队列开头(默认 false,追加到末尾)
|
|
154
135
|
* @example
|
|
@@ -163,8 +144,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
163
144
|
*/
|
|
164
145
|
registerFormatter(formatter: ProductFormatter, prepend?: boolean): void;
|
|
165
146
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @param keepBuiltin
|
|
147
|
+
* 清空所有格式化器(包括内置价格格式化器)
|
|
148
|
+
* @param keepBuiltin 是否保留内置价格格式化器(默认 true)
|
|
168
149
|
*/
|
|
169
150
|
clearFormatters(keepBuiltin?: boolean): void;
|
|
170
151
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
function
|
|
2
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
4
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
-
function
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
10
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
11
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
12
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -32,6 +32,7 @@ import { BaseModule } from "../../../modules/BaseModule";
|
|
|
32
32
|
import { QuotationModule as ClientQuotationModule } from "../../../modules/Quotation";
|
|
33
33
|
import { ProductsHooks } from "./types";
|
|
34
34
|
import { applyDetailValueToProducts, applyPriceDataToProducts, applyI18nToProducts, perfMark } from "../../utils/product";
|
|
35
|
+
|
|
35
36
|
/**
|
|
36
37
|
* IndexDB 存储名称
|
|
37
38
|
*/
|
|
@@ -68,10 +69,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
68
69
|
// 最多缓存7天
|
|
69
70
|
// 商品格式化器列表
|
|
70
71
|
_defineProperty(_assertThisInitialized(_this), "formatters", []);
|
|
71
|
-
//
|
|
72
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
73
|
-
// 旧报价单格式化器默认关闭,仅显式开启时作为兼容兜底注册
|
|
74
|
-
_defineProperty(_assertThisInitialized(_this), "isLegacyPriceFormatterEnabled", false);
|
|
72
|
+
// 是否已注册内置价格格式化器
|
|
73
|
+
_defineProperty(_assertThisInitialized(_this), "isPriceFormatterRegistered", false);
|
|
75
74
|
// 普通层 QuotationModule 桥接器:本地计算报价单价格,替代 /product/query/price
|
|
76
75
|
_defineProperty(_assertThisInitialized(_this), "quotationPriceBridge", void 0);
|
|
77
76
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeChannel", void 0);
|
|
@@ -91,8 +90,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
91
90
|
_defineProperty(_assertThisInitialized(_this), "lastPreloadCompletedAtMs", 0);
|
|
92
91
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
93
92
|
_defineProperty(_assertThisInitialized(_this), "productIndexDBSaveQueue", Promise.resolve());
|
|
94
|
-
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
95
|
-
_defineProperty(_assertThisInitialized(_this), "lastScheduleTimePoints", []);
|
|
96
93
|
return _this;
|
|
97
94
|
}
|
|
98
95
|
_createClass(ProductsModule, [{
|
|
@@ -131,8 +128,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
130
|
|
|
134
|
-
//
|
|
135
|
-
this.
|
|
131
|
+
// 注册内置的价格格式化器(作为第一个格式化器)
|
|
132
|
+
this.registerBuiltinPriceFormatter();
|
|
136
133
|
|
|
137
134
|
// 初始化 ProductDataSource 实例
|
|
138
135
|
this.initProductDataSource();
|
|
@@ -746,7 +743,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
746
743
|
key: "prepareProductsWithPrice",
|
|
747
744
|
value: (function () {
|
|
748
745
|
var _prepareProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schedule_date, extraContext, options) {
|
|
749
|
-
var tTotal, targetIds, isIncremental,
|
|
746
|
+
var tTotal, targetIds, isIncremental, _priceData$length, _this$core, products, ids, tIds, i, tPrice, priceData, context, tFormat, processedProducts, errorMessage;
|
|
750
747
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
751
748
|
while (1) switch (_context7.prev = _context7.next) {
|
|
752
749
|
case 0:
|
|
@@ -781,44 +778,34 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
781
778
|
productCount: products.length
|
|
782
779
|
});
|
|
783
780
|
|
|
784
|
-
// 2.
|
|
785
|
-
priceData = [];
|
|
786
|
-
if (!this.isLegacyPriceFormatterEnabled) {
|
|
787
|
-
_context7.next = 15;
|
|
788
|
-
break;
|
|
789
|
-
}
|
|
781
|
+
// 2. 获取价格数据(网络请求)
|
|
790
782
|
tPrice = performance.now();
|
|
791
|
-
_context7.next =
|
|
783
|
+
_context7.next = 10;
|
|
792
784
|
return this.loadProductsPrice({
|
|
793
785
|
ids: ids,
|
|
794
786
|
schedule_date: schedule_date,
|
|
795
787
|
schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
|
|
796
788
|
customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id
|
|
797
789
|
});
|
|
798
|
-
case
|
|
790
|
+
case 10:
|
|
799
791
|
priceData = _context7.sent;
|
|
800
792
|
perfMark('prepareProducts.loadPrice', performance.now() - tPrice, {
|
|
801
793
|
count: ids.length
|
|
802
794
|
});
|
|
803
795
|
this.logInfo('获取商品报价单价格成功', {
|
|
804
|
-
priceDataCount: (_priceData$length =
|
|
796
|
+
priceDataCount: (_priceData$length = priceData === null || priceData === void 0 ? void 0 : priceData.length) !== null && _priceData$length !== void 0 ? _priceData$length : 0
|
|
805
797
|
});
|
|
806
|
-
case 15:
|
|
807
798
|
context = _objectSpread({
|
|
808
799
|
schedule_date: schedule_date,
|
|
809
800
|
schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
|
|
810
801
|
customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id,
|
|
811
802
|
priceData: priceData,
|
|
812
|
-
locale: (_this$core = this.core) === null || _this$core === void 0 || (_this$core = _this$core.context) === null || _this$core === void 0 ? void 0 : _this$core.locale
|
|
813
|
-
dataVariantEvaluator: (extraContext === null || extraContext === void 0 ? void 0 : extraContext.dataVariantEvaluator) || ((_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.context) === null || _this$core2 === void 0 ? void 0 : _this$core2.dataVariantEvaluator),
|
|
814
|
-
menuList: (extraContext === null || extraContext === void 0 ? void 0 : extraContext.menuList) || [],
|
|
815
|
-
scheduleList: (extraContext === null || extraContext === void 0 ? void 0 : extraContext.scheduleList) || [],
|
|
816
|
-
strategy_context: extraContext === null || extraContext === void 0 ? void 0 : extraContext.strategy_context
|
|
803
|
+
locale: (_this$core = this.core) === null || _this$core === void 0 || (_this$core = _this$core.context) === null || _this$core === void 0 ? void 0 : _this$core.locale
|
|
817
804
|
}, extraContext); // 3. 通过格式化器流程处理商品
|
|
818
805
|
tFormat = performance.now();
|
|
819
|
-
_context7.next =
|
|
806
|
+
_context7.next = 17;
|
|
820
807
|
return this.applyFormatters(products, context);
|
|
821
|
-
case
|
|
808
|
+
case 17:
|
|
822
809
|
processedProducts = _context7.sent;
|
|
823
810
|
perfMark('prepareProducts.applyFormatters', performance.now() - tFormat, {
|
|
824
811
|
count: products.length,
|
|
@@ -831,20 +818,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
831
818
|
formatterCount: this.formatters.length
|
|
832
819
|
});
|
|
833
820
|
if (isIncremental) {
|
|
834
|
-
_context7.next =
|
|
821
|
+
_context7.next = 23;
|
|
835
822
|
break;
|
|
836
823
|
}
|
|
837
|
-
_context7.next =
|
|
824
|
+
_context7.next = 23;
|
|
838
825
|
return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
|
|
839
|
-
case
|
|
826
|
+
case 23:
|
|
840
827
|
perfMark('prepareProductsWithPrice', performance.now() - tTotal, {
|
|
841
828
|
productCount: products.length,
|
|
842
829
|
formatterCount: this.formatters.length,
|
|
843
830
|
mode: isIncremental ? 'incremental' : 'full'
|
|
844
831
|
});
|
|
845
832
|
return _context7.abrupt("return", processedProducts);
|
|
846
|
-
case
|
|
847
|
-
_context7.prev =
|
|
833
|
+
case 27:
|
|
834
|
+
_context7.prev = 27;
|
|
848
835
|
_context7.t0 = _context7["catch"](4);
|
|
849
836
|
errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
|
|
850
837
|
console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context7.t0);
|
|
@@ -852,13 +839,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
852
839
|
schedule_date: schedule_date,
|
|
853
840
|
error: errorMessage
|
|
854
841
|
});
|
|
855
|
-
case
|
|
842
|
+
case 32:
|
|
856
843
|
return _context7.abrupt("return", []);
|
|
857
|
-
case
|
|
844
|
+
case 33:
|
|
858
845
|
case "end":
|
|
859
846
|
return _context7.stop();
|
|
860
847
|
}
|
|
861
|
-
}, _callee7, this, [[4,
|
|
848
|
+
}, _callee7, this, [[4, 27]]);
|
|
862
849
|
}));
|
|
863
850
|
function prepareProductsWithPrice(_x10, _x11, _x12) {
|
|
864
851
|
return _prepareProductsWithPrice.apply(this, arguments);
|
|
@@ -871,27 +858,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
871
858
|
var _extraContext$custome;
|
|
872
859
|
var datetime = (extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime) || schedule_date;
|
|
873
860
|
var productScope = productIds ? ":products:".concat(productIds.join(',')) : '';
|
|
874
|
-
|
|
875
|
-
return "".concat(datetime, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '', ":strategy:").concat(strategyScope).concat(productScope);
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* 稳定序列化策略上下文,避免对象 key 顺序不同导致缓存 key 抖动。
|
|
880
|
-
*/
|
|
881
|
-
}, {
|
|
882
|
-
key: "stringifyStable",
|
|
883
|
-
value: function stringifyStable(value) {
|
|
884
|
-
var _this7 = this;
|
|
885
|
-
if (value == null) return '';
|
|
886
|
-
if (Array.isArray(value)) return "[".concat(value.map(function (item) {
|
|
887
|
-
return _this7.stringifyStable(item);
|
|
888
|
-
}).join(','), "]");
|
|
889
|
-
if (_typeof(value) === 'object') {
|
|
890
|
-
return "{".concat(Object.keys(value).sort().map(function (key) {
|
|
891
|
-
return "".concat(key, ":").concat(_this7.stringifyStable(value[key]));
|
|
892
|
-
}).join(','), "}");
|
|
893
|
-
}
|
|
894
|
-
return String(value);
|
|
861
|
+
return "".concat(datetime, ":customer:").concat((_extraContext$custome = extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id) !== null && _extraContext$custome !== void 0 ? _extraContext$custome : '').concat(productScope);
|
|
895
862
|
}
|
|
896
863
|
}, {
|
|
897
864
|
key: "normalizeProductIds",
|
|
@@ -1037,55 +1004,26 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1037
1004
|
return applyFormatters;
|
|
1038
1005
|
}()
|
|
1039
1006
|
/**
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
1042
|
-
* 智能定价默认替代报价单逻辑;报价单 formatter 仅在 enableLegacyPriceFormatter=true 时启用。
|
|
1007
|
+
* 注册内置的价格格式化器
|
|
1008
|
+
* 这个格式化器负责将价格数据应用到商品上
|
|
1043
1009
|
* @private
|
|
1044
1010
|
*/
|
|
1045
1011
|
)
|
|
1046
1012
|
}, {
|
|
1047
|
-
key: "
|
|
1048
|
-
value: function
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
console.warn('[ProductsModule] 内置商品格式化器已注册,跳过');
|
|
1013
|
+
key: "registerBuiltinPriceFormatter",
|
|
1014
|
+
value: function registerBuiltinPriceFormatter() {
|
|
1015
|
+
if (this.isPriceFormatterRegistered) {
|
|
1016
|
+
console.warn('[ProductsModule] 内置价格格式化器已注册,跳过');
|
|
1052
1017
|
return;
|
|
1053
1018
|
}
|
|
1054
|
-
this.isLegacyPriceFormatterEnabled = this.shouldEnableLegacyPriceFormatter();
|
|
1055
|
-
var dataVariantFormatter = function dataVariantFormatter(products, context) {
|
|
1056
|
-
var _this8$core, _strategyContext$busi;
|
|
1057
|
-
var evaluator = context.dataVariantEvaluator || ((_this8$core = _this8.core) === null || _this8$core === void 0 || (_this8$core = _this8$core.context) === null || _this8$core === void 0 ? void 0 : _this8$core.dataVariantEvaluator);
|
|
1058
|
-
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
1059
|
-
_this8.lastScheduleTimePoints = [];
|
|
1060
|
-
_this8.logWarning('智能定价评估器未注入,跳过 DataVariant 格式化', {
|
|
1061
|
-
productCount: products.length
|
|
1062
|
-
});
|
|
1063
|
-
return products;
|
|
1064
|
-
}
|
|
1065
|
-
var strategyContext = context.strategy_context || {};
|
|
1066
|
-
var businessData = {
|
|
1067
|
-
products: products,
|
|
1068
|
-
scheduleDateTime: context.schedule_datetime || context.schedule_date,
|
|
1069
|
-
scheduleList: context.scheduleList || [],
|
|
1070
|
-
menuList: context.menuList || [],
|
|
1071
|
-
customerId: context.customer_id,
|
|
1072
|
-
channel: strategyContext.channel,
|
|
1073
|
-
orderType: strategyContext.orderType || strategyContext.order_type,
|
|
1074
|
-
businessCode: (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : strategyContext.businessCode,
|
|
1075
|
-
custom: strategyContext
|
|
1076
|
-
};
|
|
1077
|
-
var result = evaluator.resolveProducts(businessData);
|
|
1078
|
-
_this8.lastScheduleTimePoints = Array.isArray(result === null || result === void 0 ? void 0 : result.scheduleTimePoints) ? _toConsumableArray(result.scheduleTimePoints) : [];
|
|
1079
|
-
return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
|
|
1080
|
-
};
|
|
1081
1019
|
|
|
1082
|
-
//
|
|
1083
|
-
var
|
|
1020
|
+
// 创建价格格式化器
|
|
1021
|
+
var priceFormatter = function priceFormatter(products, context) {
|
|
1084
1022
|
if (!context.priceData || context.priceData.length === 0) {
|
|
1085
|
-
console.log('[ProductsModule] 💰
|
|
1023
|
+
console.log('[ProductsModule] 💰 没有价格数据,跳过价格应用');
|
|
1086
1024
|
return products;
|
|
1087
1025
|
}
|
|
1088
|
-
console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528
|
|
1026
|
+
console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528\u4EF7\u683C\u6570\u636E\u5230 ".concat(products.length, " \u4E2A\u5546\u54C1"));
|
|
1089
1027
|
return applyPriceDataToProducts(products, context.priceData);
|
|
1090
1028
|
};
|
|
1091
1029
|
var i18nFormatter = function i18nFormatter(products, context) {
|
|
@@ -1094,41 +1032,18 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1094
1032
|
var detailValueFormatter = function detailValueFormatter(products, context) {
|
|
1095
1033
|
return applyDetailValueToProducts(products, context);
|
|
1096
1034
|
};
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
this.formatters.push(dataVariantFormatter);
|
|
1035
|
+
|
|
1036
|
+
// 将价格格式化器注册为第一个格式化器
|
|
1037
|
+
this.formatters.unshift(priceFormatter);
|
|
1101
1038
|
this.formatters.push(i18nFormatter);
|
|
1102
1039
|
this.formatters.push(detailValueFormatter);
|
|
1103
|
-
this.
|
|
1104
|
-
console.log('[ProductsModule] ✅
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
/**
|
|
1108
|
-
* 是否启用旧报价单价格 formatter。
|
|
1109
|
-
*
|
|
1110
|
-
* 默认关闭,避免报价单逻辑覆盖智能定价结果。
|
|
1111
|
-
*/
|
|
1112
|
-
}, {
|
|
1113
|
-
key: "shouldEnableLegacyPriceFormatter",
|
|
1114
|
-
value: function shouldEnableLegacyPriceFormatter() {
|
|
1115
|
-
var _this$otherParams3, _this$core3;
|
|
1116
|
-
return ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.enableLegacyPriceFormatter) === true || ((_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.enableLegacyPriceFormatter) === true;
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
/**
|
|
1120
|
-
* 返回最近一次 prepareProductsWithPrice / DataVariant 评估提取的变价时间点(HH:mm)。
|
|
1121
|
-
* 供 OS Server 商品 query 订阅定时刷新使用。
|
|
1122
|
-
*/
|
|
1123
|
-
}, {
|
|
1124
|
-
key: "getLastScheduleTimePoints",
|
|
1125
|
-
value: function getLastScheduleTimePoints() {
|
|
1126
|
-
return _toConsumableArray(this.lastScheduleTimePoints);
|
|
1040
|
+
this.isPriceFormatterRegistered = true;
|
|
1041
|
+
console.log('[ProductsModule] ✅ 内置价格格式化器已注册(第 1 个)');
|
|
1127
1042
|
}
|
|
1128
1043
|
|
|
1129
1044
|
/**
|
|
1130
1045
|
* 注册商品格式化器
|
|
1131
|
-
*
|
|
1046
|
+
* 格式化器会按注册顺序依次执行(内置价格格式化器始终是第一个)
|
|
1132
1047
|
* @param formatter 格式化函数
|
|
1133
1048
|
* @param prepend 是否插入到队列开头(默认 false,追加到末尾)
|
|
1134
1049
|
* @example
|
|
@@ -1146,8 +1061,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1146
1061
|
value: function registerFormatter(formatter) {
|
|
1147
1062
|
var prepend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1148
1063
|
if (prepend) {
|
|
1149
|
-
//
|
|
1150
|
-
var insertIndex = this.
|
|
1064
|
+
// 插入到价格格式化器之后(索引 1 的位置)
|
|
1065
|
+
var insertIndex = this.isPriceFormatterRegistered ? 1 : 0;
|
|
1151
1066
|
this.formatters.splice(insertIndex, 0, formatter);
|
|
1152
1067
|
console.log("[ProductsModule] \uD83D\uDCCC \u5DF2\u5728\u4F4D\u7F6E ".concat(insertIndex + 1, " \u63D2\u5165\u683C\u5F0F\u5316\u5668\uFF0C\u5F53\u524D\u5171 ").concat(this.formatters.length, " \u4E2A"));
|
|
1153
1068
|
} else {
|
|
@@ -1158,21 +1073,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1158
1073
|
}
|
|
1159
1074
|
|
|
1160
1075
|
/**
|
|
1161
|
-
*
|
|
1162
|
-
* @param keepBuiltin
|
|
1076
|
+
* 清空所有格式化器(包括内置价格格式化器)
|
|
1077
|
+
* @param keepBuiltin 是否保留内置价格格式化器(默认 true)
|
|
1163
1078
|
*/
|
|
1164
1079
|
}, {
|
|
1165
1080
|
key: "clearFormatters",
|
|
1166
1081
|
value: function clearFormatters() {
|
|
1167
1082
|
var keepBuiltin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1168
|
-
if (keepBuiltin && this.
|
|
1169
|
-
//
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
console.log('[ProductsModule] 🧹 已清空自定义格式化器,保留内置智能定价格式化器');
|
|
1083
|
+
if (keepBuiltin && this.isPriceFormatterRegistered) {
|
|
1084
|
+
// 只保留第一个格式化器(内置价格格式化器)
|
|
1085
|
+
this.formatters = [this.formatters[0]];
|
|
1086
|
+
console.log('[ProductsModule] 🧹 已清空自定义格式化器,保留内置价格格式化器');
|
|
1173
1087
|
} else {
|
|
1174
1088
|
this.formatters = [];
|
|
1175
|
-
this.
|
|
1089
|
+
this.isPriceFormatterRegistered = false;
|
|
1176
1090
|
console.log('[ProductsModule] 🧹 已清空所有格式化器');
|
|
1177
1091
|
}
|
|
1178
1092
|
}
|
|
@@ -1283,7 +1197,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1283
1197
|
key: "fetchProductsByHttp",
|
|
1284
1198
|
value: (function () {
|
|
1285
1199
|
var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
1286
|
-
var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$
|
|
1200
|
+
var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$otherParams3, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
|
|
1287
1201
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1288
1202
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1289
1203
|
case 0:
|
|
@@ -1301,7 +1215,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1301
1215
|
open_bundle: 1,
|
|
1302
1216
|
exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
|
|
1303
1217
|
force_ignore_cache_flag: 1,
|
|
1304
|
-
with: ['category', 'collection', 'resourceRelation', 'bundleGroup.bundleItem', 'optionGroup.optionItem', 'variantGroup.variantItem'
|
|
1218
|
+
with: ['category', 'collection', 'resourceRelation', 'bundleGroup.bundleItem', 'optionGroup.optionItem', 'variantGroup.variantItem'],
|
|
1305
1219
|
open_deposit: 1,
|
|
1306
1220
|
is_append_product_description: 1,
|
|
1307
1221
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
@@ -1313,7 +1227,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1313
1227
|
ids: product_ids,
|
|
1314
1228
|
collection: collection,
|
|
1315
1229
|
front_end_cache_id: cacheId,
|
|
1316
|
-
application_code: (_this$
|
|
1230
|
+
application_code: (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel
|
|
1317
1231
|
}, {
|
|
1318
1232
|
cache: undefined
|
|
1319
1233
|
});
|
|
@@ -1777,7 +1691,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1777
1691
|
key: "replaceProductsSnapshotInIndexDB",
|
|
1778
1692
|
value: (function () {
|
|
1779
1693
|
var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(products, source) {
|
|
1780
|
-
var
|
|
1694
|
+
var _this7 = this;
|
|
1781
1695
|
var errorMessage;
|
|
1782
1696
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1783
1697
|
while (1) switch (_context20.prev = _context20.next) {
|
|
@@ -1796,25 +1710,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1796
1710
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1797
1711
|
while (1) switch (_context19.prev = _context19.next) {
|
|
1798
1712
|
case 0:
|
|
1799
|
-
|
|
1713
|
+
_this7.logInfo('replaceProductsSnapshotInIndexDB 开始', {
|
|
1800
1714
|
source: source,
|
|
1801
1715
|
productCount: products.length
|
|
1802
1716
|
});
|
|
1803
1717
|
t0 = performance.now();
|
|
1804
1718
|
_context19.next = 4;
|
|
1805
|
-
return
|
|
1719
|
+
return _this7.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1806
1720
|
case 4:
|
|
1807
1721
|
if (!(products.length > 0)) {
|
|
1808
1722
|
_context19.next = 7;
|
|
1809
1723
|
break;
|
|
1810
1724
|
}
|
|
1811
1725
|
_context19.next = 7;
|
|
1812
|
-
return
|
|
1726
|
+
return _this7.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
1813
1727
|
case 7:
|
|
1814
1728
|
perfMark('replaceProductsSnapshotInIndexDB', performance.now() - t0, {
|
|
1815
1729
|
count: products.length
|
|
1816
1730
|
});
|
|
1817
|
-
|
|
1731
|
+
_this7.logInfo('replaceProductsSnapshotInIndexDB 完成', {
|
|
1818
1732
|
source: source,
|
|
1819
1733
|
productCount: products.length
|
|
1820
1734
|
});
|
|
@@ -1858,7 +1772,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1858
1772
|
key: "patchProductsInIndexDB",
|
|
1859
1773
|
value: (function () {
|
|
1860
1774
|
var _patchProductsInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(products, source) {
|
|
1861
|
-
var
|
|
1775
|
+
var _this8 = this;
|
|
1862
1776
|
var mergeActions,
|
|
1863
1777
|
validProducts,
|
|
1864
1778
|
errorMessage,
|
|
@@ -1889,22 +1803,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1889
1803
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1890
1804
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1891
1805
|
case 0:
|
|
1892
|
-
|
|
1806
|
+
_this8.logInfo('patchProductsInIndexDB 开始', {
|
|
1893
1807
|
source: source,
|
|
1894
1808
|
count: validProducts.length
|
|
1895
1809
|
});
|
|
1896
1810
|
t0 = performance.now();
|
|
1897
|
-
if (!(typeof
|
|
1811
|
+
if (!(typeof _this8.dbManager.bulkUpdate === 'function')) {
|
|
1898
1812
|
_context21.next = 7;
|
|
1899
1813
|
break;
|
|
1900
1814
|
}
|
|
1901
1815
|
_context21.next = 5;
|
|
1902
|
-
return
|
|
1816
|
+
return _this8.dbManager.bulkUpdate(INDEXDB_STORE_NAME, validProducts);
|
|
1903
1817
|
case 5:
|
|
1904
1818
|
_context21.next = 25;
|
|
1905
1819
|
break;
|
|
1906
1820
|
case 7:
|
|
1907
|
-
if (!(typeof
|
|
1821
|
+
if (!(typeof _this8.dbManager.update === 'function')) {
|
|
1908
1822
|
_context21.next = 25;
|
|
1909
1823
|
break;
|
|
1910
1824
|
}
|
|
@@ -1918,7 +1832,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1918
1832
|
}
|
|
1919
1833
|
product = _step10.value;
|
|
1920
1834
|
_context21.next = 15;
|
|
1921
|
-
return
|
|
1835
|
+
return _this8.dbManager.update(INDEXDB_STORE_NAME, product);
|
|
1922
1836
|
case 15:
|
|
1923
1837
|
_context21.next = 11;
|
|
1924
1838
|
break;
|
|
@@ -1937,7 +1851,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1937
1851
|
perfMark('patchProductsInIndexDB', performance.now() - t0, {
|
|
1938
1852
|
count: validProducts.length
|
|
1939
1853
|
});
|
|
1940
|
-
|
|
1854
|
+
_this8.logInfo('patchProductsInIndexDB 完成', {
|
|
1941
1855
|
source: source,
|
|
1942
1856
|
count: validProducts.length
|
|
1943
1857
|
});
|
|
@@ -2135,7 +2049,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2135
2049
|
}, {
|
|
2136
2050
|
key: "setupProductSync",
|
|
2137
2051
|
value: function setupProductSync() {
|
|
2138
|
-
var
|
|
2052
|
+
var _this9 = this;
|
|
2139
2053
|
if (!this.productDataSource) {
|
|
2140
2054
|
this.logWarning('setupProductSync: ProductDataSource 不可用,跳过同步初始化');
|
|
2141
2055
|
return;
|
|
@@ -2145,20 +2059,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2145
2059
|
var data = (message === null || message === void 0 ? void 0 : message.data) || message;
|
|
2146
2060
|
if (!data) return;
|
|
2147
2061
|
console.log("[ProductsModule] \u6536\u5230\u540C\u6B65\u6D88\u606F [".concat(channelKey, "]:"), data);
|
|
2148
|
-
|
|
2062
|
+
_this9.logInfo('收到同步消息', {
|
|
2149
2063
|
channelKey: channelKey,
|
|
2150
2064
|
action: data.action,
|
|
2151
2065
|
id: data.id,
|
|
2152
2066
|
action_filed: data.action_filed
|
|
2153
2067
|
});
|
|
2154
|
-
|
|
2068
|
+
_this9.pendingSyncMessages.push(_objectSpread(_objectSpread({}, data), {}, {
|
|
2155
2069
|
_channelKey: channelKey
|
|
2156
2070
|
}));
|
|
2157
|
-
if (
|
|
2158
|
-
clearTimeout(
|
|
2071
|
+
if (_this9.syncTimer) {
|
|
2072
|
+
clearTimeout(_this9.syncTimer);
|
|
2159
2073
|
}
|
|
2160
|
-
|
|
2161
|
-
|
|
2074
|
+
_this9.syncTimer = setTimeout(function () {
|
|
2075
|
+
_this9.processProductSyncMessages();
|
|
2162
2076
|
}, PRODUCT_SYNC_DEBOUNCE_MS);
|
|
2163
2077
|
};
|
|
2164
2078
|
};
|
|
@@ -2176,7 +2090,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2176
2090
|
}
|
|
2177
2091
|
}
|
|
2178
2092
|
}).catch(function (err) {
|
|
2179
|
-
|
|
2093
|
+
_this9.logError('setupProductSync: DataSource run 出错', {
|
|
2180
2094
|
error: err instanceof Error ? err.message : String(err)
|
|
2181
2095
|
});
|
|
2182
2096
|
});
|
|
@@ -2205,7 +2119,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2205
2119
|
key: "processProductSyncMessages",
|
|
2206
2120
|
value: (function () {
|
|
2207
2121
|
var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2208
|
-
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator12, _step12, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3,
|
|
2122
|
+
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator12, _step12, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, patchProductMap, patchMergeActions, storeMutated, bodyResult, _iterator13, _step13, product, freshProducts, mergeResult, _iterator14, _step14, _product, patchProducts, allChangedIds, hasChanges, errorMessage;
|
|
2209
2123
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2210
2124
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2211
2125
|
case 0:
|
|
@@ -2289,10 +2203,6 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2289
2203
|
if ((_msg$relation_product3 = msg.relation_product_ids) !== null && _msg$relation_product3 !== void 0 && _msg$relation_product3.length) {
|
|
2290
2204
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
|
|
2291
2205
|
}
|
|
2292
|
-
} else if (['product_data_variant'].includes(channelKey)) {
|
|
2293
|
-
if ((_msg$product_ids = msg.product_ids) !== null && _msg$product_ids !== void 0 && _msg$product_ids.length) {
|
|
2294
|
-
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.product_ids));
|
|
2295
|
-
}
|
|
2296
2206
|
}
|
|
2297
2207
|
case 34:
|
|
2298
2208
|
_context24.next = 13;
|
|
@@ -110,8 +110,6 @@ export interface ProductSyncMessage {
|
|
|
110
110
|
change_types?: string[];
|
|
111
111
|
/** 关联商品 ID(product_collection / product_category / product_quotation 变更时携带) */
|
|
112
112
|
relation_product_ids?: number[];
|
|
113
|
-
/** 关联商品 ID(product_data_variant 变更时携带) */
|
|
114
|
-
product_ids?: number[];
|
|
115
113
|
message_uuid?: string;
|
|
116
114
|
timestamp?: string;
|
|
117
115
|
/** 内部标记:来源频道 key */
|
|
@@ -126,18 +124,6 @@ export interface ProductFormatterContext {
|
|
|
126
124
|
customer_id?: number | string;
|
|
127
125
|
priceData?: LoadProductsPriceData[];
|
|
128
126
|
scheduleModule?: any;
|
|
129
|
-
/** 全量餐牌列表,供智能定价 menu_match 等条件判断使用 */
|
|
130
|
-
menuList?: any[];
|
|
131
|
-
/** 全量日程列表,供智能定价 schedule_match 等条件判断使用 */
|
|
132
|
-
scheduleList?: any[];
|
|
133
|
-
/** 外部传入的策略上下文,仅承载定价条件,不参与商品集合筛选 */
|
|
134
|
-
strategy_context?: Record<string, any>;
|
|
135
|
-
/** 智能定价评估器,由宿主统一注入到 PisellOS context */
|
|
136
|
-
dataVariantEvaluator?: {
|
|
137
|
-
resolveProducts: (businessData: any) => {
|
|
138
|
-
products: ProductData[];
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
127
|
locale?: string;
|
|
142
128
|
}
|
|
143
129
|
/**
|