@pisell/pisellos 0.0.57 → 0.0.59

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.
Files changed (69) hide show
  1. package/dist/core/index.d.ts.map +1 -0
  2. package/dist/effects/index.d.ts.map +1 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/modules/Account/index.d.ts.map +1 -0
  5. package/dist/modules/Account/types.d.ts.map +1 -0
  6. package/dist/modules/AccountList/index.d.ts.map +1 -0
  7. package/dist/modules/AccountList/types.d.ts.map +1 -0
  8. package/dist/modules/AccountList/utils.d.ts.map +1 -0
  9. package/dist/modules/BaseModule.d.ts.map +1 -0
  10. package/dist/modules/Cart/index.d.ts.map +1 -0
  11. package/dist/modules/Cart/types.d.ts.map +1 -0
  12. package/dist/modules/Cart/utils.d.ts.map +1 -0
  13. package/dist/modules/Date/index.d.ts.map +1 -0
  14. package/dist/modules/Date/types.d.ts.map +1 -0
  15. package/dist/modules/Date/utils.d.ts.map +1 -0
  16. package/dist/modules/Discount/index.d.ts.map +1 -0
  17. package/dist/modules/Discount/types.d.ts.map +1 -0
  18. package/dist/modules/Guests/index.d.ts.map +1 -0
  19. package/dist/modules/Guests/types.d.ts.map +1 -0
  20. package/dist/modules/Order/index.d.ts.map +1 -0
  21. package/dist/modules/Order/types.d.ts.map +1 -0
  22. package/dist/modules/Order/utils.d.ts.map +1 -0
  23. package/dist/modules/Payment/index.d.ts.map +1 -0
  24. package/dist/modules/Payment/types.d.ts.map +1 -0
  25. package/dist/modules/Product/index.d.ts.map +1 -0
  26. package/dist/modules/Product/types.d.ts.map +1 -0
  27. package/dist/modules/ProductList/index.d.ts.map +1 -0
  28. package/dist/modules/ProductList/types.d.ts.map +1 -0
  29. package/dist/modules/Resource/index.d.ts.map +1 -0
  30. package/dist/modules/Resource/types.d.ts.map +1 -0
  31. package/dist/modules/Resource/utils.d.ts.map +1 -0
  32. package/dist/modules/Rules/index.d.ts.map +1 -0
  33. package/dist/modules/Rules/types.d.ts.map +1 -0
  34. package/dist/modules/Schedule/index.d.ts.map +1 -0
  35. package/dist/modules/Schedule/type.d.ts.map +1 -0
  36. package/dist/modules/Schedule/types.d.ts.map +1 -0
  37. package/dist/modules/Schedule/utils.d.ts.map +1 -0
  38. package/dist/modules/Step/index.d.ts.map +1 -0
  39. package/dist/modules/Step/tyeps.d.ts.map +1 -0
  40. package/dist/modules/Summary/index.d.ts.map +1 -0
  41. package/dist/modules/Summary/types.d.ts.map +1 -0
  42. package/dist/modules/Summary/utils.d.ts.map +1 -0
  43. package/dist/modules/index.d.ts.map +1 -0
  44. package/dist/plugins/index.d.ts.map +1 -0
  45. package/dist/plugins/request.d.ts.map +1 -0
  46. package/dist/plugins/shopStore.d.ts.map +1 -0
  47. package/dist/plugins/window.d.ts.map +1 -0
  48. package/dist/solution/BookingByStep/index.d.ts +0 -11
  49. package/dist/solution/BookingByStep/index.d.ts.map +1 -0
  50. package/dist/solution/BookingByStep/index.js +85 -112
  51. package/dist/solution/BookingByStep/types.d.ts.map +1 -0
  52. package/dist/solution/BookingByStep/utils/products.d.ts.map +1 -0
  53. package/dist/solution/BookingByStep/utils/resources.d.ts +6 -3
  54. package/dist/solution/BookingByStep/utils/resources.d.ts.map +1 -0
  55. package/dist/solution/BookingByStep/utils/resources.js +35 -6
  56. package/dist/solution/BuyTickets/index.d.ts.map +1 -0
  57. package/dist/solution/BuyTickets/types.d.ts.map +1 -0
  58. package/dist/solution/PlaceOrder/index.d.ts.map +1 -0
  59. package/dist/solution/ShopDiscount/index.d.ts.map +1 -0
  60. package/dist/solution/ShopDiscount/types.d.ts.map +1 -0
  61. package/dist/solution/ShopDiscount/utils.d.ts.map +1 -0
  62. package/dist/solution/index.d.ts.map +1 -0
  63. package/dist/store/createStore.d.ts.map +1 -0
  64. package/dist/types/index.d.ts.map +1 -0
  65. package/lib/solution/BookingByStep/index.d.ts +0 -11
  66. package/lib/solution/BookingByStep/index.js +70 -63
  67. package/lib/solution/BookingByStep/utils/resources.d.ts +6 -3
  68. package/lib/solution/BookingByStep/utils/resources.js +32 -5
  69. package/package.json +1 -1
