@pisell/pisellos 3.0.77 → 3.0.79
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/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +21 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +2 -1
- package/dist/modules/ProductList/index.js +8 -9
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +110 -27
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/Schedule/index.d.ts +9 -0
- package/dist/modules/Schedule/index.js +76 -0
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1131 -13
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +688 -210
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +4 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +11 -6
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +16 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +2 -1
- package/lib/modules/ProductList/index.js +0 -7
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +43 -5
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/Schedule/index.d.ts +9 -0
- package/lib/modules/Schedule/index.js +60 -0
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +673 -8
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +465 -89
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +11 -5
- package/package.json +1 -1
|
@@ -1469,7 +1469,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1469
1469
|
resources.push.apply(resources, _toConsumableArray(dateResources || []));
|
|
1470
1470
|
} else {
|
|
1471
1471
|
var dateList = this.store.date.getDateList();
|
|
1472
|
-
dateList.forEach(function (n) {
|
|
1472
|
+
dateList === null || dateList === void 0 || dateList.forEach(function (n) {
|
|
1473
1473
|
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1474
1474
|
});
|
|
1475
1475
|
}
|
|
@@ -2031,6 +2031,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2031
2031
|
key: "getTimeSlotByAllResources",
|
|
2032
2032
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
2033
2033
|
var _dateRange,
|
|
2034
|
+
_dateRange2,
|
|
2034
2035
|
_this12 = this,
|
|
2035
2036
|
_cartItems$,
|
|
2036
2037
|
_cartItems$2,
|
|
@@ -2086,6 +2087,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2086
2087
|
}
|
|
2087
2088
|
});
|
|
2088
2089
|
}
|
|
2090
|
+
// 检查通过购物车 renderList 加入的资源数据里 times 的正确性,如果不对则需要修正
|
|
2091
|
+
if ((_dateRange2 = dateRange) !== null && _dateRange2 !== void 0 && (_dateRange2 = _dateRange2[0]) !== null && _dateRange2 !== void 0 && _dateRange2.date && resources.length) {
|
|
2092
|
+
var _dateRange3;
|
|
2093
|
+
var currentDate = (_dateRange3 = dateRange) === null || _dateRange3 === void 0 || (_dateRange3 = _dateRange3[0]) === null || _dateRange3 === void 0 ? void 0 : _dateRange3.date;
|
|
2094
|
+
var theDateResources = this.store.date.getResourcesListByDate(currentDate);
|
|
2095
|
+
resources.forEach(function (item) {
|
|
2096
|
+
var noCurrentDateTimes = item.times.some(function (n) {
|
|
2097
|
+
return dayjs(n.start_at).isSame(dayjs(currentDate), 'day');
|
|
2098
|
+
});
|
|
2099
|
+
if (!noCurrentDateTimes) {
|
|
2100
|
+
var _theDateResources$fin;
|
|
2101
|
+
item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin = theDateResources.find(function (n) {
|
|
2102
|
+
return n.id === item.id;
|
|
2103
|
+
})) === null || _theDateResources$fin === void 0 ? void 0 : _theDateResources$fin.times) || [];
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
// 如果依然 resources 空的,则证明他是切换日期了,此时直接从 date 模块里取
|
|
2109
|
+
if (resources.length === 0) {
|
|
2110
|
+
resources.push.apply(resources, _toConsumableArray(this.store.date.getResourcesListByDate(dateRange[0].date) || []));
|
|
2111
|
+
}
|
|
2089
2112
|
var resourcesMap = getResourcesMap(resources);
|
|
2090
2113
|
var duration = 0;
|
|
2091
2114
|
// duration = 不同账号的最长时间
|
|
@@ -2158,12 +2181,26 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2158
2181
|
}
|
|
2159
2182
|
// 计算容量的辅助函数
|
|
2160
2183
|
var calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2184
|
+
var _items$0$_resourceOri;
|
|
2185
|
+
// 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
|
|
2186
|
+
var firstResource = (_items$0$_resourceOri = items[0]._resourceOrigin) === null || _items$0$_resourceOri === void 0 ? void 0 : _items$0$_resourceOri[0].id;
|
|
2187
|
+
var sameResourceLength = items.filter(function (item) {
|
|
2188
|
+
var _item$_resourceOrigin;
|
|
2189
|
+
return ((_item$_resourceOrigin = item._resourceOrigin) === null || _item$_resourceOrigin === void 0 ? void 0 : _item$_resourceOrigin[0].id) === firstResource;
|
|
2190
|
+
}).length;
|
|
2191
|
+
if (sameResourceLength === items.length) {
|
|
2192
|
+
return 1;
|
|
2193
|
+
}
|
|
2194
|
+
// 找出单个购物车里最大的需求 capacity 即可
|
|
2195
|
+
return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
|
|
2196
|
+
return getCapacityInfoByCartItem(item).currentCapacity || 1;
|
|
2197
|
+
})));
|
|
2198
|
+
// return items.reduce((total, item) => {
|
|
2199
|
+
// return total + (getCapacityInfoByCartItem(item).currentCapacity || 0);
|
|
2200
|
+
// }, 0);
|
|
2164
2201
|
};
|
|
2165
2202
|
|
|
2166
|
-
//
|
|
2203
|
+
// 如果是多个人预约,去要求出几个 holder 下最大的商品需求容量capacity
|
|
2167
2204
|
var maxCapacity = 1;
|
|
2168
2205
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2169
2206
|
accountList.forEach(function (account) {
|
|
@@ -2191,13 +2228,257 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2191
2228
|
});
|
|
2192
2229
|
return timeSlots;
|
|
2193
2230
|
}
|
|
2231
|
+
// 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
|
|
2232
|
+
}, {
|
|
2233
|
+
key: "getTimeSlotByAllResourcesForDate",
|
|
2234
|
+
value: function () {
|
|
2235
|
+
var _getTimeSlotByAllResourcesForDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(_ref10) {
|
|
2236
|
+
var _this13 = this,
|
|
2237
|
+
_cartItems$5,
|
|
2238
|
+
_cartItems$6,
|
|
2239
|
+
_this$shopStore$get2;
|
|
2240
|
+
var resources_code, startDate, endDate, resources, cartItems, resourceIds, resourcesTypeId, isSingleResource, maxCutOffTime, maxCutOffTimeValue, duration, accountList, checkDuration, resourcesUseableMap, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold, calculateCapacityFromCartItems, maxCapacity, arr, today, _loop2, i;
|
|
2241
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context25) {
|
|
2242
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2243
|
+
case 0:
|
|
2244
|
+
resources_code = _ref10.resources_code, startDate = _ref10.startDate, endDate = _ref10.endDate;
|
|
2245
|
+
// 如果 end_date 距离start_date小于 30 天,自动追加 end_date 为今天往后的 30 天
|
|
2246
|
+
if (dayjs(endDate).diff(dayjs(startDate), 'day') < 30) {
|
|
2247
|
+
endDate = dayjs(startDate).add(30, 'day').format('YYYY-MM-DD');
|
|
2248
|
+
}
|
|
2249
|
+
// 预请求资源数据,防止日期超过之前选择的范围
|
|
2250
|
+
_context25.next = 4;
|
|
2251
|
+
return this.getAvailableDate({
|
|
2252
|
+
startDate: startDate,
|
|
2253
|
+
endDate: endDate,
|
|
2254
|
+
useCache: true
|
|
2255
|
+
});
|
|
2256
|
+
case 4:
|
|
2257
|
+
// 取出购物车中所有一已选择的第一步资源
|
|
2258
|
+
resources = [];
|
|
2259
|
+
cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2260
|
+
return !isNormalProduct(n._productOrigin);
|
|
2261
|
+
}); // if (cartItems?.[0].start_date) return [];
|
|
2262
|
+
resourceIds = [];
|
|
2263
|
+
resourcesTypeId = undefined;
|
|
2264
|
+
isSingleResource = false; // 找出购物车里最大的 cut_off_time
|
|
2265
|
+
maxCutOffTime = undefined;
|
|
2266
|
+
maxCutOffTimeValue = dayjs();
|
|
2267
|
+
cartItems.forEach(function (item) {
|
|
2268
|
+
var _item$_productOrigin17, _item$_productOrigin18, _item$_productOrigin19, _item$_productOrigin20;
|
|
2269
|
+
(_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.product_resource) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.resources) === null || _item$_productOrigin17 === void 0 || _item$_productOrigin17.forEach(function (n) {
|
|
2270
|
+
// TODO: 少了个 status 的判断
|
|
2271
|
+
if (n.code === resources_code) {
|
|
2272
|
+
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
2273
|
+
isSingleResource = n.type === 'single';
|
|
2274
|
+
}
|
|
2275
|
+
});
|
|
2276
|
+
// item._origin.resources?.forEach((n: any) => {
|
|
2277
|
+
// resourceIds.push(n.relation_id);
|
|
2278
|
+
// });
|
|
2279
|
+
if (item.resource_id && !resourceIds.includes(item.resource_id)) {
|
|
2280
|
+
resourceIds.push(item.resource_id);
|
|
2281
|
+
}
|
|
2282
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.product_resource) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.resources) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.find(function (n) {
|
|
2283
|
+
return n.code === resources_code;
|
|
2284
|
+
})) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.id;
|
|
2285
|
+
if ((_item$_productOrigin19 = item._productOrigin) !== null && _item$_productOrigin19 !== void 0 && _item$_productOrigin19.cut_off_time && ((_item$_productOrigin20 = item._productOrigin) === null || _item$_productOrigin20 === void 0 ? void 0 : _item$_productOrigin20.cut_off_time.type) === 'advance') {
|
|
2286
|
+
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2287
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2288
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
2289
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
});
|
|
2194
2293
|
|
|
2195
|
-
|
|
2294
|
+
// 保护: 如果 resources 为空则直接 return
|
|
2295
|
+
if (resources.length) {
|
|
2296
|
+
_context25.next = 14;
|
|
2297
|
+
break;
|
|
2298
|
+
}
|
|
2299
|
+
return _context25.abrupt("return", []);
|
|
2300
|
+
case 14:
|
|
2301
|
+
duration = 0; // duration = 不同账号的最长时间
|
|
2302
|
+
accountList = this.store.accountList.getAccounts();
|
|
2303
|
+
checkDuration = function checkDuration(cartItems) {
|
|
2304
|
+
var accountDuration = 0;
|
|
2305
|
+
cartItems.forEach(function (item) {
|
|
2306
|
+
// 单个预约累加账号 多个预约取最大值
|
|
2307
|
+
if (isSingleResource) {
|
|
2308
|
+
var _item$_productOrigin21;
|
|
2309
|
+
accountDuration += ((_item$_productOrigin21 = item._productOrigin) === null || _item$_productOrigin21 === void 0 || (_item$_productOrigin21 = _item$_productOrigin21.duration) === null || _item$_productOrigin21 === void 0 ? void 0 : _item$_productOrigin21.value) || 10;
|
|
2310
|
+
} else {
|
|
2311
|
+
var _item$_productOrigin22;
|
|
2312
|
+
if (accountDuration < (((_item$_productOrigin22 = item._productOrigin) === null || _item$_productOrigin22 === void 0 || (_item$_productOrigin22 = _item$_productOrigin22.duration) === null || _item$_productOrigin22 === void 0 ? void 0 : _item$_productOrigin22.value) || 10)) {
|
|
2313
|
+
var _item$_productOrigin23;
|
|
2314
|
+
accountDuration = ((_item$_productOrigin23 = item._productOrigin) === null || _item$_productOrigin23 === void 0 || (_item$_productOrigin23 = _item$_productOrigin23.duration) === null || _item$_productOrigin23 === void 0 ? void 0 : _item$_productOrigin23.value) || 10;
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
});
|
|
2318
|
+
if (accountDuration > duration) {
|
|
2319
|
+
duration = accountDuration;
|
|
2320
|
+
}
|
|
2321
|
+
};
|
|
2322
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2323
|
+
accountList.forEach(function (account) {
|
|
2324
|
+
var cartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2325
|
+
checkDuration(cartItems);
|
|
2326
|
+
});
|
|
2327
|
+
} else {
|
|
2328
|
+
checkDuration(cartItems);
|
|
2329
|
+
}
|
|
2330
|
+
// 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
|
|
2331
|
+
// 同时 session 类商品的流程也不应该调用这个方法
|
|
2332
|
+
if (!(!(cartItems !== null && cartItems !== void 0 && (_cartItems$5 = cartItems[0]) !== null && _cartItems$5 !== void 0 && _cartItems$5.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$6 = cartItems[0]) !== null && _cartItems$6 !== void 0 && _cartItems$6.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration))) {
|
|
2333
|
+
_context25.next = 20;
|
|
2334
|
+
break;
|
|
2335
|
+
}
|
|
2336
|
+
return _context25.abrupt("return", []);
|
|
2337
|
+
case 20:
|
|
2338
|
+
resourcesUseableMap = {};
|
|
2339
|
+
hasFlexibleDuration = cartItems.some(function (item) {
|
|
2340
|
+
var _item$_productOrigin24;
|
|
2341
|
+
return ((_item$_productOrigin24 = item._productOrigin) === null || _item$_productOrigin24 === void 0 || (_item$_productOrigin24 = _item$_productOrigin24.duration) === null || _item$_productOrigin24 === void 0 ? void 0 : _item$_productOrigin24.type) === 'flexible';
|
|
2342
|
+
});
|
|
2343
|
+
operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary; // 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
|
|
2344
|
+
maxBlockThreshold = 0;
|
|
2345
|
+
if (hasFlexibleDuration) {
|
|
2346
|
+
maxBlockThreshold = cartItems.reduce(function (max, item) {
|
|
2347
|
+
var _item$_productOrigin25;
|
|
2348
|
+
// 如果开启了灵活时长商品配置,则取 block_threshold 的值
|
|
2349
|
+
if ((_item$_productOrigin25 = item._productOrigin) !== null && _item$_productOrigin25 !== void 0 && (_item$_productOrigin25 = _item$_productOrigin25.duration) !== null && _item$_productOrigin25 !== void 0 && (_item$_productOrigin25 = _item$_productOrigin25.flexible_config) !== null && _item$_productOrigin25 !== void 0 && _item$_productOrigin25.is_enable_minimum_duration) {
|
|
2350
|
+
var _item$_productOrigin26;
|
|
2351
|
+
return Math.max(max, ((_item$_productOrigin26 = item._productOrigin) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.duration) === null || _item$_productOrigin26 === void 0 || (_item$_productOrigin26 = _item$_productOrigin26.flexible_config) === null || _item$_productOrigin26 === void 0 ? void 0 : _item$_productOrigin26.block_threshold) || 0);
|
|
2352
|
+
}
|
|
2353
|
+
return 0;
|
|
2354
|
+
}, 0);
|
|
2355
|
+
}
|
|
2356
|
+
// 计算容量的辅助函数
|
|
2357
|
+
calculateCapacityFromCartItems = function calculateCapacityFromCartItems(items) {
|
|
2358
|
+
var _items$0$_resourceOri2;
|
|
2359
|
+
// 还需要增加一个判断,maxCapacity 必须是我单个人里选择的资源只有同一种的情况下才可以累加,否则单个账号都是 1
|
|
2360
|
+
var firstResource = (_items$0$_resourceOri2 = items[0]._resourceOrigin) === null || _items$0$_resourceOri2 === void 0 ? void 0 : _items$0$_resourceOri2[0].id;
|
|
2361
|
+
var sameResourceLength = items.filter(function (item) {
|
|
2362
|
+
var _item$_resourceOrigin2;
|
|
2363
|
+
return ((_item$_resourceOrigin2 = item._resourceOrigin) === null || _item$_resourceOrigin2 === void 0 ? void 0 : _item$_resourceOrigin2[0].id) === firstResource;
|
|
2364
|
+
}).length;
|
|
2365
|
+
if (sameResourceLength !== items.length) {
|
|
2366
|
+
return 1;
|
|
2367
|
+
}
|
|
2368
|
+
// 找出单个购物车里最大的需求 capacity 即可
|
|
2369
|
+
return Math.max.apply(Math, _toConsumableArray(items.map(function (item) {
|
|
2370
|
+
return getCapacityInfoByCartItem(item).currentCapacity || 1;
|
|
2371
|
+
})));
|
|
2372
|
+
}; // 如果是多个预约,去要求出几个 holder 下最大的需求容量capacity
|
|
2373
|
+
maxCapacity = 1;
|
|
2374
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2375
|
+
accountList.forEach(function (account) {
|
|
2376
|
+
var accountCartItems = _this13.store.cart.getCartByAccount(account.getId());
|
|
2377
|
+
var currentCapacity = calculateCapacityFromCartItems(accountCartItems);
|
|
2378
|
+
if (currentCapacity > maxCapacity) {
|
|
2379
|
+
maxCapacity = currentCapacity;
|
|
2380
|
+
}
|
|
2381
|
+
});
|
|
2382
|
+
} else {
|
|
2383
|
+
maxCapacity = calculateCapacityFromCartItems(cartItems);
|
|
2384
|
+
}
|
|
2385
|
+
arr = [];
|
|
2386
|
+
today = dayjs().startOf('day'); // 计算 start_date 到 end_date 之间的所有日期,遍历他们并且计算每一天的可用
|
|
2387
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
2388
|
+
var currentDate, theDateResources, resourcesMap, timeSlots;
|
|
2389
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context24) {
|
|
2390
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2391
|
+
case 0:
|
|
2392
|
+
currentDate = i.format('YYYY-MM-DD');
|
|
2393
|
+
theDateResources = _this13.store.date.getResourcesListByDate(currentDate);
|
|
2394
|
+
resources.forEach(function (item) {
|
|
2395
|
+
var _theDateResources$fin2;
|
|
2396
|
+
item.times = (theDateResources === null || theDateResources === void 0 || (_theDateResources$fin2 = theDateResources.find(function (n) {
|
|
2397
|
+
return n.id === item.id;
|
|
2398
|
+
})) === null || _theDateResources$fin2 === void 0 ? void 0 : _theDateResources$fin2.times) || [];
|
|
2399
|
+
});
|
|
2400
|
+
resourcesMap = getResourcesMap(resources); // 如果日期已经过期则直接标记为不可用
|
|
2401
|
+
if (!i.isBefore(today)) {
|
|
2402
|
+
_context24.next = 7;
|
|
2403
|
+
break;
|
|
2404
|
+
}
|
|
2405
|
+
arr.push({
|
|
2406
|
+
date: currentDate,
|
|
2407
|
+
status: 'unavailable',
|
|
2408
|
+
week: i.format('ddd'),
|
|
2409
|
+
weekNum: i.day()
|
|
2410
|
+
});
|
|
2411
|
+
return _context24.abrupt("return", 1);
|
|
2412
|
+
case 7:
|
|
2413
|
+
timeSlots = getTimeSlicesByResources({
|
|
2414
|
+
resourceIds: resourceIds,
|
|
2415
|
+
resourcesMap: resourcesMap,
|
|
2416
|
+
duration: duration,
|
|
2417
|
+
currentDate: currentDate,
|
|
2418
|
+
split: 10,
|
|
2419
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
2420
|
+
capacity: maxCapacity,
|
|
2421
|
+
cut_off_time: maxCutOffTime,
|
|
2422
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
2423
|
+
operating_day_boundary: operating_day_boundary,
|
|
2424
|
+
maxBlockThreshold: maxBlockThreshold
|
|
2425
|
+
});
|
|
2426
|
+
if (timeSlots.length > 0) {
|
|
2427
|
+
arr.push({
|
|
2428
|
+
date: currentDate,
|
|
2429
|
+
status: 'available',
|
|
2430
|
+
week: i.format('ddd'),
|
|
2431
|
+
weekNum: i.day()
|
|
2432
|
+
});
|
|
2433
|
+
} else {
|
|
2434
|
+
arr.push({
|
|
2435
|
+
date: currentDate,
|
|
2436
|
+
status: 'unavailable',
|
|
2437
|
+
week: i.format('ddd'),
|
|
2438
|
+
weekNum: i.day()
|
|
2439
|
+
});
|
|
2440
|
+
}
|
|
2441
|
+
case 9:
|
|
2442
|
+
case "end":
|
|
2443
|
+
return _context24.stop();
|
|
2444
|
+
}
|
|
2445
|
+
}, _loop2);
|
|
2446
|
+
});
|
|
2447
|
+
i = dayjs(startDate);
|
|
2448
|
+
case 32:
|
|
2449
|
+
if (!i.isBefore(dayjs(endDate))) {
|
|
2450
|
+
_context25.next = 39;
|
|
2451
|
+
break;
|
|
2452
|
+
}
|
|
2453
|
+
return _context25.delegateYield(_loop2(), "t0", 34);
|
|
2454
|
+
case 34:
|
|
2455
|
+
if (!_context25.t0) {
|
|
2456
|
+
_context25.next = 36;
|
|
2457
|
+
break;
|
|
2458
|
+
}
|
|
2459
|
+
return _context25.abrupt("continue", 36);
|
|
2460
|
+
case 36:
|
|
2461
|
+
i = i.add(1, 'day');
|
|
2462
|
+
_context25.next = 32;
|
|
2463
|
+
break;
|
|
2464
|
+
case 39:
|
|
2465
|
+
return _context25.abrupt("return", arr);
|
|
2466
|
+
case 40:
|
|
2467
|
+
case "end":
|
|
2468
|
+
return _context25.stop();
|
|
2469
|
+
}
|
|
2470
|
+
}, _callee24, this);
|
|
2471
|
+
}));
|
|
2472
|
+
function getTimeSlotByAllResourcesForDate(_x19) {
|
|
2473
|
+
return _getTimeSlotByAllResourcesForDate.apply(this, arguments);
|
|
2474
|
+
}
|
|
2475
|
+
return getTimeSlotByAllResourcesForDate;
|
|
2476
|
+
}() // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
2196
2477
|
}, {
|
|
2197
2478
|
key: "submitTimeSlot",
|
|
2198
2479
|
value: function submitTimeSlot(timeSlots) {
|
|
2199
|
-
var _this$shopStore$
|
|
2200
|
-
|
|
2480
|
+
var _this$shopStore$get3,
|
|
2481
|
+
_this14 = this;
|
|
2201
2482
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2202
2483
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2203
2484
|
return !isNormalProduct(n._productOrigin);
|
|
@@ -2217,7 +2498,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2217
2498
|
}, {});
|
|
2218
2499
|
|
|
2219
2500
|
// 店铺营业结束时间
|
|
2220
|
-
var operating_day_boundary = (_this$shopStore$
|
|
2501
|
+
var operating_day_boundary = (_this$shopStore$get3 = this.shopStore.get('core')) === null || _this$shopStore$get3 === void 0 || (_this$shopStore$get3 = _this$shopStore$get3.core) === null || _this$shopStore$get3 === void 0 ? void 0 : _this$shopStore$get3.operating_day_boundary;
|
|
2221
2502
|
|
|
2222
2503
|
// 处理每个账号的商品
|
|
2223
2504
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
@@ -2227,10 +2508,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2227
2508
|
var osWarnTips = [];
|
|
2228
2509
|
var newResources = cloneDeep(item._origin.resources);
|
|
2229
2510
|
newResources.forEach(function (resource) {
|
|
2230
|
-
var _item$
|
|
2511
|
+
var _item$_productOrigin27;
|
|
2231
2512
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2232
|
-
if (((_item$
|
|
2233
|
-
var _allResources$find, _item$
|
|
2513
|
+
if (((_item$_productOrigin27 = item._productOrigin) === null || _item$_productOrigin27 === void 0 || (_item$_productOrigin27 = _item$_productOrigin27.duration) === null || _item$_productOrigin27 === void 0 ? void 0 : _item$_productOrigin27.type) === 'flexible') {
|
|
2514
|
+
var _allResources$find, _item$_productOrigin28, _item$_productOrigin29;
|
|
2234
2515
|
item.duration = {
|
|
2235
2516
|
type: 'minutes',
|
|
2236
2517
|
value: 10
|
|
@@ -2240,14 +2521,63 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2240
2521
|
var targetResourceTimes = allResources === null || allResources === void 0 || (_allResources$find = allResources.find(function (n) {
|
|
2241
2522
|
return n.id === resource.id;
|
|
2242
2523
|
})) === null || _allResources$find === void 0 ? void 0 : _allResources$find.times;
|
|
2524
|
+
// 找到最晚的 end_at 还没用,因为可能存在资源工作时间是 10:00-19:00,但是资源的 times 里有 16:30-19:00 被 block 的情况
|
|
2525
|
+
// 所以还需要排除掉 block 时间
|
|
2526
|
+
function getEarliestBlockedStartTime(_ref11) {
|
|
2527
|
+
var _earliestBlockStart;
|
|
2528
|
+
var currentStartTime = _ref11.currentStartTime,
|
|
2529
|
+
times = _ref11.times;
|
|
2530
|
+
var currentStart = dayjs(currentStartTime);
|
|
2531
|
+
var earliestBlockStart;
|
|
2532
|
+
var _iterator3 = _createForOfIteratorHelper(times || []),
|
|
2533
|
+
_step3;
|
|
2534
|
+
try {
|
|
2535
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2536
|
+
var time = _step3.value;
|
|
2537
|
+
var _iterator4 = _createForOfIteratorHelper(time.event_list || []),
|
|
2538
|
+
_step4;
|
|
2539
|
+
try {
|
|
2540
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
2541
|
+
var event = _step4.value;
|
|
2542
|
+
var eventStart = dayjs(event.start_at);
|
|
2543
|
+
var eventEnd = dayjs(event.end_at);
|
|
2544
|
+
if (eventStart.isBefore(currentStart) && eventEnd.isAfter(currentStart)) {
|
|
2545
|
+
return currentStart.format('YYYY-MM-DD HH:mm');
|
|
2546
|
+
}
|
|
2547
|
+
if (eventStart.isAfter(currentStart)) {
|
|
2548
|
+
if (!earliestBlockStart || eventStart.isBefore(earliestBlockStart)) {
|
|
2549
|
+
earliestBlockStart = eventStart;
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2553
|
+
} catch (err) {
|
|
2554
|
+
_iterator4.e(err);
|
|
2555
|
+
} finally {
|
|
2556
|
+
_iterator4.f();
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
} catch (err) {
|
|
2560
|
+
_iterator3.e(err);
|
|
2561
|
+
} finally {
|
|
2562
|
+
_iterator3.f();
|
|
2563
|
+
}
|
|
2564
|
+
return (_earliestBlockStart = earliestBlockStart) === null || _earliestBlockStart === void 0 ? void 0 : _earliestBlockStart.format('YYYY-MM-DD HH:mm');
|
|
2565
|
+
}
|
|
2243
2566
|
var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
|
|
2244
2567
|
return dayjs(curr.end_at).isAfter(dayjs(acc.end_at)) ? curr : acc;
|
|
2245
2568
|
}, targetResourceTimes[0]);
|
|
2569
|
+
var earliestBlockedStartTime = getEarliestBlockedStartTime({
|
|
2570
|
+
currentStartTime: currentStartTime,
|
|
2571
|
+
times: targetResourceTimes
|
|
2572
|
+
});
|
|
2246
2573
|
|
|
2247
2574
|
// 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
|
|
2248
2575
|
var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
|
|
2249
2576
|
var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? '23:59' : operating_day_boundary.time);
|
|
2250
|
-
var
|
|
2577
|
+
var endTimeCandidates = [resourcesEndTime.end_at, operatingBoundaryDateTime].concat(_toConsumableArray(earliestBlockedStartTime ? [earliestBlockedStartTime] : []));
|
|
2578
|
+
var endTime = endTimeCandidates.reduce(function (earliest, value) {
|
|
2579
|
+
return dayjs(value).isBefore(dayjs(earliest)) ? value : earliest;
|
|
2580
|
+
}, endTimeCandidates[0]);
|
|
2251
2581
|
// 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
|
|
2252
2582
|
var formattedEndTime;
|
|
2253
2583
|
if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
|
|
@@ -2260,19 +2590,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2260
2590
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2261
2591
|
// 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
|
|
2262
2592
|
// 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
|
|
2263
|
-
if ((_item$
|
|
2593
|
+
if ((_item$_productOrigin28 = item._productOrigin) !== null && _item$_productOrigin28 !== void 0 && (_item$_productOrigin28 = _item$_productOrigin28.duration) !== null && _item$_productOrigin28 !== void 0 && (_item$_productOrigin28 = _item$_productOrigin28.flexible_config) !== null && _item$_productOrigin28 !== void 0 && _item$_productOrigin28.is_enable_minimum_duration && dayjs(currentStartTime).add(((_item$_productOrigin29 = item._productOrigin) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.duration) === null || _item$_productOrigin29 === void 0 || (_item$_productOrigin29 = _item$_productOrigin29.flexible_config) === null || _item$_productOrigin29 === void 0 ? void 0 : _item$_productOrigin29.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
|
|
2264
2594
|
if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
|
|
2265
2595
|
osWarnTips.push('pisell2.product.card.closing-soon.warning');
|
|
2266
2596
|
}
|
|
2267
2597
|
}
|
|
2268
2598
|
} else {
|
|
2269
|
-
var _item$
|
|
2599
|
+
var _item$_productOrigin30;
|
|
2270
2600
|
resource.startTime = currentStartTime;
|
|
2271
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2601
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin30 = item._productOrigin) === null || _item$_productOrigin30 === void 0 || (_item$_productOrigin30 = _item$_productOrigin30.duration) === null || _item$_productOrigin30 === void 0 ? void 0 : _item$_productOrigin30.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2272
2602
|
}
|
|
2273
2603
|
// delete resource.times;
|
|
2274
2604
|
});
|
|
2275
|
-
|
|
2605
|
+
_this14.store.cart.updateItem({
|
|
2276
2606
|
_id: item._id,
|
|
2277
2607
|
resources: newResources,
|
|
2278
2608
|
osWarnTips: osWarnTips
|
|
@@ -2316,42 +2646,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2316
2646
|
}, {
|
|
2317
2647
|
key: "openProductDetail",
|
|
2318
2648
|
value: function () {
|
|
2319
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2649
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
|
|
2320
2650
|
var targetProductData, newScheduleArr, dateRange;
|
|
2321
|
-
return _regeneratorRuntime().wrap(function
|
|
2322
|
-
while (1) switch (
|
|
2651
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context26) {
|
|
2652
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2323
2653
|
case 0:
|
|
2324
|
-
|
|
2654
|
+
_context26.next = 2;
|
|
2325
2655
|
return this.store.products.getProduct(productId);
|
|
2326
2656
|
case 2:
|
|
2327
|
-
targetProductData =
|
|
2657
|
+
targetProductData = _context26.sent;
|
|
2328
2658
|
if (!targetProductData) {
|
|
2329
|
-
|
|
2659
|
+
_context26.next = 17;
|
|
2330
2660
|
break;
|
|
2331
2661
|
}
|
|
2332
2662
|
this.store.currentProduct = targetProductData;
|
|
2333
2663
|
this.store.currentProductMeta = {};
|
|
2334
2664
|
// 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
|
|
2335
2665
|
if (!targetProductData['schedule.ids']) {
|
|
2336
|
-
|
|
2666
|
+
_context26.next = 12;
|
|
2337
2667
|
break;
|
|
2338
2668
|
}
|
|
2339
2669
|
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
2340
2670
|
if (!this.store.currentProductMeta) this.store.currentProductMeta = {};
|
|
2341
2671
|
this.store.currentProductMeta.schedule = newScheduleArr;
|
|
2342
|
-
|
|
2672
|
+
_context26.next = 17;
|
|
2343
2673
|
break;
|
|
2344
2674
|
case 12:
|
|
2345
2675
|
if (!targetProductData.duration) {
|
|
2346
|
-
|
|
2676
|
+
_context26.next = 17;
|
|
2347
2677
|
break;
|
|
2348
2678
|
}
|
|
2349
2679
|
dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
|
|
2350
2680
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
2351
|
-
|
|
2681
|
+
_context26.next = 16;
|
|
2352
2682
|
break;
|
|
2353
2683
|
}
|
|
2354
|
-
return
|
|
2684
|
+
return _context26.abrupt("return");
|
|
2355
2685
|
case 16:
|
|
2356
2686
|
// this.store.date.getResourceDates({
|
|
2357
2687
|
// query: {
|
|
@@ -2367,11 +2697,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2367
2697
|
});
|
|
2368
2698
|
case 17:
|
|
2369
2699
|
case "end":
|
|
2370
|
-
return
|
|
2700
|
+
return _context26.stop();
|
|
2371
2701
|
}
|
|
2372
|
-
},
|
|
2702
|
+
}, _callee25, this);
|
|
2373
2703
|
}));
|
|
2374
|
-
function openProductDetail(
|
|
2704
|
+
function openProductDetail(_x20) {
|
|
2375
2705
|
return _openProductDetail.apply(this, arguments);
|
|
2376
2706
|
}
|
|
2377
2707
|
return openProductDetail;
|
|
@@ -2388,14 +2718,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2388
2718
|
// 通过商品和 schedule 来获取视频可用的时间片、时间片内资源可用的数据
|
|
2389
2719
|
}, {
|
|
2390
2720
|
key: "getTimeslotBySchedule",
|
|
2391
|
-
value: function getTimeslotBySchedule(
|
|
2721
|
+
value: function getTimeslotBySchedule(_ref12) {
|
|
2392
2722
|
var _this$store$currentPr2,
|
|
2393
2723
|
_targetProductData$pr,
|
|
2394
|
-
|
|
2395
|
-
var date =
|
|
2396
|
-
scheduleIds =
|
|
2397
|
-
resources =
|
|
2398
|
-
product =
|
|
2724
|
+
_this15 = this;
|
|
2725
|
+
var date = _ref12.date,
|
|
2726
|
+
scheduleIds = _ref12.scheduleIds,
|
|
2727
|
+
resources = _ref12.resources,
|
|
2728
|
+
product = _ref12.product;
|
|
2399
2729
|
var targetProduct = this.store.currentProduct;
|
|
2400
2730
|
// 如果外面传递了product 优先用外面的
|
|
2401
2731
|
var targetProductData = product || targetProduct;
|
|
@@ -2429,25 +2759,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2429
2759
|
if (!aIsCombined && bIsCombined) return -1;
|
|
2430
2760
|
return 0;
|
|
2431
2761
|
});
|
|
2432
|
-
|
|
2433
|
-
// 找到当前商品下第一个启用的资源id
|
|
2434
|
-
var firstEnabledResourceId = targetProductData === null || targetProductData === void 0 || (_targetProductData$pr = targetProductData.product_resource) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.resources) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.find(function (n) {
|
|
2762
|
+
var enabledResourceTypeConfigs = (targetProductData === null || targetProductData === void 0 || (_targetProductData$pr = targetProductData.product_resource) === null || _targetProductData$pr === void 0 || (_targetProductData$pr = _targetProductData$pr.resources) === null || _targetProductData$pr === void 0 ? void 0 : _targetProductData$pr.filter(function (n) {
|
|
2435
2763
|
return n.status === 1;
|
|
2436
|
-
}))
|
|
2764
|
+
})) || [];
|
|
2765
|
+
var resourceTypeConfigById = new Map(enabledResourceTypeConfigs.map(function (n) {
|
|
2766
|
+
return [n.id, n];
|
|
2767
|
+
}));
|
|
2437
2768
|
|
|
2438
2769
|
// 计算每个日程切片下日程可用的资源的容量总和
|
|
2439
2770
|
var formatScheduleTimeSlots = scheduleTimeSlots.map(function (item) {
|
|
2440
2771
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
2441
2772
|
var resourcesUseableMap = {};
|
|
2442
|
-
var
|
|
2443
|
-
|
|
2444
|
-
|
|
2773
|
+
var statsByResourceType = {};
|
|
2774
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
2775
|
+
statsByResourceType[cfg.id] = {
|
|
2776
|
+
count: 0,
|
|
2777
|
+
left: 0,
|
|
2778
|
+
summaryCount: 0,
|
|
2779
|
+
summaryConfigCount: 0
|
|
2780
|
+
};
|
|
2781
|
+
});
|
|
2782
|
+
|
|
2445
2783
|
// 遍历所有资源
|
|
2446
2784
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2785
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
|
|
2786
|
+
if (!currentResourceTypeConfig) return;
|
|
2787
|
+
|
|
2447
2788
|
// 遍历所有资源的上工时间片
|
|
2448
|
-
var
|
|
2449
|
-
var
|
|
2450
|
-
var currentResourcesTimeSlotCanUsedArr = [];
|
|
2789
|
+
var currentResourceMaxRemainingCapacity = 0;
|
|
2790
|
+
var isAllTimeSlicesUsable = true;
|
|
2451
2791
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
2452
2792
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
2453
2793
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
@@ -2455,14 +2795,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2455
2795
|
// n.start_at 是 2025-06-30 15:00 end_at 2025-06-30 17:00
|
|
2456
2796
|
// item.start 是 2025-06-30 16:00 item.end 是 2025-06-30 19:00
|
|
2457
2797
|
// 需要判断 n.start_at 和 n.end_at 是否在 item.start 和 item.end 之间
|
|
2458
|
-
//
|
|
2798
|
+
// 如果是仅用于计算的资源, n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
|
|
2799
|
+
// https://project.feishu.cn/v2qint/bug/detail/6657165010
|
|
2459
2800
|
var mTimes = m.times.filter(function (n) {
|
|
2460
|
-
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
|
|
2801
|
+
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || m.onlyComputed && dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
|
|
2461
2802
|
});
|
|
2462
2803
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
2463
2804
|
if (mTimes.length === 0) {
|
|
2464
2805
|
return;
|
|
2465
2806
|
}
|
|
2807
|
+
|
|
2808
|
+
// 统计该资源类型在这个时间片的“配置容量”(无占用),只统计上工的资源
|
|
2809
|
+
if (!m.onlyComputed) {
|
|
2810
|
+
var _currentStats = statsByResourceType[m.form_id] || {
|
|
2811
|
+
count: 0,
|
|
2812
|
+
left: 0,
|
|
2813
|
+
summaryCount: 0,
|
|
2814
|
+
summaryConfigCount: 0
|
|
2815
|
+
};
|
|
2816
|
+
if (currentResourceTypeConfig.type === 'multiple') _currentStats.summaryConfigCount += m.capacity;else _currentStats.summaryConfigCount += 1;
|
|
2817
|
+
statsByResourceType[m.form_id] = _currentStats;
|
|
2818
|
+
}
|
|
2466
2819
|
mTimes.forEach(function (childTiem) {
|
|
2467
2820
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
2468
2821
|
var res = getIsUsableByTimeItem({
|
|
@@ -2481,32 +2834,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2481
2834
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2482
2835
|
resourcesUseableMap[m.id] = res.usable;
|
|
2483
2836
|
}
|
|
2484
|
-
if (res.usable
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
|
|
2488
|
-
currentResourcesSummaryCount = res.remainingCapacity;
|
|
2837
|
+
if (!res.usable) isAllTimeSlicesUsable = false;
|
|
2838
|
+
if (res.usable && !m.onlyComputed) {
|
|
2839
|
+
if (res.remainingCapacity > currentResourceMaxRemainingCapacity) currentResourceMaxRemainingCapacity = res.remainingCapacity;
|
|
2489
2840
|
}
|
|
2490
|
-
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
2491
2841
|
});
|
|
2492
|
-
|
|
2493
|
-
if (
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2842
|
+
if (!isAllTimeSlicesUsable) return;
|
|
2843
|
+
if (m.onlyComputed) return;
|
|
2844
|
+
var currentStats = statsByResourceType[m.form_id] || {
|
|
2845
|
+
count: 0,
|
|
2846
|
+
left: 0,
|
|
2847
|
+
summaryCount: 0,
|
|
2848
|
+
summaryConfigCount: 0
|
|
2849
|
+
};
|
|
2850
|
+
currentStats.left += 1;
|
|
2851
|
+
if (currentResourceTypeConfig.type === 'multiple') {
|
|
2852
|
+
currentStats.summaryCount += currentResourceMaxRemainingCapacity;
|
|
2853
|
+
if (currentResourceMaxRemainingCapacity > currentStats.count) currentStats.count = currentResourceMaxRemainingCapacity;
|
|
2854
|
+
} else {
|
|
2855
|
+
// 单个预约:一个资源只计 1,不关心剩余容量
|
|
2856
|
+
currentStats.summaryCount += 1;
|
|
2857
|
+
if (currentStats.count < 1) currentStats.count = 1;
|
|
2505
2858
|
}
|
|
2859
|
+
statsByResourceType[m.form_id] = currentStats;
|
|
2506
2860
|
});
|
|
2507
2861
|
// 容量检测
|
|
2508
|
-
var cartItems =
|
|
2862
|
+
var cartItems = _this15.store.cart.getItems();
|
|
2509
2863
|
productResources.forEach(function (n) {
|
|
2864
|
+
var currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
|
|
2865
|
+
if (!currentResourceTypeConfig) return;
|
|
2866
|
+
var currentStats = statsByResourceType[n.id] || {
|
|
2867
|
+
count: 0,
|
|
2868
|
+
left: 0,
|
|
2869
|
+
summaryCount: 0
|
|
2870
|
+
};
|
|
2871
|
+
|
|
2510
2872
|
// 单个预约检测规则:
|
|
2511
2873
|
// 1、跟我一样的商品同一时间在购物车里不可以超过我最少的那种资源的关联的资源个数
|
|
2512
2874
|
// 2、跟我不一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,她配置了几个资源的个数+我配置了几个资源的个数,然后购物车里有几个这样的商品,对应的资源做一个去重,不超过这个去重以后的总数
|
|
@@ -2517,20 +2879,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2517
2879
|
var _m$_productOrigin, _targetProductData$id;
|
|
2518
2880
|
return ((_m$_productOrigin = m._productOrigin) === null || _m$_productOrigin === void 0 || (_m$_productOrigin = _m$_productOrigin.id) === null || _m$_productOrigin === void 0 ? void 0 : _m$_productOrigin.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id = targetProductData.id) === null || _targetProductData$id === void 0 ? void 0 : _targetProductData$id.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
|
|
2519
2881
|
});
|
|
2520
|
-
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length >
|
|
2521
|
-
|
|
2522
|
-
count = 0;
|
|
2523
|
-
summaryCount = 0;
|
|
2882
|
+
if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
|
|
2883
|
+
currentStats.left = 0;
|
|
2884
|
+
currentStats.count = 0;
|
|
2885
|
+
currentStats.summaryCount = 0;
|
|
2524
2886
|
}
|
|
2525
2887
|
// 规则 2
|
|
2526
2888
|
var otherCartItems = cartItems.filter(function (m) {
|
|
2527
|
-
var _m$_productOrigin2, _targetProductData$id2;
|
|
2528
|
-
|
|
2889
|
+
var _m$_productOrigin2, _targetProductData$id2, _m$_productOrigin3;
|
|
2890
|
+
var isTimeMatch = ((_m$_productOrigin2 = m._productOrigin) === null || _m$_productOrigin2 === void 0 || (_m$_productOrigin2 = _m$_productOrigin2.id) === null || _m$_productOrigin2 === void 0 ? void 0 : _m$_productOrigin2.toString()) !== (targetProductData === null || targetProductData === void 0 || (_targetProductData$id2 = targetProductData.id) === null || _targetProductData$id2 === void 0 ? void 0 : _targetProductData$id2.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
|
|
2891
|
+
var isResourceMatch = (_m$_productOrigin3 = m._productOrigin) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.product_resource) === null || _m$_productOrigin3 === void 0 || (_m$_productOrigin3 = _m$_productOrigin3.resources) === null || _m$_productOrigin3 === void 0 ? void 0 : _m$_productOrigin3.find(function (m) {
|
|
2892
|
+
return m.type === n.type && m.status === 1;
|
|
2893
|
+
});
|
|
2894
|
+
return isTimeMatch && isResourceMatch;
|
|
2529
2895
|
});
|
|
2530
2896
|
otherCartItems.forEach(function (m) {
|
|
2531
|
-
var _m$
|
|
2532
|
-
var sameTypeResources = (_m$
|
|
2533
|
-
return m.type === n.type;
|
|
2897
|
+
var _m$_productOrigin4;
|
|
2898
|
+
var sameTypeResources = (_m$_productOrigin4 = m._productOrigin) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.product_resource) === null || _m$_productOrigin4 === void 0 || (_m$_productOrigin4 = _m$_productOrigin4.resources) === null || _m$_productOrigin4 === void 0 ? void 0 : _m$_productOrigin4.find(function (m) {
|
|
2899
|
+
return m.type === n.type && m.status === 1;
|
|
2534
2900
|
});
|
|
2535
2901
|
var sameTypeResourcesSet = new Set([].concat(_toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.optional_resource) || []), _toConsumableArray((sameTypeResources === null || sameTypeResources === void 0 ? void 0 : sameTypeResources.default_resource) || [])));
|
|
2536
2902
|
// 把sameTypeResourcesSet 加到currentResourcesSet
|
|
@@ -2539,7 +2905,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2539
2905
|
});
|
|
2540
2906
|
});
|
|
2541
2907
|
// 先确定是否每一个currentResourcesSet在这个时间点的 event_list 都是空的,如果不是空的还需要把他踢出currentResourcesSet
|
|
2542
|
-
var currentDataResources =
|
|
2908
|
+
var currentDataResources = _this15.store.date.getResourcesListByDate(dayjs(item.start).format('YYYY-MM-DD'));
|
|
2543
2909
|
currentDataResources === null || currentDataResources === void 0 || currentDataResources.forEach(function (m) {
|
|
2544
2910
|
if (currentResourcesSet.has(m.id)) {
|
|
2545
2911
|
var mTimes = m.times.filter(function (n) {
|
|
@@ -2553,16 +2919,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2553
2919
|
}
|
|
2554
2920
|
});
|
|
2555
2921
|
if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
|
|
2556
|
-
|
|
2557
|
-
count = 0;
|
|
2558
|
-
summaryCount = 0;
|
|
2922
|
+
currentStats.left = 0;
|
|
2923
|
+
currentStats.count = 0;
|
|
2924
|
+
currentStats.summaryCount = 0;
|
|
2559
2925
|
}
|
|
2560
2926
|
} else {
|
|
2561
2927
|
// 多个预约的检测规则:
|
|
2562
2928
|
// 规则1、跟我一样的商品同一时间在购物车需要的容量总数不可以超过我配置的资源的 capacity 之和
|
|
2563
2929
|
var _sameCartItems = cartItems.filter(function (m) {
|
|
2564
|
-
var _m$
|
|
2565
|
-
return ((_m$
|
|
2930
|
+
var _m$_productOrigin5, _targetProductData$id3;
|
|
2931
|
+
return ((_m$_productOrigin5 = m._productOrigin) === null || _m$_productOrigin5 === void 0 || (_m$_productOrigin5 = _m$_productOrigin5.id) === null || _m$_productOrigin5 === void 0 ? void 0 : _m$_productOrigin5.toString()) === (targetProductData === null || targetProductData === void 0 || (_targetProductData$id3 = targetProductData.id) === null || _targetProductData$id3 === void 0 ? void 0 : _targetProductData$id3.toString()) && "".concat(m.start_date, " ").concat(m.start_time) === item.start && "".concat(m.start_date, " ").concat(m.end_time) === item.end;
|
|
2566
2932
|
});
|
|
2567
2933
|
var sameCartNeedCapacity = _sameCartItems.reduce(function (acc, curr) {
|
|
2568
2934
|
return acc + getCapacityInfoByCartItem(curr).currentCapacity;
|
|
@@ -2571,9 +2937,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2571
2937
|
return !curr.onlyComputed ? acc + curr.capacity || 0 : acc;
|
|
2572
2938
|
}, 0);
|
|
2573
2939
|
if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
|
|
2574
|
-
|
|
2575
|
-
count = 0;
|
|
2576
|
-
summaryCount = 0;
|
|
2940
|
+
currentStats.left = 0;
|
|
2941
|
+
currentStats.count = 0;
|
|
2942
|
+
currentStats.summaryCount = 0;
|
|
2577
2943
|
}
|
|
2578
2944
|
// 规则2、不管是不是跟我一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,把所有购物车的 capacity 之和 和 所有当前类型资源的 capacity 之和比较,如果超过了resourcesCapacity,则不可用
|
|
2579
2945
|
// const otherCartItems = cartItems.filter((m) => m._productOrigin?.id?.toString() !== targetProductData?.id?.toString() && m.start_time === item.start && m.end_time === item.end);
|
|
@@ -2587,8 +2953,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2587
2953
|
return !m.onlyComputed;
|
|
2588
2954
|
}));
|
|
2589
2955
|
otherSameTimesCartItems.forEach(function (m) {
|
|
2590
|
-
var _m$
|
|
2591
|
-
var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$
|
|
2956
|
+
var _m$_productOrigin6;
|
|
2957
|
+
var productResources = getResourcesByProduct(getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []), ((_m$_productOrigin6 = m._productOrigin) === null || _m$_productOrigin6 === void 0 || (_m$_productOrigin6 = _m$_productOrigin6.product_resource) === null || _m$_productOrigin6 === void 0 ? void 0 : _m$_productOrigin6.resources) || [], selectedResources, 1);
|
|
2592
2958
|
productResources.forEach(function (m) {
|
|
2593
2959
|
if (m.id === n.id) {
|
|
2594
2960
|
m.renderList.forEach(function (n) {
|
|
@@ -2635,22 +3001,61 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2635
3001
|
}, 0);
|
|
2636
3002
|
// 如果已使用容量超过了当前类型资源的容量,则不可用
|
|
2637
3003
|
if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
|
|
2638
|
-
|
|
2639
|
-
count = 0;
|
|
2640
|
-
summaryCount = 0;
|
|
3004
|
+
currentStats.left = 0;
|
|
3005
|
+
currentStats.count = 0;
|
|
3006
|
+
currentStats.summaryCount = 0;
|
|
2641
3007
|
}
|
|
2642
3008
|
}
|
|
3009
|
+
statsByResourceType[n.id] = currentStats;
|
|
2643
3010
|
});
|
|
2644
3011
|
var startDayJs = dayjs(item.start);
|
|
2645
3012
|
var endDayJs = dayjs(item.end);
|
|
3013
|
+
|
|
3014
|
+
// 选择“瓶颈资源类型”:multiple 取 summaryCount 最小,single 取 left 最小
|
|
3015
|
+
var bottleneckResourceTypeId;
|
|
3016
|
+
var bottleneckValue = Infinity;
|
|
3017
|
+
enabledResourceTypeConfigs.forEach(function (cfg) {
|
|
3018
|
+
var stats = statsByResourceType[cfg.id] || {
|
|
3019
|
+
count: 0,
|
|
3020
|
+
left: 0,
|
|
3021
|
+
summaryCount: 0,
|
|
3022
|
+
summaryConfigCount: 0
|
|
3023
|
+
};
|
|
3024
|
+
var value = cfg.type === 'multiple' ? stats.summaryCount : stats.left;
|
|
3025
|
+
if (value < bottleneckValue) {
|
|
3026
|
+
bottleneckValue = value;
|
|
3027
|
+
bottleneckResourceTypeId = cfg.id;
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
var bottleneckStats = bottleneckResourceTypeId !== undefined ? statsByResourceType[bottleneckResourceTypeId] || {
|
|
3031
|
+
count: 0,
|
|
3032
|
+
left: 0,
|
|
3033
|
+
summaryCount: 0,
|
|
3034
|
+
summaryConfigCount: 0
|
|
3035
|
+
} : {
|
|
3036
|
+
count: 0,
|
|
3037
|
+
left: 0,
|
|
3038
|
+
summaryCount: 0,
|
|
3039
|
+
summaryConfigCount: 0
|
|
3040
|
+
};
|
|
3041
|
+
var bottleneckConfig = bottleneckResourceTypeId !== undefined ? resourceTypeConfigById.get(bottleneckResourceTypeId) : undefined;
|
|
3042
|
+
var status = 'sold_out';
|
|
3043
|
+
if (bottleneckStats.left === 0) status = 'sold_out';else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0) status = 'sold_out';else if (bottleneckConfig.type === 'multiple') {
|
|
3044
|
+
var usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
|
|
3045
|
+
if (usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.summaryCount > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
3046
|
+
} else {
|
|
3047
|
+
var _usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
|
|
3048
|
+
if (_usageRatio > 0.5) status = 'lots_of_space';else if (bottleneckStats.count > 0) status = 'filling_up_fast';else status = 'sold_out';
|
|
3049
|
+
}
|
|
2646
3050
|
return {
|
|
2647
3051
|
start_time: startDayJs.format('HH:mm'),
|
|
2648
3052
|
end_time: endDayJs.format('HH:mm'),
|
|
2649
3053
|
start_at: startDayJs,
|
|
2650
3054
|
end_at: endDayJs,
|
|
2651
|
-
count: count,
|
|
2652
|
-
left:
|
|
2653
|
-
summaryCount: summaryCount
|
|
3055
|
+
count: bottleneckStats.count,
|
|
3056
|
+
left: bottleneckStats.left,
|
|
3057
|
+
summaryCount: bottleneckStats.summaryCount,
|
|
3058
|
+
status: status
|
|
2654
3059
|
};
|
|
2655
3060
|
});
|
|
2656
3061
|
return formatScheduleTimeSlots;
|
|
@@ -2691,7 +3096,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2691
3096
|
}));
|
|
2692
3097
|
|
|
2693
3098
|
// 与其他资源的时间段求交集
|
|
2694
|
-
var
|
|
3099
|
+
var _loop3 = function _loop3() {
|
|
2695
3100
|
var currentResourceSlots = allTimeSlots[i];
|
|
2696
3101
|
var intersections = [];
|
|
2697
3102
|
|
|
@@ -2720,7 +3125,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2720
3125
|
}));
|
|
2721
3126
|
};
|
|
2722
3127
|
for (var i = 1; i < allTimeSlots.length; i++) {
|
|
2723
|
-
if (
|
|
3128
|
+
if (_loop3()) continue;
|
|
2724
3129
|
}
|
|
2725
3130
|
|
|
2726
3131
|
// 格式化返回结果
|
|
@@ -2736,7 +3141,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2736
3141
|
}, {
|
|
2737
3142
|
key: "checkMaxDurationCapacity",
|
|
2738
3143
|
value: function checkMaxDurationCapacity() {
|
|
2739
|
-
var
|
|
3144
|
+
var _this16 = this;
|
|
2740
3145
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
2741
3146
|
return !isNormalProduct(item._productOrigin);
|
|
2742
3147
|
});
|
|
@@ -2775,6 +3180,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2775
3180
|
itemsByResourceType[resourceCode] = [];
|
|
2776
3181
|
}
|
|
2777
3182
|
// 避免重复添加同一个商品
|
|
3183
|
+
// 如果之前添加过的依赖相同资源的跟我现在是同一个 holder,也不需要重复添加
|
|
3184
|
+
if (itemsByResourceType[resourceCode].find(function (item) {
|
|
3185
|
+
return item.holder_id === cartItem.holder_id;
|
|
3186
|
+
})) {
|
|
3187
|
+
return;
|
|
3188
|
+
}
|
|
2778
3189
|
if (!itemsByResourceType[resourceCode].find(function (item) {
|
|
2779
3190
|
return item._id === cartItem._id;
|
|
2780
3191
|
})) {
|
|
@@ -2826,7 +3237,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2826
3237
|
var processedCartItemIds = new Set();
|
|
2827
3238
|
|
|
2828
3239
|
// 先检查所有资源类型,收集可用数量信息
|
|
2829
|
-
var
|
|
3240
|
+
var _loop4 = function _loop4() {
|
|
2830
3241
|
var _resourceTypeConfig;
|
|
2831
3242
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
2832
3243
|
resourceCode = _Object$entries$_i[0],
|
|
@@ -2873,12 +3284,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2873
3284
|
// 检查资源类型(单个预约 vs 多个预约)
|
|
2874
3285
|
// 从商品配置中获取资源类型信息
|
|
2875
3286
|
var resourceTypeConfig = null;
|
|
2876
|
-
var
|
|
2877
|
-
|
|
3287
|
+
var _iterator5 = _createForOfIteratorHelper(items),
|
|
3288
|
+
_step5;
|
|
2878
3289
|
try {
|
|
2879
|
-
for (
|
|
3290
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
2880
3291
|
var _cartItem$_productOri12;
|
|
2881
|
-
var cartItem =
|
|
3292
|
+
var cartItem = _step5.value;
|
|
2882
3293
|
if ((_cartItem$_productOri12 = cartItem._productOrigin) !== null && _cartItem$_productOri12 !== void 0 && (_cartItem$_productOri12 = _cartItem$_productOri12.product_resource) !== null && _cartItem$_productOri12 !== void 0 && _cartItem$_productOri12.resources) {
|
|
2883
3294
|
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(function (r) {
|
|
2884
3295
|
return r.code === resourceCode && r.status === 1;
|
|
@@ -2887,9 +3298,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2887
3298
|
}
|
|
2888
3299
|
}
|
|
2889
3300
|
} catch (err) {
|
|
2890
|
-
|
|
3301
|
+
_iterator5.e(err);
|
|
2891
3302
|
} finally {
|
|
2892
|
-
|
|
3303
|
+
_iterator5.f();
|
|
2893
3304
|
}
|
|
2894
3305
|
var isMultipleBooking = ((_resourceTypeConfig = resourceTypeConfig) === null || _resourceTypeConfig === void 0 ? void 0 : _resourceTypeConfig.type) === 'multiple';
|
|
2895
3306
|
var totalAvailable;
|
|
@@ -2942,7 +3353,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2942
3353
|
}));
|
|
2943
3354
|
|
|
2944
3355
|
// 找到所有资源都可用的时间段
|
|
2945
|
-
var commonTimeSlots =
|
|
3356
|
+
var commonTimeSlots = _this16.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
2946
3357
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
2947
3358
|
if (commonTimeSlots.length === 0) {
|
|
2948
3359
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -2973,7 +3384,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2973
3384
|
},
|
|
2974
3385
|
_ret2;
|
|
2975
3386
|
for (var _i = 0, _Object$entries = Object.entries(itemsByResourceType); _i < _Object$entries.length; _i++) {
|
|
2976
|
-
_ret2 =
|
|
3387
|
+
_ret2 = _loop4();
|
|
2977
3388
|
if (_ret2) return _ret2.v;
|
|
2978
3389
|
}
|
|
2979
3390
|
|
|
@@ -3017,7 +3428,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3017
3428
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3018
3429
|
});
|
|
3019
3430
|
// 检查每个时间段是否有足够的资源容量
|
|
3020
|
-
var
|
|
3431
|
+
var _loop5 = function _loop5() {
|
|
3021
3432
|
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
3022
3433
|
timeSlotKey = _Object$entries2$_i[0],
|
|
3023
3434
|
itemsInTimeSlot = _Object$entries2$_i[1];
|
|
@@ -3035,8 +3446,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3035
3446
|
var resourcesIdSet = new Set();
|
|
3036
3447
|
|
|
3037
3448
|
// 获取资源数据
|
|
3038
|
-
var dateRange =
|
|
3039
|
-
var resourcesDates =
|
|
3449
|
+
var dateRange = _this16.store.date.getDateRange();
|
|
3450
|
+
var resourcesDates = _this16.store.date.getDateList();
|
|
3040
3451
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3041
3452
|
return n.date === startDate;
|
|
3042
3453
|
});
|
|
@@ -3073,7 +3484,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3073
3484
|
},
|
|
3074
3485
|
_ret3;
|
|
3075
3486
|
for (var _i2 = 0, _Object$entries2 = Object.entries(cartItemsByTimeSlot); _i2 < _Object$entries2.length; _i2++) {
|
|
3076
|
-
_ret3 =
|
|
3487
|
+
_ret3 = _loop5();
|
|
3077
3488
|
if (_ret3 === 0) continue;
|
|
3078
3489
|
if (_ret3) return _ret3.v;
|
|
3079
3490
|
}
|
|
@@ -3092,17 +3503,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3092
3503
|
*/
|
|
3093
3504
|
}, {
|
|
3094
3505
|
key: "convertProductToCartItem",
|
|
3095
|
-
value: function convertProductToCartItem(
|
|
3096
|
-
var product =
|
|
3097
|
-
date =
|
|
3098
|
-
account =
|
|
3099
|
-
var
|
|
3100
|
-
bundle =
|
|
3101
|
-
options =
|
|
3102
|
-
origin =
|
|
3103
|
-
product_variant_id =
|
|
3104
|
-
|
|
3105
|
-
quantity =
|
|
3506
|
+
value: function convertProductToCartItem(_ref13) {
|
|
3507
|
+
var product = _ref13.product,
|
|
3508
|
+
date = _ref13.date,
|
|
3509
|
+
account = _ref13.account;
|
|
3510
|
+
var _ref14 = product || {},
|
|
3511
|
+
bundle = _ref14.bundle,
|
|
3512
|
+
options = _ref14.options,
|
|
3513
|
+
origin = _ref14.origin,
|
|
3514
|
+
product_variant_id = _ref14.product_variant_id,
|
|
3515
|
+
_ref14$quantity = _ref14.quantity,
|
|
3516
|
+
quantity = _ref14$quantity === void 0 ? 1 : _ref14$quantity;
|
|
3106
3517
|
|
|
3107
3518
|
// 处理商品数据,类似 addProductToCart 中的逻辑
|
|
3108
3519
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
@@ -3157,11 +3568,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3157
3568
|
}
|
|
3158
3569
|
}, {
|
|
3159
3570
|
key: "checkMaxDurationCapacityForDetailNums",
|
|
3160
|
-
value: function checkMaxDurationCapacityForDetailNums(
|
|
3161
|
-
var
|
|
3162
|
-
var product =
|
|
3163
|
-
date =
|
|
3164
|
-
account =
|
|
3571
|
+
value: function checkMaxDurationCapacityForDetailNums(_ref15) {
|
|
3572
|
+
var _this17 = this;
|
|
3573
|
+
var product = _ref15.product,
|
|
3574
|
+
date = _ref15.date,
|
|
3575
|
+
account = _ref15.account;
|
|
3165
3576
|
var cartItems = this.store.cart.getItems().filter(function (item) {
|
|
3166
3577
|
return !isNormalProduct(item._productOrigin);
|
|
3167
3578
|
});
|
|
@@ -3259,7 +3670,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3259
3670
|
var processedCartItemIds = new Set();
|
|
3260
3671
|
|
|
3261
3672
|
// 先检查所有资源类型,收集可用数量信息
|
|
3262
|
-
var
|
|
3673
|
+
var _loop6 = function _loop6() {
|
|
3263
3674
|
var _resourceTypeConfig2;
|
|
3264
3675
|
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
3265
3676
|
resourceCode = _Object$entries3$_i[0],
|
|
@@ -3306,12 +3717,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3306
3717
|
// 检查资源类型(单个预约 vs 多个预约)
|
|
3307
3718
|
// 从商品配置中获取资源类型信息
|
|
3308
3719
|
var resourceTypeConfig = null;
|
|
3309
|
-
var
|
|
3310
|
-
|
|
3720
|
+
var _iterator6 = _createForOfIteratorHelper(items),
|
|
3721
|
+
_step6;
|
|
3311
3722
|
try {
|
|
3312
|
-
for (
|
|
3723
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
3313
3724
|
var _cartItem$_productOri15;
|
|
3314
|
-
var cartItem =
|
|
3725
|
+
var cartItem = _step6.value;
|
|
3315
3726
|
if ((_cartItem$_productOri15 = cartItem._productOrigin) !== null && _cartItem$_productOri15 !== void 0 && (_cartItem$_productOri15 = _cartItem$_productOri15.product_resource) !== null && _cartItem$_productOri15 !== void 0 && _cartItem$_productOri15.resources) {
|
|
3316
3727
|
resourceTypeConfig = cartItem._productOrigin.product_resource.resources.find(function (r) {
|
|
3317
3728
|
return r.code === resourceCode && r.status === 1;
|
|
@@ -3320,9 +3731,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3320
3731
|
}
|
|
3321
3732
|
}
|
|
3322
3733
|
} catch (err) {
|
|
3323
|
-
|
|
3734
|
+
_iterator6.e(err);
|
|
3324
3735
|
} finally {
|
|
3325
|
-
|
|
3736
|
+
_iterator6.f();
|
|
3326
3737
|
}
|
|
3327
3738
|
var isMultipleBooking = ((_resourceTypeConfig2 = resourceTypeConfig) === null || _resourceTypeConfig2 === void 0 ? void 0 : _resourceTypeConfig2.type) === 'multiple';
|
|
3328
3739
|
var totalAvailable;
|
|
@@ -3375,7 +3786,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3375
3786
|
}));
|
|
3376
3787
|
|
|
3377
3788
|
// 找到所有资源都可用的时间段
|
|
3378
|
-
var commonTimeSlots =
|
|
3789
|
+
var commonTimeSlots = _this17.findCommonAvailableTimeSlots(resourcesOfThisType);
|
|
3379
3790
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonTimeSlots);
|
|
3380
3791
|
if (commonTimeSlots.length === 0) {
|
|
3381
3792
|
console.log("\u8D44\u6E90\u7C7B\u578B ".concat(resourceCode, " \u6CA1\u6709\u516C\u5171\u53EF\u7528\u65F6\u95F4\u6BB5"));
|
|
@@ -3406,7 +3817,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3406
3817
|
},
|
|
3407
3818
|
_ret4;
|
|
3408
3819
|
for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
|
|
3409
|
-
_ret4 =
|
|
3820
|
+
_ret4 = _loop6();
|
|
3410
3821
|
if (_ret4) return _ret4.v;
|
|
3411
3822
|
}
|
|
3412
3823
|
|
|
@@ -3450,7 +3861,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3450
3861
|
cartItemsByTimeSlot[timeSlotKey].push(cartItem);
|
|
3451
3862
|
});
|
|
3452
3863
|
// 检查每个时间段是否有足够的资源容量
|
|
3453
|
-
var
|
|
3864
|
+
var _loop7 = function _loop7() {
|
|
3454
3865
|
var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2),
|
|
3455
3866
|
timeSlotKey = _Object$entries4$_i[0],
|
|
3456
3867
|
itemsInTimeSlot = _Object$entries4$_i[1];
|
|
@@ -3469,7 +3880,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3469
3880
|
|
|
3470
3881
|
// 获取资源数据
|
|
3471
3882
|
// const dateRange = this.store.date.getDateRange();
|
|
3472
|
-
var resourcesDates =
|
|
3883
|
+
var resourcesDates = _this17.store.date.getDateList();
|
|
3473
3884
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
3474
3885
|
return n.date === startDate;
|
|
3475
3886
|
});
|
|
@@ -3506,7 +3917,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3506
3917
|
},
|
|
3507
3918
|
_ret5;
|
|
3508
3919
|
for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
|
|
3509
|
-
_ret5 =
|
|
3920
|
+
_ret5 = _loop7();
|
|
3510
3921
|
if (_ret5 === 0) continue;
|
|
3511
3922
|
if (_ret5) return _ret5.v;
|
|
3512
3923
|
}
|
|
@@ -3539,41 +3950,41 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3539
3950
|
}, {
|
|
3540
3951
|
key: "getProductTypeById",
|
|
3541
3952
|
value: function () {
|
|
3542
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3953
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
3543
3954
|
var productData, _productData$schedule;
|
|
3544
|
-
return _regeneratorRuntime().wrap(function
|
|
3545
|
-
while (1) switch (
|
|
3955
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
3956
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
3546
3957
|
case 0:
|
|
3547
|
-
|
|
3958
|
+
_context27.next = 2;
|
|
3548
3959
|
return this.store.products.getProduct(id);
|
|
3549
3960
|
case 2:
|
|
3550
|
-
productData =
|
|
3961
|
+
productData = _context27.sent;
|
|
3551
3962
|
if (!productData) {
|
|
3552
|
-
|
|
3963
|
+
_context27.next = 9;
|
|
3553
3964
|
break;
|
|
3554
3965
|
}
|
|
3555
3966
|
if (!productData.duration) {
|
|
3556
|
-
|
|
3967
|
+
_context27.next = 6;
|
|
3557
3968
|
break;
|
|
3558
3969
|
}
|
|
3559
|
-
return
|
|
3970
|
+
return _context27.abrupt("return", 'duration');
|
|
3560
3971
|
case 6:
|
|
3561
3972
|
if (!((_productData$schedule = productData['schedule.ids']) !== null && _productData$schedule !== void 0 && _productData$schedule.length)) {
|
|
3562
|
-
|
|
3973
|
+
_context27.next = 8;
|
|
3563
3974
|
break;
|
|
3564
3975
|
}
|
|
3565
|
-
return
|
|
3976
|
+
return _context27.abrupt("return", 'session');
|
|
3566
3977
|
case 8:
|
|
3567
|
-
return
|
|
3978
|
+
return _context27.abrupt("return", 'normal');
|
|
3568
3979
|
case 9:
|
|
3569
|
-
return
|
|
3980
|
+
return _context27.abrupt("return", 'normal');
|
|
3570
3981
|
case 10:
|
|
3571
3982
|
case "end":
|
|
3572
|
-
return
|
|
3983
|
+
return _context27.stop();
|
|
3573
3984
|
}
|
|
3574
|
-
},
|
|
3985
|
+
}, _callee26, this);
|
|
3575
3986
|
}));
|
|
3576
|
-
function getProductTypeById(
|
|
3987
|
+
function getProductTypeById(_x21) {
|
|
3577
3988
|
return _getProductTypeById.apply(this, arguments);
|
|
3578
3989
|
}
|
|
3579
3990
|
return getProductTypeById;
|
|
@@ -3693,12 +4104,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3693
4104
|
}, {
|
|
3694
4105
|
key: "getTimeslotsScheduleByDateRange",
|
|
3695
4106
|
value: (function () {
|
|
3696
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4107
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref16) {
|
|
3697
4108
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i5, _dates, date;
|
|
3698
|
-
return _regeneratorRuntime().wrap(function
|
|
3699
|
-
while (1) switch (
|
|
4109
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
4110
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3700
4111
|
case 0:
|
|
3701
|
-
startDate =
|
|
4112
|
+
startDate = _ref16.startDate, endDate = _ref16.endDate, scheduleIds = _ref16.scheduleIds, resources = _ref16.resources;
|
|
3702
4113
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
3703
4114
|
startDate: startDate,
|
|
3704
4115
|
endDate: endDate,
|
|
@@ -3723,14 +4134,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3723
4134
|
resources: resources
|
|
3724
4135
|
});
|
|
3725
4136
|
}
|
|
3726
|
-
return
|
|
4137
|
+
return _context28.abrupt("return", results);
|
|
3727
4138
|
case 9:
|
|
3728
4139
|
case "end":
|
|
3729
|
-
return
|
|
4140
|
+
return _context28.stop();
|
|
3730
4141
|
}
|
|
3731
|
-
},
|
|
4142
|
+
}, _callee27, this);
|
|
3732
4143
|
}));
|
|
3733
|
-
function getTimeslotsScheduleByDateRange(
|
|
4144
|
+
function getTimeslotsScheduleByDateRange(_x22) {
|
|
3734
4145
|
return _getTimeslotsScheduleByDateRange.apply(this, arguments);
|
|
3735
4146
|
}
|
|
3736
4147
|
return getTimeslotsScheduleByDateRange;
|
|
@@ -3738,7 +4149,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3738
4149
|
}, {
|
|
3739
4150
|
key: "getAvailableDateForSessionOptimize",
|
|
3740
4151
|
value: function () {
|
|
3741
|
-
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4152
|
+
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
3742
4153
|
var _this$store$currentPr3, _this$store$currentPr4, _tempProducts;
|
|
3743
4154
|
var params,
|
|
3744
4155
|
startDate,
|
|
@@ -3757,12 +4168,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3757
4168
|
openResources,
|
|
3758
4169
|
allProductResources,
|
|
3759
4170
|
targetSchedules,
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
return _regeneratorRuntime().wrap(function
|
|
3763
|
-
while (1) switch (
|
|
4171
|
+
_loop8,
|
|
4172
|
+
_args30 = arguments;
|
|
4173
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context30) {
|
|
4174
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3764
4175
|
case 0:
|
|
3765
|
-
params =
|
|
4176
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
3766
4177
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
3767
4178
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
3768
4179
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -3787,15 +4198,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3787
4198
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
3788
4199
|
cache = (_this$store$currentPr3 = this.store.currentProductMeta) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3['timeSlotBySchedule'];
|
|
3789
4200
|
if (!cache) {
|
|
3790
|
-
|
|
4201
|
+
_context30.next = 13;
|
|
3791
4202
|
break;
|
|
3792
4203
|
}
|
|
3793
4204
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
3794
|
-
|
|
4205
|
+
_context30.next = 13;
|
|
3795
4206
|
break;
|
|
3796
4207
|
}
|
|
3797
4208
|
this.store.date.setDateList(cache.dateList);
|
|
3798
|
-
return
|
|
4209
|
+
return _context30.abrupt("return", {
|
|
3799
4210
|
dateList: cache.dateList,
|
|
3800
4211
|
firstAvailableDate: cache.firstAvailableDate
|
|
3801
4212
|
});
|
|
@@ -3805,7 +4216,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3805
4216
|
schedule = (_this$store$currentPr4 = this.store.currentProductMeta) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4['schedule'];
|
|
3806
4217
|
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
3807
4218
|
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
3808
|
-
|
|
4219
|
+
_context30.next = 19;
|
|
3809
4220
|
return this.store.date.fetchResourceDates({
|
|
3810
4221
|
query: {
|
|
3811
4222
|
start_date: startDate || '',
|
|
@@ -3814,7 +4225,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3814
4225
|
}
|
|
3815
4226
|
});
|
|
3816
4227
|
case 19:
|
|
3817
|
-
res =
|
|
4228
|
+
res = _context30.sent;
|
|
3818
4229
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3819
4230
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3820
4231
|
dates = [];
|
|
@@ -3823,7 +4234,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3823
4234
|
openResources = ((_tempProducts = tempProducts) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.product_resource) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.resources) === null || _tempProducts === void 0 ? void 0 : _tempProducts.filter(function (m) {
|
|
3824
4235
|
return m.status === 1;
|
|
3825
4236
|
})) || []; // res.data 返回的一定是启用商品的资源列表,不需要再过滤了
|
|
3826
|
-
allProductResources = sortCombinedResources(res.data); // allProductResources 需要根据商品里的资源的单个预约多个预约补充resourceType
|
|
4237
|
+
allProductResources = cloneDeep(sortCombinedResources(res.data) || []); // allProductResources 需要根据商品里的资源的单个预约多个预约补充resourceType
|
|
3827
4238
|
allProductResources.forEach(function (m) {
|
|
3828
4239
|
var _tempProducts2;
|
|
3829
4240
|
var resource = (_tempProducts2 = tempProducts) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.product_resource) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.resources) === null || _tempProducts2 === void 0 ? void 0 : _tempProducts2.find(function (n) {
|
|
@@ -3834,13 +4245,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3834
4245
|
}
|
|
3835
4246
|
});
|
|
3836
4247
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
3837
|
-
|
|
3838
|
-
var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
|
|
3839
|
-
return _regeneratorRuntime().wrap(function
|
|
3840
|
-
while (1) switch (
|
|
4248
|
+
_loop8 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop8() {
|
|
4249
|
+
var currentDateStr, status, summaryCount, availableCount, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse, dateStatus, usageRatio;
|
|
4250
|
+
return _regeneratorRuntime().wrap(function _loop8$(_context29) {
|
|
4251
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3841
4252
|
case 0:
|
|
3842
4253
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
3843
|
-
status = 'available';
|
|
4254
|
+
status = 'available';
|
|
4255
|
+
summaryCount = 0;
|
|
4256
|
+
availableCount = 0; // 1. 检查商品的提前量等情况是否满足
|
|
3844
4257
|
_checkSessionProductL = checkSessionProductLeadTime(tempProducts), latestStartDate = _checkSessionProductL.latestStartDate, earliestEndDate = _checkSessionProductL.earliestEndDate;
|
|
3845
4258
|
if (latestStartDate || earliestEndDate) {
|
|
3846
4259
|
// 如果时间在最早开始时间之前,则设置为不可用
|
|
@@ -3866,17 +4279,48 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3866
4279
|
if (status === 'available') {
|
|
3867
4280
|
minTimeMaxTime = calcMinTimeMaxTimeBySchedules(targetSchedules, {}, currentDateStr);
|
|
3868
4281
|
scheduleTimeSlots = getAllSortedDateRanges(minTimeMaxTime); // 同一天内多个时间片下 只要有一个可用则视为可用
|
|
3869
|
-
timesSlotCanUse =
|
|
4282
|
+
timesSlotCanUse = false;
|
|
4283
|
+
scheduleTimeSlots.forEach(function (item) {
|
|
3870
4284
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
3871
4285
|
var resourcesUseableMap = {};
|
|
3872
4286
|
// 遍历产品下启用的资源
|
|
3873
4287
|
// 必须要保证每种类型的资源都至少有一个能够在对应时间点被选择
|
|
3874
|
-
|
|
4288
|
+
// 求出第一个资源的剩余量和总量
|
|
4289
|
+
// 剩余量=每个资源在每个时间片内剩余之和
|
|
4290
|
+
// 总量=每个资源在每个时间片内资源总量之和
|
|
4291
|
+
var isAllResourceTypesUseable = true;
|
|
4292
|
+
openResources.forEach(function (resource) {
|
|
4293
|
+
var _resource$renderList;
|
|
4294
|
+
// if (!isAllResourceTypesUseable) return;
|
|
4295
|
+
|
|
3875
4296
|
// 获取当前资源类型的资源列表
|
|
3876
4297
|
var currentResourcesList = allProductResources.filter(function (n) {
|
|
3877
4298
|
return n.form_id === resource.resource_type_id;
|
|
3878
4299
|
});
|
|
3879
|
-
|
|
4300
|
+
// 如果resource.renderList里含有 onlyComputed 的数据,需要把 currentResourcesList 的数据也修正回来
|
|
4301
|
+
(_resource$renderList = resource.renderList) === null || _resource$renderList === void 0 || _resource$renderList.forEach(function (item) {
|
|
4302
|
+
if (item.onlyComputed) {
|
|
4303
|
+
var targetIndex = currentResourcesList.findIndex(function (n) {
|
|
4304
|
+
return n.id === item.id;
|
|
4305
|
+
});
|
|
4306
|
+
if (targetIndex && targetIndex !== -1) {
|
|
4307
|
+
currentResourcesList[targetIndex].onlyComputed = true;
|
|
4308
|
+
}
|
|
4309
|
+
}
|
|
4310
|
+
});
|
|
4311
|
+
// 可能存在 renderList 没有的情况,则需要判断 resource.optional_resource 和 resource.default_resource 是否存在那个资源,如果不存在也打上 onlyComputed 的标记
|
|
4312
|
+
currentResourcesList.forEach(function (item) {
|
|
4313
|
+
var _resource$optional_re, _resource$default_res;
|
|
4314
|
+
if (!((_resource$optional_re = resource.optional_resource) !== null && _resource$optional_re !== void 0 && _resource$optional_re.includes(item.id)) && !((_resource$default_res = resource.default_resource) !== null && _resource$default_res !== void 0 && _resource$default_res.includes(item.id))) {
|
|
4315
|
+
item.onlyComputed = true;
|
|
4316
|
+
}
|
|
4317
|
+
});
|
|
4318
|
+
// currentResourcesList 排序,onlyComputed 的资源排在前面先计算
|
|
4319
|
+
currentResourcesList.sort(function (a, b) {
|
|
4320
|
+
return a.onlyComputed ? -1 : 1;
|
|
4321
|
+
});
|
|
4322
|
+
var isAnyResourceUseableInType = false;
|
|
4323
|
+
currentResourcesList === null || currentResourcesList === void 0 || currentResourcesList.forEach(function (m) {
|
|
3880
4324
|
// 遍历所有资源的上工时间片
|
|
3881
4325
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
3882
4326
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
@@ -3884,12 +4328,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3884
4328
|
var mTimes = m.times.filter(function (n) {
|
|
3885
4329
|
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
|
|
3886
4330
|
});
|
|
4331
|
+
|
|
3887
4332
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
3888
|
-
if (mTimes.length === 0)
|
|
3889
|
-
|
|
4333
|
+
if (mTimes.length === 0) return;
|
|
4334
|
+
// 如果资源可用则把他的容量纳入总计
|
|
4335
|
+
if (!m.onlyComputed) {
|
|
4336
|
+
if (resource.type === 'multiple') {
|
|
4337
|
+
summaryCount += m.capacity;
|
|
4338
|
+
} else {
|
|
4339
|
+
summaryCount += 1;
|
|
4340
|
+
}
|
|
3890
4341
|
}
|
|
3891
|
-
var
|
|
4342
|
+
var isAnyTimeSliceUseable = false;
|
|
4343
|
+
mTimes.forEach(function (childTiem) {
|
|
3892
4344
|
var _tempProducts3;
|
|
4345
|
+
if (isAnyTimeSliceUseable) return;
|
|
4346
|
+
|
|
3893
4347
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
3894
4348
|
var res = getIsUsableByTimeItem({
|
|
3895
4349
|
timeSlice: {
|
|
@@ -3907,11 +4361,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3907
4361
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
3908
4362
|
resourcesUseableMap[m.id] = res.usable;
|
|
3909
4363
|
}
|
|
3910
|
-
|
|
4364
|
+
if (res.usable && !m.onlyComputed) {
|
|
4365
|
+
isAnyTimeSliceUseable = true;
|
|
4366
|
+
if (resource.type === 'multiple') {
|
|
4367
|
+
availableCount += res.remainingCapacity;
|
|
4368
|
+
} else {
|
|
4369
|
+
availableCount += 1;
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
;
|
|
3911
4373
|
});
|
|
3912
|
-
|
|
4374
|
+
if (isAnyTimeSliceUseable) isAnyResourceUseableInType = true;
|
|
3913
4375
|
});
|
|
4376
|
+
if (!isAnyResourceUseableInType) isAllResourceTypesUseable = false;
|
|
3914
4377
|
});
|
|
4378
|
+
if (isAllResourceTypesUseable) timesSlotCanUse = true;
|
|
3915
4379
|
});
|
|
3916
4380
|
if (!timesSlotCanUse) {
|
|
3917
4381
|
status = 'unavailable';
|
|
@@ -3920,41 +4384,55 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3920
4384
|
firstAvailableDate = currentDateStr;
|
|
3921
4385
|
}
|
|
3922
4386
|
}
|
|
4387
|
+
// 状态: lots_of_space: availableCount / summaryCount > 0.5
|
|
4388
|
+
// filling_up_fast: availableCount / summaryCount <= 0.5 && availableCount > 0
|
|
4389
|
+
// sold_out: summaryCount = 0
|
|
4390
|
+
// unavailable: summaryCount > 0 && availableCount = 0
|
|
4391
|
+
|
|
4392
|
+
if (status === 'unavailable') {
|
|
4393
|
+
// dateStatus = 'unavailable'
|
|
4394
|
+
if (availableCount === 0 && summaryCount > 0) dateStatus = 'sold_out';else dateStatus = 'unavailable';
|
|
4395
|
+
} else {
|
|
4396
|
+
usageRatio = availableCount / summaryCount;
|
|
4397
|
+
if (usageRatio > 0.5) dateStatus = 'lots_of_space';else dateStatus = 'filling_up_fast';
|
|
4398
|
+
}
|
|
3923
4399
|
dates.push({
|
|
3924
4400
|
date: dayjs(currentDate).format('YYYY-MM-DD'),
|
|
3925
4401
|
week: dayjs(currentDate).format('ddd'),
|
|
3926
4402
|
weekNum: dayjs(currentDate).day(),
|
|
3927
|
-
|
|
4403
|
+
summaryCount: summaryCount,
|
|
4404
|
+
availableCount: availableCount,
|
|
4405
|
+
status: dateStatus
|
|
3928
4406
|
});
|
|
3929
4407
|
|
|
3930
4408
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
3931
4409
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 31)) {
|
|
3932
|
-
|
|
4410
|
+
_context29.next = 12;
|
|
3933
4411
|
break;
|
|
3934
4412
|
}
|
|
3935
|
-
return
|
|
3936
|
-
case
|
|
4413
|
+
return _context29.abrupt("return", 1);
|
|
4414
|
+
case 12:
|
|
3937
4415
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
3938
|
-
case
|
|
4416
|
+
case 13:
|
|
3939
4417
|
case "end":
|
|
3940
|
-
return
|
|
4418
|
+
return _context29.stop();
|
|
3941
4419
|
}
|
|
3942
|
-
},
|
|
4420
|
+
}, _loop8);
|
|
3943
4421
|
});
|
|
3944
4422
|
case 28:
|
|
3945
4423
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
3946
|
-
|
|
4424
|
+
_context30.next = 34;
|
|
3947
4425
|
break;
|
|
3948
4426
|
}
|
|
3949
|
-
return
|
|
4427
|
+
return _context30.delegateYield(_loop8(), "t0", 30);
|
|
3950
4428
|
case 30:
|
|
3951
|
-
if (!
|
|
3952
|
-
|
|
4429
|
+
if (!_context30.t0) {
|
|
4430
|
+
_context30.next = 32;
|
|
3953
4431
|
break;
|
|
3954
4432
|
}
|
|
3955
|
-
return
|
|
4433
|
+
return _context30.abrupt("break", 34);
|
|
3956
4434
|
case 32:
|
|
3957
|
-
|
|
4435
|
+
_context30.next = 28;
|
|
3958
4436
|
break;
|
|
3959
4437
|
case 34:
|
|
3960
4438
|
// 最终把资源数据也加到日期内
|
|
@@ -3969,15 +4447,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3969
4447
|
startDate: startDate,
|
|
3970
4448
|
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
3971
4449
|
};
|
|
3972
|
-
return
|
|
4450
|
+
return _context30.abrupt("return", {
|
|
3973
4451
|
dateList: dates,
|
|
3974
4452
|
firstAvailableDate: firstAvailableDate
|
|
3975
4453
|
});
|
|
3976
4454
|
case 39:
|
|
3977
4455
|
case "end":
|
|
3978
|
-
return
|
|
4456
|
+
return _context30.stop();
|
|
3979
4457
|
}
|
|
3980
|
-
},
|
|
4458
|
+
}, _callee28, this);
|
|
3981
4459
|
}));
|
|
3982
4460
|
function getAvailableDateForSessionOptimize() {
|
|
3983
4461
|
return _getAvailableDateForSessionOptimize.apply(this, arguments);
|
|
@@ -4024,18 +4502,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4024
4502
|
}, {
|
|
4025
4503
|
key: "getContactInfo",
|
|
4026
4504
|
value: (function () {
|
|
4027
|
-
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4028
|
-
return _regeneratorRuntime().wrap(function
|
|
4029
|
-
while (1) switch (
|
|
4505
|
+
var _getContactInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4506
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context31) {
|
|
4507
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4030
4508
|
case 0:
|
|
4031
|
-
return
|
|
4509
|
+
return _context31.abrupt("return", this.request.get('/customer/metadata', params));
|
|
4032
4510
|
case 1:
|
|
4033
4511
|
case "end":
|
|
4034
|
-
return
|
|
4512
|
+
return _context31.stop();
|
|
4035
4513
|
}
|
|
4036
|
-
},
|
|
4514
|
+
}, _callee29, this);
|
|
4037
4515
|
}));
|
|
4038
|
-
function getContactInfo(
|
|
4516
|
+
function getContactInfo(_x23) {
|
|
4039
4517
|
return _getContactInfo.apply(this, arguments);
|
|
4040
4518
|
}
|
|
4041
4519
|
return getContactInfo;
|