@pisell/pisellos 3.0.73 → 3.0.74

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.
@@ -21,6 +21,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
21
21
  with_good_pass: 0 | 1;
22
22
  with_discount_card: 0 | 1;
23
23
  customer_id: number;
24
+ with_wallet_pass_holder: 0 | 1;
24
25
  }): Promise<Discount[]>;
25
26
  batchSearch(code: string, customerId?: number): Promise<Discount[]>;
26
27
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
@@ -188,7 +188,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
188
188
  tags: ['good_pass', 'product_discount_card'],
189
189
  available: 1,
190
190
  relation_product: 1,
191
- with: ['extensionData'],
191
+ with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
192
192
  order_behavior_count: 1,
193
193
  order_behavior_count_customer_id: customerId || 1
194
194
  });
@@ -11,18 +11,27 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
11
11
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
12
12
  setRulesList(rulesList: Rules[]): Promise<void>;
13
13
  getRulesList(): Rules[];
14
- isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, }: {
14
+ private checkHolderMatch;
15
+ isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
15
16
  oldDiscountList: Discount[];
16
17
  newDiscountList: Discount[];
17
18
  productList: any[];
19
+ holders: {
20
+ form_record_id: number;
21
+ }[];
22
+ isFormSubject: boolean;
18
23
  }): {
19
24
  isAvailable: boolean;
20
25
  discountList: Discount[];
21
26
  productList: any[];
22
27
  };
