@pisell/pisellos 2.2.10 → 2.2.11

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/utils/cartProduct.js +26 -41
  2. package/dist/modules/Customer/index.js +1 -1
  3. package/dist/modules/Discount/index.d.ts +0 -2
  4. package/dist/modules/Discount/index.js +36 -69
  5. package/dist/modules/Discount/types.d.ts +0 -16
  6. package/dist/modules/Order/index.js +1 -4
  7. package/dist/modules/Order/utils.d.ts +0 -1
  8. package/dist/modules/Order/utils.js +0 -9
  9. package/dist/modules/Payment/index.js +2 -2
  10. package/dist/modules/Payment/types.d.ts +0 -1
  11. package/dist/modules/Payment/walletpass.js +1 -3
  12. package/dist/modules/Product/index.d.ts +1 -1
  13. package/dist/modules/ProductList/index.js +9 -8
  14. package/dist/modules/Rules/index.d.ts +0 -7
  15. package/dist/modules/Rules/index.js +196 -1065
  16. package/dist/modules/Rules/types.d.ts +1 -4
  17. package/dist/solution/BookingByStep/index.d.ts +1 -1
  18. package/dist/solution/BookingByStep/index.js +8 -30
  19. package/dist/solution/BookingByStep/utils/products.d.ts +0 -6
  20. package/dist/solution/BookingByStep/utils/products.js +0 -10
  21. package/dist/solution/BookingTicket/index.d.ts +1 -1
  22. package/dist/solution/Checkout/index.js +49 -93
  23. package/dist/solution/ShopDiscount/index.d.ts +0 -2
  24. package/dist/solution/ShopDiscount/index.js +19 -80
  25. package/dist/solution/ShopDiscount/types.d.ts +1 -4
  26. package/dist/solution/ShopDiscount/utils.d.ts +0 -55
  27. package/dist/solution/ShopDiscount/utils.js +3 -432
  28. package/lib/modules/Cart/utils/cartProduct.js +22 -35
  29. package/lib/modules/Customer/index.js +1 -1
  30. package/lib/modules/Discount/index.d.ts +0 -2
  31. package/lib/modules/Discount/index.js +4 -19
  32. package/lib/modules/Discount/types.d.ts +0 -16
  33. package/lib/modules/Order/index.js +0 -2
  34. package/lib/modules/Order/utils.d.ts +0 -1
  35. package/lib/modules/Order/utils.js +0 -11
  36. package/lib/modules/Payment/index.js +1 -1
  37. package/lib/modules/Payment/types.d.ts +0 -1
  38. package/lib/modules/Payment/walletpass.js +1 -10
  39. package/lib/modules/Product/index.d.ts +1 -1
  40. package/lib/modules/ProductList/index.js +7 -0
  41. package/lib/modules/Rules/index.d.ts +0 -7
  42. package/lib/modules/Rules/index.js +182 -824
  43. package/lib/modules/Rules/types.d.ts +1 -4
  44. package/lib/solution/BookingByStep/index.d.ts +1 -1
  45. package/lib/solution/BookingByStep/index.js +2 -19
  46. package/lib/solution/BookingByStep/utils/products.d.ts +0 -6
  47. package/lib/solution/BookingByStep/utils/products.js +2 -8
  48. package/lib/solution/BookingTicket/index.d.ts +1 -1
  49. package/lib/solution/Checkout/index.js +19 -68
  50. package/lib/solution/ShopDiscount/index.d.ts +0 -2
  51. package/lib/solution/ShopDiscount/index.js +9 -55
  52. package/lib/solution/ShopDiscount/types.d.ts +1 -4
  53. package/lib/solution/ShopDiscount/utils.d.ts +0 -55
  54. package/lib/solution/ShopDiscount/utils.js +3 -266
  55. package/package.json +2 -2
@@ -1,8 +1,4 @@
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
1
  import Decimal from "decimal.js";
5
- import dayjs from "dayjs";
6
2
  export var uniqueById = function uniqueById(arr) {
7
3
  var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
8
4
  var seen = new Set();
@@ -11,19 +7,6 @@ export var uniqueById = function uniqueById(arr) {
11
7
  });
12
8
  };
13
9
 
