@pisell/pisellos 2.3.81 → 2.3.82
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 +0 -9
- package/dist/modules/ProductList/clientDataVariants.d.ts +23 -0
- package/dist/modules/ProductList/clientDataVariants.js +165 -11
- package/dist/modules/ProductList/index.d.ts +14 -0
- package/dist/modules/ProductList/index.js +78 -11
- package/dist/solution/BaseSales/index.d.ts +16 -1
- package/dist/solution/BaseSales/index.js +531 -273
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +2 -2
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +15 -0
- package/lib/modules/ProductList/clientDataVariants.d.ts +23 -0
- package/lib/modules/ProductList/clientDataVariants.js +147 -11
- package/lib/modules/ProductList/index.d.ts +14 -0
- package/lib/modules/ProductList/index.js +59 -1
- package/lib/solution/BaseSales/index.d.ts +16 -1
- package/lib/solution/BaseSales/index.js +258 -66
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +2 -2
- package/lib/utils/platform.d.ts +8 -0
- package/lib/utils/platform.js +22 -0
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
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, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -17,7 +17,30 @@ export interface ResolveClientDataVariantsParams {
|
|
|
17
17
|
handledByOsServer: boolean;
|
|
18
18
|
scheduleList?: unknown;
|
|
19
19
|
menuList?: unknown;
|
|
20
|
+
/** Quote fast paths require hydrated relations; legacy list resolution does not. */
|
|
21
|
+
requireCompleteDataVariantRelations?: boolean;
|
|
22
|
+
/** Quote fast paths require every referenced rule; legacy list resolution is best-effort. */
|
|
23
|
+
requireEvaluatorReady?: boolean;
|
|
20
24
|
}
|
|
25
|
+
export type ResolveClientDataVariantsResult = {
|
|
26
|
+
status: 'handled-by-os-server' | 'empty' | 'data-variants-unavailable' | 'evaluator-unavailable' | 'evaluator-not-ready';
|
|
27
|
+
products: ProductData[];
|
|
28
|
+
} | {
|
|
29
|
+
status: 'resolved';
|
|
30
|
+
products: ProductData[];
|
|
31
|
+
} | {
|
|
32
|
+
status: 'error';
|
|
33
|
+
products: ProductData[];
|
|
34
|
+
error: unknown;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Strict client-side Data Variant resolution for quote fast paths.
|
|
38
|
+
*
|
|
39
|
+
* Unlike resolveClientDataVariants, callers can distinguish a complete local
|
|
40
|
+
* result from a capability/readiness/error fallback and decide to query the
|
|
41
|
+
* remote product endpoint instead.
|
|
42
|
+
*/
|
|
43
|
+
export declare function tryResolveClientDataVariants({ core, otherParams, products, queryPayload, handledByOsServer, scheduleList: explicitScheduleList, menuList: explicitMenuList, requireCompleteDataVariantRelations, requireEvaluatorReady, }: ResolveClientDataVariantsParams): ResolveClientDataVariantsResult;
|
|
21
44
|
/**
|
|
22
45
|
* 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
|
|
23
46
|
*
|
|
@@ -13,13 +13,74 @@ export function isProductQueryHandledByOsServer(core, request) {
|
|
|
13
13
|
var requestBaseUrl = String((request === null || request === void 0 ? void 0 : request.baseUrl) || '/shop').replace(/\/+$/, '');
|
|
14
14
|
return server.hasRoute('post', "".concat(requestBaseUrl, "/product/query")) === true;
|
|
15
15
|
}
|
|
16
|
+
function getBundleItems(product) {
|
|
17
|
+
if (!Array.isArray(product.bundle_group)) return [];
|
|
18
|
+
return product.bundle_group.flatMap(function (group) {
|
|
19
|
+
return Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : [];
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function hasCompleteDataVariantRelations(products) {
|
|
23
|
+
return products.every(function (product) {
|
|
24
|
+
return Array.isArray(product === null || product === void 0 ? void 0 : product.data_variants);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function hasAnyDataVariants(products) {
|
|
28
|
+
return products.some(function (product) {
|
|
29
|
+
var _product$data_variant;
|
|
30
|
+
return (((_product$data_variant = product.data_variants) === null || _product$data_variant === void 0 ? void 0 : _product$data_variant.length) || 0) > 0 || getBundleItems(product).some(function (item) {
|
|
31
|
+
return Array.isArray(item === null || item === void 0 ? void 0 : item.data_variants) && item.data_variants.length > 0;
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function collectReferencedRuleIds(products) {
|
|
36
|
+
var ids = new Set();
|
|
37
|
+
var remember = function remember(variants) {
|
|
38
|
+
if (!Array.isArray(variants)) return;
|
|
39
|
+
variants.forEach(function (variant) {
|
|
40
|
+
var _variant$data_variant;
|
|
41
|
+
var id = String((_variant$data_variant = variant === null || variant === void 0 ? void 0 : variant.data_variant_rule_id) !== null && _variant$data_variant !== void 0 ? _variant$data_variant : '').trim();
|
|
42
|
+
if (id) ids.add(id);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
products.forEach(function (product) {
|
|
46
|
+
remember(product.data_variants);
|
|
47
|
+
getBundleItems(product).forEach(function (item) {
|
|
48
|
+
return remember(item === null || item === void 0 ? void 0 : item.data_variants);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return ids;
|
|
52
|
+
}
|
|
53
|
+
function isEvaluatorReady(evaluator, products) {
|
|
54
|
+
if (typeof evaluator.isReady === 'function') {
|
|
55
|
+
if (evaluator.isReady() === false) return false;
|
|
56
|
+
}
|
|
57
|
+
if (evaluator.isReady === false || evaluator.ready === false) return false;
|
|
58
|
+
|
|
59
|
+
// The built-in evaluator is installed before its strategy request completes.
|
|
60
|
+
// A referenced Data Variant cannot be evaluated authoritatively until those
|
|
61
|
+
// configs have arrived. Evaluators without this capability remain compatible.
|
|
62
|
+
if (typeof evaluator.getStrategyConfigs === 'function') {
|
|
63
|
+
var configs = evaluator.getStrategyConfigs();
|
|
64
|
+
if (!Array.isArray(configs) || configs.length === 0) return false;
|
|
65
|
+
var availableRuleIds = new Set(configs.map(function (config) {
|
|
66
|
+
var _config$metadata$id, _config$metadata;
|
|
67
|
+
return String((_config$metadata$id = config === null || config === void 0 || (_config$metadata = config.metadata) === null || _config$metadata === void 0 ? void 0 : _config$metadata.id) !== null && _config$metadata$id !== void 0 ? _config$metadata$id : '').trim();
|
|
68
|
+
}).filter(Boolean));
|
|
69
|
+
return Array.from(collectReferencedRuleIds(products)).every(function (id) {
|
|
70
|
+
return availableRuleIds.has(id);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
16
76
|
/**
|
|
17
|
-
*
|
|
77
|
+
* Strict client-side Data Variant resolution for quote fast paths.
|
|
18
78
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
79
|
+
* Unlike resolveClientDataVariants, callers can distinguish a complete local
|
|
80
|
+
* result from a capability/readiness/error fallback and decide to query the
|
|
81
|
+
* remote product endpoint instead.
|
|
21
82
|
*/
|
|
22
|
-
export function
|
|
83
|
+
export function tryResolveClientDataVariants(_ref) {
|
|
23
84
|
var _core$context, _scheduleModule$getSc, _core$context2, _core$context3, _strategyContext$busi;
|
|
24
85
|
var core = _ref.core,
|
|
25
86
|
_ref$otherParams = _ref.otherParams,
|
|
@@ -28,11 +89,59 @@ export function resolveClientDataVariants(_ref) {
|
|
|
28
89
|
queryPayload = _ref.queryPayload,
|
|
29
90
|
handledByOsServer = _ref.handledByOsServer,
|
|
30
91
|
explicitScheduleList = _ref.scheduleList,
|
|
31
|
-
explicitMenuList = _ref.menuList
|
|
32
|
-
|
|
92
|
+
explicitMenuList = _ref.menuList,
|
|
93
|
+
_ref$requireCompleteD = _ref.requireCompleteDataVariantRelations,
|
|
94
|
+
requireCompleteDataVariantRelations = _ref$requireCompleteD === void 0 ? true : _ref$requireCompleteD,
|
|
95
|
+
_ref$requireEvaluator = _ref.requireEvaluatorReady,
|
|
96
|
+
requireEvaluatorReady = _ref$requireEvaluator === void 0 ? true : _ref$requireEvaluator;
|
|
97
|
+
if (handledByOsServer) {
|
|
98
|
+
return {
|
|
99
|
+
status: 'handled-by-os-server',
|
|
100
|
+
products: products
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (products.length === 0) {
|
|
104
|
+
return {
|
|
105
|
+
status: 'empty',
|
|
106
|
+
products: products
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (requireCompleteDataVariantRelations && !hasCompleteDataVariantRelations(products)) {
|
|
110
|
+
return {
|
|
111
|
+
status: 'data-variants-unavailable',
|
|
112
|
+
products: products
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Explicit empty arrays mean the query hydrated the relation and there is no
|
|
117
|
+
// rule to apply. This is an authoritative local base-price result even when
|
|
118
|
+
// no evaluator has been installed.
|
|
119
|
+
if (!hasAnyDataVariants(products)) {
|
|
120
|
+
return {
|
|
121
|
+
status: 'resolved',
|
|
122
|
+
products: products
|
|
123
|
+
};
|
|
124
|
+
}
|
|
33
125
|
var evaluator = core === null || core === void 0 || (_core$context = core.context) === null || _core$context === void 0 ? void 0 : _core$context.dataVariantEvaluator;
|
|
34
126
|
if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
|
|
35
|
-
return
|
|
127
|
+
return {
|
|
128
|
+
status: 'evaluator-unavailable',
|
|
129
|
+
products: products
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
if (requireEvaluatorReady && !isEvaluatorReady(evaluator, products)) {
|
|
134
|
+
return {
|
|
135
|
+
status: 'evaluator-not-ready',
|
|
136
|
+
products: products
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return {
|
|
141
|
+
status: 'error',
|
|
142
|
+
products: products,
|
|
143
|
+
error: error
|
|
144
|
+
};
|
|
36
145
|
}
|
|
37
146
|
var strategyContext = queryPayload.strategy_context && _typeof(queryPayload.strategy_context) === 'object' ? queryPayload.strategy_context : {};
|
|
38
147
|
var fatherModule = String(otherParams.fatherModule || '').trim();
|
|
@@ -43,7 +152,7 @@ export function resolveClientDataVariants(_ref) {
|
|
|
43
152
|
var businessData = {
|
|
44
153
|
products: products,
|
|
45
154
|
scheduleDateTime: queryPayload.schedule_datetime || queryPayload.schedule_date,
|
|
46
|
-
scheduleList: Array.isArray(explicitScheduleList) ? explicitScheduleList : Array.isArray(moduleScheduleList) ? moduleScheduleList : Array.isArray(contextScheduleList) ? contextScheduleList : [],
|
|
155
|
+
scheduleList: Array.isArray(explicitScheduleList) && explicitScheduleList.length > 0 ? explicitScheduleList : Array.isArray(moduleScheduleList) && moduleScheduleList.length > 0 ? moduleScheduleList : Array.isArray(contextScheduleList) ? contextScheduleList : [],
|
|
47
156
|
menuList: Array.isArray(explicitMenuList) ? explicitMenuList : Array.isArray(otherParams.menuList) ? otherParams.menuList : Array.isArray(contextMenuList) ? contextMenuList : [],
|
|
48
157
|
customerId: queryPayload.customer_id,
|
|
49
158
|
channel: strategyContext.channel,
|
|
@@ -54,9 +163,54 @@ export function resolveClientDataVariants(_ref) {
|
|
|
54
163
|
};
|
|
55
164
|
try {
|
|
56
165
|
var result = evaluator.resolveProducts(businessData);
|
|
57
|
-
|
|
166
|
+
if (!Array.isArray(result === null || result === void 0 ? void 0 : result.products)) {
|
|
167
|
+
return {
|
|
168
|
+
status: 'error',
|
|
169
|
+
products: products,
|
|
170
|
+
error: new Error('Data Variant evaluator returned an invalid product list')
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
status: 'resolved',
|
|
175
|
+
products: result.products
|
|
176
|
+
};
|
|
58
177
|
} catch (error) {
|
|
59
|
-
|
|
60
|
-
|
|
178
|
+
return {
|
|
179
|
+
status: 'error',
|
|
180
|
+
products: products,
|
|
181
|
+
error: error
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
|
|
188
|
+
*
|
|
189
|
+
* 商品列表和预约报价必须共用这个边界,避免 H5 的弹窗报价绕过客户端智能定价。
|
|
190
|
+
* OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
|
|
191
|
+
*/
|
|
192
|
+
export function resolveClientDataVariants(_ref2) {
|
|
193
|
+
var core = _ref2.core,
|
|
194
|
+
_ref2$otherParams = _ref2.otherParams,
|
|
195
|
+
otherParams = _ref2$otherParams === void 0 ? {} : _ref2$otherParams,
|
|
196
|
+
products = _ref2.products,
|
|
197
|
+
queryPayload = _ref2.queryPayload,
|
|
198
|
+
handledByOsServer = _ref2.handledByOsServer,
|
|
199
|
+
explicitScheduleList = _ref2.scheduleList,
|
|
200
|
+
explicitMenuList = _ref2.menuList;
|
|
201
|
+
var result = tryResolveClientDataVariants({
|
|
202
|
+
core: core,
|
|
203
|
+
otherParams: otherParams,
|
|
204
|
+
products: products,
|
|
205
|
+
queryPayload: queryPayload,
|
|
206
|
+
handledByOsServer: handledByOsServer,
|
|
207
|
+
scheduleList: explicitScheduleList,
|
|
208
|
+
menuList: explicitMenuList,
|
|
209
|
+
requireCompleteDataVariantRelations: false,
|
|
210
|
+
requireEvaluatorReady: false
|
|
211
|
+
});
|
|
212
|
+
if (result.status === 'error') {
|
|
213
|
+
console.error('[ClientDataVariants] Data Variant 客户端解析失败', result.error);
|
|
61
214
|
}
|
|
215
|
+
return result.products;
|
|
62
216
|
}
|
|
@@ -9,6 +9,7 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
11
|
private otherParams;
|
|
12
|
+
private rawProductPriceSources;
|
|
12
13
|
constructor(name?: string, version?: string);
|
|
13
14
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
14
15
|
/**
|
|
@@ -36,6 +37,19 @@ export declare class ProductList extends BaseModule implements Module {
|
|
|
36
37
|
schedule_date?: string;
|
|
37
38
|
channel?: string;
|
|
38
39
|
}): Promise<any>;
|
|
40
|
+
/**
|
|
41
|
+
* Remember raw remote product records before client-side Data Variant
|
|
42
|
+
* evaluation. Quote-only reads can then always start from a clean baseline.
|
|
43
|
+
*/
|
|
44
|
+
rememberRawProductQueryResult(products: Array<ProductData | Record<string, any>>): void;
|
|
45
|
+
private replaceRawProductQueryResult;
|
|
46
|
+
/**
|
|
47
|
+
* Return isolated raw price sources for the requested products.
|
|
48
|
+
*
|
|
49
|
+
* Missing IDs are intentionally omitted so callers can remotely fetch only
|
|
50
|
+
* the incomplete part of a batch quote.
|
|
51
|
+
*/
|
|
52
|
+
getRawProductPriceSources(ids: number[]): Map<number, ProductData>;
|
|
39
53
|
getProducts(): Promise<ProductData[]>;
|
|
40
54
|
getProduct(id: number): Promise<ProductData | undefined>;
|
|
41
55
|
getProductByIds(ids: number[]): Promise<ProductData[] | undefined>;
|
|
@@ -27,6 +27,7 @@ import { BaseModule } from "../BaseModule";
|
|
|
27
27
|
import { cloneDeep } from 'lodash-es';
|
|
28
28
|
import dayjs from 'dayjs';
|
|
29
29
|
import { isProductQueryHandledByOsServer, PRODUCT_QUERY_DATA_VARIANT_RELATIONS, resolveClientDataVariants } from "./clientDataVariants";
|
|
30
|
+
import { isCustomerUserPlatform } from "../../utils/platform";
|
|
30
31
|
export * from "./types";
|
|
31
32
|
export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
32
33
|
_inherits(ProductList, _BaseModule);
|
|
@@ -40,6 +41,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
40
41
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
41
42
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
42
43
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "rawProductPriceSources", new Map());
|
|
43
45
|
return _this;
|
|
44
46
|
}
|
|
45
47
|
_createClass(ProductList, [{
|
|
@@ -53,6 +55,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
53
55
|
this.core = core;
|
|
54
56
|
this.store = options.store;
|
|
55
57
|
this.otherParams = options.otherParams || {};
|
|
58
|
+
this.rawProductPriceSources.clear();
|
|
56
59
|
if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
|
|
57
60
|
this.store.list = options.initialState.list.slice().sort(function (a, b) {
|
|
58
61
|
return Number(b.sort) - Number(a.sort);
|
|
@@ -63,7 +66,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
63
66
|
this.store.selectProducts = [];
|
|
64
67
|
}
|
|
65
68
|
this.request = core.getPlugin('request');
|
|
66
|
-
case
|
|
69
|
+
case 6:
|
|
67
70
|
case "end":
|
|
68
71
|
return _context.stop();
|
|
69
72
|
}
|
|
@@ -140,6 +143,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
143
|
value: function () {
|
|
141
144
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
142
145
|
var _this$otherParams,
|
|
146
|
+
_this$otherParams2,
|
|
143
147
|
_this2 = this;
|
|
144
148
|
var _ref,
|
|
145
149
|
_ref$category_ids,
|
|
@@ -210,8 +214,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
210
214
|
};
|
|
211
215
|
rawApplicationCode = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel;
|
|
212
216
|
mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
|
|
213
|
-
queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
214
|
-
open_quotation: 1
|
|
217
|
+
queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, isCustomerUserPlatform((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform) ? {} : {
|
|
218
|
+
open_quotation: 1
|
|
219
|
+
}), {}, {
|
|
215
220
|
open_bundle: 0,
|
|
216
221
|
exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
|
|
217
222
|
with: _toConsumableArray(PRODUCT_QUERY_DATA_VARIANT_RELATIONS),
|
|
@@ -257,6 +262,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
257
262
|
originalCallback(result);
|
|
258
263
|
return _context4.abrupt("return");
|
|
259
264
|
case 4:
|
|
265
|
+
if (!handledByOsServer) {
|
|
266
|
+
// Subscription callbacks may contain only changed products. Upsert
|
|
267
|
+
// their raw records without evicting other IDs from the scope.
|
|
268
|
+
_this2.rememberRawProductQueryResult(callbackList);
|
|
269
|
+
}
|
|
260
270
|
products = resolveClientDataVariants({
|
|
261
271
|
core: _this2.core,
|
|
262
272
|
otherParams: _this2.otherParams,
|
|
@@ -264,15 +274,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
264
274
|
queryPayload: queryPayload,
|
|
265
275
|
handledByOsServer: handledByOsServer
|
|
266
276
|
});
|
|
267
|
-
_context4.next =
|
|
277
|
+
_context4.next = 8;
|
|
268
278
|
return _this2.addProduct(products);
|
|
269
|
-
case
|
|
279
|
+
case 8:
|
|
270
280
|
originalCallback(handledByOsServer ? result : _objectSpread(_objectSpread({}, result), {}, {
|
|
271
281
|
data: _objectSpread(_objectSpread({}, result.data), {}, {
|
|
272
282
|
list: products
|
|
273
283
|
})
|
|
274
284
|
}));
|
|
275
|
-
case
|
|
285
|
+
case 9:
|
|
276
286
|
case "end":
|
|
277
287
|
return _context4.stop();
|
|
278
288
|
}
|
|
@@ -291,6 +301,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
291
301
|
});
|
|
292
302
|
case 14:
|
|
293
303
|
productsData = _context5.sent;
|
|
304
|
+
if (!handledByOsServer && Array.isArray(productsData.data.list)) {
|
|
305
|
+
this.replaceRawProductQueryResult(productsData.data.list, product_ids);
|
|
306
|
+
}
|
|
294
307
|
resolvedList = resolveClientDataVariants({
|
|
295
308
|
core: this.core,
|
|
296
309
|
otherParams: this.otherParams,
|
|
@@ -309,7 +322,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
309
322
|
// }
|
|
310
323
|
this.addProduct(sortedList);
|
|
311
324
|
return _context5.abrupt("return", sortedList);
|
|
312
|
-
case
|
|
325
|
+
case 20:
|
|
313
326
|
case "end":
|
|
314
327
|
return _context5.stop();
|
|
315
328
|
}
|
|
@@ -352,6 +365,60 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
352
365
|
}
|
|
353
366
|
return loadProductsPrice;
|
|
354
367
|
}()
|
|
368
|
+
/**
|
|
369
|
+
* Remember raw remote product records before client-side Data Variant
|
|
370
|
+
* evaluation. Quote-only reads can then always start from a clean baseline.
|
|
371
|
+
*/
|
|
372
|
+
}, {
|
|
373
|
+
key: "rememberRawProductQueryResult",
|
|
374
|
+
value: function rememberRawProductQueryResult(products) {
|
|
375
|
+
var _this3 = this;
|
|
376
|
+
if (!Array.isArray(products)) return;
|
|
377
|
+
products.forEach(function (product) {
|
|
378
|
+
var _source$id;
|
|
379
|
+
var source = product;
|
|
380
|
+
var id = Number((_source$id = source === null || source === void 0 ? void 0 : source.id) !== null && _source$id !== void 0 ? _source$id : source === null || source === void 0 ? void 0 : source.product_id);
|
|
381
|
+
if (!Number.isFinite(id)) return;
|
|
382
|
+
_this3.rawProductPriceSources.set(id, cloneDeep(product));
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}, {
|
|
386
|
+
key: "replaceRawProductQueryResult",
|
|
387
|
+
value: function replaceRawProductQueryResult(products, requestedIds) {
|
|
388
|
+
var _this4 = this;
|
|
389
|
+
if (Array.isArray(requestedIds) && requestedIds.length > 0) {
|
|
390
|
+
requestedIds.forEach(function (rawId) {
|
|
391
|
+
var id = Number(rawId);
|
|
392
|
+
if (Number.isFinite(id)) _this4.rawProductPriceSources.delete(id);
|
|
393
|
+
});
|
|
394
|
+
} else {
|
|
395
|
+
// A non-ID query represents the latest catalog scope. Clearing before
|
|
396
|
+
// replacing prevents removed products from surviving indefinitely.
|
|
397
|
+
this.rawProductPriceSources.clear();
|
|
398
|
+
}
|
|
399
|
+
this.rememberRawProductQueryResult(products);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Return isolated raw price sources for the requested products.
|
|
404
|
+
*
|
|
405
|
+
* Missing IDs are intentionally omitted so callers can remotely fetch only
|
|
406
|
+
* the incomplete part of a batch quote.
|
|
407
|
+
*/
|
|
408
|
+
}, {
|
|
409
|
+
key: "getRawProductPriceSources",
|
|
410
|
+
value: function getRawProductPriceSources(ids) {
|
|
411
|
+
var _this5 = this;
|
|
412
|
+
var products = new Map();
|
|
413
|
+
if (!Array.isArray(ids)) return products;
|
|
414
|
+
ids.forEach(function (rawId) {
|
|
415
|
+
var id = Number(rawId);
|
|
416
|
+
if (!Number.isFinite(id) || products.has(id)) return;
|
|
417
|
+
var product = _this5.rawProductPriceSources.get(id);
|
|
418
|
+
if (product) products.set(id, cloneDeep(product));
|
|
419
|
+
});
|
|
420
|
+
return products;
|
|
421
|
+
}
|
|
355
422
|
}, {
|
|
356
423
|
key: "getProducts",
|
|
357
424
|
value: function () {
|
|
@@ -430,7 +497,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
430
497
|
key: "addProduct",
|
|
431
498
|
value: function () {
|
|
432
499
|
var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
|
|
433
|
-
var
|
|
500
|
+
var _this6 = this;
|
|
434
501
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
435
502
|
while (1) switch (_context10.prev = _context10.next) {
|
|
436
503
|
case 0:
|
|
@@ -439,13 +506,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
|
|
|
439
506
|
this.store.list = [];
|
|
440
507
|
}
|
|
441
508
|
products.forEach(function (n) {
|
|
442
|
-
var index =
|
|
509
|
+
var index = _this6.store.list.findIndex(function (m) {
|
|
443
510
|
return m.id === n.id;
|
|
444
511
|
});
|
|
445
512
|
if (index === -1) {
|
|
446
|
-
|
|
513
|
+
_this6.store.list.push(n);
|
|
447
514
|
} else {
|
|
448
|
-
|
|
515
|
+
_this6.store.list[index] = n;
|
|
449
516
|
}
|
|
450
517
|
});
|
|
451
518
|
// 根据 sort 值做降序排序(数字越大越靠前)
|
|
@@ -129,8 +129,23 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
129
129
|
*/
|
|
130
130
|
protected preferAuthoritativeProductQueryPrice(): boolean;
|
|
131
131
|
private getPriceQuerySchedule;
|
|
132
|
+
private isCustomerUserPriceQuery;
|
|
133
|
+
private getPriceQueryScheduleList;
|
|
134
|
+
private buildPriceQueryPayload;
|
|
135
|
+
private getRawProductPriceSources;
|
|
136
|
+
private rememberRawProductPriceSources;
|
|
137
|
+
private getSelectedProductVariantId;
|
|
138
|
+
/**
|
|
139
|
+
* 将目录原始商品还原为本次选择的 SKU 基线。
|
|
140
|
+
*
|
|
141
|
+
* 这里绝不能复用已评估后的目录商品,否则从命中智能价切回不命中的
|
|
142
|
+
* 日期时会残留旧价格。套餐仅验证所选关系存在,最终仍由 merge 方法把
|
|
143
|
+
* 评估后的套餐价格映射回用户的选择数据。
|
|
144
|
+
*/
|
|
145
|
+
private prepareRawProductForPriceQuery;
|
|
146
|
+
private resolveLocalProductForPriceQuery;
|
|
132
147
|
private loadProductsForPriceQuery;
|
|
133
|
-
private
|
|
148
|
+
private resolveProductsForPriceQuery;
|
|
134
149
|
private getAuthoritativeBundleItems;
|
|
135
150
|
private findAuthoritativeBundleItem;
|
|
136
151
|
private getAuthoritativeBundleUnitPrice;
|