@pisell/pisellos 2.1.125 → 2.1.126
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 +46 -6
- package/dist/model/strategy/adapter/itemRule/type.d.ts +11 -1
- package/dist/modules/Order/index.js +2 -2
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/ScanOrder/index.js +36 -12
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +5 -0
- package/dist/solution/VenueBooking/index.d.ts +4 -0
- package/dist/solution/VenueBooking/index.js +181 -99
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +6 -4
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +31 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +11 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.js +2 -2
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/ScanOrder/index.js +22 -3
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +5 -0
- package/lib/solution/VenueBooking/index.d.ts +4 -0
- package/lib/solution/VenueBooking/index.js +75 -9
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +13 -4
- 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);
|
|
@@ -460,7 +462,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
460
462
|
this.store.status = 'initializing';
|
|
461
463
|
this.store.error = null;
|
|
462
464
|
this.store.rawResourceData = [];
|
|
463
|
-
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);
|
|
464
467
|
this.otherParams = options.otherParams || {};
|
|
465
468
|
this.cacheId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.cacheId;
|
|
466
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) || {};
|
|
@@ -475,19 +478,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
475
478
|
this.window = core.getPlugin('window');
|
|
476
479
|
this.request = core.getPlugin('request');
|
|
477
480
|
if (this.window) {
|
|
478
|
-
_context6.next =
|
|
481
|
+
_context6.next = 24;
|
|
479
482
|
break;
|
|
480
483
|
}
|
|
481
484
|
this.logMethodError('initialize', 'window plugin missing');
|
|
482
485
|
throw new Error('venueBooking解决方案需要 window 插件支持');
|
|
483
|
-
case
|
|
486
|
+
case 24:
|
|
484
487
|
if (this.request) {
|
|
485
|
-
_context6.next =
|
|
488
|
+
_context6.next = 27;
|
|
486
489
|
break;
|
|
487
490
|
}
|
|
488
491
|
this.logMethodError('initialize', 'request plugin missing');
|
|
489
492
|
throw new Error('venueBooking解决方案需要 request 插件支持');
|
|
490
|
-
case
|
|
493
|
+
case 27:
|
|
491
494
|
// 注册基础模块(order, salesSummary, products, logger)
|
|
492
495
|
baseModules = ['scanOrderLogger', 'products', 'order', 'salesSummary'];
|
|
493
496
|
baseModules.forEach(function (step) {
|
|
@@ -581,46 +584,46 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
581
584
|
}
|
|
582
585
|
this.registerCustomerLoginListeners();
|
|
583
586
|
console.log('[VenueBooking] 初始化开始');
|
|
584
|
-
_context6.prev =
|
|
585
|
-
_context6.next =
|
|
587
|
+
_context6.prev = 50;
|
|
588
|
+
_context6.next = 53;
|
|
586
589
|
return (_this$store$order = this.store.order) === null || _this$store$order === void 0 ? void 0 : _this$store$order.recalculateSummary({
|
|
587
590
|
createIfMissing: false
|
|
588
591
|
});
|
|
589
|
-
case
|
|
592
|
+
case 53:
|
|
590
593
|
(_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || _this$store$order2.persistTempOrder();
|
|
591
|
-
_context6.next =
|
|
594
|
+
_context6.next = 56;
|
|
592
595
|
return this.loadRuntimeConfigs();
|
|
593
|
-
case
|
|
596
|
+
case 56:
|
|
594
597
|
if (!this.store.schedule) {
|
|
595
|
-
_context6.next =
|
|
598
|
+
_context6.next = 61;
|
|
596
599
|
break;
|
|
597
600
|
}
|
|
598
|
-
_context6.next =
|
|
601
|
+
_context6.next = 59;
|
|
599
602
|
return this.store.schedule.loadAllSchedule();
|
|
600
|
-
case
|
|
603
|
+
case 59:
|
|
601
604
|
this.injectScheduleResolverToQuotation();
|
|
602
605
|
(_this$store$quotation = this.store.quotation) === null || _this$store$quotation === void 0 || _this$store$quotation.loadQuotations({
|
|
603
606
|
channel: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel
|
|
604
607
|
});
|
|
605
|
-
case
|
|
606
|
-
_context6.next =
|
|
608
|
+
case 61:
|
|
609
|
+
_context6.next = 63;
|
|
607
610
|
return this.refreshItemRuleQuantityLimits();
|
|
608
|
-
case
|
|
611
|
+
case 63:
|
|
609
612
|
this.store.status = 'ready';
|
|
610
613
|
console.log('[VenueBooking] 初始化完成');
|
|
611
|
-
_context6.next =
|
|
614
|
+
_context6.next = 67;
|
|
612
615
|
return this.core.effects.emit(VenueBookingHooks.onInited, {
|
|
613
616
|
status: this.store.status
|
|
614
617
|
});
|
|
615
|
-
case
|
|
618
|
+
case 67:
|
|
616
619
|
this.logMethodSuccess('initialize', {
|
|
617
620
|
status: this.store.status
|
|
618
621
|
});
|
|
619
|
-
_context6.next =
|
|
622
|
+
_context6.next = 77;
|
|
620
623
|
break;
|
|
621
|
-
case
|
|
622
|
-
_context6.prev =
|
|
623
|
-
_context6.t0 = _context6["catch"](
|
|
624
|
+
case 70:
|
|
625
|
+
_context6.prev = 70;
|
|
626
|
+
_context6.t0 = _context6["catch"](50);
|
|
624
627
|
this.store.status = 'error';
|
|
625
628
|
this.store.error = _context6.t0 instanceof Error ? _context6.t0.message : '初始化失败';
|
|
626
629
|
console.error('[VenueBooking] 初始化失败', _context6.t0);
|
|
@@ -628,11 +631,11 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
628
631
|
status: this.store.status
|
|
629
632
|
});
|
|
630
633
|
throw _context6.t0;
|
|
631
|
-
case
|
|
634
|
+
case 77:
|
|
632
635
|
case "end":
|
|
633
636
|
return _context6.stop();
|
|
634
637
|
}
|
|
635
|
-
}, _callee6, this, [[
|
|
638
|
+
}, _callee6, this, [[50, 70]]);
|
|
636
639
|
}));
|
|
637
640
|
function initialize(_x5) {
|
|
638
641
|
return _initialize.apply(this, arguments);
|
|
@@ -1094,27 +1097,105 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1094
1097
|
}
|
|
1095
1098
|
return fetchResourceAvailability;
|
|
1096
1099
|
}() // ─── 日期概览 & 时间槽矩阵(纯计算,不发请求) ───
|
|
1100
|
+
}, {
|
|
1101
|
+
key: "getOperatingHoursScheduleIds",
|
|
1102
|
+
value: function getOperatingHoursScheduleIds() {
|
|
1103
|
+
var _this$store$openData, _this$store$openData$;
|
|
1104
|
+
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;
|
|
1105
|
+
var rawIds = openData === null || openData === void 0 ? void 0 : openData['availability.operating_hours'];
|
|
1106
|
+
if (!Array.isArray(rawIds)) return [];
|
|
1107
|
+
return _toConsumableArray(new Set(rawIds.map(function (id) {
|
|
1108
|
+
return Number(id);
|
|
1109
|
+
}).filter(function (id) {
|
|
1110
|
+
return Number.isFinite(id) && id > 0;
|
|
1111
|
+
}).map(function (id) {
|
|
1112
|
+
return Math.floor(id);
|
|
1113
|
+
})));
|
|
1114
|
+
}
|
|
1115
|
+
}, {
|
|
1116
|
+
key: "resolveSlotConfigForDate",
|
|
1117
|
+
value: function resolveSlotConfigForDate(date) {
|
|
1118
|
+
var nextSlotConfig = _objectSpread({}, this.baseSlotConfig);
|
|
1119
|
+
if (!date || !this.store.schedule) return nextSlotConfig;
|
|
1120
|
+
var operatingHoursScheduleIds = this.getOperatingHoursScheduleIds();
|
|
1121
|
+
if (!operatingHoursScheduleIds.length) return nextSlotConfig;
|
|
1122
|
+
var scheduleList = this.store.schedule.getScheduleListByIds(operatingHoursScheduleIds);
|
|
1123
|
+
if (!scheduleList.length) return nextSlotConfig;
|
|
1124
|
+
var timeRangeMap = calcMinTimeMaxTimeBySchedules(scheduleList, undefined, date);
|
|
1125
|
+
var earliestStart = null;
|
|
1126
|
+
var latestEnd = null;
|
|
1127
|
+
var _iterator3 = _createForOfIteratorHelper(scheduleList),
|
|
1128
|
+
_step3;
|
|
1129
|
+
try {
|
|
1130
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1131
|
+
var _timeRangeMap$schedul;
|
|
1132
|
+
var schedule = _step3.value;
|
|
1133
|
+
var dateRangeList = (timeRangeMap === null || timeRangeMap === void 0 || (_timeRangeMap$schedul = timeRangeMap[schedule.id]) === null || _timeRangeMap$schedul === void 0 ? void 0 : _timeRangeMap$schedul.dateRangeFormat) || [];
|
|
1134
|
+
var _iterator4 = _createForOfIteratorHelper(dateRangeList),
|
|
1135
|
+
_step4;
|
|
1136
|
+
try {
|
|
1137
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
1138
|
+
var range = _step4.value;
|
|
1139
|
+
var start = dayjs(range === null || range === void 0 ? void 0 : range.start);
|
|
1140
|
+
var end = dayjs(range === null || range === void 0 ? void 0 : range.end);
|
|
1141
|
+
if (!start.isValid() || !end.isValid()) continue;
|
|
1142
|
+
if (!earliestStart || start.isBefore(earliestStart)) {
|
|
1143
|
+
earliestStart = start;
|
|
1144
|
+
}
|
|
1145
|
+
if (!latestEnd || end.isAfter(latestEnd)) {
|
|
1146
|
+
latestEnd = end;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
} catch (err) {
|
|
1150
|
+
_iterator4.e(err);
|
|
1151
|
+
} finally {
|
|
1152
|
+
_iterator4.f();
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
} catch (err) {
|
|
1156
|
+
_iterator3.e(err);
|
|
1157
|
+
} finally {
|
|
1158
|
+
_iterator3.f();
|
|
1159
|
+
}
|
|
1160
|
+
if (!earliestStart || !latestEnd) return nextSlotConfig;
|
|
1161
|
+
return _objectSpread(_objectSpread({}, nextSlotConfig), {}, {
|
|
1162
|
+
businessStartTime: earliestStart.format('HH:mm'),
|
|
1163
|
+
businessEndTime: latestEnd.format('HH:mm')
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
}, {
|
|
1167
|
+
key: "syncOperatingHoursToSlotConfig",
|
|
1168
|
+
value: function syncOperatingHoursToSlotConfig(date) {
|
|
1169
|
+
var resolvedSlotConfig = this.resolveSlotConfigForDate(date);
|
|
1170
|
+
this.store.slotConfig = resolvedSlotConfig;
|
|
1171
|
+
return resolvedSlotConfig;
|
|
1172
|
+
}
|
|
1097
1173
|
}, {
|
|
1098
1174
|
key: "getDateRangeSummary",
|
|
1099
1175
|
value: function getDateRangeSummary(params) {
|
|
1176
|
+
var _this6 = this;
|
|
1100
1177
|
return buildDateRangeSummary({
|
|
1101
1178
|
startDate: params.startDate,
|
|
1102
1179
|
endDate: params.endDate,
|
|
1103
|
-
config: this.
|
|
1180
|
+
config: this.baseSlotConfig,
|
|
1104
1181
|
rawResources: this.store.rawResourceData,
|
|
1105
1182
|
resourceProductMap: this.resourceProductMap,
|
|
1106
|
-
quotationModule: this.store.quotation
|
|
1183
|
+
quotationModule: this.store.quotation,
|
|
1184
|
+
resolveConfig: function resolveConfig(date) {
|
|
1185
|
+
return _this6.resolveSlotConfigForDate(date);
|
|
1186
|
+
}
|
|
1107
1187
|
});
|
|
1108
1188
|
}
|
|
1109
1189
|
}, {
|
|
1110
1190
|
key: "getTimeSlotGrid",
|
|
1111
1191
|
value: function getTimeSlotGrid(date) {
|
|
1192
|
+
var resolvedSlotConfig = this.syncOperatingHoursToSlotConfig(date);
|
|
1112
1193
|
var quotationPriceMap;
|
|
1113
1194
|
if (this.store.quotation) {
|
|
1114
1195
|
var productIds = _toConsumableArray(new Set(_toConsumableArray(this.resourceProductMap.values()).map(function (m) {
|
|
1115
1196
|
return m.productId;
|
|
1116
1197
|
})));
|
|
1117
|
-
var timeLabels = generateTimeLabels(
|
|
1198
|
+
var timeLabels = generateTimeLabels(resolvedSlotConfig);
|
|
1118
1199
|
var timePoints = timeLabels.map(function (label) {
|
|
1119
1200
|
return "".concat(date, " ").concat(label);
|
|
1120
1201
|
});
|
|
@@ -1125,7 +1206,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1125
1206
|
}
|
|
1126
1207
|
return buildTimeSlotGrid({
|
|
1127
1208
|
date: date,
|
|
1128
|
-
config:
|
|
1209
|
+
config: resolvedSlotConfig,
|
|
1129
1210
|
rawResources: this.store.rawResourceData,
|
|
1130
1211
|
resourceProductMap: this.resourceProductMap,
|
|
1131
1212
|
quotationPriceMap: quotationPriceMap
|
|
@@ -1222,17 +1303,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1222
1303
|
});
|
|
1223
1304
|
var slotDuration = this.store.slotConfig.slotDurationMinutes;
|
|
1224
1305
|
var slots = [];
|
|
1225
|
-
var
|
|
1226
|
-
|
|
1306
|
+
var _iterator5 = _createForOfIteratorHelper(venueProducts),
|
|
1307
|
+
_step5;
|
|
1227
1308
|
try {
|
|
1228
|
-
for (
|
|
1229
|
-
var product =
|
|
1309
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1310
|
+
var product = _step5.value;
|
|
1230
1311
|
slots.push.apply(slots, _toConsumableArray(expandMergedSlotToIndividual(product, slotDuration)));
|
|
1231
1312
|
}
|
|
1232
1313
|
} catch (err) {
|
|
1233
|
-
|
|
1314
|
+
_iterator5.e(err);
|
|
1234
1315
|
} finally {
|
|
1235
|
-
|
|
1316
|
+
_iterator5.f();
|
|
1236
1317
|
}
|
|
1237
1318
|
return slots.sort(function (a, b) {
|
|
1238
1319
|
return a.startTime.localeCompare(b.startTime);
|
|
@@ -1265,12 +1346,12 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1265
1346
|
return (_p$metadata3 = p.metadata) === null || _p$metadata3 === void 0 ? void 0 : _p$metadata3.venue_booking;
|
|
1266
1347
|
});
|
|
1267
1348
|
var slotDuration = this.store.slotConfig.slotDurationMinutes;
|
|
1268
|
-
var
|
|
1269
|
-
|
|
1349
|
+
var _iterator6 = _createForOfIteratorHelper(venueProducts),
|
|
1350
|
+
_step6;
|
|
1270
1351
|
try {
|
|
1271
|
-
for (
|
|
1352
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
1272
1353
|
var _product$metadata;
|
|
1273
|
-
var product =
|
|
1354
|
+
var product = _step6.value;
|
|
1274
1355
|
var resourceId = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.resource_id;
|
|
1275
1356
|
if (resourceId == null) continue;
|
|
1276
1357
|
var existing = result.get(resourceId) || [];
|
|
@@ -1278,25 +1359,25 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1278
1359
|
result.set(resourceId, existing);
|
|
1279
1360
|
}
|
|
1280
1361
|
} catch (err) {
|
|
1281
|
-
|
|
1362
|
+
_iterator6.e(err);
|
|
1282
1363
|
} finally {
|
|
1283
|
-
|
|
1364
|
+
_iterator6.f();
|
|
1284
1365
|
}
|
|
1285
|
-
var
|
|
1286
|
-
|
|
1366
|
+
var _iterator7 = _createForOfIteratorHelper(result),
|
|
1367
|
+
_step7;
|
|
1287
1368
|
try {
|
|
1288
|
-
for (
|
|
1289
|
-
var
|
|
1290
|
-
key =
|
|
1291
|
-
slots =
|
|
1369
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
1370
|
+
var _step7$value = _slicedToArray(_step7.value, 2),
|
|
1371
|
+
key = _step7$value[0],
|
|
1372
|
+
slots = _step7$value[1];
|
|
1292
1373
|
result.set(key, slots.sort(function (a, b) {
|
|
1293
1374
|
return a.startTime.localeCompare(b.startTime);
|
|
1294
1375
|
}));
|
|
1295
1376
|
}
|
|
1296
1377
|
} catch (err) {
|
|
1297
|
-
|
|
1378
|
+
_iterator7.e(err);
|
|
1298
1379
|
} finally {
|
|
1299
|
-
|
|
1380
|
+
_iterator7.f();
|
|
1300
1381
|
}
|
|
1301
1382
|
return result;
|
|
1302
1383
|
}
|
|
@@ -1459,7 +1540,8 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1459
1540
|
}, {
|
|
1460
1541
|
key: "setSlotConfig",
|
|
1461
1542
|
value: function setSlotConfig(config) {
|
|
1462
|
-
this.
|
|
1543
|
+
this.baseSlotConfig = _objectSpread(_objectSpread({}, this.baseSlotConfig), config);
|
|
1544
|
+
this.store.slotConfig = _objectSpread({}, this.baseSlotConfig);
|
|
1463
1545
|
}
|
|
1464
1546
|
}, {
|
|
1465
1547
|
key: "getSlotConfig",
|
|
@@ -1509,10 +1591,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1509
1591
|
}, {
|
|
1510
1592
|
key: "injectScheduleResolverToQuotation",
|
|
1511
1593
|
value: function injectScheduleResolverToQuotation() {
|
|
1512
|
-
var
|
|
1594
|
+
var _this7 = this;
|
|
1513
1595
|
if (this.store.quotation && this.store.schedule) {
|
|
1514
1596
|
this.store.quotation.setScheduleResolver(function (id) {
|
|
1515
|
-
return
|
|
1597
|
+
return _this7.store.schedule.getScheduleListByIds([id])[0];
|
|
1516
1598
|
});
|
|
1517
1599
|
}
|
|
1518
1600
|
}
|
|
@@ -1590,25 +1672,25 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1590
1672
|
key: "recalculateOrderPricesFromQuotation",
|
|
1591
1673
|
value: function recalculateOrderPricesFromQuotation() {
|
|
1592
1674
|
var _tempOrder$products,
|
|
1593
|
-
|
|
1675
|
+
_this8 = this;
|
|
1594
1676
|
if (!this.store.order || !this.store.quotation) return;
|
|
1595
1677
|
var tempOrder = this.store.order.getTempOrder();
|
|
1596
1678
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return;
|
|
1597
1679
|
var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
1598
|
-
var
|
|
1599
|
-
|
|
1680
|
+
var _iterator8 = _createForOfIteratorHelper(tempOrder.products),
|
|
1681
|
+
_step8;
|
|
1600
1682
|
try {
|
|
1601
1683
|
var _loop = function _loop() {
|
|
1602
1684
|
var _product$metadata2;
|
|
1603
|
-
var product =
|
|
1685
|
+
var product = _step8.value;
|
|
1604
1686
|
if ((_product$metadata2 = product.metadata) !== null && _product$metadata2 !== void 0 && _product$metadata2.venue_booking) {
|
|
1605
|
-
var mapping =
|
|
1687
|
+
var mapping = _this8.resourceProductMap.get(product.metadata.resource_id);
|
|
1606
1688
|
if (!mapping) return 1; // continue
|
|
1607
|
-
var slots = expandMergedSlotToIndividual(product,
|
|
1689
|
+
var slots = expandMergedSlotToIndividual(product, _this8.store.slotConfig.slotDurationMinutes);
|
|
1608
1690
|
var updatedSlots = slots.map(function (slot) {
|
|
1609
1691
|
var _getPriceForProduct;
|
|
1610
1692
|
return _objectSpread(_objectSpread({}, slot), {}, {
|
|
1611
|
-
price: (_getPriceForProduct =
|
|
1693
|
+
price: (_getPriceForProduct = _this8.store.quotation.getPriceForProduct({
|
|
1612
1694
|
productId: mapping.productId,
|
|
1613
1695
|
datetime: slot.startTime
|
|
1614
1696
|
})) !== null && _getPriceForProduct !== void 0 ? _getPriceForProduct : mapping.price
|
|
@@ -1621,12 +1703,12 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1621
1703
|
product.metadata.price_breakdown = buildPriceBreakdown({
|
|
1622
1704
|
group: merged[0],
|
|
1623
1705
|
productId: mapping.productId,
|
|
1624
|
-
quotation:
|
|
1706
|
+
quotation: _this8.store.quotation
|
|
1625
1707
|
});
|
|
1626
1708
|
}
|
|
1627
1709
|
} else if (product.product_id != null) {
|
|
1628
1710
|
var _product$product_vari;
|
|
1629
|
-
var quotationPrice =
|
|
1711
|
+
var quotationPrice = _this8.store.quotation.getPriceForProduct({
|
|
1630
1712
|
productId: product.product_id,
|
|
1631
1713
|
variantId: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : undefined,
|
|
1632
1714
|
datetime: now
|
|
@@ -1637,13 +1719,13 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1637
1719
|
}
|
|
1638
1720
|
}
|
|
1639
1721
|
};
|
|
1640
|
-
for (
|
|
1722
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
1641
1723
|
if (_loop()) continue;
|
|
1642
1724
|
}
|
|
1643
1725
|
} catch (err) {
|
|
1644
|
-
|
|
1726
|
+
_iterator8.e(err);
|
|
1645
1727
|
} finally {
|
|
1646
|
-
|
|
1728
|
+
_iterator8.f();
|
|
1647
1729
|
}
|
|
1648
1730
|
}
|
|
1649
1731
|
}, {
|
|
@@ -1711,7 +1793,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1711
1793
|
key: "setDiscountSelected",
|
|
1712
1794
|
value: (function () {
|
|
1713
1795
|
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
1714
|
-
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,
|
|
1796
|
+
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, _iterator9, _step9, d, selectedResourceIds, _iterator10, _step10, _product$discount_lis, product, before, totalDiscountAmount, newPaymentPrice, paymentStr, afterApplyTarget, finalSummary, finalProduct, finalTarget;
|
|
1715
1797
|
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1716
1798
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1717
1799
|
case 0:
|
|
@@ -1771,18 +1853,18 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1771
1853
|
}).map(function (d) {
|
|
1772
1854
|
return d.id;
|
|
1773
1855
|
}));
|
|
1774
|
-
|
|
1856
|
+
_iterator9 = _createForOfIteratorHelper(nextDiscountList);
|
|
1775
1857
|
try {
|
|
1776
|
-
for (
|
|
1777
|
-
d =
|
|
1858
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1859
|
+
d = _step9.value;
|
|
1778
1860
|
if (d.isSelected && !beforeSelectedIds.has(d.id)) {
|
|
1779
1861
|
d.isSelected = false;
|
|
1780
1862
|
}
|
|
1781
1863
|
}
|
|
1782
1864
|
} catch (err) {
|
|
1783
|
-
|
|
1865
|
+
_iterator9.e(err);
|
|
1784
1866
|
} finally {
|
|
1785
|
-
|
|
1867
|
+
_iterator9.f();
|
|
1786
1868
|
}
|
|
1787
1869
|
}
|
|
1788
1870
|
}
|
|
@@ -1792,15 +1874,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1792
1874
|
}).map(function (d) {
|
|
1793
1875
|
return d.id;
|
|
1794
1876
|
}));
|
|
1795
|
-
|
|
1877
|
+
_iterator10 = _createForOfIteratorHelper(tempOrder.products);
|
|
1796
1878
|
_context21.prev = 19;
|
|
1797
|
-
|
|
1879
|
+
_iterator10.s();
|
|
1798
1880
|
case 21:
|
|
1799
|
-
if ((
|
|
1881
|
+
if ((_step10 = _iterator10.n()).done) {
|
|
1800
1882
|
_context21.next = 30;
|
|
1801
1883
|
break;
|
|
1802
1884
|
}
|
|
1803
|
-
product =
|
|
1885
|
+
product = _step10.value;
|
|
1804
1886
|
if ((_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length) {
|
|
1805
1887
|
_context21.next = 25;
|
|
1806
1888
|
break;
|
|
@@ -1833,10 +1915,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1833
1915
|
case 32:
|
|
1834
1916
|
_context21.prev = 32;
|
|
1835
1917
|
_context21.t0 = _context21["catch"](19);
|
|
1836
|
-
|
|
1918
|
+
_iterator10.e(_context21.t0);
|
|
1837
1919
|
case 35:
|
|
1838
1920
|
_context21.prev = 35;
|
|
1839
|
-
|
|
1921
|
+
_iterator10.f();
|
|
1840
1922
|
return _context21.finish(35);
|
|
1841
1923
|
case 38:
|
|
1842
1924
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
@@ -2209,7 +2291,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2209
2291
|
key: "loadOpenDataConfig",
|
|
2210
2292
|
value: function () {
|
|
2211
2293
|
var _loadOpenDataConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2212
|
-
var
|
|
2294
|
+
var _this9 = this;
|
|
2213
2295
|
var lastFetchedAt, cachedData;
|
|
2214
2296
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2215
2297
|
while (1) switch (_context29.prev = _context29.next) {
|
|
@@ -2240,10 +2322,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2322
|
target: 'venue_booking+online_store',
|
|
2241
2323
|
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
2242
2324
|
}).then(function (openDataConfig) {
|
|
2243
|
-
|
|
2325
|
+
_this9.otherParams.openData = openDataConfig;
|
|
2244
2326
|
return openDataConfig;
|
|
2245
2327
|
}).finally(function () {
|
|
2246
|
-
|
|
2328
|
+
_this9.loadOpenDataConfigInFlight = null;
|
|
2247
2329
|
});
|
|
2248
2330
|
return _context29.abrupt("return", this.loadOpenDataConfigInFlight);
|
|
2249
2331
|
case 11:
|
|
@@ -2372,17 +2454,17 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2372
2454
|
if (visited.has(value)) return;
|
|
2373
2455
|
visited.add(value);
|
|
2374
2456
|
if (Array.isArray(value)) {
|
|
2375
|
-
var
|
|
2376
|
-
|
|
2457
|
+
var _iterator11 = _createForOfIteratorHelper(value),
|
|
2458
|
+
_step11;
|
|
2377
2459
|
try {
|
|
2378
|
-
for (
|
|
2379
|
-
var item =
|
|
2460
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2461
|
+
var item = _step11.value;
|
|
2380
2462
|
collectFromValue(item);
|
|
2381
2463
|
}
|
|
2382
2464
|
} catch (err) {
|
|
2383
|
-
|
|
2465
|
+
_iterator11.e(err);
|
|
2384
2466
|
} finally {
|
|
2385
|
-
|
|
2467
|
+
_iterator11.f();
|
|
2386
2468
|
}
|
|
2387
2469
|
return;
|
|
2388
2470
|
}
|
|
@@ -2430,7 +2512,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2430
2512
|
key: "ensureItemRuleConfigsLoaded",
|
|
2431
2513
|
value: function () {
|
|
2432
2514
|
var _ensureItemRuleConfigsLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34() {
|
|
2433
|
-
var
|
|
2515
|
+
var _this10 = this;
|
|
2434
2516
|
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2435
2517
|
while (1) switch (_context34.prev = _context34.next) {
|
|
2436
2518
|
case 0:
|
|
@@ -2451,19 +2533,19 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2451
2533
|
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2452
2534
|
while (1) switch (_context33.prev = _context33.next) {
|
|
2453
2535
|
case 0:
|
|
2454
|
-
runtimeConfig =
|
|
2536
|
+
runtimeConfig = _this10.getItemRuleRuntimeConfig();
|
|
2455
2537
|
staticConfigs = normalizeItemRuleStrategies(runtimeConfig.strategyConfigs);
|
|
2456
2538
|
if (!(staticConfigs.length > 0)) {
|
|
2457
2539
|
_context33.next = 6;
|
|
2458
2540
|
break;
|
|
2459
2541
|
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
return _context33.abrupt("return",
|
|
2542
|
+
_this10.itemRuleConfigs = staticConfigs;
|
|
2543
|
+
_this10.itemRuleEvaluator.setStrategyConfigs(staticConfigs);
|
|
2544
|
+
return _context33.abrupt("return", _this10.itemRuleConfigs);
|
|
2463
2545
|
case 6:
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
return _context33.abrupt("return",
|
|
2546
|
+
_this10.itemRuleConfigs = [];
|
|
2547
|
+
_this10.itemRuleEvaluator.setStrategyConfigs([]);
|
|
2548
|
+
return _context33.abrupt("return", _this10.itemRuleConfigs);
|
|
2467
2549
|
case 9:
|
|
2468
2550
|
case "end":
|
|
2469
2551
|
return _context33.stop();
|
|
@@ -2537,7 +2619,7 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2537
2619
|
key: "applyPrefillByItemRule",
|
|
2538
2620
|
value: function () {
|
|
2539
2621
|
var _applyPrefillByItemRule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36() {
|
|
2540
|
-
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges,
|
|
2622
|
+
var strategyConfigs, businessData, prefillItems, productSourceMap, tempOrder, hasChanges, _iterator12, _step12, _prefillItem$product_, _targetProduct$_origi, prefillItem, productId, productVariantId, targetQuantity, sourceItem, productIndex, _sourceItem$price, _ref5, _sourceItem$original_, _ref6, _sourceItem$payment_p, sellingPrice, originalPrice, paymentPrice, targetProduct, existedQuantity, delta, nextProduct;
|
|
2541
2623
|
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2542
2624
|
while (1) switch (_context36.prev = _context36.next) {
|
|
2543
2625
|
case 0:
|
|
@@ -2582,15 +2664,15 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2582
2664
|
productSourceMap = _context36.sent;
|
|
2583
2665
|
tempOrder = this.ensureTempOrder();
|
|
2584
2666
|
hasChanges = false;
|
|
2585
|
-
|
|
2667
|
+
_iterator12 = _createForOfIteratorHelper(prefillItems);
|
|
2586
2668
|
_context36.prev = 20;
|
|
2587
|
-
|
|
2669
|
+
_iterator12.s();
|
|
2588
2670
|
case 22:
|
|
2589
|
-
if ((
|
|
2671
|
+
if ((_step12 = _iterator12.n()).done) {
|
|
2590
2672
|
_context36.next = 47;
|
|
2591
2673
|
break;
|
|
2592
2674
|
}
|
|
2593
|
-
prefillItem =
|
|
2675
|
+
prefillItem = _step12.value;
|
|
2594
2676
|
productId = Number(prefillItem.product_id);
|
|
2595
2677
|
productVariantId = Number((_prefillItem$product_ = prefillItem.product_variant_id) !== null && _prefillItem$product_ !== void 0 ? _prefillItem$product_ : 0);
|
|
2596
2678
|
targetQuantity = toNonNegativeInt(prefillItem.quantity);
|
|
@@ -2662,10 +2744,10 @@ export var VenueBookingImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2662
2744
|
case 49:
|
|
2663
2745
|
_context36.prev = 49;
|
|
2664
2746
|
_context36.t0 = _context36["catch"](20);
|
|
2665
|
-
|
|
2747
|
+
_iterator12.e(_context36.t0);
|
|
2666
2748
|
case 52:
|
|
2667
2749
|
_context36.prev = 52;
|
|
2668
|
-
|
|
2750
|
+
_iterator12.f();
|
|
2669
2751
|
return _context36.finish(52);
|
|
2670
2752
|
case 55:
|
|
2671
2753
|
if (!hasChanges) {
|
|
@@ -7,4 +7,5 @@ export declare function buildDateRangeSummary(params: {
|
|
|
7
7
|
rawResources: VenueResourceRawData[];
|
|
8
8
|
resourceProductMap: Map<number | string, ResourceProductMapping>;
|
|
9
9
|
quotationModule?: QuotationModule;
|
|
10
|
+
resolveConfig?: (date: string) => VenueBookingSlotConfig;
|
|
10
11
|
}): VenueDateSummaryItem[];
|
|
@@ -13,7 +13,8 @@ export function buildDateRangeSummary(params) {
|
|
|
13
13
|
config = params.config,
|
|
14
14
|
rawResources = params.rawResources,
|
|
15
15
|
resourceProductMap = params.resourceProductMap,
|
|
16
|
-
quotationModule = params.quotationModule
|
|
16
|
+
quotationModule = params.quotationModule,
|
|
17
|
+
resolveConfig = params.resolveConfig;
|
|
17
18
|
var result = [];
|
|
18
19
|
var productIds = quotationModule ? _toConsumableArray(new Set(_toConsumableArray(resourceProductMap.values()).map(function (m) {
|
|
19
20
|
return m.productId;
|
|
@@ -22,9 +23,10 @@ export function buildDateRangeSummary(params) {
|
|
|
22
23
|
var end = dayjs(endDate);
|
|
23
24
|
var _loop = function _loop() {
|
|
24
25
|
var date = cursor.format('YYYY-MM-DD');
|
|
26
|
+
var effectiveConfig = (resolveConfig === null || resolveConfig === void 0 ? void 0 : resolveConfig(date)) || config;
|
|
25
27
|
var quotationPriceMap;
|
|
26
28
|
if (quotationModule && productIds.length) {
|
|
27
|
-
var timeLabels = generateTimeLabels(
|
|
29
|
+
var timeLabels = generateTimeLabels(effectiveConfig);
|
|
28
30
|
var timePoints = timeLabels.map(function (label) {
|
|
29
31
|
return "".concat(date, " ").concat(label);
|
|
30
32
|
});
|
|
@@ -35,7 +37,7 @@ export function buildDateRangeSummary(params) {
|
|
|
35
37
|
}
|
|
36
38
|
var grid = buildTimeSlotGrid({
|
|
37
39
|
date: date,
|
|
38
|
-
config:
|
|
40
|
+
config: effectiveConfig,
|
|
39
41
|
rawResources: rawResources,
|
|
40
42
|
resourceProductMap: resourceProductMap,
|
|
41
43
|
quotationPriceMap: quotationPriceMap
|
|
@@ -81,7 +83,7 @@ export function buildDateRangeSummary(params) {
|
|
|
81
83
|
status = 'unavailable';
|
|
82
84
|
} else if (availableSlots === 0) {
|
|
83
85
|
status = 'sold_out';
|
|
84
|
-
} else if ((totalSlots - availableSlots) / totalSlots >=
|
|
86
|
+
} else if ((totalSlots - availableSlots) / totalSlots >= effectiveConfig.fewLeftThreshold) {
|
|
85
87
|
status = 'few_left';
|
|
86
88
|
} else {
|
|
87
89
|
status = 'available';
|
|
@@ -50,6 +50,14 @@ export declare class ItemRuleAdapter implements BusinessAdapter {
|
|
|
50
50
|
* 不适用或无配置时返回 null。
|
|
51
51
|
*/
|
|
52
52
|
extractQuantityLimits(action: ActionEffect, businessData: ItemRuleBusinessData): QuantityLimitResult | null;
|
|
53
|
+
/**
|
|
54
|
+
* 计算当前提交剩余可选的最大数量。
|
|
55
|
+
*
|
|
56
|
+
* 仅在 scope='cumulative' 且存在 requiredMax 时生效:
|
|
57
|
+
* 用 requiredMax 减去 historicalItems 中目标商品的累计数量,保底 0。
|
|
58
|
+
* 其余场景返回 undefined,保持向后兼容。
|
|
59
|
+
*/
|
|
60
|
+
private calculateRemainingMax;
|
|
53
61
|
private processPrefillCart;
|
|
54
62
|
/**
|
|
55
63
|
* 根据 quantityFrom 计算预填数量
|