@pisell/pisellos 2.1.168 → 2.1.170

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +3 -0
  3. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  4. package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
  5. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  6. package/dist/model/strategy/adapter/dataVariant/evaluator.js +867 -0
  7. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  8. package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
  9. package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  10. package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
  11. package/dist/model/strategy/adapter/dataVariant/type.d.ts +149 -0
  12. package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
  13. package/dist/model/strategy/adapter/index.d.ts +4 -0
  14. package/dist/model/strategy/adapter/index.js +5 -1
  15. package/dist/modules/Discount/index.d.ts +5 -2
  16. package/dist/modules/Discount/index.js +21 -1
  17. package/dist/modules/Discount/types.d.ts +4 -0
  18. package/dist/modules/Order/index.d.ts +1 -0
  19. package/dist/modules/Order/index.js +18 -6
  20. package/dist/modules/Order/types.d.ts +2 -0
  21. package/dist/modules/ProductList/index.d.ts +3 -1
  22. package/dist/modules/ProductList/index.js +22 -11
  23. package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
  24. package/dist/solution/ScanOrder/index.js +1 -1
  25. package/dist/solution/ShopDiscount/index.js +16 -15
  26. package/dist/solution/VenueBooking/index.d.ts +49 -3
  27. package/dist/solution/VenueBooking/index.js +537 -287
  28. package/dist/solution/VenueBooking/types.d.ts +3 -1
  29. package/dist/solution/VenueBooking/types.js +1 -0
  30. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  31. package/dist/solution/VenueBooking/utils/dateSummary.js +12 -25
  32. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  33. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -9
  34. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  35. package/dist/solution/VenueBooking/utils/smartPricing.js +302 -0
  36. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  37. package/dist/solution/VenueBooking/utils/timeSlot.js +9 -4
  38. package/lib/index.d.ts +1 -0
  39. package/lib/index.js +3 -0
  40. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
  41. package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
  42. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
  43. package/lib/model/strategy/adapter/dataVariant/evaluator.js +666 -0
  44. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
  45. package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
  46. package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
  47. package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
  48. package/lib/model/strategy/adapter/dataVariant/type.d.ts +149 -0
  49. package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
  50. package/lib/model/strategy/adapter/index.d.ts +4 -0
  51. package/lib/model/strategy/adapter/index.js +13 -2
  52. package/lib/modules/Discount/index.d.ts +5 -2
  53. package/lib/modules/Discount/index.js +11 -1
  54. package/lib/modules/Discount/types.d.ts +4 -0
  55. package/lib/modules/Order/index.d.ts +1 -0
  56. package/lib/modules/Order/index.js +11 -1
  57. package/lib/modules/Order/types.d.ts +2 -0
  58. package/lib/modules/ProductList/index.d.ts +3 -1
  59. package/lib/modules/ProductList/index.js +45 -39
  60. package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
  61. package/lib/solution/ScanOrder/index.js +1 -1
  62. package/lib/solution/ShopDiscount/index.js +3 -2
  63. package/lib/solution/VenueBooking/index.d.ts +49 -3
  64. package/lib/solution/VenueBooking/index.js +362 -113
  65. package/lib/solution/VenueBooking/types.d.ts +3 -1
  66. package/lib/solution/VenueBooking/types.js +1 -0
  67. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  68. package/lib/solution/VenueBooking/utils/dateSummary.js +5 -10
  69. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
  70. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -4
  71. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +71 -0
  72. package/lib/solution/VenueBooking/utils/smartPricing.js +225 -0
  73. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
  74. package/lib/solution/VenueBooking/utils/timeSlot.js +7 -3
  75. package/package.json +1 -1
@@ -45,6 +45,7 @@ import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
45
45
  import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
46
46
  import { buildDateRangeSummary } from "./utils/dateSummary";
47
47
  import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildVenueResourceMetadata, buildPriceBreakdown } from "./utils/slotMerge";
48
+ import { buildSlotPriceMapByScheduleSegments, formatProductsWithDataVariant, getPriceForProductAtDatetime, getSlotPriceFromMap } from "./utils/smartPricing";
48
49
  import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
49
50
  import { OrderModule } from "../../modules/Order";
50
51
  import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
@@ -98,9 +99,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
98
99
  _defineProperty(_assertThisInitialized(_this), "loginEffectDisposers", []);
99
100
  _defineProperty(_assertThisInitialized(_this), "customerLoginRefreshInFlight", null);
100
101
  _defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
102
+ /** 最近一次确认登录的客户;登录事件与 user 插件更新之间可能存在时序差。 */
103
+ _defineProperty(_assertThisInitialized(_this), "smartPricingCustomerId", void 0);
101
104
  _defineProperty(_assertThisInitialized(_this), "loadAllProductsInFlight", null);
102
105
  _defineProperty(_assertThisInitialized(_this), "productsLoaded", false);
103
106
  _defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
107
+ /** 按日期缓存 slot 智能定价 Map,避免同周重复 resolveProducts */
108
+ _defineProperty(_assertThisInitialized(_this), "slotPriceMapCache", new Map());
109
+ /** loadProducts 后缓存的全量商品(venue + addon),供分段算价复用 */
110
+ _defineProperty(_assertThisInitialized(_this), "smartPricingProductCatalog", []);
104
111
  return _this;
105
112
  }
106
113
  _createClass(VenueBookingImpl, [{
@@ -207,6 +214,42 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
207
214
  }
208
215
  return addVenueBookingLog;
209
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
+ }
210
253
  }, {
211
254
  key: "logMethodStart",
212
255
  value: function logMethodStart(method) {
@@ -321,16 +364,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
321
364
  }, {
322
365
  key: "registerCustomerLoginListeners",
323
366
  value: function registerCustomerLoginListeners() {
324
- var _this$core2,
325
- _this$core3,
326
- _accountModule$getCur,
327
- _accountModule$getAcc,
328
- _this2 = this;
367
+ var _this2 = this;
329
368
  this.clearLoginEffectListeners();
330
- var accountModule = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.getModule('account');
331
- var registerAndLoginModule = (_this$core3 = this.core) === null || _this$core3 === void 0 ? void 0 : _this$core3.getModule('registerAndLogin');
332
- var currentAccount = (accountModule === null || accountModule === void 0 || (_accountModule$getCur = accountModule.getCurrentAccount) === null || _accountModule$getCur === void 0 ? void 0 : _accountModule$getCur.call(accountModule)) || (accountModule === null || accountModule === void 0 || (_accountModule$getAcc = accountModule.getAccount) === null || _accountModule$getAcc === void 0 ? void 0 : _accountModule$getAcc.call(accountModule)) || null;
333
- var createHandleLogin = function createHandleLogin(eventName) {
369
+ var createHandleLogin = function createHandleLogin() {
334
370
  return /*#__PURE__*/function () {
335
371
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
336
372
  var customerId;
@@ -338,17 +374,24 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
338
374
  while (1) switch (_context3.prev = _context3.next) {
339
375
  case 0:
340
376
  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
+ });
341
383
  if (customerId) {
342
- _context3.next = 3;
384
+ _context3.next = 5;
343
385
  break;
344
386
  }
387
+ _this2.logPricingDiagnostics('[VenueBooking] customer login event skipped customerId not found in login payload');
345
388
  return _context3.abrupt("return");
346
- case 3:
347
- _context3.next = 5;
389
+ case 5:
390
+ _context3.next = 7;
348
391
  return _this2.refreshOrderMarketingAfterLogin({
349
392
  customerId: customerId
350
393
  });
351
- case 5:
394
+ case 7:
352
395
  case "end":
353
396
  return _context3.stop();
354
397
  }
@@ -359,8 +402,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
359
402
  };
360
403
  }();
361
404
  };
362
- this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin(AccountHooks.OnLogin));
363
- this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin(RegisterAndLoginHooks.onLoginSuccess));
405
+ this.registerLoginEffect(VenueBookingImpl.PISELL1_LOGIN_SUCCESS, createHandleLogin());
406
+ this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin());
407
+ this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
364
408
  }
