@pisell/pisellos 2.0.8 → 2.0.10
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/modules/Date/index.js +2 -0
- package/dist/solution/BookingByStep/index.d.ts +4 -2
- package/dist/solution/BookingByStep/index.js +76 -26
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +58 -2
- package/dist/solution/ShopDiscount/index.js +13 -8
- package/dist/solution/ShopDiscount/types.d.ts +1 -0
- package/dist/solution/ShopDiscount/types.js +1 -0
- package/lib/modules/Date/index.js +2 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -2
- package/lib/solution/BookingByStep/index.js +61 -19
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +54 -4
- package/lib/solution/ShopDiscount/index.js +4 -0
- package/lib/solution/ShopDiscount/types.d.ts +1 -0
- package/lib/solution/ShopDiscount/types.js +1 -0
- 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'),
|
|
@@ -1208,12 +1209,26 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1208
1209
|
currentCount: recordCount + (currentCapacity || 0),
|
|
1209
1210
|
resourcesUseableMap: resourcesUseableMap
|
|
1210
1211
|
});
|
|
1211
|
-
|
|
1212
|
+
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1213
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1212
1214
|
resourcesUseableMap[m.id] = res.usable;
|
|
1213
1215
|
}
|
|
1214
1216
|
return res.usable;
|
|
1215
1217
|
});
|
|
1216
|
-
return
|
|
1218
|
+
if (m.onlyComputed) return false;
|
|
1219
|
+
// 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
|
|
1220
|
+
return !canUseArr.some(function (n) {
|
|
1221
|
+
return n === false;
|
|
1222
|
+
});
|
|
1223
|
+
});
|
|
1224
|
+
});
|
|
1225
|
+
} else {
|
|
1226
|
+
productResources.forEach(function (item) {
|
|
1227
|
+
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1228
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1229
|
+
var recordCount = n.capacity || 0;
|
|
1230
|
+
if (n.onlyComputed) return false;
|
|
1231
|
+
return recordCount >= currentCapacity;
|
|
1217
1232
|
});
|
|
1218
1233
|
});
|
|
1219
1234
|
}
|
|
@@ -1265,6 +1280,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1265
1280
|
capacity: formatCapacity
|
|
1266
1281
|
});
|
|
1267
1282
|
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);
|
|
1283
|
+
productResources.forEach(function (item) {
|
|
1284
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1285
|
+
var recordCount = n.capacity || 0;
|
|
1286
|
+
if (n.onlyComputed) return false;
|
|
1287
|
+
return recordCount >= currentCapacity;
|
|
1288
|
+
});
|
|
1289
|
+
});
|
|
1268
1290
|
if (productResources) {
|
|
1269
1291
|
return {
|
|
1270
1292
|
id: targetCartItem.id,
|
|
@@ -1368,7 +1390,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1368
1390
|
currentCount: recordCount + (capacity || 0),
|
|
1369
1391
|
resourcesUseableMap: resourcesUseableMap
|
|
1370
1392
|
});
|
|
1371
|
-
|
|
1393
|
+
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1394
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1372
1395
|
resourcesUseableMap[n.id] = res.usable;
|
|
1373
1396
|
}
|
|
1374
1397
|
return res.usable;
|
|
@@ -1510,6 +1533,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1510
1533
|
_resources.forEach(function (n) {
|
|
1511
1534
|
var _n$renderList;
|
|
1512
1535
|
if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
|
|
1536
|
+
// 过滤掉 capacity 小于 currentCapacity 的资源
|
|
1537
|
+
n.renderList = n.renderList.filter(function (m) {
|
|
1538
|
+
var recordCount = m.capacity || 0;
|
|
1539
|
+
return recordCount >= currentCapacity;
|
|
1540
|
+
});
|
|
1513
1541
|
currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
|
|
1514
1542
|
}
|
|
1515
1543
|
});
|
|
@@ -1520,6 +1548,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1520
1548
|
selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap);
|
|
1521
1549
|
}
|
|
1522
1550
|
var productResources = getResourcesByProduct(_resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
|
|
1551
|
+
productResources.forEach(function (item) {
|
|
1552
|
+
item.renderList = item.renderList.filter(function (n) {
|
|
1553
|
+
var recordCount = n.capacity || 0;
|
|
1554
|
+
if (n.onlyComputed) return false;
|
|
1555
|
+
return recordCount >= currentCapacity;
|
|
1556
|
+
});
|
|
1557
|
+
});
|
|
1523
1558
|
// 自动选择 productResources 中对应 resources_code 的资源
|
|
1524
1559
|
var targetRenderList = (_productResources$fin = productResources.find(function (n) {
|
|
1525
1560
|
return n.code === resources_code;
|
|
@@ -1568,7 +1603,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1568
1603
|
}, {
|
|
1569
1604
|
key: "getTimeSlotByAllResources",
|
|
1570
1605
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1571
|
-
var
|
|
1606
|
+
var _dateRange,
|
|
1607
|
+
_this9 = this,
|
|
1572
1608
|
_cartItems$,
|
|
1573
1609
|
_cartItems$2;
|
|
1574
1610
|
var dateRange = this.store.date.getDateRange();
|
|
@@ -1577,8 +1613,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1577
1613
|
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1578
1614
|
// if (cartItems?.[0].start_date) return [];
|
|
1579
1615
|
var resourceIds = [];
|
|
1616
|
+
var resourcesTypeId = undefined;
|
|
1580
1617
|
cartItems.forEach(function (item) {
|
|
1581
|
-
var _item$_productOrigin9;
|
|
1618
|
+
var _item$_productOrigin9, _item$_productOrigin10;
|
|
1582
1619
|
(_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) {
|
|
1583
1620
|
if (n.code === resources_code) {
|
|
1584
1621
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -1590,7 +1627,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1590
1627
|
if (item.resource_id) {
|
|
1591
1628
|
resourceIds.push(item.resource_id);
|
|
1592
1629
|
}
|
|
1630
|
+
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) {
|
|
1631
|
+
return n.code === resources_code;
|
|
1632
|
+
})) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.id;
|
|
1593
1633
|
});
|
|
1634
|
+
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1635
|
+
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
1636
|
+
// resources.push(...dateRange[0].resource);
|
|
1637
|
+
dateRange[0].resource.forEach(function (n) {
|
|
1638
|
+
if (n.form_id === resourcesTypeId && !resources.find(function (m) {
|
|
1639
|
+
return m.id === n.id;
|
|
1640
|
+
})) {
|
|
1641
|
+
resources.push(n);
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1594
1645
|
var resourcesMap = getResourcesMap(resources);
|
|
1595
1646
|
var duration = 0;
|
|
1596
1647
|
// duration = 不同账号的最长时间
|
|
@@ -1598,8 +1649,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1598
1649
|
var checkDuration = function checkDuration(cartItems) {
|
|
1599
1650
|
var accountDuration = 0;
|
|
1600
1651
|
cartItems.forEach(function (item) {
|
|
1601
|
-
var _item$_productOrigin$3, _item$
|
|
1602
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
1652
|
+
var _item$_productOrigin$3, _item$_productOrigin11;
|
|
1653
|
+
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;
|
|
1603
1654
|
});
|
|
1604
1655
|
if (accountDuration > duration) {
|
|
1605
1656
|
duration = accountDuration;
|
|
@@ -1668,9 +1719,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1668
1719
|
accountItems.forEach(function (item, index) {
|
|
1669
1720
|
var newResources = cloneDeep(item._origin.resources);
|
|
1670
1721
|
newResources.forEach(function (resource) {
|
|
1671
|
-
var _item$_productOrigin$4, _item$
|
|
1722
|
+
var _item$_productOrigin$4, _item$_productOrigin12, _ref11, _item$_productOrigin13;
|
|
1672
1723
|
resource.startTime = currentStartTime;
|
|
1673
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$
|
|
1724
|
+
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');
|
|
1674
1725
|
delete resource.times;
|
|
1675
1726
|
});
|
|
1676
1727
|
_this10.store.cart.updateItem({
|
|
@@ -1811,10 +1862,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1811
1862
|
currentCount: 1,
|
|
1812
1863
|
resourcesUseableMap: resourcesUseableMap
|
|
1813
1864
|
});
|
|
1814
|
-
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false) {
|
|
1865
|
+
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1815
1866
|
resourcesUseableMap[m.id] = res.usable;
|
|
1816
1867
|
}
|
|
1817
|
-
// 如果资源可用,且是独占资源,remainingCapacity 始终为 1
|
|
1818
1868
|
if (res.usable && res.remainingCapacity >= count) {
|
|
1819
1869
|
count = res.remainingCapacity;
|
|
1820
1870
|
}
|
|
@@ -38,6 +38,7 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
|
|
|
38
38
|
capacity: boolean;
|
|
39
39
|
usable: boolean;
|
|
40
40
|
remainingCapacity: number;
|
|
41
|
+
reason: string;
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
44
|
* @title: 获取商品下绑定的资源列表
|
|
@@ -95,6 +96,15 @@ export declare const getTimesIntersection: (times: TimeSliceItem[], count: numbe
|
|
|
95
96
|
* @Date: 2024-09-19 20:23
|
|
96
97
|
*/
|
|
97
98
|
export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceItem>, ids: number[]) => ResourceItem[];
|
|
99
|
+
/**
|
|
100
|
+
* @title: 合并子资源的时间切片至组合资源
|
|
101
|
+
* @description:
|
|
102
|
+
* @param {ResourceItem[]} resources
|
|
103
|
+
* @param {Record<string, ResourceItem>} resourcesMap
|
|
104
|
+
* @return {*}
|
|
105
|
+
* @Author: zhiwei.Wang
|
|
106
|
+
*/
|
|
107
|
+
export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], resourcesMap: Record<string, ResourceItem>) => void;
|
|
98
108
|
/**
|
|
99
109
|
* @title: 根据资源id列表获取时间切片
|
|
100
110
|
* @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
|
|
@@ -113,7 +113,8 @@ var checkCapacity = function checkCapacity(_ref) {
|
|
|
113
113
|
if (currentCount > resource.capacity) {
|
|
114
114
|
return {
|
|
115
115
|
status: false,
|
|
116
|
-
capacity: resource.capacity
|
|
116
|
+
capacity: resource.capacity,
|
|
117
|
+
reason: 'capacityOnly'
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
120
|
var conflict = (event_list || []).filter(function (d) {
|
|
@@ -179,7 +180,9 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
179
180
|
afterToDay: false,
|
|
180
181
|
capacity: false,
|
|
181
182
|
usable: false,
|
|
182
|
-
remainingCapacity: 0
|
|
183
|
+
remainingCapacity: 0,
|
|
184
|
+
// 剩余容量
|
|
185
|
+
reason: ''
|
|
183
186
|
};
|
|
184
187
|
// 最早可预约时间为 当前日期之后并且提前量之后
|
|
185
188
|
var earliest = dayjs();
|
|
@@ -204,6 +207,7 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
204
207
|
}
|
|
205
208
|
});
|
|
206
209
|
}
|
|
210
|
+
status.reason = checkCapacityResult.reason || '';
|
|
207
211
|
if (!checkCapacityResult.status) {
|
|
208
212
|
return status;
|
|
209
213
|
}
|
|
@@ -238,6 +242,16 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
238
242
|
resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
|
|
239
243
|
if (resourcesMap[id]) {
|
|
240
244
|
combiningResources.push(resourcesMap[id]);
|
|
245
|
+
childAcc.push(Object.assign({}, resourcesMap[id], {
|
|
246
|
+
form_id: form_id,
|
|
247
|
+
resourceType: item.type,
|
|
248
|
+
children: combiningResources,
|
|
249
|
+
onlyComputed: true,
|
|
250
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
251
|
+
metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
|
|
252
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
253
|
+
})
|
|
254
|
+
}));
|
|
241
255
|
}
|
|
242
256
|
});
|
|
243
257
|
}
|
|
@@ -260,6 +274,16 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
260
274
|
resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
|
|
261
275
|
if (resourcesMap[id]) {
|
|
262
276
|
combiningResources.push(resourcesMap[id]);
|
|
277
|
+
childAcc.push(Object.assign({}, resourcesMap[id], {
|
|
278
|
+
form_id: form_id,
|
|
279
|
+
resourceType: item.type,
|
|
280
|
+
children: combiningResources,
|
|
281
|
+
onlyComputed: true,
|
|
282
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
283
|
+
metadata: _objectSpread(_objectSpread({}, resourcesMap[id].metadata), {}, {
|
|
284
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
285
|
+
})
|
|
286
|
+
}));
|
|
263
287
|
}
|
|
264
288
|
});
|
|
265
289
|
}
|
|
@@ -458,6 +482,37 @@ export var getResourcesByIds = function getResourcesByIds(resourcesMap, ids) {
|
|
|
458
482
|
});
|
|
459
483
|
};
|
|
460
484
|
|
|
485
|
+
/**
|
|
486
|
+
* @title: 合并子资源的时间切片至组合资源
|
|
487
|
+
* @description:
|
|
488
|
+
* @param {ResourceItem[]} resources
|
|
489
|
+
* @param {Record<string, ResourceItem>} resourcesMap
|
|
490
|
+
* @return {*}
|
|
491
|
+
* @Author: zhiwei.Wang
|
|
492
|
+
*/
|
|
493
|
+
export var mergeSubResourcesTimeSlices = function mergeSubResourcesTimeSlices(resources, resourcesMap) {
|
|
494
|
+
return resources.forEach(function (item) {
|
|
495
|
+
var _item$combined_resour;
|
|
496
|
+
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) {
|
|
497
|
+
var _item$combined_resour2;
|
|
498
|
+
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) {
|
|
499
|
+
var subResource = resourcesMap[id];
|
|
500
|
+
if (subResource) {
|
|
501
|
+
subResource.times.forEach(function (time) {
|
|
502
|
+
var fatherResourcesTime = item.times.find(function (n) {
|
|
503
|
+
return n.start_at === time.start_at && n.end_at === time.end_at;
|
|
504
|
+
});
|
|
505
|
+
if (fatherResourcesTime) {
|
|
506
|
+
var _fatherResourcesTime$;
|
|
507
|
+
(_fatherResourcesTime$ = fatherResourcesTime.event_list).push.apply(_fatherResourcesTime$, _toConsumableArray(time.event_list || []));
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
|
|
461
516
|
/**
|
|
462
517
|
* @title: 根据资源id列表获取时间切片
|
|
463
518
|
* @description: 传入一个技师id列表, 找出技师列表中公共的时间切片
|
|
@@ -476,6 +531,7 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
476
531
|
resourcesUseableMap = _ref5.resourcesUseableMap;
|
|
477
532
|
// 获取资源列表
|
|
478
533
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
534
|
+
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
479
535
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
480
536
|
resources.sort(function (a, b) {
|
|
481
537
|
var _a$metadata, _b$metadata;
|
|
@@ -483,21 +483,26 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
483
483
|
});
|
|
484
484
|
case 3:
|
|
485
485
|
result = _context7.sent;
|
|
486
|
-
if (result !== null && result !== void 0 && result.data) {
|
|
487
|
-
|
|
488
|
-
|
|
486
|
+
if (!(result !== null && result !== void 0 && result.data)) {
|
|
487
|
+
_context7.next = 9;
|
|
488
|
+
break;
|
|
489
489
|
}
|
|
490
|
-
|
|
490
|
+
_result$data = result.data, wallet_pass_list = _result$data.wallet_pass_list, customer = _objectWithoutProperties(_result$data, _excluded);
|
|
491
|
+
this.setCustomer(customer);
|
|
492
|
+
_context7.next = 9;
|
|
493
|
+
return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
|
|
494
|
+
case 9:
|
|
495
|
+
_context7.next = 14;
|
|
491
496
|
break;
|
|
492
|
-
case
|
|
493
|
-
_context7.prev =
|
|
497
|
+
case 11:
|
|
498
|
+
_context7.prev = 11;
|
|
494
499
|
_context7.t0 = _context7["catch"](0);
|
|
495
500
|
console.error('[ShopDiscount] 获取客户钱包信息出错:', _context7.t0);
|
|
496
|
-
case
|
|
501
|
+
case 14:
|
|
497
502
|
case "end":
|
|
498
503
|
return _context7.stop();
|
|
499
504
|
}
|
|
500
|
-
}, _callee7, this, [[0,
|
|
505
|
+
}, _callee7, this, [[0, 11]]);
|
|
501
506
|
}));
|
|
502
507
|
function getCustomerWallet(_x6) {
|
|
503
508
|
return _getCustomerWallet.apply(this, arguments);
|
|
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
|
|
|
5
5
|
onDestroy = "shopDiscount:onDestroy",
|
|
6
6
|
onLoadDiscountList = "shopDiscount:onLoadDiscountList",
|
|
7
7
|
onCustomerChange = "shopDiscount:onCustomerChange",
|
|
8
|
+
onScanCustomerChange = "shopDiscount:onScanCustomerChange",
|
|
8
9
|
onDiscountListChange = "shopDiscount:onDiscountListChange",
|
|
9
10
|
onRulesListChange = "shopDiscount:onRulesListChange",
|
|
10
11
|
onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
|
|
@@ -3,6 +3,7 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
|
|
|
3
3
|
ShopDiscountHooks["onDestroy"] = "shopDiscount:onDestroy";
|
|
4
4
|
ShopDiscountHooks["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
|
|
5
5
|
ShopDiscountHooks["onCustomerChange"] = "shopDiscount:onCustomerChange";
|
|
6
|
+
ShopDiscountHooks["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
|
|
6
7
|
ShopDiscountHooks["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
|
|
7
8
|
ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
8
9
|
ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|
|
@@ -83,6 +83,8 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
83
83
|
end_date,
|
|
84
84
|
resource_ids,
|
|
85
85
|
front_end_cache_id: this.cacheId
|
|
86
|
+
}, {
|
|
87
|
+
useCache: true
|
|
86
88
|
});
|
|
87
89
|
if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
|
|
88
90
|
return (0, import_utils.disableAllDates)(dates);
|
|
@@ -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"),
|
|
@@ -659,12 +661,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
659
661
|
currentCount: recordCount + (currentCapacity || 0),
|
|
660
662
|
resourcesUseableMap
|
|
661
663
|
});
|
|
662
|
-
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false) {
|
|
664
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
663
665
|
resourcesUseableMap[m.id] = res.usable;
|
|
664
666
|
}
|
|
665
667
|
return res.usable;
|
|
666
668
|
});
|
|
667
|
-
|
|
669
|
+
if (m.onlyComputed)
|
|
670
|
+
return false;
|
|
671
|
+
return !canUseArr.some((n2) => n2 === false);
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
} else {
|
|
675
|
+
productResources.forEach((item) => {
|
|
676
|
+
item.renderList = item.renderList.filter((n) => {
|
|
677
|
+
const recordCount = n.capacity || 0;
|
|
678
|
+
if (n.onlyComputed)
|
|
679
|
+
return false;
|
|
680
|
+
return recordCount >= currentCapacity;
|
|
668
681
|
});
|
|
669
682
|
});
|
|
670
683
|
}
|
|
@@ -721,6 +734,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
721
734
|
selectedResources,
|
|
722
735
|
currentCapacity
|
|
723
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
|
+
});
|
|
724
745
|
if (productResources) {
|
|
725
746
|
return {
|
|
726
747
|
id: targetCartItem.id,
|
|
@@ -799,7 +820,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
799
820
|
currentCount: recordCount + (capacity || 0),
|
|
800
821
|
resourcesUseableMap
|
|
801
822
|
});
|
|
802
|
-
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false) {
|
|
823
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== "capacityOnly") {
|
|
803
824
|
resourcesUseableMap[n.id] = res.usable;
|
|
804
825
|
}
|
|
805
826
|
return res.usable;
|
|
@@ -918,6 +939,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
918
939
|
resources2.forEach((n) => {
|
|
919
940
|
var _a3;
|
|
920
941
|
if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
|
|
942
|
+
n.renderList = n.renderList.filter((m) => {
|
|
943
|
+
const recordCount = m.capacity || 0;
|
|
944
|
+
return recordCount >= currentCapacity;
|
|
945
|
+
});
|
|
921
946
|
currentResourcesRenderList.push(...n.renderList || []);
|
|
922
947
|
}
|
|
923
948
|
});
|
|
@@ -941,6 +966,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
941
966
|
selectedResources,
|
|
942
967
|
currentCapacity
|
|
943
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
|
+
});
|
|
944
977
|
const targetRenderList = (_l = productResources.find(
|
|
945
978
|
(n) => n.code === resources_code
|
|
946
979
|
)) == null ? void 0 : _l.renderList;
|
|
@@ -981,13 +1014,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
981
1014
|
}
|
|
982
1015
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
983
1016
|
getTimeSlotByAllResources(resources_code) {
|
|
984
|
-
var _a, _b, _c, _d;
|
|
1017
|
+
var _a, _b, _c, _d, _e, _f;
|
|
985
1018
|
let dateRange = this.store.date.getDateRange();
|
|
986
1019
|
const resources = [];
|
|
987
1020
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
988
1021
|
const resourceIds = [];
|
|
1022
|
+
let resourcesTypeId = void 0;
|
|
989
1023
|
cartItems.forEach((item) => {
|
|
990
|
-
var _a2, _b2, _c2;
|
|
1024
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g;
|
|
991
1025
|
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
992
1026
|
if (n.code === resources_code) {
|
|
993
1027
|
resources.push(...n.renderList || []);
|
|
@@ -996,7 +1030,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
996
1030
|
if (item.resource_id) {
|
|
997
1031
|
resourceIds.push(item.resource_id);
|
|
998
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;
|
|
999
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
|
+
}
|
|
1000
1042
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
1001
1043
|
let duration = 0;
|
|
1002
1044
|
const accountList = this.store.accountList.getAccounts();
|
|
@@ -1018,7 +1060,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1018
1060
|
} else {
|
|
1019
1061
|
checkDuration(cartItems);
|
|
1020
1062
|
}
|
|
1021
|
-
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)) {
|
|
1022
1064
|
return [];
|
|
1023
1065
|
}
|
|
1024
1066
|
if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
|
|
@@ -1030,7 +1072,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1030
1072
|
weekNum: 0
|
|
1031
1073
|
},
|
|
1032
1074
|
{
|
|
1033
|
-
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) || "",
|
|
1034
1076
|
status: "available",
|
|
1035
1077
|
week: "",
|
|
1036
1078
|
weekNum: 0
|
|
@@ -1189,7 +1231,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1189
1231
|
currentCount: 1,
|
|
1190
1232
|
resourcesUseableMap
|
|
1191
1233
|
});
|
|
1192
|
-
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false) {
|
|
1234
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1193
1235
|
resourcesUseableMap[m.id] = res.usable;
|
|
1194
1236
|
}
|
|
1195
1237
|
if (res.usable && res.remainingCapacity >= count) {
|
|
@@ -38,6 +38,7 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
|
|
|
38
38
|
capacity: boolean;
|
|
39
39
|
usable: boolean;
|
|
40
40
|
remainingCapacity: number;
|
|
41
|
+
reason: string;
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
44
|
* @title: 获取商品下绑定的资源列表
|
|
@@ -95,6 +96,15 @@ export declare const getTimesIntersection: (times: TimeSliceItem[], count: numbe
|
|
|
95
96
|
* @Date: 2024-09-19 20:23
|
|
96
97
|
*/
|
|
97
98
|
export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceItem>, ids: number[]) => ResourceItem[];
|
|
99
|
+
/**
|
|
100
|
+
* @title: 合并子资源的时间切片至组合资源
|
|
101
|
+
* @description:
|
|
102
|
+
* @param {ResourceItem[]} resources
|
|
103
|
+
* @param {Record<string, ResourceItem>} resourcesMap
|
|
104
|
+
* @return {*}
|
|
105
|
+
* @Author: zhiwei.Wang
|
|
106
|
+
*/
|
|
107
|
+
export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], resourcesMap: Record<string, ResourceItem>) => void;
|
|
98
108
|
/**
|
|
99
109
|
* @title: 根据资源id列表获取时间切片
|
|
100
110
|
* @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"));
|
|
@@ -84,7 +85,8 @@ var checkCapacity = ({
|
|
|
84
85
|
if (currentCount > resource.capacity) {
|
|
85
86
|
return {
|
|
86
87
|
status: false,
|
|
87
|
-
capacity: resource.capacity
|
|
88
|
+
capacity: resource.capacity,
|
|
89
|
+
reason: "capacityOnly"
|
|
88
90
|
};
|
|
89
91
|
}
|
|
90
92
|
let conflict = (event_list || []).filter((d) => {
|
|
@@ -132,8 +134,9 @@ var getIsUsableByTimeItem = ({
|
|
|
132
134
|
afterToDay: false,
|
|
133
135
|
capacity: false,
|
|
134
136
|
usable: false,
|
|
135
|
-
remainingCapacity: 0
|
|
137
|
+
remainingCapacity: 0,
|
|
136
138
|
// 剩余容量
|
|
139
|
+
reason: ""
|
|
137
140
|
};
|
|
138
141
|
let earliest = (0, import_dayjs.default)();
|
|
139
142
|
if (!checkAfterToDay(timeSlice.start_at, earliest)) {
|
|
@@ -154,6 +157,7 @@ var getIsUsableByTimeItem = ({
|
|
|
154
157
|
}
|
|
155
158
|
});
|
|
156
159
|
}
|
|
160
|
+
status.reason = checkCapacityResult.reason || "";
|
|
157
161
|
if (!checkCapacityResult.status) {
|
|
158
162
|
return status;
|
|
159
163
|
}
|
|
@@ -178,6 +182,19 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
178
182
|
(id) => {
|
|
179
183
|
if (resourcesMap[id]) {
|
|
180
184
|
combiningResources.push(resourcesMap[id]);
|
|
185
|
+
childAcc.push(
|
|
186
|
+
Object.assign({}, resourcesMap[id], {
|
|
187
|
+
form_id,
|
|
188
|
+
resourceType: item.type,
|
|
189
|
+
children: combiningResources,
|
|
190
|
+
onlyComputed: true,
|
|
191
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
192
|
+
metadata: {
|
|
193
|
+
...resourcesMap[id].metadata,
|
|
194
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
);
|
|
181
198
|
}
|
|
182
199
|
}
|
|
183
200
|
);
|
|
@@ -207,6 +224,19 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
207
224
|
(id) => {
|
|
208
225
|
if (resourcesMap[id]) {
|
|
209
226
|
combiningResources.push(resourcesMap[id]);
|
|
227
|
+
childAcc.push(
|
|
228
|
+
Object.assign({}, resourcesMap[id], {
|
|
229
|
+
form_id,
|
|
230
|
+
resourceType: item.type,
|
|
231
|
+
children: combiningResources,
|
|
232
|
+
onlyComputed: true,
|
|
233
|
+
// 是否是只用来计算用,组合资源里,假设商品只关联了组合资源没关联子资源,需要通过这个计算来在后面从 renderList 里删除这个资源
|
|
234
|
+
metadata: {
|
|
235
|
+
...resourcesMap[id].metadata,
|
|
236
|
+
combined_resource: resourcesMap[id].combined_resource
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
);
|
|
210
240
|
}
|
|
211
241
|
}
|
|
212
242
|
);
|
|
@@ -335,6 +365,24 @@ var getTimesIntersection = (times, count) => {
|
|
|
335
365
|
var getResourcesByIds = (resourcesMap, ids) => {
|
|
336
366
|
return (ids || []).map((id) => resourcesMap[id]);
|
|
337
367
|
};
|
|
368
|
+
var mergeSubResourcesTimeSlices = (resources, resourcesMap) => {
|
|
369
|
+
return resources.forEach((item) => {
|
|
370
|
+
var _a, _b;
|
|
371
|
+
if (((_a = item == null ? void 0 : item.combined_resource) == null ? void 0 : _a.status) === 1) {
|
|
372
|
+
(_b = item == null ? void 0 : item.combined_resource) == null ? void 0 : _b.resource_ids.forEach((id) => {
|
|
373
|
+
const subResource = resourcesMap[id];
|
|
374
|
+
if (subResource) {
|
|
375
|
+
subResource.times.forEach((time) => {
|
|
376
|
+
const fatherResourcesTime = item.times.find((n) => n.start_at === time.start_at && n.end_at === time.end_at);
|
|
377
|
+
if (fatherResourcesTime) {
|
|
378
|
+
fatherResourcesTime.event_list.push(...time.event_list || []);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
};
|
|
338
386
|
var getTimeSlicesByResources = ({
|
|
339
387
|
resourceIds,
|
|
340
388
|
resourcesMap,
|
|
@@ -345,6 +393,7 @@ var getTimeSlicesByResources = ({
|
|
|
345
393
|
resourcesUseableMap
|
|
346
394
|
}) => {
|
|
347
395
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
396
|
+
mergeSubResourcesTimeSlices(resources, resourcesMap);
|
|
348
397
|
resources.sort((a, b) => {
|
|
349
398
|
var _a, _b, _c, _d;
|
|
350
399
|
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
@@ -506,5 +555,6 @@ var checkSubResourcesCapacity = (resource) => {
|
|
|
506
555
|
getSumCapacity,
|
|
507
556
|
getTimeSlicesByResource,
|
|
508
557
|
getTimeSlicesByResources,
|
|
509
|
-
getTimesIntersection
|
|
558
|
+
getTimesIntersection,
|
|
559
|
+
mergeSubResourcesTimeSlices
|
|
510
560
|
});
|
|
@@ -313,6 +313,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
313
313
|
if (result == null ? void 0 : result.data) {
|
|
314
314
|
const { wallet_pass_list, ...customer } = result.data;
|
|
315
315
|
this.setCustomer(customer);
|
|
316
|
+
await this.core.effects.emit(
|
|
317
|
+
import_types.ShopDiscountHooks.onScanCustomerChange,
|
|
318
|
+
customer
|
|
319
|
+
);
|
|
316
320
|
}
|
|
317
321
|
} catch (error) {
|
|
318
322
|
console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
|
|
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
|
|
|
5
5
|
onDestroy = "shopDiscount:onDestroy",
|
|
6
6
|
onLoadDiscountList = "shopDiscount:onLoadDiscountList",
|
|
7
7
|
onCustomerChange = "shopDiscount:onCustomerChange",
|
|
8
|
+
onScanCustomerChange = "shopDiscount:onScanCustomerChange",
|
|
8
9
|
onDiscountListChange = "shopDiscount:onDiscountListChange",
|
|
9
10
|
onRulesListChange = "shopDiscount:onRulesListChange",
|
|
10
11
|
onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
|
|
@@ -27,6 +27,7 @@ var ShopDiscountHooks = /* @__PURE__ */ ((ShopDiscountHooks2) => {
|
|
|
27
27
|
ShopDiscountHooks2["onDestroy"] = "shopDiscount:onDestroy";
|
|
28
28
|
ShopDiscountHooks2["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
|
|
29
29
|
ShopDiscountHooks2["onCustomerChange"] = "shopDiscount:onCustomerChange";
|
|
30
|
+
ShopDiscountHooks2["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
|
|
30
31
|
ShopDiscountHooks2["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
|
|
31
32
|
ShopDiscountHooks2["onRulesListChange"] = "shopDiscount:onRulesListChange";
|
|
32
33
|
ShopDiscountHooks2["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
|