@pisell/pisellos 0.0.131 → 0.0.134
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/solution/BookingByStep/index.js +13 -4
- package/dist/solution/BookingByStep/utils/resources.d.ts +8 -2
- package/dist/solution/BookingByStep/utils/resources.js +2 -1
- package/lib/solution/BookingByStep/index.js +16 -11
- package/lib/solution/BookingByStep/utils/resources.d.ts +8 -2
- package/lib/solution/BookingByStep/utils/resources.js +2 -1
- package/package.json +1 -1
|
@@ -1568,7 +1568,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1568
1568
|
} else {
|
|
1569
1569
|
var _cartItem$_productOri4, _this9$shopStore$get;
|
|
1570
1570
|
var hasFlexibleDuration = ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.type) === 'flexible';
|
|
1571
|
-
var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0
|
|
1571
|
+
var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.operating_day_boundary;
|
|
1572
1572
|
productResources.forEach(function (item) {
|
|
1573
1573
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1574
1574
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
@@ -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({
|
|
@@ -2293,7 +2298,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2293
2298
|
var _item$_productOrigin17;
|
|
2294
2299
|
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';
|
|
2295
2300
|
});
|
|
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
|
|
2301
|
+
var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
|
|
2297
2302
|
var timeSlots = getTimeSlicesByResources({
|
|
2298
2303
|
resourceIds: resourceIds,
|
|
2299
2304
|
resourcesMap: resourcesMap,
|
|
@@ -2333,7 +2338,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2333
2338
|
}, {});
|
|
2334
2339
|
|
|
2335
2340
|
// 店铺营业结束时间
|
|
2336
|
-
var 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
|
|
2341
|
+
var 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;
|
|
2337
2342
|
|
|
2338
2343
|
// 处理每个账号的商品
|
|
2339
2344
|
Object.values(itemsByAccount).forEach(function (accountItems) {
|
|
@@ -2358,7 +2363,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2358
2363
|
var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
|
|
2359
2364
|
return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
|
|
2360
2365
|
}, targetResourceTimes[0]);
|
|
2361
|
-
|
|
2366
|
+
|
|
2367
|
+
// 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
|
|
2368
|
+
var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
|
|
2369
|
+
var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? "23:59" : operating_day_boundary.time);
|
|
2370
|
+
var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
|
|
2362
2371
|
// 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
|
|
2363
2372
|
var formattedEndTime;
|
|
2364
2373
|
if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
|
|
@@ -97,7 +97,10 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
|
|
|
97
97
|
} | undefined;
|
|
98
98
|
} | undefined;
|
|
99
99
|
hasFlexibleDuration?: boolean | undefined;
|
|
100
|
-
operating_day_boundary?:
|
|
100
|
+
operating_day_boundary?: {
|
|
101
|
+
type: string;
|
|
102
|
+
time: string;
|
|
103
|
+
} | undefined;
|
|
101
104
|
}) => TimeSliceItem[];
|
|
102
105
|
/**
|
|
103
106
|
* @title: 获取时间切片列表的交集
|
|
@@ -154,7 +157,10 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
154
157
|
} | undefined;
|
|
155
158
|
} | undefined;
|
|
156
159
|
hasFlexibleDuration?: boolean | undefined;
|
|
157
|
-
operating_day_boundary?:
|
|
160
|
+
operating_day_boundary?: {
|
|
161
|
+
type: string;
|
|
162
|
+
time: string;
|
|
163
|
+
} | undefined;
|
|
158
164
|
}) => any[];
|
|
159
165
|
/**
|
|
160
166
|
* @title: 获取其他人的已选资源
|
|
@@ -463,7 +463,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
|
463
463
|
}
|
|
464
464
|
if (_status.usable) {
|
|
465
465
|
// 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
|
|
466
|
-
|
|
466
|
+
var operatingBoundaryDateTime = (operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.type) === 'start_time' ? "23:59" : operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.time;
|
|
467
|
+
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
|
|
467
468
|
break;
|
|
468
469
|
}
|
|
469
470
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
@@ -824,7 +824,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
824
824
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
825
825
|
const arr = [];
|
|
826
826
|
cartItems.forEach((cartItem) => {
|
|
827
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
827
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
828
828
|
let selectedResources = [];
|
|
829
829
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
830
830
|
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
@@ -904,7 +904,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
904
904
|
});
|
|
905
905
|
} else {
|
|
906
906
|
const hasFlexibleDuration = ((_e = (_d = cartItem._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.type) === "flexible";
|
|
907
|
-
const operating_day_boundary = (
|
|
907
|
+
const operating_day_boundary = (_g = (_f = this.shopStore.get("core")) == null ? void 0 : _f.core) == null ? void 0 : _g.operating_day_boundary;
|
|
908
908
|
productResources.forEach((item) => {
|
|
909
909
|
item.renderList = item.renderList.filter((n) => {
|
|
910
910
|
var _a2, _b2, _c2;
|
|
@@ -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)({
|
|
@@ -1476,7 +1479,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1476
1479
|
}
|
|
1477
1480
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
1478
1481
|
getTimeSlotByAllResources(resources_code) {
|
|
1479
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
1482
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1480
1483
|
let dateRange = this.store.date.getDateRange();
|
|
1481
1484
|
const resources = [];
|
|
1482
1485
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
@@ -1486,7 +1489,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1486
1489
|
let maxCutOffTime = void 0;
|
|
1487
1490
|
let maxCutOffTimeValue = (0, import_dayjs.default)();
|
|
1488
1491
|
cartItems.forEach((item) => {
|
|
1489
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2,
|
|
1492
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
|
|
1490
1493
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1491
1494
|
if (n.code === resources_code) {
|
|
1492
1495
|
resources.push(...n.renderList || []);
|
|
@@ -1499,7 +1502,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1499
1502
|
resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
|
|
1500
1503
|
(n) => n.code === resources_code
|
|
1501
1504
|
)) == null ? void 0 : _g2.id;
|
|
1502
|
-
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((
|
|
1505
|
+
if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
|
|
1503
1506
|
const currentCutOffTime = (0, import_dayjs.default)().add(
|
|
1504
1507
|
item._productOrigin.cut_off_time.unit,
|
|
1505
1508
|
item._productOrigin.cut_off_time.unit_type
|
|
@@ -1568,7 +1571,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1568
1571
|
var _a2, _b2;
|
|
1569
1572
|
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1570
1573
|
});
|
|
1571
|
-
const operating_day_boundary = (
|
|
1574
|
+
const operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
|
|
1572
1575
|
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1573
1576
|
resourceIds,
|
|
1574
1577
|
resourcesMap,
|
|
@@ -1584,7 +1587,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1584
1587
|
}
|
|
1585
1588
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
|
|
1586
1589
|
submitTimeSlot(timeSlots) {
|
|
1587
|
-
var _a, _b
|
|
1590
|
+
var _a, _b;
|
|
1588
1591
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1589
1592
|
const allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format("YYYY-MM-DD"));
|
|
1590
1593
|
const itemsByAccount = cartItems.reduce(
|
|
@@ -1598,25 +1601,27 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1598
1601
|
},
|
|
1599
1602
|
{}
|
|
1600
1603
|
);
|
|
1601
|
-
const operating_day_boundary = (
|
|
1604
|
+
const operating_day_boundary = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary;
|
|
1602
1605
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
1603
1606
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1604
1607
|
accountItems.forEach((item, index) => {
|
|
1605
1608
|
var _a2;
|
|
1606
1609
|
const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
|
|
1607
1610
|
newResources.forEach((resource) => {
|
|
1608
|
-
var _a3, _b2,
|
|
1611
|
+
var _a3, _b2, _c, _d, _e;
|
|
1609
1612
|
if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
|
|
1610
1613
|
item.duration = {
|
|
1611
1614
|
type: "minutes",
|
|
1612
1615
|
value: 10
|
|
1613
1616
|
};
|
|
1614
1617
|
resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1615
|
-
const targetResourceTimes = (
|
|
1618
|
+
const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c.times;
|
|
1616
1619
|
const resourcesEndTime = targetResourceTimes.reduce((acc, curr) => {
|
|
1617
1620
|
return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
|
|
1618
1621
|
}, targetResourceTimes[0]);
|
|
1619
|
-
const
|
|
1622
|
+
const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format("YYYY-MM-DD");
|
|
1623
|
+
const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
|
|
1624
|
+
const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
|
|
1620
1625
|
let formattedEndTime;
|
|
1621
1626
|
if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
|
|
1622
1627
|
const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
|
|
@@ -97,7 +97,10 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
|
|
|
97
97
|
} | undefined;
|
|
98
98
|
} | undefined;
|
|
99
99
|
hasFlexibleDuration?: boolean | undefined;
|
|
100
|
-
operating_day_boundary?:
|
|
100
|
+
operating_day_boundary?: {
|
|
101
|
+
type: string;
|
|
102
|
+
time: string;
|
|
103
|
+
} | undefined;
|
|
101
104
|
}) => TimeSliceItem[];
|
|
102
105
|
/**
|
|
103
106
|
* @title: 获取时间切片列表的交集
|
|
@@ -154,7 +157,10 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
|
|
|
154
157
|
} | undefined;
|
|
155
158
|
} | undefined;
|
|
156
159
|
hasFlexibleDuration?: boolean | undefined;
|
|
157
|
-
operating_day_boundary?:
|
|
160
|
+
operating_day_boundary?: {
|
|
161
|
+
type: string;
|
|
162
|
+
time: string;
|
|
163
|
+
} | undefined;
|
|
158
164
|
}) => any[];
|
|
159
165
|
/**
|
|
160
166
|
* @title: 获取其他人的已选资源
|
|
@@ -366,7 +366,8 @@ var getTimeSlicesByResource = ({
|
|
|
366
366
|
resourcesUseableMap[resource.id] = _status.usable;
|
|
367
367
|
}
|
|
368
368
|
if (_status.usable) {
|
|
369
|
-
|
|
369
|
+
const operatingBoundaryDateTime = (operating_day_boundary == null ? void 0 : operating_day_boundary.type) === "start_time" ? "23:59" : operating_day_boundary == null ? void 0 : operating_day_boundary.time;
|
|
370
|
+
if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
|
|
370
371
|
break;
|
|
371
372
|
}
|
|
372
373
|
timeSlices.push({
|