365
409
  }, {
366
410
  key: "refreshOrderMarketingAfterLogin",
@@ -377,83 +421,99 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
377
421
  }
378
422
  throw new Error('order 模块未初始化');
379
423
  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
+ });
380
433
  if (!this.customerLoginRefreshInFlight) {
381
- _context5.next = 9;
434
+ _context5.next = 11;
382
435
  break;
383
436
  }
384
437
  if (!(this.customerLoginRefreshIdInFlight === params.customerId)) {
385
- _context5.next = 7;
438
+ _context5.next = 9;
386
439
  break;
387
440
  }
388
- _context5.next = 6;
441
+ this.logPricingDiagnostics('[VenueBooking] customer login refresh reused', {
442
+ customerId: params.customerId,
443
+ reason: 'same customer refresh is already in flight'
444
+ });
445
+ _context5.next = 8;
389
446
  return this.customerLoginRefreshInFlight;
390
- case 6:
447
+ case 8:
391
448
  return _context5.abrupt("return");
392
- case 7:
393
- _context5.next = 9;
394
- return this.customerLoginRefreshInFlight;
395
449
  case 9:
450
+ _context5.next = 11;
451
+ return this.customerLoginRefreshInFlight;
452
+ case 11:
396
453
  this.customerLoginRefreshIdInFlight = params.customerId;
397
454
  refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
398
- var _this3$otherParams;
455
+ var _this3$core, _this3$core$emit;
399
456
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
400
457
  while (1) switch (_context4.prev = _context4.next) {
401
458
  case 0:
402
- if (!_this3.store.quotation) {
403
- _context4.next = 3;
404
- break;
405
- }
459
+ // 用户插件可能晚于登录 effect 更新;以已确认的登录 payload 作为本次及后续网格算价的身份来源。
460
+ _this3.smartPricingCustomerId = params.customerId;
406
461
  _context4.next = 3;
407
- return _this3.store.quotation.loadQuotations({
408
- channel: (_this3$otherParams = _this3.otherParams) === null || _this3$otherParams === void 0 ? void 0 : _this3$otherParams.channel
409
- });
410
- case 3:
411
- _this3.recalculateOrderPricesFromQuotation();
412
- _context4.next = 6;
413
462
  return _this3.store.order.loadDiscountConfig({
414
463
  customerId: params.customerId
415
464
  });
416
- case 6:
417
- _context4.next = 8;
465
+ case 3:
466
+ _this3.clearSlotPriceMapCache();
467
+ _this3.recalculateOrderPricesFromSmartPricing();
468
+ // loadDiscountConfig 会按登录前的订单价格预计算一次券;智能价更新后必须用新的
469
+ // source/main 价格字段重新套券,否则购物车行价与 Summary 会使用两套基数。
470
+ _this3.store.order.applyDiscount();
471
+ _this3.normalizeDiscountedOrderPrices(_this3.store.order.getDiscountList());
472
+ _context4.next = 9;
418
473
  return _this3.store.order.recalculateSummary({
419
474
  createIfMissing: true
420
475
  });
421
- case 8:
476
+ case 9:
422
477
  _this3.store.order.persistTempOrder();
423
- _context4.next = 11;
478
+ _context4.next = 12;
424
479
  return _this3.refreshItemRuleQuantityLimits();
425
- case 11:
426
- _context4.next = 13;
480
+ case 12:
481
+ _context4.next = 14;
427
482
  return _this3.refreshCartValidationPassed();
428
- case 13:
483
+ case 14:
484
+ _context4.next = 16;
485
+ 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
+ customerId: params.customerId
487
+ });
488
+ case 16:
429
489
  case "end":
430
490
  return _context4.stop();
431
491
  }
432
492
  }, _callee4);
433
493
  }))();
434
494
  this.customerLoginRefreshInFlight = refreshTask;
435
- _context5.prev = 12;
436
- _context5.next = 15;
495
+ _context5.prev = 14;
496
+ _context5.next = 17;
437
497
  return refreshTask;
438
- case 15:
439
- _context5.next = 20;
440
- break;
441
498
  case 17:
442
- _context5.prev = 17;
443
- _context5.t0 = _context5["catch"](12);
499
+ _context5.next = 22;
500
+ break;
501
+ case 19:
502
+ _context5.prev = 19;
503
+ _context5.t0 = _context5["catch"](14);
444
504
  throw _context5.t0;
445
- case 20:
446
- _context5.prev = 20;
505
+ case 22:
506
+ _context5.prev = 22;
447
507
  if (this.customerLoginRefreshInFlight === refreshTask) {
448
508
  this.customerLoginRefreshInFlight = null;
449
509
  this.customerLoginRefreshIdInFlight = null;
450
510
  }
451
- return _context5.finish(20);
452
- case 23:
511
+ return _context5.finish(22);
512
+ case 25:
453
513
  case "end":
454
514
  return _context5.stop();
455
515
  }
456
- }, _callee5, this, [[12, 17, 20, 23]]);
516
+ }, _callee5, this, [[14, 19, 22, 25]]);
457
517
  }));
458
518
  function refreshOrderMarketingAfterLogin(_x4) {
459
519
  return _refreshOrderMarketingAfterLogin.apply(this, arguments);
@@ -480,10 +540,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
480
540
  scheduleModule,
481
541
  quotationModule,
482
542
  openDataModule,
483
- _this$store$order,
484
543
  _this$store$order2,
485
- _this$store$quotation,
486
- _this$otherParams6,
544
+ _this$store$order3,
487
545
  _args6 = arguments;
488
546
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
489
547
  while (1) switch (_context6.prev = _context6.next) {
@@ -493,6 +551,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
493
551
  this.core = core;
494
552
  this.initializeOptions = options || {};
495
553
  this.store = _objectSpread(_objectSpread({}, this.store), options.store);
554
+ this.smartPricingCustomerId = undefined;
496
555
  this.store.entryContext = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.entryContext) || this.store.entryContext;
497
556
  this.store.status = 'initializing';
498
557
  this.store.error = null;
@@ -501,6 +560,12 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
501
560
  this.store.slotConfig = _objectSpread({}, this.baseSlotConfig);
502
561
  this.otherParams = options.otherParams || {};
503
562
  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
+ });
504
569
  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) || {};
505
570
  this.itemRuleConfigs = [];
506
571
  this.itemRuleConfigsPromise = null;
@@ -513,19 +578,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
513
578
  this.window = core.getPlugin('window');
514
579
  this.request = core.getPlugin('request');
515
580
  if (this.window) {
516
- _context6.next = 24;
581
+ _context6.next = 26;
517
582
  break;
518
583
  }
519
584
  this.logMethodError('initialize', 'window plugin missing');
520
585
  throw new Error('venueBooking解决方案需要 window 插件支持');
521
- case 24:
586
+ case 26:
522
587
  if (this.request) {
523
- _context6.next = 27;
588
+ _context6.next = 29;
524
589
  break;
525
590
  }
526
591
  this.logMethodError('initialize', 'request plugin missing');
527
592
  throw new Error('venueBooking解决方案需要 request 插件支持');
528
- case 27:
593
+ case 29:
529
594
  // 注册基础模块(order, salesSummary, products, logger)
530
595
  baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
