@pisell/pisellos 2.0.60 → 2.0.62
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/modules/Cart/index.js +5 -1
- package/dist/modules/Cart/types.d.ts +6 -2
- package/dist/modules/Cart/utils/cartDate.js +6 -0
- package/dist/modules/Product/types.d.ts +5 -0
- package/dist/modules/Schedule/utils.js +7 -1
- package/dist/solution/BookingByStep/index.js +56 -37
- package/dist/solution/BookingByStep/utils/resources.d.ts +4 -2
- package/dist/solution/BookingByStep/utils/resources.js +17 -3
- package/lib/modules/Cart/index.js +5 -1
- package/lib/modules/Cart/types.d.ts +6 -2
- package/lib/modules/Cart/utils/cartDate.js +2 -0
- package/lib/modules/Product/types.d.ts +5 -0
- package/lib/modules/Schedule/utils.js +8 -3
- package/lib/solution/BookingByStep/index.js +27 -14
- package/lib/solution/BookingByStep/utils/resources.d.ts +4 -2
- package/lib/solution/BookingByStep/utils/resources.js +15 -4
- package/package.json +1 -1
|
@@ -258,7 +258,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
258
258
|
resources = params.resources,
|
|
259
259
|
note = params.note,
|
|
260
260
|
date = params.date,
|
|
261
|
-
relationForms = params.relationForms
|
|
261
|
+
relationForms = params.relationForms,
|
|
262
|
+
osWarnTips = params.osWarnTips;
|
|
262
263
|
var quantity = params.quantity;
|
|
263
264
|
var tempCartItem = this.store.list.find(function (i) {
|
|
264
265
|
return i._id === _id;
|
|
@@ -324,6 +325,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
324
325
|
note: note
|
|
325
326
|
});
|
|
326
327
|
}
|
|
328
|
+
if (osWarnTips) {
|
|
329
|
+
tempCartItem.osWarnTips = osWarnTips;
|
|
330
|
+
}
|
|
327
331
|
return tempCartItem;
|
|
328
332
|
}
|
|
329
333
|
|
|
@@ -110,6 +110,8 @@ export interface CartItem {
|
|
|
110
110
|
bundle?: any[];
|
|
111
111
|
/** 商品规格信息 */
|
|
112
112
|
options?: any[];
|
|
113
|
+
/** 商品规格选项字符串 */
|
|
114
|
+
product_option_string?: string;
|
|
113
115
|
/** 是否为普通商品 */
|
|
114
116
|
isNormalProduct?: boolean;
|
|
115
117
|
/** 资源ID */
|
|
@@ -142,8 +144,8 @@ export interface CartItem {
|
|
|
142
144
|
_bundleOrigin?: any[];
|
|
143
145
|
/** 商品规格原始数据 */
|
|
144
146
|
_optionsOrigin?: any[];
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
+
/** 操作系统提示 */
|
|
148
|
+
osWarnTips?: string[];
|
|
147
149
|
}
|
|
148
150
|
/**
|
|
149
151
|
* 购物车状态接口
|
|
@@ -217,6 +219,8 @@ export interface IUpdateItemParams {
|
|
|
217
219
|
}[];
|
|
218
220
|
/** 商品组合规格ID */
|
|
219
221
|
product_variant_id?: number;
|
|
222
|
+
/** 操作系统提示 */
|
|
223
|
+
osWarnTips?: string[];
|
|
220
224
|
}
|
|
221
225
|
/**
|
|
222
226
|
* 折扣
|
|
@@ -39,6 +39,7 @@ export var formatDateToCartItemOrigin = function formatDateToCartItemOrigin(para
|
|
|
39
39
|
* @returns 删除后的购物车
|
|
40
40
|
*/
|
|
41
41
|
export var deleteTimeFromCartItem = function deleteTimeFromCartItem(cartItem) {
|
|
42
|
+
var _cartItem$osWarnTips;
|
|
42
43
|
// 删除UI层的数据
|
|
43
44
|
cartItem.start_date = undefined;
|
|
44
45
|
cartItem.start_time = undefined;
|
|
@@ -51,5 +52,10 @@ export var deleteTimeFromCartItem = function deleteTimeFromCartItem(cartItem) {
|
|
|
51
52
|
cartItem._origin.start_time = null;
|
|
52
53
|
cartItem._origin.end_date = null;
|
|
53
54
|
cartItem._origin.end_time = null;
|
|
55
|
+
|
|
56
|
+
// 同时清空 osWarnTips 中的关于时间的提示
|
|
57
|
+
cartItem.osWarnTips = (_cartItem$osWarnTips = cartItem.osWarnTips) === null || _cartItem$osWarnTips === void 0 ? void 0 : _cartItem$osWarnTips.filter(function (item) {
|
|
58
|
+
return !item.includes('pisell2.product.card.closing-soon.warning');
|
|
59
|
+
});
|
|
54
60
|
return cartItem;
|
|
55
61
|
};
|
|
@@ -105,6 +105,11 @@ export interface ProductData {
|
|
|
105
105
|
type: string;
|
|
106
106
|
/** 值 */
|
|
107
107
|
value: number;
|
|
108
|
+
flexible_config?: {
|
|
109
|
+
is_enable_minimum_duration?: 0 | 1;
|
|
110
|
+
warning_threshold?: number;
|
|
111
|
+
block_threshold?: number;
|
|
112
|
+
};
|
|
108
113
|
};
|
|
109
114
|
/** 商品显示设置 */
|
|
110
115
|
product_display_setting: {
|
|
@@ -140,6 +140,12 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
|
|
|
140
140
|
for (var i = 0; i < frequency_date.length; i++) {
|
|
141
141
|
var item = frequency_date[i];
|
|
142
142
|
var _start = startTmp.day(item);
|
|
143
|
+
|
|
144
|
+
// 如果计算出的日期早于startTmp,则跳到下一周的相同星期几
|
|
145
|
+
if (_start.isBefore(startTmp, 'day')) {
|
|
146
|
+
_start = _start.add(1, 'week');
|
|
147
|
+
}
|
|
148
|
+
|
|
143
149
|
// 如果周结束的那一天还超过了deadline,则需要把_end置为deadline
|
|
144
150
|
var _end = _start.add(scheduleDiff, 'second');
|
|
145
151
|
if (_end.isAfter(deadline, 'day')) {
|
|
@@ -161,7 +167,7 @@ var getDaysByRepeatWeek = function getDaysByRepeatWeek(params, isGetRange) {
|
|
|
161
167
|
daysArr.push.apply(daysArr, _toConsumableArray(getDaysByStartEnd(_start, _end)));
|
|
162
168
|
}
|
|
163
169
|
}
|
|
164
|
-
startTmp = startTmp.
|
|
170
|
+
startTmp = startTmp.add(frequency, 'week');
|
|
165
171
|
}
|
|
166
172
|
return Array.from(new Set(daysArr));
|
|
167
173
|
};
|
|
@@ -1212,21 +1212,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1212
1212
|
_this6.store.cart.removeItem(n._id);
|
|
1213
1213
|
});
|
|
1214
1214
|
}
|
|
1215
|
-
// 如果 date.startTime 和 dateRange 里的 startTime 不一样,需要修正 dateRange
|
|
1216
|
-
|
|
1217
|
-
if (dateRange
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
}, {
|
|
1224
|
-
date: dayjs(date.endTime).format('YYYY-MM-DD'),
|
|
1225
|
-
status: 'available',
|
|
1226
|
-
week: '',
|
|
1227
|
-
weekNum: 0
|
|
1228
|
-
}]);
|
|
1229
|
-
}
|
|
1215
|
+
// // 如果 date.startTime 和 dateRange 里的 startTime 不一样,需要修正 dateRange
|
|
1216
|
+
// const dateRange = this.store.date.getDateRange()
|
|
1217
|
+
// if (dateRange?.[0] && !dayjs(dateRange[0].date).isSame(dayjs(date.startTime), 'day')) {
|
|
1218
|
+
// this.setDateRange([
|
|
1219
|
+
// { date: dayjs(date.startTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
|
|
1220
|
+
// { date: dayjs(date.endTime).format('YYYY-MM-DD'), status: 'available', week: '', weekNum: 0 },
|
|
1221
|
+
// ]);
|
|
1222
|
+
// }
|
|
1230
1223
|
}
|
|
1231
1224
|
}
|
|
1232
1225
|
}, {
|
|
@@ -1528,25 +1521,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1528
1521
|
});
|
|
1529
1522
|
});
|
|
1530
1523
|
} else {
|
|
1531
|
-
var _cartItem$_productOri3, _this10$shopStore$get;
|
|
1524
|
+
var _cartItem$_productOri3, _this10$shopStore$get, _cartItem$_productOri4, _cartItem$_productOri5;
|
|
1532
1525
|
var hasFlexibleDuration = ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.type) === 'flexible';
|
|
1533
1526
|
var operating_day_boundary = (_this10$shopStore$get = _this10.shopStore.get('core')) === null || _this10$shopStore$get === void 0 || (_this10$shopStore$get = _this10$shopStore$get.core) === null || _this10$shopStore$get === void 0 ? void 0 : _this10$shopStore$get.operating_day_boundary;
|
|
1527
|
+
var maxBlockThreshold = (_cartItem$_productOri4 = cartItem._productOrigin) !== null && _cartItem$_productOri4 !== void 0 && (_cartItem$_productOri4 = _cartItem$_productOri4.duration) !== null && _cartItem$_productOri4 !== void 0 && (_cartItem$_productOri4 = _cartItem$_productOri4.flexible_config) !== null && _cartItem$_productOri4 !== void 0 && _cartItem$_productOri4.is_enable_minimum_duration ? ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.duration) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.flexible_config) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.block_threshold) || 0 : 0;
|
|
1534
1528
|
productResources.forEach(function (item) {
|
|
1535
1529
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1536
1530
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1537
1531
|
item.renderList = item.renderList.filter(function (n) {
|
|
1538
|
-
var _cartItem$
|
|
1532
|
+
var _cartItem$_productOri6, _cartItem$_productOri7;
|
|
1539
1533
|
var recordCount = n.capacity || 0;
|
|
1540
1534
|
if (n.onlyComputed) return false;
|
|
1541
1535
|
// 查一下这个资源基于商品的可用时间片
|
|
1542
1536
|
var timeSlots = getTimeSlicesByResource({
|
|
1543
1537
|
resource: n,
|
|
1544
|
-
duration: ((_cartItem$
|
|
1538
|
+
duration: ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.duration) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.value) || 10,
|
|
1545
1539
|
split: 10,
|
|
1546
1540
|
currentDate: dateRange[0].date,
|
|
1547
1541
|
hasFlexibleDuration: hasFlexibleDuration,
|
|
1548
|
-
cut_off_time: (_cartItem$
|
|
1549
|
-
operating_day_boundary: operating_day_boundary
|
|
1542
|
+
cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time,
|
|
1543
|
+
operating_day_boundary: operating_day_boundary,
|
|
1544
|
+
maxBlockThreshold: maxBlockThreshold
|
|
1550
1545
|
});
|
|
1551
1546
|
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1552
1547
|
});
|
|
@@ -1647,7 +1642,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1647
1642
|
}, {
|
|
1648
1643
|
key: "autoSelectAccountResources",
|
|
1649
1644
|
value: function autoSelectAccountResources(_ref9) {
|
|
1650
|
-
var _cartItem$
|
|
1645
|
+
var _cartItem$_productOri8, _allProductResources$;
|
|
1651
1646
|
var cartItem = _ref9.cartItem,
|
|
1652
1647
|
holder_id = _ref9.holder_id,
|
|
1653
1648
|
resources_code = _ref9.resources_code,
|
|
@@ -1696,7 +1691,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1696
1691
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1697
1692
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1698
1693
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1699
|
-
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1694
|
+
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.product_resource) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.resources) || [], selectedResources, 1);
|
|
1700
1695
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1701
1696
|
return n.code === resources_code;
|
|
1702
1697
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
@@ -1757,14 +1752,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1757
1752
|
return 0; // continue
|
|
1758
1753
|
}
|
|
1759
1754
|
var canUseTime = mTimes.find(function (item) {
|
|
1760
|
-
var _cartItem$
|
|
1755
|
+
var _cartItem$_productOri9;
|
|
1761
1756
|
var res = getIsUsableByTimeItem({
|
|
1762
1757
|
timeSlice: timeSlots,
|
|
1763
1758
|
time: item,
|
|
1764
1759
|
resource: n,
|
|
1765
1760
|
currentCount: totalCapacity + (capacity || 0),
|
|
1766
1761
|
resourcesUseableMap: resourcesUseableMap,
|
|
1767
|
-
cut_off_time: (_cartItem$
|
|
1762
|
+
cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
|
|
1768
1763
|
});
|
|
1769
1764
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1770
1765
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -2132,6 +2127,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2132
2127
|
return ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.type) === 'flexible';
|
|
2133
2128
|
});
|
|
2134
2129
|
var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
|
|
2130
|
+
|
|
2131
|
+
// 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
|
|
2132
|
+
var maxBlockThreshold = 0;
|
|
2133
|
+
if (hasFlexibleDuration) {
|
|
2134
|
+
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2135
|
+
var _item$_productOrigin15;
|
|
2136
|
+
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2137
|
+
if ((_item$_productOrigin15 = item._productOrigin) !== null && _item$_productOrigin15 !== void 0 && (_item$_productOrigin15 = _item$_productOrigin15.duration) !== null && _item$_productOrigin15 !== void 0 && (_item$_productOrigin15 = _item$_productOrigin15.flexible_config) !== null && _item$_productOrigin15 !== void 0 && _item$_productOrigin15.is_enable_minimum_duration) {
|
|
2138
|
+
var _item$_productOrigin16;
|
|
2139
|
+
return Math.max(max, ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.flexible_config) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.block_threshold) || 0);
|
|
2140
|
+
}
|
|
2141
|
+
return 0;
|
|
2142
|
+
}, 0);
|
|
2143
|
+
}
|
|
2135
2144
|
var timeSlots = getTimeSlicesByResources({
|
|
2136
2145
|
resourceIds: resourceIds,
|
|
2137
2146
|
resourcesMap: resourcesMap,
|
|
@@ -2141,7 +2150,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2141
2150
|
resourcesUseableMap: resourcesUseableMap,
|
|
2142
2151
|
cut_off_time: maxCutOffTime,
|
|
2143
2152
|
hasFlexibleDuration: hasFlexibleDuration,
|
|
2144
|
-
operating_day_boundary: operating_day_boundary
|
|
2153
|
+
operating_day_boundary: operating_day_boundary,
|
|
2154
|
+
maxBlockThreshold: maxBlockThreshold
|
|
2145
2155
|
});
|
|
2146
2156
|
return timeSlots;
|
|
2147
2157
|
}
|
|
@@ -2178,12 +2188,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2178
2188
|
var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
|
|
2179
2189
|
accountItems.forEach(function (item, index) {
|
|
2180
2190
|
var _newResources$;
|
|
2191
|
+
var osWarnTips = [];
|
|
2181
2192
|
var newResources = cloneDeep(item._origin.resources);
|
|
2182
2193
|
newResources.forEach(function (resource) {
|
|
2183
|
-
var _item$
|
|
2194
|
+
var _item$_productOrigin17;
|
|
2184
2195
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2185
|
-
if (((_item$
|
|
2186
|
-
var _allResources$find;
|
|
2196
|
+
if (((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible') {
|
|
2197
|
+
var _allResources$find, _item$_productOrigin18, _item$_productOrigin19;
|
|
2187
2198
|
item.duration = {
|
|
2188
2199
|
type: 'minutes',
|
|
2189
2200
|
value: 10
|
|
@@ -2211,16 +2222,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2211
2222
|
formattedEndTime = dayjs(endTime);
|
|
2212
2223
|
}
|
|
2213
2224
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2225
|
+
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2226
|
+
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2227
|
+
if ((_item$_productOrigin18 = item._productOrigin) !== null && _item$_productOrigin18 !== void 0 && (_item$_productOrigin18 = _item$_productOrigin18.duration) !== null && _item$_productOrigin18 !== void 0 && (_item$_productOrigin18 = _item$_productOrigin18.flexible_config) !== null && _item$_productOrigin18 !== void 0 && _item$_productOrigin18.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.flexible_config) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
|
|
2228
|
+
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2229
|
+
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2214
2232
|
} else {
|
|
2215
|
-
var _item$
|
|
2233
|
+
var _item$_productOrigin20;
|
|
2216
2234
|
resource.startTime = currentStartTime;
|
|
2217
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2235
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 || (_item$_productOrigin20 = _item$_productOrigin20.duration) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2218
2236
|
}
|
|
2219
2237
|
// delete resource.times;
|
|
2220
2238
|
});
|
|
2221
2239
|
_this13.store.cart.updateItem({
|
|
2222
2240
|
_id: item._id,
|
|
2223
|
-
resources: newResources
|
|
2241
|
+
resources: newResources,
|
|
2242
|
+
osWarnTips: osWarnTips
|
|
2224
2243
|
});
|
|
2225
2244
|
|
|
2226
2245
|
// 更新下一个商品的开始时间为当前商品的结束时间
|
|
@@ -2514,7 +2533,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2514
2533
|
}, {
|
|
2515
2534
|
key: "getResourcesByCartItemAndCode",
|
|
2516
2535
|
value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
2517
|
-
var _cartItem$
|
|
2536
|
+
var _cartItem$_productOri10;
|
|
2518
2537
|
var dateRange = this.store.date.getDateRange();
|
|
2519
2538
|
var resources = [];
|
|
2520
2539
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -2546,7 +2565,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2546
2565
|
} else {
|
|
2547
2566
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
2548
2567
|
}
|
|
2549
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
2568
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 || (_cartItem$_productOri10 = _cartItem$_productOri10.product_resource) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.resources) || [], selectedResources, currentCapacity);
|
|
2550
2569
|
var targetResource = productResources.find(function (resource) {
|
|
2551
2570
|
return resource.code === resourceCode;
|
|
2552
2571
|
});
|
|
@@ -2569,7 +2588,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2569
2588
|
});
|
|
2570
2589
|
if (mTimes.length === 0) return false;
|
|
2571
2590
|
var canUseArr = mTimes.map(function (item) {
|
|
2572
|
-
var _cartItem$
|
|
2591
|
+
var _cartItem$_productOri11;
|
|
2573
2592
|
var res = getIsUsableByTimeItem({
|
|
2574
2593
|
timeSlice: {
|
|
2575
2594
|
start_time: startTime.format('HH:mm'),
|
|
@@ -2581,7 +2600,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2581
2600
|
resource: m,
|
|
2582
2601
|
currentCount: currentCapacity || 0,
|
|
2583
2602
|
resourcesUseableMap: resourcesUseableMap,
|
|
2584
|
-
cut_off_time: (_cartItem$
|
|
2603
|
+
cut_off_time: (_cartItem$_productOri11 = cartItem._productOrigin) === null || _cartItem$_productOri11 === void 0 ? void 0 : _cartItem$_productOri11.cut_off_time
|
|
2585
2604
|
});
|
|
2586
2605
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2587
2606
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -2595,12 +2614,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2595
2614
|
});
|
|
2596
2615
|
} else {
|
|
2597
2616
|
targetResource.renderList = targetResource.renderList.filter(function (n) {
|
|
2598
|
-
var _cartItem$
|
|
2617
|
+
var _cartItem$_productOri12;
|
|
2599
2618
|
var recordCount = n.capacity || 0;
|
|
2600
2619
|
if (n.onlyComputed) return false;
|
|
2601
2620
|
var timeSlots = getTimeSlicesByResource({
|
|
2602
2621
|
resource: n,
|
|
2603
|
-
duration: ((_cartItem$
|
|
2622
|
+
duration: ((_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 || (_cartItem$_productOri12 = _cartItem$_productOri12.duration) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.value) || 10,
|
|
2604
2623
|
split: 10,
|
|
2605
2624
|
currentDate: dateRange[0].date
|
|
2606
2625
|
});
|
|
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
|
|
|
79
79
|
* @return {*}
|
|
80
80
|
* @Author: zhiwei.Wang
|
|
81
81
|
*/
|
|
82
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
|
|
82
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
|
|
83
83
|
resource: ResourceItem;
|
|
84
84
|
duration: number;
|
|
85
85
|
split: number;
|
|
@@ -101,6 +101,7 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
|
|
|
101
101
|
type: string;
|
|
102
102
|
time: string;
|
|
103
103
|
} | undefined;
|
|
104
|
+
maxBlockThreshold?: number | undefined;
|
|
104
105
|
}) => TimeSliceItem[];
|
|
105
106
|
/**
|
|
106
107
|
* @title: 获取时间切片列表的交集
|
|
@@ -138,7 +139,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
138
139
|
* @return {*}
|
|
139
140
|
* @Author: zhiwei.Wang
|
|
140
141
|
*/
|
|
141
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
|
|
142
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
|
|
142
143
|
resourceIds: number[];
|
|
143
144
|
resourcesMap: any;
|
|
144
145
|
duration: number;
|
|
@@ -161,6 +162,7 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
161
162
|
type: string;
|
|
162
163
|
time: string;
|
|
163
164
|
} | undefined;
|
|
165
|
+
maxBlockThreshold?: number | undefined;
|
|
164
166
|
}) => any[];
|
|
165
167
|
/**
|
|
166
168
|
* @title: 获取其他人的已选资源
|
|
@@ -417,11 +417,16 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
417
417
|
resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl,
|
|
418
418
|
cut_off_time = _ref5.cut_off_time,
|
|
419
419
|
hasFlexibleDuration = _ref5.hasFlexibleDuration,
|
|
420
|
-
operating_day_boundary = _ref5.operating_day_boundary
|
|
420
|
+
operating_day_boundary = _ref5.operating_day_boundary,
|
|
421
|
+
maxBlockThreshold = _ref5.maxBlockThreshold;
|
|
421
422
|
var times = resource.times;
|
|
422
423
|
|
|
423
424
|
// 存储所有时间切片
|
|
424
425
|
var timeSlices = [];
|
|
426
|
+
// times 先以开始时间为准做个排序,时间早的先循环
|
|
427
|
+
times.sort(function (a, b) {
|
|
428
|
+
return dayjs(a.start_at).diff(dayjs(b.start_at), 'minute');
|
|
429
|
+
});
|
|
425
430
|
|
|
426
431
|
// 处理每个时间范围
|
|
427
432
|
times.forEach(function (time) {
|
|
@@ -467,6 +472,13 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
467
472
|
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || '23:59')) {
|
|
468
473
|
break;
|
|
469
474
|
}
|
|
475
|
+
// 如果有配置了最低禁止购买时长,则需要判断时间切片是否在最低禁止购买时长内
|
|
476
|
+
// 看一下endTime和operatingBoundaryDateTime哪个早,哪个早用哪个去比较
|
|
477
|
+
var operatingBoundaryDateTimeObj = dayjs("".concat(endTime.format('YYYY-MM-DD'), " ").concat(operatingBoundaryDateTime));
|
|
478
|
+
var earlyTime = endTime.isBefore(operatingBoundaryDateTimeObj) ? endTime : operatingBoundaryDateTimeObj;
|
|
479
|
+
if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0, 'minutes').isAfter(earlyTime)) {
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
470
482
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
471
483
|
timeSlices.push(_objectSpread(_objectSpread({}, timeSlice), {}, {
|
|
472
484
|
// 这里需要补充这个时间段内是否可预约
|
|
@@ -574,7 +586,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
574
586
|
resourcesUseableMap = _ref6.resourcesUseableMap,
|
|
575
587
|
cut_off_time = _ref6.cut_off_time,
|
|
576
588
|
hasFlexibleDuration = _ref6.hasFlexibleDuration,
|
|
577
|
-
operating_day_boundary = _ref6.operating_day_boundary
|
|
589
|
+
operating_day_boundary = _ref6.operating_day_boundary,
|
|
590
|
+
maxBlockThreshold = _ref6.maxBlockThreshold;
|
|
578
591
|
// 获取资源列表
|
|
579
592
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
580
593
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -599,7 +612,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
|
599
612
|
resourcesUseableMap: resourcesUseableMap,
|
|
600
613
|
cut_off_time: cut_off_time,
|
|
601
614
|
hasFlexibleDuration: hasFlexibleDuration,
|
|
602
|
-
operating_day_boundary: operating_day_boundary
|
|
615
|
+
operating_day_boundary: operating_day_boundary,
|
|
616
|
+
maxBlockThreshold: maxBlockThreshold
|
|
603
617
|
}));
|
|
604
618
|
}, []);
|
|
605
619
|
|
|
@@ -144,7 +144,8 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
144
144
|
resources,
|
|
145
145
|
note,
|
|
146
146
|
date,
|
|
147
|
-
relationForms
|
|
147
|
+
relationForms,
|
|
148
|
+
osWarnTips
|
|
148
149
|
} = params;
|
|
149
150
|
let quantity = params.quantity;
|
|
150
151
|
let tempCartItem = this.store.list.find((i) => i._id === _id);
|
|
@@ -202,6 +203,9 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
202
203
|
if (note) {
|
|
203
204
|
tempCartItem = (0, import_utils.formatNoteToCartItem)({ cartItem: tempCartItem, note });
|
|
204
205
|
}
|
|
206
|
+
if (osWarnTips) {
|
|
207
|
+
tempCartItem.osWarnTips = osWarnTips;
|
|
208
|
+
}
|
|
205
209
|
return tempCartItem;
|
|
206
210
|
}
|
|
207
211
|
/**
|
|
@@ -110,6 +110,8 @@ export interface CartItem {
|
|
|
110
110
|
bundle?: any[];
|
|
111
111
|
/** 商品规格信息 */
|
|
112
112
|
options?: any[];
|
|
113
|
+
/** 商品规格选项字符串 */
|
|
114
|
+
product_option_string?: string;
|
|
113
115
|
/** 是否为普通商品 */
|
|
114
116
|
isNormalProduct?: boolean;
|
|
115
117
|
/** 资源ID */
|
|
@@ -142,8 +144,8 @@ export interface CartItem {
|
|
|
142
144
|
_bundleOrigin?: any[];
|
|
143
145
|
/** 商品规格原始数据 */
|
|
144
146
|
_optionsOrigin?: any[];
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
+
/** 操作系统提示 */
|
|
148
|
+
osWarnTips?: string[];
|
|
147
149
|
}
|
|
148
150
|
/**
|
|
149
151
|
* 购物车状态接口
|
|
@@ -217,6 +219,8 @@ export interface IUpdateItemParams {
|
|
|
217
219
|
}[];
|
|
218
220
|
/** 商品组合规格ID */
|
|
219
221
|
product_variant_id?: number;
|
|
222
|
+
/** 操作系统提示 */
|
|
223
|
+
osWarnTips?: string[];
|
|
220
224
|
}
|
|
221
225
|
/**
|
|
222
226
|
* 折扣
|
|
@@ -56,6 +56,7 @@ var formatDateToCartItemOrigin = (params) => {
|
|
|
56
56
|
return origin;
|
|
57
57
|
};
|
|
58
58
|
var deleteTimeFromCartItem = (cartItem) => {
|
|
59
|
+
var _a;
|
|
59
60
|
cartItem.start_date = void 0;
|
|
60
61
|
cartItem.start_time = void 0;
|
|
61
62
|
cartItem.end_date = void 0;
|
|
@@ -65,6 +66,7 @@ var deleteTimeFromCartItem = (cartItem) => {
|
|
|
65
66
|
cartItem._origin.start_time = null;
|
|
66
67
|
cartItem._origin.end_date = null;
|
|
67
68
|
cartItem._origin.end_time = null;
|
|
69
|
+
cartItem.osWarnTips = (_a = cartItem.osWarnTips) == null ? void 0 : _a.filter((item) => !item.includes("pisell2.product.card.closing-soon.warning"));
|
|
68
70
|
return cartItem;
|
|
69
71
|
};
|
|
70
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -105,6 +105,11 @@ export interface ProductData {
|
|
|
105
105
|
type: string;
|
|
106
106
|
/** 值 */
|
|
107
107
|
value: number;
|
|
108
|
+
flexible_config?: {
|
|
109
|
+
is_enable_minimum_duration?: 0 | 1;
|
|
110
|
+
warning_threshold?: number;
|
|
111
|
+
block_threshold?: number;
|
|
112
|
+
};
|
|
108
113
|
};
|
|
109
114
|
/** 商品显示设置 */
|
|
110
115
|
product_display_setting: {
|
|
@@ -139,7 +139,10 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
|
|
|
139
139
|
while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
|
|
140
140
|
for (let i = 0; i < frequency_date.length; i++) {
|
|
141
141
|
const item = frequency_date[i];
|
|
142
|
-
|
|
142
|
+
let _start = startTmp.day(item);
|
|
143
|
+
if (_start.isBefore(startTmp, "day")) {
|
|
144
|
+
_start = _start.add(1, "week");
|
|
145
|
+
}
|
|
143
146
|
let _end = _start.add(scheduleDiff, "second");
|
|
144
147
|
if (_end.isAfter(deadline, "day")) {
|
|
145
148
|
_end = deadline;
|
|
@@ -160,7 +163,7 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
|
|
|
160
163
|
daysArr.push(...getDaysByStartEnd(_start, _end));
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
|
-
startTmp = startTmp.
|
|
166
|
+
startTmp = startTmp.add(frequency, "week");
|
|
164
167
|
}
|
|
165
168
|
return Array.from(new Set(daysArr));
|
|
166
169
|
};
|
|
@@ -585,7 +588,9 @@ function getAllSortedDateRanges(schedules) {
|
|
|
585
588
|
return durationA - durationB;
|
|
586
589
|
});
|
|
587
590
|
const uniqueDateRanges = sortedDateRanges.filter(
|
|
588
|
-
(range, index, self) => index === self.findIndex(
|
|
591
|
+
(range, index, self) => index === self.findIndex(
|
|
592
|
+
(t) => (0, import_dayjs.default)(t.start).isSame((0, import_dayjs.default)(range.start)) && (0, import_dayjs.default)(t.end).isSame((0, import_dayjs.default)(range.end))
|
|
593
|
+
)
|
|
589
594
|
);
|
|
590
595
|
return uniqueDateRanges;
|
|
591
596
|
}
|
|
@@ -645,13 +645,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
645
645
|
this.store.cart.removeItem(n._id);
|
|
646
646
|
});
|
|
647
647
|
}
|
|
648
|
-
const dateRange = this.store.date.getDateRange();
|
|
649
|
-
if ((dateRange == null ? void 0 : dateRange[0]) && !(0, import_dayjs.default)(dateRange[0].date).isSame((0, import_dayjs.default)(date.startTime), "day")) {
|
|
650
|
-
this.setDateRange([
|
|
651
|
-
{ date: (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD"), status: "available", week: "", weekNum: 0 },
|
|
652
|
-
{ date: (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD"), status: "available", week: "", weekNum: 0 }
|
|
653
|
-
]);
|
|
654
|
-
}
|
|
655
648
|
}
|
|
656
649
|
}
|
|
657
650
|
beforeUpdateCart(params, targetCartItem) {
|
|
@@ -855,7 +848,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
855
848
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
856
849
|
const arr = [];
|
|
857
850
|
cartItems.forEach((cartItem) => {
|
|
858
|
-
var _a, _b, _c, _d, _e, _f;
|
|
851
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
859
852
|
let selectedResources = [];
|
|
860
853
|
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
861
854
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
@@ -925,6 +918,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
925
918
|
} else {
|
|
926
919
|
const hasFlexibleDuration = ((_d = (_c = cartItem._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) === "flexible";
|
|
927
920
|
const operating_day_boundary = (_f = (_e = this.shopStore.get("core")) == null ? void 0 : _e.core) == null ? void 0 : _f.operating_day_boundary;
|
|
921
|
+
const maxBlockThreshold = ((_i = (_h = (_g = cartItem._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.flexible_config) == null ? void 0 : _i.is_enable_minimum_duration) ? ((_l = (_k = (_j = cartItem._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.flexible_config) == null ? void 0 : _l.block_threshold) || 0 : 0;
|
|
928
922
|
productResources.forEach((item) => {
|
|
929
923
|
item.renderList = item.renderList.filter((n) => {
|
|
930
924
|
var _a2, _b2, _c2;
|
|
@@ -938,7 +932,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
938
932
|
currentDate: dateRange[0].date,
|
|
939
933
|
hasFlexibleDuration,
|
|
940
934
|
cut_off_time: (_c2 = cartItem._productOrigin) == null ? void 0 : _c2.cut_off_time,
|
|
941
|
-
operating_day_boundary
|
|
935
|
+
operating_day_boundary,
|
|
936
|
+
maxBlockThreshold
|
|
942
937
|
});
|
|
943
938
|
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
944
939
|
});
|
|
@@ -1469,7 +1464,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1469
1464
|
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1470
1465
|
}
|
|
1471
1466
|
);
|
|
1472
|
-
|
|
1467
|
+
let operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
|
|
1468
|
+
let maxBlockThreshold = 0;
|
|
1469
|
+
if (hasFlexibleDuration) {
|
|
1470
|
+
maxBlockThreshold = cartItems.reduce((max, item) => {
|
|
1471
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1472
|
+
if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
|
|
1473
|
+
return Math.max(max, ((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0);
|
|
1474
|
+
}
|
|
1475
|
+
return 0;
|
|
1476
|
+
}, 0);
|
|
1477
|
+
}
|
|
1473
1478
|
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1474
1479
|
resourceIds,
|
|
1475
1480
|
resourcesMap,
|
|
@@ -1479,7 +1484,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1479
1484
|
resourcesUseableMap,
|
|
1480
1485
|
cut_off_time: maxCutOffTime,
|
|
1481
1486
|
hasFlexibleDuration,
|
|
1482
|
-
operating_day_boundary
|
|
1487
|
+
operating_day_boundary,
|
|
1488
|
+
maxBlockThreshold
|
|
1483
1489
|
});
|
|
1484
1490
|
return timeSlots;
|
|
1485
1491
|
}
|
|
@@ -1506,9 +1512,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1506
1512
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1507
1513
|
accountItems.forEach((item, index) => {
|
|
1508
1514
|
var _a2;
|
|
1515
|
+
const osWarnTips = [];
|
|
1509
1516
|
const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
|
|
1510
1517
|
newResources.forEach((resource) => {
|
|
1511
|
-
var _a3, _b2, _c, _d, _e;
|
|
1518
|
+
var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
1512
1519
|
if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
|
|
1513
1520
|
item.duration = {
|
|
1514
1521
|
type: "minutes",
|
|
@@ -1539,14 +1546,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1539
1546
|
formattedEndTime = (0, import_dayjs.default)(endTime);
|
|
1540
1547
|
}
|
|
1541
1548
|
resource.endTime = formattedEndTime.format("YYYY-MM-DD HH:mm");
|
|
1549
|
+
if (((_f = (_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.is_enable_minimum_duration) && (0, import_dayjs.default)(currentStartTime).add(((_i = (_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.flexible_config) == null ? void 0 : _i.warning_threshold) || 0, "minutes").isAfter((0, import_dayjs.default)(formattedEndTime))) {
|
|
1550
|
+
if (!osWarnTips.includes("pisell2.product.card.closing-soon.warning")) {
|
|
1551
|
+
osWarnTips.push("pisell2.product.card.closing-soon.warning");
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1542
1554
|
} else {
|
|
1543
1555
|
resource.startTime = currentStartTime;
|
|
1544
|
-
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(((
|
|
1556
|
+
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(((_k = (_j = item._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.value) || 10, "minutes").format("YYYY-MM-DD HH:mm");
|
|
1545
1557
|
}
|
|
1546
1558
|
});
|
|
1547
1559
|
this.store.cart.updateItem({
|
|
1548
1560
|
_id: item._id,
|
|
1549
|
-
resources: newResources
|
|
1561
|
+
resources: newResources,
|
|
1562
|
+
osWarnTips
|
|
1550
1563
|
});
|
|
1551
1564
|
if (index < accountItems.length - 1 && ((_a2 = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a2.resourceType) === "single") {
|
|
1552
1565
|
currentStartTime = newResources[0].endTime;
|
|
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
|
|
|
79
79
|
* @return {*}
|
|
80
80
|
* @Author: zhiwei.Wang
|
|
81
81
|
*/
|
|
82
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
|
|
82
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
|
|
83
83
|
resource: ResourceItem;
|
|
84
84
|
duration: number;
|
|
85
85
|
split: number;
|
|
@@ -101,6 +101,7 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
|
|
|
101
101
|
type: string;
|
|
102
102
|
time: string;
|
|
103
103
|
} | undefined;
|
|
104
|
+
maxBlockThreshold?: number | undefined;
|
|
104
105
|
}) => TimeSliceItem[];
|
|
105
106
|
/**
|
|
106
107
|
* @title: 获取时间切片列表的交集
|
|
@@ -138,7 +139,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
|
|
|
138
139
|
* @return {*}
|
|
139
140
|
* @Author: zhiwei.Wang
|
|
140
141
|
*/
|
|
141
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
|
|
142
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
|
|
142
143
|
resourceIds: number[];
|
|
143
144
|
resourcesMap: any;
|
|
144
145
|
duration: number;
|
|
@@ -161,6 +162,7 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
161
162
|
type: string;
|
|
162
163
|
time: string;
|
|
163
164
|
} | undefined;
|
|
165
|
+
maxBlockThreshold?: number | undefined;
|
|
164
166
|
}) => any[];
|
|
165
167
|
/**
|
|
166
168
|
* @title: 获取其他人的已选资源
|
|
@@ -334,10 +334,14 @@ var getTimeSlicesByResource = ({
|
|
|
334
334
|
resourcesUseableMap = {},
|
|
335
335
|
cut_off_time,
|
|
336
336
|
hasFlexibleDuration,
|
|
337
|
-
operating_day_boundary
|
|
337
|
+
operating_day_boundary,
|
|
338
|
+
maxBlockThreshold
|
|
338
339
|
}) => {
|
|
339
|
-
|
|
340
|
+
let { times } = resource;
|
|
340
341
|
const timeSlices = [];
|
|
342
|
+
times.sort((a, b) => {
|
|
343
|
+
return (0, import_dayjs.default)(a.start_at).diff((0, import_dayjs.default)(b.start_at), "minute");
|
|
344
|
+
});
|
|
341
345
|
times.forEach((time) => {
|
|
342
346
|
const startTime = (0, import_dayjs.default)(`${time.start_at}`);
|
|
343
347
|
const endTime = (0, import_dayjs.default)(`${time.end_at}`);
|
|
@@ -369,6 +373,11 @@ var getTimeSlicesByResource = ({
|
|
|
369
373
|
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
|
|
370
374
|
break;
|
|
371
375
|
}
|
|
376
|
+
const operatingBoundaryDateTimeObj = (0, import_dayjs.default)(`${endTime.format("YYYY-MM-DD")} ${operatingBoundaryDateTime}`);
|
|
377
|
+
const earlyTime = endTime.isBefore(operatingBoundaryDateTimeObj) ? endTime : operatingBoundaryDateTimeObj;
|
|
378
|
+
if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0, "minutes").isAfter(earlyTime)) {
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
372
381
|
timeSlices.push({
|
|
373
382
|
...timeSlice,
|
|
374
383
|
// 这里需要补充这个时间段内是否可预约
|
|
@@ -428,7 +437,8 @@ var getTimeSlicesByResources = ({
|
|
|
428
437
|
resourcesUseableMap,
|
|
429
438
|
cut_off_time,
|
|
430
439
|
hasFlexibleDuration,
|
|
431
|
-
operating_day_boundary
|
|
440
|
+
operating_day_boundary,
|
|
441
|
+
maxBlockThreshold
|
|
432
442
|
}) => {
|
|
433
443
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
434
444
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -454,7 +464,8 @@ var getTimeSlicesByResources = ({
|
|
|
454
464
|
resourcesUseableMap,
|
|
455
465
|
cut_off_time,
|
|
456
466
|
hasFlexibleDuration,
|
|
457
|
-
operating_day_boundary
|
|
467
|
+
operating_day_boundary,
|
|
468
|
+
maxBlockThreshold
|
|
458
469
|
})
|
|
459
470
|
);
|
|
460
471
|
},
|