@pisell/pisellos 3.0.41 → 3.0.43

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 (61) hide show
  1. package/dist/modules/AccountList/index.js +17 -12
  2. package/dist/modules/Cart/index.d.ts +14 -0
  3. package/dist/modules/Cart/index.js +38 -1
  4. package/dist/modules/Cart/utils/cartProduct.d.ts +3 -0
  5. package/dist/modules/Cart/utils/cartProduct.js +28 -8
  6. package/dist/modules/Cart/utils/changePrice.d.ts +3 -0
  7. package/dist/modules/Cart/utils/changePrice.js +104 -0
  8. package/dist/modules/Date/index.js +74 -10
  9. package/dist/modules/Date/types.d.ts +2 -0
  10. package/dist/modules/Discount/index.d.ts +1 -0
  11. package/dist/modules/Discount/index.js +13 -6
  12. package/dist/modules/Discount/types.d.ts +10 -0
  13. package/dist/modules/ProductList/index.d.ts +7 -0
  14. package/dist/modules/ProductList/index.js +102 -39
  15. package/dist/modules/Rules/index.js +218 -80
  16. package/dist/modules/Rules/types.d.ts +7 -1
  17. package/dist/modules/Schedule/index.d.ts +9 -1
  18. package/dist/modules/Schedule/index.js +122 -2
  19. package/dist/modules/Schedule/types.d.ts +13 -0
  20. package/dist/modules/Schedule/utils.js +4 -0
  21. package/dist/solution/BookingByStep/index.d.ts +121 -30
  22. package/dist/solution/BookingByStep/index.js +760 -1065
  23. package/dist/solution/BookingByStep/utils/capacity.d.ts +47 -0
  24. package/dist/solution/BookingByStep/utils/capacity.js +132 -0
  25. package/dist/solution/BookingByStep/utils/resources.d.ts +21 -29
  26. package/dist/solution/BookingByStep/utils/resources.js +39 -95
  27. package/dist/solution/BookingByStep/utils/timeslots.d.ts +11 -0
  28. package/dist/solution/BookingByStep/utils/timeslots.js +15 -0
  29. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  30. package/dist/solution/ShopDiscount/index.js +119 -44
  31. package/lib/modules/AccountList/index.js +4 -0
  32. package/lib/modules/Cart/index.d.ts +14 -0
  33. package/lib/modules/Cart/index.js +34 -1
  34. package/lib/modules/Cart/utils/cartProduct.d.ts +3 -0
  35. package/lib/modules/Cart/utils/cartProduct.js +20 -8
  36. package/lib/modules/Cart/utils/changePrice.d.ts +3 -0
  37. package/lib/modules/Cart/utils/changePrice.js +78 -0
  38. package/lib/modules/Date/index.js +62 -5
  39. package/lib/modules/Date/types.d.ts +2 -0
  40. package/lib/modules/Discount/index.d.ts +1 -0
  41. package/lib/modules/Discount/index.js +17 -6
  42. package/lib/modules/Discount/types.d.ts +10 -0
  43. package/lib/modules/ProductList/index.d.ts +7 -0
  44. package/lib/modules/ProductList/index.js +45 -0
  45. package/lib/modules/Rules/index.js +154 -63
  46. package/lib/modules/Rules/types.d.ts +7 -1
  47. package/lib/modules/Schedule/index.d.ts +9 -1
  48. package/lib/modules/Schedule/index.js +79 -1
  49. package/lib/modules/Schedule/types.d.ts +13 -0
  50. package/lib/modules/Schedule/utils.js +4 -1
  51. package/lib/solution/BookingByStep/index.d.ts +121 -30
  52. package/lib/solution/BookingByStep/index.js +395 -585
  53. package/lib/solution/BookingByStep/utils/capacity.d.ts +47 -0
  54. package/lib/solution/BookingByStep/utils/capacity.js +106 -0
  55. package/lib/solution/BookingByStep/utils/resources.d.ts +21 -29
  56. package/lib/solution/BookingByStep/utils/resources.js +21 -58
  57. package/lib/solution/BookingByStep/utils/timeslots.d.ts +11 -0
  58. package/lib/solution/BookingByStep/utils/timeslots.js +7 -0
  59. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  60. package/lib/solution/ShopDiscount/index.js +91 -19
  61. package/package.json +1 -1
