@pisell/pisellos 2.3.28 → 2.3.29
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/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +30 -7
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +7 -1
- package/dist/modules/Order/index.js +187 -74
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
- package/dist/modules/Order/utils.d.ts +2 -1
- package/dist/modules/Order/utils.js +2 -8
- package/dist/modules/Product/types.d.ts +22 -0
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +4 -2
- package/dist/modules/ProductList/types.d.ts +2 -0
- package/dist/server/index.d.ts +50 -0
- package/dist/server/index.js +995 -749
- package/dist/server/modules/order/index.d.ts +10 -4
- package/dist/server/modules/order/index.js +404 -399
- package/dist/server/modules/products/index.d.ts +26 -7
- package/dist/server/modules/products/index.js +167 -76
- package/dist/server/modules/products/types.d.ts +14 -0
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +998 -756
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +6 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +14 -2
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +15 -14
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +23 -3
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +7 -1
- package/lib/modules/Order/index.js +104 -6
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +415 -0
- package/lib/modules/Order/utils.d.ts +2 -1
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Product/types.d.ts +22 -0
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +4 -2
- package/lib/modules/ProductList/types.d.ts +2 -0
- package/lib/server/index.d.ts +50 -0
- package/lib/server/index.js +206 -29
- package/lib/server/modules/order/index.d.ts +10 -4
- package/lib/server/modules/order/index.js +198 -139
- package/lib/server/modules/products/index.d.ts +26 -7
- package/lib/server/modules/products/index.js +114 -35
- package/lib/server/modules/products/types.d.ts +14 -0
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +229 -54
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +3 -3
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +14 -2
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/package.json +1 -1
|
@@ -18,7 +18,8 @@ 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
|
|
21
|
+
private isBuiltinFormatterRegistered;
|
|
22
|
+
private isLegacyPriceFormatterEnabled;
|
|
22
23
|
private quotationPriceBridge?;
|
|
23
24
|
private quotationBridgeChannel?;
|
|
24
25
|
private quotationBridgeLoadedKey?;
|
|
@@ -36,6 +37,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
36
37
|
private lastPreloadCompletedAtMs;
|
|
37
38
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
38
39
|
private productIndexDBSaveQueue;
|
|
40
|
+
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
41
|
+
private lastScheduleTimePoints;
|
|
39
42
|
constructor(name?: string, version?: string);
|
|
40
43
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
41
44
|
/**
|
|
@@ -108,6 +111,10 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
108
111
|
*/
|
|
109
112
|
private prepareProductsWithPrice;
|
|
110
113
|
private getProductsPriceCacheKey;
|
|
114
|
+
/**
|
|
115
|
+
* 稳定序列化策略上下文,避免对象 key 顺序不同导致缓存 key 抖动。
|
|
116
|
+
*/
|
|
117
|
+
private stringifyStable;
|
|
111
118
|
private normalizeProductIds;
|
|
112
119
|
/**
|
|
113
120
|
* 按轻量范围返回商品 ID,不做 structuredClone。
|
|
@@ -122,14 +129,26 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
122
129
|
*/
|
|
123
130
|
private applyFormatters;
|
|
124
131
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
132
|
+
* 注册内置商品格式化器。
|
|
133
|
+
*
|
|
134
|
+
* 智能定价默认替代报价单逻辑;报价单 formatter 仅在 enableLegacyPriceFormatter=true 时启用。
|
|
127
135
|
* @private
|
|
128
136
|
*/
|
|
129
|
-
private
|
|
137
|
+
private registerBuiltinProductFormatters;
|
|
138
|
+
/**
|
|
139
|
+
* 是否启用旧报价单价格 formatter。
|
|
140
|
+
*
|
|
141
|
+
* 默认关闭,避免报价单逻辑覆盖智能定价结果。
|
|
142
|
+
*/
|
|
143
|
+
private shouldEnableLegacyPriceFormatter;
|
|
144
|
+
/**
|
|
145
|
+
* 返回最近一次 prepareProductsWithPrice / DataVariant 评估提取的变价时间点(HH:mm)。
|
|
146
|
+
* 供 OS Server 商品 query 订阅定时刷新使用。
|
|
147
|
+
*/
|
|
148
|
+
getLastScheduleTimePoints(): string[];
|
|
130
149
|
/**
|
|
131
150
|
* 注册商品格式化器
|
|
132
|
-
*
|
|
151
|
+
* 格式化器会按注册顺序依次执行;legacy 启用时先兜底报价,再由智能定价覆盖。
|
|
133
152
|
* @param formatter 格式化函数
|
|
134
153
|
* @param prepend 是否插入到队列开头(默认 false,追加到末尾)
|
|
135
154
|
* @example
|
|
@@ -144,8 +163,8 @@ export declare class ProductsModule extends BaseModule implements Module {
|
|
|
144
163
|
*/
|
|
145
164
|
registerFormatter(formatter: ProductFormatter, prepend?: boolean): void;
|
|
146
165
|
/**
|
|
147
|
-
*
|
|
148
|
-
* @param keepBuiltin
|
|
166
|
+
* 清空所有格式化器(包括内置智能定价格式化器)
|
|
167
|
+
* @param keepBuiltin 是否保留内置智能定价格式化器(默认 true)
|
|
149
168
|
*/
|
|
150
169
|
clearFormatters(keepBuiltin?: boolean): void;
|
|
151
170
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
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); }
|
|
2
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
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."); }
|
|
4
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
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."); }
|
|
8
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; } }
|
|
9
4
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
5
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
+
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
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
+
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); }
|
|
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,7 +32,6 @@ 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
|
-
|
|
36
35
|
/**
|
|
37
36
|
* IndexDB 存储名称
|
|
38
37
|
*/
|
|
@@ -69,8 +68,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
69
68
|
// 最多缓存7天
|
|
70
69
|
// 商品格式化器列表
|
|
71
70
|
_defineProperty(_assertThisInitialized(_this), "formatters", []);
|
|
72
|
-
//
|
|
73
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
71
|
+
// 是否已注册内置商品格式化器
|
|
72
|
+
_defineProperty(_assertThisInitialized(_this), "isBuiltinFormatterRegistered", false);
|
|
73
|
+
// 旧报价单格式化器默认关闭,仅显式开启时作为兼容兜底注册
|
|
74
|
+
_defineProperty(_assertThisInitialized(_this), "isLegacyPriceFormatterEnabled", false);
|
|
74
75
|
// 普通层 QuotationModule 桥接器:本地计算报价单价格,替代 /product/query/price
|
|
75
76
|
_defineProperty(_assertThisInitialized(_this), "quotationPriceBridge", void 0);
|
|
76
77
|
_defineProperty(_assertThisInitialized(_this), "quotationBridgeChannel", void 0);
|
|
@@ -90,6 +91,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
90
91
|
_defineProperty(_assertThisInitialized(_this), "lastPreloadCompletedAtMs", 0);
|
|
91
92
|
/** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
|
|
92
93
|
_defineProperty(_assertThisInitialized(_this), "productIndexDBSaveQueue", Promise.resolve());
|
|
94
|
+
/** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
|
|
95
|
+
_defineProperty(_assertThisInitialized(_this), "lastScheduleTimePoints", []);
|
|
93
96
|
return _this;
|
|
94
97
|
}
|
|
95
98
|
_createClass(ProductsModule, [{
|
|
@@ -128,8 +131,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
//
|
|
132
|
-
this.
|
|
134
|
+
// 注册内置商品格式化器;智能定价默认替代报价单价格逻辑
|
|
135
|
+
this.registerBuiltinProductFormatters();
|
|
133
136
|
|
|
134
137
|
// 初始化 ProductDataSource 实例
|
|
135
138
|
this.initProductDataSource();
|
|
@@ -743,7 +746,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
743
746
|
key: "prepareProductsWithPrice",
|
|
744
747
|
value: (function () {
|
|
745
748
|
var _prepareProductsWithPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(schedule_date, extraContext, options) {
|
|
746
|
-
var tTotal, targetIds, isIncremental,
|
|
749
|
+
var tTotal, targetIds, isIncremental, _this$core, _this$core2, products, ids, tIds, i, priceData, _priceData$length, _priceData, tPrice, context, tFormat, processedProducts, errorMessage;
|
|
747
750
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
748
751
|
while (1) switch (_context7.prev = _context7.next) {
|
|
749
752
|
case 0:
|
|
@@ -778,34 +781,44 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
778
781
|
productCount: products.length
|
|
779
782
|
});
|
|
780
783
|
|
|
781
|
-
// 2.
|
|
784
|
+
// 2. 仅在 legacy 报价单 formatter 启用时加载报价单价格;默认由智能定价覆盖商品价格。
|
|
785
|
+
priceData = [];
|
|
786
|
+
if (!this.isLegacyPriceFormatterEnabled) {
|
|
787
|
+
_context7.next = 15;
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
782
790
|
tPrice = performance.now();
|
|
783
|
-
_context7.next =
|
|
791
|
+
_context7.next = 12;
|
|
784
792
|
return this.loadProductsPrice({
|
|
785
793
|
ids: ids,
|
|
786
794
|
schedule_date: schedule_date,
|
|
787
795
|
schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
|
|
788
796
|
customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id
|
|
789
797
|
});
|
|
790
|
-
case
|
|
798
|
+
case 12:
|
|
791
799
|
priceData = _context7.sent;
|
|
792
800
|
perfMark('prepareProducts.loadPrice', performance.now() - tPrice, {
|
|
793
801
|
count: ids.length
|
|
794
802
|
});
|
|
795
803
|
this.logInfo('获取商品报价单价格成功', {
|
|
796
|
-
priceDataCount: (_priceData$length = priceData === null ||
|
|
804
|
+
priceDataCount: (_priceData$length = (_priceData = priceData) === null || _priceData === void 0 ? void 0 : _priceData.length) !== null && _priceData$length !== void 0 ? _priceData$length : 0
|
|
797
805
|
});
|
|
806
|
+
case 15:
|
|
798
807
|
context = _objectSpread({
|
|
799
808
|
schedule_date: schedule_date,
|
|
800
809
|
schedule_datetime: extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime,
|
|
801
810
|
customer_id: extraContext === null || extraContext === void 0 ? void 0 : extraContext.customer_id,
|
|
802
811
|
priceData: priceData,
|
|
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
|
|
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
|
|
804
817
|
}, extraContext); // 3. 通过格式化器流程处理商品
|
|
805
818
|
tFormat = performance.now();
|
|
806
|
-
_context7.next =
|
|
819
|
+
_context7.next = 19;
|
|
807
820
|
return this.applyFormatters(products, context);
|
|
808
|
-
case
|
|
821
|
+
case 19:
|
|
809
822
|
processedProducts = _context7.sent;
|
|
810
823
|
perfMark('prepareProducts.applyFormatters', performance.now() - tFormat, {
|
|
811
824
|
count: products.length,
|
|
@@ -818,20 +831,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
818
831
|
formatterCount: this.formatters.length
|
|
819
832
|
});
|
|
820
833
|
if (isIncremental) {
|
|
821
|
-
_context7.next =
|
|
834
|
+
_context7.next = 25;
|
|
822
835
|
break;
|
|
823
836
|
}
|
|
824
|
-
_context7.next =
|
|
837
|
+
_context7.next = 25;
|
|
825
838
|
return this.core.effects.emit(ProductsHooks.onProductsPriceApplied, processedProducts);
|
|
826
|
-
case
|
|
839
|
+
case 25:
|
|
827
840
|
perfMark('prepareProductsWithPrice', performance.now() - tTotal, {
|
|
828
841
|
productCount: products.length,
|
|
829
842
|
formatterCount: this.formatters.length,
|
|
830
843
|
mode: isIncremental ? 'incremental' : 'full'
|
|
831
844
|
});
|
|
832
845
|
return _context7.abrupt("return", processedProducts);
|
|
833
|
-
case
|
|
834
|
-
_context7.prev =
|
|
846
|
+
case 29:
|
|
847
|
+
_context7.prev = 29;
|
|
835
848
|
_context7.t0 = _context7["catch"](4);
|
|
836
849
|
errorMessage = _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0);
|
|
837
850
|
console.log("[ProductsModule] \uD83C\uDF10 ERROR", _context7.t0);
|
|
@@ -839,13 +852,13 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
839
852
|
schedule_date: schedule_date,
|
|
840
853
|
error: errorMessage
|
|
841
854
|
});
|
|
842
|
-
case
|
|
855
|
+
case 34:
|
|
843
856
|
return _context7.abrupt("return", []);
|
|
844
|
-
case
|
|
857
|
+
case 35:
|
|
845
858
|
case "end":
|
|
846
859
|
return _context7.stop();
|
|
847
860
|
}
|
|
848
|
-
}, _callee7, this, [[4,
|
|
861
|
+
}, _callee7, this, [[4, 29]]);
|
|
849
862
|
}));
|
|
850
863
|
function prepareProductsWithPrice(_x10, _x11, _x12) {
|
|
851
864
|
return _prepareProductsWithPrice.apply(this, arguments);
|
|
@@ -858,7 +871,27 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
858
871
|
var _extraContext$custome;
|
|
859
872
|
var datetime = (extraContext === null || extraContext === void 0 ? void 0 : extraContext.schedule_datetime) || schedule_date;
|
|
860
873
|
var productScope = productIds ? ":products:".concat(productIds.join(',')) : '';
|
|
861
|
-
|
|
874
|
+
var strategyScope = this.stringifyStable((extraContext === null || extraContext === void 0 ? void 0 : extraContext.strategy_context) || {});
|
|
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);
|
|
862
895
|
}
|
|
863
896
|
}, {
|
|
864
897
|
key: "normalizeProductIds",
|
|
@@ -1004,26 +1037,56 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1004
1037
|
return applyFormatters;
|
|
1005
1038
|
}()
|
|
1006
1039
|
/**
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1040
|
+
* 注册内置商品格式化器。
|
|
1041
|
+
*
|
|
1042
|
+
* 智能定价默认替代报价单逻辑;报价单 formatter 仅在 enableLegacyPriceFormatter=true 时启用。
|
|
1009
1043
|
* @private
|
|
1010
1044
|
*/
|
|
1011
1045
|
)
|
|
1012
1046
|
}, {
|
|
1013
|
-
key: "
|
|
1014
|
-
value: function
|
|
1015
|
-
|
|
1016
|
-
|
|
1047
|
+
key: "registerBuiltinProductFormatters",
|
|
1048
|
+
value: function registerBuiltinProductFormatters() {
|
|
1049
|
+
var _this8 = this;
|
|
1050
|
+
if (this.isBuiltinFormatterRegistered) {
|
|
1051
|
+
console.warn('[ProductsModule] 内置商品格式化器已注册,跳过');
|
|
1017
1052
|
return;
|
|
1018
1053
|
}
|
|
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
|
+
availableWalletIds: strategyContext.available_wallet_ids,
|
|
1076
|
+
custom: strategyContext
|
|
1077
|
+
};
|
|
1078
|
+
var result = evaluator.resolveProducts(businessData);
|
|
1079
|
+
_this8.lastScheduleTimePoints = Array.isArray(result === null || result === void 0 ? void 0 : result.scheduleTimePoints) ? _toConsumableArray(result.scheduleTimePoints) : [];
|
|
1080
|
+
return Array.isArray(result === null || result === void 0 ? void 0 : result.products) ? result.products : products;
|
|
1081
|
+
};
|
|
1019
1082
|
|
|
1020
|
-
//
|
|
1021
|
-
var
|
|
1083
|
+
// 创建 legacy 报价单格式化器
|
|
1084
|
+
var legacyPriceFormatter = function legacyPriceFormatter(products, context) {
|
|
1022
1085
|
if (!context.priceData || context.priceData.length === 0) {
|
|
1023
|
-
console.log('[ProductsModule] 💰
|
|
1086
|
+
console.log('[ProductsModule] 💰 没有价格数据,跳过 legacy 报价单价格应用');
|
|
1024
1087
|
return products;
|
|
1025
1088
|
}
|
|
1026
|
-
console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528\u4EF7\
|
|
1089
|
+
console.log("[ProductsModule] \uD83D\uDCB0 \u5E94\u7528 legacy \u62A5\u4EF7\u5355\u4EF7\u683C\u5230 ".concat(products.length, " \u4E2A\u5546\u54C1"));
|
|
1027
1090
|
return applyPriceDataToProducts(products, context.priceData);
|
|
1028
1091
|
};
|
|
1029
1092
|
var i18nFormatter = function i18nFormatter(products, context) {
|
|
@@ -1032,18 +1095,41 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1032
1095
|
var detailValueFormatter = function detailValueFormatter(products, context) {
|
|
1033
1096
|
return applyDetailValueToProducts(products, context);
|
|
1034
1097
|
};
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1098
|
+
if (this.isLegacyPriceFormatterEnabled) {
|
|
1099
|
+
this.formatters.push(legacyPriceFormatter);
|
|
1100
|
+
}
|
|
1101
|
+
this.formatters.push(dataVariantFormatter);
|
|
1038
1102
|
this.formatters.push(i18nFormatter);
|
|
1039
1103
|
this.formatters.push(detailValueFormatter);
|
|
1040
|
-
this.
|
|
1041
|
-
console.log('[ProductsModule] ✅
|
|
1104
|
+
this.isBuiltinFormatterRegistered = true;
|
|
1105
|
+
console.log('[ProductsModule] ✅ 内置商品格式化器已注册(智能定价优先)');
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* 是否启用旧报价单价格 formatter。
|
|
1110
|
+
*
|
|
1111
|
+
* 默认关闭,避免报价单逻辑覆盖智能定价结果。
|
|
1112
|
+
*/
|
|
1113
|
+
}, {
|
|
1114
|
+
key: "shouldEnableLegacyPriceFormatter",
|
|
1115
|
+
value: function shouldEnableLegacyPriceFormatter() {
|
|
1116
|
+
var _this$otherParams3, _this$core3;
|
|
1117
|
+
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;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* 返回最近一次 prepareProductsWithPrice / DataVariant 评估提取的变价时间点(HH:mm)。
|
|
1122
|
+
* 供 OS Server 商品 query 订阅定时刷新使用。
|
|
1123
|
+
*/
|
|
1124
|
+
}, {
|
|
1125
|
+
key: "getLastScheduleTimePoints",
|
|
1126
|
+
value: function getLastScheduleTimePoints() {
|
|
1127
|
+
return _toConsumableArray(this.lastScheduleTimePoints);
|
|
1042
1128
|
}
|
|
1043
1129
|
|
|
1044
1130
|
/**
|
|
1045
1131
|
* 注册商品格式化器
|
|
1046
|
-
*
|
|
1132
|
+
* 格式化器会按注册顺序依次执行;legacy 启用时先兜底报价,再由智能定价覆盖。
|
|
1047
1133
|
* @param formatter 格式化函数
|
|
1048
1134
|
* @param prepend 是否插入到队列开头(默认 false,追加到末尾)
|
|
1049
1135
|
* @example
|
|
@@ -1061,8 +1147,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1061
1147
|
value: function registerFormatter(formatter) {
|
|
1062
1148
|
var prepend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1063
1149
|
if (prepend) {
|
|
1064
|
-
//
|
|
1065
|
-
var insertIndex = this.
|
|
1150
|
+
// 插入到内置智能定价格式化器之后;legacy 报价单启用时需跳过它。
|
|
1151
|
+
var insertIndex = this.isBuiltinFormatterRegistered ? this.isLegacyPriceFormatterEnabled ? 2 : 1 : 0;
|
|
1066
1152
|
this.formatters.splice(insertIndex, 0, formatter);
|
|
1067
1153
|
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"));
|
|
1068
1154
|
} else {
|
|
@@ -1073,20 +1159,21 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1073
1159
|
}
|
|
1074
1160
|
|
|
1075
1161
|
/**
|
|
1076
|
-
*
|
|
1077
|
-
* @param keepBuiltin
|
|
1162
|
+
* 清空所有格式化器(包括内置智能定价格式化器)
|
|
1163
|
+
* @param keepBuiltin 是否保留内置智能定价格式化器(默认 true)
|
|
1078
1164
|
*/
|
|
1079
1165
|
}, {
|
|
1080
1166
|
key: "clearFormatters",
|
|
1081
1167
|
value: function clearFormatters() {
|
|
1082
1168
|
var keepBuiltin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
1083
|
-
if (keepBuiltin && this.
|
|
1084
|
-
//
|
|
1085
|
-
|
|
1086
|
-
|
|
1169
|
+
if (keepBuiltin && this.isBuiltinFormatterRegistered) {
|
|
1170
|
+
// 保留 legacy 兜底(如果启用)和智能定价格式化器。
|
|
1171
|
+
var builtinCount = this.isLegacyPriceFormatterEnabled ? 2 : 1;
|
|
1172
|
+
this.formatters = this.formatters.slice(0, builtinCount);
|
|
1173
|
+
console.log('[ProductsModule] 🧹 已清空自定义格式化器,保留内置智能定价格式化器');
|
|
1087
1174
|
} else {
|
|
1088
1175
|
this.formatters = [];
|
|
1089
|
-
this.
|
|
1176
|
+
this.isBuiltinFormatterRegistered = false;
|
|
1090
1177
|
console.log('[ProductsModule] 🧹 已清空所有格式化器');
|
|
1091
1178
|
}
|
|
1092
1179
|
}
|
|
@@ -1197,7 +1284,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1197
1284
|
key: "fetchProductsByHttp",
|
|
1198
1285
|
value: (function () {
|
|
1199
1286
|
var _fetchProductsByHttp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
|
|
1200
|
-
var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$
|
|
1287
|
+
var _ref13, _ref13$category_ids, category_ids, _ref13$product_ids, product_ids, _ref13$collection, collection, customer_id, cacheId, startTime, _this$otherParams4, _productsData$data, productsData, productList, duration, _duration2, errorMessage;
|
|
1201
1288
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1202
1289
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1203
1290
|
case 0:
|
|
@@ -1215,7 +1302,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1215
1302
|
open_bundle: 1,
|
|
1216
1303
|
exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
|
|
1217
1304
|
force_ignore_cache_flag: 1,
|
|
1218
|
-
with: ['category', 'collection', 'resourceRelation', 'bundleGroup.bundleItem', 'optionGroup.optionItem', 'variantGroup.variantItem'],
|
|
1305
|
+
with: ['category', 'collection', 'resourceRelation', 'bundleGroup.bundleItem', 'optionGroup.optionItem', 'variantGroup.variantItem', 'dataVariants'],
|
|
1219
1306
|
open_deposit: 1,
|
|
1220
1307
|
is_append_product_description: 1,
|
|
1221
1308
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
@@ -1227,7 +1314,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1227
1314
|
ids: product_ids,
|
|
1228
1315
|
collection: collection,
|
|
1229
1316
|
front_end_cache_id: cacheId,
|
|
1230
|
-
application_code: (_this$
|
|
1317
|
+
application_code: (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.channel
|
|
1231
1318
|
}, {
|
|
1232
1319
|
cache: undefined
|
|
1233
1320
|
});
|
|
@@ -1759,7 +1846,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1759
1846
|
key: "replaceProductsSnapshotInIndexDB",
|
|
1760
1847
|
value: (function () {
|
|
1761
1848
|
var _replaceProductsSnapshotInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(products, source) {
|
|
1762
|
-
var
|
|
1849
|
+
var _this9 = this;
|
|
1763
1850
|
var errorMessage;
|
|
1764
1851
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1765
1852
|
while (1) switch (_context21.prev = _context21.next) {
|
|
@@ -1778,25 +1865,25 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1778
1865
|
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1779
1866
|
while (1) switch (_context20.prev = _context20.next) {
|
|
1780
1867
|
case 0:
|
|
1781
|
-
|
|
1868
|
+
_this9.logInfo('replaceProductsSnapshotInIndexDB 开始', {
|
|
1782
1869
|
source: source,
|
|
1783
1870
|
productCount: products.length
|
|
1784
1871
|
});
|
|
1785
1872
|
t0 = performance.now();
|
|
1786
1873
|
_context20.next = 4;
|
|
1787
|
-
return
|
|
1874
|
+
return _this9.dbManager.clear(INDEXDB_STORE_NAME);
|
|
1788
1875
|
case 4:
|
|
1789
1876
|
if (!(products.length > 0)) {
|
|
1790
1877
|
_context20.next = 7;
|
|
1791
1878
|
break;
|
|
1792
1879
|
}
|
|
1793
1880
|
_context20.next = 7;
|
|
1794
|
-
return
|
|
1881
|
+
return _this9.dbManager.bulkUpdate(INDEXDB_STORE_NAME, products);
|
|
1795
1882
|
case 7:
|
|
1796
1883
|
perfMark('replaceProductsSnapshotInIndexDB', performance.now() - t0, {
|
|
1797
1884
|
count: products.length
|
|
1798
1885
|
});
|
|
1799
|
-
|
|
1886
|
+
_this9.logInfo('replaceProductsSnapshotInIndexDB 完成', {
|
|
1800
1887
|
source: source,
|
|
1801
1888
|
productCount: products.length
|
|
1802
1889
|
});
|
|
@@ -1840,7 +1927,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1840
1927
|
key: "patchProductsInIndexDB",
|
|
1841
1928
|
value: (function () {
|
|
1842
1929
|
var _patchProductsInIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(products, source) {
|
|
1843
|
-
var
|
|
1930
|
+
var _this10 = this;
|
|
1844
1931
|
var mergeActions,
|
|
1845
1932
|
validProducts,
|
|
1846
1933
|
errorMessage,
|
|
@@ -1871,22 +1958,22 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1871
1958
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1872
1959
|
while (1) switch (_context22.prev = _context22.next) {
|
|
1873
1960
|
case 0:
|
|
1874
|
-
|
|
1961
|
+
_this10.logInfo('patchProductsInIndexDB 开始', {
|
|
1875
1962
|
source: source,
|
|
1876
1963
|
count: validProducts.length
|
|
1877
1964
|
});
|
|
1878
1965
|
t0 = performance.now();
|
|
1879
|
-
if (!(typeof
|
|
1966
|
+
if (!(typeof _this10.dbManager.bulkUpdate === 'function')) {
|
|
1880
1967
|
_context22.next = 7;
|
|
1881
1968
|
break;
|
|
1882
1969
|
}
|
|
1883
1970
|
_context22.next = 5;
|
|
1884
|
-
return
|
|
1971
|
+
return _this10.dbManager.bulkUpdate(INDEXDB_STORE_NAME, validProducts);
|
|
1885
1972
|
case 5:
|
|
1886
1973
|
_context22.next = 25;
|
|
1887
1974
|
break;
|
|
1888
1975
|
case 7:
|
|
1889
|
-
if (!(typeof
|
|
1976
|
+
if (!(typeof _this10.dbManager.update === 'function')) {
|
|
1890
1977
|
_context22.next = 25;
|
|
1891
1978
|
break;
|
|
1892
1979
|
}
|
|
@@ -1900,7 +1987,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1900
1987
|
}
|
|
1901
1988
|
product = _step11.value;
|
|
1902
1989
|
_context22.next = 15;
|
|
1903
|
-
return
|
|
1990
|
+
return _this10.dbManager.update(INDEXDB_STORE_NAME, product);
|
|
1904
1991
|
case 15:
|
|
1905
1992
|
_context22.next = 11;
|
|
1906
1993
|
break;
|
|
@@ -1919,7 +2006,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1919
2006
|
perfMark('patchProductsInIndexDB', performance.now() - t0, {
|
|
1920
2007
|
count: validProducts.length
|
|
1921
2008
|
});
|
|
1922
|
-
|
|
2009
|
+
_this10.logInfo('patchProductsInIndexDB 完成', {
|
|
1923
2010
|
source: source,
|
|
1924
2011
|
count: validProducts.length
|
|
1925
2012
|
});
|
|
@@ -2117,7 +2204,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2117
2204
|
}, {
|
|
2118
2205
|
key: "setupProductSync",
|
|
2119
2206
|
value: function setupProductSync() {
|
|
2120
|
-
var
|
|
2207
|
+
var _this11 = this;
|
|
2121
2208
|
if (!this.productDataSource) {
|
|
2122
2209
|
this.logWarning('setupProductSync: ProductDataSource 不可用,跳过同步初始化');
|
|
2123
2210
|
return;
|
|
@@ -2127,20 +2214,20 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2127
2214
|
var data = (message === null || message === void 0 ? void 0 : message.data) || message;
|
|
2128
2215
|
if (!data) return;
|
|
2129
2216
|
console.log("[ProductsModule] \u6536\u5230\u540C\u6B65\u6D88\u606F [".concat(channelKey, "]:"), data);
|
|
2130
|
-
|
|
2217
|
+
_this11.logInfo('收到同步消息', {
|
|
2131
2218
|
channelKey: channelKey,
|
|
2132
2219
|
action: data.action,
|
|
2133
2220
|
id: data.id,
|
|
2134
2221
|
action_filed: data.action_filed
|
|
2135
2222
|
});
|
|
2136
|
-
|
|
2223
|
+
_this11.pendingSyncMessages.push(_objectSpread(_objectSpread({}, data), {}, {
|
|
2137
2224
|
_channelKey: channelKey
|
|
2138
2225
|
}));
|
|
2139
|
-
if (
|
|
2140
|
-
clearTimeout(
|
|
2226
|
+
if (_this11.syncTimer) {
|
|
2227
|
+
clearTimeout(_this11.syncTimer);
|
|
2141
2228
|
}
|
|
2142
|
-
|
|
2143
|
-
|
|
2229
|
+
_this11.syncTimer = setTimeout(function () {
|
|
2230
|
+
_this11.processProductSyncMessages();
|
|
2144
2231
|
}, PRODUCT_SYNC_DEBOUNCE_MS);
|
|
2145
2232
|
};
|
|
2146
2233
|
};
|
|
@@ -2158,7 +2245,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2158
2245
|
}
|
|
2159
2246
|
}
|
|
2160
2247
|
}).catch(function (err) {
|
|
2161
|
-
|
|
2248
|
+
_this11.logError('setupProductSync: DataSource run 出错', {
|
|
2162
2249
|
error: err instanceof Error ? err.message : String(err)
|
|
2163
2250
|
});
|
|
2164
2251
|
});
|
|
@@ -2187,7 +2274,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2187
2274
|
key: "processProductSyncMessages",
|
|
2188
2275
|
value: (function () {
|
|
2189
2276
|
var _processProductSyncMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
2190
|
-
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator13, _step13, 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, _iterator14, _step14, product, freshProducts, mergeResult, _iterator15, _step15, _product, patchProducts, allChangedIds, hasChanges, errorMessage;
|
|
2277
|
+
var messages, deleteIds, bodyUpdates, sseRefreshIds, priceRefreshIds, shouldClearPriceCache, _iterator13, _step13, msg, channelKey, _msg$relation_product, _msg$change_types, _msg$ids2, _msg$ids, ids, bodyId, _bodyId, _msg$relation_product2, _msg$relation_product3, _msg$product_ids, uniqueDeleteIds, uniqueSSEIds, uniquePriceIds, patchProductMap, patchMergeActions, storeMutated, bodyResult, _iterator14, _step14, product, freshProducts, mergeResult, _iterator15, _step15, _product, patchProducts, allChangedIds, hasChanges, errorMessage;
|
|
2191
2278
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2192
2279
|
while (1) switch (_context25.prev = _context25.next) {
|
|
2193
2280
|
case 0:
|
|
@@ -2271,6 +2358,10 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2271
2358
|
if ((_msg$relation_product3 = msg.relation_product_ids) !== null && _msg$relation_product3 !== void 0 && _msg$relation_product3.length) {
|
|
2272
2359
|
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.relation_product_ids));
|
|
2273
2360
|
}
|
|
2361
|
+
} else if (['product_data_variant'].includes(channelKey)) {
|
|
2362
|
+
if ((_msg$product_ids = msg.product_ids) !== null && _msg$product_ids !== void 0 && _msg$product_ids.length) {
|
|
2363
|
+
sseRefreshIds.push.apply(sseRefreshIds, _toConsumableArray(msg.product_ids));
|
|
2364
|
+
}
|
|
2274
2365
|
}
|
|
2275
2366
|
case 34:
|
|
2276
2367
|
_context25.next = 13;
|
|
@@ -114,6 +114,8 @@ export interface ProductSyncMessage {
|
|
|
114
114
|
change_types?: string[];
|
|
115
115
|
/** 关联商品 ID(product_collection / product_category / product_quotation 变更时携带) */
|
|
116
116
|
relation_product_ids?: number[];
|
|
117
|
+
/** 关联商品 ID(product_data_variant 变更时携带) */
|
|
118
|
+
product_ids?: number[];
|
|
117
119
|
message_uuid?: string;
|
|
118
120
|
timestamp?: string;
|
|
119
121
|
/** 内部标记:来源频道 key */
|
|
@@ -128,6 +130,18 @@ export interface ProductFormatterContext {
|
|
|
128
130
|
customer_id?: number | string;
|
|
129
131
|
priceData?: LoadProductsPriceData[];
|
|
130
132
|
scheduleModule?: any;
|
|
133
|
+
/** 全量餐牌列表,供智能定价 menu_match 等条件判断使用 */
|
|
134
|
+
menuList?: any[];
|
|
135
|
+
/** 全量日程列表,供智能定价 schedule_match 等条件判断使用 */
|
|
136
|
+
scheduleList?: any[];
|
|
137
|
+
/** 外部传入的策略上下文,仅承载定价条件,不参与商品集合筛选 */
|
|
138
|
+
strategy_context?: Record<string, any>;
|
|
139
|
+
/** 智能定价评估器,由宿主统一注入到 PisellOS context */
|
|
140
|
+
dataVariantEvaluator?: {
|
|
141
|
+
resolveProducts: (businessData: any) => {
|
|
142
|
+
products: ProductData[];
|
|
143
|
+
};
|
|
144
|
+
};
|
|
131
145
|
locale?: string;
|
|
132
146
|
}
|
|
133
147
|
/**
|