@pisell/pisellos 0.0.73 → 0.0.75
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 +15 -4
- package/dist/solution/BookingByStep/utils/resources.d.ts +6 -1
- package/dist/solution/BookingByStep/utils/resources.js +34 -27
- package/lib/solution/BookingByStep/index.js +12 -4
- package/lib/solution/BookingByStep/utils/resources.d.ts +6 -1
- package/lib/solution/BookingByStep/utils/resources.js +9 -2
- package/package.json +1 -1
|
@@ -296,7 +296,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
296
296
|
while (1) switch (_context4.prev = _context4.next) {
|
|
297
297
|
case 0:
|
|
298
298
|
_context4.next = 2;
|
|
299
|
-
return this.request.get("/schedule");
|
|
299
|
+
return this.request.get("/schedule?num=999");
|
|
300
300
|
case 2:
|
|
301
301
|
scheduleList = _context4.sent;
|
|
302
302
|
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
@@ -1847,7 +1847,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1847
1847
|
var count = 0;
|
|
1848
1848
|
// 遍历所有资源
|
|
1849
1849
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
1850
|
+
debugger;
|
|
1850
1851
|
// 遍历所有资源的上工时间片
|
|
1852
|
+
var currentResourcesCount = 0;
|
|
1853
|
+
var currentResourcesTimeSlotCanUsedArr = [];
|
|
1851
1854
|
m.times.forEach(function (childTiem) {
|
|
1852
1855
|
// 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
|
|
1853
1856
|
var res = getIsUsableByTimeItem({
|
|
@@ -1860,15 +1863,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1860
1863
|
time: childTiem,
|
|
1861
1864
|
resource: m,
|
|
1862
1865
|
currentCount: 1,
|
|
1863
|
-
resourcesUseableMap: resourcesUseableMap
|
|
1866
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
1867
|
+
cut_off_time: targetProductData === null || targetProductData === void 0 ? void 0 : targetProductData.cut_off_time
|
|
1864
1868
|
});
|
|
1865
1869
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1866
1870
|
resourcesUseableMap[m.id] = res.usable;
|
|
1867
1871
|
}
|
|
1868
|
-
if (res.usable && res.remainingCapacity >= count) {
|
|
1869
|
-
|
|
1872
|
+
if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
|
|
1873
|
+
currentResourcesCount = res.remainingCapacity;
|
|
1870
1874
|
}
|
|
1875
|
+
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1871
1876
|
});
|
|
1877
|
+
// 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
|
|
1878
|
+
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
1879
|
+
return n === false;
|
|
1880
|
+
})) {
|
|
1881
|
+
count = currentResourcesCount;
|
|
1882
|
+
}
|
|
1872
1883
|
});
|
|
1873
1884
|
var startDayJs = dayjs(item.start);
|
|
1874
1885
|
var endDayJs = dayjs(item.end);
|
|
@@ -27,12 +27,17 @@ interface BookingItem {
|
|
|
27
27
|
* @return {*}
|
|
28
28
|
* @Author: zhiwei.Wang
|
|
29
29
|
*/
|
|
30
|
-
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, }: {
|
|
30
|
+
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, cut_off_time, }: {
|
|
31
31
|
timeSlice: TimeSliceItem;
|
|
32
32
|
time: any;
|
|
33
33
|
resource: ResourceItem;
|
|
34
34
|
currentCount: number;
|
|
35
35
|
resourcesUseableMap: Record<string, boolean>;
|
|
36
|
+
cut_off_time?: {
|
|
37
|
+
future_day: number;
|
|
38
|
+
unit: number;
|
|
39
|
+
unit_type: string;
|
|
40
|
+
} | undefined;
|
|
36
41
|
}) => {
|
|
37
42
|
afterToDay: boolean;
|
|
38
43
|
capacity: boolean;
|
|
@@ -175,7 +175,8 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
175
175
|
_ref2$currentCount = _ref2.currentCount,
|
|
176
176
|
currentCount = _ref2$currentCount === void 0 ? 1 : _ref2$currentCount,
|
|
177
177
|
_ref2$resourcesUseabl = _ref2.resourcesUseableMap,
|
|
178
|
-
resourcesUseableMap = _ref2$resourcesUseabl === void 0 ? {} : _ref2$resourcesUseabl
|
|
178
|
+
resourcesUseableMap = _ref2$resourcesUseabl === void 0 ? {} : _ref2$resourcesUseabl,
|
|
179
|
+
cut_off_time = _ref2.cut_off_time;
|
|
179
180
|
var status = {
|
|
180
181
|
afterToDay: false,
|
|
181
182
|
capacity: false,
|
|
@@ -186,6 +187,12 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
186
187
|
};
|
|
187
188
|
// 最早可预约时间为 当前日期之后并且提前量之后
|
|
188
189
|
var earliest = dayjs();
|
|
190
|
+
var _ref3 = cut_off_time || {},
|
|
191
|
+
unit = _ref3.unit,
|
|
192
|
+
unit_type = _ref3.unit_type;
|
|
193
|
+
if (unit) {
|
|
194
|
+
earliest = earliest.add(unit, unit_type);
|
|
195
|
+
}
|
|
189
196
|
// 不可预约提前量时间之前的
|
|
190
197
|
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
191
198
|
return status;
|
|
@@ -323,9 +330,9 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
323
330
|
* @Author: zhiwei.Wang
|
|
324
331
|
* @Date: 2024-01-09 13:38
|
|
325
332
|
*/
|
|
326
|
-
export var formatResources = function formatResources(
|
|
327
|
-
var booking =
|
|
328
|
-
resources =
|
|
333
|
+
export var formatResources = function formatResources(_ref4) {
|
|
334
|
+
var booking = _ref4.booking,
|
|
335
|
+
resources = _ref4.resources;
|
|
329
336
|
try {
|
|
330
337
|
var _list = _toConsumableArray(resources);
|
|
331
338
|
var maps = {};
|
|
@@ -371,16 +378,16 @@ export var formatResources = function formatResources(_ref3) {
|
|
|
371
378
|
* @return {*}
|
|
372
379
|
* @Author: zhiwei.Wang
|
|
373
380
|
*/
|
|
374
|
-
export var getTimeSlicesByResource = function getTimeSlicesByResource(
|
|
375
|
-
var resource =
|
|
376
|
-
duration =
|
|
377
|
-
|
|
378
|
-
split =
|
|
379
|
-
|
|
380
|
-
currentDate =
|
|
381
|
-
capacity =
|
|
382
|
-
|
|
383
|
-
resourcesUseableMap =
|
|
381
|
+
export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
|
|
382
|
+
var resource = _ref5.resource,
|
|
383
|
+
duration = _ref5.duration,
|
|
384
|
+
_ref5$split = _ref5.split,
|
|
385
|
+
split = _ref5$split === void 0 ? 10 : _ref5$split,
|
|
386
|
+
_ref5$currentDate = _ref5.currentDate,
|
|
387
|
+
currentDate = _ref5$currentDate === void 0 ? dayjs() : _ref5$currentDate,
|
|
388
|
+
capacity = _ref5.capacity,
|
|
389
|
+
_ref5$resourcesUseabl = _ref5.resourcesUseableMap,
|
|
390
|
+
resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl;
|
|
384
391
|
var times = resource.times;
|
|
385
392
|
|
|
386
393
|
// 存储所有时间切片
|
|
@@ -521,14 +528,14 @@ export var mergeSubResourcesTimeSlices = function mergeSubResourcesTimeSlices(re
|
|
|
521
528
|
* @return {*}
|
|
522
529
|
* @Author: zhiwei.Wang
|
|
523
530
|
*/
|
|
524
|
-
export var getTimeSlicesByResources = function getTimeSlicesByResources(
|
|
525
|
-
var resourceIds =
|
|
526
|
-
resourcesMap =
|
|
527
|
-
duration =
|
|
528
|
-
currentDate =
|
|
529
|
-
split =
|
|
530
|
-
capacity =
|
|
531
|
-
resourcesUseableMap =
|
|
531
|
+
export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
|
|
532
|
+
var resourceIds = _ref6.resourceIds,
|
|
533
|
+
resourcesMap = _ref6.resourcesMap,
|
|
534
|
+
duration = _ref6.duration,
|
|
535
|
+
currentDate = _ref6.currentDate,
|
|
536
|
+
split = _ref6.split,
|
|
537
|
+
capacity = _ref6.capacity,
|
|
538
|
+
resourcesUseableMap = _ref6.resourcesUseableMap;
|
|
532
539
|
// 获取资源列表
|
|
533
540
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
534
541
|
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
@@ -660,9 +667,9 @@ export var getOthersCartSelectedResources = function getOthersCartSelectedResour
|
|
|
660
667
|
* @return {*}
|
|
661
668
|
* @Author: zhiwei.Wang
|
|
662
669
|
*/
|
|
663
|
-
export var formatDefaultCapacitys = function formatDefaultCapacitys(
|
|
664
|
-
var capacity =
|
|
665
|
-
product_bundle =
|
|
670
|
+
export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref7) {
|
|
671
|
+
var capacity = _ref7.capacity,
|
|
672
|
+
product_bundle = _ref7.product_bundle;
|
|
666
673
|
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
|
|
667
674
|
return (product_bundle || []).map(function (d) {
|
|
668
675
|
var id = d.bundle_product_id;
|
|
@@ -701,8 +708,8 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref6) {
|
|
|
701
708
|
* @return {*}
|
|
702
709
|
* @Author: zhiwei.Wang
|
|
703
710
|
*/
|
|
704
|
-
export var getSumCapacity = function getSumCapacity(
|
|
705
|
-
var capacity =
|
|
711
|
+
export var getSumCapacity = function getSumCapacity(_ref8) {
|
|
712
|
+
var capacity = _ref8.capacity;
|
|
706
713
|
var sum = 0;
|
|
707
714
|
var _iterator2 = _createForOfIteratorHelper(capacity || []),
|
|
708
715
|
_step2;
|
|
@@ -203,7 +203,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
203
203
|
// 加载当前店铺下所有 schedule
|
|
204
204
|
async loadAllSchedule() {
|
|
205
205
|
var _a;
|
|
206
|
-
const scheduleList = await this.request.get(`/schedule`);
|
|
206
|
+
const scheduleList = await this.request.get(`/schedule?num=999`);
|
|
207
207
|
this.store.schedule.setScheduleList(((_a = scheduleList.data) == null ? void 0 : _a.list) || []);
|
|
208
208
|
}
|
|
209
209
|
// ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
@@ -1218,6 +1218,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1218
1218
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1219
1219
|
let count = 0;
|
|
1220
1220
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1221
|
+
debugger;
|
|
1222
|
+
let currentResourcesCount = 0;
|
|
1223
|
+
const currentResourcesTimeSlotCanUsedArr = [];
|
|
1221
1224
|
m.times.forEach((childTiem) => {
|
|
1222
1225
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1223
1226
|
timeSlice: {
|
|
@@ -1229,15 +1232,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1229
1232
|
time: childTiem,
|
|
1230
1233
|
resource: m,
|
|
1231
1234
|
currentCount: 1,
|
|
1232
|
-
resourcesUseableMap
|
|
1235
|
+
resourcesUseableMap,
|
|
1236
|
+
cut_off_time: targetProductData == null ? void 0 : targetProductData.cut_off_time
|
|
1233
1237
|
});
|
|
1234
1238
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1235
1239
|
resourcesUseableMap[m.id] = res.usable;
|
|
1236
1240
|
}
|
|
1237
|
-
if (res.usable && res.remainingCapacity >= count) {
|
|
1238
|
-
|
|
1241
|
+
if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
|
|
1242
|
+
currentResourcesCount = res.remainingCapacity;
|
|
1239
1243
|
}
|
|
1244
|
+
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1240
1245
|
});
|
|
1246
|
+
if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
|
|
1247
|
+
count = currentResourcesCount;
|
|
1248
|
+
}
|
|
1241
1249
|
});
|
|
1242
1250
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
1243
1251
|
const endDayJs = (0, import_dayjs.default)(item.end);
|
|
@@ -27,12 +27,17 @@ interface BookingItem {
|
|
|
27
27
|
* @return {*}
|
|
28
28
|
* @Author: zhiwei.Wang
|
|
29
29
|
*/
|
|
30
|
-
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, }: {
|
|
30
|
+
export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, cut_off_time, }: {
|
|
31
31
|
timeSlice: TimeSliceItem;
|
|
32
32
|
time: any;
|
|
33
33
|
resource: ResourceItem;
|
|
34
34
|
currentCount: number;
|
|
35
35
|
resourcesUseableMap: Record<string, boolean>;
|
|
36
|
+
cut_off_time?: {
|
|
37
|
+
future_day: number;
|
|
38
|
+
unit: number;
|
|
39
|
+
unit_type: string;
|
|
40
|
+
} | undefined;
|
|
36
41
|
}) => {
|
|
37
42
|
afterToDay: boolean;
|
|
38
43
|
capacity: boolean;
|
|
@@ -127,7 +127,8 @@ var getIsUsableByTimeItem = ({
|
|
|
127
127
|
time,
|
|
128
128
|
resource,
|
|
129
129
|
currentCount = 1,
|
|
130
|
-
resourcesUseableMap = {}
|
|
130
|
+
resourcesUseableMap = {},
|
|
131
|
+
cut_off_time
|
|
131
132
|
}) => {
|
|
132
133
|
var _a;
|
|
133
134
|
let status = {
|
|
@@ -139,6 +140,10 @@ var getIsUsableByTimeItem = ({
|
|
|
139
140
|
reason: ""
|
|
140
141
|
};
|
|
141
142
|
let earliest = (0, import_dayjs.default)();
|
|
143
|
+
const { unit, unit_type } = cut_off_time || {};
|
|
144
|
+
if (unit) {
|
|
145
|
+
earliest = earliest.add(unit, unit_type);
|
|
146
|
+
}
|
|
142
147
|
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
143
148
|
return status;
|
|
144
149
|
}
|
|
@@ -373,7 +378,9 @@ var mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
|
|
|
373
378
|
const subResource = resourcesMap[id];
|
|
374
379
|
if (subResource) {
|
|
375
380
|
subResource.times.forEach((time) => {
|
|
376
|
-
const fatherResourcesTime = item.times.find(
|
|
381
|
+
const fatherResourcesTime = item.times.find(
|
|
382
|
+
(n) => n.start_at === time.start_at && n.end_at === time.end_at
|
|
383
|
+
);
|
|
377
384
|
if (fatherResourcesTime) {
|
|
378
385
|
fatherResourcesTime.event_list.push(...time.event_list || []);
|
|
379
386
|
}
|