531
596
  baseModules.forEach(function (step) {
@@ -622,27 +687,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
622
687
  }
623
688
  this.registerCustomerLoginListeners();
624
689
  console.log('[VenueBooking] 初始化开始');
625
- _context6.prev = 50;
626
- _context6.next = 53;
627
- return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
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({
628
693
  createIfMissing: false
629
694
  });
630
- case 53:
631
- (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
632
- _context6.next = 56;
695
+ case 55:
696
+ (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || _this$store$order3.persistTempOrder();
697
+ _context6.next = 58;
633
698
  return this.loadRuntimeConfigs();
634
- case 56:
699
+ case 58:
635
700
  if (!this.store.schedule) {
636
701
  _context6.next = 61;
637
702
  break;
638
703
  }
639
- _context6.next = 59;
704
+ _context6.next = 61;
640
705
  return this.store.schedule.loadAllSchedule();
641
- case 59:
642
- this.injectScheduleResolverToQuotation();
643
- (_this$store$quotation = this.store.quotation) === null || _this$store$quotation === void 0 || _this$store$quotation.loadQuotations({
644
- channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel
645
- });
646
706
  case 61:
647
707
  _context6.next = 63;
648
708
  return this.refreshItemRuleQuantityLimits();
@@ -661,7 +721,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
661
721
  break;
662
722
  case 70:
663
723
  _context6.prev = 70;
664
- _context6.t0 = _context6["catch"](50);
724
+ _context6.t0 = _context6["catch"](52);
665
725
  this.store.status = 'error';
666
726
  this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
667
727
  console.error('[VenueBooking] 初始化失败', _context6.t0);
@@ -673,7 +733,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
673
733
  case "end":
674
734
  return _context6.stop();
675
735
  }
676
- }, _callee6, this, [[50, 70]]);
736
+ }, _callee6, this, [[52, 70]]);
677
737
  }));
678
738
  function initialize(_x5) {
679
739
  return _initialize.apply(this, arguments);
@@ -814,26 +874,166 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
814
874
  };
815
875
  }
816
876
 
877
+ /** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
878
+ }, {
879
+ key: "clearSlotPriceMapCache",
880
+ value: function clearSlotPriceMapCache() {
881
+ this.slotPriceMapCache.clear();
882
+ }
883
+
884
+ /** 读取当前登录 customerId */
885
+ }, {
886
+ key: "resolveCustomerIdForSmartPricing",
887
+ value: function resolveCustomerIdForSmartPricing() {
888
+ if (this.smartPricingCustomerId) return this.smartPricingCustomerId;
889
+ try {
890
+ var _this$core2, _userPlugin$get;
891
+ var userPlugin = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.getPlugin('user');
892
+ var customerId = Number(userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get) === null || _userPlugin$get === void 0 || (_userPlugin$get = _userPlugin$get.call(userPlugin)) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id);
893
+ return Number.isFinite(customerId) && customerId > 0 ? customerId : undefined;
894
+ } catch (_unused2) {
895
+ return undefined;
896
+ }
897
+ }
898
+ }, {
899
+ key: "resolveAvailableWalletIdsForSmartPricing",
900
+ 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);
903
+ 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
+ var source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
905
+ if (!Array.isArray(source)) return [];
906
+ var ids = source.map(function (item) {
907
+ return Number(item);
908
+ }).filter(function (item) {
909
+ return Number.isFinite(item) && item > 0;
910
+ });
911
+ return Array.from(new Set(ids));
912
+ }
913
+
914
+ /** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
915
+ }, {
916
+ key: "getScheduleListForSmartPricing",
917
+ value: function getScheduleListForSmartPricing() {
918
+ var _store;
919
+ var scheduleModule = this.store.schedule;
920
+ var list = scheduleModule === null || scheduleModule === void 0 || (_store = scheduleModule.store) === null || _store === void 0 ? void 0 : _store.scheduleList;
921
+ return Array.isArray(list) ? list : [];
922
+ }
923
+
924
+ /** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
925
+ }, {
926
+ key: "buildSmartPricingContext",
927
+ 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;
937
+ 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({
939
+ evaluator: evaluator,
940
+ scheduleList: this.getScheduleListForSmartPricing(),
941
+ 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) || [],
942
+ customerId: customerId !== null && customerId !== void 0 ? customerId : this.resolveCustomerIdForSmartPricing(),
943
+ availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
944
+ channel: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.channel,
945
+ businessCode: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode,
946
+ 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
+ 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
+ } : {});
954
+ }
955
+
956
+ /** venue + addon 全量商品,供智能定价评估 */
957
+ }, {
958
+ key: "getAllProductsForSmartPricing",
959
+ value: function getAllProductsForSmartPricing() {
960
+ if (this.smartPricingProductCatalog.length) {
961
+ return this.smartPricingProductCatalog;
962
+ }
963
+ var venueList = this.getVenueProducts();
964
+ var addonList = this.getAddonProductsList();
965
+ return [].concat(_toConsumableArray(venueList), _toConsumableArray(addonList));
966
+ }
967
+ }, {
968
+ key: "getSlotPriceMapCacheKey",
969
+ value: function getSlotPriceMapCacheKey(date, context) {
970
+ var _context$customerId, _context$channel, _context$businessCode;
971
+ return [date, (_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '', (context.availableWalletIds || []).join(','), (_context$channel = context.channel) !== null && _context$channel !== void 0 ? _context$channel : '', (_context$businessCode = context.businessCode) !== null && _context$businessCode !== void 0 ? _context$businessCode : ''].join('|');
972
+ }
973
+
974
+ /**
975
+ * 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
976
+ */
977
+ }, {
978
+ key: "buildSlotPriceMapForDate",
979
+ value: function buildSlotPriceMapForDate(date, config, productIds) {
980
+ var context = this.buildSmartPricingContext();
981
+ var cacheKey = this.getSlotPriceMapCacheKey(date, context);
982
+ var cached = this.slotPriceMapCache.get(cacheKey);
983
+ if (cached) return cached;
984
+ var timeLabels = generateTimeLabels(config);
985
+ var slotPriceMap = buildSlotPriceMapByScheduleSegments({
986
+ products: this.getAllProductsForSmartPricing(),
987
+ productIds: productIds,
988
+ date: date,
989
+ timeLabels: timeLabels,
990
+ config: config,
991
+ context: context
992
+ });
993
+ this.slotPriceMapCache.set(cacheKey, slotPriceMap);
994
+ return slotPriceMap;
995
+ }
996
+
817
997
  // ─── 场地商品 & 附加商品 ───
818
998
  }, {
819
999
  key: "loadAllProducts",
820
1000
  value: function () {
821
1001
  var _loadAllProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
822
- var _this5 = this;
1002
+ var _this6 = this;
823
1003
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
824
1004
  while (1) switch (_context10.prev = _context10.next) {
825
1005
  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
+ });
826
1014
  if (!this.loadAllProductsInFlight) {
827
- _context10.next = 2;
1015
+ _context10.next = 4;
828
1016
  break;
829
1017
  }
1018
+ this.logPricingDiagnostics('[VenueBooking] loadAllProducts request skipped', {
1019
+ reason: 'reusing existing loadAllProductsInFlight promise',
1020
+ productsLoaded: this.productsLoaded
1021
+ });
830
1022
  return _context10.abrupt("return", this.loadAllProductsInFlight);
831
- case 2:
1023
+ case 4:
1024
+ this.logPricingDiagnostics('[VenueBooking] loadAllProducts request starting', {
1025
+ productsLoaded: this.productsLoaded,
1026
+ smartPricingCustomerId: this.smartPricingCustomerId
1027
+ });
832
1028
  this.loadAllProductsInFlight = this._doLoadAllProducts().finally(function () {
833
- _this5.loadAllProductsInFlight = null;
1029
+ _this6.logPricingDiagnostics('[VenueBooking] loadAllProducts request settled', {
1030
+ productsLoaded: _this6.productsLoaded,
1031
+ smartPricingProductCatalogCount: _this6.smartPricingProductCatalog.length
1032
+ });
1033
+ _this6.loadAllProductsInFlight = null;
834
1034
  });
835
1035
  return _context10.abrupt("return", this.loadAllProductsInFlight);
836
- case 4:
1036
+ case 7:
837
1037
  case "end":
838
1038
  return _context10.stop();
839
1039
  }
@@ -848,7 +1048,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
848
1048
  key: "_doLoadAllProducts",
849
1049
  value: function () {
850
1050
  var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
851
- var _this$otherParams7, _this$store$venueProd, associatedMenus, menuListIds, allProducts, list, venueList, addonList, venueStore;
1051
+ var _this$otherParams17, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, smartPricingContext, venueList, addonList, venueStore;
852
1052
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
853
1053
  while (1) switch (_context11.prev = _context11.next) {
854
1054
  case 0:
@@ -869,7 +1069,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
869
1069
  _context11.next = 8;
870
1070
  return this.loadOpenDataConfig();
871
1071
  case 8:
872
- associatedMenus = ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 || (_this$otherParams7 = _this$otherParams7.openData) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7['menu.associated_menus']) || [];
1072
+ associatedMenus = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.openData) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['menu.associated_menus']) || [];
873
1073
  if (associatedMenus.length) {
874
1074
  _context11.next = 12;
875
1075
  break;
@@ -885,11 +1085,28 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
885
1085
  menu_list_ids: menuListIds,
886
1086
  cacheId: this.cacheId,
887
1087
  schedule_date: dayjs().format('YYYY-MM-DD'),
888
- schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
1088
+ schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
1089
+ with_extra: ['dataVariants']
889
1090
  });