14
- // 非预约商品 通过时长和日程判断是否是普通商品
15
- export var isNormalProductByDurationSchedule = function isNormalProductByDurationSchedule(item) {
16
- var _item$schedules, _item$scheduleIds;
17
- return !(item !== null && item !== void 0 && item.duration) && !(item !== null && item !== void 0 && (_item$schedules = item.schedules) !== null && _item$schedules !== void 0 && _item$schedules.length) && !(item !== null && item !== void 0 && (_item$scheduleIds = item['schedule.ids']) !== null && _item$scheduleIds !== void 0 && _item$scheduleIds.length);
18
- };
19
-
20
- // 是否全部是普通商品
21
- export var isAllNormalProduct = function isAllNormalProduct(items) {
22
- return items.every(function (item) {
23
- return isNormalProductByDurationSchedule(item);
24
- });
25
- };
26
-
27
10
  /**
28
11
  * 获取折扣金额 基于折扣卡类型计算
29
12
  * 商品券:直接返回商品价格
@@ -37,7 +20,7 @@ export var getDiscountAmount = function getDiscountAmount(discount, total, price
37
20
  var _discount$metadata;
38
21
  // 商品券
39
22
  if (discount.tag === 'good_pass') {
40
- return new Decimal(price).minus(new Decimal(price || 0)).toNumber();
23
+ return new Decimal(total).minus(new Decimal(price || 0)).toNumber();
41
24
  }
42
25
 
43
26
  // 判断是否是固定金额
@@ -45,421 +28,9 @@ export var getDiscountAmount = function getDiscountAmount(discount, total, price
45
28
 
46
29
  // 固定金额 小于0时返回0
47
30
  if (isFixedAmount) {
48
- return Math.max(new Decimal(price).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
31
+ return Math.max(new Decimal(total).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
49
32
  }
50
33
 
51
34
  // 百分比:根据折扣卡金额计算
52
- return new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(price)).toNumber();
53
- };
54
- export var getDiscountListAmountTotal = function getDiscountListAmountTotal(discount) {
55
- return discount.reduce(function (acc, cur) {
56
- return new Decimal(acc).plus(new Decimal(cur.num || 1).mul(new Decimal(cur.amount || 0))).toNumber();
57
- }, new Decimal(0));
58
- };
59
-
60
- /**
61
- * 获取折扣金额 计算每个折扣的金额
62
- * @param discount
63
- * @returns
64
- */
65
- export var getDiscountListAmount = function getDiscountListAmount(discount) {
66
- return discount.reduce(function (acc, cur) {
67
- return new Decimal(acc).plus(new Decimal(cur.amount || 0)).toNumber();
68
- }, new Decimal(0));
69
- };
70
-
71
- // 日程项接口定义
72
-
73
- // 获取时间是否在日程范围内
74
- export var getDateIsInSchedule = function getDateIsInSchedule(dateTime, scheduleList) {
75
- if (!dateTime || !scheduleList || scheduleList.length === 0) {
76
- return false;
77
- }
78
- var targetDate = dayjs(dateTime);
79
- if (!targetDate.isValid()) {
80
- return false;
81
- }
82
-
83
- // 遍历所有日程项
84
- var _iterator = _createForOfIteratorHelper(scheduleList),
85
- _step;
86
- try {
87
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
88
- var schedule = _step.value;
89
- if (isTimeInScheduleItem(dateTime, schedule)) {
90
- return true;
91
- }
92
- }
93
- } catch (err) {
94
- _iterator.e(err);
95
- } finally {
96
- _iterator.f();
97
- }
98
- return false;
99
- };
100
-
101
- // 判断时间是否在单个日程项范围内
102
- var isTimeInScheduleItem = function isTimeInScheduleItem(dateTime, schedule) {
103
- var targetDate = dayjs(dateTime);
104
- var targetDateString = dateTime.split(' ')[0]; // YYYY-MM-DD
105
- var targetTimeString = dateTime.split(' ')[1] || '00:00:00'; // HH:mm:ss
106
-
107
- switch (schedule.type) {
108
- case 'standard':
109
- return isInStandardSchedule(targetDate, targetDateString, targetTimeString, schedule);
110
- case 'time-slots':
111
- return isInTimeSlotsSchedule(targetDate, targetDateString, targetTimeString, schedule);
112
- case 'designation':
113
- return isInDesignationSchedule(targetDate, targetDateString, targetTimeString, schedule);
114
- default:
115
- return false;
116
- }
117
- };
118
-
119
- // 处理标准类型日程
120
- var isInStandardSchedule = function isInStandardSchedule(targetDate, targetDateString, targetTimeString, schedule) {
121
- if (!schedule.start_time || !schedule.end_time) {
122
- return false;
123
- }
124
- var startDate = dayjs(schedule.start_time);
125
- var endDate = dayjs(schedule.end_time);
126
-
127
- // 先检查是否在基础时间范围内(不考虑重复)
128
- var isInBasicRange = targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate);
129
- if (schedule.repeat_type === 'none') {
130
- return isInBasicRange;
131
- }
132
-
133
- // 处理重复日程
134
- return isInRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule, startDate, endDate);
135
- };
136
-
137
- // 处理时间段类型日程
138
- var isInTimeSlotsSchedule = function isInTimeSlotsSchedule(targetDate, targetDateString, targetTimeString, schedule) {
139
- if (!schedule.start_time) {
140
- return false;
141
- }
142
-
143
- // 如果不重复,使用原有逻辑
144
- if (schedule.repeat_type === 'none') {
145
- var scheduleDate = schedule.start_time.split(' ')[0];
146
-
147
- // 检查日期是否匹配
148
- if (targetDateString !== scheduleDate) {
149
- return false;
150
- }
151
-
152
- // 检查是否在任一时间段内
153
- return checkTimeSlotsForDate(targetDate, targetDateString, schedule.time_slot);
154
- }
155
-
156
- // 处理重复日程
157
- return isInTimeSlotsRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule);
158
- };
159
-
160
- // 处理指定类型日程
161
- var isInDesignationSchedule = function isInDesignationSchedule(targetDate, targetDateString, targetTimeString, schedule) {
162
- if (!schedule.designation) {
163
- return false;
164
- }
165
- var _iterator2 = _createForOfIteratorHelper(schedule.designation),
166
- _step2;
167
- try {
168
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
169
- var designation = _step2.value;
170
- var startDateTime = "".concat(designation.start_date, " ").concat(designation.start_time, ":00");
171
- var endDateTime = "".concat(designation.end_date, " ").concat(designation.end_time, ":00");
172
- var startDate = dayjs(startDateTime);
173
- var endDate = dayjs(endDateTime);
174
- if (targetDate.isSameOrAfter(startDate) && targetDate.isSameOrBefore(endDate)) {
175
- return true;
176
- }
177
- }
178
- } catch (err) {
179
- _iterator2.e(err);
180
- } finally {
181
- _iterator2.f();
182
- }
183
- return false;
184
- };
185
-
186
- // 处理重复日程逻辑
187
- var isInRepeatingSchedule = function isInRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule, startDate, endDate) {
188
- if (!schedule.repeat_rule) {
189
- return false;
190
- }
191
- var repeat_rule = schedule.repeat_rule,
192
- repeat_type = schedule.repeat_type;
193
- var targetDateOnly = dayjs(targetDateString); // 只取日期部分
194
-
195
- // 首先检查是否在包含日期中(包含日期是额外增加的有效日期)
196
- if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
197
- var _iterator3 = _createForOfIteratorHelper(repeat_rule.included_date),
198
- _step3;
199
- try {
200
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
201
- var includedDate = _step3.value;
202
- var includeStartDate = dayjs(includedDate.start);
203
- var includeEndDate = dayjs(includedDate.end);
204
- if (targetDateOnly.isSameOrAfter(includeStartDate, 'day') && targetDateOnly.isSameOrBefore(includeEndDate, 'day')) {
205
- // 在包含日期中,直接返回true,无需检查其他条件
206
- return true;
207
- }
208
- }
209
- } catch (err) {
210
- _iterator3.e(err);
211
- } finally {
212
- _iterator3.f();
213
- }
214
- }
215
-
216
- // 检查是否在排除日期中
217
- var _iterator4 = _createForOfIteratorHelper(repeat_rule.excluded_date),
218
- _step4;
219
- try {
220
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
221
- var excludedDate = _step4.value;
222
- var excludeStartDate = dayjs(excludedDate.start);
223
- var excludeEndDate = dayjs(excludedDate.end);
224
- // 检查目标日期是否在排除范围内(包含边界)
225
- if (targetDateOnly.isSameOrAfter(excludeStartDate, 'day') && targetDateOnly.isSameOrBefore(excludeEndDate, 'day')) {
226
- return false;
227
- }
228
- }
229
-
230
- // 检查重复规则的结束条件
231
- } catch (err) {
232
- _iterator4.e(err);
233
- } finally {
234
- _iterator4.f();
235
- }
236
- if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
237
- var ruleEndDate = dayjs(repeat_rule.end.end_date);
238
- if (targetDate.isAfter(ruleEndDate)) {
239
- return false;
240
- }
241
- }
242
-
243
- // 根据重复类型检查
244
- switch (repeat_type) {
245
- case 'daily':
246
- return isInDailyRepeat(targetDate, startDate, endDate, repeat_rule);
247
- case 'weekly':
248
- return isInWeeklyRepeat(targetDate, startDate, endDate, repeat_rule);
249
- default:
250
- return false;
251
- // 不支持月和年重复
252
- }
253
- };
254
-
255
- // 每日重复逻辑
256
- var isInDailyRepeat = function isInDailyRepeat(targetDate, startDate, endDate, repeatRule) {
257
- var daysDiff = targetDate.diff(startDate, 'day');
258
- if (daysDiff < 0) {
259
- return false;
260
- }
261
-
262
- // 检查频率
263
- if (daysDiff % repeatRule.frequency !== 0) {
264
- return false;
265
- }
266
-
267
- // 检查时间是否在日程的时间范围内
268
- var targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
269
- var startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
270
- var endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
271
-
272
- // 每日重复:每天都在相同的时间段内有效
273
- // 例如:01:00:00 - 16:00:00,每天都是这个时间段
274
- return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
275
- };
276
-
277
- // 每周重复逻辑
278
- var isInWeeklyRepeat = function isInWeeklyRepeat(targetDate, startDate, endDate, repeatRule) {
279
- var targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
280
-
281
- // 检查是否在指定的星期几内
282
- if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
283
- return false;
284
- }
285
-
286
- // 计算周差
287
- var weeksDiff = targetDate.diff(startDate, 'week');
288
- if (weeksDiff < 0) {
289
- return false;
290
- }
291
-
292
- // 检查频率
293
- if (weeksDiff % repeatRule.frequency !== 0) {
294
- return false;
295
- }
296
-
297
- // 检查时间是否在日程的时间范围内
298
- var targetTimeOfDay = targetDate.hour() * 3600 + targetDate.minute() * 60 + targetDate.second();
299
- var startTimeOfDay = startDate.hour() * 3600 + startDate.minute() * 60 + startDate.second();
300
- var endTimeOfDay = endDate.hour() * 3600 + endDate.minute() * 60 + endDate.second();
301
- return targetTimeOfDay >= startTimeOfDay && targetTimeOfDay <= endTimeOfDay;
302
- };
303
-
304
- // 处理 time-slots 类型的重复日程
305
- var isInTimeSlotsRepeatingSchedule = function isInTimeSlotsRepeatingSchedule(targetDate, targetDateString, targetTimeString, schedule) {
306
- if (!schedule.repeat_rule || !schedule.start_time) {
307
- return false;
308
- }
309
- var repeat_rule = schedule.repeat_rule,
310
- repeat_type = schedule.repeat_type;
311
- var startDate = dayjs(schedule.start_time);
312
- var targetDateOnly = dayjs(targetDateString);
313
-
314
- // 检查包含日期
315
- if (repeat_rule.included_date && repeat_rule.included_date.length > 0) {
316
- var _iterator5 = _createForOfIteratorHelper(repeat_rule.included_date),
317
- _step5;
318
- try {
319
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
320
- var includedDate = _step5.value;
321
- var includeStartDate = dayjs(includedDate.start);
322
- var includeEndDate = dayjs(includedDate.end);
323
- if (targetDateOnly.isSameOrAfter(includeStartDate, 'day') && targetDateOnly.isSameOrBefore(includeEndDate, 'day')) {
324
- // 在包含日期中,检查时间段
325
- return checkTimeSlotsForDate(targetDate, targetDateString, schedule.time_slot);
326
- }
327
- }
328
- } catch (err) {
329
- _iterator5.e(err);
330
- } finally {
331
- _iterator5.f();
332
- }
333
- }
334
-
335
- // 检查排除日期
336
- var _iterator6 = _createForOfIteratorHelper(repeat_rule.excluded_date),
337
- _step6;
338
- try {
339
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
340
- var excludedDate = _step6.value;
341
- var excludeStartDate = dayjs(excludedDate.start);
342
- var excludeEndDate = dayjs(excludedDate.end);
343
- if (targetDateOnly.isSameOrAfter(excludeStartDate, 'day') && targetDateOnly.isSameOrBefore(excludeEndDate, 'day')) {
344
- return false;
345
- }
346
- }
347
-
348
- // 检查重复规则的结束条件
349
- } catch (err) {
350
- _iterator6.e(err);
351
- } finally {
352
- _iterator6.f();
353
- }
354
- if (repeat_rule.end.type === 'date' && repeat_rule.end.end_date) {
355
- var ruleEndDate = dayjs(repeat_rule.end.end_date);
356
- if (targetDateOnly.isAfter(ruleEndDate, 'day')) {
357
- return false;
358
- }
359
- }
360
-
361
- // 检查目标日期是否在重复规则范围内
362
- var isDateValid = false;
363
- switch (repeat_type) {
364
- case 'daily':
365
- isDateValid = isInDailyRepeatForDate(targetDateOnly, startDate, repeat_rule);
366
- break;
367
- case 'weekly':
368
- isDateValid = isInWeeklyRepeatForDate(targetDateOnly, startDate, repeat_rule);
369
- break;
370
- default:
371
- return false;
372
- }
373
-
374
- // 如果日期有效,检查时间段
375
- if (isDateValid) {
376
- return checkTimeSlotsForDate(targetDate, targetDateString, schedule.time_slot);
377
- }
378
- return false;
379
- };
380
-
381
- // 检查目标时间是否在某个时间段内(使用目标日期 + time_slot 时间)
382
- var checkTimeSlotsForDate = function checkTimeSlotsForDate(targetDate, targetDateString, timeSlots) {
383
- var _iterator7 = _createForOfIteratorHelper(timeSlots),
384
- _step7;
385
- try {
386
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
387
- var timeSlot = _step7.value;
388
- var slotStart = "".concat(targetDateString, " ").concat(timeSlot.start_time, ":00");
389
- var slotEnd = "".concat(targetDateString, " ").concat(timeSlot.end_time, ":00");
390
- var slotStartDate = dayjs(slotStart);
391
- var slotEndDate = dayjs(slotEnd);
392
- if (targetDate.isSameOrAfter(slotStartDate) && targetDate.isSameOrBefore(slotEndDate)) {
393
- return true;
394
- }
395
- }
396
- } catch (err) {
397
- _iterator7.e(err);
398
- } finally {
399
- _iterator7.f();
400
- }
401
- return false;
402
- };
403
-
404
- // 检查日期是否满足每日重复规则(只检查日期,不检查时间)
405
- var isInDailyRepeatForDate = function isInDailyRepeatForDate(targetDate, startDate, repeatRule) {
406
- var daysDiff = targetDate.diff(startDate, 'day');
407
- if (daysDiff < 0) {
408
- return false;
409
- }
410
-
411
- // 检查频率
412
- return daysDiff % repeatRule.frequency === 0;
413
- };
414
-
415
- // 检查日期是否满足每周重复规则(只检查日期,不检查时间)
416
- var isInWeeklyRepeatForDate = function isInWeeklyRepeatForDate(targetDate, startDate, repeatRule) {
417
- var targetDayOfWeek = targetDate.day(); // 0=周日, 1=周一, ..., 6=周六
418
-
419
- // 检查是否在指定的星期几内
420
- if (!repeatRule.frequency_date.includes(targetDayOfWeek)) {
421
- return false;
422
- }
423
-
424
- // 计算周差
425
- var weeksDiff = targetDate.diff(startDate, 'week');
426
- if (weeksDiff < 0) {
427
- return false;
428
- }
429
-
430
- // 检查频率
431
- return weeksDiff % repeatRule.frequency === 0;
432
- };
433
-
434
- /**
435
- * 根据预约时间过滤优惠券列表
436
- * @param discountList 优惠券列表
437
- * @param bookingTime 预约时间 (格式: YYYY-MM-DD HH:mm:ss)
438
- * @returns 过滤后的优惠券列表
439
- */
440
- export var filterDiscountListByBookingTime = function filterDiscountListByBookingTime(discountList, bookingTime) {
441
- if (!bookingTime) {
442
- return discountList;
443
- }
444
- return discountList.filter(function (discount) {
445
- var _discount$metadata2;
446
- if ((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.validity_type) === "custom_schedule_validity") {
447
- var _discount$custom_sche;
448
- return getDateIsInSchedule(bookingTime, ((_discount$custom_sche = discount.custom_schedule_snapshot) === null || _discount$custom_sche === void 0 ? void 0 : _discount$custom_sche.data) || []);
449
- }
450
- try {
451
- var isHasStart = !!discount.start_date && !!discount.start_time;
452
- var startDate = dayjs("".concat(discount.start_date, " ").concat(discount.start_time));
453
- var bookingTimeDayjs = dayjs(bookingTime);
454
-
455
- // 判断预约时间是否在开始时间之后
456
- var isAfterStart = isHasStart ? bookingTimeDayjs.isSameOrAfter(startDate) : true;
457
-
458
- // 判断预约时间是否在过期时间之前(expire_time 为空时为长期有效)
459
- var isBeforeExpire = discount.expire_time ? bookingTimeDayjs.isSameOrBefore(dayjs(discount.expire_time)) : true;
460
- return isAfterStart && isBeforeExpire;
461
- } catch (error) {
462
- return true;
463
- }
464
- });
35
+ return new Decimal(100).minus(discount.par_value || 0).div(100).mul(new Decimal(total)).toNumber();
465
36
  };
