@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.
@@ -250,6 +250,59 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
250
250
  };
251
251
  }
252
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
+ }
253
306
  }, {
254
307
  key: "logMethodStart",
255
308
  value: function logMethodStart(method) {
@@ -374,24 +427,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
374
427
  while (1) switch (_context3.prev = _context3.next) {
375
428
  case 0:
376
429
  customerId = _this2.resolveCustomerIdFromLoginPayload(payload);
377
- _this2.logPricingDiagnostics('[VenueBooking] customer login event received', {
378
- customerId: customerId,
379
- hasLoadAllProductsInFlight: !!_this2.loadAllProductsInFlight,
380
- productsLoaded: _this2.productsLoaded,
381
- smartPricingProductCatalogCount: _this2.smartPricingProductCatalog.length
382
- });
383
430
  if (customerId) {
384
- _context3.next = 5;
431
+ _context3.next = 3;
385
432
  break;
386
433
  }
387
- _this2.logPricingDiagnostics('[VenueBooking] customer login event skipped customerId not found in login payload');
388
434
  return _context3.abrupt("return");
389
- case 5:
390
- _context3.next = 7;
435
+ case 3:
436
+ _context3.next = 5;
391
437
  return _this2.refreshOrderMarketingAfterLogin({
392
438
  customerId: customerId
393
439
  });
394
- case 7:
440
+ case 5:
395
441
  case "end":
396
442
  return _context3.stop();
397
443
  }
@@ -411,7 +457,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
411
457
  value: function () {
412
458
  var _refreshOrderMarketingAfterLogin = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
413
459
  var _this3 = this;
414
- var refreshTask;
460
+ var pricingDiagnosticsEnabled, refreshTask;
415
461
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
416
462
  while (1) switch (_context5.prev = _context5.next) {
417
463
  case 0:
@@ -421,15 +467,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
421
467
  }
422
468
  throw new Error('order 模块未初始化');
423
469
  case 2:
424
- this.logPricingDiagnostics('[VenueBooking] refreshOrderMarketingAfterLogin entered', {
425
- customerId: params.customerId,
426
- hasCustomerLoginRefreshInFlight: !!this.customerLoginRefreshInFlight,
427
- customerLoginRefreshIdInFlight: this.customerLoginRefreshIdInFlight,
428
- hasLoadAllProductsInFlight: !!this.loadAllProductsInFlight,
429
- productsLoaded: this.productsLoaded,
430
- smartPricingProductCatalogCount: this.smartPricingProductCatalog.length,
431
- note: 'This login refresh recalculates the loaded catalog and does not call loadAllProducts'
432
- });
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
+ }
433
482
  if (!this.customerLoginRefreshInFlight) {
434
483
  _context5.next = 11;
435
484
  break;
@@ -438,10 +487,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
438
487
  _context5.next = 9;
439
488
  break;
440
489
  }
441
- this.logPricingDiagnostics('[VenueBooking] customer login refresh reused', {
442
- customerId: params.customerId,
443
- reason: 'same customer refresh is already in flight'
444
- });
445
490
  _context5.next = 8;
446
491
  return this.customerLoginRefreshInFlight;
447
492
  case 8:
@@ -453,67 +498,195 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
453
498
  this.customerLoginRefreshIdInFlight = params.customerId;
454
499
  refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
455
500
  var _this3$core, _this3$core$emit;
501
+ var productsLoadBeforeLogin, loginProducts, _smartPricingContext$, _smartPricingContext$2, _smartPricingContext$3, _smartPricingContext$4, _this3$smartPricingPr, smartPricingContext, strategyConfigs, _getTempOrder;
456
502
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
457
503
  while (1) switch (_context4.prev = _context4.next) {
458
504
  case 0:
459
505
  // 用户插件可能晚于登录 effect 更新;以已确认的登录 payload 作为本次及后续网格算价的身份来源。
460
506
  _this3.smartPricingCustomerId = params.customerId;
461
- _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;
462
516
  return _this3.store.order.loadDiscountConfig({
463
517
  customerId: params.customerId
464
518
  });
465
- 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
+ }
466
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
+ }
467
605
  _this3.recalculateOrderPricesFromSmartPricing();
606
+ if (pricingDiagnosticsEnabled) {
607
+ _this3.logPricingDiagnostics('[VenueBooking] login smart pricing recalculation completed', {
608
+ orderProductsAfterRecalculation: _this3.getOrderPricingSnapshotForDiagnostics()
609
+ });
610
+ }
611
+
468
612
  // loadDiscountConfig 会按登录前的订单价格预计算一次券;智能价更新后必须用新的
469
613
  // source/main 价格字段重新套券,否则购物车行价与 Summary 会使用两套基数。
470
614
  _this3.store.order.applyDiscount();
471
615
  _this3.normalizeDiscountedOrderPrices(_this3.store.order.getDiscountList());
472
- _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;
473
623
  return _this3.store.order.recalculateSummary({
474
624
  createIfMissing: true
475
625
  });
476
- case 9:
626
+ case 31:
477
627
  _this3.store.order.persistTempOrder();
478
- _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;
479
635
  return _this3.refreshItemRuleQuantityLimits();
480
- case 12:
481
- _context4.next = 14;
636
+ case 35:
637
+ _context4.next = 37;
482
638
  return _this3.refreshCartValidationPassed();
483
- case 14:
484
- _context4.next = 16;
639
+ case 37:
640
+ _context4.next = 39;
485
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, {
486
642
  customerId: params.customerId
487
643
  });
