@pisell/pisellos 2.1.162 → 2.1.164
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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +21 -1
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +18 -6
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/ProductList/index.d.ts +3 -1
- package/dist/modules/ProductList/index.js +22 -11
- package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
- package/dist/solution/ScanOrder/index.js +1 -1
- package/dist/solution/ShopDiscount/index.js +16 -15
- package/dist/solution/VenueBooking/index.d.ts +40 -3
- package/dist/solution/VenueBooking/index.js +394 -261
- package/dist/solution/VenueBooking/types.d.ts +3 -1
- package/dist/solution/VenueBooking/types.js +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +12 -25
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -9
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +233 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +9 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +11 -1
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +11 -1
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/ProductList/index.d.ts +3 -1
- package/lib/modules/ProductList/index.js +45 -39
- package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
- package/lib/solution/ScanOrder/index.js +1 -1
- package/lib/solution/ShopDiscount/index.js +3 -2
- package/lib/solution/VenueBooking/index.d.ts +40 -3
- package/lib/solution/VenueBooking/index.js +257 -111
- package/lib/solution/VenueBooking/types.d.ts +3 -1
- package/lib/solution/VenueBooking/types.js +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +5 -10
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +180 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +7 -3
- 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, [{
|
|
@@ -321,16 +328,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
321
328
|
}, {
|
|
322
329
|
key: "registerCustomerLoginListeners",
|
|
323
330
|
value: function registerCustomerLoginListeners() {
|
|
324
|
-
var
|
|
325
|
-
_this$core3,
|
|
326
|
-
_accountModule$getCur,
|
|
327
|
-
_accountModule$getAcc,
|
|
328
|
-
_this2 = this;
|
|
331
|
+
var _this2 = this;
|
|
329
332
|
this.clearLoginEffectListeners();
|
|
330
|
-
var
|
|
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) {
|
|
333
|
+
var createHandleLogin = function createHandleLogin() {
|
|
334
334
|
return /*#__PURE__*/function () {
|
|
335
335
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
|
|
336
336
|
var customerId;
|
|
@@ -359,8 +359,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
359
359
|
};
|
|
360
360
|
}();
|
|
361
361
|
};
|
|
362
|
-
this.registerLoginEffect(
|
|
363
|
-
this.registerLoginEffect(
|
|
362
|
+
this.registerLoginEffect(VenueBookingImpl.PISELL1_LOGIN_SUCCESS, createHandleLogin());
|
|
363
|
+
this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin());
|
|
364
|
+
this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
|
|
364
365
|
}
|
|
365
366
|
}, {
|
|
366
367
|
key: "refreshOrderMarketingAfterLogin",
|
|
@@ -395,37 +396,40 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
395
396
|
case 9:
|
|
396
397
|
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
397
398
|
refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
398
|
-
var _this3$
|
|
399
|
+
var _this3$core, _this3$core$emit;
|
|
399
400
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
400
401
|
while (1) switch (_context4.prev = _context4.next) {
|
|
401
402
|
case 0:
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
break;
|
|
405
|
-
}
|
|
403
|
+
// 用户插件可能晚于登录 effect 更新;以已确认的登录 payload 作为本次及后续网格算价的身份来源。
|
|
404
|
+
_this3.smartPricingCustomerId = params.customerId;
|
|
406
405
|
_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
406
|
return _this3.store.order.loadDiscountConfig({
|
|
414
407
|
customerId: params.customerId
|
|
415
408
|
});
|
|
416
|
-
case
|
|
417
|
-
|
|
409
|
+
case 3:
|
|
410
|
+
_this3.clearSlotPriceMapCache();
|
|
411
|
+
_this3.recalculateOrderPricesFromSmartPricing();
|
|
412
|
+
// loadDiscountConfig 会按登录前的订单价格预计算一次券;智能价更新后必须用新的
|
|
413
|
+
// source/main 价格字段重新套券,否则购物车行价与 Summary 会使用两套基数。
|
|
414
|
+
_this3.store.order.applyDiscount();
|
|
415
|
+
_this3.normalizeDiscountedOrderPrices(_this3.store.order.getDiscountList());
|
|
416
|
+
_context4.next = 9;
|
|
418
417
|
return _this3.store.order.recalculateSummary({
|
|
419
418
|
createIfMissing: true
|
|
420
419
|
});
|
|
421
|
-
case
|
|
420
|
+
case 9:
|
|
422
421
|
_this3.store.order.persistTempOrder();
|
|
423
|
-
_context4.next =
|
|
422
|
+
_context4.next = 12;
|
|
424
423
|
return _this3.refreshItemRuleQuantityLimits();
|
|
425
|
-
case
|
|
426
|
-
_context4.next =
|
|
424
|
+
case 12:
|
|
425
|
+
_context4.next = 14;
|
|
427
426
|
return _this3.refreshCartValidationPassed();
|
|
428
|
-
case
|
|
427
|
+
case 14:
|
|
428
|
+
_context4.next = 16;
|
|
429
|
+
return (_this3$core = _this3.core) === null || _this3$core === void 0 || (_this3$core = _this3$core.effects) === null || _this3$core === void 0 || (_this3$core$emit = _this3$core.emit) === null || _this3$core$emit === void 0 ? void 0 : _this3$core$emit.call(_this3$core, VenueBookingHooks.onSmartPricingUpdated, {
|
|
430
|
+
customerId: params.customerId
|
|
431
|
+
});
|
|
432
|
+
case 16:
|
|
429
433
|
case "end":
|
|
430
434
|
return _context4.stop();
|
|
431
435
|
}
|
|
@@ -482,8 +486,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
482
486
|
openDataModule,
|
|
483
487
|
_this$store$order,
|
|
484
488
|
_this$store$order2,
|
|
485
|
-
_this$store$quotation,
|
|
486
|
-
_this$otherParams6,
|
|
487
489
|
_args6 = arguments;
|
|
488
490
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
489
491
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -493,6 +495,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
493
495
|
this.core = core;
|
|
494
496
|
this.initializeOptions = options || {};
|
|
495
497
|
this.store = _objectSpread(_objectSpread({}, this.store), options.store);
|
|
498
|
+
this.smartPricingCustomerId = undefined;
|
|
496
499
|
this.store.entryContext = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.entryContext) || this.store.entryContext;
|
|
497
500
|
this.store.status = 'initializing';
|
|
498
501
|
this.store.error = null;
|
|
@@ -513,19 +516,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
513
516
|
this.window = core.getPlugin('window');
|
|
514
517
|
this.request = core.getPlugin('request');
|
|
515
518
|
if (this.window) {
|
|
516
|
-
_context6.next =
|
|
519
|
+
_context6.next = 25;
|
|
517
520
|
break;
|
|
518
521
|
}
|
|
519
522
|
this.logMethodError('initialize', 'window plugin missing');
|
|
520
523
|
throw new Error('venueBooking解决方案需要 window 插件支持');
|
|
521
|
-
case
|
|
524
|
+
case 25:
|
|
522
525
|
if (this.request) {
|
|
523
|
-
_context6.next =
|
|
526
|
+
_context6.next = 28;
|
|
524
527
|
break;
|
|
525
528
|
}
|
|
526
529
|
this.logMethodError('initialize', 'request plugin missing');
|
|
527
530
|
throw new Error('venueBooking解决方案需要 request 插件支持');
|
|
528
|
-
case
|
|
531
|
+
case 28:
|
|
529
532
|
// 注册基础模块(order, salesSummary, products, logger)
|
|
530
533
|
baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
531
534
|
baseModules.forEach(function (step) {
|
|
@@ -622,46 +625,41 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
622
625
|
}
|
|
623
626
|
this.registerCustomerLoginListeners();
|
|
624
627
|
console.log('[VenueBooking] 初始化开始');
|
|
625
|
-
_context6.prev =
|
|
626
|
-
_context6.next =
|
|
628
|
+
_context6.prev = 51;
|
|
629
|
+
_context6.next = 54;
|
|
627
630
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
628
631
|
createIfMissing: false
|
|
629
632
|
});
|
|
630
|
-
case
|
|
633
|
+
case 54:
|
|
631
634
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
632
|
-
_context6.next =
|
|
635
|
+
_context6.next = 57;
|
|
633
636
|
return this.loadRuntimeConfigs();
|
|
634
|
-
case
|
|
637
|
+
case 57:
|
|
635
638
|
if (!this.store.schedule) {
|
|
636
|
-
_context6.next =
|
|
639
|
+
_context6.next = 60;
|
|
637
640
|
break;
|
|
638
641
|
}
|
|
639
|
-
_context6.next =
|
|
642
|
+
_context6.next = 60;
|
|
640
643
|
return this.store.schedule.loadAllSchedule();
|
|
641
|
-
case
|
|
642
|
-
|
|
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
|
-
case 61:
|
|
647
|
-
_context6.next = 63;
|
|
644
|
+
case 60:
|
|
645
|
+
_context6.next = 62;
|
|
648
646
|
return this.refreshItemRuleQuantityLimits();
|
|
649
|
-
case
|
|
647
|
+
case 62:
|
|
650
648
|
this.store.status = 'ready';
|
|
651
649
|
console.log('[VenueBooking] 初始化完成');
|
|
652
|
-
_context6.next =
|
|
650
|
+
_context6.next = 66;
|
|
653
651
|
return this.core.effects.emit(VenueBookingHooks.onInited, {
|
|
654
652
|
status: this.store.status
|
|
655
653
|
});
|
|
656
|
-
case
|
|
654
|
+
case 66:
|
|
657
655
|
this.logMethodSuccess('initialize', {
|
|
658
656
|
status: this.store.status
|
|
659
657
|
});
|
|
660
|
-
_context6.next =
|
|
658
|
+
_context6.next = 76;
|
|
661
659
|
break;
|
|
662
|
-
case
|
|
663
|
-
_context6.prev =
|
|
664
|
-
_context6.t0 = _context6["catch"](
|
|
660
|
+
case 69:
|
|
661
|
+
_context6.prev = 69;
|
|
662
|
+
_context6.t0 = _context6["catch"](51);
|
|
665
663
|
this.store.status = 'error';
|
|
666
664
|
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
|
|
667
665
|
console.error('[VenueBooking] 初始化失败', _context6.t0);
|
|
@@ -669,11 +667,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
669
667
|
status: this.store.status
|
|
670
668
|
});
|
|
671
669
|
throw _context6.t0;
|
|
672
|
-
case
|
|
670
|
+
case 76:
|
|
673
671
|
case "end":
|
|
674
672
|
return _context6.stop();
|
|
675
673
|
}
|
|
676
|
-
}, _callee6, this, [[
|
|
674
|
+
}, _callee6, this, [[51, 69]]);
|
|
677
675
|
}));
|
|
678
676
|
function initialize(_x5) {
|
|
679
677
|
return _initialize.apply(this, arguments);
|
|
@@ -814,6 +812,113 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
814
812
|
};
|
|
815
813
|
}
|
|
816
814
|
|
|
815
|
+
/** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
|
|
816
|
+
}, {
|
|
817
|
+
key: "clearSlotPriceMapCache",
|
|
818
|
+
value: function clearSlotPriceMapCache() {
|
|
819
|
+
this.slotPriceMapCache.clear();
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** 读取当前登录 customerId */
|
|
823
|
+
}, {
|
|
824
|
+
key: "resolveCustomerIdForSmartPricing",
|
|
825
|
+
value: function resolveCustomerIdForSmartPricing() {
|
|
826
|
+
if (this.smartPricingCustomerId) return this.smartPricingCustomerId;
|
|
827
|
+
try {
|
|
828
|
+
var _this$core2, _userPlugin$get;
|
|
829
|
+
var userPlugin = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.getPlugin('user');
|
|
830
|
+
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);
|
|
831
|
+
return Number.isFinite(customerId) && customerId > 0 ? customerId : undefined;
|
|
832
|
+
} catch (_unused2) {
|
|
833
|
+
return undefined;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}, {
|
|
837
|
+
key: "resolveAvailableWalletIdsForSmartPricing",
|
|
838
|
+
value: function resolveAvailableWalletIdsForSmartPricing() {
|
|
839
|
+
var _this$store$order3, _this$store$order3$ge, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
840
|
+
var orderWalletIds = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || (_this$store$order3$ge = _this$store$order3.getAvailableWalletIds) === null || _this$store$order3$ge === void 0 ? void 0 : _this$store$order3$ge.call(_this$store$order3);
|
|
841
|
+
var fallbackWalletIds = ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.available_wallet_ids) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.availableWalletIds) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.strategy_context) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.available_wallet_ids) || ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9 = _this$otherParams9.strategy_context) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.availableWalletIds);
|
|
842
|
+
var source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
|
|
843
|
+
if (!Array.isArray(source)) return [];
|
|
844
|
+
var ids = source.map(function (item) {
|
|
845
|
+
return Number(item);
|
|
846
|
+
}).filter(function (item) {
|
|
847
|
+
return Number.isFinite(item) && item > 0;
|
|
848
|
+
});
|
|
849
|
+
return Array.from(new Set(ids));
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
853
|
+
}, {
|
|
854
|
+
key: "getScheduleListForSmartPricing",
|
|
855
|
+
value: function getScheduleListForSmartPricing() {
|
|
856
|
+
var _store;
|
|
857
|
+
var scheduleModule = this.store.schedule;
|
|
858
|
+
var list = scheduleModule === null || scheduleModule === void 0 || (_store = scheduleModule.store) === null || _store === void 0 ? void 0 : _store.scheduleList;
|
|
859
|
+
return Array.isArray(list) ? list : [];
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
/** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
|
|
863
|
+
}, {
|
|
864
|
+
key: "buildSmartPricingContext",
|
|
865
|
+
value: function buildSmartPricingContext(customerId) {
|
|
866
|
+
var _this$core3, _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16;
|
|
867
|
+
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;
|
|
868
|
+
return {
|
|
869
|
+
evaluator: evaluator,
|
|
870
|
+
scheduleList: this.getScheduleListForSmartPricing(),
|
|
871
|
+
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) || [],
|
|
872
|
+
customerId: customerId !== null && customerId !== void 0 ? customerId : this.resolveCustomerIdForSmartPricing(),
|
|
873
|
+
availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
|
|
874
|
+
channel: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.channel,
|
|
875
|
+
businessCode: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode,
|
|
876
|
+
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),
|
|
877
|
+
strategy_context: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.strategy_context
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/** venue + addon 全量商品,供智能定价评估 */
|
|
882
|
+
}, {
|
|
883
|
+
key: "getAllProductsForSmartPricing",
|
|
884
|
+
value: function getAllProductsForSmartPricing() {
|
|
885
|
+
if (this.smartPricingProductCatalog.length) {
|
|
886
|
+
return this.smartPricingProductCatalog;
|
|
887
|
+
}
|
|
888
|
+
var venueList = this.getVenueProducts();
|
|
889
|
+
var addonList = this.getAddonProductsList();
|
|
890
|
+
return [].concat(_toConsumableArray(venueList), _toConsumableArray(addonList));
|
|
891
|
+
}
|
|
892
|
+
}, {
|
|
893
|
+
key: "getSlotPriceMapCacheKey",
|
|
894
|
+
value: function getSlotPriceMapCacheKey(date, context) {
|
|
895
|
+
var _context$customerId, _context$channel, _context$businessCode;
|
|
896
|
+
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('|');
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
|
|
901
|
+
*/
|
|
902
|
+
}, {
|
|
903
|
+
key: "buildSlotPriceMapForDate",
|
|
904
|
+
value: function buildSlotPriceMapForDate(date, config, productIds) {
|
|
905
|
+
var context = this.buildSmartPricingContext();
|
|
906
|
+
var cacheKey = this.getSlotPriceMapCacheKey(date, context);
|
|
907
|
+
var cached = this.slotPriceMapCache.get(cacheKey);
|
|
908
|
+
if (cached) return cached;
|
|
909
|
+
var timeLabels = generateTimeLabels(config);
|
|
910
|
+
var slotPriceMap = buildSlotPriceMapByScheduleSegments({
|
|
911
|
+
products: this.getAllProductsForSmartPricing(),
|
|
912
|
+
productIds: productIds,
|
|
913
|
+
date: date,
|
|
914
|
+
timeLabels: timeLabels,
|
|
915
|
+
config: config,
|
|
916
|
+
context: context
|
|
917
|
+
});
|
|
918
|
+
this.slotPriceMapCache.set(cacheKey, slotPriceMap);
|
|
919
|
+
return slotPriceMap;
|
|
920
|
+
}
|
|
921
|
+
|
|
817
922
|
// ─── 场地商品 & 附加商品 ───
|
|
818
923
|
}, {
|
|
819
924
|
key: "loadAllProducts",
|
|
@@ -848,7 +953,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
848
953
|
key: "_doLoadAllProducts",
|
|
849
954
|
value: function () {
|
|
850
955
|
var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
851
|
-
var _this$
|
|
956
|
+
var _this$otherParams17, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, venueList, addonList, venueStore;
|
|
852
957
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
853
958
|
while (1) switch (_context11.prev = _context11.next) {
|
|
854
959
|
case 0:
|
|
@@ -869,7 +974,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
869
974
|
_context11.next = 8;
|
|
870
975
|
return this.loadOpenDataConfig();
|
|
871
976
|
case 8:
|
|
872
|
-
associatedMenus = ((_this$
|
|
977
|
+
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
978
|
if (associatedMenus.length) {
|
|
874
979
|
_context11.next = 12;
|
|
875
980
|
break;
|
|
@@ -885,11 +990,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
885
990
|
menu_list_ids: menuListIds,
|
|
886
991
|
cacheId: this.cacheId,
|
|
887
992
|
schedule_date: dayjs().format('YYYY-MM-DD'),
|
|
888
|
-
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
993
|
+
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
994
|
+
with_extra: ['dataVariants']
|
|
889
995
|
});
|
|
890
996
|
case 15:
|
|
891
997
|
allProducts = _context11.sent;
|
|
892
|
-
|
|
998
|
+
rawList = Array.isArray(allProducts) ? allProducts : [];
|
|
999
|
+
list = rawList;
|
|
1000
|
+
this.smartPricingProductCatalog = rawList.slice();
|
|
1001
|
+
list = formatProductsWithDataVariant(list, this.buildSmartPricingContext(), dayjs().format('YYYY-MM-DD HH:mm:ss'));
|
|
1002
|
+
this.clearSlotPriceMapCache();
|
|
893
1003
|
venueList = list.filter(function (p) {
|
|
894
1004
|
return p.duration != null;
|
|
895
1005
|
});
|
|
@@ -915,16 +1025,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
1025
|
venueProducts: venueList,
|
|
916
1026
|
addonProducts: addonList
|
|
917
1027
|
});
|
|
918
|
-
case
|
|
919
|
-
_context11.prev =
|
|
1028
|
+
case 32:
|
|
1029
|
+
_context11.prev = 32;
|
|
920
1030
|
_context11.t0 = _context11["catch"](1);
|
|
921
1031
|
this.logMethodError('loadAllProducts', _context11.t0);
|
|
922
1032
|
throw _context11.t0;
|
|
923
|
-
case
|
|
1033
|
+
case 36:
|
|
924
1034
|
case "end":
|
|
925
1035
|
return _context11.stop();
|
|
926
1036
|
}
|
|
927
|
-
}, _callee11, this, [[1,
|
|
1037
|
+
}, _callee11, this, [[1, 32]]);
|
|
928
1038
|
}));
|
|
929
1039
|
function _doLoadAllProducts() {
|
|
930
1040
|
return _doLoadAllProducts2.apply(this, arguments);
|
|
@@ -1243,9 +1353,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1243
1353
|
config: this.baseSlotConfig,
|
|
1244
1354
|
rawResources: this.store.rawResourceData,
|
|
1245
1355
|
resourceProductMap: this.resourceProductMap,
|
|
1246
|
-
quotationModule: this.store.quotation,
|
|
1247
1356
|
resolveConfig: function resolveConfig(date) {
|
|
1248
1357
|
return _this6.resolveSlotConfigForDate(date);
|
|
1358
|
+
},
|
|
1359
|
+
buildSlotPriceMap: function buildSlotPriceMap(date, config, productIds) {
|
|
1360
|
+
return _this6.buildSlotPriceMapForDate(date, config, productIds);
|
|
1249
1361
|
}
|
|
1250
1362
|
});
|
|
1251
1363
|
}
|
|
@@ -1253,26 +1365,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1253
1365
|
key: "getTimeSlotGrid",
|
|
1254
1366
|
value: function getTimeSlotGrid(date) {
|
|
1255
1367
|
var resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
1256
|
-
var
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
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
|
-
}
|
|
1368
|
+
var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).flat().map(function (m) {
|
|
1369
|
+
return m.productId;
|
|
1370
|
+
})));
|
|
1371
|
+
var slotPriceMap = productIds.length ? this.buildSlotPriceMapForDate(date, resolvedSlotConfig, productIds) : undefined;
|
|
1270
1372
|
return buildTimeSlotGrid({
|
|
1271
1373
|
date: date,
|
|
1272
1374
|
config: resolvedSlotConfig,
|
|
1273
1375
|
rawResources: this.store.rawResourceData,
|
|
1274
1376
|
resourceProductMap: this.resourceProductMap,
|
|
1275
|
-
|
|
1377
|
+
slotPriceMap: slotPriceMap
|
|
1276
1378
|
});
|
|
1277
1379
|
}
|
|
1278
1380
|
|
|
@@ -1372,8 +1474,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1372
1474
|
}, {
|
|
1373
1475
|
key: "getSelectedSlotsForResource",
|
|
1374
1476
|
value: function getSelectedSlotsForResource(resourceId, productId) {
|
|
1375
|
-
var _this$store$
|
|
1376
|
-
var tempOrder = (_this$store$
|
|
1477
|
+
var _this$store$order4;
|
|
1478
|
+
var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
|
|
1377
1479
|
if (!tempOrder) return [];
|
|
1378
1480
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1379
1481
|
var _p$metadata, _p$metadata2;
|
|
@@ -1534,9 +1636,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1534
1636
|
}, {
|
|
1535
1637
|
key: "getAllSelectedSlots",
|
|
1536
1638
|
value: function getAllSelectedSlots() {
|
|
1537
|
-
var _this$store$
|
|
1639
|
+
var _this$store$order5;
|
|
1538
1640
|
var result = new Map();
|
|
1539
|
-
var tempOrder = (_this$store$
|
|
1641
|
+
var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
|
|
1540
1642
|
if (!tempOrder) return result;
|
|
1541
1643
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1542
1644
|
var _p$metadata3;
|
|
@@ -1708,8 +1810,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1708
1810
|
booking_uid: bookingUuid,
|
|
1709
1811
|
price_breakdown: buildPriceBreakdown({
|
|
1710
1812
|
group: group,
|
|
1711
|
-
productId: mapping.productId
|
|
1712
|
-
quotation: this.store.quotation
|
|
1813
|
+
productId: mapping.productId
|
|
1713
1814
|
})
|
|
1714
1815
|
},
|
|
1715
1816
|
_origin: {
|
|
@@ -1840,36 +1941,25 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1840
1941
|
_context18.next = 6;
|
|
1841
1942
|
return this.store.schedule.loadAllSchedule();
|
|
1842
1943
|
case 6:
|
|
1843
|
-
this.injectScheduleResolverToQuotation();
|
|
1844
1944
|
this.logMethodSuccess('loadSchedules');
|
|
1845
|
-
_context18.next =
|
|
1945
|
+
_context18.next = 13;
|
|
1846
1946
|
break;
|
|
1847
|
-
case
|
|
1848
|
-
_context18.prev =
|
|
1947
|
+
case 9:
|
|
1948
|
+
_context18.prev = 9;
|
|
1849
1949
|
_context18.t0 = _context18["catch"](1);
|
|
1850
1950
|
this.logMethodError('loadSchedules', _context18.t0);
|
|
1851
1951
|
throw _context18.t0;
|
|
1852
|
-
case
|
|
1952
|
+
case 13:
|
|
1853
1953
|
case "end":
|
|
1854
1954
|
return _context18.stop();
|
|
1855
1955
|
}
|
|
1856
|
-
}, _callee18, this, [[1,
|
|
1956
|
+
}, _callee18, this, [[1, 9]]);
|
|
1857
1957
|
}));
|
|
1858
1958
|
function loadSchedules() {
|
|
1859
1959
|
return _loadSchedules.apply(this, arguments);
|
|
1860
1960
|
}
|
|
1861
1961
|
return loadSchedules;
|
|
1862
1962
|
}()
|
|
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
1963
|
}, {
|
|
1874
1964
|
key: "getScheduleListByIds",
|
|
1875
1965
|
value: function getScheduleListByIds(ids) {
|
|
@@ -1881,8 +1971,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1881
1971
|
}, {
|
|
1882
1972
|
key: "getTempOrder",
|
|
1883
1973
|
value: function getTempOrder() {
|
|
1884
|
-
var _this$store$
|
|
1885
|
-
var result = ((_this$store$
|
|
1974
|
+
var _this$store$order6;
|
|
1975
|
+
var result = ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder()) || null;
|
|
1886
1976
|
return result;
|
|
1887
1977
|
}
|
|
1888
1978
|
}, {
|
|
@@ -1941,14 +2031,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1941
2031
|
return onCustomerLogin;
|
|
1942
2032
|
}()
|
|
1943
2033
|
}, {
|
|
1944
|
-
key: "
|
|
1945
|
-
value: function
|
|
2034
|
+
key: "recalculateOrderPricesFromSmartPricing",
|
|
2035
|
+
value: function recalculateOrderPricesFromSmartPricing() {
|
|
1946
2036
|
var _tempOrder$products,
|
|
1947
|
-
|
|
1948
|
-
if (!this.store.order
|
|
2037
|
+
_this9 = this;
|
|
2038
|
+
if (!this.store.order) return;
|
|
1949
2039
|
var tempOrder = this.store.order.getTempOrder();
|
|
1950
2040
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
|
|
1951
2041
|
var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2042
|
+
var catalog = this.getAllProductsForSmartPricing();
|
|
2043
|
+
var context = this.buildSmartPricingContext();
|
|
1952
2044
|
var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
|
|
1953
2045
|
_step12;
|
|
1954
2046
|
try {
|
|
@@ -1956,44 +2048,65 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1956
2048
|
var _product$metadata2;
|
|
1957
2049
|
var product = _step12.value;
|
|
1958
2050
|
if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
|
|
1959
|
-
var mappings =
|
|
2051
|
+
var mappings = _this9.resourceProductMap.get(product.metadata.resource_id);
|
|
1960
2052
|
if (!mappings || !mappings.length) return 0; // continue
|
|
1961
2053
|
var mapping = mappings.find(function (m) {
|
|
1962
2054
|
return Number(m.productId) === Number(product.product_id);
|
|
1963
2055
|
}) || mappings[0];
|
|
1964
2056
|
if (!mapping) return 0; // continue
|
|
1965
|
-
var slots = expandMergedSlotToIndividual(product,
|
|
2057
|
+
var slots = expandMergedSlotToIndividual(product, _this9.store.slotConfig.slotDurationMinutes);
|
|
2058
|
+
var uniqueDates = _toConsumableArray(new Set(slots.map(function (slot) {
|
|
2059
|
+
return dayjs(slot.startTime).format('YYYY-MM-DD');
|
|
2060
|
+
})));
|
|
2061
|
+
var slotPriceMaps = new Map();
|
|
2062
|
+
var _iterator13 = _createForOfIteratorHelper(uniqueDates),
|
|
2063
|
+
_step13;
|
|
2064
|
+
try {
|
|
2065
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2066
|
+
var slotDate = _step13.value;
|
|
2067
|
+
slotPriceMaps.set(slotDate, _this9.buildSlotPriceMapForDate(slotDate, _this9.store.slotConfig, [mapping.productId]));
|
|
2068
|
+
}
|
|
2069
|
+
} catch (err) {
|
|
2070
|
+
_iterator13.e(err);
|
|
2071
|
+
} finally {
|
|
2072
|
+
_iterator13.f();
|
|
2073
|
+
}
|
|
1966
2074
|
var updatedSlots = slots.map(function (slot) {
|
|
1967
|
-
var
|
|
2075
|
+
var slotDate = dayjs(slot.startTime).format('YYYY-MM-DD');
|
|
2076
|
+
var slotPriceMap = slotPriceMaps.get(slotDate);
|
|
1968
2077
|
return _objectSpread(_objectSpread({}, slot), {}, {
|
|
1969
2078
|
productId: mapping.productId,
|
|
1970
|
-
price:
|
|
2079
|
+
price: slotPriceMap ? getSlotPriceFromMap({
|
|
2080
|
+
slotPriceMap: slotPriceMap,
|
|
1971
2081
|
productId: mapping.productId,
|
|
1972
|
-
|
|
1973
|
-
|
|
2082
|
+
slotStartTime: slot.startTime,
|
|
2083
|
+
fallbackPrice: mapping.price
|
|
2084
|
+
}) : mapping.price
|
|
1974
2085
|
});
|
|
1975
2086
|
});
|
|
1976
2087
|
var merged = mergeConsecutiveSlots(updatedSlots);
|
|
1977
2088
|
if (merged.length === 1) {
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
2089
|
+
_this9.resetProductPriceForSmartPricing({
|
|
2090
|
+
product: product,
|
|
2091
|
+
price: merged[0].totalPrice,
|
|
2092
|
+
priceBreakdown: buildPriceBreakdown({
|
|
2093
|
+
group: merged[0],
|
|
2094
|
+
productId: mapping.productId
|
|
2095
|
+
})
|
|
1984
2096
|
});
|
|
1985
2097
|
}
|
|
1986
2098
|
} else if (product.product_id != null) {
|
|
1987
|
-
var
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
datetime: now
|
|
2099
|
+
var smartPrice = getPriceForProductAtDatetime({
|
|
2100
|
+
products: catalog,
|
|
2101
|
+
context: context,
|
|
2102
|
+
productId: Number(product.product_id),
|
|
2103
|
+
datetime: now,
|
|
2104
|
+
fallbackPrice: product.selling_price
|
|
2105
|
+
});
|
|
2106
|
+
_this9.resetProductPriceForSmartPricing({
|
|
2107
|
+
product: product,
|
|
2108
|
+
price: smartPrice
|
|
1992
2109
|
});
|
|
1993
|
-
if (quotationPrice !== null) {
|
|
1994
|
-
product.selling_price = quotationPrice;
|
|
1995
|
-
product.original_price = quotationPrice;
|
|
1996
|
-
}
|
|
1997
2110
|
}
|
|
1998
2111
|
},
|
|
1999
2112
|
_ret;
|
|
@@ -2007,6 +2120,30 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2007
2120
|
_iterator12.f();
|
|
2008
2121
|
}
|
|
2009
2122
|
}
|
|
2123
|
+
|
|
2124
|
+
/**
|
|
2125
|
+
* DataVariant 重算价格后,同步刷新订单展示、Rules 与 Summary 共用的价格口径。
|
|
2126
|
+
* Rules 会在本轮结束后根据当前客户的 discountList 重新写入实际折扣。
|
|
2127
|
+
*/
|
|
2128
|
+
}, {
|
|
2129
|
+
key: "resetProductPriceForSmartPricing",
|
|
2130
|
+
value: function resetProductPriceForSmartPricing(params) {
|
|
2131
|
+
var product = params.product,
|
|
2132
|
+
price = params.price,
|
|
2133
|
+
priceBreakdown = params.priceBreakdown;
|
|
2134
|
+
var metadata = product.metadata || {};
|
|
2135
|
+
product.selling_price = price;
|
|
2136
|
+
product.original_price = price;
|
|
2137
|
+
product.discount_list = [];
|
|
2138
|
+
product.metadata = _objectSpread(_objectSpread(_objectSpread({}, metadata), priceBreakdown ? {
|
|
2139
|
+
price_breakdown: priceBreakdown
|
|
2140
|
+
} : {}), {}, {
|
|
2141
|
+
source_product_price: price,
|
|
2142
|
+
main_product_original_price: price,
|
|
2143
|
+
main_product_selling_price: price,
|
|
2144
|
+
price_schema_version: 2
|
|
2145
|
+
});
|
|
2146
|
+
}
|
|
2010
2147
|
}, {
|
|
2011
2148
|
key: "scanCode",
|
|
2012
2149
|
value: function () {
|
|
@@ -2072,7 +2209,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2072
2209
|
key: "setDiscountSelected",
|
|
2073
2210
|
value: (function () {
|
|
2074
2211
|
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,
|
|
2212
|
+
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator14, _step14, d, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
2076
2213
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2077
2214
|
while (1) switch (_context21.prev = _context21.next) {
|
|
2078
2215
|
case 0:
|
|
@@ -2132,99 +2269,38 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2132
2269
|
}).map(function (d) {
|
|
2133
2270
|
return d.id;
|
|
2134
2271
|
}));
|
|
2135
|
-
|
|
2272
|
+
_iterator14 = _createForOfIteratorHelper(nextDiscountList);
|
|
2136
2273
|
try {
|
|
2137
|
-
for (
|
|
2138
|
-
d =
|
|
2274
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
2275
|
+
d = _step14.value;
|
|
2139
2276
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
2140
2277
|
d.isSelected = false;
|
|
2141
2278
|
}
|
|
2142
2279
|
}
|
|
2143
2280
|
} catch (err) {
|
|
2144
|
-
|
|
2281
|
+
_iterator14.e(err);
|
|
2145
2282
|
} finally {
|
|
2146
|
-
|
|
2283
|
+
_iterator14.f();
|
|
2147
2284
|
}
|
|
2148
2285
|
}
|
|
2149
2286
|
}
|
|
2150
2287
|
}
|
|
2151
|
-
|
|
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:
|
|
2288
|
+
this.normalizeDiscountedOrderPrices(nextDiscountList);
|
|
2213
2289
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2214
|
-
_context21.next =
|
|
2290
|
+
_context21.next = 21;
|
|
2215
2291
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2216
|
-
case
|
|
2292
|
+
case 21:
|
|
2217
2293
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2218
2294
|
return d.isSelected;
|
|
2219
2295
|
});
|
|
2220
2296
|
afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
|
|
2221
2297
|
return d.id === params.discountId;
|
|
2222
2298
|
}) || null;
|
|
2223
|
-
_context21.next =
|
|
2299
|
+
_context21.next = 25;
|
|
2224
2300
|
return this.store.order.recalculateSummary({
|
|
2225
2301
|
createIfMissing: true
|
|
2226
2302
|
});
|
|
2227
|
-
case
|
|
2303
|
+
case 25:
|
|
2228
2304
|
this.store.order.persistTempOrder();
|
|
2229
2305
|
finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
|
|
2230
2306
|
finalProduct = ((_this$store$order$get2 = this.store.order.getTempOrder()) === null || _this$store$order$get2 === void 0 || (_this$store$order$get2 = _this$store$order$get2.products) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2[0]) || null;
|
|
@@ -2233,22 +2309,78 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2233
2309
|
return d.id === params.discountId;
|
|
2234
2310
|
}) || null;
|
|
2235
2311
|
return _context21.abrupt("return", this.store.order.getDiscountList());
|
|
2236
|
-
case
|
|
2237
|
-
_context21.prev =
|
|
2238
|
-
_context21.
|
|
2239
|
-
this.logMethodError('setDiscountSelected', _context21.
|
|
2240
|
-
throw _context21.
|
|
2241
|
-
case
|
|
2312
|
+
case 33:
|
|
2313
|
+
_context21.prev = 33;
|
|
2314
|
+
_context21.t0 = _context21["catch"](1);
|
|
2315
|
+
this.logMethodError('setDiscountSelected', _context21.t0);
|
|
2316
|
+
throw _context21.t0;
|
|
2317
|
+
case 37:
|
|
2242
2318
|
case "end":
|
|
2243
2319
|
return _context21.stop();
|
|
2244
2320
|
}
|
|
2245
|
-
}, _callee21, this, [[1,
|
|
2321
|
+
}, _callee21, this, [[1, 33]]);
|
|
2246
2322
|
}));
|
|
2247
2323
|
function setDiscountSelected(_x15) {
|
|
2248
2324
|
return _setDiscountSelected.apply(this, arguments);
|
|
2249
2325
|
}
|
|
2250
2326
|
return setDiscountSelected;
|
|
2251
|
-
}()
|
|
2327
|
+
}()
|
|
2328
|
+
/**
|
|
2329
|
+
* 统一 VenueBooking 折扣后的订单行价。
|
|
2330
|
+
*
|
|
2331
|
+
* Rules 的 `discount_list.amount` 是已经按适用规则计算出的每件优惠额;它是这里唯一
|
|
2332
|
+
* 的折扣金额来源。使用智能定价写入的 source_product_price 减去该金额,再同步
|
|
2333
|
+
* selling_price 与 Summary 使用的 main_product_selling_price,避免 UI 的购物车行价、
|
|
2334
|
+
* 小计和提交订单各自读取到不同的价格字段。
|
|
2335
|
+
*/
|
|
2336
|
+
)
|
|
2337
|
+
}, {
|
|
2338
|
+
key: "normalizeDiscountedOrderPrices",
|
|
2339
|
+
value: function normalizeDiscountedOrderPrices(discountList) {
|
|
2340
|
+
var order = this.store.order;
|
|
2341
|
+
if (!order) return;
|
|
2342
|
+
var tempOrder = order.ensureTempOrder();
|
|
2343
|
+
var selectedResourceIds = new Set((discountList || []).filter(function (discount) {
|
|
2344
|
+
return discount.isSelected;
|
|
2345
|
+
}).map(function (discount) {
|
|
2346
|
+
return discount.id;
|
|
2347
|
+
}));
|
|
2348
|
+
var _iterator15 = _createForOfIteratorHelper(tempOrder.products),
|
|
2349
|
+
_step15;
|
|
2350
|
+
try {
|
|
2351
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
2352
|
+
var _product$_origin, _metadata$source_prod, _product$original_pri;
|
|
2353
|
+
var product = _step15.value;
|
|
2354
|
+
// 手动改价商品不参与券流程归一化,保留手工价格。
|
|
2355
|
+
if ((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount) continue;
|
|
2356
|
+
|
|
2357
|
+
// Rules 可能保留已取消折扣的明细;先使行级明细和当前选择状态一致。
|
|
2358
|
+
product.discount_list = (product.discount_list || []).filter(function (detail) {
|
|
2359
|
+
var _detail$discount$reso, _detail$discount;
|
|
2360
|
+
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;
|
|
2361
|
+
return resourceId != null && selectedResourceIds.has(resourceId);
|
|
2362
|
+
});
|
|
2363
|
+
var totalPerUnitDiscount = (product.discount_list || []).reduce(function (total, detail) {
|
|
2364
|
+
return total.plus(detail.amount || 0);
|
|
2365
|
+
}, new Decimal(0));
|
|
2366
|
+
var metadata = product.metadata || (product.metadata = {});
|
|
2367
|
+
var optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
2368
|
+
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';
|
|
2369
|
+
var nextSourceSellingPrice = Decimal.max(0, new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount)).toDecimalPlaces(2).toString();
|
|
2370
|
+
var nextMainSellingPrice = new Decimal(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
2371
|
+
metadata.main_product_selling_price = nextMainSellingPrice;
|
|
2372
|
+
metadata.price_schema_version = 2;
|
|
2373
|
+
product.selling_price = composeLinePrice({
|
|
2374
|
+
mainPrice: nextMainSellingPrice,
|
|
2375
|
+
bundle: product.product_bundle
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
} catch (err) {
|
|
2379
|
+
_iterator15.e(err);
|
|
2380
|
+
} finally {
|
|
2381
|
+
_iterator15.f();
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2252
2384
|
}, {
|
|
2253
2385
|
key: "addNewOrder",
|
|
2254
2386
|
value: function () {
|
|
@@ -2339,7 +2471,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2339
2471
|
key: "submitOrder",
|
|
2340
2472
|
value: function () {
|
|
2341
2473
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2342
|
-
var _this$
|
|
2474
|
+
var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21, _tempOrder$products2, result, tempOrder;
|
|
2343
2475
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2344
2476
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2345
2477
|
case 0:
|
|
@@ -2357,10 +2489,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2357
2489
|
_context24.next = 8;
|
|
2358
2490
|
return this.store.order.submitTempOrder({
|
|
2359
2491
|
cacheId: this.cacheId,
|
|
2360
|
-
platform: (_this$
|
|
2361
|
-
businessCode: (_this$
|
|
2362
|
-
channel: (_this$
|
|
2363
|
-
type: (_this$
|
|
2492
|
+
platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
2493
|
+
businessCode: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode,
|
|
2494
|
+
channel: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.channel,
|
|
2495
|
+
type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
|
|
2364
2496
|
});
|
|
2365
2497
|
case 8:
|
|
2366
2498
|
result = _context24.sent;
|
|
@@ -2389,7 +2521,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2389
2521
|
key: "addProductToOrder",
|
|
2390
2522
|
value: function () {
|
|
2391
2523
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(product) {
|
|
2392
|
-
var _product$
|
|
2524
|
+
var _product$metadata3, _product$metadata4, smartPrice, products;
|
|
2393
2525
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2394
2526
|
while (1) switch (_context25.prev = _context25.next) {
|
|
2395
2527
|
case 0:
|
|
@@ -2404,18 +2536,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2404
2536
|
}
|
|
2405
2537
|
throw new Error('order 模块未初始化');
|
|
2406
2538
|
case 4:
|
|
2407
|
-
if (!((_product$
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2539
|
+
if (!((_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.venue_booking) && product.product_id != null) {
|
|
2540
|
+
smartPrice = getPriceForProductAtDatetime({
|
|
2541
|
+
products: this.getAllProductsForSmartPricing(),
|
|
2542
|
+
context: this.buildSmartPricingContext(),
|
|
2543
|
+
productId: Number(product.product_id),
|
|
2544
|
+
datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
2545
|
+
fallbackPrice: product.selling_price
|
|
2412
2546
|
});
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
product.original_price = product.selling_price;
|
|
2418
|
-
}
|
|
2547
|
+
product.selling_price = smartPrice;
|
|
2548
|
+
product.original_price = smartPrice;
|
|
2549
|
+
} else if (product.selling_price != null && !((_product$metadata4 = product.metadata) !== null && _product$metadata4 !== void 0 && _product$metadata4.venue_booking)) {
|
|
2550
|
+
product.original_price = product.selling_price;
|
|
2419
2551
|
}
|
|
2420
2552
|
_context25.next = 7;
|
|
2421
2553
|
return this.store.order.addProductToOrder(product);
|
|
@@ -2500,7 +2632,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2500
2632
|
key: "removeProductFromOrder",
|
|
2501
2633
|
value: function () {
|
|
2502
2634
|
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identity) {
|
|
2503
|
-
var _this$store$order$get3, _this$store$
|
|
2635
|
+
var _this$store$order$get3, _this$store$order7, _this$store$order$ens, _this$store$order8, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator16, _step16, _product$metadata5, _product$metadata6, product, beforeBookingCount, _this$store$order$per, _this$store$order9;
|
|
2504
2636
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2505
2637
|
while (1) switch (_context27.prev = _context27.next) {
|
|
2506
2638
|
case 0:
|
|
@@ -2515,7 +2647,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2515
2647
|
}
|
|
2516
2648
|
throw new Error('order 模块未初始化');
|
|
2517
2649
|
case 4:
|
|
2518
|
-
tempOrder = ((_this$store$order$get3 = (_this$store$
|
|
2650
|
+
tempOrder = ((_this$store$order$get3 = (_this$store$order7 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order7)) || ((_this$store$order$ens = (_this$store$order8 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order8));
|
|
2519
2651
|
_context27.next = 7;
|
|
2520
2652
|
return this.store.order.removeProductFromOrder(identity);
|
|
2521
2653
|
case 7:
|
|
@@ -2526,23 +2658,23 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2526
2658
|
}
|
|
2527
2659
|
venueProductUids = new Set();
|
|
2528
2660
|
venueBookingUids = new Set();
|
|
2529
|
-
|
|
2661
|
+
_iterator16 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2530
2662
|
_context27.prev = 12;
|
|
2531
|
-
|
|
2663
|
+
_iterator16.s();
|
|
2532
2664
|
case 14:
|
|
2533
|
-
if ((
|
|
2665
|
+
if ((_step16 = _iterator16.n()).done) {
|
|
2534
2666
|
_context27.next = 22;
|
|
2535
2667
|
break;
|
|
2536
2668
|
}
|
|
2537
|
-
product =
|
|
2538
|
-
if (product !== null && product !== void 0 && (_product$
|
|
2669
|
+
product = _step16.value;
|
|
2670
|
+
if (product !== null && product !== void 0 && (_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) {
|
|
2539
2671
|
_context27.next = 18;
|
|
2540
2672
|
break;
|
|
2541
2673
|
}
|
|
2542
2674
|
return _context27.abrupt("continue", 20);
|
|
2543
2675
|
case 18:
|
|
2544
2676
|
if (product.identity_key) venueProductUids.add(String(product.identity_key));
|
|
2545
|
-
if ((_product$
|
|
2677
|
+
if ((_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.booking_uid) {
|
|
2546
2678
|
venueBookingUids.add(String(product.metadata.booking_uid));
|
|
2547
2679
|
}
|
|
2548
2680
|
case 20:
|
|
@@ -2554,10 +2686,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2554
2686
|
case 24:
|
|
2555
2687
|
_context27.prev = 24;
|
|
2556
2688
|
_context27.t0 = _context27["catch"](12);
|
|
2557
|
-
|
|
2689
|
+
_iterator16.e(_context27.t0);
|
|
2558
2690
|
case 27:
|
|
2559
2691
|
_context27.prev = 27;
|
|
2560
|
-
|
|
2692
|
+
_iterator16.f();
|
|
2561
2693
|
return _context27.finish(27);
|
|
2562
2694
|
case 30:
|
|
2563
2695
|
beforeBookingCount = ((_tempOrder$bookings2 = tempOrder.bookings) === null || _tempOrder$bookings2 === void 0 ? void 0 : _tempOrder$bookings2.length) || 0;
|
|
@@ -2572,7 +2704,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2572
2704
|
return true;
|
|
2573
2705
|
});
|
|
2574
2706
|
if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
|
|
2575
|
-
(_this$store$order$per = (_this$store$
|
|
2707
|
+
(_this$store$order$per = (_this$store$order9 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order9);
|
|
2576
2708
|
}
|
|
2577
2709
|
case 33:
|
|
2578
2710
|
_context27.next = 35;
|
|
@@ -2805,17 +2937,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2805
2937
|
if (visited.has(value)) return;
|
|
2806
2938
|
visited.add(value);
|
|
2807
2939
|
if (Array.isArray(value)) {
|
|
2808
|
-
var
|
|
2809
|
-
|
|
2940
|
+
var _iterator17 = _createForOfIteratorHelper(value),
|
|
2941
|
+
_step17;
|
|
2810
2942
|
try {
|
|
2811
|
-
for (
|
|
2812
|
-
var item =
|
|
2943
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
2944
|
+
var item = _step17.value;
|
|
2813
2945
|
collectFromValue(item);
|
|
2814
2946
|
}
|
|
2815
2947
|
} catch (err) {
|
|
2816
|
-
|
|
2948
|
+
_iterator17.e(err);
|
|
2817
2949
|
} finally {
|
|
2818
|
-
|
|
2950
|
+
_iterator17.f();
|
|
2819
2951
|
}
|
|
2820
2952
|
return;
|
|
2821
2953
|
}
|
|
@@ -2863,7 +2995,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2863
2995
|
key: "ensureItemRuleConfigsLoaded",
|
|
2864
2996
|
value: function () {
|
|
2865
2997
|
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2866
|
-
var
|
|
2998
|
+
var _this10 = this;
|
|
2867
2999
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2868
3000
|
while (1) switch (_context34.prev = _context34.next) {
|
|
2869
3001
|
case 0:
|
|
@@ -2884,19 +3016,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2884
3016
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2885
3017
|
while (1) switch (_context33.prev = _context33.next) {
|
|
2886
3018
|
case 0:
|
|
2887
|
-
runtimeConfig =
|
|
3019
|
+
runtimeConfig = _this10.getItemRuleRuntimeConfig();
|
|
2888
3020
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
2889
3021
|
if (!(staticConfigs.length > 0)) {
|
|
2890
3022
|
_context33.next = 6;
|
|
2891
3023
|
break;
|
|
2892
3024
|
}
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
return _context33.abrupt("return",
|
|
3025
|
+
_this10.itemRuleConfigs = staticConfigs;
|
|
3026
|
+
_this10.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
3027
|
+
return _context33.abrupt("return", _this10.itemRuleConfigs);
|
|
2896
3028
|
case 6:
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
return _context33.abrupt("return",
|
|
3029
|
+
_this10.itemRuleConfigs = [];
|
|
3030
|
+
_this10.itemRuleEvaluator.setStrategyConfigs([]);
|
|
3031
|
+
return _context33.abrupt("return", _this10.itemRuleConfigs);
|
|
2900
3032
|
case 9:
|
|
2901
3033
|
case "end":
|
|
2902
3034
|
return _context33.stop();
|
|
@@ -2970,7 +3102,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2970
3102
|
key: "applyPrefillByItemRule",
|
|
2971
3103
|
value: function () {
|
|
2972
3104
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2973
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
3105
|
+
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;
|
|
2974
3106
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2975
3107
|
while (1) switch (_context36.prev = _context36.next) {
|
|
2976
3108
|
case 0:
|
|
@@ -3015,15 +3147,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3015
3147
|
productSourceMap = _context36.sent;
|
|
3016
3148
|
tempOrder = this.ensureTempOrder();
|
|
3017
3149
|
hasChanges = false;
|
|
3018
|
-
|
|
3150
|
+
_iterator18 = _createForOfIteratorHelper(prefillItems);
|
|
3019
3151
|
_context36.prev = 20;
|
|
3020
|
-
|
|
3152
|
+
_iterator18.s();
|
|
3021
3153
|
case 22:
|
|
3022
|
-
if ((
|
|
3154
|
+
if ((_step18 = _iterator18.n()).done) {
|
|
3023
3155
|
_context36.next = 45;
|
|
3024
3156
|
break;
|
|
3025
3157
|
}
|
|
3026
|
-
prefillItem =
|
|
3158
|
+
prefillItem = _step18.value;
|
|
3027
3159
|
productId = Number(prefillItem.product_id);
|
|
3028
3160
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
3029
3161
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -3092,10 +3224,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3092
3224
|
case 47:
|
|
3093
3225
|
_context36.prev = 47;
|
|
3094
3226
|
_context36.t0 = _context36["catch"](20);
|
|
3095
|
-
|
|
3227
|
+
_iterator18.e(_context36.t0);
|
|
3096
3228
|
case 50:
|
|
3097
3229
|
_context36.prev = 50;
|
|
3098
|
-
|
|
3230
|
+
_iterator18.f();
|
|
3099
3231
|
return _context36.finish(50);
|
|
3100
3232
|
case 53:
|
|
3101
3233
|
if (!hasChanges) {
|
|
@@ -3357,7 +3489,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3357
3489
|
var raw = this.window.sessionStorage.getItem(key) || '{}';
|
|
3358
3490
|
var parsed = JSON.parse(raw);
|
|
3359
3491
|
return parsed && _typeof(parsed) === 'object' ? parsed : {};
|
|
3360
|
-
} catch (
|
|
3492
|
+
} catch (_unused4) {
|
|
3361
3493
|
return {};
|
|
3362
3494
|
}
|
|
3363
3495
|
}
|
|
@@ -3469,4 +3601,5 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3469
3601
|
return VenueBookingImpl;
|
|
3470
3602
|
}(BaseModule);
|
|
3471
3603
|
_defineProperty(VenueBookingImpl, "OPEN_DATA_CACHE_TTL", 5 * 60 * 1000);
|
|
3604
|
+
_defineProperty(VenueBookingImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
|
|
3472
3605
|
_defineProperty(VenueBookingImpl, "UI_STATE_KEY_PREFIX", 'pisell.venueBooking.uiState:');
|