@pisell/pisellos 2.1.169 → 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.
@@ -214,6 +214,95 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
214
214
  }
215
215
  return addVenueBookingLog;
216
216
  }()
217
+ /**
218
+ * 临时线上排查日志:
219
+ * - 仅对指定页面 cacheId 开启,避免影响其他页面
220
+ * - 不 await,且吞掉日志上报异常,保证日志系统不会阻断登录/商品加载主流程
221
+ */
222
+ }, {
223
+ key: "logPricingDiagnostics",
224
+ value: function logPricingDiagnostics(title) {
225
+ var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
226
+ if (!this.isPricingDiagnosticsEnabled()) return;
227
+ void this.addVenueBookingLog({
228
+ level: 'info',
229
+ title: title,
230
+ payload: payload
231
+ }).catch(function (error) {
232
+ console.warn('[VenueBooking] pricing diagnostic log failed', error);
233
+ });
234
+ }
235
+ }, {
236
+ key: "isPricingDiagnosticsEnabled",
237
+ value: function isPricingDiagnosticsEnabled() {
238
+ return String(this.cacheId || '') === VenueBookingImpl.PRICING_DEBUG_CACHE_ID;
239
+ }
240
+ }, {
241
+ key: "getAvailableWalletIdsForDiagnostics",
242
+ value: function getAvailableWalletIdsForDiagnostics() {
243
+ try {
244
+ var _this$store$order, _this$store$order$get;
245
+ return (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getAvailableWalletIds) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
246
+ } catch (error) {
247
+ return {
248
+ readFailed: true,
249
+ error: this.serializeError(error)
250
+ };
251
+ }
252
+ }
253
+ }, {
254
+ key: "getOrderPricingSnapshotForDiagnostics",
255
+ value: function getOrderPricingSnapshotForDiagnostics() {
256
+ try {
257
+ var _this$store$order2;
258
+ var products = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2 = _this$store$order2.getTempOrder()) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.products;
259
+ if (!Array.isArray(products)) return [];
260
+ return products.map(function (product) {
261
+ var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5, _product$metadata6;
262
+ return {
263
+ productId: product === null || product === void 0 ? void 0 : product.product_id,
264
+ resourceId: product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.resource_id,
265
+ isVenueBooking: !!(product !== null && product !== void 0 && (_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking),
266
+ sellingPrice: product === null || product === void 0 ? void 0 : product.selling_price,
267
+ originalPrice: product === null || product === void 0 ? void 0 : product.original_price,
268
+ sourceProductPrice: product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price,
269
+ mainProductOriginalPrice: product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price,
270
+ mainProductSellingPrice: product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_selling_price,
271
+ priceBreakdown: product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.price_breakdown,
272
+ discountList: product === null || product === void 0 ? void 0 : product.discount_list
273
+ };
274
+ });
275
+ } catch (error) {
276
+ return [{
277
+ readFailed: true,
278
+ error: this.serializeError(error)
279
+ }];
280
+ }
281
+ }
282
+ }, {
283
+ key: "getCatalogPricingSnapshotForDiagnostics",
284
+ value: function getCatalogPricingSnapshotForDiagnostics() {
285
+ var orderProductIds = new Set(this.getOrderPricingSnapshotForDiagnostics().map(function (product) {
286
+ return Number(product.productId);
287
+ }).filter(function (productId) {
288
+ return Number.isFinite(productId);
289
+ }));
290
+ return this.getAllProductsForSmartPricing().filter(function (product) {
291
+ return orderProductIds.has(Number(product === null || product === void 0 ? void 0 : product.id));
292
+ }).map(function (product) {
293
+ return {
294
+ productId: product === null || product === void 0 ? void 0 : product.id,
295
+ price: product === null || product === void 0 ? void 0 : product.price,
296
+ sellingPrice: product === null || product === void 0 ? void 0 : product.selling_price,
297
+ dataVariants: Array.isArray(product === null || product === void 0 ? void 0 : product.data_variants) ? product.data_variants.map(function (variant) {
298
+ return {
299
+ ruleId: variant === null || variant === void 0 ? void 0 : variant.data_variant_rule_id,
300
+ data: variant === null || variant === void 0 ? void 0 : variant.data
301
+ };
302
+ }) : []
303
+ };
304
+ });
305
+ }
217
306
  }, {
218
307
  key: "logMethodStart",
219
308
  value: function logMethodStart(method) {
@@ -368,7 +457,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
368
457
  value: function () {
369
458
  var _refreshOrderMarketingAfterLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
370
459
  var _this3 = this;
371
- var refreshTask;
460
+ var pricingDiagnosticsEnabled, refreshTask;
372
461
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
373
462
  while (1) switch (_context5.prev = _context5.next) {
374
463
  case 0:
@@ -378,86 +467,226 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
378
467
  }
379
468
  throw new Error('order 模块未初始化');
380
469
  case 2:
470
+ pricingDiagnosticsEnabled = this.isPricingDiagnosticsEnabled();
471
+ if (pricingDiagnosticsEnabled) {
472
+ this.logPricingDiagnostics('[VenueBooking] refreshOrderMarketingAfterLogin entered', {
473
+ customerId: params.customerId,
474
+ hasCustomerLoginRefreshInFlight: !!this.customerLoginRefreshInFlight,
475
+ customerLoginRefreshIdInFlight: this.customerLoginRefreshIdInFlight,
476
+ hasLoadAllProductsInFlight: !!this.loadAllProductsInFlight,
477
+ productsLoaded: this.productsLoaded,
478
+ smartPricingProductCatalogCount: this.smartPricingProductCatalog.length,
479
+ note: 'This login refresh reloads products with the confirmed customer context before recalculation'
480
+ });
481
+ }
381
482
  if (!this.customerLoginRefreshInFlight) {
382
- _context5.next = 9;
483
+ _context5.next = 11;
383
484
  break;
384
485
  }
385
486
  if (!(this.customerLoginRefreshIdInFlight === params.customerId)) {
386
- _context5.next = 7;
487
+ _context5.next = 9;
387
488
  break;
388
489
  }
389
- _context5.next = 6;
490
+ _context5.next = 8;
390
491
  return this.customerLoginRefreshInFlight;
391
- case 6:
492
+ case 8:
392
493
  return _context5.abrupt("return");
393
- case 7:
394
- _context5.next = 9;
395
- return this.customerLoginRefreshInFlight;
396
494
  case 9:
495
+ _context5.next = 11;
496
+ return this.customerLoginRefreshInFlight;
497
+ case 11:
397
498
  this.customerLoginRefreshIdInFlight = params.customerId;
398
499
  refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
399
500
  var _this3$core, _this3$core$emit;
501
+ var productsLoadBeforeLogin, loginProducts, _smartPricingContext$, _smartPricingContext$2, _smartPricingContext$3, _smartPricingContext$4, _this3$smartPricingPr, smartPricingContext, strategyConfigs, _getTempOrder;
400
502
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
401
503
  while (1) switch (_context4.prev = _context4.next) {
402
504
  case 0:
403
505
  // 用户插件可能晚于登录 effect 更新;以已确认的登录 payload 作为本次及后续网格算价的身份来源。
404
506
  _this3.smartPricingCustomerId = params.customerId;
405
- _context4.next = 3;
507
+ if (pricingDiagnosticsEnabled) {
508
+ _this3.logPricingDiagnostics('[VenueBooking] login pricing customer context set', {
509
+ customerId: params.customerId,
510
+ userPluginCustomerId: _this3.resolveCustomerIdForSmartPricing(),
511
+ availableWalletIdsBeforeDiscountConfig: _this3.getAvailableWalletIdsForDiagnostics(),
512
+ orderProductsBeforeDiscountConfig: _this3.getOrderPricingSnapshotForDiagnostics()
513
+ });
514
+ }
515
+ _context4.next = 4;
406
516
  return _this3.store.order.loadDiscountConfig({
407
517
  customerId: params.customerId
408
518
  });
409
- case 3:
519
+ case 4:
520
+ if (!pricingDiagnosticsEnabled) {
521
+ _context4.next = 21;
522
+ break;
523
+ }
524
+ // 仅对指定排查页面处理登录早于匿名商品请求完成的竞态。
525
+ productsLoadBeforeLogin = _this3.loadAllProductsInFlight;
526
+ if (!productsLoadBeforeLogin) {
527
+ _context4.next = 16;
528
+ break;
529
+ }
530
+ _this3.logPricingDiagnostics('[VenueBooking] login waiting for previous product load', {
531
+ customerId: params.customerId
532
+ });
533
+ _context4.prev = 8;
534
+ _context4.next = 11;
535
+ return productsLoadBeforeLogin;
536
+ case 11:
537
+ _context4.next = 16;
538
+ break;
539
+ case 13:
540
+ _context4.prev = 13;
541
+ _context4.t0 = _context4["catch"](8);
542
+ _this3.logPricingDiagnostics('[VenueBooking] previous product load failed before login reload', {
543
+ customerId: params.customerId,
544
+ error: _this3.serializeError(_context4.t0)
545
+ });
546
+ case 16:
547
+ _this3.logPricingDiagnostics('[VenueBooking] login product reload starting', {
548
+ customerId: params.customerId,
549
+ productsLoadedBeforeReload: _this3.productsLoaded,
550
+ catalogCountBeforeReload: _this3.smartPricingProductCatalog.length,
551
+ availableWalletIds: _this3.getAvailableWalletIdsForDiagnostics()
552
+ });
553
+ _context4.next = 19;
554
+ return _this3.loadAllProducts();
555
+ case 19:
556
+ loginProducts = _context4.sent;
557
+ _this3.logPricingDiagnostics('[VenueBooking] login product reload completed', {
558
+ customerId: params.customerId,
559
+ venueProductCount: loginProducts.venueProducts.length,
560
+ addonProductCount: loginProducts.addonProducts.length,
561
+ catalogCountAfterReload: _this3.smartPricingProductCatalog.length,
562
+ resourceProductMapSize: _this3.resourceProductMap.size
563
+ });
564
+ case 21:
565
+ if (pricingDiagnosticsEnabled) {
566
+ smartPricingContext = _this3.buildSmartPricingContext();
567
+ strategyConfigs = ((_smartPricingContext$ = smartPricingContext.evaluator) === null || _smartPricingContext$ === void 0 || (_smartPricingContext$2 = _smartPricingContext$.getStrategyConfigs) === null || _smartPricingContext$2 === void 0 ? void 0 : _smartPricingContext$2.call(_smartPricingContext$)) || [];
568
+ _this3.logPricingDiagnostics('[VenueBooking] login discount config loaded', {
569
+ customerId: params.customerId,
570
+ availableWalletIdsAfterDiscountConfig: _this3.getAvailableWalletIdsForDiagnostics(),
571
+ discountList: _this3.store.order.getDiscountList(),
572
+ smartPricingContext: {
573
+ customerId: smartPricingContext.customerId,
574
+ availableWalletIds: smartPricingContext.availableWalletIds,
575
+ channel: smartPricingContext.channel,
576
+ businessCode: smartPricingContext.businessCode,
577
+ orderType: smartPricingContext.orderType,
578
+ scheduleCount: ((_smartPricingContext$3 = smartPricingContext.scheduleList) === null || _smartPricingContext$3 === void 0 ? void 0 : _smartPricingContext$3.length) || 0,
579
+ menuCount: ((_smartPricingContext$4 = smartPricingContext.menuList) === null || _smartPricingContext$4 === void 0 ? void 0 : _smartPricingContext$4.length) || 0,
580
+ hasEvaluator: !!smartPricingContext.evaluator
581
+ },
582
+ strategyConfigs: strategyConfigs.map(function (config) {
583
+ var _config$metadata, _config$metadata2, _config$metadata3, _config$metadata4;
584
+ return {
585
+ ruleId: config === null || config === void 0 || (_config$metadata = config.metadata) === null || _config$metadata === void 0 ? void 0 : _config$metadata.id,
586
+ name: config === null || config === void 0 || (_config$metadata2 = config.metadata) === null || _config$metadata2 === void 0 ? void 0 : _config$metadata2.name,
587
+ 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,
588
+ priority: config === null || config === void 0 || (_config$metadata4 = config.metadata) === null || _config$metadata4 === void 0 || (_config$metadata4 = _config$metadata4.custom) === null || _config$metadata4 === void 0 ? void 0 : _config$metadata4.priority,
589
+ conditions: config === null || config === void 0 ? void 0 : config.conditions
590
+ };
591
+ }),
592
+ productsLoaded: _this3.productsLoaded,
593
+ smartPricingProductCatalogCount: (_this3$smartPricingPr = _this3.smartPricingProductCatalog) === null || _this3$smartPricingPr === void 0 ? void 0 : _this3$smartPricingPr.length,
594
+ resourceProductMapSize: _this3.resourceProductMap.size,
595
+ matchingCatalogProducts: _this3.getCatalogPricingSnapshotForDiagnostics()
596
+ });
597
+ }
410
598
  _this3.clearSlotPriceMapCache();
599
+ if (pricingDiagnosticsEnabled) {
600
+ _this3.logPricingDiagnostics('[VenueBooking] login smart pricing recalculation starting', {
601
+ slotPriceMapCacheSizeAfterClear: _this3.slotPriceMapCache.size,
602
+ orderProductsBeforeRecalculation: _this3.getOrderPricingSnapshotForDiagnostics()
603
+ });
604
+ }
411
605
  _this3.recalculateOrderPricesFromSmartPricing();
606
+ if (pricingDiagnosticsEnabled) {
607
+ _this3.logPricingDiagnostics('[VenueBooking] login smart pricing recalculation completed', {
608
+ orderProductsAfterRecalculation: _this3.getOrderPricingSnapshotForDiagnostics()
609
+ });
610
+ }
611
+
412
612
  // loadDiscountConfig 会按登录前的订单价格预计算一次券;智能价更新后必须用新的
413
613
  // source/main 价格字段重新套券,否则购物车行价与 Summary 会使用两套基数。
414
614
  _this3.store.order.applyDiscount();
415
615
  _this3.normalizeDiscountedOrderPrices(_this3.store.order.getDiscountList());
416
- _context4.next = 9;
616
+ if (pricingDiagnosticsEnabled) {
617
+ _this3.logPricingDiagnostics('[VenueBooking] login discounts reapplied', {
618
+ discountList: _this3.store.order.getDiscountList(),
619
+ orderProductsAfterDiscount: _this3.getOrderPricingSnapshotForDiagnostics()
620
+ });
621
+ }
622
+ _context4.next = 31;
417
623
  return _this3.store.order.recalculateSummary({
418
624
  createIfMissing: true
419
625
  });
420
- case 9:
626
+ case 31:
421
627
  _this3.store.order.persistTempOrder();
422
- _context4.next = 12;
628
+ if (pricingDiagnosticsEnabled) {
629
+ _this3.logPricingDiagnostics('[VenueBooking] login pricing summary persisted', {
630
+ summary: (_getTempOrder = _this3.store.order.getTempOrder()) === null || _getTempOrder === void 0 ? void 0 : _getTempOrder.summary,
631
+ orderProducts: _this3.getOrderPricingSnapshotForDiagnostics()
632
+ });
633
+ }
634
+ _context4.next = 35;
423
635
  return _this3.refreshItemRuleQuantityLimits();
424
- case 12:
425
- _context4.next = 14;
636
+ case 35:
637
+ _context4.next = 37;
426
638
  return _this3.refreshCartValidationPassed();
427
- case 14:
428
- _context4.next = 16;
639
+ case 37:
640
+ _context4.next = 39;
429
641
  return (_this3$core = _this3.core) === null || _this3$core === void 0 || (_this3$core = _this3$core.effects) === null || _this3$core === void 0 || (_this3$core$emit = _this3$core.emit) === null || _this3$core$emit === void 0 ? void 0 : _this3$core$emit.call(_this3$core, VenueBookingHooks.onSmartPricingUpdated, {
430
642
  customerId: params.customerId
431
643
  });
432
- case 16:
644
+ case 39:
645
+ if (pricingDiagnosticsEnabled) {
646
+ _this3.logPricingDiagnostics('[VenueBooking] login smart pricing update emitted', {
647
+ customerId: params.customerId,
648
+ cartValidation: _this3.store.cartValidation
649
+ });
650
+ }
651
+ case 40:
433
652
  case "end":
434
653
  return _context4.stop();
435
654
  }
436
- }, _callee4);
655
+ }, _callee4, null, [[8, 13]]);
437
656
  }))();