488
- 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:
489
652
  case "end":
490
653
  return _context4.stop();
491
654
  }
492
- }, _callee4);
655
+ }, _callee4, null, [[8, 13]]);
493
656
  }))();
494
657
  this.customerLoginRefreshInFlight = refreshTask;
495
658
  _context5.prev = 14;
496
659
  _context5.next = 17;
497
660
  return refreshTask;
498
661
  case 17:
499
- _context5.next = 22;
662
+ _context5.next = 23;
500
663
  break;
501
664
  case 19:
502
665
  _context5.prev = 19;
503
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
+ }
504
677
  throw _context5.t0;
505
- case 22:
506
- _context5.prev = 22;
678
+ case 23:
679
+ _context5.prev = 23;
507
680
  if (this.customerLoginRefreshInFlight === refreshTask) {
508
681
  this.customerLoginRefreshInFlight = null;
509
682
  this.customerLoginRefreshIdInFlight = null;
510
683
  }
511
- return _context5.finish(22);
512
- case 25:
684
+ return _context5.finish(23);
685
+ case 26:
513
686
  case "end":
514
687
  return _context5.stop();
515
688
  }
516
- }, _callee5, this, [[14, 19, 22, 25]]);
689
+ }, _callee5, this, [[14, 19, 23, 26]]);
517
690
  }));
518
691
  function refreshOrderMarketingAfterLogin(_x4) {
519
692
  return _refreshOrderMarketingAfterLogin.apply(this, arguments);
@@ -540,8 +713,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
540
713
  scheduleModule,
541
714
  quotationModule,
542
715
  openDataModule,
543
- _this$store$order2,
544
716
  _this$store$order3,
717
+ _this$store$order4,
545
718
  _args6 = arguments;
546
719
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
547
720
  while (1) switch (_context6.prev = _context6.next) {
@@ -560,12 +733,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
560
733
  this.store.slotConfig = _objectSpread({}, this.baseSlotConfig);
561
734
  this.otherParams = options.otherParams || {};
562
735
  this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
563
- this.logPricingDiagnostics('[VenueBooking] initialize product loading state', {
564
- hasLoadAllProductsInFlight: !!this.loadAllProductsInFlight,
565
- productsLoaded: this.productsLoaded,
566
- smartPricingProductCatalogCount: this.smartPricingProductCatalog.length,
567
- note: 'initialize currently does not reset the product loading state'
568
- });
569
736
  this.itemRuleRuntimeConfig = ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.venueBookingItemRule) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.itemRule) || {};
570
737
  this.itemRuleConfigs = [];
571
738
  this.itemRuleConfigsPromise = null;
@@ -578,19 +745,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
578
745
  this.window = core.getPlugin('window');
579
746
  this.request = core.getPlugin('request');
580
747
  if (this.window) {
581
- _context6.next = 26;
748
+ _context6.next = 25;
582
749
  break;
583
750
  }
584
751
  this.logMethodError('initialize', 'window plugin missing');
585
752
  throw new Error('venueBooking解决方案需要 window 插件支持');
586
- case 26:
753
+ case 25:
587
754
  if (this.request) {
588
- _context6.next = 29;
755
+ _context6.next = 28;
589
756
  break;
590
757
  }
591
758
  this.logMethodError('initialize', 'request plugin missing');
592
759
  throw new Error('venueBooking解决方案需要 request 插件支持');
593
- case 29:
760
+ case 28:
594
761
  // 注册基础模块(order, salesSummary, products, logger)
595
762
  baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
