@pisell/pisellos 0.0.500 → 0.0.502
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/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +52 -8
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +68 -1
- package/dist/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/dist/model/strategy/adapter/itemRule/index.js +1 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +10 -0
- package/dist/modules/Order/index.js +64 -40
- package/dist/modules/Order/types.d.ts +13 -1
- package/dist/modules/Order/utils.d.ts +36 -1
- package/dist/modules/Order/utils.js +120 -24
- package/dist/modules/ProductList/index.js +2 -2
- package/dist/modules/Quotation/index.js +6 -3
- package/dist/modules/SalesSummary/types.d.ts +2 -1
- package/dist/modules/SalesSummary/utils.js +10 -10
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +22 -0
- package/dist/solution/ScanOrder/index.js +863 -369
- package/dist/solution/ScanOrder/types.d.ts +31 -8
- package/dist/solution/ScanOrder/utils.d.ts +26 -0
- package/dist/solution/ScanOrder/utils.js +191 -44
- package/dist/solution/VenueBooking/index.d.ts +42 -5
- package/dist/solution/VenueBooking/index.js +692 -280
- package/dist/solution/VenueBooking/types.d.ts +23 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -1
- package/dist/solution/VenueBooking/utils/dateSummary.js +7 -5
- package/dist/solution/VenueBooking/utils/resource.d.ts +11 -1
- package/dist/solution/VenueBooking/utils/resource.js +57 -21
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +33 -12
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
- package/dist/solution/VenueBooking/utils/timeSlot.js +259 -62
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +41 -2
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +47 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/lib/model/strategy/adapter/itemRule/index.js +2 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/lib/modules/Order/index.d.ts +10 -0
- package/lib/modules/Order/index.js +40 -43
- package/lib/modules/Order/types.d.ts +13 -1
- package/lib/modules/Order/utils.d.ts +36 -1
- package/lib/modules/Order/utils.js +100 -21
- package/lib/modules/ProductList/index.js +3 -2
- package/lib/modules/Quotation/index.js +3 -0
- package/lib/modules/SalesSummary/types.d.ts +2 -1
- package/lib/modules/SalesSummary/utils.js +2 -2
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +22 -0
- package/lib/solution/ScanOrder/index.js +376 -21
- package/lib/solution/ScanOrder/types.d.ts +31 -8
- package/lib/solution/ScanOrder/utils.d.ts +26 -0
- package/lib/solution/ScanOrder/utils.js +128 -19
- package/lib/solution/VenueBooking/index.d.ts +42 -5
- package/lib/solution/VenueBooking/index.js +356 -84
- package/lib/solution/VenueBooking/types.d.ts +23 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -1
- package/lib/solution/VenueBooking/utils/dateSummary.js +14 -5
- package/lib/solution/VenueBooking/utils/resource.d.ts +11 -1
- package/lib/solution/VenueBooking/utils/resource.js +15 -4
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +5 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +29 -12
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +1 -1
- package/lib/solution/VenueBooking/utils/timeSlot.js +182 -43
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@ import { createModule } from "../BookingByStep/types";
|
|
|
35
35
|
import { ProductList } from "../../modules/ProductList";
|
|
36
36
|
import { DateModule } from "../../modules/Date";
|
|
37
37
|
import { ScheduleModule } from "../../modules/Schedule";
|
|
38
|
+
import { calcMinTimeMaxTimeBySchedules } from "../../modules/Schedule/utils";
|
|
38
39
|
import { QuotationModule } from "../../modules/Quotation";
|
|
39
40
|
import { OpenDataModule } from "../../modules/OpenData";
|
|
40
41
|
import { AccountHooks } from "../../modules/Account/types";
|
|
@@ -87,6 +88,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
87
88
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
88
89
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
89
90
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "baseSlotConfig", _objectSpread({}, DEFAULT_SLOT_CONFIG));
|
|
90
92
|
_defineProperty(_assertThisInitialized(_this), "itemRuleEvaluator", new ItemRuleEvaluator());
|
|
91
93
|
_defineProperty(_assertThisInitialized(_this), "itemRuleConfigs", []);
|
|
92
94
|
_defineProperty(_assertThisInitialized(_this), "itemRuleConfigsPromise", null);
|
|
@@ -445,6 +447,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
445
447
|
openDataModule,
|
|
446
448
|
_this$store$order,
|
|
447
449
|
_this$store$order2,
|
|
450
|
+
_this$store$quotation,
|
|
451
|
+
_this$otherParams6,
|
|
448
452
|
_args6 = arguments;
|
|
449
453
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
450
454
|
while (1) switch (_context6.prev = _context6.next) {
|
|
@@ -458,7 +462,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
458
462
|
this.store.status = 'initializing';
|
|
459
463
|
this.store.error = null;
|
|
460
464
|
this.store.rawResourceData = [];
|
|
461
|
-
this.
|
|
465
|
+
this.baseSlotConfig = _objectSpread(_objectSpread({}, DEFAULT_SLOT_CONFIG), ((_options$otherParams2 = options.otherParams) === null || _options$otherParams2 === void 0 ? void 0 : _options$otherParams2.slotConfig) || {});
|
|
466
|
+
this.store.slotConfig = _objectSpread({}, this.baseSlotConfig);
|
|
462
467
|
this.otherParams = options.otherParams || {};
|
|
463
468
|
this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
|
|
464
469
|
this.itemRuleRuntimeConfig = ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.venueBookingItemRule) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.itemRule) || {};
|
|
@@ -473,19 +478,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
473
478
|
this.window = core.getPlugin('window');
|
|
474
479
|
this.request = core.getPlugin('request');
|
|
475
480
|
if (this.window) {
|
|
476
|
-
_context6.next =
|
|
481
|
+
_context6.next = 24;
|
|
477
482
|
break;
|
|
478
483
|
}
|
|
479
484
|
this.logMethodError('initialize', 'window plugin missing');
|
|
480
485
|
throw new Error('venueBooking解决方案需要 window 插件支持');
|
|
481
|
-
case
|
|
486
|
+
case 24:
|
|
482
487
|
if (this.request) {
|
|
483
|
-
_context6.next =
|
|
488
|
+
_context6.next = 27;
|
|
484
489
|
break;
|
|
485
490
|
}
|
|
486
491
|
this.logMethodError('initialize', 'request plugin missing');
|
|
487
492
|
throw new Error('venueBooking解决方案需要 request 插件支持');
|
|
488
|
-
case
|
|
493
|
+
case 27:
|
|
489
494
|
// 注册基础模块(order, salesSummary, products, logger)
|
|
490
495
|
baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
491
496
|
baseModules.forEach(function (step) {
|
|
@@ -579,44 +584,46 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
579
584
|
}
|
|
580
585
|
this.registerCustomerLoginListeners();
|
|
581
586
|
console.log('[VenueBooking] 初始化开始');
|
|
582
|
-
_context6.prev =
|
|
583
|
-
_context6.next =
|
|
587
|
+
_context6.prev = 50;
|
|
588
|
+
_context6.next = 53;
|
|
584
589
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
585
590
|
createIfMissing: false
|
|
586
591
|
});
|
|
587
|
-
case
|
|
592
|
+
case 53:
|
|
588
593
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
589
|
-
_context6.next =
|
|
594
|
+
_context6.next = 56;
|
|
590
595
|
return this.loadRuntimeConfigs();
|
|
591
|
-
case
|
|
596
|
+
case 56:
|
|
592
597
|
if (!this.store.schedule) {
|
|
593
|
-
_context6.next =
|
|
598
|
+
_context6.next = 61;
|
|
594
599
|
break;
|
|
595
600
|
}
|
|
596
|
-
_context6.next =
|
|
601
|
+
_context6.next = 59;
|
|
597
602
|
return this.store.schedule.loadAllSchedule();
|
|
598
|
-
case 58:
|
|
599
|
-
this.injectScheduleResolverToQuotation();
|
|
600
603
|
case 59:
|
|
601
|
-
this.
|
|
602
|
-
|
|
604
|
+
this.injectScheduleResolverToQuotation();
|
|
605
|
+
(_this$store$quotation = this.store.quotation) === null || _this$store$quotation === void 0 || _this$store$quotation.loadQuotations({
|
|
606
|
+
channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel
|
|
607
|
+
});
|
|
608
|
+
case 61:
|
|
609
|
+
_context6.next = 63;
|
|
603
610
|
return this.refreshItemRuleQuantityLimits();
|
|
604
|
-
case
|
|
611
|
+
case 63:
|
|
605
612
|
this.store.status = 'ready';
|
|
606
613
|
console.log('[VenueBooking] 初始化完成');
|
|
607
|
-
_context6.next =
|
|
614
|
+
_context6.next = 67;
|
|
608
615
|
return this.core.effects.emit(VenueBookingHooks.onInited, {
|
|
609
616
|
status: this.store.status
|
|
610
617
|
});
|
|
611
|
-
case
|
|
618
|
+
case 67:
|
|
612
619
|
this.logMethodSuccess('initialize', {
|
|
613
620
|
status: this.store.status
|
|
614
621
|
});
|
|
615
|
-
_context6.next =
|
|
622
|
+
_context6.next = 77;
|
|
616
623
|
break;
|
|
617
|
-
case
|
|
618
|
-
_context6.prev =
|
|
619
|
-
_context6.t0 = _context6["catch"](
|
|
624
|
+
case 70:
|
|
625
|
+
_context6.prev = 70;
|
|
626
|
+
_context6.t0 = _context6["catch"](50);
|
|
620
627
|
this.store.status = 'error';
|
|
621
628
|
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
|
|
622
629
|
console.error('[VenueBooking] 初始化失败', _context6.t0);
|
|
@@ -624,11 +631,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
624
631
|
status: this.store.status
|
|
625
632
|
});
|
|
626
633
|
throw _context6.t0;
|
|
627
|
-
case
|
|
634
|
+
case 77:
|
|
628
635
|
case "end":
|
|
629
636
|
return _context6.stop();
|
|
630
637
|
}
|
|
631
|
-
}, _callee6, this, [[
|
|
638
|
+
}, _callee6, this, [[50, 70]]);
|
|
632
639
|
}));
|
|
633
640
|
function initialize(_x5) {
|
|
634
641
|
return _initialize.apply(this, arguments);
|
|
@@ -803,7 +810,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
803
810
|
key: "_doLoadAllProducts",
|
|
804
811
|
value: function () {
|
|
805
812
|
var _doLoadAllProducts2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
806
|
-
var _this$
|
|
813
|
+
var _this$otherParams7, _this$store$venueProd, associatedMenus, menuListIds, allProducts, list, venueList, addonList, venueStore;
|
|
807
814
|
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
808
815
|
while (1) switch (_context11.prev = _context11.next) {
|
|
809
816
|
case 0:
|
|
@@ -821,7 +828,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
821
828
|
}
|
|
822
829
|
throw new Error('addonProducts 模块未初始化');
|
|
823
830
|
case 6:
|
|
824
|
-
associatedMenus = ((_this$
|
|
831
|
+
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']) || [];
|
|
825
832
|
if (associatedMenus.length) {
|
|
826
833
|
_context11.next = 9;
|
|
827
834
|
break;
|
|
@@ -987,7 +994,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
987
994
|
key: "fetchResourceAvailability",
|
|
988
995
|
value: function () {
|
|
989
996
|
var _fetchResourceAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
990
|
-
var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i2, _rawData, _item, mapping;
|
|
997
|
+
var venueProducts, resourceIds, config, crossDay, effectiveEndDate, res, rawData, _iterator2, _step2, item, _i2, _rawData, _item, mappings, _iterator3, _step3, mapping;
|
|
991
998
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
992
999
|
while (1) switch (_context15.prev = _context15.next) {
|
|
993
1000
|
case 0:
|
|
@@ -1055,62 +1062,161 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1055
1062
|
}
|
|
1056
1063
|
}
|
|
1057
1064
|
this.store.rawResourceData = rawData;
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1065
|
+
_i2 = 0, _rawData = rawData;
|
|
1066
|
+
case 24:
|
|
1067
|
+
if (!(_i2 < _rawData.length)) {
|
|
1068
|
+
_context15.next = 34;
|
|
1069
|
+
break;
|
|
1070
|
+
}
|
|
1071
|
+
_item = _rawData[_i2];
|
|
1072
|
+
mappings = this.resourceProductMap.get(_item.resourceId);
|
|
1073
|
+
if (mappings) {
|
|
1074
|
+
_context15.next = 29;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
return _context15.abrupt("continue", 31);
|
|
1078
|
+
case 29:
|
|
1079
|
+
_iterator3 = _createForOfIteratorHelper(mappings);
|
|
1080
|
+
try {
|
|
1081
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1082
|
+
mapping = _step3.value;
|
|
1083
|
+
if (_item.main_field) mapping.resourceName = _item.main_field;
|
|
1084
|
+
if (_item.resource_form_id) mapping.formId = _item.resource_form_id;
|
|
1066
1085
|
}
|
|
1086
|
+
} catch (err) {
|
|
1087
|
+
_iterator3.e(err);
|
|
1088
|
+
} finally {
|
|
1089
|
+
_iterator3.f();
|
|
1067
1090
|
}
|
|
1091
|
+
case 31:
|
|
1092
|
+
_i2++;
|
|
1093
|
+
_context15.next = 24;
|
|
1094
|
+
break;
|
|
1095
|
+
case 34:
|
|
1068
1096
|
this.logMethodSuccess('fetchResourceAvailability', {
|
|
1069
1097
|
resourceCount: rawData.length,
|
|
1070
1098
|
totalTimes: rawData.reduce(function (sum, r) {
|
|
1071
1099
|
return sum + r.times.length;
|
|
1072
1100
|
}, 0)
|
|
1073
1101
|
});
|
|
1074
|
-
_context15.next =
|
|
1102
|
+
_context15.next = 42;
|
|
1075
1103
|
break;
|
|
1076
|
-
case
|
|
1077
|
-
_context15.prev =
|
|
1104
|
+
case 37:
|
|
1105
|
+
_context15.prev = 37;
|
|
1078
1106
|
_context15.t0 = _context15["catch"](1);
|
|
1079
1107
|
this.store.rawResourceData = [];
|
|
1080
1108
|
this.logMethodError('fetchResourceAvailability', _context15.t0);
|
|
1081
1109
|
throw _context15.t0;
|
|
1082
|
-
case
|
|
1110
|
+
case 42:
|
|
1083
1111
|
case "end":
|
|
1084
1112
|
return _context15.stop();
|
|
1085
1113
|
}
|
|
1086
|
-
}, _callee15, this, [[1,
|
|
1114
|
+
}, _callee15, this, [[1, 37]]);
|
|
1087
1115
|
}));
|
|
1088
1116
|
function fetchResourceAvailability(_x7) {
|
|
1089
1117
|
return _fetchResourceAvailability.apply(this, arguments);
|
|
1090
1118
|
}
|
|
1091
1119
|
return fetchResourceAvailability;
|
|
1092
1120
|
}() // ─── 日期概览 & 时间槽矩阵(纯计算,不发请求) ───
|
|
1121
|
+
}, {
|
|
1122
|
+
key: "getOperatingHoursScheduleIds",
|
|
1123
|
+
value: function getOperatingHoursScheduleIds() {
|
|
1124
|
+
var _this$store$openData, _this$store$openData$;
|
|
1125
|
+
var openData = this.otherParams.openData || ((_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 || (_this$store$openData$ = _this$store$openData.getOpenData) === null || _this$store$openData$ === void 0 ? void 0 : _this$store$openData$.call(_this$store$openData)) || null;
|
|
1126
|
+
var rawIds = openData === null || openData === void 0 ? void 0 : openData['availability.operating_hours'];
|
|
1127
|
+
if (!Array.isArray(rawIds)) return [];
|
|
1128
|
+
return _toConsumableArray(new Set(rawIds.map(function (id) {
|
|
1129
|
+
return Number(id);
|
|
1130
|
+
}).filter(function (id) {
|
|
1131
|
+
return Number.isFinite(id) && id > 0;
|
|
1132
|
+
}).map(function (id) {
|
|
1133
|
+
return Math.floor(id);
|
|
1134
|
+
})));
|
|
1135
|
+
}
|
|
1136
|
+
}, {
|
|
1137
|
+
key: "resolveSlotConfigForDate",
|
|
1138
|
+
value: function resolveSlotConfigForDate(date) {
|
|
1139
|
+
var nextSlotConfig = _objectSpread({}, this.baseSlotConfig);
|
|
1140
|
+
if (!date || !this.store.schedule) return nextSlotConfig;
|
|
1141
|
+
var operatingHoursScheduleIds = this.getOperatingHoursScheduleIds();
|
|
1142
|
+
if (!operatingHoursScheduleIds.length) return nextSlotConfig;
|
|
1143
|
+
var scheduleList = this.store.schedule.getScheduleListByIds(operatingHoursScheduleIds);
|
|
1144
|
+
if (!scheduleList.length) return nextSlotConfig;
|
|
1145
|
+
var timeRangeMap = calcMinTimeMaxTimeBySchedules(scheduleList, undefined, date);
|
|
1146
|
+
var earliestStart = null;
|
|
1147
|
+
var latestEnd = null;
|
|
1148
|
+
var _iterator4 = _createForOfIteratorHelper(scheduleList),
|
|
1149
|
+
_step4;
|
|
1150
|
+
try {
|
|
1151
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1152
|
+
var _timeRangeMap$schedul;
|
|
1153
|
+
var schedule = _step4.value;
|
|
1154
|
+
var dateRangeList = (timeRangeMap === null || timeRangeMap === void 0 || (_timeRangeMap$schedul = timeRangeMap[schedule.id]) === null || _timeRangeMap$schedul === void 0 ? void 0 : _timeRangeMap$schedul.dateRangeFormat) || [];
|
|
1155
|
+
var _iterator5 = _createForOfIteratorHelper(dateRangeList),
|
|
1156
|
+
_step5;
|
|
1157
|
+
try {
|
|
1158
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1159
|
+
var range = _step5.value;
|
|
1160
|
+
var start = dayjs(range === null || range === void 0 ? void 0 : range.start);
|
|
1161
|
+
var end = dayjs(range === null || range === void 0 ? void 0 : range.end);
|
|
1162
|
+
if (!start.isValid() || !end.isValid()) continue;
|
|
1163
|
+
if (!earliestStart || start.isBefore(earliestStart)) {
|
|
1164
|
+
earliestStart = start;
|
|
1165
|
+
}
|
|
1166
|
+
if (!latestEnd || end.isAfter(latestEnd)) {
|
|
1167
|
+
latestEnd = end;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
} catch (err) {
|
|
1171
|
+
_iterator5.e(err);
|
|
1172
|
+
} finally {
|
|
1173
|
+
_iterator5.f();
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
} catch (err) {
|
|
1177
|
+
_iterator4.e(err);
|
|
1178
|
+
} finally {
|
|
1179
|
+
_iterator4.f();
|
|
1180
|
+
}
|
|
1181
|
+
if (!earliestStart || !latestEnd) return nextSlotConfig;
|
|
1182
|
+
return _objectSpread(_objectSpread({}, nextSlotConfig), {}, {
|
|
1183
|
+
businessStartTime: earliestStart.format('HH:mm'),
|
|
1184
|
+
businessEndTime: latestEnd.format('HH:mm')
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
}, {
|
|
1188
|
+
key: "syncOperatingHoursToSlotConfig",
|
|
1189
|
+
value: function syncOperatingHoursToSlotConfig(date) {
|
|
1190
|
+
var resolvedSlotConfig = this.resolveSlotConfigForDate(date);
|
|
1191
|
+
this.store.slotConfig = resolvedSlotConfig;
|
|
1192
|
+
return resolvedSlotConfig;
|
|
1193
|
+
}
|
|
1093
1194
|
}, {
|
|
1094
1195
|
key: "getDateRangeSummary",
|
|
1095
1196
|
value: function getDateRangeSummary(params) {
|
|
1197
|
+
var _this6 = this;
|
|
1096
1198
|
return buildDateRangeSummary({
|
|
1097
1199
|
startDate: params.startDate,
|
|
1098
1200
|
endDate: params.endDate,
|
|
1099
|
-
config: this.
|
|
1201
|
+
config: this.baseSlotConfig,
|
|
1100
1202
|
rawResources: this.store.rawResourceData,
|
|
1101
1203
|
resourceProductMap: this.resourceProductMap,
|
|
1102
|
-
quotationModule: this.store.quotation
|
|
1204
|
+
quotationModule: this.store.quotation,
|
|
1205
|
+
resolveConfig: function resolveConfig(date) {
|
|
1206
|
+
return _this6.resolveSlotConfigForDate(date);
|
|
1207
|
+
}
|
|
1103
1208
|
});
|
|
1104
1209
|
}
|
|
1105
1210
|
}, {
|
|
1106
1211
|
key: "getTimeSlotGrid",
|
|
1107
1212
|
value: function getTimeSlotGrid(date) {
|
|
1213
|
+
var resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
1108
1214
|
var quotationPriceMap;
|
|
1109
1215
|
if (this.store.quotation) {
|
|
1110
|
-
var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).map(function (m) {
|
|
1216
|
+
var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).flat().map(function (m) {
|
|
1111
1217
|
return m.productId;
|
|
1112
1218
|
})));
|
|
1113
|
-
var timeLabels = generateTimeLabels(
|
|
1219
|
+
var timeLabels = generateTimeLabels(resolvedSlotConfig);
|
|
1114
1220
|
var timePoints = timeLabels.map(function (label) {
|
|
1115
1221
|
return "".concat(date, " ").concat(label);
|
|
1116
1222
|
});
|
|
@@ -1121,7 +1227,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1121
1227
|
}
|
|
1122
1228
|
return buildTimeSlotGrid({
|
|
1123
1229
|
date: date,
|
|
1124
|
-
config:
|
|
1230
|
+
config: resolvedSlotConfig,
|
|
1125
1231
|
rawResources: this.store.rawResourceData,
|
|
1126
1232
|
resourceProductMap: this.resourceProductMap,
|
|
1127
1233
|
quotationPriceMap: quotationPriceMap
|
|
@@ -1133,34 +1239,47 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1133
1239
|
/**
|
|
1134
1240
|
* 切换单个时段的选中状态(选中/取消)。
|
|
1135
1241
|
* 内部自动处理连续时段的合并与拆分,订单是唯一真相源。
|
|
1242
|
+
*
|
|
1243
|
+
* slot.productId 指定当前操作针对的是该 resourceId 下的哪一个商品。
|
|
1244
|
+
* 同一资源下不同 productId 之间互相隔离,不会相互合并。
|
|
1136
1245
|
*/
|
|
1137
1246
|
}, {
|
|
1138
1247
|
key: "toggleSlot",
|
|
1139
1248
|
value: function () {
|
|
1140
1249
|
var _toggleSlot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(slot) {
|
|
1141
|
-
var mapping, currentSlots, existIndex, nextSlots, products;
|
|
1250
|
+
var mappings, mapping, currentSlots, existIndex, nextSlots, products;
|
|
1142
1251
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1143
1252
|
while (1) switch (_context16.prev = _context16.next) {
|
|
1144
1253
|
case 0:
|
|
1145
1254
|
this.logMethodStart('toggleSlot', {
|
|
1146
1255
|
resourceId: slot.resourceId,
|
|
1256
|
+
productId: slot.productId,
|
|
1147
1257
|
startTime: slot.startTime
|
|
1148
1258
|
});
|
|
1149
1259
|
_context16.prev = 1;
|
|
1150
|
-
|
|
1151
|
-
if (
|
|
1260
|
+
mappings = this.resourceProductMap.get(slot.resourceId);
|
|
1261
|
+
if (!(!mappings || !mappings.length)) {
|
|
1152
1262
|
_context16.next = 5;
|
|
1153
1263
|
break;
|
|
1154
1264
|
}
|
|
1155
1265
|
throw new Error("\u672A\u627E\u5230\u8D44\u6E90 ".concat(slot.resourceId, " \u7684\u5546\u54C1\u6620\u5C04"));
|
|
1156
1266
|
case 5:
|
|
1267
|
+
mapping = mappings.find(function (m) {
|
|
1268
|
+
return m.productId === slot.productId;
|
|
1269
|
+
});
|
|
1270
|
+
if (mapping) {
|
|
1271
|
+
_context16.next = 8;
|
|
1272
|
+
break;
|
|
1273
|
+
}
|
|
1274
|
+
throw new Error("\u8D44\u6E90 ".concat(slot.resourceId, " \u672A\u5173\u8054\u5546\u54C1 ").concat(slot.productId));
|
|
1275
|
+
case 8:
|
|
1157
1276
|
if (this.store.order) {
|
|
1158
|
-
_context16.next =
|
|
1277
|
+
_context16.next = 10;
|
|
1159
1278
|
break;
|
|
1160
1279
|
}
|
|
1161
1280
|
throw new Error('order 模块未初始化');
|
|
1162
|
-
case
|
|
1163
|
-
currentSlots = this.
|
|
1281
|
+
case 10:
|
|
1282
|
+
currentSlots = this.getSelectedSlotsForResourceProduct(slot.resourceId, slot.productId);
|
|
1164
1283
|
existIndex = currentSlots.findIndex(function (s) {
|
|
1165
1284
|
return s.startTime === slot.startTime;
|
|
1166
1285
|
});
|
|
@@ -1171,32 +1290,33 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1171
1290
|
} else {
|
|
1172
1291
|
nextSlots = [].concat(_toConsumableArray(currentSlots), [slot]);
|
|
1173
1292
|
}
|
|
1174
|
-
_context16.next = 12;
|
|
1175
|
-
return this.reconcileOrderForResource(slot.resourceId, nextSlots);
|
|
1176
|
-
case 12:
|
|
1177
|
-
products = this.store.order.getOrderProducts();
|
|
1178
1293
|
_context16.next = 15;
|
|
1179
|
-
return this.
|
|
1294
|
+
return this.reconcileOrderForResourceProduct(slot.resourceId, slot.productId, nextSlots);
|
|
1180
1295
|
case 15:
|
|
1181
|
-
|
|
1296
|
+
products = this.store.order.getOrderProducts();
|
|
1297
|
+
_context16.next = 18;
|
|
1298
|
+
return this.refreshItemRuleQuantityLimits();
|
|
1299
|
+
case 18:
|
|
1300
|
+
_context16.next = 20;
|
|
1182
1301
|
return this.refreshCartValidationPassed();
|
|
1183
|
-
case
|
|
1302
|
+
case 20:
|
|
1184
1303
|
this.logMethodSuccess('toggleSlot', {
|
|
1185
1304
|
action: existIndex !== -1 ? 'remove' : 'add',
|
|
1186
1305
|
resourceId: slot.resourceId,
|
|
1306
|
+
productId: slot.productId,
|
|
1187
1307
|
slotCount: nextSlots.length
|
|
1188
1308
|
});
|
|
1189
1309
|
return _context16.abrupt("return", products);
|
|
1190
|
-
case
|
|
1191
|
-
_context16.prev =
|
|
1310
|
+
case 24:
|
|
1311
|
+
_context16.prev = 24;
|
|
1192
1312
|
_context16.t0 = _context16["catch"](1);
|
|
1193
1313
|
this.logMethodError('toggleSlot', _context16.t0);
|
|
1194
1314
|
throw _context16.t0;
|
|
1195
|
-
case
|
|
1315
|
+
case 28:
|
|
1196
1316
|
case "end":
|
|
1197
1317
|
return _context16.stop();
|
|
1198
1318
|
}
|
|
1199
|
-
}, _callee16, this, [[1,
|
|
1319
|
+
}, _callee16, this, [[1, 24]]);
|
|
1200
1320
|
}));
|
|
1201
1321
|
function toggleSlot(_x8) {
|
|
1202
1322
|
return _toggleSlot.apply(this, arguments);
|
|
@@ -1205,49 +1325,169 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1205
1325
|
}()
|
|
1206
1326
|
/**
|
|
1207
1327
|
* 获取某资源当前选中的所有独立时段(从订单中解析)。
|
|
1328
|
+
* 不传 productId 时返回该资源下所有商品的选中时段;传了则精确匹配。
|
|
1208
1329
|
*/
|
|
1209
1330
|
}, {
|
|
1210
1331
|
key: "getSelectedSlotsForResource",
|
|
1211
|
-
value: function getSelectedSlotsForResource(resourceId) {
|
|
1332
|
+
value: function getSelectedSlotsForResource(resourceId, productId) {
|
|
1212
1333
|
var _this$store$order3;
|
|
1213
1334
|
var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
|
|
1214
1335
|
if (!tempOrder) return [];
|
|
1215
1336
|
var venueProducts = tempOrder.products.filter(function (p) {
|
|
1216
1337
|
var _p$metadata, _p$metadata2;
|
|
1217
|
-
|
|
1338
|
+
if (!((_p$metadata = p.metadata) !== null && _p$metadata !== void 0 && _p$metadata.venue_booking)) return false;
|
|
1339
|
+
if (String((_p$metadata2 = p.metadata) === null || _p$metadata2 === void 0 ? void 0 : _p$metadata2.resource_id) !== String(resourceId)) return false;
|
|
1340
|
+
if (productId != null && Number(p.product_id) !== Number(productId)) return false;
|
|
1341
|
+
return true;
|
|
1218
1342
|
});
|
|
1219
1343
|
var slotDuration = this.store.slotConfig.slotDurationMinutes;
|
|
1220
1344
|
var slots = [];
|
|
1221
|
-
var
|
|
1222
|
-
|
|
1345
|
+
var _iterator6 = _createForOfIteratorHelper(venueProducts),
|
|
1346
|
+
_step6;
|
|
1223
1347
|
try {
|
|
1224
|
-
|
|
1225
|
-
var product =
|
|
1226
|
-
slots.push.apply(slots, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration))
|
|
1348
|
+
var _loop = function _loop() {
|
|
1349
|
+
var product = _step6.value;
|
|
1350
|
+
slots.push.apply(slots, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration).map(function (s) {
|
|
1351
|
+
return _objectSpread(_objectSpread({}, s), {}, {
|
|
1352
|
+
productId: Number(product.product_id)
|
|
1353
|
+
});
|
|
1354
|
+
})));
|
|
1355
|
+
};
|
|
1356
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1357
|
+
_loop();
|
|
1227
1358
|
}
|
|
1228
1359
|
} catch (err) {
|
|
1229
|
-
|
|
1360
|
+
_iterator6.e(err);
|
|
1230
1361
|
} finally {
|
|
1231
|
-
|
|
1362
|
+
_iterator6.f();
|
|
1232
1363
|
}
|
|
1233
1364
|
return slots.sort(function (a, b) {
|
|
1234
1365
|
return a.startTime.localeCompare(b.startTime);
|
|
1235
1366
|
});
|
|
1236
1367
|
}
|
|
1237
1368
|
|
|
1369
|
+
/** getSelectedSlotsForResource 的 (resourceId, productId) 精确版,内部使用。 */
|
|
1370
|
+
}, {
|
|
1371
|
+
key: "getSelectedSlotsForResourceProduct",
|
|
1372
|
+
value: function getSelectedSlotsForResourceProduct(resourceId, productId) {
|
|
1373
|
+
return this.getSelectedSlotsForResource(resourceId, productId);
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1238
1376
|
/**
|
|
1239
1377
|
* 判断某个时段是否已选中。
|
|
1378
|
+
* 不传 productId 时:只要该资源下任一商品在 startTime 被选中即返回 true;传了则精确匹配。
|
|
1240
1379
|
*/
|
|
1241
1380
|
}, {
|
|
1242
1381
|
key: "isSlotSelected",
|
|
1243
|
-
value: function isSlotSelected(resourceId, startTime) {
|
|
1244
|
-
return this.getSelectedSlotsForResource(resourceId).some(function (s) {
|
|
1382
|
+
value: function isSlotSelected(resourceId, startTime, productId) {
|
|
1383
|
+
return this.getSelectedSlotsForResource(resourceId, productId).some(function (s) {
|
|
1245
1384
|
return s.startTime === startTime;
|
|
1246
1385
|
});
|
|
1247
1386
|
}
|
|
1248
1387
|
|
|
1249
1388
|
/**
|
|
1250
|
-
*
|
|
1389
|
+
* 判断指定 (resourceId, productId, startTime) 格子是否应因其它已选项而被禁用。
|
|
1390
|
+
* 规则:
|
|
1391
|
+
* 1) 同一 resourceId 下若已选了另一个 productId 的同 startTime → 禁用
|
|
1392
|
+
* 2) 当前 resource 是组合资源:若其任一 child resource 在 startTime 被选中 → 禁用
|
|
1393
|
+
* 3) 当前 resource 是某些组合资源的 child:若该组合资源在 startTime 被选中 → 禁用
|
|
1394
|
+
* 4) 两个组合资源的 child 集合有交集,且对方在该 startTime 被选中 → 禁用
|
|
1395
|
+
*/
|
|
1396
|
+
}, {
|
|
1397
|
+
key: "isSlotDisabledBySelection",
|
|
1398
|
+
value: function isSlotDisabledBySelection(params) {
|
|
1399
|
+
var _this7 = this;
|
|
1400
|
+
var resourceId = params.resourceId,
|
|
1401
|
+
productId = params.productId,
|
|
1402
|
+
startTime = params.startTime;
|
|
1403
|
+
var allSelected = this.getAllSelectedSlots();
|
|
1404
|
+
var getSelectedAt = function getSelectedAt(resId) {
|
|
1405
|
+
var list = allSelected.get(resId) || [];
|
|
1406
|
+
return list.filter(function (s) {
|
|
1407
|
+
return s.startTime === startTime;
|
|
1408
|
+
});
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
// 规则 1:同场地、不同 productId 的已选
|
|
1412
|
+
var sameResourceSelections = getSelectedAt(resourceId);
|
|
1413
|
+
if (sameResourceSelections.some(function (s) {
|
|
1414
|
+
return Number(s.productId) !== Number(productId);
|
|
1415
|
+
})) {
|
|
1416
|
+
return true;
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
// 组合资源字段缓存
|
|
1420
|
+
var getCombinedChildIds = function getCombinedChildIds(resId) {
|
|
1421
|
+
var raw = _this7.store.rawResourceData.find(function (r) {
|
|
1422
|
+
return String(r.resourceId) === String(resId);
|
|
1423
|
+
});
|
|
1424
|
+
var combined = raw === null || raw === void 0 ? void 0 : raw.combined_resource;
|
|
1425
|
+
if (combined && combined.status === 1 && Array.isArray(combined.resource_ids)) {
|
|
1426
|
+
return combined.resource_ids;
|
|
1427
|
+
}
|
|
1428
|
+
return [];
|
|
1429
|
+
};
|
|
1430
|
+
var currentChildIds = getCombinedChildIds(resourceId);
|
|
1431
|
+
var currentIsCombined = currentChildIds.length > 0;
|
|
1432
|
+
|
|
1433
|
+
// 规则 2:当前是组合资源,任一子资源被选 → 禁用
|
|
1434
|
+
if (currentIsCombined) {
|
|
1435
|
+
var _iterator7 = _createForOfIteratorHelper(currentChildIds),
|
|
1436
|
+
_step7;
|
|
1437
|
+
try {
|
|
1438
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1439
|
+
var childId = _step7.value;
|
|
1440
|
+
if (getSelectedAt(childId).length > 0) return true;
|
|
1441
|
+
}
|
|
1442
|
+
} catch (err) {
|
|
1443
|
+
_iterator7.e(err);
|
|
1444
|
+
} finally {
|
|
1445
|
+
_iterator7.f();
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
// 规则 3 & 4:扫描所有已选的 (resId),若是组合资源,检查其 children 是否包含当前 resourceId 或与当前 child 集合有交集
|
|
1450
|
+
var _iterator8 = _createForOfIteratorHelper(allSelected),
|
|
1451
|
+
_step8;
|
|
1452
|
+
try {
|
|
1453
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1454
|
+
var _step8$value = _slicedToArray(_step8.value, 2),
|
|
1455
|
+
selectedResId = _step8$value[0],
|
|
1456
|
+
slots = _step8$value[1];
|
|
1457
|
+
if (!slots.some(function (s) {
|
|
1458
|
+
return s.startTime === startTime;
|
|
1459
|
+
})) continue;
|
|
1460
|
+
if (String(selectedResId) === String(resourceId)) continue;
|
|
1461
|
+
var selectedChildIds = getCombinedChildIds(selectedResId);
|
|
1462
|
+
if (selectedChildIds.length === 0) continue;
|
|
1463
|
+
|
|
1464
|
+
// 对方是组合资源,其 children 包含当前 resourceId(规则 3)
|
|
1465
|
+
if (selectedChildIds.some(function (id) {
|
|
1466
|
+
return String(id) === String(resourceId);
|
|
1467
|
+
})) {
|
|
1468
|
+
return true;
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// 双方都是组合资源,child 集合有交集(规则 4)
|
|
1472
|
+
if (currentIsCombined) {
|
|
1473
|
+
var intersect = selectedChildIds.some(function (id) {
|
|
1474
|
+
return currentChildIds.some(function (cid) {
|
|
1475
|
+
return String(cid) === String(id);
|
|
1476
|
+
});
|
|
1477
|
+
});
|
|
1478
|
+
if (intersect) return true;
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
} catch (err) {
|
|
1482
|
+
_iterator8.e(err);
|
|
1483
|
+
} finally {
|
|
1484
|
+
_iterator8.f();
|
|
1485
|
+
}
|
|
1486
|
+
return false;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* 获取所有已选时段(按资源分组)。每个 slot 上带 productId,便于 UI 做 per-product 判定。
|
|
1251
1491
|
*/
|
|
1252
1492
|
}, {
|
|
1253
1493
|
key: "getAllSelectedSlots",
|
|
@@ -1261,87 +1501,112 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1261
1501
|
return (_p$metadata3 = p.metadata) === null || _p$metadata3 === void 0 ? void 0 : _p$metadata3.venue_booking;
|
|
1262
1502
|
});
|
|
1263
1503
|
var slotDuration = this.store.slotConfig.slotDurationMinutes;
|
|
1264
|
-
var
|
|
1265
|
-
|
|
1504
|
+
var _iterator9 = _createForOfIteratorHelper(venueProducts),
|
|
1505
|
+
_step9;
|
|
1266
1506
|
try {
|
|
1267
|
-
|
|
1507
|
+
var _loop2 = function _loop2() {
|
|
1268
1508
|
var _product$metadata;
|
|
1269
|
-
var product =
|
|
1509
|
+
var product = _step9.value;
|
|
1270
1510
|
var resourceId = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.resource_id;
|
|
1271
|
-
if (resourceId == null) continue
|
|
1511
|
+
if (resourceId == null) return 1; // continue
|
|
1512
|
+
var productId = Number(product.product_id);
|
|
1272
1513
|
var existing = result.get(resourceId) || [];
|
|
1273
|
-
existing.push.apply(existing, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration))
|
|
1514
|
+
existing.push.apply(existing, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration).map(function (s) {
|
|
1515
|
+
return _objectSpread(_objectSpread({}, s), {}, {
|
|
1516
|
+
productId: productId
|
|
1517
|
+
});
|
|
1518
|
+
})));
|
|
1274
1519
|
result.set(resourceId, existing);
|
|
1520
|
+
};
|
|
1521
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1522
|
+
if (_loop2()) continue;
|
|
1275
1523
|
}
|
|
1276
1524
|
} catch (err) {
|
|
1277
|
-
|
|
1525
|
+
_iterator9.e(err);
|
|
1278
1526
|
} finally {
|
|
1279
|
-
|
|
1527
|
+
_iterator9.f();
|
|
1280
1528
|
}
|
|
1281
|
-
var
|
|
1282
|
-
|
|
1529
|
+
var _iterator10 = _createForOfIteratorHelper(result),
|
|
1530
|
+
_step10;
|
|
1283
1531
|
try {
|
|
1284
|
-
for (
|
|
1285
|
-
var
|
|
1286
|
-
key =
|
|
1287
|
-
slots =
|
|
1532
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
1533
|
+
var _step10$value = _slicedToArray(_step10.value, 2),
|
|
1534
|
+
key = _step10$value[0],
|
|
1535
|
+
slots = _step10$value[1];
|
|
1288
1536
|
result.set(key, slots.sort(function (a, b) {
|
|
1289
1537
|
return a.startTime.localeCompare(b.startTime);
|
|
1290
1538
|
}));
|
|
1291
1539
|
}
|
|
1292
1540
|
} catch (err) {
|
|
1293
|
-
|
|
1541
|
+
_iterator10.e(err);
|
|
1294
1542
|
} finally {
|
|
1295
|
-
|
|
1543
|
+
_iterator10.f();
|
|
1296
1544
|
}
|
|
1297
1545
|
return result;
|
|
1298
1546
|
}
|
|
1299
1547
|
|
|
1300
1548
|
/**
|
|
1301
|
-
*
|
|
1549
|
+
* 对指定 (resourceId, productId) 的订单商品进行 reconcile:
|
|
1302
1550
|
* 清除旧商品 → 合并连续时段 → 重新写入。
|
|
1551
|
+
* 同一场地下不同商品互不干扰,各自单独 reconcile。
|
|
1303
1552
|
*/
|
|
1304
1553
|
}, {
|
|
1305
|
-
key: "
|
|
1554
|
+
key: "reconcileOrderForResourceProduct",
|
|
1306
1555
|
value: (function () {
|
|
1307
|
-
var
|
|
1308
|
-
var mapping, tempOrder, merged, rawResource, venueProduct, i,
|
|
1556
|
+
var _reconcileOrderForResourceProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(resourceId, productId, slots) {
|
|
1557
|
+
var mappings, mapping, tempOrder, matchesCurrent, merged, rawResource, childRawResources, venueProduct, i, _rawResource$form_id, _venueProduct$is_char, group, identityKey, bookingUuid, startMoment, endMoment, duration, customDepositData, resourceEntry, booking;
|
|
1309
1558
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1310
1559
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1311
1560
|
case 0:
|
|
1312
|
-
|
|
1313
|
-
if (!(!
|
|
1561
|
+
mappings = this.resourceProductMap.get(resourceId);
|
|
1562
|
+
if (!(!mappings || !mappings.length || !this.store.order)) {
|
|
1314
1563
|
_context17.next = 3;
|
|
1315
1564
|
break;
|
|
1316
1565
|
}
|
|
1317
1566
|
return _context17.abrupt("return");
|
|
1318
1567
|
case 3:
|
|
1568
|
+
mapping = mappings.find(function (m) {
|
|
1569
|
+
return m.productId === productId;
|
|
1570
|
+
});
|
|
1571
|
+
if (mapping) {
|
|
1572
|
+
_context17.next = 6;
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1575
|
+
return _context17.abrupt("return");
|
|
1576
|
+
case 6:
|
|
1319
1577
|
tempOrder = this.store.order.ensureTempOrder();
|
|
1578
|
+
matchesCurrent = function matchesCurrent(meta, pid) {
|
|
1579
|
+
return !!(meta !== null && meta !== void 0 && meta.venue_booking) && String(meta === null || meta === void 0 ? void 0 : meta.resource_id) === String(resourceId) && Number(pid) === Number(productId);
|
|
1580
|
+
};
|
|
1320
1581
|
tempOrder.products = tempOrder.products.filter(function (p) {
|
|
1321
|
-
|
|
1322
|
-
return !((_p$metadata4 = p.metadata) !== null && _p$metadata4 !== void 0 && _p$metadata4.venue_booking && String((_p$metadata5 = p.metadata) === null || _p$metadata5 === void 0 ? void 0 : _p$metadata5.resource_id) === String(resourceId));
|
|
1582
|
+
return !matchesCurrent(p.metadata, p.product_id);
|
|
1323
1583
|
});
|
|
1324
1584
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (b) {
|
|
1325
|
-
var _b$metadata, _b$metadata2;
|
|
1326
|
-
|
|
1585
|
+
var _b$metadata, _b$metadata2, _b$metadata$product_i, _b$metadata3, _b$product;
|
|
1586
|
+
if (!((_b$metadata = b.metadata) !== null && _b$metadata !== void 0 && _b$metadata.venue_booking)) return true;
|
|
1587
|
+
if (String((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.resource_id) !== String(resourceId)) return true;
|
|
1588
|
+
var bookingProductId = (_b$metadata$product_i = (_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.product_id) !== null && _b$metadata$product_i !== void 0 ? _b$metadata$product_i : b === null || b === void 0 || (_b$product = b.product) === null || _b$product === void 0 ? void 0 : _b$product.product_id;
|
|
1589
|
+
if (bookingProductId == null) return false;
|
|
1590
|
+
return Number(bookingProductId) !== Number(productId);
|
|
1327
1591
|
});
|
|
1328
1592
|
if (slots.length) {
|
|
1329
|
-
_context17.next =
|
|
1593
|
+
_context17.next = 16;
|
|
1330
1594
|
break;
|
|
1331
1595
|
}
|
|
1332
1596
|
this.store.order.applyDiscount();
|
|
1333
|
-
_context17.next =
|
|
1597
|
+
_context17.next = 14;
|
|
1334
1598
|
return this.store.order.recalculateSummary({
|
|
1335
1599
|
createIfMissing: true
|
|
1336
1600
|
});
|
|
1337
|
-
case
|
|
1601
|
+
case 14:
|
|
1338
1602
|
this.store.order.persistTempOrder();
|
|
1339
1603
|
return _context17.abrupt("return");
|
|
1340
|
-
case
|
|
1604
|
+
case 16:
|
|
1341
1605
|
merged = mergeConsecutiveSlots(slots);
|
|
1342
1606
|
rawResource = this.store.rawResourceData.find(function (r) {
|
|
1343
1607
|
return String(r.resourceId) === String(resourceId);
|
|
1344
1608
|
});
|
|
1609
|
+
childRawResources = this.getCombinedChildRawResources(rawResource);
|
|
1345
1610
|
venueProduct = this.getVenueProducts().find(function (p) {
|
|
1346
1611
|
return p.id === mapping.productId;
|
|
1347
1612
|
});
|
|
@@ -1354,6 +1619,31 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1354
1619
|
endMoment = dayjs(group.endTime, 'YYYY-MM-DD HH:mm');
|
|
1355
1620
|
duration = endMoment.diff(startMoment, 'minute');
|
|
1356
1621
|
customDepositData = cloneCustomDepositData(venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.custom_deposit_data);
|
|
1622
|
+
resourceEntry = {
|
|
1623
|
+
relation_type: 'form',
|
|
1624
|
+
like_status: 'common',
|
|
1625
|
+
id: resourceId,
|
|
1626
|
+
main_field: mapping.resourceName,
|
|
1627
|
+
form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
|
|
1628
|
+
relation_id: resourceId,
|
|
1629
|
+
capacity: 1,
|
|
1630
|
+
metadata: {}
|
|
1631
|
+
};
|
|
1632
|
+
if (childRawResources && childRawResources.length) {
|
|
1633
|
+
resourceEntry.children = childRawResources.map(function (child) {
|
|
1634
|
+
var _child$form_id, _child$capacity;
|
|
1635
|
+
return {
|
|
1636
|
+
relation_type: 'form',
|
|
1637
|
+
like_status: 'common',
|
|
1638
|
+
id: child.resourceId,
|
|
1639
|
+
main_field: child.main_field || '',
|
|
1640
|
+
form_id: (_child$form_id = child.form_id) !== null && _child$form_id !== void 0 ? _child$form_id : child.formId,
|
|
1641
|
+
relation_id: child.resourceId,
|
|
1642
|
+
capacity: (_child$capacity = child.capacity) !== null && _child$capacity !== void 0 ? _child$capacity : 1,
|
|
1643
|
+
metadata: {}
|
|
1644
|
+
};
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1357
1647
|
tempOrder.products.push(normalizeOrderProduct({
|
|
1358
1648
|
product_id: mapping.productId,
|
|
1359
1649
|
product_variant_id: 0,
|
|
@@ -1361,7 +1651,6 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1361
1651
|
num: 1,
|
|
1362
1652
|
selling_price: group.totalPrice,
|
|
1363
1653
|
original_price: group.totalPrice,
|
|
1364
|
-
payment_price: group.totalPrice,
|
|
1365
1654
|
is_charge_tax: (_venueProduct$is_char = venueProduct === null || venueProduct === void 0 ? void 0 : venueProduct.is_charge_tax) !== null && _venueProduct$is_char !== void 0 ? _venueProduct$is_char : 0,
|
|
1366
1655
|
metadata: {
|
|
1367
1656
|
venue_booking: true,
|
|
@@ -1400,16 +1689,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1400
1689
|
sub_type: 'minutes',
|
|
1401
1690
|
duration: duration,
|
|
1402
1691
|
like_status: 'common',
|
|
1403
|
-
resources: [
|
|
1404
|
-
relation_type: 'form',
|
|
1405
|
-
like_status: 'common',
|
|
1406
|
-
id: resourceId,
|
|
1407
|
-
main_field: mapping.resourceName,
|
|
1408
|
-
form_id: (_rawResource$form_id = rawResource === null || rawResource === void 0 ? void 0 : rawResource.form_id) !== null && _rawResource$form_id !== void 0 ? _rawResource$form_id : mapping.formId,
|
|
1409
|
-
relation_id: resourceId,
|
|
1410
|
-
capacity: 1,
|
|
1411
|
-
metadata: {}
|
|
1412
|
-
}],
|
|
1692
|
+
resources: [resourceEntry],
|
|
1413
1693
|
schedule_id: 0,
|
|
1414
1694
|
select_date: startMoment.format('YYYY-MM-DD'),
|
|
1415
1695
|
start_date: startMoment.format('YYYY-MM-DD'),
|
|
@@ -1429,33 +1709,66 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1429
1709
|
mapping: mapping,
|
|
1430
1710
|
rawResource: rawResource,
|
|
1431
1711
|
bookingUuid: bookingUuid,
|
|
1432
|
-
productUid: identityKey
|
|
1712
|
+
productUid: identityKey,
|
|
1713
|
+
childResources: childRawResources
|
|
1433
1714
|
});
|
|
1434
1715
|
tempOrder.bookings.push(booking);
|
|
1435
1716
|
}
|
|
1436
1717
|
this.store.order.applyDiscount();
|
|
1437
|
-
_context17.next =
|
|
1718
|
+
_context17.next = 25;
|
|
1438
1719
|
return this.store.order.recalculateSummary({
|
|
1439
1720
|
createIfMissing: true
|
|
1440
1721
|
});
|
|
1441
|
-
case
|
|
1722
|
+
case 25:
|
|
1442
1723
|
this.store.order.persistTempOrder();
|
|
1443
|
-
case
|
|
1724
|
+
case 26:
|
|
1444
1725
|
case "end":
|
|
1445
1726
|
return _context17.stop();
|
|
1446
1727
|
}
|
|
1447
1728
|
}, _callee17, this);
|
|
1448
1729
|
}));
|
|
1449
|
-
function
|
|
1450
|
-
return
|
|
1730
|
+
function reconcileOrderForResourceProduct(_x9, _x10, _x11) {
|
|
1731
|
+
return _reconcileOrderForResourceProduct.apply(this, arguments);
|
|
1732
|
+
}
|
|
1733
|
+
return reconcileOrderForResourceProduct;
|
|
1734
|
+
}() /** 给定一个父 rawResource,返回其 combined_resource.resource_ids 对应的子 rawResource 列表。 */)
|
|
1735
|
+
}, {
|
|
1736
|
+
key: "getCombinedChildRawResources",
|
|
1737
|
+
value: function getCombinedChildRawResources(rawResource) {
|
|
1738
|
+
var _this8 = this;
|
|
1739
|
+
if (!rawResource) return undefined;
|
|
1740
|
+
var combined = rawResource.combined_resource;
|
|
1741
|
+
if (!combined || combined.status !== 1 || !Array.isArray(combined.resource_ids) || !combined.resource_ids.length) {
|
|
1742
|
+
return undefined;
|
|
1451
1743
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1744
|
+
var children = [];
|
|
1745
|
+
var _iterator11 = _createForOfIteratorHelper(combined.resource_ids),
|
|
1746
|
+
_step11;
|
|
1747
|
+
try {
|
|
1748
|
+
var _loop3 = function _loop3() {
|
|
1749
|
+
var id = _step11.value;
|
|
1750
|
+
var child = _this8.store.rawResourceData.find(function (r) {
|
|
1751
|
+
return String(r.resourceId) === String(id);
|
|
1752
|
+
});
|
|
1753
|
+
if (child) children.push(child);
|
|
1754
|
+
};
|
|
1755
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
1756
|
+
_loop3();
|
|
1757
|
+
}
|
|
1758
|
+
} catch (err) {
|
|
1759
|
+
_iterator11.e(err);
|
|
1760
|
+
} finally {
|
|
1761
|
+
_iterator11.f();
|
|
1762
|
+
}
|
|
1763
|
+
return children.length ? children : undefined;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
// ─── 配置 ───
|
|
1455
1767
|
}, {
|
|
1456
1768
|
key: "setSlotConfig",
|
|
1457
1769
|
value: function setSlotConfig(config) {
|
|
1458
|
-
this.
|
|
1770
|
+
this.baseSlotConfig = _objectSpread(_objectSpread({}, this.baseSlotConfig), config);
|
|
1771
|
+
this.store.slotConfig = _objectSpread({}, this.baseSlotConfig);
|
|
1459
1772
|
}
|
|
1460
1773
|
}, {
|
|
1461
1774
|
key: "getSlotConfig",
|
|
@@ -1505,10 +1818,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1505
1818
|
}, {
|
|
1506
1819
|
key: "injectScheduleResolverToQuotation",
|
|
1507
1820
|
value: function injectScheduleResolverToQuotation() {
|
|
1508
|
-
var
|
|
1821
|
+
var _this9 = this;
|
|
1509
1822
|
if (this.store.quotation && this.store.schedule) {
|
|
1510
1823
|
this.store.quotation.setScheduleResolver(function (id) {
|
|
1511
|
-
return
|
|
1824
|
+
return _this9.store.schedule.getScheduleListByIds([id])[0];
|
|
1512
1825
|
});
|
|
1513
1826
|
}
|
|
1514
1827
|
}
|
|
@@ -1577,7 +1890,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1577
1890
|
}
|
|
1578
1891
|
}, _callee19, this, [[1, 7]]);
|
|
1579
1892
|
}));
|
|
1580
|
-
function onCustomerLogin(
|
|
1893
|
+
function onCustomerLogin(_x12) {
|
|
1581
1894
|
return _onCustomerLogin.apply(this, arguments);
|
|
1582
1895
|
}
|
|
1583
1896
|
return onCustomerLogin;
|
|
@@ -1586,60 +1899,67 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1586
1899
|
key: "recalculateOrderPricesFromQuotation",
|
|
1587
1900
|
value: function recalculateOrderPricesFromQuotation() {
|
|
1588
1901
|
var _tempOrder$products,
|
|
1589
|
-
|
|
1902
|
+
_this10 = this;
|
|
1590
1903
|
if (!this.store.order || !this.store.quotation) return;
|
|
1591
1904
|
var tempOrder = this.store.order.getTempOrder();
|
|
1592
1905
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
|
|
1593
1906
|
var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1594
|
-
var
|
|
1595
|
-
|
|
1907
|
+
var _iterator12 = _createForOfIteratorHelper(tempOrder.products),
|
|
1908
|
+
_step12;
|
|
1596
1909
|
try {
|
|
1597
|
-
var
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1910
|
+
var _loop4 = function _loop4() {
|
|
1911
|
+
var _product$metadata2;
|
|
1912
|
+
var product = _step12.value;
|
|
1913
|
+
if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
|
|
1914
|
+
var mappings = _this10.resourceProductMap.get(product.metadata.resource_id);
|
|
1915
|
+
if (!mappings || !mappings.length) return 0; // continue
|
|
1916
|
+
var mapping = mappings.find(function (m) {
|
|
1917
|
+
return Number(m.productId) === Number(product.product_id);
|
|
1918
|
+
}) || mappings[0];
|
|
1919
|
+
if (!mapping) return 0; // continue
|
|
1920
|
+
var slots = expandMergedSlotToIndividual(product, _this10.store.slotConfig.slotDurationMinutes);
|
|
1921
|
+
var updatedSlots = slots.map(function (slot) {
|
|
1922
|
+
var _getPriceForProduct;
|
|
1923
|
+
return _objectSpread(_objectSpread({}, slot), {}, {
|
|
1608
1924
|
productId: mapping.productId,
|
|
1609
|
-
|
|
1610
|
-
|
|
1925
|
+
price: (_getPriceForProduct = _this10.store.quotation.getPriceForProduct({
|
|
1926
|
+
productId: mapping.productId,
|
|
1927
|
+
datetime: slot.startTime
|
|
1928
|
+
})) !== null && _getPriceForProduct !== void 0 ? _getPriceForProduct : mapping.price
|
|
1929
|
+
});
|
|
1611
1930
|
});
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1931
|
+
var merged = mergeConsecutiveSlots(updatedSlots);
|
|
1932
|
+
if (merged.length === 1) {
|
|
1933
|
+
product.selling_price = merged[0].totalPrice;
|
|
1934
|
+
product.original_price = merged[0].totalPrice;
|
|
1935
|
+
product.metadata.price_breakdown = buildPriceBreakdown({
|
|
1936
|
+
group: merged[0],
|
|
1937
|
+
productId: mapping.productId,
|
|
1938
|
+
quotation: _this10.store.quotation
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
} else if (product.product_id != null) {
|
|
1942
|
+
var _product$product_vari;
|
|
1943
|
+
var quotationPrice = _this10.store.quotation.getPriceForProduct({
|
|
1944
|
+
productId: product.product_id,
|
|
1945
|
+
variantId: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : undefined,
|
|
1946
|
+
datetime: now
|
|
1621
1947
|
});
|
|
1948
|
+
if (quotationPrice !== null) {
|
|
1949
|
+
product.selling_price = quotationPrice;
|
|
1950
|
+
product.original_price = quotationPrice;
|
|
1951
|
+
}
|
|
1622
1952
|
}
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
datetime: now
|
|
1629
|
-
});
|
|
1630
|
-
if (quotationPrice !== null) {
|
|
1631
|
-
product.selling_price = quotationPrice;
|
|
1632
|
-
product.payment_price = quotationPrice;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
};
|
|
1636
|
-
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1637
|
-
if (_loop()) continue;
|
|
1953
|
+
},
|
|
1954
|
+
_ret;
|
|
1955
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
1956
|
+
_ret = _loop4();
|
|
1957
|
+
if (_ret === 0) continue;
|
|
1638
1958
|
}
|
|
1639
1959
|
} catch (err) {
|
|
1640
|
-
|
|
1960
|
+
_iterator12.e(err);
|
|
1641
1961
|
} finally {
|
|
1642
|
-
|
|
1962
|
+
_iterator12.f();
|
|
1643
1963
|
}
|
|
1644
1964
|
}
|
|
1645
1965
|
}, {
|
|
@@ -1690,7 +2010,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1690
2010
|
}
|
|
1691
2011
|
}, _callee20, this, [[1, 15]]);
|
|
1692
2012
|
}));
|
|
1693
|
-
function scanCode(
|
|
2013
|
+
function scanCode(_x13, _x14) {
|
|
1694
2014
|
return _scanCode.apply(this, arguments);
|
|
1695
2015
|
}
|
|
1696
2016
|
return scanCode;
|
|
@@ -1707,7 +2027,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1707
2027
|
key: "setDiscountSelected",
|
|
1708
2028
|
value: (function () {
|
|
1709
2029
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
1710
|
-
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,
|
|
2030
|
+
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, totalPerUnitDiscount, newSellingPrice, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
1711
2031
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1712
2032
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1713
2033
|
case 0:
|
|
@@ -1767,18 +2087,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1767
2087
|
}).map(function (d) {
|
|
1768
2088
|
return d.id;
|
|
1769
2089
|
}));
|
|
1770
|
-
|
|
2090
|
+
_iterator13 = _createForOfIteratorHelper(nextDiscountList);
|
|
1771
2091
|
try {
|
|
1772
|
-
for (
|
|
1773
|
-
d =
|
|
2092
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2093
|
+
d = _step13.value;
|
|
1774
2094
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1775
2095
|
d.isSelected = false;
|
|
1776
2096
|
}
|
|
1777
2097
|
}
|
|
1778
2098
|
} catch (err) {
|
|
1779
|
-
|
|
2099
|
+
_iterator13.e(err);
|
|
1780
2100
|
} finally {
|
|
1781
|
-
|
|
2101
|
+
_iterator13.f();
|
|
1782
2102
|
}
|
|
1783
2103
|
}
|
|
1784
2104
|
}
|
|
@@ -1787,69 +2107,71 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1787
2107
|
return d.isSelected;
|
|
1788
2108
|
}).map(function (d) {
|
|
1789
2109
|
return d.id;
|
|
1790
|
-
}));
|
|
1791
|
-
|
|
2110
|
+
})); // 无条件归一化:不论 Rules 是否清空 discount_list、长度是否变化,
|
|
2111
|
+
// 都以 original_price - Σ (当前选中 discount_list.amount) 重算 selling_price。
|
|
2112
|
+
// 目的:避免 unselect 后 selling_price 残留、reselect 时把残留价带进下一轮 Rules 造成双折扣。
|
|
2113
|
+
// 手动改价商品(_origin.isManualDiscount=true)不参与券流程归一化,保留手工价。
|
|
2114
|
+
_iterator14 = _createForOfIteratorHelper(tempOrder.products);
|
|
1792
2115
|
_context21.prev = 19;
|
|
1793
|
-
|
|
2116
|
+
_iterator14.s();
|
|
1794
2117
|
case 21:
|
|
1795
|
-
if ((
|
|
1796
|
-
_context21.next =
|
|
2118
|
+
if ((_step14 = _iterator14.n()).done) {
|
|
2119
|
+
_context21.next = 32;
|
|
1797
2120
|
break;
|
|
1798
2121
|
}
|
|
1799
|
-
product =
|
|
1800
|
-
if ((_product$
|
|
2122
|
+
product = _step14.value;
|
|
2123
|
+
if (!((_product$_origin = product._origin) !== null && _product$_origin !== void 0 && _product$_origin.isManualDiscount)) {
|
|
1801
2124
|
_context21.next = 25;
|
|
1802
2125
|
break;
|
|
1803
2126
|
}
|
|
1804
|
-
return _context21.abrupt("continue",
|
|
2127
|
+
return _context21.abrupt("continue", 30);
|
|
1805
2128
|
case 25:
|
|
1806
|
-
|
|
1807
|
-
product.discount_list = product.discount_list.filter(function (pd) {
|
|
2129
|
+
// 1. 把 product.discount_list 和当前选中的 discount 对齐(剔除已取消的券)
|
|
2130
|
+
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1808
2131
|
var _pd$discount$resource, _pd$discount;
|
|
1809
2132
|
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;
|
|
1810
2133
|
return rid != null && selectedResourceIds.has(rid);
|
|
1811
2134
|
});
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
}
|
|
2135
|
+
|
|
2136
|
+
// 2. 以 original_price 为基准重算 selling_price
|
|
2137
|
+
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
2138
|
+
return sum + (pd.amount || 0);
|
|
2139
|
+
}, 0);
|
|
2140
|
+
newSellingPrice = new Decimal(product.original_price || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
2141
|
+
product.selling_price = newSellingPrice;
|
|
2142
|
+
if (product.metadata) {
|
|
2143
|
+
product.metadata.main_product_selling_price = newSellingPrice;
|
|
1822
2144
|
}
|
|
1823
|
-
case 28:
|
|
1824
|
-
_context21.next = 21;
|
|
1825
|
-
break;
|
|
1826
2145
|
case 30:
|
|
1827
|
-
_context21.next =
|
|
2146
|
+
_context21.next = 21;
|
|
1828
2147
|
break;
|
|
1829
2148
|
case 32:
|
|
1830
|
-
_context21.
|
|
2149
|
+
_context21.next = 37;
|
|
2150
|
+
break;
|
|
2151
|
+
case 34:
|
|
2152
|
+
_context21.prev = 34;
|
|
1831
2153
|
_context21.t0 = _context21["catch"](19);
|
|
1832
|
-
|
|
1833
|
-
case
|
|
1834
|
-
_context21.prev =
|
|
1835
|
-
|
|
1836
|
-
return _context21.finish(
|
|
1837
|
-
case
|
|
2154
|
+
_iterator14.e(_context21.t0);
|
|
2155
|
+
case 37:
|
|
2156
|
+
_context21.prev = 37;
|
|
2157
|
+
_iterator14.f();
|
|
2158
|
+
return _context21.finish(37);
|
|
2159
|
+
case 40:
|
|
1838
2160
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1839
|
-
_context21.next =
|
|
2161
|
+
_context21.next = 43;
|
|
1840
2162
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1841
|
-
case
|
|
2163
|
+
case 43:
|
|
1842
2164
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1843
2165
|
return d.isSelected;
|
|
1844
2166
|
});
|
|
1845
2167
|
afterApplyTarget = this.store.order.getDiscountList().find(function (d) {
|
|
1846
2168
|
return d.id === params.discountId;
|
|
1847
2169
|
}) || null;
|
|
1848
|
-
_context21.next =
|
|
2170
|
+
_context21.next = 47;
|
|
1849
2171
|
return this.store.order.recalculateSummary({
|
|
1850
2172
|
createIfMissing: true
|
|
1851
2173
|
});
|
|
1852
|
-
case
|
|
2174
|
+
case 47:
|
|
1853
2175
|
this.store.order.persistTempOrder();
|
|
1854
2176
|
finalSummary = ((_this$store$order$get = this.store.order.getTempOrder()) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.summary) || null;
|
|
1855
2177
|
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;
|
|
@@ -1858,18 +2180,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1858
2180
|
return d.id === params.discountId;
|
|
1859
2181
|
}) || null;
|
|
1860
2182
|
return _context21.abrupt("return", this.store.order.getDiscountList());
|
|
1861
|
-
case
|
|
1862
|
-
_context21.prev =
|
|
2183
|
+
case 55:
|
|
2184
|
+
_context21.prev = 55;
|
|
1863
2185
|
_context21.t1 = _context21["catch"](1);
|
|
1864
2186
|
this.logMethodError('setDiscountSelected', _context21.t1);
|
|
1865
2187
|
throw _context21.t1;
|
|
1866
|
-
case
|
|
2188
|
+
case 59:
|
|
1867
2189
|
case "end":
|
|
1868
2190
|
return _context21.stop();
|
|
1869
2191
|
}
|
|
1870
|
-
}, _callee21, this, [[1,
|
|
2192
|
+
}, _callee21, this, [[1, 55], [19, 34, 37, 40]]);
|
|
1871
2193
|
}));
|
|
1872
|
-
function setDiscountSelected(
|
|
2194
|
+
function setDiscountSelected(_x15) {
|
|
1873
2195
|
return _setDiscountSelected.apply(this, arguments);
|
|
1874
2196
|
}
|
|
1875
2197
|
return setDiscountSelected;
|
|
@@ -1964,7 +2286,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1964
2286
|
key: "submitOrder",
|
|
1965
2287
|
value: function () {
|
|
1966
2288
|
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1967
|
-
var _tempOrder$products2, result, tempOrder;
|
|
2289
|
+
var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _tempOrder$products2, result, tempOrder;
|
|
1968
2290
|
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1969
2291
|
while (1) switch (_context24.prev = _context24.next) {
|
|
1970
2292
|
case 0:
|
|
@@ -1981,7 +2303,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1981
2303
|
case 6:
|
|
1982
2304
|
_context24.next = 8;
|
|
1983
2305
|
return this.store.order.submitTempOrder({
|
|
1984
|
-
cacheId: this.cacheId
|
|
2306
|
+
cacheId: this.cacheId,
|
|
2307
|
+
platform: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform,
|
|
2308
|
+
businessCode: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode,
|
|
2309
|
+
channel: (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.channel,
|
|
2310
|
+
type: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.type
|
|
1985
2311
|
});
|
|
1986
2312
|
case 8:
|
|
1987
2313
|
result = _context24.sent;
|
|
@@ -2033,10 +2359,9 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2033
2359
|
});
|
|
2034
2360
|
if (quotationPrice !== null) {
|
|
2035
2361
|
product.selling_price = quotationPrice;
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
product.payment_price = quotationPrice;
|
|
2362
|
+
product.original_price = quotationPrice;
|
|
2363
|
+
} else if (product.selling_price != null) {
|
|
2364
|
+
product.original_price = product.selling_price;
|
|
2040
2365
|
}
|
|
2041
2366
|
}
|
|
2042
2367
|
_context25.next = 7;
|
|
@@ -2064,7 +2389,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2064
2389
|
}
|
|
2065
2390
|
}, _callee25, this, [[1, 16]]);
|
|
2066
2391
|
}));
|
|
2067
|
-
function addProductToOrder(
|
|
2392
|
+
function addProductToOrder(_x16) {
|
|
2068
2393
|
return _addProductToOrder.apply(this, arguments);
|
|
2069
2394
|
}
|
|
2070
2395
|
return addProductToOrder;
|
|
@@ -2113,7 +2438,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2113
2438
|
}
|
|
2114
2439
|
}, _callee26, this, [[1, 15]]);
|
|
2115
2440
|
}));
|
|
2116
|
-
function updateProductInOrder(
|
|
2441
|
+
function updateProductInOrder(_x17) {
|
|
2117
2442
|
return _updateProductInOrder.apply(this, arguments);
|
|
2118
2443
|
}
|
|
2119
2444
|
return updateProductInOrder;
|
|
@@ -2162,7 +2487,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2162
2487
|
}
|
|
2163
2488
|
}, _callee27, this, [[1, 15]]);
|
|
2164
2489
|
}));
|
|
2165
|
-
function removeProductFromOrder(
|
|
2490
|
+
function removeProductFromOrder(_x18) {
|
|
2166
2491
|
return _removeProductFromOrder.apply(this, arguments);
|
|
2167
2492
|
}
|
|
2168
2493
|
return removeProductFromOrder;
|
|
@@ -2201,7 +2526,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2201
2526
|
key: "loadOpenDataConfig",
|
|
2202
2527
|
value: function () {
|
|
2203
2528
|
var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2204
|
-
var
|
|
2529
|
+
var _this11 = this;
|
|
2205
2530
|
var lastFetchedAt, cachedData;
|
|
2206
2531
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2207
2532
|
while (1) switch (_context29.prev = _context29.next) {
|
|
@@ -2232,10 +2557,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2232
2557
|
target: 'venue_booking+online_store',
|
|
2233
2558
|
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
2234
2559
|
}).then(function (openDataConfig) {
|
|
2235
|
-
|
|
2560
|
+
_this11.otherParams.openData = openDataConfig;
|
|
2236
2561
|
return openDataConfig;
|
|
2237
2562
|
}).finally(function () {
|
|
2238
|
-
|
|
2563
|
+
_this11.loadOpenDataConfigInFlight = null;
|
|
2239
2564
|
});
|
|
2240
2565
|
return _context29.abrupt("return", this.loadOpenDataConfigInFlight);
|
|
2241
2566
|
case 11:
|
|
@@ -2332,7 +2657,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2332
2657
|
}
|
|
2333
2658
|
}, _callee31, this, [[3, 13]]);
|
|
2334
2659
|
}));
|
|
2335
|
-
function fetchItemRuleConfigsByModelIds(
|
|
2660
|
+
function fetchItemRuleConfigsByModelIds(_x19) {
|
|
2336
2661
|
return _fetchItemRuleConfigsByModelIds.apply(this, arguments);
|
|
2337
2662
|
}
|
|
2338
2663
|
return fetchItemRuleConfigsByModelIds;
|
|
@@ -2364,17 +2689,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2364
2689
|
if (visited.has(value)) return;
|
|
2365
2690
|
visited.add(value);
|
|
2366
2691
|
if (Array.isArray(value)) {
|
|
2367
|
-
var
|
|
2368
|
-
|
|
2692
|
+
var _iterator15 = _createForOfIteratorHelper(value),
|
|
2693
|
+
_step15;
|
|
2369
2694
|
try {
|
|
2370
|
-
for (
|
|
2371
|
-
var item =
|
|
2695
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
2696
|
+
var item = _step15.value;
|
|
2372
2697
|
collectFromValue(item);
|
|
2373
2698
|
}
|
|
2374
2699
|
} catch (err) {
|
|
2375
|
-
|
|
2700
|
+
_iterator15.e(err);
|
|
2376
2701
|
} finally {
|
|
2377
|
-
|
|
2702
|
+
_iterator15.f();
|
|
2378
2703
|
}
|
|
2379
2704
|
return;
|
|
2380
2705
|
}
|
|
@@ -2422,7 +2747,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2422
2747
|
key: "ensureItemRuleConfigsLoaded",
|
|
2423
2748
|
value: function () {
|
|
2424
2749
|
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2425
|
-
var
|
|
2750
|
+
var _this12 = this;
|
|
2426
2751
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2427
2752
|
while (1) switch (_context34.prev = _context34.next) {
|
|
2428
2753
|
case 0:
|
|
@@ -2443,19 +2768,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2443
2768
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2444
2769
|
while (1) switch (_context33.prev = _context33.next) {
|
|
2445
2770
|
case 0:
|
|
2446
|
-
runtimeConfig =
|
|
2771
|
+
runtimeConfig = _this12.getItemRuleRuntimeConfig();
|
|
2447
2772
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
2448
2773
|
if (!(staticConfigs.length > 0)) {
|
|
2449
2774
|
_context33.next = 6;
|
|
2450
2775
|
break;
|
|
2451
2776
|
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
return _context33.abrupt("return",
|
|
2777
|
+
_this12.itemRuleConfigs = staticConfigs;
|
|
2778
|
+
_this12.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2779
|
+
return _context33.abrupt("return", _this12.itemRuleConfigs);
|
|
2455
2780
|
case 6:
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
return _context33.abrupt("return",
|
|
2781
|
+
_this12.itemRuleConfigs = [];
|
|
2782
|
+
_this12.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2783
|
+
return _context33.abrupt("return", _this12.itemRuleConfigs);
|
|
2459
2784
|
case 9:
|
|
2460
2785
|
case "end":
|
|
2461
2786
|
return _context33.stop();
|
|
@@ -2529,7 +2854,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2529
2854
|
key: "applyPrefillByItemRule",
|
|
2530
2855
|
value: function () {
|
|
2531
2856
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2532
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
2857
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator16, _step16, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, sellingPrice, targetProduct, existedQuantity, delta, nextProduct;
|
|
2533
2858
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2534
2859
|
while (1) switch (_context36.prev = _context36.next) {
|
|
2535
2860
|
case 0:
|
|
@@ -2574,15 +2899,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2574
2899
|
productSourceMap = _context36.sent;
|
|
2575
2900
|
tempOrder = this.ensureTempOrder();
|
|
2576
2901
|
hasChanges = false;
|
|
2577
|
-
|
|
2902
|
+
_iterator16 = _createForOfIteratorHelper(prefillItems);
|
|
2578
2903
|
_context36.prev = 20;
|
|
2579
|
-
|
|
2904
|
+
_iterator16.s();
|
|
2580
2905
|
case 22:
|
|
2581
|
-
if ((
|
|
2582
|
-
_context36.next =
|
|
2906
|
+
if ((_step16 = _iterator16.n()).done) {
|
|
2907
|
+
_context36.next = 45;
|
|
2583
2908
|
break;
|
|
2584
2909
|
}
|
|
2585
|
-
prefillItem =
|
|
2910
|
+
prefillItem = _step16.value;
|
|
2586
2911
|
productId = Number(prefillItem.product_id);
|
|
2587
2912
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2588
2913
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -2590,13 +2915,13 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2590
2915
|
_context36.next = 29;
|
|
2591
2916
|
break;
|
|
2592
2917
|
}
|
|
2593
|
-
return _context36.abrupt("continue",
|
|
2918
|
+
return _context36.abrupt("continue", 43);
|
|
2594
2919
|
case 29:
|
|
2595
2920
|
if (!Number.isNaN(productVariantId)) {
|
|
2596
2921
|
_context36.next = 31;
|
|
2597
2922
|
break;
|
|
2598
2923
|
}
|
|
2599
|
-
return _context36.abrupt("continue",
|
|
2924
|
+
return _context36.abrupt("continue", 43);
|
|
2600
2925
|
case 31:
|
|
2601
2926
|
sourceItem = productSourceMap.get(buildProductKey(productId, productVariantId)) || productSourceMap.get(buildProductKey(productId, 0)) || null;
|
|
2602
2927
|
productIndex = getProductIdentityIndex(tempOrder.products, {
|
|
@@ -2604,19 +2929,16 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2604
2929
|
product_variant_id: productVariantId
|
|
2605
2930
|
});
|
|
2606
2931
|
if (!(productIndex === -1)) {
|
|
2607
|
-
_context36.next =
|
|
2932
|
+
_context36.next = 38;
|
|
2608
2933
|
break;
|
|
2609
2934
|
}
|
|
2610
2935
|
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');
|
|
2611
|
-
originalPrice = toPriceString((_ref5 = (_sourceItem$original_ = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.original_price) !== null && _sourceItem$original_ !== void 0 ? _sourceItem$original_ : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref5 !== void 0 ? _ref5 : sellingPrice, sellingPrice);
|
|
2612
|
-
paymentPrice = toPriceString((_ref6 = (_sourceItem$payment_p = sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.payment_price) !== null && _sourceItem$payment_p !== void 0 ? _sourceItem$payment_p : sourceItem === null || sourceItem === void 0 ? void 0 : sourceItem.price) !== null && _ref6 !== void 0 ? _ref6 : sellingPrice, sellingPrice);
|
|
2613
2936
|
tempOrder.products.push(normalizeOrderProduct({
|
|
2614
2937
|
product_id: productId,
|
|
2615
2938
|
product_variant_id: productVariantId,
|
|
2616
2939
|
num: targetQuantity,
|
|
2617
2940
|
selling_price: sellingPrice,
|
|
2618
|
-
original_price:
|
|
2619
|
-
payment_price: paymentPrice,
|
|
2941
|
+
original_price: sellingPrice,
|
|
2620
2942
|
metadata: {
|
|
2621
2943
|
item_rule_prefill: true,
|
|
2622
2944
|
item_rule_id: prefillItem.ruleId
|
|
@@ -2627,8 +2949,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2627
2949
|
})
|
|
2628
2950
|
}));
|
|
2629
2951
|
hasChanges = true;
|
|
2630
|
-
return _context36.abrupt("continue",
|
|
2631
|
-
case
|
|
2952
|
+
return _context36.abrupt("continue", 43);
|
|
2953
|
+
case 38:
|
|
2632
2954
|
targetProduct = tempOrder.products[productIndex];
|
|
2633
2955
|
existedQuantity = toNonNegativeInt(targetProduct.num);
|
|
2634
2956
|
delta = targetQuantity - existedQuantity;
|
|
@@ -2645,45 +2967,47 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2645
2967
|
tempOrder.products[productIndex] = nextProduct;
|
|
2646
2968
|
hasChanges = true;
|
|
2647
2969
|
}
|
|
2648
|
-
case
|
|
2970
|
+
case 43:
|
|
2649
2971
|
_context36.next = 22;
|
|
2650
2972
|
break;
|
|
2651
|
-
case
|
|
2652
|
-
_context36.next =
|
|
2973
|
+
case 45:
|
|
2974
|
+
_context36.next = 50;
|
|
2653
2975
|
break;
|
|
2654
|
-
case
|
|
2655
|
-
_context36.prev =
|
|
2976
|
+
case 47:
|
|
2977
|
+
_context36.prev = 47;
|
|
2656
2978
|
_context36.t0 = _context36["catch"](20);
|
|
2657
|
-
|
|
2658
|
-
case
|
|
2659
|
-
_context36.prev =
|
|
2660
|
-
|
|
2661
|
-
return _context36.finish(
|
|
2662
|
-
case
|
|
2979
|
+
_iterator16.e(_context36.t0);
|
|
2980
|
+
case 50:
|
|
2981
|
+
_context36.prev = 50;
|
|
2982
|
+
_iterator16.f();
|
|
2983
|
+
return _context36.finish(50);
|
|
2984
|
+
case 53:
|
|
2663
2985
|
if (!hasChanges) {
|
|
2664
|
-
_context36.next =
|
|
2986
|
+
_context36.next = 58;
|
|
2665
2987
|
break;
|
|
2666
2988
|
}
|
|
2667
|
-
|
|
2989
|
+
// Prefill 属于 products CRUD 的一种形式:新增后让 Rules 重算,以支持自动应用可用优惠券。
|
|
2990
|
+
this.store.order.applyDiscount();
|
|
2991
|
+
_context36.next = 57;
|
|
2668
2992
|
return this.store.order.recalculateSummary({
|
|
2669
2993
|
createIfMissing: true
|
|
2670
2994
|
});
|
|
2671
|
-
case
|
|
2995
|
+
case 57:
|
|
2672
2996
|
this.store.order.persistTempOrder();
|
|
2673
|
-
case
|
|
2674
|
-
_context36.next =
|
|
2997
|
+
case 58:
|
|
2998
|
+
_context36.next = 60;
|
|
2675
2999
|
return this.refreshItemRuleQuantityLimits();
|
|
2676
|
-
case
|
|
3000
|
+
case 60:
|
|
2677
3001
|
this.itemRulePrefillApplied = true;
|
|
2678
3002
|
this.logMethodSuccess('applyPrefillByItemRule', {
|
|
2679
3003
|
prefillCount: prefillItems.length,
|
|
2680
3004
|
hasChanges: hasChanges
|
|
2681
3005
|
});
|
|
2682
|
-
case
|
|
3006
|
+
case 62:
|
|
2683
3007
|
case "end":
|
|
2684
3008
|
return _context36.stop();
|
|
2685
3009
|
}
|
|
2686
|
-
}, _callee36, this, [[20,
|
|
3010
|
+
}, _callee36, this, [[20, 47, 50, 53]]);
|
|
2687
3011
|
}));
|
|
2688
3012
|
function applyPrefillByItemRule() {
|
|
2689
3013
|
return _applyPrefillByItemRule.apply(this, arguments);
|
|
@@ -2896,6 +3220,65 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2896
3220
|
return this.otherParams;
|
|
2897
3221
|
}
|
|
2898
3222
|
|
|
3223
|
+
// ─── UI 状态缓存(按 cacheId 分桶,sessionStorage) ───
|
|
3224
|
+
//
|
|
3225
|
+
// 用于物料层持久化 UI 层面的轻量状态(如当前步骤、登录回跳意图等)。
|
|
3226
|
+
// 桶键:pisell.venueBooking.uiState:<cacheId>;内部以 JSON object 形式存储多个字段。
|
|
3227
|
+
// 无 cacheId 时所有方法自动降级为 no-op,上层不用判空。
|
|
3228
|
+
}, {
|
|
3229
|
+
key: "getUIStateBucketKey",
|
|
3230
|
+
value: function getUIStateBucketKey() {
|
|
3231
|
+
if (!this.cacheId) return null;
|
|
3232
|
+
return "".concat(VenueBookingImpl.UI_STATE_KEY_PREFIX).concat(this.cacheId);
|
|
3233
|
+
}
|
|
3234
|
+
}, {
|
|
3235
|
+
key: "readUIStateBucket",
|
|
3236
|
+
value: function readUIStateBucket() {
|
|
3237
|
+
var _this$window;
|
|
3238
|
+
var key = this.getUIStateBucketKey();
|
|
3239
|
+
if (!key || !((_this$window = this.window) !== null && _this$window !== void 0 && _this$window.sessionStorage)) return {};
|
|
3240
|
+
try {
|
|
3241
|
+
var raw = this.window.sessionStorage.getItem(key) || '{}';
|
|
3242
|
+
var parsed = JSON.parse(raw);
|
|
3243
|
+
return parsed && _typeof(parsed) === 'object' ? parsed : {};
|
|
3244
|
+
} catch (_unused2) {
|
|
3245
|
+
return {};
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
}, {
|
|
3249
|
+
key: "writeUIStateBucket",
|
|
3250
|
+
value: function writeUIStateBucket(bucket) {
|
|
3251
|
+
var _this$window2;
|
|
3252
|
+
var key = this.getUIStateBucketKey();
|
|
3253
|
+
if (!key || !((_this$window2 = this.window) !== null && _this$window2 !== void 0 && _this$window2.sessionStorage)) return;
|
|
3254
|
+
this.window.sessionStorage.setItem(key, JSON.stringify(bucket));
|
|
3255
|
+
}
|
|
3256
|
+
}, {
|
|
3257
|
+
key: "setUIState",
|
|
3258
|
+
value: function setUIState(key, value) {
|
|
3259
|
+
if (!this.getUIStateBucketKey()) return;
|
|
3260
|
+
var bucket = this.readUIStateBucket();
|
|
3261
|
+
bucket[key] = value;
|
|
3262
|
+
this.writeUIStateBucket(bucket);
|
|
3263
|
+
}
|
|
3264
|
+
}, {
|
|
3265
|
+
key: "getUIState",
|
|
3266
|
+
value: function getUIState(key) {
|
|
3267
|
+
if (!this.getUIStateBucketKey()) return undefined;
|
|
3268
|
+
var bucket = this.readUIStateBucket();
|
|
3269
|
+
return bucket[key];
|
|
3270
|
+
}
|
|
3271
|
+
}, {
|
|
3272
|
+
key: "deleteUIState",
|
|
3273
|
+
value: function deleteUIState(key) {
|
|
3274
|
+
if (!this.getUIStateBucketKey()) return;
|
|
3275
|
+
var bucket = this.readUIStateBucket();
|
|
3276
|
+
if (key in bucket) {
|
|
3277
|
+
delete bucket[key];
|
|
3278
|
+
this.writeUIStateBucket(bucket);
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
|
|
2899
3282
|
// ─── OpenData 可用性 ───
|
|
2900
3283
|
}, {
|
|
2901
3284
|
key: "checkOpenDataAvailability",
|
|
@@ -2925,7 +3308,36 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2925
3308
|
}
|
|
2926
3309
|
return checkOpenDataAvailability;
|
|
2927
3310
|
}()
|
|
3311
|
+
}, {
|
|
3312
|
+
key: "setOtherParams",
|
|
3313
|
+
value: function () {
|
|
3314
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
3315
|
+
var _ref5,
|
|
3316
|
+
_ref5$cover,
|
|
3317
|
+
cover,
|
|
3318
|
+
_args43 = arguments;
|
|
3319
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3320
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3321
|
+
case 0:
|
|
3322
|
+
_ref5 = _args43.length > 1 && _args43[1] !== undefined ? _args43[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
3323
|
+
if (cover) {
|
|
3324
|
+
this.otherParams = params;
|
|
3325
|
+
} else {
|
|
3326
|
+
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
3327
|
+
}
|
|
3328
|
+
case 2:
|
|
3329
|
+
case "end":
|
|
3330
|
+
return _context43.stop();
|
|
3331
|
+
}
|
|
3332
|
+
}, _callee43, this);
|
|
3333
|
+
}));
|
|
3334
|
+
function setOtherParams(_x20) {
|
|
3335
|
+
return _setOtherParams.apply(this, arguments);
|
|
3336
|
+
}
|
|
3337
|
+
return setOtherParams;
|
|
3338
|
+
}()
|
|
2928
3339
|
}]);
|
|
2929
3340
|
return VenueBookingImpl;
|
|
2930
3341
|
}(BaseModule);
|
|
2931
|
-
_defineProperty(VenueBookingImpl, "OPEN_DATA_CACHE_TTL", 5 * 60 * 1000);
|
|
3342
|
+
_defineProperty(VenueBookingImpl, "OPEN_DATA_CACHE_TTL", 5 * 60 * 1000);
|
|
3343
|
+
_defineProperty(VenueBookingImpl, "UI_STATE_KEY_PREFIX", 'pisell.venueBooking.uiState:');
|