438
657
  this.customerLoginRefreshInFlight = refreshTask;
439
- _context5.prev = 12;
440
- _context5.next = 15;
658
+ _context5.prev = 14;
659
+ _context5.next = 17;
441
660
  return refreshTask;
442
- case 15:
443
- _context5.next = 20;
444
- break;
445
661
  case 17:
446
- _context5.prev = 17;
447
- _context5.t0 = _context5["catch"](12);
662
+ _context5.next = 23;
663
+ break;
664
+ case 19:
665
+ _context5.prev = 19;
666
+ _context5.t0 = _context5["catch"](14);
667
+ if (pricingDiagnosticsEnabled) {
668
+ this.logPricingDiagnostics('[VenueBooking] login smart pricing refresh failed', {
669
+ customerId: params.customerId,
670
+ error: this.serializeError(_context5.t0),
671
+ productsLoaded: this.productsLoaded,
672
+ smartPricingProductCatalogCount: this.smartPricingProductCatalog.length,
673
+ resourceProductMapSize: this.resourceProductMap.size,
674
+ orderProducts: this.getOrderPricingSnapshotForDiagnostics()
675
+ });
676
+ }
448
677
  throw _context5.t0;
449
- case 20:
450
- _context5.prev = 20;
678
+ case 23:
679
+ _context5.prev = 23;
451
680
  if (this.customerLoginRefreshInFlight === refreshTask) {
452
681
  this.customerLoginRefreshInFlight = null;
453
682
  this.customerLoginRefreshIdInFlight = null;
454
683
  }