@@ -184,7 +184,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
184
184
  product_ids
185
185
  }) {
186
186
  const scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
187
- this.setDateRange([{ date, status: "available", week: "", weekNum: 0 }, { date, status: "available", week: "", weekNum: 0 }]);
187
+ this.setDateRange([
188
+ { date, status: "available", week: "", weekNum: 0 },
189
+ { date, status: "available", week: "", weekNum: 0 }
190
+ ]);
188
191
  const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
189
192
  return await this.loadProducts({ schedule_ids: scheduleIds, product_ids });
190
193
  }
@@ -598,6 +601,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
598
601
  const endTime = (0, import_dayjs.default)(
599
602
  `${cartItem._origin.end_date} ${cartItem._origin.end_time}`
600
603
  );
604
+ productResources.sort((a, b) => {
605
+ var _a2, _b2, _c2, _d;
606
+ const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
607
+ const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
608
+ if (aIsCombined && !bIsCombined)
609
+ return 1;
610
+ if (!aIsCombined && bIsCombined)
611
+ return -1;
612
+ return 0;
613
+ });
614
+ const resourcesUseableMap = {};
601
615
  productResources.forEach((n) => {
602
616
  n.renderList = n.renderList.filter((m) => {
603
617
  const recordCount = capacityMap[m.id] || 0;
@@ -611,8 +625,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
611
625
  },
612
626
  time: item,
613
627
  resource: m,
614
- currentCount: recordCount + (currentCapacity || 0)
628
+ currentCount: recordCount + (currentCapacity || 0),
629
+ resourcesUseableMap
615
630
  });
631
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false) {
632
+ resourcesUseableMap[m.id] = res.usable;
633
+ }
616
634
  return res.usable;
617
635
  });
618
636
  return canUseTime;
@@ -700,53 +718,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
700
718
  });
701
719
  return timeSlots;
702
720
  }
703
- // 自动分派可用的资源-单种资源类型——此方法目前未使用,未经验证
704
- autoSelectResource({
705
- resourceProductData,
706
- resources,
707
- timeSlots
708
- }) {
709
- const dateRange = this.store.date.getDateRange();
710
- if (timeSlots) {
711
- let targetResource = null;
712
- for (const n of resources) {
713
- const canUseTime = n.times.find((item) => {
714
- const res = (0, import_resources.getIsUsableByTimeItem)({
715
- timeSlice: timeSlots,
716
- time: item,
717
- resource: n,
718
- currentCount: 1
719
- });
720
- return res.usable;
721
- });
722
- if (canUseTime) {
723
- targetResource = n;
724
- break;
725
- }
726
- }
727
- return {
728
- selectedResource: targetResource
729
- };
730
- } else {
731
- const duration = resourceProductData.product.duration.value;
732
- const resourcesMap = (0, import_utils.getResourcesMap)(resources);
733
- const resourceIds = resources.map((n) => n.id);
734
- const timeSlots2 = (0, import_resources.getTimeSlicesByResources)({
735
- resourceIds,
736
- resourcesMap,
737
- duration,
738
- currentDate: dateRange[0].date,
739
- split: 10
740
- });
741
- if (!timeSlots2) {
742
- return;
743
- }
744
- return {
745
- timeSlots: timeSlots2,
746
- selectedResource: resources[0]
747
- };
748
- }
749
- }
750
721
  // 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
