@pisell/pisellos 0.0.80 → 0.0.82
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/AccountList/index.d.ts +6 -3
- package/dist/modules/AccountList/index.js +57 -37
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/solution/BookingByStep/index.js +134 -63
- package/dist/solution/BookingByStep/utils/resources.js +18 -12
- package/lib/modules/AccountList/index.d.ts +6 -3
- package/lib/modules/AccountList/index.js +30 -9
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/solution/BookingByStep/index.js +114 -64
- package/lib/solution/BookingByStep/utils/resources.js +6 -12
- package/package.json +1 -1
|
@@ -272,10 +272,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
272
272
|
// 添加单个账户或者 guest
|
|
273
273
|
async addAccount(account, extra) {
|
|
274
274
|
if ((extra == null ? void 0 : extra.type) === "holder") {
|
|
275
|
-
const accountModules = await this.store.accountList.addHolderAccounts(
|
|
276
|
-
[account],
|
|
277
|
-
extra.customerId
|
|
278
|
-
|
|
275
|
+
const accountModules = await this.store.accountList.addHolderAccounts({
|
|
276
|
+
holders: [account],
|
|
277
|
+
customerId: extra.customerId,
|
|
278
|
+
type: "unshift"
|
|
279
|
+
});
|
|
279
280
|
return accountModules[0].getAccount();
|
|
280
281
|
}
|
|
281
282
|
const newAccount = await this.store.accountList.addAccount(
|
|
@@ -286,10 +287,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
286
287
|
// 添加账户或者 guest
|
|
287
288
|
async addAccounts(accounts, extra) {
|
|
288
289
|
if ((extra == null ? void 0 : extra.type) === "holder") {
|
|
289
|
-
this.store.accountList.addHolderAccounts(
|
|
290
|
-
accounts,
|
|
291
|
-
extra.customerId
|
|
292
|
-
|
|
290
|
+
this.store.accountList.addHolderAccounts({
|
|
291
|
+
holders: accounts,
|
|
292
|
+
customerId: extra.customerId,
|
|
293
|
+
type: "unshift"
|
|
294
|
+
});
|
|
293
295
|
return;
|
|
294
296
|
}
|
|
295
297
|
const res = [];
|
|
@@ -347,7 +349,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
347
349
|
}
|
|
348
350
|
// 获取商品/服务的可用日期
|
|
349
351
|
async getAvailableDate(params = {}) {
|
|
350
|
-
var _a, _b;
|
|
352
|
+
var _a, _b, _c;
|
|
351
353
|
let { products, startDate, endDate, type } = params;
|
|
352
354
|
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
353
355
|
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
@@ -371,7 +373,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
371
373
|
}
|
|
372
374
|
let dateRange = this.store.date.getDateRange();
|
|
373
375
|
const tempStartDate = startDate || ((_a = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _a.date);
|
|
374
|
-
const tempEndDate = endDate || ((_b = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _b.date);
|
|
376
|
+
const tempEndDate = endDate || ((_b = dateRange == null ? void 0 : dateRange[1]) == null ? void 0 : _b.date) || ((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date);
|
|
375
377
|
if (!tempProducts.length) {
|
|
376
378
|
return [];
|
|
377
379
|
}
|
|
@@ -495,6 +497,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
495
497
|
if (!targetCartItem) {
|
|
496
498
|
throw new Error(`没有找到${params._id}购物车商品`);
|
|
497
499
|
}
|
|
500
|
+
let currentResourcesCapacityMap = {};
|
|
498
501
|
if (params.resources) {
|
|
499
502
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
500
503
|
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
@@ -503,21 +506,50 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
503
506
|
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
504
507
|
params.resources = params.resources.map((n) => {
|
|
505
508
|
n.capacity = currentCapacity || 1;
|
|
509
|
+
currentResourcesCapacityMap[n.id] = currentCapacity;
|
|
506
510
|
(0, import_resources.checkSubResourcesCapacity)(n);
|
|
507
511
|
return n;
|
|
508
512
|
});
|
|
509
513
|
}
|
|
510
514
|
this.store.cart.updateItem(params);
|
|
515
|
+
const allOriginResources = [];
|
|
516
|
+
const dateRange = this.store.date.getDateRange();
|
|
517
|
+
if (dateRange == null ? void 0 : dateRange.length) {
|
|
518
|
+
dateRange.forEach((n) => {
|
|
519
|
+
if (n.resource)
|
|
520
|
+
allOriginResources.push(...n.resource);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
if (!allOriginResources.length) {
|
|
524
|
+
const dateList = this.store.date.getDateList();
|
|
525
|
+
dateList.forEach((n) => {
|
|
526
|
+
if (n.resource)
|
|
527
|
+
allOriginResources.push(...n.resource);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
511
530
|
const cartItems = this.store.cart.getItems();
|
|
512
531
|
cartItems.forEach((item) => {
|
|
513
532
|
var _a2;
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
533
|
+
const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
|
|
534
|
+
return !targetCartItem._origin.resources.some((targetRes) => {
|
|
535
|
+
var _a3, _b, _c;
|
|
536
|
+
if (targetRes.resourceType !== "single") {
|
|
537
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
538
|
+
capacity: (_a3 = item._productOrigin) == null ? void 0 : _a3.capacity,
|
|
539
|
+
product_bundle: item._origin.product.product_bundle
|
|
540
|
+
});
|
|
541
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
542
|
+
const originResource = allOriginResources.find((n) => n.id === targetRes.id);
|
|
543
|
+
if (currentResourcesCapacityMap[targetRes.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
|
|
544
|
+
return true;
|
|
545
|
+
}
|
|
546
|
+
currentResourcesCapacityMap[targetRes.id] += currentCapacity;
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
518
550
|
if (targetRes.id === m.id)
|
|
519
551
|
return true;
|
|
520
|
-
if (((
|
|
552
|
+
if (((_b = targetRes.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
521
553
|
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
522
554
|
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
523
555
|
(targetRes.metadata.combined_resource.resource_ids.includes(
|
|
@@ -530,11 +562,26 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
530
562
|
}
|
|
531
563
|
)))
|
|
532
564
|
return true;
|
|
533
|
-
if (((
|
|
565
|
+
if (((_c = m.metadata.combined_resource) == null ? void 0 : _c.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
|
|
534
566
|
return true;
|
|
535
|
-
|
|
536
|
-
|
|
567
|
+
}
|
|
568
|
+
return false;
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
if (item.start_time) {
|
|
572
|
+
const start_time = item.start_time;
|
|
573
|
+
const end_time = item.end_time;
|
|
574
|
+
const start_date = item.start_date;
|
|
575
|
+
const end_date = item.end_date;
|
|
576
|
+
this.store.cart.updateItem({
|
|
577
|
+
_id: item._id,
|
|
578
|
+
resources,
|
|
579
|
+
date: {
|
|
580
|
+
startTime: (0, import_dayjs.default)(`${start_date} ${start_time}`).format("YYYY-MM-DD HH:mm"),
|
|
581
|
+
endTime: (0, import_dayjs.default)(`${end_date} ${end_time}`).format("YYYY-MM-DD HH:mm")
|
|
582
|
+
}
|
|
537
583
|
});
|
|
584
|
+
} else {
|
|
538
585
|
this.store.cart.updateItem({
|
|
539
586
|
_id: item._id,
|
|
540
587
|
resources
|
|
@@ -621,10 +668,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
621
668
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
622
669
|
const cartItems = this.store.cart.getItems();
|
|
623
670
|
const arr = [];
|
|
624
|
-
const capacityMap = {};
|
|
625
671
|
cartItems.forEach((cartItem) => {
|
|
626
672
|
var _a, _b, _c;
|
|
627
673
|
let selectedResources = [];
|
|
674
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
675
|
+
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
676
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
677
|
+
});
|
|
678
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
679
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
628
680
|
if (cartItem.holder_id) {
|
|
629
681
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
630
682
|
cartItems,
|
|
@@ -638,12 +690,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
638
690
|
resourcesMap
|
|
639
691
|
);
|
|
640
692
|
}
|
|
641
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
642
|
-
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
643
|
-
product_bundle: cartItem._origin.product.product_bundle
|
|
644
|
-
});
|
|
645
|
-
cartItem._origin.metadata.capacity = formatCapacity;
|
|
646
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
647
693
|
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
648
694
|
resourcesMap,
|
|
649
695
|
((_c = (_b = cartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
@@ -670,7 +716,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
670
716
|
return 0;
|
|
671
717
|
});
|
|
672
718
|
n.renderList = n.renderList.filter((m) => {
|
|
673
|
-
const recordCount = capacityMap[m.id] || 0;
|
|
674
719
|
const mTimes = m.times.filter((n2) => {
|
|
675
720
|
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
676
721
|
});
|
|
@@ -687,7 +732,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
687
732
|
},
|
|
688
733
|
time: item,
|
|
689
734
|
resource: m,
|
|
690
|
-
currentCount:
|
|
735
|
+
currentCount: currentCapacity || 0,
|
|
691
736
|
resourcesUseableMap
|
|
692
737
|
});
|
|
693
738
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
@@ -750,10 +795,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
750
795
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
751
796
|
const cartItems = this.store.cart.getItems();
|
|
752
797
|
const arr = [];
|
|
753
|
-
const capacityMap = {};
|
|
754
798
|
cartItems.forEach((cartItem) => {
|
|
755
799
|
var _a, _b, _c;
|
|
756
800
|
let selectedResources = [];
|
|
801
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
802
|
+
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
803
|
+
product_bundle: cartItem._origin.product.product_bundle
|
|
804
|
+
});
|
|
805
|
+
cartItem._origin.metadata.capacity = formatCapacity;
|
|
806
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
757
807
|
if (cartItem.holder_id) {
|
|
758
808
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
759
809
|
cartItems,
|
|
@@ -767,12 +817,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
767
817
|
resourcesMap
|
|
768
818
|
);
|
|
769
819
|
}
|
|
770
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
771
|
-
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
772
|
-
product_bundle: cartItem._origin.product.product_bundle
|
|
773
|
-
});
|
|
774
|
-
cartItem._origin.metadata.capacity = formatCapacity;
|
|
775
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
776
820
|
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
777
821
|
resourcesMap,
|
|
778
822
|
((_c = (_b = cartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
@@ -799,7 +843,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
799
843
|
return 0;
|
|
800
844
|
});
|
|
801
845
|
n.renderList = n.renderList.filter((m) => {
|
|
802
|
-
const recordCount = capacityMap[m.id] || 0;
|
|
803
846
|
const mTimes = m.times.filter((n2) => {
|
|
804
847
|
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
805
848
|
});
|
|
@@ -816,7 +859,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
816
859
|
},
|
|
817
860
|
time: item,
|
|
818
861
|
resource: m,
|
|
819
|
-
currentCount:
|
|
862
|
+
currentCount: currentCapacity || 0,
|
|
820
863
|
resourcesUseableMap
|
|
821
864
|
});
|
|
822
865
|
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
@@ -869,12 +912,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
869
912
|
if (n.resource)
|
|
870
913
|
resources.push(...n.resource);
|
|
871
914
|
});
|
|
872
|
-
const resourcesMap = (0, import_utils.getResourcesMap)(
|
|
915
|
+
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
873
916
|
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
874
917
|
if (!targetCartItem) {
|
|
875
918
|
throw new Error(`没有找到${id}购物车商品`);
|
|
876
919
|
}
|
|
877
920
|
let selectedResources = [];
|
|
921
|
+
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
922
|
+
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
923
|
+
product_bundle: targetCartItem._origin.product.product_bundle
|
|
924
|
+
});
|
|
925
|
+
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
878
926
|
if (targetCartItem.holder_id) {
|
|
879
927
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
880
928
|
cartItems,
|
|
@@ -888,11 +936,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
888
936
|
resourcesMap
|
|
889
937
|
);
|
|
890
938
|
}
|
|
891
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
892
|
-
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
893
|
-
product_bundle: targetCartItem._origin.product.product_bundle
|
|
894
|
-
});
|
|
895
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
896
939
|
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
897
940
|
resourcesMap,
|
|
898
941
|
((_c = (_b = targetCartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
@@ -996,7 +1039,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
996
1039
|
const resourcesUseableMap = [
|
|
997
1040
|
...selectedResources
|
|
998
1041
|
].reduce((acc, n) => {
|
|
999
|
-
|
|
1042
|
+
var _a2;
|
|
1043
|
+
acc[n] = ((_a2 = resourcesMap[n]) == null ? void 0 : _a2.resourceType) === "single" ? false : true;
|
|
1000
1044
|
return acc;
|
|
1001
1045
|
}, {});
|
|
1002
1046
|
if (timeSlots) {
|
|
@@ -1062,14 +1106,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1062
1106
|
resources.push(...n.resource);
|
|
1063
1107
|
});
|
|
1064
1108
|
}
|
|
1065
|
-
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
1066
1109
|
const errorList = [];
|
|
1067
1110
|
const selectResourcesMap = {};
|
|
1068
1111
|
const accountList = this.store.accountList.getAccounts();
|
|
1069
1112
|
const selectForCartResources = (cartItems2) => {
|
|
1070
1113
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1071
1114
|
cartItems2.forEach((item, index) => {
|
|
1072
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1115
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1073
1116
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
1074
1117
|
capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
|
|
1075
1118
|
product_bundle: item._origin.product.product_bundle
|
|
@@ -1084,14 +1127,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1084
1127
|
};
|
|
1085
1128
|
}
|
|
1086
1129
|
if (recordTimeSlots) {
|
|
1087
|
-
|
|
1130
|
+
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find((n) => n.code === resources_code);
|
|
1131
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single") {
|
|
1088
1132
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1089
|
-
((
|
|
1090
|
-
((
|
|
1133
|
+
((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) ?? 0,
|
|
1134
|
+
((_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.type) ?? "minutes"
|
|
1091
1135
|
);
|
|
1092
1136
|
let end_at = start_at.add(
|
|
1093
|
-
((
|
|
1094
|
-
((
|
|
1137
|
+
((_j = (_i = item._productOrigin) == null ? void 0 : _i.duration) == null ? void 0 : _j.value) ?? 0,
|
|
1138
|
+
((_l = (_k = item._productOrigin) == null ? void 0 : _k.duration) == null ? void 0 : _l.type) ?? "minutes"
|
|
1095
1139
|
);
|
|
1096
1140
|
recordTimeSlots = {
|
|
1097
1141
|
start_time: start_at.format("HH:mm"),
|
|
@@ -1136,7 +1180,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1136
1180
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1137
1181
|
let selectedResources = [];
|
|
1138
1182
|
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1139
|
-
((
|
|
1183
|
+
((_n = (_m = item._productOrigin) == null ? void 0 : _m.product_resource) == null ? void 0 : _n.resources) || []
|
|
1140
1184
|
);
|
|
1141
1185
|
const currentResourcesRenderList = [];
|
|
1142
1186
|
resources2.forEach((n) => {
|
|
@@ -1144,7 +1188,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1144
1188
|
if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
|
|
1145
1189
|
n.renderList = n.renderList.filter((m) => {
|
|
1146
1190
|
var _a4;
|
|
1147
|
-
const recordCount = m.capacity || 0;
|
|
1191
|
+
const recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
|
|
1148
1192
|
const timeSlots2 = (0, import_resources.getTimeSlicesByResource)({
|
|
1149
1193
|
resource: m,
|
|
1150
1194
|
duration: ((_a4 = item == null ? void 0 : item.duration) == null ? void 0 : _a4.value) || 0,
|
|
@@ -1156,39 +1200,39 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1156
1200
|
currentResourcesRenderList.push(...n.renderList || []);
|
|
1157
1201
|
}
|
|
1158
1202
|
});
|
|
1159
|
-
const
|
|
1203
|
+
const resourcesMap = (0, import_utils.getResourcesMap)(currentResourcesRenderList);
|
|
1160
1204
|
if (item.holder_id) {
|
|
1161
1205
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1162
1206
|
allCartItems,
|
|
1163
1207
|
item.holder_id,
|
|
1164
|
-
|
|
1208
|
+
resourcesMap
|
|
1165
1209
|
);
|
|
1166
1210
|
} else {
|
|
1167
1211
|
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
1168
1212
|
allCartItems,
|
|
1169
1213
|
item._id,
|
|
1170
|
-
|
|
1214
|
+
resourcesMap
|
|
1171
1215
|
);
|
|
1172
1216
|
}
|
|
1173
1217
|
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1174
|
-
|
|
1218
|
+
resourcesMap,
|
|
1175
1219
|
(0, import_lodash_es.cloneDeep)(resources2),
|
|
1176
1220
|
selectedResources,
|
|
1177
1221
|
currentCapacity
|
|
1178
1222
|
);
|
|
1179
1223
|
productResources.forEach((item2) => {
|
|
1180
1224
|
item2.renderList = item2.renderList.filter((n) => {
|
|
1181
|
-
const recordCount = n.capacity || 0;
|
|
1225
|
+
const recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
|
|
1182
1226
|
if (n.onlyComputed)
|
|
1183
1227
|
return false;
|
|
1184
1228
|
return recordCount >= currentCapacity;
|
|
1185
1229
|
});
|
|
1186
1230
|
});
|
|
1187
|
-
const targetRenderList = (
|
|
1231
|
+
const targetRenderList = (_o = productResources.find(
|
|
1188
1232
|
(n) => n.code === resources_code
|
|
1189
|
-
)) == null ? void 0 :
|
|
1233
|
+
)) == null ? void 0 : _o.renderList;
|
|
1190
1234
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1191
|
-
if ((
|
|
1235
|
+
if ((_p = item._origin.resources) == null ? void 0 : _p.some(
|
|
1192
1236
|
(n) => n.form_id === targetRenderList[0].form_id
|
|
1193
1237
|
)) {
|
|
1194
1238
|
return;
|
|
@@ -1196,6 +1240,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1196
1240
|
const targetResource = targetRenderList[0];
|
|
1197
1241
|
targetResource.capacity = currentCapacity;
|
|
1198
1242
|
(0, import_resources.checkSubResourcesCapacity)(targetResource);
|
|
1243
|
+
if (!selectResourcesMap[targetResource.id]) {
|
|
1244
|
+
selectResourcesMap[targetResource.id] = currentCapacity;
|
|
1245
|
+
} else {
|
|
1246
|
+
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
1247
|
+
}
|
|
1199
1248
|
this.store.cart.updateItem({
|
|
1200
1249
|
_id: item._id,
|
|
1201
1250
|
resources: [
|
|
@@ -1319,12 +1368,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1319
1368
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
1320
1369
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1321
1370
|
accountItems.forEach((item, index) => {
|
|
1371
|
+
var _a;
|
|
1322
1372
|
const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
|
|
1323
1373
|
newResources.forEach((resource) => {
|
|
1324
|
-
var
|
|
1374
|
+
var _a2, _b, _c, _d;
|
|
1325
1375
|
resource.startTime = currentStartTime;
|
|
1326
1376
|
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
|
|
1327
|
-
((_b = (
|
|
1377
|
+
((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.value) ?? 0,
|
|
1328
1378
|
((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes"
|
|
1329
1379
|
).format("YYYY-MM-DD HH:mm");
|
|
1330
1380
|
delete resource.times;
|
|
@@ -1333,7 +1383,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1333
1383
|
_id: item._id,
|
|
1334
1384
|
resources: newResources
|
|
1335
1385
|
});
|
|
1336
|
-
if (index < accountItems.length - 1) {
|
|
1386
|
+
if (index < accountItems.length - 1 && ((_a = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a.resourceType) === "single") {
|
|
1337
1387
|
currentStartTime = newResources[0].endTime;
|
|
1338
1388
|
}
|
|
1339
1389
|
});
|
|
@@ -1432,8 +1482,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1432
1482
|
return -1;
|
|
1433
1483
|
return 0;
|
|
1434
1484
|
});
|
|
1435
|
-
const resourcesUseableMap = {};
|
|
1436
1485
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1486
|
+
const resourcesUseableMap = {};
|
|
1437
1487
|
let count = 0;
|
|
1438
1488
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1439
1489
|
let currentResourcesCount = 0;
|
|
@@ -180,7 +180,9 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
180
180
|
);
|
|
181
181
|
let optional_resource = item.optional_resource.reduce(
|
|
182
182
|
(childAcc, d) => {
|
|
183
|
-
|
|
183
|
+
var _a;
|
|
184
|
+
const isSelectSingleResources = ((_a = resourcesMap[d]) == null ? void 0 : _a.resourceType) === "single" && selectedResources.includes(resourcesMap[d].id);
|
|
185
|
+
if (resourcesMap[d] && !isSelectSingleResources) {
|
|
184
186
|
const combiningResources = [];
|
|
185
187
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
186
188
|
resourcesMap[d].combined_resource.resource_ids.forEach(
|
|
@@ -222,7 +224,9 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
222
224
|
);
|
|
223
225
|
let default_resource = item.default_resource.reduce(
|
|
224
226
|
(childAcc, d) => {
|
|
225
|
-
|
|
227
|
+
var _a;
|
|
228
|
+
const isSelectSingleResources = ((_a = resourcesMap[d]) == null ? void 0 : _a.resourceType) === "single" && selectedResources.includes(resourcesMap[d].id);
|
|
229
|
+
if (resourcesMap[d] && !isSelectSingleResources) {
|
|
226
230
|
const combiningResources = [];
|
|
227
231
|
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
228
232
|
resourcesMap[d].combined_resource.resource_ids.forEach(
|
|
@@ -442,21 +446,16 @@ var getOthersSelectedResources = (cartItems, accountId, resourcesMap) => {
|
|
|
442
446
|
return acc;
|
|
443
447
|
}
|
|
444
448
|
acc.push(...n.metadata.combined_resource.resource_ids);
|
|
445
|
-
n.metadata.combined_resource.resource_ids.forEach((m) => {
|
|
446
|
-
resourcesMap[m].capacity -= n.num;
|
|
447
|
-
});
|
|
448
449
|
} else {
|
|
449
450
|
Object.values(resourcesMap).forEach((m) => {
|
|
450
451
|
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
451
452
|
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
452
453
|
acc.push(m.id);
|
|
453
|
-
resourcesMap[m.id].capacity -= n.num;
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
456
|
});
|
|
457
457
|
}
|
|
458
458
|
acc.push(n.id);
|
|
459
|
-
resourcesMap[n.id].capacity -= n.num;
|
|
460
459
|
});
|
|
461
460
|
}
|
|
462
461
|
}
|
|
@@ -476,21 +475,16 @@ var getOthersCartSelectedResources = (cartItems, cartItemId, resourcesMap) => {
|
|
|
476
475
|
return acc;
|
|
477
476
|
}
|
|
478
477
|
acc.push(...n.metadata.combined_resource.resource_ids);
|
|
479
|
-
n.metadata.combined_resource.resource_ids.forEach((m) => {
|
|
480
|
-
resourcesMap[m].capacity -= n.num;
|
|
481
|
-
});
|
|
482
478
|
} else {
|
|
483
479
|
Object.values(resourcesMap).forEach((m) => {
|
|
484
480
|
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
485
481
|
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
486
482
|
acc.push(m.id);
|
|
487
|
-
resourcesMap[m.id].capacity -= n.num;
|
|
488
483
|
}
|
|
489
484
|
}
|
|
490
485
|
});
|
|
491
486
|
}
|
|
492
487
|
acc.push(n.id);
|
|
493
|
-
resourcesMap[n.id].capacity -= n.num;
|
|
494
488
|
});
|
|
495
489
|
}
|
|
496
490
|
}
|