455
- return _context5.finish(20);
456
- case 23:
684
+ return _context5.finish(23);
685
+ case 26:
457
686
  case "end":
458
687
  return _context5.stop();
459
688
  }
460
- }, _callee5, this, [[12, 17, 20, 23]]);
689
+ }, _callee5, this, [[14, 19, 23, 26]]);
461
690
  }));
462
691
  function refreshOrderMarketingAfterLogin(_x4) {
463
692
  return _refreshOrderMarketingAfterLogin.apply(this, arguments);
@@ -484,8 +713,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
484
713
  scheduleModule,
485
714
  quotationModule,
486
715
  openDataModule,
487
- _this$store$order,
488
- _this$store$order2,
716
+ _this$store$order3,
717
+ _this$store$order4,
489
718
  _args6 = arguments;
490
719
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
491
720
  while (1) switch (_context6.prev = _context6.next) {
@@ -627,11 +856,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
627
856
  console.log('[VenueBooking] 初始化开始');
628
857
  _context6.prev = 51;
629
858
  _context6.next = 54;
630
- return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
859
+ return (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.recalculateSummary({
631
860
  createIfMissing: false
632
861
  });
633
862
  case 54:
634
- (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
863
+ (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
635
864
  _context6.next = 57;
636
865
  return this.loadRuntimeConfigs();
637
866
  case 57:
@@ -836,8 +1065,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
836
1065
  }, {
837
1066
  key: "resolveAvailableWalletIdsForSmartPricing",
838
1067
  value: function resolveAvailableWalletIdsForSmartPricing() {
839
- var _this$store$order3, _this$store$order3$ge, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
840
- var orderWalletIds = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getAvailableWalletIds) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
1068
+ var _this$store$order5, _this$store$order5$ge, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
1069
+ var orderWalletIds = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getAvailableWalletIds) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.call(_this$store$order5);
841
1070
  var fallbackWalletIds = ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.available_wallet_ids) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.availableWalletIds) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.strategy_context) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.available_wallet_ids) || ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9 = _this$otherParams9.strategy_context) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.availableWalletIds);