751
722
  autoSelectAccountResources({
752
723
  holder_id,
@@ -765,7 +736,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
765
736
  var _a, _b;
766
737
  return acc + (((_b = (_a = n._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0);
767
738
  }, 0);
768
- const resources = [];
739
+ let resources = [];
769
740
  accountCartItems.forEach((item) => {
770
741
  var _a, _b, _c;
771
742
  (_c = (_b = (_a = item._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) == null ? void 0 : _c.forEach((n) => {
@@ -774,6 +745,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
774
745
  }
775
746
  });
776
747
  });
748
+ resources.sort((a, b) => {
749
+ var _a, _b, _c, _d;
750
+ const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
751
+ const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
752
+ if (aIsCombined && !bIsCombined)
753
+ return 1;
754
+ if (!aIsCombined && bIsCombined)
755
+ return -1;
756
+ return 0;
757
+ });
758
+ const resourcesUseableMap = {};
777
759
  if (timeSlots) {
778
760
  let targetResource = null;
779
761
  for (const n of resources) {
@@ -783,8 +765,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
783
765
  timeSlice: timeSlots,
784
766
  time: item,
785
767
  resource: n,
786
- currentCount: recordCount + (capacity || 0)
768
+ currentCount: recordCount + (capacity || 0),
769
+ resourcesUseableMap
787
770
  });
771
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[n.id]) !== false) {
772
+ resourcesUseableMap[n.id] = res.usable;
773
+ }
788
774
  return res.usable;
789
775
  });
790
776
  if (canUseTime) {
@@ -804,7 +790,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
804
790
  duration,
805
791
  currentDate: dateRange[0].date,
806
792
  split: 10,
807
- capacity
793
+ capacity,
794
+ resourcesUseableMap
808
795
  });
809
796
  if (!timeSlots2) {
810
797
  return;
@@ -1007,26 +994,31 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1007
994
  }
1008
995
  ];
1009
996
  }
997
+ const resourcesUseableMap = {};
1010
998
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
1011
999
  resourceIds,
1012
1000
  resourcesMap,
1013
1001
  duration,
1014
1002
  currentDate: dateRange[0].date,
1015
- split: 10
1003
+ split: 10,
1004
+ resourcesUseableMap
1016
1005
  });
1017
1006
  return timeSlots;
1018
1007
  }
1019
1008
  // 提交时间切片,绑定到对应购物车的商品上,更新购物车
1020
1009
  submitTimeSlot(timeSlots) {
1021
1010
  const cartItems = this.store.cart.getItems();
1022
- const itemsByAccount = cartItems.reduce((acc, item) => {
1023
- const holderId = item.holder_id;
1024
- if (!acc[holderId]) {
1025
- acc[holderId] = [];
1026
- }
1027
- acc[holderId].push(item);
1028
- return acc;
1029
- }, {});
1011
+ const itemsByAccount = cartItems.reduce(
1012
+ (acc, item) => {
1013
+ const holderId = item.holder_id;
1014
+ if (!acc[holderId]) {
1015
+ acc[holderId] = [];
1016
+ }
1017
+ acc[holderId].push(item);
1018
+ return acc;
1019
+ },
1020
+ {}
1021
+ );
1030
1022
  Object.values(itemsByAccount).forEach((accountItems) => {
1031
1023
  let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1032
1024
  accountItems.forEach((item, index) => {
@@ -1129,7 +1121,18 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1129
1121
  );
1130
1122
  const scheduleTimeSlots = (0, import_utils2.getAllSortedDateRanges)(minTimeMaxTime);
1131
1123
  console.log("scheduleTimeSlots:", scheduleTimeSlots, productResources);
1132
- const allProductResources = productResources.flatMap((n) => n.renderList);
1124
+ let allProductResources = productResources.flatMap((n) => n.renderList);
1125
+ allProductResources.sort((a, b) => {
1126
+ var _a2, _b2, _c2, _d;
1127
+ const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
1128
+ const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
1129
+ if (aIsCombined && !bIsCombined)
1130
+ return 1;
1131
+ if (!aIsCombined && bIsCombined)
1132
+ return -1;
1133
+ return 0;
1134
+ });
1135
+ const resourcesUseableMap = {};
1133
1136
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1134
1137
  let count = 0;
1135
1138
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
@@ -1143,8 +1146,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1143
1146
  },
1144
1147
  time: childTiem,
1145
1148
  resource: m,
1146
- currentCount: 1
1149
+ currentCount: 1,
1150
+ resourcesUseableMap
1147
1151
  });
1152
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false) {
1153
+ resourcesUseableMap[m.id] = res.usable;
1154
+ }
1148
1155
  if (res.usable && res.remainingCapacity >= count) {
1149
1156
  count = res.remainingCapacity;
1150
1157
  }