890
1091
  case 15:
891
1092
  allProducts = _context11.sent;
892
- list = Array.isArray(allProducts) ? allProducts : [];
1093
+ rawList = Array.isArray(allProducts) ? allProducts : [];
1094
+ list = rawList;
1095
+ 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
+ }
1109
+ this.clearSlotPriceMapCache();
893
1110
  venueList = list.filter(function (p) {
894
1111
  return p.duration != null;
895
1112
  });
@@ -915,16 +1132,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
915
1132
  venueProducts: venueList,
916
1133
  addonProducts: addonList
917
1134
  });
918
- case 28:
919
- _context11.prev = 28;
1135
+ case 34:
1136
+ _context11.prev = 34;
920
1137
  _context11.t0 = _context11["catch"](1);
921
1138
  this.logMethodError('loadAllProducts', _context11.t0);
922
1139
  throw _context11.t0;
923
- case 32:
1140
+ case 38:
924
1141
  case "end":
925
1142
  return _context11.stop();
926
1143
  }
927
- }, _callee11, this, [[1, 28]]);
1144
+ }, _callee11, this, [[1, 34]]);
928
1145
  }));
929
1146
  function _doLoadAllProducts() {
930
1147
  return _doLoadAllProducts2.apply(this, arguments);
@@ -939,12 +1156,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
939
1156
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
940
1157
  while (1) switch (_context12.prev = _context12.next) {
941
1158
  case 0:
942
- _context12.next = 2;
1159
+ this.logPricingDiagnostics('[VenueBooking] loadVenueProducts called', {
1160
+ hasLoadAllProductsInFlight: !!this.loadAllProductsInFlight,
1161
+ productsLoaded: this.productsLoaded
1162
+ });
1163
+ _context12.next = 3;
943
1164
  return this.loadAllProducts();
944
- case 2:
1165
+ case 3:
945
1166
  result = _context12.sent;
946
1167
  return _context12.abrupt("return", result.venueProducts);
947
- case 4:
1168
+ case 5:
948
1169
  case "end":
949
1170
  return _context12.stop();
950
1171
  }
@@ -1236,16 +1457,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1236
1457
  }, {
1237
1458
  key: "getDateRangeSummary",
1238
1459
  value: function getDateRangeSummary(params) {
1239
- var _this6 = this;
1460
+ var _this7 = this;
1240
1461
  return buildDateRangeSummary({
1241
1462
  startDate: params.startDate,
1242
1463
  endDate: params.endDate,
1243
1464
  config: this.baseSlotConfig,
1244
1465
  rawResources: this.store.rawResourceData,
1245
1466
  resourceProductMap: this.resourceProductMap,
1246
- quotationModule: this.store.quotation,
1247
1467
  resolveConfig: function resolveConfig(date) {
1248
- return _this6.resolveSlotConfigForDate(date);
1468
+ return _this7.resolveSlotConfigForDate(date);
1469
+ },
1470
+ buildSlotPriceMap: function buildSlotPriceMap(date, config, productIds) {
1471
+ return _this7.buildSlotPriceMapForDate(date, config, productIds);
1249
1472
  }
1250
1473
  });
1251
1474
  }
@@ -1253,26 +1476,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1253
1476
  key: "getTimeSlotGrid",
1254
1477
  value: function getTimeSlotGrid(date) {
1255
1478
  var resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
1256
- var quotationPriceMap;
1257
- if (this.store.quotation) {
1258
- var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).flat().map(function (m) {
1259
- return m.productId;
1260
- })));
1261
- var timeLabels = generateTimeLabels(resolvedSlotConfig);
1262
- var timePoints = timeLabels.map(function (label) {
1263
- return "".concat(date, " ").concat(label);
1264
- });
1265
- quotationPriceMap = this.store.quotation.buildProductPriceMap({
1266
- productIds: productIds,
1267
- timePoints: timePoints
1268
- });
1269
- }
1479
+ var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).flat().map(function (m) {
1480
+ return m.productId;
1481
+ })));
1482
+ var slotPriceMap = productIds.length ? this.buildSlotPriceMapForDate(date, resolvedSlotConfig, productIds) : undefined;
1270
1483
  return buildTimeSlotGrid({
1271
1484
  date: date,
1272
1485
  config: resolvedSlotConfig,
1273
1486
  rawResources: this.store.rawResourceData,
1274
1487
  resourceProductMap: this.resourceProductMap,
1275
- quotationPriceMap: quotationPriceMap
1488
+ slotPriceMap: slotPriceMap
1276
1489
  });
1277
1490
  }
1278
1491
 