@@ -172,18 +172,6 @@ var formatProductToCartItemOrigin = (params) => {
172
172
  var getProductTotalPrice = (params) => {
173
173
  const { product, bundle, options, discounts } = params;
174
174
  let price = Number(product.price);
175
- if (discounts == null ? void 0 : discounts.length) {
176
- discounts.forEach((currentValue) => {
177
- var _a;
178
- price = (0, import_utils2.getDiscountAmount)({
179
- tag: currentValue.type,
180
- par_value: currentValue.discount.percent,
181
- metadata: {
182
- discount_card_type: (_a = currentValue == null ? void 0 : currentValue.discount) == null ? void 0 : _a.discount_card_type
183
- }
184
- }, price, price);
185
- });
186
- }
187
175
  if (bundle == null ? void 0 : bundle.length) {
188
176
  price = bundle.reduce((accumulator, currentValue) => {
189
177
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
@@ -194,7 +182,21 @@ var getProductTotalPrice = (params) => {
194
182
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
195
183
  }, price);
196
184
  }
197
- return Math.max(0, price);
185
+ if (discounts == null ? void 0 : discounts.length) {
186
+ discounts.forEach((currentValue) => {
187
+ var _a;
188
+ if (currentValue.type !== "good_pass") {
189
+ price = (0, import_utils2.getDiscountAmount)({
190
+ tag: currentValue.type,
191
+ par_value: currentValue.discount.percent,
192
+ metadata: {
193
+ discount_card_type: (_a = currentValue == null ? void 0 : currentValue.discount) == null ? void 0 : _a.discount_card_type
194
+ }
195
+ }, price, price);
196
+ }
197
+ });
198
+ }
199
+ return price;
198
200
  };
199
201
  var getProductOriginTotalPrice = (params) => {
200
202
  const { product, bundle, options, discounts } = params;
@@ -252,15 +254,9 @@ var formatBundle = (bundle) => {
252
254
  price: item == null ? void 0 : item.price,
253
255
  total: item == null ? void 0 : item.price,
254
256
  price_type: item == null ? void 0 : item.price_type,
255
- original_price: item == null ? void 0 : item.original_price,
256
- original_total: item == null ? void 0 : item.original_total,
257
- price_type_ext: item == null ? void 0 : item.price_type_ext,
258
257
  bundle_sum_price: item == null ? void 0 : item.bundle_sum_price,
259
258
  bundle_sum_type: item == null ? void 0 : item.bundle_sum_type,
260
- options: formatOptions(item == null ? void 0 : item.option),
261
- _bundle_product_id: item._bundle_product_id,
262
- discount_list: item.discount_list,
263
- originBundleItem: item.originBundleItem || item
259
+ options: formatOptions(item == null ? void 0 : item.option)
264
260
  };
265
261
  });
266
262
  };