@@ -27,11 +27,12 @@ interface BookingItem {
27
27
  * @return {*}
28
28
  * @Author: zhiwei.Wang
29
29
  */
30
- export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, }: {
30
+ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, currentCount, resourcesUseableMap, }: {
31
31
  timeSlice: TimeSliceItem;
32
32
  time: any;
33
33
  resource: ResourceItem;
34
34
  currentCount: number;
35
+ resourcesUseableMap: Record<string, boolean>;
35
36
  }) => {
36
37
  afterToDay: boolean;
37
38
  capacity: boolean;
@@ -67,12 +68,13 @@ export declare const formatResources: ({ booking, resources, }: {
67
68
  * @return {*}
68
69
  * @Author: zhiwei.Wang
69
70
  */
70
- export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, }: {
71
+ export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, }: {
71
72
  resource: ResourceItem;
72
73
  duration: number;
73
74
  split: number;
74
75
  currentDate: DateType | string;
75
76
  capacity?: number | undefined;
77
+ resourcesUseableMap?: Record<string, boolean> | undefined;
76
78
  }) => TimeSliceItem[];
77
79
  /**
78
80
  * @title: 获取时间切片列表的交集
@@ -101,13 +103,14 @@ export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceIt
101
103
  * @return {*}
102
104
  * @Author: zhiwei.Wang
103
105
  */
104
- export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, }: {
106
+ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, }: {
105
107
  resourceIds: number[];
106
108
  resourcesMap: any;
107
109
  duration: number;
108
110
  currentDate: DateType | string;
109
111
  split: number;
110
112
  capacity?: number | undefined;
113
+ resourcesUseableMap: Record<string, boolean>;
111
114
  }) => any[];
112
115
  /**
113
116
  * @title: 获取其他人的已选资源
@@ -124,8 +124,10 @@ var getIsUsableByTimeItem = ({
124
124
  timeSlice,
125
125
  time,
126
126
  resource,
127
- currentCount = 1
127
+ currentCount = 1,
128
+ resourcesUseableMap = {}
128
129
  }) => {
130
+ var _a;
129
131
  let status = {
130
132
  afterToDay: false,
131
133
  capacity: false,
@@ -144,6 +146,14 @@ var getIsUsableByTimeItem = ({
144
146
  resource,
145
147
  currentCount
146
148
  });
149
+ if ((_a = resource.combined_resource) == null ? void 0 : _a.status) {
150
+ const resourceIds = resource.combined_resource.resource_ids;
151
+ resourceIds.forEach((id) => {
152
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[id]) === false) {
153
+ checkCapacityResult.status = false;
154
+ }
155
+ });
156
+ }
147
157
  if (!checkCapacityResult.status) {
148
158
  return status;
149
159
  }
@@ -264,7 +274,8 @@ var getTimeSlicesByResource = ({
264
274
  duration,
265
275
  split = 10,
266
276
  currentDate = (0, import_dayjs.default)(),
267
- capacity
277
+ capacity,
278
+ resourcesUseableMap = {}
268
279
  }) => {
269
280
  const { times } = resource;
270
281
  const timeSlices = [];
@@ -288,8 +299,12 @@ var getTimeSlicesByResource = ({
288
299
  timeSlice,
289
300
  time,
290
301
  resource,
291
- currentCount: capacity || 1
302
+ currentCount: capacity || 1,
303
+ resourcesUseableMap
292
304
  });
305
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[resource.id]) !== false) {
306
+ resourcesUseableMap[resource.id] = _status.usable;
307
+ }
293
308
  if (_status.usable) {
294
309
  timeSlices.push({
295
310
  ...timeSlice,
@@ -326,9 +341,20 @@ var getTimeSlicesByResources = ({
326
341
  duration,
327
342
  currentDate,
328
343
  split,
329
- capacity
344
+ capacity,
345
+ resourcesUseableMap
330
346
  }) => {
331
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
+ });
332
358
  let timeSliceList = resources.reduce(
333
359
  (acc, item) => {
334
360
  return acc.concat(
@@ -337,7 +363,8 @@ var getTimeSlicesByResources = ({
337
363
  duration,
338
364
  split,
339
365
  currentDate,
340
- capacity
366
+ capacity,
367
+ resourcesUseableMap
341
368
  })
342
369
  );
343
370
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.57",
4
+ "version": "0.0.59",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",