@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.
@@ -61,10 +61,12 @@ function buildDataVariantBusinessData(products, context, scheduleDateTime) {
61
61
  channel: context.channel ?? strategyContext.channel,
62
62
  orderType: context.orderType ?? strategyContext.orderType ?? strategyContext.order_type,
63
63
  businessCode: context.businessCode ?? strategyContext.business_code ?? strategyContext.businessCode,
64
- custom: strategyContext
64
+ custom: strategyContext,
65
+ debugLog: context == null ? void 0 : context.debugLog
65
66
  };
66
67
  }
67
68
  function formatProductsWithDataVariant(products, context, scheduleDateTime) {
69
+ var _a, _b, _c, _d;
68
70
  const evaluator = context.evaluator;
69
71
  if (!evaluator || typeof evaluator.resolveProducts !== "function") {
70
72
  console.warn("[VenueBooking][smartPricing] dataVariantEvaluator 未注入,跳过智能定价格式化");
@@ -72,7 +74,30 @@ function formatProductsWithDataVariant(products, context, scheduleDateTime) {
72
74
  }
73
75
  const resolvedAt = scheduleDateTime || (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
74
76
  const businessData = buildDataVariantBusinessData(products, context, resolvedAt);
77
+ (_a = context.debugLog) == null ? void 0 : _a.call(context, "[VenueBooking][smartPricing] formatProducts input", {
78
+ scheduleDateTime: resolvedAt,
79
+ customerId: businessData.customerId,
80
+ availableWalletIds: businessData.availableWalletIds,
81
+ channel: businessData.channel,
82
+ businessCode: businessData.businessCode,
83
+ orderType: businessData.orderType,
84
+ productCount: products.length,
85
+ products: products.map((product) => ({
86
+ productId: (product == null ? void 0 : product.id) ?? (product == null ? void 0 : product.product_id),
87
+ price: product == null ? void 0 : product.price,
88
+ sellingPrice: product == null ? void 0 : product.selling_price,
89
+ dataVariants: Array.isArray(product == null ? void 0 : product.data_variants) ? product.data_variants.map((variant) => ({
90
+ dataVariantRuleId: variant == null ? void 0 : variant.data_variant_rule_id,
91
+ data: variant == null ? void 0 : variant.data
92
+ })) : []
93
+ }))
94
+ });
75
95
  const result = evaluator.resolveProducts(businessData);
96
+ (_d = context.debugLog) == null ? void 0 : _d.call(context, "[VenueBooking][smartPricing] formatProducts output", {
97
+ scheduleDateTime: resolvedAt,
98
+ effectiveRuleIds: Array.from(((_c = (_b = result == null ? void 0 : result.globalEffectiveRuleMap) == null ? void 0 : _b.keys) == null ? void 0 : _c.call(_b)) || []),
99
+ resultProducts: (result == null ? void 0 : result.products) || []
100
+ });
76
101
  return Array.isArray(result == null ? void 0 : result.products) ? result.products : products;
77
102
  }
78
103
  function buildEvaluationDatetimes(params) {
@@ -115,6 +140,7 @@ function buildSlotStartDatetime(date, label, config) {
115
140
  return (0, import_dayjs.default)(`${slotDate} ${label}`).format("YYYY-MM-DD HH:mm");
116
141
  }
117
142
  function buildSlotPriceMapByScheduleSegments(params) {
143
+ var _a, _b, _c;
118
144
  const { products, productIds, date, timeLabels, config, context } = params;
119
145
  const map = /* @__PURE__ */ new Map();
120
146
  if (!productIds.length || !timeLabels.length)
@@ -127,6 +153,13 @@ function buildSlotPriceMapByScheduleSegments(params) {
127
153
  const scheduleTimePoints = typeof evaluator.buildScheduleTimePoints === "function" ? evaluator.buildScheduleTimePoints(strategyConfigs, context.scheduleList || []) : [];
128
154
  const evalDatetimes = buildEvaluationDatetimes({ date, config, scheduleTimePoints });
129
155
  const priceCache = /* @__PURE__ */ new Map();
156
+ (_a = context.debugLog) == null ? void 0 : _a.call(context, "[VenueBooking][smartPricing] slot price evaluation started", {
157
+ date,
158
+ productIds,
159
+ scheduleTimePoints,
160
+ evalDatetimes,
161
+ timeLabels
162
+ });
130
163
  for (const evalDt of evalDatetimes) {
131
164
  const resolved = formatProductsWithDataVariant(products, context, evalDt);
132
165
  const priceByProductId = /* @__PURE__ */ new Map();
@@ -137,6 +170,14 @@ function buildSlotPriceMapByScheduleSegments(params) {
137
170
  priceByProductId.set(productId, extractProductPrice(product));
138
171
  }
139
172
  priceCache.set(evalDt, priceByProductId);
173
+ (_b = context.debugLog) == null ? void 0 : _b.call(context, "[VenueBooking][smartPricing] slot segment prices resolved", {
174
+ date,
175
+ evalDatetime: evalDt,
176
+ prices: productIds.map((productId) => ({
177
+ productId,
178
+ price: priceByProductId.get(productId) ?? null
179
+ }))
180
+ });
140
181
  }
141
182
  for (const label of timeLabels) {
142
183
  const slotStart = buildSlotStartDatetime(date, label, config);
@@ -150,6 +191,10 @@ function buildSlotPriceMapByScheduleSegments(params) {
150
191
  }
151
192
  }
152
193
  }
194
+ (_c = context.debugLog) == null ? void 0 : _c.call(context, "[VenueBooking][smartPricing] slot price map completed", {
195
+ date,
196
+ entries: Array.from(map.entries()).map(([key, price]) => ({ key, price }))
197
+ });
153
198
  return map;
154
199
  }
155
200
  function getPriceForProductAtDatetime(params) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.169",
4
+ "version": "2.1.170",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",