@@ -1372,8 +1585,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1372
1585
  }, {
1373
1586
  key: "getSelectedSlotsForResource",
1374
1587
  value: function getSelectedSlotsForResource(resourceId, productId) {
1375
- var _this$store$order3;
1376
- var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
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();
1377
1590
  if (!tempOrder) return [];
1378
1591
  var venueProducts = tempOrder.products.filter(function (p) {
1379
1592
  var _p$metadata, _p$metadata2;
@@ -1438,7 +1651,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1438
1651
  }, {
1439
1652
  key: "isSlotDisabledBySelection",
1440
1653
  value: function isSlotDisabledBySelection(params) {
1441
- var _this7 = this;
1654
+ var _this8 = this;
1442
1655
  var resourceId = params.resourceId,
1443
1656
  productId = params.productId,
1444
1657
  startTime = params.startTime;
@@ -1460,7 +1673,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1460
1673
 
1461
1674
  // 组合资源字段缓存
1462
1675
  var getCombinedChildIds = function getCombinedChildIds(resId) {
1463
- var raw = _this7.store.rawResourceData.find(function (r) {
1676
+ var raw = _this8.store.rawResourceData.find(function (r) {
1464
1677
  return String(r.resourceId) === String(resId);
1465
1678
  });
1466
1679
  var combined = raw === null || raw === void 0 ? void 0 : raw.combined_resource;
@@ -1534,9 +1747,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1534
1747
  }, {
1535
1748
  key: "getAllSelectedSlots",
1536
1749
  value: function getAllSelectedSlots() {
1537
- var _this$store$order4;
1750
+ var _this$store$order6;
1538
1751
  var result = new Map();
1539
- var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
1752
+ var tempOrder = (_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder();
1540
1753
  if (!tempOrder) return result;
1541
1754
  var venueProducts = tempOrder.products.filter(function (p) {
1542
1755
  var _p$metadata3;
@@ -1708,8 +1921,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1708
1921
  booking_uid: bookingUuid,
1709
1922
  price_breakdown: buildPriceBreakdown({
1710
1923
  group: group,
1711
- productId: mapping.productId,
1712
- quotation: this.store.quotation
1924
+ productId: mapping.productId
1713
1925
  })
1714
1926
  },
1715
1927
  _origin: {
@@ -1780,7 +1992,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1780
1992
  }, {
1781
1993
  key: "getCombinedChildRawResources",
1782
1994
  value: function getCombinedChildRawResources(rawResource) {
1783
- var _this8 = this;
1995
+ var _this9 = this;
1784
1996
  if (!rawResource) return undefined;
1785
1997
  var combined = rawResource.combined_resource;
1786
1998
  if (!combined || combined.status !== 1 || !Array.isArray(combined.resource_ids) || !combined.resource_ids.length) {
@@ -1792,7 +2004,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1792
2004
  try {
1793
2005
  var _loop3 = function _loop3() {
1794
2006
  var id = _step11.value;
1795
- var child = _this8.store.rawResourceData.find(function (r) {
2007
+ var child = _this9.store.rawResourceData.find(function (r) {
1796
2008
  return String(r.resourceId) === String(id);
1797
2009
  });
1798
2010
  if (child) children.push(child);
@@ -1840,36 +2052,25 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1840
2052
  _context18.next = 6;
1841
2053
  return this.store.schedule.loadAllSchedule();
1842
2054
  case 6:
1843
- this.injectScheduleResolverToQuotation();
1844
2055
  this.logMethodSuccess('loadSchedules');
1845
- _context18.next = 14;
2056
+ _context18.next = 13;
1846
2057
  break;
1847
- case 10:
1848
- _context18.prev = 10;
2058
+ case 9:
2059
+ _context18.prev = 9;
1849
2060
  _context18.t0 = _context18["catch"](1);
1850
2061
  this.logMethodError('loadSchedules', _context18.t0);
1851
2062
  throw _context18.t0;
1852
- case 14:
2063
+ case 13:
1853
2064
  case "end":
1854
2065
  return _context18.stop();
1855
2066
  }
1856
- }, _callee18, this, [[1, 10]]);
2067
+ }, _callee18, this, [[1, 9]]);
1857
2068
  }));
1858
2069
  function loadSchedules() {
1859
2070
  return _loadSchedules.apply(this, arguments);
1860
2071
  }
1861
2072
  return loadSchedules;
1862
2073
  }()
1863
- }, {
1864
- key: "injectScheduleResolverToQuotation",
1865
- value: function injectScheduleResolverToQuotation() {
1866
- var _this9 = this;
1867
- if (this.store.quotation && this.store.schedule) {
1868
- this.store.quotation.setScheduleResolver(function (id) {
1869
- return _this9.store.schedule.getScheduleListByIds([id])[0];
1870
- });
1871
- }
1872
- }
1873
2074
  }, {
1874
2075
  key: "getScheduleListByIds",
1875
2076
  value: function getScheduleListByIds(ids) {
@@ -1881,8 +2082,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1881
2082
  }, {
1882
2083
  key: "getTempOrder",
1883
2084
  value: function getTempOrder() {
1884
- var _this$store$order5;
1885
- var result = ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder()) || null;
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;
1886
2087
  return result;
1887
2088
  }
1888
2089
  }, {
@@ -1941,14 +2142,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1941
2142
  return onCustomerLogin;
1942
2143
  }()
1943
2144
  }, {
1944
- key: "recalculateOrderPricesFromQuotation",
1945
- value: function recalculateOrderPricesFromQuotation() {
2145
+ key: "recalculateOrderPricesFromSmartPricing",
2146
+ value: function recalculateOrderPricesFromSmartPricing() {
1946
2147
  var _tempOrder$products,
1947
2148
  _this10 = this;
1948
- if (!this.store.order || !this.store.quotation) return;
2149
+ if (!this.store.order) return;
1949
2150
  var tempOrder = this.store.order.getTempOrder();
1950
2151
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
1951
2152
  var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
2153
+ var catalog = this.getAllProductsForSmartPricing();
2154
+ var context = this.buildSmartPricingContext();
1952
2155
  var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
1953
2156
  _step12;
1954
2157
  try {
@@ -1963,37 +2166,58 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
1963
2166
  }) || mappings[0];
1964
2167
  if (!mapping) return 0; // continue
1965
2168
  var slots = expandMergedSlotToIndividual(product, _this10.store.slotConfig.slotDurationMinutes);
2169
+ var uniqueDates = _toConsumableArray(new Set(slots.map(function (slot) {
2170
+ return dayjs(slot.startTime).format('YYYY-MM-DD');
2171
+ })));
2172
+ var slotPriceMaps = new Map();
2173
+ var _iterator13 = _createForOfIteratorHelper(uniqueDates),
2174
+ _step13;
2175
+ try {
2176
+ for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2177
+ var slotDate = _step13.value;
2178
+ slotPriceMaps.set(slotDate, _this10.buildSlotPriceMapForDate(slotDate, _this10.store.slotConfig, [mapping.productId]));
2179
+ }
2180
+ } catch (err) {
2181
+ _iterator13.e(err);
2182
+ } finally {
2183
+ _iterator13.f();
2184
+ }
1966
2185
  var updatedSlots = slots.map(function (slot) {
1967
- var _getPriceForProduct;
2186
+ var slotDate = dayjs(slot.startTime).format('YYYY-MM-DD');
2187
+ var slotPriceMap = slotPriceMaps.get(slotDate);
1968
2188
  return _objectSpread(_objectSpread({}, slot), {}, {
1969
2189
  productId: mapping.productId,
1970
- price: (_getPriceForProduct = _this10.store.quotation.getPriceForProduct({
2190
+ price: slotPriceMap ? getSlotPriceFromMap({
2191
+ slotPriceMap: slotPriceMap,
1971
2192
  productId: mapping.productId,
1972
- datetime: slot.startTime
1973
- })) !== null && _getPriceForProduct !== void 0 ? _getPriceForProduct : mapping.price
2193
+ slotStartTime: slot.startTime,
2194
+ fallbackPrice: mapping.price
2195
+ }) : mapping.price
1974
2196
  });
1975
2197
  });
1976
2198
  var merged = mergeConsecutiveSlots(updatedSlots);
1977
2199
  if (merged.length === 1) {
1978
- product.selling_price = merged[0].totalPrice;
1979
- product.original_price = merged[0].totalPrice;
1980
- product.metadata.price_breakdown = buildPriceBreakdown({
1981
- group: merged[0],
1982
- productId: mapping.productId,
1983
- quotation: _this10.store.quotation
2200
+ _this10.resetProductPriceForSmartPricing({
2201
+ product: product,
2202
+ price: merged[0].totalPrice,
2203
+ priceBreakdown: buildPriceBreakdown({
2204
+ group: merged[0],
2205
+ productId: mapping.productId
2206
+ })
1984
2207
  });
1985
2208
  }
1986
2209
  } else if (product.product_id != null) {
1987
- var _product$product_vari;
1988
- var quotationPrice = _this10.store.quotation.getPriceForProduct({
1989
- productId: product.product_id,
1990
- variantId: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : undefined,
1991
- datetime: now
2210
+ var smartPrice = getPriceForProductAtDatetime({
2211
+ products: catalog,
2212
+ context: context,
2213
+ productId: Number(product.product_id),
2214
+ datetime: now,
2215
+ fallbackPrice: product.selling_price
2216
+ });
2217
+ _this10.resetProductPriceForSmartPricing({
2218
+ product: product,
2219
+ price: smartPrice
1992
2220
  });
1993
- if (quotationPrice !== null) {
1994
- product.selling_price = quotationPrice;
1995
- product.original_price = quotationPrice;
1996
- }
1997
2221
  }
1998
2222
  },
1999
2223
  _ret;
@@ -2007,6 +2231,30 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2007
2231
  _iterator12.f();
2008
2232
  }
2009
2233
  }
2234
+
2235
+ /**
2236
+ * DataVariant 重算价格后,同步刷新订单展示、Rules 与 Summary 共用的价格口径。
2237
+ * Rules 会在本轮结束后根据当前客户的 discountList 重新写入实际折扣。
2238
+ */
2239
+ }, {
2240
+ key: "resetProductPriceForSmartPricing",
2241
+ value: function resetProductPriceForSmartPricing(params) {
2242
+ var product = params.product,
2243
+ price = params.price,
2244
+ priceBreakdown = params.priceBreakdown;
2245
+ var metadata = product.metadata || {};
2246
+ product.selling_price = price;
2247
+ product.original_price = price;
2248
+ product.discount_list = [];
2249
+ product.metadata = _objectSpread(_objectSpread(_objectSpread({}, metadata), priceBreakdown ? {
2250
+ price_breakdown: priceBreakdown
2251
+ } : {}), {}, {
2252
+ source_product_price: price,
2253
+ main_product_original_price: price,
2254
+ main_product_selling_price: price,
2255
+ price_schema_version: 2
2256
+ });
2257
+ }
2010
2258
  }, {
2011
2259
  key: "scanCode",
2012
2260
  value: function () {
@@ -2072,7 +2320,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2072
2320
  key: "setDiscountSelected",
2073
2321
  value: (function () {
2074
2322
  var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2075
- 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, _iterator13, _step13, d, selectedResourceIds, _iterator14, _step14, _product$_origin, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, afterApplyTarget, finalSummary, finalProduct, finalTarget;
2323
+ 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;
2076
2324
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2077
2325
  while (1) switch (_context21.prev = _context21.next) {
2078
2326
  case 0:
@@ -2132,123 +2380,118 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2132
2380
  }).map(function (d) {
2133
2381
  return d.id;
2134
2382
  }));
2135
- _iterator13 = _createForOfIteratorHelper(nextDiscountList);
2383
+ _iterator14 = _createForOfIteratorHelper(nextDiscountList);
2136
2384
  try {
2137
- for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
2138
- d = _step13.value;
2385
+ for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
2386
+ d = _step14.value;
2139
2387
  if (d.isSelected && !beforeSelectedIds.has(d.id)) {
2140
2388
  d.isSelected = false;
2141
2389
  }
2142
2390
  }
2143
2391
  } catch (err) {
2144
- _iterator13.e(err);
2392
+ _iterator14.e(err);
2145
2393
  } finally {
2146
- _iterator13.f();
2394
+ _iterator14.f();
2147
2395
  }
2148
2396
  }
2149
2397
  }
2150
2398
  }
2151
- selectedResourceIds = new Set(nextDiscountList.filter(function (d) {
2152
- return d.isSelected;
2153
- }).map(function (d) {
2154
- return d.id;
2155
- })); // 无条件归一化:不论 Rules 是否清空 discount_list、长度是否变化,
2156
- // 都以 original_price - Σ (当前选中 discount_list.amount) 重算 selling_price。
2157
- // 目的:避免 unselect 后 selling_price 残留、reselect 时把残留价带进下一轮 Rules 造成双折扣。
2158
- // 手动改价商品(_origin.isManualDiscount=true)不参与券流程归一化,保留手工价。
2159
- _iterator14 = _createForOfIteratorHelper(tempOrder.products);
2160
- _context21.prev = 19;
2161
- _iterator14.s();
2162
- case 21:
2163
- if ((_step14 = _iterator14.n()).done) {
2164
- _context21.next = 35;
2165
- break;
2166
- }
2167
- product = _step14.value;
2168
- if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
2169
- _context21.next = 25;
2170
- break;
2171
- }
2172
- return _context21.abrupt("continue", 33);
2173
- case 25:
2174
- // 1. 把 product.discount_list 和当前选中的 discount 对齐(剔除已取消的券)
2175
- product.discount_list = (product.discount_list || []).filter(function (pd) {
2176
- var _pd$discount$resource, _pd$discount;
2177
- var rid = (_pd$discount$resource = (_pd$discount = pd.discount) === null || _pd$discount === void 0 ? void 0 : _pd$discount.resource_id) !== null && _pd$discount$resource !== void 0 ? _pd$discount$resource : pd.id;
2178
- return rid != null && selectedResourceIds.has(rid);
2179
- });
2180
-
2181
- // 2. 以 source_product_price 为券作用基准:券作用于 source(不含 option),
2182
- // 再把 option 加回得到含 option 的 main_product_selling_price,最后合成 composite。
2183
- totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
2184
- return sum + (pd.amount || 0);
2185
- }, 0);
2186
- optionSum = sumOptionUnitPrice(product.product_option_item);
2187
- sourcePrice = (_product$metadata$sou = (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
2188
- newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
2189
- newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
2190
- if (product.metadata) {
2191
- product.metadata.main_product_selling_price = newMainSellingPrice;
2192
- product.metadata.price_schema_version = 2;
2193
- }
2194
- product.selling_price = composeLinePrice({
2195
- mainPrice: newMainSellingPrice,
2196
- bundle: product.product_bundle
2197
- });
2198
- case 33:
2199
- _context21.next = 21;
2200
- break;
2201
- case 35:
2202
- _context21.next = 40;
2203
- break;
2204
- case 37:
2205
- _context21.prev = 37;
2206
- _context21.t0 = _context21["catch"](19);
2207
- _iterator14.e(_context21.t0);
2208
- case 40:
2209
- _context21.prev = 40;
2210
- _iterator14.f();
2211
- return _context21.finish(40);
2212
- case 43:
2399
+ this.normalizeDiscountedOrderPrices(nextDiscountList);
2213
2400
  OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
2214
- _context21.next = 46;
2401
+ _context21.next = 21;
2215
2402
  return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
2216
- case 46:
2403
+ case 21:
2217
2404
  tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
2218
2405
  return d.isSelected;
2219
2406
  });
2220
2407
  afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
2221
2408
  return d.id === params.discountId;
2222
2409
  }) || null;