23
- calcDiscount({ discountList, productList, }: {
28
+ calcDiscount({ discountList, productList, holders, isFormSubject, }: {
24
29
  discountList: Discount[];
25
30
  productList: any[];
31
+ holders: {
32
+ form_record_id: number;
33
+ }[];
34
+ isFormSubject: boolean;
26
35
  }, options?: {
27
36
  isSelected?: boolean;
28
37
  discountId?: number;
@@ -91,6 +91,24 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
91
91
  return this.store.rulesList;
92
92
  }
93
93
 
94
+ // 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
95
+ }, {
96
+ key: "checkHolderMatch",
97
+ value: function checkHolderMatch(discount, product, holders) {
98
+ var _discount$holder;
99
+ // 非表单类型 holder 视为匹配
100
+ if (((_discount$holder = discount.holder) === null || _discount$holder === void 0 ? void 0 : _discount$holder.holder_type) !== 'form') return true;
101
+ // 主预约holder, 目前(20251124)默认只考虑单个holder的情况
102
+ var orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : undefined;
103
+ var productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
104
+ // 商品不需要选holder,则不对比holder,直接返回true,
105
+ if (!product.isNeedHolder) return true;
106
+ // 商品需要holder,但父预约及商品都无holder,返回false
107
+ if (!orderHolderId && !productHolderId) return false;
108
+ // 最终直接匹配 holder 是否相同
109
+ return (productHolderId || orderHolderId) === discount.holder.holder_id;
110
+ }
111
+
94
112
  // 判断discountList 是否可以对当前productList生效
95
113
  }, {
96
114
  key: "isDiscountListAvailable",
@@ -98,7 +116,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
98
116
  var _this2 = this;
99
117
  var oldDiscountList = _ref.oldDiscountList,
100
118
  newDiscountList = _ref.newDiscountList,
101
- productList = _ref.productList;
119
+ productList = _ref.productList,
120
+ holders = _ref.holders,
121
+ isFormSubject = _ref.isFormSubject;
102
122
  // 首先检查是否有新的优惠券可应用
103
123
  if (!newDiscountList || newDiscountList.length === 0) {
104
124
  return {
@@ -128,7 +148,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
128
148
  var mergedDiscountList = uniqueById(uniqueById([].concat(_toConsumableArray(filteredOldDiscountList), _toConsumableArray(newDiscountList))), 'product_id');
129
149
  var result = this.calcDiscount({
130
150
  discountList: mergedDiscountList,
131
- productList: _toConsumableArray(productList)
151
+ productList: _toConsumableArray(productList),
152
+ holders: holders,
153
+ isFormSubject: isFormSubject
132
154
  }, {
133
155
  scan: true
134
156
  });
@@ -170,7 +192,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
170
192
  value: function calcDiscount(_ref2, options) {
171
193
  var _this3 = this;
172
194
  var discountList = _ref2.discountList,
173
- productList = _ref2.productList;
195
+ productList = _ref2.productList,
196
+ holders = _ref2.holders,
197
+ isFormSubject = _ref2.isFormSubject;
174
198
  // 识别出来是不是在编辑的界面里又新增了商品
175
199
  // 这种情况下,如果有可用的优惠券,也会自动勾选上
176
200
  var isEditModeAddNewProduct = productList.find(function (n) {
@@ -391,6 +415,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
391
415
  product = flatItem.product;
392
416
  originProduct = flatItem.originProduct;
393
417
  } else {
418
+ var _flatItem$parentProdu;
394
419
  // bundle子商品:构造虚拟商品对象
395
420
  product = {
396
421
  _id: flatItem._id,
@@ -401,17 +426,25 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
401
426
  total: flatItem.total,
402
427
  origin_total: flatItem.origin_total,
403
428
  booking_id: flatItem.booking_id,
404
- discount_list: flatItem.discount_list || []
429
+ discount_list: flatItem.discount_list || [],
430
+ startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
405
431
  };
406
432
  originProduct = flatItem.originProduct;
407
433
  }
408
434
  addModeDiscount.forEach(function (discount) {
409
435
  var _product, _product2, _product3, _product4, _flatItem$bundleItem;
410
436
  var limitedData = discount === null || discount === void 0 ? void 0 : discount.limited_relation_product_data;
437
+
438
+ // 拿到discount配置的holder信息 product信息 product.holder 加在 isLimitedProduct
439
+ var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
440
+ var isHolderMatch = _this3.checkHolderMatch(discount, {
441
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
442
+ holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
443
+ }, holders);
411
444
  var timeLimit = true;
412
445
  timeLimit = !!filterDiscountListByBookingTime([discount], (((_product = product) === null || _product === void 0 ? void 0 : _product.startDate) || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
413
446
  // 是符合折扣的商品
414
- var isLimitedProduct = limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id);
447
+ var isLimitedProduct = (limitedData.type === 'product_all' || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
415
448
 
416
449
  // 编辑的商品 使用了优惠券不可用
417
450
  var isAvailableProduct = flatItem.type === 'main' ? !((_product2 = product) !== null && _product2 !== void 0 && _product2.booking_id && (_product3 = product) !== null && _product3 !== void 0 && (_product3 = _product3.discount_list) !== null && _product3 !== void 0 && _product3.length && (_product4 = product) !== null && _product4 !== void 0 && (_product4 = _product4.discount_list) !== null && _product4 !== void 0 && _product4.every(function (discount) {
@@ -470,7 +503,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
470
503
  product = flatItem.product;
471
504
  originProduct = flatItem.originProduct;
472
505
  } else {
473
- var _flatItem$bundleItem2, _flatItem$bundleItem3, _flatItem$bundleItem4;
506
+ var _flatItem$bundleItem2, _flatItem$bundleItem3, _flatItem$bundleItem4, _flatItem$parentProdu2;
474
507
  // bundle子商品
475
508
  product = {
476
509
  _id: flatItem._id,
@@ -482,7 +515,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
482
515
  original_price: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem2 = flatItem.bundleItem) === null || _flatItem$bundleItem2 === void 0 ? void 0 : _flatItem$bundleItem2.original_price,
483
516
  origin_total: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem3 = flatItem.bundleItem) === null || _flatItem$bundleItem3 === void 0 ? void 0 : _flatItem$bundleItem3.original_price,
484
517
  booking_id: flatItem.booking_id,
485
- discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem4 = flatItem.bundleItem) === null || _flatItem$bundleItem4 === void 0 ? void 0 : _flatItem$bundleItem4.discount_list) || []
518
+ discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem4 = flatItem.bundleItem) === null || _flatItem$bundleItem4 === void 0 ? void 0 : _flatItem$bundleItem4.discount_list) || [],
519
+ startDate: (_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.startDate
486
520
  };
487
521
  originProduct = flatItem.originProduct;
488
522
  }
@@ -506,20 +540,26 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
506
540
  var _product$discount_lis3, _product$discount_lis4;
507
541
  // 如果商品价格为 0,其实不需要使用任何优惠券,直接 return true
508
542
  // 商品券时主商品价格为0不可用
509
- if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.find(function (n) {
510
- var _n$discount;
511
- return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
512
- })) && (discount.tag || discount.type) === 'good_pass') return false;
543
+ if ((Number(product.price) <= 0 || !product.price) && !((_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length) && (discount.tag || discount.type) === 'good_pass') return false;
513
544
 
514
545
  // 折扣卡商品价格为0时不可用
515
546
  if ((Number(product.price) === 0 || !product.price) && !((_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.find(function (n) {
516
- var _n$discount2;
517
- return ((_n$discount2 = n.discount) === null || _n$discount2 === void 0 ? void 0 : _n$discount2.resource_id) === discount.id;
547
+ var _n$discount;
548
+ return ((_n$discount = n.discount) === null || _n$discount === void 0 ? void 0 : _n$discount.resource_id) === discount.id;
518
549
  })) && (discount.tag || discount.type) !== 'good_pass') return false;
519
550
  // 如果优惠券已被使用,则跳过
520
551
  var targetUsedDiscounts = usedDiscounts.get(discount.id);
521
552
  if (targetUsedDiscounts && (discount.tag || discount.type) === 'good_pass') return false;
522
553
  var limitedData = discount.limited_relation_product_data;
554
+
555
+ // 拿到discount配置的holder信息 product信息 product.holder 不可用return false
556
+ var _tempVar = (flatItem === null || flatItem === void 0 ? void 0 : flatItem.type) === 'bundle' ? flatItem === null || flatItem === void 0 ? void 0 : flatItem.parentProduct : flatItem === null || flatItem === void 0 ? void 0 : flatItem.product;
557
+ var isHolderMatch = _this3.checkHolderMatch(discount, {
558
+ isNeedHolder: isFormSubject && !(_tempVar !== null && _tempVar !== void 0 && _tempVar.isNormalProduct),
559
+ holder_id: (_tempVar === null || _tempVar === void 0 ? void 0 : _tempVar.holder_id) || product.holder_id
560
+ }, holders);
561
+ // 如果 holder 不匹配,则不适用
562
+ if (!isHolderMatch) return false;
523
563
  var timeLimit = true;
524
564
  timeLimit = !!filterDiscountListByBookingTime([discount], (product.startDate || dayjs()).format('YYYY-MM-DD HH:mm:ss')).length;
525
565
  if (!timeLimit) {
@@ -588,11 +628,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
588
628
  }
589
629
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
590
630
  if (flatItem.type === 'bundle') {
591
- var _product$discount_lis7, _flatItem$parentProdu;
631
+ var _product$discount_lis7, _flatItem$parentProdu3;
592
632
  if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
593
633
  var _item$discount2;
594
634
  return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
595
- }) || (_flatItem$parentProdu = flatItem.parentProduct) !== null && _flatItem$parentProdu !== void 0 && (_flatItem$parentProdu = _flatItem$parentProdu.discount_list) !== null && _flatItem$parentProdu !== void 0 && _flatItem$parentProdu.some(function (item) {
635
+ }) || (_flatItem$parentProdu3 = flatItem.parentProduct) !== null && _flatItem$parentProdu3 !== void 0 && (_flatItem$parentProdu3 = _flatItem$parentProdu3.discount_list) !== null && _flatItem$parentProdu3 !== void 0 && _flatItem$parentProdu3.some(function (item) {
596
636
  var _item$discount3;
597
637
  return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
598
638
  })) {
@@ -614,14 +654,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
614
654
  }
615
655
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
616
656
  if (flatItem.type === 'bundle') {
617
- var _product$discount_lis9, _flatItem$parentProdu2;
657
+ var _product$discount_lis9, _flatItem$parentProdu4;
618
658
  if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
619
659
  var _options$selectedList2;
620
660
  return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
621
661
  var _item$discount5;
622
662
  return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
623
663
  });
624
- }) || (_flatItem$parentProdu2 = flatItem.parentProduct) !== null && _flatItem$parentProdu2 !== void 0 && (_flatItem$parentProdu2 = _flatItem$parentProdu2.discount_list) !== null && _flatItem$parentProdu2 !== void 0 && _flatItem$parentProdu2.some(function (item) {
664
+ }) || (_flatItem$parentProdu4 = flatItem.parentProduct) !== null && _flatItem$parentProdu4 !== void 0 && (_flatItem$parentProdu4 = _flatItem$parentProdu4.discount_list) !== null && _flatItem$parentProdu4 !== void 0 && _flatItem$parentProdu4.some(function (item) {
625
665
  var _options$selectedList3;
626
666
  return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
627
667
  var _item$discount6;
@@ -854,7 +894,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
854
894
  }));
855
895
  }
856
896
  } else {
857
- var _selectedDiscount3$me, _flatItem$parentProdu3;
897
+ var _selectedDiscount3$me, _flatItem$parentProdu5;
858
898
  // 折扣卡:不拆分数量,直接应用
859
899
  var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
860
900
  usedDiscounts.set(_selectedDiscount3.id, true);
@@ -880,7 +920,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
880
920
  custom_product_bundle_map_id: _uniqueId,
881
921
  num: product.num || 1
882
922
  },
