@pisell/pisellos 0.0.38 → 2.0.1
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/Cart/types.d.ts +0 -4
- package/dist/modules/Cart/utils.js +11 -25
- package/dist/modules/Product/index.d.ts +0 -10
- package/dist/modules/Product/index.js +0 -13
- package/dist/modules/Product/types.d.ts +0 -4
- package/dist/modules/Resource/types.d.ts +0 -1
- package/dist/modules/index.d.ts +0 -10
- package/dist/modules/index.js +1 -11
- package/dist/solution/BookingByStep/index.d.ts +3 -13
- package/dist/solution/BookingByStep/index.js +163 -300
- package/dist/solution/BookingByStep/types.d.ts +10 -3
- package/dist/solution/BookingByStep/types.js +7 -3
- package/dist/solution/BookingByStep/utils/resources.d.ts +4 -45
- package/dist/solution/BookingByStep/utils/resources.js +33 -167
- package/lib/modules/Cart/types.d.ts +0 -4
- package/lib/modules/Cart/utils.js +11 -26
- package/lib/modules/Product/index.d.ts +0 -10
- package/lib/modules/Product/index.js +0 -3
- package/lib/modules/Product/types.d.ts +0 -4
- package/lib/modules/Resource/types.d.ts +0 -1
- package/lib/modules/index.d.ts +0 -10
- package/lib/modules/index.js +1 -21
- package/lib/solution/BookingByStep/index.d.ts +3 -13
- package/lib/solution/BookingByStep/index.js +36 -91
- package/lib/solution/BookingByStep/types.d.ts +10 -3
- package/lib/solution/BookingByStep/types.js +12 -8
- package/lib/solution/BookingByStep/utils/resources.d.ts +4 -45
- package/lib/solution/BookingByStep/utils/resources.js +25 -115
- package/package.json +2 -2
- package/dist/modules/Schedule/index.d.ts +0 -13
- package/dist/modules/Schedule/index.js +0 -71
- package/dist/modules/Schedule/type.d.ts +0 -157
- package/dist/modules/Schedule/type.js +0 -1
- package/dist/modules/Schedule/types.d.ts +0 -182
- package/dist/modules/Schedule/types.js +0 -1
- package/dist/modules/Schedule/utils.d.ts +0 -61
- package/dist/modules/Schedule/utils.js +0 -700
- package/lib/modules/Schedule/index.d.ts +0 -13
- package/lib/modules/Schedule/index.js +0 -50
- package/lib/modules/Schedule/type.d.ts +0 -157
- package/lib/modules/Schedule/type.js +0 -17
- package/lib/modules/Schedule/types.d.ts +0 -182
- package/lib/modules/Schedule/types.js +0 -17
- package/lib/modules/Schedule/utils.d.ts +0 -61
- package/lib/modules/Schedule/utils.js +0 -572
|
@@ -68,7 +68,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
68
68
|
targetCacheData = data[this.otherParams.cacheId];
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
const moduleArr = ["accountList", "cart", "
|
|
71
|
+
const moduleArr = ["accountList", "cart", "summary", "step", "products", "date", "order", "payment"];
|
|
72
72
|
moduleArr.forEach((step) => {
|
|
73
73
|
var _a2, _b2;
|
|
74
74
|
const targetModule = (0, import_types.createModule)(step, this.name);
|
|
@@ -88,7 +88,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
|
|
91
|
-
this.loadAllSchedule();
|
|
92
91
|
}
|
|
93
92
|
// 初始化step
|
|
94
93
|
initStep(stepList) {
|
|
@@ -124,15 +123,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
124
123
|
async loadProducts({
|
|
125
124
|
category_ids = [],
|
|
126
125
|
product_ids = [],
|
|
127
|
-
collection = []
|
|
128
|
-
schedule_ids = []
|
|
126
|
+
collection = []
|
|
129
127
|
}) {
|
|
130
128
|
const productsData = await this.request.post(
|
|
131
129
|
`/product/query`,
|
|
132
130
|
{
|
|
133
131
|
open_quotation: 1,
|
|
134
132
|
open_bundle: 1,
|
|
135
|
-
extension_type: ["product_appointment", "appointment_ticket"
|
|
133
|
+
extension_type: ["product_appointment", "appointment_ticket"],
|
|
136
134
|
with: ["category", "collection"],
|
|
137
135
|
status: "published",
|
|
138
136
|
num: 500,
|
|
@@ -140,33 +138,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
140
138
|
category_ids,
|
|
141
139
|
ids: product_ids,
|
|
142
140
|
collection,
|
|
143
|
-
front_end_cache_id: this.cacheId
|
|
144
|
-
schedule_ids
|
|
141
|
+
front_end_cache_id: this.cacheId
|
|
145
142
|
},
|
|
146
143
|
{ useCache: true }
|
|
147
144
|
);
|
|
148
145
|
this.store.products.addProduct(productsData.data.list);
|
|
149
146
|
return productsData.data.list;
|
|
150
147
|
}
|
|
151
|
-
loadProductByScheduleDate(date) {
|
|
152
|
-
const scheduleList = this.store.schedule.getAvailabilityDateList();
|
|
153
|
-
const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
|
|
154
|
-
this.loadProducts({ schedule_ids: scheduleIds });
|
|
155
|
-
}
|
|
156
|
-
// 加载当前店铺下所有 schedule
|
|
157
|
-
async loadAllSchedule() {
|
|
158
|
-
const scheduleList = await this.request.get(`/schedule`);
|
|
159
|
-
this.store.schedule.setScheduleList(scheduleList.data);
|
|
160
|
-
}
|
|
161
|
-
// ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
162
|
-
async loadAvailableDate({ startDate, endDate, custom_page_id }) {
|
|
163
|
-
const res = await this.request.get(`/schedule/product/availability`, {
|
|
164
|
-
start_date: startDate,
|
|
165
|
-
end_date: endDate,
|
|
166
|
-
custom_page_id
|
|
167
|
-
});
|
|
168
|
-
this.store.schedule.setAvailabilityDateList(res.data.date_list);
|
|
169
|
-
}
|
|
170
148
|
async storeProduct(productData) {
|
|
171
149
|
const activeAccount = this.getActiveAccount();
|
|
172
150
|
if (!activeAccount) {
|
|
@@ -326,18 +304,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
326
304
|
cartItems.forEach((item) => {
|
|
327
305
|
var _a;
|
|
328
306
|
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
329
|
-
const resources = (_a = item._origin.resources) == null ? void 0 : _a.filter(
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (targetRes.id === m.id)
|
|
333
|
-
return true;
|
|
334
|
-
if (((_a2 = targetRes.metadata.combined_resource) == null ? void 0 : _a2.status) === 1 && targetRes.metadata.combined_resource.resource_ids.includes(m.id))
|
|
335
|
-
return true;
|
|
336
|
-
if (((_b = m.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
|
|
337
|
-
return true;
|
|
338
|
-
return false;
|
|
339
|
-
});
|
|
340
|
-
});
|
|
307
|
+
const resources = (_a = item._origin.resources) == null ? void 0 : _a.filter(
|
|
308
|
+
(m) => !targetCartItem._origin.resources.some((targetRes) => targetRes.id === m.id)
|
|
309
|
+
);
|
|
341
310
|
this.store.cart.updateItem({
|
|
342
311
|
_id: item._id,
|
|
343
312
|
resources
|
|
@@ -397,13 +366,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
397
366
|
const cartItems = this.store.cart.getItems();
|
|
398
367
|
const arr = [];
|
|
399
368
|
cartItems.forEach((cartItem) => {
|
|
400
|
-
|
|
401
|
-
if (!cartItem.holder_id)
|
|
402
|
-
return;
|
|
403
|
-
const selectedResources = (0, import_resources.getOthersSelectedResources)(cartItems, cartItem.holder_id, resourcesMap);
|
|
404
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({ capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity, product_bundle: cartItem._origin.product.product_bundle });
|
|
405
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
406
|
-
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, ((_c = (_b = cartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [], selectedResources, currentCapacity);
|
|
369
|
+
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, cartItem, cartItems);
|
|
407
370
|
arr.push({
|
|
408
371
|
id: cartItem.id,
|
|
409
372
|
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
@@ -419,7 +382,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
419
382
|
}
|
|
420
383
|
// 给单个购物车里的商品获取资源列表
|
|
421
384
|
getResourcesListByCartItem(id) {
|
|
422
|
-
var _a, _b, _c;
|
|
423
385
|
const cartItems = this.store.cart.getItems();
|
|
424
386
|
const dateRange = this.store.date.getDateRange();
|
|
425
387
|
const resources = [];
|
|
@@ -428,16 +390,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
428
390
|
resources.push(...n.resource);
|
|
429
391
|
});
|
|
430
392
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
393
|
+
const arr = [];
|
|
431
394
|
const targetCartItem = cartItems.find((n) => n._id === id);
|
|
432
395
|
if (!targetCartItem) {
|
|
433
396
|
throw new Error(`没有找到${id}购物车商品`);
|
|
434
397
|
}
|
|
435
|
-
|
|
436
|
-
return;
|
|
437
|
-
const selectedResources = (0, import_resources.getOthersSelectedResources)(cartItems, targetCartItem.holder_id, resourcesMap);
|
|
438
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({ capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity, product_bundle: targetCartItem._origin.product.product_bundle });
|
|
439
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
440
|
-
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, ((_c = (_b = targetCartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [], selectedResources, currentCapacity);
|
|
398
|
+
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, targetCartItem, cartItems);
|
|
441
399
|
if (productResources) {
|
|
442
400
|
return {
|
|
443
401
|
id: targetCartItem.id,
|
|
@@ -466,7 +424,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
466
424
|
});
|
|
467
425
|
return timeSlots;
|
|
468
426
|
}
|
|
469
|
-
//
|
|
427
|
+
// 自动分派可用的资源-单种资源类型
|
|
470
428
|
autoSelectResource({
|
|
471
429
|
resourceProductData,
|
|
472
430
|
resources,
|
|
@@ -518,9 +476,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
518
476
|
holder_id,
|
|
519
477
|
resources_code,
|
|
520
478
|
timeSlots,
|
|
521
|
-
countMap
|
|
522
|
-
capacity
|
|
479
|
+
countMap
|
|
523
480
|
}) {
|
|
481
|
+
var _a, _b, _c;
|
|
524
482
|
const dateRange = this.store.date.getDateRange();
|
|
525
483
|
const cartItems = this.store.cart.getItems();
|
|
526
484
|
const accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
@@ -530,13 +488,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
530
488
|
};
|
|
531
489
|
}
|
|
532
490
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
533
|
-
var
|
|
534
|
-
return acc + (((
|
|
491
|
+
var _a2, _b2;
|
|
492
|
+
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0);
|
|
535
493
|
}, 0);
|
|
494
|
+
let durationType = ((_c = (_b = (_a = accountCartItems[0]) == null ? void 0 : _a._productOrigin) == null ? void 0 : _b.duration) == null ? void 0 : _c.type) ?? "minutes";
|
|
536
495
|
const resources = [];
|
|
537
496
|
accountCartItems.forEach((item) => {
|
|
538
|
-
var
|
|
539
|
-
(
|
|
497
|
+
var _a2, _b2, _c2;
|
|
498
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
540
499
|
if (n.code === resources_code) {
|
|
541
500
|
resources.push(...n.renderList || []);
|
|
542
501
|
}
|
|
@@ -551,7 +510,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
551
510
|
timeSlice: timeSlots,
|
|
552
511
|
time: item,
|
|
553
512
|
resource: n,
|
|
554
|
-
currentCount: recordCount +
|
|
513
|
+
currentCount: recordCount + 1
|
|
555
514
|
});
|
|
556
515
|
return res.usable;
|
|
557
516
|
});
|
|
@@ -571,8 +530,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
571
530
|
resourcesMap,
|
|
572
531
|
duration,
|
|
573
532
|
currentDate: dateRange[0].date,
|
|
574
|
-
split: 10
|
|
575
|
-
capacity
|
|
533
|
+
split: 10
|
|
576
534
|
});
|
|
577
535
|
if (!timeSlots2) {
|
|
578
536
|
return;
|
|
@@ -596,20 +554,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
596
554
|
const selectResourcesMap = {};
|
|
597
555
|
this.store.accountList.getAccounts().forEach((account) => {
|
|
598
556
|
const cartItems = this.store.cart.getCartByAccount(account.getId());
|
|
557
|
+
const allCartItems = this.store.cart.getItems();
|
|
599
558
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
600
559
|
cartItems.forEach((item, index) => {
|
|
601
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j
|
|
602
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({ capacity: (_a = item._productOrigin) == null ? void 0 : _a.capacity, product_bundle: item._origin.product.product_bundle });
|
|
603
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
560
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
604
561
|
if (timeSlots) {
|
|
605
562
|
if (index !== 0 && recordTimeSlots) {
|
|
606
563
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
607
|
-
((
|
|
608
|
-
((
|
|
564
|
+
((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0,
|
|
565
|
+
((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes"
|
|
609
566
|
);
|
|
610
567
|
let end_at = start_at.add(
|
|
611
|
-
((
|
|
612
|
-
((
|
|
568
|
+
((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) ?? 0,
|
|
569
|
+
((_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.type) ?? "minutes"
|
|
613
570
|
);
|
|
614
571
|
recordTimeSlots = {
|
|
615
572
|
start_time: start_at.format("HH:mm"),
|
|
@@ -622,17 +579,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
622
579
|
holder_id: item.holder_id,
|
|
623
580
|
resources_code,
|
|
624
581
|
timeSlots: recordTimeSlots,
|
|
625
|
-
countMap: selectResourcesMap
|
|
626
|
-
capacity: currentCapacity
|
|
582
|
+
countMap: selectResourcesMap
|
|
627
583
|
});
|
|
628
584
|
if (res == null ? void 0 : res.selectedResource) {
|
|
629
585
|
if (!selectResourcesMap[res.selectedResource.id]) {
|
|
630
|
-
selectResourcesMap[res.selectedResource.id] =
|
|
586
|
+
selectResourcesMap[res.selectedResource.id] = 1;
|
|
631
587
|
} else {
|
|
632
|
-
selectResourcesMap[res.selectedResource.id]
|
|
588
|
+
selectResourcesMap[res.selectedResource.id]++;
|
|
633
589
|
}
|
|
634
|
-
|
|
635
|
-
|
|
590
|
+
console.log(this.store.cart.getItems());
|
|
591
|
+
res.selectedResource.capacity = 1;
|
|
636
592
|
this.store.cart.updateItem({
|
|
637
593
|
_id: item._id,
|
|
638
594
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
@@ -643,23 +599,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
643
599
|
res.selectedResource
|
|
644
600
|
]
|
|
645
601
|
});
|
|
602
|
+
console.log(this.store.cart.getItems());
|
|
646
603
|
} else {
|
|
647
604
|
errorList.push(item._id);
|
|
648
605
|
}
|
|
649
606
|
} else {
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
return;
|
|
653
|
-
const selectedResources = (0, import_resources.getOthersSelectedResources)(allCartItems, item.holder_id, resourcesMap);
|
|
654
|
-
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, ((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || [], selectedResources, currentCapacity);
|
|
655
|
-
const targetRenderList = (_l = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _l.renderList;
|
|
607
|
+
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
|
|
608
|
+
const targetRenderList = (_i = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _i.renderList;
|
|
656
609
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
657
|
-
if ((
|
|
610
|
+
if ((_j = item._origin.resources) == null ? void 0 : _j.some((n) => n.form_id === targetRenderList[0].form_id)) {
|
|
658
611
|
return;
|
|
659
612
|
}
|
|
660
613
|
const targetResource = targetRenderList[0];
|
|
661
|
-
targetResource.capacity =
|
|
662
|
-
(0, import_resources.checkSubResourcesCapacity)(targetResource);
|
|
614
|
+
targetResource.capacity = 1;
|
|
663
615
|
this.store.cart.updateItem({
|
|
664
616
|
_id: item._id,
|
|
665
617
|
resources: [
|
|
@@ -669,7 +621,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
669
621
|
targetResource
|
|
670
622
|
]
|
|
671
623
|
});
|
|
672
|
-
console.log(account, "已分配");
|
|
673
624
|
} else {
|
|
674
625
|
errorList.push(item._id);
|
|
675
626
|
}
|
|
@@ -755,12 +706,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
755
706
|
}
|
|
756
707
|
clearCacheByModule(module2) {
|
|
757
708
|
}
|
|
758
|
-
async openProductDetail(productId) {
|
|
759
|
-
const targetProduct = await this.store.products.getProduct(productId);
|
|
760
|
-
if (targetProduct) {
|
|
761
|
-
this.store.currentProduct = targetProduct;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
709
|
};
|
|
765
710
|
// Annotate the CommonJS export names for ESM import in node:
|
|
766
711
|
0 && (module.exports = {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { ProductList, CartModule
|
|
1
|
+
import { ProductList, CartModule } from "../../modules";
|
|
2
|
+
import { AccountModule } from "../../modules/Account";
|
|
3
|
+
import { AccountListModule } from "../../modules/AccountList";
|
|
4
|
+
import { DateModule } from "../../modules/Date";
|
|
5
|
+
import { GuestListModule } from "../../modules/Guests";
|
|
6
|
+
import { OrderModule } from "../../modules/Order";
|
|
7
|
+
import { PaymentModule } from "../../modules/Payment";
|
|
8
|
+
import { ResourceListModule } from "../../modules/Resource";
|
|
9
|
+
import { StepModule } from "../../modules/Step";
|
|
10
|
+
import { SummaryModule } from "../../modules/Summary";
|
|
2
11
|
export interface BookingByStepState {
|
|
3
12
|
cart: CartModule;
|
|
4
13
|
summary: SummaryModule;
|
|
@@ -11,8 +20,6 @@ export interface BookingByStepState {
|
|
|
11
20
|
accountList: AccountListModule;
|
|
12
21
|
order: OrderModule;
|
|
13
22
|
payment: PaymentModule;
|
|
14
|
-
currentProduct: Product;
|
|
15
|
-
schedule: ScheduleModule;
|
|
16
23
|
}
|
|
17
24
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
18
25
|
export declare enum BookingByStepHooks {
|
|
@@ -24,26 +24,30 @@ __export(types_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(types_exports);
|
|
26
26
|
var import_modules = require("../../modules");
|
|
27
|
+
var import_AccountList = require("../../modules/AccountList");
|
|
28
|
+
var import_Date = require("../../modules/Date");
|
|
29
|
+
var import_Order = require("../../modules/Order");
|
|
30
|
+
var import_Payment = require("../../modules/Payment");
|
|
31
|
+
var import_Step = require("../../modules/Step");
|
|
32
|
+
var import_Summary = require("../../modules/Summary");
|
|
27
33
|
function createModule(moduleName, solutionName, name, version) {
|
|
28
34
|
switch (moduleName) {
|
|
29
35
|
case "cart":
|
|
30
36
|
return new import_modules.CartModule(`${solutionName}_${name || moduleName}`, version);
|
|
31
37
|
case "summary":
|
|
32
|
-
return new
|
|
38
|
+
return new import_Summary.SummaryModule(`${solutionName}_${name || moduleName}`, version);
|
|
33
39
|
case "step":
|
|
34
|
-
return new
|
|
40
|
+
return new import_Step.StepModule(`${solutionName}_${name || moduleName}`, version);
|
|
35
41
|
case "products":
|
|
36
42
|
return new import_modules.ProductList(`${solutionName}_${name || moduleName}`, version);
|
|
37
43
|
case "date":
|
|
38
|
-
return new
|
|
44
|
+
return new import_Date.DateModule(`${solutionName}_${name || moduleName}`, version);
|
|
39
45
|
case "accountList":
|
|
40
|
-
return new
|
|
46
|
+
return new import_AccountList.AccountListModule(`${solutionName}_${name || moduleName}`, version);
|
|
41
47
|
case "order":
|
|
42
|
-
return new
|
|
48
|
+
return new import_Order.OrderModule(`${solutionName}_${name || moduleName}`, version);
|
|
43
49
|
case "payment":
|
|
44
|
-
return new
|
|
45
|
-
case "schedule":
|
|
46
|
-
return new import_modules.ScheduleModule(`${solutionName}_${name || moduleName}`, version);
|
|
50
|
+
return new import_Payment.PaymentModule(`${solutionName}_${name || moduleName}`, version);
|
|
47
51
|
default:
|
|
48
52
|
throw new Error(`Unknown module type: ${moduleName}`);
|
|
49
53
|
}
|
|
@@ -45,7 +45,8 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
|
|
|
45
45
|
* @return {*}
|
|
46
46
|
* @Author: zhiwei.Wang
|
|
47
47
|
*/
|
|
48
|
-
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>,
|
|
48
|
+
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>, cartItem: CartItem, cartList: CartItem[]) => ResourceItem[];
|
|
49
|
+
export declare const getSumCapacity: () => number;
|
|
49
50
|
/**
|
|
50
51
|
* @title: 获取资源列表
|
|
51
52
|
* @description:
|
|
@@ -66,12 +67,11 @@ export declare const formatResources: ({ booking, resources }: {
|
|
|
66
67
|
* @return {*}
|
|
67
68
|
* @Author: zhiwei.Wang
|
|
68
69
|
*/
|
|
69
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate
|
|
70
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate }: {
|
|
70
71
|
resource: ResourceItem;
|
|
71
72
|
duration: number;
|
|
72
73
|
split: number;
|
|
73
74
|
currentDate: DateType | string;
|
|
74
|
-
capacity?: number | undefined;
|
|
75
75
|
}) => TimeSliceItem[];
|
|
76
76
|
/**
|
|
77
77
|
* @title: 获取时间切片列表的交集
|
|
@@ -100,52 +100,11 @@ export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceIt
|
|
|
100
100
|
* @return {*}
|
|
101
101
|
* @Author: zhiwei.Wang
|
|
102
102
|
*/
|
|
103
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split
|
|
103
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split }: {
|
|
104
104
|
resourceIds: number[];
|
|
105
105
|
resourcesMap: any;
|
|
106
106
|
duration: number;
|
|
107
107
|
currentDate: DateType | string;
|
|
108
108
|
split: number;
|
|
109
|
-
capacity?: number | undefined;
|
|
110
109
|
}) => any[];
|
|
111
|
-
/**
|
|
112
|
-
* @title: 获取其他人的已选资源
|
|
113
|
-
* @description:
|
|
114
|
-
* @param {CartItem[]} cartItems
|
|
115
|
-
* @param {number | string} accountId
|
|
116
|
-
* @return {*}
|
|
117
|
-
* @Author: jinglin.tan
|
|
118
|
-
*/
|
|
119
|
-
export declare const getOthersSelectedResources: (cartItems: CartItem[], accountId: number | string, resourcesMap: Record<string, ResourceItem>) => number[];
|
|
120
|
-
interface CapacityItem {
|
|
121
|
-
id: number;
|
|
122
|
-
value: number;
|
|
123
|
-
name: string;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* @title: 基于选择的商品格式化容量
|
|
127
|
-
* @description:
|
|
128
|
-
* @param {any} param1
|
|
129
|
-
* @return {*}
|
|
130
|
-
* @Author: zhiwei.Wang
|
|
131
|
-
*/
|
|
132
|
-
export declare const formatDefaultCapacitys: ({ capacity, product_bundle }: any) => CapacityItem[];
|
|
133
|
-
/**
|
|
134
|
-
* @title: 获取总容量
|
|
135
|
-
* @description:
|
|
136
|
-
* @param {object} capacity 为 formatDefaultCapacitys()的结果
|
|
137
|
-
* @return {*}
|
|
138
|
-
* @Author: zhiwei.Wang
|
|
139
|
-
*/
|
|
140
|
-
export declare const getSumCapacity: ({ capacity }: {
|
|
141
|
-
capacity: CapacityItem[];
|
|
142
|
-
}) => number;
|
|
143
|
-
/**
|
|
144
|
-
* @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
|
|
145
|
-
* @description:
|
|
146
|
-
* @param {object} resource
|
|
147
|
-
* @return {*}
|
|
148
|
-
* @Author: jinglin.tan
|
|
149
|
-
*/
|
|
150
|
-
export declare const checkSubResourcesCapacity: (resource: ResourceItem) => void;
|
|
151
110
|
export {};
|
|
@@ -29,11 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/solution/BookingByStep/utils/resources.ts
|
|
30
30
|
var resources_exports = {};
|
|
31
31
|
__export(resources_exports, {
|
|
32
|
-
checkSubResourcesCapacity: () => checkSubResourcesCapacity,
|
|
33
|
-
formatDefaultCapacitys: () => formatDefaultCapacitys,
|
|
34
32
|
formatResources: () => formatResources,
|
|
35
33
|
getIsUsableByTimeItem: () => getIsUsableByTimeItem,
|
|
36
|
-
getOthersSelectedResources: () => getOthersSelectedResources,
|
|
37
34
|
getResourcesByIds: () => getResourcesByIds,
|
|
38
35
|
getResourcesByProduct: () => getResourcesByProduct,
|
|
39
36
|
getSumCapacity: () => getSumCapacity,
|
|
@@ -114,54 +111,41 @@ var getIsUsableByTimeItem = ({ timeSlice, time, resource, currentCount = 1 }) =>
|
|
|
114
111
|
status.usable = true;
|
|
115
112
|
return status;
|
|
116
113
|
};
|
|
117
|
-
var getResourcesByProduct = (resourcesMap,
|
|
118
|
-
|
|
114
|
+
var getResourcesByProduct = (resourcesMap, cartItem, cartList) => {
|
|
115
|
+
var _a;
|
|
116
|
+
const product = cartItem._productOrigin;
|
|
117
|
+
return (((_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources) || []).reduce((acc, item) => {
|
|
119
118
|
if ((item == null ? void 0 : item.status) == 1) {
|
|
120
119
|
const form_id = item.id;
|
|
121
120
|
item.optional_resource = (item.optional_resource || []).filter(
|
|
122
121
|
(d) => item.default_resource.indexOf(d) == -1
|
|
123
122
|
);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
combiningResources.push(resourcesMap[id]);
|
|
131
|
-
}
|
|
123
|
+
const selectedResources = cartList.reduce((acc2, d) => {
|
|
124
|
+
var _a2;
|
|
125
|
+
if (d.holder_id !== cartItem.holder_id) {
|
|
126
|
+
if ((_a2 = d._origin) == null ? void 0 : _a2.resources) {
|
|
127
|
+
d._origin.resources.forEach((n) => {
|
|
128
|
+
acc2.push(n.id);
|
|
132
129
|
});
|
|
133
130
|
}
|
|
131
|
+
}
|
|
132
|
+
return acc2;
|
|
133
|
+
}, []);
|
|
134
|
+
let optional_resource = item.optional_resource.reduce((childAcc, d) => {
|
|
135
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
134
136
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
135
137
|
form_id,
|
|
136
|
-
resourceType: item.type
|
|
137
|
-
children: combiningResources,
|
|
138
|
-
metadata: {
|
|
139
|
-
...resourcesMap[d].metadata,
|
|
140
|
-
combined_resource: resourcesMap[d].combined_resource
|
|
141
|
-
}
|
|
138
|
+
resourceType: item.type
|
|
142
139
|
}));
|
|
143
140
|
}
|
|
144
141
|
return childAcc;
|
|
145
142
|
}, []);
|
|
146
143
|
let default_resource = item.default_resource.reduce((childAcc, d) => {
|
|
147
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)
|
|
148
|
-
const combiningResources = [];
|
|
149
|
-
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
150
|
-
resourcesMap[d].combined_resource.resource_ids.forEach((id) => {
|
|
151
|
-
if (resourcesMap[id]) {
|
|
152
|
-
combiningResources.push(resourcesMap[id]);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
144
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
156
145
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
157
146
|
form_id,
|
|
158
147
|
resourceType: item.type,
|
|
159
|
-
is_default: 1
|
|
160
|
-
children: combiningResources,
|
|
161
|
-
metadata: {
|
|
162
|
-
...resourcesMap[d].metadata,
|
|
163
|
-
combined_resource: resourcesMap[d].combined_resource
|
|
164
|
-
}
|
|
148
|
+
is_default: 1
|
|
165
149
|
}));
|
|
166
150
|
}
|
|
167
151
|
return childAcc;
|
|
@@ -179,6 +163,9 @@ var getResourcesByProduct = (resourcesMap, resources, selectedResources, capacit
|
|
|
179
163
|
return acc;
|
|
180
164
|
}, []);
|
|
181
165
|
};
|
|
166
|
+
var getSumCapacity = () => {
|
|
167
|
+
return 1;
|
|
168
|
+
};
|
|
182
169
|
var formatResources = ({ booking, resources }) => {
|
|
183
170
|
try {
|
|
184
171
|
let _list = [...resources];
|
|
@@ -208,8 +195,7 @@ var getTimeSlicesByResource = ({
|
|
|
208
195
|
resource,
|
|
209
196
|
duration,
|
|
210
197
|
split = 10,
|
|
211
|
-
currentDate = (0, import_dayjs.default)()
|
|
212
|
-
capacity
|
|
198
|
+
currentDate = (0, import_dayjs.default)()
|
|
213
199
|
}) => {
|
|
214
200
|
const { times } = resource;
|
|
215
201
|
const timeSlices = [];
|
|
@@ -233,7 +219,7 @@ var getTimeSlicesByResource = ({
|
|
|
233
219
|
timeSlice,
|
|
234
220
|
time,
|
|
235
221
|
resource,
|
|
236
|
-
currentCount:
|
|
222
|
+
currentCount: getSumCapacity()
|
|
237
223
|
});
|
|
238
224
|
if (_status.usable) {
|
|
239
225
|
timeSlices.push({
|
|
@@ -270,95 +256,19 @@ var getTimeSlicesByResources = ({
|
|
|
270
256
|
resourcesMap,
|
|
271
257
|
duration,
|
|
272
258
|
currentDate,
|
|
273
|
-
split
|
|
274
|
-
capacity
|
|
259
|
+
split
|
|
275
260
|
}) => {
|
|
276
261
|
let resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
277
262
|
let timeSliceList = resources.reduce((acc, item) => {
|
|
278
|
-
return acc.concat(getTimeSlicesByResource({ resource: item, duration, split, currentDate
|
|
263
|
+
return acc.concat(getTimeSlicesByResource({ resource: item, duration, split, currentDate }));
|
|
279
264
|
}, []);
|
|
280
265
|
let intersection = getTimesIntersection(timeSliceList, resources.length);
|
|
281
266
|
return intersection;
|
|
282
267
|
};
|
|
283
|
-
var getOthersSelectedResources = (cartItems, accountId, resourcesMap) => {
|
|
284
|
-
return cartItems.reduce((acc, d) => {
|
|
285
|
-
var _a;
|
|
286
|
-
if (d.holder_id !== accountId) {
|
|
287
|
-
if ((_a = d._origin) == null ? void 0 : _a.resources) {
|
|
288
|
-
d._origin.resources.forEach((n) => {
|
|
289
|
-
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
290
|
-
if (n.metadata.combined_resource.resource_ids.some((m) => acc.includes(m))) {
|
|
291
|
-
return acc;
|
|
292
|
-
}
|
|
293
|
-
acc.push(...n.metadata.combined_resource.resource_ids);
|
|
294
|
-
} else {
|
|
295
|
-
Object.values(resourcesMap).forEach((m) => {
|
|
296
|
-
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
297
|
-
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
298
|
-
acc.push(m.id);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
acc.push(n.id);
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return acc;
|
|
308
|
-
}, []);
|
|
309
|
-
};
|
|
310
|
-
var formatDefaultCapacitys = ({ capacity, product_bundle }) => {
|
|
311
|
-
if ((capacity == null ? void 0 : capacity.type) === "package") {
|
|
312
|
-
return (product_bundle || []).map((d) => {
|
|
313
|
-
const id = d.bundle_product_id;
|
|
314
|
-
const item = ((capacity == null ? void 0 : capacity.package) || []).find(
|
|
315
|
-
(item2) => item2.product_id === id
|
|
316
|
-
);
|
|
317
|
-
return {
|
|
318
|
-
id,
|
|
319
|
-
value: item ? d.num || 0 : 0,
|
|
320
|
-
name: (item == null ? void 0 : item.name) || (d == null ? void 0 : d.title)
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
if ((capacity == null ? void 0 : capacity.type) === "custom") {
|
|
325
|
-
return ((capacity == null ? void 0 : capacity.custom) || []).map((d) => {
|
|
326
|
-
return {
|
|
327
|
-
id: d.id,
|
|
328
|
-
value: d.min,
|
|
329
|
-
name: d.name
|
|
330
|
-
};
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
return [{ id: 0, value: 1, name: "" }];
|
|
334
|
-
};
|
|
335
|
-
var getSumCapacity = ({ capacity }) => {
|
|
336
|
-
let sum = 0;
|
|
337
|
-
for (let item of capacity || []) {
|
|
338
|
-
sum += item.value;
|
|
339
|
-
}
|
|
340
|
-
return sum;
|
|
341
|
-
};
|
|
342
|
-
var checkSubResourcesCapacity = (resource) => {
|
|
343
|
-
if (resource.children && resource.children.length) {
|
|
344
|
-
let countCapacity = resource.capacity;
|
|
345
|
-
resource.children.forEach((child) => {
|
|
346
|
-
if (child.capacity <= countCapacity) {
|
|
347
|
-
countCapacity -= child.capacity;
|
|
348
|
-
} else {
|
|
349
|
-
child.capacity = countCapacity;
|
|
350
|
-
countCapacity = 0;
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
268
|
// Annotate the CommonJS export names for ESM import in node:
|
|
356
269
|
0 && (module.exports = {
|
|
357
|
-
checkSubResourcesCapacity,
|
|
358
|
-
formatDefaultCapacitys,
|
|
359
270
|
formatResources,
|
|
360
271
|
getIsUsableByTimeItem,
|
|
361
|
-
getOthersSelectedResources,
|
|
362
272
|
getResourcesByIds,
|
|
363
273
|
getResourcesByProduct,
|
|
364
274
|
getSumCapacity,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"docs": "typedoc --out docs src/index.ts",
|
|
22
22
|
"sync": "node sync.js",
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
24
|
-
"deploy": "yarn run build && yarn run changeset && yarn run version &&
|
|
24
|
+
"deploy": "yarn run build && yarn run changeset && yarn run version && yarn run release"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|