2223
- _context21.next = 50;
2410
+ _context21.next = 25;
2224
2411
  return this.store.order.recalculateSummary({
2225
2412
  createIfMissing: true
2226
2413
  });
2227
- case 50:
2414
+ case 25:
2228
2415
  this.store.order.persistTempOrder();
2229
- finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
2230
- 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;
2416
+ finalSummary = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null;
2417
+ 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;
2231
2418
  this.logMethodSuccess('setDiscountSelected', params);
2232
2419
  finalTarget = this.store.order.getDiscountList().find(function (d) {
2233
2420
  return d.id === params.discountId;
2234
2421
  }) || null;
2235
2422
  return _context21.abrupt("return", this.store.order.getDiscountList());
2236
- case 58:
2237
- _context21.prev = 58;
2238
- _context21.t1 = _context21["catch"](1);
2239
- this.logMethodError('setDiscountSelected', _context21.t1);
2240
- throw _context21.t1;
2241
- case 62:
2423
+ case 33:
2424
+ _context21.prev = 33;
2425
+ _context21.t0 = _context21["catch"](1);
2426
+ this.logMethodError('setDiscountSelected', _context21.t0);
2427
+ throw _context21.t0;
2428
+ case 37:
2242
2429
  case "end":
2243
2430
  return _context21.stop();