596
763
  baseModules.forEach(function (step) {
@@ -687,41 +854,41 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
687
854
  }
688
855
  this.registerCustomerLoginListeners();
689
856
  console.log('[VenueBooking] 初始化开始');
690
- _context6.prev = 52;
691
- _context6.next = 55;
692
- return (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 ? void 0 : _this$store$order2.recalculateSummary({
857
+ _context6.prev = 51;
858
+ _context6.next = 54;
859
+ return (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.recalculateSummary({
693
860
  createIfMissing: false
694
861
  });
695
- case 55:
696
- (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || _this$store$order3.persistTempOrder();
697
- _context6.next = 58;
862
+ case 54:
863
+ (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || _this$store$order4.persistTempOrder();
864
+ _context6.next = 57;
698
865
  return this.loadRuntimeConfigs();
699
- case 58:
866
+ case 57:
700
867
  if (!this.store.schedule) {
701
- _context6.next = 61;
868
+ _context6.next = 60;
702
869
  break;
703
870
  }
704
- _context6.next = 61;
871
+ _context6.next = 60;
705
872
  return this.store.schedule.loadAllSchedule();
706
- case 61:
707
- _context6.next = 63;
873
+ case 60:
874
+ _context6.next = 62;
708
875
  return this.refreshItemRuleQuantityLimits();
709
- case 63:
876
+ case 62:
710
877
  this.store.status = 'ready';
711
878
  console.log('[VenueBooking] 初始化完成');
712
- _context6.next = 67;
879
+ _context6.next = 66;
713
880
  return this.core.effects.emit(VenueBookingHooks.onInited, {
714
881
  status: this.store.status
715
882
  });
716
- case 67:
883
+ case 66:
717
884
  this.logMethodSuccess('initialize', {
718
885
  status: this.store.status
719
886
  });
720
- _context6.next = 77;
887
+ _context6.next = 76;
721
888
  break;
722
- case 70:
723
- _context6.prev = 70;
724
- _context6.t0 = _context6["catch"](52);
889
+ case 69:
890
+ _context6.prev = 69;
891
+ _context6.t0 = _context6["catch"](51);
725
892
  this.store.status = 'error';
726
893
  this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
727
894
  console.error('[VenueBooking] 初始化失败', _context6.t0);
@@ -729,11 +896,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
729
896
  status: this.store.status
730
897
  });
731
898
  throw _context6.t0;
732
- case 77:
899
+ case 76:
733
900
  case "end":
734
901
  return _context6.stop();
735
902
  }
736
- }, _callee6, this, [[52, 70]]);
903
+ }, _callee6, this, [[51, 69]]);
737
904
  }));
738
905
  function initialize(_x5) {
739
906
  return _initialize.apply(this, arguments);
@@ -898,8 +1065,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
898
1065
  }, {
899
1066
  key: "resolveAvailableWalletIdsForSmartPricing",
900
1067
  value: function resolveAvailableWalletIdsForSmartPricing() {
901
- var _this$store$order4, _this$store$order4$ge, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
902
- var orderWalletIds = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 || (_this$store$order4$ge = _this$store$order4.getAvailableWalletIds) === null || _this$store$order4$ge === void 0 ? void 0 : _this$store$order4$ge.call(_this$store$order4);
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);
903
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);
904
1071
  var source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
905
1072
  if (!Array.isArray(source)) return [];
