@pisell/pisellos 0.0.58 → 0.0.60
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 +38 -17
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +11 -2
- package/lib/solution/BookingByStep/index.js +25 -14
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +12 -2
- package/package.json +1 -1
|
@@ -192,12 +192,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
192
192
|
key: "loadProducts",
|
|
193
193
|
value: function () {
|
|
194
194
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
195
|
-
var
|
|
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
197
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
197
198
|
while (1) switch (_context2.prev = _context2.next) {
|
|
198
199
|
case 0:
|
|
199
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
|
-
|
|
201
|
+
// 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
202
|
+
if (!((_schedule_ids = schedule_ids) !== null && _schedule_ids !== void 0 && _schedule_ids.length)) {
|
|
203
|
+
schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map(function (n) {
|
|
204
|
+
return n.id;
|
|
205
|
+
});
|
|
206
|
+
if (schedule_ids_data.length) {
|
|
207
|
+
schedule_ids = schedule_ids_data;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
_context2.next = 4;
|
|
201
211
|
return this.request.post("/product/query", {
|
|
202
212
|
open_quotation: 1,
|
|
203
213
|
open_bundle: 1,
|
|
@@ -214,11 +224,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
214
224
|
}, {
|
|
215
225
|
useCache: true
|
|
216
226
|
});
|
|
217
|
-
case
|
|
227
|
+
case 4:
|
|
218
228
|
productsData = _context2.sent;
|
|
219
229
|
this.store.products.addProduct(productsData.data.list);
|
|
220
230
|
return _context2.abrupt("return", productsData.data.list);
|
|
221
|
-
case
|
|
231
|
+
case 7:
|
|
222
232
|
case "end":
|
|
223
233
|
return _context2.stop();
|
|
224
234
|
}
|
|
@@ -890,7 +900,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
890
900
|
capacity: (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.capacity,
|
|
891
901
|
product_bundle: item._origin.product.product_bundle
|
|
892
902
|
});
|
|
903
|
+
var currentCapacity = getSumCapacity({
|
|
904
|
+
capacity: formatCapacity
|
|
905
|
+
});
|
|
893
906
|
item._origin.metadata.capacity = formatCapacity;
|
|
907
|
+
item._origin.number = currentCapacity;
|
|
894
908
|
});
|
|
895
909
|
return _context20.abrupt("return", this.store.order.submitOrder({
|
|
896
910
|
query: {
|
|
@@ -1115,7 +1129,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1115
1129
|
});
|
|
1116
1130
|
}
|
|
1117
1131
|
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1118
|
-
var cartItems = this.store.cart.getItems();
|
|
1132
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1119
1133
|
var arr = [];
|
|
1120
1134
|
var capacityMap = {};
|
|
1121
1135
|
cartItems.forEach(function (cartItem) {
|
|
@@ -1193,7 +1207,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1193
1207
|
key: "getResourcesListByCartItem",
|
|
1194
1208
|
value: function getResourcesListByCartItem(id) {
|
|
1195
1209
|
var _targetCartItem$_prod2, _targetCartItem$_prod3;
|
|
1196
|
-
var cartItems = this.store.cart.getItems();
|
|
1210
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1197
1211
|
var dateRange = this.store.date.getDateRange();
|
|
1198
1212
|
var resources = [];
|
|
1199
1213
|
dateRange.forEach(function (n) {
|
|
@@ -1265,7 +1279,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1265
1279
|
countMap = _ref8.countMap,
|
|
1266
1280
|
capacity = _ref8.capacity;
|
|
1267
1281
|
var dateRange = this.store.date.getDateRange();
|
|
1268
|
-
var cartItems = this.store.cart.getItems();
|
|
1282
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1269
1283
|
// 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
|
|
1270
1284
|
var accountCartItems = cartItems.filter(function (n) {
|
|
1271
1285
|
return n.holder_id === holder_id;
|
|
@@ -1323,7 +1337,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1323
1337
|
time: item,
|
|
1324
1338
|
resource: n,
|
|
1325
1339
|
currentCount: recordCount + (capacity || 0),
|
|
1326
|
-
resourcesUseableMap:
|
|
1340
|
+
resourcesUseableMap: resourcesUseableMap
|
|
1327
1341
|
});
|
|
1328
1342
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false) {
|
|
1329
1343
|
resourcesUseableMap[n.id] = res.usable;
|
|
@@ -1459,7 +1473,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1459
1473
|
} else {
|
|
1460
1474
|
var _item$_productOrigin8, _productResources$fin;
|
|
1461
1475
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1462
|
-
var allCartItems = _this7.store.cart.getItems();
|
|
1476
|
+
var allCartItems = cloneDeep(_this7.store.cart.getItems());
|
|
1463
1477
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1464
1478
|
var selectedResources = [];
|
|
1465
1479
|
if (item.holder_id) {
|
|
@@ -1497,7 +1511,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1497
1511
|
}
|
|
1498
1512
|
});
|
|
1499
1513
|
};
|
|
1500
|
-
var cartItems = this.store.cart.getItems();
|
|
1514
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1501
1515
|
|
|
1502
1516
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
1503
1517
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
@@ -1516,11 +1530,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1516
1530
|
}, {
|
|
1517
1531
|
key: "getTimeSlotByAllResources",
|
|
1518
1532
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1519
|
-
var _this8 = this
|
|
1533
|
+
var _this8 = this,
|
|
1534
|
+
_cartItems$,
|
|
1535
|
+
_cartItems$2;
|
|
1520
1536
|
var dateRange = this.store.date.getDateRange();
|
|
1521
1537
|
// 取出购物车中所有一已选择的第一步资源
|
|
1522
1538
|
var resources = [];
|
|
1523
|
-
var cartItems = this.store.cart.getItems();
|
|
1539
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1524
1540
|
// if (cartItems?.[0].start_date) return [];
|
|
1525
1541
|
var resourceIds = [];
|
|
1526
1542
|
cartItems.forEach(function (item) {
|
|
@@ -1559,15 +1575,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1559
1575
|
} else {
|
|
1560
1576
|
checkDuration(cartItems);
|
|
1561
1577
|
}
|
|
1578
|
+
// 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
|
|
1579
|
+
// 同时 session 类商品的流程也不应该调用这个方法
|
|
1580
|
+
if (!(cartItems !== null && cartItems !== void 0 && (_cartItems$ = cartItems[0]) !== null && _cartItems$ !== void 0 && _cartItems$.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$2 = cartItems[0]) !== null && _cartItems$2 !== void 0 && _cartItems$2.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration)) {
|
|
1581
|
+
return [];
|
|
1582
|
+
}
|
|
1562
1583
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].start_date && !dateRange) {
|
|
1563
|
-
var _cartItems
|
|
1584
|
+
var _cartItems$3, _cartItems$4;
|
|
1564
1585
|
dateRange = [{
|
|
1565
1586
|
date: cartItems === null || cartItems === void 0 ? void 0 : cartItems[0].start_date,
|
|
1566
1587
|
status: 'available',
|
|
1567
1588
|
week: '',
|
|
1568
1589
|
weekNum: 0
|
|
1569
1590
|
}, {
|
|
1570
|
-
date: (cartItems === null || cartItems === void 0 || (_cartItems$ = cartItems[0]) === null || _cartItems$ === void 0 ? void 0 : _cartItems
|
|
1591
|
+
date: (cartItems === null || cartItems === void 0 || (_cartItems$3 = cartItems[0]) === null || _cartItems$3 === void 0 ? void 0 : _cartItems$3.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$4 = cartItems[0]) === null || _cartItems$4 === void 0 ? void 0 : _cartItems$4.start_date) || '',
|
|
1571
1592
|
status: 'available',
|
|
1572
1593
|
week: '',
|
|
1573
1594
|
weekNum: 0
|
|
@@ -1591,7 +1612,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1591
1612
|
value: function submitTimeSlot(timeSlots) {
|
|
1592
1613
|
var _this9 = this;
|
|
1593
1614
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
1594
|
-
var cartItems = this.store.cart.getItems();
|
|
1615
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1595
1616
|
|
|
1596
1617
|
// 按账号分组
|
|
1597
1618
|
var itemsByAccount = cartItems.reduce(function (acc, item) {
|
|
@@ -1711,7 +1732,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1711
1732
|
var targetResourceDate = resourcesDates.find(function (n) {
|
|
1712
1733
|
return n.date === date;
|
|
1713
1734
|
});
|
|
1714
|
-
var cartItems = this.store.cart.getItems();
|
|
1735
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1715
1736
|
var resourcesMap = getResourcesMap((targetResourceDate === null || targetResourceDate === void 0 ? void 0 : targetResourceDate.resource) || []);
|
|
1716
1737
|
var selectedResources = getOthersSelectedResources(cartItems, '', resourcesMap);
|
|
1717
1738
|
var productResources = getResourcesByProduct(resourcesMap, resources || ((_this$store$currentPr2 = this.store.currentProduct) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.getData()) === null || _this$store$currentPr2 === void 0 || (_this$store$currentPr2 = _this$store$currentPr2.product_resource) === null || _this$store$currentPr2 === void 0 ? void 0 : _this$store$currentPr2.resources) || [], selectedResources, 1);
|
|
@@ -1803,7 +1824,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1803
1824
|
});
|
|
1804
1825
|
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
1805
1826
|
if (date) {
|
|
1806
|
-
var cartItems = this.store.cart.getItems();
|
|
1827
|
+
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
1807
1828
|
var cartItemsByDate = cartItems.filter(function (n) {
|
|
1808
1829
|
return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
|
|
1809
1830
|
});
|
|
@@ -27,7 +27,7 @@ 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, }: {
|
|
31
31
|
timeSlice: TimeSliceItem;
|
|
32
32
|
time: any;
|
|
33
33
|
resource: ResourceItem;
|
|
@@ -231,7 +231,7 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
231
231
|
return item.default_resource.indexOf(d) == -1;
|
|
232
232
|
});
|
|
233
233
|
var optional_resource = item.optional_resource.reduce(function (childAcc, d) {
|
|
234
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)
|
|
234
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
235
235
|
// 拼装组合资源的数据
|
|
236
236
|
var combiningResources = [];
|
|
237
237
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
@@ -253,7 +253,7 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
253
253
|
return childAcc;
|
|
254
254
|
}, []);
|
|
255
255
|
var default_resource = item.default_resource.reduce(function (childAcc, d) {
|
|
256
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)
|
|
256
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
257
257
|
// 拼装组合资源的数据
|
|
258
258
|
var combiningResources = [];
|
|
259
259
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
@@ -475,6 +475,15 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
475
475
|
resourcesUseableMap = _ref5.resourcesUseableMap;
|
|
476
476
|
// 获取资源列表
|
|
477
477
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
478
|
+
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
479
|
+
resources.sort(function (a, b) {
|
|
480
|
+
var _a$metadata, _b$metadata;
|
|
481
|
+
var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
|
|
482
|
+
var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
|
|
483
|
+
if (aIsCombined && !bIsCombined) return 1;
|
|
484
|
+
if (!aIsCombined && bIsCombined) return -1;
|
|
485
|
+
return 0;
|
|
486
|
+
});
|
|
478
487
|
|
|
479
488
|
// 获取资源列表中所有的时间切片
|
|
480
489
|
var timeSliceList = resources.reduce(function (acc, item) {
|
|
@@ -153,6 +153,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
153
153
|
collection = [],
|
|
154
154
|
schedule_ids = []
|
|
155
155
|
}) {
|
|
156
|
+
if (!(schedule_ids == null ? void 0 : schedule_ids.length)) {
|
|
157
|
+
const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
|
|
158
|
+
if (schedule_ids_data.length) {
|
|
159
|
+
schedule_ids = schedule_ids_data;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
156
162
|
const productsData = await this.request.post(
|
|
157
163
|
`/product/query`,
|
|
158
164
|
{
|
|
@@ -442,7 +448,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
442
448
|
capacity: (_a = item._productOrigin) == null ? void 0 : _a.capacity,
|
|
443
449
|
product_bundle: item._origin.product.product_bundle
|
|
444
450
|
});
|
|
451
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
445
452
|
item._origin.metadata.capacity = formatCapacity;
|
|
453
|
+
item._origin.number = currentCapacity;
|
|
446
454
|
});
|
|
447
455
|
return this.store.order.submitOrder({ query: { cartItems: newCartItems } });
|
|
448
456
|
}
|
|
@@ -563,7 +571,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
563
571
|
});
|
|
564
572
|
}
|
|
565
573
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
566
|
-
const cartItems = this.store.cart.getItems();
|
|
574
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
567
575
|
const arr = [];
|
|
568
576
|
const capacityMap = {};
|
|
569
577
|
cartItems.forEach((cartItem) => {
|
|
@@ -653,7 +661,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
653
661
|
// 给单个购物车里的商品获取资源列表
|
|
654
662
|
getResourcesListByCartItem(id) {
|
|
655
663
|
var _a, _b, _c;
|
|
656
|
-
const cartItems = this.store.cart.getItems();
|
|
664
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
657
665
|
const dateRange = this.store.date.getDateRange();
|
|
658
666
|
const resources = [];
|
|
659
667
|
dateRange.forEach((n) => {
|
|
@@ -727,7 +735,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
727
735
|
capacity
|
|
728
736
|
}) {
|
|
729
737
|
const dateRange = this.store.date.getDateRange();
|
|
730
|
-
const cartItems = this.store.cart.getItems();
|
|
738
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
731
739
|
let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
732
740
|
if (!accountCartItems.length) {
|
|
733
741
|
accountCartItems = cartItems;
|
|
@@ -766,7 +774,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
766
774
|
time: item,
|
|
767
775
|
resource: n,
|
|
768
776
|
currentCount: recordCount + (capacity || 0),
|
|
769
|
-
resourcesUseableMap
|
|
777
|
+
resourcesUseableMap
|
|
770
778
|
});
|
|
771
779
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false) {
|
|
772
780
|
resourcesUseableMap[n.id] = res.usable;
|
|
@@ -880,7 +888,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
880
888
|
errorList.push(item._id);
|
|
881
889
|
}
|
|
882
890
|
} else {
|
|
883
|
-
const allCartItems = this.store.cart.getItems();
|
|
891
|
+
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
884
892
|
let selectedResources = [];
|
|
885
893
|
if (item.holder_id) {
|
|
886
894
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
@@ -928,7 +936,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
928
936
|
}
|
|
929
937
|
});
|
|
930
938
|
};
|
|
931
|
-
const cartItems = this.store.cart.getItems();
|
|
939
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
932
940
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
933
941
|
accountList.forEach((account) => {
|
|
934
942
|
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
@@ -941,14 +949,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
941
949
|
}
|
|
942
950
|
// 从购物车中获取已经分配好第一步资源的所有时间片
|
|
943
951
|
getTimeSlotByAllResources(resources_code) {
|
|
944
|
-
var _a, _b;
|
|
952
|
+
var _a, _b, _c, _d;
|
|
945
953
|
let dateRange = this.store.date.getDateRange();
|
|
946
954
|
const resources = [];
|
|
947
|
-
const cartItems = this.store.cart.getItems();
|
|
955
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
948
956
|
const resourceIds = [];
|
|
949
957
|
cartItems.forEach((item) => {
|
|
950
|
-
var _a2, _b2,
|
|
951
|
-
(
|
|
958
|
+
var _a2, _b2, _c2;
|
|
959
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
952
960
|
if (n.code === resources_code) {
|
|
953
961
|
resources.push(...n.renderList || []);
|
|
954
962
|
}
|
|
@@ -978,6 +986,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
978
986
|
} else {
|
|
979
987
|
checkDuration(cartItems);
|
|
980
988
|
}
|
|
989
|
+
if (!((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.start_date) && !((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
|
|
990
|
+
return [];
|
|
991
|
+
}
|
|
981
992
|
if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
|
|
982
993
|
dateRange = [
|
|
983
994
|
{
|
|
@@ -987,7 +998,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
987
998
|
weekNum: 0
|
|
988
999
|
},
|
|
989
1000
|
{
|
|
990
|
-
date: ((
|
|
1001
|
+
date: ((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.end_date) || ((_d = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _d.start_date) || "",
|
|
991
1002
|
status: "available",
|
|
992
1003
|
week: "",
|
|
993
1004
|
weekNum: 0
|
|
@@ -1007,7 +1018,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1007
1018
|
}
|
|
1008
1019
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
1009
1020
|
submitTimeSlot(timeSlots) {
|
|
1010
|
-
const cartItems = this.store.cart.getItems();
|
|
1021
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1011
1022
|
const itemsByAccount = cartItems.reduce(
|
|
1012
1023
|
(acc, item) => {
|
|
1013
1024
|
const holderId = item.holder_id;
|
|
@@ -1101,7 +1112,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1101
1112
|
}
|
|
1102
1113
|
const resourcesDates = this.store.date.getDateList();
|
|
1103
1114
|
const targetResourceDate = resourcesDates.find((n) => n.date === date);
|
|
1104
|
-
const cartItems = this.store.cart.getItems();
|
|
1115
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1105
1116
|
const resourcesMap = (0, import_utils.getResourcesMap)((targetResourceDate == null ? void 0 : targetResourceDate.resource) || []);
|
|
1106
1117
|
const selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1107
1118
|
cartItems,
|
|
@@ -1190,7 +1201,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1190
1201
|
options
|
|
1191
1202
|
});
|
|
1192
1203
|
if (date) {
|
|
1193
|
-
const cartItems = this.store.cart.getItems();
|
|
1204
|
+
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1194
1205
|
const cartItemsByDate = cartItems.filter(
|
|
1195
1206
|
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
1196
1207
|
);
|
|
@@ -27,7 +27,7 @@ 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, }: {
|
|
31
31
|
timeSlice: TimeSliceItem;
|
|
32
32
|
time: any;
|
|
33
33
|
resource: ResourceItem;
|
|
@@ -171,7 +171,7 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
171
171
|
);
|
|
172
172
|
let optional_resource = item.optional_resource.reduce(
|
|
173
173
|
(childAcc, d) => {
|
|
174
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)
|
|
174
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
175
175
|
const combiningResources = [];
|
|
176
176
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
177
177
|
resourcesMap[d].combined_resource.resource_ids.forEach(
|
|
@@ -200,7 +200,7 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
200
200
|
);
|
|
201
201
|
let default_resource = item.default_resource.reduce(
|
|
202
202
|
(childAcc, d) => {
|
|
203
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)
|
|
203
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
204
204
|
const combiningResources = [];
|
|
205
205
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
206
206
|
resourcesMap[d].combined_resource.resource_ids.forEach(
|
|
@@ -345,6 +345,16 @@ var getTimeSlicesByResources = ({
|
|
|
345
345
|
resourcesUseableMap
|
|
346
346
|
}) => {
|
|
347
347
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
348
|
+
resources.sort((a, b) => {
|
|
349
|
+
var _a, _b, _c, _d;
|
|
350
|
+
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
351
|
+
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
352
|
+
if (aIsCombined && !bIsCombined)
|
|
353
|
+
return 1;
|
|
354
|
+
if (!aIsCombined && bIsCombined)
|
|
355
|
+
return -1;
|
|
356
|
+
return 0;
|
|
357
|
+
});
|
|
348
358
|
let timeSliceList = resources.reduce(
|
|
349
359
|
(acc, item) => {
|
|
350
360
|
return acc.concat(
|