@@ -268,24 +264,15 @@ var formatBundleToOrigin = (bundle) => {
268
264
  if (!(bundle == null ? void 0 : bundle.length))
269
265
  return [];
270
266
  return bundle.map((d) => {
271
- const getBundleValueByKey = (key) => {
272
- var _a;
273
- return (d == null ? void 0 : d[key]) || ((_a = d == null ? void 0 : d.originBundleItem) == null ? void 0 : _a[key]);
274
- };
275
267
  return {
276
- bundle_group_id: getBundleValueByKey("group_id"),
268
+ bundle_group_id: d.group_id,
277
269
  bundle_id: d.id,
278
- bundle_product_id: getBundleValueByKey("_bundle_product_id") || getBundleValueByKey("product_id"),
279
- bundle_variant_id: getBundleValueByKey("bundle_variant_id"),
270
+ bundle_product_id: (d == null ? void 0 : d._bundle_product_id) || (d == null ? void 0 : d.product_id),
271
+ bundle_variant_id: d.bundle_variant_id,
280
272
  num: d.num,
281
- extension_id: getBundleValueByKey("extension_id"),
282
- extension_type: getBundleValueByKey("extension_type"),
283
- option: formatOptionsToOrigin(getBundleValueByKey("option")),
284
- discount_list: d.discount_list,
285
- "bundle_selling_price": d == null ? void 0 : d.price,
286
- metadata: {
287
- custom_product_bundle_map_id: d._id
288
- }
273
+ extension_id: d.extension_id,
274
+ extension_type: d.extension_type,
275
+ option: formatOptionsToOrigin(d.option)
289
276
  };
290
277
  });
291
278
  };