@@ -925,17 +1092,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
925
1092
  }, {
926
1093
  key: "buildSmartPricingContext",
927
1094
  value: function buildSmartPricingContext(customerId) {
928
- var _this$core3,
929
- _this$otherParams10,
930
- _this$otherParams11,
931
- _this$otherParams12,
932
- _this$otherParams13,
933
- _this$otherParams14,
934
- _this$otherParams15,
935
- _this$otherParams16,
936
- _this5 = this;
1095
+ var _this$core3, _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16;
937
1096
  var evaluator = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.dataVariantEvaluator;
938
- return _objectSpread({
1097
+ return {
939
1098
  evaluator: evaluator,
940
1099
  scheduleList: this.getScheduleListForSmartPricing(),
941
1100
  menuList: ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.menuList) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 || (_this$otherParams11 = _this$otherParams11.openData) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.menuList) || [],
@@ -945,12 +1104,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
945
1104
  businessCode: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode,
946
1105
  orderType: ((_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.orderType) || ((_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.type),
947
1106
  strategy_context: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.strategy_context
948
- }, this.isPricingDiagnosticsEnabled() ? {
949
- debugLog: function debugLog(title) {
950
- var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
951
- return _this5.logPricingDiagnostics(title, payload);
952
- }
953
- } : {});
1107
+ };
954
1108
  }
955
1109
 
956
1110
  /** venue + addon 全量商品,供智能定价评估 */
@@ -999,41 +1153,21 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
999
1153
  key: "loadAllProducts",
1000
1154
  value: function () {
1001
1155
  var _loadAllProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1002
- var _this6 = this;
1156
+ var _this5 = this;
1003
1157
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1004
1158
  while (1) switch (_context10.prev = _context10.next) {
1005
1159
  case 0:
1006
- this.logPricingDiagnostics('[VenueBooking] loadAllProducts called', {
1007
- hasLoadAllProductsInFlight: !!this.loadAllProductsInFlight,
1008
- productsLoaded: this.productsLoaded,
1009
- smartPricingCustomerId: this.smartPricingCustomerId,
1010
- smartPricingProductCatalogCount: this.smartPricingProductCatalog.length,
1011
- venueProducts: !this.store.venueProducts,
1012
- addonProducts: !this.store.addonProducts
1013
- });
1014
1160
  if (!this.loadAllProductsInFlight) {
1015
- _context10.next = 4;
1161
+ _context10.next = 2;
1016
1162
  break;
1017
1163
  }
1018
- this.logPricingDiagnostics('[VenueBooking] loadAllProducts request skipped', {
1019
- reason: 'reusing existing loadAllProductsInFlight promise',
1020
- productsLoaded: this.productsLoaded
1021
- });
1022
1164
  return _context10.abrupt("return", this.loadAllProductsInFlight);
1023
- case 4:
1024
- this.logPricingDiagnostics('[VenueBooking] loadAllProducts request starting', {
1025
- productsLoaded: this.productsLoaded,
1026
- smartPricingCustomerId: this.smartPricingCustomerId
1027
- });
1165
+ case 2:
1028
1166
  this.loadAllProductsInFlight = this._doLoadAllProducts().finally(function () {
1029
- _this6.logPricingDiagnostics('[VenueBooking] loadAllProducts request settled', {
1030
- productsLoaded: _this6.productsLoaded,
1031
- smartPricingProductCatalogCount: _this6.smartPricingProductCatalog.length
1032
- });
1033
- _this6.loadAllProductsInFlight = null;
1167
+ _this5.loadAllProductsInFlight = null;
1034
1168
  });
1035
1169
  return _context10.abrupt("return", this.loadAllProductsInFlight);
1036
- case 7:
1170
+ case 4:
1037
1171
  case "end":
1038
1172
  return _context10.stop();
1039
1173
  }
@@ -1048,7 +1182,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1048
1182
  key: "_doLoadAllProducts",
1049
1183
  value: function () {
1050
1184
  var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1051
- var _this$otherParams17, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, smartPricingContext, venueList, addonList, venueStore;
1185
+ var _this$otherParams17, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, venueList, addonList, venueStore;
1052
1186
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1053
1187
  while (1) switch (_context11.prev = _context11.next) {
1054
1188
  case 0:
@@ -1093,19 +1227,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1093
1227
  rawList = Array.isArray(allProducts) ? allProducts : [];
1094
1228
  list = rawList;
1095
1229
  this.smartPricingProductCatalog = rawList.slice();
1096
- smartPricingContext = this.buildSmartPricingContext();
1097
- list = formatProductsWithDataVariant(list, smartPricingContext, dayjs().format('YYYY-MM-DD HH:mm:ss'));
1098
-
1099
- // 增加日志排查智能定价
1100
- if (this.isPricingDiagnosticsEnabled()) {
1101
- this.logPricingDiagnostics('[VenueBooking] loadAllProducts smart pricing context', {
1102
- smartPricingContext: smartPricingContext,
1103
- rawList: rawList,
1104
- list: list,
1105
- otherParams: this.otherParams,
1106
- availableWalletIds: this.getAvailableWalletIdsForDiagnostics()
1107
- });
1108
- }
1230
+ list = formatProductsWithDataVariant(list, this.buildSmartPricingContext(), dayjs().format('YYYY-MM-DD HH:mm:ss'));
1109
1231
  this.clearSlotPriceMapCache();
1110
1232
  venueList = list.filter(function (p) {
1111
1233
  return p.duration != null;
@@ -1132,16 +1254,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1132
1254
  venueProducts: venueList,
1133
1255
  addonProducts: addonList
1134
1256
  });
1135
- case 34:
1136
- _context11.prev = 34;
1257
+ case 32:
1258
+ _context11.prev = 32;
1137
1259
  _context11.t0 = _context11["catch"](1);
1138
1260
  this.logMethodError('loadAllProducts', _context11.t0);
1139
1261
  throw _context11.t0;
1140
- case 38:
1262
+ case 36:
1141
1263
  case "end":
1142
1264
  return _context11.stop();
1143
1265
  }
1144
- }, _callee11, this, [[1, 34]]);
1266
+ }, _callee11, this, [[1, 32]]);
1145
1267
  }));
