@pisell/pisellos 2.1.170 → 2.1.171
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/evaluator.js +13 -100
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/VenueBooking/index.d.ts +10 -0
- package/dist/solution/VenueBooking/index.js +421 -199
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -1
- package/dist/solution/VenueBooking/utils/smartPricing.js +9 -78
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +8 -91
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/VenueBooking/index.d.ts +10 -0
- package/lib/solution/VenueBooking/index.js +272 -82
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -1
- package/lib/solution/VenueBooking/utils/smartPricing.js +1 -46
- package/package.json +1 -1
|
@@ -56,46 +56,18 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
56
56
|
}, {
|
|
57
57
|
key: "resolveProducts",
|
|
58
58
|
value: function resolveProducts(businessData) {
|
|
59
|
-
var _this = this
|
|
60
|
-
_businessData$debugLo;
|
|
59
|
+
var _this = this;
|
|
61
60
|
var strategyConfigs = businessData.strategyConfigs ? this.normalizeStrategyConfigs(businessData.strategyConfigs) : this.strategyConfigs;
|
|
62
61
|
var menuScopeMap = this.buildMenuScopeMap(businessData.menuList || []);
|
|
63
62
|
var scheduleTimePoints = this.buildScheduleTimePoints(strategyConfigs, businessData.scheduleList || []);
|
|
64
63
|
var _this$buildGlobalEffe = this.buildGlobalEffectiveRuleMap(strategyConfigs, businessData, menuScopeMap),
|
|
65
64
|
globalEffectiveRuleMap = _this$buildGlobalEffe.globalEffectiveRuleMap,
|
|
66
65
|
rawResults = _this$buildGlobalEffe.rawResults;
|
|
67
|
-
var productDiagnostics = businessData.debugLog ? [] : undefined;
|
|
68
66
|
var products = businessData.products.map(function (product) {
|
|
69
|
-
var resolvedProduct = _this.resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap
|
|
67
|
+
var resolvedProduct = _this.resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap);
|
|
70
68
|
// 套餐子商品也可能携带 data_variants,需在同一策略上下文内继续评估并写回 bundle_item。
|
|
71
69
|
return _this.resolveProductBundleItems(resolvedProduct, businessData, globalEffectiveRuleMap, menuScopeMap);
|
|
72
70
|
});
|
|
73
|
-
businessData === null || businessData === void 0 || (_businessData$debugLo = businessData.debugLog) === null || _businessData$debugLo === void 0 || _businessData$debugLo.call(businessData, '[VenueBooking][smartPricing] evaluator result', {
|
|
74
|
-
scheduleDateTime: businessData.scheduleDateTime,
|
|
75
|
-
strategyConfigs: strategyConfigs.map(function (config) {
|
|
76
|
-
var _config$metadata, _config$metadata2, _config$metadata3;
|
|
77
|
-
return {
|
|
78
|
-
ruleId: String(config === null || config === void 0 || (_config$metadata = config.metadata) === null || _config$metadata === void 0 ? void 0 : _config$metadata.id),
|
|
79
|
-
name: config === null || config === void 0 || (_config$metadata2 = config.metadata) === null || _config$metadata2 === void 0 ? void 0 : _config$metadata2.name,
|
|
80
|
-
status: config === null || config === void 0 || (_config$metadata3 = config.metadata) === null || _config$metadata3 === void 0 || (_config$metadata3 = _config$metadata3.custom) === null || _config$metadata3 === void 0 ? void 0 : _config$metadata3.status,
|
|
81
|
-
priority: _this.getStrategyPriority(config),
|
|
82
|
-
conditions: config === null || config === void 0 ? void 0 : config.conditions
|
|
83
|
-
};
|
|
84
|
-
}),
|
|
85
|
-
globalRuleResults: rawResults.map(function (result) {
|
|
86
|
-
var _result$config, _result$config2;
|
|
87
|
-
return {
|
|
88
|
-
ruleId: String(result === null || result === void 0 || (_result$config = result.config) === null || _result$config === void 0 || (_result$config = _result$config.metadata) === null || _result$config === void 0 ? void 0 : _result$config.id),
|
|
89
|
-
name: result === null || result === void 0 || (_result$config2 = result.config) === null || _result$config2 === void 0 || (_result$config2 = _result$config2.metadata) === null || _result$config2 === void 0 ? void 0 : _result$config2.name,
|
|
90
|
-
applicable: result === null || result === void 0 ? void 0 : result.applicable,
|
|
91
|
-
code: result === null || result === void 0 ? void 0 : result.code,
|
|
92
|
-
message: result === null || result === void 0 ? void 0 : result.message,
|
|
93
|
-
matched: result === null || result === void 0 ? void 0 : result.matched
|
|
94
|
-
};
|
|
95
|
-
}),
|
|
96
|
-
effectiveRuleIds: Array.from(globalEffectiveRuleMap.keys()),
|
|
97
|
-
productDiagnostics: productDiagnostics || []
|
|
98
|
-
});
|
|
99
71
|
return {
|
|
100
72
|
products: products,
|
|
101
73
|
globalEffectiveRuleMap: globalEffectiveRuleMap,
|
|
@@ -247,60 +219,20 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
247
219
|
}
|
|
248
220
|
}, {
|
|
249
221
|
key: "resolveProduct",
|
|
250
|
-
value: function resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap
|
|
251
|
-
var _product$id, _product$price5, _resolvedProduct$pric, _resolvedProduct$_dat, _resolvedProduct$_dat2;
|
|
222
|
+
value: function resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap) {
|
|
252
223
|
var dataVariants = this.getProductDataVariants(product);
|
|
253
|
-
|
|
254
|
-
if (!dataVariants.length) {
|
|
255
|
-
var _product$price, _product$price2;
|
|
256
|
-
diagnostics === null || diagnostics === void 0 || diagnostics.push({
|
|
257
|
-
productId: productId,
|
|
258
|
-
originalPrice: (_product$price = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price !== void 0 ? _product$price : product === null || product === void 0 ? void 0 : product.selling_price,
|
|
259
|
-
finalPrice: (_product$price2 = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price2 !== void 0 ? _product$price2 : product === null || product === void 0 ? void 0 : product.selling_price,
|
|
260
|
-
reason: 'product has no data_variants',
|
|
261
|
-
variants: []
|
|
262
|
-
});
|
|
263
|
-
return product;
|
|
264
|
-
}
|
|
224
|
+
if (!dataVariants.length) return product;
|
|
265
225
|
var matchedVariants = [];
|
|
266
|
-
var variantDiagnostics = [];
|
|
267
226
|
var _iterator5 = _createForOfIteratorHelper(dataVariants),
|
|
268
227
|
_step5;
|
|
269
228
|
try {
|
|
270
229
|
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
271
230
|
var variant = _step5.value;
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
if (!rule) {
|
|
275
|
-
variantDiagnostics.push({
|
|
276
|
-
ruleId: ruleId,
|
|
277
|
-
variantData: variant.data || {},
|
|
278
|
-
globalRuleEffective: false,
|
|
279
|
-
productRulesMatched: false,
|
|
280
|
-
reason: 'referenced rule is missing or its global conditions did not match'
|
|
281
|
-
});
|
|
231
|
+
var rule = globalEffectiveRuleMap.get(String(variant.data_variant_rule_id));
|
|
232
|
+
if (!rule) continue;
|
|
233
|
+
if (!this.evaluateProductRules(rule, product, businessData, menuScopeMap)) {
|
|
282
234
|
continue;
|
|
283
235
|
}
|
|
284
|
-
var productRulesMatched = this.evaluateProductRules(rule, product, businessData, menuScopeMap);
|
|
285
|
-
if (!productRulesMatched) {
|
|
286
|
-
variantDiagnostics.push({
|
|
287
|
-
ruleId: ruleId,
|
|
288
|
-
variantData: variant.data || {},
|
|
289
|
-
globalRuleEffective: true,
|
|
290
|
-
productRulesMatched: false,
|
|
291
|
-
productRules: rule.productRules,
|
|
292
|
-
reason: 'product-level conditions did not match'
|
|
293
|
-
});
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
variantDiagnostics.push({
|
|
297
|
-
ruleId: ruleId,
|
|
298
|
-
variantData: variant.data || {},
|
|
299
|
-
globalRuleEffective: true,
|
|
300
|
-
productRulesMatched: true,
|
|
301
|
-
priority: rule.priority,
|
|
302
|
-
reason: 'variant matched and will be merged into the product'
|
|
303
|
-
});
|
|
304
236
|
matchedVariants.push({
|
|
305
237
|
ruleId: rule.ruleId,
|
|
306
238
|
priority: rule.priority,
|
|
@@ -313,27 +245,8 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
313
245
|
} finally {
|
|
314
246
|
_iterator5.f();
|
|
315
247
|
}
|
|
316
|
-
if (!matchedVariants.length)
|
|
317
|
-
|
|
318
|
-
diagnostics === null || diagnostics === void 0 || diagnostics.push({
|
|
319
|
-
productId: productId,
|
|
320
|
-
originalPrice: (_product$price3 = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price3 !== void 0 ? _product$price3 : product === null || product === void 0 ? void 0 : product.selling_price,
|
|
321
|
-
finalPrice: (_product$price4 = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price4 !== void 0 ? _product$price4 : product === null || product === void 0 ? void 0 : product.selling_price,
|
|
322
|
-
reason: 'no data_variant matched',
|
|
323
|
-
variants: variantDiagnostics
|
|
324
|
-
});
|
|
325
|
-
return product;
|
|
326
|
-
}
|
|
327
|
-
var resolvedProduct = this.mergeMatchedVariants(product, matchedVariants);
|
|
328
|
-
diagnostics === null || diagnostics === void 0 || diagnostics.push({
|
|
329
|
-
productId: productId,
|
|
330
|
-
originalPrice: (_product$price5 = product === null || product === void 0 ? void 0 : product.price) !== null && _product$price5 !== void 0 ? _product$price5 : product === null || product === void 0 ? void 0 : product.selling_price,
|
|
331
|
-
finalPrice: (_resolvedProduct$pric = resolvedProduct === null || resolvedProduct === void 0 ? void 0 : resolvedProduct.price) !== null && _resolvedProduct$pric !== void 0 ? _resolvedProduct$pric : resolvedProduct === null || resolvedProduct === void 0 ? void 0 : resolvedProduct.selling_price,
|
|
332
|
-
appliedRuleIds: (resolvedProduct === null || resolvedProduct === void 0 || (_resolvedProduct$_dat = resolvedProduct._dataVariant) === null || _resolvedProduct$_dat === void 0 ? void 0 : _resolvedProduct$_dat.appliedRuleIds) || [],
|
|
333
|
-
appliedFields: (resolvedProduct === null || resolvedProduct === void 0 || (_resolvedProduct$_dat2 = resolvedProduct._dataVariant) === null || _resolvedProduct$_dat2 === void 0 ? void 0 : _resolvedProduct$_dat2.appliedFields) || [],
|
|
334
|
-
variants: variantDiagnostics
|
|
335
|
-
});
|
|
336
|
-
return resolvedProduct;
|
|
248
|
+
if (!matchedVariants.length) return product;
|
|
249
|
+
return this.mergeMatchedVariants(product, matchedVariants);
|
|
337
250
|
}
|
|
338
251
|
|
|
339
252
|
/**
|
|
@@ -710,11 +623,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
710
623
|
}, {
|
|
711
624
|
key: "isProductInMenuScope",
|
|
712
625
|
value: function isProductInMenuScope(product, scope) {
|
|
713
|
-
var _product$
|
|
626
|
+
var _product$id,
|
|
714
627
|
_this5 = this;
|
|
715
628
|
if (scope.isAllProducts) return true;
|
|
716
629
|
if (!product || _typeof(product) !== 'object') return false;
|
|
717
|
-
var productId = this.toNumber((_product$
|
|
630
|
+
var productId = this.toNumber((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id);
|
|
718
631
|
var variantId = this.toNumber(product.product_variant_id);
|
|
719
632
|
var productKey = this.buildProductKey(productId, variantId);
|
|
720
633
|
var collectionIds = Array.isArray(product.collection_ids) ? product.collection_ids.map(function (id) {
|
|
@@ -771,8 +684,8 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
771
684
|
key: "normalizeStrategyConfigs",
|
|
772
685
|
value: function normalizeStrategyConfigs(configs) {
|
|
773
686
|
return configs.filter(function (config) {
|
|
774
|
-
var _config$
|
|
775
|
-
return (config === null || config === void 0 || (_config$
|
|
687
|
+
var _config$metadata;
|
|
688
|
+
return (config === null || config === void 0 || (_config$metadata = config.metadata) === null || _config$metadata === void 0 ? void 0 : _config$metadata.type) === 'data_variant';
|
|
776
689
|
});
|
|
777
690
|
}
|
|
778
691
|
}, {
|
|
@@ -105,7 +105,6 @@ export interface DataVariantBusinessData {
|
|
|
105
105
|
/** 当前客户可用 wallet/pass id 合并列表,对应策略条件 field: available_wallet_ids */
|
|
106
106
|
availableWalletIds?: Array<number | string>;
|
|
107
107
|
custom?: Record<string, any>;
|
|
108
|
-
debugLog?: (title: string, payload?: Record<string, any>) => void;
|
|
109
108
|
}
|
|
110
109
|
/**
|
|
111
110
|
* 全局预计算后的规则信息。
|
|
@@ -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 } from "./examples";
|
|
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
310
310
|
date: string;
|
|
311
311
|
status: string;
|
|
312
312
|
week: string;
|
|
313
|
-
weekNum: 0 | 2 | 1 |
|
|
313
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
314
314
|
}[]>;
|
|
315
315
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
316
316
|
private getScheduleDataByIds;
|
|
@@ -62,6 +62,8 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
62
62
|
private logPricingDiagnostics;
|
|
63
63
|
private isPricingDiagnosticsEnabled;
|
|
64
64
|
private getAvailableWalletIdsForDiagnostics;
|
|
65
|
+
private getOrderPricingSnapshotForDiagnostics;
|
|
66
|
+
private getCatalogPricingSnapshotForDiagnostics;
|
|
65
67
|
private logMethodStart;
|
|
66
68
|
private logMethodSuccess;
|
|
67
69
|
private logMethodError;
|
|
@@ -181,6 +183,14 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
181
183
|
onCustomerLogin(params: {
|
|
182
184
|
customerId: number;
|
|
183
185
|
}): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* 接收 pisell2 VenueBooking 登录链路诊断日志。
|
|
188
|
+
* 实际是否上报仍由 OS 内部 cacheId 白名单统一控制。
|
|
189
|
+
*/
|
|
190
|
+
logPricingDiagnosticsFromClient(params: {
|
|
191
|
+
title: string;
|
|
192
|
+
payload?: Record<string, any>;
|
|
193
|
+
}): void;
|
|
184
194
|
private recalculateOrderPricesFromSmartPricing;
|
|
185
195
|
/**
|
|
186
196
|
* DataVariant 重算价格后,同步刷新订单展示、Rules 与 Summary 共用的价格口径。
|