@@ -102,7 +102,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
102
102
  skip,
103
103
  num,
104
104
  sort_by: import_constants.SORT_BY,
105
- with: ["latestWalletDetail.wallet", "contactsInfo"],
105
+ with: ["latestWalletDetail.wallet"],
106
106
  search_wallet_flag: 1,
107
107
  search_wallet_pass_flag: 1,
108
108
  ...search && { search },
@@ -14,8 +14,6 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
14
14
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
15
15
  setDiscountList(discountList: Discount[]): Promise<void>;
16
16
  getDiscountList(): Discount[];
17
- setOriginalDiscountList(originalDiscountList: Discount[]): Promise<void>;
18
- getOriginalDiscountList(): Discount[];
19
17
  loadPrepareConfig(params: {
20
18
  action?: 'create';
21
19
  with_good_pass: 0 | 1;
@@ -44,7 +44,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
44
44
  this.openCache = false;
45
45
  }
46
46
  async initialize(core, options) {
47
- var _a, _b, _c, _d;
47
+ var _a, _b, _c;
48
48
  this.core = core;
49
49
  this.store = options == null ? void 0 : options.store;
50
50
  if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.discountList)) {
@@ -52,16 +52,11 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
52
52
  } else {
53
53
  this.store.discountList = [];
54
54
  }