1146
1268
  function _doLoadAllProducts() {
1147
1269
  return _doLoadAllProducts2.apply(this, arguments);
@@ -1156,16 +1278,12 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1156
1278
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1157
1279
  while (1) switch (_context12.prev = _context12.next) {
1158
1280
  case 0:
1159
- this.logPricingDiagnostics('[VenueBooking] loadVenueProducts called', {
1160
- hasLoadAllProductsInFlight: !!this.loadAllProductsInFlight,
1161
- productsLoaded: this.productsLoaded
1162
- });
1163
- _context12.next = 3;
1281
+ _context12.next = 2;
1164
1282
  return this.loadAllProducts();
1165
- case 3:
1283
+ case 2:
1166
1284
  result = _context12.sent;
1167
1285
  return _context12.abrupt("return", result.venueProducts);
1168
- case 5:
1286
+ case 4:
1169
1287
  case "end":
1170
1288
  return _context12.stop();
1171
1289
  }
@@ -1457,7 +1575,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1457
1575
  }, {
1458
1576
  key: "getDateRangeSummary",
1459
1577
  value: function getDateRangeSummary(params) {
1460
- var _this7 = this;
1578
+ var _this6 = this;
1461
1579
  return buildDateRangeSummary({
1462
1580
  startDate: params.startDate,
1463
1581
  endDate: params.endDate,
@@ -1465,10 +1583,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1465
1583
  rawResources: this.store.rawResourceData,
1466
1584
  resourceProductMap: this.resourceProductMap,
1467
1585
  resolveConfig: function resolveConfig(date) {
1468
- return _this7.resolveSlotConfigForDate(date);
1586
+ return _this6.resolveSlotConfigForDate(date);
1469
1587
  },
1470
1588
  buildSlotPriceMap: function buildSlotPriceMap(date, config, productIds) {
1471
- return _this7.buildSlotPriceMapForDate(date, config, productIds);
1589
+ return _this6.buildSlotPriceMapForDate(date, config, productIds);
1472
1590
  }
1473
1591
  });
1474
1592
  }
@@ -1585,8 +1703,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1585
1703
  }, {
1586
1704
  key: "getSelectedSlotsForResource",
1587
1705
  value: function getSelectedSlotsForResource(resourceId, productId) {
1588
- var _this$store$order5;
1589
- var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.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();
1590
1708
  if (!tempOrder) return [];
1591
1709
  var venueProducts = tempOrder.products.filter(function (p) {
1592
1710
  var _p$metadata, _p$metadata2;
@@ -1651,7 +1769,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1651
1769
  }, {
1652
1770
  key: "isSlotDisabledBySelection",
1653
1771
  value: function isSlotDisabledBySelection(params) {
1654
- var _this8 = this;
1772
+ var _this7 = this;
1655
1773
  var resourceId = params.resourceId,
1656
1774
  productId = params.productId,
1657
1775
  startTime = params.startTime;
@@ -1673,7 +1791,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1673
1791
 
1674
1792
  // 组合资源字段缓存
1675
1793
  var getCombinedChildIds = function getCombinedChildIds(resId) {
1676
- var raw = _this8.store.rawResourceData.find(function (r) {
1794
+ var raw = _this7.store.rawResourceData.find(function (r) {
1677
1795
  return String(r.resourceId) === String(resId);
1678
1796
  });
1679
1797
  var combined = raw === null || raw === void 0 ? void 0 : raw.combined_resource;
@@ -1747,9 +1865,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1747
1865
  }, {
1748
1866
  key: "getAllSelectedSlots",
1749
1867
  value: function getAllSelectedSlots() {
1750
- var _this$store$order6;
1868
+ var _this$store$order7;
1751
1869
  var result = new Map();
1752
- var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
1870
+ var tempOrder = (_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.getTempOrder();
1753
1871
  if (!tempOrder) return result;
1754
1872
  var venueProducts = tempOrder.products.filter(function (p) {
1755
1873
  var _p$metadata3;
@@ -1760,9 +1878,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1760
1878
  _step9;
1761
1879
  try {
1762
1880
  var _loop2 = function _loop2() {
1763
- var _product$metadata;
1881
+ var _product$metadata7;
1764
1882
  var product = _step9.value;
1765
- 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;
1766
1884
  if (resourceId == null) return 1; // continue
1767
1885
  var productId = Number(product.product_id);
1768
1886
  var existing = result.get(resourceId) || [];
@@ -1992,7 +2110,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1992
2110
  }, {
1993
2111
  key: "getCombinedChildRawResources",
1994
2112
  value: function getCombinedChildRawResources(rawResource) {
1995
- var _this9 = this;
2113
+ var _this8 = this;
1996
2114
  if (!rawResource) return undefined;
1997
2115
  var combined = rawResource.combined_resource;
1998
2116
  if (!combined || combined.status !== 1 || !Array.isArray(combined.resource_ids) || !combined.resource_ids.length) {
@@ -2004,7 +2122,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2004
2122
  try {
2005
2123
  var _loop3 = function _loop3() {
2006
2124
  var id = _step11.value;
2007
- var child = _this9.store.rawResourceData.find(function (r) {
2125
+ var child = _this8.store.rawResourceData.find(function (r) {
2008
2126
  return String(r.resourceId) === String(id);
2009
2127
  });
2010
2128
  if (child) children.push(child);
@@ -2082,8 +2200,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2082
2200
  }, {
2083
2201
  key: "getTempOrder",
2084
2202
  value: function getTempOrder() {
2085
- var _this$store$order7;
2086
- var result = ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.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;
2087
2205
  return result;
2088
2206
  }
2089
2207
  }, {
@@ -2141,31 +2259,70 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2141
2259
  }
2142
2260
  return onCustomerLogin;
2143
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
+ }
2144
2271
  }, {
2145
2272
  key: "recalculateOrderPricesFromSmartPricing",
2146
2273
  value: function recalculateOrderPricesFromSmartPricing() {
2147
2274
  var _tempOrder$products,
2148
- _this10 = this;
2149
- if (!this.store.order) return;
2275
+ _this9 = this;
2276
+ if (!this.store.order) {
2277
+ this.logPricingDiagnostics('[VenueBooking] order smart pricing recalculation skipped', {
2278
+ reason: 'order module is missing'
2279
+ });
2280
+ return;
2281
+ }
2150
2282
  var tempOrder = this.store.order.getTempOrder();
2151
- 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
+ }
2152
2289
  var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
2153
2290
  var catalog = this.getAllProductsForSmartPricing();
2154
2291
  var context = this.buildSmartPricingContext();
2292
+ var productDiagnostics = this.isPricingDiagnosticsEnabled() ? [] : null;
2155
2293
  var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
2156
2294
  _step12;
2157
2295
  try {
2158
2296
  var _loop4 = function _loop4() {
2159
- var _product$metadata2;
2297
+ var _product$metadata8;
2160
2298
  var product = _step12.value;
2161
- if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
2162
- var mappings = _this10.resourceProductMap.get(product.metadata.resource_id);
2163
- if (!mappings || !mappings.length) return 0; // continue
2299
+ if ((_product$metadata8 = product.metadata) !== null && _product$metadata8 !== void 0 && _product$metadata8.venue_booking) {
2300
+ var mappings = _this9.resourceProductMap.get(product.metadata.resource_id);
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
+ }
2164
2311
  var mapping = mappings.find(function (m) {
2165
2312
  return Number(m.productId) === Number(product.product_id);
2166
2313
  }) || mappings[0];
2167
- if (!mapping) return 0; // continue
2168
- var slots = expandMergedSlotToIndividual(product, _this10.store.slotConfig.slotDurationMinutes);
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
+ }
2325
+ var slots = expandMergedSlotToIndividual(product, _this9.store.slotConfig.slotDurationMinutes);
2169
2326
  var uniqueDates = _toConsumableArray(new Set(slots.map(function (slot) {
2170
2327
  return dayjs(slot.startTime).format('YYYY-MM-DD');
2171
2328
  })));
@@ -2175,7 +2332,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2175
2332
  try {
2176
2333
  for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2177
2334
  var slotDate = _step13.value;
2178
- slotPriceMaps.set(slotDate, _this10.buildSlotPriceMapForDate(slotDate, _this10.store.slotConfig, [mapping.productId]));
2335
+ slotPriceMaps.set(slotDate, _this9.buildSlotPriceMapForDate(slotDate, _this9.store.slotConfig, [mapping.productId]));
2179
2336
  }
2180
2337
  } catch (err) {
2181
2338
  _iterator13.e(err);
@@ -2197,7 +2354,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2197
2354
  });
2198
2355
  var merged = mergeConsecutiveSlots(updatedSlots);
2199
2356
  if (merged.length === 1) {
2200
- _this10.resetProductPriceForSmartPricing({
2357
+ var previousSellingPrice = product === null || product === void 0 ? void 0 : product.selling_price;
2358
+ _this9.resetProductPriceForSmartPricing({
2201
2359
  product: product,
2202
2360
  price: merged[0].totalPrice,
2203
2361
  priceBreakdown: buildPriceBreakdown({
@@ -2205,8 +2363,42 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2205
2363
  productId: mapping.productId
2206
2364
  })
2207
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
+ });
2208
2396
  }
2209
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;
2210
2402
  var smartPrice = getPriceForProductAtDatetime({
2211
2403
  products: catalog,
2212
2404
  context: context,
@@ -2214,10 +2406,29 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2214
2406
  datetime: now,
2215
2407
  fallbackPrice: product.selling_price
2216
2408
  });
2217
- _this10.resetProductPriceForSmartPricing({
2409
+ _this9.resetProductPriceForSmartPricing({
2218
2410
  product: product,
2219
2411
  price: smartPrice
2220
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
+ });
2221
2432
  }
2222
2433
  },
2223
2434
  _ret;
@@ -2230,6 +2441,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2230
2441
  } finally {
2231
2442
  _iterator12.f();
2232
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
+ }
2233
2460
  }
2234
2461
 
2235
2462
  /**
@@ -2679,7 +2906,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2679
2906
  key: "addProductToOrder",
2680
2907
  value: function () {
2681
2908
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(product) {
2682
- var _product$metadata3, _product$metadata4, smartPrice, products;
2909
+ var _product$metadata9, _product$metadata10, smartPrice, products;
2683
2910
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2684
2911
  while (1) switch (_context26.prev = _context26.next) {
2685
2912
  case 0:
@@ -2694,7 +2921,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2694
2921
  }
2695
2922
  throw new Error('order 模块未初始化');
2696
2923
  case 4:
2697
- 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) {
2698
2925
  smartPrice = getPriceForProductAtDatetime({
2699
2926
  products: this.getAllProductsForSmartPricing(),
2700
2927
  context: this.buildSmartPricingContext(),
@@ -2704,7 +2931,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2704
2931
  });
2705
2932
  product.selling_price = smartPrice;
2706
2933
  product.original_price = smartPrice;
2707
- } 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)) {
2708
2935
  product.original_price = product.selling_price;
2709
2936
  }
2710
2937
  _context26.next = 7;
@@ -2790,7 +3017,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2790
3017
  key: "removeProductFromOrder",
2791
3018
  value: function () {
2792
3019
  var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
2793
- var _this$store$order$get4, _this$store$order8, _this$store$order$ens, _this$store$order9, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator16, _step16, _product$metadata5, _product$metadata6, product, beforeBookingCount, _this$store$order$per, _this$store$order10;
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;
2794
3021
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2795
3022
  while (1) switch (_context28.prev = _context28.next) {
2796
3023
  case 0:
@@ -2805,7 +3032,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2805
3032
  }
2806
3033
  throw new Error('order 模块未初始化');
2807
3034
  case 4:
2808
- tempOrder = ((_this$store$order$get4 = (_this$store$order8 = this.store.order).getTempOrder) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.call(_this$store$order8)) || ((_this$store$order$ens = (_this$store$order9 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order9));
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));
2809
3036
  _context28.next = 7;
2810
3037
  return this.store.order.removeProductFromOrder(identity);
2811
3038
  case 7:
@@ -2825,14 +3052,14 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2825
3052
  break;
2826
3053
  }
2827
3054
  product = _step16.value;
2828
- 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) {
2829
3056
  _context28.next = 18;
2830
3057
  break;
2831
3058
  }
2832
3059
  return _context28.abrupt("continue", 20);
2833
3060
  case 18:
2834
3061
  if (product.identity_key) venueProductUids.add(String(product.identity_key));
2835
- 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) {
2836
3063
  venueBookingUids.add(String(product.metadata.booking_uid));
2837
3064
  }
2838
3065
  case 20:
@@ -2862,7 +3089,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2862
3089
  return true;
2863
3090
  });
2864
3091
  if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
2865
- (_this$store$order$per = (_this$store$order10 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order10);
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);
2866
3093
  }
2867
3094
  case 33:
2868
3095
  _context28.next = 35;
@@ -2900,22 +3127,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2900
3127
  while (1) switch (_context29.prev = _context29.next) {
2901
3128
  case 0:
2902
3129
  if (!this.productsLoaded) {
2903
- _context29.next = 3;
3130
+ _context29.next = 2;
2904
3131
  break;
2905
3132
  }
2906
- this.logPricingDiagnostics('[VenueBooking] getProductList loadAllProducts skipped', {
2907
- reason: 'productsLoaded is true',
2908
- addonProductCount: this.getAddonProductsList().length,
2909
- smartPricingProductCatalogCount: this.smartPricingProductCatalog.length
2910
- });
2911
3133
  return _context29.abrupt("return", attachItemRuleLimitsToTopLevelProducts(this.getAddonProductsList(), this.store.itemRuleQuantityLimits || []));
2912
- case 3:
2913
- _context29.next = 5;
3134
+ case 2:
3135
+ _context29.next = 4;
2914
3136
  return this.loadAllProducts();
2915
- case 5:
3137
+ case 4:
2916
3138
  result = _context29.sent;
2917
3139
  return _context29.abrupt("return", attachItemRuleLimitsToTopLevelProducts(result.addonProducts, this.store.itemRuleQuantityLimits || []));
2918
- case 7:
3140
+ case 6:
2919
3141
  case "end":
2920
3142
  return _context29.stop();
2921
3143
  }
@@ -3118,8 +3340,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3118
3340
  var rawProductId = (_node$product_id = node.product_id) !== null && _node$product_id !== void 0 ? _node$product_id : node.id;
3119
3341
  var productId = Number(rawProductId);
3120
3342
  if (Number.isFinite(productId) && productId > 0) {
3121
- var _ref3, _node$product_variant;
3122
- 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);
3123
3345
  var normalizedVariantId = Number.isNaN(productVariantId) ? 0 : productVariantId;
3124
3346
  var key = buildProductKey(productId, normalizedVariantId);
3125
3347
  if (!sourceMap.has(key)) sourceMap.set(key, node);
@@ -3158,7 +3380,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3158
3380
  key: "ensureItemRuleConfigsLoaded",
3159
3381
  value: function () {
3160
3382
  var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
3161
- var _this11 = this;
3383
+ var _this10 = this;
3162
3384
  return _regeneratorRuntime().wrap(function _callee35$(_context35) {
3163
3385
  while (1) switch (_context35.prev = _context35.next) {
3164
3386
  case 0:
@@ -3179,19 +3401,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3179
3401
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3180
3402
  while (1) switch (_context34.prev = _context34.next) {
3181
3403
  case 0:
3182
- runtimeConfig = _this11.getItemRuleRuntimeConfig();
3404
+ runtimeConfig = _this10.getItemRuleRuntimeConfig();
3183
3405
  staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
3184
3406
  if (!(staticConfigs.length > 0)) {
3185
3407
  _context34.next = 6;
3186
3408
  break;
3187
3409
  }
3188
- _this11.itemRuleConfigs = staticConfigs;
3189
- _this11.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
3190
- return _context34.abrupt("return", _this11.itemRuleConfigs);
3410
+ _this10.itemRuleConfigs = staticConfigs;
3411
+ _this10.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
3412
+ return _context34.abrupt("return", _this10.itemRuleConfigs);
3191
3413
  case 6:
3192
- _this11.itemRuleConfigs = [];
3193
- _this11.itemRuleEvaluator.setStrategyConfigs([]);
3194
- return _context34.abrupt("return", _this11.itemRuleConfigs);
3414
+ _this10.itemRuleConfigs = [];
3415
+ _this10.itemRuleEvaluator.setStrategyConfigs([]);
3416
+ return _context34.abrupt("return", _this10.itemRuleConfigs);
3195
3417
  case 9:
3196
3418
  case "end":
3197
3419
  return _context34.stop();
@@ -3736,14 +3958,14 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3736
3958
  key: "setOtherParams",
3737
3959
  value: function () {
3738
3960
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
3739
- var _ref5,
3740
- _ref5$cover,
3961
+ var _ref7,
3962
+ _ref7$cover,
3741
3963
  cover,
3742
3964
  _args44 = arguments;
3743
3965
  return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3744
3966
  while (1) switch (_context44.prev = _context44.next) {
3745
3967
  case 0:
3746
- _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;
3747
3969
  if (cover) {
3748
3970
  this.otherParams = params;
3749
3971
  } else {