883
- _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.num) || 1)
923
+ _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.num) || 1)
884
924
  };
885
925
 
886
926
  // 记录实际应用的折扣
@@ -22,6 +22,10 @@ export interface RulesModuleAPI {
22
22
  calcDiscount: (params: {
23
23
  discountList: any[];
24
24
  productList: any[];
25
+ holders: {
26
+ form_record_id: number;
27
+ }[];
28
+ isFormSubject: boolean;
25
29
  }) => DiscountResult;
26
30
  }
27
31
  type ProductDetail = {
@@ -39,6 +43,7 @@ type ProductDetail = {
39
43
  original_price?: number | string;
40
44
  num?: number;
41
45
  quantity: number;
46
+ holder_id?: number | string;
42
47
  startDate?: any;
43
48
  };
44
49
  export interface RulesParamsHooks {
@@ -315,6 +315,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
315
315
  end_at: dayjs.Dayjs;
316
316
  count: number;
317
317
  left: number;
318
+ summaryCount: number;
318
319
  }[];
319
320
  /**
320
321
  * 找到多个资源的公共可用时间段
@@ -2441,10 +2441,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2441
2441
  var resourcesUseableMap = {};
2442
2442
  var count = 0;
2443
2443
  var bookingLeft = 0;
2444
+ var summaryCount = 0;
2444
2445
  // 遍历所有资源
2445
2446
  allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
2446
2447
  // 遍历所有资源的上工时间片
2447
2448
  var currentResourcesCount = 0;
2449
+ var currentResourcesSummaryCount = 0;
2448
2450
  var currentResourcesTimeSlotCanUsedArr = [];
2449
2451
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
2450
2452
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
@@ -2482,6 +2484,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2482
2484
  if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
2483
2485
  currentResourcesCount = res.remainingCapacity;
2484
2486
  }
2487
+ if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
2488
+ currentResourcesSummaryCount = res.remainingCapacity;
2489
+ }
2485
2490
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
2486
2491
  });
2487
2492
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
@@ -2495,6 +2500,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2495
2500
  }
2496
2501
  if (!m.onlyComputed) {
2497
2502
  bookingLeft += 1;
2503
+ summaryCount += currentResourcesSummaryCount;
2498
2504
  }
2499
2505
  }
2500
2506
  });
@@ -2514,6 +2520,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2514
2520
  if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
2515
2521
  bookingLeft = 0;
2516
2522
  count = 0;
2523
+ summaryCount = 0;
2517
2524
  }
2518
2525
  // 规则 2
2519
2526
  var otherCartItems = cartItems.filter(function (m) {
@@ -2548,6 +2555,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2548
2555
  if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
2549
2556
  bookingLeft = 0;
2550
2557
  count = 0;
2558
+ summaryCount = 0;
2551
2559
  }
2552
2560
  } else {
2553
2561
  // 多个预约的检测规则:
@@ -2565,6 +2573,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2565
2573
  if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
2566
2574
  bookingLeft = 0;
2567
2575
  count = 0;
2576
+ summaryCount = 0;
2568
2577
  }
2569
2578
  // 规则2、不管是不是跟我一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,把所有购物车的 capacity 之和 和 所有当前类型资源的 capacity 之和比较,如果超过了resourcesCapacity,则不可用
2570
2579
  // const otherCartItems = cartItems.filter((m) => m._productOrigin?.id?.toString() !== targetProductData?.id?.toString() && m.start_time === item.start && m.end_time === item.end);
@@ -2614,7 +2623,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2614
2623
  start_at: dayjs(item.start),
2615
2624
  end_at: dayjs(item.end)
2616
2625
  })) {
2617
- mSet.set(m.id, m.pax || 1);
2626
+ var _m$pax;
2627
+ mSet.set(m.id, (_m$pax = m.pax) !== null && _m$pax !== void 0 ? _m$pax : 1);
2618
2628
  }
2619
2629
  });
2620
2630
  });
@@ -2627,6 +2637,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2627
2637
  if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
2628
2638
  bookingLeft = 0;
2629
2639
  count = 0;
2640
+ summaryCount = 0;
2630
2641
  }
2631
2642
  }
2632
2643
  });
@@ -2638,7 +2649,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2638
2649
  start_at: startDayJs,
2639
2650
  end_at: endDayJs,
2640
2651
  count: count,
2641
- left: bookingLeft
2652
+ left: bookingLeft,
2653
+ summaryCount: summaryCount
2642
2654
  };
2643
2655
  });
2644
2656
  return formatScheduleTimeSlots;
@@ -21,6 +21,13 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
21
21
  getCurrentBookingTime(): string | null;
22
22
  private filterDiscountListByBookingTime;
23
23
  setCustomer(customer: Customer): Promise<void>;
24
+ setHolders(holders: {
25
+ form_record_id: number;
26
+ }[]): void;
27
+ setBookingSubject(bookingSubject: {
28
+ type?: 'form' | 'customer';
29
+ [key: string]: any;
30
+ }): void;
24
31
  calcDiscount(productList: Record<string, any>[], options?: {
25
32
  discountId: number;
26
33
  isSelected: boolean;
@@ -51,9 +51,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
51
51
  productList: [],
52
52
  discount: null,
53
53
  rules: null,
54
+ holders: [],
54
55
  originalDiscountList: [],
55
56
  currentBookingTime: "",
56
- filteredDiscountList: []
57
+ filteredDiscountList: [],
58
+ bookingSubject: undefined
57
59
  };
58
60
  return _this;
59
61
  }
@@ -285,10 +287,23 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
285
287
  return _setCustomer.apply(this, arguments);
286
288
  }
287
289
  return setCustomer;
288
- }() // 计算优惠券
290
+ }() // 设置holders
291
+ }, {
292
+ key: "setHolders",
293
+ value: function setHolders(holders) {
294
+ this.store.holders = holders;
295
+ }
296
+ }, {
297
+ key: "setBookingSubject",
298
+ value: function setBookingSubject(bookingSubject) {
299
+ this.store.bookingSubject = bookingSubject;
300
+ }
301
+
302
+ // 计算优惠券
289
303
  }, {
290
304
  key: "calcDiscount",
291
305
  value: function calcDiscount(productList, options) {
306
+ var _this$store$bookingSu;
292
307
  this.store.productList = productList;
293
308
  var rulesModule = this.core.getModule("".concat(this.name, "_rules"));
294
309
  if (!rulesModule) {
@@ -299,7 +314,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
299
314
  }
300
315
  var _ref = rulesModule.calcDiscount({
301
316
  productList: productList,
302
- discountList: this.getDiscountList()
317
+ discountList: this.getDiscountList(),
318
+ holders: this.store.holders || [],
319
+ isFormSubject: ((_this$store$bookingSu = this.store.bookingSubject) === null || _this$store$bookingSu === void 0 ? void 0 : _this$store$bookingSu.type) === 'form'
303
320
  }, options) || {
304
321
  productList: productList,
305
322
  discountList: this.getDiscountList()
@@ -358,7 +375,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
358
375
  key: "scanCode",
359
376
  value: function () {
360
377
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
361
- var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
378
+ var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
362
379
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
363
380
  while (1) switch (_context5.prev = _context5.next) {
364
381
  case 0:
@@ -423,7 +440,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
423
440
  _ref3 = rulesModule.isDiscountListAvailable({
424
441
  productList: this.store.productList || [],
425
442
  oldDiscountList: this.getDiscountList(),
426
- newDiscountList: withScanList
443
+ newDiscountList: withScanList,
444
+ holders: this.store.holders || [],
445
+ isFormSubject: ((_this$store$bookingSu2 = this.store.bookingSubject) === null || _this$store$bookingSu2 === void 0 ? void 0 : _this$store$bookingSu2.type) === 'form'
427
446
  }) || {
428
447
  isAvailable: false,
429
448
  productList: this.store.productList || [],
@@ -670,7 +689,8 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
670
689
  customer_id: customerId,
671
690
  action: 'create',
672
691
  with_good_pass: 1,
673
- with_discount_card: 1
692
+ with_discount_card: 1,
693
+ with_wallet_pass_holder: 1
674
694
  });
675
695
  case 4:
676
696
  goodPassList = _context8.sent;
@@ -23,7 +23,16 @@ export interface ShopDiscountState {
23
23
  discount: DiscountModule | null;
24
24
  rules: RulesModule | null;
25
25
  productList: Record<string, any>[];
26
+ holders?: {
27
+ form_record_id: number;
28
+ form_id?: number;
29
+ main_field?: string;
30
+ }[];
26
31
  originalDiscountList: Discount[];
27
32
  currentBookingTime: string | null;
28
33
  filteredDiscountList: Discount[];
34
+ bookingSubject?: {
35
+ type?: 'form' | 'customer';
36
+ [key: string]: any;
37
+ };
29
38
  }
@@ -21,6 +21,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
21
21
  with_good_pass: 0 | 1;
22
22
  with_discount_card: 0 | 1;
23
23
  customer_id: number;
24
+ with_wallet_pass_holder: 0 | 1;
24
25
  }): Promise<Discount[]>;
25
26
  batchSearch(code: string, customerId?: number): Promise<Discount[]>;
26
27
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
@@ -109,7 +109,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
109
109
  tags: ["good_pass", "product_discount_card"],
110
110
  available: 1,
111
111
  relation_product: 1,
112
- with: ["extensionData"],
112
+ with: ["extensionData", "customScheduleSnapshot", "holder.detail"],
113
113
  order_behavior_count: 1,
114
114
  order_behavior_count_customer_id: customerId || 1
115
115
  });
@@ -11,18 +11,27 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
11
11
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
12
12
  setRulesList(rulesList: Rules[]): Promise<void>;
13
13
  getRulesList(): Rules[];
14
- isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, }: {
14
+ private checkHolderMatch;
15
+ isDiscountListAvailable({ oldDiscountList, newDiscountList, productList, holders, isFormSubject, }: {
15
16
  oldDiscountList: Discount[];
16
17
  newDiscountList: Discount[];
17
18
  productList: any[];
19
+ holders: {
20
+ form_record_id: number;
21
+ }[];
22
+ isFormSubject: boolean;
18
23
  }): {
19
24
  isAvailable: boolean;
20
25
  discountList: Discount[];
21
26
  productList: any[];
22
27
  };
23
- calcDiscount({ discountList, productList, }: {
28
+ calcDiscount({ discountList, productList, holders, isFormSubject, }: {
24
29
  discountList: Discount[];
25
30
  productList: any[];
31
+ holders: {
32
+ form_record_id: number;
33
+ }[];
34
+ isFormSubject: boolean;
26
35
  }, options?: {
27
36
  isSelected?: boolean;
28
37
  discountId?: number;
@@ -57,11 +57,26 @@ var RulesModule = class extends import_BaseModule.BaseModule {
57
57
  getRulesList() {
58
58
  return this.store.rulesList;
59
59
  }
60
+ // 商品不需要holder,则不需要判断,直接返回true,商品需要holder但是还没填写,那么暂时不使用带有holder的券,直到填写才去匹配
61
+ checkHolderMatch(discount, product, holders) {
62
+ var _a;
63
+ if (((_a = discount.holder) == null ? void 0 : _a.holder_type) !== "form")
64
+ return true;
65
+ const orderHolderId = Array.isArray(holders) && holders.length > 0 ? holders[0].form_record_id : void 0;
66
+ const productHolderId = Array.isArray(product.holder_id) ? product.holder_id[0] : product.holder_id;
67
+ if (!product.isNeedHolder)
68
+ return true;
69
+ if (!orderHolderId && !productHolderId)
70
+ return false;
71
+ return (productHolderId || orderHolderId) === discount.holder.holder_id;
72
+ }
60
73
  // 判断discountList 是否可以对当前productList生效
61
74
  isDiscountListAvailable({
62
75
  oldDiscountList,
63
76
  newDiscountList,
64
- productList
77
+ productList,
78
+ holders,
79
+ isFormSubject
65
80
  }) {
66
81
  if (!newDiscountList || newDiscountList.length === 0) {
67
82
  return {
@@ -88,7 +103,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
88
103
  ]), "product_id");
89
104
  const result = this.calcDiscount({
90
105
  discountList: mergedDiscountList,
91
- productList: [...productList]
106
+ productList: [...productList],
107
+ holders,
108
+ isFormSubject
92
109
  }, {
93
110
  scan: true
94
111
  });
@@ -120,7 +137,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
120
137
  }
121
138
  calcDiscount({
122
139
  discountList,
123
- productList
140
+ productList,
141
+ holders,
142
+ isFormSubject
124
143
  }, options) {
125
144
  const isEditModeAddNewProduct = productList.find((n) => n.booking_id) && productList.find((n) => !n.booking_id);
126
145
  const editModeDiscount = [];
@@ -250,6 +269,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
250
269
  const processedProductsMap = /* @__PURE__ */ new Map();
251
270
  const appliedDiscountProducts = /* @__PURE__ */ new Map();
252
271
  sortedFlattenedList.forEach((flatItem) => {
272
+ var _a;
253
273
  let product, originProduct;
254
274
  if (flatItem.type === "main") {
255
275
  product = flatItem.product;
@@ -264,17 +284,27 @@ var RulesModule = class extends import_BaseModule.BaseModule {
264
284
  total: flatItem.total,
265
285
  origin_total: flatItem.origin_total,
266
286
  booking_id: flatItem.booking_id,
267
- discount_list: flatItem.discount_list || []
287
+ discount_list: flatItem.discount_list || [],
288
+ startDate: (_a = flatItem.parentProduct) == null ? void 0 : _a.startDate
268
289
  };
269
290
  originProduct = flatItem.originProduct;
270
291
  }
271
292
  addModeDiscount.forEach((discount) => {
272
- var _a, _b, _c, _d, _e, _f;
293
+ var _a2, _b, _c, _d, _e, _f;
273
294
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
295
+ const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
296
+ const isHolderMatch = this.checkHolderMatch(
297
+ discount,
298
+ {
299
+ isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
300
+ holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
301
+ },
302
+ holders
303
+ );
274
304
  let timeLimit = true;
275
305
  timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
276
- const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
277
- const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && ((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.metadata) == null ? void 0 : _d.custom_product_bundle_map_id));
306
+ const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
307
+ const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a2 = product == null ? void 0 : product.discount_list) == null ? void 0 : _a2.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.tag || discount2.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && ((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.metadata) == null ? void 0 : _d.custom_product_bundle_map_id));
278
308
  const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
279
309
  if (isAvailableProduct && isLimitedProduct && isBundleAvailable && timeLimit) {
280
310
  (_e = discountApplicability.get(discount.id)) == null ? void 0 : _e.push(product.id);
@@ -306,7 +336,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
306
336
  });
307
337
  const processedFlatItemsMap = /* @__PURE__ */ new Map();
308
338
  sortedFlattenedList.forEach((flatItem, index) => {
309
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
339
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
310
340
  let product, originProduct;
311
341
  if (flatItem.type === "main") {
312
342
  product = flatItem.product;
@@ -322,11 +352,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
322
352
  original_price: (_a = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _a.original_price,
323
353
  origin_total: (_b = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _b.original_price,
324
354
  booking_id: flatItem.booking_id,
325
- discount_list: ((_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) || []
355
+ discount_list: ((_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) || [],
356
+ startDate: (_d = flatItem.parentProduct) == null ? void 0 : _d.startDate
326
357
  };
327
358
  originProduct = flatItem.originProduct;
328
359
  }
329
- if ((product == null ? void 0 : product.booking_id) && ((_d = product.discount_list) == null ? void 0 : _d.length) && ((_e = product == null ? void 0 : product.discount_list) == null ? void 0 : _e.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag || discount.type)))) {
360
+ if ((product == null ? void 0 : product.booking_id) && ((_e = product.discount_list) == null ? void 0 : _e.length) && ((_f = product == null ? void 0 : product.discount_list) == null ? void 0 : _f.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag || discount.type)))) {
330
361
  if (flatItem.type === "main") {
331
362
  processedProductsMap.set(product._id, [originProduct]);
332
363
  } else {
@@ -339,10 +370,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
339
370
  }
340
371
  const applicableDiscounts = sortedDiscountList.filter((discount) => {
341
372
  var _a2, _b2;
342
- if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
343
- var _a3;
344
- return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
345
- })) && (discount.tag || discount.type) === "good_pass")
373
+ if ((Number(product.price) <= 0 || !product.price) && !((_a2 = product.discount_list) == null ? void 0 : _a2.length) && (discount.tag || discount.type) === "good_pass")
346
374
  return false;
347
375
  if ((Number(product.price) === 0 || !product.price) && !((_b2 = product.discount_list) == null ? void 0 : _b2.find((n) => {
348
376
  var _a3;
@@ -353,6 +381,17 @@ var RulesModule = class extends import_BaseModule.BaseModule {
353
381
  if (targetUsedDiscounts && (discount.tag || discount.type) === "good_pass")
354
382
  return false;
355
383
  const limitedData = discount.limited_relation_product_data;
384
+ const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
385
+ const isHolderMatch = this.checkHolderMatch(
386
+ discount,
387
+ {
388
+ isNeedHolder: isFormSubject && !(_tempVar == null ? void 0 : _tempVar.isNormalProduct),
389
+ holder_id: (_tempVar == null ? void 0 : _tempVar.holder_id) || product.holder_id
390
+ },
391
+ holders
392
+ );
393
+ if (!isHolderMatch)
394
+ return false;
356
395
  let timeLimit = true;
357
396
  timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], (product.startDate || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
358
397
  if (!timeLimit) {
@@ -378,28 +417,28 @@ var RulesModule = class extends import_BaseModule.BaseModule {
378
417
  isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every((item) => {
379
418
  var _a2;
380
419
  return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
381
- }) && (!((_f = product.discount_list) == null ? void 0 : _f.length) || ((_h = (_g = product == null ? void 0 : product.discount_list) == null ? void 0 : _g.every) == null ? void 0 : _h.call(_g, (item) => item.type === "product")));
420
+ }) && (!((_g = product.discount_list) == null ? void 0 : _g.length) || ((_i = (_h = product == null ? void 0 : product.discount_list) == null ? void 0 : _h.every) == null ? void 0 : _i.call(_h, (item) => item.type === "product")));
382
421
  } else {
383
422
  const parentProduct = flatItem.parentProduct;
384
423
  if (parentProduct) {
385
424
  isManualDiscount = typeof parentProduct.isManualDiscount === "boolean" ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every((item) => {
386
425
  var _a2;
387
426
  return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
388
- }) && (!((_i = parentProduct.discount_list) == null ? void 0 : _i.length) || ((_k = (_j = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _j.every) == null ? void 0 : _k.call(_j, (item) => item.type === "product")));
427
+ }) && (!((_j = parentProduct.discount_list) == null ? void 0 : _j.length) || ((_l = (_k = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _k.every) == null ? void 0 : _l.call(_k, (item) => item.type === "product")));
389
428
  }
390
429
  }
391
430
  if (options == null ? void 0 : options.discountId) {
392
- if (flatItem.type === "main" && ((_l = product.discount_list) == null ? void 0 : _l.some((item) => {
431
+ if (flatItem.type === "main" && ((_m = product.discount_list) == null ? void 0 : _m.some((item) => {
393
432
  var _a2;
394
433
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
395
434
  }))) {
396
435
  isManualDiscount = false;
397
436
  }
398
437
  if (flatItem.type === "bundle") {
399
- if (((_m = product.discount_list) == null ? void 0 : _m.some((item) => {
438
+ if (((_n = product.discount_list) == null ? void 0 : _n.some((item) => {
400
439
  var _a2;
401
440
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
402
- })) || ((_o = (_n = flatItem.parentProduct) == null ? void 0 : _n.discount_list) == null ? void 0 : _o.some((item) => {
441
+ })) || ((_p = (_o = flatItem.parentProduct) == null ? void 0 : _o.discount_list) == null ? void 0 : _p.some((item) => {
403
442
  var _a2;
404
443
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
405
444
  }))) {
@@ -408,7 +447,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
408
447
  }
409
448
  }
410
449
  if (options == null ? void 0 : options.selectedList) {
411
- if (flatItem.type === "main" && ((_p = product.discount_list) == null ? void 0 : _p.some((item) => {
450
+ if (flatItem.type === "main" && ((_q = product.discount_list) == null ? void 0 : _q.some((item) => {
412
451
  var _a2;
413
452
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
414
453
  var _a3;
@@ -418,13 +457,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
418
457
  isManualDiscount = false;
419
458
  }
420
459
  if (flatItem.type === "bundle") {
421
- if (((_q = product.discount_list) == null ? void 0 : _q.some((item) => {
460
+ if (((_r = product.discount_list) == null ? void 0 : _r.some((item) => {
422
461
  var _a2;
423
462
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
424
463
  var _a3;
425
464
  return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
426
465
  });
427
- })) || ((_s = (_r = flatItem.parentProduct) == null ? void 0 : _r.discount_list) == null ? void 0 : _s.some((item) => {
466
+ })) || ((_t = (_s = flatItem.parentProduct) == null ? void 0 : _s.discount_list) == null ? void 0 : _t.some((item) => {
428
467
  var _a2;
429
468
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
430
469
  var _a3;
@@ -508,10 +547,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
508
547
  usedDiscounts.set(selectedDiscount2.id, true);
509
548
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
510
549
  let productOriginTotal = product.origin_total || product.total || 0;
511
- if (((_t = product.discount_list) == null ? void 0 : _t.length) && product.origin_total) {
550
+ if (((_u = product.discount_list) == null ? void 0 : _u.length) && product.origin_total) {
512
551
  productOriginTotal = product.origin_total;
513
552
  }
514
- if (Number(((_u = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _u.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
553
+ if (Number(((_v = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _v.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
515
554
  productOriginTotal = product.total;
516
555
  }
517
556
  const targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, product.price, product.price);
@@ -522,7 +561,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
522
561
  amount,
523
562
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
524
563
  discount: {
525
- discount_card_type: (_v = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _v.discount_card_type,
564
+ discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
526
565
  fixed_amount: amount,
527
566
  resource_id: selectedDiscount2.id,
528
567
  title: selectedDiscount2.format_title,
@@ -644,7 +683,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
644
683
  amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber() * (product.num || 1),
645
684
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
646
685
  discount: {
647
- discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
686
+ discount_card_type: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_card_type,
648
687
  fixed_amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber(),
649
688
  resource_id: selectedDiscount2.id,
650
689
  title: selectedDiscount2.format_title,
@@ -657,7 +696,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
657
696
  custom_product_bundle_map_id: uniqueId,
658
697
  num: product.num || 1
659
698
  },
660
- _num: (product.num || 1) * (((_x = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _x.num) || 1)
699
+ _num: (product.num || 1) * (((_y = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _y.num) || 1)
661
700
  };
662
701
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
663
702
  appliedProducts.push(discountDetail);
@@ -22,6 +22,10 @@ export interface RulesModuleAPI {
22
22
  calcDiscount: (params: {
23
23
  discountList: any[];
24
24
  productList: any[];
25
+ holders: {
26
+ form_record_id: number;
27
+ }[];
28
+ isFormSubject: boolean;
25
29
  }) => DiscountResult;
26
30
  }
27
31
  type ProductDetail = {
@@ -39,6 +43,7 @@ type ProductDetail = {
39
43
  original_price?: number | string;
40
44
  num?: number;
41
45
  quantity: number;
46
+ holder_id?: number | string;
42
47
  startDate?: any;
43
48
  };
44
49
  export interface RulesParamsHooks {
@@ -315,6 +315,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
315
315
  end_at: dayjs.Dayjs;
316
316
  count: number;
317
317
  left: number;
318
+ summaryCount: number;
318
319
  }[];
319
320
  /**
320
321
  * 找到多个资源的公共可用时间段
@@ -1723,8 +1723,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1723
1723
  const resourcesUseableMap = {};
1724
1724
  let count = 0;
1725
1725
  let bookingLeft = 0;
1726
+ let summaryCount = 0;
1726
1727
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
1727
1728
  let currentResourcesCount = 0;
1729
+ let currentResourcesSummaryCount = 0;
1728
1730
  const currentResourcesTimeSlotCanUsedArr = [];
1729
1731
  const mTimes = m.times.filter((n) => {
1730
1732
  return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
@@ -1752,6 +1754,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1752
1754
  if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
1753
1755
  currentResourcesCount = res.remainingCapacity;
1754
1756
  }
1757
+ if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
1758
+ currentResourcesSummaryCount = res.remainingCapacity;
1759
+ }
1755
1760
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1756
1761
  });
1757
1762
  if (!currentResourcesTimeSlotCanUsedArr.some(
@@ -1763,6 +1768,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1763
1768
  }
1764
1769
  if (!m.onlyComputed) {
1765
1770
  bookingLeft += 1;
1771
+ summaryCount += currentResourcesSummaryCount;
1766
1772
  }
1767
1773
  }
1768
1774
  });
@@ -1777,6 +1783,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1777
1783
  if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
1778
1784
  bookingLeft = 0;
1779
1785
  count = 0;
1786
+ summaryCount = 0;
1780
1787
  }
1781
1788
  const otherCartItems = cartItems2.filter((m) => {
1782
1789
  var _a2, _b2, _c2;
@@ -1802,6 +1809,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1802
1809
  if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
1803
1810
  bookingLeft = 0;
1804
1811
  count = 0;
1812
+ summaryCount = 0;
1805
1813
  }
1806
1814
  } else {
1807
1815
  const sameCartItems = cartItems2.filter((m) => {
@@ -1813,6 +1821,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1813
1821
  if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
1814
1822
  bookingLeft = 0;
1815
1823
  count = 0;
1824
+ summaryCount = 0;
1816
1825
  }
1817
1826
  const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
1818
1827
  const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
@@ -1847,7 +1856,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1847
1856
  { start_at: m.start_at, end_at: m.end_at },
1848
1857
  { start_at: (0, import_dayjs.default)(item.start), end_at: (0, import_dayjs.default)(item.end) }
1849
1858
  )) {
1850
- mSet.set(m.id, m.pax || 1);
1859
+ mSet.set(m.id, m.pax ?? 1);
1851
1860
  }
1852
1861
  });
1853
1862
  });
@@ -1857,6 +1866,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1857
1866
  if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
1858
1867
  bookingLeft = 0;
1859
1868
  count = 0;
1869
+ summaryCount = 0;
1860
1870
  }
1861
1871
  }
1862
1872
  });
@@ -1868,7 +1878,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1868
1878
  start_at: startDayJs,
1869
1879
  end_at: endDayJs,
1870
1880
  count,
1871
- left: bookingLeft
1881
+ left: bookingLeft,
1882
+ summaryCount
1872
1883
  };
1873
1884
  });
1874
1885
  return formatScheduleTimeSlots;
@@ -21,6 +21,13 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
21
21
  getCurrentBookingTime(): string | null;
22
22
  private filterDiscountListByBookingTime;
23
23
  setCustomer(customer: Customer): Promise<void>;
24
+ setHolders(holders: {
25
+ form_record_id: number;
26
+ }[]): void;
27
+ setBookingSubject(bookingSubject: {
28
+ type?: 'form' | 'customer';
29
+ [key: string]: any;
30
+ }): void;
24
31
  calcDiscount(productList: Record<string, any>[], options?: {
25
32
  discountId: number;
26
33
  isSelected: boolean;
@@ -51,9 +51,11 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
51
51
  productList: [],
52
52
  discount: null,
53
53
  rules: null,
54
+ holders: [],
54
55
  originalDiscountList: [],
55
56
  currentBookingTime: "",
56
- filteredDiscountList: []
57
+ filteredDiscountList: [],
58
+ bookingSubject: void 0
57
59
  };
58
60
  }
59
61
  // =========== 生命周期方法 ===========
@@ -191,8 +193,16 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
191
193
  );
192
194
  }
193
195
  }
196
+ // 设置holders
197
+ setHolders(holders) {
198
+ this.store.holders = holders;
199
+ }
200
+ setBookingSubject(bookingSubject) {
201
+ this.store.bookingSubject = bookingSubject;
202
+ }
194
203
  // 计算优惠券
195
204
  calcDiscount(productList, options) {
205
+ var _a;
196
206
  this.store.productList = productList;
197
207
  const rulesModule = this.core.getModule(`${this.name}_rules`);
198
208
  if (!rulesModule) {
@@ -201,7 +211,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
201
211
  let { productList: newProductList, discountList: newDiscountList } = rulesModule.calcDiscount(
202
212
  {
203
213
  productList,
204
- discountList: this.getDiscountList()
214
+ discountList: this.getDiscountList(),
215
+ holders: this.store.holders || [],
216
+ isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
205
217
  },
206
218
  options
207
219
  ) || { productList, discountList: this.getDiscountList() };
@@ -241,7 +253,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
241
253
  }
242
254
  // 扫码输入code
243
255
  async scanCode(code, customerId) {
244
- var _a, _b;
256
+ var _a, _b, _c;
245
257
  try {
246
258
  const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
247
259
  const rulesModule = this.store.rules;
@@ -283,7 +295,9 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
283
295
  } = rulesModule.isDiscountListAvailable({
284
296
  productList: this.store.productList || [],
285
297
  oldDiscountList: this.getDiscountList(),
286
- newDiscountList: withScanList
298
+ newDiscountList: withScanList,
299
+ holders: this.store.holders || [],
300
+ isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
287
301
  }) || {
288
302
  isAvailable: false,
289
303
  productList: this.store.productList || [],
@@ -292,7 +306,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
292
306
  if (isAvailable) {
293
307
  this.setDiscountList(newDiscountList || []);
294
308
  this.setProductList(newProductList || []);
295
- if (this.isWalkIn() && resultDiscountList.length && ((_b = this.options.otherParams) == null ? void 0 : _b.platform) === "shop") {
309
+ if (this.isWalkIn() && resultDiscountList.length && ((_c = this.options.otherParams) == null ? void 0 : _c.platform) === "shop") {
296
310
  await this.getCustomerWallet(
297
311
  resultDiscountList[0].customer_id
298
312
  );
@@ -449,7 +463,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
449
463
  customer_id: customerId,
450
464
  action: "create",
451
465
  with_good_pass: 1,
452
- with_discount_card: 1
466
+ with_discount_card: 1,
467
+ with_wallet_pass_holder: 1
453
468
  }));
454
469
  const scanDiscount = (_c = this.getDiscountList()) == null ? void 0 : _c.filter(
455
470
  (item) => item.isScan
@@ -23,7 +23,16 @@ export interface ShopDiscountState {
23
23
  discount: DiscountModule | null;
24
24
  rules: RulesModule | null;
25
25
  productList: Record<string, any>[];
26
+ holders?: {
27
+ form_record_id: number;
28
+ form_id?: number;
29
+ main_field?: string;
30
+ }[];
26
31
  originalDiscountList: Discount[];
27
32
  currentBookingTime: string | null;
28
33
  filteredDiscountList: Discount[];
34
+ bookingSubject?: {
35
+ type?: 'form' | 'customer';
36
+ [key: string]: any;
37
+ };
29
38
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.73",
4
+ "version": "3.0.74",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",