@pisell/pisellos 0.0.115 → 0.0.117

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 (55) hide show
  1. package/dist/modules/Cart/index.js +16 -35
  2. package/dist/modules/Cart/utils/cartAccount.d.ts +21 -0
  3. package/dist/modules/Cart/utils/cartAccount.js +52 -0
  4. package/dist/modules/Cart/utils/cartDate.d.ts +31 -0
  5. package/dist/modules/Cart/utils/cartDate.js +55 -0
  6. package/dist/modules/Cart/utils/cartDiscount.d.ts +19 -0
  7. package/dist/modules/Cart/utils/cartDiscount.js +35 -0
  8. package/dist/modules/Cart/utils/cartNote.d.ts +19 -0
  9. package/dist/modules/Cart/utils/cartNote.js +29 -0
  10. package/dist/modules/Cart/utils/cartProduct.d.ts +107 -0
  11. package/dist/modules/Cart/{utils.js → utils/cartProduct.js} +77 -416
  12. package/dist/modules/Cart/utils/cartRelationForms.d.ts +26 -0
  13. package/dist/modules/Cart/utils/cartRelationForms.js +29 -0
  14. package/dist/modules/Cart/utils/cartResource.d.ts +21 -0
  15. package/dist/modules/Cart/utils/cartResource.js +102 -0
  16. package/dist/modules/Cart/utils/index.d.ts +34 -0
  17. package/dist/modules/Cart/utils/index.js +63 -0
  18. package/dist/modules/Order/index.js +3 -2
  19. package/dist/modules/Product/index.d.ts +1 -1
  20. package/dist/modules/Product/types.d.ts +4 -0
  21. package/dist/modules/Product/utils.d.ts +17 -0
  22. package/dist/modules/Product/utils.js +41 -0
  23. package/dist/solution/BookingByStep/index.d.ts +25 -0
  24. package/dist/solution/BookingByStep/index.js +320 -58
  25. package/dist/solution/BookingByStep/utils/timeslots.d.ts +25 -0
  26. package/dist/solution/BookingByStep/utils/timeslots.js +209 -0
  27. package/lib/modules/Cart/index.js +14 -25
  28. package/lib/modules/Cart/utils/cartAccount.d.ts +21 -0
  29. package/lib/modules/Cart/utils/cartAccount.js +65 -0
  30. package/lib/modules/Cart/utils/cartDate.d.ts +31 -0
  31. package/lib/modules/Cart/utils/cartDate.js +75 -0
  32. package/lib/modules/Cart/utils/cartDiscount.d.ts +19 -0
  33. package/lib/modules/Cart/utils/cartDiscount.js +52 -0
  34. package/lib/modules/Cart/utils/cartNote.d.ts +19 -0
  35. package/lib/modules/Cart/utils/cartNote.js +46 -0
  36. package/lib/modules/Cart/utils/cartProduct.d.ts +107 -0
  37. package/lib/modules/Cart/{utils.js → utils/cartProduct.js} +78 -328
  38. package/lib/modules/Cart/utils/cartRelationForms.d.ts +26 -0
  39. package/lib/modules/Cart/utils/cartRelationForms.js +48 -0
  40. package/lib/modules/Cart/utils/cartResource.d.ts +21 -0
  41. package/lib/modules/Cart/utils/cartResource.js +124 -0
  42. package/lib/modules/Cart/utils/index.d.ts +34 -0
  43. package/lib/modules/Cart/utils/index.js +91 -0
  44. package/lib/modules/Order/index.js +2 -1
  45. package/lib/modules/Product/index.d.ts +1 -1
  46. package/lib/modules/Product/types.d.ts +4 -0
  47. package/lib/modules/Product/utils.d.ts +17 -0
  48. package/lib/modules/Product/utils.js +46 -0
  49. package/lib/solution/BookingByStep/index.d.ts +25 -0
  50. package/lib/solution/BookingByStep/index.js +181 -23
  51. package/lib/solution/BookingByStep/utils/timeslots.d.ts +25 -0
  52. package/lib/solution/BookingByStep/utils/timeslots.js +159 -0
  53. package/package.json +1 -1
  54. package/dist/modules/Cart/utils.d.ts +0 -257
  55. package/lib/modules/Cart/utils.d.ts +0 -257