842
1071
  var source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
843
1072
  if (!Array.isArray(source)) return [];
@@ -1474,8 +1703,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1474
1703
  }, {
1475
1704
  key: "getSelectedSlotsForResource",
1476
1705
  value: function getSelectedSlotsForResource(resourceId, productId) {
1477
- var _this$store$order4;
1478
- var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
1706
+ var _this$store$order6;
1707
+ var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
1479
1708
  if (!tempOrder) return [];
1480
1709
  var venueProducts = tempOrder.products.filter(function (p) {
1481
1710
  var _p$metadata, _p$metadata2;
@@ -1636,9 +1865,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1636
1865
  }, {
1637
1866
  key: "getAllSelectedSlots",
1638
1867
  value: function getAllSelectedSlots() {
1639
- var _this$store$order5;
1868
+ var _this$store$order7;
1640
1869
  var result = new Map();
1641
- var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
1870
+ var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
1642
1871
  if (!tempOrder) return result;
1643
1872
  var venueProducts = tempOrder.products.filter(function (p) {
1644
1873
  var _p$metadata3;
@@ -1649,9 +1878,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1649
1878
  _step9;
1650
1879
  try {
1651
1880
  var _loop2 = function _loop2() {
1652
- var _product$metadata;
1881
+ var _product$metadata7;
1653
1882
  var product = _step9.value;
1654
- var resourceId = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.resource_id;
1883
+ var resourceId = (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.resource_id;
1655
1884
  if (resourceId == null) return 1; // continue
1656
1885
  var productId = Number(product.product_id);
1657
1886
  var existing = result.get(resourceId) || [];
@@ -1971,8 +2200,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1971
2200
  }, {
1972
2201
  key: "getTempOrder",
1973
2202
  value: function getTempOrder() {
1974
- var _this$store$order6;
1975
- var result = ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder()) || null;
2203
+ var _this$store$order8;
2204
+ var result = ((_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 ? void 0 : _this$store$order8.getTempOrder()) || null;
1976
2205
  return result;
1977
2206
  }
1978
2207
  }, {
@@ -2030,30 +2259,69 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2030
2259
  }
2031
2260
  return onCustomerLogin;
2032
2261
  }()
2262
+ /**
2263
+ * 接收 pisell2 VenueBooking 登录链路诊断日志。
2264
+ * 实际是否上报仍由 OS 内部 cacheId 白名单统一控制。
2265
+ */
2266
+ }, {
2267
+ key: "logPricingDiagnosticsFromClient",
2268
+ value: function logPricingDiagnosticsFromClient(params) {
2269
+ this.logPricingDiagnostics("[VenueBooking][pisell2] ".concat(String((params === null || params === void 0 ? void 0 : params.title) || 'diagnostic')), (params === null || params === void 0 ? void 0 : params.payload) || {});
2270
+ }
2033
2271
  }, {
2034
2272
  key: "recalculateOrderPricesFromSmartPricing",
2035
2273
  value: function recalculateOrderPricesFromSmartPricing() {
2036
2274
  var _tempOrder$products,
2037
2275
  _this9 = this;
2038
- if (!this.store.order) return;
2276
+ if (!this.store.order) {
2277
+ this.logPricingDiagnostics('[VenueBooking] order smart pricing recalculation skipped', {
2278
+ reason: 'order module is missing'
2279
+ });
2280
+ return;
2281
+ }
2039
2282
  var tempOrder = this.store.order.getTempOrder();
2040
- if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
2283
+ if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) {
2284
+ this.logPricingDiagnostics('[VenueBooking] order smart pricing recalculation skipped', {
2285
+ reason: 'temp order has no products'
2286
+ });
2287
+ return;
2288
+ }
2041
2289
  var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
2042
2290
  var catalog = this.getAllProductsForSmartPricing();
2043
2291
  var context = this.buildSmartPricingContext();
2292
+ var productDiagnostics = this.isPricingDiagnosticsEnabled() ? [] : null;
2044
2293
  var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
2045
2294
  _step12;
2046
2295
  try {
2047
2296
  var _loop4 = function _loop4() {
2048
- var _product$metadata2;
2297
+ var _product$metadata8;
2049
2298
  var product = _step12.value;
2050
- if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
2299
+ if ((_product$metadata8 = product.metadata) !== null && _product$metadata8 !== void 0 && _product$metadata8.venue_booking) {
2051
2300
  var mappings = _this9.resourceProductMap.get(product.metadata.resource_id);
2052
- if (!mappings || !mappings.length) return 0; // continue
2301
+ if (!mappings || !mappings.length) {
2302
+ productDiagnostics === null || productDiagnostics === void 0 || productDiagnostics.push({
2303
+ productId: product.product_id,
2304
+ resourceId: product.metadata.resource_id,
2305
+ originalSellingPrice: product.selling_price,
2306
+ result: 'skipped',
2307
+ reason: 'resourceProductMap has no mapping for resource'
2308
+ });
2309
+ return 0; // continue
2310
+ }
2053
2311
  var mapping = mappings.find(function (m) {
2054
2312
  return Number(m.productId) === Number(product.product_id);
2055
2313
  }) || mappings[0];
2056
- if (!mapping) return 0; // continue
2314
+ if (!mapping) {
2315
+ productDiagnostics === null || productDiagnostics === void 0 || productDiagnostics.push({
2316
+ productId: product.product_id,
2317
+ resourceId: product.metadata.resource_id,
2318
+ originalSellingPrice: product.selling_price,
2319
+ result: 'skipped',
2320
+ reason: 'no product mapping selected',
2321
+ mappings: mappings
2322
+ });
2323
+ return 0; // continue
2324
+ }
2057
2325
  var slots = expandMergedSlotToIndividual(product, _this9.store.slotConfig.slotDurationMinutes);
2058
2326
  var uniqueDates = _toConsumableArray(new Set(slots.map(function (slot) {
2059
2327
  return dayjs(slot.startTime).format('YYYY-MM-DD');
@@ -2086,6 +2354,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2086
2354
  });
2087
2355
  var merged = mergeConsecutiveSlots(updatedSlots);
2088
2356
  if (merged.length === 1) {
2357
+ var previousSellingPrice = product === null || product === void 0 ? void 0 : product.selling_price;
2089
2358
  _this9.resetProductPriceForSmartPricing({
2090
2359
  product: product,
2091
2360
  price: merged[0].totalPrice,
@@ -2094,8 +2363,42 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2094
2363
  productId: mapping.productId
2095
2364
  })
2096
2365
  });
2366
+ productDiagnostics === null || productDiagnostics === void 0 || productDiagnostics.push({
2367
+ productId: product.product_id,
2368
+ resourceId: product.metadata.resource_id,
2369
+ result: 'price reset',
2370
+ previousSellingPrice: previousSellingPrice,
2371
+ finalSellingPrice: product.selling_price,
2372
+ mapping: mapping,
2373
+ slots: updatedSlots,
2374
+ merged: merged,
2375
+ slotPriceMaps: Array.from(slotPriceMaps.entries()).map(function (_ref3) {
2376
+ var _ref4 = _slicedToArray(_ref3, 2),
2377
+ date = _ref4[0],
2378
+ priceMap = _ref4[1];
2379
+ return {
2380
+ date: date,
2381
+ entries: Array.from(priceMap.entries())
2382
+ };
2383
+ })
2384
+ });
2385
+ } else {
2386
+ productDiagnostics === null || productDiagnostics === void 0 || productDiagnostics.push({
2387
+ productId: product.product_id,
2388
+ resourceId: product.metadata.resource_id,
2389
+ originalSellingPrice: product.selling_price,
2390
+ result: 'skipped',
2391
+ reason: 'expanded slots did not merge into exactly one group',
2392
+ mapping: mapping,
2393
+ slots: updatedSlots,
2394
+ merged: merged
2395
+ });
2097
2396
  }
2098
2397
  } else if (product.product_id != null) {
2398
+ var catalogProduct = productDiagnostics ? catalog === null || catalog === void 0 ? void 0 : catalog.find(function (item) {
2399
+ return Number(item === null || item === void 0 ? void 0 : item.id) === Number(product === null || product === void 0 ? void 0 : product.product_id);
2400
+ }) : undefined;
2401
+ var _previousSellingPrice = product === null || product === void 0 ? void 0 : product.selling_price;
2099
2402
  var smartPrice = getPriceForProductAtDatetime({
2100
2403
  products: catalog,
2101
2404
  context: context,
@@ -2107,6 +2410,25 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2107
2410
  product: product,
2108
2411
  price: smartPrice
2109
2412
  });
2413
+ productDiagnostics === null || productDiagnostics === void 0 || productDiagnostics.push({
2414
+ productId: product.product_id,
2415
+ result: 'price reset',
2416
+ previousSellingPrice: _previousSellingPrice,
2417
+ resolvedSmartPrice: smartPrice,
2418
+ finalSellingPrice: product.selling_price,
2419
+ catalogProduct: catalogProduct ? {
2420
+ price: catalogProduct.price,
2421
+ sellingPrice: catalogProduct.selling_price,
2422
+ dataVariants: catalogProduct.data_variants
2423
+ } : null
2424
+ });
2425
+ } else {
2426
+ productDiagnostics === null || productDiagnostics === void 0 || productDiagnostics.push({
2427
+ productId: product.product_id,
2428
+ originalSellingPrice: product.selling_price,
2429
+ result: 'skipped',
2430
+ reason: 'product_id is missing'
2431
+ });
2110
2432
  }
2111
2433
  },
2112
2434
  _ret;
@@ -2119,6 +2441,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2119
2441
  } finally {
2120
2442
  _iterator12.f();
2121
2443
  }
2444
+ if (productDiagnostics) {
2445
+ this.logPricingDiagnostics('[VenueBooking] order smart pricing recalculation detail', {
2446
+ now: now,
2447
+ context: {
2448
+ customerId: context.customerId,
2449
+ availableWalletIds: context.availableWalletIds,
2450
+ channel: context.channel,
2451
+ businessCode: context.businessCode,
2452
+ orderType: context.orderType,
2453
+ hasEvaluator: !!context.evaluator
2454
+ },
2455
+ catalogCount: catalog.length,
2456
+ resourceProductMapSize: this.resourceProductMap.size,
2457
+ productDiagnostics: productDiagnostics
2458
+ });
2459
+ }
2122
2460
  }
2123
2461
 
2124
2462
  /**
@@ -2209,7 +2547,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2209
2547
  key: "setDiscountSelected",
2210
2548
  value: (function () {
2211
2549
  var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2212
- var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator14, _step14, d, afterApplyTarget, finalSummary, finalProduct, finalTarget;
2550
+ var _tempOrder$holder, _this$store$order$get2, _this$store$order$get3, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator14, _step14, d, afterApplyTarget, finalSummary, finalProduct, finalTarget;
2213
2551
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2214
2552
  while (1) switch (_context21.prev = _context21.next) {
2215
2553
  case 0:
@@ -2302,8 +2640,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2302
2640
  });
2303
2641
  case 25:
2304
2642
  this.store.order.persistTempOrder();
2305
- finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
2306
- finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
2643
+ finalSummary = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null;
2644
+ finalProduct = ((_this$store$order$get3 = this.store.order.getTempOrder()) === null || _this$store$order$get3 === void 0 || (_this$store$order$get3 = _this$store$order$get3.products) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3[0]) || null;
2307
2645
  this.logMethodSuccess('setDiscountSelected', params);
2308
2646
  finalTarget = this.store.order.getDiscountList().find(function (d) {
2309
2647
  return d.id === params.discountId;
@@ -2568,7 +2906,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2568
2906
  key: "addProductToOrder",
2569
2907
  value: function () {
2570
2908
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(product) {
2571
- var _product$metadata3, _product$metadata4, smartPrice, products;
2909
+ var _product$metadata9, _product$metadata10, smartPrice, products;
2572
2910
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2573
2911
  while (1) switch (_context26.prev = _context26.next) {
2574
2912
  case 0:
@@ -2583,7 +2921,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2583
2921
  }
2584
2922
  throw new Error('order 模块未初始化');
2585
2923
  case 4:
2586
- if (!((_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.venue_booking) && product.product_id != null) {
2924
+ if (!((_product$metadata9 = product.metadata) !== null && _product$metadata9 !== void 0 && _product$metadata9.venue_booking) && product.product_id != null) {
2587
2925
  smartPrice = getPriceForProductAtDatetime({
2588
2926
  products: this.getAllProductsForSmartPricing(),
2589
2927
  context: this.buildSmartPricingContext(),
@@ -2593,7 +2931,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2593
2931
  });
2594
2932
  product.selling_price = smartPrice;
2595
2933
  product.original_price = smartPrice;
2596
- } else if (product.selling_price != null && !((_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 && _product$metadata4.venue_booking)) {
2934
+ } else if (product.selling_price != null && !((_product$metadata10 = product.metadata) !== null && _product$metadata10 !== void 0 && _product$metadata10.venue_booking)) {
2597
2935
  product.original_price = product.selling_price;
2598
2936
  }
2599
2937
  _context26.next = 7;
@@ -2679,7 +3017,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2679
3017
  key: "removeProductFromOrder",
2680
3018
  value: function () {
2681
3019
  var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
2682
- var _this$store$order$get3, _this$store$order7, _this$store$order$ens, _this$store$order8, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator16, _step16, _product$metadata5, _product$metadata6, product, beforeBookingCount, _this$store$order$per, _this$store$order9;
3020
+ var _this$store$order$get4, _this$store$order9, _this$store$order$ens, _this$store$order10, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator16, _step16, _product$metadata11, _product$metadata12, product, beforeBookingCount, _this$store$order$per, _this$store$order11;
2683
3021
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2684
3022
  while (1) switch (_context28.prev = _context28.next) {
2685
3023
  case 0:
@@ -2694,7 +3032,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2694
3032
  }
2695
3033
  throw new Error('order 模块未初始化');
2696
3034
  case 4:
2697
- tempOrder = ((_this$store$order$get3 = (_this$store$order7 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order7)) || ((_this$store$order$ens = (_this$store$order8 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order8));
3035
+ tempOrder = ((_this$store$order$get4 = (_this$store$order9 = this.store.order).getTempOrder) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order9)) || ((_this$store$order$ens = (_this$store$order10 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order10));
2698
3036
  _context28.next = 7;
2699
3037
  return this.store.order.removeProductFromOrder(identity);
2700
3038
  case 7:
@@ -2714,14 +3052,14 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2714
3052
  break;
2715
3053
  }
2716
3054
  product = _step16.value;
2717
- if (product !== null && product !== void 0 && (_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) {
3055
+ if (product !== null && product !== void 0 && (_product$metadata11 = product.metadata) !== null && _product$metadata11 !== void 0 && _product$metadata11.venue_booking) {
2718
3056
  _context28.next = 18;
2719
3057
  break;
2720
3058
  }
2721
3059
  return _context28.abrupt("continue", 20);
2722
3060
  case 18:
2723
3061
  if (product.identity_key) venueProductUids.add(String(product.identity_key));
2724
- if ((_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.booking_uid) {
3062
+ if ((_product$metadata12 = product.metadata) !== null && _product$metadata12 !== void 0 && _product$metadata12.booking_uid) {
2725
3063
  venueBookingUids.add(String(product.metadata.booking_uid));
2726
3064
  }
2727
3065
  case 20:
@@ -2751,7 +3089,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2751
3089
  return true;
2752
3090
  });
2753
3091
  if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
2754
- (_this$store$order$per = (_this$store$order9 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order9);
3092
+ (_this$store$order$per = (_this$store$order11 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order11);
2755
3093
  }
2756
3094
  case 33:
2757
3095
  _context28.next = 35;
@@ -3002,8 +3340,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3002
3340
  var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
3003
3341
  var productId = Number(rawProductId);
3004
3342
  if (Number.isFinite(productId) && productId > 0) {
3005
- var _ref3, _node$product_variant;
3006
- var productVariantId = Number((_ref3 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref3 !== void 0 ? _ref3 : 0);
3343
+ var _ref5, _node$product_variant;
3344
+ var productVariantId = Number((_ref5 = (_node$product_variant = node.product_variant_id) !== null && _node$product_variant !== void 0 ? _node$product_variant : node.variant_id) !== null && _ref5 !== void 0 ? _ref5 : 0);
3007
3345
  var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
3008
3346
  var key = buildProductKey(productId, normalizedVariantId);
3009
3347
  if (!sourceMap.has(key)) sourceMap.set(key, node);
@@ -3620,14 +3958,14 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3620
3958
  key: "setOtherParams",
3621
3959
  value: function () {
3622
3960
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3623
- var _ref5,
3624
- _ref5$cover,
3961
+ var _ref7,
3962
+ _ref7$cover,
3625
3963
  cover,
3626
3964
  _args44 = arguments;
3627
3965
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3628
3966
  while (1) switch (_context44.prev = _context44.next) {
3629
3967
  case 0:
3630
- _ref5 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
3968
+ _ref7 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref7$cover = _ref7.cover, cover = _ref7$cover === void 0 ? false : _ref7$cover;
3631
3969
  if (cover) {
3632
3970
  this.otherParams = params;
3633
3971
  } else {
@@ -3647,6 +3985,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3647
3985
  }]);
3648
3986
  return VenueBookingImpl;
3649
3987
  }(BaseModule);
3988
+ _defineProperty(VenueBookingImpl, "PRICING_DEBUG_CACHE_ID", '031596279011848516');
3650
3989
  _defineProperty(VenueBookingImpl, "OPEN_DATA_CACHE_TTL", 5 * 60 * 1000);
3651
3990
  _defineProperty(VenueBookingImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
3652
3991
  _defineProperty(VenueBookingImpl, "UI_STATE_KEY_PREFIX", 'pisell.venueBooking.uiState:');