@pisell/pisellos 1.0.2 → 1.0.4
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.
|
@@ -1909,6 +1909,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1909
1909
|
var hasOverlap = !dayjs(item.time.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(item.time.end_at).isBefore(dayjs(timeSlots.end_at));
|
|
1910
1910
|
return hasOverlap ? sum + item.pax : sum;
|
|
1911
1911
|
}, 0);
|
|
1912
|
+
|
|
1913
|
+
// 如果资源是单个预约,并且有 totalCapacity,则认为在当前 timeSlots 资源已经被选择过,就不可用了
|
|
1914
|
+
if (n.resourceType === 'single' && totalCapacity > 0) {
|
|
1915
|
+
return 0; // continue
|
|
1916
|
+
}
|
|
1912
1917
|
var canUseTime = mTimes.find(function (item) {
|
|
1913
1918
|
var _cartItem$_productOri12;
|
|
1914
1919
|
var res = getIsUsableByTimeItem({
|
|
@@ -1999,11 +2004,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1999
2004
|
// timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
|
|
2000
2005
|
// 假设 timeSlots.start_time 是15:40 duration 是 30min
|
|
2001
2006
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
2002
|
-
|
|
2003
|
-
cartItems.
|
|
2007
|
+
// 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
|
|
2008
|
+
var hasFlexibleProduct = cartItems.some(function (item) {
|
|
2004
2009
|
var _item$_productOrigin3;
|
|
2010
|
+
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';
|
|
2011
|
+
});
|
|
2012
|
+
cartItems.forEach(function (item, index) {
|
|
2013
|
+
var _item$_productOrigin4;
|
|
2005
2014
|
var formatCapacity = formatDefaultCapacitys({
|
|
2006
|
-
capacity: (_item$
|
|
2015
|
+
capacity: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.capacity,
|
|
2007
2016
|
product_bundle: item._origin.product.product_bundle
|
|
2008
2017
|
});
|
|
2009
2018
|
var currentCapacity = getSumCapacity({
|
|
@@ -2019,14 +2028,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2019
2028
|
};
|
|
2020
2029
|
}
|
|
2021
2030
|
if (recordTimeSlots) {
|
|
2022
|
-
var _item$
|
|
2031
|
+
var _item$_productOrigin5, _item$_productOrigin6;
|
|
2023
2032
|
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
2024
2033
|
// 前提:当前资源是单个预约才需要这么做
|
|
2025
|
-
var currentResourceConfig = (_item$
|
|
2034
|
+
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
2035
|
return n.code === resources_code;
|
|
2027
2036
|
});
|
|
2028
2037
|
// 只有 duration 类商品需要这个操作
|
|
2029
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$
|
|
2038
|
+
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) {
|
|
2030
2039
|
var _item$_productOrigin7, _item$_productOrigin8;
|
|
2031
2040
|
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');
|
|
2032
2041
|
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');
|
|
@@ -1227,6 +1227,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1227
1227
|
},
|
|
1228
1228
|
0
|
|
1229
1229
|
);
|
|
1230
|
+
if (n.resourceType === "single" && totalCapacity > 0) {
|
|
1231
|
+
continue;
|
|
1232
|
+
}
|
|
1230
1233
|
const canUseTime = mTimes.find((item) => {
|
|
1231
1234
|
var _a2;
|
|
1232
1235
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
@@ -1294,8 +1297,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1294
1297
|
const accountList = this.store.accountList.getAccounts();
|
|
1295
1298
|
const selectForCartResources = (cartItems2) => {
|
|
1296
1299
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1300
|
+
const hasFlexibleProduct = cartItems2.some((item) => {
|
|
1301
|
+
var _a2, _b;
|
|
1302
|
+
return ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.type) === "flexible";
|
|
1303
|
+
});
|
|
1297
1304
|
cartItems2.forEach((item, index) => {
|
|
1298
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m
|
|
1305
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1299
1306
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
1300
1307
|
capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
|
|
1301
1308
|
product_bundle: item._origin.product.product_bundle
|
|
@@ -1313,13 +1320,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1313
1320
|
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
1314
1321
|
(n) => n.code === resources_code
|
|
1315
1322
|
);
|
|
1316
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) &&
|
|
1323
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) && !hasFlexibleProduct) {
|
|
1317
1324
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1318
|
-
((
|
|
1325
|
+
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) || 10,
|
|
1319
1326
|
"minutes"
|
|
1320
1327
|
);
|
|
1321
1328
|
let end_at = start_at.add(
|
|
1322
|
-
((
|
|
1329
|
+
((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.value) || 10,
|
|
1323
1330
|
"minutes"
|
|
1324
1331
|
);
|
|
1325
1332
|
recordTimeSlots = {
|
|
@@ -1373,7 +1380,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1373
1380
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1374
1381
|
let selectedResources = [];
|
|
1375
1382
|
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1376
|
-
((
|
|
1383
|
+
((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []
|
|
1377
1384
|
);
|
|
1378
1385
|
const currentResourcesRenderList = [];
|
|
1379
1386
|
resources2.forEach((n) => {
|
|
@@ -1421,11 +1428,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1421
1428
|
return recordCount >= currentCapacity;
|
|
1422
1429
|
});
|
|
1423
1430
|
});
|
|
1424
|
-
const targetRenderList = (
|
|
1431
|
+
const targetRenderList = (_l = productResources.find(
|
|
1425
1432
|
(n) => n.code === resources_code
|
|
1426
|
-
)) == null ? void 0 :
|
|
1433
|
+
)) == null ? void 0 : _l.renderList;
|
|
1427
1434
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1428
|
-
if ((
|
|
1435
|
+
if ((_m = item._origin.resources) == null ? void 0 : _m.some(
|
|
1429
1436
|
(n) => n.form_id === targetRenderList[0].form_id
|
|
1430
1437
|
)) {
|
|
1431
1438
|
return;
|