@@ -0,0 +1,47 @@
1
+ import { CartItem } from "../../../modules";
2
+ import { CapacityItem, ResourceItem } from "./resources";
3
+ /**
4
+ * @title: 基于选择的商品格式化容量
5
+ * @description:
6
+ * @param {any} param1
7
+ * @return {*}
8
+ * @Author: zhiwei.Wang
9
+ */
10
+ export declare const formatDefaultCapacitys: ({ capacity, product_bundle, }: any) => CapacityItem[];
11
+ /**
12
+ * @title: 获取总容量
13
+ * @description:
14
+ * @param {object} capacity 为 formatDefaultCapacitys()的结果
15
+ * @return {*}
16
+ * @Author: zhiwei.Wang
17
+ */
18
+ export declare const getSumCapacity: ({ capacity }: {
19
+ capacity: CapacityItem[];
20
+ }) => number;
21
+ /**
22
+ * 给定购物车数据,返回对应的 capacity 信息和套餐 capacity
23
+ *
24
+ * @export
25
+ * @param {CartItem} targetCartItem
26
+ * @return {*}
27
+ */
28
+ export declare function getCapacityInfoByCartItem(targetCartItem: CartItem): {
29
+ formatCapacity: CapacityItem[];
30
+ currentCapacity: number;
31
+ };
32
+ /**
33
+ * @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
34
+ * @description:
35
+ * @param {object} resource
36
+ * @return {*}
37
+ * @Author: jinglin.tan
38
+ */
39
+ export declare const checkSubResourcesCapacity: (resource: ResourceItem) => void;
40
+ /**
41
+ * 检查资源是否有足够的容量供额外使用
42
+ * @param currentCapacity - 当前已使用的容量
43
+ * @param requiredCapacity - 需要的额外容量
44
+ * @param maxCapacity - 最大允许容量
45
+ * @returns 如果资源可以容纳额外的容量则返回 true
46
+ */
47
+ export declare const checkResourceCanUseByCapacity: (currentCapacity: number, requiredCapacity: number, maxCapacity: number) => boolean;
@@ -0,0 +1,132 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ /**
5
+ * @title: 基于选择的商品格式化容量
6
+ * @description:
7
+ * @param {any} param1
8
+ * @return {*}
9
+ * @Author: zhiwei.Wang
10
+ */
11
+ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref) {
12
+ var capacity = _ref.capacity,
13
+ product_bundle = _ref.product_bundle;
14
+ if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
15
+ return (product_bundle || []).map(function (d) {
16
+ var id = d.bundle_product_id;
17
+ var item = ((capacity === null || capacity === void 0 ? void 0 : capacity.package) || []).find(function (item) {
18
+ return item.product_id === id;
19
+ });
20
+ return {
21
+ id: id,
22
+ value: item ? d.num || 0 : 0,
23
+ name: (item === null || item === void 0 ? void 0 : item.name) || (d === null || d === void 0 ? void 0 : d.title)
24
+ };
25
+ });
26
+ }
27
+ if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'custom') {
28
+ return ((capacity === null || capacity === void 0 ? void 0 : capacity.custom) || []).map(function (d) {
29
+ return {
30
+ id: d.id,
31
+ value: d.min,
32
+ name: d.name
33
+ };
34
+ });
35
+ }
36
+
37
+ // 默认为1
38
+ return [{
39
+ id: 0,
40
+ value: 1,
41
+ name: ''
42
+ }];
43
+ };
44
+
45
+ /**
46
+ * @title: 获取总容量
47
+ * @description:
48
+ * @param {object} capacity 为 formatDefaultCapacitys()的结果
49
+ * @return {*}
50
+ * @Author: zhiwei.Wang
51
+ */
52
+ export var getSumCapacity = function getSumCapacity(_ref2) {
53
+ var capacity = _ref2.capacity;
54
+ var sum = 0;
55
+ var _iterator = _createForOfIteratorHelper(capacity || []),
56
+ _step;
57
+ try {
58
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
59
+ var item = _step.value;
60
+ sum += item.value;
61
+ }
62
+ } catch (err) {
63
+ _iterator.e(err);
64
+ } finally {
65
+ _iterator.f();
66
+ }
67
+ return sum;
68
+ };
69
+
70
+ /**
71
+ * 给定购物车数据,返回对应的 capacity 信息和套餐 capacity
72
+ *
73
+ * @export
74
+ * @param {CartItem} targetCartItem
75
+ * @return {*}
76
+ */
77
+ export function getCapacityInfoByCartItem(targetCartItem) {
78
+ var _targetCartItem$_prod;
79
+ var formatCapacity = formatDefaultCapacitys({
80
+ capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
81
+ product_bundle: targetCartItem._origin.product.product_bundle
82
+ });
83
+ var currentCapacity = getSumCapacity({
84
+ capacity: formatCapacity
85
+ });
86
+ return {
87
+ formatCapacity: formatCapacity,
88
+ currentCapacity: currentCapacity
89
+ };
90
+ }
91
+
92
+ /**
93
+ * @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
94
+ * @description:
95
+ * @param {object} resource
96
+ * @return {*}
97
+ * @Author: jinglin.tan
98
+ */
99
+ export var checkSubResourcesCapacity = function checkSubResourcesCapacity(resource) {
100
+ if (resource.children && resource.children.length) {
101
+ var countCapacity = resource.capacity; // 100
102
+ resource.children.forEach(function (child, index) {
103
+ if (index === resource.children.length - 1) {
104
+ // 如果是最后一个资源,直接拿剩余未分配完的容量去占用
105
+ // 哪怕这个东西会超过资源本身的 capacity也得让他占,PRD 里有写
106
+ child.capacity = countCapacity;
107
+ return;
108
+ }
109
+ if (child.capacity <= countCapacity) {
110
+ countCapacity -= child.capacity; // 100 - = 90
111
+ } else {
112
+ child.capacity = countCapacity; // 10
113
+ countCapacity = 0; // 0
114
+ }
115
+ });
116
+ }
117
+ };
118
+
119
+ /**
120
+ * 检查资源是否有足够的容量供额外使用
121
+ * @param currentCapacity - 当前已使用的容量
122
+ * @param requiredCapacity - 需要的额外容量
123
+ * @param maxCapacity - 最大允许容量
124
+ * @returns 如果资源可以容纳额外的容量则返回 true
125
+ */
126
+ export var checkResourceCanUseByCapacity = function checkResourceCanUseByCapacity(currentCapacity, requiredCapacity, maxCapacity) {
127
+ // Handle edge cases early
128
+ if (currentCapacity < 0 || requiredCapacity < 0 || maxCapacity <= 0) {
129
+ return false;
130
+ }
131
+ return currentCapacity + requiredCapacity <= maxCapacity;
132
+ };
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
79
79
  * @return {*}