2244
2431
  }
2245
- }, _callee21, this, [[1, 58], [19, 37, 40, 43]]);
2432
+ }, _callee21, this, [[1, 33]]);
2246
2433
  }));
2247
2434
  function setDiscountSelected(_x15) {
2248
2435
  return _setDiscountSelected.apply(this, arguments);
2249
2436
  }
2250
2437
  return setDiscountSelected;
2251
- }())
2438
+ }()
2439
+ /**
2440
+ * 统一 VenueBooking 折扣后的订单行价。
2441
+ *
2442
+ * Rules 的 `discount_list.amount` 是已经按适用规则计算出的每件优惠额;它是这里唯一
2443
+ * 的折扣金额来源。使用智能定价写入的 source_product_price 减去该金额,再同步
2444
+ * selling_price 与 Summary 使用的 main_product_selling_price,避免 UI 的购物车行价、
2445
+ * 小计和提交订单各自读取到不同的价格字段。
2446
+ */
2447
+ )
2448
+ }, {
2449
+ key: "normalizeDiscountedOrderPrices",
2450
+ value: function normalizeDiscountedOrderPrices(discountList) {
2451
+ var order = this.store.order;
2452
+ if (!order) return;
2453
+ var tempOrder = order.ensureTempOrder();
2454
+ var selectedResourceIds = new Set((discountList || []).filter(function (discount) {
2455
+ return discount.isSelected;
2456
+ }).map(function (discount) {
2457
+ return discount.id;
2458
+ }));
2459
+ var _iterator15 = _createForOfIteratorHelper(tempOrder.products),
2460
+ _step15;
2461
+ try {
2462
+ for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
2463
+ var _product$_origin, _metadata$source_prod, _product$original_pri;
2464
+ var product = _step15.value;
2465
+ // 手动改价商品不参与券流程归一化,保留手工价格。
2466
+ if ((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount) continue;
2467
+
2468
+ // Rules 可能保留已取消折扣的明细;先使行级明细和当前选择状态一致。
2469
+ product.discount_list = (product.discount_list || []).filter(function (detail) {
2470
+ var _detail$discount$reso, _detail$discount;
2471
+ var resourceId = (_detail$discount$reso = (_detail$discount = detail.discount) === null || _detail$discount === void 0 ? void 0 : _detail$discount.resource_id) !== null && _detail$discount$reso !== void 0 ? _detail$discount$reso : detail.id;
2472
+ return resourceId != null && selectedResourceIds.has(resourceId);
2473
+ });
2474
+ var totalPerUnitDiscount = (product.discount_list || []).reduce(function (total, detail) {
2475
+ return total.plus(detail.amount || 0);
2476
+ }, new Decimal(0));
2477
+ var metadata = product.metadata || (product.metadata = {});
2478
+ var optionSum = sumOptionUnitPrice(product.product_option_item);
2479
+ var sourcePrice = (_metadata$source_prod = metadata.source_product_price) !== null && _metadata$source_prod !== void 0 ? _metadata$source_prod : metadata.main_product_original_price != null ? new Decimal(Number(metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
2480
+ var nextSourceSellingPrice = Decimal.max(0, new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount)).toDecimalPlaces(2).toString();
2481
+ var nextMainSellingPrice = new Decimal(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
2482
+ metadata.main_product_selling_price = nextMainSellingPrice;
2483
+ metadata.price_schema_version = 2;
2484
+ product.selling_price = composeLinePrice({
2485
+ mainPrice: nextMainSellingPrice,
2486
+ bundle: product.product_bundle
2487
+ });
2488
+ }
2489
+ } catch (err) {
2490
+ _iterator15.e(err);
2491
+ } finally {
2492
+ _iterator15.f();
2493
+ }
2494
+ }
2252
2495
  }, {
2253
2496
  key: "addNewOrder",
2254
2497
  value: function () {
@@ -2339,7 +2582,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2339
2582
  key: "submitOrder",
2340
2583
  value: function () {
2341
2584
  var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2342
- var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _tempOrder$products2, result, tempOrder;
2585
+ var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21, _tempOrder$products2, result, tempOrder;
2343
2586
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2344
2587
  while (1) switch (_context24.prev = _context24.next) {
2345
2588
  case 0:
@@ -2357,10 +2600,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2357
2600
  _context24.next = 8;
2358
2601
  return this.store.order.submitTempOrder({
2359
2602
  cacheId: this.cacheId,
2360
- platform: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform,
2361
- businessCode: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode,
2362
- channel: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.channel,
2363
- type: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.type
2603
+ platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
2604
+ businessCode: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode,
2605
+ channel: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.channel,
2606
+ type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
2364
2607
  });
2365
2608
  case 8:
2366
2609
  result = _context24.sent;
@@ -2436,7 +2679,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2436
2679
  key: "addProductToOrder",
2437
2680
  value: function () {
2438
2681
  var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(product) {
2439
- var _product$metadata5, _product$product_vari2, quotationPrice, products;
2682
+ var _product$metadata3, _product$metadata4, smartPrice, products;
2440
2683
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2441
2684
  while (1) switch (_context26.prev = _context26.next) {
2442
2685
  case 0:
@@ -2451,18 +2694,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2451
2694
  }
2452
2695
  throw new Error('order 模块未初始化');
2453
2696
  case 4:
2454
- if (!((_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) && this.store.quotation && product.product_id != null) {
2455
- quotationPrice = this.store.quotation.getPriceForProduct({
2456
- productId: product.product_id,
2457
- variantId: (_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : undefined,
2458
- datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
2697
+ if (!((_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.venue_booking) && product.product_id != null) {
2698
+ smartPrice = getPriceForProductAtDatetime({
2699
+ products: this.getAllProductsForSmartPricing(),
2700
+ context: this.buildSmartPricingContext(),
2701
+ productId: Number(product.product_id),
2702
+ datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
2703
+ fallbackPrice: product.selling_price
2459
2704
  });
2460
- if (quotationPrice !== null) {
2461
- product.selling_price = quotationPrice;
2462
- product.original_price = quotationPrice;
2463
- } else if (product.selling_price != null) {
2464
- product.original_price = product.selling_price;
2465
- }
2705
+ product.selling_price = smartPrice;
2706
+ product.original_price = smartPrice;
2707
+ } else if (product.selling_price != null && !((_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 && _product$metadata4.venue_booking)) {
2708
+ product.original_price = product.selling_price;
2466
2709
  }
2467
2710
  _context26.next = 7;
2468
2711
  return this.store.order.addProductToOrder(product);
@@ -2547,7 +2790,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2547
2790
  key: "removeProductFromOrder",
2548
2791
  value: function () {
2549
2792
  var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
2550
- var _this$store$order$get3, _this$store$order6, _this$store$order$ens, _this$store$order7, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator15, _step15, _product$metadata6, _product$metadata7, product, beforeBookingCount, _this$store$order$per, _this$store$order8;
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;
2551
2794
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2552
2795
  while (1) switch (_context28.prev = _context28.next) {
2553
2796
  case 0:
@@ -2562,7 +2805,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2562
2805
  }
2563
2806
  throw new Error('order 模块未初始化');
2564
2807
  case 4:
2565
- tempOrder = ((_this$store$order$get3 = (_this$store$order6 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order6)) || ((_this$store$order$ens = (_this$store$order7 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order7));
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));
2566
2809
  _context28.next = 7;
2567
2810
  return this.store.order.removeProductFromOrder(identity);
2568
2811
  case 7:
@@ -2573,23 +2816,23 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2573
2816
  }
2574
2817
  venueProductUids = new Set();
2575
2818
  venueBookingUids = new Set();
2576
- _iterator15 = _createForOfIteratorHelper(tempOrder.products || []);
2819
+ _iterator16 = _createForOfIteratorHelper(tempOrder.products || []);
2577
2820
  _context28.prev = 12;
2578
- _iterator15.s();
2821
+ _iterator16.s();
2579
2822
  case 14:
2580
- if ((_step15 = _iterator15.n()).done) {
2823
+ if ((_step16 = _iterator16.n()).done) {
2581
2824
  _context28.next = 22;
2582
2825
  break;
2583
2826
  }
2584
- product = _step15.value;
2585
- if (product !== null && product !== void 0 && (_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.venue_booking) {
2827
+ product = _step16.value;
2828
+ if (product !== null && product !== void 0 && (_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) {
2586
2829
  _context28.next = 18;
2587
2830
  break;
2588
2831
  }
2589
2832
  return _context28.abrupt("continue", 20);
2590
2833
  case 18:
2591
2834
  if (product.identity_key) venueProductUids.add(String(product.identity_key));
2592
- if ((_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.booking_uid) {
2835
+ if ((_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.booking_uid) {
2593
2836
  venueBookingUids.add(String(product.metadata.booking_uid));
2594
2837
  }
2595
2838
  case 20:
@@ -2601,10 +2844,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2601
2844
  case 24:
2602
2845
  _context28.prev = 24;
2603
2846
  _context28.t0 = _context28["catch"](12);
2604
- _iterator15.e(_context28.t0);
2847
+ _iterator16.e(_context28.t0);
2605
2848
  case 27:
2606
2849
  _context28.prev = 27;
2607
- _iterator15.f();
2850
+ _iterator16.f();
2608
2851
  return _context28.finish(27);
2609
2852
  case 30:
2610
2853
  beforeBookingCount = ((_tempOrder$bookings2 = tempOrder.bookings) === null || _tempOrder$bookings2 === void 0 ? void 0 : _tempOrder$bookings2.length) || 0;
@@ -2619,7 +2862,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2619
2862
  return true;
2620
2863
  });
2621
2864
  if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
2622
- (_this$store$order$per = (_this$store$order8 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order8);
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);
2623
2866
  }
2624
2867
  case 33:
2625
2868
  _context28.next = 35;
@@ -2657,17 +2900,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2657
2900
  while (1) switch (_context29.prev = _context29.next) {
2658
2901
  case 0:
2659
2902
  if (!this.productsLoaded) {
2660
- _context29.next = 2;
2903
+ _context29.next = 3;
2661
2904
  break;
2662
2905
  }
2906
+ this.logPricingDiagnostics('[VenueBooking] getProductList loadAllProducts skipped', {
2907
+ reason: 'productsLoaded is true',
2908
+ addonProductCount: this.getAddonProductsList().length,
2909
+ smartPricingProductCatalogCount: this.smartPricingProductCatalog.length
2910
+ });
2663
2911
  return _context29.abrupt("return", attachItemRuleLimitsToTopLevelProducts(this.getAddonProductsList(), this.store.itemRuleQuantityLimits || []));
2664
- case 2:
2665
- _context29.next = 4;
2912
+ case 3:
2913
+ _context29.next = 5;
2666
2914
  return this.loadAllProducts();
2667
- case 4:
2915
+ case 5:
2668
2916
  result = _context29.sent;
2669
2917
  return _context29.abrupt("return", attachItemRuleLimitsToTopLevelProducts(result.addonProducts, this.store.itemRuleQuantityLimits || []));
2670
- case 6:
2918
+ case 7:
2671
2919
  case "end":
2672
2920
  return _context29.stop();
2673
2921
  }
@@ -2852,17 +3100,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
2852
3100
  if (visited.has(value)) return;
2853
3101
  visited.add(value);
2854
3102
  if (Array.isArray(value)) {
2855
- var _iterator16 = _createForOfIteratorHelper(value),
2856
- _step16;
3103
+ var _iterator17 = _createForOfIteratorHelper(value),
3104
+ _step17;
2857
3105
  try {
2858
- for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
2859
- var item = _step16.value;
3106
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
3107
+ var item = _step17.value;
2860
3108
  collectFromValue(item);
2861
3109
  }
2862
3110
  } catch (err) {
2863
- _iterator16.e(err);
3111
+ _iterator17.e(err);
2864
3112
  } finally {
2865
- _iterator16.f();
3113
+ _iterator17.f();
2866
3114
  }
2867
3115
  return;
2868
3116
  }
@@ -3017,7 +3265,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3017
3265
  key: "applyPrefillByItemRule",
3018
3266
  value: function () {
3019
3267
  var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
3020
- var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator17, _step17, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct;
3268
+ var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator18, _step18, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct;
3021
3269
  return _regeneratorRuntime().wrap(function _callee37$(_context37) {
3022
3270
  while (1) switch (_context37.prev = _context37.next) {
3023
3271
  case 0:
@@ -3062,15 +3310,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3062
3310
  productSourceMap = _context37.sent;
3063
3311
  tempOrder = this.ensureTempOrder();
3064
3312
  hasChanges = false;
3065
- _iterator17 = _createForOfIteratorHelper(prefillItems);
3313
+ _iterator18 = _createForOfIteratorHelper(prefillItems);
3066
3314
  _context37.prev = 20;
3067
- _iterator17.s();
3315
+ _iterator18.s();
3068
3316
  case 22:
3069
- if ((_step17 = _iterator17.n()).done) {
3317
+ if ((_step18 = _iterator18.n()).done) {
3070
3318
  _context37.next = 45;
3071
3319
  break;
3072
3320
  }
3073
- prefillItem = _step17.value;
3321
+ prefillItem = _step18.value;
3074
3322
  productId = Number(prefillItem.product_id);
3075
3323
  productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
3076
3324
  targetQuantity = toNonNegativeInt(prefillItem.quantity);
@@ -3139,10 +3387,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3139
3387
  case 47:
3140
3388
  _context37.prev = 47;
3141
3389
  _context37.t0 = _context37["catch"](20);
3142
- _iterator17.e(_context37.t0);
3390
+ _iterator18.e(_context37.t0);
3143
3391
  case 50:
3144
3392
  _context37.prev = 50;
3145
- _iterator17.f();
3393
+ _iterator18.f();
3146
3394
  return _context37.finish(50);
3147
3395
  case 53:
3148
3396
  if (!hasChanges) {
@@ -3404,7 +3652,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3404
3652
  var raw = this.window.sessionStorage.getItem(key) || '{}';
3405
3653
  var parsed = JSON.parse(raw);
3406
3654
  return parsed && _typeof(parsed) === 'object' ? parsed : {};
3407
- } catch (_unused3) {
3655
+ } catch (_unused4) {
3408
3656
  return {};
3409
3657
  }
3410
3658
  }
@@ -3515,5 +3763,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
3515
3763
  }]);
3516
3764
  return VenueBookingImpl;
3517
3765
  }(BaseModule);
3766
+ _defineProperty(VenueBookingImpl, "PRICING_DEBUG_CACHE_ID", '031596279011848516');
3518
3767
  _defineProperty(VenueBookingImpl, "OPEN_DATA_CACHE_TTL", 5 * 60 * 1000);
3768
+ _defineProperty(VenueBookingImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
3519
3769
  _defineProperty(VenueBookingImpl, "UI_STATE_KEY_PREFIX", 'pisell.venueBooking.uiState:');