@pisell/pisellos 0.0.70 → 0.0.72
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.d.ts +4 -2
- package/dist/solution/BookingByStep/index.js +58 -23
- package/dist/solution/BookingByStep/utils/resources.d.ts +9 -0
- package/dist/solution/BookingByStep/utils/resources.js +52 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -2
- package/lib/solution/BookingByStep/index.js +47 -16
- package/lib/solution/BookingByStep/utils/resources.d.ts +9 -0
- package/lib/solution/BookingByStep/utils/resources.js +49 -2
- package/package.json +1 -1
|
@@ -38,11 +38,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
38
38
|
* 删除step
|
|
39
39
|
*/
|
|
40
40
|
removeStep(key: string): void;
|
|
41
|
-
loadProducts({ category_ids, product_ids, collection, schedule_ids, }: {
|
|
41
|
+
loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
|
|
42
42
|
category_ids?: number[];
|
|
43
43
|
product_ids?: number[];
|
|
44
44
|
collection?: number | string[];
|
|
45
45
|
schedule_ids?: number[];
|
|
46
|
+
schedule_date?: string;
|
|
46
47
|
}): Promise<any>;
|
|
47
48
|
loadProductByScheduleDate({ date, product_ids, category_ids, }: {
|
|
48
49
|
date: string;
|
|
@@ -50,10 +51,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
50
51
|
category_ids?: number[];
|
|
51
52
|
}): Promise<any>;
|
|
52
53
|
loadAllSchedule(): Promise<void>;
|
|
53
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
54
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel }: {
|
|
54
55
|
startDate: string;
|
|
55
56
|
endDate: string;
|
|
56
57
|
custom_page_id?: number;
|
|
58
|
+
channel?: string;
|
|
57
59
|
}): Promise<ITime[]>;
|
|
58
60
|
storeProduct(productData: ProductData): Promise<void>;
|
|
59
61
|
addAccount(account: Account | IHolder, extra?: {
|
|
@@ -193,11 +193,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
193
193
|
value: function () {
|
|
194
194
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
195
195
|
var _schedule_ids;
|
|
196
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_ids_data, productsData;
|
|
196
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, productsData;
|
|
197
197
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
198
198
|
while (1) switch (_context2.prev = _context2.next) {
|
|
199
199
|
case 0:
|
|
200
|
-
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$schedule_ids = _ref.schedule_ids, schedule_ids = _ref$schedule_ids === void 0 ? [] : _ref$schedule_ids;
|
|
200
|
+
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$schedule_ids = _ref.schedule_ids, schedule_ids = _ref$schedule_ids === void 0 ? [] : _ref$schedule_ids, schedule_date = _ref.schedule_date;
|
|
201
201
|
// 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
202
202
|
if (!((_schedule_ids = schedule_ids) !== null && _schedule_ids !== void 0 && _schedule_ids.length)) {
|
|
203
203
|
schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map(function (n) {
|
|
@@ -220,7 +220,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
220
220
|
ids: product_ids,
|
|
221
221
|
collection: collection,
|
|
222
222
|
front_end_cache_id: this.cacheId,
|
|
223
|
-
client_schedule_ids: schedule_ids
|
|
223
|
+
client_schedule_ids: schedule_ids,
|
|
224
|
+
schedule_date: schedule_date
|
|
224
225
|
}, {
|
|
225
226
|
useCache: true
|
|
226
227
|
});
|
|
@@ -269,7 +270,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
269
270
|
return this.loadProducts({
|
|
270
271
|
schedule_ids: scheduleIds,
|
|
271
272
|
product_ids: product_ids,
|
|
272
|
-
category_ids: category_ids
|
|
273
|
+
category_ids: category_ids,
|
|
274
|
+
schedule_date: date
|
|
273
275
|
});
|
|
274
276
|
case 6:
|
|
275
277
|
return _context3.abrupt("return", _context3.sent);
|
|
@@ -314,11 +316,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
314
316
|
value: function () {
|
|
315
317
|
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
316
318
|
var _res$data$date_list;
|
|
317
|
-
var startDate, endDate, custom_page_id, dates, res;
|
|
319
|
+
var startDate, endDate, custom_page_id, channel, dates, res;
|
|
318
320
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
319
321
|
while (1) switch (_context5.prev = _context5.next) {
|
|
320
322
|
case 0:
|
|
321
|
-
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id;
|
|
323
|
+
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel;
|
|
322
324
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
323
325
|
if (dayjs(startDate).isBefore(dayjs(), 'day')) {
|
|
324
326
|
startDate = dayjs().format('YYYY-MM-DD');
|
|
@@ -337,7 +339,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
337
339
|
return this.request.get("/schedule/product/availability", {
|
|
338
340
|
start_date: startDate,
|
|
339
341
|
end_date: endDate,
|
|
340
|
-
custom_page_id: custom_page_id
|
|
342
|
+
custom_page_id: custom_page_id,
|
|
343
|
+
channel: channel
|
|
341
344
|
});
|
|
342
345
|
case 8:
|
|
343
346
|
res = _context5.sent;
|
|
@@ -350,13 +353,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
350
353
|
return _context5.abrupt("return", dates);
|
|
351
354
|
case 12:
|
|
352
355
|
res.data.date_list.forEach(function (n) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
dates[index].status = 'available';
|
|
359
|
-
}
|
|
356
|
+
var index = dates.findIndex(function (m) {
|
|
357
|
+
return m.date === n.date;
|
|
358
|
+
});
|
|
359
|
+
if (index !== -1) {
|
|
360
|
+
dates[index].status = 'available';
|
|
360
361
|
}
|
|
361
362
|
});
|
|
362
363
|
dates = disableDatesBeforeOneDay(dates);
|
|
@@ -1195,7 +1196,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1195
1196
|
});
|
|
1196
1197
|
n.renderList = n.renderList.filter(function (m) {
|
|
1197
1198
|
var recordCount = capacityMap[m.id] || 0;
|
|
1198
|
-
var
|
|
1199
|
+
var canUseArr = m.times.map(function (item) {
|
|
1199
1200
|
var res = getIsUsableByTimeItem({
|
|
1200
1201
|
timeSlice: {
|
|
1201
1202
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1213,7 +1214,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1213
1214
|
}
|
|
1214
1215
|
return res.usable;
|
|
1215
1216
|
});
|
|
1216
|
-
return
|
|
1217
|
+
if (m.onlyComputed) return false;
|
|
1218
|
+
// 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
|
|
1219
|
+
return !canUseArr.some(function (n) {
|
|
1220
|
+
return n === false;
|
|
1221
|
+
});
|
|
1217
1222
|
});
|
|
1218
1223
|
});
|
|
1219
1224
|
} else {
|
|
@@ -1221,6 +1226,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1221
1226
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1222
1227
|
item.renderList = item.renderList.filter(function (n) {
|
|
1223
1228
|
var recordCount = n.capacity || 0;
|
|
1229
|
+
if (n.onlyComputed) return false;
|
|
1224
1230
|
return recordCount >= currentCapacity;
|
|
1225
1231
|
});
|
|
1226
1232
|
});
|
|
@@ -1273,6 +1279,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1273
1279
|
capacity: formatCapacity
|
|
1274
1280
|
});
|
|
1275
1281
|
var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod3 = targetCartItem._productOrigin) === null || _targetCartItem$_prod3 === void 0 || (_targetCartItem$_prod3 = _targetCartItem$_prod3.product_resource) === null || _targetCartItem$_prod3 === void 0 ? void 0 : _targetCartItem$_prod3.resources) || [], selectedResources, currentCapacity);
|
|
1282
|
+
productResources.forEach(function (item) {
|
|
1283
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1284
|
+
var recordCount = n.capacity || 0;
|
|
1285
|
+
if (n.onlyComputed) return false;
|
|
1286
|
+
return recordCount >= currentCapacity;
|
|
1287
|
+
});
|
|
1288
|
+
});
|
|
1276
1289
|
if (productResources) {
|
|
1277
1290
|
return {
|
|
1278
1291
|
id: targetCartItem.id,
|
|
@@ -1533,6 +1546,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1533
1546
|
selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap);
|
|
1534
1547
|
}
|
|
1535
1548
|
var productResources = getResourcesByProduct(_resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
|
|
1549
|
+
productResources.forEach(function (item) {
|
|
1550
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1551
|
+
var recordCount = n.capacity || 0;
|
|
1552
|
+
if (n.onlyComputed) return false;
|
|
1553
|
+
return recordCount >= currentCapacity;
|
|
1554
|
+
});
|
|
1555
|
+
});
|
|
1536
1556
|
// 自动选择 productResources 中对应 resources_code 的资源
|
|
1537
1557
|
var targetRenderList = (_productResources$fin = productResources.find(function (n) {
|
|
1538
1558
|
return n.code === resources_code;
|
|
@@ -1581,7 +1601,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1581
1601
|
}, {
|
|
1582
1602
|
key: "getTimeSlotByAllResources",
|
|
1583
1603
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1584
|
-
var
|
|
1604
|
+
var _dateRange,
|
|
1605
|
+
_this9 = this,
|
|
1585
1606
|
_cartItems$,
|
|
1586
1607
|
_cartItems$2;
|
|
1587
1608
|
var dateRange = this.store.date.getDateRange();
|
|
@@ -1590,8 +1611,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1590
1611
|
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1591
1612
|
// if (cartItems?.[0].start_date) return [];
|
|
1592
1613
|
var resourceIds = [];
|
|
1614
|
+
var resourcesTypeId = undefined;
|
|
1593
1615
|
cartItems.forEach(function (item) {
|
|
1594
|
-
var _item$_productOrigin9;
|
|
1616
|
+
var _item$_productOrigin9, _item$_productOrigin10;
|
|
1595
1617
|
(_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || _item$_productOrigin9.forEach(function (n) {
|
|
1596
1618
|
if (n.code === resources_code) {
|
|
1597
1619
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -1603,7 +1625,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1625
|
if (item.resource_id) {
|
|
1604
1626
|
resourceIds.push(item.resource_id);
|
|
1605
1627
|
}
|
|
1628
|
+
resourcesTypeId = item === null || item === void 0 || (_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 = _item$_productOrigin10.find(function (n) {
|
|
1629
|
+
return n.code === resources_code;
|
|
1630
|
+
})) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.id;
|
|
1606
1631
|
});
|
|
1632
|
+
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1633
|
+
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
1634
|
+
// resources.push(...dateRange[0].resource);
|
|
1635
|
+
dateRange[0].resource.forEach(function (n) {
|
|
1636
|
+
if (n.form_id === resourcesTypeId && !resources.find(function (m) {
|
|
1637
|
+
return m.id === n.id;
|
|
1638
|
+
})) {
|
|
1639
|
+
resources.push(n);
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1607
1643
|
var resourcesMap = getResourcesMap(resources);
|
|
1608
1644
|
var duration = 0;
|
|
1609
1645
|
// duration = 不同账号的最长时间
|
|
@@ -1611,8 +1647,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1611
1647
|
var checkDuration = function checkDuration(cartItems) {
|
|
1612
1648
|
var accountDuration = 0;
|
|
1613
1649
|
cartItems.forEach(function (item) {
|
|
1614
|
-
var _item$_productOrigin$3, _item$
|
|
1615
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1650
|
+
var _item$_productOrigin$3, _item$_productOrigin11;
|
|
1651
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
1616
1652
|
});
|
|
1617
1653
|
if (accountDuration > duration) {
|
|
1618
1654
|
duration = accountDuration;
|
|
@@ -1681,9 +1717,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1681
1717
|
accountItems.forEach(function (item, index) {
|
|
1682
1718
|
var newResources = cloneDeep(item._origin.resources);
|
|
1683
1719
|
newResources.forEach(function (resource) {
|
|
1684
|
-
var _item$_productOrigin$4, _item$
|
|
1720
|
+
var _item$_productOrigin$4, _item$_productOrigin12, _ref11, _item$_productOrigin13;
|
|
1685
1721
|
resource.startTime = currentStartTime;
|
|
1686
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
1722
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
1687
1723
|
delete resource.times;
|
|
1688
1724
|
});
|
|
1689
1725
|
_this10.store.cart.updateItem({
|
|
@@ -1827,7 +1863,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1827
1863
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false) {
|
|
1828
1864
|
resourcesUseableMap[m.id] = res.usable;
|
|
1829
1865
|
}
|
|
1830
|
-
// 如果资源可用,且是独占资源,remainingCapacity 始终为 1
|
|
1831
1866
|
if (res.usable && res.remainingCapacity >= count) {
|
|
1832
1867
|
count = res.remainingCapacity;
|
|
1833
1868
|
}
|
|
@@ -95,6 +95,15 @@ export declare const getTimesIntersection: (times: TimeSliceItem[], count: numbe
|
|
|
95
95
|
* @Date: 2024-09-19 20:23
|
|
96
96
|
*/
|
|
97
97
|
export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceItem>, ids: number[]) => ResourceItem[];
|
|
98
|
+
/**
|
|
99
|
+
* @title: 合并子资源的时间切片至组合资源
|
|
100
|
+
* @description:
|
|
101
|
+
* @param {ResourceItem[]} resources
|
|
102
|
+
* @param {Record<string, ResourceItem>} resourcesMap
|
|
103
|
+
* @return {*}
|
|
104
|
+
* @Author: zhiwei.Wang
|
|
105
|
+
*/
|
|
106
|
+
export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], resourcesMap: Record<string, ResourceItem>) => void;
|
|
98
107
|
/**
|
|
99
108
|
* @title: 根据资源id列表获取时间切片
|
|
100
109
|
* @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
|
|
@@ -238,6 +238,16 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
238
238
|
resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
|
|
239
239
|
if (resourcesMap[id]) {
|
|
240
240
|
combiningResources.push(resourcesMap[id]);
|
|
241
|
+
childAcc.push(Object.assign({}, resourcesMap[id], {
|
|
242
|
+
form_id: form_id,
|
|
243
|
+
resourceType: item.type,
|
|
244
|
+
children: combiningResources,
|
|
245
|
+
onlyComputed: true,
|
|
246
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
247
|
+
metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
|
|
248
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
249
|
+
})
|
|
250
|
+
}));
|
|
241
251
|
}
|
|
242
252
|
});
|
|
243
253
|
}
|
|
@@ -260,6 +270,16 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
260
270
|
resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
|
|
261
271
|
if (resourcesMap[id]) {
|
|
262
272
|
combiningResources.push(resourcesMap[id]);
|
|
273
|
+
childAcc.push(Object.assign({}, resourcesMap[id], {
|
|
274
|
+
form_id: form_id,
|
|
275
|
+
resourceType: item.type,
|
|
276
|
+
children: combiningResources,
|
|
277
|
+
onlyComputed: true,
|
|
278
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
279
|
+
metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
|
|
280
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
281
|
+
})
|
|
282
|
+
}));
|
|
263
283
|
}
|
|
264
284
|
});
|
|
265
285
|
}
|
|
@@ -458,6 +478,37 @@ export var getResourcesByIds = function getResourcesByIds(resourcesMap, ids) {
|
|
|
458
478
|
});
|
|
459
479
|
};
|
|
460
480
|
|
|
481
|
+
/**
|
|
482
|
+
* @title: 合并子资源的时间切片至组合资源
|
|
483
|
+
* @description:
|
|
484
|
+
* @param {ResourceItem[]} resources
|
|
485
|
+
* @param {Record<string, ResourceItem>} resourcesMap
|
|
486
|
+
* @return {*}
|
|
487
|
+
* @Author: zhiwei.Wang
|
|
488
|
+
*/
|
|
489
|
+
export var mergeSubResourcesTimeSlices = function mergeSubResourcesTimeSlices(resources, resourcesMap) {
|
|
490
|
+
return resources.forEach(function (item) {
|
|
491
|
+
var _item$combined_resour;
|
|
492
|
+
if ((item === null || item === void 0 || (_item$combined_resour = item.combined_resource) === null || _item$combined_resour === void 0 ? void 0 : _item$combined_resour.status) === 1) {
|
|
493
|
+
var _item$combined_resour2;
|
|
494
|
+
item === null || item === void 0 || (_item$combined_resour2 = item.combined_resource) === null || _item$combined_resour2 === void 0 || _item$combined_resour2.resource_ids.forEach(function (id) {
|
|
495
|
+
var subResource = resourcesMap[id];
|
|
496
|
+
if (subResource) {
|
|
497
|
+
subResource.times.forEach(function (time) {
|
|
498
|
+
var fatherResourcesTime = item.times.find(function (n) {
|
|
499
|
+
return n.start_at === time.start_at && n.end_at === time.end_at;
|
|
500
|
+
});
|
|
501
|
+
if (fatherResourcesTime) {
|
|
502
|
+
var _fatherResourcesTime$;
|
|
503
|
+
(_fatherResourcesTime$ = fatherResourcesTime.event_list).push.apply(_fatherResourcesTime$, _toConsumableArray(time.event_list || []));
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
|
|
461
512
|
/**
|
|
462
513
|
* @title: 根据资源id列表获取时间切片
|
|
463
514
|
* @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
|
|
@@ -476,6 +527,7 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
476
527
|
resourcesUseableMap = _ref5.resourcesUseableMap;
|
|
477
528
|
// 获取资源列表
|
|
478
529
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
530
|
+
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
479
531
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
480
532
|
resources.sort(function (a, b) {
|
|
481
533
|
var _a$metadata, _b$metadata;
|
|
@@ -38,11 +38,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
38
38
|
* 删除step
|
|
39
39
|
*/
|
|
40
40
|
removeStep(key: string): void;
|
|
41
|
-
loadProducts({ category_ids, product_ids, collection, schedule_ids, }: {
|
|
41
|
+
loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
|
|
42
42
|
category_ids?: number[];
|
|
43
43
|
product_ids?: number[];
|
|
44
44
|
collection?: number | string[];
|
|
45
45
|
schedule_ids?: number[];
|
|
46
|
+
schedule_date?: string;
|
|
46
47
|
}): Promise<any>;
|
|
47
48
|
loadProductByScheduleDate({ date, product_ids, category_ids, }: {
|
|
48
49
|
date: string;
|
|
@@ -50,10 +51,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
50
51
|
category_ids?: number[];
|
|
51
52
|
}): Promise<any>;
|
|
52
53
|
loadAllSchedule(): Promise<void>;
|
|
53
|
-
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
|
|
54
|
+
loadScheduleAvailableDate({ startDate, endDate, custom_page_id, channel }: {
|
|
54
55
|
startDate: string;
|
|
55
56
|
endDate: string;
|
|
56
57
|
custom_page_id?: number;
|
|
58
|
+
channel?: string;
|
|
57
59
|
}): Promise<ITime[]>;
|
|
58
60
|
storeProduct(productData: ProductData): Promise<void>;
|
|
59
61
|
addAccount(account: Account | IHolder, extra?: {
|
|
@@ -151,7 +151,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
151
151
|
category_ids = [],
|
|
152
152
|
product_ids = [],
|
|
153
153
|
collection = [],
|
|
154
|
-
schedule_ids = []
|
|
154
|
+
schedule_ids = [],
|
|
155
|
+
schedule_date
|
|
155
156
|
}) {
|
|
156
157
|
if (!(schedule_ids == null ? void 0 : schedule_ids.length)) {
|
|
157
158
|
const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
|
|
@@ -178,7 +179,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
178
179
|
ids: product_ids,
|
|
179
180
|
collection,
|
|
180
181
|
front_end_cache_id: this.cacheId,
|
|
181
|
-
client_schedule_ids: schedule_ids
|
|
182
|
+
client_schedule_ids: schedule_ids,
|
|
183
|
+
schedule_date
|
|
182
184
|
},
|
|
183
185
|
{ useCache: true }
|
|
184
186
|
);
|
|
@@ -196,7 +198,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
196
198
|
{ date, status: "available", week: "", weekNum: 0 }
|
|
197
199
|
]);
|
|
198
200
|
const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
|
|
199
|
-
return await this.loadProducts({ schedule_ids: scheduleIds, product_ids, category_ids });
|
|
201
|
+
return await this.loadProducts({ schedule_ids: scheduleIds, product_ids, category_ids, schedule_date: date });
|
|
200
202
|
}
|
|
201
203
|
// 加载当前店铺下所有 schedule
|
|
202
204
|
async loadAllSchedule() {
|
|
@@ -208,7 +210,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
208
210
|
async loadScheduleAvailableDate({
|
|
209
211
|
startDate,
|
|
210
212
|
endDate,
|
|
211
|
-
custom_page_id
|
|
213
|
+
custom_page_id,
|
|
214
|
+
channel
|
|
212
215
|
}) {
|
|
213
216
|
var _a;
|
|
214
217
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
@@ -224,7 +227,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
224
227
|
{
|
|
225
228
|
start_date: startDate,
|
|
226
229
|
end_date: endDate,
|
|
227
|
-
custom_page_id
|
|
230
|
+
custom_page_id,
|
|
231
|
+
channel
|
|
228
232
|
}
|
|
229
233
|
);
|
|
230
234
|
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
@@ -232,11 +236,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
232
236
|
return dates;
|
|
233
237
|
}
|
|
234
238
|
res.data.date_list.forEach((n) => {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
dates[index].status = "available";
|
|
239
|
-
}
|
|
239
|
+
const index = dates.findIndex((m) => m.date === n.date);
|
|
240
|
+
if (index !== -1) {
|
|
241
|
+
dates[index].status = "available";
|
|
240
242
|
}
|
|
241
243
|
});
|
|
242
244
|
dates = (0, import_utils3.disableDatesBeforeOneDay)(dates);
|
|
@@ -646,7 +648,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
646
648
|
});
|
|
647
649
|
n.renderList = n.renderList.filter((m) => {
|
|
648
650
|
const recordCount = capacityMap[m.id] || 0;
|
|
649
|
-
const
|
|
651
|
+
const canUseArr = m.times.map((item) => {
|
|
650
652
|
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
651
653
|
timeSlice: {
|
|
652
654
|
start_time: startTime.format("HH:mm"),
|
|
@@ -664,13 +666,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
664
666
|
}
|
|
665
667
|
return res.usable;
|
|
666
668
|
});
|
|
667
|
-
|
|
669
|
+
if (m.onlyComputed)
|
|
670
|
+
return false;
|
|
671
|
+
return !canUseArr.some((n2) => n2 === false);
|
|
668
672
|
});
|
|
669
673
|
});
|
|
670
674
|
} else {
|
|
671
675
|
productResources.forEach((item) => {
|
|
672
676
|
item.renderList = item.renderList.filter((n) => {
|
|
673
677
|
const recordCount = n.capacity || 0;
|
|
678
|
+
if (n.onlyComputed)
|
|
679
|
+
return false;
|
|
674
680
|
return recordCount >= currentCapacity;
|
|
675
681
|
});
|
|
676
682
|
});
|
|
@@ -728,6 +734,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
728
734
|
selectedResources,
|
|
729
735
|
currentCapacity
|
|
730
736
|
);
|
|
737
|
+
productResources.forEach((item) => {
|
|
738
|
+
item.renderList = item.renderList.filter((n) => {
|
|
739
|
+
const recordCount = n.capacity || 0;
|
|
740
|
+
if (n.onlyComputed)
|
|
741
|
+
return false;
|
|
742
|
+
return recordCount >= currentCapacity;
|
|
743
|
+
});
|
|
744
|
+
});
|
|
731
745
|
if (productResources) {
|
|
732
746
|
return {
|
|
733
747
|
id: targetCartItem.id,
|
|
@@ -952,6 +966,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
952
966
|
selectedResources,
|
|
953
967
|
currentCapacity
|
|
954
968
|
);
|
|
969
|
+
productResources.forEach((item2) => {
|
|
970
|
+
item2.renderList = item2.renderList.filter((n) => {
|
|
971
|
+
const recordCount = n.capacity || 0;
|
|
972
|
+
if (n.onlyComputed)
|
|
973
|
+
return false;
|
|
974
|
+
return recordCount >= currentCapacity;
|
|
975
|
+
});
|
|
976
|
+
});
|
|
955
977
|
const targetRenderList = (_l = productResources.find(
|
|
956
978
|
(n) => n.code === resources_code
|
|
957
979
|
)) == null ? void 0 : _l.renderList;
|
|
@@ -992,13 +1014,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
992
1014
|
}
|
|
993
1015
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
994
1016
|
getTimeSlotByAllResources(resources_code) {
|
|
995
|
-
var _a, _b, _c, _d;
|
|
1017
|
+
var _a, _b, _c, _d, _e, _f;
|
|
996
1018
|
let dateRange = this.store.date.getDateRange();
|
|
997
1019
|
const resources = [];
|
|
998
1020
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
999
1021
|
const resourceIds = [];
|
|
1022
|
+
let resourcesTypeId = void 0;
|
|
1000
1023
|
cartItems.forEach((item) => {
|
|
1001
|
-
var _a2, _b2, _c2;
|
|
1024
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g;
|
|
1002
1025
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
1003
1026
|
if (n.code === resources_code) {
|
|
1004
1027
|
resources.push(...n.renderList || []);
|
|
@@ -1007,7 +1030,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1007
1030
|
if (item.resource_id) {
|
|
1008
1031
|
resourceIds.push(item.resource_id);
|
|
1009
1032
|
}
|
|
1033
|
+
resourcesTypeId = (_g = (_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((n) => n.code === resources_code)) == null ? void 0 : _g.id;
|
|
1010
1034
|
});
|
|
1035
|
+
if ((_b = (_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.resource) == null ? void 0 : _b.length) {
|
|
1036
|
+
dateRange[0].resource.forEach((n) => {
|
|
1037
|
+
if (n.form_id === resourcesTypeId && !resources.find((m) => m.id === n.id)) {
|
|
1038
|
+
resources.push(n);
|
|
1039
|
+
}
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1011
1042
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
1012
1043
|
let duration = 0;
|
|
1013
1044
|
const accountList = this.store.accountList.getAccounts();
|
|
@@ -1029,7 +1060,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1029
1060
|
} else {
|
|
1030
1061
|
checkDuration(cartItems);
|
|
1031
1062
|
}
|
|
1032
|
-
if (!((
|
|
1063
|
+
if (!((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) && !((_d = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _d.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
1033
1064
|
return [];
|
|
1034
1065
|
}
|
|
1035
1066
|
if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
|
|
@@ -1041,7 +1072,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1041
1072
|
weekNum: 0
|
|
1042
1073
|
},
|
|
1043
1074
|
{
|
|
1044
|
-
date: ((
|
|
1075
|
+
date: ((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.end_date) || ((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.start_date) || "",
|
|
1045
1076
|
status: "available",
|
|
1046
1077
|
week: "",
|
|
1047
1078
|
weekNum: 0
|
|
@@ -95,6 +95,15 @@ export declare const getTimesIntersection: (times: TimeSliceItem[], count: numbe
|
|
|
95
95
|
* @Date: 2024-09-19 20:23
|
|
96
96
|
*/
|
|
97
97
|
export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceItem>, ids: number[]) => ResourceItem[];
|
|
98
|
+
/**
|
|
99
|
+
* @title: 合并子资源的时间切片至组合资源
|
|
100
|
+
* @description:
|
|
101
|
+
* @param {ResourceItem[]} resources
|
|
102
|
+
* @param {Record<string, ResourceItem>} resourcesMap
|
|
103
|
+
* @return {*}
|
|
104
|
+
* @Author: zhiwei.Wang
|
|
105
|
+
*/
|
|
106
|
+
export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], resourcesMap: Record<string, ResourceItem>) => void;
|
|
98
107
|
/**
|
|
99
108
|
* @title: 根据资源id列表获取时间切片
|
|
100
109
|
* @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
|
|
@@ -40,7 +40,8 @@ __export(resources_exports, {
|
|
|
40
40
|
getSumCapacity: () => getSumCapacity,
|
|
41
41
|
getTimeSlicesByResource: () => getTimeSlicesByResource,
|
|
42
42
|
getTimeSlicesByResources: () => getTimeSlicesByResources,
|
|
43
|
-
getTimesIntersection: () => getTimesIntersection
|
|
43
|
+
getTimesIntersection: () => getTimesIntersection,
|
|
44
|
+
mergeSubResourcesTimeSlices: () => mergeSubResourcesTimeSlices
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(resources_exports);
|
|
46
47
|
var import_dayjs = __toESM(require("dayjs"));
|
|
@@ -178,6 +179,19 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
178
179
|
(id) => {
|
|
179
180
|
if (resourcesMap[id]) {
|
|
180
181
|
combiningResources.push(resourcesMap[id]);
|
|
182
|
+
childAcc.push(
|
|
183
|
+
Object.assign({}, resourcesMap[id], {
|
|
184
|
+
form_id,
|
|
185
|
+
resourceType: item.type,
|
|
186
|
+
children: combiningResources,
|
|
187
|
+
onlyComputed: true,
|
|
188
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
189
|
+
metadata: {
|
|
190
|
+
...resourcesMap[id].metadata,
|
|
191
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
);
|
|
181
195
|
}
|
|
182
196
|
}
|
|
183
197
|
);
|
|
@@ -207,6 +221,19 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
207
221
|
(id) => {
|
|
208
222
|
if (resourcesMap[id]) {
|
|
209
223
|
combiningResources.push(resourcesMap[id]);
|
|
224
|
+
childAcc.push(
|
|
225
|
+
Object.assign({}, resourcesMap[id], {
|
|
226
|
+
form_id,
|
|
227
|
+
resourceType: item.type,
|
|
228
|
+
children: combiningResources,
|
|
229
|
+
onlyComputed: true,
|
|
230
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
231
|
+
metadata: {
|
|
232
|
+
...resourcesMap[id].metadata,
|
|
233
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
);
|
|
210
237
|
}
|
|
211
238
|
}
|
|
212
239
|
);
|
|
@@ -335,6 +362,24 @@ var getTimesIntersection = (times, count) => {
|
|
|
335
362
|
var getResourcesByIds = (resourcesMap, ids) => {
|
|
336
363
|
return (ids || []).map((id) => resourcesMap[id]);
|
|
337
364
|
};
|
|
365
|
+
var mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
|
|
366
|
+
return resources.forEach((item) => {
|
|
367
|
+
var _a, _b;
|
|
368
|
+
if (((_a = item == null ? void 0 : item.combined_resource) == null ? void 0 : _a.status) === 1) {
|
|
369
|
+
(_b = item == null ? void 0 : item.combined_resource) == null ? void 0 : _b.resource_ids.forEach((id) => {
|
|
370
|
+
const subResource = resourcesMap[id];
|
|
371
|
+
if (subResource) {
|
|
372
|
+
subResource.times.forEach((time) => {
|
|
373
|
+
const fatherResourcesTime = item.times.find((n) => n.start_at === time.start_at && n.end_at === time.end_at);
|
|
374
|
+
if (fatherResourcesTime) {
|
|
375
|
+
fatherResourcesTime.event_list.push(...time.event_list || []);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
};
|
|
338
383
|
var getTimeSlicesByResources = ({
|
|
339
384
|
resourceIds,
|
|
340
385
|
resourcesMap,
|
|
@@ -345,6 +390,7 @@ var getTimeSlicesByResources = ({
|
|
|
345
390
|
resourcesUseableMap
|
|
346
391
|
}) => {
|
|
347
392
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
393
|
+
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
348
394
|
resources.sort((a, b) => {
|
|
349
395
|
var _a, _b, _c, _d;
|
|
350
396
|
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
@@ -506,5 +552,6 @@ var checkSubResourcesCapacity = (resource) => {
|
|
|
506
552
|
getSumCapacity,
|
|
507
553
|
getTimeSlicesByResource,
|
|
508
554
|
getTimeSlicesByResources,
|
|
509
|
-
getTimesIntersection
|
|
555
|
+
getTimesIntersection,
|
|
556
|
+
mergeSubResourcesTimeSlices
|
|
510
557
|
});
|