@pisell/pisellos 2.1.162 → 2.1.163
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.js +167 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +780 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/examples.js +277 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/index.js +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/dist/model/strategy/adapter/dataVariant/type.js +54 -0
- package/dist/model/strategy/adapter/index.d.ts +4 -0
- package/dist/model/strategy/adapter/index.js +5 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/index.d.ts +5 -2
- package/dist/modules/Discount/index.js +21 -1
- package/dist/modules/Discount/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +18 -6
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/ProductList/index.d.ts +3 -1
- package/dist/modules/ProductList/index.js +22 -11
- package/dist/modules/Schedule/getDateIsInSchedule.js +5 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.js +1 -1
- package/dist/solution/ShopDiscount/index.js +16 -15
- package/dist/solution/VenueBooking/index.d.ts +23 -3
- package/dist/solution/VenueBooking/index.js +267 -168
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/dist/solution/VenueBooking/utils/dateSummary.js +12 -25
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -9
- package/dist/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
- package/dist/solution/VenueBooking/utils/smartPricing.js +233 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +9 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.js +149 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +89 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +583 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/examples.js +293 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/index.js +38 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +148 -0
- package/lib/model/strategy/adapter/dataVariant/type.js +31 -0
- package/lib/model/strategy/adapter/index.d.ts +4 -0
- package/lib/model/strategy/adapter/index.js +13 -2
- package/lib/modules/Discount/index.d.ts +5 -2
- package/lib/modules/Discount/index.js +11 -1
- package/lib/modules/Discount/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +11 -1
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/ProductList/index.d.ts +3 -1
- package/lib/modules/ProductList/index.js +45 -39
- package/lib/modules/Schedule/getDateIsInSchedule.js +4 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.js +1 -1
- package/lib/solution/ShopDiscount/index.js +3 -2
- package/lib/solution/VenueBooking/index.d.ts +23 -3
- package/lib/solution/VenueBooking/index.js +164 -69
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
- package/lib/solution/VenueBooking/utils/dateSummary.js +5 -10
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -6
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -4
- package/lib/solution/VenueBooking/utils/smartPricing.d.ts +70 -0
- package/lib/solution/VenueBooking/utils/smartPricing.js +180 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +7 -3
- package/package.json +1 -1
|
@@ -45,6 +45,7 @@ import { extractResourceIds, buildResourceProductMap } from "./utils/resource";
|
|
|
45
45
|
import { buildTimeSlotGrid, isBusinessHoursCrossDay, generateTimeLabels } from "./utils/timeSlot";
|
|
46
46
|
import { buildDateRangeSummary } from "./utils/dateSummary";
|
|
47
47
|
import { mergeConsecutiveSlots, expandMergedSlotToIndividual, buildVenueIdentityKey, buildVenueBookingEntry, buildVenueResourceMetadata, buildPriceBreakdown } from "./utils/slotMerge";
|
|
48
|
+
import { buildSlotPriceMapByScheduleSegments, formatProductsWithDataVariant, getPriceForProductAtDatetime, getSlotPriceFromMap } from "./utils/smartPricing";
|
|
48
49
|
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
49
50
|
import { OrderModule } from "../../modules/Order";
|
|
50
51
|
import { RegisterAndLoginHooks } from "../RegisterAndLogin/types";
|
|
@@ -101,6 +102,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
101
102
|
_defineProperty(_assertThisInitialized(_this), "loadAllProductsInFlight", null);
|
|
102
103
|
_defineProperty(_assertThisInitialized(_this), "productsLoaded", false);
|
|
103
104
|
_defineProperty(_assertThisInitialized(_this), "loadOpenDataConfigInFlight", null);
|
|
105
|
+
/** 按日期缓存 slot 智能定价 Map,避免同周重复 resolveProducts */
|
|
106
|
+
_defineProperty(_assertThisInitialized(_this), "slotPriceMapCache", new Map());
|
|
107
|
+
/** loadProducts 后缓存的全量商品(venue + addon),供分段算价复用 */
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "smartPricingProductCatalog", []);
|
|
104
109
|
return _this;
|
|
105
110
|
}
|
|
106
111
|
_createClass(VenueBookingImpl, [{
|
|
@@ -395,37 +400,28 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
395
400
|
case 9:
|
|
396
401
|
this.customerLoginRefreshIdInFlight = params.customerId;
|
|
397
402
|
refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
398
|
-
var _this3$otherParams;
|
|
399
403
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
400
404
|
while (1) switch (_context4.prev = _context4.next) {
|
|
401
405
|
case 0:
|
|
402
|
-
|
|
403
|
-
_context4.next = 3;
|
|
404
|
-
break;
|
|
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
|
+
_context4.next = 2;
|
|
413
407
|
return _this3.store.order.loadDiscountConfig({
|
|
414
408
|
customerId: params.customerId
|
|
415
409
|
});
|
|
416
|
-
case
|
|
417
|
-
|
|
410
|
+
case 2:
|
|
411
|
+
_this3.clearSlotPriceMapCache();
|
|
412
|
+
_this3.recalculateOrderPricesFromSmartPricing();
|
|
413
|
+
_context4.next = 6;
|
|
418
414
|
return _this3.store.order.recalculateSummary({
|
|
419
415
|
createIfMissing: true
|
|
420
416
|
});
|
|
421
|
-
case
|
|
417
|
+
case 6:
|
|
422
418
|
_this3.store.order.persistTempOrder();
|
|
423
|
-
_context4.next =
|
|
419
|
+
_context4.next = 9;
|
|
424
420
|
return _this3.refreshItemRuleQuantityLimits();
|
|
425
|
-
case
|
|
426
|
-
_context4.next =
|
|
421
|
+
case 9:
|
|
422
|
+
_context4.next = 11;
|
|
427
423
|
return _this3.refreshCartValidationPassed();
|
|
428
|
-
case
|
|
424
|
+
case 11:
|
|
429
425
|
case "end":
|
|
430
426
|
return _context4.stop();
|
|
431
427
|
}
|
|
@@ -482,8 +478,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
482
478
|
openDataModule,
|
|
483
479
|
_this$store$order,
|
|
484
480
|
_this$store$order2,
|
|
485
|
-
_this$store$quotation,
|
|
486
|
-
_this$otherParams6,
|
|
487
481
|
_args6 = arguments;
|
|
488
482
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
489
483
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -633,34 +627,29 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
633
627
|
return this.loadRuntimeConfigs();
|
|
634
628
|
case 56:
|
|
635
629
|
if (!this.store.schedule) {
|
|
636
|
-
_context6.next =
|
|
630
|
+
_context6.next = 59;
|
|
637
631
|
break;
|
|
638
632
|
}
|
|
639
633
|
_context6.next = 59;
|
|
640
634
|
return this.store.schedule.loadAllSchedule();
|
|
641
635
|
case 59:
|
|
642
|
-
|
|
643
|
-
(_this$store$quotation = this.store.quotation) === null || _this$store$quotation === void 0 || _this$store$quotation.loadQuotations({
|
|
644
|
-
channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel
|
|
645
|
-
});
|
|
646
|
-
case 61:
|
|
647
|
-
_context6.next = 63;
|
|
636
|
+
_context6.next = 61;
|
|
648
637
|
return this.refreshItemRuleQuantityLimits();
|
|
649
|
-
case
|
|
638
|
+
case 61:
|
|
650
639
|
this.store.status = 'ready';
|
|
651
640
|
console.log('[VenueBooking] 初始化完成');
|
|
652
|
-
_context6.next =
|
|
641
|
+
_context6.next = 65;
|
|
653
642
|
return this.core.effects.emit(VenueBookingHooks.onInited, {
|
|
654
643
|
status: this.store.status
|
|
655
644
|
});
|
|
656
|
-
case
|
|
645
|
+
case 65:
|
|
657
646
|
this.logMethodSuccess('initialize', {
|
|
658
647
|
status: this.store.status
|
|
659
648
|
});
|
|
660
|
-
_context6.next =
|
|
649
|
+
_context6.next = 75;
|
|
661
650
|
break;
|
|
662
|
-
case
|
|
663
|
-
_context6.prev =
|
|
651
|
+
case 68:
|
|
652
|
+
_context6.prev = 68;
|
|
664
653
|
_context6.t0 = _context6["catch"](50);
|
|
665
654
|
this.store.status = 'error';
|
|
666
655
|
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
|
|
@@ -669,11 +658,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
669
658
|
status: this.store.status
|
|
670
659
|
});
|
|
671
660
|
throw _context6.t0;
|
|
672
|
-
case
|
|
661
|
+
case 75:
|
|
673
662
|
case "end":
|
|
674
663
|
return _context6.stop();
|
|
675
664
|
}
|
|
676
|
-
}, _callee6, this, [[50,
|
|
665
|
+
}, _callee6, this, [[50, 68]]);
|
|
677
666
|
}));
|
|
678
667
|
function initialize(_x5) {
|
|
679
668
|
return _initialize.apply(this, arguments);
|
|
@@ -814,6 +803,112 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
814
803
|
};
|
|
815
804
|
}
|
|
816
805
|
|
|
806
|
+
/** 清除 slot 价格分段缓存(商品重载 / 登录后 customerId 变化时调用) */
|
|
807
|
+
}, {
|
|
808
|
+
key: "clearSlotPriceMapCache",
|
|
809
|
+
value: function clearSlotPriceMapCache() {
|
|
810
|
+
this.slotPriceMapCache.clear();
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/** 读取当前登录 customerId */
|
|
814
|
+
}, {
|
|
815
|
+
key: "resolveCustomerIdForSmartPricing",
|
|
816
|
+
value: function resolveCustomerIdForSmartPricing() {
|
|
817
|
+
try {
|
|
818
|
+
var _this$core4, _userPlugin$get;
|
|
819
|
+
var userPlugin = (_this$core4 = this.core) === null || _this$core4 === void 0 ? void 0 : _this$core4.getPlugin('user');
|
|
820
|
+
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);
|
|
821
|
+
return Number.isFinite(customerId) && customerId > 0 ? customerId : undefined;
|
|
822
|
+
} catch (_unused2) {
|
|
823
|
+
return undefined;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}, {
|
|
827
|
+
key: "resolveAvailableWalletIdsForSmartPricing",
|
|
828
|
+
value: function resolveAvailableWalletIdsForSmartPricing() {
|
|
829
|
+
var _this$store$order3, _this$store$order3$ge, _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
|
|
830
|
+
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);
|
|
831
|
+
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);
|
|
832
|
+
var source = Array.isArray(orderWalletIds) && orderWalletIds.length ? orderWalletIds : fallbackWalletIds;
|
|
833
|
+
if (!Array.isArray(source)) return [];
|
|
834
|
+
var ids = source.map(function (item) {
|
|
835
|
+
return Number(item);
|
|
836
|
+
}).filter(function (item) {
|
|
837
|
+
return Number.isFinite(item) && item > 0;
|
|
838
|
+
});
|
|
839
|
+
return Array.from(new Set(ids));
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
/** 读取 schedule 全量列表,供智能定价 schedule_match 使用 */
|
|
843
|
+
}, {
|
|
844
|
+
key: "getScheduleListForSmartPricing",
|
|
845
|
+
value: function getScheduleListForSmartPricing() {
|
|
846
|
+
var _store;
|
|
847
|
+
var scheduleModule = this.store.schedule;
|
|
848
|
+
var list = scheduleModule === null || scheduleModule === void 0 || (_store = scheduleModule.store) === null || _store === void 0 ? void 0 : _store.scheduleList;
|
|
849
|
+
return Array.isArray(list) ? list : [];
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** 构建智能定价上下文,对齐 OS Server buildProductFormatterContext */
|
|
853
|
+
}, {
|
|
854
|
+
key: "buildSmartPricingContext",
|
|
855
|
+
value: function buildSmartPricingContext(customerId) {
|
|
856
|
+
var _this$core5, _this$otherParams10, _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14, _this$otherParams15, _this$otherParams16;
|
|
857
|
+
var evaluator = (_this$core5 = this.core) === null || _this$core5 === void 0 || (_this$core5 = _this$core5.context) === null || _this$core5 === void 0 ? void 0 : _this$core5.dataVariantEvaluator;
|
|
858
|
+
return {
|
|
859
|
+
evaluator: evaluator,
|
|
860
|
+
scheduleList: this.getScheduleListForSmartPricing(),
|
|
861
|
+
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) || [],
|
|
862
|
+
customerId: customerId !== null && customerId !== void 0 ? customerId : this.resolveCustomerIdForSmartPricing(),
|
|
863
|
+
availableWalletIds: this.resolveAvailableWalletIdsForSmartPricing(),
|
|
864
|
+
channel: (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.channel,
|
|
865
|
+
businessCode: (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode,
|
|
866
|
+
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),
|
|
867
|
+
strategy_context: (_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.strategy_context
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
/** venue + addon 全量商品,供智能定价评估 */
|
|
872
|
+
}, {
|
|
873
|
+
key: "getAllProductsForSmartPricing",
|
|
874
|
+
value: function getAllProductsForSmartPricing() {
|
|
875
|
+
if (this.smartPricingProductCatalog.length) {
|
|
876
|
+
return this.smartPricingProductCatalog;
|
|
877
|
+
}
|
|
878
|
+
var venueList = this.getVenueProducts();
|
|
879
|
+
var addonList = this.getAddonProductsList();
|
|
880
|
+
return [].concat(_toConsumableArray(venueList), _toConsumableArray(addonList));
|
|
881
|
+
}
|
|
882
|
+
}, {
|
|
883
|
+
key: "getSlotPriceMapCacheKey",
|
|
884
|
+
value: function getSlotPriceMapCacheKey(date, context) {
|
|
885
|
+
var _context$customerId, _context$channel, _context$businessCode;
|
|
886
|
+
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('|');
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* 按 schedule 分段构建 slot 价格 Map,带实例级缓存。
|
|
891
|
+
*/
|
|
892
|
+
}, {
|
|
893
|
+
key: "buildSlotPriceMapForDate",
|
|
894
|
+
value: function buildSlotPriceMapForDate(date, config, productIds) {
|
|
895
|
+
var context = this.buildSmartPricingContext();
|
|
896
|
+
var cacheKey = this.getSlotPriceMapCacheKey(date, context);
|
|
897
|
+
var cached = this.slotPriceMapCache.get(cacheKey);
|
|
898
|
+
if (cached) return cached;
|
|
899
|
+
var timeLabels = generateTimeLabels(config);
|
|
900
|
+
var slotPriceMap = buildSlotPriceMapByScheduleSegments({
|
|
901
|
+
products: this.getAllProductsForSmartPricing(),
|
|
902
|
+
productIds: productIds,
|
|
903
|
+
date: date,
|
|
904
|
+
timeLabels: timeLabels,
|
|
905
|
+
config: config,
|
|
906
|
+
context: context
|
|
907
|
+
});
|
|
908
|
+
this.slotPriceMapCache.set(cacheKey, slotPriceMap);
|
|
909
|
+
return slotPriceMap;
|
|
910
|
+
}
|
|
911
|
+
|
|
817
912
|
// ─── 场地商品 & 附加商品 ───
|
|
818
913
|
}, {
|
|
819
914
|
key: "loadAllProducts",
|
|
@@ -848,7 +943,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
848
943
|
key: "_doLoadAllProducts",
|
|
849
944
|
value: function () {
|
|
850
945
|
var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
851
|
-
var _this$
|
|
946
|
+
var _this$otherParams17, _this$store$venueProd, associatedMenus, menuListIds, allProducts, rawList, list, venueList, addonList, venueStore;
|
|
852
947
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
853
948
|
while (1) switch (_context11.prev = _context11.next) {
|
|
854
949
|
case 0:
|
|
@@ -869,7 +964,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
869
964
|
_context11.next = 8;
|
|
870
965
|
return this.loadOpenDataConfig();
|
|
871
966
|
case 8:
|
|
872
|
-
associatedMenus = ((_this$
|
|
967
|
+
associatedMenus = ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 || (_this$otherParams17 = _this$otherParams17.openData) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17['menu.associated_menus']) || [];
|
|
873
968
|
if (associatedMenus.length) {
|
|
874
969
|
_context11.next = 12;
|
|
875
970
|
break;
|
|
@@ -885,11 +980,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
885
980
|
menu_list_ids: menuListIds,
|
|
886
981
|
cacheId: this.cacheId,
|
|
887
982
|
schedule_date: dayjs().format('YYYY-MM-DD'),
|
|
888
|
-
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
983
|
+
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
984
|
+
with_extra: ['dataVariants']
|
|
889
985
|
});
|
|
890
986
|
case 15:
|
|
891
987
|
allProducts = _context11.sent;
|
|
892
|
-
|
|
988
|
+
rawList = Array.isArray(allProducts) ? allProducts : [];
|
|
989
|
+
list = rawList;
|
|
990
|
+
this.smartPricingProductCatalog = rawList.slice();
|
|
991
|
+
list = formatProductsWithDataVariant(list, this.buildSmartPricingContext(), dayjs().format('YYYY-MM-DD HH:mm:ss'));
|
|
992
|
+
this.clearSlotPriceMapCache();
|
|
893
993
|
venueList = list.filter(function (p) {
|
|
894
994
|
return p.duration != null;
|
|
895
995
|
});
|
|
@@ -915,16 +1015,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
915
1015
|
venueProducts: venueList,
|
|
916
1016
|
addonProducts: addonList
|
|
917
1017
|
});
|
|
918
|
-
case
|
|
919
|
-
_context11.prev =
|
|
1018
|
+
case 32:
|
|
1019
|
+
_context11.prev = 32;
|
|
920
1020
|
_context11.t0 = _context11["catch"](1);
|
|
921
1021
|
this.logMethodError('loadAllProducts', _context11.t0);
|
|
922
1022
|
throw _context11.t0;
|
|
923
|
-
case
|
|
1023
|
+
case 36:
|
|
924
1024
|
case "end":
|
|
925
1025
|
return _context11.stop();
|
|
926
1026
|
}
|
|
927
|
-
}, _callee11, this, [[1,
|
|
1027
|
+
}, _callee11, this, [[1, 32]]);
|
|
928
1028
|
}));
|
|
929
1029
|
function _doLoadAllProducts() {
|
|
930
1030
|
return _doLoadAllProducts2.apply(this, arguments);
|
|
@@ -1243,9 +1343,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1243
1343
|
config: this.baseSlotConfig,
|
|
1244
1344
|
rawResources: this.store.rawResourceData,
|
|
1245
1345
|
resourceProductMap: this.resourceProductMap,
|
|
1246
|
-
quotationModule: this.store.quotation,
|
|
1247
1346
|
resolveConfig: function resolveConfig(date) {
|
|
1248
1347
|
return _this6.resolveSlotConfigForDate(date);
|
|
1348
|
+
},
|
|
1349
|
+
buildSlotPriceMap: function buildSlotPriceMap(date, config, productIds) {
|
|
1350
|
+
return _this6.buildSlotPriceMapForDate(date, config, productIds);
|
|
1249
1351
|
}
|
|
1250
1352
|
});
|
|
1251
1353
|
}
|
|
@@ -1253,26 +1355,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1253
1355
|
key: "getTimeSlotGrid",
|
|
1254
1356
|
value: function getTimeSlotGrid(date) {
|
|
1255
1357
|
var resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
1256
|
-
var
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
})));
|
|
1261
|
-
var timeLabels = generateTimeLabels(resolvedSlotConfig);
|
|
1262
|
-
var timePoints = timeLabels.map(function (label) {
|
|
1263
|
-
return "".concat(date, " ").concat(label);
|
|
1264
|
-
});
|
|
1265
|
-
quotationPriceMap = this.store.quotation.buildProductPriceMap({
|
|
1266
|
-
productIds: productIds,
|
|
1267
|
-
timePoints: timePoints
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1358
|
+
var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).flat().map(function (m) {
|
|
1359
|
+
return m.productId;
|
|
1360
|
+
})));
|
|
1361
|
+
var slotPriceMap = productIds.length ? this.buildSlotPriceMapForDate(date, resolvedSlotConfig, productIds) : undefined;
|
|
1270
1362
|
return buildTimeSlotGrid({
|
|
1271
1363
|
date: date,
|
|
1272
1364
|
config: resolvedSlotConfig,
|
|
1273
1365
|
rawResources: this.store.rawResourceData,
|
|
1274
1366
|
resourceProductMap: this.resourceProductMap,
|
|
1275
|
-
|
|
1367
|
+
slotPriceMap: slotPriceMap
|
|
1276
1368
|
});
|
|
1277
1369
|
}
|
|
1278
1370
|
|
|
@@ -1372,8 +1464,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1372
1464
|
}, {
|
|
1373
1465
|
key: "getSelectedSlotsForResource",
|
|
1374
1466
|
value: function getSelectedSlotsForResource(resourceId, productId) {
|
|
1375
|
-
var _this$store$
|
|
1376
|
-
var tempOrder = (_this$store$
|
|
1467
|
+
var _this$store$order4;
|
|
1468
|
+
var tempOrder = (_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder();
|
|
1377
1469
|
if (!tempOrder) return [];
|
|
1378
1470
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1379
1471
|
var _p$metadata, _p$metadata2;
|
|
@@ -1534,9 +1626,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1534
1626
|
}, {
|
|
1535
1627
|
key: "getAllSelectedSlots",
|
|
1536
1628
|
value: function getAllSelectedSlots() {
|
|
1537
|
-
var _this$store$
|
|
1629
|
+
var _this$store$order5;
|
|
1538
1630
|
var result = new Map();
|
|
1539
|
-
var tempOrder = (_this$store$
|
|
1631
|
+
var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
|
|
1540
1632
|
if (!tempOrder) return result;
|
|
1541
1633
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1542
1634
|
var _p$metadata3;
|
|
@@ -1708,8 +1800,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1708
1800
|
booking_uid: bookingUuid,
|
|
1709
1801
|
price_breakdown: buildPriceBreakdown({
|
|
1710
1802
|
group: group,
|
|
1711
|
-
productId: mapping.productId
|
|
1712
|
-
quotation: this.store.quotation
|
|
1803
|
+
productId: mapping.productId
|
|
1713
1804
|
})
|
|
1714
1805
|
},
|
|
1715
1806
|
_origin: {
|
|
@@ -1840,36 +1931,25 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1840
1931
|
_context18.next = 6;
|
|
1841
1932
|
return this.store.schedule.loadAllSchedule();
|
|
1842
1933
|
case 6:
|
|
1843
|
-
this.injectScheduleResolverToQuotation();
|
|
1844
1934
|
this.logMethodSuccess('loadSchedules');
|
|
1845
|
-
_context18.next =
|
|
1935
|
+
_context18.next = 13;
|
|
1846
1936
|
break;
|
|
1847
|
-
case
|
|
1848
|
-
_context18.prev =
|
|
1937
|
+
case 9:
|
|
1938
|
+
_context18.prev = 9;
|
|
1849
1939
|
_context18.t0 = _context18["catch"](1);
|
|
1850
1940
|
this.logMethodError('loadSchedules', _context18.t0);
|
|
1851
1941
|
throw _context18.t0;
|
|
1852
|
-
case
|
|
1942
|
+
case 13:
|
|
1853
1943
|
case "end":
|
|
1854
1944
|
return _context18.stop();
|
|
1855
1945
|
}
|
|
1856
|
-
}, _callee18, this, [[1,
|
|
1946
|
+
}, _callee18, this, [[1, 9]]);
|
|
1857
1947
|
}));
|
|
1858
1948
|
function loadSchedules() {
|
|
1859
1949
|
return _loadSchedules.apply(this, arguments);
|
|
1860
1950
|
}
|
|
1861
1951
|
return loadSchedules;
|
|
1862
1952
|
}()
|
|
1863
|
-
}, {
|
|
1864
|
-
key: "injectScheduleResolverToQuotation",
|
|
1865
|
-
value: function injectScheduleResolverToQuotation() {
|
|
1866
|
-
var _this9 = this;
|
|
1867
|
-
if (this.store.quotation && this.store.schedule) {
|
|
1868
|
-
this.store.quotation.setScheduleResolver(function (id) {
|
|
1869
|
-
return _this9.store.schedule.getScheduleListByIds([id])[0];
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
1953
|
}, {
|
|
1874
1954
|
key: "getScheduleListByIds",
|
|
1875
1955
|
value: function getScheduleListByIds(ids) {
|
|
@@ -1881,8 +1961,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1881
1961
|
}, {
|
|
1882
1962
|
key: "getTempOrder",
|
|
1883
1963
|
value: function getTempOrder() {
|
|
1884
|
-
var _this$store$
|
|
1885
|
-
var result = ((_this$store$
|
|
1964
|
+
var _this$store$order6;
|
|
1965
|
+
var result = ((_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 ? void 0 : _this$store$order6.getTempOrder()) || null;
|
|
1886
1966
|
return result;
|
|
1887
1967
|
}
|
|
1888
1968
|
}, {
|
|
@@ -1941,14 +2021,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1941
2021
|
return onCustomerLogin;
|
|
1942
2022
|
}()
|
|
1943
2023
|
}, {
|
|
1944
|
-
key: "
|
|
1945
|
-
value: function
|
|
2024
|
+
key: "recalculateOrderPricesFromSmartPricing",
|
|
2025
|
+
value: function recalculateOrderPricesFromSmartPricing() {
|
|
1946
2026
|
var _tempOrder$products,
|
|
1947
|
-
|
|
1948
|
-
if (!this.store.order
|
|
2027
|
+
_this9 = this;
|
|
2028
|
+
if (!this.store.order) return;
|
|
1949
2029
|
var tempOrder = this.store.order.getTempOrder();
|
|
1950
2030
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
|
|
1951
2031
|
var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
2032
|
+
var catalog = this.getAllProductsForSmartPricing();
|
|
2033
|
+
var context = this.buildSmartPricingContext();
|
|
1952
2034
|
var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
|
|
1953
2035
|
_step12;
|
|
1954
2036
|
try {
|
|
@@ -1956,21 +2038,40 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1956
2038
|
var _product$metadata2;
|
|
1957
2039
|
var product = _step12.value;
|
|
1958
2040
|
if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
|
|
1959
|
-
var mappings =
|
|
2041
|
+
var mappings = _this9.resourceProductMap.get(product.metadata.resource_id);
|
|
1960
2042
|
if (!mappings || !mappings.length) return 0; // continue
|
|
1961
2043
|
var mapping = mappings.find(function (m) {
|
|
1962
2044
|
return Number(m.productId) === Number(product.product_id);
|
|
1963
2045
|
}) || mappings[0];
|
|
1964
2046
|
if (!mapping) return 0; // continue
|
|
1965
|
-
var slots = expandMergedSlotToIndividual(product,
|
|
2047
|
+
var slots = expandMergedSlotToIndividual(product, _this9.store.slotConfig.slotDurationMinutes);
|
|
2048
|
+
var uniqueDates = _toConsumableArray(new Set(slots.map(function (slot) {
|
|
2049
|
+
return dayjs(slot.startTime).format('YYYY-MM-DD');
|
|
2050
|
+
})));
|
|
2051
|
+
var slotPriceMaps = new Map();
|
|
2052
|
+
var _iterator13 = _createForOfIteratorHelper(uniqueDates),
|
|
2053
|
+
_step13;
|
|
2054
|
+
try {
|
|
2055
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2056
|
+
var slotDate = _step13.value;
|
|
2057
|
+
slotPriceMaps.set(slotDate, _this9.buildSlotPriceMapForDate(slotDate, _this9.store.slotConfig, [mapping.productId]));
|
|
2058
|
+
}
|
|
2059
|
+
} catch (err) {
|
|
2060
|
+
_iterator13.e(err);
|
|
2061
|
+
} finally {
|
|
2062
|
+
_iterator13.f();
|
|
2063
|
+
}
|
|
1966
2064
|
var updatedSlots = slots.map(function (slot) {
|
|
1967
|
-
var
|
|
2065
|
+
var slotDate = dayjs(slot.startTime).format('YYYY-MM-DD');
|
|
2066
|
+
var slotPriceMap = slotPriceMaps.get(slotDate);
|
|
1968
2067
|
return _objectSpread(_objectSpread({}, slot), {}, {
|
|
1969
2068
|
productId: mapping.productId,
|
|
1970
|
-
price:
|
|
2069
|
+
price: slotPriceMap ? getSlotPriceFromMap({
|
|
2070
|
+
slotPriceMap: slotPriceMap,
|
|
1971
2071
|
productId: mapping.productId,
|
|
1972
|
-
|
|
1973
|
-
|
|
2072
|
+
slotStartTime: slot.startTime,
|
|
2073
|
+
fallbackPrice: mapping.price
|
|
2074
|
+
}) : mapping.price
|
|
1974
2075
|
});
|
|
1975
2076
|
});
|
|
1976
2077
|
var merged = mergeConsecutiveSlots(updatedSlots);
|
|
@@ -1979,21 +2080,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1979
2080
|
product.original_price = merged[0].totalPrice;
|
|
1980
2081
|
product.metadata.price_breakdown = buildPriceBreakdown({
|
|
1981
2082
|
group: merged[0],
|
|
1982
|
-
productId: mapping.productId
|
|
1983
|
-
quotation: _this10.store.quotation
|
|
2083
|
+
productId: mapping.productId
|
|
1984
2084
|
});
|
|
1985
2085
|
}
|
|
1986
2086
|
} else if (product.product_id != null) {
|
|
1987
|
-
var
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
datetime: now
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
}
|
|
2087
|
+
var smartPrice = getPriceForProductAtDatetime({
|
|
2088
|
+
products: catalog,
|
|
2089
|
+
context: context,
|
|
2090
|
+
productId: Number(product.product_id),
|
|
2091
|
+
datetime: now,
|
|
2092
|
+
fallbackPrice: product.selling_price
|
|
2093
|
+
});
|
|
2094
|
+
product.selling_price = smartPrice;
|
|
2095
|
+
product.original_price = smartPrice;
|
|
1997
2096
|
}
|
|
1998
2097
|
},
|
|
1999
2098
|
_ret;
|
|
@@ -2072,7 +2171,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2072
2171
|
key: "setDiscountSelected",
|
|
2073
2172
|
value: (function () {
|
|
2074
2173
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
2075
|
-
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds,
|
|
2174
|
+
var _tempOrder$holder, _this$store$order$get, _this$store$order$get2, list, beforeTarget, updated, updatedTarget, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder2, result, beforeSelectedIds, _iterator14, _step14, d, selectedResourceIds, _iterator15, _step15, _product$_origin, _product$metadata$sou, _product$metadata3, _product$metadata4, _product$original_pri, product, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
2076
2175
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2077
2176
|
while (1) switch (_context21.prev = _context21.next) {
|
|
2078
2177
|
case 0:
|
|
@@ -2132,18 +2231,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2132
2231
|
}).map(function (d) {
|
|
2133
2232
|
return d.id;
|
|
2134
2233
|
}));
|
|
2135
|
-
|
|
2234
|
+
_iterator14 = _createForOfIteratorHelper(nextDiscountList);
|
|
2136
2235
|
try {
|
|
2137
|
-
for (
|
|
2138
|
-
d =
|
|
2236
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
2237
|
+
d = _step14.value;
|
|
2139
2238
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
2140
2239
|
d.isSelected = false;
|
|
2141
2240
|
}
|
|
2142
2241
|
}
|
|
2143
2242
|
} catch (err) {
|
|
2144
|
-
|
|
2243
|
+
_iterator14.e(err);
|
|
2145
2244
|
} finally {
|
|
2146
|
-
|
|
2245
|
+
_iterator14.f();
|
|
2147
2246
|
}
|
|
2148
2247
|
}
|
|
2149
2248
|
}
|
|
@@ -2156,15 +2255,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2156
2255
|
// 都以 original_price - Σ (当前选中 discount_list.amount) 重算 selling_price。
|
|
2157
2256
|
// 目的:避免 unselect 后 selling_price 残留、reselect 时把残留价带进下一轮 Rules 造成双折扣。
|
|
2158
2257
|
// 手动改价商品(_origin.isManualDiscount=true)不参与券流程归一化,保留手工价。
|
|
2159
|
-
|
|
2258
|
+
_iterator15 = _createForOfIteratorHelper(tempOrder.products);
|
|
2160
2259
|
_context21.prev = 19;
|
|
2161
|
-
|
|
2260
|
+
_iterator15.s();
|
|
2162
2261
|
case 21:
|
|
2163
|
-
if ((
|
|
2262
|
+
if ((_step15 = _iterator15.n()).done) {
|
|
2164
2263
|
_context21.next = 35;
|
|
2165
2264
|
break;
|
|
2166
2265
|
}
|
|
2167
|
-
product =
|
|
2266
|
+
product = _step15.value;
|
|
2168
2267
|
if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
|
|
2169
2268
|
_context21.next = 25;
|
|
2170
2269
|
break;
|
|
@@ -2204,10 +2303,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2204
2303
|
case 37:
|
|
2205
2304
|
_context21.prev = 37;
|
|
2206
2305
|
_context21.t0 = _context21["catch"](19);
|
|
2207
|
-
|
|
2306
|
+
_iterator15.e(_context21.t0);
|
|
2208
2307
|
case 40:
|
|
2209
2308
|
_context21.prev = 40;
|
|
2210
|
-
|
|
2309
|
+
_iterator15.f();
|
|
2211
2310
|
return _context21.finish(40);
|
|
2212
2311
|
case 43:
|
|
2213
2312
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
@@ -2339,7 +2438,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2339
2438
|
key: "submitOrder",
|
|
2340
2439
|
value: function () {
|
|
2341
2440
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2342
|
-
var _this$
|
|
2441
|
+
var _this$otherParams18, _this$otherParams19, _this$otherParams20, _this$otherParams21, _tempOrder$products2, result, tempOrder;
|
|
2343
2442
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2344
2443
|
while (1) switch (_context24.prev = _context24.next) {
|
|
2345
2444
|
case 0:
|
|
@@ -2357,10 +2456,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2357
2456
|
_context24.next = 8;
|
|
2358
2457
|
return this.store.order.submitTempOrder({
|
|
2359
2458
|
cacheId: this.cacheId,
|
|
2360
|
-
platform: (_this$
|
|
2361
|
-
businessCode: (_this$
|
|
2362
|
-
channel: (_this$
|
|
2363
|
-
type: (_this$
|
|
2459
|
+
platform: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.platform,
|
|
2460
|
+
businessCode: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.businessCode,
|
|
2461
|
+
channel: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.channel,
|
|
2462
|
+
type: (_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.type
|
|
2364
2463
|
});
|
|
2365
2464
|
case 8:
|
|
2366
2465
|
result = _context24.sent;
|
|
@@ -2389,7 +2488,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2389
2488
|
key: "addProductToOrder",
|
|
2390
2489
|
value: function () {
|
|
2391
2490
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(product) {
|
|
2392
|
-
var _product$metadata5, _product$
|
|
2491
|
+
var _product$metadata5, _product$metadata6, smartPrice, products;
|
|
2393
2492
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2394
2493
|
while (1) switch (_context25.prev = _context25.next) {
|
|
2395
2494
|
case 0:
|
|
@@ -2404,18 +2503,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2404
2503
|
}
|
|
2405
2504
|
throw new Error('order 模块未初始化');
|
|
2406
2505
|
case 4:
|
|
2407
|
-
if (!((_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) &&
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2506
|
+
if (!((_product$metadata5 = product.metadata) !== null && _product$metadata5 !== void 0 && _product$metadata5.venue_booking) && product.product_id != null) {
|
|
2507
|
+
smartPrice = getPriceForProductAtDatetime({
|
|
2508
|
+
products: this.getAllProductsForSmartPricing(),
|
|
2509
|
+
context: this.buildSmartPricingContext(),
|
|
2510
|
+
productId: Number(product.product_id),
|
|
2511
|
+
datetime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
2512
|
+
fallbackPrice: product.selling_price
|
|
2412
2513
|
});
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
product.original_price = product.selling_price;
|
|
2418
|
-
}
|
|
2514
|
+
product.selling_price = smartPrice;
|
|
2515
|
+
product.original_price = smartPrice;
|
|
2516
|
+
} else if (product.selling_price != null && !((_product$metadata6 = product.metadata) !== null && _product$metadata6 !== void 0 && _product$metadata6.venue_booking)) {
|
|
2517
|
+
product.original_price = product.selling_price;
|
|
2419
2518
|
}
|
|
2420
2519
|
_context25.next = 7;
|
|
2421
2520
|
return this.store.order.addProductToOrder(product);
|
|
@@ -2500,7 +2599,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2500
2599
|
key: "removeProductFromOrder",
|
|
2501
2600
|
value: function () {
|
|
2502
2601
|
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identity) {
|
|
2503
|
-
var _this$store$order$get3, _this$store$
|
|
2602
|
+
var _this$store$order$get3, _this$store$order7, _this$store$order$ens, _this$store$order8, _tempOrder$bookings, tempOrder, products, _tempOrder$bookings2, _tempOrder$bookings3, venueProductUids, venueBookingUids, _iterator16, _step16, _product$metadata7, _product$metadata8, product, beforeBookingCount, _this$store$order$per, _this$store$order9;
|
|
2504
2603
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2505
2604
|
while (1) switch (_context27.prev = _context27.next) {
|
|
2506
2605
|
case 0:
|
|
@@ -2515,7 +2614,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2515
2614
|
}
|
|
2516
2615
|
throw new Error('order 模块未初始化');
|
|
2517
2616
|
case 4:
|
|
2518
|
-
tempOrder = ((_this$store$order$get3 = (_this$store$
|
|
2617
|
+
tempOrder = ((_this$store$order$get3 = (_this$store$order7 = this.store.order).getTempOrder) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.call(_this$store$order7)) || ((_this$store$order$ens = (_this$store$order8 = this.store.order).ensureTempOrder) === null || _this$store$order$ens === void 0 ? void 0 : _this$store$order$ens.call(_this$store$order8));
|
|
2519
2618
|
_context27.next = 7;
|
|
2520
2619
|
return this.store.order.removeProductFromOrder(identity);
|
|
2521
2620
|
case 7:
|
|
@@ -2526,23 +2625,23 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2526
2625
|
}
|
|
2527
2626
|
venueProductUids = new Set();
|
|
2528
2627
|
venueBookingUids = new Set();
|
|
2529
|
-
|
|
2628
|
+
_iterator16 = _createForOfIteratorHelper(tempOrder.products || []);
|
|
2530
2629
|
_context27.prev = 12;
|
|
2531
|
-
|
|
2630
|
+
_iterator16.s();
|
|
2532
2631
|
case 14:
|
|
2533
|
-
if ((
|
|
2632
|
+
if ((_step16 = _iterator16.n()).done) {
|
|
2534
2633
|
_context27.next = 22;
|
|
2535
2634
|
break;
|
|
2536
2635
|
}
|
|
2537
|
-
product =
|
|
2538
|
-
if (product !== null && product !== void 0 && (_product$
|
|
2636
|
+
product = _step16.value;
|
|
2637
|
+
if (product !== null && product !== void 0 && (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.venue_booking) {
|
|
2539
2638
|
_context27.next = 18;
|
|
2540
2639
|
break;
|
|
2541
2640
|
}
|
|
2542
2641
|
return _context27.abrupt("continue", 20);
|
|
2543
2642
|
case 18:
|
|
2544
2643
|
if (product.identity_key) venueProductUids.add(String(product.identity_key));
|
|
2545
|
-
if ((_product$
|
|
2644
|
+
if ((_product$metadata8 = product.metadata) !== null && _product$metadata8 !== void 0 && _product$metadata8.booking_uid) {
|
|
2546
2645
|
venueBookingUids.add(String(product.metadata.booking_uid));
|
|
2547
2646
|
}
|
|
2548
2647
|
case 20:
|
|
@@ -2554,10 +2653,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2554
2653
|
case 24:
|
|
2555
2654
|
_context27.prev = 24;
|
|
2556
2655
|
_context27.t0 = _context27["catch"](12);
|
|
2557
|
-
|
|
2656
|
+
_iterator16.e(_context27.t0);
|
|
2558
2657
|
case 27:
|
|
2559
2658
|
_context27.prev = 27;
|
|
2560
|
-
|
|
2659
|
+
_iterator16.f();
|
|
2561
2660
|
return _context27.finish(27);
|
|
2562
2661
|
case 30:
|
|
2563
2662
|
beforeBookingCount = ((_tempOrder$bookings2 = tempOrder.bookings) === null || _tempOrder$bookings2 === void 0 ? void 0 : _tempOrder$bookings2.length) || 0;
|
|
@@ -2572,7 +2671,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2572
2671
|
return true;
|
|
2573
2672
|
});
|
|
2574
2673
|
if ((((_tempOrder$bookings3 = tempOrder.bookings) === null || _tempOrder$bookings3 === void 0 ? void 0 : _tempOrder$bookings3.length) || 0) !== beforeBookingCount) {
|
|
2575
|
-
(_this$store$order$per = (_this$store$
|
|
2674
|
+
(_this$store$order$per = (_this$store$order9 = this.store.order).persistTempOrder) === null || _this$store$order$per === void 0 || _this$store$order$per.call(_this$store$order9);
|
|
2576
2675
|
}
|
|
2577
2676
|
case 33:
|
|
2578
2677
|
_context27.next = 35;
|
|
@@ -2805,17 +2904,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2805
2904
|
if (visited.has(value)) return;
|
|
2806
2905
|
visited.add(value);
|
|
2807
2906
|
if (Array.isArray(value)) {
|
|
2808
|
-
var
|
|
2809
|
-
|
|
2907
|
+
var _iterator17 = _createForOfIteratorHelper(value),
|
|
2908
|
+
_step17;
|
|
2810
2909
|
try {
|
|
2811
|
-
for (
|
|
2812
|
-
var item =
|
|
2910
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
2911
|
+
var item = _step17.value;
|
|
2813
2912
|
collectFromValue(item);
|
|
2814
2913
|
}
|
|
2815
2914
|
} catch (err) {
|
|
2816
|
-
|
|
2915
|
+
_iterator17.e(err);
|
|
2817
2916
|
} finally {
|
|
2818
|
-
|
|
2917
|
+
_iterator17.f();
|
|
2819
2918
|
}
|
|
2820
2919
|
return;
|
|
2821
2920
|
}
|
|
@@ -2863,7 +2962,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2863
2962
|
key: "ensureItemRuleConfigsLoaded",
|
|
2864
2963
|
value: function () {
|
|
2865
2964
|
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2866
|
-
var
|
|
2965
|
+
var _this10 = this;
|
|
2867
2966
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2868
2967
|
while (1) switch (_context34.prev = _context34.next) {
|
|
2869
2968
|
case 0:
|
|
@@ -2884,19 +2983,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2884
2983
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2885
2984
|
while (1) switch (_context33.prev = _context33.next) {
|
|
2886
2985
|
case 0:
|
|
2887
|
-
runtimeConfig =
|
|
2986
|
+
runtimeConfig = _this10.getItemRuleRuntimeConfig();
|
|
2888
2987
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
2889
2988
|
if (!(staticConfigs.length > 0)) {
|
|
2890
2989
|
_context33.next = 6;
|
|
2891
2990
|
break;
|
|
2892
2991
|
}
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
return _context33.abrupt("return",
|
|
2992
|
+
_this10.itemRuleConfigs = staticConfigs;
|
|
2993
|
+
_this10.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2994
|
+
return _context33.abrupt("return", _this10.itemRuleConfigs);
|
|
2896
2995
|
case 6:
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
return _context33.abrupt("return",
|
|
2996
|
+
_this10.itemRuleConfigs = [];
|
|
2997
|
+
_this10.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2998
|
+
return _context33.abrupt("return", _this10.itemRuleConfigs);
|
|
2900
2999
|
case 9:
|
|
2901
3000
|
case "end":
|
|
2902
3001
|
return _context33.stop();
|
|
@@ -2970,7 +3069,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2970
3069
|
key: "applyPrefillByItemRule",
|
|
2971
3070
|
value: function () {
|
|
2972
3071
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2973
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
3072
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator18, _step18, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct;
|
|
2974
3073
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2975
3074
|
while (1) switch (_context36.prev = _context36.next) {
|
|
2976
3075
|
case 0:
|
|
@@ -3015,15 +3114,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3015
3114
|
productSourceMap = _context36.sent;
|
|
3016
3115
|
tempOrder = this.ensureTempOrder();
|
|
3017
3116
|
hasChanges = false;
|
|
3018
|
-
|
|
3117
|
+
_iterator18 = _createForOfIteratorHelper(prefillItems);
|
|
3019
3118
|
_context36.prev = 20;
|
|
3020
|
-
|
|
3119
|
+
_iterator18.s();
|
|
3021
3120
|
case 22:
|
|
3022
|
-
if ((
|
|
3121
|
+
if ((_step18 = _iterator18.n()).done) {
|
|
3023
3122
|
_context36.next = 45;
|
|
3024
3123
|
break;
|
|
3025
3124
|
}
|
|
3026
|
-
prefillItem =
|
|
3125
|
+
prefillItem = _step18.value;
|
|
3027
3126
|
productId = Number(prefillItem.product_id);
|
|
3028
3127
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
3029
3128
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -3092,10 +3191,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3092
3191
|
case 47:
|
|
3093
3192
|
_context36.prev = 47;
|
|
3094
3193
|
_context36.t0 = _context36["catch"](20);
|
|
3095
|
-
|
|
3194
|
+
_iterator18.e(_context36.t0);
|
|
3096
3195
|
case 50:
|
|
3097
3196
|
_context36.prev = 50;
|
|
3098
|
-
|
|
3197
|
+
_iterator18.f();
|
|
3099
3198
|
return _context36.finish(50);
|
|
3100
3199
|
case 53:
|
|
3101
3200
|
if (!hasChanges) {
|
|
@@ -3357,7 +3456,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3357
3456
|
var raw = this.window.sessionStorage.getItem(key) || '{}';
|
|
3358
3457
|
var parsed = JSON.parse(raw);
|
|
3359
3458
|
return parsed && _typeof(parsed) === 'object' ? parsed : {};
|
|
3360
|
-
} catch (
|
|
3459
|
+
} catch (_unused4) {
|
|
3361
3460
|
return {};
|
|
3362
3461
|
}
|
|
3363
3462
|
}
|