@@ -0,0 +1,25 @@
1
+ import { ResourceItem, TimeSliceItem } from "./resources";
2
+ /**
3
+ * 计算资源在指定时间段内的总可用时间(以分钟为单位)
4
+ * @param resource 需要计算可用时间的资源
5
+ * @param timeSlots 要检查可用性的时间段
6
+ * @param currentCapacity 当前预约所需的容量
7
+ * @returns 总可用时间(分钟)
8
+ */
9
+ export declare function calculateResourceAvailableTime({ resource, timeSlots, currentCapacity, }: {
10
+ resource: ResourceItem;
11
+ timeSlots: TimeSliceItem;
12
+ currentCapacity?: number;
13
+ }): number;
14
+ /**
15
+ * 查找最快可用的资源,如果有多个资源在相同时间点可用,则选择空闲时间最长的资源
16
+ * @param resources 资源列表
17
+ * @param currentCapacity 当前预约所需的容量
18
+ * @param countMap 已预约数量映射
19
+ * @returns 最快可用的资源
20
+ */
21
+ export declare function findFastestAvailableResource({ resources, currentCapacity, countMap, }: {
22
+ resources: ResourceItem[];
23
+ currentCapacity?: number;
24
+ countMap?: Record<number, number>;
25
+ }): ResourceItem | null;
@@ -0,0 +1,209 @@
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
+ import dayjs from "dayjs";
5
+ /**
6
+ * 计算资源在指定时间段内的总可用时间(以分钟为单位)
7
+ * @param resource 需要计算可用时间的资源
8
+ * @param timeSlots 要检查可用性的时间段
9
+ * @param currentCapacity 当前预约所需的容量
10
+ * @returns 总可用时间(分钟)
11
+ */
12
+ export function calculateResourceAvailableTime(_ref) {
13
+ var resource = _ref.resource,
14
+ timeSlots = _ref.timeSlots,
15
+ _ref$currentCapacity = _ref.currentCapacity,
16
+ currentCapacity = _ref$currentCapacity === void 0 ? 1 : _ref$currentCapacity;
17
+ // 过滤出与给定日期相同的资源时间
18
+ var matchingTimes = resource.times.filter(function (time) {
19
+ return dayjs(time.start_at).isSame(dayjs(timeSlots.start_at), 'day');
20
+ });
21
+ if (matchingTimes.length === 0) return 0;
22
+
23
+ // 计算所有时间段与目标时间槽的重叠部分
24
+ var overlaps = [];
25
+ var _iterator = _createForOfIteratorHelper(matchingTimes),
26
+ _step;
27
+ try {
28
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
29
+ var time = _step.value;
30
+ // 计算实际重叠的时间段
31
+ var overlapStart = dayjs(time.start_at).isAfter(dayjs(timeSlots.start_at)) ? dayjs(time.start_at) : dayjs(timeSlots.start_at);
32
+ var overlapEnd = dayjs(time.end_at).isBefore(dayjs(timeSlots.end_at)) ? dayjs(time.end_at) : dayjs(timeSlots.end_at);
33
+
34
+ // 只有当重叠时间段有效时才添加
35
+ if (overlapStart.isBefore(overlapEnd)) {
36
+ overlaps.push({
37
+ start: overlapStart,
38
+ end: overlapEnd
39
+ });
40
+ }
41
+ }
42
+
43
+ // 合并重叠的时间段,计算并集
44
+ } catch (err) {
45
+ _iterator.e(err);
46
+ } finally {
47
+ _iterator.f();
48
+ }
49
+ if (overlaps.length === 0) return 0;
50
+
51
+ // 按开始时间排序
52
+ overlaps.sort(function (a, b) {
53
+ return a.start.diff(b.start);
54
+ });
55
+
56
+ // 合并重叠的时间段
57
+ var merged = [];
58
+ var current = overlaps[0];
59
+ for (var i = 1; i < overlaps.length; i++) {
60
+ var next = overlaps[i];
61
+
62
+ // 如果当前时间段与下一个时间段重叠或相邻,则合并
63
+ if (current.end.isSameOrAfter(next.start)) {
64
+ current.end = current.end.isAfter(next.end) ? current.end : next.end;
65
+ } else {
66
+ // 不重叠,添加当前时间段到结果中,开始处理下一个
67
+ merged.push(current);
68
+ current = next;
69
+ }
70
+ }
71
+ merged.push(current);
72
+
73
+ // 计算所有合并后时间段的总时长
74
+ var totalAvailableMinutes = 0;
75
+ for (var _i = 0, _merged = merged; _i < _merged.length; _i++) {
76
+ var segment = _merged[_i];
77
+ totalAvailableMinutes += segment.end.diff(segment.start, 'minute');
78
+ }
79
+ return totalAvailableMinutes;
80
+ }
81
+
82
+ /**
83
+ * 查找最快可用的资源,如果有多个资源在相同时间点可用,则选择空闲时间最长的资源
84
+ * @param resources 资源列表
85
+ * @param currentCapacity 当前预约所需的容量
86
+ * @param countMap 已预约数量映射
87
+ * @returns 最快可用的资源
88
+ */
89
+ export function findFastestAvailableResource(_ref2) {
90
+ var resources = _ref2.resources,
91
+ _ref2$currentCapacity = _ref2.currentCapacity,
92
+ currentCapacity = _ref2$currentCapacity === void 0 ? 1 : _ref2$currentCapacity,
93
+ _ref2$countMap = _ref2.countMap,
94
+ countMap = _ref2$countMap === void 0 ? {} : _ref2$countMap;
95
+ var currentTime = dayjs();
96
+ var fastestTime = null;
97
+ var fastestResources = [];
98
+
99
+ // 遍历所有资源,找到最快可用的时间点
100
+ var _iterator2 = _createForOfIteratorHelper(resources),
101
+ _step2;
102
+ try {
103
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
104
+ var _resource = _step2.value;
105
+ // 获取资源当天的时间段
106
+ var todayTimes = _resource.times.filter(function (time) {
107
+ return dayjs(time.start_at).isSame(currentTime, 'day');
108
+ });
109
+ if (todayTimes.length === 0) continue;
110
+
111
+ // 按开始时间排序
112
+ todayTimes.sort(function (a, b) {
113
+ return dayjs(a.start_at).diff(dayjs(b.start_at));
114
+ });
115
+
116
+ // 找到第一个可用的时间段
117
+ var _iterator3 = _createForOfIteratorHelper(todayTimes),
118
+ _step3;
119
+ try {
120
+ var _loop = function _loop() {
121
+ var time = _step3.value;
122
+ var startTime = dayjs(time.start_at);
123
+
124
+ // 如果开始时间在当前时间之前,跳过
125
+ if (startTime.isBefore(currentTime)) return 0; // continue
126
+
127
+ // 检查这个时间段是否可用
128
+ if (_resource.resourceType === 'single') {
129
+ var _time$event_list;
130
+ // 单个预约类型:检查是否有预约
131
+ var hasBooking = (_time$event_list = time.event_list) === null || _time$event_list === void 0 ? void 0 : _time$event_list.some(function (event) {
132
+ return dayjs(event.start_at).isSame(startTime);
133
+ });
134
+ if (!hasBooking) {
135
+ if (!fastestTime || startTime.isSame(fastestTime)) {
136
+ fastestTime = startTime;
137
+ fastestResources.push(_resource);
138
+ } else if (startTime.isBefore(fastestTime)) {
139
+ fastestTime = startTime;
140
+ fastestResources = [_resource];
141
+ }
142
+ return 1; // break
143
+ }
144
+ } else {
145
+ var _time$event_list2;
146
+ // 多个预约类型:检查容量
147
+ var totalCapacity = _resource.capacity || 0;
148
+ var usedCapacity = ((_time$event_list2 = time.event_list) === null || _time$event_list2 === void 0 ? void 0 : _time$event_list2.reduce(function (sum, event) {
149
+ return dayjs(event.start_at).isSame(startTime) ? sum + (event.pax || 0) : sum;
150
+ }, 0)) || 0;
151
+ var remainingCapacity = totalCapacity - usedCapacity;
152
+ if (remainingCapacity >= (countMap[_resource.id] || 0) + currentCapacity) {
153
+ if (!fastestTime || startTime.isSame(fastestTime)) {
154
+ fastestTime = startTime;
155
+ fastestResources.push(_resource);
156
+ } else if (startTime.isBefore(fastestTime)) {
157
+ fastestTime = startTime;
158
+ fastestResources = [_resource];
159
+ }
160
+ return 1; // break
161
+ }
162
+ }
163
+ },
164
+ _ret;
165
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
166
+ _ret = _loop();
167
+ if (_ret === 0) continue;
168
+ if (_ret === 1) break;
169
+ }
170
+ } catch (err) {
171
+ _iterator3.e(err);
172
+ } finally {
173
+ _iterator3.f();
174
+ }
175
+ }
176
+
177
+ // 如果没有找到可用资源,返回null
178
+ } catch (err) {
179
+ _iterator2.e(err);
180
+ } finally {
181
+ _iterator2.f();
182
+ }
183
+ if (!fastestTime || fastestResources.length === 0) return null;
184
+
185
+ // 如果只有一个最快可用的资源,直接返回
186
+ if (fastestResources.length === 1) return fastestResources[0];
187
+
188
+ // 如果有多个最快可用的资源,比较它们的空闲时间
189
+ var maxIdleTime = 0;
190
+ var selectedResource = null;
191
+ for (var _i2 = 0, _fastestResources = fastestResources; _i2 < _fastestResources.length; _i2++) {
192
+ var resource = _fastestResources[_i2];
193
+ var idleTime = calculateResourceAvailableTime({
194
+ resource: resource,
195
+ timeSlots: {
196
+ start_time: fastestTime.format('HH:mm'),
197
+ end_time: fastestTime.format('HH:mm'),
198
+ start_at: fastestTime,
199
+ end_at: fastestTime
200
+ },
201
+ currentCapacity: (countMap[resource.id] || 0) + currentCapacity
202
+ });
203
+ if (idleTime > maxIdleTime) {
204
+ maxIdleTime = idleTime;
205
+ selectedResource = resource;
206
+ }
207
+ }
208
+ return selectedResource;
209
+ }
@@ -70,30 +70,24 @@ var CartModule = class extends import_BaseModule.BaseModule {
70
70
  * 添加商品到购物车
71
71
  */
72
72
  async addItem(params) {
73
- const { account, product, bundle, options, date } = params;
73
+ const { account, product, bundle, options, date, quantity = 1 } = params;
74
74
  let cartItem = {
75
75
  _id: (0, import_utils.getUniqueId)(),
76
76
  _origin: (0, import_utils.createCartItemOrigin)()
77
77
  };
78
78
  if (product) {
79
- if (product.product_variant_id) {
80
- const targetVariant = product.variant.find((n) => n.id === product.product_variant_id);
81
- if (targetVariant) {
82
- product.price = targetVariant.price;
83
- product.original_price = targetVariant.original_price;
84
- product.is_charge_tax = targetVariant.is_charge_tax;
85
- }
86
- }
87
- cartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
88
- cartItem._productInit = (0, import_lodash_es.cloneDeep)(product);
79
+ const newProduct = (0, import_utils.handleVariantProduct)(product);
80
+ cartItem._productOrigin = (0, import_lodash_es.cloneDeep)(newProduct);
81
+ cartItem._productInit = (0, import_lodash_es.cloneDeep)(newProduct);
89
82
  cartItem._bundleOrigin = (0, import_lodash_es.cloneDeep)(bundle);
90
83
  cartItem._optionsOrigin = (0, import_lodash_es.cloneDeep)(options);
91
84
  cartItem = (0, import_utils.formatProductToCartItem)({
92
85
  cartItem,
93
- product,
86
+ product: newProduct,
94
87
  bundle,
95
88
  options,
96
- product_variant_id: product.product_variant_id
89
+ product_variant_id: newProduct.product_variant_id,
90
+ quantity
97
91
  });
98
92
  }
99
93
  if (account) {
@@ -139,7 +133,8 @@ var CartModule = class extends import_BaseModule.BaseModule {
139
133
  resources,
140
134
  note,
141
135
  date,
142
- relationForms
136
+ relationForms,
137
+ quantity
143
138
  } = params;
144
139
  let tempCartItem = this.store.list.find((i) => i._id === _id);
145
140
  if (!tempCartItem) {
@@ -149,23 +144,17 @@ var CartModule = class extends import_BaseModule.BaseModule {
149
144
  tempCartItem = cartItem;
150
145
  }
151
146
  if (product) {
152
- if (product.product_variant_id) {
153
- const targetVariant = product.variant.find((n) => n.id === product.product_variant_id);
154
- if (targetVariant) {
155
- product.price = targetVariant.price;
156
- product.original_price = targetVariant.original_price;
157
- product.is_charge_tax = targetVariant.is_charge_tax;
158
- }
159
- }
160
- tempCartItem._productOrigin = (0, import_lodash_es.cloneDeep)(product);
147
+ const newProduct = (0, import_utils.handleVariantProduct)(product);
148
+ tempCartItem._productOrigin = (0, import_lodash_es.cloneDeep)(newProduct);
161
149
  tempCartItem._bundleOrigin = (0, import_lodash_es.cloneDeep)(bundle);
162
150
  tempCartItem._optionsOrigin = (0, import_lodash_es.cloneDeep)(options);
163
151
  tempCartItem = (0, import_utils.formatProductToCartItem)({
164
152
  cartItem: tempCartItem,
165
- product,
153
+ product: newProduct,
166
154
  bundle,
167
155
  options,
168
- product_variant_id: product.product_variant_id
156
+ product_variant_id: newProduct.product_variant_id,
157
+ quantity
169
158
  });
170
159
  }
171
160
  if (discounts) {
@@ -0,0 +1,21 @@
1
+ import { Account } from '../../Account/types';
2
+ import { CartItem } from '../types';
3
+ /**
4
+ * 格式化账户到购物车
5
+ * @param account 账户
6
+ * @returns 格式化后的账户
7
+ */
8
+ export declare const formatAccountToCartItem: (params: {
9
+ cartItem: CartItem;
10
+ account: Account;
11
+ }) => CartItem;
12
+ export declare const formatAccountToCartItemOrigin: (params: {
13
+ cartItem: CartItem;
14
+ account: Account;
15
+ }) => any;
16
+ /**
17
+ * 从购物车中删除账户信息
18
+ * @param cartItem 购物车
19
+ * @returns 删除后的购物车
20
+ */
21
+ export declare const deleteHolderFromCartItem: (cartItem: CartItem) => CartItem;
@@ -0,0 +1,65 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/Cart/utils/cartAccount.ts
20
+ var cartAccount_exports = {};
21
+ __export(cartAccount_exports, {
22
+ deleteHolderFromCartItem: () => deleteHolderFromCartItem,
23
+ formatAccountToCartItem: () => formatAccountToCartItem,
24
+ formatAccountToCartItemOrigin: () => formatAccountToCartItemOrigin
25
+ });
26
+ module.exports = __toCommonJS(cartAccount_exports);
27
+ var formatAccountToCartItem = (params) => {
28
+ const { cartItem, account } = params;
29
+ if (account) {
30
+ cartItem.holder_id = account.id;
31
+ cartItem.holder_title = account.username;
32
+ }
33
+ const oringin = formatAccountToCartItemOrigin(params);
34
+ cartItem._origin = oringin;
35
+ return cartItem;
36
+ };
37
+ var formatAccountToCartItemOrigin = (params) => {
38
+ const { cartItem, account } = params;
39
+ let origin = cartItem._origin;
40
+ if (account) {
41
+ if ((account == null ? void 0 : account.type) === "holder") {
42
+ const { customer_id, form_id, form_record_id } = (account == null ? void 0 : account._origin) || {};
43
+ origin.holder = {
44
+ customer_id,
45
+ form_id,
46
+ form_record: form_record_id ? [form_record_id] : null
47
+ };
48
+ } else {
49
+ origin.metadata.account = account;
50
+ }
51
+ }
52
+ return origin;
53
+ };
54
+ var deleteHolderFromCartItem = (cartItem) => {
55
+ cartItem.holder_id = void 0;
56
+ cartItem.holder_title = void 0;
57
+ cartItem._origin.holder = null;
58
+ return cartItem;
59
+ };
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ deleteHolderFromCartItem,
63
+ formatAccountToCartItem,
64
+ formatAccountToCartItemOrigin
65
+ });
@@ -0,0 +1,31 @@
1
+ import { CartItem } from '../types';
2
+ /**
3
+ * 格式化日期到购物车
4
+ * @param date 开始时间和结束时间
5
+ * @returns 格式化后的日期
6
+ */
7
+ export declare const formatDateToCartItem: (params: {
8
+ cartItem: CartItem;
9
+ date: {
10
+ startTime: string;
11
+ endTime: string;
12
+ };
13
+ }) => CartItem;
14
+ /**
15
+ * 格式化日期到购物车原始数据
16
+ * @param date 开始时间和结束时间
17
+ * @returns 格式化后的日期原始数据
18
+ */
19
+ export declare const formatDateToCartItemOrigin: (params: {
20
+ cartItem: CartItem;
21
+ date: {
22
+ startTime: string;
23
+ endTime: string;
24
+ };
25
+ }) => any;
26
+ /**
27
+ * 从购物车中删除时间
28
+ * @param cartItem 购物车
29
+ * @returns 删除后的购物车
30
+ */
31
+ export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
@@ -0,0 +1,75 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/modules/Cart/utils/cartDate.ts
30
+ var cartDate_exports = {};
31
+ __export(cartDate_exports, {
32
+ deleteTimeFromCartItem: () => deleteTimeFromCartItem,
33
+ formatDateToCartItem: () => formatDateToCartItem,
34
+ formatDateToCartItemOrigin: () => formatDateToCartItemOrigin
35
+ });
36
+ module.exports = __toCommonJS(cartDate_exports);
37
+ var import_dayjs = __toESM(require("dayjs"));
38
+ var formatDateToCartItem = (params) => {
39
+ const { cartItem, date } = params;
40
+ cartItem.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
41
+ cartItem.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
42
+ cartItem.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
43
+ cartItem.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
44
+ const oringin = formatDateToCartItemOrigin(params);
45
+ cartItem._origin = oringin;
46
+ return cartItem;
47
+ };
48
+ var formatDateToCartItemOrigin = (params) => {
49
+ const { cartItem, date } = params;
50
+ const origin = cartItem._origin;
51
+ origin.select_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
52
+ origin.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
53
+ origin.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
54
+ origin.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
55
+ origin.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
56
+ return origin;
57
+ };
58
+ var deleteTimeFromCartItem = (cartItem) => {
59
+ cartItem.start_date = void 0;
60
+ cartItem.start_time = void 0;
61
+ cartItem.end_date = void 0;
62
+ cartItem.end_time = void 0;
63
+ cartItem._origin.select_date = null;
64
+ cartItem._origin.start_date = null;
65
+ cartItem._origin.start_time = null;
66
+ cartItem._origin.end_date = null;
67
+ cartItem._origin.end_time = null;
68
+ return cartItem;
69
+ };
70
+ // Annotate the CommonJS export names for ESM import in node:
71
+ 0 && (module.exports = {
72
+ deleteTimeFromCartItem,
73
+ formatDateToCartItem,
74
+ formatDateToCartItemOrigin
75
+ });
@@ -0,0 +1,19 @@
1
+ import { CartItem, IDiscount } from '../types';
2
+ /**
3
+ * 格式化折扣到购物车
4
+ * @param params 参数
5
+ * @returns 格式化后的购物车
6
+ */
7
+ export declare const formatDiscountToCartItem: (params: {
8
+ cartItem: CartItem;
9
+ discounts: IDiscount[];
10
+ }) => CartItem;
11
+ /**
12
+ * 格式化折扣到购物车原始数据
13
+ * @param params 参数
14
+ * @returns 格式化后的购物车原始数据
15
+ */
16
+ export declare const formatDiscountToCartItemOrigin: (params: {
17
+ cartItem: CartItem;
18
+ discounts: IDiscount[];
19
+ }) => any;
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/Cart/utils/cartDiscount.ts
20
+ var cartDiscount_exports = {};
21
+ __export(cartDiscount_exports, {
22
+ formatDiscountToCartItem: () => formatDiscountToCartItem,
23
+ formatDiscountToCartItemOrigin: () => formatDiscountToCartItemOrigin
24
+ });
25
+ module.exports = __toCommonJS(cartDiscount_exports);
26
+ var formatDiscountToCartItem = (params) => {
27
+ const { cartItem } = params;
28
+ const oringin = formatDiscountToCartItemOrigin(params);
29
+ cartItem._origin = oringin;
30
+ return cartItem;
31
+ };
32
+ var formatDiscountToCartItemOrigin = (params) => {
33
+ const { cartItem, discounts } = params;
34
+ const origin = cartItem._origin;
35
+ if (discounts && (discounts == null ? void 0 : discounts.length)) {
36
+ if (!origin.product) {
37
+ origin.product = {};
38
+ }
39
+ origin.product.discount_list = discounts;
40
+ } else {
41
+ if (!origin.product) {
42
+ origin.product = {};
43
+ }
44
+ origin.product.discount_list = [];
45
+ }
46
+ return origin;
47
+ };
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ formatDiscountToCartItem,
51
+ formatDiscountToCartItemOrigin
52
+ });
@@ -0,0 +1,19 @@
1
+ import { CartItem } from '../types';
2
+ /**
3
+ * 格式化备注到购物车
4
+ * @param params 参数
5
+ * @returns 格式化后的购物车
6
+ */
7
+ export declare const formatNoteToCartItem: (params: {
8
+ cartItem: CartItem;
9
+ note: string;
10
+ }) => CartItem;
11
+ /**
12
+ * 格式化备注到购物车原始数据
13
+ * @param params 参数
14
+ * @returns 格式化后的购物车原始数据
15
+ */
16
+ export declare const formatNoteToCartItemOrigin: (params: {
17
+ cartItem: CartItem;
18
+ note: string;
19
+ }) => any;
@@ -0,0 +1,46 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/modules/Cart/utils/cartNote.ts
20
+ var cartNote_exports = {};
21
+ __export(cartNote_exports, {
22
+ formatNoteToCartItem: () => formatNoteToCartItem,
23
+ formatNoteToCartItemOrigin: () => formatNoteToCartItemOrigin
24
+ });
25
+ module.exports = __toCommonJS(cartNote_exports);
26
+ var formatNoteToCartItem = (params) => {
27
+ const { cartItem, note } = params;
28
+ cartItem.note = note;
29
+ const oringin = formatNoteToCartItemOrigin(params);
30
+ cartItem._origin = oringin;
31
+ return cartItem;
32
+ };
33
+ var formatNoteToCartItemOrigin = (params) => {
34
+ const { cartItem, note } = params;
35
+ const origin = cartItem._origin;
36
+ if (!origin.product) {
37
+ origin.product = {};
38
+ }
39
+ origin.product.note = note;
40
+ return origin;
41
+ };
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ formatNoteToCartItem,
45
+ formatNoteToCartItemOrigin
46
+ });