55
- if (Array.isArray((_b = options == null ? void 0 : options.initialState) == null ? void 0 : _b.originalDiscountList)) {
56
- this.store.originalDiscountList = options == null ? void 0 : options.initialState.originalDiscountList;
57
- } else {
58
- this.store.originalDiscountList = [];
59
- }
60
- if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.cacheId) {
55
+ if ((_b = options == null ? void 0 : options.otherParams) == null ? void 0 : _b.cacheId) {
61
56
  this.openCache = options.otherParams.openCache;
62
57
  this.cacheId = options.otherParams.cacheId;
63
58
  }
64
- if ((_d = options == null ? void 0 : options.otherParams) == null ? void 0 : _d.fatherModule) {
59
+ if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.fatherModule) {
65
60
  this.fatherModule = options.otherParams.fatherModule;
66
61
  }
67
62
  this.request = core.getPlugin("request");
@@ -83,14 +78,6 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
83
78
  getDiscountList() {
84
79
  return this.store.discountList;
85
80
  }
86
- // 设置原始优惠券列表
87
- async setOriginalDiscountList(originalDiscountList) {
88
- this.store.originalDiscountList = originalDiscountList;
89
- }
90
- // 获取原始优惠券列表
91
- getOriginalDiscountList() {
92
- return this.store.originalDiscountList || [];
93
- }
94
81
  async loadPrepareConfig(params) {
95
82
  var _a, _b;
96
83
  const prepareConfig = await this.request.post(
@@ -176,8 +163,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
176
163
  }
177
164
  if (discount.appliedProductDetails) {
178
165
  return discount.appliedProductDetails.reduce((total, product) => {
179
- var _a;
180
- const price = new import_decimal.default(((_a = product == null ? void 0 : product.discount) == null ? void 0 : _a.fixed_amount) || 0).mul((product == null ? void 0 : product._num) || 1);
166
+ const price = new import_decimal.default((product == null ? void 0 : product.amount) || 0).mul((product == null ? void 0 : product.num) || 1);
181
167
  return new import_decimal.default(total).plus(price).toNumber();
182
168
  }, 0);
183
169
  }
@@ -190,7 +176,6 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
190
176
  }
191
177
  async clear() {
192
178
  this.store.discountList = [];
193
- this.store.originalDiscountList = [];
194
179
  console.log("[Discount] clear");
195
180
  }
196
181
  storeChange() {
@@ -15,16 +15,11 @@ interface Formattitle {
15
15
  'zh-CN'?: any;
16
16
  'zh-HK'?: any;
17
17
  }
18
- interface PackageSubItemUsageRules {
19
- type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
20
- rules: ("original_price" | "markup_price")[];
21
- }
22
18
  interface Limitedrelationproductdata {
23
19
  id: number;
24
20
  type: 'product_all' | 'products' | 'product_collection';
25
21
  product_ids: number[];
26
22
  product_collection_id: number[];
27
- package_sub_item_usage_rules?: PackageSubItemUsageRules;
28
23
  }
29
24
  interface ApplicableProductDetails {
30
25
  amount: string;
@@ -34,14 +29,12 @@ interface ApplicableProductDetails {
34
29
  original_amount: string;
35
30
  num: number;
36
31
  discount?: {
37
- fixed_amount?: number;
38
32
  product_id?: number;
39
33
  original_amount?: string;
40
34
  percent?: string;
41
35
  resource_id?: number;
42
36
  title?: string;
43
37
  };
44
- _num: number;
45
38
  }
46
39
  interface UsageCreditsValue {
47
40
  total_credits: number;
@@ -79,8 +72,6 @@ export interface Discount {
79
72
  format_title: Formattitle;
80
73
  metadata?: {
81
74
  discount_card_type?: 'fixed_amount' | 'percent';
82
- custom_product_bundle_map_id?: string;
83
- validity_type?: "custom_schedule_validity" | "fixed_validity";
84
75
  };
85
76
  product: Product;
86
77
  type: "product" | 'good_pass';
@@ -107,16 +98,9 @@ export interface Discount {
107
98
  week_order_behavior_count?: number;
108
99
  month_order_behavior_count?: number;
109
100
  customer_order_behavior_count?: number;
110
- custom_schedule_snapshot?: {
111
- data: any[];
112
- };
113
- num?: number;
114
- start_date?: string;
115
- start_time?: string;
116
101
  }
117
102
  export interface DiscountState {
118
103
  discountList: Discount[];
119
- originalDiscountList?: Discount[];
120
104
  }
121
105
  export interface DiscountModuleAPI {
122
106
  setDiscountList: (discountList: Discount[]) => Promise<void>;