@pisell/pisellos 2.1.164 → 2.1.165
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 +0 -1
- package/dist/index.js +0 -3
- package/dist/model/strategy/adapter/index.d.ts +0 -4
- package/dist/model/strategy/adapter/index.js +1 -5
- package/dist/modules/Discount/index.d.ts +2 -5
- package/dist/modules/Discount/index.js +1 -21
- package/dist/modules/Discount/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +0 -1
- package/dist/modules/Order/index.js +6 -18
- package/dist/modules/Order/types.d.ts +0 -2
- package/dist/modules/ProductList/index.d.ts +1 -3
- package/dist/modules/ProductList/index.js +11 -22
- package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
- package/dist/solution/ScanOrder/index.js +1 -1
- package/dist/solution/ShopDiscount/index.js +15 -16
- package/dist/solution/VenueBooking/index.d.ts +8 -40
- package/dist/solution/VenueBooking/index.js +569 -655
- package/dist/solution/VenueBooking/types.d.ts +1 -3
- package/dist/solution/VenueBooking/types.js +0 -1
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -3
- package/lib/model/strategy/adapter/index.d.ts +0 -4
- package/lib/model/strategy/adapter/index.js +2 -13
- package/lib/modules/Discount/index.d.ts +2 -5
- package/lib/modules/Discount/index.js +1 -11
- package/lib/modules/Discount/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +0 -1
- package/lib/modules/Order/index.js +1 -11
- package/lib/modules/Order/types.d.ts +0 -2
- package/lib/modules/ProductList/index.d.ts +1 -3
- package/lib/modules/ProductList/index.js +39 -45
- package/lib/modules/Schedule/getDateIsInSchedule.js +0 -4
- package/lib/solution/ScanOrder/index.js +1 -1
- package/lib/solution/ShopDiscount/index.js +2 -3
- package/lib/solution/VenueBooking/index.d.ts +8 -40
- package/lib/solution/VenueBooking/index.js +129 -257
- package/lib/solution/VenueBooking/types.d.ts +1 -3
- package/lib/solution/VenueBooking/types.js +0 -1
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +10 -5
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +4 -3
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
- package/lib/solution/VenueBooking/utils/timeSlot.js +3 -7
- package/package.json +1 -1
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
- package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
- package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
- package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
- package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
- package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
|
@@ -45,7 +45,6 @@ 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";
|
|
49
48
|
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
50
49
|
import { OrderModule } from "../../modules/Order";
|
|
51
50
|
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
@@ -99,15 +98,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
99
98
|
_defineProperty(_assertThisInitialized(_this), "loginEffectDisposers", []);
|
|
100
99
|
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshInFlight", null);
|
|
101
100
|
_defineProperty(_assertThisInitialized(_this), "customerLoginRefreshIdInFlight", null);
|
|
102
|
-
/** 最近一次确认登录的客户;登录事件与 user 插件更新之间可能存在时序差。 */
|
|
103
|
-
_defineProperty(_assertThisInitialized(_this), "smartPricingCustomerId", void 0);
|
|
104
101
|
_defineProperty(_assertThisInitialized(_this), "loadAllProductsInFlight", null);
|
|
105
102
|
_defineProperty(_assertThisInitialized(_this), "productsLoaded", false);
|
|
106
103
|
_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", []);
|
|
111
104
|
return _this;
|
|
112
105
|
}
|
|
113
106
|
_createClass(VenueBookingImpl, [{
|
|
@@ -328,9 +321,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
328
321
|
}, {
|
|
329
322
|
key: "registerCustomerLoginListeners",
|
|
330
323
|
value: function registerCustomerLoginListeners() {
|
|
331
|
-
var
|
|
324
|
+
var _this$core2,
|
|
325
|
+
_this$core3,
|
|
326
|
+
_accountModule$getCur,
|
|
327
|
+
_accountModule$getAcc,
|
|
328
|
+
_this2 = this;
|
|
332
329
|
this.clearLoginEffectListeners();
|
|
333
|
-
var
|
|
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) {
|
|
334
334
|
return /*#__PURE__*/function () {
|
|
335
335
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payload) {
|
|
336
336
|
var customerId;
|
|
@@ -359,9 +359,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
359
359
|
};
|
|
360
360
|
}();
|
|
361
361
|
};
|
|
362
|
-
this.registerLoginEffect(
|
|
363
|
-
this.registerLoginEffect(
|
|
364
|
-
this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin());
|
|
362
|
+
this.registerLoginEffect(AccountHooks.OnLogin, createHandleLogin(AccountHooks.OnLogin));
|
|
363
|
+
this.registerLoginEffect(RegisterAndLoginHooks.onLoginSuccess, createHandleLogin(RegisterAndLoginHooks.onLoginSuccess));
|
|
365
364
|
}
|
|
366
365
|
}, {
|
|
367
366
|
key: "refreshOrderMarketingAfterLogin",
|
|
@@ -396,40 +395,37 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
396
395
|
case 9:
|
|
397
396
|
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
398
397
|
refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
399
|
-
var _this3$
|
|
398
|
+
var _this3$otherParams;
|
|
400
399
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
401
400
|
while (1) switch (_context4.prev = _context4.next) {
|
|
402
401
|
case 0:
|
|
403
|
-
|
|
404
|
-
|
|
402
|
+
if (!_this3.store.quotation) {
|
|
403
|
+
_context4.next = 3;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
405
406
|
_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;
|
|
406
413
|
return _this3.store.order.loadDiscountConfig({
|
|
407
414
|
customerId: params.customerId
|
|
408
415
|
});
|
|
409
|
-
case
|
|
410
|
-
|
|
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;
|
|
416
|
+
case 6:
|
|
417
|
+
_context4.next = 8;
|
|
417
418
|
return _this3.store.order.recalculateSummary({
|
|
418
419
|
createIfMissing: true
|
|
419
420
|
});
|
|
420
|
-
case
|
|
421
|
+
case 8:
|
|
421
422
|
_this3.store.order.persistTempOrder();
|
|
422
|
-
_context4.next =
|
|
423
|
+
_context4.next = 11;
|
|
423
424
|
return _this3.refreshItemRuleQuantityLimits();
|
|
424
|
-
case
|
|
425
|
-
_context4.next =
|
|
425
|
+
case 11:
|
|
426
|
+
_context4.next = 13;
|
|
426
427
|
return _this3.refreshCartValidationPassed();
|
|
427
|
-
case
|
|
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:
|
|
428
|
+
case 13:
|
|
433
429
|
case "end":
|
|
434
430
|
return _context4.stop();
|
|
435
431
|
}
|
|
@@ -486,6 +482,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
486
482
|
openDataModule,
|
|
487
483
|
_this$store$order,
|
|
488
484
|
_this$store$order2,
|
|
485
|
+
_this$store$quotation,
|
|
486
|
+
_this$otherParams6,
|
|
489
487
|
_args6 = arguments;
|
|
490
488
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
491
489
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -495,7 +493,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
495
493
|
this.core = core;
|
|
496
494
|
this.initializeOptions = options || {};
|
|
497
495
|
this.store = _objectSpread(_objectSpread({}, this.store), options.store);
|
|
498
|
-
this.smartPricingCustomerId = undefined;
|
|
499
496
|
this.store.entryContext = ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.entryContext) || this.store.entryContext;
|
|
500
497
|
this.store.status = 'initializing';
|
|
501
498
|
this.store.error = null;
|
|
@@ -516,19 +513,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
516
513
|
this.window = core.getPlugin('window');
|
|
517
514
|
this.request = core.getPlugin('request');
|
|
518
515
|
if (this.window) {
|
|
519
|
-
_context6.next =
|
|
516
|
+
_context6.next = 24;
|
|
520
517
|
break;
|
|
521
518
|
}
|
|
522
519
|
this.logMethodError('initialize', 'window plugin missing');
|
|
523
520
|
throw new Error('venueBooking解决方案需要 window 插件支持');
|
|
524
|
-
case
|
|
521
|
+
case 24:
|
|
525
522
|
if (this.request) {
|
|
526
|
-
_context6.next =
|
|
523
|
+
_context6.next = 27;
|
|
527
524
|
break;
|
|
528
525
|
}
|
|
529
526
|
this.logMethodError('initialize', 'request plugin missing');
|
|
530
527
|
throw new Error('venueBooking解决方案需要 request 插件支持');
|
|
531
|
-
case
|
|
528
|
+
case 27:
|
|
532
529
|
// 注册基础模块(order, salesSummary, products, logger)
|
|
533
530
|
baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
534
531
|
baseModules.forEach(function (step) {
|
|
@@ -625,41 +622,46 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
625
622
|
}
|
|
626
623
|
this.registerCustomerLoginListeners();
|
|
627
624
|
console.log('[VenueBooking] 初始化开始');
|
|
628
|
-
_context6.prev =
|
|
629
|
-
_context6.next =
|
|
625
|
+
_context6.prev = 50;
|
|
626
|
+
_context6.next = 53;
|
|
630
627
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
631
628
|
createIfMissing: false
|
|
632
629
|
});
|
|
633
|
-
case
|
|
630
|
+
case 53:
|
|
634
631
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
635
|
-
_context6.next =
|
|
632
|
+
_context6.next = 56;
|
|
636
633
|
return this.loadRuntimeConfigs();
|
|
637
|
-
case
|
|
634
|
+
case 56:
|
|
638
635
|
if (!this.store.schedule) {
|
|
639
|
-
_context6.next =
|
|
636
|
+
_context6.next = 61;
|
|
640
637
|
break;
|
|
641
638
|
}
|
|
642
|
-
_context6.next =
|
|
639
|
+
_context6.next = 59;
|
|
643
640
|
return this.store.schedule.loadAllSchedule();
|
|
644
|
-
case
|
|
645
|
-
|
|
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
|
+
case 61:
|
|
647
|
+
_context6.next = 63;
|
|
646
648
|
return this.refreshItemRuleQuantityLimits();
|
|
647
|
-
case
|
|
649
|
+
case 63:
|
|
648
650
|
this.store.status = 'ready';
|
|
649
651
|
console.log('[VenueBooking] 初始化完成');
|
|
650
|
-
_context6.next =
|
|
652
|
+
_context6.next = 67;
|
|
651
653
|
return this.core.effects.emit(VenueBookingHooks.onInited, {
|
|
652
654
|
status: this.store.status
|
|
653
655
|
});
|
|
654
|
-
case
|
|
656
|
+
case 67:
|
|
655
657
|
this.logMethodSuccess('initialize', {
|
|
656
658
|
status: this.store.status
|
|
657
659
|
});
|
|
658
|
-
_context6.next =
|
|
660
|
+
_context6.next = 77;
|
|
659
661
|
break;
|
|
660
|
-
case
|
|
661
|
-
_context6.prev =
|
|
662
|
-
_context6.t0 = _context6["catch"](
|
|
662
|
+
case 70:
|
|
663
|
+
_context6.prev = 70;
|
|
664
|
+
_context6.t0 = _context6["catch"](50);
|
|
663
665
|
this.store.status = 'error';
|
|
664
666
|
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
|
|
665
667
|
console.error('[VenueBooking] 初始化失败', _context6.t0);
|
|
@@ -667,11 +669,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
667
669
|
status: this.store.status
|
|
668
670
|
});
|
|
669
671
|
throw _context6.t0;
|
|
670
|
-
case
|
|
672
|
+
case 77:
|
|
671
673
|
case "end":
|
|
672
674
|
return _context6.stop();
|
|
673
675
|
}
|
|
674
|
-
}, _callee6, this, [[
|
|
676
|
+
}, _callee6, this, [[50, 70]]);
|
|
675
677
|
}));
|
|
676
678
|
function initialize(_x5) {
|
|
677
679
|
return _initialize.apply(this, arguments);
|
|
@@ -812,113 +814,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
812
814
|
};
|
|
813
815
|
}
|
|
814
816
|
|
|
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
|
-
|
|
922
817
|
// ─── 场地商品 & 附加商品 ───
|
|
923
818
|
}, {
|
|
924
819
|
key: "loadAllProducts",
|
|
@@ -953,7 +848,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
953
848
|
key: "_doLoadAllProducts",
|
|
954
849
|
value: function () {
|
|
955
850
|
var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
956
|
-
var _this$
|
|
851
|
+
var _this$otherParams7, _this$store$venueProd, associatedMenus, menuListIds, allProducts, list, venueList, addonList, venueStore;
|
|
957
852
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
958
853
|
while (1) switch (_context11.prev = _context11.next) {
|
|
959
854
|
case 0:
|
|
@@ -974,7 +869,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
974
869
|
_context11.next = 8;
|
|
975
870
|
return this.loadOpenDataConfig();
|
|
976
871
|
case 8:
|
|
977
|
-
associatedMenus = ((_this$
|
|
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']) || [];
|
|
978
873
|
if (associatedMenus.length) {
|
|
979
874
|
_context11.next = 12;
|
|
980
875
|
break;
|
|
@@ -990,16 +885,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
990
885
|
menu_list_ids: menuListIds,
|
|
991
886
|
cacheId: this.cacheId,
|
|
992
887
|
schedule_date: dayjs().format('YYYY-MM-DD'),
|
|
993
|
-
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
994
|
-
with_extra: ['dataVariants']
|
|
888
|
+
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
995
889
|
});
|
|
996
890
|
case 15:
|
|
997
891
|
allProducts = _context11.sent;
|
|
998
|
-
|
|
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();
|
|
892
|
+
list = Array.isArray(allProducts) ? allProducts : [];
|
|
1003
893
|
venueList = list.filter(function (p) {
|
|
1004
894
|
return p.duration != null;
|
|
1005
895
|
});
|
|
@@ -1025,16 +915,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1025
915
|
venueProducts: venueList,
|
|
1026
916
|
addonProducts: addonList
|
|
1027
917
|
});
|
|
1028
|
-
case
|
|
1029
|
-
_context11.prev =
|
|
918
|
+
case 28:
|
|
919
|
+
_context11.prev = 28;
|
|
1030
920
|
_context11.t0 = _context11["catch"](1);
|
|
1031
921
|
this.logMethodError('loadAllProducts', _context11.t0);
|
|
1032
922
|
throw _context11.t0;
|
|
1033
|
-
case
|
|
923
|
+
case 32:
|
|
1034
924
|
case "end":
|
|
1035
925
|
return _context11.stop();
|
|
1036
926
|
}
|
|
1037
|
-
}, _callee11, this, [[1,
|
|
927
|
+
}, _callee11, this, [[1, 28]]);
|
|
1038
928
|
}));
|
|
1039
929
|
function _doLoadAllProducts() {
|
|
1040
930
|
return _doLoadAllProducts2.apply(this, arguments);
|
|
@@ -1353,11 +1243,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1353
1243
|
config: this.baseSlotConfig,
|
|
1354
1244
|
rawResources: this.store.rawResourceData,
|
|
1355
1245
|
resourceProductMap: this.resourceProductMap,
|
|
1246
|
+
quotationModule: this.store.quotation,
|
|
1356
1247
|
resolveConfig: function resolveConfig(date) {
|
|
1357
1248
|
return _this6.resolveSlotConfigForDate(date);
|
|
1358
|
-
},
|
|
1359
|
-
buildSlotPriceMap: function buildSlotPriceMap(date, config, productIds) {
|
|
1360
|
-
return _this6.buildSlotPriceMapForDate(date, config, productIds);
|
|
1361
1249
|
}
|
|
1362
1250
|
});
|
|
1363
1251
|
}
|
|
@@ -1365,16 +1253,26 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1365
1253
|
key: "getTimeSlotGrid",
|
|
1366
1254
|
value: function getTimeSlotGrid(date) {
|
|
1367
1255
|
var resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
1368
|
-
var
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
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
|
+
}
|
|
1372
1270
|
return buildTimeSlotGrid({
|
|
1373
1271
|
date: date,
|
|
1374
1272
|
config: resolvedSlotConfig,
|
|
1375
1273
|
rawResources: this.store.rawResourceData,
|
|
1376
1274
|
resourceProductMap: this.resourceProductMap,
|
|
1377
|
-
|
|
1275
|
+
quotationPriceMap: quotationPriceMap
|
|
1378
1276
|
});
|
|
1379
1277
|
}
|
|
1380
1278
|
|
|
@@ -1474,8 +1372,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1474
1372
|
}, {
|
|
1475
1373
|
key: "getSelectedSlotsForResource",
|
|
1476
1374
|
value: function getSelectedSlotsForResource(resourceId, productId) {
|
|
1477
|
-
var _this$store$
|
|
1478
|
-
var tempOrder = (_this$store$
|
|
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();
|
|
1479
1377
|
if (!tempOrder) return [];
|
|
1480
1378
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1481
1379
|
var _p$metadata, _p$metadata2;
|
|
@@ -1636,9 +1534,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1636
1534
|
}, {
|
|
1637
1535
|
key: "getAllSelectedSlots",
|
|
1638
1536
|
value: function getAllSelectedSlots() {
|
|
1639
|
-
var _this$store$
|
|
1537
|
+
var _this$store$order4;
|
|
1640
1538
|
var result = new Map();
|
|
1641
|
-
var tempOrder = (_this$store$
|
|
1539
|
+
var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
|
|
1642
1540
|
if (!tempOrder) return result;
|
|
1643
1541
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1644
1542
|
var _p$metadata3;
|
|
@@ -1810,7 +1708,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1810
1708
|
booking_uid: bookingUuid,
|
|
1811
1709
|
price_breakdown: buildPriceBreakdown({
|
|
1812
1710
|
group: group,
|
|
1813
|
-
productId: mapping.productId
|
|
1711
|
+
productId: mapping.productId,
|
|
1712
|
+
quotation: this.store.quotation
|
|
1814
1713
|
})
|
|
1815
1714
|
},
|
|
1816
1715
|
_origin: {
|
|
@@ -1941,25 +1840,36 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1941
1840
|
_context18.next = 6;
|
|
1942
1841
|
return this.store.schedule.loadAllSchedule();
|
|
1943
1842
|
case 6:
|
|
1843
|
+
this.injectScheduleResolverToQuotation();
|
|
1944
1844
|
this.logMethodSuccess('loadSchedules');
|
|
1945
|
-
_context18.next =
|
|
1845
|
+
_context18.next = 14;
|
|
1946
1846
|
break;
|
|
1947
|
-
case
|
|
1948
|
-
_context18.prev =
|
|
1847
|
+
case 10:
|
|
1848
|
+
_context18.prev = 10;
|
|
1949
1849
|
_context18.t0 = _context18["catch"](1);
|
|
1950
1850
|
this.logMethodError('loadSchedules', _context18.t0);
|
|
1951
1851
|
throw _context18.t0;
|
|
1952
|
-
case
|
|
1852
|
+
case 14:
|
|
1953
1853
|
case "end":
|
|
1954
1854
|
return _context18.stop();
|
|
1955
1855
|
}
|
|
1956
|
-
}, _callee18, this, [[1,
|
|
1856
|
+
}, _callee18, this, [[1, 10]]);
|
|
1957
1857
|
}));
|
|
1958
1858
|
function loadSchedules() {
|
|
1959
1859
|
return _loadSchedules.apply(this, arguments);
|
|
1960
1860
|
}
|
|
1961
1861
|
return loadSchedules;
|
|
1962
1862
|
}()
|
|
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
|
+
}
|
|
1963
1873
|
}, {
|
|
1964
1874
|
key: "getScheduleListByIds",
|
|
1965
1875
|
value: function getScheduleListByIds(ids) {
|
|
@@ -1971,8 +1881,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1971
1881
|
}, {
|
|
1972
1882
|
key: "getTempOrder",
|
|
1973
1883
|
value: function getTempOrder() {
|
|
1974
|
-
var _this$store$
|
|
1975
|
-
var result = ((_this$store$
|
|
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;
|
|
1976
1886
|
return result;
|
|
1977
1887
|
}
|
|
1978
1888
|
}, {
|
|
@@ -2031,16 +1941,14 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2031
1941
|
return onCustomerLogin;
|
|
2032
1942
|
}()
|
|
2033
1943
|
}, {
|
|
2034
|
-
key: "
|
|
2035
|
-
value: function
|
|
1944
|
+
key: "recalculateOrderPricesFromQuotation",
|
|
1945
|
+
value: function recalculateOrderPricesFromQuotation() {
|
|
2036
1946
|
var _tempOrder$products,
|
|
2037
|
-
|
|
2038
|
-
if (!this.store.order) return;
|
|
1947
|
+
_this10 = this;
|
|
1948
|
+
if (!this.store.order || !this.store.quotation) return;
|
|
2039
1949
|
var tempOrder = this.store.order.getTempOrder();
|
|
2040
1950
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
|
|
2041
1951
|
var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2042
|
-
var catalog = this.getAllProductsForSmartPricing();
|
|
2043
|
-
var context = this.buildSmartPricingContext();
|
|
2044
1952
|
var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
|
|
2045
1953
|
_step12;
|
|
2046
1954
|
try {
|
|
@@ -2048,65 +1956,44 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2048
1956
|
var _product$metadata2;
|
|
2049
1957
|
var product = _step12.value;
|
|
2050
1958
|
if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
|
|
2051
|
-
var mappings =
|
|
1959
|
+
var mappings = _this10.resourceProductMap.get(product.metadata.resource_id);
|
|
2052
1960
|
if (!mappings || !mappings.length) return 0; // continue
|
|
2053
1961
|
var mapping = mappings.find(function (m) {
|
|
2054
1962
|
return Number(m.productId) === Number(product.product_id);
|
|
2055
1963
|
}) || mappings[0];
|
|
2056
1964
|
if (!mapping) return 0; // continue
|
|
2057
|
-
var slots = expandMergedSlotToIndividual(product,
|
|
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
|
-
}
|
|
1965
|
+
var slots = expandMergedSlotToIndividual(product, _this10.store.slotConfig.slotDurationMinutes);
|
|
2074
1966
|
var updatedSlots = slots.map(function (slot) {
|
|
2075
|
-
var
|
|
2076
|
-
var slotPriceMap = slotPriceMaps.get(slotDate);
|
|
1967
|
+
var _getPriceForProduct;
|
|
2077
1968
|
return _objectSpread(_objectSpread({}, slot), {}, {
|
|
2078
1969
|
productId: mapping.productId,
|
|
2079
|
-
price:
|
|
2080
|
-
slotPriceMap: slotPriceMap,
|
|
1970
|
+
price: (_getPriceForProduct = _this10.store.quotation.getPriceForProduct({
|
|
2081
1971
|
productId: mapping.productId,
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
}) : mapping.price
|
|
1972
|
+
datetime: slot.startTime
|
|
1973
|
+
})) !== null && _getPriceForProduct !== void 0 ? _getPriceForProduct : mapping.price
|
|
2085
1974
|
});
|
|
2086
1975
|
});
|
|
2087
1976
|
var merged = mergeConsecutiveSlots(updatedSlots);
|
|
2088
1977
|
if (merged.length === 1) {
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
})
|
|
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
|
|
2096
1984
|
});
|
|
2097
1985
|
}
|
|
2098
1986
|
} else if (product.product_id != null) {
|
|
2099
|
-
var
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
datetime: now
|
|
2104
|
-
fallbackPrice: product.selling_price
|
|
2105
|
-
});
|
|
2106
|
-
_this9.resetProductPriceForSmartPricing({
|
|
2107
|
-
product: product,
|
|
2108
|
-
price: smartPrice
|
|
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
|
|
2109
1992
|
});
|
|
1993
|
+
if (quotationPrice !== null) {
|
|
1994
|
+
product.selling_price = quotationPrice;
|
|
1995
|
+
product.original_price = quotationPrice;
|
|
1996
|
+
}
|
|
2110
1997
|
}
|
|
2111
1998
|
},
|
|
2112
1999
|
_ret;
|
|
@@ -2120,30 +2007,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2120
2007
|
_iterator12.f();
|
|
2121
2008
|
}
|
|
2122
2009
|
}
|
|
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
|
-
}
|
|
2147
2010
|
}, {
|
|
2148
2011
|
key: "scanCode",
|
|
2149
2012
|
value: function () {
|
|
@@ -2209,7 +2072,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2209
2072
|
key: "setDiscountSelected",
|
|
2210
2073
|
value: (function () {
|
|
2211
2074
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
2212
|
-
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator14, _step14,
|
|
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;
|
|
2213
2076
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2214
2077
|
while (1) switch (_context21.prev = _context21.next) {
|
|
2215
2078
|
case 0:
|
|
@@ -2269,38 +2132,99 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2269
2132
|
}).map(function (d) {
|
|
2270
2133
|
return d.id;
|
|
2271
2134
|
}));
|
|
2272
|
-
|
|
2135
|
+
_iterator13 = _createForOfIteratorHelper(nextDiscountList);
|
|
2273
2136
|
try {
|
|
2274
|
-
for (
|
|
2275
|
-
d =
|
|
2137
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2138
|
+
d = _step13.value;
|
|
2276
2139
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
2277
2140
|
d.isSelected = false;
|
|
2278
2141
|
}
|
|
2279
2142
|
}
|
|
2280
2143
|
} catch (err) {
|
|
2281
|
-
|
|
2144
|
+
_iterator13.e(err);
|
|
2282
2145
|
} finally {
|
|
2283
|
-
|
|
2146
|
+
_iterator13.f();
|
|
2284
2147
|
}
|
|
2285
2148
|
}
|
|
2286
2149
|
}
|
|
2287
2150
|
}
|
|
2288
|
-
|
|
2289
|
-
|
|
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:
|
|
2290
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:
|
|
2213
|
+
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
2214
|
+
_context21.next = 46;
|
|
2291
2215
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
2292
|
-
case
|
|
2216
|
+
case 46:
|
|
2293
2217
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
2294
2218
|
return d.isSelected;
|
|
2295
2219
|
});
|
|
2296
2220
|
afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
|
|
2297
2221
|
return d.id === params.discountId;
|
|
2298
2222
|
}) || null;
|
|
2299
|
-
_context21.next =
|
|
2223
|
+
_context21.next = 50;
|
|
2300
2224
|
return this.store.order.recalculateSummary({
|
|
2301
2225
|
createIfMissing: true
|
|
2302
2226
|
});
|
|
2303
|
-
case
|
|
2227
|
+
case 50:
|
|
2304
2228
|
this.store.order.persistTempOrder();
|
|
2305
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;
|
|
2306
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;
|
|
@@ -2309,78 +2233,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2309
2233
|
return d.id === params.discountId;
|
|
2310
2234
|
}) || null;
|
|
2311
2235
|
return _context21.abrupt("return", this.store.order.getDiscountList());
|
|
2312
|
-
case
|
|
2313
|
-
_context21.prev =
|
|
2314
|
-
_context21.
|
|
2315
|
-
this.logMethodError('setDiscountSelected', _context21.
|
|
2316
|
-
throw _context21.
|
|
2317
|
-
case
|
|
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:
|
|
2318
2242
|
case "end":
|
|
2319
2243
|
return _context21.stop();
|
|
2320
2244
|
}
|
|
2321
|
-
}, _callee21, this, [[1,
|
|
2245
|
+
}, _callee21, this, [[1, 58], [19, 37, 40, 43]]);
|
|
2322
2246
|
}));
|
|
2323
2247
|
function setDiscountSelected(_x15) {
|
|
2324
2248
|
return _setDiscountSelected.apply(this, arguments);
|
|
2325
2249
|
}
|
|
2326
2250
|
return setDiscountSelected;
|
|
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
|
-
}
|
|
2251
|
+
}())
|
|
2384
2252
|
}, {
|
|
2385
2253
|
key: "addNewOrder",
|
|
2386
2254
|
value: function () {
|
|
@@ -2471,7 +2339,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2471
2339
|
key: "submitOrder",
|
|
2472
2340
|
value: function () {
|
|
2473
2341
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2474
|
-
var _this$
|
|
2342
|
+
var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _tempOrder$products2, result, tempOrder;
|
|
2475
2343
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2476
2344
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2477
2345
|
case 0:
|
|
@@ -2489,10 +2357,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2489
2357
|
_context24.next = 8;
|
|
2490
2358
|
return this.store.order.submitTempOrder({
|
|
2491
2359
|
cacheId: this.cacheId,
|
|
2492
|
-
platform: (_this$
|
|
2493
|
-
businessCode: (_this$
|
|
2494
|
-
channel: (_this$
|
|
2495
|
-
type: (_this$
|
|
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
|
|
2496
2364
|
});
|
|
2497
2365
|
case 8:
|
|
2498
2366
|
result = _context24.sent;
|
|
@@ -2517,64 +2385,111 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2517
2385
|
}
|
|
2518
2386
|
return submitOrder;
|
|
2519
2387
|
}()
|
|
2388
|
+
/**
|
|
2389
|
+
* 0 元订单免费领取(非定金场景)
|
|
2390
|
+
* 与 appointment getFreeProduct 同接口:POST /pay/order/free-pay/:id
|
|
2391
|
+
*/
|
|
2520
2392
|
}, {
|
|
2521
|
-
key: "
|
|
2522
|
-
value: function () {
|
|
2523
|
-
var
|
|
2524
|
-
var
|
|
2393
|
+
key: "submitFreeOrder",
|
|
2394
|
+
value: (function () {
|
|
2395
|
+
var _submitFreeOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(id) {
|
|
2396
|
+
var res;
|
|
2525
2397
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2526
2398
|
while (1) switch (_context25.prev = _context25.next) {
|
|
2399
|
+
case 0:
|
|
2400
|
+
this.logMethodStart('submitFreeOrder', {
|
|
2401
|
+
id: id
|
|
2402
|
+
});
|
|
2403
|
+
_context25.prev = 1;
|
|
2404
|
+
if (id) {
|
|
2405
|
+
_context25.next = 4;
|
|
2406
|
+
break;
|
|
2407
|
+
}
|
|
2408
|
+
throw new Error('订单 ID 不能为空');
|
|
2409
|
+
case 4:
|
|
2410
|
+
_context25.next = 6;
|
|
2411
|
+
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
2412
|
+
case 6:
|
|
2413
|
+
res = _context25.sent;
|
|
2414
|
+
this.logMethodSuccess('submitFreeOrder', {
|
|
2415
|
+
id: id,
|
|
2416
|
+
status: res === null || res === void 0 ? void 0 : res.status
|
|
2417
|
+
});
|
|
2418
|
+
return _context25.abrupt("return", res);
|
|
2419
|
+
case 11:
|
|
2420
|
+
_context25.prev = 11;
|
|
2421
|
+
_context25.t0 = _context25["catch"](1);
|
|
2422
|
+
this.logMethodError('submitFreeOrder', _context25.t0);
|
|
2423
|
+
throw _context25.t0;
|
|
2424
|
+
case 15:
|
|
2425
|
+
case "end":
|
|
2426
|
+
return _context25.stop();
|
|
2427
|
+
}
|
|
2428
|
+
}, _callee25, this, [[1, 11]]);
|
|
2429
|
+
}));
|
|
2430
|
+
function submitFreeOrder(_x16) {
|
|
2431
|
+
return _submitFreeOrder.apply(this, arguments);
|
|
2432
|
+
}
|
|
2433
|
+
return submitFreeOrder;
|
|
2434
|
+
}())
|
|
2435
|
+
}, {
|
|
2436
|
+
key: "addProductToOrder",
|
|
2437
|
+
value: function () {
|
|
2438
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(product) {
|
|
2439
|
+
var _product$metadata5, _product$product_vari2, quotationPrice, products;
|
|
2440
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2441
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2527
2442
|
case 0:
|
|
2528
2443
|
this.logMethodStart('addProductToOrder', {
|
|
2529
2444
|
product_id: product.product_id,
|
|
2530
2445
|
product_variant_id: product.product_variant_id
|
|
2531
2446
|
});
|
|
2532
|
-
|
|
2447
|
+
_context26.prev = 1;
|
|
2533
2448
|
if (this.store.order) {
|
|
2534
|
-
|
|
2449
|
+
_context26.next = 4;
|
|
2535
2450
|
break;
|
|
2536
2451
|
}
|
|
2537
2452
|
throw new Error('order 模块未初始化');
|
|
2538
2453
|
case 4:
|
|
2539
|
-
if (!((_product$
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
2545
|
-
fallbackPrice: product.selling_price
|
|
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')
|
|
2546
2459
|
});
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
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
|
+
}
|
|
2551
2466
|
}
|
|
2552
|
-
|
|
2467
|
+
_context26.next = 7;
|
|
2553
2468
|
return this.store.order.addProductToOrder(product);
|
|
2554
2469
|
case 7:
|
|
2555
|
-
products =
|
|
2556
|
-
|
|
2470
|
+
products = _context26.sent;
|
|
2471
|
+
_context26.next = 10;
|
|
2557
2472
|
return this.refreshItemRuleQuantityLimits();
|
|
2558
2473
|
case 10:
|
|
2559
|
-
|
|
2474
|
+
_context26.next = 12;
|
|
2560
2475
|
return this.refreshCartValidationPassed();
|
|
2561
2476
|
case 12:
|
|
2562
2477
|
this.logMethodSuccess('addProductToOrder', {
|
|
2563
2478
|
productCount: products.length
|
|
2564
2479
|
});
|
|
2565
|
-
return
|
|
2480
|
+
return _context26.abrupt("return", products);
|
|
2566
2481
|
case 16:
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
this.logMethodError('addProductToOrder',
|
|
2570
|
-
throw
|
|
2482
|
+
_context26.prev = 16;
|
|
2483
|
+
_context26.t0 = _context26["catch"](1);
|
|
2484
|
+
this.logMethodError('addProductToOrder', _context26.t0);
|
|
2485
|
+
throw _context26.t0;
|
|
2571
2486
|
case 20:
|
|
2572
2487
|
case "end":
|
|
2573
|
-
return
|
|
2488
|
+
return _context26.stop();
|
|
2574
2489
|
}
|
|
2575
|
-
},
|
|
2490
|
+
}, _callee26, this, [[1, 16]]);
|
|
2576
2491
|
}));
|
|
2577
|
-
function addProductToOrder(
|
|
2492
|
+
function addProductToOrder(_x17) {
|
|
2578
2493
|
return _addProductToOrder.apply(this, arguments);
|
|
2579
2494
|
}
|
|
2580
2495
|
return addProductToOrder;
|
|
@@ -2582,48 +2497,48 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2582
2497
|
}, {
|
|
2583
2498
|
key: "updateProductInOrder",
|
|
2584
2499
|
value: function () {
|
|
2585
|
-
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2500
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2586
2501
|
var products;
|
|
2587
|
-
return _regeneratorRuntime().wrap(function
|
|
2588
|
-
while (1) switch (
|
|
2502
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2503
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2589
2504
|
case 0:
|
|
2590
2505
|
this.logMethodStart('updateProductInOrder', {
|
|
2591
2506
|
product_id: params.product_id,
|
|
2592
2507
|
product_variant_id: params.product_variant_id
|
|
2593
2508
|
});
|
|
2594
|
-
|
|
2509
|
+
_context27.prev = 1;
|
|
2595
2510
|
if (this.store.order) {
|
|
2596
|
-
|
|
2511
|
+
_context27.next = 4;
|
|
2597
2512
|
break;
|
|
2598
2513
|
}
|
|
2599
2514
|
throw new Error('order 模块未初始化');
|
|
2600
2515
|
case 4:
|
|
2601
|
-
|
|
2516
|
+
_context27.next = 6;
|
|
2602
2517
|
return this.store.order.updateProductInOrder(params);
|
|
2603
2518
|
case 6:
|
|
2604
|
-
products =
|
|
2605
|
-
|
|
2519
|
+
products = _context27.sent;
|
|
2520
|
+
_context27.next = 9;
|
|
2606
2521
|
return this.refreshItemRuleQuantityLimits();
|
|
2607
2522
|
case 9:
|
|
2608
|
-
|
|
2523
|
+
_context27.next = 11;
|
|
2609
2524
|
return this.refreshCartValidationPassed();
|
|
2610
2525
|
case 11:
|
|
2611
2526
|
this.logMethodSuccess('updateProductInOrder', {
|
|
2612
2527
|
productCount: products.length
|
|
2613
2528
|
});
|
|
2614
|
-
return
|
|
2529
|
+
return _context27.abrupt("return", products);
|
|
2615
2530
|
case 15:
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
this.logMethodError('updateProductInOrder',
|
|
2619
|
-
throw
|
|
2531
|
+
_context27.prev = 15;
|
|
2532
|
+
_context27.t0 = _context27["catch"](1);
|
|
2533
|
+
this.logMethodError('updateProductInOrder', _context27.t0);
|
|
2534
|
+
throw _context27.t0;
|
|
2620
2535
|
case 19:
|
|
2621
2536
|
case "end":
|
|
2622
|
-
return
|
|
2537
|
+
return _context27.stop();
|
|
2623
2538
|
}
|
|
2624
|
-
},
|
|
2539
|
+
}, _callee27, this, [[1, 15]]);
|
|
2625
2540
|
}));
|
|
2626
|
-
function updateProductInOrder(
|
|
2541
|
+
function updateProductInOrder(_x18) {
|
|
2627
2542
|
return _updateProductInOrder.apply(this, arguments);
|
|
2628
2543
|
}
|
|
2629
2544
|
return updateProductInOrder;
|
|
@@ -2631,66 +2546,66 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2631
2546
|
}, {
|
|
2632
2547
|
key: "removeProductFromOrder",
|
|
2633
2548
|
value: function () {
|
|
2634
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2635
|
-
var _this$store$order$get3, _this$store$
|
|
2636
|
-
return _regeneratorRuntime().wrap(function
|
|
2637
|
-
while (1) switch (
|
|
2549
|
+
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;
|
|
2551
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2552
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2638
2553
|
case 0:
|
|
2639
2554
|
this.logMethodStart('removeProductFromOrder', {
|
|
2640
2555
|
product_id: identity.product_id,
|
|
2641
2556
|
product_variant_id: identity.product_variant_id
|
|
2642
2557
|
});
|
|
2643
|
-
|
|
2558
|
+
_context28.prev = 1;
|
|
2644
2559
|
if (this.store.order) {
|
|
2645
|
-
|
|
2560
|
+
_context28.next = 4;
|
|
2646
2561
|
break;
|
|
2647
2562
|
}
|
|
2648
2563
|
throw new Error('order 模块未初始化');
|
|
2649
2564
|
case 4:
|
|
2650
|
-
tempOrder = ((_this$store$order$get3 = (_this$store$
|
|
2651
|
-
|
|
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));
|
|
2566
|
+
_context28.next = 7;
|
|
2652
2567
|
return this.store.order.removeProductFromOrder(identity);
|
|
2653
2568
|
case 7:
|
|
2654
|
-
products =
|
|
2569
|
+
products = _context28.sent;
|
|
2655
2570
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length)) {
|
|
2656
|
-
|
|
2571
|
+
_context28.next = 33;
|
|
2657
2572
|
break;
|
|
2658
2573
|
}
|
|
2659
2574
|
venueProductUids = new Set();
|
|
2660
2575
|
venueBookingUids = new Set();
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2576
|
+
_iterator15 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2577
|
+
_context28.prev = 12;
|
|
2578
|
+
_iterator15.s();
|
|
2664
2579
|
case 14:
|
|
2665
|
-
if ((
|
|
2666
|
-
|
|
2580
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
2581
|
+
_context28.next = 22;
|
|
2667
2582
|
break;
|
|
2668
2583
|
}
|
|
2669
|
-
product =
|
|
2670
|
-
if (product !== null && product !== void 0 && (_product$
|
|
2671
|
-
|
|
2584
|
+
product = _step15.value;
|
|
2585
|
+
if (product !== null && product !== void 0 && (_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.venue_booking) {
|
|
2586
|
+
_context28.next = 18;
|
|
2672
2587
|
break;
|
|
2673
2588
|
}
|
|
2674
|
-
return
|
|
2589
|
+
return _context28.abrupt("continue", 20);
|
|
2675
2590
|
case 18:
|
|
2676
2591
|
if (product.identity_key) venueProductUids.add(String(product.identity_key));
|
|
2677
|
-
if ((_product$
|
|
2592
|
+
if ((_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.booking_uid) {
|
|
2678
2593
|
venueBookingUids.add(String(product.metadata.booking_uid));
|
|
2679
2594
|
}
|
|
2680
2595
|
case 20:
|
|
2681
|
-
|
|
2596
|
+
_context28.next = 14;
|
|
2682
2597
|
break;
|
|
2683
2598
|
case 22:
|
|
2684
|
-
|
|
2599
|
+
_context28.next = 27;
|
|
2685
2600
|
break;
|
|
2686
2601
|
case 24:
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2602
|
+
_context28.prev = 24;
|
|
2603
|
+
_context28.t0 = _context28["catch"](12);
|
|
2604
|
+
_iterator15.e(_context28.t0);
|
|
2690
2605
|
case 27:
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
return
|
|
2606
|
+
_context28.prev = 27;
|
|
2607
|
+
_iterator15.f();
|
|
2608
|
+
return _context28.finish(27);
|
|
2694
2609
|
case 30:
|
|
2695
2610
|
beforeBookingCount = ((_tempOrder$bookings2 = tempOrder.bookings) === null || _tempOrder$bookings2 === void 0 ? void 0 : _tempOrder$bookings2.length) || 0;
|
|
2696
2611
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
@@ -2704,31 +2619,31 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2704
2619
|
return true;
|
|
2705
2620
|
});
|
|
2706
2621
|
if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
|
|
2707
|
-
(_this$store$order$per = (_this$store$
|
|
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);
|
|
2708
2623
|
}
|
|
2709
2624
|
case 33:
|
|
2710
|
-
|
|
2625
|
+
_context28.next = 35;
|
|
2711
2626
|
return this.refreshItemRuleQuantityLimits();
|
|
2712
2627
|
case 35:
|
|
2713
|
-
|
|
2628
|
+
_context28.next = 37;
|
|
2714
2629
|
return this.refreshCartValidationPassed();
|
|
2715
2630
|
case 37:
|
|
2716
2631
|
this.logMethodSuccess('removeProductFromOrder', {
|
|
2717
2632
|
productCount: products.length
|
|
2718
2633
|
});
|
|
2719
|
-
return
|
|
2634
|
+
return _context28.abrupt("return", products);
|
|
2720
2635
|
case 41:
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
this.logMethodError('removeProductFromOrder',
|
|
2724
|
-
throw
|
|
2636
|
+
_context28.prev = 41;
|
|
2637
|
+
_context28.t1 = _context28["catch"](1);
|
|
2638
|
+
this.logMethodError('removeProductFromOrder', _context28.t1);
|
|
2639
|
+
throw _context28.t1;
|
|
2725
2640
|
case 45:
|
|
2726
2641
|
case "end":
|
|
2727
|
-
return
|
|
2642
|
+
return _context28.stop();
|
|
2728
2643
|
}
|
|
2729
|
-
},
|
|
2644
|
+
}, _callee28, this, [[1, 41], [12, 24, 27, 30]]);
|
|
2730
2645
|
}));
|
|
2731
|
-
function removeProductFromOrder(
|
|
2646
|
+
function removeProductFromOrder(_x19) {
|
|
2732
2647
|
return _removeProductFromOrder.apply(this, arguments);
|
|
2733
2648
|
}
|
|
2734
2649
|
return removeProductFromOrder;
|
|
@@ -2736,27 +2651,27 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
2651
|
}, {
|
|
2737
2652
|
key: "getProductList",
|
|
2738
2653
|
value: function () {
|
|
2739
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2654
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2740
2655
|
var result;
|
|
2741
|
-
return _regeneratorRuntime().wrap(function
|
|
2742
|
-
while (1) switch (
|
|
2656
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2657
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2743
2658
|
case 0:
|
|
2744
2659
|
if (!this.productsLoaded) {
|
|
2745
|
-
|
|
2660
|
+
_context29.next = 2;
|
|
2746
2661
|
break;
|
|
2747
2662
|
}
|
|
2748
|
-
return
|
|
2663
|
+
return _context29.abrupt("return", attachItemRuleLimitsToTopLevelProducts(this.getAddonProductsList(), this.store.itemRuleQuantityLimits || []));
|
|
2749
2664
|
case 2:
|
|
2750
|
-
|
|
2665
|
+
_context29.next = 4;
|
|
2751
2666
|
return this.loadAllProducts();
|
|
2752
2667
|
case 4:
|
|
2753
|
-
result =
|
|
2754
|
-
return
|
|
2668
|
+
result = _context29.sent;
|
|
2669
|
+
return _context29.abrupt("return", attachItemRuleLimitsToTopLevelProducts(result.addonProducts, this.store.itemRuleQuantityLimits || []));
|
|
2755
2670
|
case 6:
|
|
2756
2671
|
case "end":
|
|
2757
|
-
return
|
|
2672
|
+
return _context29.stop();
|
|
2758
2673
|
}
|
|
2759
|
-
},
|
|
2674
|
+
}, _callee29, this);
|
|
2760
2675
|
}));
|
|
2761
2676
|
function getProductList() {
|
|
2762
2677
|
return _getProductList.apply(this, arguments);
|
|
@@ -2766,13 +2681,13 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2766
2681
|
}, {
|
|
2767
2682
|
key: "loadOpenDataConfig",
|
|
2768
2683
|
value: function () {
|
|
2769
|
-
var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2684
|
+
var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2770
2685
|
var lastFetchedAt, cachedData, openDataConfig;
|
|
2771
|
-
return _regeneratorRuntime().wrap(function
|
|
2772
|
-
while (1) switch (
|
|
2686
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2687
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2773
2688
|
case 0:
|
|
2774
2689
|
if (this.store.openData) {
|
|
2775
|
-
|
|
2690
|
+
_context30.next = 2;
|
|
2776
2691
|
break;
|
|
2777
2692
|
}
|
|
2778
2693
|
throw new Error('openData 模块未初始化');
|
|
@@ -2780,42 +2695,42 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2780
2695
|
lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
2781
2696
|
cachedData = this.store.openData.getOpenData();
|
|
2782
2697
|
if (!(cachedData && lastFetchedAt && Date.now() - lastFetchedAt < VenueBookingImpl.OPEN_DATA_CACHE_TTL)) {
|
|
2783
|
-
|
|
2698
|
+
_context30.next = 7;
|
|
2784
2699
|
break;
|
|
2785
2700
|
}
|
|
2786
2701
|
this.otherParams.openData = cachedData;
|
|
2787
|
-
return
|
|
2702
|
+
return _context30.abrupt("return", cachedData);
|
|
2788
2703
|
case 7:
|
|
2789
2704
|
if (!this.loadOpenDataConfigInFlight) {
|
|
2790
|
-
|
|
2705
|
+
_context30.next = 11;
|
|
2791
2706
|
break;
|
|
2792
2707
|
}
|
|
2793
|
-
|
|
2708
|
+
_context30.next = 10;
|
|
2794
2709
|
return this.loadOpenDataConfigInFlight;
|
|
2795
2710
|
case 10:
|
|
2796
|
-
return
|
|
2711
|
+
return _context30.abrupt("return", _context30.sent);
|
|
2797
2712
|
case 11:
|
|
2798
2713
|
this.loadOpenDataConfigInFlight = this.store.openData.fetchOpenData({
|
|
2799
2714
|
scope: 'board',
|
|
2800
2715
|
target: 'venue_booking+online_store',
|
|
2801
2716
|
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
2802
2717
|
});
|
|
2803
|
-
|
|
2804
|
-
|
|
2718
|
+
_context30.prev = 12;
|
|
2719
|
+
_context30.next = 15;
|
|
2805
2720
|
return this.loadOpenDataConfigInFlight;
|
|
2806
2721
|
case 15:
|
|
2807
|
-
openDataConfig =
|
|
2722
|
+
openDataConfig = _context30.sent;
|
|
2808
2723
|
this.otherParams.openData = openDataConfig;
|
|
2809
|
-
return
|
|
2724
|
+
return _context30.abrupt("return", openDataConfig);
|
|
2810
2725
|
case 18:
|
|
2811
|
-
|
|
2726
|
+
_context30.prev = 18;
|
|
2812
2727
|
this.loadOpenDataConfigInFlight = null;
|
|
2813
|
-
return
|
|
2728
|
+
return _context30.finish(18);
|
|
2814
2729
|
case 21:
|
|
2815
2730
|
case "end":
|
|
2816
|
-
return
|
|
2731
|
+
return _context30.stop();
|
|
2817
2732
|
}
|
|
2818
|
-
},
|
|
2733
|
+
}, _callee30, this, [[12,, 18, 21]]);
|
|
2819
2734
|
}));
|
|
2820
2735
|
function loadOpenDataConfig() {
|
|
2821
2736
|
return _loadOpenDataConfig.apply(this, arguments);
|
|
@@ -2825,29 +2740,29 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2825
2740
|
}, {
|
|
2826
2741
|
key: "loadRuntimeConfigs",
|
|
2827
2742
|
value: function () {
|
|
2828
|
-
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2743
|
+
var _loadRuntimeConfigs = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2829
2744
|
var itemRuleConfigs;
|
|
2830
|
-
return _regeneratorRuntime().wrap(function
|
|
2831
|
-
while (1) switch (
|
|
2745
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2746
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2832
2747
|
case 0:
|
|
2833
|
-
|
|
2748
|
+
_context31.next = 2;
|
|
2834
2749
|
return this.loadOpenDataConfig();
|
|
2835
2750
|
case 2:
|
|
2836
|
-
|
|
2751
|
+
_context31.next = 4;
|
|
2837
2752
|
return this.ensureItemRuleConfigsLoaded();
|
|
2838
2753
|
case 4:
|
|
2839
|
-
itemRuleConfigs =
|
|
2754
|
+
itemRuleConfigs = _context31.sent;
|
|
2840
2755
|
this.logMethodSuccess('loadRuntimeConfigs', {
|
|
2841
2756
|
itemRuleCount: itemRuleConfigs.length
|
|
2842
2757
|
});
|
|
2843
|
-
return
|
|
2758
|
+
return _context31.abrupt("return", {
|
|
2844
2759
|
itemRuleConfigs: itemRuleConfigs
|
|
2845
2760
|
});
|
|
2846
2761
|
case 7:
|
|
2847
2762
|
case "end":
|
|
2848
|
-
return
|
|
2763
|
+
return _context31.stop();
|
|
2849
2764
|
}
|
|
2850
|
-
},
|
|
2765
|
+
}, _callee31, this);
|
|
2851
2766
|
}));
|
|
2852
2767
|
function loadRuntimeConfigs() {
|
|
2853
2768
|
return _loadRuntimeConfigs.apply(this, arguments);
|
|
@@ -2857,22 +2772,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2857
2772
|
}, {
|
|
2858
2773
|
key: "fetchItemRuleConfigsByModelIds",
|
|
2859
2774
|
value: function () {
|
|
2860
|
-
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2775
|
+
var _fetchItemRuleConfigsByModelIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(strategyModelIds) {
|
|
2861
2776
|
var result, configs;
|
|
2862
|
-
return _regeneratorRuntime().wrap(function
|
|
2863
|
-
while (1) switch (
|
|
2777
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2778
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2864
2779
|
case 0:
|
|
2865
2780
|
this.logMethodStart('fetchItemRuleConfigsByModelIds', {
|
|
2866
2781
|
strategyModelIds: strategyModelIds
|
|
2867
2782
|
});
|
|
2868
2783
|
if (strategyModelIds.length) {
|
|
2869
|
-
|
|
2784
|
+
_context32.next = 3;
|
|
2870
2785
|
break;
|
|
2871
2786
|
}
|
|
2872
|
-
return
|
|
2787
|
+
return _context32.abrupt("return", []);
|
|
2873
2788
|
case 3:
|
|
2874
|
-
|
|
2875
|
-
|
|
2789
|
+
_context32.prev = 3;
|
|
2790
|
+
_context32.next = 6;
|
|
2876
2791
|
return this.request.get('/promotion', {
|
|
2877
2792
|
skip: 1,
|
|
2878
2793
|
num: 99,
|
|
@@ -2880,7 +2795,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2880
2795
|
ids: strategyModelIds
|
|
2881
2796
|
});
|
|
2882
2797
|
case 6:
|
|
2883
|
-
result =
|
|
2798
|
+
result = _context32.sent;
|
|
2884
2799
|
configs = [];
|
|
2885
2800
|
if (result.code === 200) {
|
|
2886
2801
|
configs = result.data.list.map(function (item) {
|
|
@@ -2891,21 +2806,21 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2891
2806
|
strategyModelIds: strategyModelIds,
|
|
2892
2807
|
strategyCount: configs.length
|
|
2893
2808
|
});
|
|
2894
|
-
return
|
|
2809
|
+
return _context32.abrupt("return", configs);
|
|
2895
2810
|
case 13:
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
this.logMethodError('fetchItemRuleConfigsByModelIds',
|
|
2811
|
+
_context32.prev = 13;
|
|
2812
|
+
_context32.t0 = _context32["catch"](3);
|
|
2813
|
+
this.logMethodError('fetchItemRuleConfigsByModelIds', _context32.t0, {
|
|
2899
2814
|
strategyModelIds: strategyModelIds
|
|
2900
2815
|
});
|
|
2901
|
-
return
|
|
2816
|
+
return _context32.abrupt("return", []);
|
|
2902
2817
|
case 17:
|
|
2903
2818
|
case "end":
|
|
2904
|
-
return
|
|
2819
|
+
return _context32.stop();
|
|
2905
2820
|
}
|
|
2906
|
-
},
|
|
2821
|
+
}, _callee32, this, [[3, 13]]);
|
|
2907
2822
|
}));
|
|
2908
|
-
function fetchItemRuleConfigsByModelIds(
|
|
2823
|
+
function fetchItemRuleConfigsByModelIds(_x20) {
|
|
2909
2824
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
2910
2825
|
}
|
|
2911
2826
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -2913,22 +2828,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2913
2828
|
}, {
|
|
2914
2829
|
key: "buildPrefillProductSourceMap",
|
|
2915
2830
|
value: function () {
|
|
2916
|
-
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2831
|
+
var _buildPrefillProductSourceMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2917
2832
|
var sourceMap, productList, visited, collectFromValue;
|
|
2918
|
-
return _regeneratorRuntime().wrap(function
|
|
2919
|
-
while (1) switch (
|
|
2833
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2834
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2920
2835
|
case 0:
|
|
2921
2836
|
sourceMap = new Map();
|
|
2922
|
-
|
|
2923
|
-
|
|
2837
|
+
_context33.prev = 1;
|
|
2838
|
+
_context33.next = 4;
|
|
2924
2839
|
return this.getProductList();
|
|
2925
2840
|
case 4:
|
|
2926
|
-
productList =
|
|
2841
|
+
productList = _context33.sent;
|
|
2927
2842
|
if (Array.isArray(productList)) {
|
|
2928
|
-
|
|
2843
|
+
_context33.next = 7;
|
|
2929
2844
|
break;
|
|
2930
2845
|
}
|
|
2931
|
-
return
|
|
2846
|
+
return _context33.abrupt("return", sourceMap);
|
|
2932
2847
|
case 7:
|
|
2933
2848
|
visited = new Set();
|
|
2934
2849
|
collectFromValue = function collectFromValue(value) {
|
|
@@ -2937,17 +2852,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2937
2852
|
if (visited.has(value)) return;
|
|
2938
2853
|
visited.add(value);
|
|
2939
2854
|
if (Array.isArray(value)) {
|
|
2940
|
-
var
|
|
2941
|
-
|
|
2855
|
+
var _iterator16 = _createForOfIteratorHelper(value),
|
|
2856
|
+
_step16;
|
|
2942
2857
|
try {
|
|
2943
|
-
for (
|
|
2944
|
-
var item =
|
|
2858
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
2859
|
+
var item = _step16.value;
|
|
2945
2860
|
collectFromValue(item);
|
|
2946
2861
|
}
|
|
2947
2862
|
} catch (err) {
|
|
2948
|
-
|
|
2863
|
+
_iterator16.e(err);
|
|
2949
2864
|
} finally {
|
|
2950
|
-
|
|
2865
|
+
_iterator16.f();
|
|
2951
2866
|
}
|
|
2952
2867
|
return;
|
|
2953
2868
|
}
|
|
@@ -2967,19 +2882,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2967
2882
|
}
|
|
2968
2883
|
};
|
|
2969
2884
|
collectFromValue(productList);
|
|
2970
|
-
|
|
2885
|
+
_context33.next = 15;
|
|
2971
2886
|
break;
|
|
2972
2887
|
case 12:
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
this.logMethodError('buildPrefillProductSourceMap',
|
|
2888
|
+
_context33.prev = 12;
|
|
2889
|
+
_context33.t0 = _context33["catch"](1);
|
|
2890
|
+
this.logMethodError('buildPrefillProductSourceMap', _context33.t0);
|
|
2976
2891
|
case 15:
|
|
2977
|
-
return
|
|
2892
|
+
return _context33.abrupt("return", sourceMap);
|
|
2978
2893
|
case 16:
|
|
2979
2894
|
case "end":
|
|
2980
|
-
return
|
|
2895
|
+
return _context33.stop();
|
|
2981
2896
|
}
|
|
2982
|
-
},
|
|
2897
|
+
}, _callee33, this, [[1, 12]]);
|
|
2983
2898
|
}));
|
|
2984
2899
|
function buildPrefillProductSourceMap() {
|
|
2985
2900
|
return _buildPrefillProductSourceMap.apply(this, arguments);
|
|
@@ -2994,56 +2909,56 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2994
2909
|
}, {
|
|
2995
2910
|
key: "ensureItemRuleConfigsLoaded",
|
|
2996
2911
|
value: function () {
|
|
2997
|
-
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2998
|
-
var
|
|
2999
|
-
return _regeneratorRuntime().wrap(function
|
|
3000
|
-
while (1) switch (
|
|
2912
|
+
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35() {
|
|
2913
|
+
var _this11 = this;
|
|
2914
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2915
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3001
2916
|
case 0:
|
|
3002
2917
|
if (!(this.itemRuleConfigs.length > 0)) {
|
|
3003
|
-
|
|
2918
|
+
_context35.next = 2;
|
|
3004
2919
|
break;
|
|
3005
2920
|
}
|
|
3006
|
-
return
|
|
2921
|
+
return _context35.abrupt("return", this.itemRuleConfigs);
|
|
3007
2922
|
case 2:
|
|
3008
2923
|
if (!this.itemRuleConfigsPromise) {
|
|
3009
|
-
|
|
2924
|
+
_context35.next = 4;
|
|
3010
2925
|
break;
|
|
3011
2926
|
}
|
|
3012
|
-
return
|
|
2927
|
+
return _context35.abrupt("return", this.itemRuleConfigsPromise);
|
|
3013
2928
|
case 4:
|
|
3014
|
-
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2929
|
+
this.itemRuleConfigsPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
3015
2930
|
var runtimeConfig, staticConfigs;
|
|
3016
|
-
return _regeneratorRuntime().wrap(function
|
|
3017
|
-
while (1) switch (
|
|
2931
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2932
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3018
2933
|
case 0:
|
|
3019
|
-
runtimeConfig =
|
|
2934
|
+
runtimeConfig = _this11.getItemRuleRuntimeConfig();
|
|
3020
2935
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
3021
2936
|
if (!(staticConfigs.length > 0)) {
|
|
3022
|
-
|
|
2937
|
+
_context34.next = 6;
|
|
3023
2938
|
break;
|
|
3024
2939
|
}
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
return
|
|
2940
|
+
_this11.itemRuleConfigs = staticConfigs;
|
|
2941
|
+
_this11.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2942
|
+
return _context34.abrupt("return", _this11.itemRuleConfigs);
|
|
3028
2943
|
case 6:
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
return
|
|
2944
|
+
_this11.itemRuleConfigs = [];
|
|
2945
|
+
_this11.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2946
|
+
return _context34.abrupt("return", _this11.itemRuleConfigs);
|
|
3032
2947
|
case 9:
|
|
3033
2948
|
case "end":
|
|
3034
|
-
return
|
|
2949
|
+
return _context34.stop();
|
|
3035
2950
|
}
|
|
3036
|
-
},
|
|
2951
|
+
}, _callee34);
|
|
3037
2952
|
}))();
|
|
3038
|
-
|
|
2953
|
+
_context35.next = 7;
|
|
3039
2954
|
return this.itemRuleConfigsPromise;
|
|
3040
2955
|
case 7:
|
|
3041
|
-
return
|
|
2956
|
+
return _context35.abrupt("return", _context35.sent);
|
|
3042
2957
|
case 8:
|
|
3043
2958
|
case "end":
|
|
3044
|
-
return
|
|
2959
|
+
return _context35.stop();
|
|
3045
2960
|
}
|
|
3046
|
-
},
|
|
2961
|
+
}, _callee35, this);
|
|
3047
2962
|
}));
|
|
3048
2963
|
function ensureItemRuleConfigsLoaded() {
|
|
3049
2964
|
return _ensureItemRuleConfigsLoaded.apply(this, arguments);
|
|
@@ -3053,22 +2968,22 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3053
2968
|
}, {
|
|
3054
2969
|
key: "refreshItemRuleQuantityLimits",
|
|
3055
2970
|
value: function () {
|
|
3056
|
-
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2971
|
+
var _refreshItemRuleQuantityLimits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
3057
2972
|
var strategyConfigs, businessData, limits;
|
|
3058
|
-
return _regeneratorRuntime().wrap(function
|
|
3059
|
-
while (1) switch (
|
|
2973
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2974
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3060
2975
|
case 0:
|
|
3061
|
-
|
|
3062
|
-
|
|
2976
|
+
_context36.prev = 0;
|
|
2977
|
+
_context36.next = 3;
|
|
3063
2978
|
return this.ensureItemRuleConfigsLoaded();
|
|
3064
2979
|
case 3:
|
|
3065
|
-
strategyConfigs =
|
|
2980
|
+
strategyConfigs = _context36.sent;
|
|
3066
2981
|
if (strategyConfigs.length) {
|
|
3067
|
-
|
|
2982
|
+
_context36.next = 7;
|
|
3068
2983
|
break;
|
|
3069
2984
|
}
|
|
3070
2985
|
this.store.itemRuleQuantityLimits = [];
|
|
3071
|
-
return
|
|
2986
|
+
return _context36.abrupt("return", []);
|
|
3072
2987
|
case 7:
|
|
3073
2988
|
businessData = buildItemRuleBusinessData({
|
|
3074
2989
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -3080,18 +2995,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3080
2995
|
this.logMethodSuccess('refreshItemRuleQuantityLimits', {
|
|
3081
2996
|
limitCount: limits.length
|
|
3082
2997
|
});
|
|
3083
|
-
return
|
|
2998
|
+
return _context36.abrupt("return", limits);
|
|
3084
2999
|
case 14:
|
|
3085
|
-
|
|
3086
|
-
|
|
3000
|
+
_context36.prev = 14;
|
|
3001
|
+
_context36.t0 = _context36["catch"](0);
|
|
3087
3002
|
this.store.itemRuleQuantityLimits = [];
|
|
3088
|
-
this.logMethodError('refreshItemRuleQuantityLimits',
|
|
3089
|
-
return
|
|
3003
|
+
this.logMethodError('refreshItemRuleQuantityLimits', _context36.t0);
|
|
3004
|
+
return _context36.abrupt("return", []);
|
|
3090
3005
|
case 19:
|
|
3091
3006
|
case "end":
|
|
3092
|
-
return
|
|
3007
|
+
return _context36.stop();
|
|
3093
3008
|
}
|
|
3094
|
-
},
|
|
3009
|
+
}, _callee36, this, [[0, 14]]);
|
|
3095
3010
|
}));
|
|
3096
3011
|
function refreshItemRuleQuantityLimits() {
|
|
3097
3012
|
return _refreshItemRuleQuantityLimits.apply(this, arguments);
|
|
@@ -3101,32 +3016,32 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3101
3016
|
}, {
|
|
3102
3017
|
key: "applyPrefillByItemRule",
|
|
3103
3018
|
value: function () {
|
|
3104
|
-
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3105
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
3106
|
-
return _regeneratorRuntime().wrap(function
|
|
3107
|
-
while (1) switch (
|
|
3019
|
+
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;
|
|
3021
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3022
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3108
3023
|
case 0:
|
|
3109
3024
|
if (!this.itemRulePrefillApplied) {
|
|
3110
|
-
|
|
3025
|
+
_context37.next = 2;
|
|
3111
3026
|
break;
|
|
3112
3027
|
}
|
|
3113
|
-
return
|
|
3028
|
+
return _context37.abrupt("return");
|
|
3114
3029
|
case 2:
|
|
3115
3030
|
if (this.store.order) {
|
|
3116
|
-
|
|
3031
|
+
_context37.next = 4;
|
|
3117
3032
|
break;
|
|
3118
3033
|
}
|
|
3119
|
-
return
|
|
3034
|
+
return _context37.abrupt("return");
|
|
3120
3035
|
case 4:
|
|
3121
|
-
|
|
3036
|
+
_context37.next = 6;
|
|
3122
3037
|
return this.ensureItemRuleConfigsLoaded();
|
|
3123
3038
|
case 6:
|
|
3124
|
-
strategyConfigs =
|
|
3039
|
+
strategyConfigs = _context37.sent;
|
|
3125
3040
|
if (strategyConfigs.length) {
|
|
3126
|
-
|
|
3041
|
+
_context37.next = 9;
|
|
3127
3042
|
break;
|
|
3128
3043
|
}
|
|
3129
|
-
return
|
|
3044
|
+
return _context37.abrupt("return");
|
|
3130
3045
|
case 9:
|
|
3131
3046
|
businessData = buildItemRuleBusinessData({
|
|
3132
3047
|
tempOrder: this.ensureTempOrder(),
|
|
@@ -3135,41 +3050,41 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3135
3050
|
});
|
|
3136
3051
|
prefillItems = this.itemRuleEvaluator.getPrefillItems(businessData);
|
|
3137
3052
|
if (prefillItems.length) {
|
|
3138
|
-
|
|
3053
|
+
_context37.next = 14;
|
|
3139
3054
|
break;
|
|
3140
3055
|
}
|
|
3141
3056
|
this.itemRulePrefillApplied = true;
|
|
3142
|
-
return
|
|
3057
|
+
return _context37.abrupt("return");
|
|
3143
3058
|
case 14:
|
|
3144
|
-
|
|
3059
|
+
_context37.next = 16;
|
|
3145
3060
|
return this.buildPrefillProductSourceMap();
|
|
3146
3061
|
case 16:
|
|
3147
|
-
productSourceMap =
|
|
3062
|
+
productSourceMap = _context37.sent;
|
|
3148
3063
|
tempOrder = this.ensureTempOrder();
|
|
3149
3064
|
hasChanges = false;
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3065
|
+
_iterator17 = _createForOfIteratorHelper(prefillItems);
|
|
3066
|
+
_context37.prev = 20;
|
|
3067
|
+
_iterator17.s();
|
|
3153
3068
|
case 22:
|
|
3154
|
-
if ((
|
|
3155
|
-
|
|
3069
|
+
if ((_step17 = _iterator17.n()).done) {
|
|
3070
|
+
_context37.next = 45;
|
|
3156
3071
|
break;
|
|
3157
3072
|
}
|
|
3158
|
-
prefillItem =
|
|
3073
|
+
prefillItem = _step17.value;
|
|
3159
3074
|
productId = Number(prefillItem.product_id);
|
|
3160
3075
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
3161
3076
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
3162
3077
|
if (!(!Number.isFinite(productId) || targetQuantity <= 0)) {
|
|
3163
|
-
|
|
3078
|
+
_context37.next = 29;
|
|
3164
3079
|
break;
|
|
3165
3080
|
}
|
|
3166
|
-
return
|
|
3081
|
+
return _context37.abrupt("continue", 43);
|
|
3167
3082
|
case 29:
|
|
3168
3083
|
if (!Number.isNaN(productVariantId)) {
|
|
3169
|
-
|
|
3084
|
+
_context37.next = 31;
|
|
3170
3085
|
break;
|
|
3171
3086
|
}
|
|
3172
|
-
return
|
|
3087
|
+
return _context37.abrupt("continue", 43);
|
|
3173
3088
|
case 31:
|
|
3174
3089
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
3175
3090
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -3177,7 +3092,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3177
3092
|
product_variant_id: productVariantId
|
|
3178
3093
|
});
|
|
3179
3094
|
if (!(productIndex === -1)) {
|
|
3180
|
-
|
|
3095
|
+
_context37.next = 38;
|
|
3181
3096
|
break;
|
|
3182
3097
|
}
|
|
3183
3098
|
sellingPrice = toPriceString((_sourceItem$price = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _sourceItem$price !== void 0 ? _sourceItem$price : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.selling_price, '0.00');
|
|
@@ -3197,7 +3112,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3197
3112
|
})
|
|
3198
3113
|
}));
|
|
3199
3114
|
hasChanges = true;
|
|
3200
|
-
return
|
|
3115
|
+
return _context37.abrupt("continue", 43);
|
|
3201
3116
|
case 38:
|
|
3202
3117
|
targetProduct = tempOrder.products[productIndex];
|
|
3203
3118
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
@@ -3216,34 +3131,34 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3216
3131
|
hasChanges = true;
|
|
3217
3132
|
}
|
|
3218
3133
|
case 43:
|
|
3219
|
-
|
|
3134
|
+
_context37.next = 22;
|
|
3220
3135
|
break;
|
|
3221
3136
|
case 45:
|
|
3222
|
-
|
|
3137
|
+
_context37.next = 50;
|
|
3223
3138
|
break;
|
|
3224
3139
|
case 47:
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3140
|
+
_context37.prev = 47;
|
|
3141
|
+
_context37.t0 = _context37["catch"](20);
|
|
3142
|
+
_iterator17.e(_context37.t0);
|
|
3228
3143
|
case 50:
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
return
|
|
3144
|
+
_context37.prev = 50;
|
|
3145
|
+
_iterator17.f();
|
|
3146
|
+
return _context37.finish(50);
|
|
3232
3147
|
case 53:
|
|
3233
3148
|
if (!hasChanges) {
|
|
3234
|
-
|
|
3149
|
+
_context37.next = 58;
|
|
3235
3150
|
break;
|
|
3236
3151
|
}
|
|
3237
3152
|
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
3238
3153
|
this.store.order.applyDiscount();
|
|
3239
|
-
|
|
3154
|
+
_context37.next = 57;
|
|
3240
3155
|
return this.store.order.recalculateSummary({
|
|
3241
3156
|
createIfMissing: true
|
|
3242
3157
|
});
|
|
3243
3158
|
case 57:
|
|
3244
3159
|
this.store.order.persistTempOrder();
|
|
3245
3160
|
case 58:
|
|
3246
|
-
|
|
3161
|
+
_context37.next = 60;
|
|
3247
3162
|
return this.refreshItemRuleQuantityLimits();
|
|
3248
3163
|
case 60:
|
|
3249
3164
|
this.itemRulePrefillApplied = true;
|
|
@@ -3253,9 +3168,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3253
3168
|
});
|
|
3254
3169
|
case 62:
|
|
3255
3170
|
case "end":
|
|
3256
|
-
return
|
|
3171
|
+
return _context37.stop();
|
|
3257
3172
|
}
|
|
3258
|
-
},
|
|
3173
|
+
}, _callee37, this, [[20, 47, 50, 53]]);
|
|
3259
3174
|
}));
|
|
3260
3175
|
function applyPrefillByItemRule() {
|
|
3261
3176
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -3265,24 +3180,24 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3265
3180
|
}, {
|
|
3266
3181
|
key: "applyItemRulePrefill",
|
|
3267
3182
|
value: function () {
|
|
3268
|
-
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3269
|
-
return _regeneratorRuntime().wrap(function
|
|
3270
|
-
while (1) switch (
|
|
3183
|
+
var _applyItemRulePrefill = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38() {
|
|
3184
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3185
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3271
3186
|
case 0:
|
|
3272
3187
|
this.logMethodStart('applyItemRulePrefill');
|
|
3273
|
-
|
|
3188
|
+
_context38.next = 3;
|
|
3274
3189
|
return this.applyPrefillByItemRule();
|
|
3275
3190
|
case 3:
|
|
3276
|
-
|
|
3191
|
+
_context38.next = 5;
|
|
3277
3192
|
return this.refreshItemRuleQuantityLimits();
|
|
3278
3193
|
case 5:
|
|
3279
|
-
|
|
3194
|
+
_context38.next = 7;
|
|
3280
3195
|
return this.refreshCartValidationPassed();
|
|
3281
3196
|
case 7:
|
|
3282
3197
|
case "end":
|
|
3283
|
-
return
|
|
3198
|
+
return _context38.stop();
|
|
3284
3199
|
}
|
|
3285
|
-
},
|
|
3200
|
+
}, _callee38, this);
|
|
3286
3201
|
}));
|
|
3287
3202
|
function applyItemRulePrefill() {
|
|
3288
3203
|
return _applyItemRulePrefill.apply(this, arguments);
|
|
@@ -3292,20 +3207,20 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3292
3207
|
}, {
|
|
3293
3208
|
key: "evaluateCartValidationByItemRule",
|
|
3294
3209
|
value: function () {
|
|
3295
|
-
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3210
|
+
var _evaluateCartValidationByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3296
3211
|
var strategyConfigs, businessData;
|
|
3297
|
-
return _regeneratorRuntime().wrap(function
|
|
3298
|
-
while (1) switch (
|
|
3212
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3213
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3299
3214
|
case 0:
|
|
3300
|
-
|
|
3215
|
+
_context39.next = 2;
|
|
3301
3216
|
return this.ensureItemRuleConfigsLoaded();
|
|
3302
3217
|
case 2:
|
|
3303
|
-
strategyConfigs =
|
|
3218
|
+
strategyConfigs = _context39.sent;
|
|
3304
3219
|
if (strategyConfigs.length) {
|
|
3305
|
-
|
|
3220
|
+
_context39.next = 5;
|
|
3306
3221
|
break;
|
|
3307
3222
|
}
|
|
3308
|
-
return
|
|
3223
|
+
return _context39.abrupt("return", {
|
|
3309
3224
|
passed: true,
|
|
3310
3225
|
failures: []
|
|
3311
3226
|
});
|
|
@@ -3315,12 +3230,12 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3315
3230
|
runtimeConfig: this.getItemRuleRuntimeConfig(),
|
|
3316
3231
|
itemRuleConfigs: this.itemRuleConfigs
|
|
3317
3232
|
});
|
|
3318
|
-
return
|
|
3233
|
+
return _context39.abrupt("return", this.itemRuleEvaluator.validateCart(businessData));
|
|
3319
3234
|
case 7:
|
|
3320
3235
|
case "end":
|
|
3321
|
-
return
|
|
3236
|
+
return _context39.stop();
|
|
3322
3237
|
}
|
|
3323
|
-
},
|
|
3238
|
+
}, _callee39, this);
|
|
3324
3239
|
}));
|
|
3325
3240
|
function evaluateCartValidationByItemRule() {
|
|
3326
3241
|
return _evaluateCartValidationByItemRule.apply(this, arguments);
|
|
@@ -3330,20 +3245,20 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3330
3245
|
}, {
|
|
3331
3246
|
key: "validateBeforeSubmitByItemRule",
|
|
3332
3247
|
value: function () {
|
|
3333
|
-
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3248
|
+
var _validateBeforeSubmitByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3334
3249
|
var validationResult, firstFailure, errorMessage, error;
|
|
3335
|
-
return _regeneratorRuntime().wrap(function
|
|
3336
|
-
while (1) switch (
|
|
3250
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3251
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3337
3252
|
case 0:
|
|
3338
|
-
|
|
3253
|
+
_context40.next = 2;
|
|
3339
3254
|
return this.evaluateCartValidationByItemRule();
|
|
3340
3255
|
case 2:
|
|
3341
|
-
validationResult =
|
|
3256
|
+
validationResult = _context40.sent;
|
|
3342
3257
|
if (!validationResult.passed) {
|
|
3343
|
-
|
|
3258
|
+
_context40.next = 5;
|
|
3344
3259
|
break;
|
|
3345
3260
|
}
|
|
3346
|
-
return
|
|
3261
|
+
return _context40.abrupt("return");
|
|
3347
3262
|
case 5:
|
|
3348
3263
|
firstFailure = validationResult.failures[0];
|
|
3349
3264
|
errorMessage = (firstFailure === null || firstFailure === void 0 ? void 0 : firstFailure.validationMessage) || '当前购物车未满足商品规则,请调整后再提交';
|
|
@@ -3352,9 +3267,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3352
3267
|
throw error;
|
|
3353
3268
|
case 10:
|
|
3354
3269
|
case "end":
|
|
3355
|
-
return
|
|
3270
|
+
return _context40.stop();
|
|
3356
3271
|
}
|
|
3357
|
-
},
|
|
3272
|
+
}, _callee40, this);
|
|
3358
3273
|
}));
|
|
3359
3274
|
function validateBeforeSubmitByItemRule() {
|
|
3360
3275
|
return _validateBeforeSubmitByItemRule.apply(this, arguments);
|
|
@@ -3364,10 +3279,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3364
3279
|
}, {
|
|
3365
3280
|
key: "refreshCartValidationPassed",
|
|
3366
3281
|
value: function () {
|
|
3367
|
-
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3282
|
+
var _refreshCartValidationPassed = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
|
|
3368
3283
|
var previous, nextState, validationResult, changed;
|
|
3369
|
-
return _regeneratorRuntime().wrap(function
|
|
3370
|
-
while (1) switch (
|
|
3284
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3285
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3371
3286
|
case 0:
|
|
3372
3287
|
previous = this.store.cartValidation || {
|
|
3373
3288
|
passed: null,
|
|
@@ -3377,20 +3292,20 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3377
3292
|
passed: null,
|
|
3378
3293
|
failures: []
|
|
3379
3294
|
};
|
|
3380
|
-
|
|
3381
|
-
|
|
3295
|
+
_context41.prev = 2;
|
|
3296
|
+
_context41.next = 5;
|
|
3382
3297
|
return this.evaluateCartValidationByItemRule();
|
|
3383
3298
|
case 5:
|
|
3384
|
-
validationResult =
|
|
3299
|
+
validationResult = _context41.sent;
|
|
3385
3300
|
nextState = {
|
|
3386
3301
|
passed: validationResult.passed,
|
|
3387
3302
|
failures: validationResult.failures || []
|
|
3388
3303
|
};
|
|
3389
|
-
|
|
3304
|
+
_context41.next = 12;
|
|
3390
3305
|
break;
|
|
3391
3306
|
case 9:
|
|
3392
|
-
|
|
3393
|
-
|
|
3307
|
+
_context41.prev = 9;
|
|
3308
|
+
_context41.t0 = _context41["catch"](2);
|
|
3394
3309
|
nextState = {
|
|
3395
3310
|
passed: false,
|
|
3396
3311
|
failures: []
|
|
@@ -3399,21 +3314,21 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3399
3314
|
this.store.cartValidation = nextState;
|
|
3400
3315
|
changed = previous.passed !== nextState.passed || previous.failures !== nextState.failures;
|
|
3401
3316
|
if (!changed) {
|
|
3402
|
-
|
|
3317
|
+
_context41.next = 17;
|
|
3403
3318
|
break;
|
|
3404
3319
|
}
|
|
3405
|
-
|
|
3320
|
+
_context41.next = 17;
|
|
3406
3321
|
return this.core.effects.emit(VenueBookingHooks.onCartValidationChanged, {
|
|
3407
3322
|
cartValidation: nextState,
|
|
3408
3323
|
cartValidationPassed: nextState.passed
|
|
3409
3324
|
});
|
|
3410
3325
|
case 17:
|
|
3411
|
-
return
|
|
3326
|
+
return _context41.abrupt("return", nextState.passed);
|
|
3412
3327
|
case 18:
|
|
3413
3328
|
case "end":
|
|
3414
|
-
return
|
|
3329
|
+
return _context41.stop();
|
|
3415
3330
|
}
|
|
3416
|
-
},
|
|
3331
|
+
}, _callee41, this, [[2, 9]]);
|
|
3417
3332
|
}));
|
|
3418
3333
|
function refreshCartValidationPassed() {
|
|
3419
3334
|
return _refreshCartValidationPassed.apply(this, arguments);
|
|
@@ -3423,14 +3338,14 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3423
3338
|
}, {
|
|
3424
3339
|
key: "setItemRuleRuntimeConfig",
|
|
3425
3340
|
value: function () {
|
|
3426
|
-
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3341
|
+
var _setItemRuleRuntimeConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
3427
3342
|
var _this$itemRuleRuntime, _this$itemRuleRuntime2;
|
|
3428
3343
|
var config,
|
|
3429
|
-
|
|
3430
|
-
return _regeneratorRuntime().wrap(function
|
|
3431
|
-
while (1) switch (
|
|
3344
|
+
_args42 = arguments;
|
|
3345
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3346
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3432
3347
|
case 0:
|
|
3433
|
-
config =
|
|
3348
|
+
config = _args42.length > 0 && _args42[0] !== undefined ? _args42[0] : {};
|
|
3434
3349
|
this.logMethodStart('setItemRuleRuntimeConfig');
|
|
3435
3350
|
this.itemRuleRuntimeConfig = _objectSpread(_objectSpread(_objectSpread({}, this.itemRuleRuntimeConfig), config), {}, {
|
|
3436
3351
|
pax: _objectSpread(_objectSpread({}, ((_this$itemRuleRuntime = this.itemRuleRuntimeConfig) === null || _this$itemRuleRuntime === void 0 ? void 0 : _this$itemRuleRuntime.pax) || {}), (config === null || config === void 0 ? void 0 : config.pax) || {}),
|
|
@@ -3442,10 +3357,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3442
3357
|
this.itemRuleEvaluator.setStrategyConfigs([]);
|
|
3443
3358
|
}
|
|
3444
3359
|
this.itemRulePrefillApplied = false;
|
|
3445
|
-
|
|
3360
|
+
_context42.next = 7;
|
|
3446
3361
|
return this.refreshItemRuleQuantityLimits();
|
|
3447
3362
|
case 7:
|
|
3448
|
-
|
|
3363
|
+
_context42.next = 9;
|
|
3449
3364
|
return this.refreshCartValidationPassed();
|
|
3450
3365
|
case 9:
|
|
3451
3366
|
this.logMethodSuccess('setItemRuleRuntimeConfig', {
|
|
@@ -3453,9 +3368,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3453
3368
|
});
|
|
3454
3369
|
case 10:
|
|
3455
3370
|
case "end":
|
|
3456
|
-
return
|
|
3371
|
+
return _context42.stop();
|
|
3457
3372
|
}
|
|
3458
|
-
},
|
|
3373
|
+
}, _callee42, this);
|
|
3459
3374
|
}));
|
|
3460
3375
|
function setItemRuleRuntimeConfig() {
|
|
3461
3376
|
return _setItemRuleRuntimeConfig.apply(this, arguments);
|
|
@@ -3489,7 +3404,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3489
3404
|
var raw = this.window.sessionStorage.getItem(key) || '{}';
|
|
3490
3405
|
var parsed = JSON.parse(raw);
|
|
3491
3406
|
return parsed && _typeof(parsed) === 'object' ? parsed : {};
|
|
3492
|
-
} catch (
|
|
3407
|
+
} catch (_unused3) {
|
|
3493
3408
|
return {};
|
|
3494
3409
|
}
|
|
3495
3410
|
}
|
|
@@ -3544,25 +3459,25 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3544
3459
|
}, {
|
|
3545
3460
|
key: "checkOpenDataAvailability",
|
|
3546
3461
|
value: function () {
|
|
3547
|
-
var _checkOpenDataAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3548
|
-
return _regeneratorRuntime().wrap(function
|
|
3549
|
-
while (1) switch (
|
|
3462
|
+
var _checkOpenDataAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
3463
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3464
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3550
3465
|
case 0:
|
|
3551
3466
|
if (this.store.openData) {
|
|
3552
|
-
|
|
3467
|
+
_context43.next = 2;
|
|
3553
3468
|
break;
|
|
3554
3469
|
}
|
|
3555
3470
|
throw new Error('openData 模块未初始化');
|
|
3556
3471
|
case 2:
|
|
3557
|
-
|
|
3472
|
+
_context43.next = 4;
|
|
3558
3473
|
return this.loadOpenDataConfig();
|
|
3559
3474
|
case 4:
|
|
3560
|
-
return
|
|
3475
|
+
return _context43.abrupt("return", this.store.openData.checkAvailability(this.store.schedule));
|
|
3561
3476
|
case 5:
|
|
3562
3477
|
case "end":
|
|
3563
|
-
return
|
|
3478
|
+
return _context43.stop();
|
|
3564
3479
|
}
|
|
3565
|
-
},
|
|
3480
|
+
}, _callee43, this);
|
|
3566
3481
|
}));
|
|
3567
3482
|
function checkOpenDataAvailability() {
|
|
3568
3483
|
return _checkOpenDataAvailability.apply(this, arguments);
|
|
@@ -3572,15 +3487,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3572
3487
|
}, {
|
|
3573
3488
|
key: "setOtherParams",
|
|
3574
3489
|
value: function () {
|
|
3575
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3490
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(params) {
|
|
3576
3491
|
var _ref5,
|
|
3577
3492
|
_ref5$cover,
|
|
3578
3493
|
cover,
|
|
3579
|
-
|
|
3580
|
-
return _regeneratorRuntime().wrap(function
|
|
3581
|
-
while (1) switch (
|
|
3494
|
+
_args44 = arguments;
|
|
3495
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3496
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3582
3497
|
case 0:
|
|
3583
|
-
_ref5 =
|
|
3498
|
+
_ref5 = _args44.length > 1 && _args44[1] !== undefined ? _args44[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
3584
3499
|
if (cover) {
|
|
3585
3500
|
this.otherParams = params;
|
|
3586
3501
|
} else {
|
|
@@ -3588,11 +3503,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3588
3503
|
}
|
|
3589
3504
|
case 2:
|
|
3590
3505
|
case "end":
|
|
3591
|
-
return
|
|
3506
|
+
return _context44.stop();
|
|
3592
3507
|
}
|
|
3593
|
-
},
|
|
3508
|
+
}, _callee44, this);
|
|
3594
3509
|
}));
|
|
3595
|
-
function setOtherParams(
|
|
3510
|
+
function setOtherParams(_x21) {
|
|
3596
3511
|
return _setOtherParams.apply(this, arguments);
|
|
3597
3512
|
}
|
|
3598
3513
|
return setOtherParams;
|
|
@@ -3601,5 +3516,4 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3601
3516
|
return VenueBookingImpl;
|
|
3602
3517
|
}(BaseModule);
|
|
3603
3518
|
_defineProperty(VenueBookingImpl, "OPEN_DATA_CACHE_TTL", 5 * 60 * 1000);
|
|
3604
|
-
_defineProperty(VenueBookingImpl, "PISELL1_LOGIN_SUCCESS", 'pisell1.login.success');
|
|
3605
3519
|
_defineProperty(VenueBookingImpl, "UI_STATE_KEY_PREFIX", 'pisell.venueBooking.uiState:');
|