80
80
  * @Author: zhiwei.Wang
81
81
  */
82
- export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
82
+ export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
83
83
  resource: ResourceItem;
84
84
  duration: number;
85
85
  split: number;
@@ -138,7 +138,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
138
138
  * @return {*}
139
139
  * @Author: zhiwei.Wang
140
140
  */
141
- export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary }: {
141
+ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
142
142
  resourceIds: number[];
143
143
  resourcesMap: any;
144
144
  duration: number;
@@ -180,37 +180,11 @@ export declare const getOthersSelectedResources: (cartItems: CartItem[], account
180
180
  * @Author: jinglin.tan
181
181
  */
182
182
  export declare const getOthersCartSelectedResources: (cartItems: CartItem[], cartItemId: number | string, resourcesMap: Record<string, ResourceItem>) => number[];
183
- interface CapacityItem {
183
+ export interface CapacityItem {
184
184
  id: number;
185
185
  value: number;
186
186
  name: string;
187
187
  }
188
- /**
189
- * @title: 基于选择的商品格式化容量
190
- * @description:
191
- * @param {any} param1
192
- * @return {*}
193
- * @Author: zhiwei.Wang
194
- */
195
- export declare const formatDefaultCapacitys: ({ capacity, product_bundle, }: any) => CapacityItem[];
196
- /**
197
- * @title: 获取总容量
198
- * @description:
199
- * @param {object} capacity 为 formatDefaultCapacitys()的结果
200
- * @return {*}
201
- * @Author: zhiwei.Wang
202
- */
203
- export declare const getSumCapacity: ({ capacity }: {
204
- capacity: CapacityItem[];
205
- }) => number;
206
- /**
207
- * @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
208
- * @description:
209
- * @param {object} resource
210
- * @return {*}
211
- * @Author: jinglin.tan
212
- */
213
- export declare const checkSubResourcesCapacity: (resource: ResourceItem) => void;
214
188
  /**
215
189
  * @title: 根据日期范围过滤日程
216
190
  *
@@ -248,4 +222,22 @@ export declare function getResourcesIdsByProduct(product: ProductData): number[]
248
222
  * @return {*}
249
223
  */
250
224
  export declare function sortCombinedResources(resourcesList: ResourceItem[]): ResourceItem[];
225
+ /**
226
+ * 传入一个资源组,根据 formid筛出相同类型的资源
227
+ *
228
+ * @export
229
+ * @param {ResourceItem[]} resources
230
+ * @param {string} form_id
231
+ * @return {*}
232
+ */
233
+ export declare function filterResourcesByFormItem(resources: ResourceItem[], form_id: string): ResourceItem[];
234
+ /**
235
+ * 传入两个资源,确认这两个资源是否有交集(包括组合资源)
236
+ *
237
+ * @export
238
+ * @param {ResourceItem} resource1
239
+ * @param {ResourceItem} resource2
240
+ * @return {*}
241
+ */
242
+ export declare function checkTwoResourcesIntersection(resource1: ResourceItem, resource2: ResourceItem): true | undefined;
251
243
  export {};
@@ -463,8 +463,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
463
463
  }
464
464
  if (_status.usable) {
465
465
  // 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
466
- var operatingBoundaryDateTime = (operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.type) === 'start_time' ? "23:59" : operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.time;
467
- if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
466
+ var operatingBoundaryDateTime = (operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.type) === 'start_time' ? '23:59' : operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.time;
467
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || '23:59')) {
468
468
  break;
469
469
  }
470
470
  // 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
@@ -702,99 +702,6 @@ export var getOthersCartSelectedResources = function getOthersCartSelectedResour
702
702
  return acc;
703
703
  }, []);
