@pisell/pisellos 0.0.129 → 0.0.131
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.
|
@@ -1999,11 +1999,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1999
1999
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
2000
2000
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
2001
2001
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
2002
|
-
|
|
2003
|
-
cartItems.
|
|
2002
|
+
// 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
|
|
2003
|
+
var hasFlexibleProduct = cartItems.some(function (item) {
|
|
2004
2004
|
var _item$_productOrigin3;
|
|
2005
|
+
return ((_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.type) === 'flexible';
|
|
2006
|
+
});
|
|
2007
|
+
cartItems.forEach(function (item, index) {
|
|
2008
|
+
var _item$_productOrigin4;
|
|
2005
2009
|
var formatCapacity = formatDefaultCapacitys({
|
|
2006
|
-
capacity: (_item$
|
|
2010
|
+
capacity: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.capacity,
|
|
2007
2011
|
product_bundle: item._origin.product.product_bundle
|
|
2008
2012
|
});
|
|
2009
2013
|
var currentCapacity = getSumCapacity({
|
|
@@ -2019,18 +2023,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2019
2023
|
};
|
|
2020
2024
|
}
|
|
2021
2025
|
if (recordTimeSlots) {
|
|
2022
|
-
var _item$
|
|
2026
|
+
var _item$_productOrigin5, _item$_productOrigin6;
|
|
2023
2027
|
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
2024
2028
|
// 前提:当前资源是单个预约才需要这么做
|
|
2025
|
-
var currentResourceConfig = (_item$
|
|
2029
|
+
var currentResourceConfig = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.product_resource) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.resources) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.find(function (n) {
|
|
2026
2030
|
return n.code === resources_code;
|
|
2027
2031
|
});
|
|
2028
2032
|
var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
|
|
2029
2033
|
// 只有 duration 类商品需要这个操作
|
|
2030
|
-
if (index !== 0 && recordTimeSlots &&
|
|
2031
|
-
var _item$
|
|
2032
|
-
var start_at = dayjs(recordTimeSlots.end_time).add(((_item$
|
|
2033
|
-
var end_at = start_at.add(((_item$
|
|
2034
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin6 = item._productOrigin) !== null && _item$_productOrigin6 !== void 0 && _item$_productOrigin6.duration && !hasFlexibleProduct) {
|
|
2035
|
+
var _item$_productOrigin7, _item$_productOrigin8;
|
|
2036
|
+
var start_at = dayjs(recordTimeSlots.end_time).add(((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) || 10, 'minutes');
|
|
2037
|
+
var end_at = start_at.add(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) || 10, 'minutes');
|
|
2034
2038
|
recordTimeSlots = {
|
|
2035
2039
|
start_time: start_at.format('HH:mm'),
|
|
2036
2040
|
end_time: end_at.format('HH:mm'),
|
|
@@ -2078,12 +2082,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2078
2082
|
errorList.push(item._id);
|
|
2079
2083
|
}
|
|
2080
2084
|
} else {
|
|
2081
|
-
var _item$
|
|
2085
|
+
var _item$_productOrigin9, _productResources$fin;
|
|
2082
2086
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
2083
2087
|
var allCartItems = cloneDeep(_this10.store.cart.getItems());
|
|
2084
2088
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
2085
2089
|
var selectedResources = [];
|
|
2086
|
-
var _resources = cloneDeep(((_item$
|
|
2090
|
+
var _resources = cloneDeep(((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.resources) || []);
|
|
2087
2091
|
var currentResourcesRenderList = [];
|
|
2088
2092
|
_resources.forEach(function (n) {
|
|
2089
2093
|
var _n$renderList;
|
|
@@ -2198,8 +2202,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2198
2202
|
var maxCutOffTime = undefined;
|
|
2199
2203
|
var maxCutOffTimeValue = dayjs();
|
|
2200
2204
|
cartItems.forEach(function (item) {
|
|
2201
|
-
var _item$
|
|
2202
|
-
(_item$
|
|
2205
|
+
var _item$_productOrigin10, _item$_productOrigin11, _item$_productOrigin12, _item$_productOrigin13;
|
|
2206
|
+
(_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || _item$_productOrigin10.forEach(function (n) {
|
|
2203
2207
|
// TODO: 少了个 status 的判断
|
|
2204
2208
|
if (n.code === resources_code) {
|
|
2205
2209
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2212,10 +2216,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2212
2216
|
if (item.resource_id) {
|
|
2213
2217
|
resourceIds.push(item.resource_id);
|
|
2214
2218
|
}
|
|
2215
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2219
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.find(function (n) {
|
|
2216
2220
|
return n.code === resources_code;
|
|
2217
|
-
})) === null || _item$
|
|
2218
|
-
if ((_item$
|
|
2221
|
+
})) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.id;
|
|
2222
|
+
if ((_item$_productOrigin12 = item._productOrigin) !== null && _item$_productOrigin12 !== void 0 && _item$_productOrigin12.cut_off_time && ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.cut_off_time.type) === 'advance') {
|
|
2219
2223
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2220
2224
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2221
2225
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2243,13 +2247,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2243
2247
|
cartItems.forEach(function (item) {
|
|
2244
2248
|
// 单个预约累加账号 多个预约取最大值
|
|
2245
2249
|
if (isSingleResource) {
|
|
2246
|
-
var _item$_productOrigin13;
|
|
2247
|
-
accountDuration += ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) || 10;
|
|
2248
|
-
} else {
|
|
2249
2250
|
var _item$_productOrigin14;
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2251
|
+
accountDuration += ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) || 10;
|
|
2252
|
+
} else {
|
|
2253
|
+
var _item$_productOrigin15;
|
|
2254
|
+
if (accountDuration < (((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) || 10)) {
|
|
2255
|
+
var _item$_productOrigin16;
|
|
2256
|
+
accountDuration = ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) || 10;
|
|
2253
2257
|
}
|
|
2254
2258
|
}
|
|
2255
2259
|
});
|
|
@@ -2286,8 +2290,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2286
2290
|
}
|
|
2287
2291
|
var resourcesUseableMap = {};
|
|
2288
2292
|
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2289
|
-
var _item$
|
|
2290
|
-
return ((_item$
|
|
2293
|
+
var _item$_productOrigin17;
|
|
2294
|
+
return ((_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';
|
|
2291
2295
|
});
|
|
2292
2296
|
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 || (_this$shopStore$get = _this$shopStore$get.operating_day_boundary) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.time;
|
|
2293
2297
|
var timeSlots = getTimeSlicesByResources({
|
|
@@ -2338,9 +2342,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2338
2342
|
var _newResources$;
|
|
2339
2343
|
var newResources = cloneDeep(item._origin.resources);
|
|
2340
2344
|
newResources.forEach(function (resource) {
|
|
2341
|
-
var _item$
|
|
2345
|
+
var _item$_productOrigin18;
|
|
2342
2346
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2343
|
-
if (((_item$
|
|
2347
|
+
if (((_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.type) === 'flexible') {
|
|
2344
2348
|
var _allResources$find;
|
|
2345
2349
|
item.duration = {
|
|
2346
2350
|
type: 'minutes',
|
|
@@ -2366,9 +2370,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2366
2370
|
}
|
|
2367
2371
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2368
2372
|
} else {
|
|
2369
|
-
var _item$
|
|
2373
|
+
var _item$_productOrigin19;
|
|
2370
2374
|
resource.startTime = currentStartTime;
|
|
2371
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2375
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2372
2376
|
}
|
|
2373
2377
|
// delete resource.times;
|
|
2374
2378
|
});
|
|
@@ -1294,6 +1294,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1294
1294
|
const accountList = this.store.accountList.getAccounts();
|
|
1295
1295
|
const selectForCartResources = (cartItems2) => {
|
|
1296
1296
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1297
|
+
const hasFlexibleProduct = cartItems2.some((item) => {
|
|
1298
|
+
var _a2, _b;
|
|
1299
|
+
return ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.type) === "flexible";
|
|
1300
|
+
});
|
|
1297
1301
|
cartItems2.forEach((item, index) => {
|
|
1298
1302
|
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1299
1303
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
@@ -1314,7 +1318,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1314
1318
|
(n) => n.code === resources_code
|
|
1315
1319
|
);
|
|
1316
1320
|
const resourceBookingType = (currentResourceConfig == null ? void 0 : currentResourceConfig.type) || "single";
|
|
1317
|
-
if (index !== 0 && recordTimeSlots &&
|
|
1321
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) && !hasFlexibleProduct) {
|
|
1318
1322
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1319
1323
|
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) || 10,
|
|
1320
1324
|
"minutes"
|