@pisell/pisellos 2.1.169 → 2.1.170

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.
@@ -56,18 +56,46 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
56
56
  }, {
57
57
  key: "resolveProducts",
58
58
  value: function resolveProducts(businessData) {
59
- var _this = this;
59
+ var _this = this,
60
+ _businessData$debugLo;
60
61
  var strategyConfigs = businessData.strategyConfigs ? this.normalizeStrategyConfigs(businessData.strategyConfigs) : this.strategyConfigs;
61
62
  var menuScopeMap = this.buildMenuScopeMap(businessData.menuList || []);
62
63
  var scheduleTimePoints = this.buildScheduleTimePoints(strategyConfigs, businessData.scheduleList || []);
63
64
  var _this$buildGlobalEffe = this.buildGlobalEffectiveRuleMap(strategyConfigs, businessData, menuScopeMap),
64
65
  globalEffectiveRuleMap = _this$buildGlobalEffe.globalEffectiveRuleMap,
65
66
  rawResults = _this$buildGlobalEffe.rawResults;
67
+ var productDiagnostics = businessData.debugLog ? [] : undefined;
66
68
  var products = businessData.products.map(function (product) {
67
- var resolvedProduct = _this.resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap);
69
+ var resolvedProduct = _this.resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap, productDiagnostics);
68
70
  // 套餐子商品也可能携带 data_variants,需在同一策略上下文内继续评估并写回 bundle_item。
69
71
  return _this.resolveProductBundleItems(resolvedProduct, businessData, globalEffectiveRuleMap, menuScopeMap);
70
72
  });
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
+ });
71
99
  return {
72
100
  products: products,
73
101
  globalEffectiveRuleMap: globalEffectiveRuleMap,
@@ -219,20 +247,60 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
219
247
  }
220
248
  }, {
221
249
  key: "resolveProduct",
222
- value: function resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap) {
250
+ value: function resolveProduct(product, businessData, globalEffectiveRuleMap, menuScopeMap, diagnostics) {
251
+ var _product$id, _product$price5, _resolvedProduct$pric, _resolvedProduct$_dat, _resolvedProduct$_dat2;
223
252
  var dataVariants = this.getProductDataVariants(product);
224
- if (!dataVariants.length) return product;
253
+ var productId = (_product$id = product === null || product === void 0 ? void 0 : product.id) !== null && _product$id !== void 0 ? _product$id : product === null || product === void 0 ? void 0 : product.product_id;
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
+ }
225
265
  var matchedVariants = [];
266
+ var variantDiagnostics = [];
226
267
  var _iterator5 = _createForOfIteratorHelper(dataVariants),
227
268
  _step5;
228
269
  try {
229
270
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
230
271
  var variant = _step5.value;
231
- var rule = globalEffectiveRuleMap.get(String(variant.data_variant_rule_id));
232
- if (!rule) continue;
233
- if (!this.evaluateProductRules(rule, product, businessData, menuScopeMap)) {
272
+ var ruleId = String(variant.data_variant_rule_id);
273
+ var rule = globalEffectiveRuleMap.get(ruleId);
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
+ });
234
282
  continue;
235
283
  }
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
+ });
236
304
  matchedVariants.push({
237
305
  ruleId: rule.ruleId,
238
306
  priority: rule.priority,
@@ -245,8 +313,27 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
245
313
  } finally {
246
314
  _iterator5.f();
247
315
  }
248
- if (!matchedVariants.length) return product;
249
- return this.mergeMatchedVariants(product, matchedVariants);
316
+ if (!matchedVariants.length) {
317
+ var _product$price3, _product$price4;
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;
250
337
  }
251
338
 
252
339
  /**
@@ -623,11 +710,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
623
710
  }, {
624
711
  key: "isProductInMenuScope",
625
712
  value: function isProductInMenuScope(product, scope) {
626
- var _product$id,
713
+ var _product$id2,
627
714
  _this5 = this;
628
715
  if (scope.isAllProducts) return true;
629
716
  if (!product || _typeof(product) !== 'object') return false;
630
- var productId = this.toNumber((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id);
717
+ var productId = this.toNumber((_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id);
631
718
  var variantId = this.toNumber(product.product_variant_id);
632
719
  var productKey = this.buildProductKey(productId, variantId);
633
720
  var collectionIds = Array.isArray(product.collection_ids) ? product.collection_ids.map(function (id) {
@@ -684,8 +771,8 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
684
771
  key: "normalizeStrategyConfigs",
685
772
  value: function normalizeStrategyConfigs(configs) {
686
773
  return configs.filter(function (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';
774
+ var _config$metadata4;
775
+ return (config === null || config === void 0 || (_config$metadata4 = config.metadata) === null || _config$metadata4 === void 0 ? void 0 : _config$metadata4.type) === 'data_variant';
689
776
  });
690
777
  }
691
778
  }, {
@@ -105,6 +105,7 @@ 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;
108
109
  }
109
110
  /**
110
111
  * 全局预计算后的规则信息。
@@ -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 | 1 | 5 | 4 | 2 | 3 | 6;
313
+ weekNum: 0 | 2 | 1 | 5 | 4 | 3 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -329,7 +329,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
329
329
  count: number;
330
330
  left: number;
331
331
  summaryCount: number;
332
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
332
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
333
333
  }[];
334
334
  /**
335
335
  * 找到多个资源的公共可用时间段
@@ -18,6 +18,7 @@ interface VenueBookingItemRuleRuntimeConfig {
18
18
  custom?: Record<string, any>;
19
19
  }
20
20
  export declare class VenueBookingImpl extends BaseModule implements Module {
21
+ private static readonly PRICING_DEBUG_CACHE_ID;
21
22
  protected defaultName: string;
22
23
  protected defaultVersion: string;
23
24
  isSolution: boolean;
@@ -53,6 +54,14 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
53
54
  private pickErrorMessage;
54
55
  private serializeError;
55
56
  private addVenueBookingLog;
57
+ /**
58
+ * 临时线上排查日志:
59
+ * - 仅对指定页面 cacheId 开启,避免影响其他页面
60
+ * - 不 await,且吞掉日志上报异常,保证日志系统不会阻断登录/商品加载主流程
61
+ */
62
+ private logPricingDiagnostics;
63
+ private isPricingDiagnosticsEnabled;
64
+ private getAvailableWalletIdsForDiagnostics;
56
65
  private logMethodStart;
57
66
  private logMethodSuccess;
58
67
  private logMethodError;