704
704
  };
705
- /**
706
- * @title: 基于选择的商品格式化容量
707
- * @description:
708
- * @param {any} param1
709
- * @return {*}
710
- * @Author: zhiwei.Wang
711
- */
712
- export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref7) {
713
- var capacity = _ref7.capacity,
714
- product_bundle = _ref7.product_bundle;
715
- if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
716
- return (product_bundle || []).map(function (d) {
717
- var id = d.bundle_product_id;
718
- var item = ((capacity === null || capacity === void 0 ? void 0 : capacity.package) || []).find(function (item) {
719
- return item.product_id === id;
720
- });
721
- return {
722
- id: id,
723
- value: item ? d.num || 0 : 0,
724
- name: (item === null || item === void 0 ? void 0 : item.name) || (d === null || d === void 0 ? void 0 : d.title)
725
- };
726
- });
727
- }
728
- if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'custom') {
729
- return ((capacity === null || capacity === void 0 ? void 0 : capacity.custom) || []).map(function (d) {
730
- return {
731
- id: d.id,
732
- value: d.min,
733
- name: d.name
734
- };
735
- });
736
- }
737
-
738
- // 默认为1
739
- return [{
740
- id: 0,
741
- value: 1,
742
- name: ''
743
- }];
744
- };
745
-
746
- /**
747
- * @title: 获取总容量
748
- * @description:
749
- * @param {object} capacity 为 formatDefaultCapacitys()的结果
750
- * @return {*}
751
- * @Author: zhiwei.Wang
752
- */
753
- export var getSumCapacity = function getSumCapacity(_ref8) {
754
- var capacity = _ref8.capacity;
755
- var sum = 0;
756
- var _iterator2 = _createForOfIteratorHelper(capacity || []),
757
- _step2;
758
- try {
759
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
760
- var item = _step2.value;
761
- sum += item.value;
762
- }
763
- } catch (err) {
764
- _iterator2.e(err);
765
- } finally {
766
- _iterator2.f();
767
- }
768
- return sum;
769
- };
770
-
771
- /**
772
- * @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
773
- * @description:
774
- * @param {object} resource
775
- * @return {*}
776
- * @Author: jinglin.tan
777
- */
778
- export var checkSubResourcesCapacity = function checkSubResourcesCapacity(resource) {
779
- if (resource.children && resource.children.length) {
780
- var countCapacity = resource.capacity; // 100
781
- resource.children.forEach(function (child, index) {
782
- if (index === resource.children.length - 1) {
783
- // 如果是最后一个资源,直接拿剩余未分配完的容量去占用
784
- // 哪怕这个东西会超过资源本身的 capacity也得让他占,PRD 里有写
785
- child.capacity = countCapacity;
786
- return;
787
- }
788
- if (child.capacity <= countCapacity) {
789
- countCapacity -= child.capacity; // 100 - = 90
790
- } else {
791
- child.capacity = countCapacity; // 10
792
- countCapacity = 0; // 0
793
- }
794
- });
795
- }
796
- };
797
-
798
705
  /**
799
706
  * @title: 根据日期范围过滤日程
800
707
  *
@@ -892,4 +799,41 @@ export function sortCombinedResources(resourcesList) {
892
799
  return aIsCombined === bIsCombined ? 0 : aIsCombined ? 1 : -1;
893
800
  });
894
801
  return newResourcesList;
802
+ }
803
+
804
+ /**
805
+ * 传入一个资源组,根据 formid筛出相同类型的资源
806
+ *
807
+ * @export
808
+ * @param {ResourceItem[]} resources
809
+ * @param {string} form_id
810
+ * @return {*}
811
+ */
812
+ export function filterResourcesByFormItem(resources, form_id) {
813
+ return resources.filter(function (n) {
814
+ return n.form_id === form_id;
815
+ });
816
+ }
817
+
818
+ /**
819
+ * 传入两个资源,确认这两个资源是否有交集(包括组合资源)
820
+ *
821
+ * @export
822
+ * @param {ResourceItem} resource1
823
+ * @param {ResourceItem} resource2
824
+ * @return {*}
825
+ */
826
+ export function checkTwoResourcesIntersection(resource1, resource2) {
827
+ var _resource1$metadata$c, _resource2$metadata$c;
828
+ // 检查主资源ID是否匹配
829
+ if (resource1.id === resource2.id) return true;
830
+ // 检查组合资源的情况
831
+ if (((_resource1$metadata$c = resource1.metadata.combined_resource) === null || _resource1$metadata$c === void 0 ? void 0 : _resource1$metadata$c.status) === 1 && (
832
+ // 如果现在选择的是组合资源,需要判断
833
+ // 1、当前其他购物车里是否选了当前组合资源的子资源
834
+ // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
835
+ resource1.metadata.combined_resource.resource_ids.includes(resource2.id) || resource1.metadata.combined_resource.resource_ids.some(function (n) {
836
+ return resource2.metadata.combined_resource.resource_ids.includes(n);
837
+ }))) return true;
838
+ if (((_resource2$metadata$c = resource2.metadata.combined_resource) === null || _resource2$metadata$c === void 0 ? void 0 : _resource2$metadata$c.status) === 1 && resource2.metadata.combined_resource.resource_ids.includes(resource2.id)) return true;
895
839
  }
@@ -1,3 +1,4 @@
1
+ import { Dayjs } from "dayjs";
1
2
  import { ResourceItem, TimeSliceItem } from "./resources";
2
3
  /**
3
4
  * 计算资源在指定时间段内的总可用时间(以分钟为单位)
@@ -23,3 +24,13 @@ export declare function findFastestAvailableResource({ resources, currentCapacit
23
24
  currentCapacity?: number;
24
25
  countMap?: Record<number, number>;
25
26
  }): ResourceItem | null;
27
+ /**
28
+ * 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
29
+ *
30
+ * @export
31
+ * @param {TimeSliceItem[]} times
32
+ * @param {Dayjs} startTime
33
+ * @param {Dayjs} endTime
34
+ * @return {*}
35
+ */
36
+ export declare function filterConditionTimeSlots(times: TimeSliceItem[], startTime: Dayjs, endTime: Dayjs): TimeSliceItem[];
@@ -206,4 +206,19 @@ export function findFastestAvailableResource(_ref2) {
206
206
  }
207
207
  }
208
208
  return selectedResource;
209
+ }
210
+
211
+ /**
212
+ * 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
213
+ *
214
+ * @export
215
+ * @param {TimeSliceItem[]} times
216
+ * @param {Dayjs} startTime
217
+ * @param {Dayjs} endTime
218
+ * @return {*}
219
+ */
220
+ export function filterConditionTimeSlots(times, startTime, endTime) {
221
+ return times.filter(function (n) {
222
+ return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
223
+ });
209
224
  }
@@ -10,6 +10,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
10
10
  private window;
11
11
  private store;
12
12
  private options;
13
+ private hooks?;
13
14
  constructor(name?: string, version?: string);
14
15
  initialize(core: PisellCore, options: any): Promise<void>;
15
16
  destroy(): Promise<void>;
@@ -37,6 +38,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
37
38
  isAvailable: boolean;
38
39
  productList: Record<string, any>[];
39
40
  discountList: Discount[];
41
+ type: "server" | "clientCalc";
40
42
  }>;
41
43
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
42
44
  private getCustomer;